Commit 2c14ff84 authored by liudong1993's avatar liudong1993

1、商城活动定时器

parent af7f1f37
......@@ -178,13 +178,13 @@ namespace Mall.Module.Product
//查询中奖活动
var myPrizeList = goods_Activity_GetRepository.GetList(new RB_Goods_Activity_Get_Extend() { TenantId = demodel.TenantId, MallBaseId = demodel.MallBaseId, ActivityIds = string.Join(",", list.Select(x => x.Id)), UserId = UserId });
int AfterTime = 0;
if (demodel.QActivityState == 1) {
//if (demodel.QActivityState == 1) {
var mallModel = mallBaseRepository.GetEntity(demodel.MallBaseId);
if (mallModel != null && mallModel.AfterTime > 0)
{
AfterTime = mallModel.AfterTime;
}
}
//}
foreach (var item in list)
{
if (item.RangeType == 1)
......@@ -213,10 +213,10 @@ namespace Mall.Module.Product
else
{
item.IsFinish = 2;
if (demodel.QActivityState == 1)
{
//if (demodel.QActivityState == 1)
//{
//查询分类/商品下
var clist = goods_OrderRepository.GetGoodsNumForCategoryOrGoods(item, UserId, AfterTime);
var clist = goods_OrderRepository.GetGoodsNumForCategoryOrGoods_V2(item, UserId, AfterTime);//查询所有活动日期内的已付款订单
if (item.Tier == 1 || item.Tier == 2 || item.Tier == 3)
{
//如果属于有限定层级 需要先遍历 查询出对应的层级人员
......@@ -261,7 +261,7 @@ namespace Mall.Module.Product
//商品数量
item.Number = clist.Sum(x => x.Number);
}
}
//}
}
}
}
......
......@@ -2304,6 +2304,47 @@ GROUP BY od.Id ";
}
}
/// <summary>
/// 获取分销商品数量 用户小程序端查询 只查询正常订单
/// </summary>
/// <param name="dmodel"></param>
/// <param name="UserId"></param>
/// <param name="AfterTime"></param>
/// <returns></returns>
public List<RB_Goods_Activity_Extend> GetGoodsNumForCategoryOrGoods_V2(RB_Goods_Activity_Extend dmodel, int UserId, int AfterTime)
{
string where = @$"AND o.`Status` =0 AND o.Recycled=2 AND o.OrderStatus in(2,3,4,5,6) and oa.ReOrderId is null
AND o.CreateDate >='{dmodel.StartTime.ToString("yyyy-MM-dd")}' AND o.CreateDate <='{dmodel.EndTime.ToString("yyyy-MM-dd HH:mm:ss")}'
AND IFNULL(o.{(dmodel.ActiveObject == 1 ? "DistributorTree" : "UserTree")},'') <> '' ";
if (UserId > 0)
{
where += $" AND FIND_IN_SET({UserId},o.{(dmodel.ActiveObject == 1 ? "DistributorTree" : "UserTree")})";
}
if (dmodel.RangeType == 1)
{
string sql = $@"
SELECT od.Id,od.Number,od.Final_Price,o.OrderId,o.{(dmodel.ActiveObject == 1 ? "DistributorTree" : "UserTree")} as UserTree FROM rb_goods_orderdetail od
LEFT JOIN rb_goods_order o ON o.OrderId = od.OrderId
LEFT JOIN rb_goods_category gc ON od.GoodsId = gc.GoodsId
left join rb_goods_orderaftersale oa on od.Id= oa.OrderDetialId and oa.Type=1 and oa.Status=0 and oa.ReOrderStatus in (1,2,3,4,5)
WHERE gc.CategoryId in ({dmodel.RangeIds})
{where}
GROUP BY od.Id ";
return Get<RB_Goods_Activity_Extend>(sql).ToList();
}
else
{
string sql = $@"
SELECT od.Id,od.Number,od.Final_Price,o.OrderId,o.{(dmodel.ActiveObject == 1 ? "DistributorTree" : "UserTree")} as UserTree FROM rb_goods_orderdetail od
LEFT JOIN rb_goods_order o ON o.OrderId = od.OrderId
left join rb_goods_orderaftersale oa on od.Id= oa.OrderDetialId and oa.Type=1 and oa.Status=0 and oa.ReOrderStatus in (1,2,3,4,5)
WHERE od.GoodsId in({dmodel.RangeIds})
{where}
GROUP BY od.Id ";
return Get<RB_Goods_Activity_Extend>(sql).ToList();
}
}
#endregion
}
}
This diff is collapsed.
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