Browse Source

order Control

ayHaru 4 years ago
parent
commit
c62f10f65a
2 changed files with 41 additions and 20 deletions
  1. 20 20
      application/index/controller/Order.php
  2. 21 0
      application/index/model/OrderModel.php

+ 20 - 20
application/index/controller/Order.php

@@ -12,7 +12,9 @@ class Order extends Controller
         $ret = ['check' => true,'order_sn' => $order_sn];
         json_success($ret);
     }
-
+    /**
+     * 订单绑定校验码
+    */
     public function order_bind_code(){
         $order_sn = input('param.order_sn');
         $OrderModel = new OrderModel();
@@ -21,25 +23,23 @@ class Order extends Controller
         if(empty($order)){
             return json(json_error_exception(1008));
         }
-        $code = $this->createRandCode($order_sn);
+        $code = $this->createRandCode();
+        $result = $OrderModel->editData(['order_sn' => $order_sn],['code' => $code]);
+        if($result['code'] != 1){
+            return json(json_error_exception('1006',$result['msg']));
+        }
+        json_return(200,[],'success');
     }
-
-    public function createRandCode($order_sn){
-
+    /**
+     * 生成校验码
+    */
+    public function createRandCode(){
+        $code = rand(100000,999999);
+        $OrderModel = new OrderModel();
+        $order = $OrderModel->where('code',$code)->find();
+        if(!empty($order)){
+            $this->createRandCode();
+        }
+        return $code;
     }
 }
-
-application/index/controller/Base.php application/index/controller/Box.php application/index/controller/Cabinet.php application/index/controller/Index.php application/index/controller/Node.php application/index/controller/Order.php
-        application/index/controller/Role.php
-        application/index/model/BoxModel.php
-        application/index/model/CabinetModel.php
-        application/index/model/NodeModel.php
-        application/index/model/OrderModel.php
-        application/index/model/RoleModel.php
-        application/index/validate/CabinetValidate.php
-        application/index/validate/RoleValidate.php
-        application/index/validate/UserValidate.php
-        conf/php-fpm/docker-php-fpm-start
-        config/errorCode.php
-        docker-compose-windows.yml
-        route/route.php

+ 21 - 0
application/index/model/OrderModel.php

@@ -12,4 +12,25 @@ class OrderModel extends Model{
     public function getOne($order_sn){
         return $this->where('order_sn' , $order_sn)->find();
     }
+
+    /**
+     * 根据既定条件修改信息
+     * @where $param
+     * @update $param
+     */
+    public function editData($where,$update)
+    {
+        try{
+            $result = $this->save($update, $where);
+            if(false === $result){
+                // 验证失败 输出错误信息
+                return msg(-1, '', $this->getError());
+            }else{
+
+                return msg(1, '', 'success');
+            }
+        }catch(\Exception $e){
+            return msg(-2, '', $e->getMessage());
+        }
+    }
 }