/// <summary> /// 获取优惠券 /// </summary> /// <param name="id"></param> /// <returns></returns> public ActionResult OtherCouponOwn(int id) { if (_workContext.CurrentUser == null) { return(Redirect("http://www.iyookee.cn/#/user/login")); } var couponCategory = _otherCouponCategoryService.GetCouponCategoryById(id); var condition = new OtherCouponSearchCondition { CouponCategoryId = id, Status = 0 }; var coupon = _otherCouponService.GetCouponByCondition(condition).FirstOrDefault(); if (coupon != null) { _otherCouponOwnerService.CreateRecord(_workContext.CurrentUser.Id, coupon.Id); coupon.Status = EnumOtherCouponStatus.Owned; _otherCouponService.Update(coupon); couponCategory.Count = couponCategory.Count - 1; _otherCouponCategoryService.UpdateCouponCategory(couponCategory); var brand = _productBrandService.GetProductBrandById(couponCategory.BrandId); var couponOwn = new CouponCategoryModel { Name = couponCategory.Name, Number = coupon.Number, BrandName = brand.Bname }; return(View(couponOwn)); } return(RedirectToAction("OtherCoupons", "OtherCoupons")); }
public HttpResponseMessage Index(int page, int pageSize, string number) { var condition = new OtherCouponSearchCondition { Number = number, Page = page, PageCount = pageSize, OrderBy = EnumOtherCouponSearchOrderBy.OrderById }; var coupon = _otherCouponService.GetCouponByCondition(condition).Select(p => new { p.Id, p.Number, p.Price, p.Status }).ToList(); var count = _otherCouponService.GetCouponCount(condition); return(PageHelper.toJson(new { List = coupon, TotalCount = count, Condition = condition })); }