feat(CartController): 增加购物车商品起批发量判断和修改
This commit is contained in:
parent
7967f0b9cd
commit
84f39f0ac7
@ -25,7 +25,7 @@ class CartController extends BaseApiController
|
||||
$params = (new CartValidate())->post()->goCheck('add');
|
||||
$params['uid'] = $this->request->userId;
|
||||
$result = Cart::where(['uid' => $params['uid'], 'store_id' => $params['store_id'], 'product_id' => $params['product_id'], 'is_fail' => 0, 'is_pay' => 0, 'delete_time' => null])->find();
|
||||
|
||||
$params['cart_num']=bcadd($params['cart_num'],0,2);
|
||||
//判断起批发价
|
||||
$branchProduct = StoreBranchProduct::where(
|
||||
[
|
||||
@ -36,7 +36,6 @@ class CartController extends BaseApiController
|
||||
if (!$branchProduct) {
|
||||
return $this->fail('商品不存在');
|
||||
}
|
||||
$params['cart_num']=intval($params['cart_num']);
|
||||
if ($params['cart_num'] < $branchProduct['batch']) {
|
||||
return $this->fail('起批发量低于最低值' . $branchProduct['batch']);
|
||||
}
|
||||
@ -85,7 +84,19 @@ class CartController extends BaseApiController
|
||||
{
|
||||
$params = (new CartValidate())->post()->goCheck('change');
|
||||
$params['uid'] = $this->request->userId;
|
||||
$params['cart_num']=intval($params['cart_num']);
|
||||
$params['cart_num']=bcadd($params['cart_num'],0,2);
|
||||
if (convertNumber($params['cart_num']) === false) {
|
||||
$branchProduct = StoreBranchProduct::where(
|
||||
[
|
||||
'product_id' => $params['product_id'],
|
||||
'store_id' => $params['store_id']
|
||||
]
|
||||
)->find();
|
||||
$is_bulk = StoreProductUnit::where('id', $branchProduct['unit'])->value('is_bulk');
|
||||
if ($is_bulk == 0) {
|
||||
return $this->fail('非计量商品,不能有小数,请编辑购物车');
|
||||
}
|
||||
}
|
||||
$res = CartLogic::edit($params, 'dec');
|
||||
if ($res) {
|
||||
return $this->success('修改成功');
|
||||
|
@ -65,9 +65,9 @@ class CartList extends BaseAdminDataLists implements ListsSearchInterface, Lists
|
||||
->toArray();
|
||||
$off_activity = Config::where('name', 'off_activity')->value('value');
|
||||
$user_ship = User::where('id', $userId)->value('user_ship');
|
||||
$field = 'product_id,image,price,cost,store_name,unit,delete_time,vip_price,top_cate_id';
|
||||
$field = 'product_id,image,price,cost,store_name,unit,delete_time,vip_price,top_cate_id,batch';
|
||||
if (in_array($user_ship, [4, 6, 7])) {
|
||||
$field = 'product_id,image,cost price,cost,store_name,unit,delete_time,vip_price,top_cate_id';
|
||||
$field = 'product_id,image,cost price,cost,store_name,unit,delete_time,vip_price,top_cate_id,batch';
|
||||
}
|
||||
$this->user_ship = $user_ship;
|
||||
$this->off_activity = $off_activity;
|
||||
@ -84,6 +84,7 @@ class CartList extends BaseAdminDataLists implements ListsSearchInterface, Lists
|
||||
}
|
||||
$item['goods_total_price'] = bcmul($item['cart_num'], $find['price'], 2);
|
||||
$this->total_price = bcadd($this->total_price, $item['goods_total_price'], 2);
|
||||
$item['batch'] = $find['batch'];
|
||||
$item['imgs'] = $find['image'];
|
||||
$item['price'] = $find['price'];
|
||||
$item['cost'] = $find['cost'];
|
||||
|
Loading…
x
Reference in New Issue
Block a user