- GetStoresSkus返回商品活动价格信息
This commit is contained in:
@@ -191,19 +191,8 @@ func GetStoresSkus(ctx *jxcontext.Context, storeIDs []int, isFocus bool, keyword
|
||||
sql += " AND t1.unit = ?"
|
||||
sqlParams = append(sqlParams, params["unit"].(string))
|
||||
}
|
||||
if params["skuID"] != nil {
|
||||
skuID, ok := params["skuID"].(int)
|
||||
if ok {
|
||||
sql += " AND t2.id = ?"
|
||||
sqlParams = append(sqlParams, skuID)
|
||||
} else { // todo 这里是没有用的,应该删除掉
|
||||
skuIDs := params["skuID"].([]interface{})
|
||||
sql += " AND t2.id IN (" + dao.GenQuestionMarks(len(skuIDs)) + ")"
|
||||
sqlParams = append(sqlParams, skuIDs)
|
||||
}
|
||||
}
|
||||
var skuIDs []int
|
||||
if params["skuIDs"] != nil {
|
||||
var skuIDs []int
|
||||
if err = utils.UnmarshalUseNumber([]byte(params["skuIDs"].(string)), &skuIDs); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -211,6 +200,13 @@ func GetStoresSkus(ctx *jxcontext.Context, storeIDs []int, isFocus bool, keyword
|
||||
sql += " AND t2.id IN (" + dao.GenQuestionMarks(len(skuIDs)) + ")"
|
||||
sqlParams = append(sqlParams, skuIDs)
|
||||
}
|
||||
} else if params["skuID"] != nil {
|
||||
skuID, ok := params["skuID"].(int)
|
||||
if ok {
|
||||
skuIDs = append(skuIDs, skuID)
|
||||
sql += " AND t2.id = ?"
|
||||
sqlParams = append(sqlParams, skuID)
|
||||
}
|
||||
}
|
||||
if isFocus {
|
||||
if params["fromStatus"] != nil {
|
||||
@@ -287,7 +283,7 @@ func GetStoresSkus(ctx *jxcontext.Context, storeIDs []int, isFocus bool, keyword
|
||||
CONCAT("[", GROUP_CONCAT(DISTINCT CONCAT('{"id":', t2.id, ',"comment":"', t2.comment, '","status":', t2.status, ',"createdAt":"',
|
||||
CONCAT(REPLACE(IF(t4.created_at IS NULL, '1970-01-01 00:00:00', t4.created_at)," ","T"),"+08:00"), '","updatedAt":"', CONCAT(REPLACE(IF(t4.updated_at IS NULL, '1970-01-01 00:00:00', t4.updated_at)," ","T"),"+08:00"),
|
||||
'","lastOperator":"', IF(t4.last_operator IS NULL, '', t4.last_operator), '","specQuality":', t2.spec_quality, ',"specUnit":"', t2.spec_unit, '","weight":', t2.weight,
|
||||
',"categoryID":', t2.category_id, ',"nameID":', t2.name_id, ',"subStoreID":', IF(t4.sub_store_id IS NULL, 0, t4.sub_store_id),
|
||||
',"categoryID":', t2.category_id, ',"subStoreID":', IF(t4.sub_store_id IS NULL, 0, t4.sub_store_id),
|
||||
',"price":', IF(t4.price IS NULL, 0, t4.price), ',"unitPrice":', IF(t4.unit_price IS NULL, t1.price, t4.unit_price),
|
||||
',"storeSkuStatus":', IF(t4.status IS NULL, 0, t4.status),
|
||||
',"jdID":', t2.jd_id, ',"jdSyncStatus":', IF(t4.jd_sync_status IS NULL, 0, t4.jd_sync_status),
|
||||
@@ -319,6 +315,20 @@ func GetStoresSkus(ctx *jxcontext.Context, storeIDs []int, isFocus bool, keyword
|
||||
// globals.SugarLogger.Debug(sqlData, sqlParams)
|
||||
if err = dao.GetRows(db, &skuNamesInfo.SkuNames, sqlData, sqlParams...); err == nil {
|
||||
skuNamesInfo.TotalCount = dao.GetLastTotalRowCount(db)
|
||||
|
||||
// 活动商品信息
|
||||
jxSkuPriceMap, err2 := dao.GetPromotionSkuPriceMap(db, model.VendorIDJX, storeIDs, skuIDs, time.Now(), time.Now())
|
||||
if err = err2; err != nil {
|
||||
dao.Rollback(db)
|
||||
globals.SugarLogger.Errorf("GetStoresSkus can not get sku promotion info for error:%v", err)
|
||||
return nil, err
|
||||
}
|
||||
jdSkuPriceMap, err2 := dao.GetPromotionSkuPriceMap(db, model.VendorIDJD, storeIDs, skuIDs, time.Now(), time.Now())
|
||||
if err = err2; err != nil {
|
||||
dao.Rollback(db)
|
||||
globals.SugarLogger.Errorf("GetStoresSkus can not get sku promotion info for error:%v", err)
|
||||
return nil, err
|
||||
}
|
||||
for _, skuName := range skuNamesInfo.SkuNames {
|
||||
if skuName.SkusStr != "" {
|
||||
if err = utils.UnmarshalUseNumber([]byte(skuName.SkusStr), &skuName.Skus); err != nil {
|
||||
@@ -328,7 +338,17 @@ func GetStoresSkus(ctx *jxcontext.Context, storeIDs []int, isFocus bool, keyword
|
||||
if len(skuName.Skus) > 0 {
|
||||
skuName.UnitPrice = int(utils.MustInterface2Int64(skuName.Skus[0]["unitPrice"]))
|
||||
for _, v := range skuName.Skus {
|
||||
delete(v, "unitPrice")
|
||||
index := dao.GenSkuPriceMapKey(skuName.StoreID, int(utils.MustInterface2Int64(v["id"])))
|
||||
if jdSkuPriceMap[index] != nil {
|
||||
v["actPrice"] = jdSkuPriceMap[index].Price
|
||||
} else {
|
||||
v["actPrice"] = 0
|
||||
}
|
||||
if jxSkuPriceMap[index] != nil {
|
||||
v["earningPrice"] = jxSkuPriceMap[index].EarningPrice
|
||||
} else {
|
||||
v["earningPrice"] = 0
|
||||
}
|
||||
}
|
||||
} else {
|
||||
skuName.UnitPrice = skuName.Price
|
||||
|
||||
@@ -293,7 +293,7 @@ func CreateJdPromotion(ctx *jxcontext.Context, vendorID int, isIDJd bool, isAsyn
|
||||
return "", fmt.Errorf("商品列表为空")
|
||||
}
|
||||
if vendorID == model.VendorIDJX {
|
||||
conflictPromotion, err2 := dao.GetPromotionSkuPriceMap(db, params.StoreIDs, skuIDs, promotion.BeginAt, promotion.EndAt)
|
||||
conflictPromotion, err2 := dao.GetPromotionSkuPriceMap(db, model.VendorIDJX, params.StoreIDs, skuIDs, promotion.BeginAt, promotion.EndAt)
|
||||
if err = err2; err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user