mirror of
http://git.coreshop.cn/jianweie/coreshoppro.git
synced 2026-02-05 05:09:49 +08:00
【修复】修复秒杀团购限制个人购买数量的问题。
This commit is contained in:
@@ -20,8 +20,8 @@ using CoreCms.Net.Loging;
|
|||||||
using CoreCms.Net.Model.Entities;
|
using CoreCms.Net.Model.Entities;
|
||||||
using CoreCms.Net.Model.Entities.Expression;
|
using CoreCms.Net.Model.Entities.Expression;
|
||||||
using CoreCms.Net.Model.ViewModels.Basics;
|
using CoreCms.Net.Model.ViewModels.Basics;
|
||||||
using CoreCms.Net.Model.ViewModels.UI;
|
|
||||||
using CoreCms.Net.Model.ViewModels.DTO;
|
using CoreCms.Net.Model.ViewModels.DTO;
|
||||||
|
using CoreCms.Net.Model.ViewModels.UI;
|
||||||
using CoreCms.Net.Utility.Extensions;
|
using CoreCms.Net.Utility.Extensions;
|
||||||
using CoreCms.Net.Utility.Helper;
|
using CoreCms.Net.Utility.Helper;
|
||||||
using Microsoft.AspNetCore.Mvc;
|
using Microsoft.AspNetCore.Mvc;
|
||||||
@@ -223,6 +223,7 @@ namespace CoreCms.Net.Services
|
|||||||
{
|
{
|
||||||
JObject parameters = (JObject)JsonConvert.DeserializeObject(condition.parameters);
|
JObject parameters = (JObject)JsonConvert.DeserializeObject(condition.parameters);
|
||||||
|
|
||||||
|
|
||||||
var res = await GetGroupDetail(parameters["goodsId"].ObjectToInt(0), userId, "group", item.id);
|
var res = await GetGroupDetail(parameters["goodsId"].ObjectToInt(0), userId, "group", item.id);
|
||||||
if (res.status)
|
if (res.status)
|
||||||
{
|
{
|
||||||
@@ -312,25 +313,32 @@ namespace CoreCms.Net.Services
|
|||||||
}
|
}
|
||||||
|
|
||||||
//调整前台显示数量
|
//调整前台显示数量
|
||||||
if (!string.IsNullOrEmpty(promotion.parameters))
|
var checkOrder = orderServices.FindLimitOrder(goods.product.id, userId, promotion.startTime, promotion.endTime, promotion.type);
|
||||||
{
|
|
||||||
var extendParams = (JObject)JsonConvert.DeserializeObject(promotion.parameters);
|
|
||||||
var checkOrder = orderServices.FindLimitOrder(goods.product.id, userId, promotion.startTime, promotion.endTime);
|
|
||||||
|
|
||||||
if (extendParams != null && extendParams.ContainsKey("max_goods_nums") && extendParams["max_goods_nums"].ObjectToInt(0) != 0)
|
var productStock = goods.product.stock;
|
||||||
{
|
|
||||||
var maxGoodsNums = extendParams["max_goods_nums"].ObjectToInt(0);
|
//如果最大为设置值
|
||||||
goods.stock = maxGoodsNums;
|
if (promotion.maxGoodsNums > 0)
|
||||||
//活动销售件数
|
{
|
||||||
goods.product.stock = maxGoodsNums - checkOrder.TotalOrders;
|
//最多只能买这么多
|
||||||
goods.buyPromotionCount = checkOrder.TotalOrders;
|
goods.stock = promotion.maxGoodsNums;
|
||||||
}
|
//然后实际能买的要减去以前买的
|
||||||
else
|
goods.product.stock = checkOrder.TotalOrders - promotion.maxGoodsNums >= 0 ? 0 : promotion.maxGoodsNums - checkOrder.TotalOrders;
|
||||||
{
|
|
||||||
goods.buyPromotionCount = checkOrder.TotalOrders;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//如果设置了限购数量
|
||||||
|
if (promotion.maxNums > 0)
|
||||||
|
{
|
||||||
|
//最多只能买这么多
|
||||||
|
goods.stock = promotion.maxNums;
|
||||||
|
//实际可购买数量为:实际消费数量-最大可消费数量,如果大于或者等于,就不能买了。库存为0,或最大购买数减去已经购买数
|
||||||
|
goods.product.stock = checkOrder.TotalOrders - promotion.maxNums >= 0 ? 0 : promotion.maxNums - checkOrder.TotalOrders;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
goods.buyPromotionCount = checkOrder.TotalOrders;
|
||||||
|
|
||||||
|
|
||||||
var dt = DateTime.Now;
|
var dt = DateTime.Now;
|
||||||
|
|
||||||
goods.groupId = promotion.id;
|
goods.groupId = promotion.id;
|
||||||
|
|||||||
Reference in New Issue
Block a user