wang jun vor 2 Jahren
Ursprung
Commit
6f8bc9ccae

+ 6 - 2
application/app/controller/Appointment.php

@@ -26,8 +26,12 @@ class Appointment extends BaseController
         $this->checktoken($param);
         $l_a = new appointmentlogic();
         $result = $l_a->getinfobyid($param);
-        if (!$result['status']) {
-            return backjson2(0, $result['msg'],$result['data']);
+        if (1 != $result['status']) {
+            if ($result['status'] < 0) {
+                return backjson2($result['status'], $result['msg'], $result['data']);
+            } else {
+                return backjson2(0, $result['msg'], $result['data']);
+            }
         }
         return backjson2(200, 'success', $result['data']);
     }

+ 11 - 4
application/app/logic/appointmentlogic.php

@@ -3,6 +3,7 @@ namespace app\app\logic;
 
 use app\common\model\appointmentmodel;
 use app\common\model\tubemodel;
+use app\common\model\webusermodel;
 use think\Db;
 
 /**
@@ -28,6 +29,7 @@ class appointmentlogic extends baselogic
                 ['name' => 'appointment_id', 'title' => '申请id', 'require' => true, 'type' => 'numeric'],
                 ['name' => 'testtubeno', 'title' => '测试管号', 'require' => true, 'type' => 'numeric'],
                 ['name' => 'testtype', 'title' => '测试类型', 'require' => true, 'type' => 'numeric'],
+                ['name' => 'token', 'title' => 'token', 'require' => true, 'type' => 'string'],
             ],
         ];
         return $list;
@@ -46,21 +48,22 @@ class appointmentlogic extends baselogic
         if (1 != $result['status']) {
             return $result;
         }
+        $data = $result['data'];
         $m_a = new appointmentmodel();
-        $where = ['id' => $arr['id']];
+        $where = ['id' => $data['id']];
         $field = ['name', 'sfzid', 'telno', 'signurl', 'oprdate', 'ispay', 'isuse', 'payorderno', 'id'];
         $info = $m_a->getInfo($where, $field);
         if (empty($info)) {
             return backarr(0, "无申请数据");
         }
+        $aid = $info['id'];
         if (!$info['ispay']) {
-            return backarr(0, "未支付");
+            return backarr(0, "未支付", ['id' => $aid]);
         }
         if ($info['isuse']) {
-            $aid = $info['id'];
             $m_t = new tubemodel();
             $tinfo = $m_t->getInfo(['appointment_id' => $aid], ['oprtime']);
-            return backarr(0, "已使用", ['id' => $aid, 'oprtime' => $tinfo['oprtime']]);
+            return backarr(-1, "已使用", ['id' => $aid, 'oprtime' => $tinfo['oprtime']]);
         }
         return backarr(1, "查询成功", $info);
     }
@@ -82,8 +85,10 @@ class appointmentlogic extends baselogic
         $aid = $data['appointment_id'];
         $testtubeno = $data['testtubeno'];
         $testtype = $data['testtype'];
+        $token = $data['token'];
         $m_t = new tubemodel();
         $m_a = new appointmentmodel();
+        $m_w = new webusermodel();
         $testtypelist = $m_t->gettesttypelist();
         if (!isset($testtypelist[$testtype])) {
             return backarr(0, "测试类型错误");
@@ -107,6 +112,7 @@ class appointmentlogic extends baselogic
         }
         Db::startTrans();
         try {
+            $winfo = $m_w->getinfobytoken($token);
             $tinsertData = [
                 'openid' => $ainfo['openid'],
                 'name' => $ainfo['name'],
@@ -116,6 +122,7 @@ class appointmentlogic extends baselogic
                 'code' => $ainfo['code'],
                 'appointment_id' => $ainfo['id'],
                 'test_type' => $testtype,
+                'wid' => $winfo['id'],
             ];
             $tid = $m_t->insertData($tinsertData);
             if (empty($tid)) {

+ 5 - 5
application/app/logic/webuserlogic.php

@@ -100,8 +100,8 @@ class webuserlogic extends baselogic
         $list = $m_s->getList($where, 'smscode', 1, 1)->toArray();
         if (empty($list)) {
             //发送短信
-            //$code = randomStr();
-            $code = "8888";
+            $code = randomStr();
+            //$code = "8888";
             $smsData = [
                 'telno' => $telno,
                 'smscode' => $code,
@@ -114,10 +114,10 @@ class webuserlogic extends baselogic
             $code = $list[0]['smscode'];
         }
         //发送验证码
-        /*$sendresult = $this->sendsmscode($telno, $code);
+        $sendresult = $this->sendsmscode($telno, $code);
         if (!$sendresult['status']) {
-        return backarr(0, $sendresult['msg']);
-        }*/
+            return backarr(0, $sendresult['msg']);
+        }
         return backarr(1, "验证码发送成功");
     }
     /**

+ 2 - 2
application/common/model/webusermodel.php

@@ -109,10 +109,10 @@ class webusermodel extends Model
      * wj
      * 20220118
      */
-    public function getinfobytoken($token)
+    public function getinfobytoken($token, $field = ['id'])
     {
         $where = ['token' => $token];
-        $info = $this->where($where)->find();
+        $info = $this->where($where)->field($field)->find();
         return $info ? $info : false;
     }
     /**