Sfoglia il codice sorgente

add reverse:for v1.6.5 小公排

tags/v1.6.5
huangjiajun 2 anni fa
parent
commit
72985d97cc
5 ha cambiato i file con 125 aggiunte e 31 eliminazioni
  1. +14
    -12
      db/model/user_public_platoon_setting.go
  2. +1
    -0
      go.mod
  3. +2
    -0
      go.sum
  4. +55
    -18
      svc/reward_commission.go
  5. +53
    -1
      svc/small_public_platoon_relate_commission.go

+ 14
- 12
db/model/user_public_platoon_setting.go Vedi File

@@ -5,16 +5,18 @@ import (
)

type UserPublicPlatoonSetting struct {
Id int `json:"id" xorm:"not null pk autoincr INT(11)"`
IsOpen int `json:"is_open" xorm:"not null default 0 comment('是否开启(0:关闭 1:开启)') TINYINT(1)"`
SeveralTimes int `json:"several_times" xorm:"not null default 0 comment('几乘') TINYINT(3)"`
SeveralRows int `json:"several_rows" xorm:"not null default 0 comment('几排') TINYINT(3)"`
OriginatorUid int `json:"originator_uid" xorm:"not null default -1 comment('创始人uid') INT(11)"`
Ext string `json:"ext" xorm:"comment('拓展字段(json存储)') TEXT"`
CreateAt time.Time `json:"create_at" xorm:"not null default 'CURRENT_TIMESTAMP' DATETIME"`
UpdateAt time.Time `json:"update_at" xorm:"not null default 'CURRENT_TIMESTAMP' DATETIME"`
SystemPunishTask string `json:"system_punish_task" xorm:"comment('处罚任务条件') TEXT"`
RewardTask string `json:"reward_task" xorm:"comment('奖励任务条件') TEXT"`
SystemPunishReplace int `json:"system_punish_replace" xorm:"default 0 comment('是否位置滑落 被新用户替换 0否 1是') INT(1)"`
SettleDay int `json:"settle_day" xorm:"not null default 30 comment('结算天数') INT(11)"`
Id int `json:"id" xorm:"not null pk autoincr INT(11)"`
IsOpen int `json:"is_open" xorm:"not null default 0 comment('是否开启(0:关闭 1:开启)') TINYINT(1)"`
SeveralTimes int `json:"several_times" xorm:"not null default 0 comment('几乘') TINYINT(3)"`
SeveralRows int `json:"several_rows" xorm:"not null default 0 comment('几排') TINYINT(3)"`
OriginatorUid int `json:"originator_uid" xorm:"not null default -1 comment('创始人uid') INT(11)"`
Ext string `json:"ext" xorm:"comment('拓展字段(json存储)') TEXT"`
CreateAt time.Time `json:"create_at" xorm:"not null default 'CURRENT_TIMESTAMP' DATETIME"`
UpdateAt time.Time `json:"update_at" xorm:"not null default 'CURRENT_TIMESTAMP' DATETIME"`
SystemPunishTask string `json:"system_punish_task" xorm:"comment('处罚任务条件') TEXT"`
RewardTask string `json:"reward_task" xorm:"comment('奖励任务条件') TEXT"`
SystemPunishReplace int `json:"system_punish_replace" xorm:"default 0 comment('是否位置滑落 被新用户替换 0否 1是') INT(1)"`
SettleDay int `json:"settle_day" xorm:"not null default 30 comment('结算天数') INT(11)"`
IsUseSmallPublicPlatoon int `json:"is_use_small_public_platoon" xorm:"not null default 0 comment('是否使用小公排(0:否 1:是)') INT(1)"`
IsAllowNaturalUserJoinSmallPublicPlatoon int `json:"is_allow_natural_user_join_small_public_platoon" xorm:"not null default 0 comment('是否允许自然用户加入小公排(0:否 1:是)') INT(1)"`
}

+ 1
- 0
go.mod Vedi File

@@ -3,6 +3,7 @@ module code.fnuoos.com/go_rely_warehouse/zyos_go_order_relate_rule.git
go 1.15

require (
github.com/jinzhu/copier v0.3.5
github.com/syyongx/php2go v0.9.6
go.uber.org/zap v1.13.0
golang.org/x/sync v0.0.0-20220601150217-0de741cfad7f


+ 2
- 0
go.sum Vedi File

@@ -188,6 +188,8 @@ github.com/jackc/puddle v0.0.0-20190608224051-11cab39313c9/go.mod h1:m4B5Dj62Y0f
github.com/jackc/puddle v1.1.0/go.mod h1:m4B5Dj62Y0fbyuIc15OsIqK0+JU8nkqQjsgx7dvjSWk=
github.com/jackc/puddle v1.1.1/go.mod h1:m4B5Dj62Y0fbyuIc15OsIqK0+JU8nkqQjsgx7dvjSWk=
github.com/jackc/puddle v1.1.3/go.mod h1:m4B5Dj62Y0fbyuIc15OsIqK0+JU8nkqQjsgx7dvjSWk=
github.com/jinzhu/copier v0.3.5 h1:GlvfUwHk62RokgqVNvYsku0TATCF7bAHVwEXoBh3iJg=
github.com/jinzhu/copier v0.3.5/go.mod h1:DfbEm0FYsaqBcKcFuvmOZb218JkPGtvSHsKg8S8hyyg=
github.com/jmespath/go-jmespath v0.0.0-20180206201540-c2b33e8439af/go.mod h1:Nht3zPeWKUH0NzdCt2Blrr5ys8VGpn0CEB0cQHVjt7k=
github.com/jonboulle/clockwork v0.1.0/go.mod h1:Ii8DK3G1RaLaWxj9trq07+26W01tbo22gdxWY5EU2bo=
github.com/json-iterator/go v1.1.6/go.mod h1:+SdeFBvtyEkXs7REEP0seUULqWtbJapLOCVDaaPEHmU=


+ 55
- 18
svc/reward_commission.go Vedi File

@@ -8,6 +8,7 @@ import (
"encoding/json"
"errors"
"fmt"
"github.com/jinzhu/copier"
"xorm.io/xorm"
)

@@ -77,26 +78,62 @@ func GetRewardCommission(engine *xorm.Engine, rmd *md.CommissionParam, isShare b
////积分扣除抽成后
integralFee, _, _ := CommFee(zhios_order_relate_utils.StrToFloat64(price), cfg, "integral")
//调用公排制度
var PublicPlatoonRelateCommissionReqList = []*md.PublicPlatoonRelateCommissionReq{
{
Pvd: newProvider,
Uid: zhios_order_relate_utils.IntToStr(uid),
UserLevel: zhios_order_relate_utils.IntToStr(level),
PendingAmount: zhios_order_relate_utils.Float64ToStr(fee),
PendingIntegral: zhios_order_relate_utils.Float64ToStr(integralFee),
Oid: rmd.Oid,
},
}
var order = make(map[string]*md.PublicPlatoonRelateCommissionResp)
if rmd.IsGoods == "1" {
order, err = BatchGetPublicPlatoonRelateCommissionByGoods(engine, masterId, PublicPlatoonRelateCommissionReqList)
} else {
order, err = BatchGetPublicPlatoonRelateCommissionByOrder(engine, masterId, PublicPlatoonRelateCommissionReqList)
}
if err != nil || order[rmd.Oid] == nil {

userPublicPlatoonSetting, err := db.UserPublicPlatoonSettingGetOneByParams(engine, map[string]interface{}{
"key": "is_open",
"value": 1,
})
if err != nil {
return 0, 0, 0, 0, nil, nil
}
reward := order[rmd.Oid]
var reward = &md.PublicPlatoonRelateCommissionResp{}
if userPublicPlatoonSetting.IsUseSmallPublicPlatoon == 1 { //小公排
var PublicPlatoonRelateCommissionReqList = []*md.SmallPublicPlatoonRelateCommissionReq{
{
Pvd: newProvider,
Uid: zhios_order_relate_utils.IntToStr(uid),
UserLevel: zhios_order_relate_utils.IntToStr(level),
PendingAmount: zhios_order_relate_utils.Float64ToStr(fee),
PendingIntegral: zhios_order_relate_utils.Float64ToStr(integralFee),
Oid: rmd.Oid,
},
}
var order = make(map[string]*md.SmallPublicPlatoonRelateCommissionResp)
if rmd.IsGoods == "1" {
order, err = BatchSmallGetPublicPlatoonRelateByGoods(engine, masterId, PublicPlatoonRelateCommissionReqList)
} else {
order, err = BatchSmallGetPublicPlatoonRelateCommission(engine, masterId, PublicPlatoonRelateCommissionReqList)
}
if err != nil || order[rmd.Oid] == nil {
return 0, 0, 0, 0, nil, nil
}
rewardSmall := order[rmd.Oid]
err = copier.Copy(reward, &rewardSmall)
if err != nil || reward == nil {
return 0, 0, 0, 0, nil, nil
}
} else {
var PublicPlatoonRelateCommissionReqList = []*md.PublicPlatoonRelateCommissionReq{
{
Pvd: newProvider,
Uid: zhios_order_relate_utils.IntToStr(uid),
UserLevel: zhios_order_relate_utils.IntToStr(level),
PendingAmount: zhios_order_relate_utils.Float64ToStr(fee),
PendingIntegral: zhios_order_relate_utils.Float64ToStr(integralFee),
Oid: rmd.Oid,
},
}
var order = make(map[string]*md.PublicPlatoonRelateCommissionResp)
if rmd.IsGoods == "1" {
order, err = BatchGetPublicPlatoonRelateCommissionByGoods(engine, masterId, PublicPlatoonRelateCommissionReqList)
} else {
order, err = BatchGetPublicPlatoonRelateCommissionByOrder(engine, masterId, PublicPlatoonRelateCommissionReqList)
}
if err != nil || order[rmd.Oid] == nil {
return 0, 0, 0, 0, nil, nil
}
reward = order[rmd.Oid]
}
profit := zhios_order_relate_utils.StrToFloat64(reward.SelfRateList["0"])
var ulink = &comm_plan.LvUser{}
if zhios_order_relate_utils.StrToInt(reward.CommonWealthBenefitUid) != zhios_order_relate_utils.StrToInt(reward.DirectPushBenefitUid) {


+ 53
- 1
svc/small_public_platoon_relate_commission.go Vedi File

@@ -54,7 +54,7 @@ func BatchSmallGetPublicPlatoonRelateCommission(engine *xorm.Engine, masterId st
for _, coinId := range lvGrade.ReturnType {
selfRateList[coinId] = zhios_order_relate_utils.Float64ToStr(zhios_order_relate_utils.StrToFloat64(lvGrade.SelfRateList[coinId]) * zhios_order_relate_utils.StrToFloat64(param.PendingAmount) / 100)
commonWealthSystem[coinId] = zhios_order_relate_utils.Float64ToStr(zhios_order_relate_utils.StrToFloat64(lvGrade.CommonWealthSystem[coinId]) * zhios_order_relate_utils.StrToFloat64(param.PendingAmount) / 100)
directPush[coinId] = zhios_order_relate_utils.Float64ToStr(zhios_order_relate_utils.StrToFloat64(lvGrade.DirectPush[coinId]) * zhios_order_relate_utils.StrToFloat64(param.PendingAmount))
directPush[coinId] = zhios_order_relate_utils.Float64ToStr(zhios_order_relate_utils.StrToFloat64(lvGrade.DirectPush[coinId]) * zhios_order_relate_utils.StrToFloat64(param.PendingAmount) / 100)
}

//TODO::本次消费产生的共富收益给到谁
@@ -124,3 +124,55 @@ func BatchSmallGetPublicPlatoonRelateCommission(engine *xorm.Engine, masterId st
}
return resp, nil
}
func BatchSmallGetPublicPlatoonRelateByGoods(engine *xorm.Engine, masterId string, PublicPlatoonRelateCommissionReqList []*md.SmallPublicPlatoonRelateCommissionReq) (map[string]*md.SmallPublicPlatoonRelateCommissionResp, error) {
var resp = make(map[string]*md.SmallPublicPlatoonRelateCommissionResp)
for _, param := range PublicPlatoonRelateCommissionReqList {
// 根据供应商
rewardOpt, err := db.DbsPlanRewardByPvd(engine, param.Pvd)
if err != nil {
return nil, err
}
if rewardOpt == nil {
return nil, zhios_order_relate_logx.Warn("找不到方案记录")
}
if rewardOpt.State == 0 {
return nil, zhios_order_relate_logx.Warn("抽成方案未开启")
}
if rewardOpt.PlanCommissionId == 0 {
return nil, zhios_order_relate_logx.Warn("抽成方案未设置佣金方案id")
}
fmt.Println("抽成设置:", zhios_order_relate_utils.SerializeStr(rewardOpt))
fmt.Println("commission id:", rewardOpt.PlanCommissionId)

//TODO::计算共富收益
commissionOpt, err := db.DbsPlanCommissionById(engine, rewardOpt.PlanCommissionId)
if err != nil || commissionOpt == nil || commissionOpt.Id == 0 {
return nil, err
}
var subsidyTmp = make(map[string]*md.LvGrade)
var tmp map[string]*md.LvGrade
if err := json.Unmarshal([]byte(commissionOpt.Data), &tmp); err != nil {
return nil, zhios_order_relate_logx.Warn(fmt.Sprintf("%s:分佣方案数据设置错误", masterId))
}
for _, v := range tmp {
subsidyTmp[zhios_order_relate_utils.IntToStr(v.Lv)] = v
}
lvGrade := subsidyTmp[param.UserLevel]
var directPush = make(map[string]string)
var selfRateList = make(map[string]string)
var commonWealthSystem = make(map[string]string)
for _, coinId := range lvGrade.ReturnType {
selfRateList[coinId] = zhios_order_relate_utils.Float64ToStr(zhios_order_relate_utils.StrToFloat64(lvGrade.SelfRateList[coinId]) * zhios_order_relate_utils.StrToFloat64(param.PendingAmount) / 100)
commonWealthSystem[coinId] = zhios_order_relate_utils.Float64ToStr(zhios_order_relate_utils.StrToFloat64(lvGrade.CommonWealthSystem[coinId]) * zhios_order_relate_utils.StrToFloat64(param.PendingAmount) / 100)
directPush[coinId] = zhios_order_relate_utils.Float64ToStr(zhios_order_relate_utils.StrToFloat64(lvGrade.DirectPush[coinId]) * zhios_order_relate_utils.StrToFloat64(param.PendingAmount) / 100)
}
resp[param.Oid] = &md.SmallPublicPlatoonRelateCommissionResp{
PendingAmount: param.PendingAmount,
Oid: param.Oid,
SelfRateList: selfRateList,
CommonWealthSystem: commonWealthSystem,
DirectPush: directPush,
}
}
return resp, nil
}

Caricamento…
Annulla
Salva