修复店铺名不存在的问题
All checks were successful
构建并部署到测试环境(无 SSH) / build-and-deploy (push) Successful in 7m29s
All checks were successful
构建并部署到测试环境(无 SSH) / build-and-deploy (push) Successful in 7m29s
This commit is contained in:
@@ -58,6 +58,7 @@ type RefundResponse struct {
|
|||||||
OrderID uint `json:"order_id" description:"关联订单ID"`
|
OrderID uint `json:"order_id" description:"关联订单ID"`
|
||||||
PackageUsageID *uint `json:"package_usage_id,omitempty" description:"关联套餐使用记录ID"`
|
PackageUsageID *uint `json:"package_usage_id,omitempty" description:"关联套餐使用记录ID"`
|
||||||
ShopID *uint `json:"shop_id,omitempty" description:"店铺ID"`
|
ShopID *uint `json:"shop_id,omitempty" description:"店铺ID"`
|
||||||
|
ShopName string `json:"shop_name,omitempty" description:"店铺名称"`
|
||||||
ActualReceivedAmount int64 `json:"actual_received_amount" description:"实收金额(分)"`
|
ActualReceivedAmount int64 `json:"actual_received_amount" description:"实收金额(分)"`
|
||||||
RequestedRefundAmount int64 `json:"requested_refund_amount" description:"申请退款金额(分)"`
|
RequestedRefundAmount int64 `json:"requested_refund_amount" description:"申请退款金额(分)"`
|
||||||
ApprovedRefundAmount *int64 `json:"approved_refund_amount,omitempty" description:"审批实际退款金额(分)"`
|
ApprovedRefundAmount *int64 `json:"approved_refund_amount,omitempty" description:"审批实际退款金额(分)"`
|
||||||
|
|||||||
@@ -18,6 +18,7 @@ type RefundRequest struct {
|
|||||||
OrderID uint `gorm:"column:order_id;index;not null;comment:关联订单ID" json:"order_id"`
|
OrderID uint `gorm:"column:order_id;index;not null;comment:关联订单ID" json:"order_id"`
|
||||||
PackageUsageID *uint `gorm:"column:package_usage_id;comment:关联套餐使用记录ID(可选)" json:"package_usage_id,omitempty"`
|
PackageUsageID *uint `gorm:"column:package_usage_id;comment:关联套餐使用记录ID(可选)" json:"package_usage_id,omitempty"`
|
||||||
ShopID *uint `gorm:"column:shop_id;index;comment:店铺ID(从订单获取,用于数据权限过滤)" json:"shop_id,omitempty"`
|
ShopID *uint `gorm:"column:shop_id;index;comment:店铺ID(从订单获取,用于数据权限过滤)" json:"shop_id,omitempty"`
|
||||||
|
ShopName string `gorm:"column:shop_name;->" json:"shop_name,omitempty"`
|
||||||
|
|
||||||
// 金额信息
|
// 金额信息
|
||||||
ActualReceivedAmount int64 `gorm:"column:actual_received_amount;type:bigint;not null;comment:实收金额(分)" json:"actual_received_amount"`
|
ActualReceivedAmount int64 `gorm:"column:actual_received_amount;type:bigint;not null;comment:实收金额(分)" json:"actual_received_amount"`
|
||||||
|
|||||||
@@ -132,7 +132,7 @@ func (s *Service) List(ctx context.Context, req *dto.RefundListRequest) (*dto.Re
|
|||||||
opts := &store.QueryOptions{
|
opts := &store.QueryOptions{
|
||||||
Page: req.Page,
|
Page: req.Page,
|
||||||
PageSize: req.PageSize,
|
PageSize: req.PageSize,
|
||||||
OrderBy: "created_at DESC",
|
OrderBy: "tb_refund_request.created_at DESC",
|
||||||
}
|
}
|
||||||
if opts.Page == 0 {
|
if opts.Page == 0 {
|
||||||
opts.Page = 1
|
opts.Page = 1
|
||||||
@@ -646,6 +646,7 @@ func buildRefundResponse(r *model.RefundRequest) *dto.RefundResponse {
|
|||||||
OrderID: r.OrderID,
|
OrderID: r.OrderID,
|
||||||
PackageUsageID: r.PackageUsageID,
|
PackageUsageID: r.PackageUsageID,
|
||||||
ShopID: r.ShopID,
|
ShopID: r.ShopID,
|
||||||
|
ShopName: r.ShopName,
|
||||||
ActualReceivedAmount: r.ActualReceivedAmount,
|
ActualReceivedAmount: r.ActualReceivedAmount,
|
||||||
RequestedRefundAmount: r.RequestedRefundAmount,
|
RequestedRefundAmount: r.RequestedRefundAmount,
|
||||||
ApprovedRefundAmount: r.ApprovedRefundAmount,
|
ApprovedRefundAmount: r.ApprovedRefundAmount,
|
||||||
|
|||||||
@@ -35,7 +35,11 @@ func (s *RefundStore) Create(ctx context.Context, req *model.RefundRequest) erro
|
|||||||
// GetByID 根据 ID 查询退款申请(含数据权限过滤)
|
// GetByID 根据 ID 查询退款申请(含数据权限过滤)
|
||||||
func (s *RefundStore) GetByID(ctx context.Context, id uint) (*model.RefundRequest, error) {
|
func (s *RefundStore) GetByID(ctx context.Context, id uint) (*model.RefundRequest, error) {
|
||||||
var req model.RefundRequest
|
var req model.RefundRequest
|
||||||
query := s.db.WithContext(ctx).Where("id = ?", id)
|
query := s.db.WithContext(ctx).
|
||||||
|
Model(&model.RefundRequest{}).
|
||||||
|
Select("tb_refund_request.*, tb_shop.shop_name AS shop_name").
|
||||||
|
Joins("LEFT JOIN tb_shop ON tb_shop.id = tb_refund_request.shop_id AND tb_shop.deleted_at IS NULL").
|
||||||
|
Where("tb_refund_request.id = ?", id)
|
||||||
query = middleware.ApplyShopFilter(ctx, query)
|
query = middleware.ApplyShopFilter(ctx, query)
|
||||||
if err := query.First(&req).Error; err != nil {
|
if err := query.First(&req).Error; err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
@@ -61,18 +65,21 @@ func (s *RefundStore) List(ctx context.Context, opts *store.QueryOptions, filter
|
|||||||
var requests []*model.RefundRequest
|
var requests []*model.RefundRequest
|
||||||
var total int64
|
var total int64
|
||||||
|
|
||||||
query := s.db.WithContext(ctx).Model(&model.RefundRequest{})
|
query := s.db.WithContext(ctx).
|
||||||
|
Model(&model.RefundRequest{}).
|
||||||
|
Select("tb_refund_request.*, tb_shop.shop_name AS shop_name").
|
||||||
|
Joins("LEFT JOIN tb_shop ON tb_shop.id = tb_refund_request.shop_id AND tb_shop.deleted_at IS NULL")
|
||||||
query = middleware.ApplyShopFilter(ctx, query)
|
query = middleware.ApplyShopFilter(ctx, query)
|
||||||
|
|
||||||
if filters != nil {
|
if filters != nil {
|
||||||
if filters.Status != nil {
|
if filters.Status != nil {
|
||||||
query = query.Where("status = ?", *filters.Status)
|
query = query.Where("tb_refund_request.status = ?", *filters.Status)
|
||||||
}
|
}
|
||||||
if filters.OrderID != nil {
|
if filters.OrderID != nil {
|
||||||
query = query.Where("order_id = ?", *filters.OrderID)
|
query = query.Where("tb_refund_request.order_id = ?", *filters.OrderID)
|
||||||
}
|
}
|
||||||
if filters.ShopID != nil {
|
if filters.ShopID != nil {
|
||||||
query = query.Where("shop_id = ?", *filters.ShopID)
|
query = query.Where("tb_refund_request.shop_id = ?", *filters.ShopID)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -92,7 +99,7 @@ func (s *RefundStore) List(ctx context.Context, opts *store.QueryOptions, filter
|
|||||||
if opts.OrderBy != "" {
|
if opts.OrderBy != "" {
|
||||||
query = query.Order(opts.OrderBy)
|
query = query.Order(opts.OrderBy)
|
||||||
} else {
|
} else {
|
||||||
query = query.Order("created_at DESC")
|
query = query.Order("tb_refund_request.created_at DESC")
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := query.Find(&requests).Error; err != nil {
|
if err := query.Find(&requests).Error; err != nil {
|
||||||
|
|||||||
Reference in New Issue
Block a user