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