Commit 57642925 authored by 吴春's avatar 吴春

提交物流规则

parent 51c9b061
using Mall.Common.Plugin;
using System;
using System.Collections.Generic;
using System.Text;
namespace Mall.Common.Enum.MallBase
{
public enum RulesTypeEnum
{
/// <summary>
/// 物流规则
/// </summary>
[EnumField("物流规则")]
Rule = 1,
/// <summary>
/// 包邮规则
/// </summary>
[EnumField("包邮规则")]
Pinkage = 2,
/// <summary>
/// 起送规则
/// </summary>
[EnumField("起送规则")]
OpenMinPrice = 3
}
}
using Mall.Common.AOP;
using Mall.Common.Enum.MallBase;
using System;
using System.Collections.Generic;
using System.Text;
......@@ -10,7 +11,7 @@ namespace Mall.Model.Entity.BaseSetUp
/// </summary>
[Serializable]
[DB(ConnectionName = "DefaultConnection")]
public class RB_LogisticsRules
public class RB_Logistics_Rules
{
public int ID { get; set; }
......@@ -44,6 +45,24 @@ namespace Mall.Model.Entity.BaseSetUp
public DateTime CreateDate { get; set; }
public DateTime UpdateDate { get; set; }
public DateTime DeletedDate { get; set; }
public RulesTypeEnum RulesType { get; set; }
/// <summary>
/// 是否开启起送规则
/// </summary>
public int IsOpenMinPrice { get; set; }
/// <summary>
/// 起送价格
/// </summary>
public int IsOpenAllRegionPrice { get; set; }
/// <summary>
/// 全地区起送金额
/// </summary>
public int AllRegionPrice { get; set; }
}
}
using Mall.Common.AOP;
using Mall.Common.Enum.MallBase;
using System;
using System.Collections.Generic;
using System.Text;
......@@ -10,7 +11,7 @@ namespace Mall.Model.Entity.BaseSetUp
/// </summary>
[Serializable]
[DB(ConnectionName = "DefaultConnection")]
public class RB_LogisticsRulesPrice
public class RB_Logistics_RulesPrice
{
public int ID { get; set; }
......@@ -58,6 +59,5 @@ namespace Mall.Model.Entity.BaseSetUp
public DateTime CreateDate { get; set; }
public DateTime UpdateDate { get; set; }
public DateTime DeletedDate { get; set; }
}
}
using Mall.Common.AOP;
using Mall.Common.Enum.MallBase;
using System;
using System.Collections.Generic;
using System.Text;
......@@ -10,7 +11,7 @@ namespace Mall.Model.Entity.BaseSetUp
/// </summary>
[Serializable]
[DB(ConnectionName = "DefaultConnection")]
public class RB_LogisticsRulesRegion
public class RB_Logistics_RulesRegion
{
/// <summary>
......@@ -37,11 +38,11 @@ namespace Mall.Model.Entity.BaseSetUp
public int MallBaseId { get; set; }
public RulesTypeEnum RulesType { get; set; }
public int Status { get; set; }
public DateTime CreateDate { get; set; }
public DateTime UpdateDate { get; set; }
public DateTime DeletedDate { get; set; }
}
}
......@@ -16,10 +16,9 @@ namespace Mall.Model.Entity.BaseSetUp
/// 编号
/// </summary>
public int ID { get; set; }
/// <summary>
/// 商城名称
/// </summary>
public string MallName { get; set; }
public int MallBaseId { get; set; }
/// <summary>
/// 联系号码
/// </summary>
......@@ -227,6 +226,101 @@ namespace Mall.Model.Entity.BaseSetUp
/// </summary>
public int SuspendBtn { get; set; }
/// <summary>
/// 1-展开收起,2-固定展开
/// </summary>
public int SuspendStyle { get; set; }
/// <summary>
/// 展开图标
/// </summary>
public string UnfoldIco { get; set; }
/// <summary>
/// 收起图标
/// </summary>
public string PackUpIco { get; set; }
/// <summary>
/// 在线客服开关,0-否,1-是
/// </summary>
public int OnlineService { get; set; }
/// <summary>
/// 在线客服图标
/// </summary>
public string OnlineServiceIco { get; set; }
/// <summary>
/// 返回首页导航开关,0-否,1-是
/// </summary>
public int BackTopNavigation { get; set; }
/// <summary>
/// 返回首页导航图标
/// </summary>
public string BackTopNavigationIco { get; set; }
/// <summary>
/// 一键拨号开关
/// </summary>
public int OneCall { get; set; }
/// <summary>
/// 一键拨号开关图标
/// </summary>
public string OneCallIco { get; set; }
/// <summary>
/// 客服外链开关
/// </summary>
public int ServiceOutLink { get; set; }
/// <summary>
/// 客服外链图标
/// </summary>
public string ServiceOutLinkIco { get; set; }
/// <summary>
/// 快捷导航开关
/// </summary>
public int ShortcutNavigation { get; set; }
/// <summary>
/// 快捷导航图标
/// </summary>
public string ShortcutNavigationIco { get; set; }
/// <summary>
/// 跳转小程序开关
/// </summary>
public int TurnMini { get; set; }
/// <summary>
/// 跳转小程序图标
/// </summary>
public string TurnMiniIco { get; set; }
/// <summary>
/// 自定义按钮
/// </summary>
public int Custom { get; set; }
/// <summary>
/// 跳转链接
/// </summary>
public string TurnLink { get; set; }
/// <summary>
/// 图标
/// </summary>
public int TurnIco { get; set; }
/// <summary>
/// 启用回到顶部悬浮按钮
/// </summary>
......@@ -261,14 +355,5 @@ namespace Mall.Model.Entity.BaseSetUp
/// </summary>
public int TenantId { get; set; }
/// <summary>
/// 有效期
/// </summary>
public DateTime? Indate { get; set; }
/// <summary>
/// 1-正常,2-禁用
/// </summary>
public int MallBaseState { get; set; }
}
}
......@@ -8,12 +8,12 @@ namespace Mall.Model.Extend.BaseSetUp
{
/// <summary>
/// 运费规则
/// 包邮规则
/// </summary>
[Serializable]
[DB(ConnectionName = "DefaultConnection")]
public class RB_LogisticsRules_Extend : RB_LogisticsRules
public class RB_Logistics_Pinkage_Extend : RB_Logistics_Pinkage
{
public List<RB_LogisticsRulesPrice_Extend> Detail { get; set; }
public List<RB_Logistics_RulesRegion_Extend> List { get; set; }
}
}
......@@ -11,8 +11,8 @@ namespace Mall.Model.Extend.BaseSetUp
/// </summary>
[Serializable]
[DB(ConnectionName = "DefaultConnection")]
public class RB_LogisticsRulesPrice_Extend : RB_LogisticsRulesPrice
public class RB_Logistics_RulesPrice_Extend : RB_Logistics_RulesPrice
{
public List<RB_LogisticsRulesRegion_Extend> List { get; set; }
public List<RB_Logistics_RulesRegion_Extend> List { get; set; }
}
}
......@@ -11,7 +11,7 @@ namespace Mall.Model.Extend.BaseSetUp
/// </summary>
[Serializable]
[DB(ConnectionName = "DefaultConnection")]
public class RB_LogisticsRulesRegion_Extend : RB_LogisticsRulesRegion
public class RB_Logistics_RulesRegion_Extend : RB_Logistics_RulesRegion
{
/// <summary>
/// 地区名字
......
using Mall.Common.AOP;
using Mall.Model.Entity.BaseSetUp;
using System;
using System.Collections.Generic;
using System.Text;
namespace Mall.Model.Extend.BaseSetUp
{
/// <summary>
/// 运费规则
/// </summary>
[Serializable]
[DB(ConnectionName = "DefaultConnection")]
public class RB_Logistics_Rules_Extend : RB_Logistics_Rules
{
public List<RB_Logistics_RulesPrice_Extend> Detail { get; set; }
public List<RB_Logistics_RulesRegion_Extend> List { get; set; }
}
}
......@@ -13,6 +13,9 @@ namespace Mall.Model.Extend.BaseSetUp
[DB(ConnectionName = "DefaultConnection")]
public class RB_MallBase_Extend : RB_MallBase
{
/// <summary>
/// 商城名称
/// </summary>
public string MallName { get; set; }
}
}
......@@ -4,6 +4,10 @@
<TargetFramework>netcoreapp3.0</TargetFramework>
</PropertyGroup>
<ItemGroup>
<Compile Remove="Extend\BaseSetUp\RB_Logistics_Pinkage_Extend.cs" />
</ItemGroup>
<ItemGroup>
<Folder Include="CacheEntity\" />
</ItemGroup>
......
using Mall.Model.Entity.BaseSetUp;
using Mall.Common.Plugin;
using Mall.Model.Entity.BaseSetUp;
using Mall.Model.Entity.User;
using Mall.Model.Extend.BaseSetUp;
using Mall.Repository;
using Mall.Repository.BaseSetUp;
using Mall.Repository.User;
using System;
using System.Collections.Generic;
using System.Linq;
......@@ -10,11 +14,13 @@ namespace Mall.Module.BaseSetUp
{
public class MallBaseModule
{
private RB_MiniProgramRepository miniProgramRepository = new RB_MiniProgramRepository();
private RB_MallBaseRepository mallBaseRepository = new RB_MallBaseRepository();
private RB_LogisticsRepository logisticsRepository = new RB_LogisticsRepository();
private RB_LogisticsRulesPriceRepository logisticsRulesPriceRepository = new RB_LogisticsRulesPriceRepository();
private RB_LogisticsRulesRegionRepository logisticsRulesRegionRepository = new RB_LogisticsRulesRegionRepository();
private RB_LogisticsRulesRepository logisticsRulesRepository = new RB_LogisticsRulesRepository();
private RB_Logistics_RulesPriceRepository logisticsRulesPriceRepository = new RB_Logistics_RulesPriceRepository();
private RB_Logistics_RulesRegionRepository logisticsRulesRegionRepository = new RB_Logistics_RulesRegionRepository();
private RB_Logistics_RulesRepository logisticsRulesRepository = new RB_Logistics_RulesRepository();
#region 基础设置
/// <summary>
......@@ -50,6 +56,7 @@ namespace Mall.Module.BaseSetUp
public RB_MallBase GetMallBaseEntity(int ID)
{
return mallBaseRepository.GetEntity(ID);
}
......@@ -59,16 +66,39 @@ namespace Mall.Module.BaseSetUp
/// </summary>
/// <param name="model"></param>
/// <returns></returns>
public bool AddOrUpdateMallBase(RB_MallBase model)
public bool AddOrUpdateMallBase(RB_MallBase_Extend model)
{
if (model.ID == 0)
bool flag = false;
var trans = mallBaseRepository.DbTransaction;
try
{
return mallBaseRepository.Insert(model) > 0;
if (model.ID == 0)
{
flag = mallBaseRepository.Insert(model) > 0;
}
else
{
flag = mallBaseRepository.Update(model);
}
IDictionary<string, object> fileds = new Dictionary<string, object>()
{
{ nameof(RB_MiniProgram.MallName),model.MallName},
};
IList<WhereHelper> whereHelpers = new List<WhereHelper>()
{
new WhereHelper (){ FiledName=nameof(RB_MiniProgram.MallBaseId),FiledValue=model.MallBaseId,OperatorEnum=OperatorEnum.Equal}
};
miniProgramRepository.Update(fileds, whereHelpers, trans);
mallBaseRepository.DBSession.Commit();
}
else
catch (Exception ex)
{
return mallBaseRepository.Update(model);
LogHelper.Write(ex, "SetDefaultLogisticsRules");
mallBaseRepository.DBSession.Rollback("SetDefaultLogisticsRules");
return false;
}
return flag;
}
#endregion
......@@ -112,7 +142,7 @@ namespace Mall.Module.BaseSetUp
/// <param name="rowCount">总条数</param>
/// <param name="query">查询条件</param>
/// <returns></returns>
public List<RB_LogisticsRules_Extend> GetPageListRepository(int pageIndex, int pageSize, out long rowCount, RB_LogisticsRules_Extend query)
public List<RB_Logistics_Rules_Extend> GetLogisticsRulesList(int pageIndex, int pageSize, out long rowCount, RB_Logistics_Rules_Extend query)
{
return logisticsRulesRepository.GetPageListRepository(pageIndex, pageSize, out rowCount, query);
}
......@@ -125,31 +155,481 @@ namespace Mall.Module.BaseSetUp
/// <param name="rowCount">总条数</param>
/// <param name="query">查询条件</param>
/// <returns></returns>
public List<RB_LogisticsRules_Extend> GetLogisticsRulesList(RB_LogisticsRules_Extend query)
public List<RB_Logistics_Rules_Extend> GetLogisticsRulesList(RB_Logistics_Rules_Extend query)
{
return logisticsRulesRepository.GetLogisticsRulesList(query);
}
public RB_LogisticsRules_Extend GetLogisticsRulesModel(RB_LogisticsRules_Extend query)
public RB_Logistics_Rules_Extend GetLogisticsRulesModel(RB_Logistics_Rules_Extend query)
{
RB_LogisticsRules_Extend model = logisticsRulesRepository.GetLogisticsRulesList(query).FirstOrDefault();
RB_Logistics_Rules_Extend model = logisticsRulesRepository.GetLogisticsRulesList(query).FirstOrDefault();
//获取价格规则
List<RB_LogisticsRulesPrice_Extend> ListPrice = logisticsRulesPriceRepository.GetListRepository(new RB_LogisticsRulesPrice_Extend { TenantId = query.TenantId, MallBaseId = query.MallBaseId, RulesId = query.ID });
List<RB_Logistics_RulesPrice_Extend> ListPrice = logisticsRulesPriceRepository.GetListRepository(new RB_Logistics_RulesPrice_Extend { TenantId = query.TenantId, MallBaseId = query.MallBaseId, RulesId = query.ID });
List<RB_LogisticsRulesRegion_Extend> listLogisticsRulesRegion = logisticsRulesRegionRepository.GetListRepository(new RB_LogisticsRulesRegion_Extend { TenantId = query.TenantId, MallBaseId = query.MallBaseId, PriceIds = string.Join(",", ListPrice.Select(x => x.ID)) });
List<RB_Logistics_RulesRegion_Extend> listLogisticsRulesRegion = logisticsRulesRegionRepository.GetListRepository(new RB_Logistics_RulesRegion_Extend { TenantId = query.TenantId, RulesType = Common.Enum.MallBase.RulesTypeEnum.Rule, MallBaseId = query.MallBaseId, PriceIds = string.Join(",", ListPrice.Select(x => x.ID)) });
model.Detail = new List<RB_LogisticsRulesPrice_Extend>();
model.Detail = new List<RB_Logistics_RulesPrice_Extend>();
model.Detail = ListPrice;
foreach (var item in model.Detail)
{
item.List = new List<RB_LogisticsRulesRegion_Extend>();
item.List = new List<RB_Logistics_RulesRegion_Extend>();
item.List = listLogisticsRulesRegion.Where(x => x.RulesPriceId == item.ID).ToList();
}
return model;
}
public bool SetDefaultLogisticsRules(RB_Logistics_Rules_Extend query)
{
bool flag = false;
var trans = logisticsRulesRepository.DbTransaction;
try
{
IDictionary<string, object> fileds = new Dictionary<string, object>()
{
{ nameof(RB_Logistics_Rules.IsDefault),0},
};
IList<WhereHelper> whereHelpers = new List<WhereHelper>()
{
new WhereHelper (){ FiledName=nameof(RB_Logistics_Rules.MallBaseId),FiledValue=query.MallBaseId,OperatorEnum=OperatorEnum.Equal}
};
logisticsRulesPriceRepository.Update(fileds, whereHelpers, trans);
IDictionary<string, object> filedsDefault = new Dictionary<string, object>()
{
{ nameof(RB_Logistics_Rules.IsDefault),1},
};
IList<WhereHelper> whereHelpersDefault = new List<WhereHelper>()
{
new WhereHelper (){ FiledName=nameof(RB_Logistics_Rules.ID),FiledValue=query.ID,OperatorEnum=OperatorEnum.Equal}
};
logisticsRulesPriceRepository.Update(filedsDefault, whereHelpersDefault, trans);
logisticsRulesRepository.DBSession.Commit();
}
catch (Exception ex)
{
LogHelper.Write(ex, "SetDefaultLogisticsRules");
logisticsRulesRepository.DBSession.Rollback("SetDefaultLogisticsRules");
return false;
}
return flag;
}
/// <summary>
/// 新增/修改基础信息
/// </summary>
/// <param name="model"></param>
/// <returns></returns>
public bool AddOrUpdateLogisticsRules(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);
if (model.Detail != null && model.Detail.Any())
{
foreach (var item in model.Detail)
{
item.RulesId = rulesId;
item.TenantId = model.TenantId;
item.MallBaseId = model.MallBaseId;
int priceId = logisticsRulesPriceRepository.Insert(item, trans);
item.List.ForEach(x => x.RulesPriceId = priceId);
item.List.ForEach(x => x.TenantId = model.TenantId);
item.List.ForEach(x => x.RulesType = Common.Enum.MallBase.RulesTypeEnum.Rule);
item.List.ForEach(x => x.MallBaseId = model.MallBaseId);
item.List.ForEach(x => x.CreateDate = System.DateTime.Now);
flag = logisticsRulesRegionRepository.InsertBatch(item.List, trans);
}
}
}
else
{
rulesId = model.ID;
flag = logisticsRulesRepository.Update(model, trans);
//获取价格规则
List<RB_Logistics_RulesPrice_Extend> ListPrice = logisticsRulesPriceRepository.GetListRepository(new RB_Logistics_RulesPrice_Extend { TenantId = model.TenantId, MallBaseId = model.MallBaseId, RulesId = model.ID });
List<RB_Logistics_RulesRegion_Extend> listLogisticsRulesRegion = new List<RB_Logistics_RulesRegion_Extend>();
if (ListPrice != null && ListPrice.Any())
{
listLogisticsRulesRegion = logisticsRulesRegionRepository.GetListRepository(new RB_Logistics_RulesRegion_Extend { TenantId = model.TenantId, RulesType = model.RulesType, MallBaseId = model.MallBaseId, PriceIds = string.Join(",", ListPrice.Select(x => x.ID)) });
}
//比较之前有的现在没有的价格
List<string> notPriceList = new List<string>();
notPriceList = ListPrice.Select(x => x.ID.ToString()).Except(model.Detail.Select(x => x.ID.ToString())).ToList();
var deletePriceList = ListPrice.Where(x => notPriceList.Contains(x.ID.ToString()));
foreach (var item in deletePriceList)//删除之前有现在没有的数据
{
IDictionary<string, object> fileds = new Dictionary<string, object>()
{
{ nameof(RB_Logistics_RulesPrice.Status),1},
};
IList<WhereHelper> whereHelpers = new List<WhereHelper>()
{
new WhereHelper (){ FiledName=nameof(RB_Logistics_RulesPrice.ID),FiledValue=item.ID,OperatorEnum=OperatorEnum.Equal}
};
flag = logisticsRulesPriceRepository.Update(fileds, whereHelpers, trans);
if (listLogisticsRulesRegion != null && listLogisticsRulesRegion.Any())
{
foreach (var itemRegion in listLogisticsRulesRegion.Where(x => x.RulesPriceId == item.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}
};
flag = logisticsRulesRegionRepository.Update(filedsRegion, whereHelpersRegion, trans);
}
}
}
foreach (var item in model.Detail)
{
item.RulesId = rulesId;
item.TenantId = model.TenantId;
item.MallBaseId = model.MallBaseId;
int priceId = 0;
if (item.ID == 0)
{
priceId = logisticsRulesPriceRepository.Insert(item, trans);
}
else
{
priceId = item.ID;
flag = logisticsRulesPriceRepository.Update(item, trans);
//删除之前的区域
foreach (var itemRegion in listLogisticsRulesRegion.Where(x => x.RulesPriceId == item.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}
};
flag = logisticsRulesRegionRepository.Update(filedsRegion, whereHelpersRegion, trans);
}
//比较之前有的现在没有的价格
//List<string> notRegionList = new List<string>();
//notRegionList = listLogisticsRulesRegion.Where(x => x.RulesPriceId == item.ID).Select(x => x.ID.ToString()).Except(item.List.Select(x => x.ID.ToString())).ToList();
//var deleteRegionList = listLogisticsRulesRegion.Where(x => x.RulesPriceId == item.ID).Where(x => notRegionList.Contains(x.ID.ToString()));
//foreach (var itemRegion in deleteRegionList)
//{
// IDictionary<string, object> filedsRegion = new Dictionary<string, object>()//删除价格下面对应的地区
// {
// { nameof(RB_LogisticsRulesRegion.Status),1},
// };
// IList<WhereHelper> whereHelpersRegion = new List<WhereHelper>()
// {
// new WhereHelper (){ FiledName=nameof(RB_LogisticsRulesRegion.ID),FiledValue=itemRegion.ID,OperatorEnum=OperatorEnum.Equal}
// };
// logisticsRulesRegionRepository.Update(filedsRegion, whereHelpersRegion, trans);
//}
}
item.List.ForEach(x => x.RulesPriceId = priceId);
item.List.ForEach(x => x.CreateDate = System.DateTime.Now);
item.List.ForEach(x => x.ID = 0);
item.List.ForEach(x => x.TenantId = model.TenantId);
item.List.ForEach(x => x.RulesType = model.RulesType);
item.List.ForEach(x => x.MallBaseId = model.MallBaseId);
flag = logisticsRulesRegionRepository.InsertBatch(item.List, trans);
}
}
logisticsRulesRepository.DBSession.Commit();
}
catch (Exception ex)
{
LogHelper.Write(ex, "AddOrUpdateLogisticsRules");
logisticsRulesRepository.DBSession.Rollback("AddOrUpdateLogisticsRules");
return false;
}
return flag;
}
/// <summary>
/// 删除物流规则
/// </summary>
/// <param name="gradeId"></param>
/// <param name="uid"></param>
/// <returns></returns>
public bool DelRulesInfo(int id, int uid, int mallBaseId)
{
bool flag = false;
var trans = logisticsRulesRepository.DbTransaction;
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
}
};
flag = logisticsRulesRepository.Update(cols, wheres1, trans);
//获取价格规则
List<RB_Logistics_RulesPrice_Extend> ListPrice = logisticsRulesPriceRepository.GetListRepository(new RB_Logistics_RulesPrice_Extend { TenantId = uid, MallBaseId = mallBaseId, RulesId = id });
foreach (var item in ListPrice)
{
IDictionary<string, object> fileds = new Dictionary<string, object>()
{
{ nameof(RB_Logistics_RulesPrice.Status),1},
};
IList<WhereHelper> whereHelpers = new List<WhereHelper>()
{
new WhereHelper (){ FiledName=nameof(RB_Logistics_RulesPrice.ID),FiledValue=item.ID,OperatorEnum=OperatorEnum.Equal}
};
flag = logisticsRulesPriceRepository.Update(fileds, whereHelpers, 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=item.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.Rule),
OperatorEnum=OperatorEnum.Equal
} };
flag = logisticsRulesRegionRepository.Update(filedsRegion, whereHelpersRegion, trans);
}
logisticsRulesRepository.DBSession.Commit();
}
catch (Exception ex)
{
LogHelper.Write(ex, "DelRulesInfo");
logisticsRulesRepository.DBSession.Rollback("DelRulesInfo");
return false;
}
return flag;
}
#endregion
#region 包邮规则
/// <summary>
/// 包邮规则列表
/// </summary>
/// <param name="pageIndex">页码</param>
/// <param name="pageSize">每页显示条数</param>
/// <param name="rowCount">总条数</param>
/// <param name="query">查询条件</param>
/// <returns></returns>
public List<RB_Logistics_Rules_Extend> GetLogisticsPinkageList(int pageIndex, int pageSize, out long rowCount, RB_Logistics_Rules_Extend query)
{
List<RB_Logistics_Rules_Extend> list = logisticsRulesRepository.GetPageListRepository(pageIndex, pageSize, out rowCount, query);
if (list != null && list.Any())
{
List<RB_Logistics_RulesRegion_Extend> listLogisticsRulesRegion = logisticsRulesRegionRepository.GetListRepository(new RB_Logistics_RulesRegion_Extend { TenantId = query.TenantId, RulesType = Common.Enum.MallBase.RulesTypeEnum.Pinkage, MallBaseId = query.MallBaseId, PriceIds = string.Join(",", list.Select(x => x.ID)) });
foreach (var item in list)
{
item.List = new List<RB_Logistics_RulesRegion_Extend>();
item.List = listLogisticsRulesRegion.Where(x => x.RulesPriceId == item.ID).ToList();
}
}
return list;
}
/// <summary>
/// 包邮实体
/// </summary>
/// <param name="query"></param>
/// <returns></returns>
public RB_Logistics_Rules_Extend GetPinkageModel(RB_Logistics_Rules_Extend query)
{
RB_Logistics_Rules_Extend model = logisticsRulesRepository.GetLogisticsRulesList(query).FirstOrDefault();
List<RB_Logistics_RulesRegion_Extend> listLogisticsRulesRegion = logisticsRulesRegionRepository.GetListRepository(new RB_Logistics_RulesRegion_Extend { TenantId = query.TenantId, RulesType = Common.Enum.MallBase.RulesTypeEnum.Pinkage, 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);
}
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 = Common.Enum.MallBase.RulesTypeEnum.Pinkage, 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}
};
flag = logisticsRulesRegionRepository.Update(filedsRegion, whereHelpersRegion, trans);
}
}
model.List.ForEach(x => x.TenantId = rulesId);
model.List.ForEach(x => x.CreateDate = System.DateTime.Now);
model.List.ForEach(x => x.ID = 0);
model.List.ForEach(x => x.RulesPriceId = model.TenantId);
model.List.ForEach(x => x.RulesType = Common.Enum.MallBase.RulesTypeEnum.Pinkage);
model.List.ForEach(x => x.MallBaseId = model.MallBaseId);
flag = 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)
{
bool flag = false;
var trans = logisticsRulesRepository.DbTransaction;
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
}
......
using Mall.Model.Entity.BaseSetUp;
using Mall.Model.Extend.BaseSetUp;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Mall.Repository.BaseSetUp
{
public class RB_Logistics_PinkageRepository : RepositoryBase<RB_Logistics_Pinkage>
{
/// <summary>
/// 表名称
/// </summary>
public string TableName { get { return nameof(RB_Logistics_Pinkage); } }
/// <summary>
/// 物料规则列表
/// </summary>
/// <param name="pageIndex">页码</param>
/// <param name="pageSize">每页显示条数</param>
/// <param name="rowCount">总条数</param>
/// <param name="query">查询条件</param>
/// <returns></returns>
public List<RB_Logistics_Pinkage_Extend> GetPageListRepository(int pageIndex, int pageSize, out long rowCount, RB_Logistics_Pinkage_Extend query)
{
StringBuilder builder = new StringBuilder();
builder.Append($" SELECT * FROM {TableName} WHERE {nameof(RB_Logistics_Pinkage_Extend.Status)}=0");
if (query != null)
{
if (query.TenantId > 0)
{
builder.Append($" AND {nameof(RB_Logistics_Pinkage_Extend.TenantId)}={query.TenantId}");
}
if (query.TenantId > 0)
{
builder.Append($" AND {nameof(RB_Logistics_Pinkage_Extend.MallBaseId)}={query.MallBaseId}");
}
if (!string.IsNullOrWhiteSpace(query.Name))
{
builder.Append($" AND {nameof(RB_Logistics_Pinkage_Extend.Name)} like '%{query.Name}%'");
}
}
return GetPage<RB_Logistics_Pinkage_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_Logistics_Pinkage_Extend> GetLogisticsRulesList(RB_Logistics_Pinkage_Extend query)
{
StringBuilder builder = new StringBuilder();
builder.Append($" SELECT * FROM {TableName} WHERE {nameof(RB_Logistics_Pinkage_Extend.Status)}=0 ");
if (query != null)
{
if (query.ID > 0)
{
builder.Append($" AND {nameof(RB_Logistics_Pinkage_Extend.ID)}={query.ID}");
}
if (query.TenantId > 0)
{
builder.Append($" AND {nameof(RB_Logistics_Pinkage_Extend.TenantId)}={query.TenantId}");
}
if (query.TenantId > 0)
{
builder.Append($" AND {nameof(RB_Logistics_Pinkage_Extend.MallBaseId)}={query.MallBaseId}");
}
if (!string.IsNullOrWhiteSpace(query.Name))
{
builder.Append($" AND {nameof(RB_Logistics_Pinkage_Extend.Name)} like '%{query.Name}%'");
}
}
return Get<RB_Logistics_Pinkage_Extend>(builder.ToString()).ToList();
}
}
}
......@@ -7,38 +7,39 @@ using System.Text;
namespace Mall.Repository.BaseSetUp
{
public class RB_LogisticsRulesPriceRepository:RepositoryBase<RB_LogisticsRulesPrice>
public class RB_Logistics_RulesPriceRepository:RepositoryBase<RB_Logistics_RulesPrice>
{
/// <summary>
/// 表名称
/// </summary>
public string TableName { get { return nameof(RB_LogisticsRulesPrice); } }
public string TableName { get { return nameof(RB_Logistics_RulesPrice); } }
/// <summary>
/// 获取小程序列表
/// </summary>
/// <param name="query">查询条件</param>
/// <returns></returns>
public List<RB_LogisticsRulesPrice_Extend> GetListRepository(RB_LogisticsRulesPrice_Extend query)
public List<RB_Logistics_RulesPrice_Extend> GetListRepository(RB_Logistics_RulesPrice_Extend query)
{
StringBuilder builder = new StringBuilder();
builder.Append($" SELECT * FROM {TableName} WHERE 1=1 ");
builder.Append($" SELECT * FROM {TableName} WHERE {nameof(RB_Logistics_RulesPrice_Extend.Status)}=0");
if (query != null)
{
if (query.TenantId > 0)
{
builder.Append($" AND {nameof(RB_LogisticsRulesPrice_Extend.TenantId)}={query.TenantId}");
builder.Append($" AND {nameof(RB_Logistics_RulesPrice_Extend.TenantId)}={query.TenantId}");
}
if (query.TenantId > 0)
{
builder.Append($" AND {nameof(RB_LogisticsRulesPrice_Extend.MallBaseId)}={query.MallBaseId}");
builder.Append($" AND {nameof(RB_Logistics_RulesPrice_Extend.MallBaseId)}={query.MallBaseId}");
}
if (query.RulesId > 0)
{
builder.Append($" AND {nameof(RB_LogisticsRulesPrice_Extend.RulesId)}={query.RulesId}");
builder.Append($" AND {nameof(RB_Logistics_RulesPrice_Extend.RulesId)}={query.RulesId}");
}
}
return Get<RB_LogisticsRulesPrice_Extend>(builder.ToString()).ToList();
return Get<RB_Logistics_RulesPrice_Extend>(builder.ToString()).ToList();
}
}
}
......@@ -7,12 +7,12 @@ using System.Text;
namespace Mall.Repository.BaseSetUp
{
public class RB_LogisticsRulesRegionRepository : RepositoryBase<RB_LogisticsRulesRegion>
public class RB_Logistics_RulesRegionRepository : RepositoryBase<RB_Logistics_RulesRegion>
{
// <summary>
/// 表名称
/// </summary>
public string TableName { get { return nameof(RB_LogisticsRulesRegion); } }
public string TableName { get { return nameof(RB_Logistics_RulesRegion); } }
// <summary>
/// 表名称
......@@ -20,34 +20,41 @@ namespace Mall.Repository.BaseSetUp
public string DestinationTableName { get { return nameof(RB_Destination); } }
/// <summary>
/// 获取小程序列表
/// 获取物流地区列表
/// </summary>
/// <param name="query">查询条件</param>
/// <returns></returns>
public List<RB_LogisticsRulesRegion_Extend> GetListRepository(RB_LogisticsRulesRegion_Extend query)
public List<RB_Logistics_RulesRegion_Extend> GetListRepository(RB_Logistics_RulesRegion_Extend query)
{
StringBuilder builder = new StringBuilder();
builder.Append($" SELECT a.*,b.`Name` as RegionName FROM {TableName} as a LEFT JOIN {DestinationTableName} as b on a.RegionId=b.ID WHERE 1=1 ");
builder.Append($" SELECT a.*,b.`Name` as RegionName FROM {TableName} as a LEFT JOIN {DestinationTableName} as b on a.RegionId=b.ID WHERE a.{nameof(RB_Logistics_RulesRegion_Extend.Status)}=0");
if (query != null)
{
if (query.TenantId > 0)
{
builder.Append($" AND a.{nameof(RB_LogisticsRulesRegion_Extend.TenantId)}={query.TenantId}");
builder.Append($" AND a.{nameof(RB_Logistics_RulesRegion_Extend.TenantId)}={query.TenantId}");
}
if (query.RulesType > 0)
{
builder.Append($" AND a.{nameof(RB_Logistics_RulesRegion_Extend.RulesType)}={(int)query.RulesType}");
}
if (query.TenantId > 0)
{
builder.Append($" AND a.{nameof(RB_LogisticsRulesRegion_Extend.MallBaseId)}={query.MallBaseId}");
builder.Append($" AND a.{nameof(RB_Logistics_RulesRegion_Extend.MallBaseId)}={query.MallBaseId}");
}
if (query.RulesPriceId > 0)
{
builder.Append($" AND a.{nameof(RB_LogisticsRulesRegion_Extend.RulesPriceId)}={query.RulesPriceId}");
builder.Append($" AND a.{nameof(RB_Logistics_RulesRegion_Extend.RulesPriceId)}={query.RulesPriceId}");
}
if (!string.IsNullOrWhiteSpace(query.PriceIds))
{
builder.Append($" AND a.{nameof(RB_LogisticsRulesRegion_Extend.RulesPriceId)} in ({query.PriceIds})");
builder.Append($" AND a.{nameof(RB_Logistics_RulesRegion_Extend.RulesPriceId)} in ({query.PriceIds})");
}
}
return Get<RB_LogisticsRulesRegion_Extend>(builder.ToString()).ToList();
return Get<RB_Logistics_RulesRegion_Extend>(builder.ToString()).ToList();
}
}
}
......@@ -7,12 +7,12 @@ using System.Text;
namespace Mall.Repository.BaseSetUp
{
public class RB_LogisticsRulesRepository : RepositoryBase<RB_LogisticsRules>
public class RB_Logistics_RulesRepository : RepositoryBase<RB_Logistics_Rules>
{
/// <summary>
/// 表名称
/// </summary>
public string TableName { get { return nameof(RB_LogisticsRules); } }
public string TableName { get { return nameof(RB_Logistics_Rules); } }
/// <summary>
/// 物料规则列表
/// </summary>
......@@ -21,27 +21,31 @@ namespace Mall.Repository.BaseSetUp
/// <param name="rowCount">总条数</param>
/// <param name="query">查询条件</param>
/// <returns></returns>
public List<RB_LogisticsRules_Extend> GetPageListRepository(int pageIndex, int pageSize, out long rowCount, RB_LogisticsRules_Extend query)
public List<RB_Logistics_Rules_Extend> GetPageListRepository(int pageIndex, int pageSize, out long rowCount, RB_Logistics_Rules_Extend query)
{
StringBuilder builder = new StringBuilder();
builder.Append($" SELECT * FROM {TableName} WHERE 1=1 ");
builder.Append($" SELECT * FROM {TableName} WHERE {nameof(RB_Logistics_Rules_Extend.Status)}=0");
if (query != null)
{
// where += $@" and {nameof(RB_Customer_InfoCreate.CustomerId)}={dmodel.CustomerId}";
if (query.TenantId > 0)
{
builder.Append($" AND {nameof(RB_LogisticsRules_Extend.TenantId)}={query.TenantId}");
builder.Append($" AND {nameof(RB_Logistics_Rules_Extend.TenantId)}={query.TenantId}");
}
if (query.TenantId > 0)
{
builder.Append($" AND {nameof(RB_LogisticsRules_Extend.MallBaseId)}={query.MallBaseId}");
builder.Append($" AND {nameof(RB_Logistics_Rules_Extend.MallBaseId)}={query.MallBaseId}");
}
if (!string.IsNullOrWhiteSpace(query.RulesName))
{
builder.Append($" AND {nameof(RB_LogisticsRules_Extend.RulesName)} like '%{query.RulesName}%'");
builder.Append($" AND {nameof(RB_Logistics_Rules_Extend.RulesName)} like '%{query.RulesName}%'");
}
if (query.RulesType > 0)
{
builder.Append($" AND a.{nameof(RB_Logistics_Rules_Extend.RulesType)}={(int)query.RulesType}");
}
}
return GetPage<RB_LogisticsRules_Extend>(pageIndex, pageSize, out rowCount, builder.ToString()).ToList();
return GetPage<RB_Logistics_Rules_Extend>(pageIndex, pageSize, out rowCount, builder.ToString()).ToList();
}
......@@ -53,30 +57,34 @@ namespace Mall.Repository.BaseSetUp
/// <param name="rowCount">总条数</param>
/// <param name="query">查询条件</param>
/// <returns></returns>
public List<RB_LogisticsRules_Extend> GetLogisticsRulesList( RB_LogisticsRules_Extend query)
public List<RB_Logistics_Rules_Extend> GetLogisticsRulesList( RB_Logistics_Rules_Extend query)
{
StringBuilder builder = new StringBuilder();
builder.Append($" SELECT * FROM {TableName} WHERE 1=1 ");
builder.Append($" SELECT * FROM {TableName} WHERE {nameof(RB_Logistics_Rules_Extend.Status)}=0 ");
if (query != null)
{
if (query.ID > 0)
{
builder.Append($" AND {nameof(RB_LogisticsRules_Extend.ID)}={query.ID}");
builder.Append($" AND {nameof(RB_Logistics_Rules_Extend.ID)}={query.ID}");
}
if (query.TenantId > 0)
{
builder.Append($" AND {nameof(RB_LogisticsRules_Extend.TenantId)}={query.TenantId}");
builder.Append($" AND {nameof(RB_Logistics_Rules_Extend.TenantId)}={query.TenantId}");
}
if (query.TenantId > 0)
{
builder.Append($" AND {nameof(RB_LogisticsRules_Extend.MallBaseId)}={query.MallBaseId}");
builder.Append($" AND {nameof(RB_Logistics_Rules_Extend.MallBaseId)}={query.MallBaseId}");
}
if (!string.IsNullOrWhiteSpace(query.RulesName))
{
builder.Append($" AND {nameof(RB_LogisticsRules_Extend.RulesName)} like '%{query.RulesName}%'");
builder.Append($" AND {nameof(RB_Logistics_Rules_Extend.RulesName)} like '%{query.RulesName}%'");
}
if (query.RulesType > 0)
{
builder.Append($" AND a.{nameof(RB_Logistics_Rules_Extend.RulesType)}={(int)query.RulesType}");
}
}
return Get<RB_LogisticsRules_Extend>(builder.ToString()).ToList();
return Get<RB_Logistics_Rules_Extend>(builder.ToString()).ToList();
}
}
}
using Mall.Model.Entity.BaseSetUp;
using Mall.Model.Entity.User;
using Mall.Model.Extend.BaseSetUp;
using System;
using System.Collections.Generic;
......@@ -13,6 +14,11 @@ namespace Mall.Repository.BaseSetUp
/// 表名称
/// </summary>
public string TableName { get { return nameof(RB_MallBase); } }
/// <summary>
/// 表名称
/// </summary>
public string MinTableName { get { return nameof(RB_MiniProgram); } }
/// <summary>
/// 获取小程序列表
/// </summary>
......@@ -27,10 +33,14 @@ namespace Mall.Repository.BaseSetUp
builder.Append($" SELECT * FROM {TableName} WHERE 1=1 ");
if (query != null)
{
// where += $@" and {nameof(RB_Customer_InfoCreate.CustomerId)}={dmodel.CustomerId}";
// where += $@" and ={dmodel.CustomerId}";
if (query.TenantId > 0)
{
builder.Append($" AND TenantId={query.TenantId}");
builder.Append($" AND {nameof(RB_MallBase_Extend.TenantId)}={query.TenantId}");
}
if (query.MallBaseId > 0)
{
builder.Append($" AND {nameof(RB_MallBase_Extend.MallBaseId)}={query.MallBaseId}");
}
}
return GetPage<RB_MallBase_Extend>(pageIndex, pageSize, out rowCount, builder.ToString()).ToList();
......@@ -44,12 +54,16 @@ namespace Mall.Repository.BaseSetUp
public List<RB_MallBase_Extend> GetListRepository(RB_MallBase_Extend query)
{
StringBuilder builder = new StringBuilder();
builder.Append($" SELECT * FROM {TableName} WHERE 1=1 ");
builder.Append($" SELECT a.*,b.MallName FROM {TableName} as a LEFT join {MinTableName} as b on a.MallBaseId=b.MallBaseId WHERE 1=1 ");
if (query != null)
{
if (query.TenantId > 0)
{
builder.Append($" AND TenantId={query.TenantId}");
builder.Append($" AND {nameof(RB_MallBase_Extend.TenantId)}={query.TenantId}");
}
if (query.MallBaseId > 0)
{
builder.Append($" AND {nameof(RB_MallBase_Extend.MallBaseId)}={query.MallBaseId}");
}
}
return Get<RB_MallBase_Extend>( builder.ToString()).ToList();
......
......@@ -4,6 +4,10 @@
<TargetFramework>netcoreapp3.0</TargetFramework>
</PropertyGroup>
<ItemGroup>
<Compile Remove="BaseSetUp\RB_Logistics_PinkageRepository.cs" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore" Version="2.2.0" />
<PackageReference Include="Microsoft.Extensions.Configuration" Version="3.0.1" />
......
......@@ -3,6 +3,7 @@ using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Mall.Common.API;
using Mall.Common.Plugin;
using Mall.Model.Entity.BaseSetUp;
using Mall.Model.Extend.BaseSetUp;
using Mall.Module.BaseSetUp;
......@@ -10,6 +11,7 @@ using Mall.WebApi.Filter;
using Microsoft.AspNetCore.Cors;
using Microsoft.AspNetCore.Mvc;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
namespace Mall.WebApi.Controllers.MallBase
{
......@@ -34,6 +36,10 @@ namespace Mall.WebApi.Controllers.MallBase
}
else
{
if (string.IsNullOrWhiteSpace(query.MallName))
{
return ApiResult.Failed("请输入商城名称");
}
query.TenantId = UserInfo.TenantId;
if (query.ID == 0)//新增
{
......@@ -74,37 +80,21 @@ namespace Mall.WebApi.Controllers.MallBase
}
}
/// <summary>
/// 列表
/// </summary>
/// <returns></returns>
[HttpPost]
public ApiResult GetMallBasePage()
{
// UserInfo userInfo = UserReidsCache.GetUserLoginInfo(requestParm.uid);
ResultPageModel pagelist = JsonConvert.DeserializeObject<ResultPageModel>(RequestParm.msg.ToString());
RB_MallBase_Extend demodel = JsonConvert.DeserializeObject<RB_MallBase_Extend>(RequestParm.msg.ToString());
demodel.TenantId = UserInfo.TenantId;
var list = mallBaseModule.GetPageListRepository(pagelist.pageIndex, pagelist.pageSize, out long count, demodel);
pagelist.count = Convert.ToInt32(count);
pagelist.pageData = list.Select(x => new
{
x.ID,
x.MallName,
OrderNum = 0,
MemberNum = 0,
IndateStr = x.Indate.HasValue ? x.Indate.Value.ToString("yyyy-MM-dd") : "永久",
});
return ApiResult.Success("", pagelist);
public ApiResult GetMallBaseInfo()
{
var query = new RB_MallBase_Extend();
query.TenantId = UserInfo.TenantId;
query.MallBaseId = UserInfo.MallBaseId;
var model = mallBaseModule.GetListRepository(query).FirstOrDefault();
return ApiResult.Success("获取成功", model);
}
#endregion
#region 物流设置
#region 物流规格-物流设置
/// <summary>
/// 根据商户号获取物流信息
......@@ -113,7 +103,6 @@ namespace Mall.WebApi.Controllers.MallBase
public ApiResult GetLogistics()
{
var query = JsonConvert.DeserializeObject<RB_Logistics>(RequestParm.msg.ToString());
var TenantModel = TenantModule.GetTenantModule(query.TenantId);
query.TenantId = UserInfo.TenantId;
var oldLogisticsModel = mallBaseModule.GetLogisticsList(query).FirstOrDefault();
if (oldLogisticsModel == null)
......@@ -151,9 +140,335 @@ namespace Mall.WebApi.Controllers.MallBase
}
}
#endregion
#region 运费规则
/// <summary>
/// 列表
/// </summary>
/// <returns></returns>
[HttpPost]
public ApiResult GetLogisticsRulesPage()
{
ResultPageModel pagelist = JsonConvert.DeserializeObject<ResultPageModel>(RequestParm.msg.ToString());
RB_Logistics_Rules_Extend demodel = JsonConvert.DeserializeObject<RB_Logistics_Rules_Extend>(RequestParm.msg.ToString());
demodel.TenantId = UserInfo.TenantId;
demodel.MallBaseId = UserInfo.MallBaseId;
demodel.RulesType = Common.Enum.MallBase.RulesTypeEnum.Rule;
var list = mallBaseModule.GetLogisticsRulesList(pagelist.pageIndex, pagelist.pageSize, out long count, demodel);
pagelist.count = Convert.ToInt32(count);
pagelist.pageData = list.Select(x => new
{
x.ID,
x.RulesName,
x.IsDefault
});
return ApiResult.Success("", pagelist);
}
/// <summary>
/// 获取详情
/// </summary>
/// <returns></returns>
public ApiResult GetLogisticsRules()
{
var query = JsonConvert.DeserializeObject<RB_Logistics_Rules_Extend>(RequestParm.msg.ToString());
query.TenantId = UserInfo.TenantId;
query.MallBaseId = UserInfo.MallBaseId;
query.RulesType = Common.Enum.MallBase.RulesTypeEnum.Rule;
var oldLogisticsModel = mallBaseModule.GetLogisticsRulesModel(query);
if (oldLogisticsModel == null)
{
oldLogisticsModel = new RB_Logistics_Rules_Extend();
}
return ApiResult.Success("", oldLogisticsModel);
}
/// <summary>
/// 设置默认物流规则
/// </summary>
/// <returns></returns>
public ApiResult SetLogisticsRulesDefault()
{
var query = JsonConvert.DeserializeObject<RB_Logistics_Rules_Extend>(RequestParm.msg.ToString());
query.TenantId = UserInfo.TenantId;
query.MallBaseId = UserInfo.MallBaseId;
query.RulesType = Common.Enum.MallBase.RulesTypeEnum.Rule;
bool result = mallBaseModule.SetDefaultLogisticsRules(query);
if (result)
{
return ApiResult.Success("默认运费规则设置成功");
}
else
{
return ApiResult.Failed("默认运费规则设置失败");
}
}
/// <summary>
/// 保存物流信息
/// </summary>
/// <returns></returns>
public ApiResult AddOrUpdateLogisticsRules()
{
var query = JsonConvert.DeserializeObject<RB_Logistics_Rules_Extend>(RequestParm.msg.ToString());
query.TenantId = UserInfo.TenantId;
query.MallBaseId = UserInfo.MallBaseId;
query.RulesType = Common.Enum.MallBase.RulesTypeEnum.Rule;
if (query == null)
{
return ApiResult.Failed("请传入物流规则信息");
}
else
{
if (string.IsNullOrWhiteSpace(query.RulesName))
{
return ApiResult.Failed("请输入规则名称");
}
if (query.Detail == null || !query.Detail.Any())
{
return ApiResult.Failed("请输入运费规则");
}
foreach (var item in query.Detail)
{
if (item.List == null || !item.List.Any())
{
return ApiResult.Failed("请选择地区");
}
}
query.TenantId = UserInfo.TenantId;
if (query.ID == 0)
{
query.CreateDate = System.DateTime.Now;
}
query.UpdateDate = System.DateTime.Now;
bool result = mallBaseModule.AddOrUpdateLogisticsRules(query);
if (result)
{
return ApiResult.Success("物流规则信息保存成功");
}
else
{
return ApiResult.Failed("物流规则信息保存失败");
}
}
}
public ApiResult DelRules()
{
JObject parms = JObject.Parse(RequestParm.msg.ToString());
int Id = parms.GetInt("Id", 0);
if (Id <= 0)
{
return ApiResult.Failed("请传递参数");
}
bool flag = mallBaseModule.DelRulesInfo(Id, UserInfo.TenantId, UserInfo.MallBaseId);
if (flag)
{
return ApiResult.Success();
}
else
{
return ApiResult.Failed();
}
}
#endregion
#region 包邮规则
/// <summary>
/// 列表
/// </summary>
/// <returns></returns>
[HttpPost]
public ApiResult GetLogisticsPinkagePage()
{
ResultPageModel pagelist = JsonConvert.DeserializeObject<ResultPageModel>(RequestParm.msg.ToString());
RB_Logistics_Rules_Extend demodel = JsonConvert.DeserializeObject<RB_Logistics_Rules_Extend>(RequestParm.msg.ToString());
demodel.TenantId = UserInfo.TenantId;
demodel.MallBaseId = UserInfo.MallBaseId;
demodel.RulesType = Common.Enum.MallBase.RulesTypeEnum.Pinkage;
var list = mallBaseModule.GetLogisticsPinkageList(pagelist.pageIndex, pagelist.pageSize, out long count, demodel);
pagelist.count = Convert.ToInt32(count);
pagelist.pageData = list.Select(x => new
{
x.ID,
x.RulesName,
x.AllRegionPrice,
RegionList = x.List.Select(x => x.RegionName)
});
return ApiResult.Success("", pagelist);
}
public ApiResult DelPinkage()
{
JObject parms = JObject.Parse(RequestParm.msg.ToString());
int Id = parms.GetInt("Id", 0);
if (Id <= 0)
{
return ApiResult.Failed("请传递参数");
}
bool flag = mallBaseModule.DelPinkageInfo(Id, UserInfo.TenantId, UserInfo.MallBaseId);
if (flag)
{
return ApiResult.Success();
}
else
{
return ApiResult.Failed();
}
}
/// <summary>
/// 获取详情
/// </summary>
/// <returns></returns>
public ApiResult GetLogisticsPinkage()
{
var query = JsonConvert.DeserializeObject<RB_Logistics_Rules_Extend>(RequestParm.msg.ToString());
query.TenantId = UserInfo.TenantId;
query.MallBaseId = UserInfo.MallBaseId;
query.RulesType = Common.Enum.MallBase.RulesTypeEnum.Pinkage;
var oldLogisticsModel = mallBaseModule.GetPinkageModel(query);
if (oldLogisticsModel == null)
{
oldLogisticsModel = new RB_Logistics_Rules_Extend();
}
return ApiResult.Success("", oldLogisticsModel);
}
/// <summary>
/// 保存物流信息
/// </summary>
/// <returns></returns>
public ApiResult AddOrUpdateLogisticsPinkage()
{
var query = JsonConvert.DeserializeObject<RB_Logistics_Rules_Extend>(RequestParm.msg.ToString());
query.TenantId = UserInfo.TenantId;
query.MallBaseId = UserInfo.MallBaseId;
query.RulesType = Common.Enum.MallBase.RulesTypeEnum.Pinkage;
if (query == null)
{
return ApiResult.Failed("请传入包邮规则信息");
}
else
{
if (string.IsNullOrWhiteSpace(query.RulesName))
{
return ApiResult.Failed("请输入包邮名称");
}
if (query.AllRegionPrice > -1)
{
return ApiResult.Failed("包邮费用不能为负数");
}
if (query.List == null || !query.List.Any())
{
return ApiResult.Failed("请选择地区");
}
query.TenantId = UserInfo.TenantId;
if (query.ID == 0)
{
query.CreateDate = System.DateTime.Now;
}
query.UpdateDate = System.DateTime.Now;
bool result = mallBaseModule.AddOrUpdatePinkage(query);
if (result)
{
return ApiResult.Success("包邮规则信息保存成功");
}
else
{
return ApiResult.Failed("包邮规则信息保存失败");
}
}
}
#endregion
#region 起送规则
public ApiResult GetMinPriceInfo()
{
var query = new RB_Logistics_Rules_Extend();
query.TenantId = UserInfo.TenantId;
query.MallBaseId = UserInfo.MallBaseId;
query.RulesType = Common.Enum.MallBase.RulesTypeEnum.OpenMinPrice;
var model = mallBaseModule.GetLogisticsRulesModel(query);
return ApiResult.Success("获取成功", model);
}
/// <summary>
/// 保存起送信息
/// </summary>
/// <returns></returns>
public ApiResult AddOrUpdateMinPrice()
{
var query = JsonConvert.DeserializeObject<RB_Logistics_Rules_Extend>(RequestParm.msg.ToString());
query.TenantId = UserInfo.TenantId;
query.MallBaseId = UserInfo.MallBaseId;
query.RulesType = Common.Enum.MallBase.RulesTypeEnum.OpenMinPrice;
if (query == null)
{
return ApiResult.Failed("请传入起送规则信息");
}
else
{
if (string.IsNullOrWhiteSpace(query.RulesName))
{
return ApiResult.Failed("请输入规则名称");
}
if (query.Detail == null || !query.Detail.Any())
{
return ApiResult.Failed("请输入运费规则");
}
if (query.IsOpenAllRegionPrice == 0)
{
foreach (var item in query.Detail)
{
if (item.List == null || !item.List.Any())
{
return ApiResult.Failed("请选择地区");
}
}
}
else
{
if (query.AllRegionPrice < 0)
{
return ApiResult.Failed("全地区起送金额不能为负数");
}
}
if (query.ID == 0)
{
query.CreateDate = System.DateTime.Now;
}
query.UpdateDate = System.DateTime.Now;
bool result = mallBaseModule.AddOrUpdateLogisticsRules(query);
if (result)
{
return ApiResult.Success("起送规则信息保存成功");
}
else
{
return ApiResult.Failed("起送规则信息保存失败");
}
}
}
#endregion
#endregion
......
......@@ -31,7 +31,7 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Mall.Repository", "Mall.Rep
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Mall.Module.User", "Mall.Module.User\Mall.Module.User.csproj", "{E56423C0-5AC2-48D8-88BE-5435EF6ADB3F}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Mall.Module.BaseSetUp", "Mall.Module.BaseSetUp\Mall.Module.BaseSetUp.csproj", "{9C400D7F-2BE2-40E7-B179-498097AA00AB}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Mall.Module.BaseSetUp", "Mall.Module.BaseSetUp\Mall.Module.BaseSetUp.csproj", "{9C400D7F-2BE2-40E7-B179-498097AA00AB}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
......
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