京西商城售后单
This commit is contained in:
@@ -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) {
|
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("cancelOtherWaybills, orderID:%s, bill:%v", savedOrderInfo.order.VendorOrderID, bill2Keep)
|
||||||
globals.SugarLogger.Debugf("testcancelOtherWaybills,savedOrderInfo: %v", utils.Format4Output(savedOrderInfo, false))
|
|
||||||
for _, v := range savedOrderInfo.waybills {
|
for _, v := range savedOrderInfo.waybills {
|
||||||
if v.Status < model.WaybillStatusEndBegin &&
|
if v.Status < model.WaybillStatusEndBegin &&
|
||||||
!model.IsWaybillPlatformOwn(v) &&
|
!model.IsWaybillPlatformOwn(v) &&
|
||||||
|
|||||||
@@ -1024,7 +1024,7 @@ func CancelOrder(ctx *jxcontext.Context, order *model.GoodsOrder, reason string)
|
|||||||
errList.AddErr(err)
|
errList.AddErr(err)
|
||||||
}
|
}
|
||||||
} else if orderPay.PayType == model.PayTypeTL {
|
} 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 {
|
if err != nil {
|
||||||
errList.AddErr(err)
|
errList.AddErr(err)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -147,11 +147,10 @@ func onTLpayRefund(call *tonglianpayapi.CallBackResult) (err error) {
|
|||||||
return err
|
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{
|
result, err := api.TLpayAPI.PayRefund(&tonglianpayapi.PayRefundParam{
|
||||||
Trxamt: orderPay.TotalFee,
|
Trxamt: refundFee,
|
||||||
Reqsn: utils.GetUUID(),
|
Reqsn: utils.GetUUID(),
|
||||||
// OldReqsn: orderPay.VendorOrderID,
|
|
||||||
Remark: refundDesc,
|
Remark: refundDesc,
|
||||||
OldTrxID: orderPay.TransactionID,
|
OldTrxID: orderPay.TransactionID,
|
||||||
})
|
})
|
||||||
@@ -163,7 +162,7 @@ func refundOrderByTL(ctx *jxcontext.Context, orderPay *model.OrderPay, refundID
|
|||||||
VendorID: orderPay.VendorID,
|
VendorID: orderPay.VendorID,
|
||||||
Status: model.RefundStatusNo,
|
Status: model.RefundStatusNo,
|
||||||
TransactionID: orderPay.TransactionID,
|
TransactionID: orderPay.TransactionID,
|
||||||
RefundFee: orderPay.TotalFee,
|
RefundFee: refundFee,
|
||||||
RefundCreatedAt: time.Now(),
|
RefundCreatedAt: time.Now(),
|
||||||
}
|
}
|
||||||
dao.WrapAddIDCULDEntity(orderPayRefund, ctx.GetUserName())
|
dao.WrapAddIDCULDEntity(orderPayRefund, ctx.GetUserName())
|
||||||
|
|||||||
@@ -2,15 +2,19 @@ package jx
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"strings"
|
||||||
"time"
|
"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/jx-callback/business/partner/purchase/jx/localjx"
|
||||||
|
|
||||||
"git.rosy.net.cn/baseapi/utils"
|
"git.rosy.net.cn/baseapi/utils"
|
||||||
"git.rosy.net.cn/jx-callback/business/jxutils/jxcontext"
|
"git.rosy.net.cn/jx-callback/business/jxutils/jxcontext"
|
||||||
"git.rosy.net.cn/jx-callback/business/model"
|
"git.rosy.net.cn/jx-callback/business/model"
|
||||||
"git.rosy.net.cn/jx-callback/business/partner"
|
"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 {
|
} else {
|
||||||
status = model.AfsOrderStatusFinished
|
status = model.AfsOrderStatusFinished
|
||||||
}
|
}
|
||||||
if model.IsAfsOrderJXTemp(order) {
|
orderStatus := &model.OrderStatus{
|
||||||
err = phpjx.NotifyAfsOrderStatusChanged(order, status)
|
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
|
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) {
|
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 {
|
for _, sku := range order.Skus {
|
||||||
skuMap[sku.SkuID] = sku
|
skuMap[sku.SkuID] = sku
|
||||||
}
|
}
|
||||||
orderStatus := buildOrderStatus(ctx, order, reason)
|
orderStatus := buildOrderStatus(ctx, order, reason, isJxShop(appID))
|
||||||
afsOrder := &model.AfsOrder{
|
afsOrder := &model.AfsOrder{
|
||||||
VendorID: order.VendorID,
|
VendorID: order.VendorID,
|
||||||
AfsOrderID: orderStatus.VendorOrderID,
|
AfsOrderID: orderStatus.VendorOrderID,
|
||||||
@@ -72,15 +106,27 @@ func (c *PurchaseHandler) PartRefundOrder(ctx *jxcontext.Context, order *model.G
|
|||||||
if skuMap[sku.SkuID] != nil {
|
if skuMap[sku.SkuID] != nil {
|
||||||
orderSku.Name = skuMap[sku.SkuID].SkuName
|
orderSku.Name = skuMap[sku.SkuID].SkuName
|
||||||
orderSku.UserMoney = skuMap[sku.SkuID].SalePrice
|
orderSku.UserMoney = skuMap[sku.SkuID].SalePrice
|
||||||
|
salePrice += skuMap[sku.SkuID].SalePrice
|
||||||
}
|
}
|
||||||
afsOrder.SkuUserMoney += orderSku.UserMoney
|
afsOrder.SkuUserMoney += orderSku.UserMoney
|
||||||
afsOrder.Skus = append(afsOrder.Skus, orderSku)
|
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
|
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{
|
orderStatus = &model.OrderStatus{
|
||||||
VendorOrderID: utils.Int64ToStr(localjx.GenAfsOrderNo(ctx)), // 是售后单ID,不是订单ID,订单ID在RefVendorOrderID中
|
VendorOrderID: utils.Int64ToStr(localjx.GenAfsOrderNo(ctx)), // 是售后单ID,不是订单ID,订单ID在RefVendorOrderID中
|
||||||
VendorID: order.VendorID,
|
VendorID: order.VendorID,
|
||||||
@@ -88,9 +134,21 @@ func buildOrderStatus(ctx *jxcontext.Context, order *model.GoodsOrder, reason st
|
|||||||
RefVendorOrderID: order.VendorOrderID,
|
RefVendorOrderID: order.VendorOrderID,
|
||||||
RefVendorID: order.VendorID,
|
RefVendorID: order.VendorID,
|
||||||
VendorStatus: utils.Int2Str(model.AfsOrderStatusWait4Approve),
|
VendorStatus: utils.Int2Str(model.AfsOrderStatusWait4Approve),
|
||||||
Status: model.AfsOrderStatusWait4Approve,
|
// Status: model.AfsOrderStatusWait4Approve,
|
||||||
StatusTime: time.Now(),
|
StatusTime: time.Now(),
|
||||||
Remark: reason,
|
Remark: reason,
|
||||||
|
}
|
||||||
|
if isJxShop {
|
||||||
|
orderStatus.Status = model.AfsOrderStatusWait4Approve
|
||||||
|
} else {
|
||||||
|
orderStatus.Status = model.AfsOrderStatusNew
|
||||||
}
|
}
|
||||||
return orderStatus
|
return orderStatus
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func isJxShop(appID string) bool {
|
||||||
|
if appID == api.WeixinMiniAppID2 {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user