Commit 6ff9caac authored by 吴春's avatar 吴春

提交代码

parent d6a18812
......@@ -27,6 +27,7 @@ namespace Mall.Model.Extend.User
/// 昵称
/// </summary>
public string NickName { get; set; }
/// <summary>
/// 头像
/// </summary>
......
......@@ -16,5 +16,10 @@ namespace Mall.Model.Extend.User
/// ids
/// </summary>
public string SupplierIds { get; set; }
/// <summary>
/// 介绍人名称
/// </summary>
public string IntroducerName { get; set; }
}
}
......@@ -53,6 +53,9 @@ namespace Mall.Model.Query
/// </summary>
public int SalesTimeType { get; set; }
/// <summary>
/// 排序
/// </summary>
public string OrderBy { get; set; }
}
}
......@@ -1150,7 +1150,8 @@ namespace Mall.Module.Product
if (RulesAreaModel != null && RulesAreaModel.IsOpenMinPrice == 1)
{
var RegionAreaList = logistics_RulesRegionRepository.GetListForSingle(new Model.Extend.BaseSetUp.RB_Logistics_RulesRegion_Extend() { RulesPriceId = RulesAreaModel.ID, RulesType = Common.Enum.MallBase.RulesTypeEnum.AreaBuy, TenantId = demodel.TenantId, MallBaseId = demodel.MallBaseId });
if (RegionAreaList.Any()) {
if (RegionAreaList.Any())
{
//允许以下区域购买
RAreaList = RegionAreaList.Select(x => x.RegionId).Distinct().ToList();
}
......@@ -3238,11 +3239,12 @@ namespace Mall.Module.Product
try
{
var basicModel = distributor_BasicsRepository.GetList(new RB_Distributor_Basics_Extend() { TenantId = demodel.TenantId, MallBaseId = demodel.MallBaseId }).FirstOrDefault();
if ((basicModel?.IsEnableFXGrade??2) == 1)
if ((basicModel?.IsEnableFXGrade ?? 2) == 1)
{
//粉象返佣
var FXList = distributor_FXGradeRepository.GetList(new RB_Distributor_FXGrade_Extend() { TenantId = demodel.TenantId, MallBaseId = demodel.MallBaseId });
if (FXList.Any() && FXList.Where(x => x.IsGuest == 1).Any()) {
if (FXList.Any() && FXList.Where(x => x.IsGuest == 1).Any())
{
var FXPModel = FXList.Where(x => x.IsGuest == 1).FirstOrDefault();
//验证用户必须是分销商 最低普通会员 不是以普通会员处理
var disModel = distributor_InfoRepository.GetList(new RB_Distributor_Info_Extend() { TenantId = demodel.TenantId, MallBaseId = demodel.MallBaseId, UserId = umodel.Id, AuditStatus = Common.Enum.User.DistributorAuditStatusEnum.Audited }).FirstOrDefault();
......@@ -3265,21 +3267,25 @@ namespace Mall.Module.Product
var ulist = member_UserRepository.GetList(new RB_Member_User_Extend() { UserIds = UserIds, TenantId = demodel.TenantId, MallBaseId = demodel.MallBaseId });
//查询出用户的所有分销信息
var dlist = distributor_InfoRepository.GetListForSingle(new RB_Distributor_Info_Extend() { UserIds = UserIds, TenantId = demodel.TenantId, MallBaseId = demodel.MallBaseId });
foreach (var item in dlist) {
foreach (var item in dlist)
{
item.Grade = FXList.Where(x => x.Id == item.FXGradeId).FirstOrDefault()?.Grade ?? 0;
}
//开始慢慢找 注 同级返佣数量 返佣建子表可以无限级返佣了
var DetailList = demodel.DetailList.Where(x => x.CommissionPrice > 0).ToList();
foreach (var item in DetailList) {
foreach (var item in DetailList)
{
//返佣
List<RB_Goods_OrderCommission> gocList = new List<RB_Goods_OrderCommission>();
List<FXOrderCommissionNumModel> fxNumList = new List<FXOrderCommissionNumModel>();
decimal TotalCommission = item.CommissionPrice;
int UserId = umodel.Id;
int Num = 1;
while (UserId > 0 && TotalCommission > 0) {
while (UserId > 0 && TotalCommission > 0)
{
var numodel = ulist.Where(x => x.Id == UserId).FirstOrDefault();
if (numodel == null) {
if (numodel == null)
{
UserId = 0;
break;
}
......@@ -3326,7 +3332,8 @@ namespace Mall.Module.Product
};
gocList.Add(gocModel);
}
else {
else
{
var d2Model = dlist.Where(x => x.UserId == numodel.Id).FirstOrDefault();
var FXGModel = new RB_Distributor_FXGrade_Extend();
if (d2Model == null)
......@@ -3334,14 +3341,17 @@ namespace Mall.Module.Product
LogHelper.Write("粉象返佣 用户分销商信息不存在:UserId:" + numodel.Id);
FXGModel = FXPModel;
}
else {
else
{
FXGModel = FXList.Where(x => x.Id == d2Model.FXGradeId).FirstOrDefault();
if (FXGModel == null) {
if (FXGModel == null)
{
FXGModel = FXPModel;
}
}
int MaxGrade = fxNumList.Max(x => x.Grade);
if (FXGModel.Grade < MaxGrade) {
if (FXGModel.Grade < MaxGrade)
{
//后面的全部不返佣
UserId = 0;
break;
......@@ -3358,7 +3368,8 @@ namespace Mall.Module.Product
//需要提间接普会
CommissionRatio = GetFXGradeRatioCommon(FXList, FXGModel.Id, FXPModel.Id, 2);
}
else {
else
{
CommissionRatio = GetFXGradeRatioCommon(FXList, FXGModel.Id, MaxGradeId, 1);
}
if (FXGModel.DecimalType == 1)
......@@ -3379,7 +3390,8 @@ namespace Mall.Module.Product
});
Num++;
bool IsMoneyLack = false;
if (TotalCommission < DcommionMoney) {
if (TotalCommission < DcommionMoney)
{
DcommionMoney = TotalCommission;
IsMoneyLack = true;
}
......@@ -3404,7 +3416,8 @@ namespace Mall.Module.Product
gocList.Add(gocModel);
TotalCommission -= DcommionMoney;
}
else {
else
{
UserId = 0;
//该等级的已提完了 看是否可以直接找到下一个等级的
var fx2List = dlist.Where(x => x.Grade > MaxGrade).ToList();
......@@ -4570,7 +4583,8 @@ namespace Mall.Module.Product
}
};
bool flag = goods_OrderAfterSaleRepository.Update(keyValues, wheres);
if (flag) {
if (flag)
{
//流程
goods_OrderAfterSaleLogRepository.Insert(new RB_Goods_OrderAfterSaleLog()
{
......@@ -4610,7 +4624,8 @@ namespace Mall.Module.Product
{
keyValues.Add(nameof(RB_Goods_OrderAfterSale.ReOrderStatus), OrderAfterSaleStatusEnum.ReceivedBySeller);
}
else {
else
{
keyValues.Add(nameof(RB_Goods_OrderAfterSale.ReOrderStatus), OrderAfterSaleStatusEnum.RefundedBySeller);
}
List<WhereHelper> wheres = new List<WhereHelper>() {
......@@ -4963,7 +4978,8 @@ namespace Mall.Module.Product
HpgradeList = distributor_HPGradeInfoRepository.GetList(new RB_Distributor_HPGradeInfo_Extend() { GradeIds = gradeIds, TenantId = demodel.TenantId, MallBaseId = demodel.MallBaseId }, true);
}
var FXGradeList = new List<RB_Distributor_FXGrade_Extend>();
if (oclist.Where(x => x.Type == 3).Any()) {
if (oclist.Where(x => x.Type == 3).Any())
{
string gradeIds = string.Join(",", oclist.Where(x => x.Type == 3).Select(x => x.Grade).Distinct());
FXGradeList = distributor_FXGradeRepository.GetList(new RB_Distributor_FXGrade_Extend() { GradeIds = gradeIds, TenantId = demodel.TenantId, MallBaseId = demodel.MallBaseId });
}
......@@ -4997,7 +5013,8 @@ namespace Mall.Module.Product
var hpGModel = HpgradeList.Where(x => x.Id == item.Grade).FirstOrDefault();
item.GradeDescription = hpGModel?.GradeName ?? "暂无等级";
}
else if (item.Type == 3) {
else if (item.Type == 3)
{
var fxGModel = FXGradeList.Where(x => x.Id == item.Grade).FirstOrDefault();
item.GradeDescription = fxGModel?.GradeName ?? "暂无等级";
}
......@@ -8674,6 +8691,12 @@ namespace Mall.Module.Product
{
return goods_OrderDetailRepository.GetNoOutOrderGoodsList(pageIndex, pageSize, out count, dmodel);
}
public List<RB_Distributor_Info_Extend> GetDistributorInfoList(RB_Distributor_Info_Extend dmodel)
{
return distributor_InfoRepository.GetList(dmodel);
}
#endregion
}
}
......@@ -75,7 +75,7 @@ namespace Mall.Repository.User
user.AppendFormat(" AND {0}={1} ", nameof(RB_Member_User_Extend.Source), (int)query.Source);
}
var userTotal = ExecuteScalar(user.ToString());
if (userTotal != null && Convert.ToInt32(userTotal)>0)
if (userTotal != null && Convert.ToInt32(userTotal) > 0)
{
model.UserTotalNum = Convert.ToInt32(userTotal);
}
......@@ -114,7 +114,7 @@ namespace Mall.Repository.User
{
orderNum.AppendFormat(" AND {0}<='{1} 23:59:59' ", nameof(RB_Goods_Order_Extend.CreateDate), query.EndDate);
}
var orderCountList= Get<OrderNum>(orderNum.ToString()).ToList();
var orderCountList = Get<OrderNum>(orderNum.ToString()).ToList();
if (orderCountList != null && orderCountList.Count > 0)
{
......@@ -189,7 +189,7 @@ WHERE 1=1 AND OrderStatus>=2 AND OrderStatus<=5
builder.AppendFormat(" AND A.{0}={1} ", nameof(RB_Goods_Order_Extend.OrderSource), (int)query.Source);
}
//开始时间
if (query.SalesTimeType==7)
if (query.SalesTimeType == 7)
{
builder.AppendFormat(" AND A.{0}>='{1}' ", nameof(RB_Goods_Order_Extend.CreateDate), DateTime.Now.AddDays(-7).ToString("yyyy-MM-dd"));
builder.AppendFormat(" AND A.{0}<='{1} 23:59:59' ", nameof(RB_Goods_Order_Extend.CreateDate), DateTime.Now.ToString("yyyy-MM-dd"));
......@@ -215,7 +215,7 @@ WHERE 1=1 AND OrderStatus>=2 AND OrderStatus<=5
//开始时间
if (query.StartDate != null && !string.IsNullOrWhiteSpace(query.StartDate))
{
where+=string.Format(" AND B.{0}>='{1}' ", nameof(RB_Goods_Order_Extend.CreateDate), query.StartDate);
where += string.Format(" AND B.{0}>='{1}' ", nameof(RB_Goods_Order_Extend.CreateDate), query.StartDate);
}
//结束时间
if (query.EndDate != null && !string.IsNullOrWhiteSpace(query.EndDate))
......@@ -224,14 +224,23 @@ WHERE 1=1 AND OrderStatus>=2 AND OrderStatus<=5
}
StringBuilder builder = new StringBuilder();
builder.AppendFormat(@"
SELECT A.GoodsName,Count(1) SaleCount,SUM(A.Final_Price) AS Income
// builder.AppendFormat(@"
//SELECT A.GoodsName,Count(1) SaleCount,SUM(A.Final_Price) AS Income
//FROM rb_goods_orderdetail AS A LEFT JOIN rb_goods_order AS B ON A.OrderId=B.OrderId
//WHERE 1=1 AND A.GoodsId>0 {0}
//GROUP BY A.GoodsId,A.GoodsName
//ORDER BY COunt(1) DESC
//LIMIT 100
//", where);
if (string.IsNullOrWhiteSpace(query.OrderBy))
{
query.OrderBy = "Income desc";
}
builder.AppendFormat(@$"SELECT * from (SELECT A.GoodsName,Count(1) SaleCount,SUM(A.Final_Price) AS Income
FROM rb_goods_orderdetail AS A LEFT JOIN rb_goods_order AS B ON A.OrderId=B.OrderId
WHERE 1=1 AND A.GoodsId>0 {0}
GROUP BY A.GoodsId,A.GoodsName
ORDER BY COunt(1) DESC
LIMIT 100
", where);
WHERE 1=1 AND A.GoodsId>0 {where}
GROUP BY A.GoodsId,A.GoodsName) as a ORDER BY a.{query.OrderBy} LIMIT 100 ");
var list = Get<MallSalesGoodsTop>(builder.ToString()).ToList();
if (list != null && list.Count > 0)
{
......@@ -272,15 +281,25 @@ LIMIT 100
}
StringBuilder builder = new StringBuilder();
builder.AppendFormat(@"
SELECT C.`Name` AS UserName,C.Photo,COUNT(1) SaleCount,SUM(A.Final_Price) AS Income
// builder.AppendFormat(@"
//SELECT C.`Name` AS UserName,C.Photo,COUNT(1) SaleCount,SUM(A.Final_Price) AS Income
//FROM rb_goods_orderdetail AS A LEFT JOIN rb_goods_order AS B ON A.OrderId=B.OrderId
// LEFT JOIN rb_member_user AS C ON B.UserId=C.Id
//WHERE 1=1 AND A.GoodsId>0 {0}
//GROUP BY B.UserId,C.`Name`
//ORDER BY COUNT(1) DESC
//LIMIT 100
//", where);
if (string.IsNullOrWhiteSpace(query.OrderBy))
{
query.OrderBy = "Income desc";
}
builder.AppendFormat($@"SELECT * from (SELECT C.`Name` AS UserName,C.Photo,COUNT(1) SaleCount,SUM(A.Final_Price) AS Income
FROM rb_goods_orderdetail AS A LEFT JOIN rb_goods_order AS B ON A.OrderId=B.OrderId
LEFT JOIN rb_member_user AS C ON B.UserId=C.Id
WHERE 1=1 AND A.GoodsId>0 {0}
WHERE 1=1 AND A.GoodsId>0 {where}
GROUP BY B.UserId,C.`Name`
ORDER BY COUNT(1) DESC
LIMIT 100
", where);
) as t ORDER BY t.{query.OrderBy} LIMIT 100");
var list = Get<MallSalesUserTop>(builder.ToString()).ToList();
if (list != null && list.Count > 0)
{
......
......@@ -27,17 +27,17 @@ namespace Mall.Repository.User
string where = " 1=1 AND Status=0 ";
if (dmodel.TenantId > 0)
{
where += $@" and {nameof(RB_Supplier.TenantId)}={dmodel.TenantId}";
where += $@" and a.{nameof(RB_Supplier.TenantId)}={dmodel.TenantId}";
}
if (dmodel.MallBaseId > 0)
{
where += $@" and {nameof(RB_Supplier.MallBaseId)}={dmodel.MallBaseId}";
where += $@" and a.{nameof(RB_Supplier.MallBaseId)}={dmodel.MallBaseId}";
}
if (!string.IsNullOrWhiteSpace(dmodel.Name))
{
where += $@" and {nameof(RB_Supplier.Name)} like '%{dmodel.Name}%'";
where += $@" and a.{nameof(RB_Supplier.Name)} like '%{dmodel.Name}%'";
}
string sql = $@"select * from {TableName} where {where} order by Id desc";
string sql = $@"select a.*,b.`Name` as IntroducerName from rb_distributor_info as a LEFT JOIN rb_member_user as b on a.Introducer=b.UserId {where} order by Id desc";
return GetPage<RB_Supplier_Extend>(pageIndex, pageSize, out rowCount, sql).ToList();
}
......@@ -65,7 +65,7 @@ namespace Mall.Repository.User
{
where += $@" and a.{nameof(RB_Supplier.ID)} in({dmodel.SupplierIds})";
}
string sql = $@"select * from {TableName} as A where {where} order by Id desc";
string sql = $@"select a.*,b.`Name` as IntroducerName from {TableName} as a LEFT JOIN rb_distributor_info as b on a.Introducer=b.UserId {where} order by Id desc";
return Get<RB_Supplier_Extend>(sql).ToList();
}
}
......
......@@ -58,6 +58,8 @@ namespace Mall.WebApi.Controllers.User
x.Name,
x.Mobile,
x.Address,
x.IntroducerName,
x.CommissionRate,
CardNum = x.ClientBankAccount != null ? x.ClientBankAccount.CardNum : "",
OpenBankName = x.ClientBankAccount != null ? x.ClientBankAccount.OpenBankName : "",
AccountAlias = x.ClientBankAccount != null ? x.ClientBankAccount.AccountAlias : "",
......@@ -153,7 +155,7 @@ namespace Mall.WebApi.Controllers.User
/// <summary>
/// 删除优惠券
/// 删除供应商
/// </summary>
/// <returns></returns>
[HttpPost]
......@@ -200,7 +202,22 @@ namespace Mall.WebApi.Controllers.User
return ApiResult.Success("", oldLogisticsList);
}
/// <summary>
/// 获取供应商下拉列表
/// </summary>
/// <returns></returns>
[HttpPost]
[AllowAnonymous]
public ApiResult GetDistributorInfoList()
{
var parms = RequestParm;
var query = JsonConvert.DeserializeObject<RB_Distributor_Info_Extend>(RequestParm.msg.ToString());
query.TenantId = UserInfo.TenantId;
query.MallBaseId = parms.MallBaseId;
query.AuditStatus = Common.Enum.User.DistributorAuditStatusEnum.Audited;
var oldLogisticsList = orderModule.GetDistributorInfoList(query);
return ApiResult.Success("", oldLogisticsList);
}
#endregion
......
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