【修复】修复秒杀列表显示错误的问题。

This commit is contained in:
大灰灰
2022-10-25 15:12:04 +08:00
parent 3aacf52dbb
commit b6739902da
7 changed files with 13 additions and 24 deletions

View File

@@ -57,7 +57,7 @@ namespace CoreCms.Net.IServices
/// 获取团购/秒杀商品详情
/// </summary>
/// <returns></returns>
Task<WebApiCallBack> GetGroupDetail(int goodId = 0, int userId = 0, string type = "group", int groupId = 0, bool needSku = false);
Task<WebApiCallBack> GetGroupDetail(int goodId = 0, int userId = 0, int type = (int)GlobalEnumVars.PromotionType.Group, int groupId = 0, bool needSku = false);
/// <summary>
/// 获取可领取的优惠券

View File

@@ -44,7 +44,7 @@ namespace CoreCms.Net.Model.FromBody
public int id { get; set; }
public int groupId { get; set; }
public string type { get; set; }
public int type { get; set; }
public bool needSku { get; set; } = false;

View File

@@ -551,6 +551,7 @@ namespace CoreCms.Net.Services
else
{
product = await _productsServices.QueryByClauseAsync(p => p.goodsId == good.id && p.isDel == false && p.isDefalut == true, true);
if (product == null) return null;
}
//商品基础赋值===================================================================================================

View File

@@ -190,15 +190,7 @@ namespace CoreCms.Net.Services
var jm = new WebApiCallBack { status = true };
var where = PredicateBuilder.True<CoreCmsPromotion>();
where = where.And(p => p.isEnable == true && p.isDel == false);
if (type == (int)GlobalEnumVars.PromotionType.Group)
{
where = where.And(p => p.type == (int)GlobalEnumVars.PromotionType.Group);
}
else if (type == (int)GlobalEnumVars.PromotionType.Seckill)
{
where = where.And(p => p.type == (int)GlobalEnumVars.PromotionType.Seckill);
}
where = where.And(p => p.isEnable == true && p.isDel == false && p.type == type);
var dt = DateTime.Now;
@@ -229,7 +221,7 @@ namespace CoreCms.Net.Services
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, type, item.id);
if (res.status)
{
var good = res.data as CoreCmsGoods;
@@ -274,7 +266,7 @@ namespace CoreCms.Net.Services
/// </summary>
/// <returns></returns>
public async Task<WebApiCallBack> GetGroupDetail(int goodId = 0, int userId = 0, string type = "group", int groupId = 0, bool needSku = false)
public async Task<WebApiCallBack> GetGroupDetail(int goodId = 0, int userId = 0, int type = (int)GlobalEnumVars.PromotionType.Group, int groupId = 0, bool needSku = false)
{
using var container = _serviceProvider.CreateScope();
@@ -288,14 +280,8 @@ namespace CoreCms.Net.Services
return jm;
}
var typeId = (int)GlobalEnumVars.PromotionType.Group;
if (type == GlobalEnumVars.PromotionType.Seckill.ToString().ToLowerInvariant())
{
typeId = (int)GlobalEnumVars.PromotionType.Seckill;
}
//判断商品是否参加团购
var isInGroup = _dal.IsInGroup(goodId, out var promotionId, typeId);
var isInGroup = _dal.IsInGroup(goodId, out var promotionId, type);
if (!isInGroup)
{
jm.msg = "商品未参加团购";
@@ -311,7 +297,9 @@ namespace CoreCms.Net.Services
}
var goods = new CoreCmsGoods();
goods = await goodsServices.GetGoodsDetail(goodId, userId, true, type, groupId, needSku);
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);
if (goods == null)
{
jm.msg = "商品不存在";

View File

@@ -545,7 +545,7 @@ namespace CoreCms.Net.Services
if (obj.ContainsKey("goodsId") && obj["goodsId"].ObjectToInt(0) > 0)
{
var goodsId = obj["goodsId"].ObjectToInt(0);
var goods = await _promotionServices.GetGroupDetail(goodsId, 0, "group", promotionId);
var goods = await _promotionServices.GetGroupDetail(goodsId, 0, (int)GlobalEnumVars.PromotionType.Group, promotionId);
if (goods.status)
{
var goodJson = JsonConvert.SerializeObject(goods.data);

View File

@@ -595,7 +595,7 @@
let data = {
id: this.goodsId,
groupId: this.groupId,
type: "group",
type: this.cartType,
needSku: true,
};
// 如果用户已经登录 要传用户token

View File

@@ -604,7 +604,7 @@
let data = {
id: this.goodsId,
groupId: this.groupId,
type: "seckill",
type: this.cartType,
needSku: true
};
// 如果用户已经登录 要传用户token