添加项目文件。

This commit is contained in:
JianWeie
2021-12-20 21:27:32 +08:00
parent 747486f5cb
commit 82d825b7a5
3514 changed files with 887941 additions and 0 deletions

View File

@@ -0,0 +1,486 @@
/***********************************************************************
* Project: CoreCms
* ProjectName: 核心内容管理系统
* Web: https://www.corecms.net
* Author: 大灰灰
* Email: jianweie@163.com
* CreateTime: 2021/1/31 21:45:10
* Description: 暂无
***********************************************************************/
using System;
using System.Collections.Generic;
using System.Linq;
using System.Linq.Expressions;
using System.Threading.Tasks;
using CoreCms.Net.Caching.Manual;
using CoreCms.Net.Configuration;
using CoreCms.Net.IRepository;
using CoreCms.Net.IRepository.UnitOfWork;
using CoreCms.Net.IServices;
using CoreCms.Net.Loging;
using CoreCms.Net.Model.Entities;
using CoreCms.Net.Model.ViewModels.Basics;
using CoreCms.Net.Model.ViewModels.UI;
using CoreCms.Net.Model.ViewModels.DTO;
using SqlSugar;
namespace CoreCms.Net.Services.Basic
{
public class CoreCmsAreaServices : BaseServices<CoreCmsArea>, ICoreCmsAreaServices
{
private readonly ICoreCmsAreaRepository _dal;
private readonly IUnitOfWork _unitOfWork;
public CoreCmsAreaServices(IUnitOfWork unitOfWork, ICoreCmsAreaRepository dal)
{
this._dal = dal;
base.BaseDal = dal;
_unitOfWork = unitOfWork;
}
#region ==========================================================
/// <summary>
/// 重写异步插入方法
/// </summary>
/// <param name="entity">实体数据</param>
/// <returns></returns>
public new async Task<AdminUiCallBack> InsertAsync(CoreCmsArea entity)
{
return await _dal.InsertAsync(entity);
}
/// <summary>
/// 重写异步更新方法方法
/// </summary>
/// <param name="entity"></param>
/// <returns></returns>
public new async Task<AdminUiCallBack> UpdateAsync(CoreCmsArea entity)
{
return await _dal.UpdateAsync(entity);
}
/// <summary>
/// 重写异步更新方法方法
/// </summary>
/// <param name="entity"></param>
/// <returns></returns>
public new async Task<AdminUiCallBack> UpdateAsync(List<CoreCmsArea> entity)
{
return await _dal.UpdateAsync(entity);
}
/// <summary>
/// 重写删除指定ID的数据
/// </summary>
/// <param name="id"></param>
/// <returns></returns>
public new async Task<AdminUiCallBack> DeleteByIdAsync(object id)
{
return await _dal.DeleteByIdAsync(id);
}
/// <summary>
/// 重写删除指定ID集合的数据(批量删除)
/// </summary>
/// <param name="ids"></param>
/// <returns></returns>
public new async Task<AdminUiCallBack> DeleteByIdsAsync(int[] ids)
{
return await _dal.DeleteByIdsAsync(ids);
}
#endregion
#region ==========================================================
/// <summary>
/// 获取缓存的所有数据
/// </summary>
/// <returns></returns>
public async Task<List<CoreCmsArea>> GetCaChe()
{
return await _dal.GetCaChe();
}
/// <summary>
/// 更新cache
/// </summary>
public async Task<List<CoreCmsArea>> UpdateCaChe()
{
return await _dal.UpdateCaChe();
}
#endregion
#region
/// <summary>
/// 重写根据条件查询分页数据
/// </summary>
/// <param name="predicate">判断集合</param>
/// <param name="orderByType">排序方式</param>
/// <param name="pageIndex">当前页面索引</param>
/// <param name="pageSize">分布大小</param>
/// <param name="orderByExpression"></param>
/// <param name="blUseNoLock">是否使用WITH(NOLOCK)</param>
/// <returns></returns>
public new async Task<IPageList<CoreCmsArea>> QueryPageAsync(Expression<Func<CoreCmsArea, bool>> predicate,
Expression<Func<CoreCmsArea, object>> orderByExpression, OrderByType orderByType, int pageIndex = 1,
int pageSize = 20, bool blUseNoLock = false)
{
return await _dal.QueryPageAsync(predicate, orderByExpression, orderByType, pageIndex, pageSize, blUseNoLock);
}
#endregion
#region
/// <summary>
/// 获取所有省市区信息
/// </summary>
/// <returns></returns>
public async Task<List<AreaTreeDto>> GetTreeArea(List<PostAreasTreeNode> checkedAreases, int parentId = 0,
int currentChecked = 0)
{
var list = await UpdateCaChe();
var areaTrees = GetTrees(list, parentId, checkedAreases, currentChecked);
return areaTrees;
}
/// <summary>
/// 迭代方法
/// </summary>
/// <param name="oldNavs"></param>
/// <param name="parentId"></param>
/// <returns></returns>
private static List<AreaTreeDto> GetTrees(List<CoreCmsArea> allDatas, int parentId, List<PostAreasTreeNode> checkedAreases, int currentChecked = 0)
{
List<AreaTreeDto> childTree = new List<AreaTreeDto>();
var model = allDatas.Where(p => p.parentId == parentId).ToList();
foreach (var item in model)
{
var areaTree = new AreaTreeDto();
areaTree.id = item.id;
areaTree.title = item.name;
areaTree.isLast = allDatas.Exists(p => p.parentId == item.id) == false;
areaTree.level = (int)item.depth;
areaTree.parentId = (int)item.parentId;
var isChecked = "0";
var idStr = item.id.ToString();
var parentIdStr = item.parentId.ToString();
//判断是否选中的数据
if (checkedAreases != null)
{
var areaModel = checkedAreases.Find(p => p.id == idStr);
if (areaModel != null)
{
isChecked = areaModel.ischecked.ToString();
}
var parentModel = checkedAreases.Find(p => p.id == parentIdStr);
if (parentModel != null && parentModel.ischecked == 1)
{
isChecked = "1";
}
}
//当前父节点是1下面肯定都是1
if (currentChecked == 1)
{
isChecked = "1";
}
var checkArr = new AreaTreeCheckArr()
{
@checked = isChecked,
type = "0"
};
areaTree.checkArr = new List<AreaTreeCheckArr>();
areaTree.checkArr.Add(checkArr);
childTree.Add(areaTree);
areaTree.children = GetTrees(allDatas, item.id, checkedAreases, currentChecked);
}
return childTree;
}
#endregion
#region
/// <summary>
/// 组装地区数据
/// </summary>
public List<AreaTreeDto> resolve2(List<CoreCmsArea> allDatas, int parentId, List<PostAreasTreeNode> checkedAreases, int currentChecked = 0)
{
var areaTreeList = new List<AreaTreeDto>();
var nowList = allDatas.Where(p => p.parentId == parentId).ToList();
foreach (var item in nowList)
{
var isChecked = "0";
var idStr = item.id.ToString();
var parentIdStr = item.parentId.ToString();
//判断是否选中的数据
if (checkedAreases != null)
{
var model = checkedAreases.Find(p => p.id == idStr);
if (model != null)
{
isChecked = model.ischecked.ToString();
}
var parentModel = checkedAreases.Find(p => p.id == parentIdStr);
if (parentModel != null && parentModel.ischecked == 1)
{
isChecked = "1";
}
}
//当前父节点是1下面肯定都是1
if (currentChecked == 1)
{
isChecked = "1";
}
var isLast = false;
var isChild = allDatas.Exists(p => p.parentId == item.id);
if (!isChild)
{
isLast = true;
}
var areaTree = new AreaTreeDto();
areaTree.id = item.id;
areaTree.title = item.name;
areaTree.isLast = isLast;
areaTree.level = (int)item.depth;
areaTree.parentId = (int)item.parentId;
var checkArr = new AreaTreeCheckArr()
{
@checked = isChecked,
type = "0"
};
areaTree.checkArr = new List<AreaTreeCheckArr>();
areaTree.checkArr.Add(checkArr);
areaTreeList.Add(areaTree);
}
return areaTreeList;
}
#endregion
#region areaId获取三级区域名称
/// <summary>
/// 根据areaId获取三级区域名称
/// </summary>
/// <param name="areaId"></param>
/// <param name="cacheAreas"></param>
/// <returns></returns>
public async Task<WebApiCallBack> GetAreaFullName(int areaId, List<CoreCmsArea> cacheAreas = null)
{
var jm = new WebApiCallBack { status = true };
cacheAreas ??= await GetCaChe();
var arr = GetArea(cacheAreas, areaId);
var str = string.Empty;
if (arr.Any())
{
arr.Reverse();//倒序
arr.ForEach(p => { str += p.name + " "; });
}
jm.data = str;
return jm;
}
#endregion
#region id来返回省市区信息
/// <summary>
/// 根据id来返回省市区信息如果没有查到就返回省的列表
/// </summary>
public List<CoreCmsArea> GetArea(List<CoreCmsArea> cacheAreas, int id = 0)
{
var outAreas = new List<CoreCmsArea>();
if (id > 0)
{
GetParentArea(cacheAreas, id, outAreas);
}
return outAreas;
}
#endregion
#region
/// <summary>
/// 递归取得父节点信息
/// </summary>
/// <param name=""></param>
/// <param name="id"></param>
/// <param name="outAreas"></param>
/// <param name="cacheAreas"></param>
/// <returns></returns>
private void GetParentArea(List<CoreCmsArea> cacheAreas, int id, List<CoreCmsArea> outAreas)
{
//获取当前级别
var model = cacheAreas.FirstOrDefault(p => p.id == id);
if (model != null)
{
if (outAreas.All(p => p.id != model.id)) outAreas.Add(model);
//获取父级
var parentModel = cacheAreas.Find(p => p.id == model.parentId);
if (parentModel != null)
{
if (outAreas.All(p => p.id != parentModel.id)) outAreas.Add(parentModel);
if (parentModel.parentId != 0)
{
//上面还有节点
var parentParentModel = cacheAreas.Find(p => p.id == parentModel.parentId);
if (parentParentModel != null && outAreas.All(p => p.id != parentParentModel.id)) outAreas.Add(parentParentModel);
}
}
}
}
#endregion
#region ID
/// <summary>
/// 获取最终地区ID
/// </summary>
/// <param name="provinceName">省</param>
/// <param name="cityName">市</param>
/// <param name="countyName">县</param>
/// <param name="postalCode">邮编</param>
/// <returns></returns>
public async Task<WebApiCallBack> GetAreaId(string provinceName, string cityName, string countyName, string postalCode)
{
var jm = new WebApiCallBack();
if (string.IsNullOrEmpty(provinceName) || string.IsNullOrEmpty(cityName) || string.IsNullOrEmpty(countyName))
{
jm.msg = "请提交合法参数信息";
return jm;
}
jm = new WebApiCallBack
{
status = true,
data = await GetThreeAreaId(provinceName, cityName, countyName, postalCode)
};
return jm;
}
/// <summary>
/// 获取最终地区ID
/// </summary>
/// <param name="provinceName">省</param>
/// <param name="cityName">市</param>
/// <param name="countyName">县</param>
/// <param name="postalCode">邮编</param>
/// <returns></returns>
public async Task<int> GetThreeAreaId(string provinceName, string cityName, string countyName, string postalCode)
{
var areaData = await GetCaChe();
var id = 0;
var countyList = areaData.Where(p => p.depth == (int)GlobalEnumVars.AreaDepth.County && p.name == countyName).ToList();
if (countyList.Any())
{
if (countyList.Count > 1)
{
var cityModel = areaData.Find(p => p.depth == (int)GlobalEnumVars.AreaDepth.City && p.name == cityName);
if (cityModel != null)
{
//foreach (var item in countyList)
//{
// if (item.parentId == cityModel.id)
// {
// id = item.id;
// }
//}
var result = countyList.Find(p => p.parentId == cityModel.id);
return result?.id ?? 0;
}
}
else
{
id = countyList[0].id;
}
}
else
{
//var cityModel = areaData.Find(p => p.depth == (int)GlobalEnumVars.AreaDepth.City && p.name == cityName);
//if (cityModel != null)
//{
// //创建区域
// var area = new CoreCmsArea();
// area.depth = (int)GlobalEnumVars.AreaDepth.County;
// area.name = countyName;
// area.postalCode = postalCode;
// area.parentId = cityModel.id;
// area.sort = 100;
// id = await base.InsertAsync(area);
// await UpdateCaChe();
//}
//else
//{
// var province = areaData.Find(p => p.depth == (int)GlobalEnumVars.AreaDepth.Province && p.name == provinceName);
// if (province != null)
// {
// //创建城市
// var areaCity = new CoreCmsArea();
// areaCity.depth = (int)GlobalEnumVars.AreaDepth.City;
// areaCity.name = cityName;
// //areaCity.postalCode = postalCode;
// areaCity.parentId = province.id;
// areaCity.sort = 100;
// var cityId = await base.InsertAsync(areaCity);
// //创建区域
// var areaCounty = new CoreCmsArea();
// areaCounty.depth = (int)GlobalEnumVars.AreaDepth.County;
// areaCounty.name = countyName;
// areaCounty.postalCode = postalCode;
// areaCounty.parentId = cityId;
// areaCounty.sort = 100;
// id = await base.InsertAsync(areaCounty);
// }
// else
// {
// //创建省
// var areaProvince = new CoreCmsArea();
// areaProvince.depth = (int)GlobalEnumVars.AreaDepth.Province;
// areaProvince.name = cityName;
// //areaCity.postalCode = postalCode;
// areaProvince.parentId = (int)GlobalEnumVars.AreaDepth.ProvinceParentId;
// areaProvince.sort = 100;
// var provinceId = await base.InsertAsync(areaProvince);
// //创建城市
// var areaCity = new CoreCmsArea();
// areaCity.depth = (int)GlobalEnumVars.AreaDepth.City;
// areaCity.name = cityName;
// //areaCity.postalCode = postalCode;
// areaCity.parentId = provinceId;
// areaCity.sort = 100;
// var cityId = await base.InsertAsync(areaCity);
// //创建区域
// var areaCounty = new CoreCmsArea();
// areaCounty.depth = (int)GlobalEnumVars.AreaDepth.County;
// areaCounty.name = countyName;
// areaCounty.postalCode = postalCode;
// areaCounty.parentId = cityId;
// areaCounty.sort = 100;
// id = await base.InsertAsync(areaCounty);
// }
// await UpdateCaChe();
//}
}
return id;
}
#endregion
}
}

View File

@@ -0,0 +1,113 @@
/***********************************************************************
* Project: CoreCms
* ProjectName: 核心内容管理系统
* Web: https://www.corecms.net
* Author: 大灰灰
* Email: jianweie@163.com
* CreateTime: 2021/1/31 21:45:10
* Description: 暂无
***********************************************************************/
using System;
using System.Collections.Generic;
using System.Linq;
using System.Linq.Expressions;
using System.Threading.Tasks;
using CoreCms.Net.Configuration;
using CoreCms.Net.IRepository;
using CoreCms.Net.IRepository.UnitOfWork;
using CoreCms.Net.IServices;
using CoreCms.Net.Loging;
using CoreCms.Net.Model.Entities;
using CoreCms.Net.Model.ViewModels.Basics;
using CoreCms.Net.Model.ViewModels.UI;
using CoreCms.Net.Utility.Extensions;
using CoreCms.Net.Utility.Helper;
using SqlSugar;
namespace CoreCms.Net.Services
{
/// <summary>
/// 店铺店员关联表 接口实现
/// </summary>
public class CoreCmsClerkServices : BaseServices<CoreCmsClerk>, ICoreCmsClerkServices
{
private readonly ICoreCmsClerkRepository _dal;
private readonly ICoreCmsUserServices _userServices;
private readonly ICoreCmsSettingServices _settingServices;
private readonly IUnitOfWork _unitOfWork;
public CoreCmsClerkServices(IUnitOfWork unitOfWork, ICoreCmsClerkRepository dal
, ICoreCmsUserServices userServices
, ICoreCmsSettingServices settingServices)
{
this._dal = dal;
base.BaseDal = dal;
_unitOfWork = unitOfWork;
_userServices = userServices;
_settingServices = settingServices;
}
/// <summary>
/// 判断是不是店员
/// </summary>
/// <param name="userId"></param>
/// <returns></returns>
public async Task<WebApiCallBack> IsClerk(int userId)
{
var jm = new WebApiCallBack();
var allConfigs = await _settingServices.GetConfigDictionaries();
var storeSwitch = CommonHelper.GetConfigDictionary(allConfigs, SystemSettingConstVars.StoreSwitch).ObjectToInt(2);
if (storeSwitch == 1)
{
var bl = await base.ExistsAsync(p => p.userId == userId);
jm.status = true;
jm.data = bl;
jm.msg = bl ? "是店员" : "不是店员";
}
else
{
jm.status = true;
jm.data = false;
jm.msg = "未开启到店自提";
}
return jm;
}
/// <summary>
/// 获取门店关联用户分页数据
/// </summary>
/// <param name="predicate">判断集合</param>
/// <param name="orderByType">排序方式</param>
/// <param name="pageIndex">当前页面索引</param>
/// <param name="pageSize">分布大小</param>
/// <param name="orderByExpression"></param>
/// <param name="blUseNoLock">是否使用WITH(NOLOCK)</param>
/// <returns></returns>
public async Task<IPageList<StoreClerkDto>> QueryStoreClerkDtoPageAsync(Expression<Func<StoreClerkDto, bool>> predicate,
Expression<Func<StoreClerkDto, object>> orderByExpression, OrderByType orderByType, int pageIndex = 1,
int pageSize = 20, bool blUseNoLock = false)
{
return await _dal.QueryStoreClerkDtoPageAsync(predicate, orderByExpression, orderByType, pageIndex,
pageSize, blUseNoLock);
}
/// <summary>
/// 获取单个门店用户数据
/// </summary>
/// <param name="predicate">判断集合</param>
/// <param name="blUseNoLock">是否使用WITH(NOLOCK)</param>
/// <returns></returns>
public async Task<StoreClerkDto> QueryStoreClerkDtoByClauseAsync(Expression<Func<StoreClerkDto, bool>> predicate, bool blUseNoLock = false)
{
return await _dal.QueryStoreClerkDtoByClauseAsync(predicate, blUseNoLock);
}
}
}

View File

@@ -0,0 +1,247 @@
/***********************************************************************
* Project: CoreCms
* ProjectName: 核心内容管理系统
* Web: https://www.corecms.net
* Author: 大灰灰
* Email: jianweie@163.com
* CreateTime: 2021/1/31 21:45:10
* Description: 暂无
***********************************************************************/
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using CoreCms.Net.Configuration;
using CoreCms.Net.IRepository;
using CoreCms.Net.IRepository.UnitOfWork;
using CoreCms.Net.IServices;
using CoreCms.Net.Loging;
using CoreCms.Net.Model.Entities;
using CoreCms.Net.Model.ViewModels.Api;
using CoreCms.Net.Model.ViewModels.UI;
using CoreCms.Net.Utility.Helper;
using Flurl.Http;
namespace CoreCms.Net.Services
{
/// <summary>
/// 物流公司表 接口实现
/// </summary>
public class CoreCmsLogisticsServices : BaseServices<CoreCmsLogistics>, ICoreCmsLogisticsServices
{
private readonly ICoreCmsLogisticsRepository _dal;
private readonly ICoreCmsSettingServices _settingServices;
private readonly IUnitOfWork _unitOfWork;
public CoreCmsLogisticsServices(IUnitOfWork unitOfWork, ICoreCmsLogisticsRepository dal, ICoreCmsSettingServices settingServices)
{
this._dal = dal;
_settingServices = settingServices;
base.BaseDal = dal;
_unitOfWork = unitOfWork;
}
/// <summary>
/// 根据物流编码取物流名称等信息
/// </summary>
/// <param name="logiCode">物流编码</param>
/// <returns></returns>
public async Task<WebApiCallBack> GetLogiInfo(string logiCode)
{
var jm = new WebApiCallBack();
var model = await _dal.QueryByClauseAsync(p => p.logiCode == logiCode);
jm.status = model != null;
jm.data = model;
jm.msg = jm.status ? GlobalConstVars.GetDataSuccess : GlobalConstVars.GetDataFailure;
return jm;
}
/// <summary>
/// 通过接口更新所有快递公司信息
/// </summary>
public async Task<AdminUiCallBack> DoUpdateCompany()
{
var jm = new AdminUiCallBack();
var allConfigs = await _settingServices.GetConfigDictionaries();
var showApiAppid = CommonHelper.GetConfigDictionary(allConfigs, SystemSettingConstVars.ShowApiAppid);
var showApiSecret = CommonHelper.GetConfigDictionary(allConfigs, SystemSettingConstVars.ShowApiSecret);
var shopMobile = CommonHelper.GetConfigDictionary(allConfigs, SystemSettingConstVars.ShopMobile);
var showApiTimesTamp = DateTime.Now.ToString("yyyyMMddHHmmss");
var maxSize = 1500;
var signStr = "maxSize" + maxSize + "showapi_appid" + showApiAppid + "showapi_timestamp" + showApiTimesTamp + showApiSecret;
var md5Sign = CommonHelper.Md5For32(signStr).ToLower();
var url = "https://route.showapi.com/64-20?expName=&maxSize=1500&page=&showapi_appid=" + showApiAppid +
"&showapi_timestamp=" + showApiTimesTamp + "&showapi_sign=" + md5Sign;
var person = await url.GetJsonAsync<ShowApiGetExpressCompanyListResult>();
if (person.showapi_res_code == 0)
{
if (person.showapi_res_body != null && person.showapi_res_body.ret_code == 0 && person.showapi_res_body.expressList != null && person.showapi_res_body.expressList.Count > 0)
{
var list = new List<CoreCmsLogistics>();
var systemLogistics = SystemSettingDictionary.GetSystemLogistics();
systemLogistics.ForEach(p =>
{
var logistics = new CoreCmsLogistics();
logistics.logiCode = p.sKey;
logistics.logiName = p.sDescription;
logistics.imgUrl = "";
logistics.phone = shopMobile;
logistics.url = "";
logistics.sort = -1;
logistics.isDelete = false;
list.Add(logistics);
});
var count = 0;
person.showapi_res_body.expressList.ForEach(p =>
{
var logistics = new CoreCmsLogistics();
logistics.logiCode = p.simpleName;
logistics.logiName = p.expName;
logistics.imgUrl = p.imgUrl;
logistics.phone = p.phone;
logistics.url = p.url;
logistics.sort = count * 5;
logistics.isDelete = false;
list.Add(logistics);
count++;
});
await _dal.DeleteAsync(p => p.id > 0);
var bl = await _dal.InsertAsync(list) > 0;
jm.code = bl ? 0 : 1;
jm.msg = bl ? "数据刷新成功" : "数据刷新失败";
}
else
{
jm.msg = "接口获取数据失败";
}
}
else
{
jm.msg = person.showapi_res_error;
}
return jm;
}
/// <summary>
/// 通过接口获取快递信息
/// </summary>
/// <param name="com">来源</param>
/// <param name="number">编号</param>
/// <param name="phone">手机号码</param>
/// <returns></returns>
public async Task<WebApiCallBack> ExpressPoll(string com, string number, string phone)
{
var jm = new WebApiCallBack();
if (string.IsNullOrEmpty(com))
{
jm.msg = "请提交来源";
return jm;
}
else if (string.IsNullOrEmpty(number))
{
jm.msg = "请提交编号";
return jm;
}
else if (string.IsNullOrEmpty(phone))
{
jm.msg = "请提交手机号码";
return jm;
}
var allConfigs = await _settingServices.GetConfigDictionaries();
var showApiAppid = CommonHelper.GetConfigDictionary(allConfigs, SystemSettingConstVars.ShowApiAppid);
var showApiSecret = CommonHelper.GetConfigDictionary(allConfigs, SystemSettingConstVars.ShowApiSecret);
var showApiTimesTamp = DateTime.Now.ToString("yyyyMMddHHmmss");
var signStr = "com" + com + "nu" + number + "phone" + phone + "showapi_appid" + showApiAppid + "showapi_timestamp" + showApiTimesTamp + showApiSecret;
var md5Sign = CommonHelper.Md5For32(signStr).ToLower();
var url = "https://route.showapi.com/64-19?com=" + com + "&nu=" + number + "&phone=" + phone + "&showapi_appid=" + showApiAppid +
"&showapi_timestamp=" + showApiTimesTamp + "&showapi_sign=" + md5Sign;
var result = await url.GetJsonAsync<ShowApiGetExpressPollResult>();
if (result.showapi_res_code != 0)
{
jm.status = false;
jm.msg = result.showapi_res_error;
}
else
{
switch (result.showapi_res_body.ret_code)
{
case 0:
jm.status = true;
jm.msg = "查询成功";
jm.data = result.showapi_res_body;
break;
case 1:
jm.status = false;
jm.msg = "输入参数错误";
jm.data = result.showapi_res_body;
break;
case 2:
jm.status = false;
jm.msg = "查不到物流信息";
jm.data = result.showapi_res_body;
break;
case 3:
jm.status = false;
jm.msg = "单号不符合规则";
jm.data = result.showapi_res_body;
break;
case 4:
jm.status = false;
jm.msg = "快递公司编码不符合规则";
jm.data = result.showapi_res_body;
break;
case 5:
jm.status = false;
jm.msg = "快递查询渠道异常";
jm.data = result.showapi_res_body;
break;
case 6:
jm.status = false;
jm.msg = " auto时未查到单号对应的快递公司,请指定快递公司编码";
jm.data = result.showapi_res_body;
break;
case 7:
jm.status = false;
jm.msg = "单号与手机号不匹配";
jm.data = result.showapi_res_body;
break;
default:
jm.status = false;
jm.msg = "接口调用失败";
jm.data = result.showapi_res_body;
break;
}
}
return jm;
}
}
}

View File

@@ -0,0 +1,76 @@
/***********************************************************************
* Project: CoreCms
* ProjectName: 核心内容管理系统
* Web: https://www.corecms.net
* Author: 大灰灰
* Email: jianweie@163.com
* CreateTime: 2021/1/31 21:45:10
* Description: 暂无
***********************************************************************/
using System;
using System.Collections.Generic;
using System.Linq.Expressions;
using System.Threading.Tasks;
using CoreCms.Net.Configuration;
using CoreCms.Net.IRepository;
using CoreCms.Net.IRepository.UnitOfWork;
using CoreCms.Net.IServices;
using CoreCms.Net.Model.Entities;
using CoreCms.Net.Model.ViewModels.Basics;
using CoreCms.Net.Model.ViewModels.UI;
using SqlSugar;
namespace CoreCms.Net.Services
{
/// <summary>
/// 公告表 接口实现
/// </summary>
public class CoreCmsNoticeServices : BaseServices<CoreCmsNotice>, ICoreCmsNoticeServices
{
private readonly ICoreCmsNoticeRepository _dal;
private readonly IUnitOfWork _unitOfWork;
public CoreCmsNoticeServices(IUnitOfWork unitOfWork, ICoreCmsNoticeRepository dal)
{
this._dal = dal;
base.BaseDal = dal;
_unitOfWork = unitOfWork;
}
/// <summary>
/// 重写根据条件查询分页数据
/// </summary>
/// <param name="predicate">判断集合</param>
/// <param name="orderByType">排序方式</param>
/// <param name="pageIndex">当前页面索引</param>
/// <param name="pageSize">分布大小</param>
/// <param name="orderByExpression"></param>
/// <returns></returns>
public async Task<IPageList<CoreCmsNotice>> QueryPageAsync(Expression<Func<CoreCmsNotice, bool>> predicate,
Expression<Func<CoreCmsNotice, object>> orderByExpression, OrderByType orderByType, int pageIndex = 1,
int pageSize = 20)
{
return await _dal.QueryPageAsync(predicate, orderByExpression, orderByType, pageIndex, pageSize);
}
/// <summary>
/// 获取列表首页用
/// </summary>
/// <param name="predicate">判断集合</param>
/// <param name="orderByType">排序方式</param>
/// <param name="pageIndex">当前页面索引</param>
/// <param name="pageSize">分布大小</param>
/// <param name="orderByExpression"></param>
/// <returns></returns>
public async Task<List<CoreCmsNotice>> QueryListAsync(Expression<Func<CoreCmsNotice, bool>> predicate,
Expression<Func<CoreCmsNotice, object>> orderByExpression, OrderByType orderByType, int pageIndex = 1,
int pageSize = 20)
{
return await _dal.QueryListAsync(predicate, orderByExpression, orderByType, pageIndex, pageSize);
}
}
}

View File

@@ -0,0 +1,38 @@
/***********************************************************************
* Project: CoreCms
* ProjectName: 核心内容管理系统
* Web: https://www.corecms.net
* Author: 大灰灰
* Email: jianweie@163.com
* CreateTime: 2021/1/31 21:45:10
* Description: 暂无
***********************************************************************/
using System;
using System.Threading.Tasks;
using CoreCms.Net.Configuration;
using CoreCms.Net.IRepository;
using CoreCms.Net.IRepository.UnitOfWork;
using CoreCms.Net.IServices;
using CoreCms.Net.Model.Entities;
using CoreCms.Net.Model.ViewModels.UI;
namespace CoreCms.Net.Services
{
/// <summary>
/// 单页内容 接口实现
/// </summary>
public class CoreCmsPagesItemsServices : BaseServices<CoreCmsPagesItems>, ICoreCmsPagesItemsServices
{
private readonly ICoreCmsPagesItemsRepository _dal;
private readonly IUnitOfWork _unitOfWork;
public CoreCmsPagesItemsServices(IUnitOfWork unitOfWork, ICoreCmsPagesItemsRepository dal)
{
this._dal = dal;
base.BaseDal = dal;
_unitOfWork = unitOfWork;
}
}
}

View File

@@ -0,0 +1,778 @@
/***********************************************************************
* Project: CoreCms
* ProjectName: 核心内容管理系统
* Web: https://www.corecms.net
* Author: 大灰灰
* Email: jianweie@163.com
* CreateTime: 2021/1/31 21:45:10
* Description: 暂无
***********************************************************************/
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using CoreCms.Net.Configuration;
using CoreCms.Net.IRepository;
using CoreCms.Net.IRepository.UnitOfWork;
using CoreCms.Net.IServices;
using CoreCms.Net.Loging;
using CoreCms.Net.Model.Entities;
using CoreCms.Net.Model.Entities.Expression;
using CoreCms.Net.Model.FromBody;
using CoreCms.Net.Model.ViewModels.DTO;
using CoreCms.Net.Model.ViewModels.UI;
using CoreCms.Net.Utility.Extensions;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using SqlSugar;
namespace CoreCms.Net.Services
{
/// <summary>
/// 单页 接口实现
/// </summary>
public class CoreCmsPagesServices : BaseServices<CoreCmsPages>, ICoreCmsPagesServices
{
private readonly ICoreCmsPagesRepository _dal;
private readonly ICoreCmsPagesItemsRepository _pagesItemsRepository;
private readonly ICoreCmsPromotionServices _promotionServices;
private readonly ICoreCmsNoticeServices _noticeServices;
private readonly ICoreCmsGoodsCategoryServices _goodsCategoryServices;
private readonly ICoreCmsSettingServices _settingServices;
private readonly ICoreCmsGoodsServices _goodsServices;
private readonly ICoreCmsArticleServices _articleServices;
private readonly ICoreCmsPromotionConditionServices _promotionConditionServices;
private readonly ICoreCmsPinTuanRuleServices _pinTuanRuleServices;
private readonly ICoreCmsServicesServices _servicesServices;
private readonly IUnitOfWork _unitOfWork;
public CoreCmsPagesServices(IUnitOfWork unitOfWork
, ICoreCmsPagesRepository dal
, ICoreCmsPagesItemsRepository pagesItemsRepository, ICoreCmsPromotionServices promotionServices, ICoreCmsNoticeServices noticeServices, ICoreCmsGoodsCategoryServices goodsCategoryServices, ICoreCmsSettingServices settingServices, ICoreCmsGoodsServices goodsServices, ICoreCmsArticleServices articleServices, ICoreCmsPromotionConditionServices promotionConditionServices, ICoreCmsPinTuanRuleServices pinTuanRuleServices, ICoreCmsServicesServices servicesServices)
{
this._dal = dal;
_pagesItemsRepository = pagesItemsRepository;
_promotionServices = promotionServices;
_noticeServices = noticeServices;
_goodsCategoryServices = goodsCategoryServices;
_settingServices = settingServices;
_goodsServices = goodsServices;
_articleServices = articleServices;
_promotionConditionServices = promotionConditionServices;
_pinTuanRuleServices = pinTuanRuleServices;
_servicesServices = servicesServices;
base.BaseDal = dal;
_unitOfWork = unitOfWork;
}
/// <summary>
/// 重写异步插入方法
/// </summary>
/// <param name="entity">实体数据</param>
/// <returns></returns>
public new async Task<AdminUiCallBack> InsertAsync(CoreCmsPages entity)
{
return await _dal.InsertAsync(entity);
}
/// <summary>
/// 重写异步更新方法方法
/// </summary>
/// <param name="entity"></param>
/// <returns></returns>
public new async Task<AdminUiCallBack> UpdateAsync(CoreCmsPages entity)
{
return await _dal.UpdateAsync(entity);
}
/// <summary>
/// 重写删除指定ID的数据
/// </summary>
/// <param name="id"></param>
/// <returns></returns>
public async Task<AdminUiCallBack> DeleteByIdAsync(int id)
{
return await _dal.DeleteByIdAsync(id);
}
/// <summary>
/// 更新设计
/// </summary>
/// <param name="entity"></param>
/// <returns></returns>
public async Task<AdminUiCallBack> UpdateDesignAsync(FmPagesUpdate entity)
{
return await _dal.UpdateDesignAsync(entity);
}
/// <summary>
/// 复制一个同样的数据
/// </summary>
/// <param name="id"></param>
/// <returns></returns>
public async Task<AdminUiCallBack> CopyByIdAsync(int id)
{
return await _dal.CopyByIdAsync(id);
}
#region
/// <summary>
/// 获取首页数据
/// </summary>
/// <param name="code"></param>
/// <returns></returns>
public async Task<WebApiCallBack> GetPageConfig(string code)
{
var jm = new WebApiCallBack();
var wherePage = PredicateBuilder.True<CoreCmsPages>();
wherePage = code == "mobile_home" ? wherePage.And(p => p.type == 1) : wherePage.And(p => p.code == code);
var model = await _dal.QueryByClauseAsync(wherePage);
if (model == null)
{
return jm;
}
jm.status = true;
var items = await _pagesItemsRepository.QueryListByClauseAsync(p => p.pageCode == model.code, p => p.sort, OrderByType.Asc);
var itemsDto = new List<PagesItemsDto>();
foreach (var item in items)
{
var dto = new PagesItemsDto();
dto.id = item.id;
dto.widgetCode = item.widgetCode;
dto.pageCode = item.pageCode;
dto.positionId = item.positionId;
dto.sort = item.sort;
item.parameters = item.parameters.Replace("/images/empty-banner.png", "/static/images/common/empty-banner.png");
if (item.widgetCode == "search") //搜索
{
dto.parameters = (JObject)JsonConvert.DeserializeObject(item.parameters);
}
else if (item.widgetCode == "tabBar")
{
dto.parameters = (JObject)JsonConvert.DeserializeObject(item.parameters);
}
else if (item.widgetCode == "notice")
{
JObject parameters = (JObject)JsonConvert.DeserializeObject(item.parameters);
if (parameters != null && parameters.ContainsKey("type") && parameters["type"].ToString() == "auto")
{
var list = await _noticeServices.QueryListAsync(p => p.isDel == false, p => p.createTime, OrderByType.Desc, 1, 20);
if (list != null && list.Any())
{
JArray result = JArray.FromObject(list);
parameters.Remove("list");
parameters.Add("list", result);
}
}
else if (parameters != null && parameters.ContainsKey("type") && parameters["type"].ToString() == "choose")
{
var where = PredicateBuilder.True<CoreCmsNotice>();
var orderBy = string.Empty;
var noticeIdsStr = string.Empty;
if (parameters != null && parameters.ContainsKey("list"))
{
JArray result = JArray.Parse(parameters["list"].ToString());
var noticeIds = new List<int>();
foreach (var ss in result) //查找某个字段与值
{
var noticeId = ((JObject)ss)["id"].ObjectToInt(0);
if (noticeId > 0)
{
noticeIds.Add(noticeId);
}
}
where = where.And(p => noticeIds.Contains(p.id));
if (noticeIds.Any())
{
noticeIdsStr = string.Join(",", noticeIdsStr);
//按照固定的序列id进行排序
if (AppSettingsConstVars.DbDbType == DbType.SqlServer.ToString())
{
orderBy = " CHARINDEX(RTRIM(CAST(id as NCHAR)),'" + noticeIdsStr + "') ";
}
else if (AppSettingsConstVars.DbDbType == DbType.MySql.ToString())
{
orderBy = " find_in_set(id,'" + noticeIdsStr + "') ";
}
}
}
var notices = await _noticeServices.QueryListByClauseAsync(where, orderBy);
if (notices != null && notices.Any())
{
JArray result = JArray.FromObject(notices);
parameters.Remove("list");
parameters.Add("list", result);
}
else
{
parameters.Remove("list");
parameters.Add("list", new JArray());
}
}
dto.parameters = parameters;
}
else if (item.widgetCode == "imgSlide")
{
dto.parameters = (JObject)JsonConvert.DeserializeObject(item.parameters);
}
else if (item.widgetCode == "coupon")
{
JObject parameters = (JObject)JsonConvert.DeserializeObject(item.parameters);
if (parameters != null && parameters.ContainsKey("limit") && parameters["limit"].ObjectToInt(0) != 0)
{
var list = await _promotionServices.ReceiveCouponList(parameters["limit"].ObjectToInt(0));
if (list != null && list.Any())
{
JArray result = JArray.FromObject(list);
parameters.Remove("list");
parameters.Add("list", result);
}
}
dto.parameters = parameters;
}
else if (item.widgetCode == "blank")
{
dto.parameters = (JObject)JsonConvert.DeserializeObject(item.parameters);
}
else if (item.widgetCode == "textarea")
{
JObject parameters = new JObject();
parameters["value"] = item.parameters;
dto.parameters = parameters;
}
else if (item.widgetCode == "video")
{
dto.parameters = (JObject)JsonConvert.DeserializeObject(item.parameters);
}
else if (item.widgetCode == "imgWindow")
{
dto.parameters = (JObject)JsonConvert.DeserializeObject(item.parameters);
}
else if (item.widgetCode == "imgSingle")
{
dto.parameters = (JObject)JsonConvert.DeserializeObject(item.parameters);
}
else if (item.widgetCode == "goodTabBar")
{
JObject parameters = (JObject)JsonConvert.DeserializeObject(item.parameters);
if (parameters != null && parameters.ContainsKey("list"))
{
var list = JArray.Parse(parameters["list"].ToString());
var newList = new JArray();
foreach (var jToken in list)
{
var child = (JObject)jToken;
var where = PredicateBuilder.True<CoreCmsGoods>();
where = where.And(p => p.isDel == false);
where = where.And(p => p.isMarketable == true);
if (child != null && child.ContainsKey("type") && child["type"].ToString() == "auto")
{
//商品分类,同时取所有子分类
if (child.ContainsKey("classifyId") && child["classifyId"].ObjectToInt(0) > 0)
{
var classifyId = child["classifyId"].ObjectToInt(0);
var childCats = await _goodsCategoryServices.QueryListByClauseAsync(p => p.parentId == classifyId);
var catIds = childCats != null && childCats.Any()
? childCats.Select(p => p.id).ToList()
: new List<int>();
catIds.Add(classifyId);
where = where.And(p => catIds.Contains(p.goodsCategoryId));
//扩展分类 CoreCmsGoodsCategory
}
//品牌筛选
if (child.ContainsKey("brandId") && child["brandId"].ObjectToInt(0) > 0)
{
var brandId = child["brandId"].ObjectToInt(0);
where = where.And(p => p.brandId == brandId);
}
var limit = 0;
if (child.ContainsKey("limit") && child["limit"].ObjectToInt(0) > 0)
{
limit = child["limit"].ObjectToInt(0);
}
limit = limit > 0 ? limit : 10;
var goods = await _goodsServices.QueryListByClauseAsync(where, limit, p => p.createTime, OrderByType.Desc, true);
if (goods != null && goods.Any())
{
JArray result = JArray.FromObject(goods);
child.Remove("list");
child.Add("list", result);
}
else
{
child.Remove("list");
child.Add("list", new JArray());
}
}
else
{
var orderBy = string.Empty;
string goodidsStr;
if (child != null && child.ContainsKey("list"))
{
JArray result = JArray.Parse(child["list"].ToString());
var goodids = new List<int>();
foreach (var ss in result) //查找某个字段与值
{
var goodid = ((JObject)ss)["id"].ObjectToInt(0);
if (goodid > 0)
{
goodids.Add(goodid);
}
}
where = where.And(p => goodids.Contains(p.id));
if (goodids.Any())
{
goodidsStr = string.Join(",", goodids);
//按照id序列打乱后的顺序排序
if (AppSettingsConstVars.DbDbType == DbType.SqlServer.ToString())
{
orderBy = " CHARINDEX(RTRIM(CAST(id as NCHAR)),'" + goodidsStr + "') ";
}
else if (AppSettingsConstVars.DbDbType == DbType.MySql.ToString())
{
orderBy = " find_in_set(id,'" + goodidsStr + "') ";
}
}
}
var goods = await _goodsServices.QueryListByClauseAsync(where, orderBy);
if (goods != null && goods.Any())
{
JArray result = JArray.FromObject(goods);
child.Remove("list");
child.Add("list", result);
}
else
{
child.Remove("list");
child.Add("list", new JArray());
}
}
newList.Add(child);
}
if (newList != null && newList.Any())
{
parameters.Remove("list");
parameters.Add("list", newList);
}
}
dto.parameters = parameters;
}
else if (item.widgetCode == "goods")
{
JObject parameters = (JObject)JsonConvert.DeserializeObject(item.parameters);
var where = PredicateBuilder.True<CoreCmsGoods>();
where = where.And(p => p.isDel == false);
where = where.And(p => p.isMarketable == true);
if (parameters != null && parameters.ContainsKey("type") && parameters["type"].ToString() == "auto")
{
//商品分类,同时取所有子分类
if (parameters.ContainsKey("classifyId") && parameters["classifyId"].ObjectToInt(0) > 0)
{
var classifyId = parameters["classifyId"].ObjectToInt(0);
var childCats = await _goodsCategoryServices.QueryListByClauseAsync(p => p.parentId == classifyId);
var catIds = childCats != null && childCats.Any()
? childCats.Select(p => p.id).ToList()
: new List<int>();
catIds.Add(classifyId);
where = where.And(p => catIds.Contains(p.goodsCategoryId));
//扩展分类 CoreCmsGoodsCategory
}
//品牌筛选
if (parameters.ContainsKey("brandId") && parameters["brandId"].ObjectToInt(0) > 0)
{
var brandId = parameters["brandId"].ObjectToInt(0);
where = where.And(p => p.brandId == brandId);
}
var limit = 0;
if (parameters.ContainsKey("limit") && parameters["limit"].ObjectToInt(0) > 0)
{
limit = parameters["limit"].ObjectToInt(0);
}
limit = limit > 0 ? limit : 10;
var goods = await _goodsServices.QueryListByClauseAsync(where, limit, p => p.createTime, OrderByType.Desc, false);
if (goods != null && goods.Any())
{
JArray result = JArray.FromObject(goods);
parameters.Remove("list");
parameters.Add("list", result);
}
else
{
parameters.Remove("list");
parameters.Add("list", new JArray());
}
}
else
{
var orderBy = string.Empty;
var goodidsStr = string.Empty;
if (parameters != null && parameters.ContainsKey("list"))
{
JArray result = JArray.Parse(parameters["list"].ToString());
var goodids = new List<int>();
foreach (var ss in result) //查找某个字段与值
{
var goodid = ((JObject)ss)["id"].ObjectToInt(0);
if (goodid > 0)
{
goodids.Add(goodid);
}
}
where = where.And(p => goodids.Contains(p.id));
if (goodids.Any())
{
goodidsStr = string.Join(",", goodids);
//按照id序列打乱后的顺序排序
if (AppSettingsConstVars.DbDbType == DbType.SqlServer.ToString())
{
orderBy = " CHARINDEX(RTRIM(CAST(id as NCHAR)),'" + goodidsStr + "') ";
}
else if (AppSettingsConstVars.DbDbType == DbType.MySql.ToString())
{
orderBy = " find_in_set(id,'" + goodidsStr + "') ";
}
}
}
var goods = await _goodsServices.QueryListByClauseAsync(where, orderBy);
if (goods != null && goods.Any())
{
JArray result = JArray.FromObject(goods);
parameters.Remove("list");
parameters.Add("list", result);
}
else
{
parameters.Remove("list");
parameters.Add("list", new JArray());
}
}
dto.parameters = parameters;
}
else if (item.widgetCode == "article")
{
dto.parameters = (JObject)JsonConvert.DeserializeObject(item.parameters);
}
else if (item.widgetCode == "articleClassify")
{
JObject parameters = (JObject)JsonConvert.DeserializeObject(item.parameters);
if (parameters != null)
{
if (parameters.ContainsKey("articleClassifyId") && parameters["articleClassifyId"].ObjectToInt(0) > 0)
{
var articleClassifyId = parameters["articleClassifyId"].ObjectToInt(0);
var limit = parameters["limit"].ObjectToInt(0);
limit = limit > 0 ? limit : 20;
var list = await _articleServices.QueryPageAsync(p => p.typeId == articleClassifyId,
p => p.createTime, OrderByType.Desc, 1, limit);
if (list != null && list.Any())
{
JArray result = JArray.FromObject(list);
parameters.Remove("list");
parameters.Add("list", result);
}
}
}
dto.parameters = parameters;
}
else if (item.widgetCode == "navBar")
{
dto.parameters = (JObject)JsonConvert.DeserializeObject(item.parameters);
}
else if (item.widgetCode == "groupPurchase")
{
JObject parameters = (JObject)JsonConvert.DeserializeObject(item.parameters);
if (parameters != null && parameters.ContainsKey("list"))
{
JArray result = JArray.Parse(parameters["list"].ToString());
var newReslut = new JArray();
foreach (var jToken in result)
{
var ss = (JObject)jToken;
if (ss.ContainsKey("id"))
{
//判断拼团状态
var dt = DateTime.Now;
var promotionId = ((JObject)ss)["id"].ObjectToInt(0);
if (promotionId > 0)
{
var promotionModel = await _promotionServices.QueryByClauseAsync(p => p.id == promotionId && p.isEnable == true && p.startTime <= dt && p.endTime > dt);
if (promotionModel != null)
{
var condition = await _promotionConditionServices.QueryByClauseAsync(p => p.promotionId == promotionId);
if (condition != null)
{
var obj = (JObject)JsonConvert.DeserializeObject(condition.parameters);
if (obj.ContainsKey("goodsId") && obj["goodsId"].ObjectToInt(0) > 0)
{
var goodsId = obj["goodsId"].ObjectToInt(0);
var goods = await _promotionServices.GetGroupDetail(goodsId, 0, "group", promotionId);
if (goods.status)
{
var goodJson = JsonConvert.SerializeObject(goods.data);
((JObject)ss).Add("goods", JToken.Parse(goodJson));
}
}
}
var startStatus = 1;
int lastTime = 0;
bool isOverdue = false;
if (promotionModel.startTime > dt)
{
startStatus = (int)GlobalEnumVars.PinTuanRuleStatus.notBegun;
TimeSpan ts = promotionModel.startTime.Subtract(dt);
lastTime = (int)ts.TotalSeconds;
isOverdue = lastTime > 0;
}
else if (promotionModel.startTime <= dt && promotionModel.endTime > dt)
{
startStatus = (int)GlobalEnumVars.PinTuanRuleStatus.begin;
TimeSpan ts = promotionModel.endTime.Subtract(dt);
lastTime = (int)ts.TotalSeconds;
isOverdue = lastTime > 0;
}
else
{
startStatus = (int)GlobalEnumVars.PinTuanRuleStatus.haveExpired;
}
((JObject)ss).Add("startStatus", startStatus);
((JObject)ss).Add("lastTime", lastTime);
((JObject)ss).Add("isOverdue", isOverdue);
newReslut.Add(ss);
}
}
}
}
parameters.Remove("list");
parameters.Add("list", newReslut);
}
dto.parameters = parameters;
}
else if (item.widgetCode == "record")
{
dto.parameters = (JObject)JsonConvert.DeserializeObject(item.parameters);
}
else if (item.widgetCode == "pinTuan")
{
JObject parameters = (JObject)JsonConvert.DeserializeObject(item.parameters);
if (parameters != null && parameters.ContainsKey("list"))
{
JArray result = JArray.Parse(parameters["list"].ToString());
var newReslut = new JArray();
foreach (JObject ss in result)
{
if (ss.ContainsKey("goodsId"))
{
var goodsId = ((JObject)ss)["goodsId"].ObjectToInt(0);
if (goodsId > 0)
{
var goodsInfo = await _pinTuanRuleServices.GetPinTuanInfo(goodsId);
if (goodsInfo != null)
{
var pinTuanStartStatus = 1;
int lastTime = 0;
bool isOverdue = false;
//判断拼团状态
var dt = DateTime.Now;
if (goodsInfo.startTime > dt)
{
pinTuanStartStatus = (int)GlobalEnumVars.PinTuanRuleStatus.notBegun;
TimeSpan ts = goodsInfo.startTime.Subtract(dt);
lastTime = (int)ts.TotalSeconds;
isOverdue = lastTime > 0;
}
else if (goodsInfo.startTime <= dt && goodsInfo.endTime > dt)
{
pinTuanStartStatus = (int)GlobalEnumVars.PinTuanRuleStatus.begin;
TimeSpan ts = goodsInfo.endTime.Subtract(dt);
lastTime = (int)ts.TotalSeconds;
isOverdue = lastTime > 0;
}
else
{
pinTuanStartStatus = (int)GlobalEnumVars.PinTuanRuleStatus.haveExpired;
}
decimal pinTuanPrice = goodsInfo.goodsPrice - goodsInfo.discountAmount;
if (pinTuanPrice < 0) pinTuanPrice = 0;
var obj = new JObject();
((JObject)obj).Add("pinTuanStartStatus", pinTuanStartStatus);
((JObject)obj).Add("lastTime", lastTime);
((JObject)obj).Add("isOverdue", isOverdue);
((JObject)obj).Add("pinTuanPrice", pinTuanPrice);
((JObject)obj).Add("createTime", goodsInfo.createTime);
((JObject)obj).Add("discountAmount", goodsInfo.discountAmount);
((JObject)obj).Add("endTime", goodsInfo.endTime);
((JObject)obj).Add("goodsId", goodsInfo.goodsId);
((JObject)obj).Add("goodsImage", goodsInfo.goodsImage);
((JObject)obj).Add("goodsName", goodsInfo.goodsName);
((JObject)obj).Add("goodsPrice", goodsInfo.goodsPrice);
((JObject)obj).Add("id", goodsInfo.id);
((JObject)obj).Add("isStatusOpen", goodsInfo.isStatusOpen);
((JObject)obj).Add("maxGoodsNums", goodsInfo.maxGoodsNums);
((JObject)obj).Add("maxNums", goodsInfo.maxNums);
((JObject)obj).Add("name", goodsInfo.name);
((JObject)obj).Add("peopleNumber", goodsInfo.peopleNumber);
((JObject)obj).Add("significantInterval", goodsInfo.significantInterval);
((JObject)obj).Add("sort", goodsInfo.sort);
((JObject)obj).Add("startTime", goodsInfo.startTime);
((JObject)obj).Add("updateTime", goodsInfo.updateTime);
//((JObject)ss).Add("goodsInfo", JToken.FromObject(goodsInfo));
newReslut.Add(obj);
}
}
}
}
parameters.Remove("list");
parameters.Add("list", newReslut);
}
dto.parameters = parameters;
}
else if (item.widgetCode == "service")
{
JObject parameters = (JObject)JsonConvert.DeserializeObject(item.parameters);
if (parameters != null && parameters.ContainsKey("list"))
{
JArray result = JArray.Parse(parameters["list"].ToString());
foreach (JObject ss in result)
{
if (ss.ContainsKey("id"))
{
var id = ((JObject)ss)["id"].ObjectToInt(0);
if (id > 0)
{
var serviceInfo = await _servicesServices.QueryByIdAsync(id);
if (serviceInfo != null)
{
var pinTuanStartStatus = 1;
int lastTime = 0;
bool isOverdue = false;
//判断拼团状态
var dt = DateTime.Now;
if (serviceInfo.startTime > dt)
{
pinTuanStartStatus = (int)GlobalEnumVars.ServicesOpenStatus.notBegun;
TimeSpan ts = serviceInfo.startTime.Subtract(dt);
lastTime = (int)ts.TotalSeconds;
isOverdue = lastTime > 0;
}
else if (serviceInfo.startTime <= dt && serviceInfo.endTime > dt)
{
pinTuanStartStatus = (int)GlobalEnumVars.ServicesOpenStatus.begin;
TimeSpan ts = serviceInfo.endTime.Subtract(dt);
lastTime = (int)ts.TotalSeconds;
isOverdue = lastTime > 0;
}
else
{
pinTuanStartStatus = (int)GlobalEnumVars.ServicesOpenStatus.haveExpired;
}
((JObject)ss).Add("pinTuanStartStatus", pinTuanStartStatus);
((JObject)ss).Add("lastTime", lastTime);
((JObject)ss).Add("isOverdue", isOverdue);
}
}
}
}
parameters.Remove("list");
parameters.Add("list", result);
}
dto.parameters = parameters;
}
else if (item.widgetCode == "adpop")
{
dto.parameters = (JObject)JsonConvert.DeserializeObject(item.parameters);
}
else if (item.widgetCode == "topImgSlide")
{
dto.parameters = (JObject)JsonConvert.DeserializeObject(item.parameters);
}
else
{
dto.parameters = (JObject)JsonConvert.DeserializeObject(item.parameters);
}
itemsDto.Add(dto);
}
jm.data = new
{
model.code,
desc = model.description,
model.id,
model.layout,
model.name,
model.type,
items = itemsDto
};
return jm;
}
#endregion
}
}

View File

@@ -0,0 +1,137 @@
/***********************************************************************
* Project: CoreCms
* ProjectName: 核心内容管理系统
* Web: https://www.corecms.net
* Author: 大灰灰
* Email: jianweie@163.com
* CreateTime: 2021/1/31 21:45:10
* Description: 暂无
***********************************************************************/
using System;
using System.Collections.Generic;
using System.Linq.Expressions;
using System.Threading.Tasks;
using CoreCms.Net.Configuration;
using CoreCms.Net.IRepository;
using CoreCms.Net.IRepository.UnitOfWork;
using CoreCms.Net.IServices;
using CoreCms.Net.Model.Entities;
using CoreCms.Net.Model.ViewModels.Basics;
using CoreCms.Net.Model.ViewModels.UI;
using SqlSugar;
namespace CoreCms.Net.Services
{
/// <summary>
/// 商城服务说明 接口实现
/// </summary>
public class CoreCmsServiceDescriptionServices : BaseServices<CoreCmsServiceDescription>, ICoreCmsServiceDescriptionServices
{
private readonly ICoreCmsServiceDescriptionRepository _dal;
private readonly IUnitOfWork _unitOfWork;
public CoreCmsServiceDescriptionServices(IUnitOfWork unitOfWork, ICoreCmsServiceDescriptionRepository dal)
{
this._dal = dal;
base.BaseDal = dal;
_unitOfWork = unitOfWork;
}
#region ==========================================================
/// <summary>
/// 重写异步插入方法
/// </summary>
/// <param name="entity">实体数据</param>
/// <returns></returns>
public new async Task<AdminUiCallBack> InsertAsync(CoreCmsServiceDescription entity)
{
return await _dal.InsertAsync(entity);
}
/// <summary>
/// 重写异步更新方法方法
/// </summary>
/// <param name="entity"></param>
/// <returns></returns>
public new async Task<AdminUiCallBack> UpdateAsync(CoreCmsServiceDescription entity)
{
return await _dal.UpdateAsync(entity);
}
/// <summary>
/// 重写异步更新方法方法
/// </summary>
/// <param name="entity"></param>
/// <returns></returns>
public new async Task<AdminUiCallBack> UpdateAsync(List<CoreCmsServiceDescription> entity)
{
return await _dal.UpdateAsync(entity);
}
/// <summary>
/// 重写删除指定ID的数据
/// </summary>
/// <param name="id"></param>
/// <returns></returns>
public new async Task<AdminUiCallBack> DeleteByIdAsync(object id)
{
return await _dal.DeleteByIdAsync(id);
}
/// <summary>
/// 重写删除指定ID集合的数据(批量删除)
/// </summary>
/// <param name="ids"></param>
/// <returns></returns>
public new async Task<AdminUiCallBack> DeleteByIdsAsync(int[] ids)
{
return await _dal.DeleteByIdsAsync(ids);
}
#endregion
#region ==========================================================
/// <summary>
/// 获取缓存的所有数据
/// </summary>
/// <returns></returns>
public async Task<List<CoreCmsServiceDescription>> GetCaChe()
{
return await _dal.GetCaChe();
}
/// <summary>
/// 更新cache
/// </summary>
public async Task<List<CoreCmsServiceDescription>> UpdateCaChe()
{
return await _dal.UpdateCaChe();
}
#endregion
#region
/// <summary>
/// 重写根据条件查询分页数据
/// </summary>
/// <param name="predicate">判断集合</param>
/// <param name="orderByType">排序方式</param>
/// <param name="pageIndex">当前页面索引</param>
/// <param name="pageSize">分布大小</param>
/// <param name="orderByExpression"></param>
/// <param name="blUseNoLock">是否使用WITH(NOLOCK)</param>
/// <returns></returns>
public new async Task<IPageList<CoreCmsServiceDescription>> QueryPageAsync(Expression<Func<CoreCmsServiceDescription, bool>> predicate,
Expression<Func<CoreCmsServiceDescription, object>> orderByExpression, OrderByType orderByType, int pageIndex = 1,
int pageSize = 20, bool blUseNoLock = false)
{
return await _dal.QueryPageAsync(predicate, orderByExpression, orderByType, pageIndex, pageSize, blUseNoLock);
}
#endregion
}
}

View File

@@ -0,0 +1,238 @@
/***********************************************************************
* Project: CoreCms
* ProjectName: 核心内容管理系统
* Web: https://www.corecms.net
* Author: 大灰灰
* Email: jianweie@163.com
* CreateTime: 2021/1/31 21:45:10
* Description: 暂无
***********************************************************************/
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using CoreCms.Net.Caching.Manual;
using CoreCms.Net.Configuration;
using CoreCms.Net.IRepository;
using CoreCms.Net.IRepository.UnitOfWork;
using CoreCms.Net.IServices;
using CoreCms.Net.Loging;
using CoreCms.Net.Model.Entities;
using CoreCms.Net.Model.FromBody;
using CoreCms.Net.Model.ViewModels.Basics;
using CoreCms.Net.Model.ViewModels.Options;
using CoreCms.Net.Model.ViewModels.Sms;
using CoreCms.Net.Model.ViewModels.UI;
using CoreCms.Net.Utility.Extensions;
using CoreCms.Net.Utility.Helper;
namespace CoreCms.Net.Services
{
/// <summary>
/// 店铺设置表 接口实现
/// </summary>
public class CoreCmsSettingServices : BaseServices<CoreCmsSetting>, ICoreCmsSettingServices
{
private readonly ICoreCmsSettingRepository _dal;
private readonly IUnitOfWork _unitOfWork;
public CoreCmsSettingServices(IUnitOfWork unitOfWork, ICoreCmsSettingRepository dal)
{
this._dal = dal;
base.BaseDal = dal;
_unitOfWork = unitOfWork;
}
/// <summary>
/// 重写异步更新方法方法
/// </summary>
/// <param name="model"></param>
/// <returns></returns>
public async Task<AdminUiCallBack> UpdateAsync(FMCoreCmsSettingDoSaveModel model)
{
var jm = new AdminUiCallBack();
var entity = model.entity;
if (!entity.Any())
{
jm.msg = "数据不能为空";
return jm;
}
var oldList = await _dal.QueryAsync();
var bl = false;
if (oldList.Any())
{
var arr = entity.Select(p => p.sKey).ToList();
var old = oldList.Where(p => arr.Contains(p.sKey)).ToList();
if (old.Any())
{
old.ForEach(p =>
{
var o = entity.Find(c => c.sKey == p.sKey);
p.sValue = o != null ? o.sValue : "";
});
bl = await base.UpdateAsync(old);
}
var arrOld = oldList.Select(p => p.sKey).ToList();
var newData = entity.Where(p => !arrOld.Contains(p.sKey)).ToList();
if (newData.Any())
{
var settings = new List<CoreCmsSetting>();
newData.ForEach(p =>
{
settings.Add(new CoreCmsSetting() { sKey = p.sKey, sValue = p.sValue.ToString() });
});
bl = await base.InsertAsync(settings) > 0;
}
}
else
{
var settings = new List<CoreCmsSetting>();
entity.ForEach(p =>
{
settings.Add(new CoreCmsSetting() { sKey = p.sKey, sValue = p.sValue.ToString() });
});
bl = await base.InsertAsync(settings) > 0;
}
await UpdateCache();
jm.code = bl ? 0 : 1;
jm.msg = (bl ? GlobalConstVars.EditSuccess : GlobalConstVars.EditFailure);
return jm;
}
/// <summary>
/// 获取缓存数据
/// </summary>
/// <returns></returns>
private async Task UpdateCache()
{
var list = await _dal.QueryAsync();
ManualDataCache.Instance.Set(GlobalConstVars.CacheCoreCmsSettingList, list, 1440);
var configs = SystemSettingDictionary.GetConfig();
foreach (KeyValuePair<string, DictionaryKeyValues> kvp in configs)
{
var model = list.Find(p => p.sKey == kvp.Key);
if (model != null)
{
kvp.Value.sValue = model.sValue;
}
}
ManualDataCache.Instance.Set(GlobalConstVars.CacheCoreCmsSettingByComparison, configs, 1440);
}
/// <summary>
/// 获取缓存数据
/// </summary>
/// <returns></returns>
private async Task<List<CoreCmsSetting>> GetDatas()
{
var cache = ManualDataCache.Instance.Get<List<CoreCmsSetting>>(GlobalConstVars.CacheCoreCmsSettingList);
if (cache == null)
{
var list = await _dal.QueryAsync();
ManualDataCache.Instance.Set(GlobalConstVars.CacheCoreCmsSettingList, list, 1440);
return list;
}
return ManualDataCache.Instance.Get<List<CoreCmsSetting>>(GlobalConstVars.CacheCoreCmsSettingList);
}
/// <summary>
/// 获取数据库整合后配置信息
/// </summary>
/// <returns></returns>
public async Task<Dictionary<string, DictionaryKeyValues>> GetConfigDictionaries()
{
var configs = SystemSettingDictionary.GetConfig();
var settings = await GetDatas();
foreach (KeyValuePair<string, DictionaryKeyValues> kvp in configs)
{
var model = settings.Find(p => p.sKey == kvp.Key);
if (model != null)
{
kvp.Value.sValue = model.sValue;
}
}
return configs;
}
/// <summary>
/// 获取附件存储的配置信息
/// </summary>
/// <returns></returns>
public async Task<FilesStorageOptions> GetFilesStorageOptions()
{
var filesStorageOptions = new FilesStorageOptions();
var configs = SystemSettingDictionary.GetConfig();
var settings = await GetDatas();
filesStorageOptions.StorageType = GetValue(SystemSettingConstVars.FilesStorageType, configs, settings);
filesStorageOptions.Path = GetValue(SystemSettingConstVars.FilesStoragePath, configs, settings);
filesStorageOptions.FileTypes = GetValue(SystemSettingConstVars.FilesStorageFileSuffix, configs, settings);
filesStorageOptions.MaxSize = GetValue(SystemSettingConstVars.FilesStorageFileMaxSize, configs, settings).ObjectToInt(10);
//云基础
filesStorageOptions.BucketBindUrl = GetValue(SystemSettingConstVars.FilesStorageBucketBindUrl, configs, settings);
filesStorageOptions.AccessKeyId = GetValue(SystemSettingConstVars.FilesStorageAccessKeyId, configs, settings);
filesStorageOptions.AccessKeySecret = GetValue(SystemSettingConstVars.FilesStorageAccessKeySecret, configs, settings);
//腾讯云
filesStorageOptions.AccountId = GetValue(SystemSettingConstVars.FilesStorageTencentAccountId, configs, settings);
filesStorageOptions.CosRegion = GetValue(SystemSettingConstVars.FilesStorageTencentCosRegion, configs, settings);
filesStorageOptions.TencentBucketName = GetValue(SystemSettingConstVars.FilesStorageTencentBucketName, configs, settings);
//阿里云
filesStorageOptions.BucketName = GetValue(SystemSettingConstVars.FilesStorageAliYunBucketName, configs, settings);
filesStorageOptions.Endpoint = GetValue(SystemSettingConstVars.FilesStorageAliYunEndpoint, configs, settings);
//七牛云
filesStorageOptions.QiNiuBucketName = GetValue(SystemSettingConstVars.FilesStorageQiNiuBucketName, configs, settings);
//格式化存储文件夹路径
filesStorageOptions.Path = UpLoadHelper.PathFormat(filesStorageOptions.StorageType, filesStorageOptions.Path);
return filesStorageOptions;
}
/// <summary>
/// 获取短信配置实体
/// </summary>
/// <returns></returns>
public async Task<SMSOptions> GetSmsOptions()
{
var sms = new SMSOptions();
var configs = SystemSettingDictionary.GetConfig();
var settings = await GetDatas();
sms.Enabled = GetValue(SystemSettingConstVars.SmsEnabled, configs, settings).ObjectToInt(1) == 1;
sms.UserId = GetValue(SystemSettingConstVars.SmsUserId, configs, settings);
sms.Account = GetValue(SystemSettingConstVars.SmsAccount, configs, settings);
sms.Password = GetValue(SystemSettingConstVars.SmsPassword, configs, settings);
sms.Signature = GetValue(SystemSettingConstVars.SmsSignature, configs, settings);
sms.ApiUrl = GetValue(SystemSettingConstVars.SmsApiUrl, configs, settings);
return sms;
}
public string GetValue(string key, Dictionary<string, DictionaryKeyValues> configs, List<CoreCmsSetting> settings)
{
var objSetting = settings.Find(p => p.sKey == key);
if (objSetting != null)
{
return objSetting.sValue;
}
configs.TryGetValue(key, out var di);
return di?.sValue;
}
}
}

View File

@@ -0,0 +1,251 @@
/***********************************************************************
* Project: CoreCms
* ProjectName: 核心内容管理系统
* Web: https://www.corecms.net
* Author: 大灰灰
* Email: jianweie@163.com
* CreateTime: 2021/1/31 21:45:10
* Description: 暂无
***********************************************************************/
using System;
using System.Collections.Generic;
using System.Linq;
using System.Linq.Expressions;
using System.Threading.Tasks;
using CoreCms.Net.Configuration;
using CoreCms.Net.IRepository;
using CoreCms.Net.IRepository.UnitOfWork;
using CoreCms.Net.IServices;
using CoreCms.Net.Model.Entities;
using CoreCms.Net.Model.ViewModels.Basics;
using CoreCms.Net.Model.ViewModels.UI;
using CoreCms.Net.Utility.Extensions;
using CoreCms.Net.Utility.Helper;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using SqlSugar;
namespace CoreCms.Net.Services
{
/// <summary>
/// 配送方式表 接口实现
/// </summary>
public class CoreCmsShipServices : BaseServices<CoreCmsShip>, ICoreCmsShipServices
{
private readonly ICoreCmsShipRepository _dal;
private readonly IUnitOfWork _unitOfWork;
public CoreCmsShipServices(IUnitOfWork unitOfWork, ICoreCmsShipRepository dal)
{
this._dal = dal;
base.BaseDal = dal;
_unitOfWork = unitOfWork;
}
#region ==========================================================
/// <summary>
/// 重写异步插入方法
/// </summary>
/// <param name="entity">实体数据</param>
/// <returns></returns>
public new async Task<AdminUiCallBack> InsertAsync(CoreCmsShip entity)
{
return await _dal.InsertAsync(entity);
}
/// <summary>
/// 重写异步更新方法方法
/// </summary>
/// <param name="entity"></param>
/// <returns></returns>
public new async Task<AdminUiCallBack> UpdateAsync(CoreCmsShip entity)
{
return await _dal.UpdateAsync(entity);
}
/// <summary>
/// 重写删除指定ID的数据
/// </summary>
/// <param name="id"></param>
/// <returns></returns>
public async Task<AdminUiCallBack> DeleteByIdAsync(int id)
{
return await _dal.DeleteByIdAsync(id);
}
#endregion
/// <summary>
/// 设置是否默认
/// </summary>
/// <param name="id"></param>
/// <param name="isDefault"></param>
/// <returns></returns>
public async Task<AdminUiCallBack> SetIsDefault(int id, bool isDefault)
{
return await _dal.SetIsDefault(id, isDefault);
}
#region
/// <summary>
/// 重写根据条件查询分页数据
/// </summary>
/// <param name="predicate">判断集合</param>
/// <param name="orderByType">排序方式</param>
/// <param name="pageIndex">当前页面索引</param>
/// <param name="pageSize">分布大小</param>
/// <param name="orderByExpression"></param>
/// <param name="blUseNoLock">是否使用WITH(NOLOCK)</param>
/// <returns></returns>
public new async Task<IPageList<CoreCmsShip>> QueryPageAsync(Expression<Func<CoreCmsShip, bool>> predicate,
Expression<Func<CoreCmsShip, object>> orderByExpression, OrderByType orderByType, int pageIndex = 1,
int pageSize = 20, bool blUseNoLock = false)
{
return await _dal.QueryPageAsync(predicate, orderByExpression, orderByType, pageIndex, pageSize, blUseNoLock);
}
#endregion
/// <summary>
/// 获取配送费用
/// </summary>
/// <param name="areaId">地区id</param>
/// <param name="weight">重量,单位g</param>
/// <param name="totalmoney">商品总价</param>
/// <returns></returns>
public decimal GetShipCost(int areaId = 0, decimal weight = 0, decimal totalmoney = 0)
{
decimal postfee = 0;
var idStr = areaId.ToString();
//先判断是否子地区满足条件
var def = base.QueryByClause(p =>
p.status == (int)GlobalEnumVars.ShipStatus.Yes &&
p.areaType == (int)GlobalEnumVars.ShipAreaType.Part && p.areaFee.Contains(idStr));
//没有子地区取默认
if (def == null)
{
def = base.QueryByClause(p => p.isDefault == true && p.status == (int)GlobalEnumVars.ShipStatus.Yes);
}
//没有默认取启用状态
if (def == null)
{
def = base.QueryByClause(p => p.status == (int)GlobalEnumVars.ShipStatus.Yes);
if (def == null)
{//没有配送方式返回0
return postfee;
}
}
//是否包邮
if (def.isfreePostage == true)
{
return postfee;
}
if (def.areaType == (int)GlobalEnumVars.ShipAreaType.Part)
{
var areaFee = (JArray)JsonConvert.DeserializeObject(def.areaFee);
if (areaFee != null && areaFee.Count > 0)
{
var isIn = false;
foreach (var jToken in areaFee)
{
var item = (JObject)jToken;
//if (item.Property("area") == null) continue;
var area = item["area"].ObjectToString();
var firstunitAreaPrice = item["firstunitAreaPrice"].ObjectToInt(0);
if (!string.IsNullOrEmpty(area))
{
var areaArr = CommonHelper.StringToIntArray(area);
if (areaArr.Contains(areaId))
{
isIn = true;
var total = calculate_fee(def, weight, totalmoney, firstunitAreaPrice);
postfee = Math.Round(total, 2);
break;
}
}
}
if (!isIn)
{
var total = calculate_fee(def, weight, totalmoney, 0);
postfee = Math.Round(total, 2);
}
}
else
{
var total = calculate_fee(def, weight, totalmoney, 0);
postfee = Math.Round(total, 2);
}
}
else
{
var total = calculate_fee(def, weight, totalmoney, 0);
postfee = Math.Round(total, 2);
}
return postfee;
}
/// <summary>
/// 计算运费
/// </summary>
/// <param name="ship">配送方式内容</param>
/// <param name="weight">订单总重</param>
/// <param name="totalmoney">商品总价</param>
/// <param name="firstunitAreaPrice"></param>
/// <returns></returns>
public decimal calculate_fee(CoreCmsShip ship, decimal weight, decimal totalmoney = 0, decimal firstunitAreaPrice = 0)
{
//满多少免运费
if (ship.goodsMoney > 0 && totalmoney >= ship.goodsMoney)
{
return 0;
}
if (weight > 0 && weight > ship.firstUnit)
{
decimal shipMoney = ship.firstunitPrice + (Math.Ceiling(Math.Abs(weight - ship.firstUnit) / ship.continueUnit) * ship.continueunitPrice);
return shipMoney;
}
else
{
if (ship.firstunitPrice > 0)
{
return ship.firstunitPrice;
}
else
{
return firstunitAreaPrice;
}
}
}
/// <summary>
/// 根据地区获取配送方式
/// </summary>
public CoreCmsShip GetShip(int areaId = 0)
{
var idStr = areaId.ToString();
//先判断是否子地区满足条件
var def = base.QueryByClause(p =>
p.status == (int)GlobalEnumVars.ShipStatus.Yes &&
p.areaType == (int)GlobalEnumVars.ShipAreaType.Part && p.areaFee.Contains(idStr));
//没有子地区取默认
if (def == null)
{
def = base.QueryByClause(p => p.isDefault == true && p.status == (int)GlobalEnumVars.ShipStatus.Yes);
}
//没有默认取启用状态
if (def == null)
{
def = base.QueryByClause(p => p.status == (int)GlobalEnumVars.ShipStatus.Yes);
return def;
}
return def;
}
}
}

View File

@@ -0,0 +1,94 @@
/***********************************************************************
* Project: CoreCms
* ProjectName: 核心内容管理系统
* Web: https://www.corecms.net
* Author: 大灰灰
* Email: jianweie@163.com
* CreateTime: 2021/1/31 21:45:10
* Description: 暂无
***********************************************************************/
using System;
using System.Linq.Expressions;
using System.Threading.Tasks;
using CoreCms.Net.Configuration;
using CoreCms.Net.IRepository;
using CoreCms.Net.IRepository.UnitOfWork;
using CoreCms.Net.IServices;
using CoreCms.Net.Model.Entities;
using CoreCms.Net.Model.ViewModels.Basics;
using CoreCms.Net.Model.ViewModels.UI;
using SqlSugar;
namespace CoreCms.Net.Services
{
/// <summary>
/// 门店表 接口实现
/// </summary>
public class CoreCmsStoreServices : BaseServices<CoreCmsStore>, ICoreCmsStoreServices
{
private readonly ICoreCmsStoreRepository _dal;
private readonly IUnitOfWork _unitOfWork;
public CoreCmsStoreServices(IUnitOfWork unitOfWork, ICoreCmsStoreRepository dal)
{
this._dal = dal;
base.BaseDal = dal;
_unitOfWork = unitOfWork;
}
/// <summary>
/// 重写异步插入方法
/// </summary>
/// <param name="entity">实体数据</param>
/// <returns></returns>
public new async Task<AdminUiCallBack> InsertAsync(CoreCmsStore entity)
{
return await _dal.InsertAsync(entity);
}
/// <summary>
/// 重写异步更新方法方法
/// </summary>
/// <param name="entity"></param>
/// <returns></returns>
public new async Task<AdminUiCallBack> UpdateAsync(CoreCmsStore entity)
{
return await _dal.UpdateAsync(entity);
}
#region Sql根据条件查询分页数据带距离
/// <summary>
/// Sql根据条件查询分页数据带距离
/// </summary>
/// <param name="predicate">判断集合</param>
/// <param name="orderByType">排序方式</param>
/// <param name="pageIndex">当前页面索引</param>
/// <param name="pageSize">分布大小</param>
/// <param name="orderByExpression"></param>
/// <param name="latitude">纬度</param>
/// <param name="longitude">精度</param>
/// <returns></returns>
public async Task<IPageList<CoreCmsStore>> QueryPageAsyncByCoordinate(Expression<Func<CoreCmsStore, bool>> predicate,
Expression<Func<CoreCmsStore, object>> orderByExpression, OrderByType orderByType, int pageIndex = 1,
int pageSize = 20, decimal latitude = 0, decimal longitude = 0)
{
return await _dal.QueryPageAsyncByCoordinate(predicate, orderByExpression, orderByType, pageIndex, pageSize, latitude, longitude);
}
#endregion
/// <summary>
/// 根据用户序列获取单个门店数据
/// </summary>
/// <param name="userId">用户序列</param>
/// <param name="blUseNoLock">是否使用WITH(NOLOCK)</param>
/// <returns></returns>
public async Task<CoreCmsStore> GetStoreByUserId(int userId, bool blUseNoLock = false)
{
return await _dal.GetStoreByUserId(userId, blUseNoLock);
}
}
}