[ ['name' => 'id', 'title' => '申请id', 'require' => true, 'type' => 'numeric'], ], 'finishedbyaid' => [ ['name' => 'appointment_id', 'title' => '申请id', 'require' => true, 'type' => 'numeric'], ['name' => 'testtubeno', 'title' => '测试管号', 'require' => true], ['name' => 'testtype', 'title' => '测试类型', 'require' => true, 'type' => 'numeric'], ['name' => 'token', 'title' => 'token', 'require' => true, 'type' => 'string'], ], ]; return $list; } /** * 获取用户当日申请最后一条数据 * * @param [type] $arr * @return void * @author wj * @date 2022-07-22 */ public function getinfobyid($arr) { $result = $this->checkparam(__FUNCTION__, $arr); if (1 != $result['status']) { return $result; } $data = $result['data']; $m_a = new appointmentmodel(); $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, "未支付", ['id' => $aid]); } if ($info['isuse']) { $m_t = new tubemodel(); $tinfo = $m_t->getInfo(['appointment_id' => $aid], ['oprtime']); return backarr(-1, "已使用", ['id' => $aid, 'oprtime' => $tinfo['oprtime']]); } 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']; $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, "测试类型错误"); } $where = ['id' => $aid]; $field = ['name', 'sfzid', 'telno', 'signurl', 'oprdate', 'ispay', 'isuse', 'payorderno', 'openid', 'code', 'id', 'age', 'gender', 'birthday']; $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 { $winfo = $m_w->getinfobytoken($token); $tinsertData = [ 'openid' => $ainfo['openid'], 'name' => $ainfo['name'], 'telno' => $ainfo['telno'], 'sfzid' => $ainfo['sfzid'], 'testtubeno' => $testtubeno, 'code' => $ainfo['code'], 'appointment_id' => $ainfo['id'], 'test_type' => $testtype, 'wid' => $winfo['id'], 'age' => $ainfo['age'], 'gender' => $ainfo['gender'], 'birthday' => $ainfo['birthday'], ]; $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()); } } /** * 获取测试类型 * * @return void * @author wj * @date 2022-07-26 */ public function gettesttypelist() { $t_m = new tubemodel(); $list = $t_m->gettesttypelist(); return $list; } }