diff --git a/api/service/userDoctor.go b/api/service/userDoctor.go index b90904f..feb1d4f 100644 --- a/api/service/userDoctor.go +++ b/api/service/userDoctor.go @@ -184,27 +184,6 @@ func (r *UserDoctorService) PutUserDoctor(doctorId int64, req requests.PutUserDo } } - // 修改科室数据,重新认定为未审核 - if userDoctor.DepartmentCustomId != departmentCustomId { - // 检测是否存在正在审核中的处方 - orderPrescriptionDao := dao.OrderPrescriptionDao{} - - maps := make(map[string]interface{}) - maps["doctor_id"] = doctorId - maps["prescription_status"] = 1 - orderPrescription, err := orderPrescriptionDao.GetList(maps) - if err != nil { - return false, errors.New("修改失败") - } - - if len(orderPrescription) > 0 { - return false, errors.New("存在审核中的处方,请勿修改科室数据") - } - - userDoctorData["multi_point_status"] = 2 - userDoctorData["multi_point_fail_reason"] = "" - } - // 处理科室电话 if userDoctor.DepartmentCustomMobile != req.DepartmentCustomMobile { userDoctorData["department_custom_id"] = req.DepartmentCustomMobile @@ -312,7 +291,6 @@ func (r *UserDoctorService) PutUserDoctor(doctorId int64, req requests.PutUserDo if userDoctorInfo.IdCardFront != "" && req.IdCardFront == "" { return false, errors.New("未上传新的身份证图片") } - if req.IdCardFront != "" { idCardFront := strings.Replace(req.IdCardFront, "https://img.applets.igandanyiyuan.com", "", 1) if idCardFront != userDoctorInfo.IdCardFront { @@ -385,6 +363,29 @@ func (r *UserDoctorService) PutUserDoctor(doctorId int64, req requests.PutUserDo } } + // 处理多点状态 + if userDoctor.DepartmentCustomId != departmentCustomId { + if req.SignImage != "" && req.IdCardBack != "" && req.IdCardFront != "" { + // 检测是否存在正在审核中的处方 + orderPrescriptionDao := dao.OrderPrescriptionDao{} + + maps := make(map[string]interface{}) + maps["doctor_id"] = doctorId + maps["prescription_status"] = 1 + orderPrescription, err := orderPrescriptionDao.GetList(maps) + if err != nil { + return false, errors.New("修改失败") + } + + if len(orderPrescription) > 0 { + return false, errors.New("存在审核中的处方,请勿修改科室数据") + } + + userDoctorData["multi_point_status"] = 2 + userDoctorData["multi_point_fail_reason"] = "" + } + } + // 处理银行卡 if (userDoctorInfo.IdCardFront != "" || req.IdCardFront != "") && (userDoctorInfo.IdCardBack != "" || req.IdCardBack != "") && (userDoctorInfo.SignImage != "" || req.SignImage != "") { // 签名、身份证数据不为空的情况下,银行卡数据必填 @@ -520,17 +521,14 @@ func (r *UserDoctorService) PutUserDoctor(doctorId int64, req requests.PutUserDo } // 处理医生详情数据 - if userDoctorInfo == nil { - // 新增医生详情表 - if len(userDoctorInfoData) != 0 { + if len(userDoctorInfoData) != 0 { + if userDoctorInfo == nil { userDoctorInfo, err := userDoctorInfoDao.AddUserDoctorInfoByMap(tx, userDoctorInfoData) if userDoctorInfo == nil || err != nil { tx.Rollback() return false, errors.New("修改失败") } - } - } else { - if len(userDoctorInfoData) != 0 { + } else { err = userDoctorInfoDao.EditUserDoctorInfoById(tx, userDoctorInfo.DoctorInfoId, userDoctorInfoData) if err != nil { tx.Rollback() @@ -611,7 +609,9 @@ func (r *UserDoctorService) PutUserDoctor(doctorId int64, req requests.PutUserDo return false, errors.New(err.Error()) } } - } else { + } + + if doctorBankCard != nil { // 修改 doctorBankCardData := make(map[string]interface{}) // 医生银行卡数据 if bankId != 0 { @@ -674,7 +674,7 @@ func (r *UserDoctorService) PutUserDoctor(doctorId int64, req requests.PutUserDo return false, errors.New("修改失败") } - if userCaCerts != nil && len(userCaCerts) > 0 { + if len(userCaCerts) > 0 { userCaCert := userCaCerts[0] // 检测是否已经添加签章配置 if userCaCert.IsSignConfig == 1 { diff --git a/extend/verifyDun/bankCard.go b/extend/verifyDun/bankCard.go index ac779ed..e17ea61 100644 --- a/extend/verifyDun/bankCard.go +++ b/extend/verifyDun/bankCard.go @@ -1,5 +1,16 @@ package verifyDun +import ( + "encoding/json" + "errors" + "io" + "net/http" + "net/url" + "strconv" + "strings" + "time" +) + // 请求返回值 type bankCardResultResponseData struct { Code int `json:"code"` // 接口调用状态。200:正常;其它值:调用出错 @@ -16,5 +27,63 @@ type bankCardResult struct { // CheckBankCard 银行卡三/四要素认证 func CheckBankCard(name, bankCardNo, idCardNo string) (bool, error) { - return false, nil + formData := url.Values{} + formData.Set("name", name) + formData.Set("bankCardNo", bankCardNo) + formData.Set("idCardNo", idCardNo) + formData.Set("secretId", secretId) + formData.Set("businessId", "3cb726bd85104161b25613153c4fba7c") + formData.Set("version", "v1") + formData.Set("timestamp", strconv.FormatInt(time.Now().UnixNano()/1000000, 10)) + formData.Set("nonce", string(make([]byte, 32))) + formData.Set("signature", GenSignature(formData)) + + resp, err := http.Post(apiUrl+"/"+version+"/bankcard/check", "application/x-www-form-urlencoded", strings.NewReader(formData.Encode())) + if err != nil { + return false, errors.New("调用API接口失败:" + err.Error()) + } + + defer func(Body io.ReadCloser) { + _ = Body.Close() + }(resp.Body) + + body, err := io.ReadAll(resp.Body) + if err != nil { + return false, err + } + + var responseData idCardResponseData + err = json.Unmarshal(body, &responseData) + if err != nil { + // json解析失败 + return false, err + } + + if responseData.Code != 200 { + if responseData.Msg != "" { + return false, errors.New(responseData.Msg) + } else { + return false, errors.New("身份证认证失败") + } + } + + if responseData.Result.Status == 2 { + if responseData.Result.ReasonType == 2 { + return false, errors.New("持卡人信息与输入信息不一致") + } else if responseData.Result.ReasonType == 3 { + return false, errors.New("查无此银行卡") + } else if responseData.Result.ReasonType == 4 { + return false, errors.New("查无此身份证") + } else if responseData.Result.ReasonType == 5 { + return false, errors.New("手机号码格式不正确") + } else if responseData.Result.ReasonType == 6 { + return false, errors.New("银行卡号不正确") + } else if responseData.Result.ReasonType == 7 { + return false, errors.New("其他出错,请联系客服") + } else { + return false, errors.New("银行卡认证失败") + } + } + + return true, nil }