cash limit

This commit is contained in:
苏尹岚
2020-10-20 14:19:18 +08:00
parent 150ec0701c
commit d20d77c8ec
5 changed files with 55 additions and 3 deletions

View File

@@ -1,6 +1,8 @@
package cms
import (
"fmt"
"git.rosy.net.cn/jx-callback/business/jxstore/financial"
"git.rosy.net.cn/jx-callback/business/jxutils"
@@ -82,6 +84,14 @@ func Cash(ctx *jxcontext.Context, orderID, payType int, vendorPayType string) (e
if userBill.AccountBalance < order.PayPrice {
return model.ErrCodeAccountBalanceNotEnough, err
}
//用户一天只能提现一次
billExpends, err := dao.GetBillExpend(db, order.UserID, model.BillTypeCash, DayTimeBegin, DayTimeEnd)
if err != nil {
return errCode, err
}
if len(billExpends) > 0 {
return errCode, fmt.Errorf("抱歉,一天只能提现一次!")
}
err = payHandler.CreateRefund()
return errCode, err
}

View File

@@ -18,6 +18,10 @@ import (
"git.rosy.net.cn/jx-callback/globals/api"
)
const (
CashPercentage = 90
)
func (p *PayHandler) CreatePay() (err error) {
switch p.PayType {
case model.PayTypeTL:
@@ -75,10 +79,15 @@ func (p *PayHandler) CreateRefund() (err error) {
param := &wxpayapi.TransfersParam{
PartnerTradeNo: utils.Int64ToStr(p.Order.OrderID),
CheckName: wxpayapi.CheckName,
Amount: p.Order.PayPrice,
Desc: "冲天猴儿app提现到账",
SpbillCreateIP: p.Ctx.GetRealRemoteIP(),
}
//1元以下免费以上收取10%手续费
if p.Order.PayPrice < 100 {
param.Amount = p.Order.PayPrice
} else {
param.Amount = p.Order.PayPrice * CashPercentage / 100 //手续费10%
}
if authInfo, err := p.Ctx.GetV2AuthInfo(); err == nil && authInfo.GetAuthType() == weixin.AuthTypeWxApp {
param.OpenID = authInfo.GetAuthID()
}

View File

@@ -47,7 +47,7 @@ func OnPayFinished(order *model.Order) (err error) {
case model.OrderTypeAccount:
//如果是账户充值(发布任务等)
//1、账户收入表明细
if err = AddBillIncome(db, billID, order.Type, order.PayPrice); err != nil {
if err = AddBillIncome(db, billID, model.BillTypeInvest, order.PayPrice); err != nil {
dao.Rollback(db)
}
//2、账户表账户余额增加相应值
@@ -88,7 +88,7 @@ func OnCashFinished(order *model.Order) (err error) {
case model.OrderTypeAccount:
//如果是账户提现
//1、账户支出明细增加一条
if err = AddBillExpend(db, billID, order.Type, order.PayPrice); err != nil {
if err = AddBillExpend(db, billID, model.BillTypeCash, order.PayPrice); err != nil {
dao.Rollback(db)
}
//2、账户表账户余额减少相应值