爆品预警(测试)

This commit is contained in:
苏尹岚
2020-01-20 14:14:22 +08:00
parent 1fd5737efc
commit 4b115f32f8
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()
}