From f171cfc468ff447213774752ff425effe3f3e07f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=8B=8F=E5=B0=B9=E5=B2=9A?= <770236076@qq.com> Date: Thu, 5 Nov 2020 18:21:56 +0800 Subject: [PATCH] pay --- business/jxstore/cms/order.go | 14 ++++++++------ business/jxstore/financial/financial.go | 10 +++++----- business/model/order.go | 2 +- controllers/order_controller.go | 4 ++-- 4 files changed, 16 insertions(+), 14 deletions(-) diff --git a/business/jxstore/cms/order.go b/business/jxstore/cms/order.go index c708bf0b2..ad105a44d 100644 --- a/business/jxstore/cms/order.go +++ b/business/jxstore/cms/order.go @@ -3,6 +3,8 @@ package cms import ( "fmt" + "git.rosy.net.cn/baseapi/utils" + "git.rosy.net.cn/jx-callback/business/jxstore/financial" "git.rosy.net.cn/jx-callback/business/jxutils" @@ -13,13 +15,13 @@ import ( "git.rosy.net.cn/jx-callback/business/model" ) -func CreateOrder(ctx *jxcontext.Context, orderType, price int) (orderID int64, err error) { +func CreateOrder(ctx *jxcontext.Context, orderType, price int) (orderID string, err error) { var ( db = dao.GetDB() order *model.Order ) order = &model.Order{ - OrderID: jxutils.GenOrderNo(), + OrderID: utils.Int64ToStr(jxutils.GenOrderNo()), UserID: ctx.GetUserID(), Type: orderType, Status: model.OrderStatusWait4Pay, @@ -40,11 +42,11 @@ func CreateOrder(ctx *jxcontext.Context, orderType, price int) (orderID int64, e return order.OrderID, err } -func Pay(ctx *jxcontext.Context, orderID, payType int, vendorPayType string) (result *model.Order, err error) { +func Pay(ctx *jxcontext.Context, orderID string, payType int, vendorPayType string) (result *model.Order, err error) { var ( db = dao.GetDB() order = &model.Order{ - OrderID: int64(orderID), + OrderID: orderID, } payHandler = &financial.PayHandler{ PayType: payType, @@ -66,11 +68,11 @@ func Pay(ctx *jxcontext.Context, orderID, payType int, vendorPayType string) (re return payHandler.Order, err } -func Cash(ctx *jxcontext.Context, orderID, payType int, vendorPayType string) (errCode string, err error) { +func Cash(ctx *jxcontext.Context, orderID string, payType int, vendorPayType string) (errCode string, err error) { var ( db = dao.GetDB() order = &model.Order{ - OrderID: int64(orderID), + OrderID: orderID, } payHandler = &financial.PayHandler{ PayType: payType, diff --git a/business/jxstore/financial/financial.go b/business/jxstore/financial/financial.go index 0f7f836ed..8c015a686 100644 --- a/business/jxstore/financial/financial.go +++ b/business/jxstore/financial/financial.go @@ -26,7 +26,7 @@ func (p *PayHandler) CreatePay() (err error) { param := &tonglianpayapi.CreateUnitorderOrderParam{ Trxamt: int(p.Order.PayPrice), NotifyUrl: globals.TLPayNotifyURL, - Reqsn: utils.Int64ToStr(p.Order.OrderID), + Reqsn: p.Order.OrderID, PayType: p.VendorPayType, } if p.VendorPayType == tonglianpayapi.PayTypeWxXcx { @@ -44,7 +44,7 @@ func (p *PayHandler) CreatePay() (err error) { } case model.PayTypeWX: param := &wxpayapi.CreateOrderParam{ - OutTradeNo: utils.Int64ToStr(p.Order.OrderID), + OutTradeNo: p.Order.OrderID, Body: "冲天猴儿App账户充值", NotifyURL: globals.WxpayNotifyURL, SpbillCreateIP: p.Ctx.GetRealRemoteIP(), @@ -75,7 +75,7 @@ func (p *PayHandler) CreateRefund() (err error) { //企业付款(提现) if p.VendorPayType == model.VendorPayTypeCompanyPay { param := &wxpayapi.TransfersParam{ - PartnerTradeNo: utils.Int64ToStr(p.Order.OrderID), + PartnerTradeNo: p.Order.OrderID, CheckName: wxpayapi.CheckName, Desc: "冲天猴儿app提现到账", SpbillCreateIP: p.Ctx.GetRealRemoteIP(), @@ -125,7 +125,7 @@ func OnTLPayCallback(call *tonglianpayapi.CallBackResult) (err error) { func onTLpayFinished(call *tonglianpayapi.CallBackResult) (err error) { order := &model.Order{ - OrderID: utils.Str2Int64(call.CusorderID), + OrderID: call.CusorderID, } db := dao.GetDB() if err = dao.GetEntity(db, order, "OrderID"); err == nil { @@ -231,7 +231,7 @@ func OnWxPayCallback(msg *wxpayapi.CallbackMsg) (err error) { func onWxpayFinished(msg *wxpayapi.PayResultMsg) (err error) { order := &model.Order{ - OrderID: utils.Str2Int64(msg.OutTradeNo), + OrderID: msg.OutTradeNo, } db := dao.GetDB() if err = dao.GetEntity(db, order, "OrderID"); err == nil { diff --git a/business/model/order.go b/business/model/order.go index 69f6d7571..be920f6b4 100644 --- a/business/model/order.go +++ b/business/model/order.go @@ -48,7 +48,7 @@ var ( type Order struct { ModelIDCUL - OrderID int64 `orm:"column(order_id)" json:"orderID"` //订单号 + OrderID string `orm:"column(order_id)" json:"orderID"` //订单号 UserID string `orm:"column(user_id);size(48)" json:"userID"` //用户ID Type int `json:"type"` //订单类型 Status int `json:"status"` //订单状态,待支付2,已支付5,支付成功110,支付失败115 diff --git a/controllers/order_controller.go b/controllers/order_controller.go index d47140bc3..e2b7f43f7 100644 --- a/controllers/order_controller.go +++ b/controllers/order_controller.go @@ -12,7 +12,7 @@ type OrderController struct { // @Title 支付 // @Description 支付 // @Param token header string true "认证token" -// @Param orderID formData int true "订单号" +// @Param orderID formData string true "订单号" // @Param payType formData int true "支付平台类型" // @Param vendorPayType formData string true "平台支付类型" // @Success 200 {object} controllers.CallResult @@ -28,7 +28,7 @@ func (c *OrderController) Pay() { // @Title 提现 // @Description 提现 // @Param token header string true "认证token" -// @Param orderID formData int true "订单号" +// @Param orderID formData string true "订单号" // @Param payType formData int true "支付平台类型" // @Param vendorPayType formData string true "平台支付类型" // @Success 200 {object} controllers.CallResult