Browse Source

fix:添加充值功能

geek 4 years ago
parent
commit
968ef7094d

+ 16 - 10
application/api/BaseController.php

@@ -57,17 +57,23 @@ abstract class BaseController {
         //$this->request['Accept'] = 'application/json';
         Until::$startTime = time();
         $route = [
-            '/api/token/getToken',
-            '/api/index',
-            '/api/user/login',
-            '/api/user/save',
-            '/api/admin/login',
-            '/api/admin/verifyimg',
-            '/api/order/notifyorder',
-            '/api/product/typelist',
-            '/api/store/getstore',
-            '/api/product/index'
+            'token/getToken',
+            'index',
+            'user/login',
+            'user/save',
+            'admin/login',
+            'admin/verifyimg',
+            'order/notifyorder',
+            'product/typelist',
+            'store/getstore',
+            'product/index',
+            'Server/callService',
+            'Server/callList'
         ];
+        foreach ($route as &$rule){
+            $rule = '/api/'.strtolower($rule);
+        }
+        unset($rule);
         if (!in_array(strtolower($this->request->baseUrl()), $route)) {
             if (empty($this->request->header('token'))) {
                 throw new ApiException('token不为空');

+ 79 - 1
application/api/controller/Order.php

@@ -14,6 +14,7 @@ use app\api\model\BrandModel;
 use app\api\model\CartProductModel;
 use app\api\model\CartModel;
 use app\api\model\GroupModel;
+use app\api\model\OrderChangeModel;
 use app\api\model\OrderModel;
 use app\api\model\OrderProductModel;
 use app\api\model\OrderRoomModel;
@@ -562,7 +563,7 @@ class Order extends BaseController {
             (new OrderService())->notify($input['OrderNumber']);
             Until::output([]);
         }
-        //        (new OrderService())->notify($input['OrderNumber']);
+        (new OrderService())->notify($input['OrderNumber']);
         Until::output(['decode' => md5('ef17f532-4661-b07c-5346-65dfa304c0d8' . $input['OrderNumber']),
                        'encode' => $this->request->header('serchkey')]);
     }
@@ -851,4 +852,81 @@ class Order extends BaseController {
         $model::where(['id' => $input['cartId']])->update(['status' => 0]);
         Until::output();
     }
+
+    /**
+     * @OA\Post(path="/api/Order/editOrder",
+     *   tags={"订单管理"},
+     *   summary="修改订单信息",
+     *   @OA\Parameter(name="token", in="header", description="token", @OA\Schema(type="string")),
+     *   @OA\RequestBody(
+     *     @OA\MediaType(
+     *       mediaType="multipart/form-data",
+     *         @OA\Schema(
+     *           @OA\Property(description="订单id", property="orderId", type="integer", default="1"),
+     *           @OA\Property(description="订单金额", property="orderMoney", type="string", default="13.26"),
+     *           @OA\Property(description="技师", property="staffId", type="string", default="13.26"),
+     *           @OA\Property(description="旧服务项目id", property="oldProductId", type="string", default="13.26"),
+     *           @OA\Property(description="新服务项目id", property="newProductId", type="string", default="13.26"),
+     *           required={"orderId"})
+     *       )
+     *     ),
+     *   @OA\Response(response="200", description="请求成功")
+     * )
+     */
+    public function editOrder() {
+        $input = Until::getInput();
+        $rule = [
+            'orderId|订单id' => 'require',
+        ];
+        Until::check($rule, $input);
+        if (empty($input['orderMoney']) || empty($input['staffId']) || empty($input['oldProductId']) || empty($input['newProductId'])) {
+            throw new ApiException('修改信息不能为空');
+        }
+
+        $log = new OrderChangeModel();
+        $orderModel = new OrderModel();
+        if (!empty($input['orderMoney'])) {
+            try {
+                $log->startTrans();
+                $rs = $orderModel::where(['id' => $input['orderId']])->find();
+                $log->insertGetId([
+                    'order_id' => $input['orderId'],
+                    'change'   => 'orderMoney',
+                    'remark'   => "订单金额由{$rs['order_money']}修改为{$input['orderMoney']}",
+                    'admin_id' => Until::$adminId,
+                    'order_snap' => json_encode($rs)
+                ]);
+                $orderModel::where(['id' => $input['orderId']])->update(['order_money' => $input['orderMoney']]);
+                $log->commit();
+            }catch (\Exception $e) {
+                $log->rollback();
+                throw new ApiException($e->getMessage());
+            }
+        }
+
+
+        if (!empty($input['staffId'])) {
+            try {
+                $log->startTrans();
+                $rs = $orderModel::where(['id' => $input['orderId']])->find();
+                $log->insertGetId([
+                    'order_id' => $input['orderId'],
+                    'change'   => 'orderMoney',
+                    'remark'   => "订单由职员:{$rs['staffId']}修改为职员:{$input['staffId']}",
+                    'admin_id' => Until::$adminId,
+                    'order_snap' => json_encode($rs)
+                ]);
+                $orderModel::where(['id' => $input['orderId']])->update(['staff_id' => $input['staffId']]);
+                (new AllocateModel())::where(['order_id' => $input['orderId']])->update(['staff_id' => $input['staffId']]);
+                $log->commit();
+            }catch (\Exception $e) {
+                $log->rollback();
+                throw new ApiException($e->getMessage());
+            }
+        }
+
+
+        $data = (new OrderService())->payFoodOrder($input);
+        Until::output($data);
+    }
 }

+ 37 - 27
application/api/controller/Product.php

@@ -30,6 +30,7 @@ class Product extends BaseController {
      *   @OA\Parameter(name="status", in="query", description="状态 1正常 2删除", @OA\Schema(type="integer",default="1")),
      *   @OA\Parameter(name="name", in="query", description="产品名称", @OA\Schema(type="string")),
      *   @OA\Parameter(name="brandId", in="query", description="品牌id", @OA\Schema(type="integer")),
+     *   @OA\Parameter(name="storeId", in="query", description="门店id", @OA\Schema(type="integer")),
      *   @OA\Parameter(name="companyId", in="query", description="公司id", @OA\Schema(type="integer")),
      *   @OA\Parameter(name="productTypeId", in="query", description="产品类型id", @OA\Schema(type="integer")),
      *   @OA\Parameter(name="type", in="query", description="产品分类 1洗浴 2小食", @OA\Schema(type="integer")),
@@ -65,9 +66,9 @@ class Product extends BaseController {
         if (!empty($input['companyId'])) {
             $where[] = ['p.company_id', '=', "{$input['companyId']}"];
         }
-        //        if (!empty($input['storeId'])) {
-        //            $where[] = ['s.id', '=', "{$input['storeId']}"];
-        //        }
+        if (!empty($input['storeId'])) {
+            $where[] = ['spt.store_id', '=', "{$input['storeId']}"];
+        }
         if (!empty($input['productTypeId'])) {
             $where[] = ['pt.id', '=', $input['productTypeId']];
             $where[] = ['pt.status', '=', 1];
@@ -78,6 +79,9 @@ class Product extends BaseController {
         }
         $model->setWhere($where);
         $data = $model->getProductList();
+        foreach ($data['list'] as &$v) {
+            $v['current_price'] = $v['realPrice'];
+        }
         Until::output($data);
     }
 
@@ -103,17 +107,17 @@ class Product extends BaseController {
         $model->setPageSize($input['pageSize'] ?? 10);
         $where = [];
         if (!$this->isAdmin()) {
-            $where[] = ['status','=', 1];
-        }else {
+            $where[] = ['status', '=', 1];
+        } else {
             if (!empty($input['status'])) {
                 $where[] = ['status', '=', (int)$input['status'] - 1];
             }
         }
         if (!empty($input['type']) && $input['type'] == 2) {
-            $where[] = ['type','=', 2];
+            $where[] = ['type', '=', 2];
         }
         if (!empty($input['type']) && $input['type'] == 1) {
-            $where[] = ['type','=', 1];
+            $where[] = ['type', '=', 1];
         }
         $model->setWhere($where);
         $data = $model->getProductTypeList();
@@ -144,23 +148,23 @@ class Product extends BaseController {
     public function saveType() {
         $input = Until::getInput();
         $rule = [
-            'name|分类名称'           => 'require',
-            'imgUrl|产品分类图片'         => 'require',
+            'name|分类名称'     => 'require',
+            'imgUrl|产品分类图片' => 'require',
         ];
         Until::check($rule, $input);
         $model = new ProductTypeModel();
         if (!empty($input['id'])) {
             $id = (int)$input['id'];
             $model::where(['id' => $id])->update([
-                'product_type_name'    => $input['name'],
-                'product_type_img'     => $input['imgUrl'] ?? '',
-                'type'     => $input['type'] ?? 1,
+                'product_type_name' => $input['name'],
+                'product_type_img'  => $input['imgUrl'] ?? '',
+                'type'              => $input['type'] ?? 1,
             ]);
         } else {
             $model->insertGetId([
-                'product_type_name'    => $input['name'],
-                'product_type_img'     => $input['imgUrl'] ?? '',
-                'type' => $input['type'] ?? 1
+                'product_type_name' => $input['name'],
+                'product_type_img'  => $input['imgUrl'] ?? '',
+                'type'              => $input['type'] ?? 1
             ]);
         }
         Until::output(['isSuccess' => 1]);
@@ -181,8 +185,8 @@ class Product extends BaseController {
     public function deleteType() {
         $input = Until::getInput();
         $rule = [
-            'id'           => 'require',
-            'status'         => 'require',
+            'id'     => 'require',
+            'status' => 'require',
         ];
         Until::check($rule, $input);
         $model = new ProductTypeModel();
@@ -228,8 +232,8 @@ class Product extends BaseController {
             'companyId|公司id'      => 'require',
             'brandId|品牌id'        => 'require',
             'productContent|产品内容' => 'require',
-            'productTypeId|产品类型'    => 'require',
-            'time|产品时间'    => 'require'
+            'productTypeId|产品类型'  => 'require',
+            'time|产品时间'           => 'require'
         ];
         Until::check($rule, $input);
         $model = new ProductModel();
@@ -244,11 +248,11 @@ class Product extends BaseController {
                 'brand_id'        => $input['brandId'],
                 'product_content' => $input['productContent'],
                 'product_type_id' => $input['productTypeId'],
-                'time' => $input['time'],
+                'time'            => $input['time'],
                 'status'          => $input['status'] ?? 1,
             ]);
         } else {
-            $id = $model->insertGetId([
+            $model->insertGetId([
                 'product_name'    => $input['name'],
                 'product_img'     => $input['imgUrl'],
                 'old_price'       => $input['oldPrice'],
@@ -258,13 +262,11 @@ class Product extends BaseController {
                 'product_content' => $input['productContent'],
                 'status'          => $input['status'] ?? 1,
                 'product_type_id' => $input['productTypeId'],
-                'time' => $input['time'],
+                'time'            => $input['time'],
                 'type'            => $input['type'] ?? 1
             ]);
         }
-        $model->setWhere([['p.id', '=', (int)$id]]);
-        $info = $model->getProductInfo();
-        Until::output(['info' => $info]);
+        Until::output();
     }
 
     /**
@@ -273,14 +275,22 @@ class Product extends BaseController {
      *   summary="查看产品信息",
      *   @OA\Parameter(name="token", in="header", description="token", @OA\Schema(type="string")),
      *   @OA\Parameter(name="id", in="query", description="产品id", @OA\Schema(type="ineger",default="1")),
+     *   @OA\Parameter(name="storeId", in="query", description="门店id", @OA\Schema(type="ineger",default="1")),
      *   @OA\RequestBody(
      *     ),
      *   @OA\Response(response="200", description="请求成功")
      * )
      */
-    public function read($id) {
+    public function read() {
+        $input = Until::getInput();
+        $rule = [
+            'id|产品id'      => 'require',
+            'storeId|门店id' => 'require',
+        ];
+        Until::check($rule, $input);
         $model = new ProductModel();
-        $where[] = ['p.id', '=', (int)$id];
+        $where[] = ['p.id', '=', (int)$input['id']];
+        $where[] = ['spt.store_id', '=', (int)$input['storeId']];
         $model->setWhere($where);
         $info = $model->getProductInfo();
         Until::output(['info' => $info]);

+ 102 - 0
application/api/controller/ProductTemplate.php

@@ -0,0 +1,102 @@
+<?php
+/**
+ * Author: luzheng.liu
+ * Time: 2021/6/7 16:48
+ */
+
+namespace app\api\controller;
+
+
+use app\api\BaseController;
+use app\api\model\ProductTemplateModel;
+use app\common\until\Until;
+use think\Model;
+
+class ProductTemplate extends BaseController {
+
+
+
+    /**
+     * @OA\Post(path="/api/ProductTemplate/save",
+     *   tags={"产品模板管理"},
+     *   summary="保存模板信息(没有增加,有更新)",
+     *   @OA\Parameter(name="token", in="header", description="token", @OA\Schema(type="string")),
+     *   @OA\RequestBody(
+     *     @OA\MediaType(
+     *       mediaType="application/json",
+     *         @OA\Schema(
+     *          @OA\Property(property="list", type="array",
+     *              @OA\Items(type="object",
+     *                  @OA\Property(description="商品id", property="productId", type="integer", default="1"),
+     *                  @OA\Property(description="价格", property="price", type="string", default="199.90")
+     *          )),
+     *           @OA\Property(description="模板id", property="templateId", type="integer", default="1"),
+     *           required={"list","templateId"})
+     *       )
+     *     ),
+     *   @OA\Response(response="200", description="请求成功")
+     * )
+     */
+    public function save() {
+        $input = Until::getInput();
+        $rule = [
+            'list'            => 'require',
+            'templateId|模板id' => 'require',
+        ];
+        Until::check($rule, $input);
+        $model = new ProductTemplateModel();
+        foreach ($input['list'] as $v) {
+            if (empty($v['productId']) || empty($v['price'])) {
+                continue;
+            }
+            $info = $model::where(['product_id' => $v['productId'], 'template_id' => $input['templateId']])->find();
+            if ($info === null) {
+                $data = [
+                    'product_id'  => $v['productId'],
+                    'price'       => $v['price'],
+                    'template_id' => $input['templateId']
+                ];
+                $model->insertGetId($data);
+                Until::output();
+            }
+            $model::where(['id' => $info['id']])->update(['price' => $v['price']]);
+        }
+        Until::output();
+    }
+
+    /**
+     * @OA\Post(path="/api/ProductTemplate/delete",
+     *   tags={"产品模板管理"},
+     *   summary="删除模板里的产品",
+     *   @OA\Parameter(name="token", in="header", description="token", @OA\Schema(type="string")),
+     *   @OA\RequestBody(
+     *     @OA\MediaType(
+     *       mediaType="application/json",
+     *         @OA\Schema(
+     *          @OA\Property(property="list", type="array",
+     *              @OA\Items(type="object",
+     *                  @OA\Property(description="商品id", property="productId", type="integer", default="1"),
+     *          )),
+     *           @OA\Property(description="模板id", property="templateId", type="integer", default="1"),
+     *           required={"list","templateId"})
+     *       )
+     *     ),
+     *   @OA\Response(response="200", description="请求成功")
+     * )
+     */
+    public function delete() {
+        $input = Until::getInput();
+        $rule = [
+            'list'            => 'require',
+            'templateId|模板id' => 'require',
+        ];
+        Until::check($rule, $input);
+        $model = new ProductTemplateModel();
+        $pIdList = array_column($input['list'], 'productId');
+        $pIdList = array_values(array_filter(array_unique($pIdList)));
+        $model::where([['template_id', '=', $input['templateId']], ['product_id', 'in', $pIdList]])->delete();
+        Until::output();
+    }
+
+
+}

+ 131 - 0
application/api/controller/Server.php

@@ -0,0 +1,131 @@
+<?php
+/**
+ * Author: luzheng.liu
+ * Time: 2021/6/4 14:49
+ */
+
+namespace app\api\controller;
+
+
+use app\api\BaseController;
+use app\api\model\CallServiceModel;
+use app\common\until\Until;
+
+class Server extends BaseController {
+
+    /**
+     * @OA\Post(path="/api/Server/callService",
+     *   tags={"服务管理"},
+     *   summary="叫服务",
+     *   @OA\RequestBody(
+     *     @OA\MediaType(
+     *       mediaType="multipart/form-data",
+     *         @OA\Schema(
+     *           @OA\Property(description="服务类型 1、茶水;2、水果;3、加钟", property="type", type="integer"),
+     *           @OA\Property(description="房间号", property="roomId", type="integer"),
+     *           @OA\Property(description="门店id", property="storeId", type="integer"),
+     *           required={"type","roomId","storeId"})
+     *       )
+     *     ),
+     *   @OA\Response(response="200", description="请求成功")
+     * )
+     */
+    public function callService() {
+        $input = Until::getInput();
+        $rule = [
+            'type|服务类型' => 'require',
+            'roomId|房间号' => 'require',
+            'storeId|门店id' => 'require',
+        ];
+        Until::check($rule, $input);
+        $model = new CallServiceModel();
+        $callInfo = $model::where([
+            'store_id'     => $input['storeId'],
+            'room_id'      => $input['roomId'],
+            'server_type' => $input['type'],
+            'status' => CallServiceModel::NOT_DEAL
+        ])->find();
+        if (empty($callInfo)) {
+            $model->insertGetId([
+                'store_id'     => $input['storeId'],
+                'room_id'      => $input['roomId'],
+                'server_type' => $input['type'],
+                'call_num' => 1
+            ]);
+            Until::output();
+        }
+        $model::where(['id' => $callInfo['id']])->inc('call_num')->update();
+        Until::output();
+    }
+
+    /**
+     * @OA\Post(path="/api/Server/callList",
+     *   tags={"服务管理"},
+     *   summary="叫服务列表(轮询这个接口)",
+     *   @OA\Parameter(name="token", in="header", description="token", @OA\Schema(type="string")),
+     *   @OA\RequestBody(
+     *     @OA\MediaType(
+     *       mediaType="multipart/form-data",
+     *         @OA\Schema(
+     *           @OA\Property(description="房间号", property="roomId", type="integer"),
+     *           @OA\Property(description="门店id", property="storeId", type="integer"),
+     *           required={"storeId"})
+     *       )
+     *     ),
+     *   @OA\Response(response="200", description="请求成功")
+     * )
+     */
+    public function callList() {
+        $input = Until::getInput();
+        $rule = [
+//            'roomId|房间号' => 'require',
+            'storeId|门店id' => 'require',
+        ];
+        Until::check($rule, $input);
+        $model = new CallServiceModel();
+        $where[] = ['store_id', '=', $input['storeId']];
+        $where[] = ['status', '=', CallServiceModel::NOT_DEAL];
+        if (!empty($input['roomId'])) {
+            $where[] = ['room_id', '=', $input['roomId']];
+        }
+        $list = $model::where($where)->select();
+        Until::output(['list' => $list]);
+    }
+
+    /**
+     * @OA\Post(path="/api/Server/dealCall",
+     *   tags={"服务管理"},
+     *   summary="处理叫服务",
+     *    @OA\Parameter(name="token", in="header", description="token", @OA\Schema(type="string")),
+     *   @OA\RequestBody(
+     *     @OA\MediaType(
+     *       mediaType="multipart/form-data",
+     *         @OA\Schema(
+     *           @OA\Property(description="房间号", property="roomId", type="integer"),
+     *           @OA\Property(description="门店id", property="storeId", type="integer"),
+     *           @OA\Property(description="服务类型 1、茶水;2、水果;3、加钟", property="type", type="integer"),
+     *           required={"type","roomId","storeId"})
+     *       )
+     *     ),
+     *   @OA\Response(response="200", description="请求成功")
+     * )
+     */
+    public function dealCall() {
+        $input = Until::getInput();
+        $rule = [
+            'roomId|房间号' => 'require',
+            'storeId|门店id' => 'require',
+        ];
+        Until::check($rule, $input);
+        $model = new CallServiceModel();
+        $model::where([
+            'store_id'     => $input['storeId'],
+            'room_id'      => $input['roomId'],
+            'server_type' => $input['type'],
+        ])->update(['status' => CallServiceModel::DEAL]);
+        Until::output();
+    }
+
+
+    
+}

+ 81 - 0
application/api/controller/StoreTemplate.php

@@ -0,0 +1,81 @@
+<?php
+/**
+ * Author: luzheng.liu
+ * Time: 2021/6/8 17:48
+ */
+
+namespace app\api\controller;
+
+
+use app\api\BaseController;
+use app\api\model\StoreProductTemplateModel;
+use app\common\until\Until;
+use think\Model;
+
+class StoreTemplate extends BaseController {
+
+
+
+    /**
+     * @OA\Post(path="/api/StoreTemplate/save",
+     *   tags={"门店模板管理"},
+     *   summary="保存模板信息(没有增加,有更新)",
+     *   @OA\Parameter(name="token", in="header", description="token", @OA\Schema(type="string")),
+     *   @OA\RequestBody(
+     *     @OA\MediaType(
+     *       mediaType="multipart/form-data",
+     *         @OA\Schema(
+     *           @OA\Property(description="门店id", property="storeId", type="string", default="1"),
+     *           @OA\Property(description="模板id", property="templateId", type="string", default="1"),
+     *           required={"templateId","storeId"})
+     *       )
+     *     ),
+     *   @OA\Response(response="200", description="请求成功")
+     * )
+     */
+    public function save() {
+        $input = Until::getInput();
+        $rule = [
+            'storeId|门店id'    => 'require',
+            'templateId|模板id' => 'require',
+        ];
+        Until::check($rule, $input);
+        $model = new StoreProductTemplateModel();
+        $info = $model::where(['store_id' => $input['storeId'], 'template_id' => $input['templateId']])->find();
+        if ($info === null) {
+            $data = [
+                'store_id'    => $input['storeId'],
+                'template_id' => $input['templateId'],
+            ];
+            $model->insertGetId($data);
+            Until::output();
+        }
+        $model::where(['store_id' => $input['storeId']])->update(['template_id' => $input['templateId']]);
+        Until::output();
+    }
+
+    /**
+     * @OA\Get(path="/api/StoreTemplate/delete",
+     *   tags={"门店模板管理"},
+     *   summary="删除模板",
+     *   @OA\Parameter(name="token", in="header", description="token", @OA\Schema(type="string")),
+     *   @OA\Parameter(name="门店id", in="query", description="storeId", @OA\Schema(type="ineger",default="1")),
+     *   @OA\RequestBody(
+     *   ),
+     *   @OA\Response(response="200", description="请求成功")
+     * )
+     */
+    public function delete() {
+        $input = Until::getInput();
+        $rule = [
+            //            'templateId|模板id' => 'require',
+            'storeId|模板id' => 'require',
+        ];
+        Until::check($rule, $input);
+        $model = new StoreProductTemplateModel();
+        $model::where(['store_id' => $input['storeId']])->delete();
+        Until::output();
+    }
+
+
+}

+ 131 - 0
application/api/controller/Template.php

@@ -0,0 +1,131 @@
+<?php
+/**
+ * Author: luzheng.liu
+ * Time: 2021/6/7 17:58
+ */
+
+namespace app\api\controller;
+
+
+use app\api\model\ProductTemplateModel;
+use app\common\until\Until;
+use think\Model;
+
+class Template extends \app\api\BaseController {
+
+    /**
+     * @OA\Get(path="/api/Template/index",
+     *   tags={"模板管理"},
+     *   summary="模板列表",
+     *   @OA\Parameter(name="token", in="header", description="token", @OA\Schema(type="string")),
+     *   @OA\Parameter(name="page", in="query", description="页码", @OA\Schema(type="ineger",default="1")),
+     *   @OA\Parameter(name="pageSize", in="query", description="页尺寸", @OA\Schema(type="integer",default="10")),
+     *   @OA\Parameter(name="name", in="query", description="模板名字", @OA\Schema(type="integer",default="上海")),
+     *   @OA\RequestBody(
+     *   ),
+     *   @OA\Response(response="200", description="请求成功")
+     * )
+     */
+    public function index() {
+        $input = Until::getInput();
+        $model = new \app\api\model\Template();
+        $model->setPage($input['page'] ?? 1);
+        $model->setPageSize($input['pageSize'] ?? 10);
+        $where = [];
+        $model->setSortWhere('id');
+        $data = $model->getPageList($model);
+        Until::output($data);
+    }
+
+    /**
+     * @OA\Post(path="/api/Template/save",
+     *   tags={"模板管理"},
+     *   summary="保存模板信息(没有增加,有更新)",
+     *   @OA\Parameter(name="token", in="header", description="token", @OA\Schema(type="string")),
+     *   @OA\RequestBody(
+     *     @OA\MediaType(
+     *       mediaType="multipart/form-data",
+     *         @OA\Schema(
+     *           @OA\Property(description="模板介绍", property="desc", type="string", default="xxx"),
+     *           @OA\Property(description="模板名称", property="templateName", type="string", default="上海通用 "),
+     *           @OA\Property(description="模板id", property="templateId", type="string", default="上海通用 "),
+     *           required={"templateName"})
+     *       )
+     *     ),
+     *   @OA\Response(response="200", description="请求成功")
+     * )
+     */
+    public function save() {
+        $input = Until::getInput();
+        $rule = [
+            //            'desc|介绍'       => 'require',
+            'templateName|名称' => 'require',
+            //            'templateId|模板id'         => 'require',
+        ];
+        Until::check($rule, $input);
+        $model = new \app\api\model\Template();
+        if (empty($input['templateId'])) {
+            $data = [
+                'desc'          => $input['desc'] ?? '',
+                'template_name' => $input['templateName'],
+            ];
+            $model->insertGetId($data);
+            Until::output();
+        }
+        empty($input['desc']) ?: $updateData['desc'] = $input['desc'];
+        $updateData['template_name'] = $input['templateName'];
+        $model::where(['id' => $input['templateId']])->update($updateData);
+        Until::output();
+    }
+
+    /**
+     * @OA\Get(path="/api/Template/delete",
+     *   tags={"模板管理"},
+     *   summary="删除模板",
+     *   @OA\Parameter(name="token", in="header", description="token", @OA\Schema(type="string")),
+     *   @OA\Parameter(name="模板id", in="query", description="templateId", @OA\Schema(type="ineger",default="1")),
+     *   @OA\RequestBody(
+     *   ),
+     *   @OA\Response(response="200", description="请求成功")
+     * )
+     */
+    public function delete() {
+        $input = Until::getInput();
+        $rule = [
+            'templateId|模板id' => 'require',
+        ];
+        Until::check($rule, $input);
+        $model = new \app\api\model\Template();
+        $model::where(['id' => $input['templateId']])->update(['status' => \app\api\model\Template::DELETE]);
+        Until::output();
+    }
+
+
+    /**
+     * @OA\Get(path="/api/Template/read",
+     *   tags={"模板管理"},
+     *   summary="查看模板",
+     *   @OA\Parameter(name="token", in="header", description="token", @OA\Schema(type="string")),
+     *   @OA\Parameter(name="templateId", in="query", description="模板id", @OA\Schema(type="ineger",default="1")),
+     *   @OA\RequestBody(
+     *   ),
+     *   @OA\Response(response="200", description="请求成功")
+     * )
+     */
+    public function read() {
+        $input = Until::getInput();
+        $rule = [
+            'templateId|模板id' => 'require',
+        ];
+        Until::check($rule, $input);
+        $model = new \app\api\model\Template();
+        $tempInfo = $model::where(['id' => $input['templateId']])->find();
+        $tempInfo = Until::modelToArray($tempInfo);
+        $ptModel = new ProductTemplateModel();
+        $ptList = $ptModel->getTemplateProductInfo($input['templateId']);
+        $tempInfo['list'] = $ptList;
+        Until::output($tempInfo);
+    }
+
+
+}

+ 3 - 3
application/api/controller/User.php

@@ -180,7 +180,7 @@ class User extends BaseController {
     }
 
     /**
-     * @OA\Get(path="/api/User/read",
+     * @OA\Post(path="/api/User/recharge",
      *   tags={"用户管理"},
      *   summary="充值余额",
      *   @OA\Parameter(name="token", in="header", description="token", @OA\Schema(type="string")),
@@ -188,8 +188,8 @@ class User extends BaseController {
      *     @OA\MediaType(
      *       mediaType="multipart/form-data",
      *         @OA\Schema(
-     *           @OA\Property(description="充值金额", property="recharge", type="int"),
-     *           required={"id"})
+     *           @OA\Property(description="充值金额", property="recharge", type="string"),
+     *           required={"recharge"})
      *       )
      *     ),
      *   @OA\Response(response="200", description="请求成功")

+ 16 - 0
application/api/model/CallServiceModel.php

@@ -0,0 +1,16 @@
+<?php
+/**
+ * Author: luzheng.liu
+ * Time: 2021/6/4 15:17
+ */
+
+namespace app\api\model;
+
+
+class CallServiceModel extends BaseModel {
+
+    const NOT_DEAL = 1; //未处理
+    const DEAL = 2; // 已处理
+
+    protected $table = 'call_service';
+}

+ 13 - 0
application/api/model/OrderChangeModel.php

@@ -0,0 +1,13 @@
+<?php
+/**
+ * Author: luzheng.liu
+ * Time: 2021/6/10 14:32
+ */
+
+namespace app\api\model;
+
+
+class OrderChangeModel extends BaseModel {
+
+    protected $table = 'order_change_log';
+}

+ 15 - 10
application/api/model/ProductModel.php

@@ -11,33 +11,38 @@ use think\Db;
 
 class ProductModel  extends BaseModel {
 
+    const NORMAL = 1;
+    const OFF = 2; //下架
     protected $table = 'product';
 
     public function getProductList() {
         $countModel = $this->alias('p')
             ->join('company c','c.id = p.company_id','left')
             ->join('brand b','b.id = p.brand_id','left')
-//            ->join('store s','s.id = p.store_id')
+            ->join('product_template ptemp','ptemp.product_id = p.id')
+            ->join('store_product_template spt','spt.template_id = ptemp.template_id')
             ->join('product_type pt','pt.id = p.product_type_id','left');
 
         $selectModel = $this->alias('p')
-            ->field('p.*,c.company_name,b.brand_name,pt.product_type_name')
-            ->join('company c','c.id = p.company_id','left')
-            ->join('brand b','b.id = p.brand_id','left')
-            ->join('product_type pt','pt.id = p.product_type_id','left')
+            ->field('p.*,c.company_name,b.brand_name,pt.product_type_name,ptemp.price realPrice')
+            ->join('company c', 'c.id = p.company_id', 'left')
+            ->join('brand b', 'b.id = p.brand_id', 'left')
+            ->join('product_type pt', 'pt.id = p.product_type_id', 'left')
+            ->join('product_template ptemp','ptemp.product_id = p.id')
+            ->join('store_product_template spt','spt.template_id = ptemp.template_id')
             ->order(['p.id' => 'desc']);
-//            ->join('store s','s.id = p.store_id')
-//            ->join('product_type pt','pt.id = p.product_type_id');
+
         return $this->joinModelPageList($countModel, $selectModel);
     }
 
+
     public function getProductInfo() {
         $selectModel = $this->alias('p')
-            ->field('p.*,c.company_name,b.brand_name,pt.product_type_name'
-            )
+            ->field('p.*,c.company_name,b.brand_name,pt.product_type_name,ptemp.price realPrice')
             ->join('company c','c.id = p.company_id')
             ->join('brand b','b.id = p.brand_id')
-//            ->join('store s','s.id = p.store_id')
+            ->join('product_template ptemp','ptemp.product_id = p.id')
+            ->join('store_product_template spt','spt.template_id = ptemp.template_id')
             ->join('product_type pt','pt.id = p.product_type_id')
             ->where($this->getWhere())
             ->find();

+ 25 - 0
application/api/model/ProductTemplateModel.php

@@ -0,0 +1,25 @@
+<?php
+/**
+ * Author: luzheng.liu
+ * Time: 2021/6/7 17:18
+ */
+
+namespace app\api\model;
+
+
+use app\common\until\Until;
+
+class ProductTemplateModel extends BaseModel {
+
+    protected $table = 'product_template';
+
+    public function getTemplateProductInfo(int $templateId) {
+        $rs = $this->alias('pt')
+            ->field('p.*,pt.price realPrice,pt.template_id,pt.product_id')
+            ->join('product p', 'p.id = pt.product_id')
+            ->where([['p.status','=', ProductModel::NORMAL],['pt.template_id','=',$templateId]])
+            ->select();
+        return Until::modelToArray($rs);
+    }
+
+}

+ 14 - 0
application/api/model/StoreProductTemplateModel.php

@@ -0,0 +1,14 @@
+<?php
+/**
+ * Author: luzheng.liu
+ * Time: 2021/6/7 17:18
+ */
+
+namespace app\api\model;
+
+
+class StoreProductTemplateModel extends BaseModel {
+
+    protected $table = 'store_product_template';
+
+}

+ 16 - 0
application/api/model/Template.php

@@ -0,0 +1,16 @@
+<?php
+/**
+ * Author: luzheng.liu
+ * Time: 2021/6/7 18:00
+ */
+
+namespace app\api\model;
+
+
+class Template extends BaseModel {
+
+    const NORMAL = 1;
+    const DELETE = 2;
+
+    protected $table = 'template';
+}

+ 7 - 5
application/common/service/OrderService.php

@@ -41,8 +41,9 @@ class OrderService {
         $payCode = (new StoreModel())->getPayCode($input['storeId']);
         $this->time[] = 'start' . time();
         $orderSn = Until::createSn();
-        $productInfo = (new ProductModel())::where(['id' => $input['productId']])->find();
-        $productInfo = Until::modelToArray($productInfo);
+        $productModel = new ProductModel();
+        $productModel->setWhere(['p.id' => $input['productId'],'spt.store_id' => $input['storeId']]);
+        $productInfo = $productModel->getProductInfo();
         $userInfo = (new UserModel())::where(['id' => $userId])->find();
         $userInfo = Until::modelToArray($userInfo);
         if (empty($userInfo)) {
@@ -55,7 +56,7 @@ class OrderService {
                 $orderType = 2;
             }
             $model->startTrans();
-            $orderMoney = $productInfo['current_price'] * (int)abs($input['num']);
+            $orderMoney = $productInfo['realPrice'] * (int)abs($input['num']);
             $orderId = $model->insertGetId([
                 'order_sn'         => $orderSn,
                 'order_money'      => $orderMoney,
@@ -84,6 +85,7 @@ class OrderService {
                 'product_id'      => $input['productId'],
                 'product_num'     => (int)abs($input['num']),
                 'current_price'   => $productInfo['current_price'],
+                'real_price'      => $productInfo['realPrice'],
                 'product_name'    => $productInfo['product_name'],
                 'product_img'     => $productInfo['product_img'],
                 'old_price'       => $productInfo['old_price'],
@@ -406,7 +408,7 @@ class OrderService {
     public function rechargeNotify(string $orderSn) {
         $rechargeOrderModel = new RechargeOrder();
         $rechargeInfo = $rechargeOrderModel::where(['order_sn' => $orderSn])->find();
-        if (empty($rechargeInfo) || $rechargeInfo['status'] == RechargeOrder::PAY) {
+        if (empty($rechargeInfo) || $rechargeInfo['pay_status'] == RechargeOrder::PAY) {
             return;
         }
         $rechargeModel = new RechargeRecordModel();
@@ -414,7 +416,7 @@ class OrderService {
         try {
             $rechargeOrderModel->startTrans();
             $userInfo = $userModel::where(['id' => $rechargeInfo['user_id']])->find();
-            $userModel::where(['id' => $rechargeInfo['user_id']])->inc('money', $rechargeInfo['recharge']);
+            $userModel::where(['id' => $rechargeInfo['user_id']])->inc('money', $rechargeInfo['recharge'])->update();
             $rechargeOrderModel::where(['order_sn' => $orderSn, 'pay_status' => $rechargeOrderModel::NO_PAY])
                 ->update([
                     'pay_status'       => $rechargeOrderModel::PAY,

+ 369 - 0
public/api.yaml

@@ -1464,6 +1464,12 @@ paths:
           schema:
             type: integer
         -
+          name: storeId
+          in: query
+          description: 门店id
+          schema:
+            type: integer
+        -
           name: companyId
           in: query
           description: 公司id
@@ -1720,6 +1726,70 @@ paths:
       responses:
         '200':
           description: 请求成功
+  /api/ProductTemplate/save:
+    post:
+      tags:
+        - 产品模板管理
+      summary: 保存模板信息(没有增加,有更新)
+      operationId: 'app\api\controller\ProductTemplate::save'
+      parameters:
+        -
+          name: token
+          in: header
+          description: token
+          schema:
+            type: string
+      requestBody:
+        content:
+          application/json:
+            schema:
+              required:
+                - list
+                - templateId
+              properties:
+                list:
+                  type: array
+                  items: { properties: { productId: { description: 商品id, type: integer, default: '1' }, price: { description: 价格, type: string, default: '199.90' } }, type: object }
+                templateId:
+                  description: 模板id
+                  type: integer
+                  default: '1'
+              type: object
+      responses:
+        '200':
+          description: 请求成功
+  /api/ProductTemplate/delete:
+    post:
+      tags:
+        - 产品模板管理
+      summary: 删除模板里的产品
+      operationId: 'app\api\controller\ProductTemplate::delete'
+      parameters:
+        -
+          name: token
+          in: header
+          description: token
+          schema:
+            type: string
+      requestBody:
+        content:
+          application/json:
+            schema:
+              required:
+                - list
+                - templateId
+              properties:
+                list:
+                  type: array
+                  items: { properties: { productId: { description: 商品id, type: integer, default: '1' } }, type: object }
+                templateId:
+                  description: 模板id
+                  type: integer
+                  default: '1'
+              type: object
+      responses:
+        '200':
+          description: 请求成功
   /api/Room/index:
     get:
       tags:
@@ -1985,6 +2055,99 @@ paths:
       responses:
         '200':
           description: 请求成功
+  /api/Server/callService:
+    post:
+      tags:
+        - 服务管理
+      summary: 叫服务
+      operationId: 'app\api\controller\Server::callService'
+      requestBody:
+        content:
+          multipart/form-data:
+            schema:
+              required:
+                - type
+                - roomId
+                - storeId
+              properties:
+                type:
+                  description: '服务类型 1、茶水;2、水果;3、加钟'
+                  type: integer
+                roomId:
+                  description: 房间号
+                  type: integer
+                storeId:
+                  description: 门店id
+                  type: integer
+              type: object
+      responses:
+        '200':
+          description: 请求成功
+  /api/Server/callList:
+    post:
+      tags:
+        - 服务管理
+      summary: 叫服务列表(轮询这个接口)
+      operationId: 'app\api\controller\Server::callList'
+      parameters:
+        -
+          name: token
+          in: header
+          description: token
+          schema:
+            type: string
+      requestBody:
+        content:
+          multipart/form-data:
+            schema:
+              required:
+                - storeId
+              properties:
+                roomId:
+                  description: 房间号
+                  type: integer
+                storeId:
+                  description: 门店id
+                  type: integer
+              type: object
+      responses:
+        '200':
+          description: 请求成功
+  /api/Server/dealCall:
+    post:
+      tags:
+        - 服务管理
+      summary: 处理叫服务
+      operationId: 'app\api\controller\Server::dealCall'
+      parameters:
+        -
+          name: token
+          in: header
+          description: token
+          schema:
+            type: string
+      requestBody:
+        content:
+          multipart/form-data:
+            schema:
+              required:
+                - type
+                - roomId
+                - storeId
+              properties:
+                roomId:
+                  description: 房间号
+                  type: integer
+                storeId:
+                  description: 门店id
+                  type: integer
+                type:
+                  description: '服务类型 1、茶水;2、水果;3、加钟'
+                  type: integer
+              type: object
+      responses:
+        '200':
+          description: 请求成功
   /api/Staff/index:
     get:
       tags:
@@ -2488,6 +2651,185 @@ paths:
       responses:
         '200':
           description: 请求成功
+  /api/StoreTemplate/save:
+    post:
+      tags:
+        - 门店模板管理
+      summary: 保存模板信息(没有增加,有更新)
+      operationId: 'app\api\controller\StoreTemplate::save'
+      parameters:
+        -
+          name: token
+          in: header
+          description: token
+          schema:
+            type: string
+      requestBody:
+        content:
+          multipart/form-data:
+            schema:
+              required:
+                - templateId
+                - storeId
+              properties:
+                storeId:
+                  description: 门店id
+                  type: string
+                  default: '1'
+                templateId:
+                  description: 模板id
+                  type: string
+                  default: '1'
+              type: object
+      responses:
+        '200':
+          description: 请求成功
+  /api/StoreTemplate/delete:
+    get:
+      tags:
+        - 门店模板管理
+      summary: 删除模板
+      operationId: 'app\api\controller\StoreTemplate::delete'
+      parameters:
+        -
+          name: token
+          in: header
+          description: token
+          schema:
+            type: string
+        -
+          name: 门店id
+          in: query
+          description: storeId
+          schema:
+            type: ineger
+            default: '1'
+      requestBody: {  }
+      responses:
+        '200':
+          description: 请求成功
+  /api/Template/index:
+    get:
+      tags:
+        - 模板管理
+      summary: 模板列表
+      operationId: 'app\api\controller\Template::index'
+      parameters:
+        -
+          name: token
+          in: header
+          description: token
+          schema:
+            type: string
+        -
+          name: page
+          in: query
+          description: 页码
+          schema:
+            type: ineger
+            default: '1'
+        -
+          name: pageSize
+          in: query
+          description: 页尺寸
+          schema:
+            type: integer
+            default: '10'
+        -
+          name: name
+          in: query
+          description: 模板名字
+          schema:
+            type: integer
+            default: 上海
+      requestBody: {  }
+      responses:
+        '200':
+          description: 请求成功
+  /api/Template/save:
+    post:
+      tags:
+        - 模板管理
+      summary: 保存模板信息(没有增加,有更新)
+      operationId: 'app\api\controller\Template::save'
+      parameters:
+        -
+          name: token
+          in: header
+          description: token
+          schema:
+            type: string
+      requestBody:
+        content:
+          multipart/form-data:
+            schema:
+              required:
+                - templateName
+              properties:
+                desc:
+                  description: 模板介绍
+                  type: string
+                  default: xxx
+                templateName:
+                  description: 模板名称
+                  type: string
+                  default: '上海通用 '
+                templateId:
+                  description: 模板id
+                  type: string
+                  default: '上海通用 '
+              type: object
+      responses:
+        '200':
+          description: 请求成功
+  /api/Template/delete:
+    get:
+      tags:
+        - 模板管理
+      summary: 删除模板
+      operationId: 'app\api\controller\Template::delete'
+      parameters:
+        -
+          name: token
+          in: header
+          description: token
+          schema:
+            type: string
+        -
+          name: 模板id
+          in: query
+          description: templateId
+          schema:
+            type: ineger
+            default: '1'
+      requestBody: {  }
+      responses:
+        '200':
+          description: 请求成功
+  /api/Template/read:
+    get:
+      tags:
+        - 模板管理
+      summary: 查看模板
+      operationId: 'app\api\controller\Template::read'
+      parameters:
+        -
+          name: token
+          in: header
+          description: token
+          schema:
+            type: string
+        -
+          name: templateId
+          in: query
+          description: 模板id
+          schema:
+            type: ineger
+            default: '1'
+      requestBody: {  }
+      responses:
+        '200':
+          description: 请求成功
   /api/User:
     get:
       tags:
@@ -2653,3 +2995,30 @@ paths:
       responses:
         '200':
           description: 请求成功
+  /api/User/recharge:
+    post:
+      tags:
+        - 用户管理
+      summary: 充值余额
+      operationId: 'app\api\controller\User::recharge'
+      parameters:
+        -
+          name: token
+          in: header
+          description: token
+          schema:
+            type: string
+      requestBody:
+        content:
+          multipart/form-data:
+            schema:
+              required:
+                - recharge
+              properties:
+                recharge:
+                  description: 充值金额
+                  type: string
+              type: object
+      responses:
+        '200':
+          description: 请求成功