增加领取成功时间
This commit is contained in:
parent
fbd8d0c413
commit
87e3b7a4ca
|
|
@ -7,25 +7,26 @@ import (
|
||||||
|
|
||||||
// OrderBo 领域实体Bo结构,字段和模型字段保持一致
|
// OrderBo 领域实体Bo结构,字段和模型字段保持一致
|
||||||
type OrderBo struct {
|
type OrderBo struct {
|
||||||
ID uint64
|
ID uint64
|
||||||
OrderNo string
|
OrderNo string
|
||||||
OutBizNo string
|
OutBizNo string
|
||||||
VoucherNo string
|
VoucherNo string
|
||||||
ProductNo string
|
ProductNo string
|
||||||
BatchNo string
|
BatchNo string
|
||||||
Account string
|
Account string
|
||||||
Type vo.OrderType
|
Type vo.OrderType
|
||||||
AccountType vo.OrderAccountType
|
AccountType vo.OrderAccountType
|
||||||
Status vo.OrderStatus
|
Status vo.OrderStatus
|
||||||
AppID string
|
AppID string
|
||||||
MerchantNo string
|
MerchantNo string
|
||||||
NotifyUrl string
|
NotifyUrl string
|
||||||
Channel vo.Channel
|
Channel vo.Channel
|
||||||
Attach string
|
Attach string
|
||||||
Remark string
|
Remark string
|
||||||
LastUseTime *time.Time
|
ReceiveSuccessTime *time.Time
|
||||||
CreateTime *time.Time
|
LastUseTime *time.Time
|
||||||
UpdateTime *time.Time
|
CreateTime *time.Time
|
||||||
|
UpdateTime *time.Time
|
||||||
}
|
}
|
||||||
|
|
||||||
type OrderCreateReqBo struct {
|
type OrderCreateReqBo struct {
|
||||||
|
|
|
||||||
|
|
@ -12,25 +12,26 @@ const TableNameOrder = "order"
|
||||||
|
|
||||||
// Order mapped from table <order>
|
// Order mapped from table <order>
|
||||||
type Order struct {
|
type Order struct {
|
||||||
ID uint64 `gorm:"column:id;primaryKey;autoIncrement:true" json:"id"`
|
ID uint64 `gorm:"column:id;primaryKey;autoIncrement:true" json:"id"`
|
||||||
OrderNo string `gorm:"column:order_no;not null" json:"order_no"`
|
OrderNo string `gorm:"column:order_no;not null" json:"order_no"`
|
||||||
VoucherNo string `gorm:"column:voucher_no;not null" json:"voucher_no"`
|
VoucherNo string `gorm:"column:voucher_no;not null" json:"voucher_no"`
|
||||||
OutBizNo string `gorm:"column:out_biz_no;not null;comment:外部交易号" json:"out_biz_no"` // 外部交易号
|
OutBizNo string `gorm:"column:out_biz_no;not null;comment:外部交易号" json:"out_biz_no"` // 外部交易号
|
||||||
ProductNo string `gorm:"column:product_no;not null;comment:商品编号" json:"product_no"` // 商品编号
|
ProductNo string `gorm:"column:product_no;not null;comment:商品编号" json:"product_no"` // 商品编号
|
||||||
BatchNo string `gorm:"column:batch_no;not null;comment:立减金批次号" json:"batch_no"` // 立减金批次号
|
BatchNo string `gorm:"column:batch_no;not null;comment:立减金批次号" json:"batch_no"` // 立减金批次号
|
||||||
Account string `gorm:"column:account;not null;comment:充值账号" json:"account"` // 充值账号
|
Account string `gorm:"column:account;not null;comment:充值账号" json:"account"` // 充值账号
|
||||||
AccountType uint8 `gorm:"column:account_type;not null;comment:1:oepnid/userid 2:手机号" json:"account_type"` // 1:oepnid/userid 2:手机号
|
AccountType uint8 `gorm:"column:account_type;not null;comment:1:oepnid/userid 2:手机号" json:"account_type"` // 1:oepnid/userid 2:手机号
|
||||||
Type uint8 `gorm:"column:type;not null;comment:1:招行" json:"type"`
|
Type uint8 `gorm:"column:type;not null;comment:1:招行" json:"type"`
|
||||||
Status uint8 `gorm:"column:status;not null;comment:1:待发放 2:发放中 3:发放成功 4:发放失败" json:"status"` // 1:待发放 2:发放中 3:发放成功 4:发放失败
|
Status uint8 `gorm:"column:status;not null;comment:1:待发放 2:发放中 3:发放成功 4:发放失败" json:"status"` // 1:待发放 2:发放中 3:发放成功 4:发放失败
|
||||||
AppID string `gorm:"column:app_id;not null;comment:批次所属应用" json:"app_id"` // 批次所属应用
|
AppID string `gorm:"column:app_id;not null;comment:批次所属应用" json:"app_id"` // 批次所属应用
|
||||||
MerchantNo string `gorm:"column:merchant_no;not null;comment:创建批次号的商户号" json:"merchant_no"` // 创建批次号的商户号
|
MerchantNo string `gorm:"column:merchant_no;not null;comment:创建批次号的商户号" json:"merchant_no"` // 创建批次号的商户号
|
||||||
NotifyUrl string `gorm:"column:notify_url;not null;comment:回调地址" json:"notify_url"`
|
NotifyUrl string `gorm:"column:notify_url;not null;comment:回调地址" json:"notify_url"`
|
||||||
Channel uint8 `gorm:"column:channel;not null;comment:1:微信 2:支付宝" json:"channel"` // 1:微信 2:支付宝
|
Channel uint8 `gorm:"column:channel;not null;comment:1:微信 2:支付宝" json:"channel"` // 1:微信 2:支付宝
|
||||||
Remark string `gorm:"column:remark;not null;comment:remark" json:"remark"`
|
Remark string `gorm:"column:remark;not null;comment:remark" json:"remark"`
|
||||||
Attach string `gorm:"column:attach;not null;comment:attach" json:"attach"`
|
Attach string `gorm:"column:attach;not null;comment:attach" json:"attach"`
|
||||||
LastUseTime *time.Time `gorm:"column:last_use_time" json:"last_use_time"`
|
ReceiveSuccessTime *time.Time `gorm:"column:receive_success_time" json:"receive_success_time"`
|
||||||
CreateTime *time.Time `gorm:"column:create_time" json:"create_time"`
|
LastUseTime *time.Time `gorm:"column:last_use_time" json:"last_use_time"`
|
||||||
UpdateTime *time.Time `gorm:"column:update_time" json:"update_time"`
|
CreateTime *time.Time `gorm:"column:create_time" json:"create_time"`
|
||||||
|
UpdateTime *time.Time `gorm:"column:update_time" json:"update_time"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// TableName Order's table name
|
// TableName Order's table name
|
||||||
|
|
|
||||||
|
|
@ -33,9 +33,9 @@ func (p *OrderRepoImpl) FindInBatches(ctx context.Context, w *bo.FindInBatchesUs
|
||||||
var results = make([]*model.Order, 0)
|
var results = make([]*model.Order, 0)
|
||||||
|
|
||||||
result := p.db.DB(ctx).
|
result := p.db.DB(ctx).
|
||||||
Where("last_use_time BETWEEN ? AND ?", w.StartTime, w.EndTime).
|
Where("receive_success_time BETWEEN ? AND ?", w.StartTime, w.EndTime).
|
||||||
Where("type = ?", w.Type).
|
Where("type = ?", w.Type).
|
||||||
Where("status = ?", vo.OrderStatusUse).
|
Where("status IN (?)", []uint8{vo.OrderStatusSuccess.GetValue(), vo.OrderStatusUse.GetValue()}).
|
||||||
FindInBatches(&results, 100, func(tx *gorm.DB, batch int) error {
|
FindInBatches(&results, 100, func(tx *gorm.DB, batch int) error {
|
||||||
// tx.RowsAffected 提供当前批处理中记录的计数(the count of records in the current batch)
|
// tx.RowsAffected 提供当前批处理中记录的计数(the count of records in the current batch)
|
||||||
// 'batch' 变量表示当前批号(the current batch number)
|
// 'batch' 变量表示当前批号(the current batch number)
|
||||||
|
|
@ -172,9 +172,10 @@ func (p *OrderRepoImpl) Success(ctx context.Context, id uint64, voucherNo string
|
||||||
Status: vo.OrderStatusIng.GetValue(),
|
Status: vo.OrderStatusIng.GetValue(),
|
||||||
}).
|
}).
|
||||||
Updates(model.Order{
|
Updates(model.Order{
|
||||||
Status: vo.OrderStatusSuccess.GetValue(),
|
Status: vo.OrderStatusSuccess.GetValue(),
|
||||||
VoucherNo: voucherNo,
|
VoucherNo: voucherNo,
|
||||||
UpdateTime: &now,
|
ReceiveSuccessTime: &now,
|
||||||
|
UpdateTime: &now,
|
||||||
})
|
})
|
||||||
|
|
||||||
if res.Error != nil {
|
if res.Error != nil {
|
||||||
|
|
|
||||||
|
|
@ -35,11 +35,13 @@ func (s *VoucherService) OrderNotice(ctx context.Context) error {
|
||||||
|
|
||||||
start := time.Now()
|
start := time.Now()
|
||||||
|
|
||||||
err := s.VoucherBiz.OrderNotice(ctx)
|
if err := s.VoucherBiz.OrderNotice(ctx); err != nil {
|
||||||
|
log.Error("订单定时通知,执行失败,err: %v", err)
|
||||||
|
}
|
||||||
|
|
||||||
end := time.Now()
|
end := time.Now()
|
||||||
elapsed := end.Sub(start)
|
elapsed := end.Sub(start)
|
||||||
log.Warnf("订单定时通知,开始执行时间%s,执行结束时间%s,代码块执行耗时: %s", start.Format(time.DateTime), end.Format(time.DateTime), elapsed)
|
log.Warnf("订单定时通知,开始执行时间%s,执行结束时间%s,代码块执行耗时: %s", start.Format(time.DateTime), end.Format(time.DateTime), elapsed)
|
||||||
|
|
||||||
return err
|
return nil
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue