|
|
@@ -64,14 +64,14 @@ func JoinServiceAwardDividendRelation(eg *xorm.Engine, req md.JoinServiceAwardDi |
|
|
|
if levelMap[user.Level].LevelWeight >= levelMap[parentUser.Level].LevelWeight { |
|
|
|
for _, vv := range vipAllocationSetStruct { |
|
|
|
if zhios_order_relate_utils.StrToInt(vv.FromVipId) == user.Level { |
|
|
|
err = AutoAddVip(eg, user, req.ParentUid, vv, req.RegionId, req.CreateAt) |
|
|
|
err = AutoAddVip(eg, user, req.ParentUid, vv, req.RegionId, req.CreateAt, req.AllocationNums) |
|
|
|
if err != nil { |
|
|
|
return err |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} else { |
|
|
|
err = AddVipToParent(eg, user, req.ParentUid, req.RegionId, req.CreateAt) |
|
|
|
err = AddVipToParent(eg, user, req.ParentUid, req.RegionId, req.CreateAt, req.AllocationNums) |
|
|
|
if err != nil { |
|
|
|
return err |
|
|
|
} |
|
|
@@ -79,7 +79,7 @@ func JoinServiceAwardDividendRelation(eg *xorm.Engine, req md.JoinServiceAwardDi |
|
|
|
} else { |
|
|
|
for _, vv := range vipAllocationSetStruct { |
|
|
|
if zhios_order_relate_utils.StrToInt(vv.FromVipId) == user.Level { |
|
|
|
err = AutoAddVip(eg, user, req.ParentUid, vv, req.RegionId, req.CreateAt) |
|
|
|
err = AutoAddVip(eg, user, req.ParentUid, vv, req.RegionId, req.CreateAt, req.AllocationNums) |
|
|
|
if err != nil { |
|
|
|
return err |
|
|
|
} |
|
|
@@ -91,7 +91,7 @@ func JoinServiceAwardDividendRelation(eg *xorm.Engine, req md.JoinServiceAwardDi |
|
|
|
} |
|
|
|
|
|
|
|
// AutoAddVip 自动添加会员 |
|
|
|
func AutoAddVip(engine *xorm.Engine, user *model.User, parentUid int, vipAllocationSetStruct md.VipAllocationSetStruct, regionId int, createAt string) (err error) { |
|
|
|
func AutoAddVip(engine *xorm.Engine, user *model.User, parentUid int, vipAllocationSetStruct md.VipAllocationSetStruct, regionId int, createAt string, allocationNums int) (err error) { |
|
|
|
//1、查询出当前应该分配给哪个上级会员 |
|
|
|
var serviceAwardDividendRelation models.ServiceAwardDividendRelation |
|
|
|
var hasServiceAwardDividendRelation bool |
|
|
@@ -128,7 +128,7 @@ func AutoAddVip(engine *xorm.Engine, user *model.User, parentUid int, vipAllocat |
|
|
|
ParentUid: parentUid, |
|
|
|
BindUid: 0, |
|
|
|
VipLevel: user.Level, |
|
|
|
AllocationNums: 0, |
|
|
|
AllocationNums: allocationNums, |
|
|
|
RegionId: regionId, |
|
|
|
CreateAt: createAt, |
|
|
|
UpdateAt: now.Format("2006-01-02 15:04:05"), |
|
|
@@ -146,7 +146,7 @@ func AutoAddVip(engine *xorm.Engine, user *model.User, parentUid int, vipAllocat |
|
|
|
ParentUid: parentUid, |
|
|
|
BindUid: serviceAwardDividendRelation.Uid, |
|
|
|
VipLevel: user.Level, |
|
|
|
AllocationNums: 0, |
|
|
|
AllocationNums: allocationNums, |
|
|
|
RegionId: regionId, |
|
|
|
CreateAt: createAt, |
|
|
|
UpdateAt: now.Format("2006-01-02 15:04:05"), |
|
|
@@ -171,7 +171,7 @@ func AutoAddVip(engine *xorm.Engine, user *model.User, parentUid int, vipAllocat |
|
|
|
} |
|
|
|
|
|
|
|
// AddVipToParent 添加会员至父级 |
|
|
|
func AddVipToParent(engine *xorm.Engine, user *model.User, parentUid int, regionId int, createAt string) (err error) { |
|
|
|
func AddVipToParent(engine *xorm.Engine, user *model.User, parentUid int, regionId int, createAt string, allocationNums int) (err error) { |
|
|
|
//1、查询出当前应该分配给哪个上级会员 |
|
|
|
var serviceAwardDividendRelation models.ServiceAwardDividendRelation |
|
|
|
has, err := engine.Where("uid =?", parentUid).Get(&serviceAwardDividendRelation) |
|
|
@@ -200,7 +200,7 @@ func AddVipToParent(engine *xorm.Engine, user *model.User, parentUid int, region |
|
|
|
ParentUid: parentUid, |
|
|
|
BindUid: serviceAwardDividendRelation.Uid, |
|
|
|
VipLevel: user.Level, |
|
|
|
AllocationNums: 0, |
|
|
|
AllocationNums: allocationNums, |
|
|
|
RegionId: regionId, |
|
|
|
CreateAt: createAt, |
|
|
|
UpdateAt: now.Format("2006-01-02 15:04:05"), |
|
|
|