elf 5 months ago
parent 95e1154e27
commit 63d8a10cd7

@ -77,6 +77,18 @@ func GetOrderResult(c *gin.Context) (result.Data, error) {
return result.Data{"orderResult": orderResult}, nil return result.Data{"orderResult": orderResult}, nil
} }
func GetOrderPayUrl(c *gin.Context) (result.Data, error) {
token := c.DefaultQuery("token", "")
if token == "" {
return nil, e.NewError("缺少参数")
}
order, err := service.OrderService.GetOrderByToken(token)
if err != nil {
return nil, err
}
return result.Data{"payUrl": order.PayUrl, "status": order.Status}, nil
}
func PostToZking(c *gin.Context) (result.Data, error) { func PostToZking(c *gin.Context) (result.Data, error) {
orderSn := c.DefaultQuery("order_sn", "") orderSn := c.DefaultQuery("order_sn", "")
if orderSn == "" { if orderSn == "" {
@ -121,6 +133,7 @@ func UploadSignFile(c *gin.Context) (result.Data, error) {
} }
global.DB.Model(&model.Applicant{}).Where("order_sn", order.OrderSn).UpdateColumn("sign_url", signUrl) 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"})
return result.Data{}, nil return result.Data{}, nil
} }

@ -97,7 +97,8 @@ func UploadSignedFile(c *gin.Context) {
return return
} }
global.DB.Model(&model.Applicant{}).Where("order_sn", order.OrderSn).UpdateColumn("sign_url", signFileUrl) 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) service.OrderService.AddSignLog(order.OrderSn, param)
res, err := service.OrderService.PostToZking(order.OrderSn) res, err := service.OrderService.PostToZking(order.OrderSn)
@ -115,6 +116,9 @@ func UploadSignedFile(c *gin.Context) {
return return
} }
payUrl := res.Data["url"].(string)
global.DB.Model(&model.Order{}).Where("order_sn", order.OrderSn).UpdateColumns(model.Order{Status: "submitted", PayUrl: payUrl})
c.JSON(200, result) c.JSON(200, result)
return return
} }

@ -24,6 +24,7 @@ type Applicant struct {
ComTelNum string ComTelNum string
LicenseFiles string LicenseFiles string
SignUrl string SignUrl string
SignedUrl string
Order *Order `gorm:"foreignKey:OrderSn;references:OrderSn"` Order *Order `gorm:"foreignKey:OrderSn;references:OrderSn"`
CreatedAt time.Time CreatedAt time.Time
UpdatedAt time.Time `json:"-"` UpdatedAt time.Time `json:"-"`

@ -10,6 +10,8 @@ type Order struct {
RequestID string RequestID string
OrderSn string OrderSn string
Token string Token string
Status string
PayUrl string
User *User `gorm:"foreignKey:OrderSn;references:OrderSn"` User *User `gorm:"foreignKey:OrderSn;references:OrderSn"`
Project *Project `gorm:"foreignKey:OrderSn;references:OrderSn"` Project *Project `gorm:"foreignKey:OrderSn;references:OrderSn"`
Applicant *Applicant `gorm:"foreignKey:OrderSn;references:OrderSn"` Applicant *Applicant `gorm:"foreignKey:OrderSn;references:OrderSn"`

@ -14,4 +14,5 @@ func webRouteInit(r *gin.Engine) {
webGroup.Match([]string{"GET", "OPTIONS"}, "/post-to-zking", result.Json(h5.PostToZking)) webGroup.Match([]string{"GET", "OPTIONS"}, "/post-to-zking", result.Json(h5.PostToZking))
webGroup.Match([]string{"POST", "OPTIONS"}, "/update-applicant", result.Json(h5.UpdateApplicant)) webGroup.Match([]string{"POST", "OPTIONS"}, "/update-applicant", result.Json(h5.UpdateApplicant))
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))
} }

@ -62,6 +62,7 @@ func (s *orderService) saveOrder(orderSn string, requestID string) (*model.Order
o.Token = utils.Md5(orderSn + utils.GenerateRandomString(10) + strconv.Itoa(int(time.Now().UnixMicro()))) o.Token = utils.Md5(orderSn + utils.GenerateRandomString(10) + strconv.Itoa(int(time.Now().UnixMicro())))
o.OrderSn = orderSn o.OrderSn = orderSn
o.RequestID = requestID o.RequestID = requestID
o.Status = "initial"
err := global.DB.Save(&o).Error err := global.DB.Save(&o).Error
if err != nil { if err != nil {
return nil, err return nil, err

Loading…
Cancel
Save