diff --git a/api/h5/index.go b/api/h5/index.go index 52a9082..86b5d47 100644 --- a/api/h5/index.go +++ b/api/h5/index.go @@ -51,6 +51,10 @@ func GetSignUrl(c *gin.Context) (result.Data, error) { return nil, err } + if order.Applicant.SignUrl == "" { + return nil, e.NewError("签章文件未生成") + } + param := signer.SignParam{} param.Url = order.Applicant.SignUrl param.UploadUrl = global.Config.Server.Domain + "/api/suixing/upload-signed-file" @@ -193,3 +197,15 @@ func GenerateSignFile(c *gin.Context) (result.Data, error) { return result.Data{}, nil } + +func GetPayInfo(c *gin.Context) (result.Data, error) { + token := c.DefaultQuery("token", "") + if token == "" { + return nil, e.NewError("缺少参数") + } + payInfo, err := service.OrderService.GetPayInfo(token) + if err != nil { + return nil, err + } + return result.Data{"PayInfo": payInfo}, nil +} diff --git a/dto/response/pay_info_response.go b/dto/response/pay_info_response.go new file mode 100644 index 0000000..dfe1c71 --- /dev/null +++ b/dto/response/pay_info_response.go @@ -0,0 +1,23 @@ +package response + +type PayInfoResponse struct { + OrderSn string + OrderCreateTime string + PayAmount string + ProductName string + Remark string + Payee Payee + Payer Payer +} + +type Payer struct { + BankName string + BankCardNum string + BankUserName string +} + +type Payee struct { + BankName string + BankCardNum string + BankUserName string +} diff --git a/insure b/insure index 642de70..eae4f2f 100755 Binary files a/insure and b/insure differ diff --git a/model/project.go b/model/project.go index 0260811..dcc2852 100644 --- a/model/project.go +++ b/model/project.go @@ -14,6 +14,7 @@ type Project struct { BdName string StartDate string Amount string + InsureAmount string Province string City string District string diff --git a/router/web.go b/router/web.go index 26f1b1d..de01ea6 100644 --- a/router/web.go +++ b/router/web.go @@ -17,5 +17,6 @@ func webRouteInit(r *gin.Engine) { webGroup.Match([]string{"POST", "OPTIONS"}, "/upload-sign-file", result.Json(h5.UploadSignFile)) webGroup.Match([]string{"GET", "OPTIONS"}, "/get-order-pay-url", result.Json(h5.GetOrderPayUrl)) 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)) } diff --git a/service/order_service.go b/service/order_service.go index 2ce5343..29c3e2e 100644 --- a/service/order_service.go +++ b/service/order_service.go @@ -3,11 +3,13 @@ package service import ( "encoding/json" "errors" + "fmt" "github.com/gin-gonic/gin" "github.com/xuri/excelize/v2" "gorm.io/gorm" "insure/dto/request" "insure/dto/request/manage" + "insure/dto/response" "insure/e" "insure/global" "insure/model" @@ -16,6 +18,7 @@ import ( "insure/third_party/zking" "insure/utils" "insure/utils/excel" + "math" "net/http" "strconv" "strings" @@ -90,6 +93,14 @@ func (s *orderService) saveUser(orderNo string, user suixing.User) (*model.User, } func (s *orderService) saveProject(orderNo string, project suixing.Project) (*model.Project, error) { + + projectAmount, _ := strconv.ParseFloat(project.Amount, 64) + insureAmount := math.Round(projectAmount * 0.003) + if insureAmount < 200 { + insureAmount = 200.00 + } + insureAmountStr := fmt.Sprintf("%.2f", insureAmount) + p := model.Project{} p.OrderNo = orderNo p.Name = project.Name @@ -98,6 +109,7 @@ func (s *orderService) saveProject(orderNo string, project suixing.Project) (*mo p.BdName = project.BdName p.StartDate = project.StartDate p.Amount = project.Amount + p.InsureAmount = insureAmountStr p.Province = project.Province p.City = project.City p.District = project.District @@ -795,3 +807,31 @@ func (s *orderService) UpdateInvoice(req request.UpdateInvoiceRequest) (*model.O func (s *orderService) UpdateOrderAfterPostToInsure(orderNo, payUrl string, orderSn string) { global.DB.Model(&model.Order{}).Where("order_no", orderNo).UpdateColumns(model.Order{Status: "submitted", PayUrl: payUrl, OrderSn: orderSn}) } + +func (s *orderService) GetPayInfo(token string) (*response.PayInfoResponse, error) { + order, err := s.GetOrderByToken(token) + if err != nil { + return nil, err + } + if order.Status != "submitted" { + return nil, e.NewError("订单状态异常") + } + payInfo := response.PayInfoResponse{ + PayAmount: order.Project.InsureAmount, + OrderSn: order.OrderSn, + OrderCreateTime: order.CreatedAt.Format("2006-01-02 15:04:05"), + ProductName: "投标保证保险", + Remark: "", + Payee: response.Payee{ + BankName: "中国工商银行福州下渡支行", + BankCardNum: "1402024519601002227", + BankUserName: "紫金财产保险股份有限公司福建分公司", + }, + Payer: response.Payer{ + BankName: order.User.BankName, + BankCardNum: order.User.BankCardNum, + BankUserName: order.User.BankUserName, + }, + } + return &payInfo, nil +} diff --git a/service/pdf_service.go b/service/pdf_service.go index 15e32ef..33b2b7b 100644 --- a/service/pdf_service.go +++ b/service/pdf_service.go @@ -6,7 +6,6 @@ import ( "insure/global" "insure/model" "insure/utils" - "math" "os" "strconv" "time" @@ -667,12 +666,8 @@ func genTable(pdf *gofpdf.Fpdf, order *model.Order) { {w: 0, h: tableH, txtStr: ""}, }...) - insureAmount := math.Round(projectAmount * 0.003) - if insureAmount < 200 { - insureAmount = 200.00 - } - insureAmountStr := fmt.Sprintf("%.2f", insureAmount) - insureAmount, _ = strconv.ParseFloat(fmt.Sprintf("%.2f", insureAmount), 64) + insureAmountStr := order.Project.InsureAmount + insureAmount, _ := strconv.ParseFloat(insureAmountStr, 64) myPdf.addRows("", "LM", []pdfCell{ {w: col1Width + col2Width, h: tableH, txtStr: "保险费"}, {w: 0, h: tableH, txtStr: ""},