This commit is contained in:
parent
01ac62f2bc
commit
f4872bfe74
|
|
@ -7,10 +7,10 @@ import (
|
|||
|
||||
// UseLogBo 领域实体Bo结构,字段和模型字段保持一致
|
||||
type UseLogBo struct {
|
||||
ID uint64
|
||||
OrderNo string
|
||||
Amount int64
|
||||
Type vo.UseLogType
|
||||
UseTime *time.Time
|
||||
CreateTime *time.Time
|
||||
ID uint64
|
||||
OrderNo string
|
||||
Amount int64
|
||||
Type vo.UseLogType
|
||||
OperateTime *time.Time
|
||||
CreateTime *time.Time
|
||||
}
|
||||
|
|
|
|||
|
|
@ -35,23 +35,24 @@ func (v *VoucherBiz) WechatNotifyConsumer(ctx context.Context, tag string, req *
|
|||
}
|
||||
|
||||
if req.PlainText.ConsumeInformation.ConsumeTime != "" {
|
||||
inputFormat := time.RFC3339
|
||||
useTime, err2 := time.Parse(inputFormat, req.PlainText.ConsumeInformation.ConsumeTime)
|
||||
|
||||
useTime, err2 := time.Parse(time.RFC3339, req.PlainText.ConsumeInformation.ConsumeTime)
|
||||
if err2 != nil {
|
||||
return err2
|
||||
}
|
||||
|
||||
useLog, err2 := v.UseLogRepo.GetByUseTimeOrder(ctx, order.OrderNo, &useTime)
|
||||
|
||||
if err2 != nil && !errors.Is(err2, gorm.ErrRecordNotFound) {
|
||||
return err2
|
||||
}
|
||||
|
||||
if useLog == nil {
|
||||
_, err = v.UseLogRepo.Create(ctx, &bo.UseLogBo{
|
||||
OrderNo: order.OrderNo,
|
||||
Amount: req.PlainText.ConsumeInformation.ConsumeAmount,
|
||||
Type: vo.UseLogTypeUsed,
|
||||
UseTime: &useTime,
|
||||
OrderNo: order.OrderNo,
|
||||
Amount: req.PlainText.ConsumeInformation.ConsumeAmount,
|
||||
Type: vo.UseLogTypeUsed,
|
||||
OperateTime: &useTime,
|
||||
})
|
||||
if err != nil {
|
||||
return err
|
||||
|
|
|
|||
|
|
@ -12,12 +12,12 @@ const TableNameUseLog = "use_log"
|
|||
|
||||
// UseLog mapped from table <user_log>
|
||||
type UseLog struct {
|
||||
ID uint64 `gorm:"column:id;primaryKey;autoIncrement:true" json:"id"`
|
||||
OrderNo string `gorm:"column:order_no;not null" json:"order_no"`
|
||||
Amount int64 `gorm:"column:amount;not null;comment:核销金额" json:"amount"`
|
||||
Type uint8 `gorm:"column:type;not null;comment:1:核销 2:退款" json:"type"`
|
||||
UseTime *time.Time `gorm:"column:use_time;not null" json:"use_time"`
|
||||
CreateTime *time.Time `gorm:"column:create_time;not null" json:"create_time"`
|
||||
ID uint64 `gorm:"column:id;primaryKey;autoIncrement:true" json:"id"`
|
||||
OrderNo string `gorm:"column:order_no;not null" json:"order_no"`
|
||||
Amount int64 `gorm:"column:amount;not null;comment:核销金额" json:"amount"`
|
||||
Type uint8 `gorm:"column:type;not null;comment:1:核销 2:退款" json:"type"`
|
||||
OperateTime *time.Time `gorm:"column:operate_time;not null" json:"operate_time"`
|
||||
CreateTime *time.Time `gorm:"column:create_time;not null" json:"create_time"`
|
||||
}
|
||||
|
||||
// TableName UseLog's table name
|
||||
|
|
|
|||
|
|
@ -29,11 +29,11 @@ func (this *UseLogRepoImpl) Create(ctx context.Context, req *bo.UseLogBo) (*bo.U
|
|||
now := time.Now()
|
||||
|
||||
info := &model.UseLog{
|
||||
OrderNo: req.OrderNo,
|
||||
Type: req.Type.GetValue(),
|
||||
Amount: req.Amount,
|
||||
UseTime: req.UseTime,
|
||||
CreateTime: &now,
|
||||
OrderNo: req.OrderNo,
|
||||
Type: req.Type.GetValue(),
|
||||
Amount: req.Amount,
|
||||
OperateTime: req.OperateTime,
|
||||
CreateTime: &now,
|
||||
}
|
||||
|
||||
if err := this.DB(ctx).Create(info).Error; err != nil {
|
||||
|
|
@ -62,7 +62,7 @@ func (this *UseLogRepoImpl) GetByID(ctx context.Context, id uint64) (*bo.UseLogB
|
|||
func (this *UseLogRepoImpl) GetByUseTimeOrder(ctx context.Context, orderNo string, useTime *time.Time) (*bo.UseLogBo, error) {
|
||||
var item model.UseLog
|
||||
|
||||
tx := this.DB(ctx).Where(model.UseLog{OrderNo: orderNo, UseTime: useTime}).First(&item)
|
||||
tx := this.DB(ctx).Where(model.UseLog{OrderNo: orderNo, OperateTime: useTime}).First(&item)
|
||||
|
||||
if tx.Error != nil {
|
||||
return nil, tx.Error
|
||||
|
|
|
|||
Loading…
Reference in New Issue