Commit 4303516c authored by 吴春's avatar 吴春

提交

parent 825be94e
using Mall.Common.Plugin;
using System;
using System.Collections.Generic;
using System.Text;
namespace Mall.Common.Enum.MallBase
{
public enum LogisticsTypeEnum
{
/// <summary>
/// 快递鸟
/// </summary>
[EnumField("快递鸟")]
ExpressBird = 1,
/// <summary>
/// 阿里云接口
/// </summary>
[EnumField("阿里云接口")]
Aliyun = 2
}
}
using Mall.Common.AOP;
using Mall.Common.Enum;
using System;
using System.Collections.Generic;
using System.Text;
namespace Mall.Model.Entity.BaseSetUp
{
/// <summary>
/// 地区
/// </summary>
[Serializable]
[DB(ConnectionName = "DefaultConnection")]
public class RB_Destination
{
/// <summary>
/// 主键
/// </summary>
public int ID
{
get;
set;
}
/// <summary>
/// 名称
/// </summary>
public string Name
{
get;
set;
}
/// <summary>
/// 父级节点编号
/// </summary>
public int? ParentID
{
get;
set;
}
/// <summary>
/// 等级 1-国家,2-省,3-市,4-区县
/// </summary>
public AreaRegionEnum CodeLevel
{
get;
set;
}
/// <summary>
/// 三码
/// </summary>
public string ThreeCode { get; set; }
/// <summary>
/// 地区英文名
/// </summary>
public string EnName { get; set; }
/// <summary>
/// 四字码
/// </summary>
public string FourCode { get; set; }
/// <summary>
/// 自定义区域,如'1,2'
/// </summary>
public string Area { get; set; }
/// <summary>
/// 删除状态
/// </summary>
public Common.Enum.DateStateEnum Status
{
get;
set;
}
/// <summary>
/// 经度
/// </summary>
public string Lng
{
get;
set;
}
/// <summary>
/// 纬度
/// </summary>
public string Lat
{
get;
set;
}
/// <summary>
/// 城市图片
/// </summary>
public string Images { get; set; }
}
}
using Mall.Common.AOP;
using Mall.Common.Enum.MallBase;
using System;
using System.Collections.Generic;
using System.Text;
namespace Mall.Model.Entity.BaseSetUp
{
/// <summary>
/// 物流设置
/// </summary>
[Serializable]
[DB(ConnectionName = "DefaultConnection")]
public class RB_Logistics
{
/// <summary>
/// 编号
/// </summary>
public int ID { get; set; }
/// <summary>
///查询类型选择 1-快递鸟,2-阿里云接口
/// </summary>
public LogisticsTypeEnum LogisticsType { get; set; }
/// <summary>
/// 阿里云APPCODE
/// </summary>
public string AliyunAppCode { get; set; }
/// <summary>
/// 快递鸟用户ID
/// </summary>
public string ExpressBirdID { get; set; }
/// <summary>
/// 快递鸟API KEY
/// </summary>
public string ExpressBirdAPIKey { get; set; }
public int TenantId { get; set; }
}
}
using Mall.Common.AOP;
using System;
using System.Collections.Generic;
using System.Text;
namespace Mall.Model.Entity.BaseSetUp
{
/// <summary>
/// 运费规则
/// </summary>
[Serializable]
[DB(ConnectionName = "DefaultConnection")]
public class RB_LogisticsRules
{
public int ID { get; set; }
/// <summary>
/// 商户id
/// </summary>
public int TenantId { get; set; }
/// <summary>
/// 小程序id
/// </summary>
public int MallBaseId { get; set; }
/// <summary>
/// 0-否1-是
/// </summary>
public int IsDefault { get; set; }
/// <summary>
/// 规则名称
/// </summary>
public string RulesName { get; set; }
/// <summary>
/// 计费方式
/// </summary>
public int ChargeMode { get; set; }
public int Status { get; set; }
public DateTime CreateDate { get; set; }
public DateTime UpdateDate { get; set; }
public DateTime DeletedDate { get; set; }
}
}
using Mall.Common.AOP;
using System;
using System.Collections.Generic;
using System.Text;
namespace Mall.Model.Entity.BaseSetUp
{
/// <summary>
/// 运费规则价格
/// </summary>
[Serializable]
[DB(ConnectionName = "DefaultConnection")]
public class RB_LogisticsRulesPrice
{
public int ID { get; set; }
/// <summary>
/// 商户id
/// </summary>
public int TenantId { get; set; }
/// <summary>
/// 小程序id
/// </summary>
public int MallBaseId { get; set; }
/// <summary>
/// 运费规则id
/// </summary>
public int RulesId { get; set; }
/// <summary>
/// 首重
/// </summary>
public int First { get; set; }
/// <summary>
/// 首重价格
/// </summary>
public int FirstPrice { get; set; }
/// <summary>
/// 首重
/// </summary>
public int Second { get; set; }
/// <summary>
/// 首重价格
/// </summary>
public int SecondPrice { get; set; }
public int Status { get; set; }
public DateTime CreateDate { get; set; }
public DateTime UpdateDate { get; set; }
public DateTime DeletedDate { get; set; }
}
}
using Mall.Common.AOP;
using System;
using System.Collections.Generic;
using System.Text;
namespace Mall.Model.Entity.BaseSetUp
{
/// <summary>
/// 运费规则地区
/// </summary>
[Serializable]
[DB(ConnectionName = "DefaultConnection")]
public class RB_LogisticsRulesRegion
{
/// <summary>
/// 价格
/// </summary>
public int RulesPriceId { get; set; }
/// <summary>
/// 地区id
/// </summary>
public int RegionId { get; set; }
public int ID { get; set; }
/// <summary>
/// 商户id
/// </summary>
public int TenantId { get; set; }
/// <summary>
/// 小程序id
/// </summary>
public int MallBaseId { get; set; }
public int Status { get; set; }
public DateTime CreateDate { get; set; }
public DateTime UpdateDate { get; set; }
public DateTime DeletedDate { get; set; }
}
}
...@@ -209,7 +209,7 @@ namespace Mall.Model.Entity.BaseSetUp ...@@ -209,7 +209,7 @@ namespace Mall.Model.Entity.BaseSetUp
public int OtherTencent { get; set; } public int OtherTencent { get; set; }
/// <summary> /// <summary>
/// 定位地址是否必填 /// 会员等级标识
/// </summary> /// </summary>
public int OtherMemerLevel { get; set; } public int OtherMemerLevel { get; set; }
...@@ -265,5 +265,10 @@ namespace Mall.Model.Entity.BaseSetUp ...@@ -265,5 +265,10 @@ namespace Mall.Model.Entity.BaseSetUp
/// 有效期 /// 有效期
/// </summary> /// </summary>
public DateTime? Indate { get; set; } public DateTime? Indate { get; set; }
/// <summary>
/// 1-正常,2-禁用
/// </summary>
public int MallBaseState { get; set; }
} }
} }
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_Destination_Extend : RB_Destination
{
/// <summary>
/// 洲查询使用
/// </summary>
public string QArea { get; set; }
/// <summary>
/// 国家查询使用
/// </summary>
public string QCountry { get; set; }
/// <summary>
/// 省份查询使用
/// </summary>
public string QProvince { get; set; }
/// <summary>
/// 城市查询使用
/// </summary>
public string QCity { get; set; }
/// <summary>
/// 地区查询使用
/// </summary>
public string QDistrict { get; set; }
/// <summary>
/// 行政级别名称
/// </summary>
public string CodeLevelName
{
get
{
string str = string.Empty;
if (this.CodeLevel > 0)
{
str = Common.Plugin.EnumHelper.GetEnumName(CodeLevel);
}
return str;
}
}
/// <summary>
/// 所属国家
/// </summary>
public string CountryName { get; set; }
/// <summary>
/// 所属省份
/// </summary>
public string ProvinceName { get; set; }
/// <summary>
/// 所属城市
/// </summary>
public string CityName { get; set; }
/// <summary>
/// ID查询字符串
/// </summary>
public string QIds { get; set; }
}
}
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_LogisticsRulesPrice_Extend : RB_LogisticsRulesPrice
{
public List<RB_LogisticsRulesRegion_Extend> List { get; set; }
}
}
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_LogisticsRulesRegion_Extend : RB_LogisticsRulesRegion
{
/// <summary>
/// 地区名字
/// </summary>
public string RegionName { get; set; }
public string PriceIds { get; set; }
}
}
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_LogisticsRules_Extend : RB_LogisticsRules
{
public List<RB_LogisticsRulesPrice_Extend> Detail { get; set; }
}
}
using Mall.Common.Plugin;
using Mall.Model.Entity.BaseSetUp;
using Mall.Model.Extend.BaseSetUp;
using Mall.Repository;
using Mall.Repository.BaseSetUp;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Mall.Module.BaseSetUp
{
/// <summary>
/// 地区模块
/// </summary>
public class DestinationModule
{
private Rb_destinationRepository rb_DestinationRepository = new Rb_destinationRepository();
/// <summary>
/// 获取地区分页列表
/// </summary>
/// <param name="pageIndex"></param>
/// <param name="pageSize"></param>
/// <param name="where"></param>
/// <param name="count"></param>
/// <returns></returns>
public List<RB_Destination_Extend> GetPageList(int pageIndex, int pageSize, RB_Destination_Extend where, out long count)
{
return rb_DestinationRepository.GetPageList(pageIndex, pageSize, where, out count);
}
/// <summary>
/// 根据洲获取国家
/// </summary>
/// <returns></returns>
public List<RB_Destination_Extend> GetCountryByArea(string Area)
{
RB_Destination_Extend where = new RB_Destination_Extend()
{
QArea = Area,
CodeLevel = Common.Enum.AreaRegionEnum.CountryEnum
};
return rb_DestinationRepository.GetListExt(where);
}
/// <summary>
/// 获取国家
/// </summary>
/// <returns></returns>
public List<RB_Destination_Extend> GetCountry()
{
RB_Destination_Extend where = new RB_Destination_Extend()
{
CodeLevel = Common.Enum.AreaRegionEnum.CountryEnum
};
return rb_DestinationRepository.GetListExt(where);
}
/// <summary>
/// 根据条件获取单个地区
/// </summary>
/// <param name="where"></param>
/// <returns></returns>
public RB_Destination_Extend GetEntityExt(RB_Destination_Extend where)
{
return rb_DestinationRepository.GetEntityExt(where);
}
/// <summary>
/// 根据地区名称获取地区列表
/// </summary>
/// <param name="where"></param>
/// <returns></returns>
public List<RB_Destination_Extend> GetListByNames(string[] where)
{
return rb_DestinationRepository.GetListByNames(where);
}
/// <summary>
/// 获取实体
/// </summary>
/// <param name="id"></param>
/// <returns></returns>
public RB_Destination GetEntity(object id)
{
return rb_DestinationRepository.GetEntity(id);
}
/// <summary>
/// 根据父节点编号获取子列表
/// </summary>
/// <param name="ParentID">父节点编号</param>
/// <returns></returns>
public List<RB_Destination_Extend> GetChildList(int ParentID)
{
RB_Destination_Extend where = new RB_Destination_Extend()
{
ParentID = ParentID
};
return rb_DestinationRepository.GetListExt(where);
}
/// <summary>
/// 获取所有的地区数据
/// </summary>
/// <returns></returns>
public List<RB_Destination_Extend> GetListByCountryId(RB_Destination_Extend where)
{
return rb_DestinationRepository.GetListByCountryId(where);
}
/// <summary>
/// 获取城市列表
/// </summary>
/// <returns></returns>
public List<RB_Destination_Extend> GetCityList()
{
RB_Destination_Extend where = new RB_Destination_Extend()
{
CodeLevel = Common.Enum.AreaRegionEnum.CityEnum
};
return rb_DestinationRepository.GetListExt(where);
}
/// <summary>
/// 根据查询条件获取
/// </summary>
/// <param name="where"></param>
/// <returns></returns>
public List<RB_Destination_Extend> GetListModule(RB_Destination_Extend where)
{
return rb_DestinationRepository.GetListExt(where);
}
/// <summary>
/// 获取省份和城市列表
/// </summary>
/// <param name="isGetArea">是否查询区县</param>
/// <returns></returns>
public object GetProviceAndCityList(bool isGetArea = false)
{
var CommonList = Mall.Common.Data.AreaDataHelper.GetAreaList();
if (CommonList != null && CommonList.Count > 0)
{
if (isGetArea)
{
return CommonList.Where(qitem => (qitem.L == 3 || qitem.L == 2 || qitem.L == 4) && qitem.P != 2).Select(qitem => new { ID = qitem.I, Name = qitem.N });
}
else
{
return CommonList.Where(qitem => (qitem.L == 3 || qitem.L == 2) && qitem.P != 2).Select(qitem => new { ID = qitem.I, Name = qitem.N });
}
}
var list = rb_DestinationRepository.GetProviceAndCityList(isGetArea: isGetArea);
return list.Select(item => new { item.ID, item.Name });
}
/// <summary>
/// 获取列表
/// </summary>
/// <returns></returns>
public List<Mall.Common.Data.Node> GetAllList()
{
return rb_DestinationRepository.GetAllList();
}
/// <summary>
/// 新增修改地区
/// </summary>
/// <param name="model"></param>
/// <returns></returns>
public bool Set(RB_Destination model)
{
var flag = false;
if (model.ID > 0)
{
Dictionary<string, object> fileds = new Dictionary<string, object>()
{
{nameof(RB_Destination.Name), model.Name},
{nameof(RB_Destination.EnName), model.EnName},
{nameof(RB_Destination.ParentID), model.ParentID},
{nameof(RB_Destination.CodeLevel), model.CodeLevel},
{nameof(RB_Destination.ThreeCode), model.ThreeCode},
{nameof(RB_Destination.FourCode), model.FourCode},
{nameof(RB_Destination.Images), model.Images},
};
if (model.Area != null && !string.IsNullOrEmpty(model.Area))
{
fileds.Add(nameof(RB_Destination.Area), model.Area);
}
List<WhereHelper> whereHelpers = new List<WhereHelper>()
{
new WhereHelper(){ FiledName=nameof(RB_Destination.ID),FiledValue=model.ID ,OperatorEnum=OperatorEnum.Equal}
};
flag = rb_DestinationRepository.Update(fileds, whereHelpers);
}
else
{
flag = rb_DestinationRepository.Insert(model) > 0;
}
return flag;
}
/// <summary>
/// 删除数据
/// </summary>
/// <param name="ID"></param>
/// <returns></returns>
public bool Remove(RB_Destination model)
{
Dictionary<string, object> fileds = new Dictionary<string, object>()
{
{ nameof(RB_Destination_Extend.Status),(int)Common.Enum.DateStateEnum.Delete}
};
var flag = true;
var trans = rb_DestinationRepository.DbTransaction;
try
{
//省
List<RB_Destination_Extend> ProvinceList = new List<RB_Destination_Extend>();
//城市
List<RB_Destination_Extend> CityList = new List<RB_Destination_Extend>();
//区县
List<RB_Destination_Extend> DistrictList = new List<RB_Destination_Extend>();
switch (model.CodeLevel)
{
//删除国家及国家下面的所有数据
case Common.Enum.AreaRegionEnum.CountryEnum:
ProvinceList = this.GetChildList(model.ID);
foreach (var item in ProvinceList)
{
CityList = this.GetChildList(item.ID);
foreach (var subItem in DistrictList)
{
DistrictList = this.GetChildList(subItem.ID);
foreach (var thirdItem in DistrictList)
{
//删除区县
rb_DestinationRepository.Update(fileds, new WhereHelper(nameof(RB_Destination_Extend.ID), thirdItem.ID), trans);
}
//删除城市
rb_DestinationRepository.Update(fileds, new WhereHelper(nameof(RB_Destination_Extend.ID), subItem.ID), trans);
}
//删除省
rb_DestinationRepository.Update(fileds, new WhereHelper(nameof(RB_Destination_Extend.ID), item.ID), trans);
}
//删除国家
rb_DestinationRepository.Update(fileds, new WhereHelper(nameof(RB_Destination_Extend.ID), model.ID), trans);
break;
//删除省及省下面的市、区县
case Common.Enum.AreaRegionEnum.ProvinceEnum:
CityList = this.GetChildList(model.ID);
foreach (var item in DistrictList)
{
DistrictList = this.GetChildList(item.ID);
foreach (var subItem in DistrictList)
{
//删除区县
rb_DestinationRepository.Update(fileds, new WhereHelper(nameof(RB_Destination_Extend.ID), subItem.ID), trans);
}
//删除城市
rb_DestinationRepository.Update(fileds, new WhereHelper(nameof(RB_Destination_Extend.ID), item.ID), trans);
}
//删除省
rb_DestinationRepository.Update(fileds, new WhereHelper(nameof(RB_Destination_Extend.ID), model.ID), trans);
break;
//删除城市及下面的区县
case Common.Enum.AreaRegionEnum.CityEnum:
DistrictList = this.GetChildList(model.ID);
foreach (var item in DistrictList)
{
//删除区县
rb_DestinationRepository.Update(fileds, new WhereHelper(nameof(RB_Destination_Extend.ID), item.ID), trans);
}
//删除城市
rb_DestinationRepository.Update(fileds, new WhereHelper(nameof(RB_Destination_Extend.ID), model.ID), trans);
break;
//删除区县
case Common.Enum.AreaRegionEnum.DistrictEnum:
rb_DestinationRepository.Update(fileds, new WhereHelper(nameof(RB_Destination_Extend.ID), model.ID), trans);
break;
}
rb_DestinationRepository.DBSession.Commit();
}
catch (Exception ex)
{
LogHelper.Write(ex, "Remove");
rb_DestinationRepository.DBSession.Rollback("Remove");
flag = false;
}
return flag;
}
/// <summary>
/// 判断是否存在
/// </summary>
/// <param name="where"></param>
/// <returns></returns>
public bool IsExists(RB_Destination where)
{
IList<WhereHelper> whereHelpers = new List<WhereHelper>()
{
new WhereHelper(){ FiledName=nameof(RB_Destination.Name), FiledValue=where.Name.Trim(), OperatorEnum= OperatorEnum.Equal},
new WhereHelper(){ FiledName=nameof(RB_Destination.Status), FiledValue=(int)Common.Enum.DateStateEnum.Normal, OperatorEnum= OperatorEnum.Equal},
new WhereHelper(){ FiledName=nameof(RB_Destination.CodeLevel), FiledValue=where.CodeLevel, OperatorEnum= OperatorEnum.Equal},
};
//地区,验证城市下面的区不重复
if (where.CodeLevel == Common.Enum.AreaRegionEnum.DistrictEnum)
{
whereHelpers.Add(new WhereHelper(nameof(RB_Destination.ParentID), where.ParentID));
}
if (where.ID > 0)
{
whereHelpers.Add(new WhereHelper()
{
FiledName = nameof(RB_Destination.ID),
FiledValue = where.ID,
OperatorEnum = OperatorEnum.NotEqual
});
}
return rb_DestinationRepository.Exists(whereHelpers);
}
}
}
...@@ -3,6 +3,7 @@ using Mall.Model.Extend.BaseSetUp; ...@@ -3,6 +3,7 @@ using Mall.Model.Extend.BaseSetUp;
using Mall.Repository.BaseSetUp; using Mall.Repository.BaseSetUp;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq;
using System.Text; using System.Text;
namespace Mall.Module.BaseSetUp namespace Mall.Module.BaseSetUp
...@@ -10,7 +11,12 @@ namespace Mall.Module.BaseSetUp ...@@ -10,7 +11,12 @@ namespace Mall.Module.BaseSetUp
public class MallBaseModule public class MallBaseModule
{ {
private RB_MallBaseRepository mallBaseRepository = new RB_MallBaseRepository(); 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();
#region 基础设置
/// <summary> /// <summary>
/// 获取小程序列表 /// 获取小程序列表
/// </summary> /// </summary>
...@@ -25,6 +31,17 @@ namespace Mall.Module.BaseSetUp ...@@ -25,6 +31,17 @@ namespace Mall.Module.BaseSetUp
} }
/// <summary>
/// 获取小程序列表
/// </summary>
/// <param name="query">查询条件</param>
/// <returns></returns>
public List<RB_MallBase_Extend> GetListRepository(RB_MallBase_Extend query)
{
return mallBaseRepository.GetListRepository(query);
}
/// <summary> /// <summary>
/// 根据编号获取实体 /// 根据编号获取实体
/// </summary> /// </summary>
...@@ -42,7 +59,7 @@ namespace Mall.Module.BaseSetUp ...@@ -42,7 +59,7 @@ namespace Mall.Module.BaseSetUp
/// </summary> /// </summary>
/// <param name="model"></param> /// <param name="model"></param>
/// <returns></returns> /// <returns></returns>
public bool AddOrUpdate(RB_MallBase model) public bool AddOrUpdateMallBase(RB_MallBase model)
{ {
if (model.ID == 0) if (model.ID == 0)
{ {
...@@ -53,5 +70,87 @@ namespace Mall.Module.BaseSetUp ...@@ -53,5 +70,87 @@ namespace Mall.Module.BaseSetUp
return mallBaseRepository.Update(model); return mallBaseRepository.Update(model);
} }
} }
#endregion
#region 物流设置
/// <summary>
/// 根据商户id获取物流信息
/// </summary>
/// <param name="query">查询条件</param>
/// <returns></returns>
public List<RB_Logistics> GetLogisticsList(RB_Logistics query)
{
return logisticsRepository.GetListRepository(query);
}
/// <summary>
/// 新增/修改基础信息
/// </summary>
/// <param name="model"></param>
/// <returns></returns>
public bool AddOrUpdateLogistics(RB_Logistics model)
{
if (model.ID == 0)
{
return logisticsRepository.Insert(model) > 0;
}
else
{
return logisticsRepository.Update(model);
}
}
#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_LogisticsRules_Extend> GetPageListRepository(int pageIndex, int pageSize, out long rowCount, RB_LogisticsRules_Extend query)
{
return logisticsRulesRepository.GetPageListRepository(pageIndex, pageSize, out rowCount, query);
}
/// <summary>
/// 物流规则列表
/// </summary>
/// <param name="pageIndex">页码</param>
/// <param name="pageSize">每页显示条数</param>
/// <param name="rowCount">总条数</param>
/// <param name="query">查询条件</param>
/// <returns></returns>
public List<RB_LogisticsRules_Extend> GetLogisticsRulesList(RB_LogisticsRules_Extend query)
{
return logisticsRulesRepository.GetLogisticsRulesList(query);
}
public RB_LogisticsRules_Extend GetLogisticsRulesModel(RB_LogisticsRules_Extend query)
{
RB_LogisticsRules_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_LogisticsRulesRegion_Extend> listLogisticsRulesRegion = logisticsRulesRegionRepository.GetListRepository(new RB_LogisticsRulesRegion_Extend { TenantId = query.TenantId, MallBaseId = query.MallBaseId, PriceIds = string.Join(",", ListPrice.Select(x => x.ID)) });
model.Detail = new List<RB_LogisticsRulesPrice_Extend>();
model.Detail = ListPrice;
foreach (var item in model.Detail)
{
item.List = new List<RB_LogisticsRulesRegion_Extend>();
}
return model;
}
#endregion
} }
} }
using Mall.Model.Entity.BaseSetUp;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Mall.Model.Extend.BaseSetUp;
using Mall.Common.Enum;
namespace Mall.Repository.BaseSetUp
{
/// <summary>
/// 地区表仓储层
/// </summary>
public partial class Rb_destinationRepository : RepositoryBase<RB_Destination>
{
/// <summary>
/// 表名称
/// </summary>
public string TableName { get { return nameof(RB_Destination); } }
/// <summary>
/// 获取地区分页列表
/// </summary>
/// <param name="pageIndex"></param>
/// <param name="pageSize"></param>
/// <param name="where"></param>
/// <param name="count"></param>
/// <returns></returns>
public List<RB_Destination_Extend> GetPageList(int pageIndex, int pageSize, RB_Destination_Extend where, out long count)
{
StringBuilder sb = new StringBuilder();
sb.AppendFormat(" SELECT * FROM {0} WHERE 1=1 ", TableName);
sb.AppendFormat(" AND {0}={1} ", nameof(RB_Destination_Extend.Status), (int)Common.Enum.DateStateEnum.Normal);
if (where != null)
{
if (where.Name != null && !string.IsNullOrEmpty(where.Name.Trim()))
{
sb.AppendFormat(" AND {0} LIKE '%{1}%' ", nameof(RB_Destination_Extend.Name), where.Name.Trim());
}
var QArea = Common.ConvertHelper.ConvertInt(where.QArea);
var QCountry = Common.ConvertHelper.ConvertInt(where.QCountry);
var QProvince = Common.ConvertHelper.ConvertInt(where.QProvince);
var QCity = Common.ConvertHelper.ConvertInt(where.QCity);
var QDistrict = Common.ConvertHelper.ConvertInt(where.QDistrict);
//区
if (QDistrict > 0)
{
sb.AppendFormat(" AND {0}={1} ", nameof(RB_Destination_Extend.ID), QDistrict);
}
if (QCity > 0 && QDistrict <= 0)
{
sb.AppendFormat(" AND ({0}={1} OR {2}={3}) ", nameof(RB_Destination_Extend.ParentID), QCity, nameof(RB_Destination_Extend.ID), QCity);
}
if (QProvince > 0 && QCity <= 0 && QDistrict <= 0)
{
sb.AppendFormat(" AND (({0}={1} AND {2}={3}) OR ({4}={5}) ) ", nameof(RB_Destination_Extend.ParentID), QProvince, nameof(RB_Destination_Extend.CodeLevel), (int)Common.Enum.AreaRegionEnum.CityEnum, nameof(RB_Destination_Extend.ID), QProvince);
}
if (QCountry > 0 && QProvince <= 0 && QCity <= 0 && QDistrict <= 0)
{
sb.AppendFormat(" AND (({0}={1} AND {2}={3}) OR ({4}={5})) ", nameof(RB_Destination_Extend.ParentID), QCountry, nameof(RB_Destination_Extend.CodeLevel), (int)Common.Enum.AreaRegionEnum.ProvinceEnum, nameof(RB_Destination_Extend.ID), QCountry);
}
if (QArea > 0 && QCountry <= 0 && QProvince <= 0 && QCity <= 0 && QDistrict <= 0)
{
sb.AppendFormat(" AND FIND_IN_SET({0},{1}) AND {2}={3} ", QArea, nameof(RB_Destination_Extend.Area), nameof(RB_Destination_Extend.CodeLevel), (int)Common.Enum.AreaRegionEnum.CountryEnum);
}
}
sb.AppendFormat(" ORDER BY {0} ASC ", nameof(RB_Destination_Extend.ID));
return GetPage<RB_Destination_Extend>(pageIndex, pageSize, out count, sb.ToString()).ToList();
}
/// <summary>
/// 获取所有的地区数据
/// </summary>
/// <returns></returns>
public List<RB_Destination_Extend> GetListExt(RB_Destination_Extend where)
{
StringBuilder sb = new StringBuilder();
sb.AppendFormat("SELECT * FROM {0} WHERE 1=1 ", TableName);
sb.AppendFormat(" AND {0}={1} ", nameof(RB_Destination_Extend.Status), (int)Common.Enum.DateStateEnum.Normal);
if (where != null)
{
if (where.CodeLevel > 0)
{
sb.AppendFormat(" AND {0}={1}", nameof(RB_Destination_Extend.CodeLevel), (int)where.CodeLevel);
}
if (where.ParentID > 0)
{
sb.AppendFormat(" AND {0}={1} ", nameof(RB_Destination_Extend.ParentID), where.ParentID);
}
if (where.QArea != null && !string.IsNullOrEmpty(where.QArea))
{
var QArea = Common.ConvertHelper.ConvertInt(where.QArea);
if (QArea > 0)
{
sb.AppendFormat(" AND FIND_IN_SET({0},{1}) ", QArea, nameof(RB_Destination_Extend.Area));
}
}
if (where.Name != null && !string.IsNullOrEmpty(where.Name.Trim()))
{
sb.AppendFormat(" AND {0} LIKE '%{1}%' ", nameof(RB_Destination_Extend.Name), where.Name.Trim());
}
}
return Get<RB_Destination_Extend>(sb.ToString()).ToList();
}
/// <summary>
/// 获取所有的地区数据
/// </summary>
/// <returns></returns>
public List<RB_Destination_Extend> GetListByCountryId(RB_Destination_Extend where)
{
string whereStr = string.Format(" AND {0}={1} ", nameof(RB_Destination_Extend.Status), (int)Common.Enum.DateStateEnum.Normal);
StringBuilder sb = new StringBuilder();
sb.AppendFormat(@"
SELECT * FROM {0} WHERE ParentID IN
(
SELECT ID FROM {0} WHERE ParentID IN({1}) {2}
) {2}
", TableName, where.QIds, whereStr);
return Get<RB_Destination_Extend>(sb.ToString()).ToList();
}
/// <summary>
/// 获取所有的省份和城市数据
/// </summary>
/// <returns></returns>
public List<RB_Destination_Extend> GetProviceAndCityList(bool isGetArea = false)
{
string whereStr = " AND CodeLevel IN(2,3)";
if (isGetArea)
{
whereStr = " AND CodeLevel IN(2,3,4) ";
}
StringBuilder sb = new StringBuilder();
sb.AppendFormat(@"
SELECT * FROM {0} WHERE 1=1 AND ParentID<>2 {1}
", TableName, whereStr);
sb.AppendFormat(" AND {0}={1} ", nameof(RB_Destination_Extend.Status), (int)Common.Enum.DateStateEnum.Normal);
return Get<RB_Destination_Extend>(sb.ToString()).ToList();
}
/// <summary>
/// 根据条件获取单个地区
/// </summary>
/// <param name="where"></param>
/// <returns></returns>
public RB_Destination_Extend GetEntityExt(RB_Destination_Extend where)
{
StringBuilder sb = new StringBuilder();
sb.AppendFormat("SELECT * FROM {0} WHERE 1=1 ", TableName);
if (where != null)
{
if (where.Name != null && !string.IsNullOrEmpty(where.Name.Trim()))
{
sb.AppendFormat(" AND {0}='{1}'", nameof(RB_Destination_Extend.Name), where.Name.Trim());
}
if (where.ParentID != null && where.ParentID > 0)
{
sb.AppendFormat(" AND {0}={1} ", nameof(RB_Destination_Extend.ID), where.ParentID);
}
}
sb.Append(" LIMIT 1;");
return Get<RB_Destination_Extend>(sb.ToString()).ToList().FirstOrDefault();
}
/// <summary>
/// 根据地区名称获取地区列表
/// </summary>
/// <param name="where"></param>
/// <returns></returns>
public List<RB_Destination_Extend> GetListByNames(string[] where)
{
StringBuilder sbWhere = new StringBuilder();
StringBuilder sb = new StringBuilder();
sb.AppendFormat("SELECT * FROM {0} WHERE 1=1 ", TableName);
sb.AppendFormat(" AND {0}<>{1} ", nameof(RB_Destination_Extend.CodeLevel), (int)AreaRegionEnum.DistrictEnum);
if (where != null && where.Length > 0)
{
var index = 0;
foreach (var item in where)
{
if (!string.IsNullOrEmpty(item.Trim()))
{
if (index == 0)
{
sbWhere.AppendFormat(" {0} LIKE '{1}%' ", nameof(RB_Destination_Extend.Name), item.Trim());
}
else
{
sbWhere.AppendFormat(" OR {0} LIKE '{1}%' ", nameof(RB_Destination_Extend.Name), item.Trim());
}
index++;
}
}
}
if (!string.IsNullOrEmpty(sbWhere.ToString()))
{
sb.AppendFormat(" AND ({0}) ", sbWhere.ToString());
}
return Get<RB_Destination_Extend>(sb.ToString()).ToList();
}
/// <summary>
/// 获取地区列表
/// </summary>
/// <returns></returns>
public List<Mall.Common.Data.Node> GetAllList()
{
List<Common.Data.Node> queryList = new List<Common.Data.Node>();
StringBuilder sb = new StringBuilder();
sb.AppendFormat("SELECT * FROM {0} WHERE 1=1 ", TableName);
sb.AppendFormat(" AND {0}={1} ", nameof(RB_Destination_Extend.Status), (int)Common.Enum.DateStateEnum.Normal);
List<RB_Destination_Extend> list = Get<RB_Destination_Extend>(sb.ToString()).ToList();
foreach (var item in list)
{
Common.Data.Node model = new Common.Data.Node()
{
I = item.ID,
N = item.Name,
E = !string.IsNullOrWhiteSpace(item.EnName) ? item.EnName : "",
C = !string.IsNullOrWhiteSpace(item.ThreeCode) ? item.ThreeCode : "",
L = Convert.ToInt32(item.CodeLevel),
P = Convert.ToInt32(item.ParentID),
S = (int)item.Status
};
queryList.Add(model);
}
return queryList;
}
/// <summary>
/// 根据Ids获取地区名称
/// </summary>
/// <param name="Ids">地区编号</param>
/// <returns></returns>
public string GetNames(string Ids)
{
if (!string.IsNullOrEmpty(Ids))
{
StringBuilder sb = new StringBuilder();
sb.AppendFormat("SELECT GROUP_CONCAT(Name) AS Name FROM {0} ", TableName);
sb.Append(" WHERE 1=1 ");
sb.AppendFormat(" AND {0}={1} ", nameof(RB_Destination_Extend.Status), (int)Common.Enum.DateStateEnum.Normal);
sb.AppendFormat(" AND Id in({0})", Ids.TrimStart(',').TrimEnd(','));
var obj = base.ExecuteScalar(sb.ToString());
if (obj != null)
{
return obj.ToString();
}
return "";
}
return "";
}
/// <summary>
/// 根据id 获取所有数据
/// </summary>
/// <param name="Ids"></param>
/// <returns></returns>
public List<RB_Destination> GetDictvalueListForIds(string Ids)
{
if (!string.IsNullOrEmpty(Ids))
{
StringBuilder sb = new StringBuilder();
sb.AppendFormat("SELECT * FROM {0} ", TableName);
sb.Append(" WHERE 1=1 ");
sb.AppendFormat(" AND {0}={1} ", nameof(RB_Destination_Extend.Status), (int)Common.Enum.DateStateEnum.Normal);
sb.AppendFormat(" AND Id in({0})", Ids.TrimStart(',').TrimEnd(','));
return base.Get(sb.ToString()).ToList();
}
return new List<RB_Destination>();
}
/// <summary>
/// 获取中国所有城市
/// </summary>
/// <returns></returns>
public List<RB_Destination> GetAllStartCity(int CountryId = 2)
{
string where = " 1=1";
if (CountryId > 0)
{
where += $@" and dpp.ID={CountryId}";
}
string sql = $@"SELECT d.* FROM rb_destination d
LEFT JOIN rb_destination dp ON d.ParentID=dp.ID
LEFT JOIN rb_destination dpp ON dp.ParentID=dpp.ID
WHERE {where} AND d.CodeLevel=3 AND d.`Status`=0";
return Get(sql).ToList();
}
/// <summary>
/// 获取中国所有城市
/// </summary>
/// <returns></returns>
public List<RB_Destination> GetAllStartCityTemp(int CountryId = 2)
{
string sql = $@"SELECT d.* FROM rb_destination d
LEFT JOIN rb_destination dp ON d.ParentID=dp.ID
LEFT JOIN rb_destination dpp ON dp.ParentID=dpp.ID ";
return Get(sql).ToList();
}
}
}
using Mall.Model.Entity.BaseSetUp;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Mall.Repository.BaseSetUp
{
public class RB_LogisticsRepository : RepositoryBase<RB_Logistics>
{
/// <summary>
/// 表名称
/// </summary>
public string TableName { get { return nameof(RB_Logistics); } }
/// <summary>
/// 根据商户id获取物流信息
/// </summary>
/// <param name="query">查询条件</param>
/// <returns></returns>
public List<RB_Logistics> GetListRepository(RB_Logistics query)
{
StringBuilder builder = new StringBuilder();
builder.Append($" SELECT * FROM {TableName} WHERE 1=1 ");
if (query != null)
{
if (query.TenantId > 0)
{
builder.Append($" AND TenantId={query.TenantId}");
}
}
return Get<RB_Logistics>(builder.ToString()).ToList();
}
}
}
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_LogisticsRulesPriceRepository:RepositoryBase<RB_LogisticsRulesPrice>
{
/// <summary>
/// 表名称
/// </summary>
public string TableName { get { return nameof(RB_LogisticsRulesPrice); } }
/// <summary>
/// 获取小程序列表
/// </summary>
/// <param name="query">查询条件</param>
/// <returns></returns>
public List<RB_LogisticsRulesPrice_Extend> GetListRepository(RB_LogisticsRulesPrice_Extend query)
{
StringBuilder builder = new StringBuilder();
builder.Append($" SELECT * FROM {TableName} WHERE 1=1 ");
if (query != null)
{
if (query.TenantId > 0)
{
builder.Append($" AND {nameof(RB_LogisticsRulesPrice_Extend.TenantId)}={query.TenantId}");
}
if (query.TenantId > 0)
{
builder.Append($" AND {nameof(RB_LogisticsRulesPrice_Extend.MallBaseId)}={query.MallBaseId}");
}
if (query.RulesId > 0)
{
builder.Append($" AND {nameof(RB_LogisticsRulesPrice_Extend.RulesId)}={query.RulesId}");
}
}
return Get<RB_LogisticsRulesPrice_Extend>(builder.ToString()).ToList();
}
}
}
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_LogisticsRulesRegionRepository : RepositoryBase<RB_LogisticsRulesRegion>
{
// <summary>
/// 表名称
/// </summary>
public string TableName { get { return nameof(RB_LogisticsRulesRegion); } }
// <summary>
/// 表名称
/// </summary>
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)
{
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 ");
if (query != null)
{
if (query.TenantId > 0)
{
builder.Append($" AND a.{nameof(RB_LogisticsRulesRegion_Extend.TenantId)}={query.TenantId}");
}
if (query.TenantId > 0)
{
builder.Append($" AND a.{nameof(RB_LogisticsRulesRegion_Extend.MallBaseId)}={query.MallBaseId}");
}
if (query.RulesPriceId > 0)
{
builder.Append($" AND a.{nameof(RB_LogisticsRulesRegion_Extend.RulesPriceId)}={query.RulesPriceId}");
}
if (!string.IsNullOrWhiteSpace(query.PriceIds))
{
builder.Append($" AND a.{nameof(RB_LogisticsRulesRegion_Extend.RulesPriceId)} in ({query.PriceIds})");
}
}
return Get<RB_LogisticsRulesRegion_Extend>(builder.ToString()).ToList();
}
}
}
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_LogisticsRulesRepository : RepositoryBase<RB_LogisticsRules>
{
/// <summary>
/// 表名称
/// </summary>
public string TableName { get { return nameof(RB_LogisticsRules); } }
/// <summary>
/// 物料规则列表
/// </summary>
/// <param name="pageIndex">页码</param>
/// <param name="pageSize">每页显示条数</param>
/// <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)
{
StringBuilder builder = new StringBuilder();
builder.Append($" SELECT * FROM {TableName} WHERE 1=1 ");
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}");
}
if (query.TenantId > 0)
{
builder.Append($" AND {nameof(RB_LogisticsRules_Extend.MallBaseId)}={query.MallBaseId}");
}
if (!string.IsNullOrWhiteSpace(query.RulesName))
{
builder.Append($" AND {nameof(RB_LogisticsRules_Extend.RulesName)} like '%{query.RulesName}%'");
}
}
return GetPage<RB_LogisticsRules_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_LogisticsRules_Extend> GetLogisticsRulesList( RB_LogisticsRules_Extend query)
{
StringBuilder builder = new StringBuilder();
builder.Append($" SELECT * FROM {TableName} WHERE 1=1 ");
if (query != null)
{
if (query.ID > 0)
{
builder.Append($" AND {nameof(RB_LogisticsRules_Extend.ID)}={query.ID}");
}
if (query.TenantId > 0)
{
builder.Append($" AND {nameof(RB_LogisticsRules_Extend.TenantId)}={query.TenantId}");
}
if (query.TenantId > 0)
{
builder.Append($" AND {nameof(RB_LogisticsRules_Extend.MallBaseId)}={query.MallBaseId}");
}
if (!string.IsNullOrWhiteSpace(query.RulesName))
{
builder.Append($" AND {nameof(RB_LogisticsRules_Extend.RulesName)} like '%{query.RulesName}%'");
}
}
return Get<RB_LogisticsRules_Extend>(builder.ToString()).ToList();
}
}
}
...@@ -9,6 +9,10 @@ namespace Mall.Repository.BaseSetUp ...@@ -9,6 +9,10 @@ namespace Mall.Repository.BaseSetUp
{ {
public class RB_MallBaseRepository : RepositoryBase<RB_MallBase> public class RB_MallBaseRepository : RepositoryBase<RB_MallBase>
{ {
/// <summary>
/// 表名称
/// </summary>
public string TableName { get { return nameof(RB_MallBase); } }
/// <summary> /// <summary>
/// 获取小程序列表 /// 获取小程序列表
/// </summary> /// </summary>
...@@ -20,9 +24,10 @@ namespace Mall.Repository.BaseSetUp ...@@ -20,9 +24,10 @@ namespace Mall.Repository.BaseSetUp
public List<RB_MallBase_Extend> GetPageListRepository(int pageIndex, int pageSize, out long rowCount, RB_MallBase_Extend query) public List<RB_MallBase_Extend> GetPageListRepository(int pageIndex, int pageSize, out long rowCount, RB_MallBase_Extend query)
{ {
StringBuilder builder = new StringBuilder(); StringBuilder builder = new StringBuilder();
builder.Append(" SELECT * FROM RB_MallBase WHERE 1=1 "); builder.Append($" SELECT * FROM {TableName} WHERE 1=1 ");
if (query != null) if (query != null)
{ {
// where += $@" and {nameof(RB_Customer_InfoCreate.CustomerId)}={dmodel.CustomerId}";
if (query.TenantId > 0) if (query.TenantId > 0)
{ {
builder.Append($" AND TenantId={query.TenantId}"); builder.Append($" AND TenantId={query.TenantId}");
...@@ -30,5 +35,25 @@ namespace Mall.Repository.BaseSetUp ...@@ -30,5 +35,25 @@ namespace Mall.Repository.BaseSetUp
} }
return GetPage<RB_MallBase_Extend>(pageIndex, pageSize, out rowCount, builder.ToString()).ToList(); return GetPage<RB_MallBase_Extend>(pageIndex, pageSize, out rowCount, builder.ToString()).ToList();
} }
/// <summary>
/// 获取小程序列表
/// </summary>
/// <param name="query">查询条件</param>
/// <returns></returns>
public List<RB_MallBase_Extend> GetListRepository(RB_MallBase_Extend query)
{
StringBuilder builder = new StringBuilder();
builder.Append($" SELECT * FROM {TableName} WHERE 1=1 ");
if (query != null)
{
if (query.TenantId > 0)
{
builder.Append($" AND TenantId={query.TenantId}");
}
}
return Get<RB_MallBase_Extend>( builder.ToString()).ToList();
}
} }
} }
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Mall.Common.API;
using Mall.Common.Plugin;
using Mall.Module.BaseSetUp;
using Mall.WebApi.Filter;
using Microsoft.AspNetCore.Cors;
using Microsoft.AspNetCore.Mvc;
using Newtonsoft.Json.Linq;
namespace Mall.WebApi.Controllers.MallBase
{
[Route("api/[controller]/[action]")]
[ApiExceptionFilter]
[ApiController]
[EnableCors("AllowCors")]
public class DestinationController : BaseController
{
/// <summary>
/// 地区模块处理类
/// </summary>
private DestinationModule destinationModule = new DestinationModule();
/// <summary>
/// 根据父节点编号获取子列表
/// </summary>
/// <param name="ParentID">父节点编号</param>
/// <returns></returns>
public virtual ApiResult GetChildList(RequestParm request)
{
JObject parm = JObject.Parse(request.msg.ToString());
int ID = parm.GetInt("Id");
if (ID > 0)
{
var CommonList = Mall.Common.Data.AreaDataHelper.GetAreaList();
if (CommonList != null && CommonList.Count > 0)
{
return ApiResult.Success("", CommonList.Where(qitem => qitem.P == ID).Select(qitem => new { ID = qitem.I, Name = qitem.N }));
}
var list = destinationModule.GetChildList(ID).Select(item => new { item.ID, item.Name });
return ApiResult.Success("", list);
}
else
{
return ApiResult.Failed("未找到相关数据!");
}
}
}
}
\ No newline at end of file
...@@ -4,6 +4,7 @@ using System.Linq; ...@@ -4,6 +4,7 @@ using System.Linq;
using System.Threading.Tasks; using System.Threading.Tasks;
using Mall.Common.API; using Mall.Common.API;
using Mall.Model.Entity.BaseSetUp; using Mall.Model.Entity.BaseSetUp;
using Mall.Model.Extend.BaseSetUp;
using Mall.Module.BaseSetUp; using Mall.Module.BaseSetUp;
using Mall.WebApi.Filter; using Mall.WebApi.Filter;
using Microsoft.AspNetCore.Cors; using Microsoft.AspNetCore.Cors;
...@@ -20,9 +21,12 @@ namespace Mall.WebApi.Controllers.MallBase ...@@ -20,9 +21,12 @@ namespace Mall.WebApi.Controllers.MallBase
{ {
private MallBaseModule mallBaseModule = new MallBaseModule(); private MallBaseModule mallBaseModule = new MallBaseModule();
public ApiResult AddOrUpdate() private Module.User.TenantModule TenantModule = new Module.User.TenantModule();
#region 基础设置
public ApiResult AddOrUpdateMallBase()
{ {
var query = JsonConvert.DeserializeObject<RB_MallBase>(RequestParm.msg.ToString()); var query = JsonConvert.DeserializeObject<RB_MallBase_Extend>(RequestParm.msg.ToString());
if (query == null) if (query == null)
{ {
...@@ -30,12 +34,34 @@ namespace Mall.WebApi.Controllers.MallBase ...@@ -30,12 +34,34 @@ namespace Mall.WebApi.Controllers.MallBase
} }
else else
{ {
query.TenantId = UserInfo.TenantId;
if (query.ID == 0)//新增 if (query.ID == 0)//新增
{ {
var TenantModel = TenantModule.GetTenantModule(query.TenantId);
if (TenantModel == null)
{
return ApiResult.Failed("请确保商户信息正确");
}
if (TenantModel.AccountStatus != 2)
{
return ApiResult.Failed("商户状态审核不通过");
}
if (TenantModel.IsEffective == 0 && TenantModel.AccountValidate.HasValue && TenantModel.AccountValidate.Value < System.DateTime.Now)
{
return ApiResult.Failed("商户账号已过期");
}
//判断当前商户下面有多少小程序
if (TenantModel.CreateMiniPrograme.HasValue)
{
var oldList = mallBaseModule.GetListRepository(query);
if (oldList.Count() >= TenantModel.CreateMiniPrograme.Value)
{
return ApiResult.Failed("商户可建小程序数:" + TenantModel.CreateMiniPrograme.Value);
}
}
} }
bool result = mallBaseModule.AddOrUpdate(query); bool result = mallBaseModule.AddOrUpdateMallBase(query);
if (result) if (result)
{ {
return ApiResult.Success("基础信息保存成功"); return ApiResult.Success("基础信息保存成功");
...@@ -47,5 +73,89 @@ namespace Mall.WebApi.Controllers.MallBase ...@@ -47,5 +73,89 @@ 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);
}
#endregion
#region 物流设置
#region 物流规格-物流设置
/// <summary>
/// 根据商户号获取物流信息
/// </summary>
/// <returns></returns>
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)
{
oldLogisticsModel = new RB_Logistics();
oldLogisticsModel.LogisticsType = Common.Enum.MallBase.LogisticsTypeEnum.ExpressBird;
}
return ApiResult.Success("", oldLogisticsModel);
}
/// <summary>
/// 保存物流信息
/// </summary>
/// <returns></returns>
public ApiResult AddOrUpdateLogistics()
{
var query = JsonConvert.DeserializeObject<RB_Logistics>(RequestParm.msg.ToString());
if (query == null)
{
return ApiResult.Failed("请传入物流基础信息");
}
else
{
query.TenantId = UserInfo.TenantId;
bool result = mallBaseModule.AddOrUpdateLogistics(query);
if (result)
{
return ApiResult.Success("物流设置信息保存成功");
}
else
{
return ApiResult.Failed("基物流设置信息保存失败");
}
}
}
#endregion
#endregion
} }
} }
\ No newline at end of file
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