ljl 4 months ago
parent bca1b7646a
commit 5b18d2a3ca

@ -90,14 +90,18 @@ func GetOrderPayUrl(c *gin.Context) (result.Data, error) {
}
func PostToZking(c *gin.Context) (result.Data, error) {
orderSn := c.DefaultQuery("order_sn", "")
if orderSn == "" {
orderNo := c.DefaultQuery("order_no", "")
if orderNo == "" {
return nil, e.NewError("缺少参数")
}
res, err := service.OrderService.PostToZking(orderSn)
res, err := service.OrderService.PostToZking(orderNo)
if err != nil {
return nil, err
}
payUrl := res.Data["url"].(string)
orderSn := res.Data["order_sn"].(string)
service.OrderService.UpdateOrderAfterPostToInsure(orderNo, payUrl, orderSn)
return result.Data{"result": res}, nil
}
@ -132,8 +136,8 @@ func UploadSignFile(c *gin.Context) (result.Data, error) {
return nil, err
}
global.DB.Model(&model.Applicant{}).Where("order_sn", order.OrderSn).UpdateColumn("sign_url", signUrl)
global.DB.Model(&model.Order{}).Where("order_sn", order.OrderSn).UpdateColumns(model.Order{Status: "generated"})
global.DB.Model(&model.Applicant{}).Where("order_no", order.OrderNo).UpdateColumn("sign_url", signUrl)
global.DB.Model(&model.Order{}).Where("order_no", order.OrderNo).UpdateColumns(model.Order{Status: "generated"})
return result.Data{}, nil
}

@ -50,7 +50,7 @@ func Create(c *gin.Context) {
return
}
data["order_sn"] = order.OrderSn
data["order_sn"] = order.OrderNo
data["url"] = global.Config.Server.Domain + "/tender?token=" + order.Token
result["data"] = data
c.JSON(200, result)
@ -97,11 +97,11 @@ func UploadSignedFile(c *gin.Context) {
return
}
global.DB.Model(&model.Applicant{}).Where("order_sn", order.OrderSn).UpdateColumn("signed_url", signFileUrl)
global.DB.Model(&model.Order{}).Where("order_sn", order.OrderSn).UpdateColumn("status", "signed")
service.OrderService.AddSignLog(order.OrderSn, param)
global.DB.Model(&model.Applicant{}).Where("order_no", order.OrderNo).UpdateColumn("signed_url", signFileUrl)
global.DB.Model(&model.Order{}).Where("order_no", order.OrderNo).UpdateColumn("status", "signed")
service.OrderService.AddSignLog(order.OrderNo, param)
res, err := service.OrderService.PostToZking(order.OrderSn)
res, err := service.OrderService.PostToZking(order.OrderNo)
if err != nil {
result["status"] = "0"
result["msg"] = "文件保存失败:" + err.Error()
@ -117,7 +117,8 @@ func UploadSignedFile(c *gin.Context) {
}
payUrl := res.Data["url"].(string)
global.DB.Model(&model.Order{}).Where("order_sn", order.OrderSn).UpdateColumns(model.Order{Status: "submitted", PayUrl: payUrl})
orderSn := res.Data["order_sn"].(string)
service.OrderService.UpdateOrderAfterPostToInsure(order.OrderNo, payUrl, orderSn)
c.JSON(200, result)
return

@ -73,7 +73,7 @@ func Push(c *gin.Context) {
}
if orderResult.Status == "3" {
global.DB.Model(&model.Order{}).Where("order_sn", orderResult.OrderSn).UpdateColumns(model.Order{Status: "payed"})
global.DB.Model(&model.Order{}).Where("order_no", orderResult.OrderNo).UpdateColumns(model.Order{Status: "payed"})
}
fmt.Println("orderResult:", orderResult)
@ -84,7 +84,7 @@ func Push(c *gin.Context) {
callbackParam.Timestamp = strconv.Itoa(int(time.Now().Unix()))
callbackData := suixing.CreateCallbackData{
DataType: "1",
OrderSn: pushData.OrderSn,
OrderSn: orderResult.OrderNo,
PolicyNo: pushData.PolicyNo,
MinPremium: pushData.MinPremium,
Rate: pushData.Rate,

@ -423,8 +423,8 @@ func (s *pdfTable) write() {
func gen3() {
pdf := gofpdf.New("P", "mm", "A4", "")
pdf.AddPage()
pdf.AddUTF8Font("SIMFANG", "", "./SIMFANG.TTF")
pdf.SetFont("SIMFANG", "", float64(10))
pdf.AddUTF8Font("simsong", "", "./simsong.ttf")
pdf.SetFont("simsong", "", float64(10))
imgFileStr := "./static/assets/img/zking_logo.png"
infoPtr := pdf.RegisterImage(imgFileStr, "")
@ -444,6 +444,8 @@ func gen3() {
pdf.Cell(40, 10, "并可就其中内容要求本公司做出解释。在您已充分理解保险条款后,请您如实填写本投保单并签章确认。")
pdf.Ln(-1)
pdf.HTMLBasicNew()
genTable(pdf)
pdf.Ln(-1)
pdf.Cell(40, 10, "投保人声明:贵公司已向本人交付并详细介绍了《紫金财产保险股份有限公司投标保证保险条款》的内容, 特 别是对保险合同中免除保险人责任的条款和投保人、被保险人义务的内容做了明确说明,本人已知悉其涵义, 同意投保并以此投保单作为订立保险合同的依据。")

@ -3,6 +3,7 @@ package manage
type OrderQueryRequest struct {
PageQueryRequest
OrderSn string `form:"orderSn"`
OrderNo string `form:"orderNo"`
AssuredName string `form:"assuredName"`
AssuredCreditCode string `form:"assuredCreditCode"`
AssuredContactName string `form:"assuredContactName"`

BIN
insure

Binary file not shown.

@ -7,7 +7,7 @@ import (
type Applicant struct {
ID int
OrderSn string
OrderNo string
ApplicantName string
CreditVld string
CreditCode string
@ -25,7 +25,7 @@ type Applicant struct {
LicenseFiles string
SignUrl string
SignedUrl string
Order *Order `gorm:"foreignKey:OrderSn;references:OrderSn"`
Order *Order `gorm:"foreignKey:OrderNo;references:OrderNo"`
CreatedAt time.Time
UpdatedAt time.Time `json:"-"`
}

@ -7,7 +7,7 @@ import (
type Assured struct {
ID int
OrderSn string
OrderNo string
AssuredName string
ComTelArea string
CreditCode string
@ -23,7 +23,7 @@ type Assured struct {
Address string
ComTelNum string
Agency string
Order *Order `gorm:"foreignKey:OrderSn;references:OrderSn"`
Order *Order `gorm:"foreignKey:OrderNo;references:OrderNo"`
CreatedAt time.Time
UpdatedAt time.Time `json:"-"`
}

@ -8,15 +8,16 @@ import (
type Order struct {
ID int
RequestID string
OrderNo string
OrderSn string
Token string
Status string
PayUrl string
User *User `gorm:"foreignKey:OrderSn;references:OrderSn"`
Project *Project `gorm:"foreignKey:OrderSn;references:OrderSn"`
Applicant *Applicant `gorm:"foreignKey:OrderSn;references:OrderSn"`
Assured *Assured `gorm:"foreignKey:OrderSn;references:OrderSn"`
OrderResult *OrderResult `gorm:"foreignKey:OrderSn;references:OrderSn"`
User *User `gorm:"foreignKey:OrderNo;references:OrderNo"`
Project *Project `gorm:"foreignKey:OrderNo;references:OrderNo"`
Applicant *Applicant `gorm:"foreignKey:OrderNo;references:OrderNo"`
Assured *Assured `gorm:"foreignKey:OrderNo;references:OrderNo"`
OrderResult *OrderResult `gorm:"foreignKey:OrderNo;references:OrderNo"`
CreatedAt time.Time
UpdatedAt time.Time `json:"-"`
}

@ -7,6 +7,7 @@ import (
type OrderResult struct {
ID int
OrderNo string
OrderSn string
PolicyNo string
MinPremium string
@ -22,7 +23,7 @@ type OrderResult struct {
ConfirmReceiptLink string
ConfirmReceiptLinkMd5 string
Remark string
Order *Order `gorm:"foreignKey:OrderSn;references:OrderSn"`
Order *Order `gorm:"foreignKey:OrderNo;references:OrderNo"`
CreatedAt time.Time
UpdatedAt time.Time `json:"-"`
}

@ -7,7 +7,7 @@ import (
type Project struct {
ID int
OrderSn string
OrderNo string
Name string
TpID string
BdID string
@ -28,7 +28,7 @@ type Project struct {
TenderFileUrl string
TenderFileUrlMd5 string
ProjectApprovalNo string
Order *Order `gorm:"foreignKey:OrderSn;references:OrderSn"`
Order *Order `gorm:"foreignKey:OrderNo;references:OrderNo"`
CreatedAt time.Time
UpdatedAt time.Time `json:"-"`
}

@ -7,7 +7,7 @@ import (
type SignLog struct {
ID int
OrderSn string
OrderNo string
PcInfo string
CaInfo string
FileInfo string

@ -7,7 +7,7 @@ import (
type User struct {
ID int
OrderSn string
OrderNo string
Mobile string
Username string
UserID string
@ -17,7 +17,7 @@ type User struct {
BankName string
BankCardNum string
BankUserName string
Order *Order `gorm:"foreignKey:OrderSn;references:OrderSn"`
Order *Order `gorm:"foreignKey:OrderNo;references:OrderNo"`
CreatedAt time.Time
UpdatedAt time.Time `json:"-"`
}

@ -28,25 +28,25 @@ type orderService struct {
}
func (s *orderService) CreateOrder(param suixing.CreateParam) (*model.Order, error) {
orderSn := utils.GenerateNo("order")
orderNo := utils.GenerateNo("order")
order, err := s.saveOrder(orderSn, param.RequestID)
order, err := s.saveOrder(orderNo, param.RequestID)
if err != nil {
return nil, err
}
user, err := s.saveUser(orderSn, param.Data.User)
user, err := s.saveUser(orderNo, param.Data.User)
if err != nil {
return nil, err
}
project, err := s.saveProject(orderSn, param.Data.Project)
project, err := s.saveProject(orderNo, param.Data.Project)
if err != nil {
return nil, err
}
applicant, err := s.saveApplicant(orderSn, param.Data.Applicant)
applicant, err := s.saveApplicant(orderNo, param.Data.Applicant)
if err != nil {
return nil, err
}
assured, err := s.saveAssured(orderSn, param.Data.Assured)
assured, err := s.saveAssured(orderNo, param.Data.Assured)
if err != nil {
return nil, err
}
@ -57,10 +57,10 @@ func (s *orderService) CreateOrder(param suixing.CreateParam) (*model.Order, err
return order, nil
}
func (s *orderService) saveOrder(orderSn string, requestID string) (*model.Order, error) {
func (s *orderService) saveOrder(orderNo string, requestID string) (*model.Order, error) {
o := model.Order{}
o.Token = utils.Md5(orderSn + utils.GenerateRandomString(10) + strconv.Itoa(int(time.Now().UnixMicro())))
o.OrderSn = orderSn
o.Token = utils.Md5(orderNo + utils.GenerateRandomString(10) + strconv.Itoa(int(time.Now().UnixMicro())))
o.OrderNo = orderNo
o.RequestID = requestID
o.Status = "initial"
err := global.DB.Save(&o).Error
@ -70,9 +70,9 @@ func (s *orderService) saveOrder(orderSn string, requestID string) (*model.Order
return &o, nil
}
func (s *orderService) saveUser(orderSn string, user suixing.User) (*model.User, error) {
func (s *orderService) saveUser(orderNo string, user suixing.User) (*model.User, error) {
u := model.User{}
u.OrderSn = orderSn
u.OrderNo = orderNo
u.UserID = user.UserID
u.Username = user.Username
u.Mobile = user.Mobile
@ -89,9 +89,9 @@ func (s *orderService) saveUser(orderSn string, user suixing.User) (*model.User,
return &u, nil
}
func (s *orderService) saveProject(orderSn string, project suixing.Project) (*model.Project, error) {
func (s *orderService) saveProject(orderNo string, project suixing.Project) (*model.Project, error) {
p := model.Project{}
p.OrderSn = orderSn
p.OrderNo = orderNo
p.Name = project.Name
p.TpID = project.TpID
p.BdID = project.BdID
@ -119,13 +119,13 @@ func (s *orderService) saveProject(orderSn string, project suixing.Project) (*mo
return &p, nil
}
func (s *orderService) saveApplicant(orderSn string, applicant suixing.Applicant) (*model.Applicant, error) {
func (s *orderService) saveApplicant(orderNo string, applicant suixing.Applicant) (*model.Applicant, error) {
licenseFiles, err := json.Marshal(applicant.LicenseFiles)
if err != nil {
return nil, err
}
a := model.Applicant{}
a.OrderSn = orderSn
a.OrderNo = orderNo
a.ApplicantName = applicant.ApplicantName
a.CreditVld = applicant.CreditVld
a.CreditCode = applicant.CreditCode
@ -149,9 +149,9 @@ func (s *orderService) saveApplicant(orderSn string, applicant suixing.Applicant
return &a, nil
}
func (s *orderService) saveAssured(orderSn string, assured suixing.Assured) (*model.Assured, error) {
func (s *orderService) saveAssured(orderNo string, assured suixing.Assured) (*model.Assured, error) {
a := model.Assured{}
a.OrderSn = orderSn
a.OrderNo = orderNo
a.AssuredName = assured.AssuredName
a.CreditVld = assured.CreditVld
a.CreditCode = assured.CreditCode
@ -194,6 +194,26 @@ func (s *orderService) GetOrderByToken(token string) (*model.Order, error) {
return &order, nil
}
func (s *orderService) GetOrderByOrderNo(orderNo string) (*model.Order, error) {
order := model.Order{}
err := global.DB.
Preload("User").
Preload("Project").
Preload("Applicant").
Preload("Assured").
Where("order_no", orderNo).
First(&order).
Error
if err != nil {
if errors.Is(err, gorm.ErrRecordNotFound) {
return nil, e.NewError("记录不存在")
} else {
return nil, e.NewError("数据异常")
}
}
return &order, nil
}
func (s *orderService) GetOrderByOrderSn(orderSn string) (*model.Order, error) {
order := model.Order{}
err := global.DB.
@ -214,7 +234,7 @@ func (s *orderService) GetOrderByOrderSn(orderSn string) (*model.Order, error) {
return &order, nil
}
func (s *orderService) AddSignLog(orderSn string, param signer.UploadParam) (*model.SignLog, error) {
func (s *orderService) AddSignLog(orderNo string, param signer.UploadParam) (*model.SignLog, error) {
var err error
isUploadPdf := 1
if param.IsUploadPdf != "" {
@ -225,7 +245,7 @@ func (s *orderService) AddSignLog(orderSn string, param signer.UploadParam) (*mo
}
l := model.SignLog{}
l.OrderSn = orderSn
l.OrderNo = orderNo
l.Params = param.Params
l.CaInfo = param.CaInfo
l.IsUploadPdf = isUploadPdf
@ -238,7 +258,7 @@ func (s *orderService) AddSignLog(orderSn string, param signer.UploadParam) (*mo
return &l, nil
}
func (s *orderService) PostToZking(orderSn string) (*zking.Result, error) {
func (s *orderService) PostToZking(orderNo string) (*zking.Result, error) {
order := model.Order{}
err := global.DB.
@ -246,7 +266,7 @@ func (s *orderService) PostToZking(orderSn string) (*zking.Result, error) {
Preload("Project").
Preload("Applicant").
Preload("Assured").
Where("order_sn", orderSn).
Where("order_no", orderNo).
First(&order).Error
if err != nil {
@ -649,7 +669,7 @@ func (s *orderService) SaveOrderResult(data zking.PushCallbackData) (*model.Orde
return nil, e.NewError("参数错误")
}
_, err := s.GetOrderByOrderSn(data.OrderSn)
order, err := s.GetOrderByOrderSn(data.OrderSn)
if err != nil {
return nil, err
}
@ -660,6 +680,7 @@ func (s *orderService) SaveOrderResult(data zking.PushCallbackData) (*model.Orde
return nil, err
}
orderResult.OrderNo = order.OrderNo
orderResult.OrderSn = data.OrderSn
orderResult.PolicyNo = data.PolicyNo
orderResult.Status = data.Status
@ -740,3 +761,7 @@ func (s *orderService) UpdateApplicant(req request.UpdateApplicantRequest) (*mod
return order, nil
}
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})
}

Binary file not shown.

Binary file not shown.
Loading…
Cancel
Save