public JsonResult SumCardPkgConsumeItems() { ReturnedData data = new ReturnedData(); try { string cardNo = NullHelper.Convert<string>(Request["cardNo"], ""); string itemData = NullHelper.Convert<string>(Request["itemData"], ""); if (!string.IsNullOrEmpty(itemData)) { List<ConsumePkgViewModel> list = JsonSerializerPkg(itemData, ConsumeType.ClubPackage); ClubCardMgm cardMgm = new ClubCardMgm(); var card = cardMgm.GetClubCardByCardNo(cardNo); var conlist = GetConsumeList(list, card, ConsumeType.ClubPackage); ConsumeMgm conMgm = new ConsumeMgm(); var consSerNo = conMgm.ConsumePkg(conlist); data.Success = true; LogHandler.Info(Emp.UserName + "添加会员套餐消费,时间:" + DateTime.Now); data.Message = consSerNo + "|" + conlist.FirstOrDefault().CreatedDate.ToString("yyyy/MM/dd HH:mm:ss"); data.Data = cardMgm.GetDetailByClubCardPkgID(list[0].PkgId); } } catch (Exception ex) { data.Success = false; data.Message = "出现错误,请联系维护人员"; data.Error = ex.ToString(); LogHandler.Error(ex.Message.ToString()); } return Json(data, JsonRequestBehavior.AllowGet); }
/// <summary> /// 获取会员卡套餐消费项目 /// </summary> /// <returns></returns> public JsonResult GetCardPkgItemList() { ReturnedData data = new ReturnedData(); try { string cardPkgId = NullHelper.Convert<string>(Request["cardPkgId"],"-1"); ClubCardMgm cardMgm = new ClubCardMgm(); var result = cardMgm.GetDetailByClubCardPkgID(cardPkgId); List<SelectListItem> itemList = new List<SelectListItem>(); result = result.SkipWhile(i => i.RemainCount == 0).ToList(); if(result!=null&&result.Count>0) { result.ForEach(item => { if (item.RemainCount > 0) { if (itemList.Count <= 0) itemList.Add(new SelectListItem() { Text = item.ItemName, Value = item.PackageDetailID.ToString(), Selected = true }); else itemList.Add(new SelectListItem() { Text = item.ItemName, Value = item.PackageDetailID.ToString() }); } }); } else { itemList.Add(new SelectListItem() { Text = "套餐无可用项目", Value = "-1", Selected = true }); } data.Success = true; data.Data = itemList; } catch(Exception ex) { LogHandler.Error(ex.Message.ToString()); data.Success = false; data.Message = "出现错误,请联系维护人员"; data.Error = ex.ToString(); } return Json(data, JsonRequestBehavior.AllowGet); }