| | |
| | | ResultEntity resultEntity = new ResultEntity(); |
| | | try |
| | | { |
| | | var temp = _context.SimCost.Where(e => e.id == md.id).SingleOrDefault(); |
| | | var temp = _context.SimCost.Where(e => e.sim_id == md.sim_id && e.bill_year==md.bill_year && e.bill_month==md.bill_month).SingleOrDefault(); |
| | | var tempBind = _context.SimBindView.Where(e => e.Id == md.sim_id).SingleOrDefault(); |
| | | if (temp != null && temp.status=="0") |
| | | { |
| | | temp.bill_amount = md.bill_amount; |
| | | temp.bill_month = md.accounted_time.Month; |
| | | temp.bill_year = md.accounted_time.Year; |
| | | //temp.bill_month =md.m; |
| | | //temp.bill_year = md.accounted_time.Year; |
| | | temp.sub_userid = md.sub_userid; |
| | | temp.up_time = DateTime.Now; |
| | | if(tempBind!=null) |
| | |
| | | } |
| | | else |
| | | { |
| | | md.bill_month = md.accounted_time.Month; |
| | | md.bill_year = md.accounted_time.Year; |
| | | //md.bill_month = md.accounted_time.Month; |
| | | //md.bill_year = md.accounted_time.Year; |
| | | |
| | | //当月重复判断 |
| | | var monthck = _context.SimCost.Where(c => c.sim_id == md.sim_id && c.bill_year == md.bill_year && c.bill_month == md.bill_month).Count(); |
| | | if(monthck>0) |
| | | { |
| | | resultEntity.Result = false; |
| | | resultEntity.Message = string.Format("此电话卡在[{0}-{1}]月已存在记录,不能重复添加;",md.bill_year,md.bill_month); |
| | | return resultEntity; |
| | | } |
| | | else |
| | | //var monthck = _context.SimCost.Where(c => c.sim_id == md.sim_id && c.bill_year == md.bill_year && c.bill_month == md.bill_month).Count(); |
| | | //if(monthck>0) |
| | | //{ |
| | | // resultEntity.Result = false; |
| | | // resultEntity.Message = string.Format("此电话卡在[{0}-{1}]月已存在记录,不能重复添加;",md.bill_year,md.bill_month); |
| | | // return resultEntity; |
| | | //} |
| | | //else |
| | | { |
| | | md.up_time = DateTime.Now; |
| | | md.status = "0"; |
| | | |
| | | md.accounted_time = DateTime.Now; |
| | | if (tempBind != null) |
| | | { |
| | | md.allow_amount = decimal.Parse(tempBind.cardpro); |
| | |
| | | /// </summary> |
| | | /// <param name="searchEntity"></param> |
| | | /// <returns></returns> |
| | | public ResultDataEntity<SimCostView> SearchSimCostByPage(SimCostDTOSearch searchEntity) |
| | | public List<SimCostView> SearchSimCostByPage(string sim ,int year) |
| | | { |
| | | ResultDataEntity<SimCostView> data = new ResultDataEntity<SimCostView>(); |
| | | List<SimCostView> data = new List<SimCostView>(); |
| | | try |
| | | { |
| | | //var codedata = (from e in _context.SysCodes |
| | |
| | | // && e.CodeField == "cardpro" |
| | | // select c).OrderBy(x => x.Sort).ToList(); |
| | | |
| | | var dt = _context.SimCostView.OrderByDescending(c => c.accounted_time).ToList(); |
| | | if (!string.IsNullOrEmpty(searchEntity.searchtime)) |
| | | { |
| | | var times = searchEntity.searchtime.Split('|'); |
| | | if(times.Length==2) |
| | | { |
| | | DateTime d1 = DateTime.Parse(times[0]); |
| | | DateTime d2 = DateTime.Parse(times[1]); |
| | | dt = dt.Where(c => c.accounted_time > d1 && c.accounted_time < d2).ToList(); |
| | | } |
| | | } |
| | | if (!string.IsNullOrEmpty(searchEntity.searchsim)) |
| | | { |
| | | dt = dt.Where(c => !string.IsNullOrEmpty(c.simcard) && c.simcard.Contains(searchEntity.searchsim)).ToList(); |
| | | } |
| | | data = _context.SimCostView.Where(c => c.bill_year==year && c.sim_id==sim).OrderBy(c=>c.bill_month).ToList(); |
| | | //if (!string.IsNullOrEmpty(searchEntity.searchtime)) |
| | | //{ |
| | | // var times = searchEntity.searchtime.Split('|'); |
| | | // if(times.Length==2) |
| | | // { |
| | | // DateTime d1 = DateTime.Parse(times[0]); |
| | | // DateTime d2 = DateTime.Parse(times[1]); |
| | | // dt = dt.Where(c => c.accounted_time > d1 && c.accounted_time < d2).ToList(); |
| | | // } |
| | | //} |
| | | //if (!string.IsNullOrEmpty(searchEntity.searchsim)) |
| | | //{ |
| | | // dt = dt.Where(c => !string.IsNullOrEmpty(c.simcard) && c.simcard.Contains(searchEntity.searchsim)).ToList(); |
| | | //} |
| | | //SimCostDTOSearch searchEntity = new SimCostDTOSearch(); |
| | | //searchEntity.rows = 20; |
| | | //searchEntity.page = 1; |
| | | |
| | | if (searchEntity.totalrows == 0) |
| | | searchEntity.totalrows = dt.Count(); |
| | | //if (searchEntity.totalrows == 0) |
| | | // searchEntity.totalrows = dt.Count(); |
| | | |
| | | var signinList = dt.Skip((searchEntity.page - 1) * searchEntity.rows).Take(searchEntity.rows).ToList(); |
| | | //var signinList = dt.Skip((searchEntity.page - 1) * searchEntity.rows).Take(searchEntity.rows).ToList(); |
| | | |
| | | //signinList = signinList.Select(a => new SimBindView() |
| | | //{ |
| | |
| | | // username = a.username |
| | | //}).ToList(); |
| | | |
| | | data.LoadData(searchEntity, signinList); |
| | | //data.LoadData(searchEntity, signinList); |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | |
| | | return data; |
| | | } |
| | | |
| | | |
| | | /// <summary> |
| | | /// 查询费用记录 |
| | | /// </summary> |
| | | /// <param name="userid"></param> |
| | | /// <param name="bill_year"></param> |
| | | /// <param name="bill_month"></param> |
| | | /// <returns></returns> |
| | | public SimCostView GetSimCost(string userid, int bill_year, int bill_month) |
| | | { |
| | | |
| | |
| | | return entity; |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 查询内容 |
| | | /// </summary> |
| | | /// <param name="searchEntity"></param> |
| | | /// <returns></returns> |
| | | public ResultDataEntity<SimCostYearView> SearchSimCostYearByPage(SimCostDTOSearch searchEntity) |
| | | { |
| | | ResultDataEntity<SimCostYearView> data = new ResultDataEntity<SimCostYearView>(); |
| | | try |
| | | { |
| | | int year=DateTime.Now.Year; |
| | | if (!string.IsNullOrEmpty(searchEntity.searchtime)) |
| | | { |
| | | year = int.Parse(searchEntity.searchtime); |
| | | } |
| | | |
| | | var dt = (from c in _context.SimCostYearView where c.bill_year==year orderby c.sim select c).ToList(); |
| | | |
| | | if (!string.IsNullOrEmpty(searchEntity.searchsim)) |
| | | { |
| | | dt = dt.Where(c => c.sim==searchEntity.searchsim).ToList(); |
| | | } |
| | | |
| | | if (searchEntity.totalrows == 0) |
| | | searchEntity.totalrows = dt.Count(); |
| | | |
| | | var signinList = dt.Skip((searchEntity.page - 1) * searchEntity.rows).Take(searchEntity.rows).ToList(); |
| | | if(signinList.Count>0) |
| | | { |
| | | var month = DateTime.Now.Month-1; |
| | | var ck = (from c in _context.SimCost where c.status == "1" && c.bill_year == year orderby c.bill_month descending select c).FirstOrDefault(); |
| | | if(ck!=null) |
| | | { |
| | | month= ck.bill_month; |
| | | } |
| | | foreach (var item in signinList) |
| | | { |
| | | item.month = month; |
| | | } |
| | | } |
| | | |
| | | data.LoadData(searchEntity, signinList); |
| | | } |
| | | catch (Exception ex) |
| | | { |
| | | throw; |
| | | } |
| | | return data; |
| | | } |
| | | |
| | | #endregion |
| | | } |
| | | } |