From be301ec24a0b28cb832ebe41c8c221f69ffb2904 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=82=B9=E6=99=AF=E7=AB=8B?= Date: Tue, 9 Mar 2021 14:48:22 +0800 Subject: [PATCH] Update Order.php --- app/data/controller/api/auth/Order.php | 21 +++++++-------------- 1 file changed, 7 insertions(+), 14 deletions(-) diff --git a/app/data/controller/api/auth/Order.php b/app/data/controller/api/auth/Order.php index 01a25d9e2..6c7768069 100644 --- a/app/data/controller/api/auth/Order.php +++ b/app/data/controller/api/auth/Order.php @@ -65,17 +65,17 @@ class Order extends Auth if ($order['from'] > 0) { $map = ['id' => $order['from'], 'status' => 1]; $fromer = $this->app->db->name('DataUser')->where($map)->find(); - if (empty($fromer)) $this->error('未找到推荐人'); + if (empty($fromer)) $this->error('推荐人异常'); } foreach (explode('||', $rules) as $rule) { [$code, $spec, $count] = explode('@', $rule); // 商品信息检查 $goodsInfo = $this->app->db->name('ShopGoods')->where(['code' => $code, 'status' => 1, 'deleted' => 0])->find(); $goodsItem = $this->app->db->name('ShopGoodsItem')->where(['goods_code' => $code, 'goods_spec' => $spec, 'status' => 1])->find(); - if (empty($goodsInfo) || empty($goodsItem)) $this->error('商品数据查询异常'); + if (empty($goodsInfo) || empty($goodsItem)) $this->error('商品查询异常'); // 商品类型检查 if ($truckType < 0) $truckType = $goodsInfo['truck_type']; - if ($truckType !== $goodsInfo['truck_type']) $this->error('不能混合下单!'); + if ($truckType !== $goodsInfo['truck_type']) $this->error('不能混合下单'); // 限制购买数量 if (isset($goods['limit_max_num']) && $goods['limit_max_num'] > 0) { $map = [['a.status', 'in', [2, 3, 4, 5]], ['b.goods_code', '=', $goods['code']], ['a.uid', '=', $this->uuid]]; @@ -394,18 +394,15 @@ class Order extends Auth /** * 订单状态统计 - * @throws \think\db\exception\DataNotFoundException - * @throws \think\db\exception\DbException - * @throws \think\db\exception\ModelNotFoundException */ public function total() { $map = ['uid' => $this->uuid, 'deleted' => 0]; $data = ['t0' => 0, 't1' => 0, 't2' => 0, 't3' => 0, 't4' => 0, 't5' => 0]; - $query = $this->app->db->name('ShopOrder')->fieldRaw('status,count(1) count'); - $query->where($map)->group('status')->select()->each(function ($item) use (&$data) { + $query = $this->app->db->name('ShopOrder')->field('status,count(1) count'); + foreach ($query->where($map)->group('status')->cursor() as $item) { $data["t{$item['status']}"] = $item['count']; - }); + } $this->success('获取统计成功', $data); } @@ -415,10 +412,7 @@ class Order extends Auth public function track() { try { - $data = $this->_vali([ - 'code.require' => '快递不能为空', - 'number.require' => '单号不能为空', - ]); + $data = $this->_vali(['code.require' => '快递不能为空', 'number.require' => '单号不能为空']); $result = TruckService::instance()->query($data['code'], $data['number']); empty($result['code']) ? $this->error($result['info']) : $this->success('快递追踪信息', $result); } catch (HttpResponseException $exception) { @@ -427,5 +421,4 @@ class Order extends Auth $this->error($exception->getMessage()); } } - } \ No newline at end of file