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