1
This commit is contained in:
@@ -98,7 +98,8 @@ func (c *PrinterHandler) getOrderContent(order *model.GoodsOrder, storeTel strin
|
||||
|
||||
for _, sku := range order.Skus {
|
||||
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*int64(sku.Count)))
|
||||
//标品需要打印条形码
|
||||
|
||||
@@ -1397,6 +1397,11 @@ func CancelOrder(ctx *jxcontext.Context, order *model.GoodsOrder, reason string)
|
||||
if err != nil {
|
||||
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 {
|
||||
//如果用了优惠券,状态要刷回去
|
||||
|
||||
@@ -50,50 +50,50 @@ func pay4OrderByTT(ctx *jxcontext.Context, order *model.GoodsOrder, vendorPayTyp
|
||||
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))
|
||||
switch msg.MsgType {
|
||||
case wxpayapi.MsgTypePay:
|
||||
err = onWxpayFinished(msg.Data.(*wxpayapi.PayResultMsg))
|
||||
case wxpayapi.MsgTypeRefund:
|
||||
err = onWxpayRefund(msg.Data.(*wxpayapi.RefundResultMsg))
|
||||
switch payType {
|
||||
case tiktok.PayStatus: // 支付回调
|
||||
err = onTTPayFinished(msg)
|
||||
case tiktok.RefundStatus: // 退款回调
|
||||
err = onTTPayRefund(refund)
|
||||
}
|
||||
return err
|
||||
}
|
||||
|
||||
func onTTPayFinished(msg *wxpayapi.PayResultMsg) (err error) {
|
||||
func onTTPayFinished(msg *tiktok.DetailCallBackMessage) (err error) {
|
||||
orderPay := &model.OrderPay{
|
||||
PayOrderID: msg.OutTradeNo,
|
||||
PayOrderID: msg.CpOrderno,
|
||||
PayType: model.PayTypeWX,
|
||||
}
|
||||
orderPay.DeletedAt = utils.DefaultTimeValue
|
||||
db := dao.GetDB()
|
||||
if err = dao.GetEntity(db, orderPay, "PayOrderID", "PayType", "DeletedAt"); err == nil {
|
||||
orderPay.PayFinishedAt = utils.Time2Pointer(wxpayapi.PayTime2Time(msg.TimeEnd))
|
||||
orderPay.TransactionID = msg.TransactionID
|
||||
orderPay.PayFinishedAt = utils.Time2Pointer(wxpayapi.PayTime2Time(utils.Int64ToStr(msg.PaidAt)))
|
||||
orderPay.TransactionID = msg.ChannelNo
|
||||
orderPay.OriginalData = utils.Format4Output(msg, true)
|
||||
if msg.ResultCode == wxpayapi.ResponseCodeSuccess {
|
||||
if msg.Status == tiktok.ResponseCodeSuccess {
|
||||
orderPay.Status = model.PayStatusYes
|
||||
} else {
|
||||
orderPay.Status = model.PayStatusFailed
|
||||
}
|
||||
dao.UpdateEntity(db, orderPay)
|
||||
if msg.ResultCode == wxpayapi.ResponseCodeSuccess {
|
||||
if msg.Status == tiktok.ResponseCodeSuccess {
|
||||
err = OnPayFinished(orderPay)
|
||||
}
|
||||
} 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
|
||||
}
|
||||
|
||||
func onTTPayRefund(msg *wxpayapi.RefundResultMsg) (err error) {
|
||||
func onTTPayRefund(msg *tiktok.DetailCallBackMessage2Refund) (err error) {
|
||||
orderPayRefund := &model.OrderPayRefund{
|
||||
RefundID: msg.ReqInfoObj.OutRefundNo,
|
||||
RefundID: msg.CpRefundno,
|
||||
}
|
||||
db := dao.GetDB()
|
||||
if err = dao.GetEntity(db, orderPayRefund, "RefundID"); err == nil {
|
||||
if msg.ResultCode == wxpayapi.ResponseCodeSuccess {
|
||||
if msg.Status == tiktok.ResponseCodeSuccess {
|
||||
orderPayRefund.Status = model.RefundStatusYes
|
||||
} else {
|
||||
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 {
|
||||
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 {
|
||||
param.Acct = authInfo.GetAuthID()
|
||||
globals.SugarLogger.Debug("==============1",authInfo)
|
||||
}
|
||||
if param.Acct == "" {
|
||||
return nil, fmt.Errorf("未找到用户的认证ID!")
|
||||
}
|
||||
globals.SugarLogger.Debug("==============2",param)
|
||||
}
|
||||
if vendorPayType == tonglianpayapi.PayTypeH5 {
|
||||
param2 := &tonglianpayapi.CreateH5UnitorderOrderParam{
|
||||
@@ -75,8 +64,6 @@ func pay4OrderByTL(ctx *jxcontext.Context, order *model.GoodsOrder, payType int,
|
||||
err = api.TLpayAPI.CreateH5UnitorderOrder(param2)
|
||||
} else {
|
||||
result, err := api.TLpayAPI.CreateUnitorderOrder(param)
|
||||
globals.SugarLogger.Debug("=============444",result)
|
||||
globals.SugarLogger.Debug("=============444",err)
|
||||
if err == nil {
|
||||
var result2 tonglianpayapi.PayInfo
|
||||
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 {
|
||||
param.OpenID = authInfo.GetAuthID()
|
||||
}
|
||||
globals.SugarLogger.Debug("err1=====================", err)
|
||||
|
||||
result, err := api.WxpayAPI.CreateUnifiedOrder(param)
|
||||
globals.SugarLogger.Debug("err2=====================", err)
|
||||
globals.SugarLogger.Debug("err3=====================", fmt.Sprintf("%+v", result))
|
||||
if err == nil {
|
||||
orderPay = &model.OrderPay{
|
||||
PayOrderID: param.OutTradeNo,
|
||||
|
||||
@@ -43,7 +43,12 @@ func (c *PurchaseHandler) AgreeOrRefuseRefund(ctx *jxcontext.Context, order *mod
|
||||
if status == model.AfsOrderStatusFinished {
|
||||
orderPays, err := dao.GetOrderPayList(dao.GetDB(), order.VendorOrderID, order.VendorID)
|
||||
if err == nil {
|
||||
_, err = localjx.RefundOrderByTL(ctx, orderPays[0], order.VendorOrderID, int(order.SkuUserMoney), reason)
|
||||
if orderPays[0].PayType == model.PayTypeTL {
|
||||
_, 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 {
|
||||
return err
|
||||
} else {
|
||||
@@ -127,7 +132,12 @@ func (c *PurchaseHandler) PartRefundOrder(ctx *jxcontext.Context, order *model.G
|
||||
if !isJxShop(appID) {
|
||||
orderPays, err := dao.GetOrderPayList(db, order.VendorOrderID, order.VendorID)
|
||||
if err == nil {
|
||||
_, err = localjx.RefundOrderByTL(ctx, orderPays[0], order.VendorOrderID, int(salePrice), reason)
|
||||
if orderPays[0].PayType == model.PayTypeTL {
|
||||
_, 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 {
|
||||
return err
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user