|
@@ -15,8 +15,7 @@ import (
|
|
|
|
|
|
func ActiveCashOut(c *gin.Context) {
|
|
|
var inData models.PayCashOutRequest
|
|
|
- var merchantAccountSql shanghu.MerchantAccount
|
|
|
- var clientAccountSql shanghu.MerchantClientAccount
|
|
|
+ var clientAccountSql shanghu.ActiveClientAccount
|
|
|
var cashOut shanghu.CashOut
|
|
|
var trans []models.TransferDetailList
|
|
|
var transDetail models.TransferDetailList
|
|
@@ -67,7 +66,7 @@ func ActiveCashOut(c *gin.Context) {
|
|
|
//校验金额是否够
|
|
|
if inData.AccountType == "client" {
|
|
|
clientAccountSql.ClientOpenID = inData.OpenId
|
|
|
- clientAccountInfo, err := clientAccountSql.GetClientAccount()
|
|
|
+ clientAccountInfo, err := clientAccountSql.GetActiveAccount()
|
|
|
if err != nil {
|
|
|
app.Error(c, 400, err, err.Error())
|
|
|
return
|
|
@@ -76,27 +75,15 @@ func ActiveCashOut(c *gin.Context) {
|
|
|
app.Error(c, 400, errors.New("账号余额不够"), "账号余额不够")
|
|
|
return
|
|
|
}
|
|
|
- var client shanghu.MerchantClientUser
|
|
|
+ var client shanghu.ActiveUser
|
|
|
client.Code = "7jb6"
|
|
|
clientInfo, _ := client.GetUserInfoByCode()
|
|
|
- if clientInfo.ClientOpenID == inData.OpenId {
|
|
|
+ if clientInfo.OpenID == inData.OpenId {
|
|
|
cashOut.Fee = decimal.NewFromInt(0)
|
|
|
} else {
|
|
|
cashOut.Fee = inData.Amount.Mul(decimal.NewFromFloat32(0.05))
|
|
|
}
|
|
|
|
|
|
- } else if inData.AccountType == "merchant" {
|
|
|
- merchantAccountSql.MerchantOpenID = inData.OpenId
|
|
|
- merchantAccountInfo, err := merchantAccountSql.GetMerchantAccount()
|
|
|
- if err != nil {
|
|
|
- app.Error(c, 400, err, err.Error())
|
|
|
- return
|
|
|
- }
|
|
|
- if inData.Amount.Cmp(merchantAccountInfo.Amount) > 0 {
|
|
|
- app.Error(c, 400, errors.New("账号余额不够"), "账号余额不够")
|
|
|
- return
|
|
|
- }
|
|
|
- cashOut.Fee = decimal.NewFromInt(0)
|
|
|
} else {
|
|
|
app.Error(c, 400, errors.New("账户类型错误"), "账户类型错误")
|
|
|
return
|
|
@@ -118,7 +105,7 @@ func ActiveCashOut(c *gin.Context) {
|
|
|
transDetail.TransferAmount = inData.Amount.Sub(cashOut.Fee).Mul(decimal.NewFromInt(100)).IntPart()
|
|
|
transDetail.UserName = userName
|
|
|
transDetail.Openid = inData.OpenId
|
|
|
- transDetail.TransferRemark = "提现"
|
|
|
+ transDetail.TransferRemark = "活动提现"
|
|
|
|
|
|
trans = append(trans, transDetail)
|
|
|
|
|
@@ -144,8 +131,8 @@ func ActiveCashOut(c *gin.Context) {
|
|
|
|
|
|
bm.Set("appid", inData.Appid)
|
|
|
bm.Set("out_batch_no", partnerTradeNo)
|
|
|
- bm.Set("batch_name", "提现")
|
|
|
- bm.Set("batch_remark", "提现")
|
|
|
+ bm.Set("batch_name", "活动提现")
|
|
|
+ bm.Set("batch_remark", "活动提现")
|
|
|
bm.Set("total_amount", inData.Amount.Sub(cashOut.Fee).Mul(decimal.NewFromInt(100)).IntPart())
|
|
|
bm.Set("total_num", 1)
|
|
|
bMap = append(bMap, structToMap(&transDetail))
|