elf 4 months ago
parent 5b48365e4b
commit 1738b5b5cf

@ -51,6 +51,10 @@ func GetSignUrl(c *gin.Context) (result.Data, error) {
return nil, err return nil, err
} }
if order.Applicant.SignUrl == "" {
return nil, e.NewError("签章文件未生成")
}
param := signer.SignParam{} param := signer.SignParam{}
param.Url = order.Applicant.SignUrl param.Url = order.Applicant.SignUrl
param.UploadUrl = global.Config.Server.Domain + "/api/suixing/upload-signed-file" 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 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
}

@ -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
}

BIN
insure

Binary file not shown.

@ -14,6 +14,7 @@ type Project struct {
BdName string BdName string
StartDate string StartDate string
Amount string Amount string
InsureAmount string
Province string Province string
City string City string
District string District string

@ -17,5 +17,6 @@ func webRouteInit(r *gin.Engine) {
webGroup.Match([]string{"POST", "OPTIONS"}, "/upload-sign-file", result.Json(h5.UploadSignFile)) 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-pay-url", result.Json(h5.GetOrderPayUrl))
webGroup.Match([]string{"GET", "OPTIONS"}, "/get-order-status", result.Json(h5.GetOrderStatus)) 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{"POST", "OPTIONS"}, "/generate-sign-file", result.Json(h5.GenerateSignFile))
} }

@ -3,11 +3,13 @@ package service
import ( import (
"encoding/json" "encoding/json"
"errors" "errors"
"fmt"
"github.com/gin-gonic/gin" "github.com/gin-gonic/gin"
"github.com/xuri/excelize/v2" "github.com/xuri/excelize/v2"
"gorm.io/gorm" "gorm.io/gorm"
"insure/dto/request" "insure/dto/request"
"insure/dto/request/manage" "insure/dto/request/manage"
"insure/dto/response"
"insure/e" "insure/e"
"insure/global" "insure/global"
"insure/model" "insure/model"
@ -16,6 +18,7 @@ import (
"insure/third_party/zking" "insure/third_party/zking"
"insure/utils" "insure/utils"
"insure/utils/excel" "insure/utils/excel"
"math"
"net/http" "net/http"
"strconv" "strconv"
"strings" "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) { 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 := model.Project{}
p.OrderNo = orderNo p.OrderNo = orderNo
p.Name = project.Name p.Name = project.Name
@ -98,6 +109,7 @@ func (s *orderService) saveProject(orderNo string, project suixing.Project) (*mo
p.BdName = project.BdName p.BdName = project.BdName
p.StartDate = project.StartDate p.StartDate = project.StartDate
p.Amount = project.Amount p.Amount = project.Amount
p.InsureAmount = insureAmountStr
p.Province = project.Province p.Province = project.Province
p.City = project.City p.City = project.City
p.District = project.District 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) { 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}) 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
}

@ -6,7 +6,6 @@ import (
"insure/global" "insure/global"
"insure/model" "insure/model"
"insure/utils" "insure/utils"
"math"
"os" "os"
"strconv" "strconv"
"time" "time"
@ -667,12 +666,8 @@ func genTable(pdf *gofpdf.Fpdf, order *model.Order) {
{w: 0, h: tableH, txtStr: ""}, {w: 0, h: tableH, txtStr: ""},
}...) }...)
insureAmount := math.Round(projectAmount * 0.003) insureAmountStr := order.Project.InsureAmount
if insureAmount < 200 { insureAmount, _ := strconv.ParseFloat(insureAmountStr, 64)
insureAmount = 200.00
}
insureAmountStr := fmt.Sprintf("%.2f", insureAmount)
insureAmount, _ = strconv.ParseFloat(fmt.Sprintf("%.2f", insureAmount), 64)
myPdf.addRows("", "LM", []pdfCell{ myPdf.addRows("", "LM", []pdfCell{
{w: col1Width + col2Width, h: tableH, txtStr: "保险费"}, {w: col1Width + col2Width, h: tableH, txtStr: "保险费"},
{w: 0, h: tableH, txtStr: ""}, {w: 0, h: tableH, txtStr: ""},

Loading…
Cancel
Save