1
This commit is contained in:
@@ -98,7 +98,8 @@ func (c *PrinterHandler) getOrderContent(order *model.GoodsOrder, storeTel strin
|
|||||||
|
|
||||||
for _, sku := range order.Skus {
|
for _, sku := range order.Skus {
|
||||||
orderFmt += `%s\n`
|
orderFmt += `%s\n`
|
||||||
orderFmt += `%6s%8s%8s\n`
|
//orderFmt += `%8s%10s%10s\n`
|
||||||
|
orderFmt += `%8s%8s\n`
|
||||||
//orderParams = append(orderParams, sku.SkuName, "x"+utils.Int2Str(sku.Count), jxutils.IntPrice2StandardCurrencyString(sku.SalePrice), jxutils.IntPrice2StandardCurrencyString(sku.SalePrice*int64(sku.Count)))
|
//orderParams = append(orderParams, sku.SkuName, "x"+utils.Int2Str(sku.Count), jxutils.IntPrice2StandardCurrencyString(sku.SalePrice), jxutils.IntPrice2StandardCurrencyString(sku.SalePrice*int64(sku.Count)))
|
||||||
orderParams = append(orderParams, sku.SkuName, "x"+utils.Int2Str(sku.Count), jxutils.IntPrice2StandardCurrencyString(sku.SalePrice*int64(sku.Count)))
|
orderParams = append(orderParams, sku.SkuName, "x"+utils.Int2Str(sku.Count), jxutils.IntPrice2StandardCurrencyString(sku.SalePrice*int64(sku.Count)))
|
||||||
//标品需要打印条形码
|
//标品需要打印条形码
|
||||||
|
|||||||
@@ -1397,6 +1397,11 @@ func CancelOrder(ctx *jxcontext.Context, order *model.GoodsOrder, reason string)
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
errList.AddErr(err)
|
errList.AddErr(err)
|
||||||
}
|
}
|
||||||
|
}else if orderPay.PayType == model.PayTypeTicTok {
|
||||||
|
orderPayRefund, err = RefundOrderByTT(ctx, orderPay, refundID, orderPay.TotalFee, reason)
|
||||||
|
if err != nil {
|
||||||
|
errList.AddErr(err)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if err == nil {
|
if err == nil {
|
||||||
//如果用了优惠券,状态要刷回去
|
//如果用了优惠券,状态要刷回去
|
||||||
|
|||||||
@@ -50,50 +50,50 @@ func pay4OrderByTT(ctx *jxcontext.Context, order *model.GoodsOrder, vendorPayTyp
|
|||||||
return orderPay, err
|
return orderPay, err
|
||||||
}
|
}
|
||||||
|
|
||||||
func OnTTPayCallback(msg *wxpayapi.CallbackMsg) (err error) {
|
func OnTTPayCallback(msg *tiktok.DetailCallBackMessage, refund *tiktok.DetailCallBackMessage2Refund, payType string) (err error) {
|
||||||
globals.SugarLogger.Debugf("OnWxPayCallback msg:%s", utils.Format4Output(msg, true))
|
globals.SugarLogger.Debugf("OnWxPayCallback msg:%s", utils.Format4Output(msg, true))
|
||||||
switch msg.MsgType {
|
switch payType {
|
||||||
case wxpayapi.MsgTypePay:
|
case tiktok.PayStatus: // 支付回调
|
||||||
err = onWxpayFinished(msg.Data.(*wxpayapi.PayResultMsg))
|
err = onTTPayFinished(msg)
|
||||||
case wxpayapi.MsgTypeRefund:
|
case tiktok.RefundStatus: // 退款回调
|
||||||
err = onWxpayRefund(msg.Data.(*wxpayapi.RefundResultMsg))
|
err = onTTPayRefund(refund)
|
||||||
}
|
}
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
func onTTPayFinished(msg *wxpayapi.PayResultMsg) (err error) {
|
func onTTPayFinished(msg *tiktok.DetailCallBackMessage) (err error) {
|
||||||
orderPay := &model.OrderPay{
|
orderPay := &model.OrderPay{
|
||||||
PayOrderID: msg.OutTradeNo,
|
PayOrderID: msg.CpOrderno,
|
||||||
PayType: model.PayTypeWX,
|
PayType: model.PayTypeWX,
|
||||||
}
|
}
|
||||||
orderPay.DeletedAt = utils.DefaultTimeValue
|
orderPay.DeletedAt = utils.DefaultTimeValue
|
||||||
db := dao.GetDB()
|
db := dao.GetDB()
|
||||||
if err = dao.GetEntity(db, orderPay, "PayOrderID", "PayType", "DeletedAt"); err == nil {
|
if err = dao.GetEntity(db, orderPay, "PayOrderID", "PayType", "DeletedAt"); err == nil {
|
||||||
orderPay.PayFinishedAt = utils.Time2Pointer(wxpayapi.PayTime2Time(msg.TimeEnd))
|
orderPay.PayFinishedAt = utils.Time2Pointer(wxpayapi.PayTime2Time(utils.Int64ToStr(msg.PaidAt)))
|
||||||
orderPay.TransactionID = msg.TransactionID
|
orderPay.TransactionID = msg.ChannelNo
|
||||||
orderPay.OriginalData = utils.Format4Output(msg, true)
|
orderPay.OriginalData = utils.Format4Output(msg, true)
|
||||||
if msg.ResultCode == wxpayapi.ResponseCodeSuccess {
|
if msg.Status == tiktok.ResponseCodeSuccess {
|
||||||
orderPay.Status = model.PayStatusYes
|
orderPay.Status = model.PayStatusYes
|
||||||
} else {
|
} else {
|
||||||
orderPay.Status = model.PayStatusFailed
|
orderPay.Status = model.PayStatusFailed
|
||||||
}
|
}
|
||||||
dao.UpdateEntity(db, orderPay)
|
dao.UpdateEntity(db, orderPay)
|
||||||
if msg.ResultCode == wxpayapi.ResponseCodeSuccess {
|
if msg.Status == tiktok.ResponseCodeSuccess {
|
||||||
err = OnPayFinished(orderPay)
|
err = OnPayFinished(orderPay)
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
globals.SugarLogger.Debugf("onWxpayFinished msg:%s, err:%v", utils.Format4Output(msg, true), err)
|
globals.SugarLogger.Debugf("onTTpayFinished msg:%s, err:%v", utils.Format4Output(msg, true), err)
|
||||||
}
|
}
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
func onTTPayRefund(msg *wxpayapi.RefundResultMsg) (err error) {
|
func onTTPayRefund(msg *tiktok.DetailCallBackMessage2Refund) (err error) {
|
||||||
orderPayRefund := &model.OrderPayRefund{
|
orderPayRefund := &model.OrderPayRefund{
|
||||||
RefundID: msg.ReqInfoObj.OutRefundNo,
|
RefundID: msg.CpRefundno,
|
||||||
}
|
}
|
||||||
db := dao.GetDB()
|
db := dao.GetDB()
|
||||||
if err = dao.GetEntity(db, orderPayRefund, "RefundID"); err == nil {
|
if err = dao.GetEntity(db, orderPayRefund, "RefundID"); err == nil {
|
||||||
if msg.ResultCode == wxpayapi.ResponseCodeSuccess {
|
if msg.Status == tiktok.ResponseCodeSuccess {
|
||||||
orderPayRefund.Status = model.RefundStatusYes
|
orderPayRefund.Status = model.RefundStatusYes
|
||||||
} else {
|
} else {
|
||||||
orderPayRefund.Status = model.RefundStatusFailed
|
orderPayRefund.Status = model.RefundStatusFailed
|
||||||
|
|||||||
@@ -45,25 +45,14 @@ func pay4OrderByTL(ctx *jxcontext.Context, order *model.GoodsOrder, payType int,
|
|||||||
if err == nil && authInfo.GetAuthType() == weixin.AuthTypeMini && authInfo.GetAuthTypeID() == subAppID {
|
if err == nil && authInfo.GetAuthType() == weixin.AuthTypeMini && authInfo.GetAuthTypeID() == subAppID {
|
||||||
param.Acct = authInfo.GetAuthID()
|
param.Acct = authInfo.GetAuthID()
|
||||||
}
|
}
|
||||||
// 抖音小程序,调起微信支付界面
|
|
||||||
//if err == nil && authInfo.GetAuthType() == douyin.AuthTypeTiktokMini {
|
|
||||||
// appID, jsCode := weixin.SplitJsCode(subAppID)
|
|
||||||
// appID = auth2.WeCartAppID
|
|
||||||
// sessionInfo, err := weixin.GetWxApp(appID).SNSCode2Session(jsCode)
|
|
||||||
// if err == nil {
|
|
||||||
// param.Acct = sessionInfo.OpenID
|
|
||||||
// }
|
|
||||||
//}
|
|
||||||
}
|
}
|
||||||
if vendorPayType == tonglianpayapi.PayTypeZfbJS || vendorPayType == tonglianpayapi.PayTypeZfbApp ||vendorPayType == tonglianpayapi.PayTypeZfbQrcode {
|
if vendorPayType == tonglianpayapi.PayTypeZfbJS || vendorPayType == tonglianpayapi.PayTypeZfbApp {
|
||||||
if authInfo, err := ctx.GetV2AuthInfo(); err == nil {
|
if authInfo, err := ctx.GetV2AuthInfo(); err == nil {
|
||||||
param.Acct = authInfo.GetAuthID()
|
param.Acct = authInfo.GetAuthID()
|
||||||
globals.SugarLogger.Debug("==============1",authInfo)
|
|
||||||
}
|
}
|
||||||
if param.Acct == "" {
|
if param.Acct == "" {
|
||||||
return nil, fmt.Errorf("未找到用户的认证ID!")
|
return nil, fmt.Errorf("未找到用户的认证ID!")
|
||||||
}
|
}
|
||||||
globals.SugarLogger.Debug("==============2",param)
|
|
||||||
}
|
}
|
||||||
if vendorPayType == tonglianpayapi.PayTypeH5 {
|
if vendorPayType == tonglianpayapi.PayTypeH5 {
|
||||||
param2 := &tonglianpayapi.CreateH5UnitorderOrderParam{
|
param2 := &tonglianpayapi.CreateH5UnitorderOrderParam{
|
||||||
@@ -75,8 +64,6 @@ func pay4OrderByTL(ctx *jxcontext.Context, order *model.GoodsOrder, payType int,
|
|||||||
err = api.TLpayAPI.CreateH5UnitorderOrder(param2)
|
err = api.TLpayAPI.CreateH5UnitorderOrder(param2)
|
||||||
} else {
|
} else {
|
||||||
result, err := api.TLpayAPI.CreateUnitorderOrder(param)
|
result, err := api.TLpayAPI.CreateUnitorderOrder(param)
|
||||||
globals.SugarLogger.Debug("=============444",result)
|
|
||||||
globals.SugarLogger.Debug("=============444",err)
|
|
||||||
if err == nil {
|
if err == nil {
|
||||||
var result2 tonglianpayapi.PayInfo
|
var result2 tonglianpayapi.PayInfo
|
||||||
json.Unmarshal([]byte(result.PayInfo), &result2)
|
json.Unmarshal([]byte(result.PayInfo), &result2)
|
||||||
|
|||||||
@@ -40,8 +40,11 @@ func pay4OrderByWX(ctx *jxcontext.Context, order *model.GoodsOrder, vendorPayTyp
|
|||||||
if authInfo, err := ctx.GetV2AuthInfo(); err == nil && authInfo.GetAuthType() == weixin.AuthTypeMini {
|
if authInfo, err := ctx.GetV2AuthInfo(); err == nil && authInfo.GetAuthType() == weixin.AuthTypeMini {
|
||||||
param.OpenID = authInfo.GetAuthID()
|
param.OpenID = authInfo.GetAuthID()
|
||||||
}
|
}
|
||||||
|
globals.SugarLogger.Debug("err1=====================", err)
|
||||||
|
|
||||||
result, err := api.WxpayAPI.CreateUnifiedOrder(param)
|
result, err := api.WxpayAPI.CreateUnifiedOrder(param)
|
||||||
|
globals.SugarLogger.Debug("err2=====================", err)
|
||||||
|
globals.SugarLogger.Debug("err3=====================", fmt.Sprintf("%+v", result))
|
||||||
if err == nil {
|
if err == nil {
|
||||||
orderPay = &model.OrderPay{
|
orderPay = &model.OrderPay{
|
||||||
PayOrderID: param.OutTradeNo,
|
PayOrderID: param.OutTradeNo,
|
||||||
|
|||||||
@@ -43,7 +43,12 @@ func (c *PurchaseHandler) AgreeOrRefuseRefund(ctx *jxcontext.Context, order *mod
|
|||||||
if status == model.AfsOrderStatusFinished {
|
if status == model.AfsOrderStatusFinished {
|
||||||
orderPays, err := dao.GetOrderPayList(dao.GetDB(), order.VendorOrderID, order.VendorID)
|
orderPays, err := dao.GetOrderPayList(dao.GetDB(), order.VendorOrderID, order.VendorID)
|
||||||
if err == nil {
|
if err == nil {
|
||||||
|
if orderPays[0].PayType == model.PayTypeTL {
|
||||||
_, err = localjx.RefundOrderByTL(ctx, orderPays[0], order.VendorOrderID, int(order.SkuUserMoney), reason)
|
_, err = localjx.RefundOrderByTL(ctx, orderPays[0], order.VendorOrderID, int(order.SkuUserMoney), reason)
|
||||||
|
}
|
||||||
|
if orderPays[0].PayType == model.PayTypeTicTok {
|
||||||
|
_, err = localjx.RefundOrderByTT(ctx, orderPays[0], order.VendorOrderID, int(order.SkuUserMoney), reason)
|
||||||
|
}
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
} else {
|
} else {
|
||||||
@@ -127,7 +132,12 @@ func (c *PurchaseHandler) PartRefundOrder(ctx *jxcontext.Context, order *model.G
|
|||||||
if !isJxShop(appID) {
|
if !isJxShop(appID) {
|
||||||
orderPays, err := dao.GetOrderPayList(db, order.VendorOrderID, order.VendorID)
|
orderPays, err := dao.GetOrderPayList(db, order.VendorOrderID, order.VendorID)
|
||||||
if err == nil {
|
if err == nil {
|
||||||
|
if orderPays[0].PayType == model.PayTypeTL {
|
||||||
_, err = localjx.RefundOrderByTL(ctx, orderPays[0], order.VendorOrderID, int(salePrice), reason)
|
_, err = localjx.RefundOrderByTL(ctx, orderPays[0], order.VendorOrderID, int(salePrice), reason)
|
||||||
|
}
|
||||||
|
if orderPays[0].PayType == model.PayTypeTicTok {
|
||||||
|
_, err = localjx.RefundOrderByTT(ctx, orderPays[0], order.VendorOrderID, int(salePrice), reason)
|
||||||
|
}
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -287,7 +287,7 @@ aliUpcAppCode = "00a6eefba0204d3fa310ac0ee7a6fc54"
|
|||||||
wxpayNotifyURL = "http://callback.jxc4.com/wxpay/msg/"
|
wxpayNotifyURL = "http://callback.jxc4.com/wxpay/msg/"
|
||||||
|
|
||||||
# 抖音支付回调地址
|
# 抖音支付回调地址
|
||||||
tiktokNotifyUrl = "http://callback.test.jxc4.com/ttpay/msg/"
|
tiktokNotifyUrl = "http://callback.jxc4.com/ttpay/msg/"
|
||||||
|
|
||||||
tonglianPayAppID = "00183083"
|
tonglianPayAppID = "00183083"
|
||||||
tonglianPayKey = "18048531223"
|
tonglianPayKey = "18048531223"
|
||||||
@@ -386,7 +386,7 @@ weixinAppSecretPrint = "ff4128908947cfb71002f74599c0dbf9"
|
|||||||
wxpayNotifyURL = "http://callback-jxgy.jxc4.com/wxpay/msg/"
|
wxpayNotifyURL = "http://callback-jxgy.jxc4.com/wxpay/msg/"
|
||||||
|
|
||||||
# 抖音支付回调地址
|
# 抖音支付回调地址
|
||||||
tiktokNotifyUrl = "http://callback.test.jxc4.com/ttpay/msg/"
|
tiktokNotifyUrl = "http://callback-jxgy.jxc4.com/ttpay/msg/"
|
||||||
|
|
||||||
tonglianPayAppID = "00183083"
|
tonglianPayAppID = "00183083"
|
||||||
tonglianPayKey = "18048531223"
|
tonglianPayKey = "18048531223"
|
||||||
@@ -574,7 +574,7 @@ aliUpcAppCode = "00a6eefba0204d3fa310ac0ee7a6fc54"
|
|||||||
wxpayNotifyURL = "http://callback.beta.jxc4.com/wxpay/msg/"
|
wxpayNotifyURL = "http://callback.beta.jxc4.com/wxpay/msg/"
|
||||||
|
|
||||||
# 抖音支付回调地址
|
# 抖音支付回调地址
|
||||||
tiktokNotifyUrl = "http://callback.test.jxc4.com/ttpay/msg/"
|
tiktokNotifyUrl = "http://callback.beta.jxc4.com/ttpay/msg/"
|
||||||
|
|
||||||
tonglianPayAppID = "00183083"
|
tonglianPayAppID = "00183083"
|
||||||
tonglianPayKey = "18048531223"
|
tonglianPayKey = "18048531223"
|
||||||
|
|||||||
66
controllers/tictok_callback.go
Normal file
66
controllers/tictok_callback.go
Normal file
@@ -0,0 +1,66 @@
|
|||||||
|
package controllers
|
||||||
|
|
||||||
|
import (
|
||||||
|
"bytes"
|
||||||
|
"git.rosy.net.cn/jx-callback/business/partner/purchase/jx/localjx"
|
||||||
|
"io/ioutil"
|
||||||
|
"net/http"
|
||||||
|
|
||||||
|
"git.rosy.net.cn/jx-callback/globals/api"
|
||||||
|
|
||||||
|
"git.rosy.net.cn/baseapi/utils"
|
||||||
|
"git.rosy.net.cn/jx-callback/globals"
|
||||||
|
|
||||||
|
"github.com/astaxie/beego/server/web"
|
||||||
|
"github.com/astaxie/beego/server/web/context"
|
||||||
|
)
|
||||||
|
|
||||||
|
type TicTocController struct {
|
||||||
|
web.Controller
|
||||||
|
}
|
||||||
|
|
||||||
|
type TicktockRes struct {
|
||||||
|
ErrNo int `json:"err_no"`
|
||||||
|
ErrTips string `json:"err_tips"`
|
||||||
|
}
|
||||||
|
|
||||||
|
func MsgSuccess() *TicktockRes {
|
||||||
|
return &TicktockRes{
|
||||||
|
ErrNo: 0,
|
||||||
|
ErrTips: "success",
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func MsgFail() *TicktockRes {
|
||||||
|
return &TicktockRes{
|
||||||
|
ErrNo: 400,
|
||||||
|
ErrTips: "business fail",
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func (c *TicTocController) Msg() {
|
||||||
|
if c.Ctx.Input.Method() == http.MethodPost {
|
||||||
|
call, refund, payType, err := api.TiktokApi.GetCallbackMsg(getPayInfo(c.Ctx))
|
||||||
|
globals.SugarLogger.Debugf("tictok callback callbackResponse:%s", utils.Format4Output(call, true))
|
||||||
|
if err != nil {
|
||||||
|
c.Data["json"] = MsgFail()
|
||||||
|
c.ServeJSON()
|
||||||
|
return
|
||||||
|
}
|
||||||
|
err = localjx.OnTTPayCallback(call, refund, payType)
|
||||||
|
if err != nil {
|
||||||
|
c.Data["json"] = MsgFail()
|
||||||
|
c.ServeJSON()
|
||||||
|
return
|
||||||
|
}
|
||||||
|
c.Data["json"] = MsgSuccess()
|
||||||
|
c.ServeJSON()
|
||||||
|
} else {
|
||||||
|
c.Abort("404")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
func getPayInfo(ctx *context.Context) *http.Request {
|
||||||
|
ctx.Request.Body = ioutil.NopCloser(bytes.NewReader(ctx.Input.RequestBody))
|
||||||
|
return ctx.Request
|
||||||
|
}
|
||||||
@@ -182,6 +182,7 @@ func init() {
|
|||||||
web.AutoRouter(&controllers.KnowUploadController{})
|
web.AutoRouter(&controllers.KnowUploadController{})
|
||||||
web.AutoRouter(&controllers.AliApiController{})
|
web.AutoRouter(&controllers.AliApiController{})
|
||||||
//web.AutoRouter(&controllers.BiddingController{})
|
//web.AutoRouter(&controllers.BiddingController{})
|
||||||
|
web.AutoRouter(&controllers.TicTocController{})
|
||||||
|
|
||||||
// 如下都是用于检测存活的空接口
|
// 如下都是用于检测存活的空接口
|
||||||
web.Any("/", func(ctx *beecontext.Context) {
|
web.Any("/", func(ctx *beecontext.Context) {
|
||||||
|
|||||||
Reference in New Issue
Block a user