更新发布商品数量

This commit is contained in:
yaooo 2023-09-27 16:44:17 +08:00
parent 3f23292dc7
commit 35285c3e8f
2 changed files with 12 additions and 2 deletions

View File

@ -69,7 +69,7 @@ class ProductRepository extends BaseRepository
protected $dao;
const CREATE_PARAMS = [
"image", "slider_image", "store_name", "store_info", "keyword", "bar_code", "guarantee_template_id", "cate_id", "mer_cate_id", "unit_name", "sort" , "is_show", "is_good", 'is_gift_bag', 'integral_rate', "video_link", "temp_id", "content", "spec_type", "extension_type", "attr", 'mer_labels', 'delivery_way', 'delivery_free','param_temp_id','extend', 'source_product_id',
"image", "slider_image", "store_name", "store_info", "keyword", "bar_code", "guarantee_template_id", "cate_id", "mer_cate_id", "unit_name", "sort" , "is_show", "is_good", 'is_gift_bag', 'integral_rate', "video_link", "temp_id", "content", "spec_type", "extension_type", "attr", 'mer_labels', 'delivery_way', 'delivery_free','param_temp_id','extend', 'source_product_id', 'stock_num',
["brand_id",0],
['once_max_count',0],
['once_min_count',0],

View File

@ -83,6 +83,8 @@ class StoreProduct extends BaseController
{
$res = $this->request->params($this->repository::CREATE_PARAMS);
$data = $this->repository->checkParams($res,$merId);
$stockNum = $data['stock_num'] ?? 0;
unset($data['stock_num']);
$data['mer_id'] = $merId;
$data['is_gift_bag'] = 0;
$merchant = app()->make(MerchantRepository::class)->get($merId);
@ -96,7 +98,15 @@ class StoreProduct extends BaseController
}else{
$product_type=0;//普通商品
}
$this->repository->create($data, $product_type, 1);
$productId = $this->repository->create($data, $product_type, 1);
$unique = Db::name('store_product_attr_value')->where('product_id', $productId)->value('unique');
if (!empty($unique) && $stockNum > 0) {
$this->repository->stockIn($merId, [
'product_id' => $productId,
'unique' => $unique,
'number' => $stockNum,
]);
}
return app('json')->success('添加成功');
}