|
@@ -70,15 +70,15 @@ func (e *EquityActive) GiftVip() {
|
|
equityStockLock.Unlock()
|
|
equityStockLock.Unlock()
|
|
}()
|
|
}()
|
|
//3. 判断库存
|
|
//3. 判断库存
|
|
- eInfo := e.findVipStock(activeId, mold)
|
|
|
|
- if eInfo == nil || len(*eInfo) == 0 {
|
|
|
|
|
|
+ count, eInfo := e.findVipStock(activeId, mold)
|
|
|
|
+ if count < 1 || eInfo == nil || len(*eInfo) == 0 {
|
|
// 没有库存
|
|
// 没有库存
|
|
go e.sendAlarmMail(activeName, activeId, mold, 0)
|
|
go e.sendAlarmMail(activeName, activeId, mold, 0)
|
|
return
|
|
return
|
|
}
|
|
}
|
|
- if len(*eInfo)-1 <= config.Config.EquityActive.MailAlarm.Threshold {
|
|
|
|
|
|
+ if int(count)-1 <= config.Config.EquityActive.MailAlarm.Threshold {
|
|
// 发库存告警时这减去1是因为这一次马上会消耗一个
|
|
// 发库存告警时这减去1是因为这一次马上会消耗一个
|
|
- go e.sendAlarmMail(activeName, activeId, mold, len(*eInfo)-1)
|
|
|
|
|
|
+ go e.sendAlarmMail(activeName, activeId, mold, int(count)-1)
|
|
}
|
|
}
|
|
eId := common.IntAll((*eInfo)[0]["id"])
|
|
eId := common.IntAll((*eInfo)[0]["id"])
|
|
//4. 更新库存
|
|
//4. 更新库存
|
|
@@ -138,8 +138,13 @@ func (e *EquityActive) matchOrder() (ok bool, mold int) {
|
|
}
|
|
}
|
|
|
|
|
|
// 查看兑换权益码信息
|
|
// 查看兑换权益码信息
|
|
-func (e *EquityActive) findVipStock(activeId, mold int) (data *[]map[string]interface{}) {
|
|
|
|
- query := fmt.Sprintf("SELECT id,name,code,date_format(ex_end_time,'%%Y-%%m-%%d') as ex_end_time FROM %s where state= 0 and mold=? and active_id=? ;", TableEquityInfo)
|
|
|
|
|
|
+func (e *EquityActive) findVipStock(activeId, mold int) (count int64, data *[]map[string]interface{}) {
|
|
|
|
+ countQuery := fmt.Sprintf("SELECT count(*) FROM %s where state= 0 and mold=? and active_id=? ;", TableEquityInfo)
|
|
|
|
+ count = util.Mysql.CountBySql(countQuery, mold, activeId)
|
|
|
|
+ if count <= 0 {
|
|
|
|
+ return
|
|
|
|
+ }
|
|
|
|
+ query := fmt.Sprintf("SELECT id,name,code,date_format(ex_end_time,'%%Y-%%m-%%d') as ex_end_time FROM %s where state= 0 and mold=? and active_id=? limit 1 ;", TableEquityInfo)
|
|
data = util.Mysql.SelectBySql(query, mold, activeId)
|
|
data = util.Mysql.SelectBySql(query, mold, activeId)
|
|
return
|
|
return
|
|
}
|
|
}
|