|
@@ -26,7 +26,7 @@ class ShopHotel extends Api
|
|
|
select: ['id','invite_id','user_id','name','image','images','back_rate','address']
|
|
|
);
|
|
|
if (!$info){
|
|
|
- return $this->success('未开通门店');
|
|
|
+ return $this->error('未开通门店');
|
|
|
}
|
|
|
// 待核销金额
|
|
|
$wait_use = Db::name('bill')->where(['shop_id'=>$info['id'],'table_name'=>'hotel_order','status'=>2])->field('sum(total_amount - back_amount) as money')->find();
|
|
@@ -65,7 +65,7 @@ class ShopHotel extends Api
|
|
|
select: ['id','invite_id','user_id','name','image','images','back_rate','address']
|
|
|
);
|
|
|
if (!$info){
|
|
|
- return $this->success('未开通门店');
|
|
|
+ return $this->error('未开通门店');
|
|
|
}
|
|
|
switch ($params['type']){
|
|
|
case 1:
|
|
@@ -109,4 +109,58 @@ class ShopHotel extends Api
|
|
|
'num' => $used['num'] ?? 0,
|
|
|
]);
|
|
|
}
|
|
|
+
|
|
|
+ // 趋势图
|
|
|
+ public function trend()
|
|
|
+ {
|
|
|
+ $user_id = $this->auth->id;
|
|
|
+
|
|
|
+ $model = new HotelModel();
|
|
|
+ $info = $model->getDetail(
|
|
|
+ params: ['user_id' => $user_id],
|
|
|
+ select: ['id','invite_id','user_id','name','image','images','back_rate','address']
|
|
|
+ );
|
|
|
+ if (!$info){
|
|
|
+ return $this->error('未开通门店');
|
|
|
+ }
|
|
|
+
|
|
|
+ // 七日数据走势统计
|
|
|
+ $createtimeBetween = [
|
|
|
+ strtotime(date('Y-m-d 00:00:00', strtotime('-6 day'))),
|
|
|
+ strtotime(date('Y-m-d 23:59:59')),
|
|
|
+ ];
|
|
|
+ $dates = [];
|
|
|
+ for ($i = 6; $i >= 0; $i--){
|
|
|
+ $dates[] = date('Y-m-d', strtotime('-'.$i.' day'));
|
|
|
+ }
|
|
|
+
|
|
|
+ $wait_use = Db::name('bill')
|
|
|
+ ->field('DATE(FROM_UNIXTIME(createtime)) as order_date,sum(total_amount - back_amount) as money,count(id) as num')
|
|
|
+ ->where(['shop_id'=>$info['id'],'table_name'=>'hotel_order'])
|
|
|
+ ->whereIn('status',[1,2,3])
|
|
|
+ ->whereBetween('createtime',$createtimeBetween)
|
|
|
+ ->group('order_date')
|
|
|
+ ->order('order_date','asc')
|
|
|
+ ->select();
|
|
|
+
|
|
|
+ $num = [];
|
|
|
+ $money = [];
|
|
|
+ foreach ($dates as $key=>$date){
|
|
|
+ $num[$key] = 0;
|
|
|
+ $money[$key] = '0';
|
|
|
+ foreach ($wait_use as $k=>$v){
|
|
|
+ if ($date == $v['order_date']){
|
|
|
+ $num[$key] = $v['num'];
|
|
|
+ $money[$key] = $v['money'];
|
|
|
+ }
|
|
|
+ }
|
|
|
+ $dates[$key] = date('m/d',strtotime($date));
|
|
|
+ }
|
|
|
+
|
|
|
+ return $this->success('success',[
|
|
|
+ 'money' => $money,
|
|
|
+ 'num' => $num,
|
|
|
+ 'dates' => $dates
|
|
|
+ ]);
|
|
|
+ }
|
|
|
}
|