diff --git a/app/common/repositories/store/order/StoreOrderRepository.php b/app/common/repositories/store/order/StoreOrderRepository.php index d5830de5..96682a73 100644 --- a/app/common/repositories/store/order/StoreOrderRepository.php +++ b/app/common/repositories/store/order/StoreOrderRepository.php @@ -1491,6 +1491,12 @@ class StoreOrderRepository extends BaseRepository ] ); if (!$res) throw new ValidateException('数据不存在'); + if(in_array($res['source'],[13])){ + $res['bank_info']=Db::name('merchant_intention')->where('status',1)->where('uid',$res['uid'])->field('company_name,bank_username,bank_opening,bank_code')->find(); + }else{ + $res['bank_info']=[]; + } + $res['integral'] = (int)$res['integral']; return $res->append(['refund_extension_one', 'refund_extension_two']); } diff --git a/app/common/repositories/store/order/StoreOtherOrderRepository.php b/app/common/repositories/store/order/StoreOtherOrderRepository.php index 8a6b4c84..4f935036 100644 --- a/app/common/repositories/store/order/StoreOtherOrderRepository.php +++ b/app/common/repositories/store/order/StoreOtherOrderRepository.php @@ -201,42 +201,7 @@ class StoreOtherOrderRepository extends BaseRepository $order->transaction_id = $subOrders[$order->order_sn]['transaction_id']; } $presell = false; - //todo 等待付尾款 - if ($order->activity_type == 2) { - $_make = app()->make(ProductPresellSkuRepository::class); - if ($order->orderProduct[0]['cart_info']['productPresell']['presell_type'] == 2) { - $order->status = 10; - $presell = true; - } else { - $_make->incCount($order->orderProduct[0]['activity_id'], $order->orderProduct[0]['product_sku'], 'two_pay'); - } - $_make->incCount($order->orderProduct[0]['activity_id'], $order->orderProduct[0]['product_sku'], 'one_pay'); - } else if ($order->activity_type == 4) { - $order->status = 9; - $order->save(); - $group_buying_id = app()->make(ProductGroupBuyingRepository::class)->create( - $groupOrder->user, - $order->orderProduct[0]['cart_info']['activeSku']['product_group_id'], - $order->orderProduct[0]['activity_id'], - $order->order_id - ); - $order->orderProduct[0]->activity_id = $group_buying_id; - $order->orderProduct[0]->save(); - } else if ($order->activity_type == 3) { - //更新助力状态 - app()->make(ProductAssistSetRepository::class)->changStatus($order->orderProduct[0]['activity_id']); - } - - //更新委托订单处理 - if ($order->activity_type == 99) { - $cartIdArray = explode(',', $order->cart_id); - $ecartList = Db::name('store_cart')->whereIn('cart_id', $cartIdArray)->select(); - foreach ($ecartList as $ecart) { - if (!empty($ecart['source_id'])) { - Db::name('community')->where('community_id', $ecart['source_id'])->update(['entrust_order_id' => $order->order_id ?? 0]); - } - } - } + // 订单的类型 0 发货 1 自提 if ($order->order_type == 1 && $order->status != 10) { $order->verify_code = $this->verifyCode(); @@ -253,19 +218,6 @@ class StoreOtherOrderRepository extends BaseRepository 'user_type' => $storeOrderStatusRepository::U_TYPE_USER, ]; - //TODO 成为推广员 - foreach ($order->orderProduct as $product) { - if ($flag && $product['cart_info']['product']['is_gift_bag']) { - app()->make(UserRepository::class)->promoter($order->uid); - $flag = false; - } - } - if ($order->order_type == 0) { - //发起队列物流信息处理 - //event('order.sendGoodsCode', $order); - Queue::push(SendGoodsCodeJob::class, $order); - } - // 商户流水账单数据 $finance[] = [ 'order_id' => $order->order_id, @@ -305,36 +257,7 @@ class StoreOtherOrderRepository extends BaseRepository } if (!$presell) { - if ($order['extension_one'] > 0) { - $finance[] = [ - 'order_id' => $order->order_id, - 'order_sn' => $order->order_sn, - 'user_info' => $groupOrder->user->nickname, - 'user_id' => $uid, - 'financial_type' => 'brokerage_one', - 'financial_pm' => 0, - 'type' => 1, - 'number' => $order['extension_one'], - 'mer_id' => $order->mer_id, - 'financial_record_sn' => $financeSn . ($i++) - ]; - } - - if ($order['extension_two'] > 0) { - $finance[] = [ - 'order_id' => $order->order_id, - 'order_sn' => $order->order_sn, - 'user_info' => $groupOrder->user->nickname, - 'user_id' => $uid, - 'financial_type' => 'brokerage_two', - 'financial_pm' => 0, - 'type' => 1, - 'number' => $order['extension_two'], - 'mer_id' => $order->mer_id, - 'financial_record_sn' => $financeSn . ($i++) - ]; - } - + if ($order['commission_rate'] > 0) { $finance[] = [ 'order_id' => $order->order_id, @@ -409,14 +332,8 @@ class StoreOtherOrderRepository extends BaseRepository 'id' => $order->order_id ] ], $order->mer_id); - //自动打印订单 - $this->autoPrinter($order->order_id, $order->mer_id); } - //分销判断 - // if ($groupOrder->user->spread_uid) { - // Queue::push(UserBrokerageLevelJob::class, ['uid' => $groupOrder->user->spread_uid, 'type' => 'spread_pay_num', 'inc' => 1]); - // Queue::push(UserBrokerageLevelJob::class, ['uid' => $groupOrder->user->spread_uid, 'type' => 'spread_money', 'inc' => $groupOrder->pay_price]); - // } + app()->make(UserRepository::class)->update($groupOrder->uid, [ 'pay_count' => Db::raw('pay_count+' . count($groupOrder->orderList)), 'pay_price' => Db::raw('pay_price+' . $groupOrder->pay_price), @@ -428,38 +345,14 @@ class StoreOtherOrderRepository extends BaseRepository } $financialRecordRepository->insertAll($finance); $storeOrderStatusRepository->batchCreateLog($orderStatus); - if (count($groupOrder['give_coupon_ids']) > 0) - $groupOrder['give_coupon_ids'] = app()->make(StoreCouponRepository::class)->getGiveCoupon($groupOrder['give_coupon_ids'])->column('coupon_id'); $groupOrder->save(); }); - if (count($groupOrder['give_coupon_ids']) > 0) { - try { - Queue::push(PayGiveCouponJob::class, ['ids' => $groupOrder['give_coupon_ids'], 'uid' => $groupOrder['uid']]); - } catch (Exception $e) { - } - } - Queue::push(SendSmsJob::class, ['tempId' => 'ORDER_PAY_SUCCESS', 'id' => $groupOrder->group_order_id]); Queue::push(SendSmsJob::class, ['tempId' => 'ADMIN_PAY_SUCCESS_CODE', 'id' => $groupOrder->group_order_id]); Queue::push(UserBrokerageLevelJob::class, ['uid' => $groupOrder->uid, 'type' => 'pay_money', 'inc' => $groupOrder->pay_price]); Queue::push(UserBrokerageLevelJob::class, ['uid' => $groupOrder->uid, 'type' => 'pay_num', 'inc' => 1]); app()->make(UserBrokerageRepository::class)->incMemberValue($groupOrder->uid, 'member_pay_num', $groupOrder->group_order_id); - $groupOrder = $groupOrder->toArray(); - event('order.paySuccess', compact('groupOrder')); - //店内扫码支付 - if (isset($groupOrder['micro_pay']) && $groupOrder['micro_pay'] == 1) { - $order = $this->dao->search(['uid' => $groupOrder->uid])->where('group_order_id', $groupOrder->group_order_id)->find(); - $order->status = 2; - $order->verify_time = date('Y-m-d H:i:s'); - $user = $order->user; - event('order.take.before', compact('order')); - Db::transaction(function () use ($order, $user) { - $this->takeAfter($order, $user); - $order->save(); - }); - event('order.take', compact('order')); - } } diff --git a/app/common/repositories/store/product/ProductRepository.php b/app/common/repositories/store/product/ProductRepository.php index 26a8391e..b901f34b 100644 --- a/app/common/repositories/store/product/ProductRepository.php +++ b/app/common/repositories/store/product/ProductRepository.php @@ -344,7 +344,15 @@ class ProductRepository extends BaseRepository $ret = Spu::getInstance()->where('product_id', $id)->whereIn('product_type', [0, 98, 99])->find(); Db::transaction(function () use ($id, $data, $settleParams, $ret) { $this->save($id, $settleParams, null, [], 0); - app()->make(SpuRepository::class)->update($ret->spu_id, ['price' => $data['price']]); + $value = $data['mer_labels']; + if (!empty($value)) { + if (!is_array($value)) { + $data['mer_labels'] = ',' . $value . ','; + } else { + $data['mer_labels'] = ',' . implode(',', $value) . ','; + } + } + app()->make(SpuRepository::class)->update($ret->spu_id, ['price' => $data['price'],'mer_labels'=>$data['mer_labels']]); Queue(SendSmsJob::class, ['tempId' => 'PRODUCT_INCREASE', 'id' => $id]); }); } @@ -541,7 +549,7 @@ class ProductRepository extends BaseRepository { $result = []; foreach ($data as $value) { - if (is_int($value)||$value['category']) { + if (is_int($value) || $value['category']) { $result[] = [ 'product_id' => $productId, 'mer_cate_id' => $value, @@ -726,7 +734,7 @@ class ProductRepository extends BaseRepository if ($data['product_type'] == 3) $make = app()->make(ProductAssistSkuRepository::class); if ($data['product_type'] == 4) $make = app()->make(ProductGroupSkuRepository::class); - $spu_where = ['activity_id' => $activeId, 'product_type' => $data['product_type'], 'product_id' => $id]; + $spu_where = ['activity_id' => $activeId??0, 'product_type' => $data['product_type'], 'product_id' => $id]; $spu = $spu_make->getSearch($spu_where)->find(); $data['star'] = $spu['star'] ?? ''; $data['mer_labels'] = $spu['mer_labels'] ?? ''; @@ -1939,13 +1947,13 @@ class ProductRepository extends BaseRepository } else { //加入购物车 //购物车现有 - $_num = $this->productOnceCountCart($where['product_id'], $data['product_attr_unique'], $userInfo->uid, $data['product_type'],$data['source']); + $_num = $this->productOnceCountCart($where['product_id'], $data['product_attr_unique'], $userInfo->uid, $data['product_type'], $data['source']); $cart_num = $_num + $data['cart_num']; } if ($sku['stock'] < $cart_num) throw new ValidateException('库存不足'); //添加购物车 if (!$data['is_new']) { - $cart = app()->make(StoreCartRepository::class)->getCartByProductSku($data['product_attr_unique'], $userInfo->uid, $data['product_type'],$data['source']); + $cart = app()->make(StoreCartRepository::class)->getCartByProductSku($data['product_attr_unique'], $userInfo->uid, $data['product_type'], $data['source']); } return compact('product', 'sku', 'cart'); } @@ -1958,7 +1966,7 @@ class ProductRepository extends BaseRepository * @author Qinii * @day 5/26/21 */ - public function productOnceCountCart($productId, $product_attr_unique, $uid, $product_type = 0,$source=0) + public function productOnceCountCart($productId, $product_attr_unique, $uid, $product_type = 0, $source = 0) { $make = app()->make(StoreCartRepository::class); $where = [ @@ -1970,7 +1978,7 @@ class ProductRepository extends BaseRepository 'product_id' => $productId, 'uid' => $uid, 'product_attr_unique' => $product_attr_unique, - 'source'=>$source + 'source' => $source ]; $cart_num = $make->getSearch($where)->sum('cart_num'); return $cart_num; @@ -2346,7 +2354,7 @@ class ProductRepository extends BaseRepository foreach ($data['attrValue'] as $k => $item) { //$data['attrValue'][$k]['stock'] = 0; } - app()->make(ProductLabelRepository::class)->checkHas($merId, $data['mer_labels']); + app()->make(ProductLabelRepository::class)->checkHas(0, $data['mer_labels']); $count = app()->make(StoreCategoryRepository::class)->getWhereCount(['store_category_id' => $data['cate_id'], 'is_show' => 1]); if (!$count) throw new ValidateException('平台分类不存在或不可用'); app()->make(StoreProductValidate::class)->check($data); @@ -2575,4 +2583,50 @@ class ProductRepository extends BaseRepository ); return compact('count', 'list'); } + + /** + * 添加商品到云市场 + */ + public function add_cloud_product($data, $merchant) + { + if ($data['is_del'] == 1) { + return Db::name('cloud_product')->where('product_id', $data['product_id'])->delete(); + } + if ($data['product_id'] && $data['type']) { + switch ($data['type']) { + case 'five': + $data['type'] = 5; + break; + case 'two': + $data['type'] = 6; + break; + case 'three': + $data['type'] = 7; + break; + case 'seven': + $data['type'] = 8; + break; + } + $store_product=Db::name('store_product')->where('product_id',$data['product_id'])->find(); + $datas = [ + 'product_id' => $data['product_id'], + 'cate_id' => $store_product['cate_id'], + 'mer_id' => $merchant['mer_id'], + 'source_mer_id' => 0, + 'street_code' => $merchant['street_id'], + 'type_id' => $merchant['type_id'], + 'category_id' => $merchant['category_id'], + 'weight' => 1, + 'status' => 1, + 'create_time' => date('Y-m-d H:i:s'), + 'mer_labels' => ',' . $data['type'] . ',', + ]; + $res= Db::name('cloud_product')->where('product_id',$data['product_id'])->where('mer_id',$merchant['mer_id'])->find(); + if($res){ + throw new ValidateException('该商品已设置过'); + } + return Db::name('cloud_product')->insert($datas); + } + return false; + } } diff --git a/app/controller/api/Auth.php b/app/controller/api/Auth.php index 01560b84..f697f7b9 100644 --- a/app/controller/api/Auth.php +++ b/app/controller/api/Auth.php @@ -369,10 +369,11 @@ class Auth extends BaseController if ($store_service) { $mer_arr = Db::name('merchant')->where('mer_id', $store_service['mer_id'])->where('is_del', 0)->field('type_id,mer_avatar,mer_banner,business_status,mer_info,category_id,service_phone,mer_address,uid,mer_name,create_time,update_time,mer_settlement_agree_status,is_margin,street_id')->find(); + $bank_info = Db::name('merchant_intention')->where('mer_id', $store_service['mer_id'])->field('company_name,bank_username,bank_opening,bank_code')->find(); if ($mer_arr && $mer_arr['mer_avatar'] != '' && $mer_arr['mer_banner'] != '' && $mer_arr['mer_info'] && $mer_arr['service_phone'] != '' && $mer_arr['mer_address'] != '') { $data['is_wsxx'] = 1; } - $data['mer_info'] = $mer_arr; + $data['mer_info'] = array_merge($mer_arr,$bank_info); $typCode = Db::name('merchant_type')->where('mer_type_id', $mer_arr['type_id'] ?? 0)->value('type_code'); $data['mer_info']['type_code'] = $typCode; $data['mer_info']['setting_status'] = 0; @@ -1592,19 +1593,12 @@ class Auth extends BaseController if ($status == 1) { $repository->updateStatus($id, $data); $intention = Db::name('merchant_intention')->where('mer_intention_id', $id)->where('type', 1)->find(); - $merLicenseImage = ''; if (!empty($intention['images'])) { $merLicenseImageArray = explode(',', $intention['images']); - $merLicenseImage = $merLicenseImageArray[0] ?? ''; + app()->make(ConfigValueRepository::class)->setFormData([ + 'mer_certificate' => $merLicenseImageArray + ], $intention['mer_id']); } - $merCertificate = merchantConfig($intention['mer_id'], 'mer_certificate'); - if (!is_array($merCertificate)) { - $merCertificate = explode(',', $merCertificate); - } - $merCertificate[0] = $merLicenseImage; - app()->make(ConfigValueRepository::class)->setFormData([ - 'mer_certificate' => $merCertificate - ], $intention['mer_id']); } Db::name('merchant_intention')->where('mer_intention_id', $id)->where('type', 1)->update($updData); } else { diff --git a/app/controller/api/Common.php b/app/controller/api/Common.php index 265feb19..1ba6ea6d 100644 --- a/app/controller/api/Common.php +++ b/app/controller/api/Common.php @@ -32,6 +32,8 @@ use app\common\repositories\user\UserSignRepository; use app\common\repositories\user\UserVisitRepository; use app\common\repositories\wechat\TemplateMessageRepository; use app\common\repositories\wechat\WechatUserRepository; +use app\common\repositories\store\product\ProductLabelRepository; + use app\common\model\system\merchant\Merchant; use crmeb\basic\BaseController; use crmeb\services\AlipayService; @@ -48,7 +50,13 @@ use think\facade\Cache; use think\facade\Db; use think\facade\Log; use think\Response; +use AlibabaCloud\SDK\Ocr\V20191230\Ocr; +use AlibabaCloud\Tea\Exception\TeaError; +use AlibabaCloud\Tea\Utils\Utils; +use Darabonba\OpenApi\Models\Config; +use AlibabaCloud\SDK\Ocr\V20191230\Models\RecognizeBusinessLicenseRequest; +use AlibabaCloud\Tea\Utils\Utils\RuntimeOptions; /** * Class Common * @package app\controller\api @@ -543,4 +551,59 @@ class Common extends BaseController return app('json')->success($data); } + + /** + * + * 商户营业执照 + */ + public function merchant_license_identify($image){ + $config = new Config([ + // 必填,您的 AccessKey ID + "accessKeyId" => 'LTAI5t7mhH3ij2cNWs1zhPmv', + // 必填,您的 AccessKey Secret + "accessKeySecret" => 'gqo2wMpvi8h5bDBmCpMje6BaiXvcPu' + ]); + // Endpoint 请参考 https://api.aliyun.com/product/ocr + $config->endpoint = "ocr.cn-shanghai.aliyuncs.com"; + $client= new Ocr($config); + $recognizeBusinessLicenseRequest = new RecognizeBusinessLicenseRequest([ + "imageURL" => $image + ]); + $runtime = new RuntimeOptions([]); + try { + // 复制代码运行请自行打印 API 的返回值 + $resp=$client->recognizeBusinessLicenseWithOptions($recognizeBusinessLicenseRequest, $runtime); + $a= Utils::toArray($resp->body); + $data=[]; + if($a){ + $data['address']=$a['Data']['Address']; + $data['business']=$a['Data']['Business']; + $data['legal_person']=$a['Data']['LegalPerson']; + $data['name']=$a['Data']['Name']; + $data['register_number']=$a['Data']['RegisterNumber']; + $data['type']=$a['Data']['Type']; + } + return app('json')->success($data); + + } + catch (Exception $error) { + if (!($error instanceof TeaError)) { + $error = new TeaError([], $error->getMessage(), $error->getCode(), $error); + } + $a=Utils::assertAsString($error->message); + return app('json')->fail($a); + + } + } + + /** + * 商品标签 + */ + public function label_lst(ProductLabelRepository $repository) + { + [$page, $limit] = $this->getPage(); + $where = $this->request->params(['name', 'type', 'status']); + $data = $repository->getList($where,$page, $limit); + return app('json')->success($data); + } } diff --git a/app/controller/api/Statistics.php b/app/controller/api/Statistics.php index b4dcca17..484ed87a 100644 --- a/app/controller/api/Statistics.php +++ b/app/controller/api/Statistics.php @@ -2,6 +2,8 @@ namespace app\controller\api; +use app\common\model\system\merchant\Merchant; +use app\common\model\system\merchant\MerchantType; use crmeb\basic\BaseController; use think\facade\Db; @@ -40,6 +42,7 @@ class Statistics extends BaseController } $where[] = ['is_del', '=', 0]; $where[] = ['status', '=', 1]; + $where[] = ['type_id', '=', $parmas['mer_type_id']]; $count = Db::name('merchant')->where($where)->count(); return app('json')->success(['count' => $count]); } @@ -60,8 +63,9 @@ class Statistics extends BaseController if (!isset($parmas['mer_intention_id']) || $parmas['mer_intention_id'] == '') { return app('json')->fail('mer_intention_id:格式错误'); } + $merchant = Merchant::where('mer_intention_id', $parmas['mer_intention_id'])->find(); $where[] = ['create_time', 'between time', [date("Y-m-d H:i:s", $parmas['start_time']), date("Y-m-d H:i:s", $parmas['end_time'])]]; - $where[] = ['mer_id', '=', $parmas['mer_intention_id']]; + $where[] = ['mer_id', '=', $merchant['mer_id']]; $where[] = ['mer_status', '=', 1]; $where[] = ['status', '=', 1]; $where[] = ['is_used', '=', 1]; @@ -311,4 +315,144 @@ class Statistics extends BaseController ->sum('p.total_price'); return app('json')->success(['trade_amount' => $count]); } + + // 镇级下的镇级供应链商户 + public function SupplyChainMerchant() + { + $parmas = $this->request->param(); + + $where[] = ['street_id', '=', $parmas['street_code']]; + $where[] = ['is_del', '=', 0]; + $where[] = ['status', '=', 1]; + // 镇级供应链 type_code = TypeTownSupplyChain + $merchantType = MerchantType::where('type_code', 'TypeTownSupplyChain')->find()->toArray(); + + $where[] = ['type_id', '=', $merchantType['mer_type_id']]; + + $list = Db::name('merchant')->where($where)->select(); + + return app('json')->success(compact('list')); + } + + public function GeneralMerchant() + { + $parmas = $this->request->param(); + + $where[] = ['street_id', '=', $parmas['street_code']]; + $where[] = ['is_del', '=', 0]; + $where[] = ['status', '=', 1]; + // 镇级普通商户 type_code = TypeStore + $merchantType = MerchantType::where('type_code', 'TypeStore')->find(); + + $where[] = ['type_id', '=', $merchantType['mer_type_id']]; + + $list = Db::name('merchant')->where($where)->select(); + + return app('json')->success(compact('list')); + } + + + + /** + * 镇级供应链商户商品数量查询 + */ + public function SupplyChainProduct() + { + $parmas = $this->request->param(); + + $merchant = Merchant::where('mer_intention_id', $parmas['mer_intention_id'])->find(); + if (empty($merchant) || $merchant['type_id'] != 17) { + return app('json')->success(); + } + $merchantName = $merchant['mer_name']; + $where[] = ['mer_id', '=', $merchant['mer_id']]; + $where[] = ['mer_status', '=', 1]; + $where[] = ['status', '=', 1]; + $where[] = ['is_used', '=', 1]; + $where[] = ['is_show', '=', 1]; + $count = Db::name('store_product')->where($where)->count(); + return app('json')->success(compact('count', 'merchantName')); + } + + public function GeneralMerchantProduct() + { + $parmas = $this->request->param(); + + $merchant = Merchant::where('mer_intention_id', $parmas['mer_intention_id'])->find(); + if (empty($merchant) || $merchant['type_id'] != 10) { + return app('json')->success(); + } + $merchantName = $merchant['mer_name']; + $where[] = ['mer_id', '=', $merchant['mer_id']]; + $where[] = ['mer_status', '=', 1]; + $where[] = ['status', '=', 1]; + $where[] = ['is_used', '=', 1]; + $where[] = ['is_show', '=', 1]; + $count = Db::name('store_product')->where($where)->count(); + return app('json')->success(compact('count', 'merchantName')); + } + + /** + * 商户商品库存更新查询 + */ + public function SupplyChainProductStockCount1() + { + $parmas = $this->request->param(); + + $merchant = Merchant::where('mer_intention_id', $parmas['mer_intention_id'])->find(); + if (empty($merchant) || $merchant['type_id'] != 17) { + return app('json')->success(); + } + $where[] = ['mer_id', '=', $merchant['mer_id']]; + $count = Db::name('store_product_stock')->where($where)->count(); + return app('json')->success(['count' => $count]); + } + + /** + * 商户商品库存更新查询 + */ + public function ProductStockCount1() + { + $parmas = $this->request->param(); + + $merchant = Merchant::where('mer_intention_id', $parmas['mer_intention_id'])->find(); + if (empty($merchant) || $merchant['type_id'] != 10) { + return app('json')->success(); + } + $where[] = ['mer_id', '=', $merchant['mer_id']]; + $count = Db::name('store_product_stock')->where($where)->count(); + return app('json')->success(['count' => $count]); + } + + /** + * 采购金额和销售金额 + */ + public function SupplyChainProductPrice() + { + $parmas = $this->request->param(); + if (isset($parmas['type']) && $parmas['type'] != '') { + switch ($parmas['type']) { + case 200: + $where[] = ['p.source', '=', 200]; + break; + case 300: + $where[] = ['p.source', '=', 0]; + break; + } + } else { + $where[] = ['p.source', '=', 0]; + } + $merchant = Merchant::where('mer_intention_id', $parmas['mer_intention_id'])->find(); + if (empty($merchant) || $merchant['type_id'] == 17) { + return app('json')->success(); + } + $mer_id = $merchant['mer_id']; + $where[] = ['p.is_refund', '=', 0]; + $count = Db::name('store_order_product')->alias('p') + ->where($where) + ->join('store_order o', 'o.mer_id=' . $mer_id . ' and o.paid=1 and o.is_del=0') + ->sum('p.total_price'); + $merName = $merchant['mer_name']; + return app('json')->success(compact('merName', 'count')); + } } diff --git a/app/controller/api/dataview/Logistics.php b/app/controller/api/dataview/Logistics.php index 7bb44361..342651cf 100755 --- a/app/controller/api/dataview/Logistics.php +++ b/app/controller/api/dataview/Logistics.php @@ -37,26 +37,39 @@ class Logistics extends BaseController { // 查区县的镇农科公司 $list = []; - $companyList = Db::connect('work_task')->name('company')->where(['area' => $this->areaCode, 'company_type'=>41])->select()->toArray(); + $companyList = Db::connect('work_task')->name('company')->where('id', 69)->where(['area' => $this->areaCode, 'company_type'=>41])->select()->toArray(); foreach ($companyList as $company) { // 先从供销系统 查出镇下边的所有配送员-小组服务公司的负责人 $serviceGroupCompanyIds = Db::connect('work_task')->name('company') ->where(['street'=> $company['street'], 'company_type'=>18]) ->column('id'); - + if (empty($serviceGroupCompanyIds)) { + continue; + } $userIdList = Db::connect('work_task')->name('user') ->whereIn('company_id', $serviceGroupCompanyIds) ->where(['group_id'=>5]) - ->column('id'); + ->field('id, nickname')->select()->toArray(); + + if (empty($userIdList)) { + continue; + } // 从物流系统 查物流订单排序 确定谁是 镇辖区内配送订单最多的配送员 $topCourier = Db::connect('logistics')->name('logistics') ->field(['courier_id','courier_name','COUNT(order_id) AS order_count']) - ->whereIn('courier_id', $userIdList) + ->whereIn('courier_id', array_column($userIdList, 'id')) ->group('courier_id') ->order('order_count DESC') ->find(); + + if (!empty($userIdList) && empty($topCourier)) { + $topCourier['courier_id'] = $userIdList[0]['id']; + $topCourier['courier_name'] = $userIdList[0]['nickname']; + $topCourier['order_count'] = 0; + } + // 小组公司没有配送员或是没有三轮车 if (empty($topCourier)) { continue; @@ -65,8 +78,15 @@ class Logistics extends BaseController // 三轮车车牌号 根据配送员id反查公司id,公司id反查车牌号 $courier = Db::connect('work_task')->name('user')->where(['id'=>$topCourier['courier_id']])->find(); + if (empty($courier)) { + continue; + } $vehicleRent = Db::connect('work_task')->name('vehicle_rent')->where(['rent_company_id'=>$courier['company_id']])->find(); + if (empty($vehicleRent)) { + continue; + } + $topCourier['id'] = $vehicleRent['car_id']; $topCourier['license'] = $vehicleRent['car_license']; $topCourier['area_code'] = $courier['area']; @@ -128,17 +148,24 @@ class Logistics extends BaseController // 第二页 物流信息统计 public function logisticsCount() { + $topCourier = []; + // 查询镇辖区内配送订单最多的配送员 // 先从供销系统 查出镇下边的所有配送员-小组服务公司的负责人 $serviceGroupCompanyIds = Db::connect('work_task')->name('company') ->where(['street'=> $this->streetCode, 'company_type'=>18]) ->column('id'); + if (empty($serviceGroupCompanyIds)) { + return app('json')->success($topCourier); + } $userIdList = Db::connect('work_task')->name('user') ->whereIn('company_id', $serviceGroupCompanyIds) ->where(['group_id'=>5]) ->column('id'); - + if (empty($userIdList)) { + return app('json')->success($topCourier); + } // 从物流系统 查物流订单排序 确定谁是 镇辖区内配送订单最多的配送员 $topCourier = Db::connect('logistics')->name('logistics') ->field(['courier_id','courier_name','COUNT(order_id) AS order_count']) @@ -146,6 +173,17 @@ class Logistics extends BaseController ->group('courier_id') ->order('order_count DESC') ->find(); + + if (!empty($userIdList) && empty($topCourier)) { + $user = Db::connect('work_task')->name('user')->where('id', $userIdList[0])->find(); + $topCourier['courier_id'] = $user['id']; + $topCourier['courier_name'] = $user['nickname']; + $topCourier['order_count'] = 0; + } + + if (empty($topCourier)) { + return app('json')->success($topCourier); + } // 返查配送员的物流配送订单统计信息 // 待取货数 $topCourier['pending_order_count'] = Db::connect('logistics')->name('logistics')->where(['status'=>0, 'courier_id'=>$topCourier['courier_id']])->count(); @@ -167,9 +205,13 @@ class Logistics extends BaseController public function logisticsMapCount() { $courierId = $this->request->param('courier_id'); + $latestOrder = []; + $latestTenOrder = []; // 最近一次取货地址 最新一笔的配送中订单的取货地址 $latestLogistics = Db::connect('logistics')->name('logistics')->where(['status'=>1, 'courier_id' => $courierId])->order('id', 'desc')->find(); - + if (empty($latestLogistics)) { + return app('json')->success(compact('latestOrder', 'latestTenOrder')); + } $latestOrderInfo = Db::name('store_order')->where(['order_id'=>$latestLogistics['order_id']])->find(); $merchant = Db::name('merchant')->where(['mer_id'=>$latestOrderInfo['mer_id']])->find(); diff --git a/app/controller/api/dataview/Order.php b/app/controller/api/dataview/Order.php index 2730f1ef..0c4ee527 100755 --- a/app/controller/api/dataview/Order.php +++ b/app/controller/api/dataview/Order.php @@ -43,7 +43,7 @@ class Order extends BaseController public function currOrderInfo() { try { - $day = '2023-11-29'; // today + $day = 'today'; // today $currOrderCountQuery = Db::name('store_order')->alias('o') ->field(['o.order_sn', 'o.real_name', 'o.user_phone', 'o.user_address', 'o.user_address_code', 'p.store_name', 'm.mer_name', 'o.create_time', 'o.status']) ->leftJoin('product_order_log og', 'o.order_id = og.order_id') @@ -177,7 +177,7 @@ class Order extends BaseController { // 查到镇级 if ($this->areaCode != '' && $this->streetCode != '') { - $list = Db::query("SELECT p.store_name, SUM(o.`total_num`) AS total_quantity + $list = Db::query("SELECT p.store_name, SUM(op.`product_num`) AS total_quantity FROM `eb_store_product` p JOIN `eb_store_order_product` op ON p.product_id = op.product_id JOIN `eb_store_order` o ON o.`order_id` = op.`order_id` @@ -188,7 +188,7 @@ class Order extends BaseController LIMIT 50"); } else { // 查到区县级 - $list = Db::query("SELECT p.store_name, SUM(o.`total_num`) AS total_quantity + $list = Db::query("SELECT p.store_name, SUM(op.`product_num`) AS total_quantity FROM `eb_store_product` p JOIN `eb_store_order_product` op ON p.product_id = op.product_id JOIN `eb_store_order` o ON o.`order_id` = op.`order_id` diff --git a/app/controller/api/server/StoreProduct.php b/app/controller/api/server/StoreProduct.php index f210075a..a2425d5f 100644 --- a/app/controller/api/server/StoreProduct.php +++ b/app/controller/api/server/StoreProduct.php @@ -256,4 +256,35 @@ class StoreProduct extends BaseController return app('json')->fail('入库失败'); } } + + + + /** + * 商户添加商品到云仓 + */ + public function add_cloud_product() + { + $data = $this->request->params(['product_id', 'type', 'is_del']); + $merchant = app()->make(MerchantRepository::class)->search(['mer_id' => $this->merId,])->find(); + $res = $this->repository->add_cloud_product($data, $merchant); + if ($res) { + return app('json')->success('设置成功'); + } else { + return app('json')->fail('设置失败'); + } + } + + + /** + * 云仓商品列表 + */ + public function cloud_product_list(){ + [$page, $limit] = $this->getPage(); + $merchant = app()->make(MerchantRepository::class)->search(['mer_id' => $this->merId,])->find(); + $product_ids=Db::name('cloud_product')->where('mer_id',$this->merId()) + ->page($page)->limit($limit)->column('product_id'); + $select = Db::name('store_product')->where('mer_id', $this->merId())->whereIn('product_id',$product_ids)->select()->toArray(); + $count = Db::name('cloud_product')->where('mer_id',$merchant['mer_id'])->count(); + return app('json')->success(['list'=>$select,'count'=>$count]); + } } diff --git a/app/controller/api/store/merchant/Merchant.php b/app/controller/api/store/merchant/Merchant.php index 559e979d..cbbcb097 100755 --- a/app/controller/api/store/merchant/Merchant.php +++ b/app/controller/api/store/merchant/Merchant.php @@ -268,15 +268,16 @@ class Merchant extends BaseController if (empty($id)) { return app('json')->fail('参数错误'); } + $merchant = app()->make(MerchantRepository::class)->search(['mer_id' => $id])->find(); - $data = Db::name('merchant')->where('mer_id', $id)->find(); - $data['mer_certificate'] = merchantConfig($id, 'mer_certificate'); - $data['mer_certificate'] = $data['mer_certificate'][0] ?? ''; - // $append = ['merchantCategory', 'merchantType', 'mer_certificate']; - // if ($merchant['is_margin'] == -10) - // $append[] = 'refundMarginOrder'; + // $data = Db::name('merchant')->where('mer_id', $id)->find(); + $merchant['mer_certificate'] = merchantConfig($id, 'mer_certificate'); + // $data['mer_certificate'] = $data['mer_certificate'][0] ?? ''; + $append = ['merchantCategory', 'merchantType', 'mer_certificate']; + if ($merchant['is_margin'] == -10) + $append[] = 'refundMarginOrder'; - // $data = $merchant->append($append)->hidden(['mark', 'reg_admin_id', 'sort'])->toArray(); + $data = $merchant->append($append)->hidden(['mark', 'reg_admin_id', 'sort','financial_bank'])->toArray(); $delivery = $repository->get($id) + systemConfig(['tx_map_key']); $data = array_merge($data, $delivery); $data['sys_bases_status'] = systemConfig('sys_bases_status') === '0' ? 0 : 1; diff --git a/app/controller/api/store/merchant/MerchantIntention.php b/app/controller/api/store/merchant/MerchantIntention.php index 8dbe29ac..b5ec4edf 100644 --- a/app/controller/api/store/merchant/MerchantIntention.php +++ b/app/controller/api/store/merchant/MerchantIntention.php @@ -135,6 +135,7 @@ class MerchantIntention extends BaseController 'village_id', 'is_nmsc', 'bank_username', + 'bank_code', 'bank_opening', 'bank_front', 'bank_back', @@ -142,7 +143,7 @@ class MerchantIntention extends BaseController 'cardno_back', ]); - if (empty($data['bank_username']) || empty($data['bank_opening']) || empty($data['bank_front']) || empty($data['bank_back']) || empty($data['cardno_front']) || empty($data['cardno_back'])) { + if (empty($data['bank_username']) || empty($data['bank_opening'])||empty($data['bank_code'])) { return app('json')->fail('请完善银行卡及身份信息'); } @@ -175,6 +176,7 @@ class MerchantIntention extends BaseController } $intenInfo['bank_username'] = $data['bank_username']; $intenInfo['bank_opening'] = $data['bank_opening']; + $intenInfo['bank_code'] = $data['bank_code']; $intenInfo['bank_front'] = $data['bank_front']; $intenInfo['bank_back'] = $data['bank_back']; $intenInfo['cardno_front'] = $data['cardno_front']; @@ -205,6 +207,7 @@ class MerchantIntention extends BaseController 'address' => $intenInfo['address'] ?? '', 'bank_username' => $data['bank_username'] ?? '', 'bank_opening' => $data['bank_opening'] ?? '', + 'bank_code' => $data['bank_code'] ?? '', 'bank_front' => $data['bank_front'] ?? '', 'bank_back' => $data['bank_back'] ?? '', 'cardno_front' => $data['cardno_front'] ?? '', diff --git a/app/controller/api/store/product/CloudWarehouse.php b/app/controller/api/store/product/CloudWarehouse.php index 75f6a67d..576fd5d4 100644 --- a/app/controller/api/store/product/CloudWarehouse.php +++ b/app/controller/api/store/product/CloudWarehouse.php @@ -30,7 +30,7 @@ class CloudWarehouse extends BaseController * @param SpuRepository $repository * @param MerchantDao $merchantDao */ - public function __construct(App $app, MerchantDao $merchantDao, SpuRepository $spuRepository,SpuDao $SpuDao) + public function __construct(App $app, MerchantDao $merchantDao, SpuRepository $spuRepository, SpuDao $SpuDao) { parent::__construct($app); $this->merchantDao = $merchantDao; @@ -43,28 +43,60 @@ class CloudWarehouse extends BaseController * type_id 13云仓商品列表 * @return mixed */ - public function index($street_code, $page = 1, $category_id = 0,$location='') + public function index($street_code, $page = 1, $category_id = 0, $cate_pid = 0,$cate_id = 0,$location = '') { - $cloud_product = Db::name('cloud_product') - ->where('cate_id',$category_id) - ->where('street_code', $street_code)->where('status', 1)->page($page)->column('product_id'); + + $cloud_where['street_code']=$street_code; + $cloud_where['status']=1; + if($cate_pid!=0){ + $cate_id=Db::name('store_category')->where('pid',$cate_pid)->where('is_show',1)->column('store_category_id'); + } + if($cate_id>0){ + $cloud_where['cate_id']=$cate_id; + } + $cloud_product_arr = Db::name('cloud_product') + ->where($cloud_where) + ->where(function($query){ + $query->whereOr('mer_labels', '') + ->whereOr('mer_labels',',5,'); + })->page($page)->field('product_id,mer_labels')->select(); + $cloud_product = []; + foreach ($cloud_product_arr as $key => $value) { + $cloud_product[] = $value['product_id']; + } $where = [ 'is_show' => 1, 'is_used' => 1, 'status' => 1, 'is_del' => 0, 'mer_status' => 1, - 'product_type'=>98, - 'product_id'=>$cloud_product + 'product_type' => 98, + 'product_id' => $cloud_product ]; - if (!$cloud_product && $category_id==0) { + if (!$cloud_product) { return app('json')->success(['count' => 0, 'list' => []]); } - $count = Db::name('cloud_product')->where('street_code', $street_code)->where('status', 1)->count(); - - $products = $this->spuRepository->getApiSearch($where,$page,10, false,true); - if($products['list']){ - $list=$products['list']; + $count = Db::name('cloud_product') + ->where($cloud_where) + ->where(function($query){ + $query->whereOr('mer_labels', '') + ->whereOr('mer_labels',',5,'); + })->count(); + + $products = $this->spuRepository->getApiSearch($where, $page, 10, false, true); + if ($products['list']) { + $list = $products['list']; + foreach ($cloud_product_arr as $key => $value) { + foreach ($list as $k => $v) { + if ($value['product_id'] == $v['product_id']) { + if ($value['mer_labels'] == ',5,') { + $list[$k]['mer_labels_name'] = '五日达'; + } else { + $list[$k]['mer_labels_name'] = '次日达'; + } + } + } + } } return app('json')->success(['count' => $count, 'list' => $list]); } @@ -75,10 +107,10 @@ class CloudWarehouse extends BaseController */ public function town() { - $params = $this->request->params(['category_id', 'street_code', 'order', ['product_type', 0], 'keyword', 'page','cate_pid']); + $params = $this->request->params(['category_id', 'street_code', 'order', ['product_type', 0], 'keyword', 'page', 'cate_pid']); $search = [ 'street_id' => $params['street_code'], - 'type_id' =>[Merchant::TypeStore,Merchant::TypeTownSupplyChain], + 'type_id' => [Merchant::TypeStore, Merchant::TypeTownSupplyChain], 'status' => 1, 'is_del' => 0, 'mer_state' => 1, @@ -101,10 +133,10 @@ class CloudWarehouse extends BaseController if (!empty($params['category_id'])) { $where['cate_id'] = $params['category_id']; } - if($params['cate_pid']!=''){ + if ($params['cate_pid'] != '') { $where['cate_pid'] = $params['cate_pid']; } - $products = $this->spuRepository->getApiSearch($where, $page, $limit, false,true); + $products = $this->spuRepository->getApiSearch($where, $page, $limit, false, true); return app('json')->success($products); } } diff --git a/app/controller/api/store/product/StoreProduct.php b/app/controller/api/store/product/StoreProduct.php index cb001a22..5625a0c2 100644 --- a/app/controller/api/store/product/StoreProduct.php +++ b/app/controller/api/store/product/StoreProduct.php @@ -211,7 +211,8 @@ class StoreProduct extends BaseController "attr", "attrValue", 'spec_type', - 'is_stock' + 'is_stock', + 'mer_labels' ]; $data = $this->request->params($params); // $count = app()->make(StoreCategoryRepository::class)->getWhereCount(['store_category_id' => $data['mer_cate_id'],'is_show' => 1,'mer_id' => $this->request->merId()]); diff --git a/app/controller/api/store/product/StoreSpu.php b/app/controller/api/store/product/StoreSpu.php index 76bff57e..59fbadb0 100644 --- a/app/controller/api/store/product/StoreSpu.php +++ b/app/controller/api/store/product/StoreSpu.php @@ -59,7 +59,8 @@ class StoreSpu extends BaseController 'product_ids', 'mer_id', 'type_id', - 'street_id' + 'street_id', + 'category_id' ]); if ($where['type_id']) { $arr = ['status' => 1, 'mer_state' => 1, 'is_del' => 0]; @@ -74,6 +75,9 @@ class StoreSpu extends BaseController $where['product_type'] = $where['product_type']??0; $where['order'] = $where['order'] ?: 'star'; if ($where['is_trader'] != 1) unset($where['is_trader']); + if($where['category_id']!=''){ + $where['mer_ids']= Db::name('merchant')->where(['category_id'=>$where['category_id'],'status'=>1,'is_del'=>0])->column('mer_id'); + } $data = $this->repository->getApiSearch($where, $page, $limit, $this->userInfo); return app('json')->success($data); } diff --git a/app/controller/merchant/store/product/Product.php b/app/controller/merchant/store/product/Product.php index 294ee9f5..54a5c341 100644 --- a/app/controller/merchant/store/product/Product.php +++ b/app/controller/merchant/store/product/Product.php @@ -29,14 +29,14 @@ use think\facade\Db; class Product extends BaseController { - protected $repository ; + protected $repository; /** * Product constructor. * @param App $app * @param repository $repository */ - public function __construct(App $app ,repository $repository) + public function __construct(App $app, repository $repository) { parent::__construct($app); $this->repository = $repository; @@ -50,17 +50,17 @@ class Product extends BaseController public function lst() { [$page, $limit] = $this->getPage(); - $where = $this->request->params(['temp_id','cate_id','keyword',['type',1],'mer_cate_id','is_gift_bag','status','us_status','product_id','mer_labels',['order','sort'],'is_ficti','svip_price_type']); - $where = array_merge($where,$this->repository->switchType($where['type'],$this->request->merId(),0)); - $type=$this->request->merchant()['type_id']; - $typeCode=Db::name('merchant_type')->where('mer_type_id',$type)->value('type_code'); - $product_type=0; + $where = $this->request->params(['temp_id', 'cate_id', 'keyword', ['type', 1], 'mer_cate_id', 'is_gift_bag', 'status', 'us_status', 'product_id', 'mer_labels', ['order', 'sort'], 'is_ficti', 'svip_price_type']); + $where = array_merge($where, $this->repository->switchType($where['type'], $this->request->merId(), 0)); + $type = $this->request->merchant()['type_id']; + $typeCode = Db::name('merchant_type')->where('mer_type_id', $type)->value('type_code'); + $product_type = 0; // if ($type==12){ - if ($typeCode==Merchant::TypeCode['TypeSupplyChain']){ - $where['product_type']=98;//供应链 + if ($typeCode == Merchant::TypeCode['TypeSupplyChain']) { + $where['product_type'] = 98; //供应链 } - return app('json')->success($this->repository->getList($this->request->merId(),$where, $page, $limit)); + return app('json')->success($this->repository->getList($this->request->merId(), $where, $page, $limit)); } /** @@ -71,9 +71,9 @@ class Product extends BaseController */ public function detail($id) { - if(!$this->repository->merExists($this->request->merId(),$id)) + if (!$this->repository->merExists($this->request->merId(), $id)) return app('json')->fail('数据不存在'); - return app('json')->success($this->repository->getAdminOneProduct($id,null)); + return app('json')->success($this->repository->getAdminOneProduct($id, null)); } /** @@ -85,7 +85,7 @@ class Product extends BaseController public function create() { $params = $this->request->params($this->repository::CREATE_PARAMS); - $data = $this->repository->checkParams($params,$this->request->merId()); + $data = $this->repository->checkParams($params, $this->request->merId()); // $cate_id=StoreCategory::where('pid',$data['cate_id'])->where('level',2)->value('store_category_id'); // if(!$cate_id){ // return app('json')->fail('请先添加第三级分类'); @@ -97,15 +97,15 @@ class Product extends BaseController $data['status'] = $this->request->merchant()->is_audit ? 0 : 1; $data['mer_status'] = ($this->request->merchant()->is_del || !$this->request->merchant()->mer_state || !$this->request->merchant()->status) ? 0 : 1; $data['rate'] = 3; - $typeCode=Db::name('merchant_type')->where('mer_type_id',$this->request->merchant()->type_id)->value('type_code'); + $typeCode = Db::name('merchant_type')->where('mer_type_id', $this->request->merchant()->type_id)->value('type_code'); // if ($this->request->merchant()->type_id==12){ - if ($typeCode==Merchant::TypeCode['TypeSupplyChain']){ - $product_type=98;//供应链 - }else{ - $product_type=0;//普通商品 + if ($typeCode == Merchant::TypeCode['TypeSupplyChain']) { + $product_type = 98; //供应链 + } else { + $product_type = 0; //普通商品 } $data['update_time'] = date('Y-m-d H:i:s'); - $this->repository->create($data,$product_type,1); + $this->repository->create($data, $product_type, 1); return app('json')->success('添加成功'); } @@ -119,7 +119,7 @@ class Product extends BaseController public function update($id) { $params = $this->request->params($this->repository::CREATE_PARAMS); - $data = $this->repository->checkParams($params,$this->request->merId(), $id); + $data = $this->repository->checkParams($params, $this->request->merId(), $id); if (!$this->repository->merExists($this->request->merId(), $id)) return app('json')->fail('数据不存在'); $pro = $this->repository->getWhere(['product_id' => $id]); @@ -133,7 +133,7 @@ class Product extends BaseController $data['update_time'] = date('Y-m-d H:i:s'); $typeSupplyChainId = Db::name('MerchantType')->where('type_code', Merchant::TypeCode['TypeSupplyChain'])->value('mer_type_id'); $productType = $this->request->merchant()->type_id == $typeSupplyChainId ? 98 : 0; - $this->repository->edit($id, $data, $this->request->merId(), $productType,1); + $this->repository->edit($id, $data, $this->request->merId(), $productType, 1); return app('json')->success('编辑成功'); } @@ -145,9 +145,9 @@ class Product extends BaseController */ public function delete($id) { - if(!$this->repository->merExists($this->request->merId(),$id)) + if (!$this->repository->merExists($this->request->merId(), $id)) return app('json')->fail('数据不存在'); - if($this->repository->getWhereCount(['product_id' => $id,'is_show' => 1,'status' => 1])) + if ($this->repository->getWhereCount(['product_id' => $id, 'is_show' => 1, 'status' => 1])) return app('json')->fail('商品上架中'); $this->repository->delete($id); //queue(ChangeSpuStatusJob::class,['product_type' => 0,'id' => $id]); @@ -157,9 +157,9 @@ class Product extends BaseController public function destory($id) { - if(!$this->repository->merDeleteExists($this->request->merId(),$id)) + if (!$this->repository->merDeleteExists($this->request->merId(), $id)) return app('json')->fail('只能删除回收站的商品'); - if(app()->make(StoreCartRepository::class)->getProductById($id)) + if (app()->make(StoreCartRepository::class)->getProductById($id)) return app('json')->fail('商品有被加入购物车不可删除'); $this->repository->destory($id); return app('json')->success('删除成功'); @@ -174,14 +174,14 @@ class Product extends BaseController */ public function getStatusFilter() { - $type=$this->request->merchant()['type_id']; - $product_type=0; - $typeCode=Db::name('merchant_type')->where('mer_type_id',$type)->value('type_code'); + $type = $this->request->merchant()['type_id']; + $product_type = 0; + $typeCode = Db::name('merchant_type')->where('mer_type_id', $type)->value('type_code'); // if ($type==12){ - if ($typeCode==Merchant::TypeCode['TypeSupplyChain']){ - $product_type=98;//供应链 + if ($typeCode == Merchant::TypeCode['TypeSupplyChain']) { + $product_type = 98; //供应链 } - return app('json')->success($this->repository->getFilter($this->request->merId(),'商品',$product_type)); + return app('json')->success($this->repository->getFilter($this->request->merId(), '商品', $product_type)); } /** @@ -192,10 +192,10 @@ class Product extends BaseController */ public function config() { - $data = systemConfig(['extension_status','svip_switch_status','integral_status']); - $merData= merchantConfig($this->request->merId(),['mer_integral_status','mer_integral_rate','mer_svip_status','svip_store_rate']); - $svip_store_rate = $merData['svip_store_rate'] > 0 ? bcdiv($merData['svip_store_rate'],100,2) : 0; - $data['mer_svip_status'] = ($data['svip_switch_status'] && $merData['mer_svip_status'] != 0 ) ? 1 : 0; + $data = systemConfig(['extension_status', 'svip_switch_status', 'integral_status']); + $merData = merchantConfig($this->request->merId(), ['mer_integral_status', 'mer_integral_rate', 'mer_svip_status', 'svip_store_rate']); + $svip_store_rate = $merData['svip_store_rate'] > 0 ? bcdiv($merData['svip_store_rate'], 100, 2) : 0; + $data['mer_svip_status'] = ($data['svip_switch_status'] && $merData['mer_svip_status'] != 0) ? 1 : 0; $data['svip_store_rate'] = $svip_store_rate; $data['integral_status'] = $data['integral_status'] && $merData['mer_integral_status'] ? 1 : 0; $data['integral_rate'] = $merData['mer_integral_rate'] ?: 0; @@ -213,7 +213,7 @@ class Product extends BaseController */ public function restore($id) { - if(!$this->repository->merDeleteExists($this->request->merId(),$id)) + if (!$this->repository->merDeleteExists($this->request->merId(), $id)) return app('json')->fail('只能恢复回收站的商品'); $this->repository->restore($id); return app('json')->success('商品已恢复'); @@ -235,7 +235,7 @@ class Product extends BaseController public function updateSort($id) { $sort = $this->request->param('sort'); - $this->repository->updateSort($id,$this->request->merId(),['sort' => $sort]); + $this->repository->updateSort($id, $this->request->merId(), ['sort' => $sort]); return app('json')->success('修改成功'); } @@ -265,7 +265,7 @@ class Product extends BaseController public function setLabels($id) { $data = $this->request->params(['mer_labels']); - app()->make(SpuRepository::class)->setLabels($id,0,$data,$this->request->merId()); + app()->make(SpuRepository::class)->setLabels($id, 0, $data, $this->request->merId()); return app('json')->success('修改成功'); } @@ -279,7 +279,7 @@ class Product extends BaseController { $params = [ "mer_cate_id", - "sort" , + "sort", "is_show", "is_good", "attr", @@ -291,12 +291,12 @@ class Product extends BaseController // $count = app()->make(StoreCategoryRepository::class)->getWhereCount(['store_category_id' => $data['mer_cate_id'],'is_show' => 1,'mer_id' => $this->request->merId()]); // if (!$count) throw new ValidateException('商户分类不存在或不可用'); $data['status'] = 1; - $res=$this->repository->freeTrial($id, $data,$this->request->merId()); - if($res && $params['is_stock']==1){ - $arr=[ - 'mer_id'=>$this->request->merId(), - 'product_id'=>$data['attrValue'][0]['product_id'], - 'create_time'=>date('Y-m-d H:i:s') + $res = $this->repository->freeTrial($id, $data, $this->request->merId()); + if ($res && $params['is_stock'] == 1) { + $arr = [ + 'mer_id' => $this->request->merId(), + 'product_id' => $data['attrValue'][0]['product_id'], + 'create_time' => date('Y-m-d H:i:s') ]; Db::name('store_product_stock')->insert($arr); } @@ -313,7 +313,7 @@ class Product extends BaseController public function switchStatus($id) { $status = $this->request->param('status', 0) == 1 ? 1 : 0; - $this->repository->switchShow($id, $status,'is_show',$this->request->merId()); + $this->repository->switchShow($id, $status, 'is_show', $this->request->merId()); return app('json')->success('修改成功'); } @@ -329,7 +329,7 @@ class Product extends BaseController $ids = $this->request->param('ids'); if (empty($ids)) return app('json')->fail('请选择商品'); $status = $this->request->param('status') == 1 ? 1 : 0; - $this->repository->batchSwitchShow($ids,$status,'is_show',$this->request->merId()); + $this->repository->batchSwitchShow($ids, $status, 'is_show', $this->request->merId()); return app('json')->success('修改成功'); } @@ -342,7 +342,7 @@ class Product extends BaseController public function batchTemplate() { $ids = $this->request->param('ids'); - $ids = is_array($ids) ? $ids : explode(',',$ids); + $ids = is_array($ids) ? $ids : explode(',', $ids); $data = $this->request->params(['temp_id']); if (empty($ids)) return app('json')->fail('请选择商品'); if (empty($data['temp_id'])) return app('json')->fail('请选择运费模板'); @@ -351,7 +351,7 @@ class Product extends BaseController if (!$make->merInExists($this->request->merId(), [$data['temp_id']])) return app('json')->fail('请选择您自己的运费模板'); $data['delivery_free'] = 0; - $this->repository->updates($ids,$data); + $this->repository->updates($ids, $data); return app('json')->success('修改成功'); } @@ -368,7 +368,7 @@ class Product extends BaseController if (empty($ids)) return app('json')->fail('请选择商品'); if (!$this->repository->merInExists($this->request->merId(), $ids)) return app('json')->fail('请选择您自己商品'); - app()->make(SpuRepository::class)->batchLabels($ids, $data,$this->request->merId()); + app()->make(SpuRepository::class)->batchLabels($ids, $data, $this->request->merId()); return app('json')->success('修改成功'); } @@ -385,7 +385,7 @@ class Product extends BaseController if (empty($ids)) return app('json')->fail('请选择商品'); if (!$this->repository->merInExists($this->request->merId(), $ids)) return app('json')->fail('请选择您自己商品'); - $this->repository->updates($ids,$data); + $this->repository->updates($ids, $data); return app('json')->success('修改成功'); } @@ -399,37 +399,83 @@ class Product extends BaseController public function batchExtension(ProductAttrValueRepository $repository) { $ids = $this->request->param('ids'); - $data = $this->request->params(['extension_one','extension_two']); + $data = $this->request->params(['extension_one', 'extension_two']); if ($data['extension_one'] > 1 || $data['extension_one'] < 0 || $data['extension_two'] < 0 || $data['extension_two'] > 1) { return app('json')->fail('比例0~1之间'); } if (empty($ids)) return app('json')->fail('请选择商品'); if (!$this->repository->merInExists($this->request->merId(), $ids)) return app('json')->fail('请选择您自己商品'); - $repository->updatesExtension($ids,$data); + $repository->updatesExtension($ids, $data); return app('json')->success('修改成功'); } public function batchSvipType() { $ids = $this->request->param('ids'); - $data = $this->request->params([['svip_price_type',0]]); + $data = $this->request->params([['svip_price_type', 0]]); if (empty($ids)) return app('json')->fail('请选择商品'); if (!$this->repository->merInExists($this->request->merId(), $ids)) return app('json')->fail('请选择您自己商品'); - $this->repository->updates($ids,$data); + $this->repository->updates($ids, $data); return app('json')->success('修改成功'); } /** * 导入商品列表管理 */ - public function xlsx_import_list(){ + public function xlsx_import_list() + { [$page, $limit] = $this->getPage(); - $select=Db::name('store_product_import')->where('mer_id',$this->request->merId())->page($page)->limit($limit)->select()->toArray(); - $count=Db::name('store_product_import')->where('mer_id',$this->request->merId())->count(); - return app('json')->success(['list'=>$select,'count'=>$count]); - + $select = Db::name('store_product_import')->where('mer_id', $this->request->merId())->page($page)->limit($limit)->select()->toArray(); + $count = Db::name('store_product_import')->where('mer_id', $this->request->merId())->count(); + return app('json')->success(['list' => $select, 'count' => $count]); } + + /** + * 商户添加商品到云仓 + */ + public function add_cloud_product() + { + $data = $this->request->params(['product_id', 'type', 'is_del']); + $res = $this->repository->add_cloud_product($data, $this->request->merchant()); + if ($res) { + return app('json')->success('设置成功'); + } else { + return app('json')->fail('设置失败'); + } + } + + + /** + * 云仓商品列表 + */ + public function cloud_product_list(){ + [$page, $limit] = $this->getPage(); + + $cloud_product_arr=Db::name('cloud_product')->where('mer_id',$this->request->merId()) + ->page($page)->limit($limit)->field('product_id,mer_labels')->select(); + $cloud_product = []; + foreach ($cloud_product_arr as $key => $value) { + $cloud_product[] = $value['product_id']; + } + $select = Db::name('store_product')->where('mer_id', $this->request->merId())->whereIn('product_id',$cloud_product)->select()->toArray(); + $count = Db::name('cloud_product')->where('mer_id',$this->request->merId())->count(); + if ($select) { + foreach ($cloud_product_arr as $key => $value) { + foreach ($select as $k => $v) { + if ($value['product_id'] == $v['product_id']) { + if ($value['mer_labels'] == ',5,') { + $select[$k]['mer_labels_name'] = '五日达'; + } else { + $select[$k]['mer_labels_name'] = '次日达'; + } + } + } + } + } + return app('json')->success(['list'=>$select,'count'=>$count]); + } + } diff --git a/app/controller/merchant/store/product/ProductLabel.php b/app/controller/merchant/store/product/ProductLabel.php index 56dca928..4aa28e59 100644 --- a/app/controller/merchant/store/product/ProductLabel.php +++ b/app/controller/merchant/store/product/ProductLabel.php @@ -30,7 +30,9 @@ class ProductLabel extends BaseController { [$page, $limit] = $this->getPage(); $where = $this->request->params(['name', 'type', 'status']); - $where['mer_id'] = $this->request->merId(); + if($where['type']!=1){ + $where['mer_id'] = $this->request->merId(); + } $data = $this->repository->getList($where,$page, $limit); return app('json')->success($data); } diff --git a/app/listener/ProductCreate.php b/app/listener/ProductCreate.php index f753b2ee..c50d2075 100644 --- a/app/listener/ProductCreate.php +++ b/app/listener/ProductCreate.php @@ -53,6 +53,7 @@ class ProductCreate $datas = [ 'product_id' => $product_id, 'mer_id' => $merchant['mer_id'], + 'cate_id' => $product['cate_id'], 'source_mer_id' => $cityMerchant['mer_id'], 'street_code' => $merchant['street_id'], 'type_id' => $merchant['type_id'], diff --git a/app/validate/merchant/MerchantUpdateValidate.php b/app/validate/merchant/MerchantUpdateValidate.php index 33e0732f..0a55eb65 100644 --- a/app/validate/merchant/MerchantUpdateValidate.php +++ b/app/validate/merchant/MerchantUpdateValidate.php @@ -21,7 +21,7 @@ class MerchantUpdateValidate extends Validate protected $failException = true; protected $rule = [ - 'mer_info|店铺简介' => 'require|max:200', + // 'mer_info|店铺简介' => 'require|max:200', 'mer_avatar|店铺头像' => 'require|max:128', 'mer_banner|店铺banner' => 'require|max:128', 'mini_banner|店铺街banner' => 'max:128', diff --git a/composer.json b/composer.json index eeb7ca31..0d419104 100644 --- a/composer.json +++ b/composer.json @@ -60,7 +60,8 @@ "topthink/think-api": "1.0.27", "intervention/image": "^2.7", "fastknife/ajcaptcha": "^1.2", - "nelexa/zip": "^4.0" + "nelexa/zip": "^4.0", + "alibabacloud/ocr-20191230": "^3.0" }, "require-dev": { "symfony/var-dumper": "^4.2", diff --git a/composer.lock b/composer.lock index 68d601ea..bdd6c404 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "60838a051e04cfb13dd75049f7540171", + "content-hash": "58b44ebbb4f75dc8b47bcaa0ae8327f7", "packages": [ { "name": "adbario/php-dot-notation", @@ -252,6 +252,59 @@ "description": "Alibaba Cloud Gateway SPI Client", "time": "2022-07-14T05:31:35+00:00" }, + { + "name": "alibabacloud/ocr-20191230", + "version": "3.0.0", + "source": { + "type": "git", + "url": "https://github.com/alibabacloud-sdk-php/Ocr-20191230.git", + "reference": "8d7ad521074b2fd6c392cf0f2b114ce43f0612b8" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/alibabacloud-sdk-php/Ocr-20191230/zipball/8d7ad521074b2fd6c392cf0f2b114ce43f0612b8", + "reference": "8d7ad521074b2fd6c392cf0f2b114ce43f0612b8", + "shasum": "", + "mirrors": [ + { + "url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%", + "preferred": true + } + ] + }, + "require": { + "alibabacloud/darabonba-openapi": "^0.2.8", + "alibabacloud/endpoint-util": "^0.1.0", + "alibabacloud/openapi-util": "^0.1.10|^0.2.1", + "alibabacloud/openplatform-20191219": "^2.0.1", + "alibabacloud/tea-fileform": "^0.3.0", + "alibabacloud/tea-oss-sdk": "^0.3.0", + "alibabacloud/tea-oss-utils": "^0.3.1", + "alibabacloud/tea-utils": "^0.2.19", + "php": ">5.5" + }, + "type": "library", + "autoload": { + "psr-4": { + "AlibabaCloud\\SDK\\Ocr\\V20191230\\": "src" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "Apache-2.0" + ], + "authors": [ + { + "name": "Alibaba Cloud SDK", + "email": "sdk-team@alibabacloud.com" + } + ], + "description": "Alibaba Cloud OCR (20191230) SDK Library for PHP", + "support": { + "source": "https://github.com/alibabacloud-sdk-php/Ocr-20191230/tree/3.0.0" + }, + "time": "2023-07-04T02:18:29+00:00" + }, { "name": "alibabacloud/openapi-util", "version": "0.1.13", @@ -288,6 +341,55 @@ "description": "Alibaba Cloud OpenApi Util", "time": "2022-11-06T05:49:55+00:00" }, + { + "name": "alibabacloud/openplatform-20191219", + "version": "2.0.1", + "source": { + "type": "git", + "url": "https://github.com/alibabacloud-sdk-php/OpenPlatform-20191219.git", + "reference": "02ffa72369f8649214f1cfa336b52a544735f517" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/alibabacloud-sdk-php/OpenPlatform-20191219/zipball/02ffa72369f8649214f1cfa336b52a544735f517", + "reference": "02ffa72369f8649214f1cfa336b52a544735f517", + "shasum": "", + "mirrors": [ + { + "url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%", + "preferred": true + } + ] + }, + "require": { + "alibabacloud/darabonba-openapi": "^0.2.8", + "alibabacloud/endpoint-util": "^0.1.0", + "alibabacloud/openapi-util": "^0.1.10|^0.2.1", + "alibabacloud/tea-utils": "^0.2.17", + "php": ">5.5" + }, + "type": "library", + "autoload": { + "psr-4": { + "AlibabaCloud\\SDK\\OpenPlatform\\V20191219\\": "src" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "Apache-2.0" + ], + "authors": [ + { + "name": "Alibaba Cloud SDK", + "email": "sdk-team@alibabacloud.com" + } + ], + "description": "Alibaba Cloud OpenPlatform (20191219) SDK Library for PHP", + "support": { + "source": "https://github.com/alibabacloud-sdk-php/OpenPlatform-20191219/tree/2.0.1" + }, + "time": "2023-02-07T06:39:39+00:00" + }, { "name": "alibabacloud/tea", "version": "3.2.1", @@ -343,6 +445,156 @@ ], "time": "2023-05-16T06:43:41+00:00" }, + { + "name": "alibabacloud/tea-fileform", + "version": "0.3.4", + "source": { + "type": "git", + "url": "https://github.com/alibabacloud-sdk-php/tea-fileform.git", + "reference": "4bf0c75a045c8115aa8cb1a394bd08d8bb833181" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/alibabacloud-sdk-php/tea-fileform/zipball/4bf0c75a045c8115aa8cb1a394bd08d8bb833181", + "reference": "4bf0c75a045c8115aa8cb1a394bd08d8bb833181", + "shasum": "", + "mirrors": [ + { + "url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%", + "preferred": true + } + ] + }, + "require": { + "alibabacloud/tea": "^3.0", + "php": ">5.5" + }, + "require-dev": { + "phpunit/phpunit": "^4.8.35|^5.4.3" + }, + "type": "library", + "autoload": { + "psr-4": { + "AlibabaCloud\\Tea\\FileForm\\": "src" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "Apache-2.0" + ], + "authors": [ + { + "name": "Alibaba Cloud SDK", + "email": "sdk-team@alibabacloud.com" + } + ], + "description": "Alibaba Cloud Tea File Library for PHP", + "support": { + "issues": "https://github.com/alibabacloud-sdk-php/tea-fileform/issues", + "source": "https://github.com/alibabacloud-sdk-php/tea-fileform/tree/0.3.4" + }, + "time": "2020-12-01T07:24:35+00:00" + }, + { + "name": "alibabacloud/tea-oss-sdk", + "version": "0.3.6", + "source": { + "type": "git", + "url": "https://github.com/alibabacloud-sdk-php/tea-oss-sdk.git", + "reference": "e28e70e2842b2e4da031a774209231bf08d7965c" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/alibabacloud-sdk-php/tea-oss-sdk/zipball/e28e70e2842b2e4da031a774209231bf08d7965c", + "reference": "e28e70e2842b2e4da031a774209231bf08d7965c", + "shasum": "", + "mirrors": [ + { + "url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%", + "preferred": true + } + ] + }, + "require": { + "alibabacloud/credentials": "^1.1", + "alibabacloud/tea-fileform": "^0.3.0", + "alibabacloud/tea-oss-utils": "^0.3.0", + "alibabacloud/tea-utils": "^0.2.0", + "alibabacloud/tea-xml": "^0.2", + "php": ">5.5" + }, + "type": "library", + "autoload": { + "psr-4": { + "AlibabaCloud\\SDK\\OSS\\": "src" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "Apache-2.0" + ], + "authors": [ + { + "name": "Alibaba Cloud SDK", + "email": "sdk-team@alibabacloud.com" + } + ], + "description": "Aliyun Tea OSS SDK Library for PHP", + "support": { + "source": "https://github.com/alibabacloud-sdk-php/tea-oss-sdk/tree/0.3.6" + }, + "time": "2022-10-13T07:23:51+00:00" + }, + { + "name": "alibabacloud/tea-oss-utils", + "version": "0.3.1", + "source": { + "type": "git", + "url": "https://github.com/alibabacloud-sdk-php/tea-oss-utils.git", + "reference": "19f58fc509347f075664e377742d4f9e18465372" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/alibabacloud-sdk-php/tea-oss-utils/zipball/19f58fc509347f075664e377742d4f9e18465372", + "reference": "19f58fc509347f075664e377742d4f9e18465372", + "shasum": "", + "mirrors": [ + { + "url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%", + "preferred": true + } + ] + }, + "require": { + "alibabacloud/tea": "^3.0", + "guzzlehttp/psr7": "^1.0", + "php": ">5.5" + }, + "require-dev": { + "phpunit/phpunit": "^4.8.35|^5.4.3|^9.4" + }, + "type": "library", + "autoload": { + "psr-4": { + "AlibabaCloud\\Tea\\OSSUtils\\": "src" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "Apache-2.0" + ], + "authors": [ + { + "name": "Alibaba Cloud SDK", + "email": "sdk-team@alibabacloud.com" + } + ], + "description": "Alibaba Cloud Tea OSS Utils Library for PHP", + "support": { + "source": "https://github.com/alibabacloud-sdk-php/tea-oss-utils/tree/0.3.1" + }, + "time": "2023-01-08T13:26:58+00:00" + }, { "name": "alibabacloud/tea-utils", "version": "0.2.19", @@ -5053,5 +5305,5 @@ "ext-swoole": "^4.4.0" }, "platform-dev": [], - "plugin-api-version": "2.3.0" + "plugin-api-version": "2.1.0" } diff --git a/public/mer.html b/public/mer.html index c9f83c1f..37140559 100644 --- a/public/mer.html +++ b/public/mer.html @@ -1 +1 @@ -
401