5
This commit is contained in:
parent
58149a8c08
commit
78ab9a6ba6
@ -2,12 +2,12 @@ package service
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"errors"
|
"errors"
|
||||||
|
"github.com/shopspring/decimal"
|
||||||
"hospital-admin-api/api/dao"
|
"hospital-admin-api/api/dao"
|
||||||
"hospital-admin-api/api/dto"
|
"hospital-admin-api/api/dto"
|
||||||
"hospital-admin-api/api/requests"
|
"hospital-admin-api/api/requests"
|
||||||
"hospital-admin-api/global"
|
"hospital-admin-api/global"
|
||||||
"hospital-admin-api/utils"
|
"hospital-admin-api/utils"
|
||||||
"math"
|
|
||||||
"time"
|
"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -118,11 +118,17 @@ func (r *DoctorWithdrawalService) PutDoctorWithdrawalIncome(req requests.PutDoct
|
|||||||
}()
|
}()
|
||||||
|
|
||||||
// 计算实际提现金额
|
// 计算实际提现金额
|
||||||
actualWithdrawalAmount := math.Floor((doctorWithdrawal.AppliedWithdrawalAmount-req.IncomeTax)*100) / 100
|
var appliedWithdrawalAmount = decimal.NewFromFloat(doctorWithdrawal.AppliedWithdrawalAmount)
|
||||||
|
var incomeTax = decimal.NewFromFloat(req.IncomeTax)
|
||||||
|
|
||||||
|
// (计算提现金额-个人所得税金额) * 100 取小数点后3位,
|
||||||
|
actualWithdrawalAmount := appliedWithdrawalAmount.Sub(incomeTax).Mul(decimal.NewFromFloat(100)).Floor().Div(decimal.NewFromFloat(100))
|
||||||
|
// 转为float64
|
||||||
|
result, _ := actualWithdrawalAmount.Float64()
|
||||||
|
|
||||||
// 提现申请修改数据-提现金额固定不动,修改个人所得税,实际提现金额跟随变动
|
// 提现申请修改数据-提现金额固定不动,修改个人所得税,实际提现金额跟随变动
|
||||||
doctorWithdrawalData := make(map[string]interface{})
|
doctorWithdrawalData := make(map[string]interface{})
|
||||||
doctorWithdrawalData["actual_withdrawal_amount"] = actualWithdrawalAmount // 实际提现金额
|
doctorWithdrawalData["actual_withdrawal_amount"] = result // 实际提现金额
|
||||||
doctorWithdrawalData["income_tax"] = req.IncomeTax // 提现所得税金额
|
doctorWithdrawalData["income_tax"] = req.IncomeTax // 提现所得税金额
|
||||||
err := doctorWithdrawalDao.EditDoctorWithdrawalById(tx, doctorWithdrawal.WithdrawalId, doctorWithdrawalData)
|
err := doctorWithdrawalDao.EditDoctorWithdrawalById(tx, doctorWithdrawal.WithdrawalId, doctorWithdrawalData)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -353,7 +359,7 @@ func (r *DoctorWithdrawalService) getDoctorWithdrawalOrderAmountTotal(withdrawal
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 总金额
|
// 总金额
|
||||||
var amountTotal float64
|
var amountTotal = decimal.NewFromFloat(0)
|
||||||
for _, v := range doctorWithdrawalOrders {
|
for _, v := range doctorWithdrawalOrders {
|
||||||
// 获取订单数据
|
// 获取订单数据
|
||||||
orderInquiryDao := dao.OrderInquiryDao{}
|
orderInquiryDao := dao.OrderInquiryDao{}
|
||||||
@ -374,10 +380,19 @@ func (r *DoctorWithdrawalService) getDoctorWithdrawalOrderAmountTotal(withdrawal
|
|||||||
return 0, errors.New("存在支付状态错误订单,数据错误")
|
return 0, errors.New("存在支付状态错误订单,数据错误")
|
||||||
}
|
}
|
||||||
|
|
||||||
amountTotal = amountTotal + orderInquiry.AmountTotal
|
var orderInquiryAmountTotal = decimal.NewFromFloat(orderInquiry.AmountTotal)
|
||||||
|
|
||||||
|
amountTotal = amountTotal.Sub(orderInquiryAmountTotal)
|
||||||
}
|
}
|
||||||
|
|
||||||
amountTotal = amountTotal * 0.75
|
// 分成比例
|
||||||
|
var prop = decimal.NewFromFloat(0.75)
|
||||||
|
|
||||||
return amountTotal, nil
|
// 计算分成
|
||||||
|
amountTotal = amountTotal.Mul(prop)
|
||||||
|
|
||||||
|
// 转为float64
|
||||||
|
result, _ := amountTotal.Float64()
|
||||||
|
|
||||||
|
return result, nil
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user