['paid','status','is_writeoff'], 'between_time' => 'create_time', '%like%' => ['order_id'], ]; } /** * @notes 零售订单列表 * @return array * @throws \think\db\exception\DataNotFoundException * @throws \think\db\exception\DbException * @throws \think\db\exception\ModelNotFoundException * @date 2024/04/27 11:26 */ public function lists(): array { $userId=$this->request->userId; if(!$userId) return []; $data = StoreOrder::with(['store'])->where($this->searchWhere)->where('uid',$userId) ->limit($this->limitOffset, $this->limitLength) ->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_count']=count(explode(',',$item['cart_id'])); }) ->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; } /** * @notes 零售订单数量 * @return int * @date 2024/04/27 11:26 */ public function count(): int { $userId=$this->request->userId; return StoreOrder::where($this->searchWhere)->where('uid',$userId)->count(); } }