爆品预警(测试)

This commit is contained in:
苏尹岚
2020-01-20 14:14:22 +08:00
parent 5f1607b73e
commit e48d262f8f
3 changed files with 40 additions and 6 deletions

View File

@@ -169,7 +169,8 @@ type tUpdateStoresSkus struct {
}
type tStoreSkusSecKill struct {
StoreID int
StoreID int `orm:"column(store_id)"`
VendorID int `orm:"column(vendor_id)"`
SecKillCount int
SecKillCount2 int
}
@@ -3347,7 +3348,7 @@ func getCellForSpecTag(rowNum int, row []string, storeSkuMap map[int][]*partner.
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
// 2. 爆品价格低于1元商品小于5个报警 type2
var (
@@ -3391,7 +3392,7 @@ func SendSeckillSkusCountMsg(ctx *jxcontext.Context, vendorIDs []int, isAsync, i
}
}
case model.VendorIDJD:
var storeSecKill *tStoreSkusSecKill
var storeSecKill = &tStoreSkusSecKill{}
sql := `
SELECT t1.store_id,count(*) sec_kill_count, count(t1.price < 100 or NULL) sec_kill_count2
FROM(
@@ -3411,7 +3412,6 @@ func SendSeckillSkusCountMsg(ctx *jxcontext.Context, vendorIDs []int, isAsync, i
GROUP BY 1
`
sqlParams := []interface{}{
model.ActSkuSecKill,
store.ID, vendorID,
model.ActSkuSecKill, model.StoreSkuBindStatusNormal,
utils.DefaultTimeValue,
@@ -3421,15 +3421,21 @@ func SendSeckillSkusCountMsg(ctx *jxcontext.Context, vendorIDs []int, isAsync, i
type2 = storeSecKill.SecKillCount2
}
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)
}
fmt.Println(type1, type2, vendorID)
}
return retVal, err
}, storeList)
tasksch.HandleTask(task, nil, true).Run()
if !isAsync {
_, err = task.GetResult(0)
result, err := task.GetResult(0)
return result, err
} else {
hint = task.GetID()
}

View File

@@ -649,3 +649,22 @@ func (c *StoreSkuController) UpdateStoreSkusSpecTag() {
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
})
}

View File

@@ -1845,6 +1845,15 @@ func init() {
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.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.ControllerComments{
Method: "SyncJdStoreProducts",