Browse Source

update

master
DengBiao 1 year ago
parent
commit
581123146c
4 changed files with 119 additions and 0 deletions
  1. +13
    -0
      db/model/user_public_platoon_laxin_reward_setting.go
  2. +11
    -0
      md/small_public_platoon_relate_commission.go
  3. +9
    -0
      rule/small_public_platoon_relate_commission.go
  4. +86
    -0
      svc/small_public_platoon_relate_commission.go

+ 13
- 0
db/model/user_public_platoon_laxin_reward_setting.go View File

@@ -0,0 +1,13 @@
package model

import "time"

type UserPublicPlatoonLaxinRewardSetting struct {
Id int64 `json:"id" xorm:"pk autoincr BIGINT(20)"`
IsUse int `json:"is_use" xorm:"default 0 comment('是否在使用,1:是,0,否') TINYINT(1)"`
IsUseRewardLimit int `json:"is_use_reward_limit" xorm:"default 0 comment('是否开启奖励限制(奖励积分只能获取等级与自己一样或等级低的人的奖励积分) ') TINYINT(1)"`
CoinId int `json:"coin_id" xorm:"INT(11)"`
Detail string `json:"detail" xorm:"TEXT"`
CreateAt time.Time `json:"create_at" xorm:"not null default 'CURRENT_TIMESTAMP' comment('创建时间') TIMESTAMP"`
UpdateAt time.Time `json:"update_at" xorm:"default 'CURRENT_TIMESTAMP' comment('更新时间') TIMESTAMP"`
}

+ 11
- 0
md/small_public_platoon_relate_commission.go View File

@@ -31,6 +31,17 @@ type SmallPublicPlatoonRelateCommissionResp struct {
PendingIntegral string `json:"pending_integral"` //待处理金额
}

type CalcSmallPublicPlatoonRelateLaXinReward struct {
Uid string `json:"uid"`
CoinId int `json:"coin_id"`
Value string `json:"value"`
}

type CalcSmallPublicPlatoonRelateLaXinDetail struct {
Key int `json:"key"`
Val interface{} `json:"val"`
}

type SmallAddPublicPlatoonRelateCommissionReq struct {
Uid string `json:"uid"`
RecommendUid string `json:"recommend_uid"` //推荐人uid


+ 9
- 0
rule/small_public_platoon_relate_commission.go View File

@@ -25,6 +25,15 @@ func BatchGetSmallPublicPlatoonRelateCommissionByOrder(engine *xorm.Engine, mast
return resp, nil
}

// CalcSmallPublicPlatoonRelateLaXinReward 计算拉新奖励
func CalcSmallPublicPlatoonRelateLaXinReward(engine *xorm.Engine, masterId string, rewardUid int) ([]*md.CalcSmallPublicPlatoonRelateLaXinReward, error) {
resp, err := svc.CalcSmallPublicPlatoonRelateLaXinReward(engine, masterId, rewardUid)
if err != nil {
return nil, err
}
return resp, nil
}

// AddSmallPublicPlatoonRelateCommission 新增小公排用户关系记录
func AddSmallPublicPlatoonRelateCommission(engine *xorm.Engine, AddSmallPublicPlatoonRelateCommissionReqList []*md.SmallAddPublicPlatoonRelateCommissionReq) (map[string]*model.UserSmallPublicPlatoonRelation, error) {
var resp = map[string]*model.UserSmallPublicPlatoonRelation{}


+ 86
- 0
svc/small_public_platoon_relate_commission.go View File

@@ -2,6 +2,7 @@ package svc

import (
"code.fnuoos.com/go_rely_warehouse/zyos_go_order_relate_rule.git/db"
"code.fnuoos.com/go_rely_warehouse/zyos_go_order_relate_rule.git/db/model"
"code.fnuoos.com/go_rely_warehouse/zyos_go_order_relate_rule.git/md"
zhios_order_relate_utils "code.fnuoos.com/go_rely_warehouse/zyos_go_order_relate_rule.git/utils"
zhios_order_relate_logx "code.fnuoos.com/go_rely_warehouse/zyos_go_order_relate_rule.git/utils/logx"
@@ -145,6 +146,91 @@ func BatchSmallGetPublicPlatoonRelateCommission(engine *xorm.Engine, masterId st
return resp, nil
}

func CalcSmallPublicPlatoonRelateLaXinReward(engine *xorm.Engine, masterId string, rewardUid int) (resp []*md.CalcSmallPublicPlatoonRelateLaXinReward, err error) {
userPublicPlatoonRelation, err := db.UserSmallPublicPlatoonRelationGetOneByParams(engine, map[string]interface{}{
"key": "uid",
"value": rewardUid,
})
if err != nil {
return nil, err
}
if userPublicPlatoonRelation == nil {
return nil, errors.New("未查询到公排关系记录")
}
if userPublicPlatoonRelation.FatherUid == "" {
//TODO::原始创始人
return
} else {
//1、查询 user_public_platoon_laxin_reward_setting
var m model.UserPublicPlatoonLaxinRewardSetting
has, err1 := engine.Where("id >= 1").Get(&m)
if err1 != nil {
return nil, zhios_order_relate_logx.Error(err1)
}
if has == false {
return
}
if m.IsUse == 0 {
return
}

//2、解析 detail
var detail []*md.CalcSmallPublicPlatoonRelateLaXinDetail
if err2 := json.Unmarshal([]byte(m.Detail), &detail); err != nil {
return nil, err2
}

fatherPositions := strings.Split(userPublicPlatoonRelation.FatherUid, "-")
var rewardUserLevelWeight int
if m.IsUseRewardLimit == 1 {
//3、判断是否开启奖励限制
rewardUser, err3 := db.UserFindByID(engine, rewardUid)
if err3 != nil {
return nil, err3
}

rewardUserLevel, err4 := db.UserLevelByID(engine, rewardUser.Level)
if err4 != nil {
return nil, err4
}
if rewardUserLevel == nil {
return nil, errors.New("未查询到对应等级")
}
rewardUserLevelWeight = rewardUserLevel.LevelWeight
}

for k, v := range fatherPositions {
if m.IsUseRewardLimit == 1 {
//查询对应用户的等级
tmpUser, err3 := db.UserFindByID(engine, v)
if err3 != nil {
return nil, err3
}

tmpUserLevel, err4 := db.UserLevelByID(engine, tmpUser.Level)
if err4 != nil {
return nil, err4
}
if tmpUserLevel == nil {
return nil, errors.New("未查询到奖励用户对应等级")
}
if tmpUserLevel.LevelWeight < rewardUserLevelWeight {
//奖励人等级小于
continue
}
}
value, _ := zhios_order_relate_utils.InterfaceToString(detail[k].Val)
tmp := md.CalcSmallPublicPlatoonRelateLaXinReward{
Uid: v,
CoinId: m.CoinId,
Value: value,
}
resp = append(resp, &tmp)
}
}
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 {


Loading…
Cancel
Save