推荐商品自动关注,修改,以及暂时只整4个小城市

This commit is contained in:
苏尹岚
2020-01-13 14:53:40 +08:00
parent 140d2835e8
commit 36fbaadb97
9 changed files with 62 additions and 24 deletions

View File

@@ -365,7 +365,7 @@ func DeleteConfig(ctx *jxcontext.Context, key, configType string) (err error) {
} }
} }
errList.AddErr(err) errList.AddErr(err)
storeList, err2 := dao.GetStoreList(db, nil, nil, key) storeList, err2 := dao.GetStoreList(db, nil, nil, nil, nil, key)
if err = err2; err == nil && len(storeList) > 0 { if err = err2; err == nil && len(storeList) > 0 {
storeIDs := make([]int, len(storeList)) storeIDs := make([]int, len(storeList))
for k, v := range storeList { for k, v := range storeList {

View File

@@ -1993,7 +1993,7 @@ func SendAlarmVendorSnapshot(ctx *jxcontext.Context, parentTask tasksch.ITask, p
} }
if len(userList) > 0 { if len(userList) > 0 {
allStores, err := dao.GetStoreList(db, nil, nil, "") allStores, err := dao.GetStoreList(db, nil, nil, nil, nil, "")
if err != nil { if err != nil {
return err return err
} }
@@ -2167,7 +2167,7 @@ func SaveAndSendAlarmVendorSnapshot(ctx *jxcontext.Context, vendorIDs, storeIDs
func SyncStoresCourierInfo(ctx *jxcontext.Context, storeIDs []int, isAsync, isContinueWhenError bool) (hint string, err error) { func SyncStoresCourierInfo(ctx *jxcontext.Context, storeIDs []int, isAsync, isContinueWhenError bool) (hint string, err error) {
db := dao.GetDB() db := dao.GetDB()
storeList2, err := dao.GetStoreList(db, storeIDs, nil, "") storeList2, err := dao.GetStoreList(db, storeIDs, nil, nil, nil, "")
var storeList []*model.Store var storeList []*model.Store
for _, v := range storeList2 { for _, v := range storeList2 {
if v.Status != model.StoreStatusDisabled { if v.Status != model.StoreStatusDisabled {

View File

@@ -830,10 +830,6 @@ func UpdateStoresSkusByBind(ctx *jxcontext.Context, parentTask tasksch.ITask, sk
} }
}() }()
for _, storeID := range storeIDs { for _, storeID := range storeIDs {
fmt.Println(storeID)
for _, v := range skuBindInfosMap[storeID] {
fmt.Println(*v)
}
skuIDs, err2 := updateStoresSkusWithoutSync(ctx, db, []int{storeID}, skuBindInfosMap[storeID], false) skuIDs, err2 := updateStoresSkusWithoutSync(ctx, db, []int{storeID}, skuBindInfosMap[storeID], false)
if err = err2; err != nil { if err = err2; err != nil {
dao.Rollback(db) dao.Rollback(db)
@@ -2886,7 +2882,7 @@ func FocusStoreSkusByExcelBin(ctx *jxcontext.Context, reader io.Reader, isAsync,
skuIDs = append(skuIDs, k) skuIDs = append(skuIDs, k)
} }
skuList, err := dao.GetSkus(db, skuIDs, nil, nil, nil) skuList, err := dao.GetSkus(db, skuIDs, nil, nil, nil)
storeList, err := dao.GetStoreList(db, nil, nil, "") storeList, err := dao.GetStoreList(db, nil, nil, nil, nil, "")
if err != nil && len(skuList) == 0 { if err != nil && len(skuList) == 0 {
return result, err return result, err
} }
@@ -3059,12 +3055,18 @@ func FocusStoreSkusBySku(ctx *jxcontext.Context, skuBindInfos []*StoreSkuBindInf
return hint, err return hint, err
} }
func AutoFocusStoreSkusWithoutFocusForTopSkus(ctx *jxcontext.Context, isAsync, isContinueWhenError bool) (hint string, err error) { func AutoFocusStoreSkusForTopSkus(ctx *jxcontext.Context, isAsync, isContinueWhenError bool) (hint string, err error) {
db := dao.GetDB() db := dao.GetDB()
var ( var (
result1 []interface{} result1 []interface{}
cityCodes = []int{
530100, //昆明
430300, //湘潭市
510700, //绵阳市
520100, //贵阳市
}
) )
storeList, err := dao.GetStoreList(db, nil, nil, "") storeList, err := dao.GetStoreList(db, nil, cityCodes, nil, nil, "")
taskSeqFunc := func(task *tasksch.SeqTask, step int, params ...interface{}) (result interface{}, err error) { taskSeqFunc := func(task *tasksch.SeqTask, step int, params ...interface{}) (result interface{}, err error) {
switch step { switch step {
case 0: case 0:
@@ -3096,7 +3098,7 @@ func AutoFocusStoreSkusWithoutFocusForTopSkus(ctx *jxcontext.Context, isAsync, i
for _, v := range skuName { for _, v := range skuName {
skuNameMap[v.ID] = v.ID skuNameMap[v.ID] = v.ID
} }
skuNameAndPlaceList, err2 := GetTopSkusByCityCode(ctx, v.CityCode, v.ID) skuNameAndPlaceList, err2 := GetTopSkusByCityCode(ctx, v.CityCode, 0)
if err2 != nil { if err2 != nil {
return retVal, err2 return retVal, err2
} }
@@ -3110,17 +3112,18 @@ func AutoFocusStoreSkusWithoutFocusForTopSkus(ctx *jxcontext.Context, isAsync, i
var skuBindInfoList []*StoreSkuBindInfo var skuBindInfoList []*StoreSkuBindInfo
for _, vv := range skuNameAndPlaceList { for _, vv := range skuNameAndPlaceList {
if skuNameMap[vv.ID] != 0 { if skuNameMap[vv.ID] != 0 {
priceReferList, err := dao.GetPriceReferSnapshotNoPage(db, []int{vv.CityCode}, nil, []int{vv.ID}, utils.Time2Date(time.Now().AddDate(0, 0, -1)))
if err == nil && len(priceReferList) > 0 {
storeSkuBindInfo := &StoreSkuBindInfo{ storeSkuBindInfo := &StoreSkuBindInfo{
StoreID: v.ID, StoreID: v.ID,
NameID: vv.ID, NameID: vv.ID,
UnitPrice: priceReferList[0].MidUnitPrice * payPercentage / 100, // UnitPrice: priceReferList[0].MidUnitPrice * payPercentage / 100,
IsFocus: 1, IsFocus: 1,
IsSale: 0, IsSale: 0,
} }
skuBindInfoList = append(skuBindInfoList, storeSkuBindInfo) priceReferList, err := dao.GetPriceReferSnapshotNoPage(db, []int{vv.CityCode}, nil, []int{vv.ID}, utils.Time2Date(time.Now().AddDate(0, 0, -1)))
if err == nil && len(priceReferList) > 0 {
storeSkuBindInfo.UnitPrice = priceReferList[0].MidUnitPrice * payPercentage / 100
} }
skuBindInfoList = append(skuBindInfoList, storeSkuBindInfo)
} }
} }
retVal = skuBindInfoList retVal = skuBindInfoList
@@ -3155,7 +3158,7 @@ func AutoFocusStoreSkusWithoutFocus(ctx *jxcontext.Context, skuIDs []int, isSync
nameMap = make(map[int]*StoreSkuBindInfo) nameMap = make(map[int]*StoreSkuBindInfo)
) )
db := dao.GetDB() db := dao.GetDB()
storeList, err := dao.GetStoreList(db, nil, nil, "") storeList, err := dao.GetStoreList(db, nil, nil, nil, nil, "")
for _, v := range storeList { for _, v := range storeList {
storeSkuList, _ := dao.GetStoreSkusAndSkuName(db, []int{v.ID}, skuIDs, nil) storeSkuList, _ := dao.GetStoreSkusAndSkuName(db, []int{v.ID}, skuIDs, nil)
for _, vv := range storeSkuList { for _, vv := range storeSkuList {

View File

@@ -219,7 +219,7 @@ func TryAddStoreBossRole4User(ctx *jxcontext.Context, user *model.User) (err err
if user.Type&model.UserTypeStoreBoss != 0 { if user.Type&model.UserTypeStoreBoss != 0 {
userMobile := user.GetMobile() userMobile := user.GetMobile()
if userMobile != "" { if userMobile != "" {
if storeList, err := dao.GetStoreList(dao.GetDB(), nil, []string{userMobile}, ""); err == nil && len(storeList) > 0 { if storeList, err := dao.GetStoreList(dao.GetDB(), nil, nil, nil, []string{userMobile}, ""); err == nil && len(storeList) > 0 {
roleList := make([]*authz.RoleInfo, len(storeList)) roleList := make([]*authz.RoleInfo, len(storeList))
for k, v := range storeList { for k, v := range storeList {
roleList[k] = autils.NewStoreBossRole(v.ID) roleList[k] = autils.NewStoreBossRole(v.ID)

View File

@@ -146,6 +146,9 @@ func Init() {
ScheduleTimerFunc("CreateStorePriceScore", func() { ScheduleTimerFunc("CreateStorePriceScore", func() {
cms.CreateStorePriceScore(jxcontext.AdminCtx) cms.CreateStorePriceScore(jxcontext.AdminCtx)
}, createStorePriceTimeList) }, createStorePriceTimeList)
ScheduleTimerFunc("AutoFocusStoreSkusForTopSkus", func() {
cms.AutoFocusStoreSkusForTopSkus(jxcontext.AdminCtx, true, true)
}, createStorePriceTimeList)
} }
ScheduleTimerFunc("AutoSaleStoreSku", func() { ScheduleTimerFunc("AutoSaleStoreSku", func() {
cms.AutoSaleStoreSku(jxcontext.AdminCtx, nil, false) cms.AutoSaleStoreSku(jxcontext.AdminCtx, nil, false)

View File

@@ -102,7 +102,7 @@ func BeginSavePriceRefer(ctx *jxcontext.Context, cityCodes, skuIDs []int, isAsyn
resultMap = make(map[int]map[int]*model.PriceReferSnapshot) resultMap = make(map[int]map[int]*model.PriceReferSnapshot)
resultCountryMap = make(map[int]*model.PriceReferSnapshot) resultCountryMap = make(map[int]*model.PriceReferSnapshot)
) )
storeList, err := dao.GetStoreList(db, nil, nil, "") storeList, err := dao.GetStoreList(db, nil, nil, nil, nil, "")
if err != nil { if err != nil {
return result, err return result, err
} }

View File

@@ -422,7 +422,7 @@ func GetOpenedStoreCouriersByStoreID(db *DaoDB, storeID, vendorID int) (storeMap
return storeMaps, nil return storeMaps, nil
} }
func GetStoreList(db *DaoDB, idList []int, mobileList []string, shortRoleName string) (storeList []*model.Store, err error) { func GetStoreList(db *DaoDB, idList, cityCodes, statuss []int, mobileList []string, shortRoleName string) (storeList []*model.Store, err error) {
sql := ` sql := `
SELECT t1.* SELECT t1.*
FROM store t1 FROM store t1
@@ -434,6 +434,14 @@ func GetStoreList(db *DaoDB, idList []int, mobileList []string, shortRoleName st
sql += " AND t1.id IN (" + GenQuestionMarks(len(idList)) + ")" sql += " AND t1.id IN (" + GenQuestionMarks(len(idList)) + ")"
sqlParams = append(sqlParams, idList) sqlParams = append(sqlParams, idList)
} }
if len(cityCodes) > 0 {
sql += " AND t1.city_code IN (" + GenQuestionMarks(len(cityCodes)) + ")"
sqlParams = append(sqlParams, cityCodes)
}
if len(statuss) > 0 {
sql += " AND t1.status IN (" + GenQuestionMarks(len(statuss)) + ")"
sqlParams = append(sqlParams, statuss)
}
if len(mobileList) > 0 { if len(mobileList) > 0 {
sql += " AND (t1.tel1 IN (" + GenQuestionMarks(len(mobileList)) + ") OR t1.tel2 IN (" + GenQuestionMarks(len(mobileList)) + "))" sql += " AND (t1.tel1 IN (" + GenQuestionMarks(len(mobileList)) + ") OR t1.tel2 IN (" + GenQuestionMarks(len(mobileList)) + "))"
sqlParams = append(sqlParams, mobileList, mobileList) sqlParams = append(sqlParams, mobileList, mobileList)

View File

@@ -626,3 +626,18 @@ func (c *StoreSkuController) FocusStoreSkusBySku() {
return retVal, "", err return retVal, "", err
}) })
} }
// @Title 自动关注畅销品
// @Description 自动关注畅销品
// @Param token header string true "认证token"
// @Param isAsync formData bool true "是否异步,缺省是同步"
// @Param isContinueWhenError formData bool true "单个同步失败是否继续缺省false"
// @Success 200 {object} controllers.CallResult
// @Failure 200 {object} controllers.CallResult
// @router /AutoFocusStoreSkusForTopSkus [post]
func (c *StoreSkuController) AutoFocusStoreSkusForTopSkus() {
c.callAutoFocusStoreSkusForTopSkus(func(params *tStoreSkuAutoFocusStoreSkusForTopSkusParams) (retVal interface{}, errCode string, err error) {
retVal, err = cms.AutoFocusStoreSkusForTopSkus(params.Ctx, params.IsAsync, params.IsContinueWhenError)
return retVal, "", err
})
}

View File

@@ -1665,6 +1665,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: "AutoFocusStoreSkusForTopSkus",
Router: `/AutoFocusStoreSkusForTopSkus`,
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: "CopyStoreSkus", Method: "CopyStoreSkus",