elf 3 months ago
parent 4bf949e748
commit b0776ebe71

@ -10,6 +10,7 @@ import (
"insure/model"
"insure/service"
"insure/third_party/signer"
"insure/utils"
"insure/utils/result"
)
@ -209,3 +210,8 @@ func GetPayInfo(c *gin.Context) (result.Data, error) {
}
return result.Data{"PayInfo": payInfo}, nil
}
func GetOrderNo(c *gin.Context) (result.Data, error) {
orderNo := utils.GenerateNo("order")
return result.Data{"orderNo": orderNo}, nil
}

@ -64,11 +64,16 @@ func Surrend(c *gin.Context) {
"msg": "成功",
"data": data,
}
isTest := c.DefaultQuery("isTest", "0")
body, _ := io.ReadAll(c.Request.Body)
if body != nil {
fmt.Printf("surrend body:%s\n", body)
}
if isTest == "1" {
body = []byte("{\"requestid\":\"c11cfbe1944a40ad847b396ff5261291\",\"appid\":\"zijin\",\"timestamp\":\"1721113249\",\"version\":\"1.0.0\",\"sign\":\"744dfc008c1955f94188450ac24c71aaf3f74bf2\",\"data\":{\"policyNo\":\"21122235000024000020\",\"bankName\":\"中国建设银行\",\"accountName\":\"湖南弘湘建设工程管理有限公司\",\"bankCardNum\":\"6217001820001592123\",\"backPremium\":\"5000.00\",\"contactName\":\"李一一\",\"contactPhone\":\"18120815541\",\"fileList\":[],\"reason\":\"\"}}")
}
var param suixing.RevokeParam
err := json.Unmarshal(body, &param)
if err != nil {

@ -19,12 +19,13 @@ import (
func checkParam(c *gin.Context) (*zking.CommonParam, error) {
body, _ := io.ReadAll(c.Request.Body)
if body != nil {
fmt.Printf("push body:%s\n", body)
fmt.Printf("zking callback body:%s\n", body)
}
isTest := c.DefaultQuery("isTest", "0")
if isTest == "1" {
str := "{\"data\":\"{\\\"msg\\\":\\\"成功\\\",\\\"policy_no\\\":\\\"2112223500002400001E\\\",\\\"code\\\":\\\"200\\\",\\\"ordersn\\\":\\\"565e3dfef7cb47e592c7f1f815915bbf\\\",\\\"gurantee_link\\\":\\\"https://test-open.zking.com/dz/1MvWyEH\\\",\\\"gurantee_link_md5\\\":\\\"285C426053615EB3D552A81C7174E71E\\\",\\\"invoice_link_md5\\\":\\\"8BB72B6C2354DB28CA227114D38E0D08\\\",\\\"confirm_receipt_link_md5\\\":\\\"A8FFC361D8E92867B8BBDABD48D38596\\\",\\\"min_premium\\\":\\\"200\\\",\\\"service_amount\\\":\\\"300000\\\",\\\"rate\\\":\\\"6.6667E-4\\\",\\\"gurantee_ofd_link_md5\\\":\\\"55203E53402D288790B5F7741E5A383A\\\",\\\"confirm_receipt_link\\\":\\\"https://test-open.zking.com/dz/1MvWyEI\\\",\\\"gurantee_ofd_link\\\":\\\"https://oss.test-open.zking.com/external/20240704/2361857da50c4c3ea4a74f908d911a57.ofd\\\",\\\"invoice_link\\\":\\\"http://oss.open.zking.com/static/2022-05-31/f185af975ef545898912f441f0b3a9ef.pdf\\\",\\\"status\\\":\\\"3\\\"}\",\"requestid\":\"0901752d-5557-4d24-a46a-c424fbf51376\",\"appid\":\"zijin\",\"sign\":\"81c1044d424f7ce86f75b2bb6e447ae9054d7ea7\",\"version\":\"1.0.0\",\"timestamp\":\"1720099217019\"}"
//str := "{\"data\":\"{\\\"msg\\\":\\\"成功\\\",\\\"policy_no\\\":\\\"2112223500002400001E\\\",\\\"code\\\":\\\"200\\\",\\\"ordersn\\\":\\\"565e3dfef7cb47e592c7f1f815915bbf\\\",\\\"gurantee_link\\\":\\\"https://test-open.zking.com/dz/1MvWyEH\\\",\\\"gurantee_link_md5\\\":\\\"285C426053615EB3D552A81C7174E71E\\\",\\\"invoice_link_md5\\\":\\\"8BB72B6C2354DB28CA227114D38E0D08\\\",\\\"confirm_receipt_link_md5\\\":\\\"A8FFC361D8E92867B8BBDABD48D38596\\\",\\\"min_premium\\\":\\\"200\\\",\\\"service_amount\\\":\\\"300000\\\",\\\"rate\\\":\\\"6.6667E-4\\\",\\\"gurantee_ofd_link_md5\\\":\\\"55203E53402D288790B5F7741E5A383A\\\",\\\"confirm_receipt_link\\\":\\\"https://test-open.zking.com/dz/1MvWyEI\\\",\\\"gurantee_ofd_link\\\":\\\"https://oss.test-open.zking.com/external/20240704/2361857da50c4c3ea4a74f908d911a57.ofd\\\",\\\"invoice_link\\\":\\\"http://oss.open.zking.com/static/2022-05-31/f185af975ef545898912f441f0b3a9ef.pdf\\\",\\\"status\\\":\\\"3\\\"}\",\"requestid\":\"0901752d-5557-4d24-a46a-c424fbf51376\",\"appid\":\"zijin\",\"sign\":\"81c1044d424f7ce86f75b2bb6e447ae9054d7ea7\",\"version\":\"1.0.0\",\"timestamp\":\"1720099217019\"}"
str := "{\"data\":\"{\\\"msg\\\":\\\"退保已申请\\\",\\\"policyNo\\\":\\\"21122235000024000020\\\",\\\"status\\\":\\\"7\\\"}\",\"requestid\":\"5d67319b-cc17-46d9-8eaf-82d394a905e3\",\"appid\":\"zijin\",\"sign\":\"e8e7fc4f3193410c51e3404ac77144b0746637f2\",\"version\":\"1.0.0\",\"timestamp\":\"1721143798688\"}"
body = []byte(str)
}
@ -43,6 +44,7 @@ func checkParam(c *gin.Context) (*zking.CommonParam, error) {
}
func Push(c *gin.Context) {
fmt.Println("push callback:")
data := map[string]interface{}{}
result := map[string]interface{}{
"code": 200,

@ -15,5 +15,7 @@ type OrderQueryRequest struct {
ApplicantContactName string `form:"applicantContactName"`
ApplicantContactMobile string `form:"applicantContactMobile"`
PolicyNo string `form:"policyNo"`
InsureTimeStart string `form:"insureTimeStart"`
InsureTimeEnd string `form:"insureTimeEnd"`
CreatedAt string `form:"createdAt"`
}

BIN
insure

Binary file not shown.

@ -39,3 +39,18 @@ func (a Order) MarshalJSON() ([]byte, error) {
Alias: (*Alias)(&a),
})
}
func (a Order) GetStatusText() string {
if a.Status == "submitted" {
return "待支付"
} else if a.Status == "initial" {
return "待提交"
} else if a.Status == "payed" {
return "已出函"
} else if a.Status == "generated" {
return "待提交"
} else if a.Status == "signed" {
return "待提交"
}
return "待提交"
}

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

@ -19,4 +19,5 @@ func webRouteInit(r *gin.Engine) {
webGroup.Match([]string{"GET", "OPTIONS"}, "/get-order-status", result.Json(h5.GetOrderStatus))
webGroup.Match([]string{"GET", "OPTIONS"}, "/get-pay-info", result.Json(h5.GetPayInfo))
webGroup.Match([]string{"POST", "OPTIONS"}, "/generate-sign-file", result.Json(h5.GenerateSignFile))
webGroup.Match([]string{"GET", "OPTIONS"}, "/get-order-no", result.Json(h5.GetOrderNo))
}

@ -400,11 +400,15 @@ func (s *orderService) PostToZking(orderNo string) (*zking.Result, error) {
}
func (s *orderService) SaveClaim(param suixing.ClaimParam) (*model.Claim, error) {
claim := model.Claim{}
err := global.DB.Where("policy_no", param.Data.PolicyNo).First(&claim).Error
if err != nil && !e.Is(err, gorm.ErrRecordNotFound) {
return nil, err
}
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
@ -460,11 +464,15 @@ func (s *orderService) ZkingClaim(claim *model.Claim) (*zking.Result, error) {
}
func (s *orderService) SaveRevoke(param suixing.RevokeParam) (*model.Revoke, error) {
revoke := model.Revoke{}
err := global.DB.Where("policy_no", param.Data.PolicyNo).First(&revoke).Error
if err != nil && !e.Is(err, gorm.ErrRecordNotFound) {
return nil, err
}
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
@ -568,65 +576,75 @@ func (s *orderService) buildQuery(req manage.OrderQueryRequest) *gorm.DB {
if req.OrderSn != "" {
tx = tx.Where("order_sn", req.OrderSn)
}
if req.OrderNo != "" {
tx = tx.Where("order_no", req.OrderNo)
}
if req.InsureTimeStart != "" && req.InsureTimeEnd != "" {
startInsureTime := req.InsureTimeStart + " 00:00:00"
endInsureTime := req.InsureTimeEnd + " 23:59:59"
var orderSns []string
global.DB.Model(&model.OrderResult{}).Where("created_at >= ?", startInsureTime).Where("created_at <= ?", endInsureTime).Pluck("order_sn", &orderSns)
tx = tx.Where("order_sn in (?)", orderSns)
}
if req.AssuredName != "" {
var orderSns []string
global.DB.Model(&model.Assured{}).Where("assured_name", req.AssuredName).Pluck("order_sn", &orderSns)
tx = tx.Where("order_sn", orderSns)
tx = tx.Where("order_sn in (?)", orderSns)
}
if req.AssuredCreditCode != "" {
var orderSns []string
global.DB.Model(&model.Assured{}).Where("credit_code", req.AssuredCreditCode).Pluck("order_sn", &orderSns)
tx = tx.Where("order_sn", orderSns)
tx = tx.Where("order_sn in (?)", orderSns)
}
if req.AssuredContactName != "" {
var orderSns []string
global.DB.Model(&model.Assured{}).Where("contact_name", req.AssuredContactName).Pluck("order_sn", &orderSns)
tx = tx.Where("order_sn", orderSns)
tx = tx.Where("order_sn in (?)", orderSns)
}
if req.AssuredContactMobile != "" {
var orderSns []string
global.DB.Model(&model.Assured{}).Where("contact_mobile", req.AssuredContactMobile).Pluck("order_sn", &orderSns)
tx = tx.Where("order_sn", orderSns)
tx = tx.Where("order_sn in (?)", orderSns)
}
if req.ProjectName != "" {
var orderSns []string
global.DB.Model(&model.Project{}).Where("name", req.ProjectName).Pluck("order_sn", &orderSns)
tx = tx.Where("order_sn", orderSns)
tx = tx.Where("order_sn in (?)", orderSns)
}
if req.TpId != "" {
var orderSns []string
global.DB.Model(&model.Project{}).Where("tp_id", req.TpId).Pluck("order_sn", &orderSns)
tx = tx.Where("order_sn", orderSns)
tx = tx.Where("order_sn in (?)", orderSns)
}
if req.ApplicantName != "" {
var orderSns []string
global.DB.Model(&model.Applicant{}).Where("applicant_name", req.ApplicantName).Pluck("order_sn", &orderSns)
tx = tx.Where("order_sn", orderSns)
tx = tx.Where("order_sn in (?)", orderSns)
}
if req.ApplicantName != "" {
var orderSns []string
global.DB.Model(&model.Applicant{}).Where("applicant_name", req.ApplicantName).Pluck("order_sn", &orderSns)
tx = tx.Where("order_sn", orderSns)
tx = tx.Where("order_sn in (?)", orderSns)
}
if req.AssuredCreditCode != "" {
var orderSns []string
global.DB.Model(&model.Applicant{}).Where("credit_code", req.AssuredCreditCode).Pluck("order_sn", &orderSns)
tx = tx.Where("order_sn", orderSns)
tx = tx.Where("order_sn in (?)", orderSns)
}
if req.AssuredContactName != "" {
var orderSns []string
global.DB.Model(&model.Applicant{}).Where("contact_name", req.AssuredContactName).Pluck("order_sn", &orderSns)
tx = tx.Where("order_sn", orderSns)
tx = tx.Where("order_sn in (?)", orderSns)
}
if req.AssuredContactMobile != "" {
var orderSns []string
global.DB.Model(&model.Applicant{}).Where("contact_mobile", req.AssuredContactMobile).Pluck("order_sn", &orderSns)
tx = tx.Where("order_sn", orderSns)
tx = tx.Where("order_sn in (?)", orderSns)
}
if req.PolicyNo != "" {
var orderSns []string
global.DB.Model(&model.OrderResult{}).Where("policy_no", req.PolicyNo).Pluck("order_sn", &orderSns)
tx = tx.Where("order_sn", orderSns)
tx = tx.Where("order_sn in (?)", orderSns)
}
return tx
}
@ -637,7 +655,7 @@ func (s *orderService) GenerateOrdersExcel(req manage.OrderQueryRequest) *exceli
tx := s.buildQuery(req)
f := excel.NewFile()
headers := []string{"订单号", "项目编号", "项目名称", "招标人名称", "招标联系人", "招标人身份证", "招标联系手机", "投标人名称", "投标联系人", "投标人身份证", "投标联系手机", "保单号", "下单时间"}
headers := []string{"订单号", "项目订单编号", "项目来源", "招标项目编号", "项目名称", "保险公司", "保险产品", "保/批单号", "招标人", "投标人", "出函时间", "起保时间", "保函天数", "保费", "保额", "保单状态"}
excel.SetSimpleHeaders(headers, "Sheet1", f)
for {
orders := make([]model.Order, pageSize)
@ -661,22 +679,27 @@ func (orderService) buildOrdersExcel(orders []model.Order, sheet string, f *exce
for _, order := range orders {
col := 0
policyNo := ""
policyCreatedAt := ""
if order.OrderResult != nil {
policyNo = order.OrderResult.PolicyNo
policyCreatedAt = order.OrderResult.CreatedAt.Format(time.DateTime)
}
f.SetCellValue(sheet, excel.CellKey(row, &col), order.OrderNo)
f.SetCellValue(sheet, excel.CellKey(row, &col), order.OrderSn)
f.SetCellValue(sheet, excel.CellKey(row, &col), "易交易电子信息交易中心")
f.SetCellValue(sheet, excel.CellKey(row, &col), order.Project.TpID)
f.SetCellValue(sheet, excel.CellKey(row, &col), order.Project.Name)
f.SetCellValue(sheet, excel.CellKey(row, &col), "紫金财产保险股份有限公司福建分公司")
f.SetCellValue(sheet, excel.CellKey(row, &col), "投标保证保险")
f.SetCellValue(sheet, excel.CellKey(row, &col), policyNo)
f.SetCellValue(sheet, excel.CellKey(row, &col), order.Assured.AssuredName)
f.SetCellValue(sheet, excel.CellKey(row, &col), order.Assured.ContactName)
f.SetCellValue(sheet, excel.CellKey(row, &col), order.Assured.CreditCode)
f.SetCellValue(sheet, excel.CellKey(row, &col), order.Assured.ContactMobile)
f.SetCellValue(sheet, excel.CellKey(row, &col), order.Applicant.ApplicantName)
f.SetCellValue(sheet, excel.CellKey(row, &col), order.Applicant.ContactName)
f.SetCellValue(sheet, excel.CellKey(row, &col), order.Applicant.CreditCode)
f.SetCellValue(sheet, excel.CellKey(row, &col), order.Applicant.ContactMobile)
f.SetCellValue(sheet, excel.CellKey(row, &col), policyNo)
f.SetCellValue(sheet, excel.CellKey(row, &col), order.CreatedAt.Format(time.DateTime))
f.SetCellValue(sheet, excel.CellKey(row, &col), policyCreatedAt)
f.SetCellValue(sheet, excel.CellKey(row, &col), order.Project.StartDate)
f.SetCellValue(sheet, excel.CellKey(row, &col), "180天")
f.SetCellValue(sheet, excel.CellKey(row, &col), order.Project.InsureAmount)
f.SetCellValue(sheet, excel.CellKey(row, &col), order.Project.Amount)
f.SetCellValue(sheet, excel.CellKey(row, &col), order.GetStatusText())
row++
}
}

File diff suppressed because it is too large Load Diff

@ -2,6 +2,7 @@ package utils
import (
"context"
"fmt"
"insure/global"
"log"
"math/rand"
@ -16,8 +17,10 @@ func GenerateNo(noType string) string {
key := "no_" + noType + ":" + now.Format("200601021504")
cxt := context.Background()
val := global.Redis.Incr(cxt, key).Val()
fmt.Println("val:", val)
global.Redis.ExpireAt(cxt, key, now.Add(time.Minute))
valStr := strconv.Itoa(int(val))
fmt.Println("valStr:", valStr)
l := len(valStr)
valStr = strings.Repeat("0", l) + valStr
return now.Format("20060102150405") + valStr

Loading…
Cancel
Save