feat: 增加根据用户ID判断购物车商品是否参与活动的功能

This commit is contained in:
mkm 2024-07-09 15:15:51 +08:00
parent 02d488c296
commit 5835271186

View File

@ -42,7 +42,6 @@ class CartList extends BaseAdminDataLists implements ListsSearchInterface, Lists
*/
public function lists($where = []): array
{
$userId = $this->request->get('uid');
$where = [
'staff_id' => $this->adminId,
'is_pay' => 0
@ -55,9 +54,19 @@ class CartList extends BaseAdminDataLists implements ListsSearchInterface, Lists
return $item;
})
->toArray();
// $off_activity = Config::where('name', 'off_activity')->value('value');
$off_activity = Config::where('name', 'off_activity')->value('value');
$off_activity = 0;
$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) {
$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')
@ -65,10 +74,10 @@ class CartList extends BaseAdminDataLists implements ListsSearchInterface, Lists
->find();
if ($find) {
if($off_activity==1){
$this->activity_price = bcadd(bcmul($find['cost'],$item['cart_num'], 2), $this->activity_price, 2);
if ($off_activity == 1) {
$this->activity_price = bcadd(bcmul($find['cost'], $item['cart_num'], 2), $this->activity_price, 2);
$item['price'] = $find['cost'];
}else{
} else {
$item['price'] = $find['price'];
}
$item['goods_total_price'] = bcmul($item['cart_num'], $find['price'], 2);