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.
ERP/ERPOMS/HuoWuServiceNew.asmx.cs

1056 lines
43 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 NetLibrary.Data;
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Services;
using TradeData;
using TradeManage;
using TradeManageNew;
using TradeModel;
namespace ERPOMS
{
/// <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";
}
#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);
return list;
}
#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"]);
int UserId= Convert.ToInt32(Session["UserId"]);
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(UserId, 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 List<JC_BaseCodeDetail> GetPlatBaseCode(int CompanyID, string KeyName)
{
Pages.Login(this.Session);
if (CompanyID == 0) CompanyID = Convert.ToInt32(Session["CompanyId"]);
return DataNew.GetPlatBaseCode(CompanyID, KeyName);
}
#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 货物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 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 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 = DataNew.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 读取sku属性
[WebMethod(EnableSession = true)]
public List<JC_Property> GetPropertyList()
{
Pages.Login(this.Session);
int CompanyId = Convert.ToInt32(Session["CompanyId"]);
var obj = new BaseService();
var list = obj.GetPropertyList(CompanyId);
return list;
}
#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();
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 void SaveGoodsPrice(int GoodsId, decimal? NowPrice)
{
Pages.Login(this.Session);
var obj = new HuoWuData();
if (NowPrice == null)
NowPrice = 0;
obj.UpdateGoodsPrice(GoodsId, NowPrice);
}
#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]);
}
}
}
}
Pages.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 计算运费
[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
[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 = Convert.ToInt32(base.Session["CompanyId"]);
MUserId = Convert.ToInt32(base.Session["UserId"]);
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 (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 == 22)
where.Add("b.guserid_tiktok", "=", 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;
}
#region 查询货物sku
[WebMethod(EnableSession = true)]
public void UpdateGoodsDays()
{
DataNew.UpdateGoodsDays();
}
#endregion
#region 首页编号前三
[WebMethod(EnableSession = true)]
public string GetDefaultDataForGoodsCode22(int Days)
{
PagesNew.Login(this.Session);
int CompanyId = Convert.ToInt32(Session["CompanyId"]);
int userid = Convert.ToInt32(Session["UserId"]);
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(userid, 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 GetDefaultDataForGoodsCode11(int Days)
{
PagesNew.Login(this.Session);
int CompanyId = Convert.ToInt32(Session["CompanyId"]);
int userid = Convert.ToInt32(Session["UserId"]);
BaseService obj = new BaseService();
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(userid, 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
}
}