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...) }