From 901e977025394fbe7fd9c7b130115c9732e8a0c9 Mon Sep 17 00:00:00 2001 From: mkm <727897186@qq.com> Date: Wed, 26 Apr 2023 17:25:44 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0=E5=90=8E=E5=8F=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../store/order/StoreOrderRepository.php | 34 +++++++++++-------- crmeb/jobs/ProductImportJob.php | 27 +++++++++++++++ 2 files changed, 47 insertions(+), 14 deletions(-) create mode 100644 crmeb/jobs/ProductImportJob.php diff --git a/app/common/repositories/store/order/StoreOrderRepository.php b/app/common/repositories/store/order/StoreOrderRepository.php index c79d475d..241b0f77 100644 --- a/app/common/repositories/store/order/StoreOrderRepository.php +++ b/app/common/repositories/store/order/StoreOrderRepository.php @@ -37,6 +37,7 @@ use app\common\repositories\user\UserBrokerageRepository; use app\common\repositories\user\UserMerchantRepository; use app\common\repositories\user\UserRepository; use crmeb\jobs\PayGiveCouponJob; +use crmeb\jobs\ProductImportJob; use crmeb\jobs\SendSmsJob; use crmeb\jobs\UserBrokerageLevelJob; use crmeb\jobs\SupplyChainOrderBrokerAgeJob; @@ -2461,24 +2462,26 @@ class StoreOrderRepository extends BaseRepository $mer_cate['level']=1; $mer_cate_id=Db::name('store_category')->insertGetId($mer_cate); } - $make = app()->make(ProductRepository::class); $type=Db::name('merchant')->where('mer_id',$merId)->value('type_id'); $product_type=0; if ($type==12){ $product_type=98;//供应链 } foreach ($data as $datum) { - $find=Db::name('store_product')->where('mer_id', $merId)->where('bar_code', $datum['where']['bar_code'])->find(); - if ($find){ - Db::name('store_product')->where('product_id', $find['product_id'])->update($datum['value']); - }else{ +// $find=Db::name('store_product')->where('mer_id', $merId)->where('bar_code', $datum['where']['bar_code'])->find(); +// if ($find){ +// Db::name('store_product')->where('product_id', $find['product_id'])->update($datum['value']); +// }else{ $store_category_id=Db::name('store_category')->where('mer_id',0)->where('cate_name',$datum['value']['cate_id'])->value('store_category_id'); + if ($store_category_id==null){ + $store_category_id=438; + } $datas = [ - "image" => "https://lihai001.oss-cn-chengdu.aliyuncs.com/def/03d76202301101051502568.png", + "image" => "https://lihai001.oss-cn-chengdu.aliyuncs.com/public/kk/luzhou/static4/oa_app/23565656.png", "slider_image" => [ - 0 => "https://lihai001.oss-cn-chengdu.aliyuncs.com/def/3d80f202301101051438680.png", + 0 => "https://lihai001.oss-cn-chengdu.aliyuncs.com/public/kk/luzhou/static4/oa_app/23565656.png", ], - "store_name" => $datum['value']['store_name'], + "store_name" => $datum['value']['store_name'].' '.$datum['value']['specifications'], "store_info" => $datum['value']['store_name'], "keyword" => $datum['value']['keyword'], "bar_code" => $datum['value']['bar_code'], @@ -2487,7 +2490,7 @@ class StoreOrderRepository extends BaseRepository "mer_cate_id" => [ 0 => $mer_cate_id//要修改 ], - 'product_type'=>98, + 'product_type'=>$product_type, "unit_name" => $datum['value']['unit_name'], "sort" => 0, "is_show" => "", @@ -2513,10 +2516,10 @@ class StoreOrderRepository extends BaseRepository "pay_limit" => 0, "attrValue" => [ [ - "image" => "https://lihai001.oss-cn-chengdu.aliyuncs.com/def/03d76202301101051502568.png", + "image" => "https://lihai001.oss-cn-chengdu.aliyuncs.com/public/kk/luzhou/static4/oa_app/23565656.png", "price" => $datum['value']['price'], "cost" => $datum['value']['price'], - "ot_price" => $datum['value']['cost'], + "ot_price" => $datum['value']['price'], "svip_price" => null, "stock" => $datum['value']['stock'], "bar_code" => $datum['value']['bar_code'], @@ -2525,7 +2528,7 @@ class StoreOrderRepository extends BaseRepository ], ], "give_coupon_ids" => [], - "type" => 0,//供应链商品 + "type" => 0, "svip_price" => 0, "svip_price_type" => 0, "params" => [], @@ -2534,8 +2537,11 @@ class StoreOrderRepository extends BaseRepository "mer_status" => 1, "rate" => 3, ]; - $make->create($datas,$product_type); - } + $data_list=[ + 'data'=>$datas, + 'product_type'=>$product_type, + ]; + Queue::push(ProductImportJob::class,$data_list); } return true; } diff --git a/crmeb/jobs/ProductImportJob.php b/crmeb/jobs/ProductImportJob.php new file mode 100644 index 00000000..fdecdfce --- /dev/null +++ b/crmeb/jobs/ProductImportJob.php @@ -0,0 +1,27 @@ +make(ProductRepository::class); + $make->create($data['data'],$data['product_type']); + }catch (\Exception $e){ + Log::error('商户ID:'.$data['mer_id'].' 导入文件 error : ' . $e->getMessage()); + } + $job->delete(); + } + + public function failed($data) + { + // TODO: Implement failed() method. + } +}