This commit is contained in:
苏尹岚
2020-06-23 18:01:36 +08:00
parent 4120717078
commit 961e4378ee
3 changed files with 70 additions and 0 deletions

View File

@@ -779,6 +779,7 @@ 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

@@ -385,6 +385,21 @@ func GenOrderNo(ctx *jxcontext.Context) (orderNo int64) {
return orderNo
}
func GenAfsOrderNo(ctx *jxcontext.Context) (orderNo int64) {
const prefix = 80
const randPartNum = 100
orderNo = time.Now().Unix() - orderNoBeginTimestamp
orderNo = orderNo * randPartNum
md5Bytes := md5.Sum([]byte(utils.GetUUID()))
randPart := 0
for k, v := range md5Bytes {
randPart += int(v) << ((k % 3) * 8)
}
orderNo += int64(randPart % randPartNum)
orderNo += int64(math.Pow10(int(math.Log10(float64(orderNo)))+1)) * prefix
return orderNo
}
func GenPayOrderID(order *model.GoodsOrder) (payOrderID int64) {
return utils.Str2Int64(order.VendorOrderID)
}

View File

@@ -2,7 +2,11 @@ package jx
import (
"fmt"
"time"
"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"
@@ -37,6 +41,56 @@ 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)
for _, sku := range order.Skus {
skuMap[sku.SkuID] = sku
}
orderStatus := buildOrderStatus(ctx, order, reason)
afsOrder := &model.AfsOrder{
VendorID: order.VendorID,
AfsOrderID: orderStatus.VendorOrderID,
VendorOrderID: orderStatus.RefVendorOrderID,
VendorStoreID: order.VendorStoreID,
StoreID: order.StoreID,
AfsCreatedAt: time.Now(),
VendorAppealType: "",
AppealType: model.AfsAppealTypeRefund,
VendorReasonType: utils.Int2Str(model.AfsReasonNotOthers),
ReasonType: model.AfsReasonNotOthers,
ReasonDesc: utils.LimitUTF8StringLen(reason, 1024),
ReasonImgList: "",
RefundType: model.AfsTypePartRefund,
VendorOrgCode: "",
}
for _, sku := range refundSkuList {
orderSku := &model.OrderSkuFinancial{
Count: sku.Count,
VendorSkuID: utils.Int2Str(sku.SkuID),
SkuID: sku.SkuID,
}
if skuMap[sku.SkuID] != nil {
orderSku.Name = skuMap[sku.SkuID].SkuName
orderSku.UserMoney = skuMap[sku.SkuID].SalePrice
}
afsOrder.SkuUserMoney += orderSku.UserMoney
afsOrder.Skus = append(afsOrder.Skus, orderSku)
}
err = fmt.Errorf("%s不支持售后部分退款请让买家发起退款", model.VendorChineseNames[model.VendorIDJX])
return err
}
func buildOrderStatus(ctx *jxcontext.Context, order *model.GoodsOrder, reason string) (orderStatus *model.OrderStatus) {
orderStatus = &model.OrderStatus{
VendorOrderID: utils.Int64ToStr(localjx.GenAfsOrderNo(ctx)), // 是售后单ID不是订单ID订单ID在RefVendorOrderID中
VendorID: order.VendorID,
OrderType: model.OrderTypeAfsOrder,
RefVendorOrderID: order.VendorOrderID,
RefVendorID: order.VendorID,
VendorStatus: utils.Int2Str(model.AfsOrderStatusWait4Approve),
Status: model.AfsOrderStatusWait4Approve,
StatusTime: time.Now(),
Remark: reason,
}
return orderStatus
}