爆品预警(测试)
This commit is contained in:
@@ -169,7 +169,8 @@ type tUpdateStoresSkus struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type tStoreSkusSecKill struct {
|
type tStoreSkusSecKill struct {
|
||||||
StoreID int
|
StoreID int `orm:"column(store_id)"`
|
||||||
|
VendorID int `orm:"column(vendor_id)"`
|
||||||
SecKillCount int
|
SecKillCount int
|
||||||
SecKillCount2 int
|
SecKillCount2 int
|
||||||
}
|
}
|
||||||
@@ -3347,7 +3348,7 @@ func getCellForSpecTag(rowNum int, row []string, storeSkuMap map[int][]*partner.
|
|||||||
storeSkuMap[storeID] = append(storeSkuMap[storeID], skuMap)
|
storeSkuMap[storeID] = append(storeSkuMap[storeID], skuMap)
|
||||||
}
|
}
|
||||||
|
|
||||||
func SendSeckillSkusCountMsg(ctx *jxcontext.Context, vendorIDs []int, isAsync, isContinueWhenError bool) (hint string, err error) {
|
func SendSeckillSkusCountMsg(ctx *jxcontext.Context, vendorIDs []int, isAsync, isContinueWhenError bool) (hint interface{}, err error) {
|
||||||
// 1. 如果爆品低于8个,报警 type1
|
// 1. 如果爆品低于8个,报警 type1
|
||||||
// 2. 爆品价格低于1元商品小于5个,报警 type2
|
// 2. 爆品价格低于1元商品小于5个,报警 type2
|
||||||
var (
|
var (
|
||||||
@@ -3391,7 +3392,7 @@ func SendSeckillSkusCountMsg(ctx *jxcontext.Context, vendorIDs []int, isAsync, i
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
case model.VendorIDJD:
|
case model.VendorIDJD:
|
||||||
var storeSecKill *tStoreSkusSecKill
|
var storeSecKill = &tStoreSkusSecKill{}
|
||||||
sql := `
|
sql := `
|
||||||
SELECT t1.store_id,count(*) sec_kill_count, count(t1.price < 100 or NULL) sec_kill_count2
|
SELECT t1.store_id,count(*) sec_kill_count, count(t1.price < 100 or NULL) sec_kill_count2
|
||||||
FROM(
|
FROM(
|
||||||
@@ -3411,7 +3412,6 @@ func SendSeckillSkusCountMsg(ctx *jxcontext.Context, vendorIDs []int, isAsync, i
|
|||||||
GROUP BY 1
|
GROUP BY 1
|
||||||
`
|
`
|
||||||
sqlParams := []interface{}{
|
sqlParams := []interface{}{
|
||||||
model.ActSkuSecKill,
|
|
||||||
store.ID, vendorID,
|
store.ID, vendorID,
|
||||||
model.ActSkuSecKill, model.StoreSkuBindStatusNormal,
|
model.ActSkuSecKill, model.StoreSkuBindStatusNormal,
|
||||||
utils.DefaultTimeValue,
|
utils.DefaultTimeValue,
|
||||||
@@ -3421,15 +3421,21 @@ func SendSeckillSkusCountMsg(ctx *jxcontext.Context, vendorIDs []int, isAsync, i
|
|||||||
type2 = storeSecKill.SecKillCount2
|
type2 = storeSecKill.SecKillCount2
|
||||||
}
|
}
|
||||||
if type1 < type1Count || type2 < type2Count {
|
if type1 < type1Count || type2 < type2Count {
|
||||||
|
var storeSecKill2 = &tStoreSkusSecKill{}
|
||||||
|
storeSecKill2.StoreID = store.ID
|
||||||
|
storeSecKill2.VendorID = vendorID
|
||||||
|
storeSecKill2.SecKillCount = type1
|
||||||
|
storeSecKill2.SecKillCount2 = type2
|
||||||
|
retVal = []*tStoreSkusSecKill{storeSecKill2}
|
||||||
err = sendDDMsgBySpecSkusCount(db, type1, type2, storeDetial, vendorID)
|
err = sendDDMsgBySpecSkusCount(db, type1, type2, storeDetial, vendorID)
|
||||||
}
|
}
|
||||||
fmt.Println(type1, type2, vendorID)
|
|
||||||
}
|
}
|
||||||
return retVal, err
|
return retVal, err
|
||||||
}, storeList)
|
}, storeList)
|
||||||
tasksch.HandleTask(task, nil, true).Run()
|
tasksch.HandleTask(task, nil, true).Run()
|
||||||
if !isAsync {
|
if !isAsync {
|
||||||
_, err = task.GetResult(0)
|
result, err := task.GetResult(0)
|
||||||
|
return result, err
|
||||||
} else {
|
} else {
|
||||||
hint = task.GetID()
|
hint = task.GetID()
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -649,3 +649,22 @@ func (c *StoreSkuController) UpdateStoreSkusSpecTag() {
|
|||||||
return retVal, "", err
|
return retVal, "", err
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// @Title 手动爆品预警
|
||||||
|
// @Description 手动爆品预警
|
||||||
|
// @Param token header string true "认证token"
|
||||||
|
// @Param vendorIDs 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 /SendSeckillSkusCountMsg [post]
|
||||||
|
func (c *StoreSkuController) SendSeckillSkusCountMsg() {
|
||||||
|
var vendorIDList []int
|
||||||
|
c.callSendSeckillSkusCountMsg(func(params *tStoreSkuSendSeckillSkusCountMsgParams) (retVal interface{}, errCode string, err error) {
|
||||||
|
if jxutils.Strings2Objs(params.VendorIDs, &vendorIDList); err == nil {
|
||||||
|
retVal, err = cms.SendSeckillSkusCountMsg(params.Ctx, vendorIDList, params.IsAsync, params.IsContinueWhenError)
|
||||||
|
}
|
||||||
|
return retVal, "", err
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|||||||
@@ -1845,6 +1845,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: "SendSeckillSkusCountMsg",
|
||||||
|
Router: `/SendSeckillSkusCountMsg`,
|
||||||
|
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: "SyncJdStoreProducts",
|
Method: "SyncJdStoreProducts",
|
||||||
|
|||||||
Reference in New Issue
Block a user