Browse Source

add reverse:for v3.2.1 极差返回直推奖励

tags/v3.2.1
huangjiajun 2 years ago
parent
commit
3bfd8dfe11
5 changed files with 17 additions and 7 deletions
  1. +6
    -2
      db/dbs_user.go
  2. +2
    -0
      md/commission_parameter.go
  3. +3
    -0
      rule/relate_commission.go
  4. +4
    -3
      svc/reward_commission.go
  5. +2
    -2
      svc/user_relative_network.go

+ 6
- 2
db/dbs_user.go View File

@@ -17,9 +17,13 @@ func DbsUserFindByIds(eg *xorm.Engine, uid []int) (*[]model.User, error) {
return &users, nil
}

func DbsUserRelate(eg *xorm.Engine, uid int) (*[]model.UserRelate, error) {
func DbsUserRelate(eg *xorm.Engine, uid, level int) (*[]model.UserRelate, error) {
var userRelate []model.UserRelate
if err := eg.Where("uid = ?", uid).Asc("level").Find(&userRelate); err != nil {
sess := eg.Where("uid = ?", uid)
if level > 0 {
sess.And("level<=?", level)
}
if err := sess.Asc("level").Find(&userRelate); err != nil {
return nil, zhios_order_relate_logx.Error(err)
}
if len(userRelate) == 0 {


+ 2
- 0
md/commission_parameter.go View File

@@ -14,6 +14,7 @@ type CommissionParam struct {
PaidPrice string `json:"paid_price"`
Oid string `json:"oid"` //标记
IsGoods string `json:"is_goods"`
IsShowExtend string `json:"is_show_extend"`
}
type CommissionFirstParam struct {
CommissionParam CommissionParam `json:"commission_param"`
@@ -27,4 +28,5 @@ type CommissionFirstParam struct {
OwnbuyReturnType int `json:"ownbuy_return_type"` //自购是否返利 0返利 1不返利
Oid string `json:"oid"`
ShowLevel string `json:"show_level"`
IsShowExtend string `json:"is_show_extend"`
}

+ 3
- 0
rule/relate_commission.go View File

@@ -45,6 +45,8 @@ func BatchGetCommissionByGoods(eg *xorm.Engine, dbName string, commissionParamLi
}
param.CommissionParam.Oid = param.GoodsId
param.CommissionParam.IsGoods = "1"
param.CommissionParam.IsShowExtend = param.IsShowExtend

_, _, _, _, lvUser, err := svc.GetRewardCommission(eg, &param.CommissionParam, isShare, param.Uid, param.Provider, dbName, isAllLevelReturn, map[string]string{}, virType)
if err != nil {
return err
@@ -146,6 +148,7 @@ func SettleCommWithGoodsDetail(eg *xorm.Engine, dbName string, CommissionParam m
}
CommissionParam.CommissionParam.Oid = CommissionParam.GoodsId
CommissionParam.CommissionParam.IsGoods = "1"
CommissionParam.CommissionParam.IsShowExtend = CommissionParam.IsShowExtend

profit, pvdFee, sysFee, subsidyFee, lvUser, err := svc.GetRewardCommission(eg, &CommissionParam.CommissionParam, isShare, CommissionParam.Uid, CommissionParam.Provider, dbName, isAllLevelReturn, mapData, virType)
return profit, pvdFee, sysFee, subsidyFee, lvUser, err


+ 4
- 3
svc/reward_commission.go View File

@@ -182,10 +182,11 @@ func GetRewardCommission(engine *xorm.Engine, rmd *md.CommissionParam, isShare b
return 0, pvdFee, sysFee, 0, ulink, nil
}
//常规级差

var userRelationship *[]md.UserRelation
if returnAllLevel {
userRelationship, err = UserRelativeNetwork(engine, uid)
userRelationship, err = UserRelativeNetwork(engine, uid, 0)
} else if rmd.IsShowExtend == "1" {
userRelationship, err = UserRelativeNetwork(engine, uid, 1)
} else {
userRelationship = nil
}
@@ -490,7 +491,7 @@ func CalcCommission(uid, level, oldDiff, ownbuyReturnType int, fee, integralFee
levelWeight1 = lvWeight.LevelWeight
level1 = lvWeight.Id
}
if err := comm_plan.Fn[opt.Mode](opt, fee, integralFee, lvUser, pvd, sysFee, integralSysFee,level1, levelWeight1); err != nil {
if err := comm_plan.Fn[opt.Mode](opt, fee, integralFee, lvUser, pvd, sysFee, integralSysFee, level1, levelWeight1); err != nil {
fmt.Println("方案有问题1")
return 0, 0, 0, nil, err
}


+ 2
- 2
svc/user_relative_network.go View File

@@ -7,8 +7,8 @@ import (
)

// 获取用户关系等级, 如果返回nil则没有上级用户
func UserRelativeNetwork(eg *xorm.Engine, uid int) (*[]md.UserRelation, error) {
parent, err := db.DbsUserRelate(eg, uid)
func UserRelativeNetwork(eg *xorm.Engine, uid, level int) (*[]md.UserRelation, error) {
parent, err := db.DbsUserRelate(eg, uid, level)
if err != nil || parent == nil {
return nil, err
}


Loading…
Cancel
Save