|
@@ -13,90 +13,100 @@ type HTFuturesAccountController struct {
|
|
|
controllers.WebHookController
|
|
|
}
|
|
|
|
|
|
+// // SyncCustomerRiskLevel 风险测评同步接口
|
|
|
+// // @Summary 风险测评同步接口
|
|
|
+// // @Description 风险测评同步接口
|
|
|
+// // @Success 200 {object} controllers.BaseResponse
|
|
|
+// // @router /riskLevel [post]
|
|
|
//
|
|
|
-//// SyncCustomerRiskLevel 风险测评同步接口
|
|
|
-//// @Summary 风险测评同步接口
|
|
|
-//// @Description 风险测评同步接口
|
|
|
-//// @Success 200 {object} controllers.BaseResponse
|
|
|
-//// @router /riskLevel [post]
|
|
|
-//func (h *UserController) SyncCustomerRiskLevel() {
|
|
|
-// controllers.Wrap(&h.BaseController, func() (result *controllers.WrapData, err error) {
|
|
|
-// result = h.InitWrapData("同步风险等级")
|
|
|
-// htConfig := config.GetConfig(contants.HT).(*config.HTBizConfig)
|
|
|
-// webhookRequest := new(WebhookRequest)
|
|
|
-// h.GetPostParams(webhookRequest)
|
|
|
-// privateKey, err := authUtils.ParsePrivateKey(htConfig.GetWebhookPrivateKey())
|
|
|
-// if err != nil {
|
|
|
-// err = exception.NewWithException(exception.SysError, err.Error())
|
|
|
-// logger.Error("解析私钥失败: %v", err)
|
|
|
-// h.FailedResult("解析私钥失败", result)
|
|
|
+// func (h *UserController) SyncCustomerRiskLevel() {
|
|
|
+// controllers.Wrap(&h.BaseController, func() (result *controllers.WrapData, err error) {
|
|
|
+// result = h.InitWrapData("同步风险等级")
|
|
|
+// htConfig := config.GetConfig(contants.HT).(*config.HTBizConfig)
|
|
|
+// webhookRequest := new(WebhookRequest)
|
|
|
+// h.GetPostParams(webhookRequest)
|
|
|
+// privateKey, err := authUtils.ParsePrivateKey(htConfig.GetWebhookPrivateKey())
|
|
|
+// if err != nil {
|
|
|
+// err = exception.NewWithException(exception.SysError, err.Error())
|
|
|
+// logger.Error("解析私钥失败: %v", err)
|
|
|
+// h.FailedResult("解析私钥失败", result)
|
|
|
+// return
|
|
|
+// }
|
|
|
+// decodeData, err := authUtils.DecryptWithRSA(privateKey, webhookRequest.Data)
|
|
|
+// if err != nil {
|
|
|
+// err = exception.NewWithException(exception.SysError, err.Error())
|
|
|
+// logger.Error("解密请求体失败: %v", err)
|
|
|
+// h.FailedResult("解密请求体失败", result)
|
|
|
+// return
|
|
|
+// }
|
|
|
+// syncCustomerRiskLevelReq := new(SyncCustomerRiskLevelReq)
|
|
|
+// err = json.Unmarshal(decodeData, syncCustomerRiskLevelReq)
|
|
|
+// if err != nil {
|
|
|
+// err = exception.NewWithException(exception.SyncRiskError, err.Error())
|
|
|
+// logger.Error("解析请求体失败: %v", err)
|
|
|
+// h.FailedResult("解析请求体失败", result)
|
|
|
+// return
|
|
|
+// }
|
|
|
+// custInfo := syncCustomerRiskLevelReq.CustInfo
|
|
|
+// riskInfo := syncCustomerRiskLevelReq.RiskInfo
|
|
|
+// if custInfo.ClientName == "" {
|
|
|
+// err = exception.New(exception.SyncRiskError)
|
|
|
+// h.FailedResult("用户名字不能为空", result)
|
|
|
+// return
|
|
|
+// }
|
|
|
+// if custInfo.MobileTel == "" {
|
|
|
+// err = exception.New(exception.SyncRiskError)
|
|
|
+// h.FailedResult("手机号码不能为空", result)
|
|
|
+// return
|
|
|
+// }
|
|
|
+// if custInfo.IdNo == "" {
|
|
|
+// err = exception.New(exception.SyncRiskError)
|
|
|
+// h.FailedResult("身份证号不能为空", result)
|
|
|
+// return
|
|
|
+// }
|
|
|
+// //if !utils.IsValidIDCard(custInfo.IdNo) && !utils.IsValidOldIDCard(custInfo.IdNo) {
|
|
|
+// // err = exception.New(exception.SyncRiskError)
|
|
|
+// // h.FailedResult("身份证号不合法", result)
|
|
|
+// // return
|
|
|
+// //}
|
|
|
+// if riskInfo.CorpRiskLevel == "" {
|
|
|
+// err = exception.New(exception.SyncRiskError)
|
|
|
+// h.FailedResult("风险等级不能为空", result)
|
|
|
+// return
|
|
|
+// }
|
|
|
+// if riskInfo.CorpEndDate == "" {
|
|
|
+// err = exception.New(exception.SyncRiskError)
|
|
|
+// h.FailedResult("风险测评有效结束日期不能为空", result)
|
|
|
+// return
|
|
|
+// }
|
|
|
+// err = userService.UpdateRiskLevelInfo(userService.RiskLevelInfoDTO{
|
|
|
+// Name: custInfo.ClientName,
|
|
|
+// PhoneNumber: custInfo.MobileTel,
|
|
|
+// RiskLevel: riskInfo.CorpRiskLevel,
|
|
|
+// RiskValidEndDate: riskInfo.CorpEndDate,
|
|
|
+// })
|
|
|
+// if err != nil {
|
|
|
+// logger.ErrorWithTraceId(h.Ctx, err.Error())
|
|
|
+// h.FailedResult(err.Error(), result)
|
|
|
+// err = exception.New(exception.SyncRiskError)
|
|
|
+// return
|
|
|
+// }
|
|
|
+// logger.InfoWithTraceId(h.Ctx, err.Error())
|
|
|
+// result = h.InitWrapData("同步风险等级成功")
|
|
|
+// h.SuccessResult("success", syncCustomerRiskLevelReq, result)
|
|
|
// return
|
|
|
-// }
|
|
|
-// decodeData, err := authUtils.DecryptWithRSA(privateKey, webhookRequest.Data)
|
|
|
-// if err != nil {
|
|
|
-// err = exception.NewWithException(exception.SysError, err.Error())
|
|
|
-// logger.Error("解密请求体失败: %v", err)
|
|
|
-// h.FailedResult("解密请求体失败", result)
|
|
|
-// return
|
|
|
-// }
|
|
|
-// syncCustomerRiskLevelReq := new(SyncCustomerRiskLevelReq)
|
|
|
-// err = json.Unmarshal(decodeData, syncCustomerRiskLevelReq)
|
|
|
-// if err != nil {
|
|
|
-// err = exception.NewWithException(exception.SyncRiskError, err.Error())
|
|
|
-// logger.Error("解析请求体失败: %v", err)
|
|
|
-// h.FailedResult("解析请求体失败", result)
|
|
|
-// return
|
|
|
-// }
|
|
|
-// custInfo := syncCustomerRiskLevelReq.CustInfo
|
|
|
-// riskInfo := syncCustomerRiskLevelReq.RiskInfo
|
|
|
-// if custInfo.ClientName == "" {
|
|
|
-// err = exception.New(exception.SyncRiskError)
|
|
|
-// h.FailedResult("用户名字不能为空", result)
|
|
|
-// return
|
|
|
-// }
|
|
|
-// if custInfo.MobileTel == "" {
|
|
|
-// err = exception.New(exception.SyncRiskError)
|
|
|
-// h.FailedResult("手机号码不能为空", result)
|
|
|
-// return
|
|
|
-// }
|
|
|
-// if custInfo.IdNo == "" {
|
|
|
-// err = exception.New(exception.SyncRiskError)
|
|
|
-// h.FailedResult("身份证号不能为空", result)
|
|
|
-// return
|
|
|
-// }
|
|
|
-// //if !utils.IsValidIDCard(custInfo.IdNo) && !utils.IsValidOldIDCard(custInfo.IdNo) {
|
|
|
-// // err = exception.New(exception.SyncRiskError)
|
|
|
-// // h.FailedResult("身份证号不合法", result)
|
|
|
-// // return
|
|
|
-// //}
|
|
|
-// if riskInfo.CorpRiskLevel == "" {
|
|
|
-// err = exception.New(exception.SyncRiskError)
|
|
|
-// h.FailedResult("风险等级不能为空", result)
|
|
|
-// return
|
|
|
-// }
|
|
|
-// if riskInfo.CorpEndDate == "" {
|
|
|
-// err = exception.New(exception.SyncRiskError)
|
|
|
-// h.FailedResult("风险测评有效结束日期不能为空", result)
|
|
|
-// return
|
|
|
-// }
|
|
|
-// err = userService.UpdateRiskLevelInfo(userService.RiskLevelInfoDTO{
|
|
|
-// Name: custInfo.ClientName,
|
|
|
-// PhoneNumber: custInfo.MobileTel,
|
|
|
-// RiskLevel: riskInfo.CorpRiskLevel,
|
|
|
-// RiskValidEndDate: riskInfo.CorpEndDate,
|
|
|
// })
|
|
|
-// if err != nil {
|
|
|
-// logger.ErrorWithTraceId(h.Ctx, err.Error())
|
|
|
-// h.FailedResult(err.Error(), result)
|
|
|
-// err = exception.New(exception.SyncRiskError)
|
|
|
-// return
|
|
|
-// }
|
|
|
-// logger.InfoWithTraceId(h.Ctx, err.Error())
|
|
|
-// result = h.InitWrapData("同步风险等级成功")
|
|
|
-// h.SuccessResult("success", syncCustomerRiskLevelReq, result)
|
|
|
-// return
|
|
|
-// })
|
|
|
-//}
|
|
|
+// }
|
|
|
+var (
|
|
|
+ riskMappingMap = map[string]string{
|
|
|
+ "0": "C1",
|
|
|
+ "1": "C1",
|
|
|
+ "2": "C2",
|
|
|
+ "3": "C3",
|
|
|
+ "4": "C4",
|
|
|
+ "5": "C5",
|
|
|
+ }
|
|
|
+)
|
|
|
|
|
|
// SyncCustomerRiskLevel 风险测评同步接口
|
|
|
// @Summary 风险测评同步接口
|
|
@@ -146,6 +156,7 @@ func (h *HTFuturesAccountController) SyncCustomerRiskLevel() {
|
|
|
h.FailedResult("风险测评有效结束日期不合法["+riskInfo.CorpEndDate+"]", result)
|
|
|
return
|
|
|
}
|
|
|
+
|
|
|
err = userService.UpdateRiskLevelInfo(userService.RiskLevelInfoDTO{
|
|
|
Name: custInfo.ClientName,
|
|
|
PhoneNumber: custInfo.DealMobileTel,
|
|
@@ -208,11 +219,17 @@ func (h *HTFuturesAccountController) SyncCustomerAccountInfo() {
|
|
|
h.FailedResult("风险测评有效结束日期不能为空", result)
|
|
|
return
|
|
|
}
|
|
|
-
|
|
|
+ if risk, ok := riskMappingMap[riskInfo.CorpRiskLevel]; ok {
|
|
|
+ riskInfo.CorpRiskLevel = risk
|
|
|
+ } else {
|
|
|
+ err = exception.New(exception.SyncRiskError)
|
|
|
+ h.FailedResult(fmt.Sprintf("风险等级不合法,应答结果:%s", riskInfo.CorpRiskLevel), result)
|
|
|
+ return
|
|
|
+ }
|
|
|
err = userService.UpdateRiskLevelInfo(userService.RiskLevelInfoDTO{
|
|
|
Name: custInfo.ClientName,
|
|
|
PhoneNumber: custInfo.MobileTel,
|
|
|
- RiskLevel: fmt.Sprintf("C%s", riskInfo.CorpRiskLevel),
|
|
|
+ RiskLevel: riskInfo.CorpRiskLevel,
|
|
|
RiskValidEndDate: riskInfo.CorpEndDate,
|
|
|
})
|
|
|
if err != nil {
|