1
This commit is contained in:
@@ -232,8 +232,9 @@ type ActStoreSku2 struct {
|
|||||||
SpecQuality float32 `json:"-"`
|
SpecQuality float32 `json:"-"`
|
||||||
SpecUnit string `json:"-"`
|
SpecUnit string `json:"-"`
|
||||||
Comment string `json:"-"`
|
Comment string `json:"-"`
|
||||||
TrendType int `json:"trendType"` //折扣活动使用,涨跌趋势,1为涨,2为跌,0为不动
|
TrendType int `json:"trendType"` //折扣活动使用,涨跌趋势,1为涨,2为跌,0为不动
|
||||||
TrendPrice int `json:"trendPrice"` //涨跌具体多少
|
TrendPrice int `json:"trendPrice"` //涨跌具体多少
|
||||||
|
MonthlySales int `json:"monthlySales"` // 月销量
|
||||||
}
|
}
|
||||||
|
|
||||||
type StoreSkuAct struct {
|
type StoreSkuAct struct {
|
||||||
|
|||||||
@@ -153,9 +153,43 @@ func GetActStoreSkuVendorList(db *DaoDB, actID int, vendorIDs, storeIDs, skuIDs
|
|||||||
totalCount = GetLastTotalRowCount2(db, txDB)
|
totalCount = GetLastTotalRowCount2(db, txDB)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
storeAndSkuMap := make(map[int][]int, 0)
|
||||||
|
storeActMap := make(map[int][]*model.ActStoreSku2, 0)
|
||||||
|
for _, v := range actStoreSkuList {
|
||||||
|
storeAndSkuMap[v.StoreID] = append(storeAndSkuMap[v.StoreID], v.SkuID)
|
||||||
|
storeActMap[v.StoreID] = append(storeActMap[v.StoreID], v)
|
||||||
|
}
|
||||||
|
|
||||||
|
for storeID, skuIds := range storeAndSkuMap {
|
||||||
|
settleSkuCountSql := ` SELECT sum(s.count) count,s.sku_id FROM order_sku_financial s WHERE s.jx_store_id = ? AND s.created_at >= ? AND s.sku_id IN (` + GenQuestionMarks(len(skuIds)) + `) AND s.is_afs_order = 0 GROUP BY s.sku_id`
|
||||||
|
settleSkuCountParam := []interface{}{storeID, time.Now().AddDate(0, -1, 0), skuIds}
|
||||||
|
settleCount := make([]*SettleSkuCount, 0, 0)
|
||||||
|
|
||||||
|
globals.SugarLogger.Debugf("-------settleSkuCountSql := %s", settleSkuCountSql)
|
||||||
|
globals.SugarLogger.Debugf("-------settleSkuCountParam := %s", utils.Format4Output(settleSkuCountParam, false))
|
||||||
|
if err = GetRows(db, settleCount, settleSkuCountSql, settleSkuCountParam...); err != nil {
|
||||||
|
globals.SugarLogger.Debugf("统计商品月销量异常:%v", err)
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, scv := range settleCount {
|
||||||
|
for _, sam := range storeActMap[storeID] {
|
||||||
|
if scv.SkuId == sam.SkuID {
|
||||||
|
sam.MonthlySales = scv.Count
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
return totalCount, actStoreSkuList, err
|
return totalCount, actStoreSkuList, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type SettleSkuCount struct {
|
||||||
|
Count int `json:"count"` // 销量
|
||||||
|
SkuId int `json:"sku_id"` // 商品
|
||||||
|
}
|
||||||
|
|
||||||
func GetActStoreSkuVendorInfo(db *DaoDB, actID int, vendorIDs, storeIDs, skuIDs []int) (actStoreSkuMap map[int][]*model.ActStoreSku2, err error) {
|
func GetActStoreSkuVendorInfo(db *DaoDB, actID int, vendorIDs, storeIDs, skuIDs []int) (actStoreSkuMap map[int][]*model.ActStoreSku2, err error) {
|
||||||
leftOrEmpty := ""
|
leftOrEmpty := ""
|
||||||
if len(vendorIDs) == 1 && vendorIDs[0] == -1 {
|
if len(vendorIDs) == 1 && vendorIDs[0] == -1 {
|
||||||
|
|||||||
Reference in New Issue
Block a user