[ ['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'], ['name' => 'testtype', 'title' => '测试类型', 'require' => true, 'type' => 'numeric'], ], ]; 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; } $m_a = new appointmentmodel(); $where = ['id' => $arr['id']]; $field = ['name', 'sfzid', 'telno', 'signurl', 'oprdate', 'ispay', 'isuse', 'payorderno']; $info = $m_a->getInfo($where, $field); if (empty($info)) { return backarr(0, "无申请数据"); } if (!$info['ispay']) { return backarr(0, "未支付"); } if ($info['isuse']) { return backarr(0, "已使用"); } 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']; $m_t = new tubemodel(); $m_a = new appointmentmodel(); $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']; $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()); } } /** * 获取测试类型 * * @return void * @author wj * @date 2022-07-26 */ public function gettesttypelist() { $t_m = new tubemodel(); $list = $t_m->gettesttypelist(); return $list; } }