query
This commit is contained in:
parent
5ce7dfbb88
commit
5ff8c8a0e6
|
|
@ -18,11 +18,6 @@ func (v *VoucherBiz) Notice(ctx context.Context) error {
|
|||
return err
|
||||
}
|
||||
|
||||
return v.ExecuteNotice(ctx)
|
||||
}
|
||||
|
||||
func (v *VoucherBiz) ExecuteNotice(ctx context.Context) error {
|
||||
|
||||
now := time.Now()
|
||||
|
||||
// 获取七天前的日期
|
||||
|
|
@ -40,6 +35,11 @@ func (v *VoucherBiz) ExecuteNotice(ctx context.Context) error {
|
|||
EndTime: &endTime,
|
||||
}
|
||||
|
||||
return v.ExecuteNotice(ctx, req)
|
||||
}
|
||||
|
||||
func (v *VoucherBiz) ExecuteNotice(ctx context.Context, req *bo.FindInBatchesUseBo) error {
|
||||
|
||||
return v.OrderRepo.FindInBatches(ctx, req, func(ctx context.Context, rows []*bo.OrderBo) error {
|
||||
|
||||
for _, order := range rows {
|
||||
|
|
@ -50,8 +50,6 @@ func (v *VoucherBiz) ExecuteNotice(ctx context.Context) error {
|
|||
|
||||
}
|
||||
|
||||
time.Sleep(1 * time.Second)
|
||||
|
||||
return nil
|
||||
})
|
||||
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@ import (
|
|||
func (v *VoucherBiz) PushWechatQuery(ctx http.Context, req *do.WechatQuery) error {
|
||||
|
||||
if v.Get("CMB_WECHAT_QUERY") {
|
||||
return fmt.Errorf("此台服务队列正在处理中,ip:", ctx.Header().Get("X-Forwarded-For"))
|
||||
return fmt.Errorf("此台服务队列正在处理中,ip:%s", ctx.Header().Get("X-Forwarded-For"))
|
||||
}
|
||||
|
||||
if req.ProductNo != "" {
|
||||
|
|
@ -56,12 +56,16 @@ func (v *VoucherBiz) WechatQuery(ctx context.Context, msg string) error {
|
|||
}
|
||||
|
||||
start := time.Now()
|
||||
log.Warnf("微信券查询处理开始:%s,msg:%s", start.String(), msg)
|
||||
fmt.Printf("微信券查询处理开始:%s,msg:%s", start.String(), msg)
|
||||
startStr := time.Now().String()
|
||||
|
||||
log.Warnf("微信券查询处理开始:%s,msg:%s", startStr, msg)
|
||||
fmt.Printf("微信券查询处理开始:%s,msg:%s", startStr, msg)
|
||||
|
||||
n := 0
|
||||
num := 0
|
||||
err := v.OrderRepo.FinSucByStockIdInBatches(ctx, req, func(ctx context.Context, rows []*bo.OrderBo) error {
|
||||
|
||||
n += 1
|
||||
for _, order := range rows {
|
||||
|
||||
num += 1
|
||||
|
|
@ -72,13 +76,13 @@ func (v *VoucherBiz) WechatQuery(ctx context.Context, msg string) error {
|
|||
|
||||
}
|
||||
|
||||
time.Sleep(1 * time.Second)
|
||||
log.Warnf("微信券查询处理第 %d 批次,执行开始时间:%s,当前执行耗时:%s", n, startStr, time.Now().Sub(start).String())
|
||||
|
||||
return nil
|
||||
})
|
||||
|
||||
log.Warnf("微信券查询处理耗时:%s,msg:%s,处理%d单", time.Now().Sub(start).String(), msg, num)
|
||||
fmt.Printf("微信券查询处理耗时:%s,msg:%s,处理%d单", time.Now().Sub(start).String(), msg, num)
|
||||
log.Warnf("微信券查询处理耗时:%s,处理%d单,msg:%s", time.Now().Sub(start).String(), num, msg)
|
||||
fmt.Printf("微信券查询处理耗时:%s,处理%d单,msg:%s", time.Now().Sub(start).String(), num, msg)
|
||||
|
||||
return err
|
||||
}
|
||||
|
|
|
|||
|
|
@ -101,7 +101,6 @@ func (p *OrderRepoImpl) FindInBatches(ctx context.Context, w *bo.FindInBatchesUs
|
|||
var results = make([]*model.Order, 0)
|
||||
|
||||
result := p.DB(ctx).
|
||||
Where("type = ?", w.Type).
|
||||
Where("status IN (?)", []uint8{vo.OrderStatusSuccess.GetValue(), vo.OrderStatusUse.GetValue()}).
|
||||
Where("receive_success_time BETWEEN ? AND ?", w.StartTime, w.EndTime).
|
||||
FindInBatches(&results, 100, func(tx *gorm.DB, batch int) error {
|
||||
|
|
|
|||
|
|
@ -15,11 +15,11 @@ func TestNoticeTime(t *testing.T) {
|
|||
now := time.Now()
|
||||
|
||||
// 获取七天前的日期
|
||||
noticeStartDay := now.AddDate(0, 0, -29)
|
||||
noticeStartDay := now.AddDate(0, 0, -15)
|
||||
// 获取七天前 00:00:00 的时间
|
||||
startTime := time.Date(noticeStartDay.Year(), noticeStartDay.Month(), noticeStartDay.Day(), 0, 0, 0, 0, noticeStartDay.Location())
|
||||
|
||||
noticeEndDay := now.AddDate(0, 0, -28)
|
||||
noticeEndDay := now.AddDate(0, 0, -1)
|
||||
// 获取昨天 23:59:59 的时间
|
||||
endTime := time.Date(noticeEndDay.Year(), noticeEndDay.Month(), noticeEndDay.Day(), 23, 59, 59, 0, noticeEndDay.Location())
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue