From 0a9ec200066431bd04c3ba51edeb42c85797c78b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E8=8B=8F=E5=B0=B9=E5=B2=9A?= <770236076@qq.com> Date: Wed, 6 Nov 2019 09:40:19 +0800 Subject: [PATCH] =?UTF-8?q?=E5=88=B7=E6=96=B0=E5=8E=86=E5=8F=B2=E8=AE=A2?= =?UTF-8?q?=E5=8D=95=E7=BB=93=E7=AE=97=E4=BB=B7=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- business/jxcallback/orderman/order.go | 26 +++++++++----------------- business/model/dao/dao_order.go | 12 ++++++------ 2 files changed, 15 insertions(+), 23 deletions(-) diff --git a/business/jxcallback/orderman/order.go b/business/jxcallback/orderman/order.go index da729ccc8..6552734f2 100644 --- a/business/jxcallback/orderman/order.go +++ b/business/jxcallback/orderman/order.go @@ -637,32 +637,24 @@ func (c *OrderManager) RefreshHistoryOrdersEarningPrice(ctx *jxcontext.Context, v := batchItemList[0].(*model.GoodsOrder) order, _ := c.loadOrder(v.VendorOrderID, "", v.VendorID) updateSingleOrderEarningPrice(order, db) - for _, orderSku := range order.Skus { - actStoreSkuList, err := dao.GetEffectiveActStoreSkuInfo(db, 0, []int{v.VendorID}, []int{v.StoreID}, []int{orderSku.SkuID}, v.OrderCreatedAt, v.OrderCreatedAt) - if err != nil { - globals.SugarLogger.Errorf("updateOrderSkuOtherInfo can not get sku promotion info for error:%v", err) - return "", err + for _, value := range order.Skus { + dao.Begin(db) + _, err := dao.UpdateOrderSkuEariningPrice(db, value, v.StoreID, fromDateParm, toDateParm) + if err == nil{ + dao.Commit(db) } - if actStoreSkuMap := jxutils.NewActStoreSkuMap(actStoreSkuList, false); actStoreSkuMap != nil { - for _, value := range actStoreSkuList { - num, err := dao.UpdateOrderSkuEariningPrice(db, value, fromDateParm, toDateParm) - if err != nil && !isContinueWhenError { - return "", err - } else { - globals.SugarLogger.Debug(fmt.Sprintf("更新order_sku , 行数:%d, storeid :%d ,skuid : %d, vendoreid : %d, earningPrice : %v, store_sub_id : %d", num, value.StoreID, value.SkuID, value.VendorID, value.EarningPrice, value.ActID)) - } - } + if err != nil && !isContinueWhenError { + dao.Rollback(db) + return "", err } } return retVal, err }, orderList) tasksch.HandleTask(task1, task, true).Run() case 1: - num2, err2 := dao.UpdateGoodOrderEaringPrice(db, fromDateParm, toDateParm) + _, err2 := dao.UpdateGoodOrderEaringPrice(db, fromDateParm, toDateParm) if err2 != nil && !isContinueWhenError { return "", err2 - } else { - globals.SugarLogger.Debug(fmt.Sprintf("更新goods_order , 行数:%d, 时间: %v 至 %v", num2, fromDateParm, toDateParm)) } } return result, err diff --git a/business/model/dao/dao_order.go b/business/model/dao/dao_order.go index f04d2ea40..c1274e932 100644 --- a/business/model/dao/dao_order.go +++ b/business/model/dao/dao_order.go @@ -590,7 +590,7 @@ func GetRiskOrderCount(db *DaoDB, dayNum int, includeToday bool) (storeOrderList return storeOrderList, GetRows(db, &storeOrderList, sql, sqlParams) } -func UpdateOrderSkuEariningPrice(db *DaoDB, actStoreSku2 *model.ActStoreSku2, fromDateParm, toDateParm time.Time) (num int64, err error) { +func UpdateOrderSkuEariningPrice(db *DaoDB, skus *model.OrderSku, storeID int, fromDateParm, toDateParm time.Time) (num int64, err error) { sql := ` UPDATE order_sku t1 JOIN goods_order tt1 ON tt1.vendor_order_id = t1.vendor_order_id @@ -602,13 +602,13 @@ func UpdateOrderSkuEariningPrice(db *DaoDB, actStoreSku2 *model.ActStoreSku2, fr WHERE t1.store_sub_id = 0 ` sqlParams := []interface{}{ - actStoreSku2.VendorID, - actStoreSku2.SkuID, - actStoreSku2.StoreID, + skus.VendorID, + skus.SkuID, + storeID, fromDateParm, toDateParm, - actStoreSku2.EarningPrice, - actStoreSku2.ActID, + skus.EarningPrice, + skus.StoreSubID, } return ExecuteSQL(db, sql, sqlParams...) }