repository = $repository; $this->areaCode = $this->request->param('areaCode', ''); $this->streetCode = $this->request->param('streetCode', ''); if ($this->areaCode == '' && $this->streetCode == '') { throw new ValidateException('请选择地区'); } } public function currOrderInfo() { try { // 今日订单数 $currOrderCountQuery = Db::name('store_order')->alias('o') ->field(['o.order_sn', 'o.real_name', 'o.user_phone', 'o.user_address', 'o.user_address_code', 'p.store_name', 'm.mer_name', 'o.create_time', 'o.status']) ->leftJoin('product_order_log og', 'o.order_id = og.order_id') ->leftJoin('merchant m', 'o.mer_id = m.mer_id') ->leftJoin('store_order_product op', 'o.order_id = op.order_id') ->leftJoin('product_library p', 'op.product_id = p.id') ->whereDay('og.create_time', '2023-11-29') ->where('o.paid', 1) ->whereNotNull('o.pay_time'); if ($this->areaCode != '') { $currOrderCountQuery->where('og.district_code', $this->areaCode); } if ($this->streetCode != '') { $currOrderCountQuery->where('og.street_code', $this->streetCode); } $currOrderCount = $currOrderCountQuery->count(); [$page, $limit] = $this->getPage(); $client = new \GuzzleHttp\Client(); // 今日订单列表 $currOrderList = $currOrderCountQuery->page($page, $limit)->select()->toArray(); foreach ($currOrderList as $k => $order) { $getUrl = env('LOGISTICS_HOST_URL') . '/api/courierData?order_sn=' . $order['order_sn']; $response = $client->request('GET', $getUrl); $courierData = json_decode($response->getBody(), true); $currOrderList[$k]['courier'] = $courierData['data']['courier_name']; } return app('json')->success(compact('currOrderCount', 'currOrderList')); } catch (ValidateException $e) { throw new ValidateException($e->getMessage()); } } }