public ActionResult ChargeItem(string isRegular) { List<dynamic> chargeList = new ChargeItemRule().GetChargeItemForCheckBox(isRegular); var showList = from charge in chargeList select new { ID = charge.ID, NAME = charge.NAME, PRICE = charge.UNITPRICE }; return Json(showList, JsonRequestBehavior.AllowGet); }
/// <summary> /// 获取欠费详细信息 /// </summary> /// <param name="customerIDList"></param> /// <returns></returns> public JsonResult GetArrearInfo(string customerIDs) { CustomerRule cusRule = new CustomerRule(); AgreementsRule agreeRule = new AgreementsRule(); ChargeRule chRule = new ChargeRule(); ChargeItemRule chargeItemRule = new ChargeItemRule(); List<object> arrearList = new List<object>(); string[] customerIDArray = customerIDs.Split(','); foreach (string customerID in customerIDArray) { // 客户信息 var customer = cusRule.CustomerDetail(customerID); // 协议信息 var agreements = agreeRule.GetAgreementObjectByCustomerID(customerID); decimal totalFee = chRule.CaculateCustomerFee(customerID); //缴费总月份 Ajax.Model.Customer c = new CustomerRule().GetModel(customerID); int monthCount = chRule.GetMonthCount(Convert.ToDateTime(c.BeginChargeDate)); // 缴费项目信息 List<dynamic> chargeItemList = new ChargeItemRule().SearchChargeItem(customerID); var chargeItem = from chargeItems in chargeItemList select new { Name = chargeItems.NAME, Price = chargeItemRule.GetPriceByItemID(chargeItems.ID, Convert.ToDecimal(chargeItems.COUNT), customerID), Count = chargeItems.COUNT, AgreeMentMoney = chargeItems.AGREEMENTMONEY, ItemCount = monthCount * CaculateItemCount(chargeItems.AGREEMENTMONEY, Convert.ToString(chargeItemRule.GetPriceByItemID(chargeItems.ID, Convert.ToDecimal(chargeItems.COUNT), customerID)), chargeItems.COUNT) }; //子客户费用信息 List<Ajax.Model.Customer> customerChildrenList = new CustomerRule().GetChildrenCustomer(customerID); var childrenCustomer = from childC in customerChildrenList select new { Name = childC.Name, Fee = chRule.CaculateCustomerFee(childC.ID, false) }; arrearList.Add(new { customer, agreements, monthCount, totalFee, chargeItem, childrenCustomer }); } return Json(arrearList, JsonRequestBehavior.AllowGet); }
public ActionResult AddChargeItem(ChargeItem item) { AjaxResult result = new AjaxResult(); item.ID = Guid.NewGuid().ToString("N").ToUpper(); item.PY = Pinyin.GetPinyin(item.Name); ChargeItemRule rule = new ChargeItemRule(); item.Code = rule.GetNewCode(); try { rule.Add(item); result.Success = true; result.Message = "缴费项目添加成功。"; } catch (Exception ex) { result.Success = false; result.Message = ex.Message; } return Json(result, JsonRequestBehavior.AllowGet); }
/// <summary> /// 新增临时收费 /// </summary> /// <param name="tCharge"></param> /// <param name="tChargeDetails"></param> public void AddTempCharge(TempCharge tCharge, List<TempChargeDetail> tChargeDetails) { if (tChargeDetails != null) { tCharge.ID = Guid.NewGuid().ToString("N"); tCharge.CreateTime = DateTime.Now; foreach (TempChargeDetail detail in tChargeDetails) { detail.ID = Guid.NewGuid().ToString("N"); detail.TempChargeID = tCharge.ID; detail.CreateTime = DateTime.Now; if (!string.IsNullOrEmpty(detail.ItemID)) { decimal itemPrice = new ChargeItemRule().GetPriceByItemID(detail.ItemID, detail.Count, ""); detail.Money = Convert.ToDecimal(detail.Count) * itemPrice; tCharge.Money += detail.Money; } } dal.AddTempCharge(tCharge, tChargeDetails); } }
/// <summary> /// 新增临时收费 /// </summary> /// <param name="tCharge"></param> /// <param name="tChargeDetails"></param> public void AddTempCharge(TempCharge tCharge, List <TempChargeDetail> tChargeDetails) { if (tChargeDetails != null) { tCharge.ID = Guid.NewGuid().ToString("N"); tCharge.CreateTime = DateTime.Now; foreach (TempChargeDetail detail in tChargeDetails) { detail.ID = Guid.NewGuid().ToString("N"); detail.TempChargeID = tCharge.ID; detail.CreateTime = DateTime.Now; if (!string.IsNullOrEmpty(detail.ItemID)) { decimal itemPrice = new ChargeItemRule().GetPriceByItemID(detail.ItemID, detail.Count, ""); detail.Money = Convert.ToDecimal(detail.Count) * itemPrice; tCharge.Money += detail.Money; } } dal.AddTempCharge(tCharge, tChargeDetails); } }
/// <summary> /// 缴费操作 /// </summary> /// <param name="CustomerID">客户ID</param> /// <param name="ChargeMonth">缴费月数</param> /// <param name="ChargeMoney">缴费金额</param> /// <returns></returns> public string Charge(string CustomerID, int ChargeMonth, decimal ChargeMoney, string operatorID) { CustomerRule customerRule = new CustomerRule(); Ajax.DAL.ChargeDAL chargeDAL = new DAL.ChargeDAL(); Customer customer = customerRule.GetModel(CustomerID); SysParameterRule parameterRule = new SysParameterRule(); dynamic result = new System.Dynamic.ExpandoObject(); int status = 0; // 缴费状态,0 不自动审批,1 自动审批 decimal allMoney = 0m; status = Convert.ToInt32(parameterRule.GetSysParameterValue(Ajax.Common.CommonEnums.SysParameterEnums.ChargeAutoPass)); if (customer == null) { result = "客户不存在"; return(result); } if (customer.Status != 1) { result = "客户状态非启用,不能缴费"; return(result); } Agreements agreement = new AgreementsRule().GetAgreementByCustomerID(CustomerID); // 定义缴费主表对象 Ajax.Model.Charge charge = new Ajax.Model.Charge() { AgreementID = agreement == null ? null : agreement.ID, BeginDate = agreement == null ? customer.BeginChargeDate.Value : agreement.BeginDate, EndDate = agreement == null?customer.BeginChargeDate.Value.AddMonths(ChargeMonth) : agreement.EndDate, CreateDate = DateTime.Now, CustomerID = CustomerID, ID = Guid.NewGuid().ToString("N"), IsAgreementCharge = agreement == null ? 0 : 1, Money = ChargeMoney, OperatorID = operatorID, Status = status }; // 协议缴费,不计算缴费明细 if (agreement != null) { string temp = chargeDAL.ChargeByAgreement(charge, agreement); if (!string.IsNullOrEmpty(temp)) { result = temp; } else { result = "缴费成功"; } } // 非协议缴费,计算缴费明细 else { // 明细缴费 List <Ajax.Model.ChargeDetail> chargeDetailList = new List <Ajax.Model.ChargeDetail>(); // 缴费明细 List <CustomerChargeItem> myChargeItem = new List <CustomerChargeItem>(); myChargeItem = new CustomerChargeItemRule().GetListBycustomerID(CustomerID); ChargeItemRule chargeitemRule = new ChargeItemRule(); // 先添加本客户 foreach (CustomerChargeItem item in myChargeItem) { Ajax.Model.ChargeDetail chargeDetail = new Ajax.Model.ChargeDetail() { ChargeID = charge.ID, CreateDate = DateTime.Now, ID = Guid.NewGuid().ToString("N"), ChargeItemID = item.ItemID, ItemMoney = chargeitemRule.GetPriceByItemID(item.ItemID, item.Count, CustomerID) * ChargeMonth, Month = ChargeMonth, Status = status }; allMoney += chargeDetail.ItemMoney; chargeDetailList.Add(chargeDetail); } List <Customer> childCustomerList = customerRule.GetChildrenCustomer(CustomerID); foreach (Customer c in childCustomerList) { myChargeItem = new CustomerChargeItemRule().GetListBycustomerID(c.ID); foreach (CustomerChargeItem item in myChargeItem) { Ajax.Model.ChargeDetail chargeDetail = new Ajax.Model.ChargeDetail() { ChargeID = charge.ID, CreateDate = DateTime.Now, ID = Guid.NewGuid().ToString("N"), ChargeItemID = item.ItemID, ItemMoney = chargeitemRule.GetPriceByItemID(item.ItemID, item.Count, c.ID) * ChargeMonth, Month = ChargeMonth, Status = status }; allMoney += chargeDetail.ItemMoney; chargeDetailList.Add(chargeDetail); } } charge.Money = allMoney; chargeDAL.ChargeByMonth(charge, chargeDetailList.ToArray(), ChargeMonth); result = "缴费成功"; } return(result); }
/// <summary> /// 递归计算客户(默认包括子客户)的应缴费用 /// </summary> /// <param name="customerID"></param> /// <param name="containChildCustomer">是否计继续算子客户应缴费用</param> /// <returns></returns> public decimal CaculateCustomerFee(string customerID, bool containChildCustomer = true) { decimal totalFee = 0; Customer c = new CustomerRule().GetModel(customerID); int monthCount = GetMonthCount(Convert.ToDateTime(c.BeginChargeDate)); ChargeItemRule chargeItemRule = new ChargeItemRule(); Agreements agree = new AgreementsRule().GetAgreementByCustomerID(customerID); if (agree != null) { totalFee = new AgreementsRule().GetLastAgreeFee(agree.ID); if (agree.EndDate > DateTime.Now) { monthCount = GetMonthCount(agree.EndDate); //客户缴费项 List <CustomerChargeItem> chargeItems = new CustomerChargeItemRule().GetListBycustomerID(customerID); foreach (CustomerChargeItem chargeItem in chargeItems) { if (chargeItem.AgreementMoney > 0) { totalFee += chargeItem.AgreementMoney; } else { decimal itemPrice = chargeItemRule.GetPriceByItemID(chargeItem.ItemID, chargeItem.Count, customerID); totalFee += monthCount * chargeItem.Count * itemPrice; } } } } else //非协议用户&协议过期 { //客户缴费项 List <CustomerChargeItem> chargeItems = new CustomerChargeItemRule().GetListBycustomerID(customerID); foreach (CustomerChargeItem chargeItem in chargeItems) { if (chargeItem.AgreementMoney > 0) { totalFee += chargeItem.AgreementMoney * monthCount; } else { decimal itemPrice = chargeItemRule.GetPriceByItemID(chargeItem.ItemID, chargeItem.Count, customerID); totalFee += monthCount * chargeItem.Count * itemPrice; } } //递归所有子客户应缴金额 if (containChildCustomer) { List <Customer> customerChildrenList = new CustomerRule().GetChildrenCustomer(customerID); if (customerChildrenList != null) { //子客户费用 foreach (Customer childC in customerChildrenList) { totalFee += CaculateCustomerFee(childC.ID); } } } } return(totalFee); }
public ActionResult SelectChargeItemByType() { List<dynamic> list = new ChargeItemRule().SelectChargeItemByType(); ViewBag.ChargeItemList=list; return PartialView(); }
public ActionResult SearchCustomerChildrenList(string customerID) { List<dynamic> childrenChargeItems = new ChargeItemRule().GetCustomerChildrenInfo(customerID); if (childrenChargeItems != null) { var showList = from childrenChargeItem in childrenChargeItems select new { Name = childrenChargeItem.NAME, AreaName = childrenChargeItem.AREANAME, Address = childrenChargeItem.ADDRESS, ChargeName = childrenChargeItem.CHARGENAME, Price = childrenChargeItem.UNITPRICE, Count = childrenChargeItem.COUNT, ItemCount = 0 }; return Json(new { total = childrenChargeItems.Count, rows = showList }, JsonRequestBehavior.AllowGet); } return Json(new { total = 0, rows = "" }, JsonRequestBehavior.AllowGet); }
public ActionResult SearchChargeItem(string customerID) { List<dynamic> chargeItemList = new ChargeItemRule().SearchChargeItem(customerID); if (chargeItemList != null) { var showList = from chargeItems in chargeItemList select new { Name = chargeItems.NAME, Price = chargeItems.UNITPRICE, Count = chargeItems.COUNT, AgreeMentMoney = chargeItems.AGREEMENTMONEY, ItemCount = 0 }; return Json(new { total = chargeItemList.Count, rows = showList }, JsonRequestBehavior.AllowGet); } return Json(new { total = 0, rows = "" }, JsonRequestBehavior.AllowGet); }
/// <summary> /// 递归计算客户(默认包括子客户)的应缴费用 /// </summary> /// <param name="customerID"></param> /// <param name="containChildCustomer">是否计继续算子客户应缴费用</param> /// <returns></returns> public decimal CaculateCustomerFee(string customerID, bool containChildCustomer = true) { decimal totalFee = 0; Customer c = new CustomerRule().GetModel(customerID); int monthCount = GetMonthCount(Convert.ToDateTime(c.BeginChargeDate)); ChargeItemRule chargeItemRule = new ChargeItemRule(); Agreements agree = new AgreementsRule().GetAgreementByCustomerID(customerID); if (agree != null) { totalFee = new AgreementsRule().GetLastAgreeFee(agree.ID); if (agree.EndDate > DateTime.Now) { monthCount = GetMonthCount(agree.EndDate); //客户缴费项 List<CustomerChargeItem> chargeItems = new CustomerChargeItemRule().GetListBycustomerID(customerID); foreach (CustomerChargeItem chargeItem in chargeItems) { if (chargeItem.AgreementMoney > 0) { totalFee += chargeItem.AgreementMoney; } else { decimal itemPrice = chargeItemRule.GetPriceByItemID(chargeItem.ItemID, chargeItem.Count, customerID); totalFee += monthCount * chargeItem.Count * itemPrice; } } } } else//非协议用户&协议过期 { //客户缴费项 List<CustomerChargeItem> chargeItems = new CustomerChargeItemRule().GetListBycustomerID(customerID); foreach (CustomerChargeItem chargeItem in chargeItems) { if (chargeItem.AgreementMoney > 0) { totalFee += chargeItem.AgreementMoney * monthCount; } else { decimal itemPrice = chargeItemRule.GetPriceByItemID(chargeItem.ItemID, chargeItem.Count, customerID); totalFee += monthCount * chargeItem.Count * itemPrice; } } //递归所有子客户应缴金额 if (containChildCustomer) { List<Customer> customerChildrenList = new CustomerRule().GetChildrenCustomer(customerID); if (customerChildrenList != null) { //子客户费用 foreach (Customer childC in customerChildrenList) { totalFee += CaculateCustomerFee(childC.ID); } } } } return totalFee; }
/// <summary> /// 缴费操作 /// </summary> /// <param name="CustomerID">客户ID</param> /// <param name="ChargeMonth">缴费月数</param> /// <param name="ChargeMoney">缴费金额</param> /// <returns></returns> public string Charge(string CustomerID, int ChargeMonth, decimal ChargeMoney, string operatorID) { CustomerRule customerRule = new CustomerRule(); Ajax.DAL.ChargeDAL chargeDAL = new DAL.ChargeDAL(); Customer customer = customerRule.GetModel(CustomerID); SysParameterRule parameterRule = new SysParameterRule(); dynamic result = new System.Dynamic.ExpandoObject(); int status = 0; // 缴费状态,0 不自动审批,1 自动审批 decimal allMoney = 0m; status = Convert.ToInt32(parameterRule.GetSysParameterValue(Ajax.Common.CommonEnums.SysParameterEnums.ChargeAutoPass)); if (customer == null) { result = "客户不存在"; return result; } if (customer.Status != 1) { result = "客户状态非启用,不能缴费"; return result; } Agreements agreement = new AgreementsRule().GetAgreementByCustomerID(CustomerID); // 定义缴费主表对象 Ajax.Model.Charge charge = new Ajax.Model.Charge() { AgreementID = agreement == null ? null : agreement.ID, BeginDate = agreement == null ? customer.BeginChargeDate.Value : agreement.BeginDate, EndDate = agreement == null ? customer.BeginChargeDate.Value.AddMonths(ChargeMonth) : agreement.EndDate, CreateDate = DateTime.Now, CustomerID = CustomerID, ID = Guid.NewGuid().ToString("N"), IsAgreementCharge = agreement == null ? 0 : 1, Money = ChargeMoney, OperatorID = operatorID, Status = status }; // 协议缴费,不计算缴费明细 if (agreement != null) { string temp = chargeDAL.ChargeByAgreement(charge, agreement); if (!string.IsNullOrEmpty(temp)) { result = temp; } else { result = "缴费成功"; } } // 非协议缴费,计算缴费明细 else { // 明细缴费 List<Ajax.Model.ChargeDetail> chargeDetailList = new List<Ajax.Model.ChargeDetail>(); // 缴费明细 List<CustomerChargeItem> myChargeItem = new List<CustomerChargeItem>(); myChargeItem = new CustomerChargeItemRule().GetListBycustomerID(CustomerID); ChargeItemRule chargeitemRule = new ChargeItemRule(); // 先添加本客户 foreach (CustomerChargeItem item in myChargeItem) { Ajax.Model.ChargeDetail chargeDetail = new Ajax.Model.ChargeDetail() { ChargeID = charge.ID, CreateDate = DateTime.Now, ID = Guid.NewGuid().ToString("N"), ChargeItemID = item.ItemID, ItemMoney = chargeitemRule.GetPriceByItemID(item.ItemID, item.Count, CustomerID) * ChargeMonth, Month = ChargeMonth, Status = status }; allMoney += chargeDetail.ItemMoney; chargeDetailList.Add(chargeDetail); } List<Customer> childCustomerList = customerRule.GetChildrenCustomer(CustomerID); foreach (Customer c in childCustomerList) { myChargeItem = new CustomerChargeItemRule().GetListBycustomerID(c.ID); foreach (CustomerChargeItem item in myChargeItem) { Ajax.Model.ChargeDetail chargeDetail = new Ajax.Model.ChargeDetail() { ChargeID = charge.ID, CreateDate = DateTime.Now, ID = Guid.NewGuid().ToString("N"), ChargeItemID = item.ItemID, ItemMoney = chargeitemRule.GetPriceByItemID(item.ItemID, item.Count, c.ID) * ChargeMonth, Month = ChargeMonth, Status = status }; allMoney += chargeDetail.ItemMoney; chargeDetailList.Add(chargeDetail); } } charge.Money = allMoney; chargeDAL.ChargeByMonth(charge, chargeDetailList.ToArray(), ChargeMonth); result = "缴费成功"; } return result; }
public JsonResult CustomerDetail(string customerID) { if (!string.IsNullOrEmpty(customerID)) { // 客户信息 var customer = new CustomerRule().CustomerDetail(customerID); // 缴费项目信息 List<dynamic> chargeItemList = new ChargeItemRule().SearchChargeItem(customerID); var chargeItem = from chargeItems in chargeItemList select new { Name = chargeItems.NAME, Price = chargeItems.UNITPRICE, Count = chargeItems.COUNT, AgreeMentMoney = chargeItems.AGREEMENTMONEY, ItemCount = 0 }; // 协议信息 var agreements = new AgreementsRule().GetAgreementObjectByCustomerID(customerID); // 子客户信息 var childCustomer = new CustomerRule().GetChildrenCustomer(customerID); // 缴费历史 //int itemCount = 0; var chargeHistory = new ChargeRule().ChargeSearch(customerID); // 欠费记录 var arrearRecord = new YearEndArrearRule().GetArrearRecordByCustomerID(customerID); //chargeHistory, return Json(new { customer, chargeItem, agreements, childCustomer, arrearRecord, chargeHistory }, JsonRequestBehavior.AllowGet); } else { return Json(new Ajax.Model.Customer()); } }
public ActionResult ModifyChargeItem(ChargeItem item) { AjaxResult result = new AjaxResult(); try { item.PY = Pinyin.GetPinyin(item.Name); bool flag = new ChargeItemRule().Update(item); if (flag) { result.Success = true; result.Message = "收费项修改成功"; } else { result.Success = false; result.Message = "收费项修改失败"; } } catch (Exception ex) { result.Success = false; result.Message = ex.Message; return Json(result, JsonRequestBehavior.AllowGet); } return Json(result, JsonRequestBehavior.AllowGet); }
public ActionResult DeleteChargeItem(string ID) { AjaxResult result = new AjaxResult(); try { bool flag = new ChargeItemRule().DeleteChargeItem(ID); if (flag) { result.Success = true; result.Message = "删除成功。"; } else { result.Success = false; result.Message = "删除失败。"; } } catch (Exception ex) { result.Success = false; result.Message = ex.Message; return Json(result, JsonRequestBehavior.AllowGet); } return Json(result, JsonRequestBehavior.AllowGet); }
public ActionResult SearchChargeItem(EasyUIGridParamModel param, string name) { int itemCount = 0; List<dynamic> ChargeItemList = new ChargeItemRule().SearchChargeItem(param, name, out itemCount); var showList = from charge in ChargeItemList select new { ID = charge.ID, Code = charge.CODE, Name = charge.NAME, IsRegular = Convert.ToString(charge.ISREGULAR).Replace("False", "否").Replace("True", "是"), IsPloy = Convert.ToString(charge.ISPLOY).Replace("False", "否").Replace("True", "是"), UnitPrice = string.Format("{0} ", charge.UNITPRICE), Unit = string.Format(" 元 [{0}]", charge.UNIT), CategoryName = charge.CATEGORYNAME, UnitID1 = charge.UNITID1, UnitID2 = charge.UNITID2 }; return Json(new { total = itemCount, rows = showList }, JsonRequestBehavior.AllowGet); }