|
@@ -0,0 +1,51 @@
|
|
|
+<?php
|
|
|
+
|
|
|
+namespace app\api\controller\shop;
|
|
|
+
|
|
|
+use app\common\controller\Api;
|
|
|
+use app\common\model\HotelModel;
|
|
|
+use app\common\model\OfflineShopModel;
|
|
|
+use app\common\model\OfflineTypeModel;
|
|
|
+use app\utils\DataUtil;
|
|
|
+use think\Db;
|
|
|
+/**
|
|
|
+ * 示例接口
|
|
|
+ */
|
|
|
+class ShopHotel extends Api
|
|
|
+{
|
|
|
+ protected $noNeedLogin = [''];
|
|
|
+ protected $noNeedRight = ['*'];
|
|
|
+
|
|
|
+ public function home()
|
|
|
+ {
|
|
|
+ $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->success('未开通门店');
|
|
|
+ }
|
|
|
+ // 待核销金额
|
|
|
+ $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();
|
|
|
+
|
|
|
+ // 已核销
|
|
|
+ $used = Db::name('bill')->where(['shop_id'=>$info['id'],'table_name'=>'hotel_order','status'=>3])->field('sum(total_amount - back_amount) as money')->find();
|
|
|
+
|
|
|
+ // 已退款
|
|
|
+ $refund = Db::name('bill')->where(['shop_id'=>$info['id'],'table_name'=>'hotel_order','status'=>4])->field('sum(total_amount - back_amount) as money')->find();
|
|
|
+
|
|
|
+ $statistics = [
|
|
|
+ 'wait_use' => $wait_use['money'] ?? 0,
|
|
|
+ 'used' => $used['money'] ?? 0,
|
|
|
+ 'refund' => $refund['money'] ?? 0,
|
|
|
+ ];
|
|
|
+
|
|
|
+ return $this->success('success',[
|
|
|
+ 'info' => $info,
|
|
|
+ 'statistics' => $statistics
|
|
|
+ ]);
|
|
|
+ }
|
|
|
+}
|