123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158 |
- package web_hook
- import (
- logger "eta/eta_mini_ht_api/common/component/log"
- "eta/eta_mini_ht_api/common/exception"
- "eta/eta_mini_ht_api/controllers"
- userService "eta/eta_mini_ht_api/domian/user"
- )
- type HTFuturesAccountController struct {
- controllers.WebHookController
- }
- // SyncCustomerRiskLevel 风险测评同步接口
- // @Summary 风险测评同步接口
- // @Description 风险测评同步接口
- // @Success 200 {object} controllers.BaseResponse
- // @router /v1/syncRiskLevel/ [post]
- func (h *HTFuturesAccountController) SyncCustomerRiskLevel() {
- controllers.WrapWebhook(&h.WebHookController, func() (result *controllers.WrapData, err error) {
- result = h.InitWrapData("同步风险等级")
- syncCustomerRiskLevelReq := new(SyncCustomerRiskLevelReq)
- h.GetPostParams(syncCustomerRiskLevelReq)
- 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
- })
- }
- // SyncCustomerAccountInfo 开户信息同步接口
- // @Summary 开户信息同步接口
- // @Description 开户信息同步接口
- // @Success 200 {object} controllers.BaseResponse
- // @router /v1/syncAccountInfo/ [post]
- func (h *HTFuturesAccountController) SyncCustomerAccountInfo() {
- controllers.WrapWebhook(&h.WebHookController, func() (result *controllers.WrapData, err error) {
- result = h.InitWrapData("同步风险等级")
- syncCustomerRiskLevelReq := new(SyncCustomerRiskLevelReq)
- h.GetPostParams(syncCustomerRiskLevelReq)
- 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
- })
- }
- type SyncCustomerRiskLevelReq struct {
- CustInfo CustInfo `json:"custInfo"`
- RiskInfo RiskInfo `json:"riskInfo"`
- }
- type CustInfo struct {
- MobileTel string `json:"mobile_tel"`
- ClientName string `json:"client_name"`
- IdKind string `json:"id_kind"`
- IdNo string `json:"id_no"`
- }
- type RiskInfo struct {
- CorpBeginDate string `json:"corp_begin_date"`
- CorpEndDate string `json:"corp_end_date"`
- UserInvestTerm string `json:"user_invest_term"`
- UserInvestKind string `json:"user_invest_kind"`
- CorpRiskLevel string `json:"corp_risk_level"`
- }
- type SyncCustomerAccountInfoReq struct {
- CustInfo CustInfo `json:"custInfo"`
- RiskInfo RiskInfo `json:"riskInfo"`
- }
|