feat(CartList): 修改购物车列表逻辑,支持商品成本计算与库存管理
This commit is contained in:
parent
5527ec60dd
commit
1fd77a396b
@ -7,6 +7,7 @@ use app\admin\lists\BaseAdminDataLists;
|
||||
use app\common\lists\ListsSearchInterface;
|
||||
use app\common\model\order\Cart;
|
||||
use app\common\lists\ListsExtendInterface;
|
||||
use app\common\model\dict\DictType;
|
||||
use app\common\model\store_branch_product\StoreBranchProduct;
|
||||
use app\common\model\store_product_attr_value\StoreProductAttrValue;
|
||||
use app\common\model\store_product_unit\StoreProductUnit;
|
||||
@ -57,11 +58,15 @@ class CartList extends BaseAdminDataLists implements ListsSearchInterface, Lists
|
||||
return $item;
|
||||
})
|
||||
->toArray();
|
||||
$check = DictType::where('type', 'activities')->find();
|
||||
|
||||
foreach ($list as $key => &$item) {
|
||||
$find = StoreBranchProduct::where(['id' => $item['product_id']])
|
||||
->field('product_id,image,price,store_name,unit')
|
||||
->field('product_id,image,price,cost,store_name,unit')
|
||||
->find();
|
||||
if (isset($check) && $check['status'] == 1) {
|
||||
$find['price'] = $find['cost'];
|
||||
}
|
||||
if ($find) {
|
||||
$item['goods_total_price'] = bcmul($item['cart_num'], $find['price'], 2);
|
||||
$this->total_price = bcadd($this->total_price, $item['goods_total_price'], 2);
|
||||
@ -69,9 +74,7 @@ class CartList extends BaseAdminDataLists implements ListsSearchInterface, Lists
|
||||
$item['sell'] = $find['price'];
|
||||
$item['goods_name'] = $find['store_name'];
|
||||
$item['unit_name'] = StoreProductUnit::where('id', $find['unit'])->value('name');
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
return $list;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user