Browse Source

Merge remote-tracking branch 'origin/master'

master
huangjiajun 5 days ago
parent
commit
0fa3cd2d46
8 changed files with 239 additions and 207 deletions
  1. +2
    -0
      app/e/code.go
  2. +32
    -5
      app/hdl/hdl_wallet.go
  3. +1
    -1
      app/md/md.wallet.go
  4. +21
    -15
      app/svc/svc_withdraw_apply.go
  5. +69
    -70
      docs/docs.go
  6. +66
    -68
      docs/swagger.json
  7. +45
    -46
      docs/swagger.yaml
  8. +3
    -2
      go.mod

+ 2
- 0
app/e/code.go View File

@@ -119,6 +119,7 @@ const (
ERR_PAY_ERR = 500013
ERR_IS_BIND_THIRDOTHER = 500014
ERR_IS_GRPC = 501000
ERR_INIT_RABBITMQ = 500016
)

var MsgFlags = map[int]string{
@@ -235,4 +236,5 @@ var MsgFlags = map[int]string{
ERR_LEVEL_REACH_TOP: "已经是最高等级",
ERR_USER_CHECK_ERR: "校验失败",
ERR_IS_GRPC: "GRPC请求失败",
ERR_INIT_RABBITMQ: "连接mq失败",
}

+ 32
- 5
app/hdl/hdl_wallet.go View File

@@ -12,9 +12,12 @@ import (
"code.fnuoos.com/EggPlanet/egg_system_rules.git/enum"
md2 "code.fnuoos.com/EggPlanet/egg_system_rules.git/md"
"code.fnuoos.com/EggPlanet/egg_system_rules.git/rule"
md3 "code.fnuoos.com/EggPlanet/egg_system_rules.git/rule/egg_energy/md"
"code.fnuoos.com/go_rely_warehouse/zyos_go_mq.git/rabbit"
"errors"
"fmt"
"github.com/gin-gonic/gin"
"github.com/jinzhu/copier"
"time"
)

@@ -158,9 +161,10 @@ func WithdrawApply(c *gin.Context) {
}
user := svc.GetUser(c)
var userId, openId string
var kind int
//sysCfgDb := implement.NewSysCfgDb(db.Db, cache.GetPool().Get())
//sysCfgMap := sysCfgDb.SysCfgFindWithDb(enum.AlipayAppId, enum.WxAppId)
if req.Kind == int(enum.FinWithdrawApplyWithdrawKindForAli) {
if req.Kind == enum.FinWithdrawApplyWithdrawKindForAli.String() {
alipayUserInfoDb := implement.NewAlipayUserInfoDb(db.Db)
aliInfo, err := alipayUserInfoDb.GetAlipayUserInfo(user.Id)
if err != nil {
@@ -174,7 +178,8 @@ func WithdrawApply(c *gin.Context) {
//appId = sysCfgMap[enum.AlipayAppId]
userId = aliInfo.UserId
openId = aliInfo.OpenId
} else if req.Kind == int(enum.FinWithdrawApplyWithdrawKindForWx) {
kind = int(enum.FinWithdrawApplyWithdrawKindForAli)
} else if req.Kind == enum.FinWithdrawApplyWithdrawKindForWx.String() {
wxUserInfoDb := implement.NewWxUserInfoDb(db.Db)
wxInfo, err := wxUserInfoDb.GetWxUserInfo(user.Id)
if err != nil {
@@ -188,6 +193,7 @@ func WithdrawApply(c *gin.Context) {
//appId = sysCfgMap[enum.WxAppId]
userId = wxInfo.UserId
openId = wxInfo.OpenId
kind = int(enum.FinWithdrawApplyWithdrawKindForWx)
} else {
e.OutErr(c, e.ERR, "未知的提现类型")
return
@@ -240,7 +246,7 @@ func WithdrawApply(c *gin.Context) {
//4、新增提现记录
now := time.Now()
finWithdrawApplyDb := implement.NewFinWithdrawApplyDb(db.Db)
insertAffected, err := finWithdrawApplyDb.FinWithdrawApplyInsertOneBySession(session, &model.FinWithdrawApply{
finWithdrawApply := &model.FinWithdrawApply{
Uid: user.Id,
AdmId: 0,
Amount: req.Amount,
@@ -257,7 +263,7 @@ func WithdrawApply(c *gin.Context) {
Reason: 0,
PaymentDate: "",
State: 0,
WithdrawKind: req.Kind,
WithdrawKind: kind,
IsFirst: func(isFirst bool) int {
if isFirst {
return 1
@@ -267,7 +273,8 @@ func WithdrawApply(c *gin.Context) {
Memo: "",
UpdateAt: now.Format("2006-01-02 15:04:05"),
CreateAt: now.Format("2006-01-02 15:04:05"),
})
}
insertAffected, err := finWithdrawApplyDb.FinWithdrawApplyInsertOneBySession(session, finWithdrawApply)
if err != nil {
session.Rollback()
e.OutErr(c, e.ERR_DB_ORM, err)
@@ -284,11 +291,31 @@ func WithdrawApply(c *gin.Context) {
e.OutErr(c, e.ERR_DB_ORM, err)
return
}
err = session.Commit()
if err != nil {
_ = session.Rollback()
e.OutErr(c, e.ERR_DB_ORM, err)
return
}

//5、推入mq
if isAuto {
ch, err1 := rabbit.Cfg.Pool.GetChannel()
if err1 != nil {
e.OutErr(c, e.ERR_INIT_RABBITMQ, err1.Error())
return
}
defer ch.Release()
var data md3.EggFinWithdrawApplyData
err = copier.Copy(&data, &finWithdrawApply)
if err != nil {
e.OutErr(c, e.ERR, err.Error())
return
}

ch.Publish(md3.EggAppExchange, utils.SerializeStr(data), md3.EggFinWithdrawApply)
}

e.OutSuc(c, "success", nil)
}



+ 1
- 1
app/md/md.wallet.go View File

@@ -28,7 +28,7 @@ type WithdrawGetAmountResp struct {

type WithdrawApplyReq struct {
Amount string `json:"amount"` // 金额
Kind int `json:"kind"` // 提现方式(1:支付宝 2:微信)
Kind string `json:"kind"` // 提现方式(alipay:支付宝 wx:微信)
}

type GetWithdrawConditionResp struct {


+ 21
- 15
app/svc/svc_withdraw_apply.go View File

@@ -28,21 +28,35 @@ func CheckWithdraw(c *gin.Context, amount string) (err error, realAmount, fee st
return
}

//2、判断是否为第一次提现
var isCompleteFirstWithdraw bool
has, err := db.Db.Where("uid = ? and ", user.Id).
And("uid =?", user.Id).
Get(model.FinWithdrawApply{})
if has { //第一次提现
isFirst = true
var firstWithdrawSet md.FirstWithdrawSet
utils.Unserialize([]byte(withdrawSetting.FrequencySet), &firstWithdrawSet)
if firstWithdrawSet.IsNeedRealName == 0 && firstWithdrawSet.FirstWithdrawAmountLimit >= amount {
isCompleteFirstWithdraw = true
}
}

//2、判断“是否实名”
if withdrawSetting.IsRealName == 1 && user.IsRealName != 1 {
if isCompleteFirstWithdraw && withdrawSetting.IsRealName == 1 && user.IsRealName != 1 {
return errors.New("非实名用户不可提现"), realAmount, fee, isAuto, isFirst
}

//3、判断“提现金额”
if utils.StrToFloat64(withdrawSetting.WithdrawAmountLimit) > 0 {
if isCompleteFirstWithdraw && utils.StrToFloat64(withdrawSetting.WithdrawAmountLimit) > 0 {
withdrawAmountLimitValue, _ := decimal.NewFromString(withdrawSetting.WithdrawAmountLimit)
if amountValue.GreaterThan(withdrawAmountLimitValue) {
if amountValue.LessThan(withdrawAmountLimitValue) {
return errors.New("非可提现金额"), realAmount, fee, isAuto, isFirst
}
}

//4、判断“提现倍数”
if utils.StrToFloat64(withdrawSetting.WithdrawMultipleLimit) > 0 {
if isCompleteFirstWithdraw && utils.StrToFloat64(withdrawSetting.WithdrawMultipleLimit) > 0 {
result := utils.StrToFloat64(amount) / utils.StrToFloat64(withdrawSetting.WithdrawMultipleLimit)
// 检查结果是否非常接近一个整数
roundedResult := math.Round(result)
@@ -52,12 +66,12 @@ func CheckWithdraw(c *gin.Context, amount string) (err error, realAmount, fee st
}

//5、验证会员等级
if withdrawSetting.VipLevelLimit > 0 && withdrawSetting.VipLevelLimit > user.Level {
if isCompleteFirstWithdraw && withdrawSetting.VipLevelLimit > 0 && withdrawSetting.VipLevelLimit > user.Level {
return errors.New("非可提现会员等级"), realAmount, fee, isAuto, isFirst
}

//6、 验证小数点
if withdrawSetting.IsSupportDecimalPoint > 0 && strings.Contains(amount, ".") {
if isCompleteFirstWithdraw && withdrawSetting.IsSupportDecimalPoint == 0 && strings.Contains(amount, ".") {
return errors.New("不支持的提现金额"), realAmount, fee, isAuto, isFirst
}

@@ -146,19 +160,11 @@ func CheckWithdraw(c *gin.Context, amount string) (err error, realAmount, fee st
//10、判断是否为自动提现
if withdrawSetting.IsAuto > 0 {
autoAmountLimit, _ := decimal.NewFromString(withdrawSetting.IsAutoAmountLimit)
if amountValue.GreaterThanOrEqual(autoAmountLimit) {
if amountValue.LessThanOrEqual(autoAmountLimit) {
isAuto = true
}
}

//11、判断是否为第一次提现
has, err := db.Db.Where("uid = ? and ", user.Id).
And("uid =?", user.Id).
Get(model.FinWithdrawApply{})
if has {
isFirst = true
}

if utils.StrToFloat64(realAmount) <= 0 {
return errors.New("当前提现金额有误"), realAmount, fee, isAuto, isFirst
}


+ 69
- 70
docs/docs.go View File

@@ -1,5 +1,4 @@
// Code generated by swaggo/swag. DO NOT EDIT.

// Package docs Code generated by swaggo/swag. DO NOT EDIT
package docs

import "github.com/swaggo/swag"
@@ -2305,9 +2304,7 @@ const docTemplate = `{
"name": "req",
"in": "body",
"required": true,
"schema": {
"type": "object"
}
"schema": {}
}
],
"responses": {
@@ -2975,6 +2972,68 @@ const docTemplate = `{
}
}
},
"code_fnuoos_com_EggPlanet_egg_models_git_src_model.ImSendRedPackageOrd": {
"type": "object",
"properties": {
"amount": {
"type": "string"
},
"create_time": {
"type": "string"
},
"id": {
"type": "integer"
},
"im_data": {
"type": "string"
},
"im_uid": {
"type": "integer"
},
"ord_no": {
"type": "string"
},
"received_im_user_ids": {
"type": "string"
},
"received_times": {
"type": "string"
},
"received_user_amount": {
"type": "string"
},
"received_user_ids": {
"type": "string"
},
"red_packet_balance_amount": {
"type": "string"
},
"red_packet_balance_nums": {
"type": "integer"
},
"red_packet_nums": {
"type": "integer"
},
"red_packet_type": {
"type": "integer"
},
"state": {
"type": "integer"
},
"uid": {
"type": "integer"
},
"update_time": {
"type": "string"
},
"wait_draw_im_user_ids": {
"type": "string"
},
"wait_draw_user_ids": {
"type": "string"
}
}
},
"comm.AccessRecordsReq": {
"type": "object",
"properties": {
@@ -4301,7 +4360,7 @@ const docTemplate = `{
"description": "红包详情信息",
"allOf": [
{
"$ref": "#/definitions/model.ImSendRedPackageOrd"
"$ref": "#/definitions/code_fnuoos_com_EggPlanet_egg_models_git_src_model.ImSendRedPackageOrd"
}
]
},
@@ -4912,8 +4971,8 @@ const docTemplate = `{
"type": "string"
},
"kind": {
"description": "提现方式(1:支付宝 2:微信)",
"type": "integer"
"description": "提现方式(alipay:支付宝 wx:微信)",
"type": "string"
}
}
},
@@ -4926,68 +4985,6 @@ const docTemplate = `{
}
}
},
"model.ImSendRedPackageOrd": {
"type": "object",
"properties": {
"amount": {
"type": "string"
},
"create_time": {
"type": "string"
},
"id": {
"type": "integer"
},
"im_data": {
"type": "string"
},
"im_uid": {
"type": "integer"
},
"ord_no": {
"type": "string"
},
"received_im_user_ids": {
"type": "string"
},
"received_times": {
"type": "string"
},
"received_user_amount": {
"type": "string"
},
"received_user_ids": {
"type": "string"
},
"red_packet_balance_amount": {
"type": "string"
},
"red_packet_balance_nums": {
"type": "integer"
},
"red_packet_nums": {
"type": "integer"
},
"red_packet_type": {
"type": "integer"
},
"state": {
"type": "integer"
},
"uid": {
"type": "integer"
},
"update_time": {
"type": "string"
},
"wait_draw_im_user_ids": {
"type": "string"
},
"wait_draw_user_ids": {
"type": "string"
}
}
},
"pb.SendRedPacketResp": {
"type": "object",
"properties": {
@@ -5010,6 +5007,8 @@ var SwaggerInfo = &swag.Spec{
Description: "APP客户端-Api接口",
InfoInstanceName: "swagger",
SwaggerTemplate: docTemplate,
LeftDelim: "{{",
RightDelim: "}}",
}

func init() {


+ 66
- 68
docs/swagger.json View File

@@ -2298,9 +2298,7 @@
"name": "req",
"in": "body",
"required": true,
"schema": {
"type": "object"
}
"schema": {}
}
],
"responses": {
@@ -2968,6 +2966,68 @@
}
}
},
"code_fnuoos_com_EggPlanet_egg_models_git_src_model.ImSendRedPackageOrd": {
"type": "object",
"properties": {
"amount": {
"type": "string"
},
"create_time": {
"type": "string"
},
"id": {
"type": "integer"
},
"im_data": {
"type": "string"
},
"im_uid": {
"type": "integer"
},
"ord_no": {
"type": "string"
},
"received_im_user_ids": {
"type": "string"
},
"received_times": {
"type": "string"
},
"received_user_amount": {
"type": "string"
},
"received_user_ids": {
"type": "string"
},
"red_packet_balance_amount": {
"type": "string"
},
"red_packet_balance_nums": {
"type": "integer"
},
"red_packet_nums": {
"type": "integer"
},
"red_packet_type": {
"type": "integer"
},
"state": {
"type": "integer"
},
"uid": {
"type": "integer"
},
"update_time": {
"type": "string"
},
"wait_draw_im_user_ids": {
"type": "string"
},
"wait_draw_user_ids": {
"type": "string"
}
}
},
"comm.AccessRecordsReq": {
"type": "object",
"properties": {
@@ -4294,7 +4354,7 @@
"description": "红包详情信息",
"allOf": [
{
"$ref": "#/definitions/model.ImSendRedPackageOrd"
"$ref": "#/definitions/code_fnuoos_com_EggPlanet_egg_models_git_src_model.ImSendRedPackageOrd"
}
]
},
@@ -4905,8 +4965,8 @@
"type": "string"
},
"kind": {
"description": "提现方式(1:支付宝 2:微信)",
"type": "integer"
"description": "提现方式(alipay:支付宝 wx:微信)",
"type": "string"
}
}
},
@@ -4919,68 +4979,6 @@
}
}
},
"model.ImSendRedPackageOrd": {
"type": "object",
"properties": {
"amount": {
"type": "string"
},
"create_time": {
"type": "string"
},
"id": {
"type": "integer"
},
"im_data": {
"type": "string"
},
"im_uid": {
"type": "integer"
},
"ord_no": {
"type": "string"
},
"received_im_user_ids": {
"type": "string"
},
"received_times": {
"type": "string"
},
"received_user_amount": {
"type": "string"
},
"received_user_ids": {
"type": "string"
},
"red_packet_balance_amount": {
"type": "string"
},
"red_packet_balance_nums": {
"type": "integer"
},
"red_packet_nums": {
"type": "integer"
},
"red_packet_type": {
"type": "integer"
},
"state": {
"type": "integer"
},
"uid": {
"type": "integer"
},
"update_time": {
"type": "string"
},
"wait_draw_im_user_ids": {
"type": "string"
},
"wait_draw_user_ids": {
"type": "string"
}
}
},
"pb.SendRedPacketResp": {
"type": "object",
"properties": {


+ 45
- 46
docs/swagger.yaml View File

@@ -12,6 +12,47 @@ definitions:
description: 总数据量
type: integer
type: object
code_fnuoos_com_EggPlanet_egg_models_git_src_model.ImSendRedPackageOrd:
properties:
amount:
type: string
create_time:
type: string
id:
type: integer
im_data:
type: string
im_uid:
type: integer
ord_no:
type: string
received_im_user_ids:
type: string
received_times:
type: string
received_user_amount:
type: string
received_user_ids:
type: string
red_packet_balance_amount:
type: string
red_packet_balance_nums:
type: integer
red_packet_nums:
type: integer
red_packet_type:
type: integer
state:
type: integer
uid:
type: integer
update_time:
type: string
wait_draw_im_user_ids:
type: string
wait_draw_user_ids:
type: string
type: object
comm.AccessRecordsReq:
properties:
index:
@@ -931,7 +972,7 @@ definitions:
properties:
detail:
allOf:
- $ref: '#/definitions/model.ImSendRedPackageOrd'
- $ref: '#/definitions/code_fnuoos_com_EggPlanet_egg_models_git_src_model.ImSendRedPackageOrd'
description: 红包详情信息
list:
description: 领取红包用户列表
@@ -1352,8 +1393,8 @@ definitions:
description: 金额
type: string
kind:
description: 提现方式(1:支付宝 2:微信)
type: integer
description: 提现方式(alipay:支付宝 wx:微信)
type: string
type: object
md.WithdrawGetAmountResp:
properties:
@@ -1361,47 +1402,6 @@ definitions:
description: 余额
type: string
type: object
model.ImSendRedPackageOrd:
properties:
amount:
type: string
create_time:
type: string
id:
type: integer
im_data:
type: string
im_uid:
type: integer
ord_no:
type: string
received_im_user_ids:
type: string
received_times:
type: string
received_user_amount:
type: string
received_user_ids:
type: string
red_packet_balance_amount:
type: string
red_packet_balance_nums:
type: integer
red_packet_nums:
type: integer
red_packet_type:
type: integer
state:
type: integer
uid:
type: integer
update_time:
type: string
wait_draw_im_user_ids:
type: string
wait_draw_user_ids:
type: string
type: object
pb.SendRedPacketResp:
properties:
seq:
@@ -2923,8 +2923,7 @@ paths:
in: body
name: req
required: true
schema:
type: object
schema: {}
produces:
- application/json
responses:


+ 3
- 2
go.mod View File

@@ -2,11 +2,12 @@ module applet

go 1.19

//replace code.fnuoos.com/EggPlanet/egg_models.git => E:/company/Egg/egg_models
replace code.fnuoos.com/EggPlanet/egg_models.git => E:/company/Egg/egg_models

//replace code.fnuoos.com/EggPlanet/egg_system_rules.git => E:/company/Egg/egg_system_rules
replace code.fnuoos.com/EggPlanet/egg_system_rules.git => E:/company/Egg/egg_system_rules

require (
github.com/jinzhu/copier v0.4.0
github.com/boombuler/barcode v1.0.1
github.com/dchest/uniuri v0.0.0-20200228104902-7aecb25e1fe5
github.com/dgrijalva/jwt-go v3.2.0+incompatible


Loading…
Cancel
Save