修改切换店铺的逻辑和查询的逻辑

This commit is contained in:
liu 2024-07-02 10:43:53 +08:00
parent 08f6eedff4
commit 54844d161e
2 changed files with 9 additions and 2 deletions

View File

@ -8,6 +8,7 @@ use app\common\lists\ListsSearchInterface;
use app\common\model\store_branch_product\StoreBranchProduct;
use app\common\model\store_order\StoreOrder;
use app\common\model\store_order_cart_info\StoreOrderCartInfo;
use app\common\model\store_product\StoreProduct;
use app\common\model\store_product_unit\StoreProductUnit;
/**
@ -56,6 +57,9 @@ class OrderList extends BaseAdminDataLists implements ListsSearchInterface
->field('product_id,cart_num,verify_code,is_writeoff,writeoff_time,old_cart_id,cart_info')->limit(3)->select()
->each(function ($v) use ($item) {
$find = StoreBranchProduct::where('product_id', $v['product_id'])->where('store_id', $item['store_id'])->withTrashed()->find();
if(empty($find)){
$find = StoreProduct::where('id', $v['product_id'])->withTrashed()->find();
}
$v['store_name'] = $find['store_name'];
$v['image'] = $find['image'];
// $v['price'] = $find['price'];

View File

@ -82,8 +82,11 @@ class OrderLogic extends BaseLogic
foreach ($cart_select as $k => $v) {
$find = StoreBranchProduct::where(['product_id' => $v['product_id'], 'store_id' => $params['store_id']])->field($field)->withTrashed()->find();
if (!$find) {
unset($cart_select[$k]);
continue;
// unset($cart_select[$k]);
// continue;
$field = 'id branch_product_id,store_name,image,unit,price,vip_price,cost,purchase, id product_id';
$find = StoreProduct::where(['id' => $v['product_id']])->field($field)->withTrashed()->find();
$cart_select[$k]['status'] = 1;//缺货标识
}
unset($cart_select[$k]['id']);
$cart_select[$k]['total_price'] = bcmul($v['cart_num'], $find['price'], 2); //订单总价