You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

8171 lines
325 KiB
C#

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Services;
using TradeModel;
using NetLibrary.Data;
using System.Data;
using TradeData;
using NetLibrary;
using System.IO;
using NetLibrary.ReportPrint;
using NetLibrary.Log;
using System.Drawing;
using ZXing;
using ZXing.Common;
using ZXing.QrCode;
using TradeManage;
using NPOI.HSSF.UserModel;
using NPOI.SS.UserModel;
using System.Net;
using System.Web.UI;
using System.Text;
using NPOI.HSSF.Model;
using System.Runtime.Remoting.Metadata.W3cXsd2001;
namespace TradeManageNew
{
/// <summary>
/// HuoWuServiceNew 的摘要说明
/// </summary>
[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 HuoWuServiceNew : System.Web.Services.WebService
{
[WebMethod]
public string HelloWorld()
{
return "Hello World";
}
[WebMethod(EnableSession = true)]
public JsonModel<List<HW_GoodsDetail2>> GetGoodsDetailList(int TJ1, int IsYC, int IsJQ, int StoreId, int AQNum, string Name, string Supplier, int TJ2, int SNum, int ENum, int PageIndex, int PageSize, string Sort)
{
HuoWuData data = new HuoWuData();
int num = Convert.ToInt32(base.Session["CompanyId"]);
RefParameterCollection where = new RefParameterCollection();
if (IsYC == 0)
{
where.Add("isnull(a.IsYC,0)", "=", 0, DbType.Int32);
}
if (IsYC == 2)
{
where.Add("a.IsYC", "=", 1, DbType.Int32);
}
where.Add("b.CompanyId", "=", num, DbType.Int32);
if (AQNum == 1)
{
where.Add("a.GoodsNum-isnull(a.GoodsHJNum2,0)", "<", 0, DbType.Int32);
}
where.Add("b.State", "=", 1, DbType.Int32);
if (Supplier != "")
{
where.Add("b.SupplierId", "like", Supplier, DbType.String);
}
Name = Name.Trim();
if ((Name != "") && (IsJQ == 0))
{
if (TJ1 == 1)
{
where.Add("b.GoodsName", "like", Name, DbType.String);
}
if (TJ1 == 2)
{
where.Add("b.GoodsCode", "like", Name, DbType.String);
}
if (TJ1 == 4)
{
where.Add("(a.SKU1", "like", Name, DbType.String);
where.Add("a.SKU2", "like", Name, "or", DbType.String);
where.Add("a.SKU3", "like", Name, "or", DbType.String);
where.Add("a.SKU4", "like", Name, "or", DbType.String);
where.Add("a.SKU5", "like", Name, "or", DbType.String);
where.Add("a.SKU6", "like", Name, "or", DbType.String);
where.Add("a.SKU7", "like", Name, "or", ")", DbType.String);
}
}
else if ((Name != "") && (IsJQ == 1))
{
if (TJ1 == 1)
{
where.Add("b.GoodsName", "=", Name, DbType.String);
}
if (TJ1 == 2)
{
where.Add("b.GoodsCode", "=", Name, DbType.String);
}
if (TJ1 == 4)
{
where.Add("(a.SKU1", "=", Name, DbType.String);
where.Add("a.SKU2", "=", Name, "or", DbType.String);
where.Add("a.SKU3", "=", Name, "or", DbType.String);
where.Add("a.SKU4", "=", Name, "or", DbType.String);
where.Add("a.SKU5", "=", Name, "or", DbType.String);
where.Add("a.SKU6", "=", Name, "or", DbType.String);
where.Add("a.SKU7", "=", Name, "or", ")", DbType.String);
}
}
if (TJ2 == 1)
{
if (SNum > 0)
{
where.Add("a.GoodsNum", ">=", SNum, DbType.Int32);
}
if (ENum > 0)
{
where.Add("a.GoodsNum", "<=", ENum, DbType.Int32);
}
}
else if (TJ2 == 2)
{
if (SNum > 0)
{
where.Add("a.GoodsHJNum", ">=", SNum, DbType.Int32);
}
if (ENum > 0)
{
where.Add("a.GoodsHJNum", "<=", ENum, DbType.Int32);
}
}
else if (TJ2 == 3)
{
if (SNum > 0)
{
where.Add("a.GoodsHJNum2", ">=", SNum, DbType.Int32);
}
if (ENum > 0)
{
where.Add("a.GoodsHJNum2", "<=", ENum, DbType.Int32);
}
}
else if (TJ2 == 4)
{
if (SNum > 0)
{
where.Add("a.GoodsHJNum3", ">=", SNum, DbType.Int32);
}
if (ENum > 0)
{
where.Add("a.GoodsHJNum3", "<=", ENum, DbType.Int32);
}
}
else if (TJ2 == 5)
{
if (SNum > 0)
{
where.Add("a.GoodsHJNum4", ">=", SNum, DbType.Int32);
}
if (ENum > 0)
{
where.Add("a.GoodsHJNum4", "<=", ENum, DbType.Int32);
}
}
JsonModel<List<HW_GoodsDetail2>> model = new JsonModel<List<HW_GoodsDetail2>>();
int rowCount = 0;
model.DataSource = DataNew.GetListHW_GoodsDetailNew(StoreId, where, PageIndex, PageSize, Sort, out rowCount);
model.RowCount = rowCount;
string gids = "";
if (model.DataSource != null)
{
foreach (var detail in model.DataSource)
{
gids += detail.GoodsId + ",";
}
}
List<HW_GoodsStar> slist = null;
if (gids != "")
{
slist = DataNew.GetListGoodsStar(gids.TrimEnd(','));
}
if (model.DataSource != null)
{
foreach (var detail in model.DataSource)
{
string html = "";
List<JC_Shop> czlist = new List<JC_Shop>();
if (slist != null)
{
var smd = slist.FindAll(n => n.GoodsId == detail.GoodsId);
if (smd != null)
{
foreach (var ssmd in smd)
{
var czmd = czlist.Find(n => n.ShopId == ssmd.ShopId);
if (czmd == null)
{
decimal score=Convert.ToDecimal(ssmd.Star1.Value*1.00/100+ssmd.Star2.Value*2.00/100+ssmd.Star3*3.00/100+ssmd.Star4*4.00/100+ssmd.Star5*5.00/100);
string starhtml="";
if(score>=Convert.ToDecimal(4.5))
starhtml+="<img src='../images/star.png'/><img src='../images/star.png'/><img src='../images/star.png'/><img src='../images/star.png'/><img src='../images/star.png'/>";
else if(score>=Convert.ToDecimal(4))
starhtml+="<img src='../images/star.png'/><img src='../images/star.png'/><img src='../images/star.png'/><img src='../images/star.png'/><img src='../images/star2.png'/>";
else if(score>=Convert.ToDecimal(3))
starhtml+="<img src='../images/star.png'/><img src='../images/star.png'/><img src='../images/star.png'/><img src='../images/star2.png'/><img src='../images/star2.png'/>";
else if(score>=Convert.ToDecimal(2))
starhtml+="<img src='../images/star.png'/><img src='../images/star.png'/><img src='../images/star2.png'/><img src='../images/star2.png'/><img src='../images/star2.png'/>";
else if(score>=Convert.ToDecimal(1))
starhtml+="<img src='../images/star.png'/><img src='../images/star2.png'/><img src='../images/star2.png'/><img src='../images/star2.png'/><img src='../images/star2.png'/>";
else
starhtml+="<img src='../images/star2.png'/><img src='../images/star2.png'/><img src='../images/star2.png'/><img src='../images/star2.png'/><img src='../images/star2.png'/>";
html += @"<div style='float:left'> " + ssmd.ShopName + ":" + starhtml + score.ToString("0.0") + " out of 5 Stars" + ssmd.Star6 + " ";
html += @"<br />5 Star<div style='border:1px solid gray;width:100px;height:10px;display:inline-block;'><div style='background-color:#ffce00;width:"+ssmd.Star5.Value+"px;height:10px;'></div></div>"+ssmd.Star5+@"% <br />4 Star<div style='border:1px solid gray;width:100px;height:10px;display:inline-block;'><div style='background-color:#ffce00;width:"+ssmd.Star4.Value+"px;height:10px'></div></div>"+ssmd.Star4+@"%<br />3 Star<div style='border:1px solid gray;width:100px;height:10px;display:inline-block;'><div style='background-color:#ffce00;width:"+ssmd.Star3.Value+"px;height:10px'></div></div>"+ssmd.Star3+@"% <br />2 Star<div style='border:1px solid gray;width:100px;height:10px;display:inline-block;'><div style='background-color:#ffce00;width:"+ssmd.Star2.Value+"px;height:10px'></div></div>"+ssmd.Star2+@"%<br />1 Star<div style='border:1px solid gray;width:100px;height:10px;display:inline-block;'><div style='background-color:#ffce00;width:" + ssmd.Star1.Value + "px;height:10px'></div></div>" + ssmd.Star1 + @"%
</div>";
}
var spmd=new JC_Shop();
spmd.ShopId=ssmd.ShopId;
czlist.Add(spmd);
}
}
}
detail.UpdateName = html;
if (detail.Solid.HasValue)
{
detail.TotalSolid = detail.Solid * detail.GoodsNum;
}
else
{
detail.TotalSolid = 0;
}
}
}
return model;
}
[WebMethod(EnableSession = true)]
public JsonModel<List<HW_GoodsDetailNew2>> GetGoodsDetailListNew2(int GNum, int TJ1, int IsYC, int IsJQ, int StoreId, int AQNum, int AQNum2, string Name, string Supplier, int TJ2, int SNum, int ENum, int cgjh, int PageIndex, int PageSize, string Sort)
{
HuoWuData data = new HuoWuData();
int num = Convert.ToInt32(base.Session["CompanyId"]);
RefParameterCollection where = new RefParameterCollection();
if (IsYC == 0)
{
where.Add("isnull(a.IsYC,0)", "=", 0, DbType.Int32);
}
if (cgjh > 0)
where.Add("FHPlan", "=", cgjh, DbType.Int32);
if (IsYC == 2)
{
where.Add("a.IsYC", "=", 1, DbType.Int32);
}
where.Add("b.CompanyId", "=", num, DbType.Int32);
if (AQNum == 1)
{
where.Add("isnull(a.WestNum,0)-isnull(a.GoodsHJNum12,0)", "<", 0, DbType.Int32);
}
if (AQNum2 == 1)
{
where.Add("isnull(a.EastNum,0)-isnull(a.GoodsHJNum13,0)", "<", 0, DbType.Int32);
}
where.Add("b.State", "=", 1, DbType.Int32);
if (Supplier != "")
{
where.Add("b.SupplierId", "like", Supplier, DbType.String);
}
Name = Name.Trim();
if ((Name != "") && (IsJQ == 0))
{
if (TJ1 == 1)
{
where.Add("b.GoodsName", "like", Name, DbType.String);
}
if (TJ1 == 2)
{
where.Add("b.GoodsCode", "like", Name, DbType.String);
}
if (TJ1 == 4)
{
where.Add("(a.SKU1", "like", Name, DbType.String);
where.Add("a.SKU2", "like", Name, "or", DbType.String);
where.Add("a.SKU3", "like", Name, "or", DbType.String);
where.Add("a.SKU4", "like", Name, "or", DbType.String);
where.Add("a.SKU5", "like", Name, "or", DbType.String);
where.Add("a.SKU6", "like", Name, "or", DbType.String);
where.Add("a.SKU7", "like", Name, "or", ")", DbType.String);
}
}
else if ((Name != "") && (IsJQ == 1))
{
if (TJ1 == 1)
{
where.Add("b.GoodsName", "=", Name, DbType.String);
}
if (TJ1 == 2)
{
where.Add("b.GoodsCode", "=", Name, DbType.String);
}
if (TJ1 == 4)
{
where.Add("(a.SKU1", "=", Name, DbType.String);
where.Add("a.SKU2", "=", Name, "or", DbType.String);
where.Add("a.SKU3", "=", Name, "or", DbType.String);
where.Add("a.SKU4", "=", Name, "or", DbType.String);
where.Add("a.SKU5", "=", Name, "or", DbType.String);
where.Add("a.SKU6", "=", Name, "or", DbType.String);
where.Add("a.SKU7", "=", Name, "or", ")", DbType.String);
}
}
if (TJ2 == 1)
{
if (SNum > 0)
{
where.Add("a.GoodsNum", ">=", SNum, DbType.Int32);
}
if (ENum > 0)
{
where.Add("a.GoodsNum", "<=", ENum, DbType.Int32);
}
}
else if (TJ2 == 2)
{
if (SNum > 0)
{
where.Add("a.GoodsHJNum", ">=", SNum, DbType.Int32);
}
if (ENum > 0)
{
where.Add("a.GoodsHJNum", "<=", ENum, DbType.Int32);
}
}
else if (TJ2 == 3)
{
if (SNum > 0)
{
where.Add("a.GoodsHJNum2", ">=", SNum, DbType.Int32);
}
if (ENum > 0)
{
where.Add("a.GoodsHJNum2", "<=", ENum, DbType.Int32);
}
}
else if (TJ2 == 4)
{
if (SNum > 0)
{
where.Add("a.GoodsHJNum3", ">=", SNum, DbType.Int32);
}
if (ENum > 0)
{
where.Add("a.GoodsHJNum3", "<=", ENum, DbType.Int32);
}
}
else if (TJ2 == 5)
{
if (SNum > 0)
{
where.Add("a.GoodsHJNum4", ">=", SNum, DbType.Int32);
}
if (ENum > 0)
{
where.Add("a.GoodsHJNum4", "<=", ENum, DbType.Int32);
}
}
if (GNum == 1)
where.Add("a.CGNum", ">", 0, DbType.Int32);
JsonModel<List<HW_GoodsDetailNew2>> model = new JsonModel<List<HW_GoodsDetailNew2>>();
int rowCount = 0;
model.DataSource = DataNew.GetListHW_GoodsDetailNew2(StoreId, where, PageIndex, PageSize, Sort, out rowCount);
model.RowCount = rowCount;
string gids = "";
if (model.DataSource != null)
{
foreach (var detail in model.DataSource)
{
gids += detail.GoodsId + ",";
}
}
List<HW_GoodsStar> slist = null;
if (gids != "")
{
slist = DataNew.GetListGoodsStar(gids.TrimEnd(','));
}
if (model.DataSource != null)
{
foreach (var detail in model.DataSource)
{
string html = "";
List<JC_Shop> czlist = new List<JC_Shop>();
if (slist != null)
{
var smd = slist.FindAll(n => n.GoodsId == detail.GoodsId);
if (smd != null)
{
foreach (var ssmd in smd)
{
var czmd = czlist.Find(n => n.ShopId == ssmd.ShopId);
if (czmd == null)
{
decimal score = Convert.ToDecimal(ssmd.Star1.Value * 1.00 / 100 + ssmd.Star2.Value * 2.00 / 100 + ssmd.Star3 * 3.00 / 100 + ssmd.Star4 * 4.00 / 100 + ssmd.Star5 * 5.00 / 100);
string starhtml = "";
if (score >= Convert.ToDecimal(4.5))
starhtml += "<img src='../images/star.png'/><img src='../images/star.png'/><img src='../images/star.png'/><img src='../images/star.png'/><img src='../images/star.png'/>";
else if (score >= Convert.ToDecimal(4))
starhtml += "<img src='../images/star.png'/><img src='../images/star.png'/><img src='../images/star.png'/><img src='../images/star.png'/><img src='../images/star2.png'/>";
else if (score >= Convert.ToDecimal(3))
starhtml += "<img src='../images/star.png'/><img src='../images/star.png'/><img src='../images/star.png'/><img src='../images/star2.png'/><img src='../images/star2.png'/>";
else if (score >= Convert.ToDecimal(2))
starhtml += "<img src='../images/star.png'/><img src='../images/star.png'/><img src='../images/star2.png'/><img src='../images/star2.png'/><img src='../images/star2.png'/>";
else if (score >= Convert.ToDecimal(1))
starhtml += "<img src='../images/star.png'/><img src='../images/star2.png'/><img src='../images/star2.png'/><img src='../images/star2.png'/><img src='../images/star2.png'/>";
else
starhtml += "<img src='../images/star2.png'/><img src='../images/star2.png'/><img src='../images/star2.png'/><img src='../images/star2.png'/><img src='../images/star2.png'/>";
html += @"<div style='float:left'> " + ssmd.ShopName + ":" + starhtml + score.ToString("0.0") + " out of 5 Stars" + ssmd.Star6 + " ";
html += @"<br />5 Star<div style='border:1px solid gray;width:100px;height:10px;display:inline-block;'><div style='background-color:#ffce00;width:" + ssmd.Star5.Value + "px;height:10px;'></div></div>" + ssmd.Star5 + @"% <br />4 Star<div style='border:1px solid gray;width:100px;height:10px;display:inline-block;'><div style='background-color:#ffce00;width:" + ssmd.Star4.Value + "px;height:10px'></div></div>" + ssmd.Star4 + @"%<br />3 Star<div style='border:1px solid gray;width:100px;height:10px;display:inline-block;'><div style='background-color:#ffce00;width:" + ssmd.Star3.Value + "px;height:10px'></div></div>" + ssmd.Star3 + @"% <br />2 Star<div style='border:1px solid gray;width:100px;height:10px;display:inline-block;'><div style='background-color:#ffce00;width:" + ssmd.Star2.Value + "px;height:10px'></div></div>" + ssmd.Star2 + @"%<br />1 Star<div style='border:1px solid gray;width:100px;height:10px;display:inline-block;'><div style='background-color:#ffce00;width:" + ssmd.Star1.Value + "px;height:10px'></div></div>" + ssmd.Star1 + @"%
</div>";
}
var spmd = new JC_Shop();
spmd.ShopId = ssmd.ShopId;
czlist.Add(spmd);
}
}
}
detail.UpdateName = html;
if (detail.Solid.HasValue)
{
detail.TotalSolid = detail.Solid * detail.GoodsNum;
}
else
{
detail.TotalSolid = 0;
}
}
}
return model;
}
[WebMethod(EnableSession = true)]
public JsonModel<List<HW_GoodsDetailNew2>> GetGoodsDetailListNew22(int platid,int MUserId,int cpzt,int GNum, int TJ1, int IsYC, int IsJQ, int StoreId, int AQNum, int AQNum2, string Name, string Supplier, int TJ2, int SNum, int ENum, int cgjh, int kh, int PageIndex, int PageSize, string Sort)
{
HuoWuData data = new HuoWuData();
int num = 0;
if (base.Session["CompanyId"] != null)
{
num = Convert.ToInt32(base.Session["CompanyId"]);
}
else
{
num = 1;
}
RefParameterCollection where = new RefParameterCollection();
if (cpzt > 0)
{
where.Add("isnull(a.SalesType,0)", "=", cpzt, DbType.Int32);
}
if (IsYC == 0)
{
where.Add("isnull(a.IsYC,0)", "=", 0, DbType.Int32);
}
if (IsYC == 2)
{
where.Add("a.IsYC", "=", 1, DbType.Int32);
}
where.Add("b.CompanyId", "=", num, DbType.Int32);
if (cgjh > 0)
where.Add("FHPlan", "=", cgjh, DbType.Int32);
if (cgjh > 0)
where.Add("FHPlan", "=", cgjh, DbType.Int32);
// if (MName!=""&&platid==2)
// where.Add("b.MName", "=", MName, DbType.String);
//else if (MName != "" && platid == 3)
// where.Add("b.groupname_ebay", "=", MName, DbType.String);
// else if (MName != "" && platid == 6)
// where.Add("b.groupname_wlmart", "=", MName, DbType.String);
// else if (MName != "" && platid == 15)
// where.Add("b.groupname_shopify", "=", MName, DbType.String);
// else if (MName != "" && platid == 18)
// where.Add("b.groupname_wayfair", "=", MName, DbType.String);
// else if (MName != "" && platid ==21)
// where.Add("b.groupname_sheIn", "=", MName, DbType.String);
if (MUserId != 0 && platid == 2)
where.Add("b.muserid", "=", MUserId, DbType.Int32);
else if (MUserId != 0 && platid == 3)
where.Add("b.guserid_ebay", "=", MUserId, DbType.Int32);
else if (MUserId != 0 && platid == 6)
where.Add("b.guserid_wlmart", "=", MUserId, DbType.Int32);
else if (MUserId != 0 && platid == 15)
where.Add("b.guserid_shopify", "=", MUserId, DbType.Int32);
else if (MUserId != 0 && platid == 18)
where.Add("b.guserid_wayfair", "=", MUserId, DbType.Int32);
else if (MUserId != 0 && platid == 21)
where.Add("b.guserid_sheIn", "=", MUserId, DbType.Int32);
else if (MUserId != 0 && platid == 23)
where.Add("b.guserid_temu", "=", MUserId, DbType.Int32);
if (AQNum == 1)
{
where.Add("isnull(a.WestNum,0)-isnull(a.GoodsHJNum12,0)", "<", 0, DbType.Int32);
}
if (AQNum2 == 1)
{
where.Add("isnull(a.EastNum,0)-isnull(a.GoodsHJNum13,0)", "<", 0, DbType.Int32);
}
where.Add("b.State", "=", 1, DbType.Int32);
if (Supplier != "")
{
where.Add("b.SupplierId", "like", Supplier, DbType.String);
}
Name = Name.Trim();
if ((Name != "") && (IsJQ == 0))
{
if (TJ1 == 1)
{
where.Add("b.GoodsName", "like", Name, DbType.String);
}
if (TJ1 == 2)
{
where.Add("b.GoodsCode", "like", Name, DbType.String);
}
if (TJ1 == 4)
{
where.Add("(a.SKU1", "like", Name, DbType.String);
where.Add("a.SKU2", "like", Name, "or", DbType.String);
where.Add("a.SKU3", "like", Name, "or", DbType.String);
where.Add("a.SKU4", "like", Name, "or", DbType.String);
where.Add("a.SKU5", "like", Name, "or", DbType.String);
where.Add("a.SKU6", "like", Name, "or", DbType.String);
where.Add("a.SKU7", "like", Name, "or", ")", DbType.String);
}
}
else if ((Name != "") && (IsJQ == 1))
{
if (TJ1 == 1)
{
where.Add("b.GoodsName", "=", Name, DbType.String);
}
if (TJ1 == 2)
{
where.Add("b.GoodsCode", "=", Name, DbType.String);
}
if (TJ1 == 4)
{
where.Add("(a.SKU1", "=", Name, DbType.String);
where.Add("a.SKU2", "=", Name, "or", DbType.String);
where.Add("a.SKU3", "=", Name, "or", DbType.String);
where.Add("a.SKU4", "=", Name, "or", DbType.String);
where.Add("a.SKU5", "=", Name, "or", DbType.String);
where.Add("a.SKU6", "=", Name, "or", DbType.String);
where.Add("a.SKU7", "=", Name, "or", ")", DbType.String);
}
}
if (TJ2 == 1)
{
if (StoreId == 6)
{
if (SNum > 0)
{
where.Add("a.WestNum", ">=", SNum, DbType.Int32);
}
if (ENum > 0)
{
where.Add("a.WestNum", "<=", ENum, DbType.Int32);
}
}
else if (StoreId == 11)
{
if (SNum > 0)
{
where.Add("a.EastNum", ">=", SNum, DbType.Int32);
}
if (ENum > 0)
{
where.Add("a.EastNum", "<=", ENum, DbType.Int32);
}
}
else
{
if (SNum > 0)
{
where.Add("a.GoodsNum", ">=", SNum, DbType.Int32);
}
if (ENum > 0)
{
where.Add("a.GoodsNum", "<=", ENum, DbType.Int32);
}
}
}
else if (TJ2 == 2)
{
if (SNum > 0)
{
where.Add("a.GoodsHJNum", ">=", SNum, DbType.Int32);
}
if (ENum > 0)
{
where.Add("a.GoodsHJNum", "<=", ENum, DbType.Int32);
}
}
else if (TJ2 == 3)
{
if (SNum > 0)
{
where.Add("a.GoodsHJNum2", ">=", SNum, DbType.Int32);
}
if (ENum > 0)
{
where.Add("a.GoodsHJNum2", "<=", ENum, DbType.Int32);
}
}
else if (TJ2 == 4)
{
if (SNum > 0)
{
where.Add("a.GoodsHJNum3", ">=", SNum, DbType.Int32);
}
if (ENum > 0)
{
where.Add("a.GoodsHJNum3", "<=", ENum, DbType.Int32);
}
}
else if (TJ2 == 5)
{
if (SNum > 0)
{
where.Add("a.GoodsHJNum4", ">=", SNum, DbType.Int32);
}
if (ENum > 0)
{
where.Add("a.GoodsHJNum4", "<=", ENum, DbType.Int32);
}
}
if (GNum == 1)
where.Add("a.CGNum", ">", 0, DbType.Int32);
if (kh != -1)
where.Add("b.IsExamine", "=", kh, DbType.Int32);
JsonModel<List<HW_GoodsDetailNew2>> model = new JsonModel<List<HW_GoodsDetailNew2>>();
int rowCount = 0;
model.DataSource = DataNew.GetListHW_GoodsDetailNew22(platid,StoreId, where, PageIndex, PageSize, Sort, out rowCount);
model.RowCount = rowCount;
string gids = "";
if (model.DataSource != null)
{
foreach (var detail in model.DataSource)
{
gids += detail.GoodsId + ",";
}
}
List<HW_GoodsStar> slist = null;
if (gids != "")
{
slist = DataNew.GetListGoodsStar(gids.TrimEnd(','));
}
if (model.DataSource != null)
{
var saleNums = DataNew.GetStoreGoodsSaleNumsNowDay();
foreach (var detail in model.DataSource)
{
string html = "";
List<JC_Shop> czlist = new List<JC_Shop>();
if (slist != null)
{
var smd = slist.FindAll(n => n.GoodsId == detail.GoodsId);
if (smd != null)
{
foreach (var ssmd in smd)
{
var czmd = czlist.Find(n => n.ShopId == ssmd.ShopId);
if (czmd == null)
{
decimal score = Convert.ToDecimal(ssmd.Star1.Value * 1.00 / 100 + ssmd.Star2.Value * 2.00 / 100 + ssmd.Star3 * 3.00 / 100 + ssmd.Star4 * 4.00 / 100 + ssmd.Star5 * 5.00 / 100);
string starhtml = "";
if (score >= Convert.ToDecimal(4.5))
starhtml += "<img src='../images/star.png'/><img src='../images/star.png'/><img src='../images/star.png'/><img src='../images/star.png'/><img src='../images/star.png'/>";
else if (score >= Convert.ToDecimal(4))
starhtml += "<img src='../images/star.png'/><img src='../images/star.png'/><img src='../images/star.png'/><img src='../images/star.png'/><img src='../images/star2.png'/>";
else if (score >= Convert.ToDecimal(3))
starhtml += "<img src='../images/star.png'/><img src='../images/star.png'/><img src='../images/star.png'/><img src='../images/star2.png'/><img src='../images/star2.png'/>";
else if (score >= Convert.ToDecimal(2))
starhtml += "<img src='../images/star.png'/><img src='../images/star.png'/><img src='../images/star2.png'/><img src='../images/star2.png'/><img src='../images/star2.png'/>";
else if (score >= Convert.ToDecimal(1))
starhtml += "<img src='../images/star.png'/><img src='../images/star2.png'/><img src='../images/star2.png'/><img src='../images/star2.png'/><img src='../images/star2.png'/>";
else
starhtml += "<img src='../images/star2.png'/><img src='../images/star2.png'/><img src='../images/star2.png'/><img src='../images/star2.png'/><img src='../images/star2.png'/>";
html += @"<div style='float:left'> " + ssmd.ShopName + ":" + starhtml + score.ToString("0.0") + " out of 5 Stars" + ssmd.Star6 + " ";
html += @"<br />5 Star<div style='border:1px solid gray;width:100px;height:10px;display:inline-block;'><div style='background-color:#ffce00;width:" + ssmd.Star5.Value + "px;height:10px;'></div></div>" + ssmd.Star5 + @"% <br />4 Star<div style='border:1px solid gray;width:100px;height:10px;display:inline-block;'><div style='background-color:#ffce00;width:" + ssmd.Star4.Value + "px;height:10px'></div></div>" + ssmd.Star4 + @"%<br />3 Star<div style='border:1px solid gray;width:100px;height:10px;display:inline-block;'><div style='background-color:#ffce00;width:" + ssmd.Star3.Value + "px;height:10px'></div></div>" + ssmd.Star3 + @"% <br />2 Star<div style='border:1px solid gray;width:100px;height:10px;display:inline-block;'><div style='background-color:#ffce00;width:" + ssmd.Star2.Value + "px;height:10px'></div></div>" + ssmd.Star2 + @"%<br />1 Star<div style='border:1px solid gray;width:100px;height:10px;display:inline-block;'><div style='background-color:#ffce00;width:" + ssmd.Star1.Value + "px;height:10px'></div></div>" + ssmd.Star1 + @"%
</div>";
}
var spmd = new JC_Shop();
spmd.ShopId = ssmd.ShopId;
czlist.Add(spmd);
}
}
}
detail.UpdateName = html;
if (detail.Solid.HasValue)
{
detail.TotalSolid = detail.Solid * detail.GoodsNum;
}
else
{
detail.TotalSolid = 0;
}
if (saleNums != null)
{
var _EsaleNum = saleNums.Where(r => r.StoreId == 11 && r.DetailId == detail.DetailId).FirstOrDefault();
detail.ENowDaySaleNum = _EsaleNum == null ? 0 : _EsaleNum.SaleNum;
var _WsaleNum = saleNums.Where(r => r.StoreId == 6 && r.DetailId == detail.DetailId).FirstOrDefault();
detail.WNowDaySaleNum = _WsaleNum == null ? 0 : _WsaleNum.SaleNum;
}
}
}
return model;
}
[WebMethod(EnableSession = true)]
public JsonModel<List<HW_GoodsDetailNew2>> GetGoodsDetailListNew5(int GNum, int TJ1, int IsYC, int IsJQ, int StoreId, int AQNum, int AQNum2, string Name, string Supplier, int TJ2, int SNum, int ENum, int PageIndex, int PageSize, string Sort)
{
HuoWuData data = new HuoWuData();
int num = Convert.ToInt32(base.Session["CompanyId"]);
RefParameterCollection where = new RefParameterCollection();
if (Session["KTSKU"].ToString() == "")
return null;
string ktsku = Session["KTSKU"].ToString();
if (IsYC == 0)
{
where.Add("isnull(a.IsYC,0)", "=", 0, DbType.Int32);
}
if (IsYC == 2)
{
where.Add("a.IsYC", "=", 1, DbType.Int32);
}
where.Add("b.CompanyId", "=", num, DbType.Int32);
if (AQNum == 1)
{
where.Add("isnull(a.WestNum,0)-isnull(a.GoodsHJNum12,0)", "<", 0, DbType.Int32);
}
if (AQNum2 == 1)
{
where.Add("isnull(a.EastNum,0)-isnull(a.GoodsHJNum13,0)", "<", 0, DbType.Int32);
}
where.Add("b.State", "=", 1, DbType.Int32);
if (Supplier != "")
{
where.Add("b.SupplierId", "like", Supplier, DbType.String);
}
Name = Name.Trim();
where.Add("b.GoodsCode", "like right", ktsku, DbType.String);
if ((Name != "") && (IsJQ == 0))
{
if (TJ1 == 1)
{
where.Add("b.GoodsName", "like", Name, DbType.String);
}
if (TJ1 == 2)
{
where.Add("b.GoodsCode", "like", Name, DbType.String);
}
if (TJ1 == 4)
{
where.Add("(a.SKU1", "like", Name, DbType.String);
where.Add("a.SKU2", "like", Name, "or", DbType.String);
where.Add("a.SKU3", "like", Name, "or", DbType.String);
where.Add("a.SKU4", "like", Name, "or", DbType.String);
where.Add("a.SKU5", "like", Name, "or", DbType.String);
where.Add("a.SKU6", "like", Name, "or", DbType.String);
where.Add("a.SKU7", "like", Name, "or", ")", DbType.String);
}
}
else if ((Name != "") && (IsJQ == 1))
{
if (TJ1 == 1)
{
where.Add("b.GoodsName", "=", Name, DbType.String);
}
if (TJ1 == 2)
{
where.Add("b.GoodsCode", "=", Name, DbType.String);
}
if (TJ1 == 4)
{
where.Add("(a.SKU1", "=", Name, DbType.String);
where.Add("a.SKU2", "=", Name, "or", DbType.String);
where.Add("a.SKU3", "=", Name, "or", DbType.String);
where.Add("a.SKU4", "=", Name, "or", DbType.String);
where.Add("a.SKU5", "=", Name, "or", DbType.String);
where.Add("a.SKU6", "=", Name, "or", DbType.String);
where.Add("a.SKU7", "=", Name, "or", ")", DbType.String);
}
}
if (TJ2 == 1)
{
if (SNum > 0)
{
where.Add("a.GoodsNum", ">=", SNum, DbType.Int32);
}
if (ENum > 0)
{
where.Add("a.GoodsNum", "<=", ENum, DbType.Int32);
}
}
else if (TJ2 == 2)
{
if (SNum > 0)
{
where.Add("a.GoodsHJNum", ">=", SNum, DbType.Int32);
}
if (ENum > 0)
{
where.Add("a.GoodsHJNum", "<=", ENum, DbType.Int32);
}
}
else if (TJ2 == 3)
{
if (SNum > 0)
{
where.Add("a.GoodsHJNum2", ">=", SNum, DbType.Int32);
}
if (ENum > 0)
{
where.Add("a.GoodsHJNum2", "<=", ENum, DbType.Int32);
}
}
else if (TJ2 == 4)
{
if (SNum > 0)
{
where.Add("a.GoodsHJNum3", ">=", SNum, DbType.Int32);
}
if (ENum > 0)
{
where.Add("a.GoodsHJNum3", "<=", ENum, DbType.Int32);
}
}
else if (TJ2 == 5)
{
if (SNum > 0)
{
where.Add("a.GoodsHJNum4", ">=", SNum, DbType.Int32);
}
if (ENum > 0)
{
where.Add("a.GoodsHJNum4", "<=", ENum, DbType.Int32);
}
}
if (GNum == 1)
where.Add("a.CGNum", ">", 0, DbType.Int32);
JsonModel<List<HW_GoodsDetailNew2>> model = new JsonModel<List<HW_GoodsDetailNew2>>();
int rowCount = 0;
model.DataSource = DataNew.GetListHW_GoodsDetailNew2(StoreId, where, PageIndex, PageSize, Sort, out rowCount);
model.RowCount = rowCount;
string gids = "";
if (model.DataSource != null)
{
foreach (var detail in model.DataSource)
{
gids += detail.GoodsId + ",";
}
}
List<HW_GoodsStar> slist = null;
if (gids != "")
{
slist = DataNew.GetListGoodsStar(gids.TrimEnd(','));
}
if (model.DataSource != null)
{
foreach (var detail in model.DataSource)
{
string html = "";
List<JC_Shop> czlist = new List<JC_Shop>();
if (slist != null)
{
var smd = slist.FindAll(n => n.GoodsId == detail.GoodsId);
if (smd != null)
{
foreach (var ssmd in smd)
{
var czmd = czlist.Find(n => n.ShopId == ssmd.ShopId);
if (czmd == null)
{
decimal score = Convert.ToDecimal(ssmd.Star1.Value * 1.00 / 100 + ssmd.Star2.Value * 2.00 / 100 + ssmd.Star3 * 3.00 / 100 + ssmd.Star4 * 4.00 / 100 + ssmd.Star5 * 5.00 / 100);
string starhtml = "";
if (score >= Convert.ToDecimal(4.5))
starhtml += "<img src='../images/star.png'/><img src='../images/star.png'/><img src='../images/star.png'/><img src='../images/star.png'/><img src='../images/star.png'/>";
else if (score >= Convert.ToDecimal(4))
starhtml += "<img src='../images/star.png'/><img src='../images/star.png'/><img src='../images/star.png'/><img src='../images/star.png'/><img src='../images/star2.png'/>";
else if (score >= Convert.ToDecimal(3))
starhtml += "<img src='../images/star.png'/><img src='../images/star.png'/><img src='../images/star.png'/><img src='../images/star2.png'/><img src='../images/star2.png'/>";
else if (score >= Convert.ToDecimal(2))
starhtml += "<img src='../images/star.png'/><img src='../images/star.png'/><img src='../images/star2.png'/><img src='../images/star2.png'/><img src='../images/star2.png'/>";
else if (score >= Convert.ToDecimal(1))
starhtml += "<img src='../images/star.png'/><img src='../images/star2.png'/><img src='../images/star2.png'/><img src='../images/star2.png'/><img src='../images/star2.png'/>";
else
starhtml += "<img src='../images/star2.png'/><img src='../images/star2.png'/><img src='../images/star2.png'/><img src='../images/star2.png'/><img src='../images/star2.png'/>";
html += @"<div style='float:left'> " + ssmd.ShopName + ":" + starhtml + score.ToString("0.0") + " out of 5 Stars" + ssmd.Star6 + " ";
html += @"<br />5 Star<div style='border:1px solid gray;width:100px;height:10px;display:inline-block;'><div style='background-color:#ffce00;width:" + ssmd.Star5.Value + "px;height:10px;'></div></div>" + ssmd.Star5 + @"% <br />4 Star<div style='border:1px solid gray;width:100px;height:10px;display:inline-block;'><div style='background-color:#ffce00;width:" + ssmd.Star4.Value + "px;height:10px'></div></div>" + ssmd.Star4 + @"%<br />3 Star<div style='border:1px solid gray;width:100px;height:10px;display:inline-block;'><div style='background-color:#ffce00;width:" + ssmd.Star3.Value + "px;height:10px'></div></div>" + ssmd.Star3 + @"% <br />2 Star<div style='border:1px solid gray;width:100px;height:10px;display:inline-block;'><div style='background-color:#ffce00;width:" + ssmd.Star2.Value + "px;height:10px'></div></div>" + ssmd.Star2 + @"%<br />1 Star<div style='border:1px solid gray;width:100px;height:10px;display:inline-block;'><div style='background-color:#ffce00;width:" + ssmd.Star1.Value + "px;height:10px'></div></div>" + ssmd.Star1 + @"%
</div>";
}
var spmd = new JC_Shop();
spmd.ShopId = ssmd.ShopId;
czlist.Add(spmd);
}
}
}
detail.UpdateName = html;
if (detail.Solid.HasValue)
{
detail.TotalSolid = detail.Solid * detail.GoodsNum;
}
else
{
detail.TotalSolid = 0;
}
}
}
return model;
}
#region 导入运费
[WebMethod(EnableSession = true)]
public string ExcelSavePostFee(int IsFG, string FileName)
{
PagesNew.Login(this.Session);
if (string.IsNullOrEmpty(FileName) == true) return "要导入的文件路径不能为空";
string ServerFileName = AppDomain.CurrentDomain.BaseDirectory + FileName;
if (System.IO.File.Exists(ServerFileName) == false) return "要导入的文件路径不存在";
int CompanyId = Convert.ToInt32(Session["CompanyId"]);
try
{
MicrosoftExcel excel = new MicrosoftExcel();
DataTable tb = excel.ImportExcel(ServerFileName);
string error = "";
if (tb.Columns.Contains("Express or Ground Tracking ID") == false) { error = error + "导入模板的 Express or Ground Tracking ID 列不存在"; }
if (tb.Columns.Contains("Net Charge Amount") == false) { error = error + "导入模板的 Net Charge Amount 列不存在"; }
if (tb.Columns.Contains("Ground Tracking ID Prefix") == false) { error = error + "导入模板的 Ground Tracking ID Prefix 列不存在"; }
if (string.IsNullOrEmpty(error) == false) return error + ";请重新下载模板导入";
HuoWuData obj = new HuoWuData();
int UserId = Convert.ToInt32(Session["UserId"]);
int Count = 0;
int Count2 = 0;
string trinfo = "";
for (int i = 0; i < tb.Rows.Count; i++)
{
string TrackCode = tb.Rows[i]["Ground Tracking ID Prefix"].ToString().Trim() + tb.Rows[i]["Express or Ground Tracking ID"].ToString().Replace(" ", "").Trim();
if (tb.Rows[i]["Net Charge Amount"].ToString().Trim() == "" || TrackCode == "")
continue;
decimal PostFee = 0;
try
{
PostFee = Convert.ToDecimal(tb.Rows[i]["Net Charge Amount"].ToString().Trim());
}
catch (Exception ex)
{
continue;
}
if (IsFG == 1)
obj.ImportTrackCodeClear(TrackCode);
int a = DataNew.ImportTrackCode(TrackCode, PostFee, 0);
if (a > 0)
{
Count++;
}
else
{
Count2++;
trinfo += tb.Rows[i]["Express or Ground Tracking ID"].ToString().Trim() + "\r\n";
}
}
error = "导入成功" + Count.ToString() + "条";
if (Count2 > 0)
error += Count2 + "条数据运单号在系统找不对到\r\n" + trinfo;
return error;
}
catch (Exception e)
{
return "文件导入失败!请确定模板格式是否正确,或者重新下载模板,填写数据,重新导入!!!" + e.Message;
}
return "导入成功";
}
#endregion
#region 货物model
[WebMethod(EnableSession = true)]
public List<HW_GoodsDetailNew> GetGoodsDeatilListForTM(int GoodsId)
{
PagesNew.Login(this.Session);
var obj = new HuoWuData();
var obj1 = new BaseService();
var list = DataNew.GetGoodsDetail(GoodsId);
//var list1 = obj.GetFirstGoodsInList(GoodsId);
int TypeNo = 0;
if (list != null)
{
foreach (var md in list)
{
if (md.TypeCode != null && md.TypeCode != "")
{
int TypeNo1 = Convert.ToInt32(md.TypeCode);
if (TypeNo1 > TypeNo)
TypeNo = TypeNo1;
}
if (md.GoodsImageIds != null && md.GoodsImageIds != "")
md.ImgList = obj1.GetResourceList(md.GoodsImageIds);
}
}
//if (list != null && list1 != null)
//{
// foreach (var md in list)
// {
// md.GoodsPostion = list1.FindAll(n => n.DetailId == md.DetailId);
// if (md.GoodsPostion != null && md.GoodsPostion.Count > 0)
// md.PostPrice = md.GoodsPostion[0].PostPrice;
// else
// md.PostPrice = 0;
// }
//}
if (list != null && list.Count > 0)
{
list[0].TypeNo = TypeNo;
}
return list;
}
#endregion
#region 保存货物
[WebMethod(EnableSession = true)]
public string SaveGoodsForTM(HW_Goods model, List<HW_GoodsDetailNew> DetailList, List<HW_BuyLink> LinkList, List<HW_Shop> shoplist)
{
try
{
PagesNew.Login(this.Session);
int CompanyId = Convert.ToInt32(Session["CompanyId"]);
int InUserId = Convert.ToInt32(Session["UserId"]);
var obj = new HuoWuData();
if (model.GoodsId == null)
model.GoodsId = 0;
if (model.XPId > 0 && model.GoodsId == 0)
{
if (obj.IsGoodsXP(model.XPId.Value) > 0)
return "-1";//"这个选品货物已经加过编号,不能重复添加";
}
if (model.GoodsId == 0 && obj.IsGoodsCode(CompanyId, model.GoodsId.Value, model.GoodsCode) > 0)
{
return "-2";//"这个货物编号已经存在";
}
if (model.SupplierId.Trim() != "")
{
int SId = BaseService.GetSupplierIdForTM(CompanyId, model.SupplierId.Trim(), model.IsGYS.Value, InUserId);
if (SId == 0)
return "-3";//"供应商名字不存在,请确定填写是否正确或者勾选新供应商";
model.Supplier = SId;
}
// model.Solid = 1;
model.CompanyId = CompanyId;
model.InDate = DateTime.Now;
if (model.GoodsId > 0)
model.UpdateDate = DateTime.Now;
if (model.GoodsId == 0)
model.SortName = obj.GetGoodsSortName(model.SortId.Value);
string goodEg = model.GoodsCode.Substring(0, 3);
string goodNo = model.GoodsCode.Substring(3, model.GoodsCode.Length - 3);
try
{
model.GoodsEg = goodEg;
model.GoodsNo = Convert.ToInt32(goodNo);
}
catch
{
}
if (model.UpdateName != null)
{
if (!model.UpdateName.Contains(Session["Name"].ToString()))
model.UpdateName = model.UpdateName + ";" + Session["Name"].ToString();
}
else
{
model.UpdateName = Session["Name"].ToString();
}
int GoodsId = DataNew.SaveGoodsInfoForTM(model);
if (DetailList != null)
{
foreach (var md in DetailList)
{
md.GoodsId = GoodsId;
if (md.GoodsInNum == null)
md.GoodsInNum = 0;
if (md.GoodsLockNum == null)
md.GoodsLockNum = 0;
if (md.GoodsOutNum == null)
md.GoodsOutNum = 0;
if (md.GoodsPlanNum == null)
md.GoodsPlanNum = 0;
md.PostPrice = model.PostPrice;
if (md.Weight == null)
md.Weight = model.Weight;
md.Solid = 1;
int DetailId = DataNew.SaveGoodsDetail(md);
if (md.GoodsPostion != null)
{
for (int i = 0; i < md.GoodsPostion.Count; i++)
{
md.GoodsPostion[i].DetailId = DetailId;
md.GoodsPostion[i].ChaseId = 0;
md.GoodsPostion[i].InDate = DateTime.Now;
md.GoodsPostion[i].InUserId = Convert.ToInt32(Session["UserId"]);
md.GoodsPostion[i].Price = md.Price;
md.GoodsPostion[i].PostPrice = model.PostPrice;
md.GoodsPostion[i].GoodsLockNum = 0;
obj.SaveGoodsInListNew(md.GoodsPostion[i]);
}
}
}
}
PagesNew.SaveLog(InUserId, "货物信息", "修改货物信息", GoodsId);
if (LinkList != null)
{
foreach (var md in LinkList)
{
md.GoodsId = GoodsId;
obj.SaveBuyLink(md);
}
}
//obj.DeleteShop(GoodsId);
string InName = Convert.ToString(Session["Name"]);
string Ids = "";
if (shoplist != null)
{
foreach (var md1 in shoplist)
{
md1.GoodsId = GoodsId;
md1.InName = InName;
int Id = obj.SaveShopForTM(md1);
Ids += Id.ToString() + ",";
}
}
obj.DeleteShopForTM(Ids.Trim(','), GoodsId);
return GoodsId.ToString();
}
catch (Exception ex)
{
return ex.Message;
}
}
#endregion
#region 货物链接
[WebMethod(EnableSession = true)]
public List<HW_BuyLinkNew> GetGoodsLink(int GoodsId)
{
PagesNew.Login(this.Session);
var obj = new HuoWuData();
int UserId = Convert.ToInt32(Session["UserId"]);
var list = DataNew.GetGoodsBuyLink(GoodsId, UserId);
return list;
}
#endregion
#region 保存货物
[WebMethod(EnableSession = true)]
public string SaveGoodsForTMNew(HW_GoodsNew model, List<HW_GoodsDetailNew> DetailList, List<HW_BuyLinkNew> LinkList, List<HW_Shop> shoplist)
{
try
{
PagesNew.Login(this.Session);
int CompanyId = Convert.ToInt32(Session["CompanyId"]);
int InUserId = Convert.ToInt32(Session["UserId"]);
var obj = new HuoWuData();
if (model.GoodsId == null)
model.GoodsId = 0;
if (model.XPId > 0 && model.GoodsId == 0)
{
if (obj.IsGoodsXP(model.XPId.Value) > 0)
return "-1";//"这个选品货物已经加过编号,不能重复添加";
}
if (model.GoodsId == 0 && obj.IsGoodsCode(CompanyId, model.GoodsId.Value, model.GoodsCode) > 0)
{
return "-2";//"这个货物编号已经存在";
}
if (model.SupplierId.Trim() != "")
{
int SId = BaseService.GetSupplierIdForTM(CompanyId, model.SupplierId.Trim(), model.IsGYS.Value, InUserId);
if (SId == 0)
return "-3";//"供应商名字不存在,请确定填写是否正确或者勾选新供应商";
model.Supplier = SId;
}
// model.Solid = 1;
model.CompanyId = CompanyId;
model.InDate = DateTime.Now;
if (model.GoodsId > 0)
model.UpdateDate = DateTime.Now;
// if (model.GoodsId == 0)
// model.SortName = obj.GetGoodsSortName(model.SortId.Value);
string goodEg = model.GoodsCode.Substring(0, 3);
string goodNo = model.GoodsCode.Substring(3, model.GoodsCode.Length - 3);
try
{
model.GoodsEg = goodEg;
model.GoodsNo = Convert.ToInt32(goodNo);
}
catch
{
}
if (model.UpdateName != null)
{
if (!model.UpdateName.Contains(Session["Name"].ToString()))
model.UpdateName = model.UpdateName + ";" + Session["Name"].ToString();
}
else
{
model.UpdateName = Session["Name"].ToString();
}
int GoodsId = DataNew.SaveGoodsInfoForTMNew(model);
if (DetailList != null)
{
foreach (var md in DetailList)
{
md.GoodsId = GoodsId;
if (md.GoodsInNum == null)
md.GoodsInNum = 0;
if (md.GoodsLockNum == null)
md.GoodsLockNum = 0;
if (md.GoodsOutNum == null)
md.GoodsOutNum = 0;
if (md.GoodsPlanNum == null)
md.GoodsPlanNum = 0;
md.PostPrice = model.PostPrice;
if (md.Weight == null)
md.Weight = model.Weight;
md.Solid = 1;
int DetailId = DataNew.SaveGoodsDetail(md);
DataNew.Delete_CFSKU(DetailId);//删除拆分sku
if (md.SKU14 != null && md.SKU14 != "")//拆分sku
{
md.SKU14 = md.SKU14.Replace("", ",").Trim(',');
string[] sks = md.SKU14.Split(',');
for (int m = 0; m < sks.Length; m++)
{
DataNew.Save_CFSKU(DetailId, sks[m].Trim(), Session["Name"].ToString());
}
}
if (md.GoodsPostion != null)
{
for (int i = 0; i < md.GoodsPostion.Count; i++)
{
md.GoodsPostion[i].DetailId = DetailId;
md.GoodsPostion[i].ChaseId = 0;
md.GoodsPostion[i].InDate = DateTime.Now;
md.GoodsPostion[i].InUserId = Convert.ToInt32(Session["UserId"]);
md.GoodsPostion[i].Price = md.Price;
md.GoodsPostion[i].PostPrice = model.PostPrice;
md.GoodsPostion[i].GoodsLockNum = 0;
obj.SaveGoodsInListNew(md.GoodsPostion[i]);
}
}
}
}
PagesNew.SaveLog(InUserId, "货物信息", "修改货物信息", GoodsId);
if (LinkList != null)
{
foreach (var md in LinkList)
{
md.GoodsId = GoodsId;
DataNew.SaveBuyLink(md);
}
}
//obj.DeleteShop(GoodsId);
string InName = Convert.ToString(Session["Name"]);
string Ids = "";
if (shoplist != null)
{
foreach (var md1 in shoplist)
{
md1.GoodsId = GoodsId;
md1.InName = InName;
int Id = DataNew.SaveShopForTM(md1);
Ids += Id.ToString() + ",";
}
}
DataNew.DeleteShopForTM(Ids.Trim(','), GoodsId, InName);
return GoodsId.ToString();
}
catch (Exception ex)
{
return ex.Message;
}
}
#endregion
#region 货物model
[WebMethod(EnableSession = true)]
public HW_GoodsNew GetGoodsInfoModelForTM(int GoodsId)
{
PagesNew.Login(this.Session);
var obj = new HuoWuData();
int CompanyId = Convert.ToInt32(Session["CompanyId"]);
var Model = DataNew.GetGoodsModelNew(GoodsId);
var obj1 = new BaseService();
//var list = obj1.GetSupplierListFromGoods(CompanyId, GoodsId);
//string sname = "";
//if (list != null)
//{
// foreach (var md in list)
// {
// sname += md.SupplierName + ",";
// }
//}
//Model.SupplierList = list;
//Model.SupplierId = sname.Trim(',');
if (Model.GoodsImageIds != null && Model.GoodsImageIds != "")
Model.ImgList = obj1.GetResourceList(Model.GoodsImageIds);
return Model;
}
#endregion
#region 查询货物sku
[WebMethod(EnableSession = true)]
public void UpdateGoodsDays()
{
DataNew.UpdateGoodsDays();
}
#endregion
#region 查询货物sku
[WebMethod(EnableSession = true)]
public void UpdateGoodsFees()
{
DataNew.UpdateGoodsFees();
}
#endregion
#region 查询货物sku
[WebMethod(EnableSession = true)]
public List<HW_GoodsUserNew> GetGoodsUser2(int Type,int UserId, DateTime? SDate,DateTime? EDate)
{
var obj = new HuoWuData();
int CompanyId = Convert.ToInt32(Session["CompanyId"]);
var list = DataNew.GetListGoodsUser2(Type,UserId, SDate, EDate);
return list;
}
#endregion
#region 导入货物
[WebMethod(EnableSession = true)]
public string ExcelSaveGoodsHWC(string FileName, string SortName, int CompanyId)
{
PagesNew.Login(this.Session);
if (string.IsNullOrEmpty(FileName) == true) return "要导入的文件路径不能为空";
string ServerFileName = AppDomain.CurrentDomain.BaseDirectory + FileName;
if (System.IO.File.Exists(ServerFileName) == false) return "要导入的文件路径不存在";
//int CompanyId = Convert.ToInt32(Session["CompanyId"]);
try
{
MicrosoftExcel excel = new MicrosoftExcel();
DataTable tb = excel.ImportExcel(ServerFileName);
string error = "";
if (tb.Columns.Contains("货物编号") == false) { error = error + "导入模板的 货物编号 列不存在"; }
if (tb.Columns.Contains("报关名称") == false) { error = error + "导入模板的 报关名称 列不存在"; }
if (tb.Columns.Contains("体积(立方)") == false) { error = error + "导入模板的 体积(立方) 列不存在"; }
//if (tb.Columns.Contains("单价") == false) { error = error + "导入模板的 单价 列不存在"; }
//if (tb.Columns.Contains("重量(克)") == false) { error = error + "导入模板的 重量(克) 列不存在"; }
//if (tb.Columns.Contains("入库数量") == false) { error = error + "导入模板的 入库数量 列不存在"; }
if (string.IsNullOrEmpty(error) == false) return error + ";请重新下载模板导入";
HuoWuData obj = new HuoWuData();
int UserId = Convert.ToInt32(Session["UserId"]);
int Num = 0;
for (int i = 0; i < tb.Rows.Count; i++)
{
var md = new HW_GoodsExcelModel2();
md.GoodsCode = tb.Rows[i]["货物编号"].ToString().Trim();
if (md.GoodsCode == "")
{
// error += "第" + (i + 2).ToString() + " 行的货物编号没填<br/>";
continue;
}
md.GoodsName = tb.Rows[i]["报关名称"].ToString().Trim();
if (md.GoodsName == "")
{
md.GoodsName = md.GoodsCode;
// error += "第" + (i + 2).ToString() + " 行的货物名称没填<br/>";
// continue;
}
md.SortName1 = SortName;
md.SortId = 0;
md.SKU1 = "";
md.SKU2 = "";
md.SKU3 = "";
md.SKU4 = "";
md.SKU1 = tb.Rows[i]["SKU"].ToString().Trim();
if (tb.Columns.Contains("SKU2") == true)
md.SKU2 = tb.Rows[i]["SKU2"].ToString().Trim();
if (tb.Columns.Contains("SKU3") == true)
md.SKU3 = tb.Rows[i]["SKU3"].ToString().Trim();
if (tb.Columns.Contains("SKU4") == true)
md.SKU4 = tb.Rows[i]["SKU4"].ToString().Trim();
md.GoodsEngLishName = tb.Rows[i]["报关英文名"].ToString().Trim().Replace(",", "");
if (md.GoodsEngLishName == "")
md.GoodsEngLishName = "Goods";
if (md.GoodsEngLishName.Length > 20)
md.GoodsEngLishName = md.GoodsEngLishName.Substring(0, 20);
//md.Link1 = tb.Rows[i]["购买链接1"].ToString().Trim();
//md.LinkName1 = tb.Rows[i]["购买链接1名称"].ToString().Trim();
//md.Link2 = tb.Rows[i]["购买链接2"].ToString().Trim();
//md.LinkName2 = tb.Rows[i]["购买链接2名称"].ToString().Trim();
//md.Link3 = tb.Rows[i]["购买链接3"].ToString().Trim();
//md.LinkName3 = tb.Rows[i]["购买链接3名称"].ToString().Trim();
//md.Link4 = tb.Rows[i]["购买链接4"].ToString().Trim();
//md.LinkName4 = tb.Rows[i]["购买链接4名称"].ToString().Trim();
try
{
if (tb.Rows[i]["进价"].ToString().Trim() != "")
md.Price = Convert.ToDecimal(tb.Rows[i]["进价"].ToString().Trim());
}
catch (Exception ex)
{
// error += "第" + (i + 2).ToString() + " 行的单价必须是数字<br/>";
md.Price = 0;
}
if (tb.Rows[i]["重量(克)"].ToString().Trim() == "")
{
md.Weight = 0;
md.Weight2 = 0;
}
else
{
try
{
md.Weight = Convert.ToDecimal(tb.Rows[i]["重量(克)"].ToString().Trim());
md.Weight2 = md.Weight * Convert.ToDecimal(0.035274);
}
catch (Exception ex)
{
// error += "第" + (i + 2).ToString() + " 行的重量(克)必须是数字<br/>";
// continue;
}
}
if (tb.Rows[i]["长(英寸)"].ToString().Trim() == "")
{
md.Long = 0;
}
else
{
try
{
md.Long = Convert.ToDecimal(tb.Rows[i]["长(英寸)"].ToString().Trim());
}
catch (Exception ex)
{
// error += "第" + (i + 2).ToString() + " 行的重量(克)必须是数字<br/>";
// continue;
}
}
if (tb.Rows[i]["宽(英寸)"].ToString().Trim() == "")
{
md.Width = 0;
}
else
{
try
{
md.Width = Convert.ToDecimal(tb.Rows[i]["宽(英寸)"].ToString().Trim());
}
catch (Exception ex)
{
// error += "第" + (i + 2).ToString() + " 行的重量(克)必须是数字<br/>";
// continue;
}
}
if (tb.Rows[i]["高(英寸)"].ToString().Trim() == "")
{
md.Height = 0;
}
else
{
try
{
md.Height = Convert.ToDecimal(tb.Rows[i]["高(英寸)"].ToString().Trim());
}
catch (Exception ex)
{
// error += "第" + (i + 2).ToString() + " 行的重量(克)必须是数字<br/>";
// continue;
}
}
if (tb.Rows[i]["体积(立方)"].ToString().Trim() == "")
{
md.Solid = 0;
if(md.Long>0&&md.Height>0&&md.Width>0)
md.Solid = md.Long * md.Height * md.Weight * Convert.ToDecimal(0.0283168);
}
else
{
try
{
md.Solid = Convert.ToDecimal(tb.Rows[i]["体积(立方)"].ToString().Trim());
}
catch (Exception ex)
{
// error += "第" + (i + 2).ToString() + " 行的重量(克)必须是数字<br/>";
// continue;
}
}
md.CompanyId = CompanyId;
md.InUserId = UserId;
md.GoodsEg = md.GoodsCode;
md.GoodsNo = 0;
md.GoodsNum = 0;
md.TypeDesc = tb.Rows[i]["描述"].ToString().Trim();
if (tb.Rows[i]["图片"].ToString().Trim() != "")
md.ImgUrl = "../attached/hwc" + CompanyId.ToString() + "/" + tb.Rows[i]["图片"].ToString().Trim();
int a = DataNew.ExcelSaveGoodsHWC(md);
if (a == 2)
{
error += "第" + (i + 2).ToString() + " 行的SKU已经存在<br/>";
continue;
}
else
Num++;
}
if (error == "")
{
error = "数据导入成功;" + Num.ToString() + "条";
}
else
{
error += "其它数据导入成功;";
}
return error;
}
catch (Exception e)
{
return "文件导入失败!请确定模板格式是否正确,或者重新下载模板,填写数据,重新导入!!!" + e.Message;
}
return "导入成功";
}
#endregion
#region 导入货物入库
[WebMethod(EnableSession = true)]
public string ExcelSaveGoodsRKHWC(string FileName, int CompanyId)
{
PagesNew.Login(this.Session);
if (string.IsNullOrEmpty(FileName) == true) return "要导入的文件路径不能为空";
string ServerFileName = AppDomain.CurrentDomain.BaseDirectory + FileName;
if (System.IO.File.Exists(ServerFileName) == false) return "要导入的文件路径不存在";
// int CompanyId = Convert.ToInt32(Session["CompanyId"]);
try
{
MicrosoftExcel excel = new MicrosoftExcel();
DataTable tb = excel.ImportExcel(ServerFileName);
string error = "";
if (tb.Columns.Contains("SKU") == false) { error = error + "导入模板的 SKU 列不存在"; }
if (tb.Columns.Contains("入库数量") == false) { error = error + "导入模板的 入库数量 列不存在"; }
if (tb.Columns.Contains("库位") == false) { error = error + "导入模板的 库位 列不存在"; }
//if (tb.Columns.Contains("单价") == false) { error = error + "导入模板的 单价 列不存在"; }
//if (tb.Columns.Contains("重量(克)") == false) { error = error + "导入模板的 重量(克) 列不存在"; }
if (tb.Columns.Contains("入库日期") == false) { error = error + "导入模板的 入库日期 列不存在"; }
if (string.IsNullOrEmpty(error) == false) return error + ";请重新下载模板导入";
HuoWuData obj = new HuoWuData();
int UserId = Convert.ToInt32(Session["UserId"]);
int Num = 0;
HW_GoodsInRecord model = new HW_GoodsInRecord();
model.CompanyId = CompanyId;
model.InDate = DateTime.Now;
model.InUserId = UserId;
model.InNum = 0;
model.IsDelete = 0;
model.ChaseId = 0;
var InId = obj.SaveGoodsInRecordForTM(model);
DateTime? st = null;
for (int i = 0; i < tb.Rows.Count; i++)
{
var md = new HW_GoodsInDetailHWC();
md.SKU = tb.Rows[i]["SKU"].ToString().Trim();
if (md.SKU == "")
{
// error += "第" + (i + 2).ToString() + " 行的SKU没填<br/>";
continue;
}
md.PostionCode = tb.Rows[i]["库位"].ToString().Trim();
DateTime InDate = DateTime.Now;
try
{
if (tb.Rows[i]["入库日期"].ToString().Trim() != "")
md.InDate = Convert.ToDateTime(tb.Rows[i]["入库日期"].ToString().Trim());
}
catch (Exception ex)
{
error += "第" + (i + 2).ToString() + " 行的入库日期格式不正确<br/>";
md.InDate = InDate;
}
try
{
if (tb.Rows[i]["入库数量"].ToString().Trim() != "")
md.KCNum = Convert.ToInt32(tb.Rows[i]["入库数量"].ToString().Trim());
}
catch (Exception ex)
{
error += "第" + (i + 2).ToString() + " 行的入库数量必须是数字<br/>";
md.KCNum = 0;
}
if (tb.Rows[i]["单价"].ToString().Trim() == "")
{
md.Price = 0;
}
else
{
try
{
md.Price = Convert.ToDecimal(tb.Rows[i]["单价"].ToString().Trim());
}
catch (Exception ex)
{
md.Price = 0;
// error += "第" + (i + 2).ToString() + " 行的重量(克)必须是数字<br/>";
// continue;
}
}
HW_GoodsInRK rmd = new HW_GoodsInRK();
rmd.InId = InId;
int rkid = obj.SaveInRecordDetail(rmd);
md.OrderGoodsId = 0;
md.ChaseId = 0;
md.CKDetailId = 0;
md.RKDetailId = rkid;
md.CompanyId = CompanyId;
md.InUserId = UserId;
md.DetailId = 0;
md.PostionId = 0;
md.OldNum = md.KCNum;
md.PostPrice = 0;
md.InDate = md.InDate;
md.HWCFee = 0;
int a = obj.Save_GoodsInDetailHWC(md);
if (a == -1)
{
error += "第" + (i + 2).ToString() + " 行的sku不存在<br/>";
continue;
}
else
if (a == -2)
{
error += "第" + (i + 2).ToString() + " 行的入库库位不存在<br/>";
continue;
}
else
{
Num++;
if (st != null && md.InDate != st)
{
DataNew.SumInDoFee(st.Value, CompanyId);
}
st = md.InDate;
}
}
if (st != null)
{
DataNew.SumInDoFee(st.Value, CompanyId);
}
if (error == "")
{
error = "数据导入成功;" + Num.ToString() + "条";
}
else
{
error += "其它数据导入成功;";
}
DataNew.SumKC(CompanyId);//库存合计
return error;
}
catch (Exception e)
{
return "文件导入失败!请确定模板格式是否正确,或者重新下载模板,填写数据,重新导入!!!" + e.Message;
}
return "导入成功";
}
#endregion
#region 保存货物
[WebMethod(EnableSession = true)]
public string SaveGoodsForHWC(int CompanyId,HW_Goods model, List<HW_GoodsDetail> DetailList, List<HW_BuyLink> LinkList, List<HW_Shop> shoplist)
{
try
{
PagesNew.Login(this.Session);
// int CompanyId = Convert.ToInt32(Session["CompanyId"]);
int InUserId = Convert.ToInt32(Session["UserId"]);
var obj = new HuoWuData();
if (model.GoodsId == null)
model.GoodsId = 0;
//if (model.XPId > 0 && model.GoodsId == 0)
//{
// if (obj.IsGoodsXP(model.XPId.Value) > 0)
// return "-1";//"这个选品货物已经加过编号,不能重复添加";
//}
if (model.GoodsId == 0 && obj.IsGoodsCode(CompanyId, model.GoodsId.Value, model.GoodsCode) > 0)
{
return "-2";//"这个货物编号已经存在";
}
if (model.SupplierId.Trim() != "")
{
int SId = BaseService.GetSupplierIdForTM(CompanyId, model.SupplierId.Trim(), model.IsGYS.Value, InUserId);
if (SId == 0)
return "-3";//"供应商名字不存在,请确定填写是否正确或者勾选新供应商";
model.Supplier = SId;
}
// model.Solid = 1;
model.CompanyId = CompanyId;
model.InDate = DateTime.Now;
if (model.GoodsId > 0)
model.UpdateDate = DateTime.Now;
// if (model.GoodsId == 0)
// model.SortName = obj.GetGoodsSortName(model.SortId.Value);
string goodEg = model.GoodsCode.Substring(0, 3);
string goodNo = model.GoodsCode.Substring(3, model.GoodsCode.Length - 3);
try
{
model.GoodsEg = goodEg;
model.GoodsNo = Convert.ToInt32(goodNo);
}
catch
{
}
if (model.UpdateName != null)
{
if (!model.UpdateName.Contains(Session["Name"].ToString()))
model.UpdateName = model.UpdateName + ";" + Session["Name"].ToString();
}
else
{
model.UpdateName = Session["Name"].ToString();
}
int GoodsId = obj.SaveGoodsInfoForHWC(model);
if (DetailList != null)
{
foreach (var md in DetailList)
{
md.GoodsId = GoodsId;
if (md.GoodsInNum == null)
md.GoodsInNum = 0;
if (md.GoodsLockNum == null)
md.GoodsLockNum = 0;
if (md.GoodsOutNum == null)
md.GoodsOutNum = 0;
if (md.GoodsPlanNum == null)
md.GoodsPlanNum = 0;
md.PostPrice = model.PostPrice;
if (md.Weight == null)
md.Weight = model.Weight;
md.Solid = 1;
int DetailId = obj.SaveGoodsDetail(md);
if (md.GoodsPostion != null)
{
for (int i = 0; i < md.GoodsPostion.Count; i++)
{
md.GoodsPostion[i].DetailId = DetailId;
md.GoodsPostion[i].ChaseId = 0;
md.GoodsPostion[i].InDate = DateTime.Now;
md.GoodsPostion[i].InUserId = Convert.ToInt32(Session["UserId"]);
md.GoodsPostion[i].Price = md.Price;
md.GoodsPostion[i].PostPrice = model.PostPrice;
md.GoodsPostion[i].GoodsLockNum = 0;
obj.SaveGoodsInListNew(md.GoodsPostion[i]);
}
}
}
}
PagesNew.SaveLog(InUserId, "货物信息", "修改货物信息", GoodsId);
if (LinkList != null)
{
foreach (var md in LinkList)
{
md.GoodsId = GoodsId;
obj.SaveBuyLink(md);
}
}
//obj.DeleteShop(GoodsId);
string InName = Convert.ToString(Session["Name"]);
string Ids = "";
if (shoplist != null)
{
foreach (var md1 in shoplist)
{
md1.GoodsId = GoodsId;
md1.InName = InName;
int Id = obj.SaveShopForTM(md1);
Ids += Id.ToString() + ",";
}
}
obj.DeleteShopForTM(Ids.Trim(','), GoodsId);
return GoodsId.ToString();
}
catch (Exception ex)
{
return ex.Message;
}
}
#endregion
#region 刷新库存
[WebMethod(EnableSession = true)]
public void UpdateGoodsNum(int GoodsId)
{
PagesNew.Login(this.Session);
var obj = new HuoWuData();
DataNew.UpdateGoodsNumHWC(GoodsId);
}
#endregion
#region 保存分类
[WebMethod(EnableSession = true)]
public int SaveGoodsSort(HW_GoodsSortModel model)
{
PagesNew.Login(this.Session);
int CompanyId = Convert.ToInt32(Session["CompanyId"]);
var obj = new HuoWuData();
model.CompanyId = CompanyId;
if (model.ParentId > 0)
{
model.SortCode = model.SortCode.ToUpper();
var md = obj.GetSortModelModel(model.ParentId.Value);
if (md != null)
{
model.Layer = md.Layer + 1;
model.ParentCode = md.EnglishCode + md.ParentCode;
model.EnglishCode = model.SortCode;
model.ParentSort = md.SortNo;
}
}
int Pid = 0;
if (model.ParentId != null)
Pid = model.ParentId.Value;
//if (obj.IsGoodsEgCode(CompanyId, model.SortId.Value, model.EnglishCode, Pid) > 0)
//{
// return -1;
//}
model.SortNo = model.SortNo.PadLeft(3, '0');
int SortId = obj.SaveGoodsSort(model);
return 0;
}
#endregion
#region 导入运费
[WebMethod(EnableSession = true)]
public string ExcelSavePostFeeHWC(int CompanyId, int IsFG, string FileName)
{
PagesNew.Login(this.Session);
if (string.IsNullOrEmpty(FileName) == true) return "要导入的文件路径不能为空";
string ServerFileName = AppDomain.CurrentDomain.BaseDirectory + FileName;
if (System.IO.File.Exists(ServerFileName) == false) return "要导入的文件路径不存在";
// int CompanyId = Convert.ToInt32(Session["CompanyId"]);
try
{
MicrosoftExcel excel = new MicrosoftExcel();
DataTable tb = excel.ImportExcel(ServerFileName);
string error = "";
if (tb.Columns.Contains("Express or Ground Tracking ID") == false) { error = error + "导入模板的 Express or Ground Tracking ID 列不存在"; }
if (tb.Columns.Contains("Net Charge Amount") == false) { error = error + "导入模板的 Net Charge Amount 列不存在"; }
if (tb.Columns.Contains("Ground Tracking ID Prefix") == false) { error = error + "导入模板的 Ground Tracking ID Prefix 列不存在"; }
if (string.IsNullOrEmpty(error) == false) return error + ";请重新下载模板导入";
HuoWuData obj = new HuoWuData();
int UserId = Convert.ToInt32(Session["UserId"]);
int Count = 0;
int Count2 = 0;
string trinfo = "";
for (int i = 0; i < tb.Rows.Count; i++)
{
string TrackCode = tb.Rows[i]["Ground Tracking ID Prefix"].ToString().Trim() + tb.Rows[i]["Express or Ground Tracking ID"].ToString().Trim();
if (tb.Rows[i]["Net Charge Amount"].ToString().Trim() == "" || TrackCode == "")
continue;
decimal PostFee = 0;
try
{
PostFee = Convert.ToDecimal(tb.Rows[i]["Net Charge Amount"].ToString().Trim());
}
catch (Exception ex)
{
continue;
}
if (IsFG == 1)
DataNew.ImportTrackCodeClear(TrackCode);
int a = DataNew.ImportTrackCodeNew(TrackCode, PostFee, 0);
if (a > 0)
{
Count++;
}
else
{
Count2++;
trinfo += tb.Rows[i]["Express or Ground Tracking ID"].ToString().Trim() + "\r\n";
}
}
DataNew.SumPostFee(CompanyId);
error = "导入成功" + Count.ToString() + "条";
if (Count2 > 0)
error += Count2 + "条数据运单号在系统找不对到\r\n" + trinfo;
return error;
}
catch (Exception e)
{
return "文件导入失败!请确定模板格式是否正确,或者重新下载模板,填写数据,重新导入!!!" + e.Message;
}
return "导入成功";
}
#endregion
#region 导入运费
[WebMethod(EnableSession = true)]
public string ExcelSavePostFeeHWC2(int CompanyId, int IsFG, string FileName)
{
PagesNew.Login(this.Session);
if (string.IsNullOrEmpty(FileName) == true) return "要导入的文件路径不能为空";
string ServerFileName = AppDomain.CurrentDomain.BaseDirectory + FileName;
if (System.IO.File.Exists(ServerFileName) == false) return "要导入的文件路径不存在";
//int CompanyId = Convert.ToInt32(Session["CompanyId"]);
try
{
MicrosoftExcel excel = new MicrosoftExcel();
DataTable tb = excel.ImportExcel(ServerFileName);
string error = "";
if (tb.Columns.Contains("order id") == false) { error = error + "导入模板的 order id 列不存在"; }
if (tb.Columns.Contains("fba fees") == false) { error = error + "导入模板的 fba fees 列不存在"; }
if (string.IsNullOrEmpty(error) == false) return error + ";请重新下载模板导入";
HuoWuData obj = new HuoWuData();
int UserId = Convert.ToInt32(Session["UserId"]);
int Count = 0;
int Count2 = 0;
string trinfo = "";
for (int i = 0; i < tb.Rows.Count; i++)
{
string ordercode = tb.Rows[i]["order id"].ToString().Trim();
if (tb.Rows[i]["fba fees"].ToString().Trim() == "" || ordercode == "")
continue;
decimal PostFee = 0;
try
{
PostFee = Convert.ToDecimal(tb.Rows[i]["fba fees"].ToString().Trim());
}
catch (Exception ex)
{
continue;
}
if (PostFee < 0)
PostFee = PostFee * -1;
if (IsFG == 1)
DataNew.ImportTrackCode2Clear(ordercode);
string TrackCode = "FBA" + DateTime.Now.ToString("yyyyMMddHHmm") + i.ToString();
int a = DataNew.ImportTrackCode2(ordercode, TrackCode, PostFee);
if (a > 0)
{
Count++;
}
else
{
Count2++;
trinfo += ordercode + "\r\n";
}
}
error = "导入成功" + Count.ToString() + "条";
DataNew.SumPostFee(CompanyId);
if (Count2 > 0)
error += Count2 + "条数据订单在系统找不对到\r\n" + trinfo;
return error;
}
catch (Exception e)
{
return "文件导入失败!请确定模板格式是否正确,或者重新下载模板,填写数据,重新导入!!!" + e.Message;
}
return "导入成功";
}
#endregion
#region 导入运费
[WebMethod(EnableSession = true)]
public string ExcelSavePostFeeHWC3(int CompanyId, int IsFG, string FileName, int PostId)
{
PagesNew.Login(this.Session);
if (string.IsNullOrEmpty(FileName) == true) return "要导入的文件路径不能为空";
string ServerFileName = AppDomain.CurrentDomain.BaseDirectory + FileName;
if (System.IO.File.Exists(ServerFileName) == false) return "要导入的文件路径不存在";
// int CompanyId = Convert.ToInt32(Session["CompanyId"]);
string Name = Convert.ToString(Session["Name"]);
try
{
MicrosoftExcel excel = new MicrosoftExcel();
DataTable tb = excel.ImportExcel(ServerFileName);
string error = "";
if (tb.Columns.Contains("订单号") == false) { error = error + "导入模板的 订单号 列不存在"; }
if (tb.Columns.Contains("跟踪码") == false) { error = error + "导入模板的 跟踪码 列不存在"; }
if (string.IsNullOrEmpty(error) == false) return error + ";请重新下载模板导入";
HuoWuData obj = new HuoWuData();
int UserId = Convert.ToInt32(Session["UserId"]);
int Count = 0;
int Count2 = 0;
string trinfo = "";
for (int i = 0; i < tb.Rows.Count; i++)
{
string ordercode = tb.Rows[i]["订单号"].ToString().Trim();
if (tb.Rows[i]["跟踪码"].ToString().Trim() == "" || ordercode == "")
continue;
string trackcode = tb.Rows[i]["跟踪码"].ToString().Trim();
if (IsFG == 1)
obj.ImportTrackCode3Clear(ordercode);
int a = obj.ImportTrackCode3(PostId, ordercode, trackcode, Name);
if (a > 0)
{
Count++;
}
else
{
Count2++;
trinfo += ordercode + "\r\n";
}
}
error = "导入成功" + Count.ToString() + "条";
if (Count2 > 0)
error += Count2 + "条数据订单在系统找不对到\r\n" + trinfo;
return error;
}
catch (Exception e)
{
return "文件导入失败!请确定模板格式是否正确,或者重新下载模板,填写数据,重新导入!!!" + e.Message;
}
return "导入成功";
}
#endregion
#region 导入订单跟踪码
[WebMethod(EnableSession = true)]
public string ExcelSavePostFee3(int IsFG, string FileName, int PostId)
{
Pages.Login(this.Session);
if (string.IsNullOrEmpty(FileName) == true) return "要导入的文件路径不能为空";
string ServerFileName = AppDomain.CurrentDomain.BaseDirectory + FileName;
if (System.IO.File.Exists(ServerFileName) == false) return "要导入的文件路径不存在";
int CompanyId = Convert.ToInt32(Session["CompanyId"]);
string Name = Convert.ToString(Session["Name"]);
try
{
MicrosoftExcel excel = new MicrosoftExcel();
DataTable tb = excel.ImportExcel(ServerFileName);
string error = "";
if (tb.Columns.Contains("订单号") == false) { error = error + "导入模板的 订单号 列不存在"; }
if (tb.Columns.Contains("跟踪码") == false) { error = error + "导入模板的 跟踪码 列不存在"; }
if (tb.Columns.Contains("SKU") == false) { error = error + "导入模板的 SKU 列不存在"; }
if (string.IsNullOrEmpty(error) == false) return error + ";请重新下载模板导入";
HuoWuData obj = new HuoWuData();
int UserId = Convert.ToInt32(Session["UserId"]);
int Count = 0;
int Count2 = 0;
string trinfo = "";
for (int i = 0; i < tb.Rows.Count; i++)
{
if (string.IsNullOrEmpty(tb.Rows[i]["订单号"].ToString().Trim()))
{
return "第" + (i + 1).ToString() + "行订单号为空";
}
if (string.IsNullOrEmpty(tb.Rows[i]["跟踪码"].ToString().Trim()))
{
return "第" + (i + 1).ToString() + "行跟踪码为空";
}
if (string.IsNullOrEmpty(tb.Rows[i]["SKU"].ToString().Trim()))
{
return "第" + (i + 1).ToString() + "行SKU为空";
}
//导入之前先判断这个SKU是否在erp中存在
var skuStr = tb.Rows[i]["SKU"].ToString().Trim();
var sku = skuStr.Split('x')[1];
var hwDetail = DataNew.GetHWGoodsDetailBySKU(sku);
if (hwDetail == null)
{
return "第" + (i + 1).ToString() + "行SKU:" + sku + "在系统中未找到";
}
}
for (int i = 0; i < tb.Rows.Count; i++)
{
string ordercode = tb.Rows[i]["订单号"].ToString().Trim();
if (tb.Rows[i]["跟踪码"].ToString().Trim() == "" || ordercode == "")
continue;
string trackcode = tb.Rows[i]["跟踪码"].ToString().Trim();
if (tb.Rows[i]["SKU"].ToString().Trim() == "")
continue;
//var sku = tb.Rows[i]["SKU"].ToString().Trim();
var skuStr = tb.Rows[i]["SKU"].ToString().Trim();
var newsku = "";
var qty = skuStr.Split('x')[0];
var sku = skuStr.Split('x')[1];
var hwDetail = DataNew.GetHWGoodsDetailBySKU(sku);
if (hwDetail == null)
{
return "第" + (i + 1).ToString() + "行SKU:" + sku + "在系统中未找到";
}
else
{
if(hwDetail.GoodsId== 5527)//组合商品SKU对应SKU14
{
if (string.IsNullOrEmpty(hwDetail.SKU14))
return "第" + (i + 1).ToString() + "行SKU:" + hwDetail.SKU1 + "的组合SKU为空";
var skuarr = hwDetail.SKU14.Split(',');
foreach (var _sku in skuarr)
{
newsku += qty + "x" + _sku + "+";
}
newsku = newsku.TrimEnd('+');
}
else
{
newsku += (qty + "x" + hwDetail.SKU1);//导入时统一转化成货物的SKU1
}
}
if (IsFG == 1)
obj.ImportTrackCode3Clear(ordercode);
int a = DataNew.ImportTrackCode3(PostId, ordercode, trackcode, Name, newsku);
if (a > 0)
{
Count++;
}
else
{
Count2++;
trinfo += ordercode + "\r\n";
}
}
error = "导入成功" + Count.ToString() + "条";
if (Count2 > 0)
error += Count2 + "条数据订单在系统找不对到\r\n" + trinfo;
return error;
}
catch (Exception e)
{
return "文件导入失败!请确定模板格式是否正确,或者重新下载模板,填写数据,重新导入!!!" + e.Message;
}
return "导入成功";
}
#endregion
#region 货物model
[WebMethod(EnableSession = true)]
public HW_Goods GetGoodsInfoModelForHWC(int GoodsId)
{
PagesNew.Login(this.Session);
var obj = new HuoWuData();
int CompanyId = Convert.ToInt32(Session["CompanyId"]);
var Model = DataNew.GetGoodsModel(GoodsId);
var obj1 = new BaseService();
if (Model.GoodsImageIds != null && Model.GoodsImageIds != "")
Model.ImgList = obj1.GetResourceList(Model.GoodsImageIds);
return Model;
}
#endregion
#region 货物model
[WebMethod(EnableSession = true)]
public void Update_GoodsSure(int GoodsId, int IsSure)
{
PagesNew.Login(this.Session);
var obj = new HuoWuData();
DataNew.Update_GoodsSure(GoodsId, IsSure);
}
#endregion
#region 货物model
[WebMethod(EnableSession = true)]
public void Update_GoodsSureList(List<HW_GoodsDetail> list, int IsSure)
{
PagesNew.Login(this.Session);
var obj = new HuoWuData();
foreach (var md in list)
{
DataNew.Update_GoodsSure(md.GoodsId.Value, IsSure);
}
}
#endregion
#region 查询货物sku
[WebMethod(EnableSession = true)]
public JsonModel<List<HW_GoodsDetail>> GetGoodsDetailList2(int CompanyId, int TJ1, int IsJQ, int StoreId, int AQNum, string Name, string Supplier, int TJ2, int SNum, int ENum, int PageIndex, int PageSize, string Sort)
{
PagesNew.Login(this.Session);
var obj = new HuoWuData();
// int CompanyId = Convert.ToInt32(Session["CompanyId"]);
RefParameterCollection Param = new RefParameterCollection();
Param.Add("b.CompanyId", "=", CompanyId, DbType.Int32);
if (AQNum == 1)
Param.Add("a.GoodsNum-a.SafeNum", "<", 0, DbType.Int32);
Param.Add("b.State", "=", 1, DbType.Int32);
if (Supplier != "")
Param.Add("b.SupplierId", "like", Supplier, DbType.String);
Name = Name.Trim();
if (Name != "" && IsJQ == 0)
{
if (TJ1 == 1)
Param.Add("b.GoodsName", "like", Name, DbType.String);
if (TJ1 == 2)
{
Param.Add("b.GoodsCode", "like", Name, DbType.String);
}
if (TJ1 == 4)
{
Param.Add("(a.SKU1", "like", Name, DbType.String);
Param.Add("a.SKU2", "like", Name, "or", DbType.String);
Param.Add("a.SKU3", "like", Name, "or", DbType.String);
Param.Add("a.SKU4", "like", Name, "or", DbType.String);
Param.Add("a.SKU5", "like", Name, "or", DbType.String);
Param.Add("a.SKU6", "like", Name, "or", DbType.String);
Param.Add("a.SKU7", "like", Name, "or", ")", DbType.String);
}
}
else
if (Name != "" && IsJQ == 1)
{
if (TJ1 == 1)
Param.Add("b.GoodsName", "=", Name, DbType.String);
if (TJ1 == 2)
{
Param.Add("b.GoodsCode", "=", Name, DbType.String);
}
if (TJ1 == 4)
{
Param.Add("(a.SKU1", "=", Name, DbType.String);
Param.Add("a.SKU2", "=", Name, "or", DbType.String);
Param.Add("a.SKU3", "=", Name, "or", DbType.String);
Param.Add("a.SKU4", "=", Name, "or", DbType.String);
Param.Add("a.SKU5", "=", Name, "or", DbType.String);
Param.Add("a.SKU6", "=", Name, "or", DbType.String);
Param.Add("a.SKU7", "=", Name, "or", ")", DbType.String);
}
}
if (TJ2 == 1)
{
if (SNum > 0)
Param.Add("a.GoodsNum", ">=", SNum, DbType.Int32);
if (ENum > 0)
Param.Add("a.GoodsNum", "<=", ENum, DbType.Int32);
}
else if (TJ2 == 2)
{
if (SNum > 0)
Param.Add("a.GoodsHJNum", ">=", SNum, DbType.Int32);
if (ENum > 0)
Param.Add("a.GoodsHJNum", "<=", ENum, DbType.Int32);
}
else if (TJ2 == 3)
{
if (SNum > 0)
Param.Add("a.GoodsHJNum2", ">=", SNum, DbType.Int32);
if (ENum > 0)
Param.Add("a.GoodsHJNum2", "<=", ENum, DbType.Int32);
}
else if (TJ2 == 4)
{
if (SNum > 0)
Param.Add("a.GoodsHJNum3", ">=", SNum, DbType.Int32);
if (ENum > 0)
Param.Add("a.GoodsHJNum3", "<=", ENum, DbType.Int32);
}
else if (TJ2 == 5)
{
if (SNum > 0)
Param.Add("a.GoodsHJNum4", ">=", SNum, DbType.Int32);
if (ENum > 0)
Param.Add("a.GoodsHJNum4", "<=", ENum, DbType.Int32);
}
JsonModel<List<HW_GoodsDetail>> resultModel = new JsonModel<List<HW_GoodsDetail>>();
int RowCount = 0;
resultModel.DataSource = DataNew.GetListHW_GoodsDetail(StoreId, Param, PageIndex, PageSize, Sort, out RowCount);
resultModel.RowCount = RowCount;
if (resultModel.DataSource != null)
{
foreach (var md in resultModel.DataSource)
{
if (md.Solid != null)
md.TotalSolid = md.Solid * md.GoodsNum;
else
md.TotalSolid = 0;
}
}
return resultModel;
}
#endregion
#region 首页编号前三
[WebMethod(EnableSession = true)]
public string GetDefaultDataForGoodsCode(int Days)
{
PagesNew.Login(this.Session);
int CompanyId = Convert.ToInt32(Session["CompanyId"]);
BaseService obj = new BaseService();
// DateTime st=new DateTime();
// st =Convert.ToDateTime("2014-04-10");
// DateTime sdate = DateTime.Today.AddDays(-1);
//DateTime sdate2 = Convert.ToDateTime(DateTime.Today.AddDays(-1).ToString("yyyy-MM-dd") + " 08:00");
//DateTime edate2 = Convert.ToDateTime(DateTime.Today.ToString("yyyy-MM-dd") + " 08:00");
DateTime sdate2 = Convert.ToDateTime(DateTime.Today.AddDays(-1).ToString("yyyy-MM-dd") + " 00:00");
DateTime edate2 = Convert.ToDateTime(DateTime.Today.ToString("yyyy-MM-dd") + " 00:00");
if (Days == 0)
{
sdate2 = Convert.ToDateTime(DateTime.Today.ToString("yyyy-MM-dd") + " 00:00");
edate2 = Convert.ToDateTime(DateTime.Today.AddDays(1).ToString("yyyy-MM-dd") + " 00:00");
}
var list = DataNew.GetDefaultDataForCode(CompanyId, sdate2, edate2);
string shtml = "";
if (list != null)
{
foreach (var md in list)
{
if (md.Num2 != null && md.Num2 != "")
shtml += "<img width='40px' height='40px' src=" + md.Num2 + " />" + md.Num1 + "销量:【" + md.Num3 + "】 ";
else
shtml += md.Num1 + " 销量:【" + md.Num3 + "】 ";
}
}
return shtml;
}
#endregion
#region 首页编号前三
[WebMethod(EnableSession = true)]
public string GetDefaultDataForGoodsCode11(int Days)
{
PagesNew.Login(this.Session);
int CompanyId = Convert.ToInt32(Session["CompanyId"]);
BaseService obj = new BaseService();
// DateTime st=new DateTime();
// st =Convert.ToDateTime("2014-04-10");
// DateTime sdate = DateTime.Today.AddDays(-1);
//DateTime sdate2 = Convert.ToDateTime(DateTime.Today.AddDays(-1).ToString("yyyy-MM-dd") + " 08:00");
//DateTime edate2 = Convert.ToDateTime(DateTime.Today.ToString("yyyy-MM-dd") + " 08:00");
DateTime sdate2 = Convert.ToDateTime(DateTime.Today.AddDays(-1).ToString("yyyy-MM-dd") + " 00:00");
DateTime edate2 = Convert.ToDateTime(DateTime.Today.ToString("yyyy-MM-dd") + " 00:00");
if (Days == 0)
{
sdate2 = Convert.ToDateTime(DateTime.Today.ToString("yyyy-MM-dd") + " 00:00");
edate2 = Convert.ToDateTime(DateTime.Today.AddDays(1).ToString("yyyy-MM-dd") + " 00:00");
}
var list = DataNew.GetDefaultDataForCode(CompanyId, sdate2, edate2);
string shtml = "";
if (list != null)
{
int i = 1;
foreach (var md in list)
{
if (md.Num2 != null && md.Num2 != "")
shtml += "<tr><td style='text-align:center'>"+i.ToString()+ "</td><td sgcode='" + md.Num1 + "'><img src=" + md.Num2 + " width ='50px' height ='50px'/> " + md.Num1 + " </td><td class='hidden-xs'>" + md.Num3.Value+ "</td></tr>";
else
shtml += "<tr><td style='text-align:center'>" + i.ToString() + "</td><td sgcode='" + md.Num1 + "'>" + md.Num1 + " </td><td class='hidden-xs'>" + md.Num3.Value+ "</td></tr>";
i++;
}
}
return shtml;
}
#endregion
#region 首页编号前三
[WebMethod(EnableSession = true)]
public string GetDefaultDataForGoodsCode2(int Days)
{
PagesNew.Login(this.Session);
int CompanyId = Convert.ToInt32(Session["CompanyId"]);
BaseService obj = new BaseService();
// DateTime st=new DateTime();
// st =Convert.ToDateTime("2014-04-10");
DateTime sdate = DateTime.Today.AddDays(-1);
DateTime sdate2 = Convert.ToDateTime(DateTime.Today.AddDays(-1).ToString("yyyy-MM-dd") + " 00:00");
DateTime edate2 = Convert.ToDateTime(DateTime.Today.ToString("yyyy-MM-dd") + " 00:00");
if (Days == 0)
{
sdate2 = Convert.ToDateTime(DateTime.Today.ToString("yyyy-MM-dd") + " 00:00");
edate2 = Convert.ToDateTime(DateTime.Today.AddDays(1).ToString("yyyy-MM-dd") + " 00:00");
}
var list2 = DataNew.GetDefaultDataForCode2(CompanyId, sdate2, edate2);
string shtml = "";
if (list2 != null)
{
foreach (var md in list2)
{
if (md.Num2 != null && md.Num2 != "")
shtml += "<img width='40px' height='40px' src=" + md.Num2 + " />" + md.Num1 + "销售额:【" + md.Num4.Value.ToString("0.00") + "$】 ";
else
shtml += md.Num1 + " 销售额:【" + md.Num4.Value.ToString("0.00") + "$】 ";
}
}
return shtml;
}
#endregion
#region 首页编号前三
[WebMethod(EnableSession = true)]
public string GetDefaultDataForGoodsCode22(int Days)
{
PagesNew.Login(this.Session);
int CompanyId = Convert.ToInt32(Session["CompanyId"]);
BaseService obj = new BaseService();
// DateTime st=new DateTime();
// st =Convert.ToDateTime("2014-04-10");
DateTime sdate = DateTime.Today.AddDays(-1);
DateTime sdate2 = Convert.ToDateTime(DateTime.Today.AddDays(-1).ToString("yyyy-MM-dd") + " 00:00");
DateTime edate2 = Convert.ToDateTime(DateTime.Today.ToString("yyyy-MM-dd") + " 00:00");
if (Days == 0)
{
sdate2 = Convert.ToDateTime(DateTime.Today.ToString("yyyy-MM-dd") + " 00:00");
edate2 = Convert.ToDateTime(DateTime.Today.AddDays(1).ToString("yyyy-MM-dd") + " 00:00");
}
var list2 = DataNew.GetDefaultDataForCode2(CompanyId, sdate2, edate2);
string shtml = "";
if (list2 != null)
{
int i = 1;
foreach (var md in list2)
{
if (md.Num2 != null && md.Num2 != "")
shtml += "<tr><td style='text-align:center'>" + i.ToString() + "</td><td sgcode='" + md.Num1 + "'><img src=" + md.Num2 + " width ='50px' height ='50px'/> " + md.Num1 + " </td><td class='hidden-xs'>" + (md.Num4.HasValue ? md.Num4.Value.ToString("0.00") : "0.00") + "$</td></tr>";
else
shtml += "<tr><td style='text-align:center'>" + i.ToString() + "</td><td sgcode='" + md.Num1 + "'>" + md.Num1 + " </td><td class='hidden-xs'>" + (md.Num4.HasValue ? md.Num4.Value.ToString("0.00") : "0.00") + "$</td></tr>";
i++;
}
}
return shtml;
}
#endregion
#region 导入货物图片
[WebMethod(EnableSession = true)]
public string ExcelPhoto(int CompanyId, string FileName)
{
try
{
string unRarPath = AppDomain.CurrentDomain.BaseDirectory + "attached/hwc" + CompanyId.ToString();
string unRarPath2 = AppDomain.CurrentDomain.BaseDirectory + "attached/rar" + CompanyId.ToString() + DateTime.Now.ToString("yyyyMMddHHmmss");
if (Directory.Exists(unRarPath) == false) Directory.CreateDirectory(unRarPath);
CustomIO.RarDecompress(unRarPath2, AppDomain.CurrentDomain.BaseDirectory + "ServerCookies", System.IO.Path.GetFileName(FileName));
List<string> ListModel = new List<string>();
CustomIO.GetListFile(unRarPath2, ListModel);
foreach (var PhotoUrl in ListModel)
{
string name = Path.GetFileName(PhotoUrl);
File.Copy(PhotoUrl, unRarPath + "/" + name, true);
}
Directory.Delete(unRarPath2, true);
string error = "数据导入成功";
return error;
}
catch (Exception e)
{
return "导入失败;" + e.Message.ToString();
}
}
#endregion
#region 影藏
[WebMethod(EnableSession = true)]
public void Update_GoodsShow(int Id, int IsYC)
{
DataNew.Update_GoodsShow(Id, IsYC);
}
#endregion
#region 货物model
[WebMethod(EnableSession = true)]
public void Update_CGGoodsNum(int DetailId, int sjout, int Num, int Num2, int pstate, string bhremark, List<HW_GoodsBFPlan> list)
{
PagesNew.Login(this.Session);
int Year = DateTime.Today.Year;
DataNew.Delete_GoodsBFPlan(Year, DetailId, sjout);
DataNew.Update_CGGoodsNum2(DetailId, Num, Num2, pstate, bhremark);
if (pstate == 3)//审批通过
{
DataNew.Update_CGGoodsNum(DetailId, Num2);
}
if (list == null)
return;
foreach (var md in list)
{
md.year = Year;
if (sjout == 1)
{
md.outdate = DateTime.Now;
md.outname = Session["Name"].ToString();
}
md.indate = DateTime.Now;
md.inname = Session["Name"].ToString();
DataNew.Save_GoodsBFPlan(md);
}
//DataNew.UpdateGoodsBFPlan(DetailId, pstate);
if (pstate == 1)
{
DataNew.SaveIOpenMess(32, "领导添加了产品需要采购,请尽快去货物信息那边确定");
}
if (pstate == 2)
{
DataNew.SaveIOpenMess(1, "采购已经确认了采购数量,请尽快去货物信息那边审批通过");
}
if (pstate == 3)
{
DataNew.SaveIOpenMess(32, "领导已经审批了你的采购,请尽快去下单采购");
}
}
#endregion
#region 货物model
[WebMethod(EnableSession = true)]
public void Update_CGGoodsNum2(int DetailId, int sjout, int Num, int Num2, int pstate, List<HW_GoodsBFPlan> list)
{
PagesNew.Login(this.Session);
int Year = DateTime.Today.Year;
DataNew.Delete_GoodsBFPlan(Year, DetailId, sjout);
if (list == null|| list.Count==0)
return;
foreach (var md in list)
{
md.year = Year;
if (sjout == 1)
{
md.outdate = DateTime.Now;
md.outname = Session["Name"].ToString();
}
md.indate = DateTime.Now;
md.inname = Session["Name"].ToString();
DataNew.Save_GoodsBFPlan(md);
}
if (pstate == 3)//审批通过
{
DataNew.delete_ProductionDetail(list[0].detailid.Value);
foreach (var md in list)
{
HW_ProductionDetail Model = new HW_ProductionDetail();
Model.mid = md.detailid;
Model.weeknum = md.cgsl;
Model.sdate = md.sdate;
Model.edate = md.edate;
Model.weekname = "Week" + md.weekno.ToString() + "【" + md.sdate.Value.ToString("yyyy-MM-dd") + "---" + md.edate.Value.ToString("yyyy-MM-dd") + "】";
DataNew.Save_ProductionDetail2(Model);
}
}
}
#endregion
#region 保存
[WebMethod(EnableSession = true)]
public int Save_GoodsBFPlan(List<HW_GoodsBFPlan> list)
{
PagesNew.Login(this.Session);
if (list == null)
return 0;
int Year = DateTime.Today.Year;
DataNew.Delete_GoodsBFPlan(Year, list[0].detailid.Value, list[0].sjout.Value);
foreach (var md in list)
{
md.year = Year;
md.indate = DateTime.Now;
md.inname = Session["Name"].ToString();
DataNew.Save_GoodsBFPlan(md);
}
return 1;
}
#endregion
#region 返回周次
[WebMethod(EnableSession = true)]
public List<HW_WeekName> GetPlanWeekList(int detailid)
{
PagesNew.Login(this.Session);
var obj = new HuoWuData();
int Year = DateTime.Today.Year;
System.DateTime fDt = DateTime.Parse(Year.ToString() + "-01-01");
int k = Convert.ToInt32(DateTime.Today.DayOfWeek);//得到该年的第一天是周几
if (k == 0)
k = 7;
DateTime sdt = DateTime.Today.AddDays(-1 * (k - 1));
DateTime ssdt = sdt.AddDays(-56);
if (ssdt > fDt)
{
k = Convert.ToInt32(fDt.DayOfWeek);//得到该年的第一天是周几
if (k == 0)
k = 7;
sdt = fDt.AddDays(-1 * (k - 1));
}
else
sdt = ssdt;
var slist = DataNew.GetListGoodsBFPlan(Year, detailid,0);
List<HW_WeekName> wlist = new List<HW_WeekName>();
// int j = 1;
for (int i = 0; i < 52; i++)
{
HW_WeekName wmd = new HW_WeekName();
//var md = GetWeekName2(sdt.AddDays(i * 7).Year, sdt.AddDays(i * 7));
wmd.SDate = sdt.AddDays(i * 7);
wmd.EDate = wmd.SDate.Value.AddDays(6);
wmd.Num = i + 1;
if (slist != null)
{
var smd = slist.Find(n => n.weekno == wmd.Num);
if (smd != null)
wmd.cgsl = smd.cgsl;
}
//if (md.SDate >= ssdt && md.SDate <= ssdt.AddDays(7))
// md.IsNow = 1;
//if (md.SDate <= DateTime.Today && md.EDate >= DateTime.Today)
// md.IsNow = 2;
wlist.Add(wmd);
}
return wlist;
}
#endregion
#region 返回周次
[WebMethod(EnableSession = true)]
public List<HW_WeekName> GetPlanWeekList2(int detailid)
{
PagesNew.Login(this.Session);
var obj = new HuoWuData();
int Year = DateTime.Today.Year;
System.DateTime fDt = DateTime.Parse(Year.ToString() + "-01-01");
int k = Convert.ToInt32(DateTime.Today.DayOfWeek);//得到该年的第一天是周几
if (k == 0)
k = 7;
DateTime sdt = DateTime.Today.AddDays(-1 * (k - 1));
DateTime ssdt = sdt.AddDays(-56);
if (ssdt > fDt)
{
k = Convert.ToInt32(fDt.DayOfWeek);//得到该年的第一天是周几
if (k == 0)
k = 7;
sdt = fDt.AddDays(-1 * (k - 1));
}
else
sdt = ssdt;
var slist = DataNew.GetListGoodsBFPlan(Year, detailid, 1);
List<HW_WeekName> wlist = new List<HW_WeekName>();
// int j = 1;
for (int i = 0; i < 52; i++)
{
HW_WeekName wmd = new HW_WeekName();
//var md = GetWeekName2(sdt.AddDays(i * 7).Year, sdt.AddDays(i * 7));
wmd.SDate = sdt.AddDays(i * 7);
wmd.EDate = wmd.SDate.Value.AddDays(6);
wmd.Num = i + 1;
if (slist != null)
{
var smd = slist.Find(n => n.weekno == wmd.Num);
if (smd != null)
{
wmd.cgsl = smd.cgsl;
wmd.remark = smd.remark;
wmd.checknote = smd.checknote;
}
}
//if (md.SDate >= ssdt && md.SDate <= ssdt.AddDays(7))
// md.IsNow = 1;
//if (md.SDate <= DateTime.Today && md.EDate >= DateTime.Today)
// md.IsNow = 2;
wlist.Add(wmd);
}
return wlist;
}
#endregion
#region 查询入库记录
[WebMethod(EnableSession = true)]
public JsonModel<List<HW_GoodsInRecord>> GetListHW_GoodsInListForTM(int TJ, string RKType, string GoodsName, DateTime? SDate, DateTime? EDate, int IsDetail, int PageIndex, int PageSize, string Sort)
{
PagesNew.Login(this.Session);
var obj = new HuoWuData();
int CompanyId = Convert.ToInt32(Session["CompanyId"]);
RefParameterCollection Param = new RefParameterCollection();
Param.Add("a.CompanyId", "=", CompanyId, DbType.Int32);
Param.Add("a.IsDelete", "=", 0, DbType.Int32);
// if (RKType == 1)
// Param.Add("a.ChaseId", ">", 0, DbType.String);
// else if (RKType == 2)
// Param.Add("a.ChaseId", "=", 0, DbType.String);
// if(RKType!="")
// Param.Add("a.InReason", "in", "'采购管理','库存调整'", DbType.String);
if (SDate != null)
Param.Add("a.InDate", ">=", SDate, DbType.DateTime);
if (EDate != null)
Param.Add("a.InDate", "<", EDate.Value.AddDays(1), DbType.DateTime);
if (TJ == 6)
{
Param.Add("a.InCode", "like", GoodsName.Trim(), DbType.String);
}
else
if (TJ == 7)
{
Param.Add("b.BuyCode", "like", GoodsName.Trim(), DbType.String);
}
JsonModel<List<HW_GoodsInRecord>> resultModel = new JsonModel<List<HW_GoodsInRecord>>();
int RowCount = 0;
if (TJ > 4)
GoodsName = "";
resultModel.DataSource = DataNew.GetListHW_GoodsInRecordForTM2(TJ, RKType.TrimEnd(','), GoodsName.Trim(), Param, PageIndex, PageSize, Sort, out RowCount);
resultModel.RowCount = RowCount;
if (IsDetail == 1 && resultModel.DataSource != null)
{
foreach (var md in resultModel.DataSource)
{
var list = obj.GetRKDetailListForTM(md.Id.Value);
md.GoodsInRecordList = list;
}
}
return resultModel;
}
#endregion
#region 查询出库记录
[WebMethod(EnableSession = true)]
public JsonModel<List<HW_GoodsOutRecord>> GetListHW_GoodsOutListForTM(int TJ, string GoodsName, DateTime? SDate, DateTime? EDate, int IsDetail, string CKType, int PageIndex, int PageSize, string Sort)
{
PagesNew.Login(this.Session);
var obj = new HuoWuData();
int CompanyId = Convert.ToInt32(Session["CompanyId"]);
RefParameterCollection Param = new RefParameterCollection();
Param.Add("a.CompanyId", "=", CompanyId, DbType.Int32);
Param.Add("a.IsDelete", "=", 0, DbType.Int32);
//if (CKType == 1)
// Param.Add("a.OrderId", ">", 0, DbType.String);
//else if (CKType == 2)
// Param.Add("a.OrderId", "=", 0, DbType.String);
if (SDate != null)
Param.Add("a.InDate", ">=", SDate, DbType.DateTime);
if (EDate != null)
Param.Add("a.InDate", "<", EDate.Value.AddDays(1), DbType.DateTime);
if (TJ == 6)
{
Param.Add("a.OutCode", "like", GoodsName.Trim(), DbType.String);
}
else
if (TJ == 7)
{
Param.Add("b.PlatOrderCode", "like", GoodsName.Trim(), DbType.String);
}
if (TJ > 4)
GoodsName = "";
JsonModel<List<HW_GoodsOutRecord>> resultModel = new JsonModel<List<HW_GoodsOutRecord>>();
int RowCount = 0;
resultModel.DataSource = DataNew.GetListHW_GoodsOutListForTM(TJ, CKType.TrimEnd(','), GoodsName, Param, PageIndex, PageSize, Sort, out RowCount);
resultModel.RowCount = RowCount;
if (IsDetail == 1 && resultModel.DataSource != null)
{
foreach (var md in resultModel.DataSource)
{
var list = obj.GetOutCKDetailListForTM(md.OutId.Value);
md.GoodsOutCKList = list;
}
}
return resultModel;
}
#endregion
#region 导出出库记录
[WebMethod(EnableSession = true)]
public APIReturnModel ImportListHW_GoodsOutListForTM(int TJ, string GoodsName, DateTime? SDate, DateTime? EDate, string CKType)
{
Pages.Login(this.Session);
var rmodel = new APIReturnModel();
try
{
var datas = DataNew.GetImportHW_GoodsOutList(TJ, CKType, GoodsName, SDate, EDate);
DataTable tb = new DataTable();
tb.Columns.Add("订单号", Type.GetType("System.String"));
tb.Columns.Add("SKU", Type.GetType("System.String"));
tb.Columns.Add("出库时间", Type.GetType("System.String"));
tb.Columns.Add("出库原因", Type.GetType("System.String"));
tb.Columns.Add("出库库位", Type.GetType("System.String"));
tb.Columns.Add("出库数量", Type.GetType("System.String"));
if (datas != null)
{
foreach (var item in datas)
{
DataRow row = tb.NewRow();
row["订单号"] = item.OrderCode;
row["SKU"] = item.SKU;
row["出库时间"] = item.InDate.HasValue ? item.InDate.Value.ToString("yyyy-MM-dd hh:mm:ss") : "";
row["出库原因"] = item.OutReason;
row["出库库位"] = item.PostionCode;
row["出库数量"] = item.OutNum.ToString();
tb.Rows.Add(row);
}
}
TableColumnCollection listColumns = new TableColumnCollection();
listColumns.Add("订单号", "订单号", DbType.String, "");
listColumns.Add("SKU", "SKU", DbType.String, "");
listColumns.Add("出库时间", "出库时间", DbType.String, "");
listColumns.Add("出库原因", "出库原因", DbType.String, "");
listColumns.Add("出库库位", "出库库位", DbType.String, "");
listColumns.Add("出库数量", "出库数量", DbType.String, "");
MicrosoftExcel obj2 = new MicrosoftExcel();
var filePath = obj2.Export(tb, listColumns);
rmodel.Code = 1;
rmodel.Message = filePath;
}
catch (Exception ex)
{
rmodel.Code = 0;
rmodel.Message = ex.Message;
}
return rmodel;
}
#endregion
#region 修改数量
[WebMethod(EnableSession = true)]
public void UpdateGoodsOutNum()
{
PagesNew.Login(this.Session);
var obj = new HuoWuData();
DataNew.UpdateGoodsOutNum();
}
#endregion
#region 刷新库存
[WebMethod(EnableSession = true)]
public void UpdateGoodsNumNew(int GoodsId)
{
PagesNew.Login(this.Session);
var obj = new HuoWuData();
DataNew.UpdateGoodsNumNew(GoodsId);
}
#endregion
#region 刷新库存
[WebMethod(EnableSession = true)]
public void UpdateGoodsNumNew2(int GoodsId)
{
PagesNew.Login(this.Session);
var obj = new HuoWuData();
DataNew.UpdateGoodsNumNew2(GoodsId);
}
#endregion
#region 计算运费
[WebMethod(EnableSession = true)]
public string GoodsFedexFee(int PostId, string RevAddr, string RevPhone, string RevCity, string RevProvinceCode, string RevPostCode, string Width, string Height, string Long, string Weight, int Num, string PostType)
{
PagesNew.Login(this.Session);
var obj = new HuoWuData();
JC_ExpressService service = new JC_ExpressService();
JC_ExpressPost expressModel = service.GetExpressModel(1, PostId);
TradeManageNew.FedexRateNew2 rate = new TradeManageNew.FedexRateNew2();
TradeManageNew.FedexRateNew2.Key = expressModel.UserCode;
TradeManageNew.FedexRateNew2.Password = expressModel.CheckCode;
TradeManageNew.FedexRateNew2.AccountNumber = expressModel.client_id;
TradeManageNew.FedexRateNew2.MeterNumber = expressModel.client_secret;
TradeManageNew.FedexRateNew2.PayAccountNumber = expressModel.refresh_token;
TradeManageNew.FedexRateNew2.HubId = expressModel.Code;
TradeManageNew.FedexFeeMdNew md = new TradeManageNew.FedexFeeMdNew();
TradeManageNew.FedexRateNew2.Addr2 = 1;
md.RevName = "jack";
md.RevPhone = RevPhone;
md.RevAddr = RevAddr;
md.RevCity = RevCity;
md.RevProv = RevProvinceCode;
md.RevPostCode = RevPostCode;
md.RevCountry = "US";
md.OrderId = 0;
md.SendAddr = "2611 E LINDSAY PRIVADO";// address.EnglishAddress;
md.SendCountry = "US";// address.countycode;
md.SendCity = "ONTARIO";// address.city;
md.SendProv = "CA";// address.provincecode;
md.SendPostCode = "91761";// address.PostCode;
//md.SendAddr = "480 W 83rd St";// address.EnglishAddress;
//md.SendCountry = "US";// address.countycode;
//md.SendCity = "Hialeah";// address.city;
//md.SendProv = "FL";// address.provincecode;
//md.SendPostCode = "33166";// address.PostCode;3 1 JIDE TOYS CORP. JIDE TOYS CORP. 2611 E LINDSAY PRIVADO 2611 E LINDSAY PRIVADO 9012637906 91761 CA ONTARIO US 315000 CA ONTARIO US NULL
if (Width != null && Width != "")
{
md.Width = (Math.Ceiling(Convert.ToDecimal(Width) * Num).ToString());
}
if (Height != null && Height != "")
{
md.Height = Math.Ceiling(Convert.ToDecimal(Height) * Num).ToString();
}
if (Long != null && Long != "")
{
md.Lenght = Math.Ceiling(Convert.ToDecimal(Long) * Num).ToString();
}
md.Weight = Convert.ToDecimal(Weight) * 0.0625M * Num;
md.PostType = PostType;// "SMART_POST";
string str = "";
string html = rate.GetFee(md, out str);
if (str != "")
return str;
return html;
}
#endregion
#region 导出库存
[WebMethod(EnableSession = true)]
public string GetList_GoodsLeftExcel(string PostionCode, string GoodsName, int StoreId)
{
var obj = new HuoWuData();
int CompanyId = Convert.ToInt32(Session["CompanyId"]);
RefParameterCollection Param = new RefParameterCollection();
if (PostionCode != "")
Param.Add("d.PostionCode", "=", PostionCode, DbType.String);
if (StoreId > 0)
Param.Add("d.StoreId", "=", StoreId, DbType.String);
if (GoodsName.Trim() != "")
{
Param.Add("(c.GoodsCode", "=", GoodsName.Trim(), DbType.String);
Param.Add("c.GoodsOldCode", "=", GoodsName.Trim(), "or", ")", DbType.String);
}
if (GoodsName.Trim().Contains(" "))
{
Param.Add("(c.GoodsCode", "=", GoodsName.Trim().Split(' ')[0].Trim(), DbType.String);
Param.Add("c.GoodsOldCode", "=", GoodsName.Trim().Split(' ')[0].Trim(), "or", ")", DbType.String);
Param.Add("b.TypeCode", "=", GoodsName.Trim().Split(' ')[1].Trim(), DbType.String);
}
string Sort = "c.GoodsCode,b.TypeCode";
DataTable tb = DataNew.GetList_GoodsLeftExcel(Param, Sort);
TableColumnCollection listColumns = new TableColumnCollection();
listColumns.Add("GoodsOldCode", "编码", DbType.String, "");
listColumns.Add("GoodsCode", "新编码", DbType.String, "");
listColumns.Add("GoodsName", "名称", DbType.String, "");
listColumns.Add("TypeCode", "型号", DbType.String, "");
listColumns.Add("TypeDesc", "规格描述", DbType.String, "");
listColumns.Add("GoodsNum", "库存数量", DbType.String, "");
listColumns.Add("LockNum", "匹配锁定数量", DbType.String, "");
listColumns.Add("LeftNum", "剩余数量", DbType.String, "");
listColumns.Add("PostionCode", "库位", DbType.String, "");
listColumns.Add("Solid", "单个立方", DbType.String, "");
listColumns.Add("Solid2", "剩余总立方", DbType.String, "");
listColumns.Add("pk", "盘库", DbType.String, "");
MicrosoftExcel obj2 = new MicrosoftExcel();
return obj2.Export(tb, listColumns);
}
#endregion
#region 保存
[WebMethod(EnableSession = true)]
public int Save_JZLink(List<HW_JZLink> list)
{
PagesNew.Login(this.Session);
if (list == null)
return 0;
foreach (var md in list)
{
DataNew.Save_JZLink(md);
}
return 1;
}
#endregion
#region 删除
[WebMethod(EnableSession = true)]
public bool Delete_JZLink(int Id)
{
PagesNew.Login(this.Session);
DataNew.Delete_JZLink(Id);
return true;
}
#endregion
#region 多条件普通查询
[WebMethod(EnableSession = true)]
public List<HW_JZLink> GetListJZLink2(int GoodsId)
{
PagesNew.Login(this.Session);
int UserId = Convert.ToInt32(Session["UserId"]);
var ListModel = DataNew.GetListJZLink(GoodsId, UserId);
return ListModel;
}
#endregion
#region 货物运费model
[WebMethod(EnableSession = true)]
public HW_PostFee GetModelPostFee(int GoodsId)
{
PagesNew.Login(this.Session);
var md = DataNew.GetModelPostFee(GoodsId);
List<JC_Money> list2 = new BaseService().GetMoneyList2();
if (md != null && list2 != null)
{
var fmd = list2.Find(n => n.PlatId == 2 && n.MCode == "USD");
if (fmd != null)
md.FeeRate = fmd.MRate;
}
return md;
}
#endregion
#region 计算运费
[WebMethod(EnableSession = true)]
public string GoodsFedexFee2(int GoodsId, string RevAddr, string RevPhone, string RevCity, string RevProvinceCode, string RevPostCode, string Width, string Height, string Long, string Weight, int Num)
{
PagesNew.Login(this.Session);
var obj = new HuoWuData();
if (Long == "" || Long == "0")
{
var gmd= DataNew.GetGoodsModelNew(GoodsId);
if (gmd != null)
{
Long =Math.Ceiling(gmd.Long.Value * 0.3937008M).ToString();
Height= Math.Ceiling(gmd.Height.Value * 0.3937008M).ToString();
Width = Math.Ceiling(gmd.Width.Value * 0.3937008M).ToString();
Weight = Math.Ceiling(gmd.Weight.Value * 0.035274M).ToString();
}
}
string str = GoodsFedexFee3(GoodsId, 237, RevAddr, RevPhone, RevCity, RevProvinceCode, RevPostCode, Width, Height, Long, Weight, Num, "SMART_POST");
string str2 = "";
string str3 = "";
string str4 = "";
string str5 = "";
if (str != "")
str2 = GoodsFedexFee3(GoodsId, 237, RevAddr, RevPhone, RevCity, RevProvinceCode, RevPostCode, Width, Height, Long, Weight, Num, "FEDEX_GROUND");
if (str2 != "")
str3 = GoodsFedexFee3(GoodsId, 237, RevAddr, RevPhone, RevCity, RevProvinceCode, RevPostCode, Width, Height, Long, Weight, Num, "GROUND_HOME_DELIVERY");
if (str3 != "")
str4 = GoodsFedexFee3(GoodsId, 228, RevAddr, RevPhone, RevCity, RevProvinceCode, RevPostCode, Width, Height, Long, Weight, Num, "SMART_POST");
if (str4 != "")
str5 = GoodsFedexFee3(GoodsId, 228, RevAddr, RevPhone, RevCity, RevProvinceCode, RevPostCode, Width, Height, Long, Weight, Num, "FEDEX_GROUND");
if (str5 != "")
GoodsFedexFee3(GoodsId, 228, RevAddr, RevPhone, RevCity, RevProvinceCode, RevPostCode, Width, Height, Long, Weight, Num, "GROUND_HOME_DELIVERY");
return "ok";
}
#endregion
#region 计算运费
[WebMethod(EnableSession = true)]
public string GoodsFedexFee3(int GoodsId, int PostId, string RevAddr, string RevPhone, string RevCity, string RevProvinceCode, string RevPostCode, string Width, string Height, string Long, string Weight, int Num, string PostType)
{
PagesNew.Login(this.Session);
var obj = new HuoWuData();
JC_ExpressService service = new JC_ExpressService();
JC_ExpressPost expressModel = service.GetExpressModel(1, PostId);
TradeManageNew.FedexRateNew2 rate = new TradeManageNew.FedexRateNew2();
TradeManageNew.FedexRateNew2.Key = expressModel.UserCode;
TradeManageNew.FedexRateNew2.Password = expressModel.CheckCode;
TradeManageNew.FedexRateNew2.AccountNumber = expressModel.client_id;
TradeManageNew.FedexRateNew2.MeterNumber = expressModel.client_secret;
TradeManageNew.FedexRateNew2.PayAccountNumber = expressModel.refresh_token;
TradeManageNew.FedexRateNew2.HubId = expressModel.Code;
TradeManageNew.FedexRateNew2.PostId = PostId;
TradeManageNew.FedexFeeMdNew md = new TradeManageNew.FedexFeeMdNew();
TradeManageNew.FedexRateNew2.Addr2 = 1;
md.OrderGoodsId = GoodsId;
md.RevName = "jack";
md.RevPhone = RevPhone;
md.RevAddr = RevAddr;
md.RevCity = RevCity;
md.RevProv = RevProvinceCode;
md.RevPostCode = RevPostCode;
md.RevCountry = "US";
md.OrderId = 0;
JC_PostAddress address = new BaseService().GetAddressModel2(PostId);
md.SendAddr = address.EnglishAddress;
md.SendAddr = address.EnglishAddress;
md.SendCountry = address.countycode;
md.SendCity = address.city;
md.SendProv = address.provincecode;
md.SendPostCode = address.PostCode;
//md.SendAddr = "2611 E LINDSAY PRIVADO";// address.EnglishAddress;
//md.SendCountry = "US";// address.countycode;
//md.SendCity = "ONTARIO";// address.city;
//md.SendProv = "CA";// address.provincecode;
//md.SendPostCode = "91761";// address.PostCode;
//md.SendAddr = "480 W 83rd St";// address.EnglishAddress;
//md.SendCountry = "US";// address.countycode;
//md.SendCity = "Hialeah";// address.city;
//md.SendProv = "FL";// address.provincecode;
//md.SendPostCode = "33166";// address.PostCode;3 1 JIDE TOYS CORP. JIDE TOYS CORP. 2611 E LINDSAY PRIVADO 2611 E LINDSAY PRIVADO 9012637906 91761 CA ONTARIO US 315000 CA ONTARIO US NULL
if (Width != null && Width != "")
{
md.Width = (Math.Ceiling(Convert.ToDecimal(Width) * Num).ToString());
}
if (Height != null && Height != "")
{
md.Height = Math.Ceiling(Convert.ToDecimal(Height) * Num).ToString();
}
if (Long != null && Long != "")
{
md.Lenght = Math.Ceiling(Convert.ToDecimal(Long) * Num).ToString();
}
md.Weight = Convert.ToDecimal(Weight) * 0.0625M * Num;
md.PostType = PostType;// "SMART_POST";
string str = "";
string html = rate.GetFee(md, out str);
if (str != "")
return str;
return html;
}
#endregion
#region 查询库存
[WebMethod(EnableSession = true)]
public JsonModel<List<HW_GoodsLeft2>> GetList_GoodsLeftPostion(string PostionCode, string GoodsName, int StoreId, int PageIndex, int PageSize)
{
var obj = new HuoWuData();
int CompanyId = Convert.ToInt32(Session["CompanyId"]);
RefParameterCollection Param = new RefParameterCollection();
// Param.Add("f.CompanyId", "=", CompanyId, DbType.Int32);
if (PostionCode != "")
Param.Add("d.PostionCode", "like", PostionCode, DbType.String);
if (StoreId > 0)
Param.Add("d.StoreId", "=", StoreId, DbType.String);
if (GoodsName.Trim() != "")
{
Param.Add("c.GoodsCode", "like", GoodsName.Trim(), DbType.String);
}
JsonModel<List<HW_GoodsLeft2>> resultModel = new JsonModel<List<HW_GoodsLeft2>>();
string Sort = "a.PostionId,a.GoodsId";
int RowCount = 0;
resultModel.DataSource = DataNew.GetList_GoodsLeftPostion(Param, PageIndex, PageSize, Sort, out RowCount);
resultModel.RowCount = RowCount;
return resultModel;
}
#endregion
#region 查询库存
[WebMethod(EnableSession = true)]
public JsonModel<List<HW_GoodsLeft>> GetList_GoodsLeftForTM(string PostionCode, string GoodsName, int StoreId, int PageIndex, int PageSize)
{
var obj = new HuoWuData();
int CompanyId = Convert.ToInt32(Session["CompanyId"]);
RefParameterCollection Param = new RefParameterCollection();
// Param.Add("f.CompanyId", "=", CompanyId, DbType.Int32);
if (PostionCode != "")
Param.Add("d.PostionCode", "=", PostionCode, DbType.String);
if (StoreId > 0)
Param.Add("d.StoreId", "=", StoreId, DbType.String);
if (GoodsName.Trim() != "")
{
Param.Add("(c.GoodsCode", "like", GoodsName.Trim(), DbType.String);
Param.Add("c.GoodsOldCode", "like", GoodsName.Trim(), "or", DbType.String);
Param.Add("b.SKU1", "like", GoodsName.Trim(), "or", ")", DbType.String);
}
JsonModel<List<HW_GoodsLeft>> resultModel = new JsonModel<List<HW_GoodsLeft>>();
string Sort = "c.GoodsCode,b.TypeCode";
int RowCount = 0;
resultModel.DataSource = obj.GetList_GoodsLeftForTM(Param, PageIndex, PageSize, Sort, out RowCount);
resultModel.RowCount = RowCount;
return resultModel;
}
#endregion
#region 返回周次
[WebMethod(EnableSession = true)]
public List<HW_WeekName> GetHW_WeekNameList3()
{
PagesNew.Login(this.Session);
var obj = new HuoWuData();
int Year = DateTime.Today.Year;
System.DateTime fDt = DateTime.Parse(Year.ToString() + "-01-01");
int k = Convert.ToInt32(fDt.DayOfWeek);//得到该年的第一天是周几
if(k==0)
k=7;
DateTime sdt=fDt.AddDays(k-1);
List<HW_WeekName> wlist = new List<HW_WeekName>();
int j = 1;
for (int i = 0; i < 54; i++)
{
HW_WeekName wmd = new HW_WeekName();
wmd.SDate = sdt.AddDays((i-1) * 7);
wmd.EDate = sdt.AddDays(i * 7);
wmd.Num = i + 1;
if (wmd.SDate <= DateTime.Today && wmd.EDate >= DateTime.Today)
wmd.IsNow = 1;
if (wmd.SDate.Value.Year > Year)
{
wmd.WeekName = "Week" + j.ToString()+"【" + wmd.SDate.Value.ToString("yyyy-MM-dd") + "----" + wmd.EDate.Value.ToString("yyyy-MM-dd")+"】";
j++;
}
else
wmd.WeekName = "Week" + (i+1).ToString() + "【" + wmd.SDate.Value.ToString("yyyy-MM-dd") + "----" + wmd.EDate.Value.ToString("yyyy-MM-dd") + "】";
sdt.AddDays(7);
wlist.Add(wmd);
}
if (DateTime.Today.Month <= 2)
{
sdt = sdt.AddDays(-28);
int m = 49;
for (int i = 0; i<4; i++)
{
HW_WeekName wmd = new HW_WeekName();
wmd.SDate = sdt.AddDays((i - 1) * 7);
wmd.EDate = sdt.AddDays(i * 7);
wmd.Num = m;
m++;
if (wmd.SDate.Value.Year > Year)
{
wmd.WeekName = "Week" + j.ToString() + "【" + wmd.SDate.Value.ToString("yyyy-MM-dd") + "----" + wmd.EDate.Value.ToString("yyyy-MM-dd") + "】";
j++;
}
else
wmd.WeekName = "Week" + (i + 1).ToString() + "【" + wmd.SDate.Value.ToString("yyyy-MM-dd") + "----" + wmd.EDate.Value.ToString("yyyy-MM-dd") + "】";
sdt.AddDays(7);
wlist.Add(wmd);
}
}
var wwlist = wlist.OrderBy(n => n.SDate);
return wlist;
}
#endregion
#region 返回周次
[WebMethod(EnableSession = true)]
public List<HW_WeekName> GetHW_WeekNameList()
{
PagesNew.Login(this.Session);
var obj = new HuoWuData();
int Year = DateTime.Today.Year;
System.DateTime fDt = DateTime.Parse(Year.ToString() + "-01-01");
int k = Convert.ToInt32(DateTime.Today.DayOfWeek);//得到该年的第一天是周几
if (k == 0)
k = 7;
DateTime sdt = DateTime.Today.AddDays(-1*(k - 1));
DateTime ssdt = sdt.AddDays(-56);
if (ssdt > fDt)
{
k = Convert.ToInt32(fDt.DayOfWeek);//得到该年的第一天是周几
if (k == 0)
k = 7;
sdt = fDt.AddDays(-1 * (k - 1));
}
else
sdt = ssdt;
List<HW_WeekName> wlist = new List<HW_WeekName>();
// int j = 1;
for (int i = 0; i < 57; i++)
{
var md = GetWeekName(sdt.AddDays(i * 7).Year, sdt.AddDays(i * 7));
if (md != null)
{
if (md.SDate >= ssdt && md.SDate <= ssdt.AddDays(7))
md.IsNow = 1;
if (md.SDate <= DateTime.Today && md.EDate>= DateTime.Today)
md.IsNow = 2;
wlist.Add(md);
}
}
return wlist;
}
#endregion
#region 返回周次
[WebMethod(EnableSession = true)]
public HW_WeekName GetWeekName2(int Year, DateTime sdate)
{
var obj = new HuoWuData();
DateTime sdt = sdate;
for (int i = 0; i < 54; i++)
{
HW_WeekName wmd = new HW_WeekName();
wmd.SDate = sdt.AddDays((i - 1) * 7);
wmd.EDate = wmd.SDate.Value.AddDays(6);
wmd.Num = i + 1;
wmd.WeekName = "Week" + (i + 1).ToString() + "【" + wmd.SDate.Value.ToString("yyyy-MM-dd") + "----" + wmd.EDate.Value.ToString("yyyy-MM-dd") + "】";
wmd.WeekName2 = "Week" + (i + 1).ToString();
sdt.AddDays(7);
if (wmd.SDate >= sdate && sdate <= wmd.EDate)
return wmd;
}
return null;
}
#endregion
#region 返回周次
[WebMethod(EnableSession = true)]
public HW_WeekName GetWeekName(int Year,DateTime sdate)
{
var obj = new HuoWuData();
System.DateTime fDt = DateTime.Parse(Year.ToString() + "-01-01");
int k = Convert.ToInt32(fDt.DayOfWeek);//得到该年的第一天是周几
if (k == 0)
k = 7;
DateTime sdt = fDt.AddDays(-1*(k-1));
for (int i = 0; i < 54; i++)
{
HW_WeekName wmd = new HW_WeekName();
wmd.SDate = sdt.AddDays(i * 7);
wmd.EDate = wmd.SDate.Value.AddDays(6);
wmd.Num = i + 1;
if (wmd.SDate.Value.Year != wmd.EDate.Value.Year)
{
wmd.WeekName = "Week1【" + wmd.SDate.Value.ToString("yyyy-MM-dd") + "---" + wmd.EDate.Value.ToString("yyyy-MM-dd") + "】";
wmd.WeekName2 = "Week1";
}
else
{
wmd.WeekName = "Week" + (i + 1).ToString() + "【" + wmd.SDate.Value.ToString("yyyy-MM-dd") + "---" + wmd.EDate.Value.ToString("yyyy-MM-dd") + "】";
wmd.WeekName2 = "Week" + (i + 1).ToString();
}
sdt.AddDays(7);
if (wmd.SDate >= sdate && sdate <= wmd.EDate)
return wmd;
}
return null;
}
#endregion
#region 返回周次
[WebMethod(EnableSession = true)]
public List<HW_WeekName> GetHW_WeekNameList2(DateTime SDate,DateTime EDate)
{
PagesNew.Login(this.Session);
//int k = Convert.ToInt32(DateTime.Today.DayOfWeek);//得到该年的第一天是周几
//if (k == 0)
// k = 7;
//DateTime sdt = DateTime.Today.AddDays(-1 * (k - 1));
List<HW_WeekName> wlist = new List<HW_WeekName>();
for(int i=0;i<60;i++)
{
if (SDate.AddDays(i * 7) > EDate)
break;
var md = GetWeekName(SDate.AddDays(i * 7).Year, SDate.AddDays(i * 7));
if (md != null)
wlist.Add(md);
}
return wlist;
}
#endregion
#region 分页查询
[WebMethod(EnableSession = true)]
public JsonModel<List<HW_ProductionPlan>> GetListProductionPlan(string cs, int PageIndex, int PageSize)
{
PagesNew.Login(this.Session);
string where = CustomIO.Base64StringToString(cs);
if (where != "") where = "where " + where.Substring(4);
var resultModel = new JsonModel<List<HW_ProductionPlan>>();
int RowCount = 0;
resultModel.DataSource = DataNew.GetListProductionPlan(where, PageIndex, PageSize, "", out RowCount);
resultModel.RowCount = RowCount;
string mids = "";
if (resultModel.DataSource != null)
{
foreach (var md in resultModel.DataSource)
{
mids += md.id + ",";
}
if (resultModel.DataSource.Count > 0)
resultModel.DataSource[0].mids = mids;
}
return resultModel;
}
#endregion
#region 分页查询
[WebMethod(EnableSession = true)]
public List<HW_ProductionDetail> GetListProductionPlanDetail(string mids)
{
PagesNew.Login(this.Session);
var dlist = DataNew.GetListProductionDetail(mids.TrimEnd(','));
return dlist;
}
#endregion
#region 分页查询
[WebMethod(EnableSession = true)]
public List<HW_ProductionDetail> GetListProductionPlanDetail2(int mid)
{
PagesNew.Login(this.Session);
var dlist = DataNew.GetListProductionDetail2(mid);
return dlist;
}
#endregion
#region 删除
[WebMethod(EnableSession = true)]
public int Delete_ProductionDetail(int id)
{
PagesNew.Login(this.Session);
DataNew.Delete_ProductionDetail(id);
return 1;
}
#endregion
#region 保存
[WebMethod(EnableSession = true)]
public int Save_Production(HW_ProductionPlan Model)
{
PagesNew.Login(this.Session);
if (Model.ListModel != null)
{
foreach (var md in Model.ListModel)
{
md.mid = Model.detailid;
DataNew.Save_ProductionDetail(md);
}
}
return 1;
}
#endregion
#region 删除
[WebMethod(EnableSession = true)]
public int Delete_Production(int id)
{
PagesNew.Login(this.Session);
DataNew.Delete_Production(id);
return 1;
}
#endregion
#region 货物model
[WebMethod(EnableSession = true)]
public HW_ProductionDetail GetModel_ProductionDetail(int id,string weekname)
{
PagesNew.Login(this.Session);
var md = DataNew.GetModel_ProductionDetail(id, weekname);
return md;
}
#endregion
#region 分页查询
[WebMethod(EnableSession = true)]
public List<HW_GoodsUserNew> GetListGoodsPlanDetail(string mids)
{
PagesNew.Login(this.Session);
var dlist = DataNew.GetListGoodsPlanDetail(mids.TrimEnd(','));
return dlist;
}
#endregion
#region 分页查询
[WebMethod(EnableSession = true)]
public List<HW_BuyLink> GetListGoodsPlanUrl(string mids)
{
PagesNew.Login(this.Session);
var dlist = DataNew.GetListGoodsPlanUrl(mids.TrimEnd(','));
return dlist;
}
#endregion
#region 分页查询
[WebMethod(EnableSession = true)]
public List<JC_Shop> GetListGoodsShop(int platid)
{
PagesNew.Login(this.Session);
var slist = DataNew.GetListGoodsShop(platid);
return slist;
}
#endregion
#region 分页查询
[WebMethod(EnableSession = true)]
public List<JC_Shop> GetListGoodsShop2()
{
PagesNew.Login(this.Session);
List<JC_Shop> shop = new List<JC_Shop>();
JC_Shop smd = new JC_Shop();
smd.ShopId = 2;
smd.ShopNo = "1";
smd.ShopName="亚马逊1";
shop.Add(smd);
smd = new JC_Shop();
smd.ShopId = 2;
smd.ShopNo = "2";
smd.ShopName = "亚马逊2";
shop.Add(smd);
smd = new JC_Shop();
smd.ShopId = 2;
smd.ShopNo = "3";
smd.ShopName = "亚马逊3";
shop.Add(smd);
smd = new JC_Shop();
smd.ShopId = 2;
smd.ShopNo = "4";
smd.ShopName = "亚马逊4";
shop.Add(smd);
smd = new JC_Shop();
smd.ShopId = 2;
smd.ShopNo = "5";
smd.ShopName = "亚马逊5";
shop.Add(smd);
smd = new JC_Shop();//EBAY1 EBAY2 WALMART1 WALMALT2 WISH1 WISH2 速卖通 自建站
smd.ShopId = 3;
smd.ShopNo = "1";
smd.ShopName = "EBAY1";
shop.Add(smd);
smd = new JC_Shop();
smd.ShopId = 3;
smd.ShopNo = "2";
smd.ShopName = "EBAY2";
shop.Add(smd);
smd = new JC_Shop();
smd.ShopId =6 ;
smd.ShopNo = "1";
smd.ShopName = "WALMART1";
shop.Add(smd);
smd = new JC_Shop();
smd.ShopId = 6;
smd.ShopNo = "2";
smd.ShopName = "WALMALT2";
shop.Add(smd);
smd = new JC_Shop();
smd.ShopId = 18;
smd.ShopNo = "1";
smd.ShopName = "WayFair1";
shop.Add(smd);
smd = new JC_Shop();
smd.ShopId = 18;
smd.ShopNo = "2";
smd.ShopName = "WayFair2";
shop.Add(smd);
smd = new JC_Shop();
smd.ShopId = 1;
smd.ShopNo = "1";
smd.ShopName = "速卖通";
shop.Add(smd);
smd = new JC_Shop();
smd.ShopId = 15;
smd.ShopNo = "1";
smd.ShopName = "自建站";
shop.Add(smd);
return shop;
}
#endregion
#region 分页查询
[WebMethod(EnableSession = true)]
public List<JC_Shop> GetListGoodsShopNew2(int platid)
{
PagesNew.Login(this.Session);
List<JC_Shop> shop = new List<JC_Shop>();
if (platid == 2)
{
JC_Shop smd = new JC_Shop();
smd.ShopId = 2;
smd.ShopNo = "1";
smd.ShopName = "亚马逊1";
shop.Add(smd);
smd = new JC_Shop();
smd.ShopId = 2;
smd.ShopNo = "2";
smd.ShopName = "亚马逊2";
shop.Add(smd);
smd = new JC_Shop();
smd.ShopId = 2;
smd.ShopNo = "3";
smd.ShopName = "亚马逊3";
shop.Add(smd);
smd = new JC_Shop();
smd.ShopId = 2;
smd.ShopNo = "4";
smd.ShopName = "亚马逊4";
shop.Add(smd);
smd = new JC_Shop();
smd.ShopId = 2;
smd.ShopNo = "5";
smd.ShopName = "亚马逊5";
shop.Add(smd);
}
else if (platid == 3)
{
JC_Shop smd = new JC_Shop();//EBAY1 EBAY2 WALMART1 WALMALT2 WISH1 WISH2 速卖通 自建站
smd.ShopId = 3;
smd.ShopNo = "1";
smd.ShopName = "EBAY1";
shop.Add(smd);
smd = new JC_Shop();
smd.ShopId = 3;
smd.ShopNo = "2";
smd.ShopName = "EBAY2";
shop.Add(smd);
}
else if (platid == 6)
{
JC_Shop smd = new JC_Shop();
smd.ShopId = 6;
smd.ShopNo = "1";
smd.ShopName = "WALMART1";
shop.Add(smd);
smd = new JC_Shop();
smd.ShopId = 6;
smd.ShopNo = "2";
smd.ShopName = "WALMALT2";
shop.Add(smd);
}
//smd = new JC_Shop();
//smd.ShopId = 18;
//smd.ShopNo = "1";
//smd.ShopName = "WayFair1";
//shop.Add(smd);
//smd = new JC_Shop();
//smd.ShopId = 18;
//smd.ShopNo = "2";
//smd.ShopName = "WayFair2";
//shop.Add(smd);
//smd = new JC_Shop();
//smd.ShopId = 1;
//smd.ShopNo = "1";
//smd.ShopName = "速卖通";
//shop.Add(smd);
//smd = new JC_Shop();
//smd.ShopId = 15;
//smd.ShopNo = "1";
//smd.ShopName = "自建站";
//shop.Add(smd);
return shop;
}
#endregion
#region 分页查询
[WebMethod(EnableSession = true)]
public List<JC_Shop> GetListGoodsShop22()
{
PagesNew.Login(this.Session);
List<JC_Shop> shop = new List<JC_Shop>();
var slist = DataNew.GetListGoodsShop(0);
var ymxmd = slist.FindAll(n => n.PlatType == 2);
if (ymxmd != null)
{
int i = 0;
foreach (var md in ymxmd)
{
i++;
JC_Shop smd = new JC_Shop();
smd.ShopId = 2;
smd.ShopNo = i.ToString();
smd.ShopName = "亚马逊" + i.ToString();
shop.Add(smd);
}
}
var ebaymd = slist.FindAll(n => n.PlatType == 3);
if (ebaymd != null)
{
int i = 0;
foreach (var md in ebaymd)
{
i++;
JC_Shop smd = new JC_Shop();
smd.ShopId = 3;
smd.ShopNo = i.ToString();
smd.ShopName = "Ebay" + i.ToString();
shop.Add(smd);
}
}
var wemmd = slist.FindAll(n => n.PlatType == 6);
if (wemmd != null)
{
int i = 0;
foreach (var md in wemmd)
{
i++;
JC_Shop smd = new JC_Shop();
smd.ShopId = 6;
smd.ShopNo = i.ToString();
smd.ShopName = "沃尔玛" + i.ToString();
shop.Add(smd);
}
}
var wishmd = slist.FindAll(n => n.PlatType == 18);
if (wishmd != null)
{
int i = 0;
foreach (var md in wishmd)
{
i++;
JC_Shop smd = new JC_Shop();
smd.ShopId =18;
smd.ShopNo = i.ToString();
smd.ShopName = "Wayfair" + i.ToString();
shop.Add(smd);
}
}
var smtmd = slist.FindAll(n => n.PlatType == 1);
if (smtmd != null)
{
int i = 0;
foreach (var md in smtmd)
{
i++;
JC_Shop smd = new JC_Shop();
smd.ShopId = 1;
smd.ShopNo = i.ToString();
smd.ShopName = "速卖通" + i.ToString();
shop.Add(smd);
}
}
var zjzmd = slist.FindAll(n => n.PlatType == 15);
if (zjzmd != null)
{
int i = 0;
foreach (var md in zjzmd)
{
i++;
JC_Shop smd = new JC_Shop();
smd.ShopId = md.ShopId;
smd.ShopNo = i.ToString();
smd.ShopName = "自建站" + i.ToString();
shop.Add(smd);
}
}
return shop;
}
#endregion
#region 分页查询
[WebMethod(EnableSession = true)]
public List<HW_GoodsPlanCount> GetListGoodsShopCount3(string mids)
{
PagesNew.Login(this.Session);
mids = mids.TrimEnd(',');
var dlist = DataNew.GetListGoodsShopCount3(mids);
return dlist;
}
#endregion
#region 分页查询
[WebMethod(EnableSession = true)]
public List<HW_GoodsPlanCount> GetListGoodsShopCount4(string mids)
{
PagesNew.Login(this.Session);
mids = mids.TrimEnd(',');
var dlist = DataNew.GetListGoodsShopCount4(mids);
return dlist;
}
#endregion
#region 分页查询
[WebMethod(EnableSession = true)]
public List<HW_GoodsPlanCount> GetListGoodsShopCount2(int ShopId,int GoodsId,int Year)
{
PagesNew.Login(this.Session);
var dlist = DataNew.GetListGoodsShopCount2(GoodsId, ShopId,Year);
return dlist;
}
#endregion
#region 分页查询
[WebMethod(EnableSession = true)]
public List<JC_UserInfo> GetListGoodsUserInfo(string name)
{
PagesNew.Login(this.Session);
var ulist = DataNew.GetListGoodsUserInfo(name);
return ulist;
}
#endregion
#region 保存
[WebMethod(EnableSession = true)]
public int Save_GoodsUser(HW_GoodsUser Model)
{
PagesNew.Login(this.Session);
return DataNew.Save_GoodsUser(Model);
}
#endregion
#region 保存
[WebMethod(EnableSession = true)]
public void SaveGoodsPlan()
{
PagesNew.Login(this.Session);
DataNew.SaveGoodsPlan();
}
#endregion
#region 保存
[WebMethod(EnableSession = true)]
public int Save_GoodsExtra(HW_GoodsExtra Model)
{
PagesNew.Login(this.Session);
return DataNew.Save_GoodsExtra(Model);
}
#endregion
#region 保存
[WebMethod(EnableSession = true)]
public int UpdateIsEnd(int GoodsId,int IsEnd)
{
PagesNew.Login(this.Session);
return DataNew.UpdateIsEnd(GoodsId, IsEnd);
}
#endregion
#region 查询货物sku
[WebMethod(EnableSession = true)]
public JsonModel<List<HW_GoodsUserNew2>> GetGoodsUser22(int UserId, string GoodsCode, int ShopId,string grade, int PageIndex, int PageSize, string Sort)
{
PagesNew.Login(this.Session);
var obj = new HuoWuData();
int CompanyId = Convert.ToInt32(Session["CompanyId"]);
RefParameterCollection Param = new RefParameterCollection();
if(grade!="0")
Param.Add("a.grade", "=", grade, DbType.String);
if (UserId > 0)
Param.Add("a.UserId", "=", UserId, DbType.Int32);
if (GoodsCode != "")
Param.Add("d.GoodsCode", "like", GoodsCode, DbType.String);
if (ShopId > 0)
Param.Add("a.ShopId", "=", ShopId, DbType.Int32);
JsonModel<List<HW_GoodsUserNew2>> resultModel = new JsonModel<List<HW_GoodsUserNew2>>();
int RowCount = 0;
resultModel.DataSource = DataNew.GetListGoodsUser22(Param, PageIndex, PageSize, Sort, out RowCount);
resultModel.RowCount = RowCount;
return resultModel;
}
#endregion
#region 查询货物sku
[WebMethod(EnableSession = true)]
public List<HW_GoodsStoreNumCount> GetListGoodsStoreCount(int storeId, string sku)
{
PagesNew.Login(this.Session);
var obj = new HuoWuData();
var list = DataNew.GetListGoodsStoreCount(storeId, sku);
int num = 0;
decimal tj = 0M;
decimal je=0M;
if (list != null)
{
foreach (var md in list)
{
if (md.KCNum != null)
num += md.KCNum.Value;
if (md.TJSolid != null)
tj += md.TJSolid.Value;
if (md.TJPrice != null)
je += md.TJPrice.Value;
}
}
if (list != null)
{
list[0].HJKCNum = num;
list[0].HJPrice = je;
list[0].HJSolid = tj;
}
return list;
}
#endregion
#region 查询货物sku
[WebMethod(EnableSession = true)]
public string GetListGoodsStoreCountExcel(int storeId, string sku)
{
PagesNew.Login(this.Session);
var obj = new HuoWuData();
var list = DataNew.GetListGoodsStoreCount(storeId, sku);
int num = 0;
decimal tj = 0M;
decimal je = 0M;
foreach (var md in list)
{
if (md.KCNum != null)
num += md.KCNum.Value;
if (md.TJSolid != null)
tj += md.TJSolid.Value;
if (md.TJPrice != null)
je += md.TJPrice.Value;
}
if (list != null)
{
HW_GoodsStoreNumCount md = new HW_GoodsStoreNumCount();
md.GoodsCode = "合计:";
md.KCNum = num;
md.TJPrice = je;
md.TJSolid = tj;
list.Add(md);
}
TableColumnCollection listColumns = new TableColumnCollection();
listColumns.Add("GoodsCode", "货物SKU", DbType.String, "");
listColumns.Add("KCNum", "库存数", DbType.String, "");
listColumns.Add("Solid", "单个体积", DbType.String, "");
listColumns.Add("TJSolid", "合计体积", DbType.String, "");
listColumns.Add("InPrice", "单个价格", DbType.String, "");
listColumns.Add("TJPrice", "合计价格", DbType.String, "");
MicrosoftExcel obj2 = new MicrosoftExcel();
return obj2.Export(list, listColumns);
}
#endregion
#region 查询库存
[WebMethod(EnableSession = true)]
public JsonModel<List<HW_GoodsLeftNew>> GetList_GoodsLeftForTMNew(string PostionCode, string GoodsName, string GoodsName2, int StoreId, int sdays, int edays, int PageIndex, int PageSize)
{
PagesNew.Login(this.Session);
var obj = new HuoWuData();
int CompanyId = Convert.ToInt32(Session["CompanyId"]);
RefParameterCollection Param = new RefParameterCollection();
// Param.Add("f.CompanyId", "=", CompanyId, DbType.Int32);
if (PostionCode != "")
Param.Add("d.PostionCode", "=", PostionCode, DbType.String);
if (StoreId > 0)
Param.Add("d.StoreId", "=", StoreId, DbType.String);
if (GoodsName.Trim() != "")
{
Param.Add("(c.GoodsCode", "=", GoodsName.Trim(), DbType.String);
Param.Add("b.sku1", "=", GoodsName.Trim(), "or", ")", DbType.String);
}
if (GoodsName2.Trim() != "")
{
Param.Add("(c.GoodsCode", "like", GoodsName2.Trim(), DbType.String);
Param.Add("b.sku1", "like", GoodsName2.Trim(), "or", ")", DbType.String);
}
if (GoodsName.Trim().Contains(" "))
{
Param.Add("(c.GoodsCode", "=", GoodsName.Trim().Split(' ')[0].Trim(), DbType.String);
Param.Add("c.GoodsOldCode", "=", GoodsName.Trim().Split(' ')[0].Trim(), "or", ")", DbType.String);
Param.Add("b.TypeCode", "=", GoodsName.Trim().Split(' ')[1].Trim(), DbType.String);
}
if (sdays >= 0)
{
Param.Add(" DATEDIFF(DAY,a.indate,GETDATE())", ">=", sdays, DbType.Int32);
}
if (edays >= 0)
{
Param.Add(" DATEDIFF(DAY,a.indate,GETDATE())", "<=", edays, DbType.Int32);
}
JsonModel<List<HW_GoodsLeftNew>> resultModel = new JsonModel<List<HW_GoodsLeftNew>>();
string Sort = "c.GoodsCode,b.TypeCode";
int RowCount = 0;
resultModel.DataSource = DataNew.GetList_GoodsLeftForTMNew(Param, PageIndex, PageSize, Sort, out RowCount);
resultModel.RowCount = RowCount;
return resultModel;
}
#endregion
#region 保存
[WebMethod(EnableSession = true)]
public int UpDoPrice(List<HW_GoodsLeftNew> list,decimal doprice)
{
PagesNew.Login(this.Session);
if (list != null)
{
foreach (var md in list)
{
DataNew.UpDoPrice(md.PostionId.Value, md.DetailId.Value,doprice);
}
}
return 1;
}
#endregion
#region 导出库存
[WebMethod(EnableSession = true)]
public string GetList_GoodsLeftExcel2(string PostionCode, string GoodsName, string GoodsName2, int StoreId, int sdays, int edays)
{
var obj = new HuoWuData();
int CompanyId = Convert.ToInt32(Session["CompanyId"]);
RefParameterCollection Param = new RefParameterCollection();
// Param.Add("f.CompanyId", "=", CompanyId, DbType.Int32);
if (PostionCode != "")
Param.Add("d.PostionCode", "=", PostionCode, DbType.String);
if (StoreId > 0)
Param.Add("d.StoreId", "=", StoreId, DbType.String);
if (GoodsName.Trim() != "")
{
Param.Add("(c.GoodsCode", "=", GoodsName.Trim(), DbType.String);
Param.Add("b.sku1", "=", GoodsName.Trim(), "or", ")", DbType.String);
}
if (GoodsName2.Trim() != "")
{
Param.Add("(c.GoodsCode", "like", GoodsName2.Trim(), DbType.String);
Param.Add("b.sku1", "like", GoodsName2.Trim(), "or", ")", DbType.String);
}
if (GoodsName.Trim().Contains(" "))
{
Param.Add("(c.GoodsCode", "=", GoodsName.Trim().Split(' ')[0].Trim(), DbType.String);
Param.Add("c.GoodsOldCode", "=", GoodsName.Trim().Split(' ')[0].Trim(), "or", ")", DbType.String);
Param.Add("b.TypeCode", "=", GoodsName.Trim().Split(' ')[1].Trim(), DbType.String);
}
if (sdays >= 0)
{
Param.Add(" DATEDIFF(DAY,a.indate,GETDATE())", ">=", sdays, DbType.Int32);
}
if (edays >= 0)
{
Param.Add(" DATEDIFF(DAY,a.indate,GETDATE())", "<=", edays, DbType.Int32);
}
JsonModel<List<HW_GoodsLeftNew>> resultModel = new JsonModel<List<HW_GoodsLeftNew>>();
string Sort = "c.GoodsCode,b.TypeCode";
int RowCount = 0;
resultModel.DataSource = DataNew.GetList_GoodsLeftForTMNew(Param, 1, 50000, Sort, out RowCount);
TableColumnCollection listColumns = new TableColumnCollection();
listColumns.Add("GoodsCode", "编码", DbType.String, "");
listColumns.Add("GoodsOldCode", "老编码", DbType.String, "");
listColumns.Add("TypeCode", "SKU", DbType.String, "");
listColumns.Add("GoodsName", "名称", DbType.String, "");
listColumns.Add("TypeDesc", "规格描述", DbType.String, "");
listColumns.Add("GoodsNum", "库存数量", DbType.String, "");
listColumns.Add("LockNum", "匹配锁定数量", DbType.String, "");
listColumns.Add("StoreName", "仓库", DbType.String, "");
listColumns.Add("PostionCode", "库位", DbType.String, "");
listColumns.Add("LeftNum", "库龄", DbType.String, "");
listColumns.Add("DoPrice", "处理价格$", DbType.String, "");
if (Convert.ToInt32(Session["UserId"]) == 53|| Convert.ToInt32(Session["UserId"]) == 1)
{
listColumns.Add("Solid", "单个体积", DbType.String, "");
listColumns.Add("price", "单价", DbType.String, "");
}
MicrosoftExcel obj2 = new MicrosoftExcel();
return obj2.Export(resultModel.DataSource, listColumns);
}
#endregion
#region 保存
[WebMethod(EnableSession = true)]
public int Update_Grade(List<HW_GoodsUserNew2> list, string grade)
{
PagesNew.Login(this.Session);
if (list != null)
{
foreach (var md in list)
{
DataNew.UpdateGoodsGrade(md.Id.Value, grade);
}
}
return 1;
}
#endregion
#region 保存
[WebMethod(EnableSession = true)]
public int UpdateGoodsUser(int shopid,string name, int userid)
{
PagesNew.Login(this.Session);
DataNew.UpdateGoodsUser(shopid, name,userid);
return 1;
}
#endregion
#region 查询货物
[WebMethod(EnableSession = true)]
public JsonModel<List<HW_Goods_New>> GetGoodsInfoListForTM22(int SortId, int OffNum, string SortName, int TypeCode, string Name, string Supplier, int SNum, int ENum, decimal SPrice, decimal EPrice, int IsWH, int IsHW, int IsDH, int IsBH, int accurate,int jybh, int IsShowAll, int IsOnlyYC, int PageIndex, int PageSize, string Sort)
{
var obj = new HuoWuData();
int CompanyId = Convert.ToInt32(Session["CompanyId"]);
RefParameterCollection Param = new RefParameterCollection();
Param.Add("CompanyId", "=", CompanyId, DbType.Int32);
if (SortName != "" && SortName != "-全部-" && SortName != "全部")
Param.Add("SortName", "like", SortName, DbType.String);
if (SortId != 0)
Param.Add("SortId", "=", SortId, DbType.Int32);
//if (Edate != null)
// Param.Add("InDate", "<", Edate.Value.AddDays(1), DbType.DateTime);
Param.Add("State", "=", 1, DbType.Int32);
if (IsShowAll != 1)//不展示所有
{
if (IsOnlyYC == 1) //只展示隐藏
{
Param.Add("IsYC", "=", 1, DbType.Int32);
}
else
{
Param.Add("IsNull(IsYC,0)", "=", 0, DbType.Int32);
}
}
else //展示所有
{
if (IsOnlyYC == 1) //只展示隐藏
{
Param.Add("IsYC", "=", 1, DbType.Int32);
}
}
if (Supplier != "")
Param.Add("SupplierId", "like", Supplier, DbType.String);
Name = Name.Trim();
if (Name != "" && accurate == 0)
{
//if (TypeCode == 1)
// Param.Add("GoodsName", "like", Name, DbType.String);
if (TypeCode == 2)
{
Param.Add("(GoodsCode", "like", Name, DbType.String);
Param.Add("GoodsOldCode", "like", Name, "or", ")", DbType.String);
}
if (TypeCode == 3)
Param.Add("GoodsSupplyCode", "like", Name, DbType.String);
//if (TypeCode == 4)
// Param.Add("b.SKU1", "=", Name, DbType.String);
if (TypeCode == 5)
Param.Add("GoodsSupplyCode", "like", Name, DbType.String);
if (TypeCode == 6)
Param.Add("UpdateName", "like", Name, DbType.String);
}
if (Name != "" && accurate == 1)
{
//if (TypeCode == 1)
// Param.Add("GoodsName", "=", Name, DbType.String);
if (TypeCode == 2)
{
Param.Add("(GoodsCode", "=", Name, DbType.String);
Param.Add("GoodsOldCode", "=", Name, "or", ")", DbType.String);
}
if (TypeCode == 3)
Param.Add("GoodsSupplyCode", "=", Name, DbType.String);
//if (TypeCode == 4)
// Param.Add("b.SKU1", "=", Name, DbType.String);
if (TypeCode == 5)
Param.Add("GoodsSupplyCode", "=", Name, DbType.String);
if (TypeCode == 6)
Param.Add("UpdateName", "=", Name, DbType.String);
}
string sku = "";
if (Name != "" && (TypeCode == 4 || TypeCode == 1) && accurate == 0)
{
sku = Name;
}
if (OffNum != 99999)
{
if (OffNum >= 0)
Param.Add("a.UpOff", ">=", OffNum, DbType.Int32);
else
Param.Add("a.UpOff", "<=", OffNum, DbType.Int32);
}
if (SNum > 0)
Param.Add("b.GoodsNum", ">=", SNum, DbType.Int32);
if (ENum > 0)
Param.Add("b.GoodsNum", "<=", ENum, DbType.Int32);
if (SPrice > 0)
Param.Add("NowPrice", ">=", SPrice, DbType.Decimal);
if (EPrice > 0)
Param.Add("NowPrice", "<=", EPrice, DbType.Decimal);
if (IsWH == 1)
Param.Add("NoGoods", "=", 1, DbType.Int32);
if (jybh == 1)
Param.Add("b.GoodsHJNum2-isnull(b.GoodsNum,0)-isnull(b.GoodsInNum2,0)", ">", 0, DbType.Int32);
JsonModel<List<HW_Goods_New>> resultModel = new JsonModel<List<HW_Goods_New>>();
int RowCount = 0;
resultModel.DataSource = DataNew.GetListHW_GoodsInfoNewForTM(CompanyId, sku, IsDH, IsBH, Param, PageIndex, PageSize, Sort, out RowCount);
resultModel.RowCount = RowCount;
string Ids = "";
if (resultModel.DataSource != null)
{
foreach (var md in resultModel.DataSource)
{
Ids += md.GoodsId.ToString() + ",";
if (md.Solid != null)
md.TotalSolid = md.Solid * md.GoodsNum;
}
}
if (IsHW == 1 && resultModel.DataSource != null)
{
if (Ids != "")
{
var list1 = obj.GetGoodsDetailList(Ids.Trim(','));
if (list1 != null)
{
foreach (var md in resultModel.DataSource)
{
var list2 = list1.FindAll(n => n.GoodsId == md.GoodsId);
if (list2 != null)
{
md.GoodsList = list2;
}
}
}
}
}
return resultModel;
}
#endregion
#region 导入货物
[WebMethod(EnableSession = true)]
public string ExcelSaveGoodsSKUNew(string FileName, string SortName)
{
PagesNew.Login(this.Session);
if (string.IsNullOrEmpty(FileName) == true) return "要导入的文件路径不能为空";
string ServerFileName = AppDomain.CurrentDomain.BaseDirectory + FileName;
if (System.IO.File.Exists(ServerFileName) == false) return "要导入的文件路径不存在";
//int CompanyId = Convert.ToInt32(Session["CompanyId"]);
try
{
MicrosoftExcel excel = new MicrosoftExcel();
DataTable tb = excel.ImportExcel(ServerFileName);
string error = "";
if (tb.Columns.Contains("货物编号") == false) { error = error + "导入模板的 货物编号 列不存在"; }
if (tb.Columns.Contains("报关名称") == false) { error = error + "导入模板的 报关名称 列不存在"; }
if (tb.Columns.Contains("SKU") == false) { error = error + "导入模板的 SKU 列不存在"; }
//if (tb.Columns.Contains("单价") == false) { error = error + "导入模板的 单价 列不存在"; }
//if (tb.Columns.Contains("重量(克)") == false) { error = error + "导入模板的 重量(克) 列不存在"; }
//if (tb.Columns.Contains("入库数量") == false) { error = error + "导入模板的 入库数量 列不存在"; }
if (string.IsNullOrEmpty(error) == false) return error + ";请重新下载模板导入";
HuoWuData obj = new HuoWuData();
int UserId = Convert.ToInt32(Session["UserId"]);
int Num = 0;
HW_GoodsExcelModel2 omd = null;
for (int i = 0; i < tb.Rows.Count; i++)
{
var md = new HW_GoodsExcelModel2();
if (omd != null)
md = omd;
if (tb.Rows[i]["SKU"].ToString().Trim() == "")
{
continue;
}
md.SKU1 = tb.Rows[i]["SKU"].ToString().Trim();
if (tb.Rows[i]["货物编号"].ToString().Trim() != "")
md.GoodsCode = tb.Rows[i]["货物编号"].ToString().Trim();
if (tb.Rows[i]["报关名称"].ToString().Trim() != "")
md.GoodsName = tb.Rows[i]["报关名称"].ToString().Trim();
md.SortName1 = SortName;
md.SortId = 0;
md.SKU1 = "";
md.SKU2 = "";
md.SKU3 = "";
md.SKU4 = "";
//if (tb.Columns.Contains("SKU2") == true)
// md.SKU2 = tb.Rows[i]["SKU2"].ToString().Trim();
//if (tb.Columns.Contains("SKU3") == true)
// md.SKU3 = tb.Rows[i]["SKU3"].ToString().Trim();
//if (tb.Columns.Contains("SKU4") == true)
// md.SKU4 = tb.Rows[i]["SKU4"].ToString().Trim();
if (tb.Rows[i]["报关英文名"].ToString().Trim() != "")
md.GoodsEngLishName = tb.Rows[i]["报关英文名"].ToString().Trim().Replace(",", "");
if (md.GoodsEngLishName == "")
md.GoodsEngLishName = "Goods";
if (md.GoodsEngLishName.Length >= 50)
md.GoodsEngLishName = md.GoodsEngLishName.Substring(0, 49);
// if (tb.Rows[i]["描述"].ToString().Trim() != "")
md.TypeDesc = tb.Rows[i]["描述"].ToString().Trim();
if (tb.Rows[i]["箱率"].ToString().Trim() != "")
md.BoxRate = Convert.ToDecimal(tb.Rows[i]["箱率"].ToString().Trim());
if (tb.Rows[i]["单个毛重(克)"].ToString().Trim() != "")
md.Weight2 = Convert.ToDecimal(tb.Rows[i]["单个毛重(克)"].ToString().Trim()) * 0.035274M;
if (tb.Rows[i]["单个净重g"].ToString().Trim() != "")
md.NetWeight = Convert.ToDecimal(tb.Rows[i]["单个净重g"].ToString().Trim());
if (tb.Rows[i]["外箱毛重g"].ToString().Trim() != "")
md.Weight = Convert.ToDecimal(tb.Rows[i]["外箱毛重g"].ToString().Trim());
//md.Link1 = tb.Rows[i]["购买链接1"].ToString().Trim();
//md.LinkName1 = tb.Rows[i]["购买链接1名称"].ToString().Trim();
//md.Link2 = tb.Rows[i]["购买链接2"].ToString().Trim();
//md.LinkName2 = tb.Rows[i]["购买链接2名称"].ToString().Trim();
//md.Link3 = tb.Rows[i]["购买链接3"].ToString().Trim();
//md.LinkName3 = tb.Rows[i]["购买链接3名称"].ToString().Trim();
//md.Link4 = tb.Rows[i]["购买链接4"].ToString().Trim();
//md.LinkName4 = tb.Rows[i]["购买链接4名称"].ToString().Trim();
try
{
if (tb.Rows[i]["进价"].ToString().Trim() != "")
md.Price = Convert.ToDecimal(tb.Rows[i]["进价"].ToString().Trim());
}
catch (Exception ex)
{
// error += "第" + (i + 2).ToString() + " 行的单价必须是数字<br/>";
md.Price = 0;
}
if (tb.Rows[i]["外箱长(英寸)"].ToString().Trim() != "")
{
try
{
md.Long = Convert.ToDecimal(tb.Rows[i]["外箱长(英寸)"].ToString().Trim());
}
catch (Exception ex)
{
// error += "第" + (i + 2).ToString() + " 行的重量(克)必须是数字<br/>";
// continue;
}
}
if (tb.Rows[i]["外箱宽(英寸)"].ToString().Trim() != "")
{
try
{
md.Width = Convert.ToDecimal(tb.Rows[i]["外箱宽(英寸)"].ToString().Trim());
}
catch (Exception ex)
{
// error += "第" + (i + 2).ToString() + " 行的重量(克)必须是数字<br/>";
// continue;
}
}
if (tb.Rows[i]["外箱高(英寸)"].ToString().Trim() != "")
{
try
{
md.Height = Convert.ToDecimal(tb.Rows[i]["外箱高(英寸)"].ToString().Trim());
}
catch (Exception ex)
{
// error += "第" + (i + 2).ToString() + " 行的重量(克)必须是数字<br/>";
// continue;
}
}
if (tb.Rows[i]["单个长(英寸)"].ToString().Trim() != "")
{
try
{
md.Long2 = Convert.ToDecimal(tb.Rows[i]["单个长(英寸)"].ToString().Trim());
}
catch (Exception ex)
{
// error += "第" + (i + 2).ToString() + " 行的重量(克)必须是数字<br/>";
// continue;
}
}
if (tb.Rows[i]["单个宽(英寸)"].ToString().Trim() != "")
{
try
{
md.Width2 = Convert.ToDecimal(tb.Rows[i]["单个宽(英寸)"].ToString().Trim());
}
catch (Exception ex)
{
// error += "第" + (i + 2).ToString() + " 行的重量(克)必须是数字<br/>";
// continue;
}
}
if (tb.Rows[i]["单个宽(英寸)"].ToString().Trim() != "")
{
try
{
md.Height2 = Convert.ToDecimal(tb.Rows[i]["单个宽(英寸)"].ToString().Trim());
}
catch (Exception ex)
{
// error += "第" + (i + 2).ToString() + " 行的重量(克)必须是数字<br/>";
// continue;
}
}
if (tb.Rows[i]["产品开发人员"].ToString().Trim() != "")
md.KFName = tb.Rows[i]["产品开发人员"].ToString().Trim();
if (tb.Rows[i]["产品维护人员"].ToString().Trim() != "")
md.KFName2 = tb.Rows[i]["产品维护人员"].ToString().Trim();
else
{
md.KFName2 = md.KFName;
}
if (tb.Rows[i]["税率"].ToString().Trim() != "")
md.FeeRate = Convert.ToDecimal(tb.Rows[i]["税率"].ToString().Trim());
if (md.Long2 > 0 && md.Height2 > 0 && md.Width2 > 0)
md.Solid = md.Long2 * md.Height2 * md.Width2 * 0.0000164M;
if (tb.Rows[i]["备注"].ToString().Trim() != "")
md.GoodsInfo = tb.Rows[i]["备注"].ToString().Trim();
md.CompanyId = 1;
md.InUserId = UserId;
md.GoodsEg = md.GoodsCode;
md.GoodsNo = 0;
md.GoodsNum = 0;
if (tb.Rows[i]["图片"].ToString().Trim() != "")
md.ImgUrl = "../attached/gimg/" + tb.Rows[i]["图片"].ToString().Trim();
omd = md;
int a = DataNew.ExcelSaveGoodsSKUNEW(md);
if (a == 2)
{
error += "第" + (i + 2).ToString() + " 行的SKU已经存在<br/>";
continue;
}
else
Num++;
}
if (error == "")
{
error = "数据导入成功;" + Num.ToString() + "条";
}
else
{
error += "其它数据导入成功;";
}
return error;
}
catch (Exception e)
{
return "文件导入失败!请确定模板格式是否正确,或者重新下载模板,填写数据,重新导入!!!" + e.Message;
}
return "导入成功";
}
#endregion
#region 查询出库货物明细
[WebMethod(EnableSession = true)]
public List<HW_GoodsOutCKNew> GetGoodsOutDetailNew(string GoodsCode, int StoreId,string barcode)
{
PagesNew.Login(this.Session);
var obj = new HuoWuData();
string TypeCode = "";
if (GoodsCode.Trim().Contains(" "))
{
TypeCode = GoodsCode.Trim().Split(' ')[1].Trim();
GoodsCode = GoodsCode.Trim().Split(' ')[0].Trim();
}
int CompanyId = Convert.ToInt32(Session["CompanyId"]);
if (barcode.Trim() != "")
{
var list = DataNew.GetGoodsOutDetailNew2(barcode);
return list;
}
else
{
var list = DataNew.GetGoodsOutDetailNew(CompanyId, GoodsCode, TypeCode, StoreId);
return list;
}
}
#endregion
#region 保存货物出库单
[WebMethod(EnableSession = true)]
public HW_GoodsOutRecordBuy SaveGoodsOutBuy(HW_GoodsOutRecordBuy model, List<HW_GoodsOutCKNew> CKList, int state)
{
PagesNew.Login(this.Session);
// bool bk = BaseService.SyncLock3();
// if (bk == false)
// return "当前有其他人正在操作库存匹配,为保证库存数据准确您暂时无法出库";
HW_GoodsOutRecordBuy rmd = new HW_GoodsOutRecordBuy();
int CompanyId = Convert.ToInt32(Session["CompanyId"]);
int UserId = Convert.ToInt32(Session["UserId"]);
var obj = new HuoWuData();
model.CompanyId = CompanyId;
model.InDate = DateTime.Now;
model.InUserId = UserId;
model.IsDelete = state;
int Num = 0;
if (CKList != null)
{
foreach (var md in CKList)
{
if (md.OutNum != null)
Num += md.OutNum.Value;
}
}
model.OutNum = Num;
if (CKList != null)
{
//var OutDetailList = new List<HW_GoodsOutDetail>();
string error = "";
foreach (var md in CKList)
{
int kc = DataNew.iskc(md.PostionId.Value, md.DetailId.Value);
if (md.OutNum > kc)
{
error += md.SKU1 + "[" + md.PostionDesc + "] ";
}
}
if (error != "")
{
rmd.OutReason = error + "Insufficient inventory,Please modify the quantity;";
return rmd;
}
}
var OutId = DataNew.SaveGoodsOutBuy(model);
if (CKList != null)
{
//var OutDetailList = new List<HW_GoodsOutDetail>();
DataNew.DeleteGoodsOutDetailBuy(OutId);
foreach (var md in CKList)
{
md.Id = 0;
md.OutId = OutId;
int ckid = DataNew.SaveGoodsOutDetailBuy(md,state);
if (md.OutNum != null && md.OutNum.Value > 0 && state == 2)
{
//for (int i = 0; i < md.OutNum.Value; i++)
//{
obj.SaveGoodsOutInnerForTM2(md.DetailId.Value, md.PostionId.Value, md.StoreId.Value, md.OutNum.Value, ckid);
// }
}
}
// obj.SaveGoodsOutGoodsNum(OutId);
}
if (state == 2)
PagesNew.SaveLog(UserId, "出库调整", model.OutCode + "出库单", OutId);
rmd.OutId = OutId;
return rmd;
}
#endregion
#region 保存货物出库单(南美)
[WebMethod(EnableSession = true)]
public HW_GoodsOutRecordBuy SaveGoodsOutBuy_NMLock(HW_GoodsOutRecordBuy model, List<HW_GoodsOutCKNew> CKList, int state)
{
PagesNew.Login(this.Session);
// bool bk = BaseService.SyncLock3();
// if (bk == false)
// return "当前有其他人正在操作库存匹配,为保证库存数据准确您暂时无法出库";
HW_GoodsOutRecordBuy rmd = new HW_GoodsOutRecordBuy();
int CompanyId = Convert.ToInt32(Session["CompanyId"]);
int UserId = Convert.ToInt32(Session["UserId"]);
var obj = new HuoWuData();
model.CompanyId = CompanyId;
model.InDate = DateTime.Now;
model.InUserId = UserId;
model.IsDelete = state;
int Num = 0;
if (CKList != null)
{
foreach (var md in CKList)
{
if (md.OutNum != null)
Num += md.OutNum.Value;
}
}
model.OutNum = Num;
if (CKList != null)
{
//var OutDetailList = new List<HW_GoodsOutDetail>();
string error = "";
foreach (var md in CKList)
{
int kc = DataNew.iskc(md.PostionId.Value, md.DetailId.Value);
if (md.OutNum > kc)
{
error += md.SKU1 + "[" + md.PostionDesc + "] ";
}
}
if (error != "")
{
rmd.OutReason = error + "Insufficient inventory,Please modify the quantity;";
return rmd;
}
}
var OutId = DataNew.SaveGoodsOutBuy(model);
if (CKList != null)
{
//var OutDetailList = new List<HW_GoodsOutDetail>();
DataNew.DeleteGoodsOutDetailBuy(OutId);
foreach (var md in CKList)
{
md.Id = 0;
md.OutId = OutId;
int ckid = DataNew.SaveGoodsOutDetailBuy_NM(md, state);
if (md.OutNum != null && md.OutNum.Value > 0 && state ==3)
{
//for (int i = 0; i < md.OutNum.Value; i++)
//{
DataNew.SaveGoodsOutInnerForNMLock(md.DetailId.Value, md.PostionId.Value, md.StoreId.Value, md.OutNum.Value, ckid);
// }
}
}
// obj.SaveGoodsOutGoodsNum(OutId);
}
rmd.OutId = OutId;
return rmd;
}
#endregion
#region 保存货物出库单(南美)
[WebMethod(EnableSession = true)]
public int SaveGoodsOutBuy_NMOut(int OutId, List<HW_GoodsOutCKNew> CKList, int state,string PayType)
{
PagesNew.Login(this.Session);
DataNew.UpdateGoodsOutBuyNM(OutId, state, PayType);
if (CKList != null)
{
foreach (var md in CKList)
{
DataNew.SaveGoodsOutInnerForNMOut(md.Id.Value);
}
// obj.SaveGoodsOutGoodsNum(OutId);
}
//int CompanyId = Convert.ToInt32(Session["CompanyId"]);
// int UserId = Convert.ToInt32(Session["UserId"]);
// PagesNew.SaveLog(UserId, "南美直销", model.OutCode + "出库单", OutId);
// rmd.OutId = OutId;
return 1;
}
#endregion
#region 批量删除
[WebMethod(EnableSession = true)]
public int NM_DeleteOrder(int outid)
{
PagesNew.Login(this.Session);
string Name = Convert.ToString(Session["Name"])+DateTime.Now.ToString("yyyyMMddhhmm")+"操作删除";
DataNew.DeleteNMOrder(outid,Name);
return 1;
}
#endregion
#region 查询出库记录
[WebMethod(EnableSession = true)]
public JsonModel<List<HW_GoodsOutRecordBuy>> GetListHW_GoodsOutListBuy(int TJ, string GoodsName, DateTime? SDate, DateTime? EDate, int IsDetail, string CKType, int PageIndex, int PageSize, string Sort)
{
var obj = new HuoWuData();
int CompanyId = Convert.ToInt32(Session["CompanyId"]);
RefParameterCollection Param = new RefParameterCollection();
Param.Add("a.CompanyId", "=", CompanyId, DbType.Int32);
// Param.Add("a.IsDelete", "=", 0, DbType.Int32);
//if (CKType == 1)
// Param.Add("a.OrderId", ">", 0, DbType.String);
//else if (CKType == 2)
// Param.Add("a.OrderId", "=", 0, DbType.String);
if (SDate != null)
Param.Add("a.InDate", ">=", SDate, DbType.DateTime);
if (EDate != null)
Param.Add("a.InDate", "<", EDate.Value.AddDays(1), DbType.DateTime);
if (TJ == 6)
{
Param.Add("a.OutCode", "like", GoodsName.Trim(), DbType.String);
}
else
if (TJ == 7)
{
Param.Add("b.PlatOrderCode", "like", GoodsName.Trim(), DbType.String);
}
if (TJ > 4)
GoodsName = "";
JsonModel<List<HW_GoodsOutRecordBuy>> resultModel = new JsonModel<List<HW_GoodsOutRecordBuy>>();
int RowCount = 0;
resultModel.DataSource = DataNew.GetListHW_GoodsOutListBuy(TJ, CKType.TrimEnd(','), GoodsName, Param, PageIndex, PageSize, Sort, out RowCount);
resultModel.RowCount = RowCount;
if (IsDetail == 1 && resultModel.DataSource != null)
{
foreach (var md in resultModel.DataSource)
{
var list = DataNew.GetOutCKDetailListForTM(md.OutId.Value);
md.GoodsOutCKList2 = list;
}
}
return resultModel;
}
#endregion
#region 查询出库记录
[WebMethod(EnableSession = true)]
public JsonModel<List<HW_GoodsOutRecordBuy>> GetListHW_GoodsOutListBuyNM(int TJ,int StoreId,int State, string GoodsName, string PayType, DateTime? SDate, DateTime? EDate, int IsDetail, string CKType, int PageIndex, int PageSize, string Sort)
{
var obj = new HuoWuData();
int CompanyId = Convert.ToInt32(Session["CompanyId"]);
RefParameterCollection Param = new RefParameterCollection();
Param.Add("a.CompanyId", "=", CompanyId, DbType.Int32);
// Param.Add("a.IsDelete", "=", 0, DbType.Int32);
if (PayType!="-1")
Param.Add("a.PayType", "=", PayType, DbType.String);
if (StoreId >0)
Param.Add("a.StoreId", "=", StoreId, DbType.Int32);
if (State>0)
Param.Add("a.IsDelete", "=", State, DbType.Int32);
else
Param.Add("a.IsDelete", "<>", 1, DbType.Int32);
if (SDate != null)
Param.Add("a.InDate", ">=", SDate, DbType.DateTime);
if (EDate != null)
Param.Add("a.InDate", "<", EDate.Value.AddDays(1), DbType.DateTime);
if (TJ == 6)
{
Param.Add("a.OutCode", "like", GoodsName.Trim(), DbType.String);
}
else
if (TJ == 7)
{
Param.Add("b.PlatOrderCode", "like", GoodsName.Trim(), DbType.String);
}
if (TJ > 4)
GoodsName = "";
JsonModel<List<HW_GoodsOutRecordBuy>> resultModel = new JsonModel<List<HW_GoodsOutRecordBuy>>();
int RowCount = 0;
resultModel.DataSource = DataNew.GetListHW_GoodsOutListBuy(TJ, CKType.TrimEnd(','), GoodsName, Param, PageIndex, PageSize, Sort, out RowCount);
resultModel.RowCount = RowCount;
if (IsDetail == 1 && resultModel.DataSource != null)
{
foreach (var md in resultModel.DataSource)
{
var list = DataNew.GetOutCKDetailListForTM(md.OutId.Value);
md.GoodsOutCKList2 = list;
}
}
return resultModel;
}
#endregion
#region 查询出库记录
[WebMethod(EnableSession = true)]
public string GetListHW_GoodsOutListBuyExcel(int TJ, int StoreId, int State, string GoodsName, string PayType, DateTime? SDate, DateTime? EDate, int IsDetail, string CKType, int PageIndex, int PageSize, string Sort)
{
var obj = new HuoWuData();
int CompanyId = Convert.ToInt32(Session["CompanyId"]);
RefParameterCollection Param = new RefParameterCollection();
Param.Add("a.CompanyId", "=", CompanyId, DbType.Int32);
// Param.Add("a.IsDelete", "=", 0, DbType.Int32);
if (PayType != "-1")
Param.Add("a.PayType", "=", PayType, DbType.String);
if (StoreId > 0)
Param.Add("a.StoreId", "=", StoreId, DbType.Int32);
if (State > 0)
Param.Add("a.IsDelete", "=", State, DbType.Int32);
else
Param.Add("a.IsDelete", "<>", 1, DbType.Int32);
if (SDate != null)
Param.Add("a.InDate", ">=", SDate, DbType.DateTime);
if (EDate != null)
Param.Add("a.InDate", "<", EDate.Value.AddDays(1), DbType.DateTime);
if (TJ == 6)
{
Param.Add("a.OutCode", "like", GoodsName.Trim(), DbType.String);
}
else
if (TJ == 7)
{
Param.Add("b.PlatOrderCode", "like", GoodsName.Trim(), DbType.String);
}
if (TJ > 4)
GoodsName = "";
JsonModel<List<HW_GoodsOutRecordBuy>> resultModel = new JsonModel<List<HW_GoodsOutRecordBuy>>();
int RowCount = 0;
resultModel.DataSource = DataNew.GetListHW_GoodsOutListBuy(TJ, CKType.TrimEnd(','), GoodsName, Param, PageIndex, PageSize, Sort, out RowCount);
resultModel.RowCount = RowCount;
List<HW_GoodsOutRecordBuy> excellist = new List<HW_GoodsOutRecordBuy>();
if (IsDetail == 1 && resultModel.DataSource != null)
{
foreach (var md in resultModel.DataSource)
{
excellist.Add(md);
var list = DataNew.GetOutCKDetailListForTM(md.OutId.Value);
md.GoodsOutCKList2 = list;
if (list != null)
{
foreach (var gmd in list)
{
HW_GoodsOutRecordBuy ggmd = new HW_GoodsOutRecordBuy();
// ggmd.BuyName = gmd.GoodsCode + " " + gmd.TypeDesc;
ggmd.State = "Commodity list";
ggmd.ExcelName = gmd.SKU1;
ggmd.ExcelName2 = gmd.OutNum.ToString();
ggmd.ExcelName3 = gmd.FinalPrice.Value.ToString("0.00");
excellist.Add(ggmd);
}
}
}
}
TableColumnCollection listColumns = new TableColumnCollection();
listColumns.Add("OutCode", "OrderCode", DbType.String, "");
listColumns.Add("InName", "Operator", DbType.String, "");
listColumns.Add("InDate", "BuyDate", DbType.String, "yyyy-MM-dd");
listColumns.Add("BuyName", "Purchaser Name", DbType.String, "");
listColumns.Add("BuyPhone", "Purchaser Phone", DbType.String, "");
listColumns.Add("Price", "Total Money", DbType.String, "");
listColumns.Add("commission", "commission", DbType.String, "");
listColumns.Add("StoreName", "StoreName", DbType.String, "");
listColumns.Add("PayType", "PayType", DbType.String, "");
listColumns.Add("State", "Status", DbType.String, "");
listColumns.Add("ExcelName", "SKU", DbType.String, "");
listColumns.Add("ExcelName2", "Selling Quantity", DbType.String, "");
listColumns.Add("ExcelName3", "Selling Price", DbType.String, "");
MicrosoftExcel obj2 = new MicrosoftExcel();
return obj2.Export(excellist, listColumns);
}
#endregion
#region 返回出库Model
[WebMethod(EnableSession = true)]
public HW_GoodsOutRecordBuy GetOutCKModelBuy(int OutId)
{
PagesNew.Login(this.Session);
var obj = new HuoWuData();
return DataNew.GetOutCKModelBuy(OutId);
}
#endregion
#region 返回出库明细
[WebMethod(EnableSession = true)]
public List<HW_GoodsOutCKNew> GetOutCKDetailListBuy(int OutId)
{
PagesNew.Login(this.Session);
var obj = new HuoWuData();
var list = DataNew.GetOutCKDetailListForTM(OutId);
return list;
}
#endregion
#region 导出采购单
[WebMethod(EnableSession = true)]
public string GetListBuyOutExcel(int outid)
{
PagesNew.Login(this.Session);
var obj = new DD_OrderData();
var list = DataNew.GetOutCKDetailListBuyExcel(outid);
if (list == null)
return "";
int i = 0;
foreach (var md in list)
{
if (i == 1)
{
md.OutCode = "";
md.BuyName = "";
md.BuyPhone = "";
}
i++;
}
var md2 = new HW_GoodsOutCKNew();
md2.PostionDesc = "Total";
md2.FinalPrice = list[0].Price;
list.Add(md2);
TableColumnCollection listColumns = new TableColumnCollection();
listColumns.Add("OutCode", "OrderCode", DbType.String, "");
listColumns.Add("BuyName", "BuyName", DbType.String, "");
listColumns.Add("BuyPhone", "BuyPhone", DbType.String, "");
listColumns.Add("GoodsCode", "Products Code", DbType.String, "");
listColumns.Add("SKU1", "SKU", DbType.String, "");
listColumns.Add("OutNum", "Selling Quantity", DbType.String, "");
listColumns.Add("Price", "Unit Price", DbType.String, "");
listColumns.Add("OffPrice", "Discount", DbType.String, "");
listColumns.Add("PostionDesc", "Storage Location", DbType.String, "");
listColumns.Add("FinalPrice", "Total price", DbType.String, "");
MicrosoftExcel obj2 = new MicrosoftExcel();
return obj2.Export(list, listColumns);
}
#endregion
#region 返回出库Model
[WebMethod(EnableSession = true)]
public string PrintReturnCode(string code,string ordercode)
{
PagesNew.Login(this.Session);
var obj = new HuoWuData();
string url= System.AppDomain.CurrentDomain.BaseDirectory + "ServerCookies/" + Guid.NewGuid().ToString() + ".jpg";
Image img = null;
GetBarcode(200, 500, BarcodeLib.TYPE.CODE128, code, out img, url);
JC_ExpressService service = new JC_ExpressService();
DataTable table = new DataTable();
table.Columns.Add("SKU2");
table.Columns.Add("Photo0");
string str2 = "";
DataRow row = table.NewRow();
row["Photo0"] = url;
row["SKU2"] = ordercode;
table.Rows.Add(row);
TableColumnCollection listColumns = new TableColumnCollection();
listColumns.Add("SKU2", "SKU2", DbType.String, "");
listColumns.Add("Photo0", "Photo0", DbType.Object, "200*100");
MicrosoftWord word = new MicrosoftWord();
str2 = word.Export("Scripts/returnlabel.doc", table, listColumns, ".pdf");
return str2;
}
#endregion
public static void GetBarcode(int height, int width, BarcodeLib.TYPE type, string code, out System.Drawing.Image image, string fileSaveUrl)
{
try
{
image = null;
BarcodeLib.Barcode b = new BarcodeLib.Barcode();
b.BackColor = System.Drawing.Color.White;//图片背景颜色
b.ForeColor = System.Drawing.Color.Black;//条码颜色
b.IncludeLabel = true;
b.Alignment = BarcodeLib.AlignmentPositions.LEFT;
b.LabelPosition = BarcodeLib.LabelPositions.BOTTOMCENTER;
b.ImageFormat = System.Drawing.Imaging.ImageFormat.Jpeg;//图片格式
System.Drawing.Font font = new System.Drawing.Font("verdana", 10f);//字体设置
b.LabelFont = font;
b.Height = height;//图片高度设置(px单位)
b.Width = width;//图片宽度设置(px单位)
image = b.Encode(type, code);//生成图片
image.Save(fileSaveUrl, System.Drawing.Imaging.ImageFormat.Jpeg);
}
catch (Exception ex)
{
image = null;
}
}
#region 保存
[WebMethod(EnableSession = true)]
public int Save_BFNum1(int detailid, int num1)
{
PagesNew.Login(this.Session);
DataNew.UpdateBuyBFNum1(detailid, num1);
return 1;
}
#endregion
#region 保存
[WebMethod(EnableSession = true)]
public int Save_BFNum2(int detailid, int num2)
{
PagesNew.Login(this.Session);
DataNew.UpdateBuyBFNum2(detailid, num2);
return 1;
}
#endregion
#region 保存
[WebMethod(EnableSession = true)]
public int Save_BFNum3(int detailid, DateTime? JH_Date)
{
PagesNew.Login(this.Session);
DataNew.UpdateBuyBFNum3(detailid, JH_Date);
return 1;
}
#endregion
#region 保存
[WebMethod(EnableSession = true)]
public int Save_BFNum4(int detailid, int num3)
{
PagesNew.Login(this.Session);
DataNew.UpdateBuyBFNum4(detailid, num3);
return 1;
}
#endregion
#region 保存
[WebMethod(EnableSession = true)]
public int Save_BFNum(int detailid,int num1,int num2)
{
PagesNew.Login(this.Session);
DataNew.UpdateBuyBFNum(detailid,num1,num2);
return 1;
}
#endregion
#region 保存
[WebMethod(EnableSession = true)]
public int UpdateSalesType(int detailid, int SalesType)
{
PagesNew.Login(this.Session);
DataNew.UpdateSalesType(detailid, SalesType);
return 1;
}
#endregion
#region 保存
[WebMethod(EnableSession = true)]
public int Clear_BFNum()
{
PagesNew.Login(this.Session);
DataNew.UpdateClearBFNum();
return 1;
}
#endregion
#region 导出备货
[WebMethod(EnableSession = true)]
public string GetList_GoodsBF(int CK)
{
var obj = new HuoWuData();
var list = DataNew.GetListBFNum(CK);
if (list == null)
return "";
var hjnum = list.Sum(n => n.BHNum);
var hjtj = list.Sum(n => n.TSolid);
var md = new HW_GoodsDetailNew();
md.SKU1 = "合计:";
md.BHNum = hjnum;
md.TSolid = hjtj;
list.Add(md);
TableColumnCollection listColumns = new TableColumnCollection();
listColumns.Add("SKU1", "货号", DbType.String, "");
listColumns.Add("Solid", "CMB", DbType.Decimal, "");
listColumns.Add("BHNum", "Number", DbType.Int32, "");
listColumns.Add("TSolid", "Total立方", DbType.Decimal, "");
listColumns.Add("JH_Date", "交货日期", DbType.String, "yyyy-MM-dd");
listColumns.Add("Cert", "已经出", DbType.Int32, "");
MicrosoftExcelNew obj2 = new MicrosoftExcelNew();
return obj2.Export(list, listColumns);
}
#endregion
#region 返回
[WebMethod(EnableSession = true)]
public HW_GoodsDetailNew GetGoodsModelForBF(int detailid)
{
PagesNew.Login(this.Session);
var obj = new HuoWuData();
return DataNew.GetGoodsModelForBF(detailid);
}
#endregion
#region 导出库存总立方前一百/两百
[WebMethod(EnableSession = true)]
public string GetList_GoodsSolid(int count)
{
var obj = new HuoWuData();
var list = DataNew.GetGoodsSolidTopDatas(count);
if (list == null)
return "";
var hjObj = new GoodsSolidTopModel();
hjObj.SKU = "合计";
hjObj.WestNum = list.Sum(r => r.WestNum);
hjObj.WestSolids = list.Sum(r => r.WestSolids);
hjObj.EastNum = list.Sum(r => r.EastNum);
hjObj.EastSolids = list.Sum(r => r.EastSolids);
hjObj.TotalNum = list.Sum(r => r.TotalNum);
hjObj.TotalSolid = list.Sum(r => r.TotalSolid);
list.Add(hjObj);
//创建工作薄
HSSFWorkbook workbook = new HSSFWorkbook();
HSSFSheet sheet = (HSSFSheet)workbook.CreateSheet("Sheet1");
sheet.SetColumnWidth(0, 18 * 256);
var drawing = sheet.CreateDrawingPatriarch();
//填充列标题以及样式
int rowsNum = 0; //行号
HSSFRow headerRow = (HSSFRow)sheet.CreateRow(rowsNum);
headerRow.CreateCell(0, CellType.STRING).SetCellValue("图片");
headerRow.CreateCell(1, CellType.STRING).SetCellValue("SKU");
headerRow.CreateCell(2, CellType.STRING).SetCellValue("编号");
headerRow.CreateCell(3, CellType.STRING).SetCellValue("名称");
headerRow.CreateCell(4, CellType.STRING).SetCellValue("人员");
headerRow.CreateCell(5, CellType.STRING).SetCellValue("单个立方");
headerRow.CreateCell(6, CellType.STRING).SetCellValue("西部库存数量");
headerRow.CreateCell(7, CellType.STRING).SetCellValue("西部库存立方");
headerRow.CreateCell(8, CellType.STRING).SetCellValue("东部库存数量");
headerRow.CreateCell(9, CellType.STRING).SetCellValue("东部库存立方");
headerRow.CreateCell(10, CellType.STRING).SetCellValue("总库存数量");
headerRow.CreateCell(11, CellType.STRING).SetCellValue("总库存立方");
rowsNum = 1; //行号
foreach (var link in list)
{
var pictureData = GetImageFromUrl(link.FirstImgUrl);
//byte[] pictureData = System.IO.File.ReadAllBytes(AppDomain.CurrentDomain.BaseDirectory + link.FirstImgUrl);
if (pictureData != null)
{
var pictureIndex = workbook.AddPicture(pictureData, PictureType.PNG);
// 在每一行的第一列插入图片
var pictureCell = sheet.CreateRow(rowsNum).CreateCell(0);
sheet.GetRow(rowsNum).Height = 80 * 20;
pictureCell.CellStyle = workbook.CreateCellStyle();
var anchor = new HSSFClientAnchor(0, 0, 0, 0, 0, rowsNum, 1, rowsNum + 1);
anchor.AnchorType = 2;
var picture = drawing.CreatePicture(anchor, pictureIndex);
}
else
{
var _dataCell = sheet.CreateRow(rowsNum).CreateCell(0);
sheet.GetRow(rowsNum).Height = 80 * 20;
_dataCell.SetCellValue("");
}
// 在每一行的第二列插入数据
sheet.GetRow(rowsNum).CreateCell(1).SetCellValue(link.SKU);
sheet.GetRow(rowsNum).CreateCell(2).SetCellValue(link.GoodsCode);
sheet.GetRow(rowsNum).CreateCell(3).SetCellValue(link.GoodsName);
sheet.GetRow(rowsNum).CreateCell(4).SetCellValue(link.UserName);
sheet.GetRow(rowsNum).CreateCell(5).SetCellValue(link.SingleSolid.ToString());
sheet.GetRow(rowsNum).CreateCell(6).SetCellValue(link.WestNum.ToString());
sheet.GetRow(rowsNum).CreateCell(7).SetCellValue(link.WestSolids.ToString());
sheet.GetRow(rowsNum).CreateCell(8).SetCellValue(link.EastNum.ToString());
sheet.GetRow(rowsNum).CreateCell(9).SetCellValue(link.EastSolids.ToString());
sheet.GetRow(rowsNum).CreateCell(10).SetCellValue(link.TotalNum.ToString());
sheet.GetRow(rowsNum).CreateCell(11).SetCellValue(link.TotalSolid.ToString());
rowsNum++;
}
string filename = Guid.NewGuid().ToString() + ".xls";
string DirectoryName = AppDomain.CurrentDomain.BaseDirectory + "ServerCookies";
if (System.IO.Directory.Exists(DirectoryName) == false) System.IO.Directory.CreateDirectory(DirectoryName);
string ServerFileName = DirectoryName + "/" + filename;
//保存
using (FileStream fs = new FileStream(ServerFileName, FileMode.Create, FileAccess.Write))
{
workbook.Write(fs);
}
workbook.Dispose();
return "ServerCookies/" + filename;
}
#region 导出编号分配销量
[WebMethod(EnableSession = true)]
public string GetList_GoodsForPlan()
{
var obj = new HuoWuData();
var list = DataNew.GetGoodsforPlan();
if (list == null)
return "";
//创建工作薄
HSSFWorkbook workbook = new HSSFWorkbook();
HSSFSheet sheet = (HSSFSheet)workbook.CreateSheet("Sheet1");
sheet.SetColumnWidth(0, 18 * 256);
var drawing = sheet.CreateDrawingPatriarch();
//填充列标题以及样式
int rowsNum = 0; //行号
HSSFRow headerRow = (HSSFRow)sheet.CreateRow(rowsNum);
headerRow.CreateCell(0, CellType.STRING).SetCellValue("图片");
headerRow.CreateCell(1, CellType.STRING).SetCellValue("SKU");
headerRow.CreateCell(4, CellType.STRING).SetCellValue("人员");
rowsNum = 1; //行号
foreach (var link in list)
{
var pictureData = GetImageFromUrl(link.FirstImgUrl);
if (pictureData != null)
{
var pictureIndex = workbook.AddPicture(pictureData, PictureType.PNG);
// 在每一行的第一列插入图片
var pictureCell = sheet.CreateRow(rowsNum).CreateCell(0);
sheet.GetRow(rowsNum).Height = 80 * 20;
pictureCell.CellStyle = workbook.CreateCellStyle();
var anchor = new HSSFClientAnchor(0, 0, 0, 0, 0, rowsNum, 1, rowsNum + 1);
anchor.AnchorType = 2;
var picture = drawing.CreatePicture(anchor, pictureIndex);
}
else
{
var _dataCell = sheet.CreateRow(rowsNum).CreateCell(0);
sheet.GetRow(rowsNum).Height = 80 * 20;
_dataCell.SetCellValue("");
}
// 在每一行的第二列插入数据
sheet.GetRow(rowsNum).CreateCell(2).SetCellValue(link.GoodsCode);
sheet.GetRow(rowsNum).CreateCell(3).SetCellValue(link.GoodsName);
sheet.GetRow(rowsNum).CreateCell(4).SetCellValue(link.UserName);
rowsNum++;
}
string filename = Guid.NewGuid().ToString() + ".xls";
string DirectoryName = AppDomain.CurrentDomain.BaseDirectory + "ServerCookies";
if (System.IO.Directory.Exists(DirectoryName) == false) System.IO.Directory.CreateDirectory(DirectoryName);
string ServerFileName = DirectoryName + "/" + filename;
//保存
using (FileStream fs = new FileStream(ServerFileName, FileMode.Create, FileAccess.Write))
{
workbook.Write(fs);
}
workbook.Dispose();
return "ServerCookies/" + filename;
}
#endregion
// 从URL获取图片数据
public byte[] GetImageFromUrl(string url)
{
try
{
using (WebClient webClient = new WebClient())
{
return webClient.DownloadData(new Uri(url));
}
}
catch (Exception ex)
{
return null;
}
}
#endregion
[WebMethod(EnableSession = true)]
public string GetGoodsCodeLabel(string code, int num)
{
PagesNew.Login(base.Session);
OrderPrintData data = new OrderPrintData();
DataTable table = new DataTable();
table.Columns.Add("SKU2");
string str2 = "";
string wordTemplatePath = "";
for(int i=0;i<num; i++)
{
wordTemplatePath = "Scripts/code.doc";
DataRow row = table.NewRow();
row["SKU2"] = code;
table.Rows.Add(row);
}
TableColumnCollection listColumns = new TableColumnCollection();
listColumns.Add("SKU2", "SKU2", DbType.String, "");
MicrosoftWord word = new MicrosoftWord();
if (wordTemplatePath != null)
{
str2 = word.Export(wordTemplatePath, table, listColumns, ".pdf");
}
return str2;
}
[WebMethod(EnableSession = true)]
public string GeStoreLabel(List<CK_StorePostion> list)
{
PagesNew.Login(base.Session);
if (list == null)
return "";
OrderPrintData data = new OrderPrintData();
DataTable table = new DataTable();
table.Columns.Add("Photo2");
table.Columns.Add("SKU2");
string str2 = "";
string wordTemplatePath = "";
wordTemplatePath = "Scripts/storecode.doc";
foreach (var md in list)
{
string code = md.PostionCode;
System.Drawing.Image img = GetBarcodeBitmap(code, 80, 270);
string path = AppDomain.CurrentDomain.BaseDirectory + "attached/storecode/" + code + "code.jpg";
img.Save(path, System.Drawing.Imaging.ImageFormat.Jpeg);
DataRow row = table.NewRow();
row["Photo2"] = path;
row["SKU2"] = code;
table.Rows.Add(row);
}
TableColumnCollection listColumns = new TableColumnCollection();
listColumns.Add("SKU2", "SKU2", DbType.String, "");
listColumns.Add("Photo2", "Photo2", DbType.Object, "80*270");
MicrosoftWord word = new MicrosoftWord();
if (wordTemplatePath != null)
{
str2 = word.Export(wordTemplatePath, table, listColumns, ".pdf");
}
return str2;
}
/// <summary>
/// 生成条形码
/// </summary>
/// <param name="barcodeContent">需要生成条码的内容</param>
/// <param name="barcodeWidth">条码宽度</param>
/// <param name="barcodeHeight">条码长度</param>
/// <returns>返回条码图形</returns>
public static Bitmap GetBarcodeBitmap(string barcodeContent, int barcodeWidth, int barcodeHeight)
{
BarcodeWriter barcodeWriter = new BarcodeWriter();
barcodeWriter.Format = BarcodeFormat.CODE_39;//设置编码格式
EncodingOptions encodingOptions = new EncodingOptions();
encodingOptions.Width = barcodeWidth;//设置宽度
encodingOptions.Height = barcodeHeight;//设置长度
encodingOptions.Margin = 2;//设置边距
barcodeWriter.Options = encodingOptions;
Bitmap bitmap = barcodeWriter.Write(barcodeContent);
return bitmap;
}
#region 导入新ASIN
[WebMethod(EnableSession = true)]
public string ImportASIN(string FileName)
{
PagesNew.Login(this.Session);
if (string.IsNullOrEmpty(FileName) == true) return "要导入的文件路径不能为空";
string ServerFileName = AppDomain.CurrentDomain.BaseDirectory + FileName;
if (System.IO.File.Exists(ServerFileName) == false) return "要导入的文件路径不存在";
int CompanyId = Convert.ToInt32(Session["CompanyId"]);
try
{
MicrosoftExcel excel = new MicrosoftExcel();
DataTable tb = excel.ImportExcel(ServerFileName);
string error = "";
if (tb.Columns.Contains("ASIN") == false) { error = error + "导入模板的 ASIN 列不存在"; }
if (tb.Columns.Contains("SKU") == false) { error = error + "导入模板的 SKU 列不存在"; }
if (tb.Columns.Contains("店铺") == false) { error = error + "导入模板的 店铺 列不存在"; }
if (string.IsNullOrEmpty(error) == false) return error + ";请导入格式不正确";
List<DD_GoodsPM> OrderList = new List<DD_GoodsPM>();
int count = 0;
for (int i = 0; i < tb.Rows.Count; i++)
{
DD_GoodsPM md = new DD_GoodsPM();
if (tb.Rows[i]["ASIN"].ToString().Trim() != "")
{
md.asin = tb.Rows[i]["ASIN"].ToString().Trim();
md.sku = tb.Rows[i]["SKU"].ToString().Trim();
md.shopname = tb.Rows[i]["店铺"].ToString().Trim();
md.state = 1;
md.sync = 0;
int a = DataNew.Save_GoodsPMExcel(md);
if (a == -1)
{
error += md.asin + "店铺名对应不上";
}
else if (a == -2)
{
error += md.asin + "sku对应不上";
}
else
{
count++;
}
}
}
error = "数据导入成功【" + count + "条】;" + error;
return error;
//}
}
catch (Exception e)
{
return "文件导入失败!请确定模板格式是否正确,或者重新下载模板,填写数据,重新导入!!!" + e.Message;
}
return "导入成功";
}
#endregion
#region 批量删除
[WebMethod(EnableSession = true)]
public int PL_DeletePM(List<DD_GoodsPM> list)
{
PagesNew.Login(this.Session);
foreach (var md in list)
{
DataNew.Delete_GoodsPM(md.id.Value);
}
return 1;
}
#endregion
#region 保存
[WebMethod(EnableSession = true)]
public int Save_GoodsPM(DD_GoodsPM Model)
{
PagesNew.Login(this.Session);
return DataNew.Save_GoodsPM(Model);
}
#endregion
#region 删除
[WebMethod(EnableSession = true)]
public bool Delete_GoodsPM(int id)
{
PagesNew.Login(this.Session);
DataNew.Delete_GoodsPM(id);
return true;
}
#endregion
#region 分页查询
[WebMethod(EnableSession = true)]
public JsonModel<List<DD_GoodsPM>> GetListGoodsPM(string cs, int PageIndex, int PageSize)
{
PagesNew.Login(this.Session);
string where = CustomIO.Base64StringToString(cs);
if (where != "") where = "where " + where.Substring(4);
var resultModel = new JsonModel<List<DD_GoodsPM>>();
int RowCount = 0;
resultModel.DataSource = DataNew.GetListGoodsPM(where, PageIndex, PageSize, "", out RowCount);
resultModel.RowCount = RowCount;
return resultModel;
}
#endregion
#region 保存
[WebMethod(EnableSession = true)]
public int Save_IsSp(int detailid, Boolean issp)
{
PagesNew.Login(this.Session);
DataNew.UpdatetGoodsIsSP(detailid, issp);
return 1;
}
#endregion
#region 查询货物分类
[WebMethod(EnableSession = true)]
public List<HW_GoodsSortModel> GetGoodsSortList()
{
PagesNew.Login(this.Session);
var obj = new HuoWuData();
int CompanyId = Convert.ToInt32(Session["CompanyId"]);
var list = obj.GetGoodsSort(CompanyId);
//if (list != null)
//{
// var md = new HW_GoodsSortModel();
// md.SortId = 0;
// md.SortNo = "";
// md.SortName = "-无-";
// list.Add(md);
//}
return list;
}
#endregion
#region
[WebMethod(EnableSession = true)]
public int GetGoodsOutMess()
{
PagesNew.Login(this.Session);
var obj = new HuoWuData();
int UserId = Convert.ToInt32(Session["UserId"]);
int num = DataNew.GetGoodsOutMess(UserId);
return num;
}
#endregion
#region
[WebMethod(EnableSession = true)]
public decimal GetGoodsKCTJNum()
{
PagesNew.Login(this.Session);
var obj = new HuoWuData();
decimal num = DataNew.GetGoodsKCTJNum();
return num;
}
#endregion
#region
[WebMethod(EnableSession = true)]
public DT_DefaultDataNew GetNMOrderTJ()
{
PagesNew.Login(this.Session);
var obj = new HuoWuData();
var md = DataNew.GetNMOrderTJ();
return md;
}
#endregion
#region 返回人员列表
[WebMethod(EnableSession = true)]
public List<JC_UserInfo> GetListUserSelect()
{
PagesNew.Login(this.Session);
var list = DataNew.GetListUserSelect();
return list;
}
#endregion
#region 修改编号分配
[WebMethod(EnableSession = true)]
public int UpdateGoodsMate(int platid,int goodsid, int userid, string name)
{
PagesNew.Login(this.Session);
DataNew.UpdateGoodsMate(platid,goodsid, userid,name);
return 1;
}
#endregion
#region 修改商品方案数
[WebMethod(EnableSession = true)]
public int UpdateGoodsPlanCount(int goodsid,int? planCount)
{
PagesNew.Login(this.Session);
DataNew.UpdateGoodsPlanCount(goodsid,planCount);
return 1;
}
#endregion
#region 修改商品方案数
[WebMethod(EnableSession = true)]
public APIReturnModel UpdateGoodsEditPlanCount(int goodsid, int? edplanCount)
{
PagesNew.Login(this.Session);
var rmodel = new APIReturnModel();
try
{
DataNew.UpdateGoodsEditPlanCount(goodsid, edplanCount);
rmodel.Code = 1;
rmodel.Message = "成功";
}
catch (Exception ex)
{
rmodel.Code = 0;
rmodel.Message = "失败:" + ex.Message;
}
return rmodel;
}
#endregion
#region 修改编号分配
[WebMethod(EnableSession = true)]
public int UpdateGoodsMateFromGoodids(List<HW_ProductionPlan> list, int userid, string name,int platid)
{
PagesNew.Login(this.Session);
foreach (var md in list)
{
DataNew.UpdateGoodsMate(platid,md.id.Value, userid, name);
}
return 1;
}
#endregion
#region 查询货物分类
[WebMethod(EnableSession = true)]
public List<HW_GoodsSortModel> GetGoodsSortListNew()
{
PagesNew.Login(this.Session);
var obj = new HuoWuData();
int CompanyId = Convert.ToInt32(Session["CompanyId"]);
var list = DataNew.GetGoodsSort(CompanyId);
return list;
}
#endregion
#region 保存sku计划
[WebMethod(EnableSession = true)]
public int Save_GoodsUserPlanCount(HW_GoodsUserPlanCount Model)
{
PagesNew.Login(this.Session);
return DataNew.Save_GoodsUserPlanCount(Model);
}
#endregion
#region 人员部门
[WebMethod(EnableSession = true)]
public int GetModel_UserDept()
{
PagesNew.Login(this.Session);
int userid = Convert.ToInt32(Session["UserId"]);
return DataNew.GetModel_UserDept(userid);
}
#endregion
#region 分页查询
[WebMethod(EnableSession = true)]
public JsonModel<List<HW_GoodsUserPlanCount>> GetListGoodsUserPlanCount(string cs, int PageIndex, int PageSize)
{
PagesNew.Login(this.Session);
string where = CustomIO.Base64StringToString(cs);
if (where != "") where = "where " + where.Substring(4);
var resultModel = new JsonModel<List<HW_GoodsUserPlanCount>>();
int RowCount = 0;
resultModel.DataSource = DataNew.GetListGoodsUserPlanCount(where, PageIndex, PageSize, "", out RowCount);
resultModel.RowCount = RowCount;
return resultModel;
}
#endregion
#region 分页查询
[WebMethod(EnableSession = true)]
public JsonModel<List<HW_ProductionPlan>> GetListGoodsPlan(int iscg,int platid, int muserid, int isly,DateTime? lysdt, DateTime? lyedt,DateTime? lysdt2, DateTime? lyedt2,string lynr, string cs, string name, int IsFP, int IsLJ, int IsEnd, int cdtj,int iskc,int fas,int shopId,int isShowAll,int isOnlyYC, int PageIndex, int PageSize)
{
PagesNew.Login(this.Session);
string where = CustomIO.Base64StringToString(cs);
if (where != "") where = "where " + where.Substring(4) + " and a.state=1 and a.companyid=1 ";
else
where = "where a.state=1 and a.companyid=1 ";
if (isShowAll != 1)//不展示所有
{
if (isOnlyYC == 1)//只展示隐藏
{
where += " and Isnull(a.IsYC,0)=1";
}
else
{
where += " and Isnull(a.IsYC,0)=0";
}
}
else //展示所有
{
if (isOnlyYC == 1)//只展示隐藏
{
where += " and Isnull(a.IsYC,0)=1";
}
}
//if (platid == 2 && muserid > 0)
//{
// where += " and a.muserid=" + muserid + " ";
//}
//else if (platid == 3 && muserid > 0)
//{
// where += " and a.guserid_ebay=" + muserid + " ";
//}
//else if (platid == 6 && muserid > 0)
//{
// where += " and a.guserid_wlmart=" + muserid + " ";
//}
//else if (platid == 15 && muserid > 0)
//{
// where += " and a.guserid_shopify=" + muserid + " ";
//}
//else if (platid == 18&& muserid > 0)
//{
// where += " and a.guserid_wayfair=" + muserid + " ";
//}
//else if (platid == 21 && muserid > 0)
//{
// where += " and a.guserid_sheIn=" + muserid + " ";
//}
//if (platid == 2 && muserid > 0)
//{
// where += " and (a.muserid=" + muserid + " or a.muserid in( select UserId from JC_UserInfo where guserid=" + muserid + " ))";
//}
//else if (platid == 3 && muserid > 0)
//{
// where += " and (a.guserid_ebay=" + muserid + " or a.guserid_ebay in( select UserId from JC_UserInfo where guserid=" + muserid + " ))";
//}
//else if (platid == 6 && muserid > 0)
//{
// where += " and (a.guserid_wlmart=" + muserid + " or a.guserid_wlmart in( select UserId from JC_UserInfo where guserid=" + muserid + " ))";
//}
//else if (platid == 15 && muserid > 0)
//{
// where += " and (a.guserid_shopify=" + muserid + " or a.guserid_shopify in( select UserId from JC_UserInfo where guserid=" + muserid + " ))";
//}
//else if (platid == 18 && muserid > 0)
//{
// where += " and (a.guserid_wayfair=" + muserid + " or a.guserid_wayfair in( select UserId from JC_UserInfo where guserid=" + muserid + " ))";
//}
//else if (platid == 21 && muserid > 0)
//{
// where += " and (a.guserid_sheIn=" + muserid + " or a.guserid_sheIn in( select UserId from JC_UserInfo where guserid=" + muserid + " ))";
//}
int userid = Convert.ToInt32(Session["UserId"]);
if (userid == 126)//美工需要看到所有商品
iscg = 0;
//如果是管理员账号选择全部则显示所有,并且选择组长时显示下属所有组员数据,
if(userid==1 || userid==51 || userid==53 || userid == 114 || userid==32 || userid==170 || userid==225 || userid==126 || userid==115 || userid==251)
{
if (platid == 2 && muserid > 0)
{
where += " and (a.muserid=" + muserid + " or a.muserid in( select UserId from JC_UserInfo where guserid=" + muserid + " ))";
}
else if (platid == 3 && muserid > 0)
{
where += " and (a.guserid_ebay=" + muserid + " or a.guserid_ebay in( select UserId from JC_UserInfo where guserid=" + muserid + " ))";
}
else if (platid == 6 && muserid > 0)
{
where += " and (a.guserid_wlmart=" + muserid + " or a.guserid_wlmart in( select UserId from JC_UserInfo where guserid=" + muserid + " ))";
}
else if (platid == 15 && muserid > 0)
{
where += " and (a.guserid_shopify=" + muserid + " or a.guserid_shopify in( select UserId from JC_UserInfo where guserid=" + muserid + " ))";
}
else if (platid == 18 && muserid > 0)
{
where += " and (a.guserid_wayfair=" + muserid + " or a.guserid_wayfair in( select UserId from JC_UserInfo where guserid=" + muserid + " ))";
}
else if (platid == 21 && muserid > 0)
{
where += " and (a.guserid_sheIn=" + muserid + " or a.guserid_sheIn in( select UserId from JC_UserInfo where guserid=" + muserid + " ))";
}
else if (platid == 22 && muserid > 0)
{
where += " and (a.guserid_tiktok=" + muserid + " or a.guserid_tiktok in( select UserId from JC_UserInfo where guserid=" + muserid + " ))";
}
else if (platid == 23 && muserid > 0)
{
where += " and (a.guserid_temu=" + muserid + " or a.guserid_temu in( select UserId from JC_UserInfo where guserid=" + muserid + " ))";
}
}
else //如果不是管理员,选择全部是才显示自己以及下属所有组员数据,选择单个人时,只显示选中人的数据
{
if(muserid==0)//选择全部
{
if (platid == 2)
{
where += " and (a.muserid=" + userid + " or a.muserid in( select UserId from JC_UserInfo where guserid=" + userid + " ))";
}
else if (platid == 3)
{
where += " and (a.guserid_ebay=" + userid + " or a.guserid_ebay in( select UserId from JC_UserInfo where guserid=" + userid + " ))";
}
else if (platid == 6)
{
where += " and (a.guserid_wlmart=" + userid + " or a.guserid_wlmart in( select UserId from JC_UserInfo where guserid=" + userid + " ))";
}
else if (platid == 15)
{
where += " and (a.guserid_shopify=" + userid + " or a.guserid_shopify in( select UserId from JC_UserInfo where guserid=" + userid + " ))";
}
else if (platid == 18)
{
where += " and (a.guserid_wayfair=" + userid + " or a.guserid_wayfair in( select UserId from JC_UserInfo where guserid=" + userid + " ))";
}
else if (platid == 21)
{
where += " and (a.guserid_sheIn=" + userid + " or a.guserid_sheIn in( select UserId from JC_UserInfo where guserid=" + userid + " ))";
}
else if (platid == 22)
{
where += " and (a.guserid_tiktok=" + userid + " or a.guserid_tiktok in( select UserId from JC_UserInfo where guserid=" + userid + " ))";
}
else if (platid == 23)
{
where += " and (a.guserid_temu=" + userid + " or a.guserid_temu in( select UserId from JC_UserInfo where guserid=" + userid + " ))";
}
}
else //选择单个人
{
if (platid == 2 && muserid > 0)
{
where += " and a.muserid=" + muserid + " ";
}
else if (platid == 3 && muserid > 0)
{
where += " and a.guserid_ebay=" + muserid + " ";
}
else if (platid == 6 && muserid > 0)
{
where += " and a.guserid_wlmart=" + muserid + " ";
}
else if (platid == 15 && muserid > 0)
{
where += " and a.guserid_shopify=" + muserid + " ";
}
else if (platid == 18 && muserid > 0)
{
where += " and a.guserid_wayfair=" + muserid + " ";
}
else if (platid == 21 && muserid > 0)
{
where += " and a.guserid_sheIn=" + muserid + " ";
}
else if (platid == 22 && muserid > 0)
{
where += " and a.guserid_tiktok=" + muserid + " ";
}
else if (platid == 23 && muserid > 0)
{
where += " and a.guserid_temu=" + muserid + " ";
}
}
}
string cgname = Convert.ToString(Session["Name"]);
if (iscg == 1&& userid!=32 && userid!=170)
{
where += " and (a.KFName='" + cgname + "' or a.KFName2='" + cgname + "' )";
}
if (IsEnd == 0)
where += " and isnull(a.IsEnd,0)=0 ";
if (fas != -1)
where += " and isnull(a.PlanCount,0)=" + fas;
if (platid == 2)
{
if (isly == 1 && userid == 1)
where += " and (isnull(a.Leaveword,'')<>'' or isnull(a.Leaveword_cg,'')<>'') ";
else
if (isly == 1 && iscg == 0)
where += " and isnull(a.Leaveword,'')<>'' ";
else if (isly == 1 && iscg == 1)
where += " and isnull(a.Leaveword_cg,'')<>'' ";
}
else if (platid == 3)
{
if (isly == 1 && userid == 1)
where += " and (isnull(a.LeaveWord_ebay,'')<>'' or isnull(a.Leaveword_cg,'')<>'') ";
else
if (isly == 1 && iscg == 0)
where += " and isnull(a.LeaveWord_ebay,'')<>'' ";
else if (isly == 1 && iscg == 1)
where += " and isnull(a.Leaveword_cg,'')<>'' ";
}
else if (platid == 6)
{
if (isly == 1 && userid == 1)
where += " and (isnull(a.LeaveWord_walmart,'')<>'' or isnull(a.Leaveword_cg,'')<>'') ";
else
if (isly == 1 && iscg == 0)
where += " and isnull(a.LeaveWord_walmart,'')<>'' ";
else if (isly == 1 && iscg == 1)
where += " and isnull(a.Leaveword_cg,'')<>'' ";
}
else if (platid == 15)
{
if (isly == 1 && userid == 1)
where += " and (isnull(a.LeaveWord_shopify,'')<>'' or isnull(a.Leaveword_cg,'')<>'') ";
else
if (isly == 1 && iscg == 0)
where += " and isnull(a.LeaveWord_shopify,'')<>'' ";
else if (isly == 1 && iscg == 1)
where += " and isnull(a.Leaveword_cg,'')<>'' ";
}
else if (platid == 18)
{
if (isly == 1 && userid == 1)
where += " and (isnull(a.LeaveWord_wayfair,'')<>'' or isnull(a.Leaveword_cg,'')<>'') ";
else
if (isly == 1 && iscg == 0)
where += " and isnull(a.LeaveWord_wayfair,'')<>'' ";
else if (isly == 1 && iscg == 1)
where += " and isnull(a.Leaveword_cg,'')<>'' ";
}
else if (platid == 21)
{
if (isly == 1 && userid == 1)
where += " and (isnull(a.LeaveWord_shein,'')<>'' or isnull(a.Leaveword_cg,'')<>'') ";
else
if (isly == 1 && iscg == 0)
where += " and isnull(a.LeaveWord_shein,'')<>'' ";
else if (isly == 1 && iscg == 1)
where += " and isnull(a.Leaveword_cg,'')<>'' ";
}
else if (platid == 22)
{
if (isly == 1 && userid == 1)
where += " and (isnull(a.LeaveWord_tiktok,'')<>'' or isnull(a.Leaveword_cg,'')<>'') ";
else
if (isly == 1 && iscg == 0)
where += " and isnull(a.LeaveWord_tiktok,'')<>'' ";
else if (isly == 1 && iscg == 1)
where += " and isnull(a.Leaveword_cg,'')<>'' ";
}
else if (platid == 23)
{
if (isly == 1 && userid == 1)
where += " and (isnull(a.LeaveWord_temu,'')<>'' or isnull(a.Leaveword_cg,'')<>'') ";
else
if (isly == 1 && iscg == 0)
where += " and isnull(a.LeaveWord_temu,'')<>'' ";
else if (isly == 1 && iscg == 1)
where += " and isnull(a.Leaveword_cg,'')<>'' ";
}
string goodsids = "";
List<DT_OrderGoods> olist = null;
if (lysdt2 != null && lyedt2 != null)//根据没有留言日期查留言
{
var lylist = DataNew.GetListGoodsLeaveWordFromDate(lysdt2, lyedt2.Value.AddDays(1), platid, "");
if (lylist != null)
{
foreach (var lmd in lylist)
{
goodsids += lmd.goodsid.ToString() + ",";
}
}
if (goodsids != "")
{
goodsids = goodsids.TrimEnd(',');
where += " and a.goodsid not in (" + goodsids + ") "; //在这个日期范围内没有留言的产品
}
}
else
{
if (lysdt != null && lyedt != null)//根据日期查留言
{
var lylist = DataNew.GetListGoodsLeaveWordFromDate(lysdt, lyedt.Value.AddDays(1), platid, lynr);
if (lylist != null)
{
foreach (var lmd in lylist)
{
goodsids += lmd.goodsid.ToString() + ",";
}
}
else
{
goodsids = "0,";
}
}
if (goodsids != "")
{
goodsids = goodsids.TrimEnd(',');
where += " and a.goodsid in (" + goodsids + ") ";
olist = DataNew.GetListGoodsOrdersFromDate(lysdt, lyedt.Value.AddDays(1), goodsids, platid);//根据留言货统计订单数量
}
}
var resultModel = new JsonModel<List<HW_ProductionPlan>>();
int RowCount = 0;
resultModel.DataSource = DataNew.GetListGoodsPlan(platid, name, IsFP, IsLJ, where, cdtj,iskc,shopId, PageIndex, PageSize, "", out RowCount);
resultModel.RowCount = RowCount;
string mids = "";
if (resultModel.DataSource != null)
{
foreach (var md in resultModel.DataSource)
{
mids += md.id + ",";
if (md.Leaveword != null && md.Leaveword != "")
md.readname = "阅读";
if (md.Leaveword_cg != null && md.Leaveword_cg != "")
md.readname_cg = "阅读";
if (olist != null)
{
var oomd = olist.Find(n => n.GoodsId == md.id);
if (oomd != null)
{
md.OrderNum = oomd.GoodsNum;
}
}
}
List<AD_FeeCompute> adlist = null;
if (mids != "")
{
var glist = DataNew.GetListGoodsPlanDetail2(mids.TrimEnd(','), platid);
var upDayList = DataNew.GetGoodsUpFirstList(mids.TrimEnd(','));//商品第一次上架日期
var imList = DataNew.GetGoodsDayImpressionsList(mids.TrimEnd(','));//商品每天的曝光量
var last2DayadFees = DataNew.GetGoodsLast2DayAdFeeList(mids.TrimEnd(','));//商品前天的广告花费
var imDaysList = DataNew.GetShopGoodDayImpressionsList(mids.TrimEnd(','));//获取商品前三十天的曝光量
var ginNumList = DataNew.GetGoodsInNumList(mids.TrimEnd(','));//获取商品生产中和完成的数量
var goodsSortList = DataNew.GetGoodsSortShopModelForGoodIds(mids.TrimEnd(','));//获取商品所属类目关联的店铺
var goodsBuyLinkList = DataNew.GetHWBuyLinkModelForGoodIds(mids.TrimEnd(','));//获取商品的所有购买链接
//30天为0的折线图数据
var nullImDaysList = new List<ZXTDataModel>();
for (var d = -30; d < 0; d++)
{
nullImDaysList.Add(new ZXTDataModel { Name = DateTime.Now.AddDays(d).ToString("yyyy-MM-dd"), Value = 0 });
}
if (platid == 2)
{
adlist = DataNew.GetListFeeCompute(mids.TrimEnd(','));
}
var pmList= DataNew.GetOrderGoodsCodeData();
if (glist != null)
{
foreach (var md in resultModel.DataSource)
{
var gmdlist = glist.FindAll(n => n.GoodsId == md.id);
if (gmdlist != null)
{
for (int i = 0; i < gmdlist.Count; i++)
{
string pmStr = "";//小类/大类排名
decimal? lastWeekFee = null;
decimal? prefee = null;
decimal? weeklr = null;
decimal? nextfee = 0.1M;
string UpDay = "";//商品第一次上传时间
int? impressinos = 0;//曝光量
decimal? last2dayAdFee = null;//前天广告费用
List<ZXTDataModel> zxtDatas=new List<ZXTDataModel>(); //前三十天的曝光量折线图数据
int ftype = 0;
if (adlist != null)
{
var sadmd = adlist.Find(n => n.GoodsId == gmdlist[i].GoodsId && n.ShopId == gmdlist[i].ShopId);
if (sadmd != null)
{
lastWeekFee = sadmd.WeekFee2;
prefee = sadmd.PreDayFee1;
weeklr = sadmd.WeekLR2-sadmd.WeekFee2;
nextfee = sadmd.NextFee;
if(sadmd.Type!=null)
ftype = sadmd.Type.Value;
}
}
var pmobj = pmList != null ? pmList.Find(n => n.GoodsId == gmdlist[i].GoodsId && n.ShopId == gmdlist[i].ShopId) : null;
if (pmobj != null)
{
pmStr = pmobj.Int3.ToString() + "/" + pmobj.Int2.ToString();
}
var upDayObj = upDayList != null ? upDayList.Find(n => n.GoodsId == gmdlist[i].GoodsId && n.ShopId == gmdlist[i].ShopId) : null;
if (upDayObj != null)
UpDay = upDayObj.FirstDay;
var imObj = imList != null ? imList.Find(n => n.GoodsId == gmdlist[i].GoodsId && n.ShopId == gmdlist[i].ShopId) : null;
if (imObj != null)
impressinos = imObj.Impressions;
var lastAdfeeObj = last2DayadFees != null ? last2DayadFees.Find(n => n.goodsid == gmdlist[i].GoodsId && n.shopid == gmdlist[i].ShopId) : null;
if (lastAdfeeObj != null)
last2dayAdFee = lastAdfeeObj.spend;
var zxtDataList = imDaysList != null ? imDaysList.Where(r => r.ShopId == gmdlist[i].ShopId && r.GoodsId == gmdlist[i].GoodsId).ToList() : null;
if (zxtDataList != null)
{
zxtDatas = zxtDataList.OrderBy(r => r.RDate).Select(r => new ZXTDataModel { Name = r.RDate.ToString("yyyy-MM-dd"), Value = r.Impressions }).ToList();
}
else
{
zxtDatas = nullImDaysList;
}
switch (i)
{
case 0:
md.ShopName1 = gmdlist[i].ShopName;// + "[" + gmdlist[i].Name + "]";
md.ShopUrl1 = gmdlist[i].url;
md.PreDayFee1 = prefee;
md.WeekLR1 = weeklr;
md.NextFee1 = nextfee;
md.NextFeeType1 = ftype;
md.LastWeekFee1 = lastWeekFee;
md.SmallAndBigRank1 = pmStr;
md.UpFirstDay1 = UpDay;
md.Impressions1 = impressinos;
md.Last2DayAdfee1 = last2dayAdFee;
md.BGLZXTData1 = zxtDatas;
break;
case 1:
md.ShopName2 = gmdlist[i].ShopName;// + "[" + gmdlist[i].Name + "]";
md.ShopUrl2 = gmdlist[i].url;
md.PreDayFee2 = prefee;
md.WeekLR2 = weeklr;
md.NextFee2 = nextfee;
md.NextFeeType2 = ftype;
md.LastWeekFee2 = lastWeekFee;
md.SmallAndBigRank2 = pmStr;
md.UpFirstDay2 = UpDay;
md.Impressions2 = impressinos;
md.Last2DayAdfee2 = last2dayAdFee;
md.BGLZXTData2 = zxtDatas;
break;
case 2:
md.ShopName3 = gmdlist[i].ShopName;// + "[" + gmdlist[i].Name + "]";
md.ShopUrl3 = gmdlist[i].url;
md.PreDayFee3 = prefee;
md.WeekLR3 = weeklr;
md.NextFee3 = nextfee;
md.NextFeeType3 = ftype;
md.LastWeekFee3 = lastWeekFee;
md.SmallAndBigRank3 = pmStr;
md.UpFirstDay3 = UpDay;
md.Impressions3 = impressinos;
md.Last2DayAdfee3 = last2dayAdFee;
md.BGLZXTData3 = zxtDatas;
break;
case 3:
md.ShopName4 = gmdlist[i].ShopName;// + "[" + gmdlist[i].Name + "]";
md.ShopUrl4 = gmdlist[i].url;
md.PreDayFee4= prefee;
md.WeekLR4 = weeklr;
md.NextFee4 = nextfee;
md.NextFeeType4 = ftype;
md.LastWeekFee4 = lastWeekFee;
md.SmallAndBigRank4 = pmStr;
md.UpFirstDay4 = UpDay;
md.Impressions4 = impressinos;
md.Last2DayAdfee4 = last2dayAdFee;
md.BGLZXTData4 = zxtDatas;
break;
case 4:
md.ShopName5 = gmdlist[i].ShopName;// + "[" + gmdlist[i].Name + "]";
md.ShopUrl5 = gmdlist[i].url;
md.PreDayFee5 = prefee;
md.WeekLR5 = weeklr;
md.NextFee5= nextfee;
md.NextFeeType5 = ftype;
md.LastWeekFee5 = lastWeekFee;
md.SmallAndBigRank5 = pmStr;
md.UpFirstDay5 = UpDay;
md.Impressions5 = impressinos;
md.Last2DayAdfee5 = last2dayAdFee;
md.BGLZXTData5 = zxtDatas;
break;
case 5:
md.ShopName6 = gmdlist[i].ShopName;// + "[" + gmdlist[i].Name + "]";
md.ShopUrl6 = gmdlist[i].url;
md.PreDayFee6 = prefee;
md.WeekLR6 = weeklr;
md.NextFee6= nextfee;
md.NextFeeType6 = ftype;
md.LastWeekFee6 = lastWeekFee;
md.SmallAndBigRank6 = pmStr;
md.UpFirstDay6 = UpDay;
md.Impressions6 = impressinos;
md.Last2DayAdfee6 = last2dayAdFee;
md.BGLZXTData6 = zxtDatas;
break;
case 6:
md.ShopName7 = gmdlist[i].ShopName;// + "[" + gmdlist[i].Name + "]";
md.ShopUrl7 = gmdlist[i].url;
md.PreDayFee7= prefee;
md.WeekLR7= weeklr;
md.NextFee7= nextfee;
md.NextFeeType7= ftype;
md.LastWeekFee7 = lastWeekFee;
md.SmallAndBigRank7 = pmStr;
md.UpFirstDay7 = UpDay;
md.Impressions7 = impressinos;
md.Last2DayAdfee7 = last2dayAdFee;
md.BGLZXTData7 = zxtDatas;
break;
case 7:
md.ShopName8 = gmdlist[i].ShopName;// + "[" + gmdlist[i].Name + "]";
md.ShopUrl8 = gmdlist[i].url;
md.PreDayFee8= prefee;
md.WeekLR8 = weeklr;
md.NextFee8= nextfee;
md.NextFeeType8 = ftype;
md.LastWeekFee8 = lastWeekFee;
md.SmallAndBigRank8 = pmStr;
md.UpFirstDay8 = UpDay;
md.Impressions8 = impressinos;
md.Last2DayAdfee8 = last2dayAdFee;
md.BGLZXTData8 = zxtDatas;
break;
case 8:
md.ShopName9 = gmdlist[i].ShopName;// + "[" + gmdlist[i].Name + "]";
md.ShopUrl9 = gmdlist[i].url;
md.PreDayFee9 = prefee;
md.WeekLR9= weeklr;
md.NextFee9 = nextfee;
md.NextFeeType9= ftype;
md.LastWeekFee9 = lastWeekFee;
md.SmallAndBigRank9 = pmStr;
md.UpFirstDay9 = UpDay;
md.Impressions9 = impressinos;
md.Last2DayAdfee9 = last2dayAdFee;
md.BGLZXTData9 = zxtDatas;
break;
case 9:
md.ShopName10 = gmdlist[i].ShopName;// + "[" + gmdlist[i].Name + "]";
md.ShopUrl10 = gmdlist[i].url;
md.PreDayFee10 = prefee;
md.WeekLR10 = weeklr;
md.NextFee10 = nextfee;
md.NextFeeType10 = ftype;
md.LastWeekFee10 = lastWeekFee;
md.SmallAndBigRank10 = pmStr;
md.UpFirstDay10 = UpDay;
md.Impressions10 = impressinos;
md.Last2DayAdfee10 = last2dayAdFee;
md.BGLZXTData10 = zxtDatas;
break;
default:
break;
}
}
}
}
}
if (ginNumList != null)
{
foreach(var md in resultModel.DataSource)
{
var gmd = ginNumList.Find(r => r.GoodsId == md.id);
if (gmd != null)
{
md.GoodsInNum = gmd.GoodsInNum;
md.BHNum3=gmd.BHNum3;
md.JYCGNum = gmd.JYCGNum;
}
}
}
if (goodsSortList != null)
{
foreach(var md in resultModel.DataSource)
{
var goodMustShop = "";
var gsls = goodsSortList.Where(r => r.GoodsId == md.id);
if(gsls!=null && gsls.Count() > 0)
{
foreach(var gsl in gsls)
{
var link = goodsBuyLinkList.Where(r =>r.GoodsId==md.id && r.LinkDesc.Trim().ToUpper() == gsl.ShopName.Trim().ToUpper()).FirstOrDefault();
goodMustShop += link == null ? ("<p style='margin:2px 0;white-space: nowrap;'><a style='color:red;margin-left:5px;'>" + gsl.ShopName + "</a></p>") : ("<p style='margin:2px 0;white-space: nowrap;'><a style='color:green;margin-left:5px;' target='_blank' href='" + link.LinkUrl + "'>" + gsl.ShopName + "</a></p>");
}
}
md.GoodMustShop = goodMustShop;
}
}
}
if (resultModel.DataSource.Count > 0)
resultModel.DataSource[0].mids = mids;
var dlist = DataNew.GetListGoodsDetailLeftNum(mids.TrimEnd(','));
if (dlist != null)
{
foreach (var md in dlist)
{
var rmd = resultModel.DataSource.Find(n => n.id == md.goodsid);
if (rmd != null)
{
rmd.LeftNumE = md.LeftNumE;
rmd.LeftNumW = md.LeftNumW;
rmd.StockAndOnloadNumE = md.StockAndOnloadNumE;
rmd.StockAndOnloadNumW = md.StockAndOnloadNumW;
if (rmd.LeftNumE + rmd.LeftNumW <= 0)
rmd.NoOutDaysColor = "black";
else
{
if (!rmd.NoOutDays.HasValue || rmd.NoOutDays.Value >= 0 && rmd.NoOutDays.Value <= 9)
{
rmd.NoOutDaysColor = "black";
}
else if(rmd.NoOutDays.Value >= 10 && rmd.NoOutDays.Value <= 19)
{
rmd.NoOutDaysColor = "yellowgreen";
}
else if(rmd.NoOutDays.Value >= 20 && rmd.NoOutDays.Value <= 30)
{
rmd.NoOutDaysColor = "deeppink";
}
else if (rmd.NoOutDays.Value > 30)
{
rmd.NoOutDaysColor = "red";
}
}
}
}
}
}
return resultModel;
}
#endregion
#region 平台店铺
[WebMethod(EnableSession = true)]
public List<JC_Shop> GetZTShopList(string ShopNames)
{
PagesNew.Login(this.Session);
var list = DataNew.GetShopList(1, 2);
if (ShopNames!=null&&ShopNames != "")
{
string[] sps = ShopNames.Trim(',').Split(',');
if (list != null)
{
for(int i=0;i<sps.Length;i++)
{
var smd = list.Find(n => n.ShopName == sps[i].ToString());
if (smd != null)
smd.IsCheck = true;
}
}
}
return list;
}
#endregion
#region 平台店铺
[WebMethod(EnableSession = true)]
public JsonModel<List<TJ_UserGoodsScore>> GetUserGoodsScore(int platid,int UserId, int SNum, int ENum, DateTime? sdate, DateTime? edate, int PageIndex, int PageSize)
{
PagesNew.Login(this.Session);
List<TJ_UserGoodsScore> list = null;
if(platid==2)
list= DataNew.GetUserGoodsScore(UserId, sdate, edate,SNum,ENum);
else if (platid == 3)
list = DataNew.GetUserGoodsScore3(UserId, sdate, edate, SNum, ENum);
else if (platid == 6)
list = DataNew.GetUserGoodsScore6(UserId, sdate, edate, SNum, ENum);
else if (platid == 15)
list = DataNew.GetUserGoodsScore15(UserId, sdate, edate, SNum, ENum);
else if (platid == 18)
list = DataNew.GetUserGoodsScore18(UserId, sdate, edate, SNum, ENum);
else if (platid ==21)
list = DataNew.GetUserGoodsScore21(UserId, sdate, edate, SNum, ENum);
JsonModel<List<TJ_UserGoodsScore>> resultModel = new JsonModel<List<TJ_UserGoodsScore>>();
if (list != null)
{
resultModel.DataSource = list.Take(PageSize).Skip(PageSize * (PageIndex - 1)).ToList();
resultModel.RowCount = list.Count;
}
return resultModel;
}
#endregion
#region 导出积分
[WebMethod(EnableSession = true)]
public string GetUserGoodsScoreExcel(int platid, int UserId, int SNum, int ENum, DateTime? sdate, DateTime? edate)
{
PagesNew.Login(this.Session);
var obj = new DD_OrderData();
List<TJ_UserGoodsScore> list = null;
if (platid == 2)
list = DataNew.GetUserGoodsScore(UserId, sdate, edate, SNum, ENum);
else if (platid == 3)
list = DataNew.GetUserGoodsScore3(UserId, sdate, edate, SNum, ENum);
else if (platid == 6)
list = DataNew.GetUserGoodsScore6(UserId, sdate, edate, SNum, ENum);
else if (platid == 15)
list = DataNew.GetUserGoodsScore15(UserId, sdate, edate, SNum, ENum);
else if (platid == 18)
list = DataNew.GetUserGoodsScore18(UserId, sdate, edate, SNum, ENum);
else if (platid == 21)
list = DataNew.GetUserGoodsScore21(UserId, sdate, edate, SNum, ENum);
if (list == null)
return "" ;
TableColumnCollection listColumns = new TableColumnCollection();
listColumns.Add("GoodsCode", "货号", DbType.String, "");
listColumns.Add("Name", "人员", DbType.String, "");
listColumns.Add("GroupName", "组长", DbType.String, "");
listColumns.Add("amzonzjeweek1", "7Days销售额$", DbType.String, "");
listColumns.Add("amzonzjeweek2", "14Days销售额$", DbType.String, "");
listColumns.Add("amzonzjeweek3", "21Days销售额$", DbType.String, "");
listColumns.Add("amzonzje", "Month销售额$", DbType.String, "");
listColumns.Add("amzonmlweek1", "7Days利润$", DbType.String, "");
listColumns.Add("amzonmlweek2", "14Days利润$", DbType.String, "");
listColumns.Add("amzonmlweek3", "21Days利润$", DbType.String, "");
listColumns.Add("amzonml", "Month利润$", DbType.String, "");
listColumns.Add("amzonmllweek1", "7Days利润率", DbType.String, "");
listColumns.Add("amzonmllweek2", "14Days利润率", DbType.String, "");
listColumns.Add("amzonmllweek3", "21Days利润率", DbType.String, "");
listColumns.Add("amzonmll", "Month利润率", DbType.String, "");
listColumns.Add("amzonjf", "计分", DbType.String, "");
MicrosoftExcel obj2 = new MicrosoftExcel();
return obj2.Export(list, listColumns);
}
#endregion
#region 导出积分
[WebMethod(EnableSession = true)]
public string GetUserGoodsScoreExcel2(int platid, int UserId, int SNum, int ENum, DateTime? sdate, DateTime? edate)
{
PagesNew.Login(this.Session);
var obj = new DD_OrderData();
List<TJ_UserGoodsScore> list = null;
if (platid == 2)
list = DataNew.GetUserGoodsScore(UserId, sdate, edate, SNum, ENum);
else if (platid == 3)
list = DataNew.GetUserGoodsScore3(UserId, sdate, edate, SNum, ENum);
else if (platid == 6)
list = DataNew.GetUserGoodsScore6(UserId, sdate, edate, SNum, ENum);
else if (platid == 15)
list = DataNew.GetUserGoodsScore15(UserId, sdate, edate, SNum, ENum);
else if (platid == 18)
list = DataNew.GetUserGoodsScore18(UserId, sdate, edate, SNum, ENum);
else if (platid == 21)
list = DataNew.GetUserGoodsScore21(UserId, sdate, edate, SNum, ENum);
if (list == null|| list.Count==0)
return "";
TableColumnCollection listColumns = new TableColumnCollection();
listColumns.Add("Name", "人员", DbType.String, "");
listColumns.Add("Num", "产品个数", DbType.String, "");
listColumns.Add("TGRate", "通过率%", DbType.String, "");
listColumns.Add("Num1", "小于500$", DbType.String, "");
listColumns.Add("Num2", "500-1000$", DbType.String, "");
listColumns.Add("Num3", "1000-10000$", DbType.String, "");
listColumns.Add("Num4", "10000-100000$", DbType.String, "");
listColumns.Add("Num5", "大于100000$", DbType.String, "");
listColumns.Add("HJ", "计分", DbType.String, "");
MicrosoftExcel obj2 = new MicrosoftExcel();
return obj2.Export(list[0].Data2, listColumns);
}
#endregion
#region 保存
[WebMethod(EnableSession = true)]
public string Save_GoodsLeaveWord(HW_GoodsLeaveWord Model)
{
PagesNew.Login(this.Session);
Model.indate = DateTime.Now;
Model.inname = Session["Name"].ToString();
Model.isread = 0;
Model.leaveword2 = Model.inname + "[" + DateTime.Now.ToString("MM-dd") + "]:" + Model.leaveword;
DataNew.Save_GoodsLeaveWord(Model);
return Model.leaveword2;
}
#endregion
#region 多条件普通查询
[WebMethod(EnableSession = true)]
public List<HW_GoodsLeaveWord> GetListGoodsLeaveWord(int goodsid,int leavetype,int platid)
{
PagesNew.Login(this.Session);
var ListModel = DataNew.GetListGoodsLeaveWord(goodsid, leavetype, platid);
return ListModel;
}
#endregion
#region 保存
[WebMethod(EnableSession = true)]
public int UpdateIsExamine(int goodsId, int isExamine)
{
PagesNew.Login(this.Session);
DataNew.UpdateIsExamine(goodsId, isExamine);
return 1;
}
#endregion
#region 取消智能库存页面有计划未确认的采购数据
[WebMethod(EnableSession = true)]
public ApiResponseModel CancelCGPlanByDetailids(string detailids)
{
PagesNew.Login(base.Session);
var robj = new ApiResponseModel();
detailids = detailids.TrimEnd(',');
try
{
int count = DataNew.GetCancelCGPlanNoQueRen(detailids);
if (count > 0)
{
robj.Code = 0;
robj.Message = "取消失败:只能取消状态是有计划未确认的数据";
return robj;
}
DataNew.CancelCGPlan(detailids, DateTime.Now.Year);
robj.Code = 1;
robj.Message = "Success";
}
catch (Exception ex)
{
robj.Code = 0;
robj.Message = "取消失败:" + ex.Message;
}
return robj;
}
#endregion
#region 显示隐藏货物信息--商品信息页面的数据
[WebMethod(EnableSession = true)]
public ApiResponseModel XSYCGoodsInfoData(int goodsId, int isyc)
{
PagesNew.Login(base.Session);
var robj = new ApiResponseModel();
try
{
DataNew.UpdateGoodsInfoXSYC(goodsId, isyc);
robj.Code = 1;
robj.Message = "Success";
}
catch (Exception ex)
{
robj.Code = 0;
robj.Message = "取消失败:" + ex.Message;
}
return robj;
}
#endregion
#region 保存产品补贴价格
[WebMethod(EnableSession = true)]
public APIReturnModel SaveGoodsBTPrice(decimal? btPrice, int goodsid)
{
PagesNew.Login(base.Session);
var rmodel = new APIReturnModel();
try
{
DataNew.SaveGoodsBTPrice(goodsid, btPrice);
rmodel.Code = 1;
rmodel.Message = "成功";
}
catch (Exception ex)
{
rmodel.Code = 0;
rmodel.Message = "失败:" + ex.Message;
}
return rmodel;
}
#endregion
#region 刷新2024-04-01到2024-07-31的此产品订单补贴费用
[WebMethod(EnableSession = true)]
public APIReturnModel UpdateOrderBTPrice(int goodsid,int platid)
{
PagesNew.Login(base.Session);
var rmodel = new APIReturnModel();
try
{
DataNew.UpdateOrderBTPrice(goodsid, platid);
rmodel.Code = 1;
rmodel.Message = "成功";
}
catch (Exception ex)
{
rmodel.Code = 0;
rmodel.Message = "失败:" + ex.Message;
}
return rmodel;
}
#endregion
#region TEMU店铺商品价格
[WebMethod(EnableSession = true)]
public JsonModel<List<TemuShopGoodPrice>> GetTemuShopGoodPriceDatas(int shopid,string search, int PageIndex, int PageSize)
{
PagesNew.Login(this.Session);
var rdata = new JsonModel<List<TemuShopGoodPrice>>();
int rowCount = 0;
var datas = DataNew.GetTemuShopGoodPriceList(shopid, search, PageIndex, PageSize, out rowCount);
rdata.DataSource = datas;
rdata.RowCount = rowCount;
return rdata;
}
[WebMethod(EnableSession = true)]
public APIReturnModel SaveTemuShopGoodPrice(TemuShopGoodPrice md)
{
PagesNew.Login(this.Session);
var userid = Convert.ToInt32(base.Session["UserId"]);
var rmodel = new APIReturnModel();
var data = DataNew.GetTemuShopGoodPrice(md.Shopid, md.SKU, md.SPUID);
if (data != null)
{
rmodel.Code = 0;
rmodel.Message = "已存在相同的店铺商品数据";
return rmodel;
}
md.CreateUserId = userid;
DataNew.SaveTemuShopGoodPrice(md);
rmodel.Code = 1;
rmodel.Message = "";
return rmodel;
}
[WebMethod(EnableSession = true)]
public APIReturnModel ImportTemuShopGoodPrices(string filePath)
{
PagesNew.Login(this.Session);
var userid = Convert.ToInt32(base.Session["UserId"]);
string ServerFileName = AppDomain.CurrentDomain.BaseDirectory + filePath;
var rmodel = new APIReturnModel();
try
{
MicrosoftExcel excel = new MicrosoftExcel();
DataTable tb = excel.ImportExcel(ServerFileName);
string error = "";
if (tb.Columns.Contains("店铺名") == false) { error = error + "导入模板的 店铺名 列不存在"; }
if (tb.Columns.Contains("SKU") == false) { error = error + "导入模板的 SKU 列不存在"; }
if (tb.Columns.Contains("SPUID") == false) { error = error + "导入模板的 SPU 列不存在"; }
if (tb.Columns.Contains("价格") == false) { error = error + "导入模板的 价格 列不存在"; }
if (string.IsNullOrEmpty(error) == false)
{
rmodel.Code = 0;
rmodel.Message= error;
}
var goods = new List<TemuShopGoodPrice>();
StringBuilder sb=new StringBuilder();
for (int i = 0; i < tb.Rows.Count; i++)
{
var shopName = tb.Rows[i]["店铺名"].ToString();
if (string.IsNullOrEmpty(shopName))
{
sb.Append("第" + (i + 1).ToString() + "行店铺名不能为空;");
continue;
}
var shop=DataNew.GetShopByShopName(shopName);
if(shop==null)
{
sb.Append("第" + (i + 1).ToString() + "行店铺名:" + shopName + "不存在;");
continue;
}
var sku= tb.Rows[i]["SKU"].ToString();
if (string.IsNullOrEmpty(sku))
{
sb.Append("第" + (i + 1).ToString() + "行SKU不能为空");
continue;
}
var spuid = tb.Rows[i]["SPUID"].ToString();
if (string.IsNullOrEmpty(spuid))
{
sb.Append("第" + (i + 1).ToString() + "行SPUID不能为空");
continue;
}
if (string.IsNullOrEmpty(tb.Rows[i]["价格"].ToString()))
{
sb.Append("第" + (i + 1).ToString() + "行价格不能为空;");
continue;
}
var data = DataNew.GetTemuShopGoodPrice(shop.ShopId.Value, sku, spuid);
if (data != null)
{
sb.Append("第" + (i + 1).ToString() + "行已存在相同数据;");
continue;
}
var md = new TemuShopGoodPrice()
{
Shopid = shop.ShopId.Value,
SPUID =spuid,
SKU = sku,
SalePrice = Convert.ToDecimal(tb.Rows[i]["价格"]),
CreateUserId = userid,
};
goods.Add(md);
}
if (sb.Length > 0)
{
rmodel.Code = 0;
rmodel.Message= sb.ToString();
return rmodel;
}
foreach (var md in goods)
{
DataNew.SaveTemuShopGoodPrice(md);
}
rmodel.Code = 1;
rmodel.Message = "";
return rmodel;
}
catch(Exception ex)
{
rmodel.Code = 0;
rmodel.Message = ex.Message;
return rmodel;
}
}
//temu 活动导入
[WebMethod(EnableSession = true)]
public APIReturnModel ImportTemuHuoDongPrices_old(string filePath)
{
//PagesNew.Login(this.Session);
var userid = Convert.ToInt32(base.Session["UserId"]);
string ServerFileName = AppDomain.CurrentDomain.BaseDirectory + filePath;
var rmodel = new APIReturnModel();
try
{
MicrosoftExcel excel = new MicrosoftExcel();
DataTable tb = excel.ImportExcel(ServerFileName);
string error = "";
if (tb.Columns.Contains("店铺名") == false) { error = error + "导入模板的 店铺名 列不存在"; }
if (tb.Columns.Contains("SKU") == false) { error = error + "导入模板的 SKU 列不存在"; }
if (tb.Columns.Contains("SKUID") == false) { error = error + "导入模板的 SKUID 列不存在"; }
if (tb.Columns.Contains("价格") == false) { error = error + "导入模板的 价格 列不存在"; }
if (tb.Columns.Contains("折扣") == false) { error = error + "导入模板的 折扣 列不存在"; }
if (tb.Columns.Contains("售价") == false) { error = error + "导入模板的 售价 列不存在"; }
if (tb.Columns.Contains("数量") == false) { error = error + "导入模板的 数量 列不存在"; }
if (string.IsNullOrEmpty(error) == false)
{
rmodel.Code = 0;
rmodel.Message = error;
}
var data = new List<TemuShopGoodActive>();
StringBuilder sb = new StringBuilder();
var shopName = tb.Rows[0]["店铺名"].ToString();
if (string.IsNullOrEmpty(shopName))
{
sb.Append("第" + (2).ToString() + "行店铺名不能为空;");
}
var shop = DataNew.GetShopByShopName(shopName);
if (shop == null)
{
sb.Append("第" + (2).ToString() + "行店铺名:" + shopName + "不存在;");
}
var sku = tb.Rows[0]["SKU"].ToString();
if (string.IsNullOrEmpty(sku))
{
sb.Append("第" + (2).ToString() + "行SKU不能为空");
}
var SKUID = tb.Rows[0]["SKUID"].ToString();
if (string.IsNullOrEmpty(SKUID))
{
sb.Append("第" + (2).ToString() + "行SKUID不能为空");
}
if (string.IsNullOrEmpty(tb.Rows[0]["价格"].ToString()))
{
sb.Append("第" + (2).ToString() + "行价格不能为空;");
}
if (string.IsNullOrEmpty(tb.Rows[0]["折扣"].ToString()))
{
sb.Append("第" + (2).ToString() + "行折扣不能为空;");
}
if (string.IsNullOrEmpty(tb.Rows[0]["售价"].ToString()))
{
sb.Append("第" + (2).ToString() + "行售价不能为空;");
}
if (string.IsNullOrEmpty(tb.Rows[0]["数量"].ToString()))
{
sb.Append("第" + (2).ToString() + "行数量不能为空;");
}
if (string.IsNullOrEmpty(tb.Rows[0]["开始时间"].ToString()))
{
sb.Append("第" + (2).ToString() + "行开始时间不能为空;");
}
if (string.IsNullOrEmpty(tb.Rows[0]["结束时间"].ToString()))
{
sb.Append("第" + (2).ToString() + "行结束时间不能为空;");
}
if (sb.Length > 0)
{
rmodel.Code = 0;
rmodel.Message = sb.ToString();
return rmodel;
}
var md = new TemuShopGoodActive()
{
Shopid = shop.ShopId.Value,
ShopName= shopName,
CreateUserId = userid,
CreateTime = DateTime.Now,
State = 1,
};
var mddetail = new TemuShopGoodActiveDetail()
{
OffNum = Convert.ToDecimal(tb.Rows[0]["折扣"].ToString()),
SalePrice = Convert.ToDecimal(tb.Rows[0]["售价"].ToString()),
ActiveNum = Convert.ToInt32(tb.Rows[0]["数量"].ToString()),
State = 1,
SDate = Convert.ToDateTime(tb.Rows[0]["开始时间"].ToString()),
EDate = Convert.ToDateTime(tb.Rows[0]["结束时间"].ToString()),
};
if (md.ListModel==null)
{
md.ListModel = new List<TemuShopGoodActiveDetail>();
}
md.ListModel.Add(mddetail);
//md.ListModel
data.Add(md);
for (int i = 1; i < tb.Rows.Count; i++)
{
int shopid2 = 0;
var shopName2 = tb.Rows[i]["店铺名"].ToString();
var sku2 = tb.Rows[i]["SKU"].ToString();
var SKUID2 = tb.Rows[i]["SKUID"].ToString();
var price2 = tb.Rows[i]["价格"].ToString();
var shopNamei = tb.Rows[i - 1]["店铺名"].ToString();
var skui = tb.Rows[i - 1]["SKU"].ToString();
var SKUIDi = tb.Rows[i - 1]["SKUID"].ToString();
var shopi = DataNew.GetShopByShopName(shopNamei);
var md2 = new TemuShopGoodActive();
if (string.IsNullOrEmpty(price2))
{
sb.Append("第" + (i + 1).ToString() + "行价格不能为空;");
}
if (string.IsNullOrEmpty(tb.Rows[i]["折扣"].ToString()))
{
sb.Append("第" + (i + 1).ToString() + "行折扣不能为空;");
}
if (string.IsNullOrEmpty(tb.Rows[i]["售价"].ToString()))
{
sb.Append("第" + (i + 1).ToString() + "行售价不能为空;");
}
if (string.IsNullOrEmpty(tb.Rows[i]["数量"].ToString()))
{
sb.Append("第" + (i + 1).ToString() + "行数量不能为空;");
}
if (string.IsNullOrEmpty(shopName2) && string.IsNullOrEmpty(sku2) && string.IsNullOrEmpty(sku2))
{
if (string.IsNullOrEmpty(shopName2))
{
var shop2 = DataNew.GetShopByShopName(shopNamei);
tb.Rows[i]["店铺名"] = shopNamei;
shopName2 = tb.Rows[i]["店铺名"].ToString();
if (shop2 != null)
{
shopid2 = shop2.ShopId.Value;
}
else
{
sb.Append("第" + (i - 1).ToString() + "行店铺名:" + shopName2 + "不存在;");
}
}
else
{
shopid2 = DataNew.GetShopByShopName(shopName2).ShopId.Value;
}
if (string.IsNullOrEmpty(sku2))
{
tb.Rows[i]["SKU"] = tb.Rows[i - 1]["SKU"];
sku2 = tb.Rows[i]["SKU"].ToString();
}
if (string.IsNullOrEmpty(SKUID2))
{
tb.Rows[i]["SKUID"] = tb.Rows[i - 1]["SKUID"];
SKUID2 = tb.Rows[i]["SKUID"].ToString();
}
md2 = data.Where(p => p.Shopid == shopi.ShopId.Value && p.SKU == skui && p.SPUID == SKUIDi).FirstOrDefault();
if (md2!=null)
{
var mddetail2 = new TemuShopGoodActiveDetail()
{
OffNum = Convert.ToDecimal(tb.Rows[i]["折扣"].ToString()),
SalePrice = Convert.ToDecimal(tb.Rows[i]["售价"].ToString()),
ActiveNum = Convert.ToInt32(tb.Rows[i]["数量"].ToString()),
State=1,
SDate = Convert.ToDateTime(tb.Rows[i]["开始时间"].ToString()),
EDate = Convert.ToDateTime(tb.Rows[i]["结束时间"].ToString()),
};
data.Where(p => p.Shopid == shopi.ShopId.Value && p.SKU == skui && p.SPUID == SKUIDi).FirstOrDefault().ListModel.Add(mddetail2);
}
}
else
{
if (string.IsNullOrEmpty(shopName2))
{
var shop2 = DataNew.GetShopByShopName(shopNamei);
tb.Rows[i]["店铺名"] = shopNamei;
shopName2 = tb.Rows[i]["店铺名"].ToString();
if (shop2 != null)
{
shopid2 = shop2.ShopId.Value;
}
else
{
sb.Append("第" + (i - 1).ToString() + "行店铺名:" + shopName2 + "不存在;");
}
}
else
{
shopid2 = DataNew.GetShopByShopName(shopName2).ShopId.Value;
}
if (string.IsNullOrEmpty(sku2))
{
tb.Rows[i]["SKU"] = tb.Rows[i - 1]["SKU"];
sku2 = tb.Rows[i]["SKU"].ToString();
}
if (string.IsNullOrEmpty(SKUID2))
{
tb.Rows[i]["SKUID"] = tb.Rows[i - 1]["SKUID"];
SKUID2 = tb.Rows[i]["SKUID"].ToString();
}
var exdata = DataNew.GetTemuShopGoodPrice(shopid2, sku2, SKUID2);
if (exdata != null)
{
sb.Append("第" + (i + 1).ToString() + "行已存在相同数据;");
continue;
}
md2.Shopid = shopid2;
md2.ShopName = shopName2;
md2.SKU = sku2;
md2.SPUID = SKUID2;
md2.BasePrice = Convert.ToDecimal(price2);
md2.CreateUserId = userid;
md2.CreateTime = DateTime.Now;
md2.State = 1;
if (md2.ListModel == null)
{
md2.ListModel = new List<TemuShopGoodActiveDetail>();
}
var mddetail2 = new TemuShopGoodActiveDetail()
{
OffNum = Convert.ToDecimal(tb.Rows[i]["折扣"].ToString()),
SalePrice = Convert.ToDecimal(tb.Rows[i]["售价"].ToString()),
State = 1,
ActiveNum = Convert.ToInt32(tb.Rows[i]["数量"].ToString()),
SDate = Convert.ToDateTime(tb.Rows[i]["开始时间"].ToString()),
EDate = Convert.ToDateTime(tb.Rows[i]["结束时间"].ToString()),
};
md2.ListModel.Add(mddetail2);
data.Add(md2);
}
}
if (sb.Length > 0)
{
rmodel.Code = 0;
rmodel.Message = sb.ToString();
return rmodel;
}
foreach (var i in data)
{
DataNew.Save_TemuShopGoodActive(i);
}
rmodel.Code = 1;
rmodel.Message = "";
return rmodel;
}
catch (Exception ex)
{
rmodel.Code = 0;
rmodel.Message = ex.Message;
return rmodel;
}
}
//temu 活动导入(褚改)
[WebMethod(EnableSession = true)]
public APIReturnModel ImportTemuHuoDongPrices(string filePath)
{
//PagesNew.Login(this.Session);
var userid = Convert.ToInt32(base.Session["UserId"]);
string ServerFileName = AppDomain.CurrentDomain.BaseDirectory + filePath;
var rmodel = new APIReturnModel();
try
{
MicrosoftExcel excel = new MicrosoftExcel();
DataTable tb = excel.ImportExcel(ServerFileName);
string error = "";
if (tb.Columns.Contains("店铺名") == false) { error = error + "导入模板的 店铺名 列不存在"; }
if (tb.Columns.Contains("SKU") == false) { error = error + "导入模板的 SKU 列不存在"; }
if (tb.Columns.Contains("SKUID") == false) { error = error + "导入模板的 SKUID 列不存在"; }
if (tb.Columns.Contains("价格") == false) { error = error + "导入模板的 价格 列不存在"; }
if (tb.Columns.Contains("折扣") == false) { error = error + "导入模板的 折扣 列不存在"; }
if (tb.Columns.Contains("共享库存") == false) { error = error + "导入模板的 共享库存 列不存在"; }
if (tb.Columns.Contains("售价") == false) { error = error + "导入模板的 售价 列不存在"; }
if (tb.Columns.Contains("数量") == false) { error = error + "导入模板的 数量 列不存在"; }
if (string.IsNullOrEmpty(error) == false)
{
rmodel.Code = 0;
rmodel.Message = error;
}
StringBuilder sb = new StringBuilder();
for (int i = 0; i < tb.Rows.Count; i++)
{
var shopName = tb.Rows[i]["店铺名"].ToString();
if (i == 0)
{
if (string.IsNullOrEmpty(shopName))
{
sb.Append("第1行店铺名不能为空");
}
}
if (shopName != "")
{
var shop = DataNew.GetShopByShopName(shopName);
if (shop == null)
{
sb.Append("第" + (i+1).ToString() + "行店铺名:" + shopName + "不存在;");
}
}
var sku = tb.Rows[i]["SKU"].ToString();
if (string.IsNullOrEmpty(sku))
{
sb.Append("第" + (i + 1).ToString() + "行SKU不能为空");
}
var SKUID = tb.Rows[i]["SKUID"].ToString();
if (string.IsNullOrEmpty(SKUID))
{
sb.Append("第" + (i + 1).ToString() + "行SKUID不能为空");
}
if (string.IsNullOrEmpty(tb.Rows[i]["价格"].ToString()))
{
sb.Append("第" + (i + 1).ToString() + "行价格不能为空;");
}
if (string.IsNullOrEmpty(tb.Rows[i]["折扣"].ToString()))
{
sb.Append("第" + (i + 1).ToString() + "行折扣不能为空;");
}
if (string.IsNullOrEmpty(tb.Rows[i]["售价"].ToString()))
{
sb.Append("第" + (i + 1).ToString() + "行售价不能为空;");
}
if (tb.Rows[i]["共享库存"].ToString() != "是" && string.IsNullOrEmpty(tb.Rows[i]["数量"].ToString()))
{
sb.Append("第" + (i + 1).ToString() + "行数量不能为空;");
}
if (string.IsNullOrEmpty(tb.Rows[i]["开始时间"].ToString()))
{
sb.Append("第" + (i + 1).ToString() + "行开始时间不能为空;");
}
if (string.IsNullOrEmpty(tb.Rows[i]["结束时间"].ToString()))
{
sb.Append("第" + (i + 1).ToString() + "行结束时间不能为空;");
}
}
if (sb.Length > 0)
{
rmodel.Code = 0;
rmodel.Message = sb.ToString();
return rmodel;
}
string shopname = "";
TemuShopGoodActive Model = null;
List<TemuShopGoodActiveDetail> mlist = null;
for (int i = 0; i < tb.Rows.Count; i++)
{
if (i == 0 ||(tb.Rows[i]["店铺名"].ToString()!=""&&tb.Rows[i]["店铺名"].ToString()!= shopname))
{
if (Model != null)
{
Model.ListModel = mlist;
DataNew.Save_TemuShopGoodActive(Model);
Model = null;
mlist = null;
}
shopname = tb.Rows[i]["店铺名"].ToString();
Model = new TemuShopGoodActive();
Model.State = 1;
Model.CreateTime = DateTime.Now;
Model.CreateUserId = Convert.ToInt32(Session["UserId"]);
var shop = DataNew.GetShopByShopName(shopname);
Model.Shopid = shop.ShopId;
mlist = new List<TemuShopGoodActiveDetail>();
}
TemuShopGoodActiveDetail mmd = new TemuShopGoodActiveDetail();
mmd.SKU = tb.Rows[i]["SKU"].ToString();
mmd.SKUId = tb.Rows[i]["SKUID"].ToString();
mmd.BasePrice =Convert.ToDecimal(tb.Rows[i]["价格"].ToString());
mmd.OffNum = Convert.ToDecimal(tb.Rows[i]["折扣"].ToString());
mmd.SalePrice = Convert.ToDecimal(tb.Rows[i]["售价"].ToString());
if (tb.Rows[i]["共享库存"].ToString()== "是")
mmd.ActiveNum =0;
else
mmd.ActiveNum = Convert.ToInt32(tb.Rows[i]["数量"].ToString());
mmd.SDate = Convert.ToDateTime(tb.Rows[i]["开始时间"].ToString());
mmd.EDate = Convert.ToDateTime(tb.Rows[i]["结束时间"].ToString());
mlist.Add(mmd);
}
if (Model != null)
{
Model.ListModel = mlist;
DataNew.Save_TemuShopGoodActive(Model);
}
rmodel.Code = 1;
rmodel.Message = "";
return rmodel;
}
catch (Exception ex)
{
rmodel.Code = 0;
rmodel.Message = ex.Message;
return rmodel;
}
}
[WebMethod(EnableSession = true)]
public APIReturnModel DeleteTemuShopGoodPrice(int id)
{
PagesNew.Login(this.Session);
var rmodel = new APIReturnModel();
DataNew.DeleteTemuShopGoodPrice(id);
rmodel.Code = 1;
rmodel.Message = "";
return rmodel;
}
#endregion
#region TEMU商品价格审核
[WebMethod(EnableSession = true)]
public JsonModel<List<TemuShopGoodPriceCheck>> GetTemuShopGoodPriceCheckDatas(int shopid, string search,int? state, int PageIndex, int PageSize)
{
PagesNew.Login(this.Session);
var rdata = new JsonModel<List<TemuShopGoodPriceCheck>>();
int rowCount = 0;
var datas = DataNew.GetTemuShopGoodPriceChecks(shopid, search, state, PageIndex, PageSize, out rowCount);
if (datas != null)
{
decimal usdrate = 6.5M;//美金汇率
List<JC_Money> list2 = new BaseService().GetMoneyList2();
if (list2 != null)
{
var fmd = list2.Find(n => n.PlatId == 2 && n.MCode == "USD");
if (fmd != null)
usdrate = fmd.MRate.Value;
}
foreach (var md in datas)
{
// var yfmd = DataNew.GetModelPostFee(md.GoodsId);
decimal? jsygyf = 0;//预估运费
if (md.PostPrice != null)
jsygyf = md.PostPrice;
if (jsygyf>0)
{
// if (yfmd.Fee1 != null)
// {
// jsygyf = yfmd.Fee1;
// }
// if (yfmd.Fee3 != null)
// {
// if (yfmd.Fee3 > 0 && yfmd.Fee3 < jsygyf)
// jsygyf = yfmd.Fee3;
// }
// if (yfmd.Fee5 != null)
// {
// if (yfmd.Fee5 > 0 && yfmd.Fee5 < jsygyf)
// jsygyf = yfmd.Fee5;
// }
// if (yfmd.Fee7 != null)
// {
// if (yfmd.Fee7 > 0 && yfmd.Fee7 < jsygyf)
// jsygyf = yfmd.Fee7;
// }
decimal? cb = null;
if (md.InPrice != null)
cb = Math.Round(md.InPrice.Value / usdrate, 2);
if (md.FeeRate != null)
cb += Math.Round(md.InPrice.Value * md.FeeRate.Value * 0.01M / usdrate, 2);
if (md.Solid != null)
cb += md.Solid.Value * 130M;
if (jsygyf > 0&& cb>0)//运费或者成本没有不计算
{
cb += jsygyf;
cb = Math.Round((cb.Value / 0.8M) * 1.1M,2);//先除以0.8再乘以1.1 固定加成
md.CBPrice = cb;
}
}
}
}
rdata.DataSource = datas;
rdata.RowCount = rowCount;
return rdata;
}
[WebMethod(EnableSession = true)]
public APIReturnModel SaveTemuShopGoodPriceCheck(TemuShopGoodPriceCheck md)
{
PagesNew.Login(this.Session);
var userid = Convert.ToInt32(base.Session["UserId"]);
var rmodel = new APIReturnModel();
var data = DataNew.GetTemuShopGoodPriceCheck(md.TemuShopGoodPriceId.Value);
if (data != null && data.State==0)
{
rmodel.Code = 0;
rmodel.Message = "已存在相同的店铺商品数据正在审核中";
return rmodel;
}
md.CreateUserId = userid;
md.State = 0;
DataNew.SaveTemuShopGoodPriceCheck(md);
rmodel.Code = 1;
rmodel.Message = "";
return rmodel;
}
[WebMethod(EnableSession = true)]
public APIReturnModel DeleteTemuShopGoodPriceCheck(int id)
{
PagesNew.Login(this.Session);
var rmodel = new APIReturnModel();
var data = DataNew.GetTemuShopGoodPriceCheckById(id);
if (data != null && data.State!=0)
{
rmodel.Code = 0;
rmodel.Message = "审批已结束,不能删除";
return rmodel;
}
DataNew.DeleteTemuShopGoodPrice(id);
rmodel.Code = 1;
rmodel.Message = "";
return rmodel;
}
[WebMethod(EnableSession = true)]
public List<TemuShopGoodPrice> GetTemuShopGoodsByShop(int shopid)
{
PagesNew.Login(this.Session);
var datas = DataNew.GetTemuShopGoodsByShop(shopid);
return datas;
}
[WebMethod(EnableSession = true)]
public APIReturnModel CheckTemuShopGoodsPrice(string ids,int state)
{
PagesNew.Login(this.Session);
var rmodel = new APIReturnModel();
var userid = Convert.ToInt32(base.Session["UserId"]);
ids = ids.TrimEnd(',');
var _ids = ids.Split(',').ToList();
foreach(var id in _ids)
{
DataNew.CheckTemuShopGoodPrice(Convert.ToInt32(id), userid, state);
}
rmodel.Code = 1;
rmodel.Message = "";
return rmodel;
}
#endregion
#region 获取TEMU待审核价格的数量
[WebMethod(EnableSession = true)]
public int GetTemuShopGoodCheckingQty()
{
try
{
PagesNew.Login(this.Session);
var rdata = new JsonModel<int>();
var qty = DataNew.GetTemuGoodPriceCheckingQty();
return qty;
}
catch (Exception ex)
{
return 0;
}
}
#endregion
#region 修改售价
[WebMethod(EnableSession = true)]
public int Save_ManuaPrice(int detailid, string ManuaPrice)
{
PagesNew.Login(this.Session);
DataNew.Save_ManuaPrice(detailid, ManuaPrice);
return 1;
}
#endregion
#region 修改temu售价
[WebMethod(EnableSession = true)]
public int Save_TemuPrice(int detailid, string TemuPrice)
{
PagesNew.Login(this.Session);
DataNew.Save_TemuPrice(detailid, TemuPrice);
return 1;
}
#endregion
#region 导入运费
[WebMethod(EnableSession = true)]
public string ExcelSaveDT_FeeForYF(int IsFG, string FileName,int PostId)
{
ErrorFollow.TraceWrite("Excel导入订单运费修改开始", "文件名称:" + FileName, "");
Pages.Login(this.Session);
if (string.IsNullOrEmpty(FileName) == true) return "要导入的文件路径不能为空";
string ServerFileName = AppDomain.CurrentDomain.BaseDirectory + FileName;
if (System.IO.File.Exists(ServerFileName) == false) return "要导入的文件路径不存在";
int CompanyId = Convert.ToInt32(Session["CompanyId"]);
try
{
MicrosoftExcel excel = new MicrosoftExcel();
DataTable tb = excel.ImportExcel(ServerFileName);
string error = "";
if (tb.Columns.Contains("订单号") == false) { error = error + "导入模板的 订单号 列不存在"; }
if (tb.Columns.Contains("运费") == false) { error = error + "导入模板的 运费 列不存在"; }
if (string.IsNullOrEmpty(error) == false) return error + ";请重新下载模板导入";
int UserId = Convert.ToInt32(Session["UserId"]);
int Count = 0;
StringBuilder sb = new StringBuilder();
for (int i = 0; i < tb.Rows.Count; i++)
{
ErrorFollow.TraceWrite("Excel导入订单运费修改读取第" + (i + 1) + "行", "文件名称:" + FileName, error);
string orderCode = tb.Rows[i]["订单号"].ToString().Trim();
if (string.IsNullOrEmpty(orderCode))
{
sb.Append("第" + (i + 1) + "行订单号为空;");
continue;
}
decimal PostFee = 0;
try
{
PostFee = Convert.ToDecimal(tb.Rows[i]["运费"].ToString().Trim());
}
catch (Exception ex)
{
sb.Append("第" + (i + 1) + "行运费格式不正确;");
continue;
}
ErrorFollow.TraceWrite("Excel导入订单运费修改读取第" + (i + 1) + "行", "订单号:" + orderCode, "运费:" + PostFee);
var a = DataNew.UpdateDT_FeeYFByOrderCode(orderCode, PostFee);
if (a > 0)
{
ErrorFollow.TraceWrite("Excel导入订单运费修改读取第" + (i + 1) + "行", "更新成功", "");
Count++;
}
}
error = "导入成功" + Count.ToString() + "条;";
error += sb.ToString();
ErrorFollow.TraceWrite("Excel导入订单运费修改结束", "文件名称:" + FileName, error);
return error;
}
catch (Exception e)
{
return "文件导入失败!请确定模板格式是否正确,或者重新下载模板,填写数据,重新导入!!!" + e.Message;
}
return "导入成功";
}
#endregion
[WebMethod(EnableSession = true)]
public List<TemuSKUOrder> GetTemuOrderFromSKU(string sku)
{
PagesNew.Login(this.Session);
var datas = DataNew.GetTemuOrderFromSKU(sku);
if (datas != null&& datas.Count>0)
{
TemuSKUOrder amd = new TemuSKUOrder();
decimal TotalPrice = 0;
decimal yj = 0;
decimal ck = 0;
decimal sjtc = 0;
decimal sjyf = 0;
decimal cb = 0;
decimal hwsf = 0;
decimal lr = 0;
int num = 0;
foreach (var md in datas)
{
md.InDate2 = md.InDate.Value.ToString("yyy-MM-dd");
TotalPrice += md.TotalPrice.Value;
yj += md.yj.Value;
ck += md.ck.Value;
sjtc += md.sjtc.Value;
sjyf += md.sjyf.Value;
cb += md.cb.Value;
hwsf += md.hwsf.Value;
lr += md.lr.Value;
num += md.GoodsNum.Value;
}
amd.SKU1 = "合计:";
amd.TotalPrice = TotalPrice;
amd.yj = yj;
amd.ck = ck;
amd.sjtc = sjtc;
amd.sjyf = sjyf;
amd.hwsf = hwsf;
amd.cb = cb;
amd.lr = lr;
amd.KCNum = datas[0].KCNum;
amd.GoodsNum = num;
datas.Insert(0,amd);
}
return datas;
}
}
}