Commit ae764314 authored by 吴春's avatar 吴春

提交代码

parent 81ae2c0d
using System;
using System.Collections.Generic;
using System.Text;
namespace Mall.Model.Entity.GuideCar
{
public class RB_GuideCar_Site
{
public int ID { get; set; }
/// <summary>
/// 商户id
/// </summary>
public int TenantId { get; set; }
/// <summary>
/// 小程序id
/// </summary>
public int MallBaseId { get; set; }
/// <summary>
/// 站点名称
/// </summary>
public string SiteName { get; set; }
public int Status { get; set; }
public DateTime CreateDate { get; set; }
public DateTime UpdateDate { get; set; }
public int RulesType { get; set; }
}
}
...@@ -17,7 +17,7 @@ namespace Mall.Model.Entity.BaseSetUp ...@@ -17,7 +17,7 @@ namespace Mall.Model.Entity.BaseSetUp
/// <summary> /// <summary>
/// 价格 /// 价格
/// </summary> /// </summary>
public int RulesPriceId { get; set; } public int SiteId { get; set; }
/// <summary> /// <summary>
/// 地区id /// 地区id
...@@ -38,7 +38,7 @@ namespace Mall.Model.Entity.BaseSetUp ...@@ -38,7 +38,7 @@ namespace Mall.Model.Entity.BaseSetUp
public int MallBaseId { get; set; } public int MallBaseId { get; set; }
public RulesTypeEnum RulesType { get; set; } public int RulesType { get; set; }
public int Status { get; set; } public int Status { get; set; }
......
...@@ -15,7 +15,7 @@ namespace Mall.Model.Extend.GuideCar ...@@ -15,7 +15,7 @@ namespace Mall.Model.Extend.GuideCar
/// </summary> /// </summary>
public string RegionName { get; set; } public string RegionName { get; set; }
public string PriceIds { get; set; } public string SiteIds { get; set; }
/// <summary> /// <summary>
......
using Mall.Model.Entity.GuideCar;
using System;
using System.Collections.Generic;
using System.Text;
namespace Mall.Model.Extend.GuideCar
{
/// <summary>
/// 司导站点扩展表
/// </summary>
public class RB_GuideCar_Site_Extend : RB_GuideCar_Site
{
/// <summary>
/// 地区列表
/// </summary>
public List<RB_GuideCar_SiteRegion_Extend> RegionList { get; set; }
/// <summary>
/// 规格的ids
/// </summary>
public string SiteIds { get; set; }
}
}
...@@ -9,10 +9,12 @@ using Mall.Common.Plugin; ...@@ -9,10 +9,12 @@ using Mall.Common.Plugin;
using Mall.Model.Entity.Product; using Mall.Model.Entity.Product;
using Mall.Model.Entity.User; using Mall.Model.Entity.User;
using Mall.Model.Extend.BaseSetUp; using Mall.Model.Extend.BaseSetUp;
using Mall.Model.Extend.GuideCar;
using Mall.Model.Extend.Product; using Mall.Model.Extend.Product;
using Mall.Model.Extend.User; using Mall.Model.Extend.User;
using Mall.Model.Query; using Mall.Model.Query;
using Mall.Repository.BaseSetUp; using Mall.Repository.BaseSetUp;
using Mall.Repository.GuideCar;
using Mall.Repository.Product; using Mall.Repository.Product;
using Mall.Repository.User; using Mall.Repository.User;
using Newtonsoft.Json; using Newtonsoft.Json;
...@@ -37,7 +39,7 @@ namespace Mall.Module.Product ...@@ -37,7 +39,7 @@ namespace Mall.Module.Product
/// 商品分类 /// 商品分类
/// </summary> /// </summary>
private readonly RB_Product_CategoryRepository product_CategoryRepository = new RB_Product_CategoryRepository(); private readonly RB_Product_CategoryRepository product_CategoryRepository = new RB_Product_CategoryRepository();
/// <summary> /// <summary>
/// 商品 /// 商品
/// </summary> /// </summary>
...@@ -83,7 +85,7 @@ namespace Mall.Module.Product ...@@ -83,7 +85,7 @@ namespace Mall.Module.Product
/// 商品会员价格 /// 商品会员价格
/// </summary> /// </summary>
private readonly RB_Goods_MemberPriceRepository goods_MemberPriceRepository = new RB_Goods_MemberPriceRepository(); private readonly RB_Goods_MemberPriceRepository goods_MemberPriceRepository = new RB_Goods_MemberPriceRepository();
/// <summary> /// <summary>
/// 商户仓储层对象 /// 商户仓储层对象
/// </summary> /// </summary>
...@@ -131,6 +133,14 @@ namespace Mall.Module.Product ...@@ -131,6 +133,14 @@ namespace Mall.Module.Product
/// </summary> /// </summary>
private RB_SmallShops_PriceRepository smallShops_PriceRepository = new RB_SmallShops_PriceRepository(); private RB_SmallShops_PriceRepository smallShops_PriceRepository = new RB_SmallShops_PriceRepository();
/// <summary>
/// 司导站点
/// </summary>
private RB_GuideCar_SiteRepository SiteRepository = new RB_GuideCar_SiteRepository();
/// <summary>
/// 司导站点地区
/// </summary>
private RB_GuideCar_SiteRegionRepository SiteRegionRepository = new RB_GuideCar_SiteRegionRepository();
#region 基础配置 #region 基础配置
...@@ -140,7 +150,183 @@ namespace Mall.Module.Product ...@@ -140,7 +150,183 @@ namespace Mall.Module.Product
#region 站点配置 #region 站点配置
/// <summary>
/// 包邮规则列表
/// </summary>
/// <param name="pageIndex">页码</param>
/// <param name="pageSize">每页显示条数</param>
/// <param name="rowCount">总条数</param>
/// <param name="query">查询条件</param>
/// <returns></returns>
public List<RB_GuideCar_Site_Extend> GetLogisticsPinkageList(int pageIndex, int pageSize, out long rowCount, RB_GuideCar_Site_Extend query)
{
List<RB_GuideCar_Site_Extend> list = SiteRepository.GetPageListRepository(pageIndex, pageSize, out rowCount, query);
if (list != null && list.Any())
{
List<RB_GuideCar_SiteRegion_Extend> listLogisticsRulesRegion = SiteRegionRepository.GetListRepository(new RB_GuideCar_SiteRegion_Extend { TenantId = query.TenantId, RulesType =1, MallBaseId = query.MallBaseId, SiteIds = string.Join(",", list.Select(x => x.ID)) });
foreach (var item in list)
{
item.RegionList = new List<RB_GuideCar_SiteRegion_Extend>();
item.RegionList = listLogisticsRulesRegion.Where(x => x.SiteId == item.ID).ToList();
}
}
return list;
}
/// <summary>
/// 包邮实体
/// </summary>
/// <param name="query"></param>
/// <returns></returns>
public RB_GuideCar_Site_Extend GetPinkageModel(RB_GuideCar_Site_Extend query)
{
RB_GuideCar_Site_Extend model = SiteRepository.GetLogisticsRulesList(query).FirstOrDefault();
if (model != null)
{
//List<RB_Logistics_RulesRegion_Extend> listLogisticsRulesRegion = logisticsRulesRegionRepository.GetListRepository(new RB_Logistics_RulesRegion_Extend { TenantId = query.TenantId, RulesType = query.RulesType, MallBaseId = query.MallBaseId, RulesPriceId = model.ID });
//model.List = new List<RB_Logistics_RulesRegion_Extend>();
//model.List = listLogisticsRulesRegion;
}
return model;
}
/// <summary>
/// 新增/修改基础信息
/// </summary>
/// <param name="model"></param>
/// <returns></returns>
public bool AddOrUpdatePinkage(RB_Logistics_Rules_Extend model)
{
bool flag = false;
var trans = logisticsRulesRepository.DbTransaction;
try
{
int rulesId = 0;
if (model.ID == 0)
{
rulesId = logisticsRulesRepository.Insert(model, trans);
flag = rulesId > 0;
}
else
{
rulesId = model.ID;
flag = logisticsRulesRepository.Update(model, trans);
List<RB_Logistics_RulesRegion_Extend> listLogisticsRulesRegion = logisticsRulesRegionRepository.GetListRepository(new RB_Logistics_RulesRegion_Extend { TenantId = model.TenantId, RulesType = model.RulesType, MallBaseId = model.MallBaseId, RulesPriceId = model.ID });
//删除之前的区域
foreach (var itemRegion in listLogisticsRulesRegion.Where(x => x.RulesPriceId == model.ID))
{
IDictionary<string, object> filedsRegion = new Dictionary<string, object>()//删除价格下面对应的地区
{
{ nameof(RB_Logistics_RulesRegion.Status),1},
{ nameof(RB_Logistics_RulesRegion.UpdateDate),System.DateTime.Now},
};
IList<WhereHelper> whereHelpersRegion = new List<WhereHelper>()
{
new WhereHelper (){ FiledName=nameof(RB_Logistics_RulesRegion.ID),FiledValue=itemRegion.ID,OperatorEnum=OperatorEnum.Equal}
};
logisticsRulesRegionRepository.Update(filedsRegion, whereHelpersRegion, trans);
}
}
if (model.List != null && model.List.Any())
{
model.List.ForEach(x => x.TenantId = model.TenantId);
model.List.ForEach(x => x.CreateDate = System.DateTime.Now);
model.List.ForEach(x => x.ID = 0);
model.List.ForEach(x => x.RulesPriceId = rulesId);
model.List.ForEach(x => x.RulesType = model.RulesType);
model.List.ForEach(x => x.MallBaseId = model.MallBaseId);
logisticsRulesRegionRepository.InsertBatch(model.List, trans);
}
logisticsRulesRepository.DBSession.Commit();
}
catch (Exception ex)
{
LogHelper.Write(ex, "AddOrUpdatePinkage");
logisticsRulesRepository.DBSession.Rollback("AddOrUpdatePinkage");
return false;
}
return flag;
}
/// <summary>
/// 删除包邮规则
/// </summary>
/// <param name="gradeId"></param>
/// <param name="uid"></param>
/// <returns></returns>
public bool DelPinkageInfo(int id, int uid, int mallBaseId)
{
var trans = logisticsRulesRepository.DbTransaction;
bool flag;
try
{
Dictionary<string, object> cols = new Dictionary<string, object>()
{
{ nameof(RB_Logistics_Rules.Status),1},
{ nameof(RB_Logistics_Rules.UpdateDate),DateTime.Now},
};
List<WhereHelper> wheres1 = new List<WhereHelper>() {
new WhereHelper(){
FiledName=nameof(RB_Logistics_Rules.ID),
FiledValue=id,
OperatorEnum=OperatorEnum.Equal
},
new WhereHelper(){
FiledName=nameof(RB_Logistics_Rules.TenantId),
FiledValue=Convert.ToInt32(uid),
OperatorEnum=OperatorEnum.Equal
},
new WhereHelper(){
FiledName=nameof(RB_Logistics_Rules.MallBaseId),
FiledValue=Convert.ToInt32(mallBaseId),
OperatorEnum=OperatorEnum.Equal
},
new WhereHelper(){
FiledName=nameof(RB_Logistics_Rules.RulesType),
FiledValue=Convert.ToInt32(Common.Enum.MallBase.RulesTypeEnum.Pinkage),
OperatorEnum=OperatorEnum.Equal
}
};
flag = logisticsRulesRepository.Update(cols, wheres1, trans);
IDictionary<string, object> filedsRegion = new Dictionary<string, object>()//删除价格下面对应的地区
{
{ nameof(RB_Logistics_RulesRegion.Status),1},
{ nameof(RB_Logistics_RulesRegion.UpdateDate),System.DateTime.Now},
};
IList<WhereHelper> whereHelpersRegion = new List<WhereHelper>()
{
new WhereHelper (){ FiledName=nameof(RB_Logistics_RulesRegion.RulesPriceId),FiledValue=id,OperatorEnum=OperatorEnum.Equal},
new WhereHelper(){
FiledName=nameof(RB_Logistics_RulesRegion.TenantId),
FiledValue=Convert.ToInt32(uid),
OperatorEnum=OperatorEnum.Equal
},
new WhereHelper(){
FiledName=nameof(RB_Logistics_RulesRegion.MallBaseId),
FiledValue=Convert.ToInt32(mallBaseId),
OperatorEnum=OperatorEnum.Equal
},
new WhereHelper(){
FiledName=nameof(RB_Logistics_RulesRegion.RulesType),
FiledValue=Convert.ToInt32(Common.Enum.MallBase.RulesTypeEnum.Pinkage),
OperatorEnum=OperatorEnum.Equal
} };
flag = logisticsRulesRegionRepository.Update(filedsRegion, whereHelpersRegion, trans);
logisticsRulesRepository.DBSession.Commit();
}
catch (Exception ex)
{
LogHelper.Write(ex, "DelPinkageInfo");
logisticsRulesRepository.DBSession.Rollback("DelPinkageInfo");
return false;
}
return flag;
}
#endregion #endregion
} }
} }
...@@ -44,13 +44,13 @@ LEFT JOIN {DestinationTableName} as c on b.ParentID = c.ID WHERE a.{nameof(RB_ ...@@ -44,13 +44,13 @@ LEFT JOIN {DestinationTableName} as c on b.ParentID = c.ID WHERE a.{nameof(RB_
{ {
builder.Append($" AND a.{nameof(RB_GuideCar_SiteRegion_Extend.MallBaseId)}={query.MallBaseId}"); builder.Append($" AND a.{nameof(RB_GuideCar_SiteRegion_Extend.MallBaseId)}={query.MallBaseId}");
} }
if (query.RulesPriceId > 0) if (query.SiteId > 0)
{ {
builder.Append($" AND a.{nameof(RB_GuideCar_SiteRegion_Extend.RulesPriceId)}={query.RulesPriceId}"); builder.Append($" AND a.{nameof(RB_GuideCar_SiteRegion_Extend.SiteId)}={query.SiteId}");
} }
if (!string.IsNullOrWhiteSpace(query.PriceIds)) if (!string.IsNullOrWhiteSpace(query.SiteIds))
{ {
builder.Append($" AND a.{nameof(RB_GuideCar_SiteRegion_Extend.RulesPriceId)} in ({query.PriceIds})"); builder.Append($" AND a.{nameof(RB_GuideCar_SiteRegion_Extend.SiteId)} in ({query.SiteIds})");
} }
} }
return Get<RB_GuideCar_SiteRegion_Extend>(builder.ToString()).ToList(); return Get<RB_GuideCar_SiteRegion_Extend>(builder.ToString()).ToList();
...@@ -80,13 +80,13 @@ LEFT JOIN {DestinationTableName} as c on b.ParentID = c.ID WHERE a.{nameof(RB_ ...@@ -80,13 +80,13 @@ LEFT JOIN {DestinationTableName} as c on b.ParentID = c.ID WHERE a.{nameof(RB_
{ {
builder.Append($" AND a.{nameof(RB_GuideCar_SiteRegion_Extend.MallBaseId)}={query.MallBaseId}"); builder.Append($" AND a.{nameof(RB_GuideCar_SiteRegion_Extend.MallBaseId)}={query.MallBaseId}");
} }
if (query.RulesPriceId > 0) if (query.SiteId > 0)
{ {
builder.Append($" AND a.{nameof(RB_GuideCar_SiteRegion_Extend.RulesPriceId)}={query.RulesPriceId}"); builder.Append($" AND a.{nameof(RB_GuideCar_SiteRegion_Extend.SiteId)}={query.SiteId}");
} }
if (!string.IsNullOrWhiteSpace(query.PriceIds)) if (!string.IsNullOrWhiteSpace(query.SiteIds))
{ {
builder.Append($" AND a.{nameof(RB_GuideCar_SiteRegion_Extend.RulesPriceId)} in ({query.PriceIds})"); builder.Append($" AND a.{nameof(RB_GuideCar_SiteRegion_Extend.SiteId)} in ({query.SiteIds})");
} }
} }
return Get<RB_GuideCar_SiteRegion_Extend>(builder.ToString()).ToList(); return Get<RB_GuideCar_SiteRegion_Extend>(builder.ToString()).ToList();
......
using Mall.Model.Entity.GuideCar;
using Mall.Model.Extend.GuideCar;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Mall.Repository.GuideCar
{
public class RB_GuideCar_SiteRepository:BaseRepository<RB_GuideCar_Site>
{
/// <summary>
/// 表名称
/// </summary>
public string TableName { get { return nameof(RB_GuideCar_Site); } }
/// <summary>
/// 物料规则列表
/// </summary>
/// <param name="pageIndex">页码</param>
/// <param name="pageSize">每页显示条数</param>
/// <param name="rowCount">总条数</param>
/// <param name="query">查询条件</param>
/// <returns></returns>
public List<RB_GuideCar_Site_Extend> GetPageListRepository(int pageIndex, int pageSize, out long rowCount, RB_GuideCar_Site_Extend query)
{
StringBuilder builder = new StringBuilder();
builder.Append($" SELECT * FROM {TableName} WHERE {nameof(RB_GuideCar_Site_Extend.Status)}=0");
if (query != null)
{
// where += $@" and {nameof(RB_Customer_InfoCreate.CustomerId)}={dmodel.CustomerId}";
if (query.TenantId > 0)
{
builder.Append($" AND {nameof(RB_GuideCar_Site_Extend.TenantId)}={query.TenantId}");
}
if (query.TenantId > 0)
{
builder.Append($" AND {nameof(RB_GuideCar_Site_Extend.MallBaseId)}={query.MallBaseId}");
}
if (!string.IsNullOrWhiteSpace(query.SiteName))
{
builder.Append($" AND {nameof(RB_GuideCar_Site_Extend.SiteName)} like '%{query.SiteName}%'");
}
if (query.RulesType > 0)
{
builder.Append($" AND {nameof(RB_GuideCar_Site_Extend.RulesType)}={(int)query.RulesType}");
}
}
return GetPage<RB_GuideCar_Site_Extend>(pageIndex, pageSize, out rowCount, builder.ToString()).ToList();
}
/// <summary>
/// 物流规则列表
/// </summary>
/// <param name="pageIndex">页码</param>
/// <param name="pageSize">每页显示条数</param>
/// <param name="rowCount">总条数</param>
/// <param name="query">查询条件</param>
/// <returns></returns>
public List<RB_GuideCar_Site_Extend> GetLogisticsRulesList(RB_GuideCar_Site_Extend query)
{
StringBuilder builder = new StringBuilder();
builder.Append($" SELECT * FROM {TableName} WHERE {nameof(RB_GuideCar_Site_Extend.Status)}=0 ");
if (query != null)
{
if (query.ID > 0)
{
builder.Append($" AND {nameof(RB_GuideCar_Site_Extend.ID)}={query.ID}");
}
if (query.TenantId > 0)
{
builder.Append($" AND {nameof(RB_GuideCar_Site_Extend.TenantId)}={query.TenantId}");
}
if (query.MallBaseId > 0)
{
builder.Append($" AND {nameof(RB_GuideCar_Site_Extend.MallBaseId)}={query.MallBaseId}");
}
if (!string.IsNullOrWhiteSpace(query.SiteName))
{
builder.Append($" AND {nameof(RB_GuideCar_Site_Extend.SiteName)} like '%{query.SiteName}%'");
}
if (query.RulesType > 0)
{
builder.Append($" AND {nameof(RB_GuideCar_Site_Extend.RulesType)}={(int)query.RulesType}");
}
if (!string.IsNullOrEmpty(query.SiteIds))
{
builder.Append($" AND {nameof(RB_GuideCar_Site_Extend.ID)} in({query.SiteIds})");
}
}
return Get<RB_GuideCar_Site_Extend>(builder.ToString()).ToList();
}
}
}
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