mirror of
http://git.coreshop.cn/jianweie/coreshoppro.git
synced 2026-03-22 14:27:21 +08:00
【新增】新增微信扫码支付功能,对接PC端。
【新增】增加DTO类库,将逐步完善dto层。 【修复】修复【分类】切换后,切换回来未清零原始数据,导致更新数据重复的问题。 【调整】移除模板库功能,防止出现审核因为模板库页面存在而导致的审核失败。暂将模板库的代码存放到会员QQ群内,方便下载使用。 【调整】代码生成器【Repository.tpl】移除Cache手动增删改,【SqlSugarSetup】增加sqlsugar自动检测增删改后清理二级缓存。 【调整】后端新增秒杀独立组件,用于区分团购及秒杀的差异,首页新增秒杀组件。 【优化】重写首页所有组件样式及接口数据获取效率。 【优化】优化拼团,秒杀,团购,接龙数据获取逻辑,提升列表及详情页面数据获取效率。 【优化】调整拼团,秒杀,团购,服务商品推广海报为新式海报效果。增加服务商品推广海报。 【优化】清理h5相关代码判断,移除h5支付组件,提高响应速度。 【优化】移除小程序前端冗余代码。加快代码执行效率。
This commit is contained in:
@@ -13,6 +13,7 @@ using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using CoreCms.Net.Configuration;
|
||||
using CoreCms.Net.DTO;
|
||||
using CoreCms.Net.IRepository;
|
||||
using CoreCms.Net.IRepository.UnitOfWork;
|
||||
using CoreCms.Net.IServices;
|
||||
@@ -175,17 +176,17 @@ namespace CoreCms.Net.Services
|
||||
#endregion
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#region 获取团购列表数据
|
||||
/// <summary>
|
||||
/// 获取团购列表数据
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public async Task<WebApiCallBack> GetGroupList(int type, int userId, int status, int pageIndex, int pageSize)
|
||||
public async Task<WebApiCallBack> GetGroupList(int type, int status, int pageIndex, int pageSize)
|
||||
{
|
||||
using var container = _serviceProvider.CreateScope();
|
||||
|
||||
var goodsServices = container.ServiceProvider.GetService<ICoreCmsGoodsServices>();
|
||||
var orderServices = container.ServiceProvider.GetService<ICoreCmsOrderServices>();
|
||||
|
||||
var jm = new WebApiCallBack { status = true };
|
||||
|
||||
@@ -207,51 +208,75 @@ namespace CoreCms.Net.Services
|
||||
{
|
||||
where = where.And(p => p.endTime < dt);
|
||||
}
|
||||
|
||||
var goods = new List<CoreCmsGoods>();
|
||||
var list = await _dal.QueryPageAsync(where, p => p.endTime, OrderByType.Desc, pageIndex, pageSize);
|
||||
if (list != null && list.Any())
|
||||
var promotions = await _dal.QueryPageAsync(where, p => p.endTime, OrderByType.Desc, pageIndex, pageSize, true, true, 60);
|
||||
var dtoData = new List<GroupPurchaseSeckillDTO>();
|
||||
if (promotions != null && promotions.Any())
|
||||
{
|
||||
foreach (var item in list)
|
||||
//获取团购序列
|
||||
var pIds = promotions.Select(p => p.id).ToList();
|
||||
//获取规则参数
|
||||
var conditions = await _promotionConditionServices.QueryListByClauseAsync(p => pIds.Contains(p.promotionId), p => p.id, OrderByType.Asc, true, true);
|
||||
//获取规则结果集
|
||||
var results = await _promotionResultServices.QueryListByClauseAsync(p => pIds.Contains(p.promotionId), p => p.id, OrderByType.Asc, true, true);
|
||||
|
||||
var goodIds = (from condition in conditions where condition != null && condition.parameters.Contains("goodsId") select (JObject)JsonConvert.DeserializeObject(condition.parameters) into parameters select parameters["goodsId"].ObjectToInt(0)).ToList();
|
||||
|
||||
var goodData = await goodsServices.QueryGoodWithDefaultProductAsync(p => goodIds.Contains(p.id), p => p.id, OrderByType.Asc, true);
|
||||
|
||||
foreach (var item in promotions)
|
||||
{
|
||||
var promotionId = item.id;
|
||||
var condition = await _promotionConditionServices.QueryByClauseAsync(p => p.promotionId == promotionId);
|
||||
var dtNow = DateTime.Now;
|
||||
|
||||
var dto = new GroupPurchaseSeckillDTO();
|
||||
|
||||
//事物处理过程开始
|
||||
dto.id = item.id;
|
||||
dto.name = item.name;
|
||||
dto.type = item.type;
|
||||
dto.sort = item.sort;
|
||||
dto.maxNums = item.maxNums;
|
||||
dto.maxGoodsNums = item.maxGoodsNums;
|
||||
dto.maxRecevieNums = item.maxRecevieNums;
|
||||
dto.startTime = item.startTime;
|
||||
dto.endTime = item.endTime;
|
||||
dto.isEnable = item.isEnable;
|
||||
dto.isExclusive = item.isExclusive;
|
||||
dto.isAutoReceive = item.isAutoReceive;
|
||||
dto.effectiveDays = item.effectiveDays;
|
||||
dto.effectiveHours = item.effectiveHours;
|
||||
dto.startStatus = status;
|
||||
|
||||
var condition = conditions.Find(p => p.promotionId == item.id);
|
||||
if (condition != null && condition.parameters.Contains("goodsId"))
|
||||
{
|
||||
JObject parameters = (JObject)JsonConvert.DeserializeObject(condition.parameters);
|
||||
|
||||
|
||||
var res = await GetGroupDetail(parameters["goodsId"].ObjectToInt(0), userId, type, item.id);
|
||||
if (res.status)
|
||||
var parameters = (JObject)JsonConvert.DeserializeObject(condition.parameters);
|
||||
var goodId = parameters["goodsId"].ObjectToInt(0);
|
||||
var good = goodData.Find(p => p.id == goodId);
|
||||
if (good != null)
|
||||
{
|
||||
var good = res.data as CoreCmsGoods;
|
||||
dto.goodBrief = good.brief;
|
||||
dto.goodName = good.name;
|
||||
dto.goodThumbnail = good.image;
|
||||
dto.goodImages = good.images;
|
||||
dto.goodStock = good.stock;
|
||||
dto.goodViewCount = good.viewCount;
|
||||
dto.goodUnit = good.unit;
|
||||
dto.mktPrice = good.mktprice;
|
||||
dto.price = good.price;
|
||||
|
||||
good.groupId = item.id;
|
||||
good.groupType = item.type;
|
||||
good.groupStatus = item.isEnable;
|
||||
good.groupTime = DateTime.Now;
|
||||
good.groupStartTime = item.startTime;
|
||||
good.groupEndTime = item.endTime;
|
||||
|
||||
TimeSpan ts = item.endTime.Subtract(dt);
|
||||
good.groupTimestamp = (int)ts.TotalSeconds;
|
||||
|
||||
goods.Add(good);
|
||||
}
|
||||
else
|
||||
{
|
||||
item.expression1 = res.msg;
|
||||
TimeSpan ts = item.endTime.Subtract(dtNow);
|
||||
dto.timestamp = (int)ts.TotalSeconds;
|
||||
}
|
||||
}
|
||||
dtoData.Add(dto);
|
||||
}
|
||||
}
|
||||
|
||||
jm.data = new
|
||||
{
|
||||
goods,
|
||||
list.TotalCount,
|
||||
list.TotalPages,
|
||||
list,
|
||||
promotions.TotalCount,
|
||||
promotions.TotalPages,
|
||||
list = dtoData,
|
||||
pageIndex,
|
||||
pageSize
|
||||
};
|
||||
@@ -266,7 +291,7 @@ namespace CoreCms.Net.Services
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
|
||||
public async Task<WebApiCallBack> GetGroupDetail(int goodId = 0, int userId = 0, int type = (int)GlobalEnumVars.PromotionType.Group, int groupId = 0, bool needSku = false)
|
||||
public async Task<WebApiCallBack> GetGroupDetail(int groupId, int userId, int type, bool needSku)
|
||||
{
|
||||
using var container = _serviceProvider.CreateScope();
|
||||
|
||||
@@ -275,31 +300,40 @@ namespace CoreCms.Net.Services
|
||||
|
||||
var jm = new WebApiCallBack() { msg = "关键参数丢失" };
|
||||
|
||||
if (goodId == 0)
|
||||
if (groupId == 0)
|
||||
{
|
||||
return jm;
|
||||
}
|
||||
|
||||
//判断商品是否参加团购
|
||||
var isInGroup = _dal.IsInGroup(goodId, out var promotionId, type);
|
||||
if (!isInGroup)
|
||||
{
|
||||
jm.msg = "商品未参加团购";
|
||||
return jm;
|
||||
}
|
||||
|
||||
var promotion = await _dal.QueryByClauseAsync(p => p.isDel == false && p.isEnable == true && p.id == promotionId);
|
||||
var promotion = await _dal.QueryByClauseAsync(p => p.isDel == false && p.isEnable == true && p.id == groupId, true, true);
|
||||
if (promotion == null)
|
||||
{
|
||||
jm.msg = "无此活动";
|
||||
jm.otherData = promotionId;
|
||||
jm.otherData = groupId;
|
||||
return jm;
|
||||
}
|
||||
|
||||
var goodId = 0;
|
||||
var condition = await _promotionConditionServices.QueryByClauseAsync(p => p.promotionId == groupId, true, true);
|
||||
if (condition != null)
|
||||
{
|
||||
var obj = (JObject)JsonConvert.DeserializeObject(condition.parameters);
|
||||
if (obj.ContainsKey("goodsId") && obj["goodsId"].ObjectToInt(0) > 0)
|
||||
{
|
||||
goodId = obj["goodsId"].ObjectToInt(0);
|
||||
}
|
||||
}
|
||||
|
||||
if (goodId == 0)
|
||||
{
|
||||
jm.msg = "未提交商品信息";
|
||||
jm.otherData = groupId;
|
||||
return jm;
|
||||
}
|
||||
|
||||
var goods = new CoreCmsGoods();
|
||||
string typeStr = type == (int)GlobalEnumVars.PromotionType.Group ? GlobalEnumVars.PromotionType.Group.ToString().ToLowerInvariant() : GlobalEnumVars.PromotionType.Seckill.ToString().ToLowerInvariant();
|
||||
|
||||
goods = await goodsServices.GetGoodsDetail(goodId, userId, true, typeStr, groupId, needSku);
|
||||
var goods = await goodsServices.GetGoodsDetail(goodId, userId, true, typeStr, groupId, needSku);
|
||||
if (goods == null)
|
||||
{
|
||||
jm.msg = "商品不存在";
|
||||
@@ -315,8 +349,6 @@ namespace CoreCms.Net.Services
|
||||
//调整前台显示数量
|
||||
var checkOrder = orderServices.FindLimitOrder(goods.product.id, userId, promotion.startTime, promotion.endTime, promotion.type);
|
||||
|
||||
var productStock = goods.product.stock;
|
||||
|
||||
//如果最大为设置值
|
||||
if (promotion.maxGoodsNums > 0)
|
||||
{
|
||||
@@ -335,10 +367,8 @@ namespace CoreCms.Net.Services
|
||||
goods.product.stock = checkOrder.TotalOrders - promotion.maxNums >= 0 ? 0 : promotion.maxNums - checkOrder.TotalOrders;
|
||||
}
|
||||
|
||||
|
||||
goods.buyPromotionCount = checkOrder.TotalOrders;
|
||||
|
||||
|
||||
var dt = DateTime.Now;
|
||||
|
||||
goods.groupId = promotion.id;
|
||||
@@ -351,7 +381,6 @@ namespace CoreCms.Net.Services
|
||||
TimeSpan ts = promotion.endTime.Subtract(dt);
|
||||
goods.groupTimestamp = (int)ts.TotalSeconds;
|
||||
|
||||
|
||||
//进行促销后要更换原销售价替换原市场价
|
||||
var originPrice = Math.Round(goods.product.price + goods.product.promotionAmount, 2);
|
||||
goods.product.mktprice = originPrice;
|
||||
|
||||
Reference in New Issue
Block a user