- 优化updateOrderSkuOtherInfo中对于skuID的获取处理

This commit is contained in:
gazebo
2019-09-10 21:06:03 +08:00
parent a6350630bd
commit a2bb472640

View File

@@ -271,16 +271,11 @@ func (c *OrderManager) updateOrderSkuOtherInfo(order *model.GoodsOrder, db *dao.
orderSkus := order.Skus
vendorSkuIDs := make([]int64, 0)
skuIDMap := make(map[int]int)
for _, v := range orderSkus {
intVendorSkuID := utils.Str2Int64WithDefault(v.VendorSkuID, 0)
if intVendorSkuID != 0 {
vendorSkuIDs = append(vendorSkuIDs, intVendorSkuID)
}
if skuID := jxutils.GetSkuIDFromOrderSku(v); skuID > 0 {
skuIDMap[skuID] = 1
}
}
if len(vendorSkuIDs) > 0 {
tableName := "t2"
@@ -311,17 +306,7 @@ func (c *OrderManager) updateOrderSkuOtherInfo(order *model.GoodsOrder, db *dao.
skumapper[v.VendorSkuID] = v
}
// var skuPriceMap map[int64]*dao.PromotionStoreSku
var actStoreSkuMap *jxutils.ActStoreSkuMap
if len(skuIDMap) > 0 {
actStoreSkuList, err := dao.GetEffectiveActStoreSkuInfo(db, 0, []int{order.VendorID}, []int{jxStoreID}, jxutils.IntMap2List(skuIDMap), order.OrderCreatedAt, order.OrderCreatedAt)
if err != nil {
globals.SugarLogger.Errorf("updateOrderSkuOtherInfo can not get sku promotion info for error:%v", err)
return err
}
actStoreSkuMap = jxutils.NewActStoreSkuMap(actStoreSkuList, false)
}
skuIDMap := make(map[int]int)
for _, v := range orderSkus {
v.VendorOrderID = order.VendorOrderID
v.VendorID = order.VendorID
@@ -342,12 +327,25 @@ func (c *OrderManager) updateOrderSkuOtherInfo(order *model.GoodsOrder, db *dao.
}
}
if actStoreSkuMap != nil {
if skuID := jxutils.GetSkuIDFromOrderSku(v); skuID > 0 {
if actStoreSku := actStoreSkuMap.GetActStoreSku(jxStoreID, skuID, order.VendorID); actStoreSku != nil {
v.EarningPrice = actStoreSku.EarningPrice
if true { //v.StoreSubName != "" { // 之前这里为什么要加判断?
v.StoreSubID = actStoreSku.ActID
if skuID := jxutils.GetSkuIDFromOrderSku(v); skuID > 0 {
skuIDMap[skuID] = 1
}
}
if len(skuIDMap) > 0 {
actStoreSkuList, err := dao.GetEffectiveActStoreSkuInfo(db, 0, []int{order.VendorID}, []int{jxStoreID}, jxutils.IntMap2List(skuIDMap), order.OrderCreatedAt, order.OrderCreatedAt)
if err != nil {
globals.SugarLogger.Errorf("updateOrderSkuOtherInfo can not get sku promotion info for error:%v", err)
return err
}
if actStoreSkuMap := jxutils.NewActStoreSkuMap(actStoreSkuList, false); actStoreSkuMap != nil {
for _, v := range orderSkus {
if skuID := jxutils.GetSkuIDFromOrderSku(v); skuID > 0 {
if actStoreSku := actStoreSkuMap.GetActStoreSku(jxStoreID, skuID, order.VendorID); actStoreSku != nil {
v.EarningPrice = actStoreSku.EarningPrice
if true { //v.StoreSubName != "" { // 之前这里为什么要加判断?
v.StoreSubID = actStoreSku.ActID
}
}
}
}