Przeglądaj źródła

add reverse:for v1.3.1 公排制度集成

tags/v1.3.1
huangjiajun 2 lat temu
rodzic
commit
c9e361fc08
3 zmienionych plików z 75 dodań i 14 usunięć
  1. +1
    -0
      md/commission_parameter.go
  2. +5
    -1
      rule/relate_commission.go
  3. +69
    -13
      svc/reward_commission.go

+ 1
- 0
md/commission_parameter.go Wyświetl plik

@@ -12,6 +12,7 @@ type CommissionParam struct {
LowestCouponPrice string `json:"lowestCouponPrice"`
MinGroupPrice string `json:"min_group_price"`
PaidPrice string `json:"paid_price"`
Oid string `json:"oid"` //标记
}
type CommissionFirstParam struct {
CommissionParam CommissionParam `json:"commission_param"`


+ 5
- 1
rule/relate_commission.go Wyświetl plik

@@ -45,7 +45,7 @@ func BatchGetCommissionByGoods(eg *xorm.Engine, dbName string, commissionParamLi
if param.GoodsId == "" {
return errors.New("商品ID缺失")
}
param.CommissionParam.Oid=param.GoodsId
_, _, _, _, lvUser, err := svc.GetRewardCommission(eg, &param.CommissionParam, isShare, param.Uid, param.Provider, dbName, isAllLevelReturn, map[string]string{}, virType)
if err != nil {
return err
@@ -96,6 +96,7 @@ func BatchGetCommissionByOrder(engine *xorm.Engine, dbName string, CommissionPar
return errors.New("订单缺失")
}
param.CommissionParam.OldPrice = param.CommissionParam.GoodsPrice
param.CommissionParam.Oid=param.Oid

profit, pvdFee, sysFee, subsidyFee, lvUser, err := svc.GetRewardCommission(engine, &param.CommissionParam, isShare, param.Uid, param.Provider, dbName, isAllLevelReturn, map[string]string{}, virType)
if err != nil {
@@ -144,6 +145,8 @@ func SettleCommWithGoodsDetail(eg *xorm.Engine, dbName string, CommissionParam m
if virCfg != nil && virCfg.Val != "" {
virType = virCfg.Val
}
CommissionParam.CommissionParam.Oid=CommissionParam.GoodsId

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
}
@@ -165,6 +168,7 @@ func GetRewardCommission(eg *xorm.Engine, dbName, mode string, CommissionParam m
if CommissionParam.IsAllLevelReturn != 0 {
isAllLevelReturn = true
}
CommissionParam.CommissionParam.Oid=CommissionParam.GoodsId
var lvUser = &comm_plan.LvUser{}
var mapsDta = map[string]string{"show_level": CommissionParam.ShowLevel}
if isAll {


+ 69
- 13
svc/reward_commission.go Wyświetl plik

@@ -4,6 +4,7 @@ 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/lib/comm_plan"
"code.fnuoos.com/go_rely_warehouse/zyos_go_order_relate_rule.git/md"
"code.fnuoos.com/go_rely_warehouse/zyos_go_order_relate_rule.git/rule"
zhios_order_relate_utils "code.fnuoos.com/go_rely_warehouse/zyos_go_order_relate_rule.git/utils"
"errors"
"fmt"
@@ -17,6 +18,9 @@ func GetRewardCommission(engine *xorm.Engine, rmd *md.CommissionParam, isShare b
if virType == "commission" {
rmd.GoodsPrice = rmd.Commission
}
if rmd.Oid == "" {
rmd.Oid = "1"
}
var (
err error
uid = 0
@@ -53,12 +57,6 @@ func GetRewardCommission(engine *xorm.Engine, rmd *md.CommissionParam, isShare b
return 0, 0, 0, 0, nil, errors.New("分佣方案未设置")
}

var userRelationship *[]md.UserRelation
if returnAllLevel {
userRelationship, err = UserRelativeNetwork(engine, uid)
} else {
userRelationship = nil
}
// 获取全部佣金
com, price := getCommission(rmd, provider)
fmt.Println(com)
@@ -67,15 +65,73 @@ func GetRewardCommission(engine *xorm.Engine, rmd *md.CommissionParam, isShare b
if zhios_order_relate_utils.InArr(cfg.Mode, []string{"lv_price", "lv_winery"}) && zhios_order_relate_utils.StrToFloat64(rmd.OldPrice) > 0 { //价格为基数
comf = zhios_order_relate_utils.StrToFloat64(rmd.OldPrice)
}
// userRelationship == nil 是只返回第一层 即用户自己的
pvdFee, sysFee, subsidyFee, ulink, err := CalcCommission(uid, level, 0, ownbuyReturnType, comf, zhios_order_relate_utils.StrToFloat64(price), isShare, cfg, userRelationship, newProvider, newLevel, engine)
if err != nil {
return 0, 0, 0, 0, nil, nil
if cfg.Mode != "public_platoon" { //公排走另一个制度
var userRelationship *[]md.UserRelation
if returnAllLevel {
userRelationship, err = UserRelativeNetwork(engine, uid)
} else {
userRelationship = nil
}
// userRelationship == nil 是只返回第一层 即用户自己的
pvdFee, sysFee, subsidyFee, ulink, err := CalcCommission(uid, level, 0, ownbuyReturnType, comf, zhios_order_relate_utils.StrToFloat64(price), isShare, cfg, userRelationship, newProvider, newLevel, engine)
if err != nil {
return 0, 0, 0, 0, nil, nil
}
if ulink == nil {
return 0, 0, 0, 0, nil, nil
}
return ulink.Profit, pvdFee, sysFee, subsidyFee, ulink, nil
} else { //公排
//佣金扣除抽成后
fee, pvdFee, sysFee := CommFee(comf, cfg, "commission")
////积分扣除抽成后
//var integralSysFee float64 = 0
//integralFee, _, integralSysFee := CommFee(comf, 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),
Oid: rmd.Oid,
},
}
order, err := rule.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{}
//共富收益处理
ulink = getRewardLink(reward.CommonWealthBenefitUid, 2, reward.CommonWealthSystem, ulink)
//直推收益处理
ulink = getRewardLink(reward.DirectPushBenefitUid, 1, reward.DirectPush, ulink)
//自购
ulink = getRewardLink(reward.Uid, 0, reward.SelfRateList, ulink)
return profit, pvdFee, sysFee, 0, nil, nil
}
}
func getRewardLink(uid string, diff int, reward map[string]string, ulinkParent *comm_plan.LvUser) *comm_plan.LvUser {
var SubsidyFee = zhios_order_relate_utils.StrToFloat64(reward["0"])
var SubsidyFeeList = make([]*comm_plan.VirtualCoinCommission, 0)
for k, v := range reward {
var tmp = &comm_plan.VirtualCoinCommission{
Cid: k,
Val: zhios_order_relate_utils.StrToFloat64(v),
}
SubsidyFeeList = append(SubsidyFeeList, tmp)
}
if ulink == nil {
return 0, 0, 0, 0, nil, nil
//组装数据
var ulink = &comm_plan.LvUser{
Uid: zhios_order_relate_utils.StrToInt(uid),
SubsidyFee: SubsidyFee,
SubsidyFeeList: SubsidyFeeList,
Diff: diff,
ParentUser: ulinkParent,
}
return ulink.Profit, pvdFee, sysFee, subsidyFee, ulink, nil
return ulink
}

func getCommission(d *md.CommissionParam, provider string) (string, string) {


Ładowanie…
Anuluj
Zapisz