更新后台

This commit is contained in:
mkm 2023-04-26 17:25:44 +08:00
parent a5f478d660
commit 901e977025
2 changed files with 47 additions and 14 deletions

View File

@ -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;
}

View File

@ -0,0 +1,27 @@
<?php
namespace crmeb\jobs;
use app\common\repositories\store\product\ProductRepository;
use crmeb\interfaces\JobInterface;
use think\facade\Log;
class ProductImportJob implements JobInterface
{
public function fire($job, $data)
{
try{
$make = app()->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.
}
}