pay
This commit is contained in:
@@ -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,
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user