feat: 增加根据用户ID判断购物车商品是否参与活动的功能
This commit is contained in:
parent
02d488c296
commit
5835271186
@ -42,7 +42,6 @@ class CartList extends BaseAdminDataLists implements ListsSearchInterface, Lists
|
|||||||
*/
|
*/
|
||||||
public function lists($where = []): array
|
public function lists($where = []): array
|
||||||
{
|
{
|
||||||
$userId = $this->request->get('uid');
|
|
||||||
$where = [
|
$where = [
|
||||||
'staff_id' => $this->adminId,
|
'staff_id' => $this->adminId,
|
||||||
'is_pay' => 0
|
'is_pay' => 0
|
||||||
@ -55,9 +54,19 @@ class CartList extends BaseAdminDataLists implements ListsSearchInterface, Lists
|
|||||||
return $item;
|
return $item;
|
||||||
})
|
})
|
||||||
->toArray();
|
->toArray();
|
||||||
// $off_activity = Config::where('name', 'off_activity')->value('value');
|
$off_activity = Config::where('name', 'off_activity')->value('value');
|
||||||
$off_activity = 0;
|
$off_activity = 0;
|
||||||
$this->off_activity = $off_activity;
|
$this->off_activity = $off_activity;
|
||||||
|
$uid = 0;
|
||||||
|
if ($this->request->get('uid')) {
|
||||||
|
$uid = $this->request->get('uid');
|
||||||
|
}
|
||||||
|
if ($uid > 0) {
|
||||||
|
$user_ship = User::where('id', $uid)->value('user_ship');
|
||||||
|
if (in_array($user_ship, [4, 5, 6, 7])) {
|
||||||
|
$off_activity = 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
foreach ($list as $key => &$item) {
|
foreach ($list as $key => &$item) {
|
||||||
$find = StoreBranchProduct::where(['product_id' => $item['product_id'], 'store_id' => $item['store_id']])
|
$find = StoreBranchProduct::where(['product_id' => $item['product_id'], 'store_id' => $item['store_id']])
|
||||||
->field('product_id,image,price,cost,store_name,unit,delete_time,vip_price')
|
->field('product_id,image,price,cost,store_name,unit,delete_time,vip_price')
|
||||||
@ -65,10 +74,10 @@ class CartList extends BaseAdminDataLists implements ListsSearchInterface, Lists
|
|||||||
->find();
|
->find();
|
||||||
|
|
||||||
if ($find) {
|
if ($find) {
|
||||||
if($off_activity==1){
|
if ($off_activity == 1) {
|
||||||
$this->activity_price = bcadd(bcmul($find['cost'],$item['cart_num'], 2), $this->activity_price, 2);
|
$this->activity_price = bcadd(bcmul($find['cost'], $item['cart_num'], 2), $this->activity_price, 2);
|
||||||
$item['price'] = $find['cost'];
|
$item['price'] = $find['cost'];
|
||||||
}else{
|
} else {
|
||||||
$item['price'] = $find['price'];
|
$item['price'] = $find['price'];
|
||||||
}
|
}
|
||||||
$item['goods_total_price'] = bcmul($item['cart_num'], $find['price'], 2);
|
$item['goods_total_price'] = bcmul($item['cart_num'], $find['price'], 2);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user