|
|
|
@ -363,6 +363,126 @@ func (s *orderService) PostToZking(orderSn string) (*zking.Result, error) {
|
|
|
|
|
return result, nil
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (s *orderService) ZkingClaim(claim model.Claim) (*zking.Result, error) {
|
|
|
|
|
var fileList []map[string]string
|
|
|
|
|
err := json.Unmarshal([]byte(claim.FileList), &fileList)
|
|
|
|
|
if err != nil {
|
|
|
|
|
return nil, err
|
|
|
|
|
}
|
|
|
|
|
createData := suixing.ClaimData{
|
|
|
|
|
PolicyNo: claim.PolicyNo,
|
|
|
|
|
BankName: claim.BankName,
|
|
|
|
|
AccountName: claim.AccountName,
|
|
|
|
|
ContactName: claim.ContactName,
|
|
|
|
|
ContactPhone: claim.ContactPhone,
|
|
|
|
|
FileList: fileList,
|
|
|
|
|
BankCardNum: claim.BankCardNum,
|
|
|
|
|
BackPremium: claim.BackPremium,
|
|
|
|
|
Reason: claim.Reason,
|
|
|
|
|
}
|
|
|
|
|
data, _ := json.Marshal(createData)
|
|
|
|
|
|
|
|
|
|
param := zking.CommonParam{
|
|
|
|
|
AppID: global.Config.Zking.AppID,
|
|
|
|
|
RequestID: utils.GenerateNo("requestId"),
|
|
|
|
|
Timestamp: strconv.Itoa(int(time.Now().Unix())),
|
|
|
|
|
Version: "1.0.0",
|
|
|
|
|
Data: string(data),
|
|
|
|
|
}
|
|
|
|
|
result, err := zking.InsureApi.SuixingClaim(param)
|
|
|
|
|
if err != nil {
|
|
|
|
|
return nil, err
|
|
|
|
|
}
|
|
|
|
|
if result.Code != "200" {
|
|
|
|
|
return nil, e.NewError(result.Msg)
|
|
|
|
|
}
|
|
|
|
|
return result, nil
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (s *orderService) saveRevoke(param suixing.RevokeParam) (*model.Revoke, error) {
|
|
|
|
|
fileList, err := json.Marshal(param.Data.FileList)
|
|
|
|
|
if err != nil {
|
|
|
|
|
return nil, err
|
|
|
|
|
}
|
|
|
|
|
revoke := model.Revoke{}
|
|
|
|
|
revoke.PolicyNo = param.Data.PolicyNo
|
|
|
|
|
revoke.BankName = param.Data.BankName
|
|
|
|
|
revoke.AccountName = param.Data.AccountName
|
|
|
|
|
revoke.ContactName = param.Data.ContactName
|
|
|
|
|
revoke.ContactPhone = param.Data.ContactPhone
|
|
|
|
|
revoke.FileList = string(fileList)
|
|
|
|
|
revoke.BankCardNum = param.Data.BankCardNum
|
|
|
|
|
revoke.BackPremium = param.Data.BackPremium
|
|
|
|
|
revoke.Reason = param.Data.Reason
|
|
|
|
|
|
|
|
|
|
err = global.DB.Save(&revoke).Error
|
|
|
|
|
|
|
|
|
|
if err != nil {
|
|
|
|
|
return nil, err
|
|
|
|
|
}
|
|
|
|
|
return &revoke, nil
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func (s *orderService) ZkingRevoke(revoke model.Revoke) (*zking.Result, error) {
|
|
|
|
|
var fileList []map[string]string
|
|
|
|
|
err := json.Unmarshal([]byte(revoke.FileList), &fileList)
|
|
|
|
|
if err != nil {
|
|
|
|
|
return nil, err
|
|
|
|
|
}
|
|
|
|
|
createData := suixing.ClaimData{
|
|
|
|
|
PolicyNo: revoke.PolicyNo,
|
|
|
|
|
BankName: revoke.BankName,
|
|
|
|
|
AccountName: revoke.AccountName,
|
|
|
|
|
ContactName: revoke.ContactName,
|
|
|
|
|
ContactPhone: revoke.ContactPhone,
|
|
|
|
|
FileList: fileList,
|
|
|
|
|
BankCardNum: revoke.BankCardNum,
|
|
|
|
|
BackPremium: revoke.BackPremium,
|
|
|
|
|
Reason: revoke.Reason,
|
|
|
|
|
}
|
|
|
|
|
data, _ := json.Marshal(createData)
|
|
|
|
|
|
|
|
|
|
param := zking.CommonParam{
|
|
|
|
|
AppID: global.Config.Zking.AppID,
|
|
|
|
|
RequestID: utils.GenerateNo("requestId"),
|
|
|
|
|
Timestamp: strconv.Itoa(int(time.Now().Unix())),
|
|
|
|
|
Version: "1.0.0",
|
|
|
|
|
Data: string(data),
|
|
|
|
|
}
|
|
|
|
|
result, err := zking.InsureApi.SuixingClaim(param)
|
|
|
|
|
if err != nil {
|
|
|
|
|
return nil, err
|
|
|
|
|
}
|
|
|
|
|
if result.Code != "200" {
|
|
|
|
|
return nil, e.NewError(result.Msg)
|
|
|
|
|
}
|
|
|
|
|
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) {
|
|
|
|
|
order := model.Order{}
|
|
|
|
|
err := global.DB.
|
|
|
|
@ -535,6 +655,11 @@ func (s *orderService) SaveOrderResult(data zking.PushCallbackData) (*model.Orde
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
orderResult := model.OrderResult{}
|
|
|
|
|
err = global.DB.Where("order_sn", data.OrderSn).First(&orderResult).Error
|
|
|
|
|
if err != nil && !errors.Is(err, gorm.ErrRecordNotFound) {
|
|
|
|
|
return nil, err
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
orderResult.OrderSn = data.OrderSn
|
|
|
|
|
orderResult.PolicyNo = data.PolicyNo
|
|
|
|
|
orderResult.Status = data.Status
|
|
|
|
|