七月迭代短暂完结,还有很多后端的关键东西没有弄,这是一版赶时间做的东西
All checks were successful
构建并部署到测试环境(无 SSH) / build-and-deploy (push) Successful in 8m26s
All checks were successful
构建并部署到测试环境(无 SSH) / build-and-deploy (push) Successful in 8m26s
This commit is contained in:
@@ -144,3 +144,29 @@ func (s *RefundStore) FindActiveByOrderID(ctx context.Context, orderID uint) (*m
|
||||
}
|
||||
return &req, nil
|
||||
}
|
||||
|
||||
// HasUnfinishedByAsset 检查资产是否存在仍会影响资产状态的退款申请。
|
||||
// 待审批、已退回,以及已通过但退款后资产处理尚未完成的申请均视为未终结。
|
||||
func (s *RefundStore) HasUnfinishedByAsset(ctx context.Context, assetType string, assetID uint) (bool, error) {
|
||||
var assetColumn string
|
||||
switch assetType {
|
||||
case constants.ExchangeAssetTypeIotCard:
|
||||
assetColumn = "iot_card_id"
|
||||
case constants.ExchangeAssetTypeDevice:
|
||||
assetColumn = "device_id"
|
||||
default:
|
||||
return false, gorm.ErrInvalidData
|
||||
}
|
||||
|
||||
var count int64
|
||||
err := s.db.WithContext(ctx).
|
||||
Model(&model.RefundRequest{}).
|
||||
Where(assetColumn+" = ?", assetID).
|
||||
Where("status IN ? OR (status = ? AND asset_reset = ?)",
|
||||
[]int{model.RefundStatusPending, model.RefundStatusReturned},
|
||||
model.RefundStatusApproved,
|
||||
false,
|
||||
).
|
||||
Count(&count).Error
|
||||
return count > 0, err
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user