Commit d63436f2 authored by liudong1993's avatar liudong1993

Merge branch 'sdzq' of http://gitlab.oytour.com/Kui2/mall.oytour.com into sdzq-ld

parents 55f5d35d 7d82ed23
......@@ -2412,5 +2412,55 @@ namespace Mall.Module.Education
}
#endregion
#region 网课小程序个人中心-学习卡中心
/// <summary>
/// 领劵中心优惠券
/// </summary>
/// <param name="query">查询条件</param>
/// <returns></returns>
public List<RB_Education_Coupon_Extend> GetAllCouponList(int pageIndex, int pageSize, out long rowCount, RB_Education_Coupon_Extend query)
{
var list = discountCouponRepository.GetAllCouponList(pageIndex, pageSize, out rowCount, query);
//获取特定商品或者分类的数据
string Ids = string.Join(",", list.Where(x => x.UseType == Common.Enum.MarketingCenter.UseTypeEnum.Category).Select(x => x.ID));
if (!string.IsNullOrWhiteSpace(Ids))
{
query.UseType = Common.Enum.MarketingCenter.UseTypeEnum.Category;
var listProduct = productRepository.GetListByDiscountCouponIds(query, Ids);
foreach (var item in list.Where(x => x.UseType == Common.Enum.MarketingCenter.UseTypeEnum.Category))
{
item.ProductList = new List<RB_Education_CouponProduct_Extend>();
item.ProductList = listProduct.Where(x => x.CouponId == item.ID).ToList();
}
}
Ids = string.Join(",", list.Where(x => x.UseType == Common.Enum.MarketingCenter.UseTypeEnum.Product).Select(x => x.ID));
if (!string.IsNullOrWhiteSpace(Ids))
{
query.UseType = Common.Enum.MarketingCenter.UseTypeEnum.Product;
var listProduct = productRepository.GetListByDiscountCouponIds(query, Ids);
foreach (var item in list.Where(x => x.UseType == Common.Enum.MarketingCenter.UseTypeEnum.Product))
{
item.ProductList = new List<RB_Education_CouponProduct_Extend>();
item.ProductList = listProduct.Where(x => x.CouponId == item.ID).ToList();
}
}
return list;
}
/// <summary>
/// 会员优惠券
/// </summary>
/// <returns></returns>
public List<RB_Education_MemberCoupon_Extend> GetMemberDiscountCouponList(RB_Education_MemberCoupon_Extend query)
{
return memberCouponRepository.GetList(query);
}
#endregion
}
}
......@@ -204,7 +204,7 @@ SELECT a.ID as MemberCouponId,a.UserId,b.`Name`,b.CouponType,b.UseType,b.MinCons
/// <returns></returns>
public List<RB_Education_Coupon_Extend> GetAllCouponList(int pageIndex, int pageSize, out long rowCount, RB_Education_Coupon_Extend query)
{
string where = " where a.`Status`=0 and a.PickupCenter=1";
string where = " where a.`Status`=0 and a.PickupCenter=1 and (a.TotalNum=-1 or a.TotalNum>0)";
string userWhere = "";//分类
if (query != null)
{
......@@ -234,10 +234,10 @@ SELECT a.ID as MemberCouponId,a.UserId,b.`Name`,b.CouponType,b.UseType,b.MinCons
where += $" AND a.{nameof(RB_Education_Coupon_Extend.SmallShopId)}=0";
}
}
string sql = @$" SELECT t.*,c.MemberNum from (SELECT a.ID,a.`Name`,a.`Describe`,a.CouponType,a.UseType,a.StartDate,a.EndDate,a.CouponIco,a.IndateDay,a.IndateType from {TableName} as a
string sql = @$" SELECT t.*,c.MemberNum from (SELECT a.ID,a.`Name`,a.`Describe`,a.CouponType,a.UseType,a.StartDate,a.EndDate,a.CouponIco,a.IndateDay,a.IndateType,a.TotalNum,a.CouponIco from {TableName} as a
{where} and a.IndateType=1
UNION ALL
SELECT a.ID,a.`Name`,a.`Describe`,a.CouponType,a.UseType,a.StartDate,a.EndDate,a.CouponIco,a.IndateDay,a.IndateType from {TableName} as a
SELECT a.ID,a.`Name`,a.`Describe`,a.CouponType,a.UseType,a.StartDate,a.EndDate,a.CouponIco,a.IndateDay,a.IndateType,a.TotalNum,a.CouponIco from {TableName} as a
{where} and a.IndateType=2 and a.EndDate>NOW() )
as t LEFT JOIN (SELECT CouponId,COUNT(*) as MemberNum from RB_Education_MemberCoupon where `Status`=0 {userWhere} GROUP BY CouponId) as c on t.ID=c.CouponId ";
return GetPage<RB_Education_Coupon_Extend>(pageIndex, pageSize, out rowCount, sql).ToList();
......
......@@ -51,6 +51,10 @@ namespace Mall.Repository.Education
{
builder.Append($" AND a.{nameof(RB_Education_MemberCoupon_Extend.Id)} in ({query.Ids})");
}
//if (query.UseState >= 0)
//{
// builder.Append($" AND a.{nameof(RB_Member_DiscountCoupon_Extend.UseState)}={query.UseState}");
//}
}
string sql = @$" select * FROM {TableName} AS a where 1=1 {builder.ToString()} ";
return Get<RB_Education_MemberCoupon_Extend>(sql).ToList();
......
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