소스 검색

add reverse:for v1.4.2 收益计算更新

tags/v1.4.2
huangjiajun 2 년 전
부모
커밋
0e8b651b4e
3개의 변경된 파일73개의 추가작업 그리고 1개의 파일을 삭제
  1. +1
    -0
      md/commission_parameter.go
  2. +4
    -0
      rule/relate_commission.go
  3. +68
    -1
      svc/reward_commission.go

+ 1
- 0
md/commission_parameter.go 파일 보기

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


+ 4
- 0
rule/relate_commission.go 파일 보기

@@ -46,6 +46,7 @@ func BatchGetCommissionByGoods(eg *xorm.Engine, dbName string, commissionParamLi
return errors.New("商品ID缺失")
}
param.CommissionParam.Oid = param.GoodsId
param.CommissionParam.IsGoods = "1"
_, _, _, _, 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 +147,7 @@ func SettleCommWithGoodsDetail(eg *xorm.Engine, dbName string, CommissionParam m
virType = virCfg.Val
}
CommissionParam.CommissionParam.Oid = CommissionParam.GoodsId
CommissionParam.CommissionParam.IsGoods = "1"

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
@@ -169,6 +171,8 @@ func GetRewardCommission(eg *xorm.Engine, dbName, mode string, CommissionParam m
isAllLevelReturn = true
}
CommissionParam.CommissionParam.Oid = CommissionParam.GoodsId
CommissionParam.CommissionParam.IsGoods = "1"

var lvUser = &comm_plan.LvUser{}
var mapsDta = map[string]string{"show_level": CommissionParam.ShowLevel}
if isAll {


+ 68
- 1
svc/reward_commission.go 파일 보기

@@ -5,6 +5,7 @@ import (
"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"
zhios_order_relate_utils "code.fnuoos.com/go_rely_warehouse/zyos_go_order_relate_rule.git/utils"
"encoding/json"
"errors"
"fmt"
"xorm.io/xorm"
@@ -96,7 +97,12 @@ func GetRewardCommission(engine *xorm.Engine, rmd *md.CommissionParam, isShare b
Oid: rmd.Oid,
},
}
order, err := BatchGetPublicPlatoonRelateCommissionByOrder(engine, masterId, PublicPlatoonRelateCommissionReqList)
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
}
@@ -408,3 +414,64 @@ func convertList2Map(a []*comm_plan.VirtualCoinCommission) (b map[string]float64
}
return b
}

// BatchGetPublicPlatoonRelateCommission 批量分佣 商品显示
func BatchGetPublicPlatoonRelateCommissionByGoods(engine *xorm.Engine, masterId string, PublicPlatoonRelateCommissionReqList []*md.PublicPlatoonRelateCommissionReq) (map[string]*md.PublicPlatoonRelateCommissionResp, error) {
var resp = make(map[string]*md.PublicPlatoonRelateCommissionResp)
for _, param := range PublicPlatoonRelateCommissionReqList {
// 根据供应商
rewardOpt, err := db.DbsPlanRewardByPvd(engine, param.Pvd)
if err != nil {
resp[param.Oid] = &md.PublicPlatoonRelateCommissionResp{}
continue
}
if rewardOpt == nil {
resp[param.Oid] = &md.PublicPlatoonRelateCommissionResp{}
continue
}
if rewardOpt.State == 0 {
resp[param.Oid] = &md.PublicPlatoonRelateCommissionResp{}
continue
}
if rewardOpt.PlanCommissionId == 0 {
resp[param.Oid] = &md.PublicPlatoonRelateCommissionResp{}
continue
}
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 {
resp[param.Oid] = &md.PublicPlatoonRelateCommissionResp{}
continue
}
var subsidyTmp = make(map[string]*md.LvGrade)
var tmp map[string]*md.LvGrade
if err := json.Unmarshal([]byte(commissionOpt.Data), &tmp); err != nil {
resp[param.Oid] = &md.PublicPlatoonRelateCommissionResp{}
continue
}
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))
}
resp[param.Oid] = &md.PublicPlatoonRelateCommissionResp{
Uid: param.Uid,
PendingAmount: param.PendingAmount,
Oid: param.Oid,
SelfRateList: selfRateList,
CommonWealthSystem: commonWealthSystem,
DirectPush: directPush,
}
}
return resp, nil
}

불러오는 중...
취소
저장