Merge remote-tracking branch 'origin/jdshop' into qidongsheng

This commit is contained in:
qidongsheng
2020-06-27 10:11:54 +08:00
4 changed files with 73 additions and 17 deletions

View File

@@ -779,7 +779,6 @@ func (s *DefScheduler) solutionJdsOrder(bill *model.Waybill) (err error) {
func (s *DefScheduler) cancelOtherWaybills(savedOrderInfo *WatchOrderInfo, bill2Keep *model.Waybill, cancelReasonID int, cancelReason string) (err error) {
globals.SugarLogger.Debugf("cancelOtherWaybills, orderID:%s, bill:%v", savedOrderInfo.order.VendorOrderID, bill2Keep)
globals.SugarLogger.Debugf("testcancelOtherWaybills,savedOrderInfo: %v", utils.Format4Output(savedOrderInfo, false))
for _, v := range savedOrderInfo.waybills {
if v.Status < model.WaybillStatusEndBegin &&
!model.IsWaybillPlatformOwn(v) &&

View File

@@ -1024,7 +1024,7 @@ func CancelOrder(ctx *jxcontext.Context, order *model.GoodsOrder, reason string)
errList.AddErr(err)
}
} else if orderPay.PayType == model.PayTypeTL {
orderPayRefund, err = refundOrderByTL(ctx, orderPay, refundID, orderPay.TotalFee, reason)
orderPayRefund, err = RefundOrderByTL(ctx, orderPay, refundID, orderPay.TotalFee, reason)
if err != nil {
errList.AddErr(err)
}

View File

@@ -147,11 +147,10 @@ func onTLpayRefund(call *tonglianpayapi.CallBackResult) (err error) {
return err
}
func refundOrderByTL(ctx *jxcontext.Context, orderPay *model.OrderPay, refundID string, refundFee int, refundDesc string) (orderPayRefund *model.OrderPayRefund, err error) {
func RefundOrderByTL(ctx *jxcontext.Context, orderPay *model.OrderPay, refundID string, refundFee int, refundDesc string) (orderPayRefund *model.OrderPayRefund, err error) {
result, err := api.TLpayAPI.PayRefund(&tonglianpayapi.PayRefundParam{
Trxamt: orderPay.TotalFee,
Reqsn: utils.GetUUID(),
// OldReqsn: orderPay.VendorOrderID,
Trxamt: refundFee,
Reqsn: utils.GetUUID(),
Remark: refundDesc,
OldTrxID: orderPay.TransactionID,
})
@@ -163,7 +162,7 @@ func refundOrderByTL(ctx *jxcontext.Context, orderPay *model.OrderPay, refundID
VendorID: orderPay.VendorID,
Status: model.RefundStatusNo,
TransactionID: orderPay.TransactionID,
RefundFee: orderPay.TotalFee,
RefundFee: refundFee,
RefundCreatedAt: time.Now(),
}
dao.WrapAddIDCULDEntity(orderPayRefund, ctx.GetUserName())

View File

@@ -2,15 +2,19 @@ package jx
import (
"fmt"
"strings"
"time"
"git.rosy.net.cn/jx-callback/business/model/dao"
"git.rosy.net.cn/jx-callback/globals/api"
"git.rosy.net.cn/jx-callback/business/partner/purchase/jx/localjx"
"git.rosy.net.cn/baseapi/utils"
"git.rosy.net.cn/jx-callback/business/jxutils/jxcontext"
"git.rosy.net.cn/jx-callback/business/model"
"git.rosy.net.cn/jx-callback/business/partner"
"git.rosy.net.cn/jx-callback/business/partner/purchase/jx/phpjx"
)
// 审核售后单申请
@@ -21,8 +25,26 @@ func (c *PurchaseHandler) AgreeOrRefuseRefund(ctx *jxcontext.Context, order *mod
} else {
status = model.AfsOrderStatusFinished
}
if model.IsAfsOrderJXTemp(order) {
err = phpjx.NotifyAfsOrderStatusChanged(order, status)
orderStatus := &model.OrderStatus{
VendorOrderID: order.AfsOrderID, // 是售后单ID不是订单ID订单ID在RefVendorOrderID中
VendorID: order.VendorID,
OrderType: model.OrderTypeAfsOrder,
RefVendorOrderID: order.VendorOrderID,
RefVendorID: order.VendorID,
VendorStatus: utils.Int2Str(status),
Status: status,
StatusTime: time.Now(),
Remark: reason,
}
partner.CurOrderManager.OnAfsOrderStatusChanged(orderStatus)
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 err != nil {
return err
}
}
}
return err
}
@@ -41,11 +63,23 @@ func (c *PurchaseHandler) RefundOrder(ctx *jxcontext.Context, order *model.Goods
// 发起部分退款
func (c *PurchaseHandler) PartRefundOrder(ctx *jxcontext.Context, order *model.GoodsOrder, refundSkuList []*model.OrderSku, reason string) (err error) {
var skuMap = make(map[int]*model.OrderSku)
var (
skuMap = make(map[int]*model.OrderSku)
appID = ""
salePrice int64
)
referer := ctx.GetRequest().Referer()
index := strings.Index(referer, "//")
if index > 0 {
list := strings.Split(referer[index+2:], "/")
if len(list) >= 2 {
appID = list[1]
}
}
for _, sku := range order.Skus {
skuMap[sku.SkuID] = sku
}
orderStatus := buildOrderStatus(ctx, order, reason)
orderStatus := buildOrderStatus(ctx, order, reason, isJxShop(appID))
afsOrder := &model.AfsOrder{
VendorID: order.VendorID,
AfsOrderID: orderStatus.VendorOrderID,
@@ -72,15 +106,27 @@ func (c *PurchaseHandler) PartRefundOrder(ctx *jxcontext.Context, order *model.G
if skuMap[sku.SkuID] != nil {
orderSku.Name = skuMap[sku.SkuID].SkuName
orderSku.UserMoney = skuMap[sku.SkuID].SalePrice
salePrice += skuMap[sku.SkuID].SalePrice
}
afsOrder.SkuUserMoney += orderSku.UserMoney
afsOrder.Skus = append(afsOrder.Skus, orderSku)
}
err = fmt.Errorf("%s不支持售后部分退款请让买家发起退款", model.VendorChineseNames[model.VendorIDJX])
if afsOrder != nil {
err = partner.CurOrderManager.OnAfsOrderNew(afsOrder, orderStatus)
}
if !isJxShop(appID) {
orderPays, err := dao.GetOrderPayList(dao.GetDB(), order.VendorOrderID, order.VendorID)
if err == nil {
_, err = localjx.RefundOrderByTL(ctx, orderPays[0], order.VendorOrderID, int(salePrice), reason)
if err != nil {
return err
}
}
}
return err
}
func buildOrderStatus(ctx *jxcontext.Context, order *model.GoodsOrder, reason string) (orderStatus *model.OrderStatus) {
func buildOrderStatus(ctx *jxcontext.Context, order *model.GoodsOrder, reason string, isJxShop bool) (orderStatus *model.OrderStatus) {
orderStatus = &model.OrderStatus{
VendorOrderID: utils.Int64ToStr(localjx.GenAfsOrderNo(ctx)), // 是售后单ID不是订单ID订单ID在RefVendorOrderID中
VendorID: order.VendorID,
@@ -88,9 +134,21 @@ func buildOrderStatus(ctx *jxcontext.Context, order *model.GoodsOrder, reason st
RefVendorOrderID: order.VendorOrderID,
RefVendorID: order.VendorID,
VendorStatus: utils.Int2Str(model.AfsOrderStatusWait4Approve),
Status: model.AfsOrderStatusWait4Approve,
StatusTime: time.Now(),
Remark: reason,
// Status: model.AfsOrderStatusWait4Approve,
StatusTime: time.Now(),
Remark: reason,
}
if isJxShop {
orderStatus.Status = model.AfsOrderStatusWait4Approve
} else {
orderStatus.Status = model.AfsOrderStatusNew
}
return orderStatus
}
func isJxShop(appID string) bool {
if appID == api.WeixinMiniAppID2 {
return true
}
return false
}