using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.Services; using NetLibrary.ReportPrint; using System.Data; using NetLibrary; using NetLibrary.Data; using TradeModel; using TradeData; namespace TradeManageNew.CangKu { /// /// CK_Service 的摘要说明 /// [WebService(Namespace = "http://tempuri.org/")] [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)] [System.ComponentModel.ToolboxItem(false)] // 若要允许使用 ASP.NET AJAX 从脚本中调用此 Web 服务,请取消对下行的注释。 [System.Web.Script.Services.ScriptService] public class CK_Service : System.Web.Services.WebService { [WebMethod] public string HelloWorld() { return "Hello World"; } #region [WebMethod(EnableSession = true)] public List GetListUSMap(string statename, int StoreId, int IsEast) { PagesNew.Login(this.Session); var list= DataNew.GetListUSMap( statename,StoreId, IsEast); return list; } #endregion #region 海外仓状态 [WebMethod(EnableSession = true)] public int Save_USMap(DT_USMapNew model) { PagesNew.Login(this.Session); DataNew.Save_USMap(model); return 0; } #endregion #region [WebMethod(EnableSession = true)] public string Get_StoreNum(string SKU) { PagesNew.Login(this.Session); var slist=DataNew.GetStoreList(); string shtml = "
"; shtml +=""; shtml +=""; shtml += ""; foreach (var smd in slist) { shtml += ""; shtml += ""; } shtml += ""; var hlist = new List(); var hlist2 = new List(); foreach (var smd in slist) { var klist = DataNew.GetKCNumList(smd.StoreId.Value, SKU); if (klist != null) { foreach (var kmd in klist) { var kkmd = new HW_GoodsKCNum(); kkmd.DetailId = kmd.DetailId; kkmd.FirstImgUrl = kmd.FirstImgUrl; kkmd.SKU = kmd.SKU1; kkmd.Num = kmd.GoodsNum; kkmd.Soild = kmd.Solid; kkmd.TotalSoild = kmd.TotalSolid; kkmd.StoreId =smd.StoreId; hlist.Add(kkmd); if (hlist2 != null) { var hmd=hlist2.Find(n => n.DetailId == kmd.DetailId); if (hmd == null) { hlist2.Add(kkmd); } } else hlist2.Add(kkmd); } } } if (hlist2 != null) { foreach (var hmd in hlist2) { shtml += ""; shtml += ""; shtml += ""; if(hmd.Soild!=null) shtml += ""; else shtml += ""; foreach (var smd in slist) { var kmd = hlist.Find(n => n.StoreId == smd.StoreId && n.DetailId == hmd.DetailId); if(kmd!=null) shtml += ""; else shtml += ""; } shtml += ""; } } shtml += "
缩略图货物单个体积"+smd.StoreName+"立方
"+hmd.SKU+""+hmd.Soild+"" + kmd.Num + "" + kmd.TotalSoild + "
"; return shtml; } #endregion #region [WebMethod(EnableSession = true)] public string Get_StoreNumExcel(string SKU) { PagesNew.Login(this.Session); var slist = DataNew.GetStoreList(); var hlist = new List(); int i = 1; foreach (var smd in slist) { var klist = DataNew.GetKCNumList(smd.StoreId.Value, SKU); if (klist != null) { foreach (var kmd in klist) { var kkmd = new HW_GoodsKCNum(); kkmd.DetailId = kmd.DetailId; kkmd.FirstImgUrl = kmd.FirstImgUrl; kkmd.SKU = kmd.SKU1; kkmd.Soild = kmd.Solid; if (i == 1) { kkmd.Num = kmd.GoodsNum; kkmd.TotalSoild = kmd.TotalSolid; } if (i == 2) { kkmd.Num2 = kmd.GoodsNum; kkmd.TotalSoild2 = kmd.TotalSolid; } if (i == 3) { kkmd.Num3 = kmd.GoodsNum; kkmd.TotalSoild3 = kmd.TotalSolid; } if (i ==4) { kkmd.Num4 = kmd.GoodsNum; kkmd.TotalSoild4 = kmd.TotalSolid; } if (i == 5) { kkmd.Num5 = kmd.GoodsNum; kkmd.TotalSoild5 = kmd.TotalSolid; } if (i ==6) { kkmd.Num6 = kmd.GoodsNum; kkmd.TotalSoild6 = kmd.TotalSolid; } kkmd.StoreId = smd.StoreId; if (hlist != null) { var hmd = hlist.Find(n => n.DetailId == kmd.DetailId); if (hmd == null) { hlist.Add(kkmd); } else { if (i == 1) { hmd.Num = kmd.GoodsNum; hmd.TotalSoild = kmd.TotalSolid; } if (i == 2) { hmd.Num2 = kmd.GoodsNum; hmd.TotalSoild2 = kmd.TotalSolid; } if (i == 3) { hmd.Num3 = kmd.GoodsNum; hmd.TotalSoild3 = kmd.TotalSolid; } if (i == 4) { hmd.Num4 = kmd.GoodsNum; hmd.TotalSoild4 = kmd.TotalSolid; } if (i == 5) { hmd.Num5 = kmd.GoodsNum; hmd.TotalSoild5 = kmd.TotalSolid; } if (i == 6) { hmd.Num6 = kmd.GoodsNum; hmd.TotalSoild6 = kmd.TotalSolid; } } } else hlist.Add(kkmd); } } i++; } TableColumnCollection listColumns = new TableColumnCollection(); listColumns.Add("SKU", "SKU", DbType.String, ""); listColumns.Add("Soild", "当个体积", DbType.String, ""); i = 1; foreach (var smd in slist) { if (i == 1) { listColumns.Add("Num", smd.StoreName, DbType.String, ""); listColumns.Add("TotalSoild", "立方", DbType.String, ""); } if (i == 2) { listColumns.Add("Num2", smd.StoreName, DbType.String, ""); listColumns.Add("TotalSoild2", "立方", DbType.String, ""); } if (i == 3) { listColumns.Add("Num3", smd.StoreName, DbType.String, ""); listColumns.Add("TotalSoild3", "立方", DbType.String, ""); } if (i ==4) { listColumns.Add("Num4", smd.StoreName, DbType.String, ""); listColumns.Add("TotalSoild4", "立方", DbType.String, ""); } if (i == 5) { listColumns.Add("Num5", smd.StoreName, DbType.String, ""); listColumns.Add("TotalSoild5", "立方", DbType.String, ""); } if (i == 6) { listColumns.Add("Num6", smd.StoreName, DbType.String, ""); listColumns.Add("TotalSoild6", "立方", DbType.String, ""); } i++; } MicrosoftExcel obj2 = new MicrosoftExcel(); return obj2.Export(hlist, listColumns); } #endregion #region [WebMethod(EnableSession = true)] public int UpdateFedexSpare() { PagesNew.Login(this.Session); DataNew.UpdateFedexSpare(); return 0; } #endregion #region [WebMethod(EnableSession = true)] public List GetPostFee(DateTime? SDate, DateTime? EDate) { PagesNew.Login(this.Session); var list = DataNew.GetPostFee(SDate, EDate); if (list != null) { decimal hjfee6 = 0; decimal hjfee66 = 0; decimal hjfee3 = 0; foreach (var md in list) { decimal ygyf = 0; decimal ygyf2 = 0; if (md.RevFax == "Residential" || md.RevFax == "RESIDENTIAL") { if (md.Fee6 != null && md.Fee8 != null && md.Fee6 > 0 && md.Fee6 < md.Fee8) { ygyf = md.Fee6.Value; } else if (md.Fee6 != null && md.Fee8 != null && md.Fee8 > 0 && md.Fee6 > md.Fee8) { ygyf = md.Fee8.Value; } if (md.Fee66 != null && md.Fee88 != null && md.Fee66 > 0 && md.Fee66 < md.Fee88) { ygyf2 = md.Fee66.Value; } else if (md.Fee66 != null && md.Fee88 != null && md.Fee88 > 0 && md.Fee66 > md.Fee88) { ygyf2 = md.Fee88.Value; } } if (md.RevFax == "Commercial" || md.RevFax == "OFFICE") { if (md.Fee6 != null && md.Fee7 != null && md.Fee6 > 0 && md.Fee6 < md.Fee7) { ygyf = md.Fee6.Value; } else if (md.Fee6 != null && md.Fee7 != null && md.Fee7 > 0 && md.Fee6 > md.Fee7) { ygyf = md.Fee7.Value; } if (md.Fee66 != null && md.Fee77 != null && md.Fee66 > 0 && md.Fee66 < md.Fee77) { ygyf2 = md.Fee66.Value; } else if (md.Fee66 != null && md.Fee77 != null && md.Fee77 > 0 && md.Fee66 > md.Fee77) { ygyf2 = md.Fee77.Value; } } if (ygyf == 0) { if(md.Fee6!=null) ygyf = md.Fee6.Value; if (md.Fee7 != null && md.Fee7.Value < ygyf) ygyf = md.Fee7.Value; if (md.Fee8 != null && md.Fee8.Value < ygyf) ygyf = md.Fee8.Value; } if (ygyf2 == 0) { if (md.Fee66 != null) ygyf2 = md.Fee66.Value; if (md.Fee77 != null && md.Fee77.Value < ygyf) ygyf2 = md.Fee77.Value; if (md.Fee88 != null && md.Fee88.Value < ygyf) ygyf2 = md.Fee88.Value; } md.Fee2 = ygyf2; md.Fee1 = ygyf; if (ygyf2 > 0 && ygyf > 0) md.Fee3 = ygyf2 - ygyf; hjfee6 += ygyf2; hjfee66 += ygyf; if(md.Fee3!=null) hjfee3 += md.Fee3.Value; } var nmd = new DT_FedexCount(); nmd.PostName = "合计:"; nmd.Fee1 = hjfee6; // nmd.Fee7 = hjfee7; // nmd.Fee8 = hjfee8; nmd.Fee2 = hjfee66; nmd.Fee3 = hjfee3; // nmd.Fee77 = hjfee77; // nmd.Fee88 = hjfee88; list.Add(nmd); } return list; } #endregion #region 查询我的店铺 [WebMethod(EnableSession = true)] public List GetMyShop() { PagesNew.Login(this.Session); var obj = new CK_HouseData(); string Name = Convert.ToString(Session["Name"]); int UserId = Convert.ToInt32(Session["UserId"]); var list = DataNew.GetMyShop(Name, UserId); return list; } #endregion #region 查询我的店铺 [WebMethod(EnableSession = true)] public List GetMyShop2() { PagesNew.Login(this.Session); var obj = new CK_HouseData(); var list = DataNew.GetMyShop("", 1); return list; } #endregion #region 查询我的店铺 [WebMethod(EnableSession = true)] public List GetMyShop3() { PagesNew.Login(this.Session); var obj = new CK_HouseData(); var list = DataNew.GetMateShop(); return list; } #endregion #region 查询开启仓库 [WebMethod(EnableSession = true)] public List GetUseStoreHouse() { PagesNew.Login(this.Session); var obj = new CK_HouseData(); int CompanyId = Convert.ToInt32(Session["CompanyId"]); var list = obj.GetUseStoreHouse(CompanyId); return list; } #endregion #region CK_DayData页 #region 保存 [WebMethod(EnableSession = true)] public int Save_DayData(CK_DayData Model) { PagesNew.Login(this.Session); Model.InDate = DateTime.Now; Model.InName = Session["Name"].ToString(); return DataNew.Save_DayData(Model); } #endregion #region 删除 [WebMethod(EnableSession = true)] public bool Delete_DayData(int Id) { PagesNew.Login(this.Session); DataNew.Delete_DayData(Id); return true; } #endregion #region 返回Model [WebMethod(EnableSession = true)] public CK_DayData GetModel_DayData(int Id) { PagesNew.Login(this.Session); var Model=DataNew.GetModel_DayData(Id); return Model; } #endregion #region 分页查询 [WebMethod(EnableSession = true)] public JsonModel> GetListDayData(string InName,DateTime? StartDate,DateTime? StopDate,int PageIndex, int PageSize) { PagesNew.Login(this.Session); RefParameterCollection where = new RefParameterCollection(); if (string.IsNullOrEmpty(InName) == false) where.Add(new RefParameter("a.InName", "like", InName,DbType.String)); if (StartDate != null) where.Add(new RefParameter("InDate", ">=", StartDate, System.Data.DbType.DateTime)); if (StopDate != null) where.Add(new RefParameter("convert(varchar(10), InDate, 120)", "<=", StopDate, System.Data.DbType.DateTime)); JsonModel> resultModel = new JsonModel>(); int RowCount = 0; resultModel.DataSource=DataNew.GetListDayData(where,PageIndex,PageSize, "", out RowCount); resultModel.RowCount = RowCount; return resultModel; } #endregion #region 分页查询 [WebMethod(EnableSession = true)] public JsonModel> GetListDayData(string cs,int PageIndex, int PageSize) { PagesNew.Login(this.Session); string where = CustomIO.Base64StringToString(cs); int UserId = Convert.ToInt32(Session["UserId"]); if (UserId > 1) where += " and InName='" + Session["Name"].ToString()+"' "; if (where!="")where = "where " + where.Substring(4); var resultModel = new JsonModel>(); int RowCount = 0; resultModel.DataSource=DataNew.GetListDayData(where,PageIndex,PageSize, "", out RowCount); resultModel.RowCount = RowCount; return resultModel; } #endregion #endregion #region 分页查询 [WebMethod(EnableSession = true)] public JsonModel> GetListUserBuyNum(string cs,int IsMX,int PageIndex, int PageSize) { PagesNew.Login(this.Session); string where = CustomIO.Base64StringToString(cs); if (where!="")where = "where " + where.Substring(4); int UserId = Convert.ToInt32(Session["UserId"]); if (UserId > 1) where += " and a.UserId='" + UserId + "' "; var resultModel = new JsonModel>(); int RowCount = 0; resultModel.DataSource=DataNew.GetListUserBuyNum2(where,PageIndex,PageSize, "", out RowCount); resultModel.RowCount = RowCount; if (IsMX == 1) { if (resultModel.DataSource != null) { string ids = ""; foreach (var md in resultModel.DataSource) { ids += md.Id + ","; } var GList = DataNew.GetListUserBuyDetail(ids.TrimEnd(',')); if (GList != null) { foreach (var md in resultModel.DataSource) { var smd = GList.FindAll(n => n.MastId == md.Id); md.GoodsDetail = smd; } } } } return resultModel; } #endregion #region 分页查询 [WebMethod(EnableSession = true)] public JsonModel> GetGoodsUserApply(int StoreId,string StoreName, int Type, string GoodsName, int PageIndex, int PageSize) { PagesNew.Login(this.Session); int CompanyId = Convert.ToInt32(Session["CompanyId"]); RefParameterCollection where = new RefParameterCollection(); where.Add(new RefParameter("c.CompanyId", "=", CompanyId, System.Data.DbType.Int32)); if (GoodsName != "") { if(Type==1) where.Add(new RefParameter("c.GoodsCode", "like", GoodsName, System.Data.DbType.String)); } JsonModel> resultModel = new JsonModel>(); int RowCount = 0; resultModel.DataSource = DataNew.GetListUserBuyNum(StoreId, StoreName,where, PageIndex, PageSize, "c.GoodsCode", out RowCount); resultModel.RowCount = RowCount; return resultModel; } #endregion #region 分页查询 [WebMethod(EnableSession = true)] public string GetGoodsUserApplyExcel(int StoreId, string StoreName, int Type, string GoodsName, int PageIndex, int PageSize) { PagesNew.Login(this.Session); var obj = new CK_HouseData(); string Name = Convert.ToString(Session["Name"]); int UserId = Convert.ToInt32(Session["UserId"]); var list = DataNew.GetMyShop(Name, UserId); if (list == null) return "0"; int CompanyId = Convert.ToInt32(Session["CompanyId"]); RefParameterCollection where = new RefParameterCollection(); where.Add(new RefParameter("c.CompanyId", "=", CompanyId, System.Data.DbType.Int32)); if (GoodsName != "") { if (Type == 1) where.Add(new RefParameter("c.GoodsCode", "like", GoodsName, System.Data.DbType.String)); } JsonModel> resultModel = new JsonModel>(); int RowCount = 0; resultModel.DataSource = DataNew.GetListUserBuyNum(StoreId, StoreName, where, PageIndex, PageSize, "c.GoodsCode", out RowCount); TableColumnCollection listColumns = new TableColumnCollection(); listColumns.Add("DetailId", "货物id", DbType.String, ""); listColumns.Add("GoodsName", "货物名称", DbType.String, ""); listColumns.Add("GoodsCode", "编号", DbType.String, ""); listColumns.Add("SKU", "编号sku", DbType.String, ""); listColumns.Add("KCNum", "当前库存", DbType.String, ""); listColumns.Add("LeftNum", "当前剩余", DbType.String, ""); int i = 0; foreach(var smd in list) { i++; if(i<11) listColumns.Add("Num"+i.ToString(), smd.ShopName+"认购数", DbType.String, ""); } MicrosoftExcel obj2 = new MicrosoftExcel(); return obj2.Export(resultModel.DataSource, listColumns); } #endregion #region 分页查询 [WebMethod(EnableSession = true)] public JsonModel> GetMyGoodsUserList(int ShopId, int Num, string GoodsName,int PX, int PageIndex, int PageSize) { PagesNew.Login(this.Session); int UserId = Convert.ToInt32(Session["UserId"]); string Name = Convert.ToString(Session["Name"]); RefParameterCollection where = new RefParameterCollection(); if (ShopId > 0) where.Add(new RefParameter("a.ShopId", "=", ShopId, System.Data.DbType.Int32)); else if(UserId>1) { var slist = DataNew.GetMyShop(Name, UserId); string shipids = "0,"; if (slist != null) { foreach(var smd in slist) { shipids += smd.ShopId + ","; } } where.Add(new RefParameter("a.ShopId", "in", shipids.TrimEnd(','), System.Data.DbType.String)); } if (GoodsName != "") { where.Add(new RefParameter("d.GoodsCode", "like", GoodsName, System.Data.DbType.String)); } if(Num>0) where.Add(new RefParameter("a.NowNum", ">", 0, System.Data.DbType.Int32)); JsonModel> resultModel = new JsonModel>(); int RowCount = 0; string orderby = "d.GoodsCode"; if(PX==1) orderby = "a.NowNum"; if (PX == 2) orderby = "a.NowNum desc"; resultModel.DataSource = DataNew.GetListMyUserBuyNum22(where, PageIndex, PageSize, orderby, out RowCount); resultModel.RowCount = RowCount; return resultModel; } #endregion #region 分页查询 [WebMethod(EnableSession = true)] public JsonModel> GetGoodsUserList(int ShopId, int StoreId,string StoreName,int Num, string GoodsName, int PageIndex, int PageSize) { PagesNew.Login(this.Session); int UserId = Convert.ToInt32(Session["UserId"]); RefParameterCollection where = new RefParameterCollection(); if (ShopId > 0) where.Add(new RefParameter("a.ShopId", "=", ShopId, System.Data.DbType.Int32)); if (GoodsName != "") { where.Add(new RefParameter("c.GoodsCode", "like", GoodsName, System.Data.DbType.String)); } if (Num > 0) where.Add(new RefParameter("a.KCNum-isnull(d.NowNum,0)", ">", 0, System.Data.DbType.Int32)); JsonModel> resultModel = new JsonModel>(); int RowCount = 0; resultModel.DataSource = DataNew.GetListUserBuyNum(StoreId,StoreName, where, PageIndex, PageSize, "c.GoodsCode", out RowCount); resultModel.RowCount = RowCount; return resultModel; } #endregion #region 保存 [WebMethod(EnableSession = true)] public string Save_UserBuyNum(HW_UserBuyNum model,List List) { PagesNew.Login(this.Session); int UserId = Convert.ToInt32(Session["UserId"]); string error = ""; model.InDate = DateTime.Now; model.UserId = UserId; int MasterId = DataNew.Save_UserBuyNum(model); foreach (var Model in List) { Model.Id = 0; Model.MastId = MasterId; Model.CheckNum = Model.BuyNum; Model.MateNum = 0; Model.InNum = Model.BuyNum; if (model.Type == 2) Model.InNum = 0; int a = DataNew.Save_UserBuyDetail(model.Type.Value,Model); if (a == -1) error +=Model.ShopName+""+ Model.SKU+"认购数量超过当前剩余数量;"; } if (error == "") { return "提交成功"; } return error+",其他数据提交成功"; } #endregion #region 保存 [WebMethod(EnableSession = true)] public string Save_UserBuyNumList(HW_UserBuyNum model, List List) { PagesNew.Login(this.Session); int UserId = Convert.ToInt32(Session["UserId"]); string error = ""; model.InDate = DateTime.Now; model.UserId = UserId; int MasterId = DataNew.Save_UserBuyNum(model); foreach (var Model in List) { Model.Id = 0; Model.MastId = MasterId; Model.CheckNum = Model.BuyNum; Model.InDate = DateTime.Now; Model.MateNum = 0; Model.InNum = Model.BuyNum; if (model.Type == 2) Model.InNum = 0; int a = DataNew.Save_UserBuyDetail(model.Type.Value, Model); if (a!=-100000) error += Model.SKU+"剩余只有"+a+"个了"+""+Model.ShopName + "店铺认购数量超过当前剩余数量;"; } if (error == "") { return "提交成功"; } else { DataNew.Delete_UserBuyNum(MasterId);//删除之前数据 } return error +"请修改数量后再提交"; } #endregion #region 导入认购 [WebMethod(EnableSession = true)] public List ExcelBuyGoods(string FileName, int StoreId) { PagesNew.Login(this.Session); if (string.IsNullOrEmpty(FileName) == true) return null; string ServerFileName = AppDomain.CurrentDomain.BaseDirectory + FileName; if (System.IO.File.Exists(ServerFileName) == false) return null; int CompanyId = Convert.ToInt32(Session["CompanyId"]); string Name = Convert.ToString(Session["Name"]); List list = new List(); try { MicrosoftExcel excel = new MicrosoftExcel(); DataTable tb = excel.ImportExcel(ServerFileName); string error = ""; if (tb.Columns.Contains("货物id") == false) { error = error + "导入文件没有货物id 列"; } // if (tb.Columns.Contains("重量") == false) { error = error + "导入文件没有 重量 列"; } // if (tb.Columns.Contains("运费") == false) { error = error + "导入文件没有 运费 列"; } if (string.IsNullOrEmpty(error) == false) return null; int UserId = Convert.ToInt32(Session["UserId"]); int Count = 0; var slist = DataNew.GetMyShop(Name, UserId); string ids = ""; for (int i = 0; i < tb.Rows.Count; i++) { var md = new HW_UserBuyDetail(); md.DetailId = Convert.ToInt32(tb.Rows[i]["货物id"].ToString().Trim()); md.GoodsName = tb.Rows[i]["货物名称"].ToString().Trim(); md.SKU = tb.Rows[i]["编号sku"].ToString().Trim(); md.KCNum = Convert.ToInt32(tb.Rows[i]["当前库存"].ToString().Trim()); md.LeftNum = Convert.ToInt32(tb.Rows[i]["当前剩余"].ToString().Trim()); int j = 0; int IsNum = 0; foreach (var smd in slist) { string sname = smd.ShopName + "认购数"; j++; if (j > 10) continue; if (tb.Rows[i][sname].ToString().Trim() != "") { IsNum = 1; if (j == 1) md.Num1 = Convert.ToInt32(tb.Rows[i][sname].ToString().Trim()); if (j == 2) md.Num2 = Convert.ToInt32(tb.Rows[i][sname].ToString().Trim()); if (j == 3) md.Num3 = Convert.ToInt32(tb.Rows[i][sname].ToString().Trim()); if (j == 4) md.Num4 = Convert.ToInt32(tb.Rows[i][sname].ToString().Trim()); if (j == 5) md.Num5 = Convert.ToInt32(tb.Rows[i][sname].ToString().Trim()); if (j == 6) md.Num6 = Convert.ToInt32(tb.Rows[i][sname].ToString().Trim()); if (j == 7) md.Num7 = Convert.ToInt32(tb.Rows[i][sname].ToString().Trim()); if (j == 8) md.Num8 = Convert.ToInt32(tb.Rows[i][sname].ToString().Trim()); if (j == 9) md.Num9 = Convert.ToInt32(tb.Rows[i][sname].ToString().Trim()); if (j == 10) md.Num10 = Convert.ToInt32(tb.Rows[i][sname].ToString().Trim()); } } if (IsNum == 1) { ids += md.DetailId.ToString() + ","; list.Add(md); } } if(ids!="") { var imglist=DataNew.GetListGoodsImg(ids.TrimEnd(',')); if (imglist != null) { foreach (var md in list) { var imd = imglist.Find(n => n.DetailId == md.DetailId); if (imd != null) md.FirstImgUrl = imd.FirstImgUrl; } } } return list; } catch (Exception e) { return null; } return null; } #endregion #region 删除 [WebMethod(EnableSession = true)] public int Delete_UserBuyNum(int Id) { PagesNew.Login(this.Session); if (DataNew.CheckName_UserBuyNum(Id) == true) DataNew.Delete_UserBuyNum(Id); else { return 0; } return 1; } #endregion #region 调整店铺库存 [WebMethod(EnableSession = true)] public int Update_UserBuyShop(int DetailId,int StoreId, int ShopId, int ShopId2,int Num) { PagesNew.Login(this.Session); var klist = DataNew.GetShopGoodsNumNoMate2(StoreId, ShopId, DetailId); int UserId = Convert.ToInt32(Session["UserId"]); if (klist != null) { int LeftNum = Num; foreach (var mmd in klist) { if (LeftNum <= 0) break; if (mmd.InNum - mmd.MateNum >= LeftNum) { mmd.AddNum = LeftNum; LeftNum = 0; } else { mmd.AddNum = mmd.InNum - mmd.MateNum; LeftNum = LeftNum - mmd.AddNum.Value; } } if (LeftNum > 0) return 0; foreach (var md in klist) { if (md.AddNum > 0) { DataNew.UpdateUserBuyNumMate2(md.Id.Value, md.AddNum.Value, ShopId, ShopId2); } } } return 1; } #endregion #region 分页查询 [WebMethod(EnableSession = true)] public JsonModel> GetAllShopGoods(int ShopId, int StoreId, int Num, string GoodsName, int PageIndex, int PageSize) { PagesNew.Login(this.Session); int UserId = Convert.ToInt32(Session["UserId"]); RefParameterCollection where = new RefParameterCollection(); if (ShopId > 0) where.Add(new RefParameter("a.ShopId", "=", ShopId, System.Data.DbType.Int32)); if (GoodsName != "") { where.Add(new RefParameter("d.GoodsCode", "=", GoodsName, System.Data.DbType.String)); } if (Num > 0) where.Add(new RefParameter("a.NowNum", ">", 0, System.Data.DbType.Int32)); JsonModel> resultModel = new JsonModel>(); int RowCount = 0; resultModel.DataSource = DataNew.GetListUserBuyAll(StoreId, where, PageIndex, PageSize, "d.GoodsCode", out RowCount); resultModel.RowCount = RowCount; return resultModel; } #endregion #region 分页查询 [WebMethod(EnableSession = true)] public HW_UserBuyDetail GetAllShopGoodsSum(int ShopId, int StoreId, int Num, string GoodsName) { PagesNew.Login(this.Session); var md = DataNew.GetUserBuyAllSum(StoreId, ShopId, GoodsName, Num); return md; } #endregion #region 分页查询 [WebMethod(EnableSession = true)] public HW_UserBuyDetail GetAllShopGoodsSum2(int StoreId) { PagesNew.Login(this.Session); var md = DataNew.GetUserBuyAllSum2(StoreId); return md; } #endregion #region 分页查询 [WebMethod(EnableSession = true)] public JsonModel> GetAllShopGoods2(int StoreId, int State, string GoodsName, int PageIndex, int PageSize) { PagesNew.Login(this.Session); int UserId = Convert.ToInt32(Session["UserId"]); RefParameterCollection where = new RefParameterCollection(); if (GoodsName != "") { where.Add(new RefParameter("d.GoodsCode", "like", GoodsName, System.Data.DbType.String)); } if (State==1) where.Add(new RefParameter("isnull(a.KCNum,0)-isnull(b.NowNum,0)", "=", 0, System.Data.DbType.Int32)); if (State == 2) where.Add(new RefParameter("isnull(a.KCNum,0)-isnull(b.NowNum,0)", ">", 0, System.Data.DbType.Int32)); if (State == 3) where.Add(new RefParameter("isnull(b.InNum,0)", ">", 0, System.Data.DbType.Int32)); where.Add(new RefParameter("f.StoreId", "=", StoreId, System.Data.DbType.Int32)); JsonModel> resultModel = new JsonModel>(); int RowCount = 0; resultModel.DataSource = DataNew.GetListUserBuyAll2(StoreId, where, PageIndex, PageSize, "d.GoodsCode", out RowCount); resultModel.RowCount = RowCount; var slist = DataNew.GetMateShop(); var buylist = DataNew.GetShopBuyNum(StoreId); if (resultModel.DataSource!=null&&slist != null) { foreach(var md in resultModel.DataSource) { md.TSolid = md.Solid * md.GoodsNum; md.MSolid = md.Solid * md.InNum; md.NSolid = md.Solid * md.NowNum; int i=0; foreach (var smd in slist) { i++; Type type = md.GetType(); //var ps = type.GetProperties(); var ps = type.GetProperties().ToList(); var bmd = buylist.Find(n => n.DetailId == md.DetailId && n.ShopId == smd.ShopId); if (bmd != null) { foreach (var p in ps) { if (p.Name == "Num" + i.ToString()) p.SetValue(md, bmd.NowNum, null); if (p.Name == "Solid" + i.ToString()) p.SetValue(md, md.Solid * bmd.NowNum, null); } } } } } return resultModel; } #endregion #region 分页查询 [WebMethod(EnableSession = true)] public string GetAllShopGoodsExcel(int StoreId, int State, string GoodsName,int IsSoild, int PageIndex, int PageSize) { PagesNew.Login(this.Session); RefParameterCollection where = new RefParameterCollection(); if (GoodsName != "") { where.Add(new RefParameter("d.GoodsCode", "like", GoodsName, System.Data.DbType.String)); } if (State == 1) where.Add(new RefParameter("isnull(a.KCNum,0)-isnull(b.NowNum,0)", "=", 0, System.Data.DbType.Int32)); if (State == 2) where.Add(new RefParameter("isnull(a.KCNum,0)-isnull(b.NowNum,0)", ">", 0, System.Data.DbType.Int32)); if (State == 3) where.Add(new RefParameter("isnull(b.InNum,0)", ">", 0, System.Data.DbType.Int32)); where.Add(new RefParameter("f.StoreId", "=", StoreId, System.Data.DbType.Int32)); JsonModel> resultModel = new JsonModel>(); int RowCount = 0; resultModel.DataSource = DataNew.GetListUserBuyAll2(StoreId, where, PageIndex, PageSize, "d.GoodsCode", out RowCount); resultModel.RowCount = RowCount; var slist = DataNew.GetMateShop(); var buylist = DataNew.GetShopBuyNum(StoreId); if (resultModel.DataSource != null && slist != null) { foreach (var md in resultModel.DataSource) { md.TSolid = md.Solid * md.GoodsNum; md.MSolid = md.Solid * md.InNum; md.NSolid = md.Solid * md.NowNum; int i = 0; foreach (var smd in slist) { i++; Type type = md.GetType(); //var ps = type.GetProperties(); var ps = type.GetProperties().ToList(); var bmd = buylist.Find(n => n.DetailId == md.DetailId && n.ShopId == smd.ShopId); if (bmd != null) { foreach (var p in ps) { if (p.Name == "Num" + i.ToString()) p.SetValue(md, bmd.NowNum, null); if (p.Name == "Solid" + i.ToString()) p.SetValue(md, md.Solid * bmd.NowNum, null); } } } } } TableColumnCollection listColumns = new TableColumnCollection(); listColumns.Add("GoodsCode", "编号", DbType.String, ""); listColumns.Add("SKU", "编号sku", DbType.String, ""); listColumns.Add("StoreName", "仓库", DbType.String, ""); listColumns.Add("GoodsNum", "当前库存", DbType.String, ""); if(IsSoild==1) listColumns.Add("TSolid", "总立方", DbType.String, ""); //listColumns.Add("InNum", "累计认购数量", DbType.String, ""); //if (IsSoild == 1) // listColumns.Add("MSolid", "累计认购立方", DbType.String, ""); listColumns.Add("NowNum", "认购库存", DbType.String, ""); if (IsSoild == 1) listColumns.Add("NSolid", "认购库存立方", DbType.String, ""); int j = 0; foreach (var smd in slist) { j++; listColumns.Add("Num" + j.ToString(), smd.ShopName + "认购库存", DbType.String, ""); if (IsSoild == 1) listColumns.Add("Solid" + j.ToString(), smd.ShopName + "认购立方", DbType.String, ""); } MicrosoftExcel obj2 = new MicrosoftExcel(); return obj2.Export(resultModel.DataSource, listColumns); } #endregion #region 业远费用 [WebMethod(EnableSession = true)] public List GetListUserFee(int ShopId, DateTime? SDate, DateTime? EDate) { PagesNew.Login(base.Session); EDate = EDate.Value.AddDays(1); DateTime start = Convert.ToDateTime(SDate.Value.ToShortDateString()); DateTime end = Convert.ToDateTime(EDate.Value.ToShortDateString()); TimeSpan sp = end.Subtract(start); int days = sp.Days; var list = DataNew.GetListUserFee(SDate, EDate, ShopId); var slist = DataNew.GetListUserShop(ShopId); var flist = new List(); if (slist != null) { decimal TotalFee = 0; decimal TotalFee1 = 0; decimal TotalFee2= 0; decimal TotalFee3= 0; decimal TotalFee4= 0; decimal TotalFee5= 0; foreach (var smd in slist) { for (int i = 0; i < days; i++) { var fmd = new HW_UserFee(); fmd.InDate = start.AddDays(i); fmd.ShopId = smd.ShopId; fmd.ShopName = smd.ShopName; if (smd.Master != null && smd.Master != "") fmd.ShopUser = smd.Master; if (smd.ShopUser != null && smd.ShopUser != "") fmd.ShopUser += " " + smd.ShopUser; fmd.Num1 =0; fmd.Num2=0; fmd.Num3=0; fmd.Num4=0; fmd.Num5=0; fmd.Num6=0; fmd.Num7=0; if (list != null) { var ffmd = list.Find(n => n.ShopId == smd.ShopId && n.FeeType == 1 && n.InDate.Value.ToString("yyyy-MM-dd") == start.AddDays(i).ToString("yyyy-MM-dd")); if (ffmd != null) { fmd.FeeDesc1 = ffmd.FeeDesc; fmd.Num1 = ffmd.TotalFee; } var ffmd2 = list.Find(n => n.ShopId == smd.ShopId && n.FeeType == 2 && n.InDate.Value.ToString("yyyy-MM-dd") == start.AddDays(i).ToString("yyyy-MM-dd")); if (ffmd2 != null) { fmd.FeeDesc2 = ffmd2.FeeDesc; fmd.Num2 = ffmd2.TotalFee; } } fmd.TotalPrice = fmd.Num1 + fmd.Num2 + fmd.Num3 + fmd.Num4+ fmd.Num5 + fmd.Num6 + fmd.Num7; TotalFee1+=fmd.Num1.Value; TotalFee2+=fmd.Num2.Value; TotalFee3+=fmd.Num3.Value; TotalFee4+=fmd.Num4.Value; TotalFee5+=fmd.Num5.Value; TotalFee += fmd.TotalPrice.Value; flist.Add(fmd); } } var fmd2= new HW_UserFee(); fmd2.FeeDesc2 = "总计:"; fmd2.Num1 = TotalFee1; fmd2.Num2 = TotalFee2; fmd2.Num3 = TotalFee3; fmd2.Num4 = TotalFee4; fmd2.Num5 = TotalFee5; fmd2.TotalPrice = TotalFee; flist.Add(fmd2); } return flist; } #endregion #region 导出费用 [WebMethod(EnableSession = true)] public string GetGoodsUserFeeExcel(int ShopId, DateTime? SDate, DateTime? EDate) { PagesNew.Login(base.Session); EDate = EDate.Value.AddDays(1); DateTime start = Convert.ToDateTime(SDate.Value.ToShortDateString()); DateTime end = Convert.ToDateTime(EDate.Value.ToShortDateString()); TimeSpan sp = end.Subtract(start); int days = sp.Days; var list = DataNew.GetListUserFee(SDate, EDate, ShopId); var slist = DataNew.GetListUserShop(ShopId); var flist = new List(); if (slist != null) { decimal TotalFee = 0; decimal TotalFee1 = 0; decimal TotalFee2 = 0; decimal TotalFee3 = 0; decimal TotalFee4 = 0; decimal TotalFee5 = 0; foreach (var smd in slist) { for (int i = 0; i < days; i++) { var fmd = new HW_UserFee(); fmd.InDate = start.AddDays(i); fmd.ShopId = smd.ShopId; fmd.ShopName = smd.ShopName; if (smd.Master != null && smd.Master != "") fmd.ShopUser = smd.Master; if (smd.ShopUser != null && smd.ShopUser != "") fmd.ShopUser += " " + smd.ShopUser; fmd.Num1 = 0; fmd.Num2 = 0; fmd.Num3 = 0; fmd.Num4 = 0; fmd.Num5 = 0; fmd.Num6 = 0; fmd.Num7 = 0; if (list != null) { var ffmd = list.Find(n => n.ShopId == smd.ShopId && n.FeeType == 1 && n.InDate.Value.ToString("yyyy-MM-dd") == start.AddDays(i).ToString("yyyy-MM-dd")); if (ffmd != null) { fmd.FeeDesc1 = ffmd.FeeDesc; fmd.Num1 = ffmd.TotalFee; } var ffmd2 = list.Find(n => n.ShopId == smd.ShopId && n.FeeType == 2 && n.InDate.Value.ToString("yyyy-MM-dd") == start.AddDays(i).ToString("yyyy-MM-dd")); if (ffmd2 != null) { fmd.FeeDesc2 = ffmd2.FeeDesc; fmd.Num2 = ffmd2.TotalFee; } } fmd.TotalPrice = fmd.Num1 + fmd.Num2 + fmd.Num3 + fmd.Num4 + fmd.Num5 + fmd.Num6 + fmd.Num7; TotalFee1 += fmd.Num1.Value; TotalFee2 += fmd.Num2.Value; TotalFee3 += fmd.Num3.Value; TotalFee4 += fmd.Num4.Value; TotalFee5 += fmd.Num5.Value; TotalFee += fmd.TotalPrice.Value; flist.Add(fmd); } } var fmd2 = new HW_UserFee(); fmd2.FeeDesc2 = "总计:"; fmd2.Num1 = TotalFee1; fmd2.Num2 = TotalFee2; fmd2.Num3 = TotalFee3; fmd2.Num4 = TotalFee4; fmd2.Num5 = TotalFee5; fmd2.TotalPrice = TotalFee; flist.Add(fmd2); } TableColumnCollection listColumns = new TableColumnCollection(); listColumns.Add("InDate", "费用日期", DbType.String, "yyyy-MM-dd"); listColumns.Add("ShopName", "店铺", DbType.String, ""); listColumns.Add("ShopUser", "运营人员", DbType.String, ""); listColumns.Add("FeeDesc1", "认购库存立方", DbType.String, ""); listColumns.Add("FeeDesc2", "发货单数", DbType.String, ""); listColumns.Add("Num1", "仓库费用", DbType.String, ""); listColumns.Add("Num2", "发货费用", DbType.String, ""); listColumns.Add("Num3", "其他费用", DbType.String, ""); listColumns.Add("TotalPrice", "合计", DbType.String, ""); MicrosoftExcel obj2 = new MicrosoftExcel(); return obj2.Export(flist, listColumns); } #endregion } }