wang jun 2 years ago
parent
commit
77fe056e4c

+ 19 - 0
application/app/controller/Appointment.php

@@ -31,5 +31,24 @@ class Appointment extends BaseController
         }
         }
         return backjson2(1, 'success', $result['data']);
         return backjson2(1, 'success', $result['data']);
     }
     }
+    /**
+     * 请求数据完成
+     * 根据appointment_id和testtubeno
+     *
+     * @return void
+     * @author wj
+     * @date 2022-07-25
+     */
+    public function finishedbyaid()
+    {
+        $param = request()->param();
+        $this->checktoken($param);
+        $l_a = new appointmentlogic();
+        $result = $l_a->finishedbyaid($param);
+        if (!$result['status']) {
+            return backjson2(0, $result['msg']);
+        }
+        return backjson2(1, 'success', $result['data']);
+    }
 
 
 }
 }

+ 71 - 1
application/app/logic/appointmentlogic.php

@@ -1,7 +1,9 @@
 <?php
 <?php
 namespace app\app\logic;
 namespace app\app\logic;
 
 
-use app\index\model\appointmentmodel;
+use app\app\model\appointmentmodel;
+use app\app\model\tubemodel;
+use think\Db;
 
 
 /**
 /**
  * 登记记录表
  * 登记记录表
@@ -22,6 +24,10 @@ class appointmentlogic extends baselogic
             'getinfobyid' => [
             'getinfobyid' => [
                 ['name' => 'id', 'title' => '申请id', 'require' => true, 'type' => 'numeric'],
                 ['name' => 'id', 'title' => '申请id', 'require' => true, 'type' => 'numeric'],
             ],
             ],
+            'finishedbyaid' => [
+                ['name' => 'appointment_id', 'title' => '申请id', 'require' => true, 'type' => 'numeric'],
+                ['name' => 'testtubeno', 'title' => '测试管号', 'require' => true, 'type' => 'numeric'],
+            ],
         ];
         ];
         return $list;
         return $list;
     }
     }
@@ -54,4 +60,68 @@ class appointmentlogic extends baselogic
         }
         }
         return backarr(1, "查询成功", $info);
         return backarr(1, "查询成功", $info);
     }
     }
+    /**
+     * 请求数据完成
+     * 根据appointment_id和testtubeno
+     *
+     * @return void
+     * @author wj
+     * @date 2022-07-25
+     */
+    public function finishedbyaid($arr)
+    {
+        $result = $this->checkparam(__FUNCTION__, $arr);
+        if (1 != $result['status']) {
+            return $result;
+        }
+        $data = $result['data'];
+        $aid = $data['appointment_id'];
+        $testtubeno = $data['testtubeno'];
+        $m_t = new tubemodel();
+        $m_a = new appointmentmodel();
+        $where = ['id' => $aid];
+        $field = ['name', 'sfzid', 'telno', 'signurl', 'oprdate', 'ispay', 'isuse', 'payorderno', 'openid', 'code', 'id'];
+        $ainfo = $m_a->getInfo($where, $field);
+        if (empty($ainfo)) {
+            return backarr(0, "无申请数据");
+        }
+        if (!$ainfo['ispay']) {
+            return backarr(0, "未支付");
+        }
+        if ($ainfo['isuse']) {
+            return backarr(0, "已使用");
+        }
+        $where = ['appointment_id' => $aid, 'testtubeno' => $testtubeno];
+        $tinfo = $m_t->getInfo($where);
+        if (!empty($tinfo)) {
+            return backarr(0, "数据已存在");
+        }
+        Db::startTrans();
+        try {
+            $tinsertData = [
+                'openid' => $ainfo['openid'],
+                'name' => $ainfo['openid'],
+                'telno' => $ainfo['openid'],
+                'sfzid' => $ainfo['openid'],
+                'testtubeno' => $testtubeno,
+                'code' => $ainfo['code'],
+                'appointment_id' => $ainfo['id'],
+            ];
+            $tid = $m_t->insertData($tinsertData);
+            if (empty($tid)) {
+                throw new \Exception("试管信息添加失败");
+            }
+            $aupdateData = ['isuse' => 1];
+            $awhere = ['id' => $aid];
+            $row = $m_a->updateinfo($awhere, $aupdateData);
+            if (empty($row)) {
+                throw new \Exception("申请单修改失败");
+            }
+            Db::commit();
+            return backarr(1, "操作成功", ['tid' => $tid]);
+        } catch (\Exception $e) {
+            Db::rollback();
+            return backarr(0, $e->getMessage());
+        }
+    }
 }
 }