根据skuID关注部分商品
This commit is contained in:
@@ -2835,3 +2835,45 @@ func GetCellForFocusStoreSkus(db *dao.DaoDB, rowNum int, row []string, sheetPara
|
|||||||
}
|
}
|
||||||
skuMap[skuID] = price
|
skuMap[skuID] = price
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func FocusStoreSkusBySku(ctx *jxcontext.Context, skuIDs []int, isAsync, isContinueWhenError bool) (hint string, err error) {
|
||||||
|
var (
|
||||||
|
skuBindInfos []*StoreSkuBindInfo
|
||||||
|
skuNameMap = make(map[int][]*StoreSkuBindSkuInfo)
|
||||||
|
storeIDs []int
|
||||||
|
)
|
||||||
|
db := dao.GetDB()
|
||||||
|
skuList, err := dao.GetSkus(db, skuIDs, nil, nil, nil)
|
||||||
|
storeList, err := dao.GetStoreList(db, nil, nil, "")
|
||||||
|
for _, v := range storeList {
|
||||||
|
storeIDs = append(storeIDs, v.ID)
|
||||||
|
}
|
||||||
|
for _, v := range skuList {
|
||||||
|
skuNameMap[v.NameID] = append(skuNameMap[v.NameID], &StoreSkuBindSkuInfo{
|
||||||
|
SkuID: v.ID,
|
||||||
|
IsSale: 1,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
task := tasksch.NewParallelTask("根据skuID部分关注商品", tasksch.NewParallelConfig().SetIsContinueWhenError(isContinueWhenError), ctx,
|
||||||
|
func(task *tasksch.ParallelTask, batchItemList []interface{}, params ...interface{}) (retVal interface{}, err error) {
|
||||||
|
store := batchItemList[0].(*model.Store)
|
||||||
|
for k, v := range skuNameMap {
|
||||||
|
midPrice, _ := dao.GetMidPriceByNameID(db, store.CityCode, k, utils.Time2Date(time.Now().AddDate(0, 0, -1)))
|
||||||
|
skuBindInfo := &StoreSkuBindInfo{
|
||||||
|
NameID: k,
|
||||||
|
UnitPrice: midPrice,
|
||||||
|
IsFocus: 1,
|
||||||
|
Skus: v,
|
||||||
|
}
|
||||||
|
retVal = []*StoreSkuBindInfo{skuBindInfo}
|
||||||
|
}
|
||||||
|
return retVal, err
|
||||||
|
}, storeList)
|
||||||
|
tasksch.HandleTask(task, nil, true).Run()
|
||||||
|
result, err := task.GetResult(0)
|
||||||
|
for _, v := range result {
|
||||||
|
skuBindInfos = append(skuBindInfos, v.(*StoreSkuBindInfo))
|
||||||
|
}
|
||||||
|
hint, err = UpdateStoresSkus(ctx, storeIDs, skuBindInfos, false, isAsync, isContinueWhenError)
|
||||||
|
return hint, err
|
||||||
|
}
|
||||||
|
|||||||
@@ -1347,12 +1347,11 @@ func GetDeletedStoreSkuBind(db *DaoDB, storeID, skuID int) (storeSkuBind *model.
|
|||||||
|
|
||||||
func GetMidPriceByNameID(db *DaoDB, cityCode, skuNameID int, snapDate time.Time) (midPrice int, err error) {
|
func GetMidPriceByNameID(db *DaoDB, cityCode, skuNameID int, snapDate time.Time) (midPrice int, err error) {
|
||||||
var (
|
var (
|
||||||
storeSkuExt []*StoreSkuExt
|
sku []*model.SkuAndName
|
||||||
price int
|
skuMap = make(map[int]int)
|
||||||
skuMap = make(map[int]int)
|
|
||||||
)
|
)
|
||||||
sql := `
|
sql := `
|
||||||
SELECT a.mid_price bind_price,a.sku_id,b.spec_quality sku_spec_quality
|
SELECT a.mid_price price, a.sku_id id, b.spec_quality, c.unit, b.spec_unit
|
||||||
FROM price_refer_snapshot a
|
FROM price_refer_snapshot a
|
||||||
JOIN sku b ON a.sku_id = b.id
|
JOIN sku b ON a.sku_id = b.id
|
||||||
JOIN sku_name c ON c.id = b.name_id
|
JOIN sku_name c ON c.id = b.name_id
|
||||||
@@ -1365,13 +1364,26 @@ func GetMidPriceByNameID(db *DaoDB, cityCode, skuNameID int, snapDate time.Time)
|
|||||||
snapDate,
|
snapDate,
|
||||||
cityCode,
|
cityCode,
|
||||||
}
|
}
|
||||||
err = GetRows(db, &storeSkuExt, sql, sqlParams...)
|
err = GetRows(db, &sku, sql, sqlParams...)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return 0, err
|
return 0, err
|
||||||
}
|
}
|
||||||
if len(storeSkuExt) > 0 {
|
if len(sku) > 0 {
|
||||||
for _, v := range storeSkuExt {
|
for _, v := range sku {
|
||||||
price = model.SpecialSpecQuality / int(utils.Float64TwoInt64(float64(v.SkuSpecQuality))) * v.BindPrice
|
var (
|
||||||
|
price int
|
||||||
|
specQuality float64
|
||||||
|
)
|
||||||
|
if v.Unit == model.SpecialUnit {
|
||||||
|
if v.SpecUnit == model.SpecUnitNames[1] || v.SpecUnit == model.SpecUnitNames[2] {
|
||||||
|
specQuality = float64(v.SpecQuality) * 1000
|
||||||
|
} else {
|
||||||
|
specQuality = float64(v.SpecQuality)
|
||||||
|
}
|
||||||
|
price = int(utils.Float64TwoInt64(utils.Int2Float64(model.SpecialSpecQuality) / specQuality * utils.Int2Float64(v.Price)))
|
||||||
|
} else {
|
||||||
|
price = v.Price
|
||||||
|
}
|
||||||
if skuMap[skuNameID] < price {
|
if skuMap[skuNameID] < price {
|
||||||
skuMap[skuNameID] = price
|
skuMap[skuNameID] = price
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -243,6 +243,7 @@ type SkuAndName struct {
|
|||||||
ExPrefix string
|
ExPrefix string
|
||||||
ExPrefixBegin *time.Time
|
ExPrefixBegin *time.Time
|
||||||
ExPrefixEnd *time.Time
|
ExPrefixEnd *time.Time
|
||||||
|
Price int
|
||||||
}
|
}
|
||||||
|
|
||||||
func (*Sku) TableUnique() [][]string {
|
func (*Sku) TableUnique() [][]string {
|
||||||
|
|||||||
@@ -554,7 +554,7 @@ func (c *StoreSkuController) FocusStoreSkusByExcel() {
|
|||||||
|
|
||||||
// @Title 得到门店的分类列表
|
// @Title 得到门店的分类列表
|
||||||
// @Description 得到门店的分类列表(按商品销量)
|
// @Description 得到门店的分类列表(按商品销量)
|
||||||
// @Param token header string false "认证token"
|
// @Param token header string true "认证token"
|
||||||
// @Param storeID query int true "门店ID"
|
// @Param storeID query int true "门店ID"
|
||||||
// @Param parentID query int false "父分类id"
|
// @Param parentID query int false "父分类id"
|
||||||
// @Success 200 {object} controllers.CallResult
|
// @Success 200 {object} controllers.CallResult
|
||||||
@@ -572,7 +572,7 @@ func (c *StoreSkuController) GetStoreCategories() {
|
|||||||
|
|
||||||
// @Title 获取各平台所有门店某商品的价格
|
// @Title 获取各平台所有门店某商品的价格
|
||||||
// @Description 获取各平台所有门店某商品的价格
|
// @Description 获取各平台所有门店某商品的价格
|
||||||
// @Param token header string false "认证token"
|
// @Param token header string true "认证token"
|
||||||
// @Param skuID formData int true "商品ID"
|
// @Param skuID formData int true "商品ID"
|
||||||
// @Param vendorIDs formData string true "厂商ID列表"
|
// @Param vendorIDs formData string true "厂商ID列表"
|
||||||
// @Param isAsync formData bool true "是否异步,缺省是同步"
|
// @Param isAsync formData bool true "是否异步,缺省是同步"
|
||||||
@@ -589,3 +589,22 @@ func (c *StoreSkuController) GetVendorStoreSkuPrice() {
|
|||||||
return retVal, "", err
|
return retVal, "", err
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// @Title 根据skuID关注商品,价格为中位价,部分可售
|
||||||
|
// @Description 根据skuID关注商品,价格为中位价,部分可售
|
||||||
|
// @Param token header string true "认证token"
|
||||||
|
// @Param skuIDs formData string true "商品ID列表"
|
||||||
|
// @Param isAsync formData bool true "是否异步,缺省是同步"
|
||||||
|
// @Param isContinueWhenError formData bool true "单个同步失败是否继续,缺省false"
|
||||||
|
// @Success 200 {object} controllers.CallResult
|
||||||
|
// @Failure 200 {object} controllers.CallResult
|
||||||
|
// @router /FocusStoreSkusBySku [post]
|
||||||
|
func (c *StoreSkuController) FocusStoreSkusBySku() {
|
||||||
|
var skuIDList []int
|
||||||
|
c.callFocusStoreSkusBySku(func(params *tStoreSkuFocusStoreSkusBySkuParams) (retVal interface{}, errCode string, err error) {
|
||||||
|
if jxutils.Strings2Objs(params.SkuIDs, &skuIDList); err == nil {
|
||||||
|
retVal, err = cms.FocusStoreSkusBySku(params.Ctx, skuIDList, params.IsAsync, params.IsContinueWhenError)
|
||||||
|
}
|
||||||
|
return retVal, "", err
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|||||||
@@ -1620,6 +1620,15 @@ func init() {
|
|||||||
Filters: nil,
|
Filters: nil,
|
||||||
Params: nil})
|
Params: nil})
|
||||||
|
|
||||||
|
beego.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:StoreSkuController"] = append(beego.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:StoreSkuController"],
|
||||||
|
beego.ControllerComments{
|
||||||
|
Method: "FocusStoreSkusBySku",
|
||||||
|
Router: `/FocusStoreSkusBySku`,
|
||||||
|
AllowHTTPMethods: []string{"post"},
|
||||||
|
MethodParams: param.Make(),
|
||||||
|
Filters: nil,
|
||||||
|
Params: nil})
|
||||||
|
|
||||||
beego.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:StoreSkuController"] = append(beego.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:StoreSkuController"],
|
beego.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:StoreSkuController"] = append(beego.GlobalControllerRouter["git.rosy.net.cn/jx-callback/controllers:StoreSkuController"],
|
||||||
beego.ControllerComments{
|
beego.ControllerComments{
|
||||||
Method: "GetMissingStoreSkuFromOrder",
|
Method: "GetMissingStoreSkuFromOrder",
|
||||||
|
|||||||
Reference in New Issue
Block a user