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

增加订单数量接口

... ... @@ -405,6 +405,7 @@ class Cars extends Api
}else{
$where2 = [];
}
//普通商品
$where1['bg_id'] = ['in',$goods_id_s];
$where1['type'] = $type[2];
... ...
... ... @@ -244,6 +244,18 @@ class Common
}
/**
* 查询总数(软删除)
* @ApiInternal
*/
public static function countSoftTotal($table,$where){
$count = Db::name($table)
->where($where)
->useSoftDelete('deletetime')
->count();
return $count;
}
/**
* 商品列表
* @ApiInternal
*/
... ...
... ... @@ -23,6 +23,46 @@ class Orders extends Api
}
/**
* @ApiTitle (我的订单状态数量)
* @ApiSummary (我的订单状态数量)
* @ApiMethod (GET)
* @ApiRoute (/api/orders/myOrderTotal)
* @ApiHeaders (name=token, type=string, required=true, description="请求的Token")
*
* @ApiReturn({
"code": 1,
"msg": "成功",
"time": "1575700114",
"data": {
"total": 1,//待付款
"total1": 0,//待发货
"total2": 0,//待收货
"total3": 1,//已完成
"total4": 1//退换货
}
})
*/
public function myOrderTotal(){
if($this->request->isGet()){
$arr = [];
$status = $this->order_status;
//待付款
$arr['total'] = Common::countSoftTotal('order',['uid'=>$this->uid,'status'=>$status[0]]);
//待发货
$arr['total1'] = Common::countSoftTotal('order',['uid'=>$this->uid,'status'=>$status[2]]);
//待收货
$arr['total2'] = Common::countSoftTotal('order',['uid'=>$this->uid,'status'=>$status[5]]);
//已完成
$arr['total3'] = Common::countSoftTotal('order',['uid'=>$this->uid,'status'=>$status[8]]);
//退换货
$arr['total4'] = Common::countSoftTotal('order',['uid'=>$this->uid,'status'=>['in',[6,7]]]);
$this->success('成功',$arr);
}else{
$this->error('请求方式错误');
}
}
/**
* @ApiTitle (我的订单)
* @ApiSummary (我的订单)
* @ApiMethod (GET)
... ...
... ... @@ -248,12 +248,11 @@ return [
//结算商品可使用优惠券
'settle_use_coupon' => [
'rule' => [
'goods_id' => 'require|number',
'goods_id' => 'require',
'total_goods_price' => 'require|number',
],
'msg' => [
'goods_id.require' => '商品id不能为空',
'goods_id.number' => '商品id必须为数字',
'total_goods_price.require' => '商品总金额不能为空',
'total_goods_price.number' => '商品总金额必须为数字',
]
... ...
此 diff 太大无法显示。