金额使用整数, 不再扣押金, 价格每个人看到自己的-1
This commit is contained in:
@@ -3,6 +3,7 @@ package dispute
|
||||
import (
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"math"
|
||||
"time"
|
||||
|
||||
"hfb_sys/backend/internal/model"
|
||||
@@ -302,10 +303,10 @@ type arbitrationSettlement struct {
|
||||
}
|
||||
|
||||
func buildArbitrationSettlement(order model.RentalOrder, req ArbitrateRequest) (arbitrationSettlement, error) {
|
||||
total := order.RentAmount + order.DepositAmount
|
||||
ownerRentAmount := order.OwnerRentAmount
|
||||
total := roundMoney(order.RentAmount + order.DepositAmount)
|
||||
ownerRentAmount := roundMoney(order.OwnerRentAmount)
|
||||
if ownerRentAmount <= 0 || ownerRentAmount > order.RentAmount {
|
||||
ownerRentAmount = order.RentAmount
|
||||
ownerRentAmount = roundMoney(order.RentAmount)
|
||||
}
|
||||
settlement := arbitrationSettlement{}
|
||||
orderID := order.ID
|
||||
@@ -359,6 +360,7 @@ func buildArbitrationSettlement(order model.RentalOrder, req ArbitrateRequest) (
|
||||
case "full_refund":
|
||||
addRenterRefund(total, "仲裁全额退款")
|
||||
case "partial_refund":
|
||||
req.Amount = roundMoney(req.Amount)
|
||||
if req.Amount <= 0 || req.Amount > total {
|
||||
return settlement, ErrInvalidDispute
|
||||
}
|
||||
@@ -368,7 +370,7 @@ func buildArbitrationSettlement(order model.RentalOrder, req ArbitrateRequest) (
|
||||
addOwnerIncome(ownerRentAmount, "仲裁确认订单金额结算给号主")
|
||||
addRenterRefund(order.DepositAmount, "仲裁释放押金给租客")
|
||||
case "deduct_deposit", "compensate_owner":
|
||||
deductAmount := req.Amount
|
||||
deductAmount := roundMoney(req.Amount)
|
||||
if deductAmount <= 0 {
|
||||
deductAmount = order.DepositAmount
|
||||
}
|
||||
@@ -390,9 +392,13 @@ func buildArbitrationSettlement(order model.RentalOrder, req ArbitrateRequest) (
|
||||
|
||||
func minMoney(a float64, b float64) float64 {
|
||||
if a < b {
|
||||
return a
|
||||
return roundMoney(a)
|
||||
}
|
||||
return b
|
||||
return roundMoney(b)
|
||||
}
|
||||
|
||||
func roundMoney(value float64) float64 {
|
||||
return math.Round(value)
|
||||
}
|
||||
|
||||
func (r *Repository) baseQuery() *gorm.DB {
|
||||
|
||||
Reference in New Issue
Block a user