更新商品导入
This commit is contained in:
parent
33e96588a3
commit
e1f105d98a
@ -2521,14 +2521,26 @@ class StoreOrderRepository extends BaseRepository
|
||||
$find = Db::name('store_product')->where('mer_id', $merId)->where('store_name', $datum['value']['store_name'])->find();
|
||||
$attr_one = explode('|', $datum['value']['attr_one']);
|
||||
$attr_two = explode('|', $datum['value']['attr_two']);
|
||||
$attr=[];
|
||||
$arr = [];
|
||||
foreach ($attr_one as $key => $value){
|
||||
$attr[$value]=$attr_two[$key];
|
||||
$arr[] = [
|
||||
'value' => $value,
|
||||
'detail' => [$attr_two[$key] ?? []],
|
||||
'inputVisible' => false
|
||||
];
|
||||
}
|
||||
$array_values=array_values($attr);
|
||||
if ($find) {
|
||||
$store_product_attr_value = Db::name('store_product_attr_value')->where('product_id', $find['product_id'])->where('bar_code', $datum['value']['bar_code'])->find();
|
||||
if ($store_product_attr_value) {
|
||||
Log::error('xls导入商品:已经导入过该规格了');
|
||||
return false;
|
||||
continue;
|
||||
}
|
||||
foreach ($attr_one as $kk => $vv) {
|
||||
$is_update=false;
|
||||
foreach ($attr as $kk => $vv) {
|
||||
|
||||
/**查询当前规格是否存在 */
|
||||
$attr_values_find = Db::name('store_product_attr')->where('product_id', $find['product_id'])->where('attr_name', $kk)
|
||||
->find();
|
||||
@ -2536,31 +2548,29 @@ class StoreOrderRepository extends BaseRepository
|
||||
$attr_values= $attr_values_find['attr_values'];
|
||||
$attr_values = explode('-!-', $attr_values);
|
||||
if (!in_array($vv, $attr_values)) {
|
||||
$attr_values[] = $vv;
|
||||
$attr_values = implode('-!-', $attr_values);
|
||||
Db::name('store_product_attr')->where('product_id', $find['product_id'])->where('attr_name', $kk)->update(['attr_values' => $attr_values]);
|
||||
}
|
||||
$attr_values[] = $vv;
|
||||
$attr_values = implode('-!-', $attr_values);
|
||||
Db::name('store_product_attr')->where('product_id', $find['product_id'])->where('attr_name', $kk)->update(['attr_values' => $attr_values]);
|
||||
$this->create_product_attr_value($find,$datum,$product_type,$attr,$merId,implode(',',$array_values));
|
||||
}
|
||||
$is_update=true;
|
||||
} else {
|
||||
$attr_values = $vv;
|
||||
|
||||
Db::name('store_product_attr')->insert(
|
||||
[
|
||||
'product_id' => $exist['product_id'],
|
||||
'attr_name' => $kk, 'attr_values' => $attr_values
|
||||
]
|
||||
);
|
||||
$datas=[
|
||||
'product_id' => $find['product_id'],
|
||||
'attr_name' => $kk, 'attr_values' => $vv,
|
||||
];
|
||||
Db::name('store_product_attr')->insert($datas);
|
||||
}
|
||||
}
|
||||
$attrValue['stock'] = 1;
|
||||
$unique = app(ProductRepository::class)->setUnique($find['product_id'], $datum['value']['bar_code'], $product_type);
|
||||
$attrValue['unique'] = $unique;
|
||||
$attrValue['detail'] = json_encode($attrValue['detail']);
|
||||
$attrValue['product_id'] = $find['product_id'];
|
||||
$attrValue['mer_id'] = $merId;
|
||||
Db::name('store_product_attr_value')->insert($attrValue);
|
||||
if($is_update==false){
|
||||
$this->create_product_attr_value($find,$datum,$product_type,$attr,$merId,implode(',',$array_values));
|
||||
}
|
||||
|
||||
} else {
|
||||
$cate_id = 0;
|
||||
$spec_type = 0;
|
||||
$spec_type = 1;
|
||||
$detail = $attr;
|
||||
|
||||
$cate_id_one = Db::name('store_category')->where('mer_id', 0)->where('cate_name', $datum['value']['cate_id_one'])->value('store_category_id');
|
||||
if ($cate_id_one) {
|
||||
$cate_id_two = Db::name('store_category')->where('mer_id', 0)->where('cate_name', $datum['value']['cate_id_two'])->value('store_category_id');
|
||||
@ -2568,14 +2578,7 @@ class StoreOrderRepository extends BaseRepository
|
||||
$cate_id = $cate_id_two;
|
||||
}
|
||||
}
|
||||
foreach ($attr_one as $k => $v) {
|
||||
$arr[] = [
|
||||
'value' => $v,
|
||||
'detail' => [$attr_two[$k] ?? []],
|
||||
'inputVisible' => false
|
||||
];
|
||||
$spec_type = 1;
|
||||
}
|
||||
|
||||
$datas = [
|
||||
"image" => "https://lihai001.oss-cn-chengdu.aliyuncs.com/public/kk/luzhou/static4/oa_app/23565656.png",
|
||||
"slider_image" => [
|
||||
@ -2627,6 +2630,7 @@ class StoreOrderRepository extends BaseRepository
|
||||
"bar_code" => (int)$datum['value']['bar_code'],
|
||||
"weight" => 0,
|
||||
"volume" => 0,
|
||||
"detail" => $detail,
|
||||
],
|
||||
],
|
||||
"give_coupon_ids" => [],
|
||||
@ -2645,13 +2649,27 @@ class StoreOrderRepository extends BaseRepository
|
||||
];
|
||||
$make = app()->make(ProductRepository::class);
|
||||
$id = $make->create($datas, 98);
|
||||
halt($id);
|
||||
Queue::push(ProductImportJob::class, $data_list);
|
||||
// Queue::push(ProductImportJob::class, $data_list);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public function create_product_attr_value($find,$datum,$product_type,$attr_values,$merId,$sku){
|
||||
$attrValue['stock'] = 1;
|
||||
$unique = app(ProductRepository::class)->setUnique($find['product_id'], $datum['value']['bar_code'], $product_type);
|
||||
$attrValue['unique'] = $unique;
|
||||
$attrValue['detail'] = json_encode($attr_values);
|
||||
$attrValue['product_id'] = $find['product_id'];
|
||||
$attrValue['mer_id'] = $merId;
|
||||
$attrValue['sku'] = $sku;
|
||||
$attrValue['cost'] = $datum['value']['cost'];
|
||||
$attrValue['ot_price'] =$datum['value']['price'];
|
||||
$attrValue['price'] = $datum['value']['price'];
|
||||
$attrValue['procure_price'] = $datum['value']['procure_price'];
|
||||
$attrValue["image"] = "https://lihai001.oss-cn-chengdu.aliyuncs.com/public/kk/luzhou/static4/oa_app/23565656.png";
|
||||
Db::name('store_product_attr_value')->insert($attrValue);
|
||||
}
|
||||
/**
|
||||
* 订单结算
|
||||
* @param $id
|
||||
|
@ -275,7 +275,7 @@ class MerchantIntention extends BaseController
|
||||
if ($adminRepository->fieldExists('account', $data['phone']))
|
||||
throw new ValidateException('手机号已是管理员,不可申请');
|
||||
$data['create_time'] = date('Y-m-d H:i:s', time());
|
||||
$this->repository->updateIntention((int)$id, $data);
|
||||
$updateIntention=$this->repository->updateIntention((int)$id, $data);
|
||||
SwooleTaskService::admin('notice', [
|
||||
'type' => 'new_intention',
|
||||
'data' => [
|
||||
@ -308,7 +308,11 @@ class MerchantIntention extends BaseController
|
||||
if (!$res['ok']) {
|
||||
throw new ValidateException('供销平台申请商户入驻失败,' . $res['msg']);
|
||||
}
|
||||
return app('json')->success('修改成功');
|
||||
if($updateIntention){
|
||||
return app('json')->success('修改成功');
|
||||
}else{
|
||||
return app('json')->success('修改失败');
|
||||
}
|
||||
}
|
||||
|
||||
public function lst()
|
||||
|
@ -188,7 +188,31 @@ class StoreImport extends BaseController
|
||||
];
|
||||
app()->make(StoreOrderRepository::class)->setProduct($data['data'],$data['mer_id']);
|
||||
}else{
|
||||
|
||||
$check =[
|
||||
'A1'=>'商品名称(必填)',
|
||||
'B1'=>'平台一级类目(必填)',
|
||||
'C1'=>'平台二级类目(必填)',
|
||||
'D1'=>'店铺一级商品分类',
|
||||
'E1'=>'店铺二级商品分类',
|
||||
'F1'=>'规格组',
|
||||
'G1'=>'规格值',
|
||||
'H1'=>'销售单位',
|
||||
'I1'=>'零售价(必填)',
|
||||
'J1'=>'成本价',
|
||||
'K1'=>'商品条码',
|
||||
'L1'=>'商品品牌',
|
||||
];
|
||||
SpreadsheetExcelService::instance()->checkImport($path,$check);
|
||||
$data = [
|
||||
'mer_id' => $this->request->merId(),
|
||||
'data' => [
|
||||
'path' => $path,
|
||||
'sql' => ['store_name' => 'A', 'cate_id_one' => 'B', 'cate_id_two' => 'C', 'cate_id_one_mer' => 'D', 'cate_id_one_two' => 'E',
|
||||
'attr_one' => 'F', 'attr_two' => 'G', 'unit_name' => 'H', 'price' => 'I','cost'=>'J','bar_code'=>'K','brand_id'=>'L'],
|
||||
'where' => ['bar_code' => 'K'],
|
||||
]
|
||||
];
|
||||
app()->make(StoreOrderRepository::class)->setProduct($data['data'],$data['mer_id']);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user