|
@@ -312,6 +312,77 @@ func (h *HTFuturesAccountController) SyncCustomerAccountInfo() {
|
|
|
})
|
|
|
}
|
|
|
|
|
|
+// SyncCustomerIDInfo 证件信息同步接口
|
|
|
+// @Summary证件信息同步接口
|
|
|
+// @Description 证件信息同步接口
|
|
|
+// @Success 200 {object} controllers.BaseResponse
|
|
|
+// @router /v1/syncIDInfo/ [post]
|
|
|
+func (h *HTFuturesAccountController) SyncCustomerIDInfo() {
|
|
|
+ controllers.WrapWebhook(&h.WebHookController, func() (result *controllers.WrapData, err error) {
|
|
|
+ result = h.InitWrapData("证件信息信息")
|
|
|
+ syncCustomerRiskLevelReq := new(IDInfoReq)
|
|
|
+ h.GetPostParams(syncCustomerRiskLevelReq)
|
|
|
+ if ThirdRateLimitFilter(syncCustomerRiskLevelReq.IdNo) != 200 {
|
|
|
+ err = exception.New(exception.TooManyRequest)
|
|
|
+ h.FailedResult("接口请求太频繁,请稍后重试", result)
|
|
|
+ return
|
|
|
+ }
|
|
|
+
|
|
|
+ if syncCustomerRiskLevelReq.MobileTel == "" {
|
|
|
+ err = exception.New(exception.SyncAccountStatusError)
|
|
|
+ h.FailedResult("手机号码不能为空", result)
|
|
|
+ return
|
|
|
+ }
|
|
|
+ if _, ok := idKindMap[syncCustomerRiskLevelReq.IdKind]; !ok {
|
|
|
+ err = exception.New(exception.SyncAccountStatusError)
|
|
|
+ validIdKind := make([]string, 0)
|
|
|
+ for _, v := range idKindMap {
|
|
|
+ validIdKind = append(validIdKind, string(v))
|
|
|
+ }
|
|
|
+ h.FailedResult(fmt.Sprintf("证件类型不合法,当前只支持[%s]", strings.Join(validIdKind, ",")), result)
|
|
|
+ return
|
|
|
+ }
|
|
|
+ if syncCustomerRiskLevelReq.IdNo == "" {
|
|
|
+ err = exception.New(exception.SyncAccountStatusError)
|
|
|
+ h.FailedResult("证号号码不能为空", result)
|
|
|
+ return
|
|
|
+ }
|
|
|
+ idBeginDate, parseErr := time.Parse(time.DateOnly, syncCustomerRiskLevelReq.IdBeginDate)
|
|
|
+ if parseErr != nil {
|
|
|
+ err = exception.New(exception.SyncAccountStatusError)
|
|
|
+ h.FailedResult("身份证有效开始时间不合法["+syncCustomerRiskLevelReq.IdBeginDate+"]", result)
|
|
|
+ return
|
|
|
+ }
|
|
|
+ idEndDate, parseErr := time.Parse(time.DateOnly, syncCustomerRiskLevelReq.IdEndDate)
|
|
|
+ if parseErr != nil {
|
|
|
+ err = exception.New(exception.SyncAccountStatusError)
|
|
|
+ h.FailedResult("身份证有效结束时间不合法["+syncCustomerRiskLevelReq.IdEndDate+"]", result)
|
|
|
+ return
|
|
|
+ }
|
|
|
+ if idEndDate.Before(idBeginDate) {
|
|
|
+ err = exception.New(exception.SyncAccountStatusError)
|
|
|
+ h.FailedResult("身份证有效结束时间不合法,开始日期不能大于结束日期", result)
|
|
|
+ return
|
|
|
+ }
|
|
|
+ err = accountService.UpdateUserIDINFO(accountService.IDInfoDTO{
|
|
|
+ MobileTel: syncCustomerRiskLevelReq.MobileTel,
|
|
|
+ IdKind: syncCustomerRiskLevelReq.IdKind,
|
|
|
+ IdNo: syncCustomerRiskLevelReq.IdNo,
|
|
|
+ IdBeginDate: idBeginDate,
|
|
|
+ IdEndDate: idEndDate,
|
|
|
+ })
|
|
|
+ if err != nil {
|
|
|
+ logger.ErrorWithTraceId(h.Ctx, err.Error())
|
|
|
+ h.FailedResult(err.Error(), result)
|
|
|
+ err = exception.New(exception.SyncAccountStatusError)
|
|
|
+ return
|
|
|
+ }
|
|
|
+ result = h.InitWrapData("同步开户信息成功")
|
|
|
+ h.SuccessResult("success", syncCustomerRiskLevelReq, result)
|
|
|
+ return
|
|
|
+ })
|
|
|
+}
|
|
|
+
|
|
|
type SyncCustomerRiskLevelReq struct {
|
|
|
CustInfo CustInfo `json:"custInfo"`
|
|
|
RiskInfo RiskInfo `json:"riskInfo"`
|
|
@@ -368,3 +439,10 @@ type AccountOpenInfoReq struct {
|
|
|
ErrorMessage string `json:"error_message"`
|
|
|
Timestamp int64 `json:"timestamp"`
|
|
|
}
|
|
|
+type IDInfoReq struct {
|
|
|
+ MobileTel string `json:"mobile_tel"`
|
|
|
+ IdKind int `json:"id_kind"`
|
|
|
+ IdNo string `json:"id_no"`
|
|
|
+ IdBeginDate string `json:"id_begin_date"`
|
|
|
+ IdEndDate string `json:"id_end_date"`
|
|
|
+}
|