pay
This commit is contained in:
@@ -3,6 +3,8 @@ package cms
|
|||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
|
||||||
|
"git.rosy.net.cn/baseapi/utils"
|
||||||
|
|
||||||
"git.rosy.net.cn/jx-callback/business/jxstore/financial"
|
"git.rosy.net.cn/jx-callback/business/jxstore/financial"
|
||||||
"git.rosy.net.cn/jx-callback/business/jxutils"
|
"git.rosy.net.cn/jx-callback/business/jxutils"
|
||||||
|
|
||||||
@@ -13,13 +15,13 @@ import (
|
|||||||
"git.rosy.net.cn/jx-callback/business/model"
|
"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 (
|
var (
|
||||||
db = dao.GetDB()
|
db = dao.GetDB()
|
||||||
order *model.Order
|
order *model.Order
|
||||||
)
|
)
|
||||||
order = &model.Order{
|
order = &model.Order{
|
||||||
OrderID: jxutils.GenOrderNo(),
|
OrderID: utils.Int64ToStr(jxutils.GenOrderNo()),
|
||||||
UserID: ctx.GetUserID(),
|
UserID: ctx.GetUserID(),
|
||||||
Type: orderType,
|
Type: orderType,
|
||||||
Status: model.OrderStatusWait4Pay,
|
Status: model.OrderStatusWait4Pay,
|
||||||
@@ -40,11 +42,11 @@ func CreateOrder(ctx *jxcontext.Context, orderType, price int) (orderID int64, e
|
|||||||
return order.OrderID, err
|
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 (
|
var (
|
||||||
db = dao.GetDB()
|
db = dao.GetDB()
|
||||||
order = &model.Order{
|
order = &model.Order{
|
||||||
OrderID: int64(orderID),
|
OrderID: orderID,
|
||||||
}
|
}
|
||||||
payHandler = &financial.PayHandler{
|
payHandler = &financial.PayHandler{
|
||||||
PayType: payType,
|
PayType: payType,
|
||||||
@@ -66,11 +68,11 @@ func Pay(ctx *jxcontext.Context, orderID, payType int, vendorPayType string) (re
|
|||||||
return payHandler.Order, err
|
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 (
|
var (
|
||||||
db = dao.GetDB()
|
db = dao.GetDB()
|
||||||
order = &model.Order{
|
order = &model.Order{
|
||||||
OrderID: int64(orderID),
|
OrderID: orderID,
|
||||||
}
|
}
|
||||||
payHandler = &financial.PayHandler{
|
payHandler = &financial.PayHandler{
|
||||||
PayType: payType,
|
PayType: payType,
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ func (p *PayHandler) CreatePay() (err error) {
|
|||||||
param := &tonglianpayapi.CreateUnitorderOrderParam{
|
param := &tonglianpayapi.CreateUnitorderOrderParam{
|
||||||
Trxamt: int(p.Order.PayPrice),
|
Trxamt: int(p.Order.PayPrice),
|
||||||
NotifyUrl: globals.TLPayNotifyURL,
|
NotifyUrl: globals.TLPayNotifyURL,
|
||||||
Reqsn: utils.Int64ToStr(p.Order.OrderID),
|
Reqsn: p.Order.OrderID,
|
||||||
PayType: p.VendorPayType,
|
PayType: p.VendorPayType,
|
||||||
}
|
}
|
||||||
if p.VendorPayType == tonglianpayapi.PayTypeWxXcx {
|
if p.VendorPayType == tonglianpayapi.PayTypeWxXcx {
|
||||||
@@ -44,7 +44,7 @@ func (p *PayHandler) CreatePay() (err error) {
|
|||||||
}
|
}
|
||||||
case model.PayTypeWX:
|
case model.PayTypeWX:
|
||||||
param := &wxpayapi.CreateOrderParam{
|
param := &wxpayapi.CreateOrderParam{
|
||||||
OutTradeNo: utils.Int64ToStr(p.Order.OrderID),
|
OutTradeNo: p.Order.OrderID,
|
||||||
Body: "冲天猴儿App账户充值",
|
Body: "冲天猴儿App账户充值",
|
||||||
NotifyURL: globals.WxpayNotifyURL,
|
NotifyURL: globals.WxpayNotifyURL,
|
||||||
SpbillCreateIP: p.Ctx.GetRealRemoteIP(),
|
SpbillCreateIP: p.Ctx.GetRealRemoteIP(),
|
||||||
@@ -75,7 +75,7 @@ func (p *PayHandler) CreateRefund() (err error) {
|
|||||||
//企业付款(提现)
|
//企业付款(提现)
|
||||||
if p.VendorPayType == model.VendorPayTypeCompanyPay {
|
if p.VendorPayType == model.VendorPayTypeCompanyPay {
|
||||||
param := &wxpayapi.TransfersParam{
|
param := &wxpayapi.TransfersParam{
|
||||||
PartnerTradeNo: utils.Int64ToStr(p.Order.OrderID),
|
PartnerTradeNo: p.Order.OrderID,
|
||||||
CheckName: wxpayapi.CheckName,
|
CheckName: wxpayapi.CheckName,
|
||||||
Desc: "冲天猴儿app提现到账",
|
Desc: "冲天猴儿app提现到账",
|
||||||
SpbillCreateIP: p.Ctx.GetRealRemoteIP(),
|
SpbillCreateIP: p.Ctx.GetRealRemoteIP(),
|
||||||
@@ -125,7 +125,7 @@ func OnTLPayCallback(call *tonglianpayapi.CallBackResult) (err error) {
|
|||||||
|
|
||||||
func onTLpayFinished(call *tonglianpayapi.CallBackResult) (err error) {
|
func onTLpayFinished(call *tonglianpayapi.CallBackResult) (err error) {
|
||||||
order := &model.Order{
|
order := &model.Order{
|
||||||
OrderID: utils.Str2Int64(call.CusorderID),
|
OrderID: call.CusorderID,
|
||||||
}
|
}
|
||||||
db := dao.GetDB()
|
db := dao.GetDB()
|
||||||
if err = dao.GetEntity(db, order, "OrderID"); err == nil {
|
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) {
|
func onWxpayFinished(msg *wxpayapi.PayResultMsg) (err error) {
|
||||||
order := &model.Order{
|
order := &model.Order{
|
||||||
OrderID: utils.Str2Int64(msg.OutTradeNo),
|
OrderID: msg.OutTradeNo,
|
||||||
}
|
}
|
||||||
db := dao.GetDB()
|
db := dao.GetDB()
|
||||||
if err = dao.GetEntity(db, order, "OrderID"); err == nil {
|
if err = dao.GetEntity(db, order, "OrderID"); err == nil {
|
||||||
|
|||||||
@@ -48,7 +48,7 @@ var (
|
|||||||
type Order struct {
|
type Order struct {
|
||||||
ModelIDCUL
|
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
|
UserID string `orm:"column(user_id);size(48)" json:"userID"` //用户ID
|
||||||
Type int `json:"type"` //订单类型
|
Type int `json:"type"` //订单类型
|
||||||
Status int `json:"status"` //订单状态,待支付2,已支付5,支付成功110,支付失败115
|
Status int `json:"status"` //订单状态,待支付2,已支付5,支付成功110,支付失败115
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ type OrderController struct {
|
|||||||
// @Title 支付
|
// @Title 支付
|
||||||
// @Description 支付
|
// @Description 支付
|
||||||
// @Param token header string true "认证token"
|
// @Param token header string true "认证token"
|
||||||
// @Param orderID formData int true "订单号"
|
// @Param orderID formData string true "订单号"
|
||||||
// @Param payType formData int true "支付平台类型"
|
// @Param payType formData int true "支付平台类型"
|
||||||
// @Param vendorPayType formData string true "平台支付类型"
|
// @Param vendorPayType formData string true "平台支付类型"
|
||||||
// @Success 200 {object} controllers.CallResult
|
// @Success 200 {object} controllers.CallResult
|
||||||
@@ -28,7 +28,7 @@ func (c *OrderController) Pay() {
|
|||||||
// @Title 提现
|
// @Title 提现
|
||||||
// @Description 提现
|
// @Description 提现
|
||||||
// @Param token header string true "认证token"
|
// @Param token header string true "认证token"
|
||||||
// @Param orderID formData int true "订单号"
|
// @Param orderID formData string true "订单号"
|
||||||
// @Param payType formData int true "支付平台类型"
|
// @Param payType formData int true "支付平台类型"
|
||||||
// @Param vendorPayType formData string true "平台支付类型"
|
// @Param vendorPayType formData string true "平台支付类型"
|
||||||
// @Success 200 {object} controllers.CallResult
|
// @Success 200 {object} controllers.CallResult
|
||||||
|
|||||||
Reference in New Issue
Block a user