xxxrrrdddd 3 年之前
父节点
当前提交
c62027fd83
共有 2 个文件被更改,包括 10 次插入4 次删除
  1. 4 4
      application/api/controller/MobileController.php
  2. 6 0
      application/common/model/Mobile.php

+ 4 - 4
application/api/controller/MobileController.php

@@ -186,16 +186,16 @@ class MobileController extends UserApi
             'county'=>'require|integer',
             'address'=>'require',
         ]);
-        $mobile=Mobile::where('status',0)->findOrFail($data['mobile_id']);
+
+        Db::startTrans();
+        $mobile=Mobile::lock(true)->findOrFail($data['mobile_id']);
         if($mobile['type']==1){
             $this->_validate([
                 'pay_type'=>'require|in:1,2,3',
             ]);
         }
-
+        $mobile->shouldBuy();
         Area::shouldSend($data['county']);
-
-        Db::startTrans();
         SmsSend::setMobile($data['phone'])->setCode($data['sms_code'] ?? '')->setEvent('order')->check();
         $order = $data;
         $order['admin_id'] = $mobile['proxy_id'];

+ 6 - 0
application/common/model/Mobile.php

@@ -152,4 +152,10 @@ class Mobile extends Model
             $mobile->save();
         }
     }
+
+    public function shouldBuy(){
+        if($this['status']!=0){
+            throw_user('改靓号已售或不存在');
+        }
+    }
 }