更新库存

This commit is contained in:
yaooo 2023-09-28 09:32:31 +08:00
parent 0b6d5e236f
commit 878219bd7c
2 changed files with 10 additions and 15 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', 'stock_num', 'stock',
"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',
["brand_id",0],
['once_max_count',0],
['once_min_count',0],

View File

@ -83,11 +83,6 @@ 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']);
if (!empty($data['stock'])) {
unset($data['stock']);
}
$data['mer_id'] = $merId;
$data['is_gift_bag'] = 0;
$merchant = app()->make(MerchantRepository::class)->get($merId);
@ -101,15 +96,15 @@ class StoreProduct extends BaseController
}else{
$product_type=0;//普通商品
}
$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,
]);
}
// $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('添加成功');
}