Selaa lähdekoodia

修改报名人信息

15954078560 2 vuotta sitten
vanhempi
commit
e8e52c6963
1 muutettua tiedostoa jossa 63 lisäystä ja 3 poistoa
  1. 63 3
      application/api/controller/User.php

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

@@ -1721,11 +1721,71 @@ class User extends Api
         if ($active_refund) {
             $this->error('您正在申请退款,暂不可修改信息');
         }
+        //检查信息
+        if (!$name || iconv_strlen($name, 'utf-8') > 50) {
+            $this->error('请输入正确姓名');
+        }
+        if (iconv_strlen($idcard, 'utf-8') != 18) {
+            $this->error('请输入正确身份证号');
+        }
+        if (!is_mobile($mobile)) {
+            $this->error('请输入正确手机号');
+        }
+        if (!$emergencycontact || iconv_strlen($emergencycontact, 'utf-8') > 50) {
+            $this->error('请输入紧急联系人');
+        }
+        if (!is_mobile($contactmobile)) {
+            $this->error('请输入正确紧急联系人方式');
+        }
+        //判断是否报名过
+        $count = Db::name('active_people')->where(['active_id' => $info['active_id'], 'idcard' => $idcard, 'status' => ['neq', 3]])->count('id');
+        if ($count) {
+            $this->error('该信息已报名过活动');
+        }
+        $count2 = Db::name('active_people_modify')->where(['active_id' => $info['active_id'], 'idcard' => $idcard, 'status' => 0])->count('id');
+        if ($count2) {
+            $this->error('该信息已提交过修改,请等待审核');
+        }
+        //构建修改数据
+        $data = [
+            'active_id' => $info['active_id'],
+            'order_id' => $info['order_id'],
+            'people_id' => $id,
+            'user_id' => $info['user_id'],
+            'name' => $name,
+            'credtype' => $info['credtype'],
+            'idcard' => $idcard,
+            'mobile' => $mobile,
+            'emergencycontact' => $emergencycontact,
+            'contactmobile' => $contactmobile,
+            'insurance' => $info['insurance'],
+            'originalprice' => $info['originalprice'],
+            'vipprice' => $info['vipprice'],
+            'coupon_id' => $info['coupon_id'],
+            'coupontype' => $info['coupontype'],
+            'couponprice' => $info['couponprice'],
+            'is_free' => $info['is_free'],
+            'price' => $info['price'],
+            'is_self' => $info['is_self'],
+            'createtime' => time()
+        ];
 
+        //开启事务
+        Db::startTrans();
+        //添加记录
+        $rs = Db::name('active_people_modify')->insertGetId($data);
+        if (!$rs) {
+            Db::rollback();
+            $this->error('修改失败');
+        }
+        //修改原记录状态
+        $rt = Db::name('active_people')->where(['id' => $id, 'modifystatus' => 0])->setField('modifystatus', 1);
+        if (!$rt) {
+            Db::rollback();
+            $this->error('修改失败');
+        }
 
-
-
-
+        $this->success('修改成功');
     }
 
 }