Commit 0aff0e4d authored by 吴春's avatar 吴春

修改/新增优惠券接口

parent 3ed4261b
......@@ -74,6 +74,9 @@ namespace Mall.Model.Entity.User
/// </summary>
public int UseState { get; set; }
/// <summary>
/// 优惠券id
/// </summary>
......@@ -117,7 +120,10 @@ namespace Mall.Model.Entity.User
public UseTypeEnum UseType { get; set; }
/// <summary>
/// 删除
/// </summary>
public int Status { get; set; }
/// <summary>
/// 最低消费金额(元)
/// </summary>
......
......@@ -72,5 +72,11 @@ namespace Mall.Model.Extend.MarketingCenter
/// 分类
/// </summary>
public int[] CategoryIds { get; set; }
/// <summary>
/// 领劵中心领取
/// </summary>
public int GetType { get; set; }
}
}
......@@ -30,7 +30,10 @@ namespace Mall.Model.Extend.User
/// </summary>
public string AliasName { get; set; }
/// <summary>
/// 头像
/// </summary>
public string Photo { get; set; }
/// <summary>
/// 优惠卷ids
......
......@@ -320,6 +320,56 @@ namespace Mall.Module.MarketingCenter
return flag;
}
/// <summary>
/// 删除优惠券
/// </summary>
/// <param name="gradeId"></param>
/// <param name="uid"></param>
/// <returns></returns>
public bool DelMemberCoupon(int id, int uid, int mallBaseId)
{
bool flag = false;
try
{
Dictionary<string, object> cols1 = new Dictionary<string, object>()
{
{ nameof(RB_Member_DiscountCoupon.Status),1},
{ nameof(RB_Member_DiscountCoupon.Remarks),System.DateTime.Now+"删除"},
};
List<WhereHelper> wheres1 = new List<WhereHelper>() {
new WhereHelper(){
FiledName=nameof(RB_Member_DiscountCoupon.Id),
FiledValue=id,
OperatorEnum=OperatorEnum.Equal
},
new WhereHelper(){
FiledName=nameof(RB_Member_DiscountCoupon.TenantId),
FiledValue=Convert.ToInt32(uid),
OperatorEnum=OperatorEnum.Equal
},
new WhereHelper(){
FiledName=nameof(RB_Member_DiscountCoupon.MallBaseId),
FiledValue=Convert.ToInt32(mallBaseId),
OperatorEnum=OperatorEnum.Equal
}
};
flag = memberCouponRepository.Update(cols1, wheres1);
}
catch (Exception ex)
{
LogHelper.Write(ex, "DelMemberCoupon");
return false;
}
return flag;
}
/// <summary>
/// 领劵中心
/// </summary>
......
......@@ -57,7 +57,7 @@ namespace Mall.Repository.MarketingCenter
/// </summary>
/// <param name="query">查询条件</param>
/// <returns></returns>
public List<RB_DiscountCoupon_Extend> GetDiscountCouponList(RB_DiscountCoupon_Extend query,bool IsSelectDel = false)
public List<RB_DiscountCoupon_Extend> GetDiscountCouponList(RB_DiscountCoupon_Extend query, bool IsSelectDel = false)
{
StringBuilder builder = new StringBuilder();
if (IsSelectDel)
......@@ -260,6 +260,14 @@ as t LEFT JOIN (SELECT CouponId,COUNT(*) as MemberNum from rb_member_discountc
where += $" AND a.{nameof(RB_Member_DiscountCoupon.UserId)}={query.UserId}";
}
if (query.StartDate.HasValue)
{
where += $" AND a.{nameof(RB_Member_DiscountCoupon.CreateDate)}>='{query.StartDate.Value:yyyy-MM-dd HH:mm:ss}'";
}
if (query.EndDate.HasValue)
{
where += $" AND a.{nameof(RB_Member_DiscountCoupon.CreateDate)}<='{query.EndDate.Value:yyyy-MM-dd HH:mm:ss}'";
}
if (query.UseState == 0)
{
where += $" AND a.{nameof(RB_Member_DiscountCoupon_Extend.UseState)}={query.UseState} AND a.{nameof(RB_Member_DiscountCoupon_Extend.EndDate)}> NOW()";
......@@ -273,7 +281,7 @@ as t LEFT JOIN (SELECT CouponId,COUNT(*) as MemberNum from rb_member_discountc
where += $" AND a.{nameof(RB_Member_DiscountCoupon_Extend.EndDate)}<NOW() AND a.{nameof(RB_Member_DiscountCoupon_Extend.UseState)}=0";
}
}
string sql = @$" SELECT a.ID as MemberCouponId,a.StartDate,a.EndDate,b.ID,b.`Name`,b.`Describe`,b.CouponType,b.UseType,
string sql = @$" SELECT a.ID as MemberCouponId,a.UseState,a.StartDate,a.EndDate,b.ID,b.`Name`,b.`Describe`,b.CouponType,b.UseType,a.GetType,
b.MinConsumePrice,b.MaxDiscountsPrice,b.DiscountsPrice,b.IndateDay,b.IndateType from rb_member_discountcoupon as a LEFT JOIN rb_discountcoupon as b
on a.CouponId=b.ID {where} ";
return GetPage<RB_DiscountCoupon_Extend>(pageIndex, pageSize, out rowCount, sql).ToList();
......
......@@ -333,7 +333,7 @@ LEFT JOIN {DiscountCouponTableName} as c on c.ID=a.CouponId where a.EndDate<NO
}
}
string sql = @$" SELECT a.*,b.CreateDate as OrderCreateDate,c.`Name`,c.MinConsumePrice,c.CouponType,d.AliasName from rb_member_discountcoupon as a
string sql = @$" SELECT a.*,b.CreateDate as OrderCreateDate,c.`Name`,c.MinConsumePrice,c.CouponType,c.DiscountsPrice,d.`Name` as AliasName,d.Photo from rb_member_discountcoupon as a
LEFT JOIN rb_goods_order as b on a.OrderId=b.OrderId
LEFT JOIN rb_discountcoupon as c on c.ID=a.CouponId
LEFT JOIN rb_member_user as d on d.AliasName=a.UserId where a.UseState=1 {builder.ToString()}";
......
......@@ -471,6 +471,73 @@ namespace Mall.WebApi.Controllers.MarketingCenter
/// <summary>
/// 我的优惠券
/// </summary>
/// <returns></returns>
[HttpPost]
public ApiResult GetCouponPageListByMemberId()
{
var req = RequestParm;
ResultPageModel pagelist = JsonConvert.DeserializeObject<ResultPageModel>(req.msg.ToString());
RB_DiscountCoupon_Extend demodel = JsonConvert.DeserializeObject<RB_DiscountCoupon_Extend>(req.msg.ToString());
demodel.TenantId = UserInfo.TenantId;
demodel.MallBaseId = req.MallBaseId;
var list = IntegralModule.GetMemberDisCouponList(pagelist.pageIndex, pagelist.pageSize, out long count, demodel);
pagelist.count = Convert.ToInt32(count);
pagelist.pageData = list.Select(x => new
{
x.Name,
x.Describe,
x.MinConsumePrice,
x.MaxDiscountsPrice,
x.DiscountsPrice,
x.CouponType,
x.ID,
x.MemberCouponId,
CreateDate = x.CreateDate.ToString("yyyy-MM-dd HH:ss:mm"),
StartDate = x.StartDate.HasValue ? x.StartDate.Value.ToString("yyyy-MM-dd HH:ss:mm") : "",
EndDate = x.EndDate.HasValue ? x.EndDate.Value.ToString("yyyy-MM-dd HH:ss:mm") : "",
UseTypeStr = ((int)x.UseType == 3 || (int)x.UseType == 4) ? x.UseType.GetEnumName() : (x.ProductList != null && x.ProductList.Any() ? string.Join("、", x.ProductList.Select(x => x.Relevance)) : ""),
x.UseType,
x.ProductList,
x.PickupCenter,
x.UseState,
x.GetType
});
return ApiResult.Success("", pagelist);
}
/// <summary>
/// 删除用户优惠券
/// </summary>
/// <returns></returns>
[HttpPost]
public ApiResult DelMemberCoupon()
{
var parms = RequestParm;
JObject parmsJob = JObject.Parse(RequestParm.msg.ToString());
int Id = parmsJob.GetInt("MemberCouponId", 0);
if (Id <= 0)
{
return ApiResult.Failed("请传递参数");
}
bool flag = IntegralModule.DelMemberCoupon(Id, UserInfo.TenantId, parms.MallBaseId);
if (flag)
{
return ApiResult.Success();
}
else
{
return ApiResult.Failed();
}
}
#endregion
......@@ -747,12 +814,15 @@ namespace Mall.WebApi.Controllers.MarketingCenter
pagelist.count = Convert.ToInt32(count);
pagelist.pageData = list.Select(x => new
{
x.Photo,
x.OrderCreateDate,
x.OrderId,
x.Name,
x.AliasName,
x.MinConsumePrice,
CouponTypeStr = Mall.Common.Plugin.EnumHelper.GetEnumName(x.CouponType),
x.CouponType,
x.DiscountsPrice,
x.UseState
});
return ApiResult.Success("", pagelist);
......
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