增加领取成功时间

This commit is contained in:
李子铭 2025-03-17 15:03:20 +08:00
parent fbd8d0c413
commit 87e3b7a4ca
4 changed files with 50 additions and 45 deletions

View File

@ -7,25 +7,26 @@ import (
// OrderBo 领域实体Bo结构字段和模型字段保持一致
type OrderBo struct {
ID uint64
OrderNo string
OutBizNo string
VoucherNo string
ProductNo string
BatchNo string
Account string
Type vo.OrderType
AccountType vo.OrderAccountType
Status vo.OrderStatus
AppID string
MerchantNo string
NotifyUrl string
Channel vo.Channel
Attach string
Remark string
LastUseTime *time.Time
CreateTime *time.Time
UpdateTime *time.Time
ID uint64
OrderNo string
OutBizNo string
VoucherNo string
ProductNo string
BatchNo string
Account string
Type vo.OrderType
AccountType vo.OrderAccountType
Status vo.OrderStatus
AppID string
MerchantNo string
NotifyUrl string
Channel vo.Channel
Attach string
Remark string
ReceiveSuccessTime *time.Time
LastUseTime *time.Time
CreateTime *time.Time
UpdateTime *time.Time
}
type OrderCreateReqBo struct {

View File

@ -12,25 +12,26 @@ const TableNameOrder = "order"
// Order mapped from table <order>
type Order struct {
ID uint64 `gorm:"column:id;primaryKey;autoIncrement:true" json:"id"`
OrderNo string `gorm:"column:order_no;not null" json:"order_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"` // 外部交易号
ProductNo string `gorm:"column:product_no;not null;comment:商品编号" json:"product_no"` // 商品编号
BatchNo string `gorm:"column:batch_no;not null;comment:立减金批次号" json:"batch_no"` // 立减金批次号
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:手机号
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:发放失败
AppID string `gorm:"column:app_id;not null;comment:批次所属应用" json:"app_id"` // 批次所属应用
MerchantNo string `gorm:"column:merchant_no;not null;comment:创建批次号的商户号" json:"merchant_no"` // 创建批次号的商户号
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:支付宝
Remark string `gorm:"column:remark;not null;comment:remark" json:"remark"`
Attach string `gorm:"column:attach;not null;comment:attach" json:"attach"`
LastUseTime *time.Time `gorm:"column:last_use_time" json:"last_use_time"`
CreateTime *time.Time `gorm:"column:create_time" json:"create_time"`
UpdateTime *time.Time `gorm:"column:update_time" json:"update_time"`
ID uint64 `gorm:"column:id;primaryKey;autoIncrement:true" json:"id"`
OrderNo string `gorm:"column:order_no;not null" json:"order_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"` // 外部交易号
ProductNo string `gorm:"column:product_no;not null;comment:商品编号" json:"product_no"` // 商品编号
BatchNo string `gorm:"column:batch_no;not null;comment:立减金批次号" json:"batch_no"` // 立减金批次号
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:手机号
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:发放失败
AppID string `gorm:"column:app_id;not null;comment:批次所属应用" json:"app_id"` // 批次所属应用
MerchantNo string `gorm:"column:merchant_no;not null;comment:创建批次号的商户号" json:"merchant_no"` // 创建批次号的商户号
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:支付宝
Remark string `gorm:"column:remark;not null;comment:remark" json:"remark"`
Attach string `gorm:"column:attach;not null;comment:attach" json:"attach"`
ReceiveSuccessTime *time.Time `gorm:"column:receive_success_time" json:"receive_success_time"`
LastUseTime *time.Time `gorm:"column:last_use_time" json:"last_use_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

View File

@ -33,9 +33,9 @@ func (p *OrderRepoImpl) FindInBatches(ctx context.Context, w *bo.FindInBatchesUs
var results = make([]*model.Order, 0)
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("status = ?", vo.OrderStatusUse).
Where("status IN (?)", []uint8{vo.OrderStatusSuccess.GetValue(), vo.OrderStatusUse.GetValue()}).
FindInBatches(&results, 100, func(tx *gorm.DB, batch int) error {
// tx.RowsAffected 提供当前批处理中记录的计数the count of records in the current batch
// 'batch' 变量表示当前批号the current batch number
@ -172,9 +172,10 @@ func (p *OrderRepoImpl) Success(ctx context.Context, id uint64, voucherNo string
Status: vo.OrderStatusIng.GetValue(),
}).
Updates(model.Order{
Status: vo.OrderStatusSuccess.GetValue(),
VoucherNo: voucherNo,
UpdateTime: &now,
Status: vo.OrderStatusSuccess.GetValue(),
VoucherNo: voucherNo,
ReceiveSuccessTime: &now,
UpdateTime: &now,
})
if res.Error != nil {

View File

@ -35,11 +35,13 @@ func (s *VoucherService) OrderNotice(ctx context.Context) error {
start := time.Now()
err := s.VoucherBiz.OrderNotice(ctx)
if err := s.VoucherBiz.OrderNotice(ctx); err != nil {
log.Error("订单定时通知,执行失败,err: %v", err)
}
end := time.Now()
elapsed := end.Sub(start)
log.Warnf("订单定时通知,开始执行时间%s,执行结束时间%s,代码块执行耗时: %s", start.Format(time.DateTime), end.Format(time.DateTime), elapsed)
return err
return nil
}