Commit 86fc535b authored by liudong1993's avatar liudong1993

vip返佣

parent 2ad753e0
......@@ -410,7 +410,7 @@ namespace Mall.Module.User
string UserIds = member_UserRepository.GetMemberParentIdStr(pmodel.Id);
var ulist = member_UserRepository.GetList(new RB_Member_User_Extend() { UserIds = UserIds, TenantId = TenantId, MallBaseId = MallBaseId });
//查询出用户的所有分销信息
var dlist = distributor_InfoRepository.GetListForSingle(new RB_Distributor_Info_Extend() { UserIds = UserIds, TenantId = TenantId, MallBaseId = MallBaseId });
var dlist = distributor_InfoRepository.GetListForSingle(new RB_Distributor_Info_Extend() { UserIds = UserIds, AuditStatus = Common.Enum.User.DistributorAuditStatusEnum.Audited, TenantId = TenantId, MallBaseId = MallBaseId });
foreach (var item in dlist)
{
item.Grade = FXList.Where(x => x.Id == item.FXGradeId).FirstOrDefault()?.Grade ?? 0;
......@@ -582,14 +582,51 @@ namespace Mall.Module.User
}
}
}
foreach (var qitem in gocList)
try
{
if (qitem.Commission > 0)
var trans = vipBuy_CommissionRepository.DbTransaction;
if (gocList.Any())
{
vipBuy_CommissionRepository.Insert(qitem);
//分销商增加相应的佣金
string FUserIds = string.Join(",", gocList.Select(x => x.UserId).Distinct());
//最后再次查询分销商 便于返佣金
var fdlist = distributor_InfoRepository.GetListForSingle(new RB_Distributor_Info_Extend() { UserIds = FUserIds, AuditStatus = Common.Enum.User.DistributorAuditStatusEnum.Audited, TenantId = TenantId, MallBaseId = MallBaseId });
foreach (var qitem in gocList)
{
if (qitem.Commission > 0)
{
bool flag = vipBuy_CommissionRepository.Insert(qitem, trans) > 0;
if (flag)
{
//分销商增加相应的佣金
var numodel = ulist.Where(x => x.Id == qitem.UserId).FirstOrDefault();
var fmodel = fdlist.Where(x => x.UserId == (numodel?.Id ?? 0)).FirstOrDefault();
if (fmodel != null)
{
//分销商增加佣金
Dictionary<string, object> keyValues = new Dictionary<string, object>() {
{ nameof(RB_Distributor_Info.TotalCommission),(fmodel.TotalCommission??0)+(qitem.Commission??0)},
{ nameof(RB_Distributor_Info.CommissionWithdrawal),(fmodel.CommissionWithdrawal??0)+(qitem.Commission??0)},
};
List<WhereHelper> wheres = new List<WhereHelper>() {
new WhereHelper(){
FiledName=nameof(RB_Distributor_Info.Id),
FiledValue=fmodel.Id,
OperatorEnum=OperatorEnum.Equal
}
};
distributor_InfoRepository.Update(keyValues, wheres, trans);
}
}
}
}
}
vipBuy_CommissionRepository.DBSession.Commit();
}
catch (Exception ex)
{
LogHelper.Write(ex, "InsertVipBuyCommission");
vipBuy_CommissionRepository.DBSession.Rollback();
}
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment