作者 jinglong
1 个管道 的构建 通过 耗费 8 秒

增加订单数量接口

@@ -405,6 +405,7 @@ class Cars extends Api @@ -405,6 +405,7 @@ class Cars extends Api
405 }else{ 405 }else{
406 $where2 = []; 406 $where2 = [];
407 } 407 }
  408 +
408 //普通商品 409 //普通商品
409 $where1['bg_id'] = ['in',$goods_id_s]; 410 $where1['bg_id'] = ['in',$goods_id_s];
410 $where1['type'] = $type[2]; 411 $where1['type'] = $type[2];
@@ -244,6 +244,18 @@ class Common @@ -244,6 +244,18 @@ class Common
244 } 244 }
245 245
246 /** 246 /**
  247 + * 查询总数(软删除)
  248 + * @ApiInternal
  249 + */
  250 + public static function countSoftTotal($table,$where){
  251 + $count = Db::name($table)
  252 + ->where($where)
  253 + ->useSoftDelete('deletetime')
  254 + ->count();
  255 + return $count;
  256 + }
  257 +
  258 + /**
247 * 商品列表 259 * 商品列表
248 * @ApiInternal 260 * @ApiInternal
249 */ 261 */
@@ -23,6 +23,46 @@ class Orders extends Api @@ -23,6 +23,46 @@ class Orders extends Api
23 } 23 }
24 24
25 /** 25 /**
  26 + * @ApiTitle (我的订单状态数量)
  27 + * @ApiSummary (我的订单状态数量)
  28 + * @ApiMethod (GET)
  29 + * @ApiRoute (/api/orders/myOrderTotal)
  30 + * @ApiHeaders (name=token, type=string, required=true, description="请求的Token")
  31 + *
  32 + * @ApiReturn({
  33 + "code": 1,
  34 + "msg": "成功",
  35 + "time": "1575700114",
  36 + "data": {
  37 + "total": 1,//待付款
  38 + "total1": 0,//待发货
  39 + "total2": 0,//待收货
  40 + "total3": 1,//已完成
  41 + "total4": 1//退换货
  42 + }
  43 + })
  44 + */
  45 + public function myOrderTotal(){
  46 + if($this->request->isGet()){
  47 + $arr = [];
  48 + $status = $this->order_status;
  49 + //待付款
  50 + $arr['total'] = Common::countSoftTotal('order',['uid'=>$this->uid,'status'=>$status[0]]);
  51 + //待发货
  52 + $arr['total1'] = Common::countSoftTotal('order',['uid'=>$this->uid,'status'=>$status[2]]);
  53 + //待收货
  54 + $arr['total2'] = Common::countSoftTotal('order',['uid'=>$this->uid,'status'=>$status[5]]);
  55 + //已完成
  56 + $arr['total3'] = Common::countSoftTotal('order',['uid'=>$this->uid,'status'=>$status[8]]);
  57 + //退换货
  58 + $arr['total4'] = Common::countSoftTotal('order',['uid'=>$this->uid,'status'=>['in',[6,7]]]);
  59 + $this->success('成功',$arr);
  60 + }else{
  61 + $this->error('请求方式错误');
  62 + }
  63 + }
  64 +
  65 + /**
26 * @ApiTitle (我的订单) 66 * @ApiTitle (我的订单)
27 * @ApiSummary (我的订单) 67 * @ApiSummary (我的订单)
28 * @ApiMethod (GET) 68 * @ApiMethod (GET)
@@ -248,12 +248,11 @@ return [ @@ -248,12 +248,11 @@ return [
248 //结算商品可使用优惠券 248 //结算商品可使用优惠券
249 'settle_use_coupon' => [ 249 'settle_use_coupon' => [
250 'rule' => [ 250 'rule' => [
251 - 'goods_id' => 'require|number', 251 + 'goods_id' => 'require',
252 'total_goods_price' => 'require|number', 252 'total_goods_price' => 'require|number',
253 ], 253 ],
254 'msg' => [ 254 'msg' => [
255 'goods_id.require' => '商品id不能为空', 255 'goods_id.require' => '商品id不能为空',
256 - 'goods_id.number' => '商品id必须为数字',  
257 'total_goods_price.require' => '商品总金额不能为空', 256 'total_goods_price.require' => '商品总金额不能为空',
258 'total_goods_price.number' => '商品总金额必须为数字', 257 'total_goods_price.number' => '商品总金额必须为数字',
259 ] 258 ]
此 diff 太大无法显示。