diff --git a/business/jxcallback/orderman/orderman_ext.go b/business/jxcallback/orderman/orderman_ext.go index 3a9d22d5a..0d1130a41 100644 --- a/business/jxcallback/orderman/orderman_ext.go +++ b/business/jxcallback/orderman/orderman_ext.go @@ -848,6 +848,7 @@ func (c *OrderManager) GetStoresOrderSaleInfoNew(ctx *jxcontext.Context, storeID afsOrderMap := make(map[string]*model.GoodsOrder) for _, v := range afsSkuList { universalOrderID := jxutils.ComposeUniversalOrderID(v.VendorOrderID, v.VendorID) + universalOrderSkuID := universalOrderID + "/" + utils.Int2Str(jxutils.GetSkuIDFromOrderSkuFinancial(v)) order := afsOrderMap[universalOrderID] if order == nil { order = &model.GoodsOrder{ @@ -857,13 +858,18 @@ func (c *OrderManager) GetStoresOrderSaleInfoNew(ctx *jxcontext.Context, storeID if order.StoreID == 0 { order.StoreID = v.StoreID } + if orderSku := orderSkuMap[universalOrderSkuID]; orderSku != nil { + order.ActualPayPrice = orderSku.ActualPayPrice + } afsOrderMap[universalOrderID] = order } order.SkuCount += v.Count - universalOrderSkuID := universalOrderID + "/" + utils.Int2Str(jxutils.GetSkuIDFromOrderSkuFinancial(v)) if orderSku := orderSkuMap[universalOrderSkuID]; orderSku != nil { - order.EarningPrice += orderSku.EarningPrice + order.ShopPrice += orderSku.ShopPrice * int64(v.Count) + order.VendorPrice += orderSku.VendorPrice * int64(v.Count) + order.SalePrice += orderSku.SalePrice * int64(v.Count) + order.EarningPrice += orderSku.EarningPrice * int64(v.Count) } } for universalOrderID, v := range afsOrderMap { @@ -884,7 +890,11 @@ func (c *OrderManager) GetStoresOrderSaleInfoNew(ctx *jxcontext.Context, storeID saleInfoMap[index] = saleInfo } saleInfo.ActualPayPrice += v.ActualPayPrice - saleInfo.Count += v.SkuCount + saleInfo.ShopPrice += v.ShopPrice + saleInfo.VendorPrice += v.VendorPrice + saleInfo.SalePrice += v.SalePrice + saleInfo.EarningPrice += v.EarningPrice + saleInfo.Count++ } for _, v := range saleInfoMap { saleInfoList = append(saleInfoList, v) diff --git a/business/model/dao/dao_order.go b/business/model/dao/dao_order.go index 3693aea78..1438e7c7d 100644 --- a/business/model/dao/dao_order.go +++ b/business/model/dao/dao_order.go @@ -176,7 +176,7 @@ func GetStoresOrderSaleInfo(db *DaoDB, storeIDList []int, fromTime time.Time, to sql += fmt.Sprintf(` UNION SELECT IF(t0.jx_store_id > 0, t0.jx_store_id, t0.store_id) store_id, t0.vendor_id, -1 status, - COUNT(*) count, SUM(t1.shop_price) shop_price, SUM(t1.vendor_price) vendor_price, SUM(t1.sale_price) sale_price, 0 actual_pay_price, + COUNT(DISTINCT(t0.id)) count, SUM(t1.shop_price) shop_price, SUM(t1.vendor_price) vendor_price, SUM(t1.sale_price) sale_price, 0 actual_pay_price, CAST(SUM(IF(t1.earning_price <> 0, t1.earning_price, IF(t1.shop_price <> 0 && t1.shop_price < t1.sale_price, t1.shop_price, t1.sale_price) * IF(t5.pay_percentage > 0, t5.pay_percentage, %d) / 100)) AS SIGNED) earning_price FROM afs_order t0 JOIN order_sku_financial t2 ON t2.afs_order_id = t0.afs_order_id AND t2.vendor_id = t0.vendor_id AND t2.is_afs_order = 1 @@ -195,6 +195,7 @@ func GetStoresOrderSaleInfo(db *DaoDB, storeIDList []int, fromTime time.Time, to GROUP BY 1,2,3` sql += " ORDER BY 1,2,3" + // globals.SugarLogger.Debug(sql) err = GetRows(db, &saleInfoList, sql, sqlParams...) return saleInfoList, err }