From a2bb472640264de9b75485c1cd50f357d3e75a6f Mon Sep 17 00:00:00 2001 From: gazebo Date: Tue, 10 Sep 2019 21:06:03 +0800 Subject: [PATCH] =?UTF-8?q?-=20=E4=BC=98=E5=8C=96updateOrderSkuOtherInfo?= =?UTF-8?q?=E4=B8=AD=E5=AF=B9=E4=BA=8EskuID=E7=9A=84=E8=8E=B7=E5=8F=96?= =?UTF-8?q?=E5=A4=84=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- business/jxcallback/orderman/order.go | 42 +++++++++++++-------------- 1 file changed, 20 insertions(+), 22 deletions(-) diff --git a/business/jxcallback/orderman/order.go b/business/jxcallback/orderman/order.go index 3973c1abf..6b534b5c8 100644 --- a/business/jxcallback/orderman/order.go +++ b/business/jxcallback/orderman/order.go @@ -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 + } } } }