/// <summary> /// 获取产品列表 /// </summary> public void GetGoodsList() { int cid = GetInt("cid"); //int order = GetInt("order"); int start = GetInt("start"); int limit = GetInt("limit"); int type = GetInt("type"); string wheresql = string.Empty; string shoppingcartql = ""; if (cid > 0) { wheresql += string.Format(" and Cid={0}", cid); } if (type > 0) { switch (type) { case 1: wheresql += " and IsHot>0 "; break; case 2: wheresql += " and IsRecommend>0 "; break; default: break; } } //switch (order) //{ // case 1: // shoppingcartql += " order by Sales asc "; break; // case -1: // shoppingcartql += " order by Sales desc "; break; // case 2: // shoppingcartql += " order by CreateTime asc "; break; // case -2: // shoppingcartql += " order by CreateTime desc "; break; // case 3: // shoppingcartql += " order by Nowprice asc "; break; // case -3: // shoppingcartql += " order by Nowprice desc "; break; // default: break; //} var goodsresult = GoodsHelper.GetGoodsList(CurSellerId, wheresql, shoppingcartql, start * limit, limit, 1); var jt = new JsonTransfer(); jt.Add("list", goodsresult.Results); jt.Add("totalcount", goodsresult.TotalCount); Response.Write(jt.ToJson()); Response.End(); }
/// <summary> /// 删除产品列表 /// </summary> public void DelGoodsList() { var gids = GetString("gids"); var gidList = Utility.GetListint(gids); if (gidList.Count == 0) { ReturnErrorMsg("参数有误"); return; } var wheresql = string.Format(" and a.Id in({0})", gids); var goodsresult = GoodsHelper.GetGoodsList(CurSellerId, wheresql); if (goodsresult.Results.Count != gidList.Count) { ReturnErrorMsg("没有权限删除其他商户产品或产品不存在"); return; } var data = new List <ChangeCountItem>(); foreach (var goods in goodsresult.Results) { var item = data.FirstOrDefault(o => o.Id == goods.Cid); if (item == null) { data.Add(new ChangeCountItem() { Id = goods.Cid, Change = -1 }); } else { item.Change--; } } bool ur = true; if (data.Count > 0) { ur = GoodsCategoriesHelper.UpdateGoodsCategoriesCount(data); } if (ur && GoodsHelper.DelGoodsList(CurSellerId, gids)) { ReturnCorrectMsg("删除成功"); } else { ReturnErrorMsg("删除失败"); } }
private void GetGoods() { var sellerid = GetInt("sellerid"); var start = GetInt("start"); var limit = GetInt("limit"); var goods = GoodsHelper.GetGoodsList(sellerid, "", "", start * limit, limit); var data = new PagResults <object>(); data.TotalCount = goods.TotalCount; foreach (var item in goods.Results) { var o = new { id = item.Id, title = item.Title }; data.Results.Add(o); } JsonTransfer jt = new JsonTransfer(); jt.Add("data", data); Response.Write(DesEncrypt(jt).ToLower()); Response.End(); }
/// <summary> /// 获取充值统计 /// </summary> private void GetConsumeStat() { var sellerId = CurSellerId; var type = (StatisticsType)GetInt("type"); //统计类型 var start = GetInt("start"); //传0 var limit = GetInt("limit"); //传10 只取前十名 var data = new ConsumeStatResponse(); data.Stat = new ConsumeStatisticsHelper.ReqConsumeStatistics(type); switch (type) { case StatisticsType.Day: data.Stat = ConsumeStatisticsHelper.GetConsumeDateStatisticsList(sellerId, DateTime.Now); break; case StatisticsType.Month: data.Stat = ConsumeStatisticsHelper.GetConsumeMonthStatisticsList(sellerId, DateTime.Now.Year, DateTime.Now.Month); break; case StatisticsType.Quarter: data.Stat = ConsumeStatisticsHelper.GetConsumeQuarterStatisticsList(sellerId, DateTime.Now.Year); break; case StatisticsType.Year: data.Stat = ConsumeStatisticsHelper.GetConsumeYearStatisticsList(sellerId, DateTime.Now.Year); break; } var startTime = DateTime.Now; var endTime = DateTime.Now; switch (type) { case StatisticsType.Day: startTime = DateTime.Now.Date; endTime = startTime.AddDays(1).AddMilliseconds(-1); break; case StatisticsType.Month: startTime = new DateTime(startTime.Year, startTime.Month, 1).Date; endTime = startTime.AddMonths(1).AddMilliseconds(-1); break; case StatisticsType.Quarter: case StatisticsType.Year: startTime = new DateTime(startTime.Year, 1, 1).Date; endTime = startTime.AddYears(1).AddMilliseconds(-1); break; } var glist = new List <ConsumeGoodsItem>(); var list = ChargeLogHelper.GetChargeLogList(CurSellerId, startTime, endTime, start * limit, limit); var index = 0; foreach (var chargeLog in list) { index = 0; foreach (var i in chargeLog.GidList) { var item = glist.FirstOrDefault(o => o.Gid == i); if (item == null) { item = new ConsumeGoodsItem(); item.Gid = i; item.Num = chargeLog.NumList[index]; glist.Add(item); } else { item.Num += chargeLog.NumList[index]; } index++; } } var goodslist = GoodsHelper.GetGoodsList(glist.Select(o => o.Gid).ToList()); foreach (var goodse in goodslist) { var ritem = new ReqConsumeStatItem(); ritem.GoodsName = goodse.Title; ritem.GoodsCategoriesName = goodse.Cname; var gitem = glist.FirstOrDefault(o => o.Gid == goodse.Id); if (gitem != null) { ritem.Num = gitem.Num; ritem.Pre = (ritem.Num * 1.0 / data.Stat.TotalGoodsNum * 100).ToString("F2"); } data.List.Add(ritem); } data.List = data.List.OrderBy(o => o.Num).ToList();//排序 var jt = new JsonTransfer(); jt.Add("data", data); Response.Write(jt.ToJson()); Response.End(); }