订单earningprice拆分新版
This commit is contained in:
@@ -341,7 +341,6 @@ func (c *OrderManager) updateOrderSkuOtherInfo(order *model.GoodsOrder, db *dao.
|
||||
return err
|
||||
}
|
||||
skumapper := storeSkuPriceAndWeight2Map(l)
|
||||
var skuMultiCountMap = make(map[int][]*tSkuCountPrice)
|
||||
for _, v := range orderSkus {
|
||||
v.VendorOrderID = order.VendorOrderID
|
||||
v.VendorID = order.VendorID
|
||||
@@ -370,29 +369,26 @@ func (c *OrderManager) updateOrderSkuOtherInfo(order *model.GoodsOrder, db *dao.
|
||||
salePrice = 0
|
||||
}
|
||||
v.EarningPrice = jxutils.CaculateSkuEarningPrice(v.ShopPrice, salePrice, storePayPercentage)
|
||||
skuMultiCountMap[v.SkuID] = append(skuMultiCountMap[v.SkuID], &tSkuCountPrice{
|
||||
Count: v.Count,
|
||||
SalePrice: v.SalePrice,
|
||||
})
|
||||
}
|
||||
// 直营店始终按比例结算,不考虑活动与结算表
|
||||
if changePriceType != model.StoreChangePriceTypeManagedStore {
|
||||
updateSingleOrderEarningPrice(order, db)
|
||||
}
|
||||
globals.SugarLogger.Debugf("skuMultiCountMap", utils.Format4Output(skuMultiCountMap, false))
|
||||
//TODO 重复购买有活动且结算价大于0的商品需要拆分,第一个商品按结算价,后面的商品按shopprice 或者 saleprice, 2020-05-06
|
||||
//TODO 京东美团的订单,做活动的商品之前就会拆分出来,所以只做更新,饿百暂时不管, 2020-05-07
|
||||
//TODO 不根据商品是否拆分,直接根据该商品做了活动,并且他的vendorPrice 和 salePrice 相等,就按新规则结算, 2020-05-11
|
||||
if order.VendorID == model.VendorIDJD || order.VendorID == model.VendorIDMTWM {
|
||||
for _, v := range orderSkus {
|
||||
if v.EarningPrice > 0 {
|
||||
if len(skuMultiCountMap[v.SkuID]) > 1 {
|
||||
var price = 0
|
||||
for _, vv := range skuMultiCountMap[v.SkuID] {
|
||||
if int(vv.SalePrice) > price {
|
||||
price = int(vv.SalePrice)
|
||||
}
|
||||
}
|
||||
if price == int(v.SalePrice) {
|
||||
var storeID int
|
||||
if order.StoreID == 0 {
|
||||
storeID = order.JxStoreID
|
||||
} else {
|
||||
storeID = order.StoreID
|
||||
}
|
||||
result, err := dao.GetEffectiveActStoreSkuInfo2(db, 0, []int{order.VendorID}, []int{model.ActSkuSecKill, model.ActSkuDirectDown}, []int{storeID}, []int{v.SkuID}, order.OrderCreatedAt, order.OrderCreatedAt)
|
||||
if len(result) > 0 && err == nil {
|
||||
if v.VendorPrice == v.SalePrice {
|
||||
var earningPrice = 0
|
||||
if v.ShopPrice < v.SalePrice {
|
||||
earningPrice = int(utils.Float64TwoInt64(math.Round(utils.Int2Float64(int(v.ShopPrice)) * utils.Int2Float64(storePayPercentage) / 100)))
|
||||
|
||||
Reference in New Issue
Block a user