作者 李忠强

更新

... ... @@ -4,6 +4,8 @@
namespace app\api\controller;
use app\api\model\GoodsSpec;
use app\api\model\SpecValue;
use app\common\controller\Api;
/**
... ... @@ -86,4 +88,44 @@ class Cart extends Api
->select();
$this->success('SUCCESS',$list);
}
/**
* @ApiTitle (价格计算)
* @ApiSummary ([{goods_id:22 goods_sku_id:106 number:2} {goods_id:23 goods_sku_id:66 number:2}])
* @ApiMethod (POST)
* @ApiHeaders (name=token, type=string, required=true, description="请求的Token")
* @ApiParams (name="data_json", type="string", required=true, description="下单的商品json数据")
* @ApiParams (name="goods_id", type="integer", required=false, description="商品id 此值不传 json数组注释用")
* @ApiParams (name="goods_sku_id", type="integer", required=false, description="规格id 此值不传 json数组注释用")
* @ApiParams (name="number", type="integer", required=false, description="购买数量 此值不传 json数组注释用")
* @ApiReturn ({
'code':'1',
'msg':'返回成功'
'data':
"price": "37574.00" 总价
})
*/
public function priceCalculation()
{
$json = $this->request->post('data_json');
if (!$json) $this->error('data_json参数不能为空');
// $json = '[{"goods_id":22,"goods_sku_id":106,"number":2},{"goods_id":23,"goods_sku_id":66,"number":2}]';
$data = json_decode($json,true);
$goodsmodel = new \app\api\model\Goods();
$skumodel = new GoodsSpec();
$sum_price = 0; //总价格
foreach ($data as $key => $value){
if (!is_numeric($value['goods_id']) || !is_numeric($value['goods_sku_id']) || !is_numeric($value['number'])){
$this->error('参数不合法');
}
$goods = $goodsmodel->where('goods_id',$value['goods_id'])->field('goods_id,goods_name,image,spec_type')->find();
if (!$goods) $this->error('商品不存在');
$sku = $skumodel->where('goods_spec_id',$value['goods_sku_id'])
->field('goods_spec_id,spec_sku_id,goods_price')->find();
if (!$sku) $this->error('商品规格不存在');
$sum_price = bcadd($sum_price,bcmul($sku['goods_price'],$value['number'],2),2);
}
$this->success('下单页详情',['price'=>$sum_price]);
}
}
\ No newline at end of file
... ...
... ... @@ -75,4 +75,71 @@ class Rider extends Api
});
$this->success('订单列表',$list);
}
/**
* @ApiTitle (骑手个人页面)
* @ApiMethod (POST)
* @ApiHeaders (name=token, type=string, required=true, description="请求的Token")
* @ApiReturn ({
'code':'1',
'msg':'返回成功'
'data':
"avatar": 头像,
"nickname": 昵称,
"money": 余额,
"today_price": 今日所得,
"seven_price": 七日所得,
"all_price": 历史所得,
"today_order": 今日订单数,
"seven_order": 七日订单数,
"all_order": 历史订单数,
})
*/
public function userIndex()
{
$data = [
'avatar' => cdnurl($this->auth->avatar,true),
'nickname' => $this->auth->nickname,
'money' => $this->auth->money
];
$model = new RiderOrder();
$todaytime = strtotime(date('Y-m-d',time()));
$seventime = $todaytime-86400*7;
$today = $model
->where('user_id',$this->auth->id)
->where('status','2')
->where('sendtime','>',$todaytime)
->sum('price');
$todaycount = $model
->where('user_id',$this->auth->id)
->where('status','2')
->where('sendtime','>',$todaytime)
->count();
$seven = $model
->where('fa_rider_order.user_id',$this->auth->id)
->where('status','2')
->where('fa_rider_order.status','>',$seventime)
->sum('price');
$sevencount = $model
->where('fa_rider_order.user_id',$this->auth->id)
->where('status','2')
->where('fa_rider_order.status','>',$seventime)
->count();
$all = $model
->where('fa_rider_order.user_id',$this->auth->id)
->where('fa_rider_order.status','2')
->sum('price');
$allcount = $model
->where('fa_rider_order.user_id',$this->auth->id)
->where('fa_rider_order.status','2')
->count();
$data['today_price'] = $today;
$data['seven_price'] = $seven;
$data['all_price'] = $all;
$data['today_order'] = $todaycount;
$data['seven_order'] = $sevencount;
$data['all_order'] = $allcount;
$this->success('骑手个人页',$data);
}
}
\ No newline at end of file
... ...
... ... @@ -9,7 +9,7 @@ return [
/**
* CDN地址
*/
'cdnurl' => '',
'cdnurl' => 'http://temporaryfood.qiniu.broing.cn',
/**
* 文件保存格式
*/
... ...