Browse Source

酒店商家控制台

Panda 1 week ago
parent
commit
38f8ba24d2

+ 51 - 0
application/api/controller/shop/ShopHotel.php

@@ -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
+        ]);
+    }
+}

+ 8 - 0
application/common/model/HotelModel.php

@@ -19,6 +19,14 @@ class HotelModel extends BaseModel
     protected $updateTime = false;
     protected $deleteTime = false;
 
+    public function searchUserIdAttribute($query, $value, array $params)
+    {
+        if (empty($value)) {
+            return $query;
+        }
+        return $query->where('user_id', $value);
+    }
+
     public function getImageAttr($value, $data)
     {
         return cdnurl($value);