feat(OrderList): 修改订单列表逻辑,重构商品信息获取与展示方式
This commit is contained in:
parent
9d2d78881a
commit
909e66b1f3
@ -5,6 +5,7 @@ namespace app\api\lists\order;
|
||||
|
||||
use app\admin\lists\BaseAdminDataLists;
|
||||
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_unit\StoreProductUnit;
|
||||
@ -50,23 +51,25 @@ class OrderList extends BaseAdminDataLists implements ListsSearchInterface
|
||||
->order(['id' => 'desc'])
|
||||
->select()
|
||||
->each(function ($item) {
|
||||
$item['goods_list']=StoreOrderCartInfo::where('oid',$item['id'])->with(['goodsName'=> function ($query) {
|
||||
$query->withTrashed();
|
||||
}])->field('product_id,cart_num,verify_code,is_writeoff,writeoff_time,old_cart_id')->limit(3)->select();
|
||||
$item['goods_list'] = StoreOrderCartInfo::where('oid', $item['id'])
|
||||
->field('product_id,cart_num,verify_code,is_writeoff,writeoff_time,old_cart_id')->limit(3)->select()
|
||||
->each(function ($v) use ($item) {
|
||||
$find = StoreBranchProduct::where('product_id', $v['product_id'])->where('store_id', $item['store_id'])->find();
|
||||
$v['store_name'] = $find['store_name'];
|
||||
$v['image'] = $find['image'];
|
||||
$v['price'] = $find['price'];
|
||||
$v['unit_name'] = StoreProductUnit::where('id', $find['unit'])->value('name') ?? '';
|
||||
});
|
||||
$item['goods_count'] = count(explode(',', $item['cart_id']));
|
||||
if ($item['refund_reason_time']) {
|
||||
$item['refund_reason_time'] = date('Y-m-d H:i:s', $item['refund_reason_time']);
|
||||
}
|
||||
if ($item['pay_time']) {
|
||||
$item['pay_time'] = date('Y-m-d H:i:s', $item['pay_time']);
|
||||
}
|
||||
})
|
||||
->toArray();
|
||||
foreach ($data as &$value){
|
||||
if($value['refund_reason_time']){
|
||||
$value['refund_reason_time'] = date('Y-m-d H:i:s',$value['refund_reason_time']);
|
||||
}
|
||||
if($value['pay_time']){
|
||||
$value['pay_time'] = date('Y-m-d H:i:s',$value['pay_time']);
|
||||
}
|
||||
foreach ($value['goods_list'] as &$vv){
|
||||
$vv['unit'] =StoreProductUnit::where('id',$vv['unit'])->value('name')??'';
|
||||
}
|
||||
}
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
@ -81,5 +84,4 @@ class OrderList extends BaseAdminDataLists implements ListsSearchInterface
|
||||
$userId = $this->request->userId;
|
||||
return StoreOrder::where($this->searchWhere)->where('uid', $userId)->count();
|
||||
}
|
||||
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user