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