ljl 4 months ago
parent e0dafa4997
commit 10308c20d6

@ -57,7 +57,7 @@ func Create(c *gin.Context) {
return return
} }
/*func Surrend(c *gin.Context) { func Surrend(c *gin.Context) {
data := map[string]interface{}{} data := map[string]interface{}{}
result := map[string]interface{}{ result := map[string]interface{}{
"code": 200, "code": 200,
@ -66,7 +66,7 @@ func Create(c *gin.Context) {
} }
body, _ := io.ReadAll(c.Request.Body) body, _ := io.ReadAll(c.Request.Body)
if body != nil { if body != nil {
fmt.Printf("body:%s\n", body) fmt.Printf("surrend body:%s\n", body)
} }
var param suixing.RevokeParam var param suixing.RevokeParam
@ -86,7 +86,24 @@ func Create(c *gin.Context) {
return return
} }
service.OrderService.SaveClaim() revoke, err := service.OrderService.SaveRevoke(param)
if err != nil {
result["code"] = 501
result["msg"] = err.Error()
c.JSON(200, result)
return
}
ret, err := service.OrderService.ZkingRevoke(revoke)
fmt.Println("revoke ret:", ret)
if err != nil {
result["code"] = 501
result["msg"] = err.Error()
c.JSON(200, result)
return
}
c.JSON(200, result)
return
} }
func Claim(c *gin.Context) { func Claim(c *gin.Context) {
@ -117,8 +134,26 @@ func Claim(c *gin.Context) {
c.JSON(200, result) c.JSON(200, result)
return return
} }
service.OrderService.SaveClaim(param)
}*/ claim, err := service.OrderService.SaveClaim(param)
if err != nil {
result["code"] = 501
result["msg"] = err.Error()
c.JSON(200, result)
return
}
ret, err := service.OrderService.ZkingClaim(claim)
fmt.Println("claim ret:", ret)
if err != nil {
result["code"] = 501
result["msg"] = err.Error()
c.JSON(200, result)
return
}
c.JSON(200, result)
return
}
func UploadSignedFile(c *gin.Context) { func UploadSignedFile(c *gin.Context) {
result := map[string]interface{}{ result := map[string]interface{}{

@ -8,5 +8,7 @@ import (
func suixingRouteInit(r *gin.Engine) { func suixingRouteInit(r *gin.Engine) {
sxGroup := r.Group("/suixing") sxGroup := r.Group("/suixing")
sxGroup.Match([]string{"POST", "OPTIONS"}, "/gurantee/create", suixing.Create) sxGroup.Match([]string{"POST", "OPTIONS"}, "/gurantee/create", suixing.Create)
sxGroup.Match([]string{"POST", "OPTIONS"}, "/gurantee/surrend", suixing.Surrend)
sxGroup.Match([]string{"POST", "OPTIONS"}, "/gurantee/claim", suixing.Claim)
sxGroup.Match([]string{"POST", "OPTIONS"}, "/upload-signed-file", suixing.UploadSignedFile) sxGroup.Match([]string{"POST", "OPTIONS"}, "/upload-signed-file", suixing.UploadSignedFile)
} }

@ -399,7 +399,31 @@ func (s *orderService) PostToZking(orderNo string) (*zking.Result, error) {
return result, nil return result, nil
} }
func (s *orderService) ZkingClaim(claim model.Claim) (*zking.Result, error) { func (s *orderService) SaveClaim(param suixing.ClaimParam) (*model.Claim, error) {
fileList, err := json.Marshal(param.Data.FileList)
if err != nil {
return nil, err
}
claim := model.Claim{}
claim.PolicyNo = param.Data.PolicyNo
claim.BankName = param.Data.BankName
claim.AccountName = param.Data.AccountName
claim.ContactName = param.Data.ContactName
claim.ContactPhone = param.Data.ContactPhone
claim.FileList = string(fileList)
claim.BankCardNum = param.Data.BankCardNum
claim.BackPremium = param.Data.BackPremium
claim.Reason = param.Data.Reason
err = global.DB.Save(&claim).Error
if err != nil {
return nil, err
}
return &claim, nil
}
func (s *orderService) ZkingClaim(claim *model.Claim) (*zking.Result, error) {
var fileList []map[string]string var fileList []map[string]string
err := json.Unmarshal([]byte(claim.FileList), &fileList) err := json.Unmarshal([]byte(claim.FileList), &fileList)
if err != nil { if err != nil {
@ -435,7 +459,7 @@ func (s *orderService) ZkingClaim(claim model.Claim) (*zking.Result, error) {
return result, nil return result, nil
} }
func (s *orderService) saveRevoke(param suixing.RevokeParam) (*model.Revoke, error) { func (s *orderService) SaveRevoke(param suixing.RevokeParam) (*model.Revoke, error) {
fileList, err := json.Marshal(param.Data.FileList) fileList, err := json.Marshal(param.Data.FileList)
if err != nil { if err != nil {
return nil, err return nil, err
@ -459,7 +483,7 @@ func (s *orderService) saveRevoke(param suixing.RevokeParam) (*model.Revoke, err
return &revoke, nil return &revoke, nil
} }
func (s *orderService) ZkingRevoke(revoke model.Revoke) (*zking.Result, error) { func (s *orderService) ZkingRevoke(revoke *model.Revoke) (*zking.Result, error) {
var fileList []map[string]string var fileList []map[string]string
err := json.Unmarshal([]byte(revoke.FileList), &fileList) err := json.Unmarshal([]byte(revoke.FileList), &fileList)
if err != nil { if err != nil {
@ -495,30 +519,6 @@ func (s *orderService) ZkingRevoke(revoke model.Revoke) (*zking.Result, error) {
return result, nil return result, nil
} }
func (s *orderService) SaveClaim(param suixing.ClaimParam) (*model.Claim, error) {
fileList, err := json.Marshal(param.Data.FileList)
if err != nil {
return nil, err
}
claim := model.Claim{}
claim.PolicyNo = param.Data.PolicyNo
claim.BankName = param.Data.BankName
claim.AccountName = param.Data.AccountName
claim.ContactName = param.Data.ContactName
claim.ContactPhone = param.Data.ContactPhone
claim.FileList = string(fileList)
claim.BankCardNum = param.Data.BankCardNum
claim.BackPremium = param.Data.BackPremium
claim.Reason = param.Data.Reason
err = global.DB.Save(&claim).Error
if err != nil {
return nil, err
}
return &claim, nil
}
func (s *orderService) GetOrderResultByToken(token string) (*model.OrderResult, error) { func (s *orderService) GetOrderResultByToken(token string) (*model.OrderResult, error) {
order := model.Order{} order := model.Order{}
err := global.DB. err := global.DB.

Loading…
Cancel
Save