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/TradeManage/SysManageServiceNew.asmx.cs

8778 lines
389 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 TradeManageNew;
using NetLibrary.Data;
using System.Data;
using TradeData;
using System.Text;
using NetLibrary.ReportPrint;
using NetLibrary;
using TradeModel;
using NetLibrary.Log;
using System.Web.Script.Serialization;
using System.Collections;
using System.Reflection;
using System.IO;
using System.Text.RegularExpressions;
namespace TradeManage
{
/// <summary>
/// SysManageServiceNew 的摘要说明
/// </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 SysManageServiceNew : System.Web.Services.WebService
{
[WebMethod]
public string HelloWorld()
{
return "Hello World";
}
#region 保存店铺数据
[WebMethod(EnableSession = true)]
public int SaveShopData2(JC_ShopDataNew Model)
{
PagesNew.Login(this.Session);
int CompanyId = Convert.ToInt32(Session["CompanyId"]);
if (Model.Id == null || Model.Id.Value == 0)
Model.InDate = DateTime.Now;
Model.InName = Session["Name"].ToString();
Model.InUserId = Convert.ToInt32(Session["UserId"]);
int Id = DataNew.SaveShopData(Model);
return Id;
}
#endregion
#region 查询店铺数据
[WebMethod(EnableSession = true)]
public JsonModel<List<JC_ShopDataNew>> GetListJC_ShopData2(int ShopId, string ShopIds, DateTime? SDate, DateTime? EDate, int PageIndex, int PageSize)
{
PagesNew.Login(this.Session);
RefParameterCollection Param = new RefParameterCollection();
if (ShopId > 0)
Param.Add("a.ShopId", "=", ShopId, DbType.Int32);
else if (ShopIds != "")
{
Param.Add("a.ShopId", "in", ShopIds.Trim(','), 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);
JsonModel<List<JC_ShopDataNew>> resultModel = new JsonModel<List<JC_ShopDataNew>>();
int RowCount = 0;
string Sort = "Id desc";
resultModel.DataSource = DataNew.GetListJC_ShopData2(Param, PageIndex, PageSize, Sort, out RowCount);
resultModel.RowCount = RowCount;
return resultModel;
}
#endregion
#region 报表182
[WebMethod(EnableSession = true)]
public string GetReportTable182(DateTime? InDate, DateTime? EDate, int DeptId, int ShopId, int PlatId, string MoneyCode, string Sort)
{
string dd = "";
try
{
var obj = new BaseService();
EDate=EDate.Value.AddDays(1);
string tj = "";
string tj1 = "";
if (DeptId > 0)
{
tj += " and b.DeptId=" + DeptId + " ";
tj1 += " and a.DeptId=" + DeptId + " ";
}
if (PlatId > 0)
{
tj += " and b.PlatType=" + PlatId + " ";
tj1 += " and a.PlatType=" + PlatId + " ";
}
if (ShopId > 0)
{
tj += " and b.ShopId=" + ShopId + " ";
tj1 += " and a.ShopId=" + ShopId + " ";
}
if (MoneyCode != "0")
tj += " and a.MoneyCode='" + MoneyCode + "' ";
decimal hj = DataNew.GetListTotalPrice2(InDate.Value, EDate.Value);
TimeSpan ts = EDate.Value - InDate.Value;
int days = ts.Days;
decimal thj = 100000 * 12 * days / 365;//每月10w 每天平摊仓储费
decimal fje = 0;
if (hj > 0)
fje = thj * 1.00M / hj;
string sql = @"
select a.ShopId,a.ShopName,OrderNum=isnull(c.OrderNum,0),USDMoney=isnull(c.USDMoney,0),RMBMoney=isnull(c.RMBMoney,0),AvgPrice=case when c.OrderNum is null or c.USDMoney is null or c.OrderNum=0 then 0 else c.USDMoney/c.OrderNum end,InPrice=d.InPrice,InPrice=d.InPrice,BZ=case when d.InPrice>0 then RMBMoney/d.InPrice else 0 end,LR=0,MLL='',ShopCDGoods=0,ShopTJGoods=0,ckfee=0.00,mdfee=isnull(c.OrderNum,0)*0.6,ftckfee=isnull(c.USDMoney,0)*" + fje + @",LR2=0,MLL2='',b.Rate3 from JC_Shop a
inner join (select b.ShopId,OrderNum=COUNT(0),USDMoney=SUM(dbo.MoneyUSDChange(TotalPrice,a.MoneyCode,a.CompanyId)),RMBMoney=SUM(dbo.MoneyChange(TotalPrice,a.MoneyCode,a.CompanyId)) from DT_OrderInfo a with(nolock)
inner join JC_Shop b with(nolock) on a.ShopId=b.ShopId
where a.State>0 " + tj + " and a.State<3 and a.OrderDate>='" + InDate.Value.ToString("yyyy-MM-dd")+"' and a.OrderDate<'" + EDate.Value.ToString("yyyy-MM-dd")+@"' group by b.ShopId)c on a.ShopId=c.ShopId
left join (select ShopId,Rate3=sum(isnull(Rate3,0)) from JC_ShopData with(nolock) where InDate>='" + InDate.Value.ToString("yyyy-MM-dd") + "' and InDate<'" + EDate.Value.ToString("yyyy-MM-dd") + @"'
group by ShopId) b on a.ShopId=b.ShopId
inner join (select a.ShopId,InPrice=sum(isnull(d.InPrice,0)*b.GoodsNum) from DT_OrderInfo a with(nolock)
inner join DT_OrderGoods b with(nolock) on a.OrderId=b.OrderId
inner join HW_GoodsDetail c with(nolock) on b.DetailId=c.DetailId
inner join HW_GoodsInfo d with(nolock) on c.GoodsId=d.GoodsId
where a.State>0 and a.State<3 and a.OrderDate>='" + InDate.Value.ToString("yyyy-MM-dd") + "' and a.OrderDate<'" + EDate.Value.ToString("yyyy-MM-dd") + @"' group by a.ShopId)d on a.ShopId=d.ShopId
where a.CompanyId=1 " + tj1 + " order by " + Sort;
DataTable dt = obj.GetReportData(sql);
string sql2 = @"
select a.*,Num2=isnull(b.Num2,0) from (
select b.ShopId,Num=COUNT(0) from HW_GoodsInfo a with(nolock)
inner join HW_Shop b with(nolock) on a.GoodsId=b.GoodsId
group by b.ShopId)a
left join (
select a.ShopId,Num2=COUNT(distinct c.GoodsId) from DT_OrderInfo a with(nolock)
inner join DT_OrderGoods b with(nolock) on a.OrderId=b.OrderId
inner join HW_GoodsDetail c with(nolock) on b.DetailId=c.DetailId
where a.State>0 and a.State<3 and a.OrderDate>='" + InDate.Value.ToString("yyyy-MM-dd") + "' and a.OrderDate<'" + EDate.Value.ToString("yyyy-MM-dd") + @"' group by a.ShopId)b on a.ShopId=b.ShopId";
DataTable dt2 = obj.GetReportData(sql2);
var dlist = DataNew.GetListGoodsDays(InDate.Value);
DD_OrderData data = new DD_OrderData();
if (dt != null)
{
decimal f1 = 0;
decimal f2 = 0;
decimal f3 = 0;
decimal f4 = 0;
decimal f5 = 0;
decimal f6 = 0;
// int ds = 0;
// decimal f9 = 0;
decimal cyxs = 0;
decimal cyyj = 0;
decimal hwcb = 0;
decimal hwtc = 0;
decimal hwyf = 0;
decimal hwyf1 = 0;
decimal hwyf2 = 0;
int yf1 = 0;
int yf2 = 0;
for (int i = 0; i < dt.Rows.Count; i++)
{
decimal ckfee = 0;//存储费
decimal mdfee = 0;//面单费
decimal MRate = Convert.ToDecimal((double)6.5);
List<JC_Money> list7 = new BaseService().GetMoneyList2();
var olist = DataNew.GetListShopList2(Convert.ToInt32(dt.Rows[i]["ShopId"]), InDate);
string ids = "";
if (olist != null)
{
foreach (var order in olist)
{
ids += order.OrderId.ToString() + ",";
}
}
if (ids != "")
{
// List<DT_OrderGoods> orderGoodsListPP = DataNew.GetOrderGoodsListPP(ids.Trim(','));
List<DT_OrderGoods> orderGoodsList = DataNew.GetOrderGoodsList(ids.Trim(','));
if (orderGoodsList != null)
{
//ds += orderGoodsList.Count;
//foreach (var md in orderGoodsList)
//{
// f9 += md.GoodsPrice.Value * md.GoodsNum.Value;
//}
foreach (var md in olist)
{
List<DT_OrderGoods> gmd = null;
if (gmd == null)
gmd = orderGoodsList.FindAll(n => n.OrderId == md.OrderId);
md.GoodsList = gmd;
}
}
}
decimal lr = 0;
decimal lr2 = 0;
string AddrType = "";
decimal tweight = 0;
if (olist != null)
{
foreach (var md in olist)
{
//if (md.PlatOrderCode == "2793358899439")
//{
// string cc = "";
//}
JC_Money money = list7.Find(n => n.MCode == "USD" && n.PlatId == md.PlatId);
if (money != null)
{
MRate = money.MRate.Value;
}
else
{
money = list7.Find(n => n.MCode == "USD");
MRate = money.MRate.Value;
}
decimal TotalPrice = md.TotalPrice.Value;
decimal yj = 0M;
yj = TotalPrice * Convert.ToDecimal((double)0.15);
int PlatType = md.PlatId.Value;
if (PlatType == 1)
{
yj = TotalPrice * Convert.ToDecimal((double)0.05);
}
else if (PlatType == 4)
{
yj = 0;
}
else if (PlatType == 5)
{
yj = TotalPrice * Convert.ToDecimal((double)0.1);
}
f1 += TotalPrice;
f2 += yj;
decimal GoodsPrice = 0M;
decimal TCFee = 0M;
decimal TCFee2 = 0M;
decimal SolidFee = 0M;
decimal GoodsPrice2 = 0M;
decimal ckfee2 = 0M;
tweight = 0;
if (md.GoodsList != null)
{
if (md.GoodsList.Count > 0)
{
AddrType = md.GoodsList[0].JoinOrderCode;
}
if (md.GoodsList != null)
{
foreach (DT_OrderGoods goods in md.GoodsList)
{
if (dlist != null)
{
var dmd = dlist.Find(n => n.OrderId == md.OrderId && n.DetailId == goods.DetailId);
if (dmd != null && dmd.days > 0)
{
ckfee2 += dmd.days.Value * 1.00M * goods.Solid2.Value * goods.GoodsNum.Value * 0.3M;
ckfee += dmd.days.Value * 1.00M * goods.Solid2.Value * goods.GoodsNum.Value * 0.3M;
}
}
//if (goods.GoodsFee.HasValue && (goods.GoodsFee.Value > 0M))
//{
// GoodsPrice += goods.GoodsFee.Value;
//}
//else
if (goods.Weight != null)
{
tweight += goods.Weight.Value * goods.GoodsNum.Value;
}
if (goods.GoodsPrice.HasValue)
{
GoodsPrice2 += goods.GoodsPrice.Value * goods.GoodsNum.Value;
//f9 += goods.GoodsPrice.Value * goods.GoodsNum.Value;
}
// ds++;
if (goods.TCFee != null && goods.TCFee > 0 && goods.GoodsPrice != null)//税费
{
GoodsPrice2 += goods.GoodsPrice.Value * goods.GoodsNum.Value * goods.TCFee.Value * Convert.ToDecimal(0.01);
}
//if (goods.Solid != null && goods.Solid > 0)//匹配的头程费
//{
// TCFee2 += goods.Solid.Value * goods.GoodsNum.Value;
//}
//else
if (goods.Solid2.HasValue)
{
SolidFee += goods.Solid2.Value * goods.GoodsNum.Value;
}
}
}
}
if (GoodsPrice2 > 0M)
{
GoodsPrice = GoodsPrice2 / MRate;
}
f4 += GoodsPrice;
decimal escrowFee = 0M;
if ((TCFee == 0M) && (SolidFee > 0M))
{
TCFee = Convert.ToDecimal(65) * SolidFee;
}
// TCFee += TCFee2;
f5 += TCFee;// +TCFee2;
if (md.escrowFee.HasValue)
{
escrowFee = md.escrowFee.Value;
}
decimal num10 = 0M;
if (md.PostFee.HasValue)
{
num10 = md.PostFee.Value;
}
// decimal num11 = 0M;
// decimal num12 = 0M;
// decimal num13 = 0M;
//if (md.Post == 222 || md.Post == 226 || md.Post == 227)
//{
// num13 = num10 * Convert.ToDecimal((double)0.1);
//}
decimal feestore11 = 0M;//e仓运费
decimal feestore6 = 0M;//w仓运费
decimal feestore = 0M;
if (md.Fee11 != null && md.Fee11 > 0)
{
feestore11 = md.Fee11.Value;
}
if (feestore11 == 0 && md.Fee12 != null && md.Fee12 > 0)
feestore11 = md.Fee12.Value;
if (md.Fee12 != null && md.Fee12 > 0 && md.Fee12 < feestore11)
{
feestore11 = md.Fee12.Value;
}
if (feestore11 == 0 && md.Fee13 != null && md.Fee13 > 0)
feestore11 = md.Fee13.Value;
if (md.Fee13 != null && md.Fee13 > 0 && md.Fee13 < feestore11)
{
feestore11 = md.Fee13.Value;
}
if (AddrType == "Residential" || AddrType == "RESIDENTIAL")
{
if (md.Fee11 != null && md.Fee13 != null && md.Fee11 > 0 && md.Fee11 < md.Fee13)
{
feestore11 = md.Fee11.Value;
}
else if (md.Fee11 != null && md.Fee13 != null && md.Fee13 > 0 && md.Fee11 > md.Fee13)
{
feestore11 = md.Fee13.Value;
}
}
if (AddrType == "Commercial" || AddrType == "OFFICE")
{
if (md.Fee11 != null && md.Fee12 != null && md.Fee11 > 0 && md.Fee11 < md.Fee12)
{
feestore11 = md.Fee11.Value;
}
else if (md.Fee11 != null && md.Fee12 != null && md.Fee12 > 0 && md.Fee11 > md.Fee12)
{
feestore11 = md.Fee12.Value;
}
}
if (md.Fee12 != null && tweight >= 1120 && md.Fee12 > 0)
feestore11 = md.Fee12.Value;
if (feestore11 > 0)
{
hwyf1 += feestore11;
yf1++;
// DD_OrderData.GetGoodsFee2(md.OrderId.Value, num14);
}
if (md.Fee6 != null && md.Fee6 > 0)
{
feestore6 = md.Fee6.Value;
}
if (feestore6 == 0 && md.Fee7 != null && md.Fee7 > 0)
feestore6 = md.Fee7.Value;
if (md.Fee7 != null && md.Fee7 > 0 && md.Fee7 < feestore6)
{
feestore6 = md.Fee7.Value;
}
if (feestore6 == 0 && md.Fee8 != null && md.Fee8 > 0)
feestore6 = md.Fee8.Value;
if (md.Fee8 != null && md.Fee8 > 0 && md.Fee8 < feestore6)
{
feestore6 = md.Fee8.Value;
}
if (AddrType == "Residential" || AddrType == "RESIDENTIAL")
{
if (md.Fee6 != null && md.Fee8 != null && md.Fee6 > 0 && md.Fee6 < md.Fee8)
{
feestore6 = md.Fee6.Value;
}
else if (md.Fee6 != null && md.Fee8 != null && md.Fee8 > 0 && md.Fee6 > md.Fee8)
{
feestore6 = md.Fee8.Value;
}
}
if (AddrType == "Commercial" || AddrType == "OFFICE")
{
if (md.Fee6 != null && md.Fee7 != null && md.Fee6 > 0 && md.Fee6 < md.Fee7)
{
feestore6 = md.Fee6.Value;
}
else if (md.Fee6 != null && md.Fee7 != null && md.Fee7 > 0 && md.Fee6 > md.Fee7)
{
feestore6 = md.Fee7.Value;
}
}
if (md.Fee7 != null && tweight >= 1120 && md.Fee7 > 0)
feestore6 = md.Fee7.Value;
if (feestore6 > 0)
{
hwyf2 += feestore6;
yf2++;
// DD_OrderData.GetGoodsFee2(md.OrderId.Value, num14);
}
feestore = feestore11;
if (feestore11 == 0)
feestore = feestore6;
if (feestore6 > 0 && feestore6 < feestore11)
feestore = feestore6;
f6 += feestore;
md.PostFee = new decimal?(num10);
md.BoxFee = new decimal?(feestore);//运费
//decimal num15 = 0M;
decimal num16 = 0M;
// DD_OrderData.GetGoodsFee2(md.OrderId.Value, TCFee);
num16 = TotalPrice - yj - GoodsPrice - escrowFee - feestore - TCFee - ckfee2 - 0.6M;
// ErrorFollow.TraceWrite("Fee18", md.PlatOrderCode, "TotalPrice:" + TotalPrice + "|yj:" + yj + "|GoodsPrice:" + GoodsPrice + "|feestore:" + feestore + "|escrowFee:" + escrowFee + "|TCFee:" + TCFee + "|lr:" + num16);
decimal lrje2 = TotalPrice - yj - GoodsPrice - escrowFee - feestore - TCFee - TotalPrice * fje - 0.6M;
if (feestore > 0 && GoodsPrice > 0)
{
//cyxs += TotalPrice;
//cyyj += yj;
//hwcb += GoodsPrice;
//hwtc += TCFee;
//hwyf += num14;
lr += num16;
lr2 += lrje2;
}
}
}
dt.Rows[i]["ckfee"] = Convert.ToDecimal(ckfee.ToString("0.00"));
decimal ptckfee2 = 0;
if (dt.Rows[i]["ftckfee"].ToString() != "")
ptckfee2 = Convert.ToDecimal(dt.Rows[i]["ftckfee"].ToString());
dt.Rows[i]["ftckfee"] = Convert.ToDecimal(ptckfee2.ToString("0.00"));
decimal ggfee = 0;
if (dt.Rows[i]["Rate3"].ToString() != "")
ggfee = Convert.ToDecimal(dt.Rows[i]["Rate3"].ToString());
lr = lr - ggfee;
lr2 = lr2 - ggfee;
dt.Rows[i]["LR"] = lr;
dt.Rows[i]["LR2"] = lr2;
if (dt.Rows[i]["USDMoney"].ToString() != "" && Convert.ToDecimal(dt.Rows[i]["USDMoney"]) > 0)
dt.Rows[i]["MLL"] = (lr * 100 / Convert.ToDecimal(dt.Rows[i]["USDMoney"])).ToString("0.00") + "%";
if (dt.Rows[i]["USDMoney"].ToString() != "" && Convert.ToDecimal(dt.Rows[i]["USDMoney"]) > 0)
dt.Rows[i]["MLL2"] = (lr2 * 100 / Convert.ToDecimal(dt.Rows[i]["USDMoney"])).ToString("0.00") + "%";
if (dt2 != null)
{
var row = dt2.Select("shopId=" + Convert.ToInt32(dt.Rows[i]["ShopId"]));
if (row != null && row.Length > 0)
{
dt.Rows[i]["ShopCDGoods"] = Convert.ToInt32(row[0]["Num2"]);
dt.Rows[i]["ShopTJGoods"] = Convert.ToInt32(row[0]["Num"]);
}
}
}
//decimal f0 = f1 - f2 - f4 - f5 - f6;
//decimal zlr = cyxs - cyyj - hwcb - hwtc - hwyf - hwyf1 - hwyf2-yf1-yf2;
}
return GetReport3(dt, 46);
}
catch (Exception ex)
{
string a = dd;
return "";
}
}
#endregion
#region 报表401
[WebMethod(EnableSession = true)]
public string GetReportTable401(DateTime? SDate, DateTime? EDate, int UserId, string GoodsCode)
{
var obj = new BaseService();
int CompanyId = Convert.ToInt32(Session["CompanyId"]);
string tj = "";
string tj2 = "";
EDate = EDate.Value.AddDays(1);
if (SDate != null)
{
tj += " and OrderDate>='" + SDate.Value.ToString("yyyy-MM-dd") + "' ";
// tj2 += " b.LastOrderDate>='" + SDate.Value.ToString("yyyy-MM-dd") + "' ";
}
if (EDate != null)
{
tj += " and OrderDate<'" + EDate.Value.ToString("yyyy-MM-dd") + "' ";
// tj2 += " and b.LastOrderDate<'" + EDate.Value.AddDays(1).ToString("yyyy-MM-dd") + "' ";
}
if (UserId > 0)
{
tj2 += " where a.UserId=" + UserId + " ";
}
string tj3 = "";
string tj4 = "";
if (SDate != null)
{
tj3 += " OrderDate>='" + SDate.Value.ToString("yyyy-MM-dd") + "' ";
tj4 += " addate>='" + SDate.Value.ToString("yyyy-MM-dd") + "' ";
}
if (EDate != null)
{
tj3 += " and OrderDate<'" + EDate.Value.ToString("yyyy-MM-dd") + "' ";
tj4 += " and addate<'" + EDate.Value.AddDays(1).ToString("yyyy-MM-dd") + "' ";
}
//decimal hj = DataNew.GetListTotalPrice2(SDate.Value, EDate.Value);
//TimeSpan ts = EDate.Value - SDate.Value;
//int days = ts.Days;
//decimal thj = 100000 * 12 * days / 365;//每月10w 每天平摊仓储费
//decimal fje = 0;
//if (hj > 0)
// fje = thj * 1.00M / hj;
//if (GoodsCode != "")
// tj2 += " and e.GoodsCode='" + GoodsCode + "' ";
string sql = @"
declare @MRate decimal(18,4)
select top 1 @MRate=MRate from JC_Money where MCode='USD' and PlatId=2
--参与计算得订单
select *,zje=dbo.MoneyUSDChange(TotalPrice,MoneyCode,1),yj=dbo.getYJRate2(PlatId,dbo.MoneyUSDChange(TotalPrice,MoneyCode,2)) into #DT_OrderInfoUser from DT_OrderInfo with(nolock) where CompanyId=1 and State>0 and State<3 " + tj + @" and dbo.[GetOrderPostFee](OrderId)>0
--退款费用
select DR_BackFee,orderid into #BackFee_ls from DT_OrderInfo where " + tj3 + @"
--退货运费
select DR_PostFee,orderid into #PostFee_ls from DT_OrderInfo where " + tj3 + @"
--退货申诉赔款
select DR_SSFee,orderid into #SSFee_ls from DT_OrderInfo where " + tj3 + @"
--广告费
select shopid,goodsid,addfee=SUM(dec3) into #ADFee_ls from DT_AdFee where " + tj4 + @" group by shopid,goodsid
--select * from #ADFee_ls where addfee>10000
--仓储费
/*select e.OrderId,ckfee=isnull(sum((DATEDIFF(day,a.InDate,a.UpDateTime)+1)*0.5*d.GoodsNum*ISNULL(c.Solid,0)),0) into #CKFee_ls from HW_GoodsInDetail a with(nolock)
inner join HW_GoodsDetail b with(nolock) on a.DetailId=b.DetailId
inner join HW_GoodsInfo c with(nolock) on b.GoodsId=c.GoodsId
inner join DT_OrderGoods d with(nolock) on a.OrderGoodsId=d.Id
inner join #DT_OrderInfoUser e on d.OrderId=e.OrderId
where a.UpDateTime is not null group by e.OrderId*/
update #DT_OrderInfoUser set GoodsNum=1 where ISNULL(GoodsNum,0)=0
select a.ShopId,PlatId=case when a.PlatId=2 then 2 else 1 end,c.GoodsId,zje=SUM(a.zje*b.GoodsNum/a.GoodsNum),yj=SUM(a.yj*b.GoodsNum/a.GoodsNum),OrderNum=COUNT(distinct a.PlatOrderCode),Num=sum(b.GoodsNum),OutGoods=count(distinct d.GoodsId),cb=sum(b.GoodsNum*isnull(d.InPrice,0))/6.6,tc=sum(170*isnull(d.Solid,0)*isnull(b.GoodsNum,0)),md=sum(b.GoodsNum)*0.6,yf=SUM(L.yf),sf=sum(b.GoodsNum*isnull(d.InPrice,0)*isnull(d.FeeRate,0)*0.01)/6.6,ck=isnull(sum(L.ck),0),tkf=isnull(sum(e.DR_BackFee),0),thyf=isnull(sum(f.DR_PostFee),0),ssf=isnull(sum(g.DR_SSFee),0) into #DT_Fee_LS from #DT_OrderInfoUser a with(nolock)
inner join DT_OrderGoods b with(nolock) on a.OrderId=b.OrderId
inner join HW_GoodsDetail c with(nolock) on b.DetailId=c.DetailId
inner join HW_GoodsInfo d with(nolock) on c.GoodsId=d.GoodsId
left join [DT_Fees] L on a.OrderId=L.OrderId
left join #BackFee_ls e on a.OrderId=e.OrderId
left join #PostFee_ls f on a.OrderId=f.OrderId
left join #SSFee_ls g on a.OrderId=g.OrderId
group by a.PlatId,a.ShopId,c.GoodsId
--drop table #DT_Fee_LS
select a.*,ggf=isnull(b.addfee,0),ml=zje-yj-cb-tc-md-yf-sf-ck-tkf-thyf-isnull(b.addfee,0)+ssf,ml2=zje-yj-cb-tc-yf-sf-tkf-thyf-isnull(b.addfee,0)+ssf into #DT_Fee_LS2 from #DT_Fee_LS a
left join #ADFee_ls b on a.GoodsId=b.goodsid and a.ShopId=b.shopid
select b.UserId,ml=SUM(c.ml2)*@MRate into #DT_Fee_LS3 from HW_GoodsUser a with(nolock)
inner join JC_UserInfo b on a.UserId=b.UserId
inner join #DT_Fee_LS2 c on a.GoodsId=c.GoodsId and a.ShopId=c.ShopId
where b.State=1
group by b.UserId
--select SUM(zje),sum(cb),SUM(tc),SUM(yf) from #DT_Fee_LS2
select a.*,GoodsNum=d.Num,NoGoods=d.Num-OutGoods,Rate=OutGoods*1.00/d.Num,ymxml=isnull(e.ml,0),rylx=case when kh=0 then '新人不考核' else '正常考核' end,ymxkh=kh,ymxjj=case when kh=0 then 0 when kh>=80000 and isnull(e.ml,0)>=kh then floor((isnull(e.ml,0)-kh)/10000)*300 when kh>=80000 and isnull(e.ml,0)<kh then floor((kh-isnull(e.ml,0))/10000)*-300 when kh<80000 and isnull(e.ml,0)>=kh then floor((isnull(e.ml,0)-kh)/10000)*300 else 0 end from (
select b.UserId,b.UserName,b.Name,Num=SUM(Num),OutGoods=SUM(OutGoods),OrderNum=SUM(OrderNum),zje=SUM(c.zje),yj=SUM(c.yj),cb=SUM(c.cb),tc=SUM(c.tc),md=SUM(c.md),yf=SUM(c.yf),sf=SUM(c.sf),ck=SUM(c.ck),tkf=SUM(c.tkf),thyf=SUM(c.thyf),ggf=SUM(c.ggf),ssf=SUM(c.ssf),ml=SUM(c.ml),mll=SUM(c.ml)/SUM(c.zje),kh=MAX(isnull(AnnualDay,0)) from HW_GoodsUser a with(nolock)
inner join JC_UserInfo b on a.UserId=b.UserId
inner join #DT_Fee_LS2 c on a.GoodsId=c.GoodsId and a.ShopId=c.ShopId
where b.State=1
group by b.UserId,b.UserName,b.Name)a
inner join (select UserId,Num=COUNT(distinct GoodsId) from HW_GoodsUser with(nolock)
group by UserId)d on a.UserId=d.UserId
left join #DT_Fee_LS3 e on a.UserId=e.UserId
" + tj2 + @"
--select * from HW_GoodsUser
";
DataTable dt = obj.GetReportData(sql);
return GetReport2(dt, 50);
}
#endregion
#region 报表403
[WebMethod(EnableSession = true)]
public string GetReportTable403(DateTime? SDate, DateTime? EDate, int UserId, string GoodsCode, decimal? moneyrate)
{
try
{
var obj = new BaseService();
int CompanyId = Convert.ToInt32(Session["CompanyId"]);
string tj = "";
string tj2 = "";
string tj3 = "";
EDate = EDate.Value.AddDays(1);
if (SDate != null)
{
tj += " and a.OrderDate>='" + SDate.Value.ToString("yyyy-MM-dd") + "' ";
tj3 += " and d.OrderDate>='" + SDate.Value.ToString("yyyy-MM-dd") + "' ";
}
if (EDate != null)
{
tj += " and a.OrderDate<'" + EDate.Value.ToString("yyyy-MM-dd") + "' ";
tj3 += " and d.OrderDate<'" + EDate.Value.ToString("yyyy-MM-dd") + "' ";
}
if (UserId > 0)
{
tj2 += " where a.UserId=" + UserId + " ";
}
//decimal hj = DataNew.GetListTotalPrice2(SDate.Value, EDate.Value);
TimeSpan ts = EDate.Value - SDate.Value;
int days = ts.Days;
//decimal thj = 100000 * 12 * days / 365;//每月10w 每天平摊仓储费
//decimal fje = 0;
//if (hj > 0)
// fje = thj * 1.00M / hj;
if (moneyrate == null)
moneyrate = 6.8M;
//if (GoodsCode != "")
// tj2 += " and e.GoodsCode='" + GoodsCode + "' ";
string sql = @"
declare @MRate decimal(18,4)
select top 1 @MRate=" + moneyrate + @"
--MRate from JC_Money where MCode='USD' and PlatId=2
--sjyf 实际运费 thf 退货费 thyf 退货运费 wlssf 物流申诉费 qtfy 其他费用 ggf 广告费
--yj 佣金,escrowFee 税费,yf 预估运费,b.cb 成本 人民币 ,b.sjcb 匹配成本 人民币 ,b.hwsf 货物税费 人民币,b.sjhwsf 匹配税费 人民币,b.ck 仓储费,b.md 面单费 tc 头程费
select a.OrderId,a.ShopId,a.PlatId,a.PlatOrderCode,a.OrderCode,a.OrderDate,a.InDate,a.TotalPrice,escrowFee=isnull(a.escrowFee,0),a.MoneyCode,a.GoodsNum,thf=DR_BackFee,thyf=DR_PostFee,wlssf=DR_SSFee,qtfy=Other_Fee,ggf=Ad_Fee,b.yj,yf=case when c.PostFee>0 then c.PostFee else isnull(b.yf,0) end,cb=case when b.sjcb>0 then b.sjcb/isnull(b.moneyrate,1) else ISNULL(b.cb,0)/isnull(b.moneyrate,1) end,hwsf=case when b.sjhwsf>0 then b.sjhwsf/isnull(b.moneyrate,1) else isnull(b.hwsf,0)/isnull(b.moneyrate,1) end,b.ck,b.md,tc=case when isnull(b.sjtc,0)>0 then b.sjtc else b.tc end into #ls_fee from DT_OrderInfo a with(nolock)
inner join DT_OrderXXInfo c with(nolock) on a.orderid=c.orderid
left join DT_Fees b with(nolock) on a.OrderId=b.orderid
where a.State>0 and a.State<3 " + tj + @"
select a.UserId,ordernum=COUNT(distinct d.OrderId),codenum=COUNT(distinct a.GoodsId),GoodsNum=sum(c.GoodsNum) into #ls_fee5 from HW_GoodsUser a with(nolock)
inner join HW_GoodsDetail b with(nolock) on a.GoodsId=b.GoodsId
inner join DT_OrderGoods c with(nolock) on b.DetailId=c.DetailId
inner join DT_OrderInfo d with(nolock) on c.OrderId=d.OrderId and a.ShopId=d.ShopId
where d.State>0 and d.State<3 " + tj3 + @"
group by a.UserId
select a.UserId,a.ShopId,d.OrderId into #ls_fee2 from HW_GoodsUser a with(nolock)
inner join HW_GoodsDetail b with(nolock) on a.GoodsId=b.GoodsId
inner join DT_OrderGoods c with(nolock) on b.DetailId=c.DetailId
inner join DT_OrderInfo d with(nolock) on c.OrderId=d.OrderId and a.ShopId=d.ShopId
where d.State>0 and d.State<3 " + tj3 + @"
group by a.UserId,a.ShopId,d.OrderId
select a.UserId,zje=SUM(b.TotalPrice) into #ls_fee3 from #ls_fee2 a
inner join #ls_fee b on a.OrderId=b.OrderId
group by a.UserId
select a.UserId,zje,escrowFee,yj,yf,cb,hwsf,tc,ck,md,thf,thyf,ggf,qtfy,wlssf,ml=zje-escrowFee-yj-yf-cb-hwsf-tc-ck-md-thf-thyf-ggf-qtfy+wlssf,ymxml=zje-escrowFee-yj-yf-cb-hwsf-tc-thf-thyf-ggf-qtfy+wlssf,mll=case when zje>0 then (zje-escrowFee-yj-yf-cb-hwsf-tc-ck-md-thf-thyf-ggf-qtfy+wlssf)*100.00/zje else 0 end into #ls_fee4 from (
select a.UserId,zje=SUM(b.TotalPrice),escrowFee=SUM(b.escrowFee),yj=SUM(isnull(yj,0)),yf=SUM(isnull(yf,0)),cb=SUM(isnull(cb,0)),hwsf=SUM(isnull(hwsf,0)),tc=SUM(isnull(tc,0)),ck=SUM(isnull(ck,0)),md=SUM(isnull(md,0)),thf=SUM(isnull(thf,0)),thyf=SUM(isnull(thyf,0)),qtfy=SUM(isnull(qtfy,0)),ggf=SUM(isnull(ggf,0)),wlssf=SUM(isnull(wlssf,0)) from #ls_fee2 a
inner join #ls_fee b on a.OrderId=b.OrderId
where b.yf>0 and b.cb>0
group by a.UserId)a
select a.UserName,GoodsNum=a.Num,OutGoods=g.codenum,NoGoods=a.Num-g.codenum,Rate=g.codenum*1.00/a.Num,a.Name,sjzje=f.zje,OrderNum=g.ordernum,Num=g.GoodsNum,e.*,rylx=case when kh=0 then '新人不考核' else '正常考核' end,ymxkh=kh,ymxjj=isnull(e.ymxml,0)-kh from (
select a.UserId,a.UserName,a.Name,kh=550*" + days + @",b.Num from JC_UserInfo a
inner join (
select UserId,Num=COUNT(distinct GoodsId) from HW_GoodsUser with(nolock)
group by UserId)b on a.UserId=b.UserId
where a.state=1)a
inner join #ls_fee4 e on a.UserId=e.UserId
left join #ls_fee3 f on a.UserId=f.UserId
left join #ls_fee5 g on a.UserId=g.UserId
" + tj2 + @"";
DataTable dt = obj.GetReportData(sql);
return GetReport2(dt, 53);
}
catch (Exception ex)
{
ErrorFollow.TraceWrite("GetReportTable401", "", ex.Message);
return null;
}
}
#endregion
// #region 报表18
// [WebMethod(EnableSession = true)]
// public string GetReportTable18(DateTime? InDate, int DeptId, int ShopId, int PlatId, string MoneyCode, string Sort, bool isyc)
// {
// string dd = "";
// try
// {
// var obj = new BaseService();
// string tj = "";
// string tj1 = "";
// //if (DeptId > 0)
// //{
// // tj += " and b.DeptId=" + DeptId + " ";
// // tj1 += " and a.DeptId=" + DeptId + " ";
// //}
// if (PlatId > 0)
// {
// tj += " and a.PlatId=" + PlatId + " ";
// tj1 += " and a.PlatId=" + PlatId + " ";
// }
// if (ShopId > 0)
// {
// tj += " and a.ShopId=" + ShopId + " ";
// tj1 += " and a.ShopId=" + ShopId + " ";
// }
// //if (MoneyCode != "0")
// // tj += " and a.MoneyCode='" + MoneyCode + "' ";
// // string sql = @"
// //declare @moneyrate decimal(18,4)
// //select @moneyrate=MRate from JC_Money where MCode='USD' and PlatId=2
// //select a.ShopId,a.TotalPrice,escrowFee=isnull(a.escrowFee,0),a.RMBPrice,c.yj,yf=c.yf,cb=c.cb,hwsf=c.hwsf,c.tc,c.ck,c.md,a.Ad_Fee,a.DR_BackFee,a.DR_PostFee,a.DR_SSFee,a.Other_Fee,moneyrate=isnull(c.moneyrate,@moneyrate) into #ls from DT_OrderInfo a with(nolock)
// //inner join DT_OrderXXInfo b with(nolock) on a.OrderId=b.OrderId
// //left join DT_Fees c with(nolock) on a.OrderId=c.orderid
// //where DATEDIFF(day,a.OrderDate,'" + InDate.Value.ToString("yyyy-MM-dd") + @"')=0 " + tj + @" and a.State>0 and a.State<3
// //select a.*,Num2=isnull(b.Num2,0) into #ls2 from (
// //select b.ShopId,Num=COUNT(0) from HW_GoodsInfo a with(nolock)
// //inner join HW_Shop b with(nolock) on a.GoodsId=b.GoodsId
// //group by b.ShopId)a
// //left join (
// //select a.ShopId,Num2=COUNT(distinct c.GoodsId) from DT_OrderInfo a with(nolock)
// //inner join DT_OrderGoods b with(nolock) on a.OrderId=b.OrderId
// //inner join HW_GoodsDetail c with(nolock) on b.DetailId=c.DetailId
// //where a.State>0 and a.State<3 and DATEDIFF(day,a.OrderDate,'" + InDate.Value.ToString("yyyy-MM-dd") + @"')=0 group by a.ShopId)b on a.ShopId=b.ShopId
// //select d.ShopName,Master=case when d.Master=d.buyer then d.Master when d.buyer is not null and d.buyer<>'' then d.Master+'-'+d.buyer else d.Master end,a.OrderNum,a.RMBMoney,a.USDMoney,AvgPrice=case when a.OrderNum>0 then cast(a.USDMoney/a.OrderNum as decimal(18,2)) else 0 end,a.InPrice,LR=cast(b.ml as decimal(18,2)),MLL=case when b.TotalPrice>0 then cast(b.ml*100/b.TotalPrice as decimal(18,2)) else 0 end,ShopTJGoods=e.Num,ShopCDGoods=e.Num2,ckfee,a.mdfee,a.adfee,bz=case when a.InPrice>0 then CAST(a.RMBMoney/a.InPrice as decimal(18,2)) else 0 end,c.GoodRate,c.ODR,c.DSRService,c.DSRGoods,h.DSRPost,c.USDUseMoney,c.USDNoMoney,c.RMBUseMoney,c.RMBNoMoney,c.Rate1,c.Rate2,f.Rate3,c.Rate4,c.PropertyViolate,c.Rate5,g.Rate6,Rate7=isnull(c.Rate7,d.dayfee),JL=cast(b.ml as decimal(18,2))+isnull(ckfee,0)+isnull(mdfee,0)-isnull(c.Rate3,0)-isnull(c.Rate7,d.dayfee),FeeDate=isnull(c.FeeDate,d.FeeDate),TXFee=isnull(c.TXFee,d.TXFee) from
// //JC_Shop d left join (
// //select ShopId,OrderNum=COUNT(0),RMBMoney=SUM(RMBPrice),escrowFee=sum(escrowFee),USDMoney=SUM(TotalPrice),InPrice=SUM(cb),ckfee=SUM(ck),mdfee=SUM(md),adfee=SUM(Ad_Fee) from #ls
// //group by ShopId)a on d.ShopId=a.ShopId
// //left join (select ShopId,TotalPrice=sum(TotalPrice),ml=sum(isnull(TotalPrice,0)-isnull(escrowFee,0)-isnull(yj,0)-isnull(yf,0)-((isnull(cb,0)+isnull(hwsf,0))/moneyrate)-isnull(tc,0)-isnull(ck,0)-isnull(md,0)-isnull(Ad_Fee,0)) from #ls where yf>0
// //group by ShopId)b on a.ShopId=b.ShopId
// //left join (
// //select GoodRate,ODR,DSRService,DSRGoods,DSRPost,USDUseMoney,USDNoMoney,RMBUseMoney, RMBNoMoney,Rate1,Rate2,Rate3,Rate4,PropertyViolate,Rate5,Rate6,Rate7,FeeDate,TXFee
// //TXFee,ShopId from JC_ShopData
// //where DATEDIFF(day,indate,'" + InDate.Value.ToString("yyyy-MM-dd") + @"')=0 )c on a.ShopId=c.ShopId
// //left Join #ls2 e on a.ShopId=e.ShopId
// // left join (select shopid,SUM(ABS(adfee)) Rate3 from AD_FeeList where DATEDIFF(day,addate,'" + InDate.Value.AddDays(-2).ToString("yyyy-MM-dd") + "')=0 group by shopid) f on d.ShopId=f.shopid "+
// // " left join ( select shopid,SUM(ABS(adfee)) Rate6 from AD_FeeList where CONVERT(varchar(7), addate, 120)='"+ InDate.Value.ToString("yyyy-MM") + "' group by shopid) g on d.ShopId=g.shopid "+
// // " left join(select b.name shopName,case when a.Spend=0 or a.ad_sale_amount=0 then 0 else cast((Spend/ad_sale_amount)*100 as decimal(12,2)) end DSRPost from ( select sid,SUM(ISNULL(ABS(spend),0)) Spend, SUM(ISNULL(ad_sales_amount,0)) ad_sale_amount from [192.168.1.187].[UpGoods].dbo.LxERP_ProductPerformance where summary_field='Asin' and RequestDate='" + InDate.Value.AddDays(-2).ToString("yyyy-MM-dd") + "' group by sid) a left join [192.168.1.187].[UpGoods].dbo.LxERP_Amazon_Shop b on a.sid=b.sid) h on d.ShopName=h.shopName "
// // + " order by " + Sort;
// string sql = @"
//declare @moneyrate decimal(18,4)
//select @moneyrate=MRate from JC_Money where MCode='USD' and PlatId=2
//select a.ShopId,a.TotalPrice,escrowFee=isnull(a.escrowFee,0),a.RMBPrice,c.yj,yf=c.yf,cb=c.cb,hwsf=c.hwsf,c.tc,c.ck,c.md,a.Ad_Fee,a.DR_BackFee,a.DR_PostFee,a.DR_SSFee,a.Other_Fee,moneyrate=isnull(c.moneyrate,@moneyrate),ISnull( c.SubsidyFee,0) SubsidyFee into #ls from DT_OrderInfo a with(nolock)
//inner join DT_OrderXXInfo b with(nolock) on a.OrderId=b.OrderId
//left join DT_Fees c with(nolock) on a.OrderId=c.orderid
//where DATEDIFF(day,a.OrderDate,'" + InDate.Value.ToString("yyyy-MM-dd") + @"')=0 " + tj + @" and a.State>0 and a.State<3
//select a.*,Num2=isnull(b.Num2,0) into #ls2 from (
//select b.ShopId,Num=COUNT(0) from HW_GoodsInfo a with(nolock)
//inner join HW_Shop b with(nolock) on a.GoodsId=b.GoodsId
//group by b.ShopId)a
//left join (
//select a.ShopId,Num2=COUNT(distinct c.GoodsId) from DT_OrderInfo a with(nolock)
//inner join DT_OrderGoods b with(nolock) on a.OrderId=b.OrderId
//inner join HW_GoodsDetail c with(nolock) on b.DetailId=c.DetailId
//where a.State>0 and a.State<3 and DATEDIFF(day,a.OrderDate,'" + InDate.Value.ToString("yyyy-MM-dd") + @"')=0 group by a.ShopId)b on a.ShopId=b.ShopId
//select * from (
//select d.ShopName,Master=case when d.Master=d.buyer then d.Master when d.buyer is not null and d.buyer<>'' then d.Master+'-'+d.buyer else d.Master end,a.OrderNum,a.RMBMoney,a.USDMoney,AvgPrice=case when a.OrderNum>0 then cast(a.USDMoney/a.OrderNum as decimal(18,2)) else 0 end,a.InPrice,LR=cast(b.ml as decimal(18,2)),MLL=case when b.TotalPrice>0 then cast(b.ml*100/b.TotalPrice as decimal(18,2)) else 0 end,ShopTJGoods=e.Num,ShopCDGoods=e.Num2,ckfee,a.mdfee,a.adfee,bz=case when a.InPrice>0 then CAST(a.RMBMoney/a.InPrice as decimal(18,2)) else 0 end,a.yf,c.GoodRate,c.ODR,t3.CVR DSRService,t3.user_sessions DSRGoods,f.DSRPost,c.USDUseMoney, n1.originalTotalCurrencyAmount as USDNoMoney,c.RMBUseMoney,c.RMBNoMoney,t2.orderDefectRate Rate1,t2.validTrackingRate Rate2,Case when d.PlatType=2 then f.Rate3 else c.Rate3 end Rate3,t4.RefundRate as Rate4, ABS( ISNULL( t4.RefundAmount,0) ) as PropertyViolate,t2.cancelRate Rate5,Case when d.PlatType=2 then g.Rate6 else (select SUM(ISNULL(Rate3,0)) from JC_ShopData where ShopId=d.ShopId and DATEDIFF(MONTH,InDate,'2023-10-18')=0) end Rate6,Rate7=isnull(c.Rate7,d.dayfee),JL=cast(b.ml as decimal(18,2))+isnull(ckfee,0)-isnull(c.Rate3,0)-isnull(c.Rate7,d.dayfee),t1.financialEventGroupEndLocale as FeeDate,t1.originalTotalCurrencyAmount as TXFee from
//JC_Shop d left join (
//select ShopId,OrderNum=COUNT(0),RMBMoney=SUM(RMBPrice),escrowFee=sum(escrowFee),USDMoney=SUM(TotalPrice),InPrice=SUM(cb),ckfee=SUM(ck),mdfee=SUM(md),adfee=SUM(Ad_Fee),yf=SUM(yf) from #ls
//group by ShopId)a on d.ShopId=a.ShopId
//left join (select ShopId,TotalPrice=sum(TotalPrice),ml=sum(isnull(TotalPrice,0)-isnull(escrowFee,0)-isnull(yj,0)-isnull(yf,0)-((isnull(cb,0)+isnull(hwsf,0))/moneyrate)-isnull(tc,0)-isnull(ck,0)-isnull(md,0)-isnull(Ad_Fee,0)+SubsidyFee ) from #ls where yf>0
//group by ShopId)b on a.ShopId=b.ShopId
//left join (
//select GoodRate,ODR,DSRService,DSRGoods,DSRPost,USDUseMoney,USDNoMoney,RMBUseMoney, RMBNoMoney,Rate1,Rate2,Rate3,Rate4,PropertyViolate,Rate5,Rate6,Rate7,FeeDate,TXFee
//TXFee,ShopId from JC_ShopData
//where DATEDIFF(day,indate,'" + InDate.Value.ToString("yyyy-MM-dd") + @"')=0 )c on a.ShopId=c.ShopId
//left Join #ls2 e on a.ShopId=e.ShopId
//left join [192.168.1.187].[UpGoods].dbo.LxERP_Amazon_Shop o on d.ShopName=o.name
//left join ( select sid, CONVERT(decimal(12,2), SUM(t.cost)) as Rate3,CONVERT(decimal(12,2), SUM(t.sales)) as ad_sales , case when CONVERT(decimal(12,2), SUM(t.sales))<=0 then '∞' else CONVERT(nvarchar(20), convert(decimal(12,2), (CONVERT(decimal(12,2), SUM(t.cost))/CONVERT(decimal(12,2), SUM(t.sales)))*100)) end DSRPost from( select sid, SUM( ISNULL(cost,0)) as cost,SUM(ISNULL(sales,0))sales from [192.168.1.187].[UpGoods].dbo.LxERP_SPAdGroupReports where CONVERT(date,report_date)='" + InDate.Value.AddDays(-2).Date.ToString("yyyy-MM-dd") + "' group by sid union all select sid, SUM( ISNULL(cost,0)) as cost,SUM(ISNULL(sales,0))sales from [192.168.1.187].[UpGoods].dbo.LxERP_SBCampaignReports where CONVERT(date,report_date)='" + InDate.Value.AddDays(-2).Date.ToString("yyyy-MM-dd") + "' group by sid union all select sid, SUM( ISNULL(cost,0)) as cost,SUM(ISNULL(sales,0))sales from [192.168.1.187].[UpGoods].dbo.LxERP_SDAdGroupReports where CONVERT(date,report_date)='" + InDate.Value.AddDays(-2).Date.ToString("yyyy-MM-dd") + "' group by sid) t group by sid ) f on f.sid=o.sid" +
//" \r\n left join (select sid, CONVERT(decimal(12,2), SUM(t.cost)) as Rate6 from( select sid, SUM( ISNULL(cost,0)) as cost from [192.168.1.187].[UpGoods].dbo.LxERP_SPAdGroupReports where CONVERT(date,report_date)<='" + InDate.Value.AddDays(-2).ToString("yyyy-MM-dd") + "' and CONVERT(date,report_date)>='" + InDate.Value.AddDays(-31).ToString("yyyy-MM-dd") + "' group by sid union all select sid, SUM( ISNULL(cost,0)) as cost from [192.168.1.187].[UpGoods].dbo.LxERP_SBCampaignReports where CONVERT(date,report_date)<='" + InDate.Value.AddDays(-2).ToString("yyyy-MM-dd") + "' and CONVERT(date,report_date)>='" + InDate.Value.AddDays(-31).ToString("yyyy-MM-dd") + "' group by sid union all select sid, SUM( ISNULL(cost,0)) as cost from [192.168.1.187].[UpGoods].dbo.LxERP_SDAdGroupReports where CONVERT(date,report_date)<='" + InDate.Value.AddDays(-2).ToString("yyyy-MM-dd") + "' and CONVERT(date,report_date)>='" + InDate.Value.AddDays(-31).ToString("yyyy-MM-dd") + "' group by sid) t group by sid) g on o.sid=g.sid " +
// " \r\n left join(select t.row, t.storename,t.financialEventGroupEndLocale,t.originCurrencyIcon,CAST(ISNULL( t.originalTotalCurrencyAmount,0) as decimal(12,2)) as originalTotalCurrencyAmount from ( select ROW_NUMBER() over(PARTITION BY storename ORDER BY requestDate DESC) row,storename, financialEventGroupEndLocale,originCurrencyIcon,originalTotalCurrencyAmount from [192.168.1.187].[UpGoods].dbo.LxERP_SettlementSummaryData where accountType='Standard' and processingStatus='Closed ') t where t.row=1) t1 on d.ShopName=t1.storeName left join (select storename,CONVERT(decimal(12,2), SUM(ISNULL(originalTotalCurrencyAmount,0))) originalTotalCurrencyAmount from [192.168.1.187].[UpGoods].dbo.LxERP_SettlementSummaryData where processingStatus='Open' and accountType='Standard' group by storename) n1 on d.ShopName=n1.storeName " +
// "\r\n" +
// " left join (select sid, CAST( orderDefectRate *100 as decimal(12,2)) orderDefectRate,CAST( validTrackingRate *100 as decimal(12,2)) validTrackingRate,cast(CancelRate *100 as decimal(12,2)) cancelRate from (\r\nselect ROW_NUMBER() over(PARTITION BY sid ORDER BY requestDate DESC) row,sid, orderDefectRate,validTrackingRate,CancelRate from [192.168.1.187].[UpGoods].dbo.Amazon_V2_SELLER_PERFORMANCE_REPORT where CONVERT(date, RequestDate)='" + InDate.Value.AddDays(-1).Date.ToString("yyyy-MM-dd") + "') t where t.row=1)t2 on t2.sid=o.sid \r\nleft join (select sid, user_sessions,totalOrderItems, case when user_sessions=0 or totalOrderItems=0 then 0 else convert(decimal(12,2),(totalOrderItems*1.00/user_sessions)*100 ) end as CVR from [192.168.1.187].[UpGoods].dbo.Amazon_SALES_AND_TRAFFIC_REPORT where CONVERT(date, ReportDate)='" + InDate.Value.AddDays(-2).Date.ToString("yyyy-MM-dd") + "') t3 on t3.sid=o.sid\r\nleft join [192.168.1.187].[UpGoods].dbo.AmazonStoreRefundAmountAndRate t4 on t4.sid=o.sid and Convert(date, t4.ReportDate)='" + InDate.Value.AddDays(-2).Date.ToString("yyyy-MM-dd") + "'\r\n"
// + " where d.PlatType=2 union all\r\n select d.ShopName,Master=case when d.Master=d.buyer then d.Master when d.buyer is not null and d.buyer<>'' then d.Master+'-'+d.buyer else d.Master end,a.OrderNum,a.RMBMoney,a.USDMoney,AvgPrice=case when a.OrderNum>0 then cast(a.USDMoney/a.OrderNum as decimal(18,2)) else 0 end,a.InPrice,LR=cast(b.ml as decimal(18,2)),MLL=case when b.TotalPrice>0 then cast(b.ml*100/b.TotalPrice as decimal(18,2)) else 0 end,ShopTJGoods=e.Num,ShopCDGoods=e.Num2,ckfee,a.mdfee,a.adfee,bz=case when a.InPrice>0 then CAST(a.RMBMoney/a.InPrice as decimal(18,2)) else 0 end,a.yf,c.GoodRate,c.ODR,c.DSRService,c.DSRGoods,case when ISNULL(c.DSRPost,0)=0 then '' else CONVERT(nvarchar(20),c.DSRPost) end DSRPost,c.USDUseMoney,c.USDNoMoney,c.RMBUseMoney,c.RMBNoMoney,c.Rate1,c.Rate2,c.Rate3,c.Rate4,c.PropertyViolate,c.Rate5,c.Rate6,Rate7=isnull(c.Rate7,d.dayfee),JL=cast(b.ml as decimal(18,2))+isnull(ckfee,0)-isnull(c.Rate3,0)-isnull(c.Rate7,d.dayfee),FeeDate=isnull(c.FeeDate,d.FeeDate),TXFee=isnull(c.TXFee,d.TXFee) from \r\nJC_Shop d left join (\r\nselect ShopId,OrderNum=COUNT(0),RMBMoney=SUM(RMBPrice),escrowFee=sum(escrowFee),USDMoney=SUM(TotalPrice),InPrice=SUM(cb),ckfee=SUM(ck),mdfee=SUM(md),adfee=SUM(Ad_Fee),yf=SUM(yf) from #ls\r\ngroup by ShopId)a on d.ShopId=a.ShopId\r\nleft join (select ShopId,TotalPrice=sum(TotalPrice),ml=sum(isnull(TotalPrice,0)-isnull(escrowFee,0)-isnull(yj,0)-isnull(yf,0)-((isnull(cb,0)+isnull(hwsf,0))/moneyrate)-isnull(tc,0)-isnull(ck,0)-isnull(md,0)-isnull(Ad_Fee,0)+ SubsidyFee) from #ls where yf>0\r\ngroup by ShopId)b on a.ShopId=b.ShopId\r\nleft join (\r\nselect GoodRate,ODR,DSRService,DSRGoods,DSRPost,USDUseMoney,USDNoMoney,RMBUseMoney, RMBNoMoney,Rate1,Rate2,Rate3,Rate4,PropertyViolate,Rate5,Rate6,Rate7,FeeDate,TXFee\r\nTXFee,ShopId from JC_ShopData\r\nwhere DATEDIFF(day,indate,'" + InDate.Value.ToString("yyyy-MM-dd") + "')=0 )c on a.ShopId=c.ShopId\r\nleft Join #ls2 e on a.ShopId=e.ShopId where d.PlatType!=2 " + (isyc ? " and d.Master!='东南亚专用'" : "") + "\r\n) a order by " + Sort;
// DataTable dt = obj.GetReportData(sql);
// return GetReport3(dt, 18);
// }
// catch (Exception ex)
// {
// string a = dd;
// return "";
// }
// }
// #endregion
#region 报表18
[WebMethod(EnableSession = true)]
public string GetReportTable18(DateTime? InDate, int DeptId, int ShopId, int PlatId, string MoneyCode, string Sort, bool isyc)
{
string dd = "";
try
{
var obj = new BaseService();
string tj = "";
string tj1 = "";
//if (DeptId > 0)
//{
// tj += " and b.DeptId=" + DeptId + " ";
// tj1 += " and a.DeptId=" + DeptId + " ";
//}
if (PlatId > 0)
{
tj += " and a.PlatId=" + PlatId + " ";
tj1 += " and a.PlatId=" + PlatId + " ";
}
if (ShopId > 0)
{
tj += " and a.ShopId=" + ShopId + " ";
tj1 += " and a.ShopId=" + ShopId + " ";
}
string tj2 = "";
if (PlatId > 0)
{
tj2 += " where c.PlatType=" + PlatId + " ";
}
if (ShopId > 0)
{
tj2 += " where c.ShopId=" + ShopId + " ";
}
string tj3 = "";
if (PlatId > 0)
{
tj3 += " where d.PlatType=" + PlatId + " ";
}
if (ShopId > 0)
{
tj3 += " where d.ShopId=" + ShopId + " ";
}
//if (MoneyCode != "0")
// tj += " and a.MoneyCode='" + MoneyCode + "' ";
// string sql = @"
//declare @moneyrate decimal(18,4)
//select @moneyrate=MRate from JC_Money where MCode='USD' and PlatId=2
//select a.ShopId,a.TotalPrice,escrowFee=isnull(a.escrowFee,0),a.RMBPrice,c.yj,yf=c.yf,cb=c.cb,hwsf=c.hwsf,c.tc,c.ck,c.md,a.Ad_Fee,a.DR_BackFee,a.DR_PostFee,a.DR_SSFee,a.Other_Fee,moneyrate=isnull(c.moneyrate,@moneyrate) into #ls from DT_OrderInfo a with(nolock)
//inner join DT_OrderXXInfo b with(nolock) on a.OrderId=b.OrderId
//left join DT_Fees c with(nolock) on a.OrderId=c.orderid
//where DATEDIFF(day,a.OrderDate,'" + InDate.Value.ToString("yyyy-MM-dd") + @"')=0 " + tj + @" and a.State>0 and a.State<3
//select a.*,Num2=isnull(b.Num2,0) into #ls2 from (
//select b.ShopId,Num=COUNT(0) from HW_GoodsInfo a with(nolock)
//inner join HW_Shop b with(nolock) on a.GoodsId=b.GoodsId
//group by b.ShopId)a
//left join (
//select a.ShopId,Num2=COUNT(distinct c.GoodsId) from DT_OrderInfo a with(nolock)
//inner join DT_OrderGoods b with(nolock) on a.OrderId=b.OrderId
//inner join HW_GoodsDetail c with(nolock) on b.DetailId=c.DetailId
//where a.State>0 and a.State<3 and DATEDIFF(day,a.OrderDate,'" + InDate.Value.ToString("yyyy-MM-dd") + @"')=0 group by a.ShopId)b on a.ShopId=b.ShopId
//select d.ShopName,Master=case when d.Master=d.buyer then d.Master when d.buyer is not null and d.buyer<>'' then d.Master+'-'+d.buyer else d.Master end,a.OrderNum,a.RMBMoney,a.USDMoney,AvgPrice=case when a.OrderNum>0 then cast(a.USDMoney/a.OrderNum as decimal(18,2)) else 0 end,a.InPrice,LR=cast(b.ml as decimal(18,2)),MLL=case when b.TotalPrice>0 then cast(b.ml*100/b.TotalPrice as decimal(18,2)) else 0 end,ShopTJGoods=e.Num,ShopCDGoods=e.Num2,ckfee,a.mdfee,a.adfee,bz=case when a.InPrice>0 then CAST(a.RMBMoney/a.InPrice as decimal(18,2)) else 0 end,c.GoodRate,c.ODR,c.DSRService,c.DSRGoods,h.DSRPost,c.USDUseMoney,c.USDNoMoney,c.RMBUseMoney,c.RMBNoMoney,c.Rate1,c.Rate2,f.Rate3,c.Rate4,c.PropertyViolate,c.Rate5,g.Rate6,Rate7=isnull(c.Rate7,d.dayfee),JL=cast(b.ml as decimal(18,2))+isnull(ckfee,0)+isnull(mdfee,0)-isnull(c.Rate3,0)-isnull(c.Rate7,d.dayfee),FeeDate=isnull(c.FeeDate,d.FeeDate),TXFee=isnull(c.TXFee,d.TXFee) from
//JC_Shop d left join (
//select ShopId,OrderNum=COUNT(0),RMBMoney=SUM(RMBPrice),escrowFee=sum(escrowFee),USDMoney=SUM(TotalPrice),InPrice=SUM(cb),ckfee=SUM(ck),mdfee=SUM(md),adfee=SUM(Ad_Fee) from #ls
//group by ShopId)a on d.ShopId=a.ShopId
//left join (select ShopId,TotalPrice=sum(TotalPrice),ml=sum(isnull(TotalPrice,0)-isnull(escrowFee,0)-isnull(yj,0)-isnull(yf,0)-((isnull(cb,0)+isnull(hwsf,0))/moneyrate)-isnull(tc,0)-isnull(ck,0)-isnull(md,0)-isnull(Ad_Fee,0)) from #ls where yf>0
//group by ShopId)b on a.ShopId=b.ShopId
//left join (
//select GoodRate,ODR,DSRService,DSRGoods,DSRPost,USDUseMoney,USDNoMoney,RMBUseMoney, RMBNoMoney,Rate1,Rate2,Rate3,Rate4,PropertyViolate,Rate5,Rate6,Rate7,FeeDate,TXFee
//TXFee,ShopId from JC_ShopData
//where DATEDIFF(day,indate,'" + InDate.Value.ToString("yyyy-MM-dd") + @"')=0 )c on a.ShopId=c.ShopId
//left Join #ls2 e on a.ShopId=e.ShopId
// left join (select shopid,SUM(ABS(adfee)) Rate3 from AD_FeeList where DATEDIFF(day,addate,'" + InDate.Value.AddDays(-2).ToString("yyyy-MM-dd") + "')=0 group by shopid) f on d.ShopId=f.shopid "+
// " left join ( select shopid,SUM(ABS(adfee)) Rate6 from AD_FeeList where CONVERT(varchar(7), addate, 120)='"+ InDate.Value.ToString("yyyy-MM") + "' group by shopid) g on d.ShopId=g.shopid "+
// " left join(select b.name shopName,case when a.Spend=0 or a.ad_sale_amount=0 then 0 else cast((Spend/ad_sale_amount)*100 as decimal(12,2)) end DSRPost from ( select sid,SUM(ISNULL(ABS(spend),0)) Spend, SUM(ISNULL(ad_sales_amount,0)) ad_sale_amount from [192.168.1.187].[UpGoods].dbo.LxERP_ProductPerformance where summary_field='Asin' and RequestDate='" + InDate.Value.AddDays(-2).ToString("yyyy-MM-dd") + "' group by sid) a left join [192.168.1.187].[UpGoods].dbo.LxERP_Amazon_Shop b on a.sid=b.sid) h on d.ShopName=h.shopName "
// + " order by " + Sort;
//string sql = @"
//declare @moneyrate decimal(18,4)
//select @moneyrate=MRate from JC_Money where MCode='USD' and PlatId=2
//select a.ShopId,a.TotalPrice,escrowFee=isnull(a.escrowFee,0),a.RMBPrice,c.yj,yf=c.yf,cb=c.cb,hwsf=c.hwsf,c.tc,c.ck,c.md,a.Ad_Fee,a.DR_BackFee,a.DR_PostFee,a.DR_SSFee,a.Other_Fee,moneyrate=isnull(c.moneyrate,@moneyrate),ISnull( c.SubsidyFee,0) SubsidyFee into #ls from DT_OrderInfo a with(nolock)
//inner join DT_OrderXXInfo b with(nolock) on a.OrderId=b.OrderId
//left join DT_Fees c with(nolock) on a.OrderId=c.orderid
//where DATEDIFF(day,a.OrderDate,'" + InDate.Value.ToString("yyyy-MM-dd") + @"')=0 " + tj + @" and a.State>0 and a.State<3
//select a.*,Num2=isnull(b.Num2,0) into #ls2 from (
//select b.ShopId,Num=COUNT(0) from HW_GoodsInfo a with(nolock)
//inner join HW_Shop b with(nolock) on a.GoodsId=b.GoodsId
//left join jc_shop c on b.ShopId=c.ShopId " + tj2 + @"
//group by b.ShopId)a
//left join (
//select a.ShopId,Num2=COUNT(distinct c.GoodsId) from DT_OrderInfo a with(nolock)
//inner join DT_OrderGoods b with(nolock) on a.OrderId=b.OrderId
//inner join HW_GoodsDetail c with(nolock) on b.DetailId=c.DetailId
//where a.State>0 and a.State<3 and DATEDIFF(day,a.OrderDate,'" + InDate.Value.ToString("yyyy-MM-dd") + @"')=0 group by a.ShopId)b on a.ShopId=b.ShopId
//select * from (
//select d.ShopName,Master=case when d.Master=d.buyer then d.Master when d.buyer is not null and d.buyer<>'' then d.Master+'-'+d.buyer else d.Master end,a.OrderNum,a.RMBMoney,a.USDMoney,AvgPrice=case when a.OrderNum>0 then cast(a.USDMoney/a.OrderNum as decimal(18,2)) else 0 end,a.InPrice,LR=cast(b.ml as decimal(18,2)),MLL=case when b.TotalPrice>0 then cast(b.ml*100/b.TotalPrice as decimal(18,2)) else 0 end,ShopTJGoods=e.Num,ShopCDGoods=e.Num2,ckfee,a.mdfee,a.adfee,bz=case when a.InPrice>0 then CAST(a.RMBMoney/a.InPrice as decimal(18,2)) else 0 end,a.yf,c.GoodRate,c.ODR,DSRService=0,DSRGoods=null,DSRPost=0,c.USDUseMoney, USDNoMoney=0,c.RMBUseMoney,c.RMBNoMoney,Rate1=null,Rate2=null,Rate4=null, PropertyViolate=0, Rate5=0,Rate6=0,Rate7=isnull(c.Rate7,d.dayfee),JL=cast(b.ml as decimal(18,2))+isnull(ckfee,0)-isnull(c.Rate3,0)-isnull(c.Rate7,d.dayfee),FeeDate=null,TXFee=0 from
//JC_Shop d left join (
//select ShopId,OrderNum=COUNT(0),RMBMoney=SUM(RMBPrice),escrowFee=sum(escrowFee),USDMoney=SUM(TotalPrice),InPrice=SUM(cb),ckfee=SUM(ck),mdfee=SUM(md),adfee=SUM(Ad_Fee),yf=SUM(yf) from #ls
//group by ShopId)a on d.ShopId=a.ShopId
//left join (select ShopId,TotalPrice=sum(TotalPrice),ml=sum(isnull(TotalPrice,0)-isnull(escrowFee,0)-isnull(yj,0)-isnull(yf,0)-((isnull(cb,0)+isnull(hwsf,0))/moneyrate)-isnull(tc,0)-isnull(ck,0)-isnull(md,0)-isnull(Ad_Fee,0)+SubsidyFee) from #ls where yf>0
//group by ShopId)b on a.ShopId=b.ShopId
//left join (
//select GoodRate,ODR,DSRService,DSRGoods,DSRPost,USDUseMoney,USDNoMoney,RMBUseMoney, RMBNoMoney,Rate1,Rate2,Rate3,Rate4,PropertyViolate,Rate5,Rate6,Rate7,FeeDate,TXFee
//TXFee,ShopId from JC_ShopData
//where DATEDIFF(day,indate,'" + InDate.Value.ToString("yyyy-MM-dd") + @"')=0 )c on a.ShopId=c.ShopId
//left Join #ls2 e on a.ShopId=e.ShopId "+ tj3 + @"
//) a order by " + Sort;
string sql = @"
declare @moneyrate decimal(18,4)
select @moneyrate=MRate from JC_Money where MCode='USD' and PlatId=2
select a.ShopId,a.TotalPrice,escrowFee=isnull(a.escrowFee,0),a.RMBPrice,c.yj,yf=c.yf,cb=c.cb,hwsf=c.hwsf,c.tc,c.ck,c.md,a.Ad_Fee,a.DR_BackFee,a.DR_PostFee,a.DR_SSFee,a.Other_Fee,moneyrate=isnull(c.moneyrate,@moneyrate),ISnull( c.SubsidyFee,0) SubsidyFee into #ls from DT_OrderInfo a with(nolock)
inner join DT_OrderXXInfo b with(nolock) on a.OrderId=b.OrderId
left join DT_Fees c with(nolock) on a.OrderId=c.orderid
where DATEDIFF(day,a.OrderDate,'" + InDate.Value.ToString("yyyy-MM-dd") + @"')=0 " + tj + @" and a.State>0 and a.State<3
select a.*,Num2=isnull(b.Num2,0) into #ls2 from (
select b.ShopId,Num=COUNT(0) from HW_GoodsInfo a with(nolock)
inner join HW_Shop b with(nolock) on a.GoodsId=b.GoodsId
inner join jc_shop c on b.ShopId=c.ShopId " + tj2 + @"
group by b.ShopId)a
left join (
select a.ShopId,Num2=COUNT(distinct c.GoodsId) from DT_OrderInfo a with(nolock)
inner join DT_OrderGoods b with(nolock) on a.OrderId=b.OrderId
inner join HW_GoodsDetail c with(nolock) on b.DetailId=c.DetailId
where a.State>0 and a.State<3 and DATEDIFF(day,a.OrderDate,'" + InDate.Value.ToString("yyyy-MM-dd") + @"')=0 group by a.ShopId)b on a.ShopId=b.ShopId
select * from (
select d.ShopName,Master=case when d.Master=d.buyer then d.Master when d.buyer is not null and d.buyer<>'' then d.Master+'-'+d.buyer else d.Master end,a.OrderNum,a.RMBMoney,a.USDMoney,AvgPrice=case when a.OrderNum>0 then cast(a.USDMoney/a.OrderNum as decimal(18,2)) else 0 end,a.InPrice,LR=cast(b.ml as decimal(18,2)),MLL=case when b.TotalPrice>0 then cast(b.ml*100/b.TotalPrice as decimal(18,2)) else 0 end,ShopTJGoods=e.Num,ShopCDGoods=e.Num2,ckfee,a.mdfee,a.adfee,bz=case when a.InPrice>0 then CAST(a.RMBMoney/a.InPrice as decimal(18,2)) else 0 end,a.yf,c.GoodRate,c.ODR,t3.CVR DSRService,t3.user_sessions DSRGoods,f.DSRPost,c.USDUseMoney, n1.originalTotalCurrencyAmount as USDNoMoney,c.RMBUseMoney,c.RMBNoMoney,t2.orderDefectRate Rate1,t2.validTrackingRate Rate2,Case when d.PlatType=2 then f.Rate3 else c.Rate3 end Rate3,t4.RefundRate as Rate4, ABS( ISNULL( t4.RefundAmount,0) ) as PropertyViolate,t2.cancelRate Rate5,Case when d.PlatType=2 then g.Rate6 else (select SUM(ISNULL(Rate3,0)) from JC_ShopData where ShopId=d.ShopId and DATEDIFF(MONTH,InDate,'2023-10-18')=0) end Rate6,Rate7=isnull(c.Rate7,d.dayfee),JL=cast(b.ml as decimal(18,2))+isnull(ckfee,0)-isnull(c.Rate3,0)-isnull(c.Rate7,d.dayfee),t1.financialEventGroupEndLocale as FeeDate,t1.originalTotalCurrencyAmount as TXFee from
JC_Shop d left join (
select ShopId,OrderNum=COUNT(0),RMBMoney=SUM(RMBPrice),escrowFee=sum(escrowFee),USDMoney=SUM(TotalPrice),InPrice=SUM(cb),ckfee=SUM(ck),mdfee=SUM(md),adfee=SUM(Ad_Fee),yf=SUM(yf) from #ls
group by ShopId)a on d.ShopId=a.ShopId
left join (select ShopId,TotalPrice=sum(TotalPrice),ml=sum(isnull(TotalPrice,0)-isnull(escrowFee,0)-isnull(yj,0)-isnull(yf,0)-((isnull(cb,0)+isnull(hwsf,0))/moneyrate)-isnull(tc,0)-isnull(ck,0)-isnull(md,0)-isnull(Ad_Fee,0)+SubsidyFee) from #ls where yf>0
group by ShopId)b on a.ShopId=b.ShopId
left join (
select GoodRate,ODR,DSRService,DSRGoods,DSRPost,USDUseMoney,USDNoMoney,RMBUseMoney, RMBNoMoney,Rate1,Rate2,Rate3,Rate4,PropertyViolate,Rate5,Rate6,Rate7,FeeDate,TXFee
TXFee,ShopId from JC_ShopData
where DATEDIFF(day,indate,'" + InDate.Value.ToString("yyyy-MM-dd") + @"')=0 )c on a.ShopId=c.ShopId
inner Join #ls2 e on a.ShopId=e.ShopId
left join [192.168.1.187].[UpGoods].dbo.LxERP_Amazon_Shop o on d.ShopName=o.name
left join ( select sid, CONVERT(decimal(12,2), SUM(t.cost)) as Rate3,CONVERT(decimal(12,2), SUM(t.sales)) as ad_sales , case when CONVERT(decimal(12,2), SUM(t.sales))<=0 then '∞' else CONVERT(nvarchar(20), convert(decimal(12,2), (CONVERT(decimal(12,2), SUM(t.cost))/CONVERT(decimal(12,2), SUM(t.sales)))*100)) end DSRPost from( select sid, SUM( ISNULL(cost,0)) as cost,SUM(ISNULL(sales,0))sales from [192.168.1.187].[UpGoods].dbo.LxERP_SPAdGroupReports where CONVERT(date,report_date)='" + InDate.Value.AddDays(-2).Date.ToString("yyyy-MM-dd") + "' group by sid union all select sid, SUM( ISNULL(cost,0)) as cost,SUM(ISNULL(sales,0))sales from [192.168.1.187].[UpGoods].dbo.LxERP_SBCampaignReports where CONVERT(date,report_date)='" + InDate.Value.AddDays(-2).Date.ToString("yyyy-MM-dd") + "' group by sid union all select sid, SUM( ISNULL(cost,0)) as cost,SUM(ISNULL(sales,0))sales from [192.168.1.187].[UpGoods].dbo.LxERP_SDAdGroupReports where CONVERT(date,report_date)='" + InDate.Value.AddDays(-2).Date.ToString("yyyy-MM-dd") + "' group by sid) t group by sid ) f on f.sid=o.sid" +
" \r\n left join (select sid, CONVERT(decimal(12,2), SUM(t.cost)) as Rate6 from( select sid, SUM( ISNULL(cost,0)) as cost from [192.168.1.187].[UpGoods].dbo.LxERP_SPAdGroupReports where CONVERT(date,report_date)<='" + InDate.Value.AddDays(-2).ToString("yyyy-MM-dd") + "' and CONVERT(date,report_date)>='" + InDate.Value.AddDays(-31).ToString("yyyy-MM-dd") + "' group by sid union all select sid, SUM( ISNULL(cost,0)) as cost from [192.168.1.187].[UpGoods].dbo.LxERP_SBCampaignReports where CONVERT(date,report_date)<='" + InDate.Value.AddDays(-2).ToString("yyyy-MM-dd") + "' and CONVERT(date,report_date)>='" + InDate.Value.AddDays(-31).ToString("yyyy-MM-dd") + "' group by sid union all select sid, SUM( ISNULL(cost,0)) as cost from [192.168.1.187].[UpGoods].dbo.LxERP_SDAdGroupReports where CONVERT(date,report_date)<='" + InDate.Value.AddDays(-2).ToString("yyyy-MM-dd") + "' and CONVERT(date,report_date)>='" + InDate.Value.AddDays(-31).ToString("yyyy-MM-dd") + "' group by sid) t group by sid) g on o.sid=g.sid " +
" \r\n left join(select t.row, t.storename,t.financialEventGroupEndLocale,t.originCurrencyIcon,CAST(ISNULL( t.originalTotalCurrencyAmount,0) as decimal(12,2)) as originalTotalCurrencyAmount from ( select ROW_NUMBER() over(PARTITION BY storename ORDER BY requestDate DESC) row,storename, financialEventGroupEndLocale,originCurrencyIcon,originalTotalCurrencyAmount from [192.168.1.187].[UpGoods].dbo.LxERP_SettlementSummaryData where accountType='Standard' and processingStatus='Closed ') t where t.row=1) t1 on d.ShopName=t1.storeName left join (select storename,CONVERT(decimal(12,2), SUM(ISNULL(originalTotalCurrencyAmount,0))) originalTotalCurrencyAmount from [192.168.1.187].[UpGoods].dbo.LxERP_SettlementSummaryData where processingStatus='Open' and accountType='Standard' group by storename) n1 on d.ShopName=n1.storeName " +
"\r\n" +
" left join (select sid, CAST( orderDefectRate *100 as decimal(12,2)) orderDefectRate,CAST( validTrackingRate *100 as decimal(12,2)) validTrackingRate,cast(CancelRate *100 as decimal(12,2)) cancelRate from (\r\nselect ROW_NUMBER() over(PARTITION BY sid ORDER BY requestDate DESC) row,sid, orderDefectRate,validTrackingRate,CancelRate from [192.168.1.187].[UpGoods].dbo.Amazon_V2_SELLER_PERFORMANCE_REPORT where CONVERT(date, RequestDate)='" + InDate.Value.AddDays(-1).Date.ToString("yyyy-MM-dd") + "') t where t.row=1)t2 on t2.sid=o.sid \r\nleft join (select sid, user_sessions,totalOrderItems, case when user_sessions=0 or totalOrderItems=0 then 0 else convert(decimal(12,2),(totalOrderItems*1.00/user_sessions)*100 ) end as CVR from [192.168.1.187].[UpGoods].dbo.Amazon_SALES_AND_TRAFFIC_REPORT where CONVERT(date, ReportDate)='" + InDate.Value.AddDays(-2).Date.ToString("yyyy-MM-dd") + "') t3 on t3.sid=o.sid\r\nleft join [192.168.1.187].[UpGoods].dbo.AmazonStoreRefundAmountAndRate t4 on t4.sid=o.sid and Convert(date, t4.ReportDate)='" + InDate.Value.AddDays(-2).Date.ToString("yyyy-MM-dd") + "'\r\n"
+ " where d.PlatType=2 union all\r\n select d.ShopName,Master=case when d.Master=d.buyer then d.Master when d.buyer is not null and d.buyer<>'' then d.Master+'-'+d.buyer else d.Master end,a.OrderNum,a.RMBMoney,a.USDMoney,AvgPrice=case when a.OrderNum>0 then cast(a.USDMoney/a.OrderNum as decimal(18,2)) else 0 end,a.InPrice,LR=cast(b.ml as decimal(18,2)),MLL=case when b.TotalPrice>0 then cast(b.ml*100/b.TotalPrice as decimal(18,2)) else 0 end,ShopTJGoods=e.Num,ShopCDGoods=e.Num2,ckfee,a.mdfee,a.adfee,bz=case when a.InPrice>0 then CAST(a.RMBMoney/a.InPrice as decimal(18,2)) else 0 end,a.yf,c.GoodRate,c.ODR,c.DSRService,c.DSRGoods,case when ISNULL(c.DSRPost,0)=0 then '' else CONVERT(nvarchar(20),c.DSRPost) end DSRPost,c.USDUseMoney,c.USDNoMoney,c.RMBUseMoney,c.RMBNoMoney,c.Rate1,c.Rate2,c.Rate3,c.Rate4,c.PropertyViolate,c.Rate5,c.Rate6,Rate7=isnull(c.Rate7,d.dayfee),JL=cast(b.ml as decimal(18,2))+isnull(ckfee,0)-isnull(c.Rate3,0)-isnull(c.Rate7,d.dayfee),FeeDate=isnull(c.FeeDate,d.FeeDate),TXFee=isnull(c.TXFee,d.TXFee) from \r\nJC_Shop d left join (\r\nselect ShopId,OrderNum=COUNT(0),RMBMoney=SUM(RMBPrice),escrowFee=sum(escrowFee),USDMoney=SUM(TotalPrice),InPrice=SUM(cb),ckfee=SUM(ck),mdfee=SUM(md),adfee=SUM(Ad_Fee),yf=SUM(yf) from #ls\r\ngroup by ShopId)a on d.ShopId=a.ShopId\r\nleft join (select ShopId,TotalPrice=sum(TotalPrice),ml=sum(isnull(TotalPrice,0)-isnull(escrowFee,0)-isnull(yj,0)-isnull(yf,0)-((isnull(cb,0)+isnull(hwsf,0))/moneyrate)-isnull(tc,0)-isnull(ck,0)-isnull(md,0)-isnull(Ad_Fee,0) + SubsidyFee) from #ls where yf>0\r\ngroup by ShopId)b on a.ShopId=b.ShopId\r\nleft join (\r\nselect GoodRate,ODR,DSRService,DSRGoods,DSRPost,USDUseMoney,USDNoMoney,RMBUseMoney, RMBNoMoney,Rate1,Rate2,Rate3,Rate4,PropertyViolate,Rate5,Rate6,Rate7,FeeDate,TXFee\r\nTXFee,ShopId from JC_ShopData\r\nwhere DATEDIFF(day,indate,'" + InDate.Value.ToString("yyyy-MM-dd") + "')=0 )c on a.ShopId=c.ShopId\r\nleft Join #ls2 e on a.ShopId=e.ShopId where d.PlatType!=2 " + (isyc ? " and d.Master!='东南亚专用'" : "") + "\r\n) a order by " + Sort;
DataTable dt = obj.GetReportData(sql);
return GetReport3(dt, 18);
}
catch (Exception ex)
{
string a = dd;
return "";
}
}
#endregion
#region 报表18(备份0518)
[WebMethod(EnableSession = true)]
public string GetReportTable1822(DateTime? InDate, int DeptId, int ShopId, int PlatId, string MoneyCode, string Sort)
{
string dd = "";
try
{
var obj = new BaseService();
string tj = "";
string tj1 = "";
if (DeptId > 0)
{
tj += " and b.DeptId=" + DeptId + " ";
tj1 += " and a.DeptId=" + DeptId + " ";
}
if (PlatId > 0)
{
tj += " and b.PlatType=" + PlatId + " ";
tj1 += " and a.PlatType=" + PlatId + " ";
}
if (ShopId > 0)
{
tj += " and b.ShopId=" + ShopId + " ";
tj1 += " and a.ShopId=" + ShopId + " ";
}
if (MoneyCode != "0")
tj += " and a.MoneyCode='" + MoneyCode + "' ";
string sql = @"
select a.ShopId,a.ShopName,OrderNum=isnull(c.OrderNum,0),USDMoney=isnull(c.USDMoney,0),RMBMoney=isnull(c.RMBMoney,0),AvgPrice=case when c.OrderNum is null or c.USDMoney is null or c.OrderNum=0 then 0 else c.USDMoney/c.OrderNum end,b.GoodRate,b.ODR,b.DSRGoods,b.DSRService,b.DSRPost,b.USDUseMoney,b.USDUseMoney,b.USDNoMoney,b.RMBUseMoney,b.RMBNoMoney,b.InforViolate,b.PropertyViolate,b.OtherViolate,b.Rate1,b.Rate2,b.Rate3,b.Rate4,b.Rate5,b.Rate6,FeeDate=isnull(b.FeeDate,a.FeeDate),TXFee=isnull(b.TXFee,a.TXFee),InPrice=d.InPrice,InPrice=d.InPrice,BZ=case when d.InPrice>0 then RMBMoney/d.InPrice else 0 end,LR=0,MLL='',ShopCDGoods=0,ShopTJGoods=0,ckfee=0.00,mdfee=0.00,adfee=0.00 from JC_Shop a
inner join (select b.ShopId,OrderNum=COUNT(0),USDMoney=SUM(dbo.MoneyUSDChange(TotalPrice,a.MoneyCode,a.CompanyId)),RMBMoney=SUM(dbo.MoneyChange(TotalPrice,a.MoneyCode,a.CompanyId)) from DT_OrderInfo a with(nolock)
inner join JC_Shop b with(nolock) on a.ShopId=b.ShopId
where a.State>0 " + tj + " and a.State<3 and DATEDIFF(day,a.OrderDate,'" + InDate.Value.ToString("yyyy-MM-dd") + @"')=0 group by b.ShopId)c on a.ShopId=c.ShopId
left join JC_ShopData b with(nolock) on a.ShopId=b.ShopId and DATEDIFF(day,b.InDate,'" + InDate.Value.ToString("yyyy-MM-dd") + @"')=0
inner join (select a.ShopId,InPrice=sum(isnull(d.InPrice,0)*b.GoodsNum) from DT_OrderInfo a with(nolock)
inner join DT_OrderGoods b with(nolock) on a.OrderId=b.OrderId
inner join HW_GoodsDetail c with(nolock) on b.DetailId=c.DetailId
inner join HW_GoodsInfo d with(nolock) on c.GoodsId=d.GoodsId
where a.State>0 and a.State<3 and DATEDIFF(day,a.OrderDate,'" + InDate.Value.ToString("yyyy-MM-dd") + @"')=0 group by a.ShopId)d on a.ShopId=d.ShopId
where a.CompanyId=1 " + tj1 + " order by " + Sort;
DataTable dt = obj.GetReportData(sql);
string sql2 = @"
select a.*,Num2=isnull(b.Num2,0) from (
select b.ShopId,Num=COUNT(0) from HW_GoodsInfo a with(nolock)
inner join HW_Shop b with(nolock) on a.GoodsId=b.GoodsId
group by b.ShopId)a
left join (
select a.ShopId,Num2=COUNT(distinct c.GoodsId) from DT_OrderInfo a with(nolock)
inner join DT_OrderGoods b with(nolock) on a.OrderId=b.OrderId
inner join HW_GoodsDetail c with(nolock) on b.DetailId=c.DetailId
where a.State>0 and a.State<3 and DATEDIFF(day,a.OrderDate,'" + InDate.Value.ToString("yyyy-MM-dd") + @"')=0 group by a.ShopId)b on a.ShopId=b.ShopId";
DataTable dt2 = obj.GetReportData(sql2);
DataNew.updatestorefee(InDate.Value, InDate.Value.AddDays(1));
DD_OrderData data = new DD_OrderData();
if (dt != null)
{
decimal f1 = 0;
decimal f2 = 0;
decimal f3 = 0;
decimal f4 = 0;
decimal f5 = 0;
decimal f6 = 0;
// int ds = 0;
// decimal f9 = 0;
decimal cyxs = 0;
decimal cyyj = 0;
decimal hwcb = 0;
decimal hwtc = 0;
decimal hwyf = 0;
decimal hwyf1 = 0;
decimal hwyf2 = 0;
int yf1 = 0;
int yf2 = 0;
decimal zlr = 0;//总利润
decimal hjyj = 0;
decimal hjyf = 0;
for (int i = 0; i < dt.Rows.Count; i++)
{
decimal MRate = Convert.ToDecimal((double)6.5);
List<JC_Money> list7 = new BaseService().GetMoneyList2();
var olist = DataNew.GetListShopList2(Convert.ToInt32(dt.Rows[i]["ShopId"]), InDate);
string ids = "";
if (olist != null)
{
foreach (var order in olist)
{
ids += order.OrderId.ToString() + ",";
}
}
if (ids != "")
{
// List<DT_OrderGoods> orderGoodsListPP = DataNew.GetOrderGoodsListPP(ids.Trim(','));
List<DT_OrderGoods_tj> orderGoodsList = DataNew.GetOrderGoodsListtj(ids.Trim(','));
if (orderGoodsList != null)
{
//ds += orderGoodsList.Count;
//foreach (var md in orderGoodsList)
//{
// f9 += md.GoodsPrice.Value * md.GoodsNum.Value;
//}
foreach (var md in olist)
{
List<DT_OrderGoods_tj> gmd = null;
if (gmd == null)
gmd = orderGoodsList.FindAll(n => n.OrderId == md.OrderId);
md.GoodsListtj = gmd;
}
}
}
decimal lr = 0;
string AddrType = "";
decimal tweight = 0;
decimal hjckfee = 0;//仓储费
decimal hjmdfee = 0;//面单费
decimal hjadfee = 0;//广告费
if (olist != null)
{
foreach (var md in olist)
{
//if (md.PlatOrderCode == "2793358899439")
//{
// string cc = "";
//}
JC_Money money = list7.Find(n => n.MCode == "USD" && n.PlatId == md.PlatId);
if (money != null)
{
MRate = money.MRate.Value;
}
else
{
money = list7.Find(n => n.MCode == "USD");
MRate = money.MRate.Value;
}
decimal TotalPrice = md.TotalPrice.Value;
decimal yj = 0M;
yj = TotalPrice * Convert.ToDecimal((double)0.15);
int PlatType = md.PlatId.Value;
if (PlatType == 1)
{
yj = TotalPrice * Convert.ToDecimal((double)0.05);
}
else if (PlatType == 4)
{
yj = 0;
}
else if (PlatType == 5)
{
yj = TotalPrice * Convert.ToDecimal((double)0.1);
}
else if (PlatType == 18)
{
yj = TotalPrice * Convert.ToDecimal((double)0.06);
}
else if (PlatType == 15)
{
yj = TotalPrice * Convert.ToDecimal((double)0.029) + 0.3M;
}
f1 += TotalPrice;
f2 += yj;
decimal GoodsPrice = 0M;
decimal TCFee = 0M;
decimal TCFee2 = 0M;
decimal SolidFee = 0M;
decimal GoodsPrice2 = 0M;
decimal ckfee = 0;//仓储费
decimal mdfee = 0;//面单费
decimal adfee = 0;//广告费
tweight = 0;
if (md.GoodsListtj != null)
{
if (md.GoodsListtj.Count > 0)
{
AddrType = md.GoodsListtj[0].JoinOrderCode;
}
if (md.GoodsListtj != null)
{
foreach (DT_OrderGoods_tj goods in md.GoodsListtj)
{
//if (goods.GoodsFee.HasValue && (goods.GoodsFee.Value > 0M))
//{
// GoodsPrice += goods.GoodsFee.Value;
//}
//else
if (goods.Weight != null)
{
tweight += goods.Weight.Value * goods.GoodsNum.Value;
}
if (goods.GoodsPrice.HasValue)
{
GoodsPrice2 += goods.GoodsPrice.Value * goods.GoodsNum.Value;
//f9 += goods.GoodsPrice.Value * goods.GoodsNum.Value;
}
// ds++;
if (goods.TCFee != null && goods.TCFee > 0 && goods.GoodsPrice != null)//税费
{
GoodsPrice2 += goods.GoodsPrice.Value * goods.GoodsNum.Value * goods.TCFee.Value * Convert.ToDecimal(0.01);
}
//if (goods.Solid != null && goods.Solid > 0)//匹配的头程费
//{
// TCFee2 += goods.Solid.Value * goods.GoodsNum.Value;
//}
//else
if (goods.Solid2.HasValue)
{
SolidFee += goods.Solid2.Value * goods.GoodsNum.Value;
}
if (goods.ckfee != null)
ckfee += goods.ckfee.Value;
if (goods.mdfee != null)
mdfee += goods.mdfee.Value;
if (goods.adfee != null)
adfee += goods.adfee.Value;
if (goods.ckfee != null)
hjckfee += ckfee;
if (goods.mdfee != null)
hjmdfee += mdfee;
if (goods.adfee != null)
hjadfee += adfee;
}
}
}
if (GoodsPrice2 > 0M)
{
GoodsPrice = GoodsPrice2 / MRate;
}
f4 += GoodsPrice;
decimal escrowFee = 0M;
if ((TCFee == 0M) && (SolidFee > 0M))
{
TCFee = Convert.ToDecimal(170) * SolidFee;
}
// TCFee += TCFee2;
f5 += TCFee;// +TCFee2;
if (md.escrowFee.HasValue)
{
escrowFee = md.escrowFee.Value;
}
decimal num10 = 0M;
if (md.PostFee.HasValue)
{
num10 = md.PostFee.Value;
}
// decimal num11 = 0M;
// decimal num12 = 0M;
// decimal num13 = 0M;
//if (md.Post == 222 || md.Post == 226 || md.Post == 227)
//{
// num13 = num10 * Convert.ToDecimal((double)0.1);
//}
decimal feestore11 = 0M;//e仓运费
decimal feestore6 = 0M;//w仓运费
decimal feestore = 0M;
if (md.Fee11 != null && md.Fee11 > 0)
{
feestore11 = md.Fee11.Value;
}
if (feestore11 == 0 && md.Fee12 != null && md.Fee12 > 0)
feestore11 = md.Fee12.Value;
if (md.Fee12 != null && md.Fee12 > 0 && md.Fee12 < feestore11)
{
feestore11 = md.Fee12.Value;
}
if (feestore11 == 0 && md.Fee13 != null && md.Fee13 > 0)
feestore11 = md.Fee13.Value;
if (md.Fee13 != null && md.Fee13 > 0 && md.Fee13 < feestore11)
{
feestore11 = md.Fee13.Value;
}
if (AddrType == "Residential" || AddrType == "RESIDENTIAL")
{
if (md.Fee11 != null && md.Fee13 != null && md.Fee11 > 0 && md.Fee11 < md.Fee13)
{
feestore11 = md.Fee11.Value;
}
else if (md.Fee11 != null && md.Fee13 != null && md.Fee13 > 0 && md.Fee11 > md.Fee13)
{
feestore11 = md.Fee13.Value;
}
}
if (AddrType == "Commercial" || AddrType == "OFFICE")
{
if (md.Fee11 != null && md.Fee12 != null && md.Fee11 > 0 && md.Fee11 < md.Fee12)
{
feestore11 = md.Fee11.Value;
}
else if (md.Fee11 != null && md.Fee12 != null && md.Fee12 > 0 && md.Fee11 > md.Fee12)
{
feestore11 = md.Fee12.Value;
}
}
if (md.Fee12 != null && tweight >= 1120 && md.Fee12 > 0)
feestore11 = md.Fee12.Value;
if (feestore11 > 0)
{
hwyf1 += feestore11;
yf1++;
// DD_OrderData.GetGoodsFee2(md.OrderId.Value, num14);
}
if (md.Fee6 != null && md.Fee6 > 0)
{
feestore6 = md.Fee6.Value;
}
if (feestore6 == 0 && md.Fee7 != null && md.Fee7 > 0)
feestore6 = md.Fee7.Value;
if (md.Fee7 != null && md.Fee7 > 0 && md.Fee7 < feestore6)
{
feestore6 = md.Fee7.Value;
}
if (feestore6 == 0 && md.Fee8 != null && md.Fee8 > 0)
feestore6 = md.Fee8.Value;
if (md.Fee8 != null && md.Fee8 > 0 && md.Fee8 < feestore6)
{
feestore6 = md.Fee8.Value;
}
if (AddrType == "Residential" || AddrType == "RESIDENTIAL")
{
if (md.Fee6 != null && md.Fee8 != null && md.Fee6 > 0 && md.Fee6 < md.Fee8)
{
feestore6 = md.Fee6.Value;
}
else if (md.Fee6 != null && md.Fee8 != null && md.Fee8 > 0 && md.Fee6 > md.Fee8)
{
feestore6 = md.Fee8.Value;
}
}
if (AddrType == "Commercial" || AddrType == "OFFICE")
{
if (md.Fee6 != null && md.Fee7 != null && md.Fee6 > 0 && md.Fee6 < md.Fee7)
{
feestore6 = md.Fee6.Value;
}
else if (md.Fee6 != null && md.Fee7 != null && md.Fee7 > 0 && md.Fee6 > md.Fee7)
{
feestore6 = md.Fee7.Value;
}
}
if (md.Fee7 != null && tweight >= 1120 && md.Fee7 > 0)
feestore6 = md.Fee7.Value;
if (feestore6 > 0)
{
hwyf2 += feestore6;
yf2++;
// DD_OrderData.GetGoodsFee2(md.OrderId.Value, num14);
}
feestore = feestore11;
if (feestore11 == 0)
feestore = feestore6;
if (feestore6 > 0 && feestore6 < feestore11)
feestore = feestore6;
f6 += feestore;
md.PostFee = new decimal?(num10);
md.BoxFee = new decimal?(feestore);//运费
//var admd = DataNew.GetModel_OrderFee(md.OrderId.Value);///仓储 面单 广告费
//if (admd != null)
//{
// ckfee = admd.ckfee.Value;
// mdfee = admd.mdfee.Value;
// adfee = admd.adfee.Value;
// hjckfee += ckfee;
// hjmdfee += mdfee;
// hjadfee += adfee;
//}
//decimal num15 = 0M;
decimal num16 = 0M;
// DD_OrderData.GetGoodsFee2(md.OrderId.Value, TCFee);
hjyj += yj;
hjyf += feestore;
num16 = TotalPrice - yj - GoodsPrice - escrowFee - feestore - TCFee - ckfee - adfee;
// ErrorFollow.TraceWrite("Fee18", md.PlatOrderCode, "TotalPrice:" + TotalPrice + "|yj:" + yj + "|GoodsPrice:" + GoodsPrice + "|feestore:" + feestore + "|escrowFee:" + escrowFee + "|TCFee:" + TCFee + "|lr:" + num16);
if (feestore > 0 && GoodsPrice > 0)
{
//cyxs += TotalPrice;
//cyyj += yj;
//hwcb += GoodsPrice;
//hwtc += TCFee;
//hwyf += num14;
lr += num16;
}
}
}
ErrorFollow.TraceWrite("利润", hjyj.ToString(), hjyf.ToString());
dt.Rows[i]["ckfee"] = hjckfee;
dt.Rows[i]["mdfee"] = hjmdfee;
dt.Rows[i]["adfee"] = hjadfee;
dt.Rows[i]["LR"] = lr;
if (dt.Rows[i]["USDMoney"].ToString() != "" && Convert.ToDecimal(dt.Rows[i]["USDMoney"]) > 0)
dt.Rows[i]["MLL"] = (lr * 100 / Convert.ToDecimal(dt.Rows[i]["USDMoney"])).ToString("0.00") + "%";
if (dt2 != null)
{
var row = dt2.Select("shopId=" + Convert.ToInt32(dt.Rows[i]["ShopId"]));
if (row != null && row.Length > 0)
{
dt.Rows[i]["ShopCDGoods"] = Convert.ToInt32(row[0]["Num2"]);
dt.Rows[i]["ShopTJGoods"] = Convert.ToInt32(row[0]["Num"]);
}
}
}
//decimal f0 = f1 - f2 - f4 - f5 - f6;
//decimal zlr = cyxs - cyyj - hwcb - hwtc - hwyf - hwyf1 - hwyf2-yf1-yf2;
}
return GetReport3(dt, 18);
}
catch (Exception ex)
{
string a = dd;
return "";
}
}
#endregion
#region 报表18
[WebMethod(EnableSession = true)]
public string GetReportExcel18(DateTime? InDate, int DeptId, int ShopId, int PlatId, string MoneyCode, string Sort)
{
var obj = new BaseService();
string tj = "";
string tj1 = "";
if (DeptId > 0)
{
tj += " and b.DeptId=" + DeptId + " ";
tj1 += " and a.DeptId=" + DeptId + " ";
}
if (PlatId > 0)
{
tj += " and b.PlatType=" + PlatId + " ";
tj1 += " and a.PlatType=" + PlatId + " ";
}
if (ShopId > 0)
{
tj += " and b.ShopId=" + ShopId + " ";
tj1 += " and a.ShopId=" + ShopId + " ";
}
if (MoneyCode != "0")
tj += " and a.MoneyCode='" + MoneyCode + "' ";
string sql = @"
select a.ShopId,a.ShopName,OrderNum=isnull(c.OrderNum,0),USDMoney=isnull(c.USDMoney,0),RMBMoney=isnull(c.RMBMoney,0),AvgPrice=case when c.OrderNum is null or c.USDMoney is null or c.OrderNum=0 then 0 else c.USDMoney/c.OrderNum end,b.GoodRate,b.ODR,b.DSRGoods,b.DSRService,b.DSRPost,b.USDUseMoney,b.USDUseMoney,b.USDNoMoney,b.RMBUseMoney,b.RMBNoMoney,b.InforViolate,b.PropertyViolate,b.OtherViolate,b.Rate1,b.Rate2,b.Rate3,b.Rate4,b.Rate5,b.Rate6,FeeDate=isnull(b.FeeDate,a.FeeDate),TXFee=isnull(b.TXFee,a.TXFee),InPrice=d.InPrice,InPrice=d.InPrice,BZ=case when d.InPrice>0 then RMBMoney/d.InPrice else 0 end,LR=0 from JC_Shop a
inner join (select b.ShopId,OrderNum=COUNT(0),USDMoney=SUM(dbo.MoneyUSDChange(TotalPrice,a.MoneyCode,a.CompanyId)),RMBMoney=SUM(dbo.MoneyChange(TotalPrice,a.MoneyCode,a.CompanyId)) from DT_OrderInfo a
inner join JC_Shop b on a.ShopId=b.ShopId
where a.State>0 " + tj + " and a.State<3 and DATEDIFF(day,a.OrderDate,'" + InDate.Value.ToString("yyyy-MM-dd") + @"')=0 group by b.ShopId)c on a.ShopId=c.ShopId
left join JC_ShopData b on a.ShopId=b.ShopId and DATEDIFF(day,b.InDate,'" + InDate.Value.ToString("yyyy-MM-dd") + @"')=0
inner join (select a.ShopId,InPrice=sum(isnull(d.InPrice,0)*b.GoodsNum) from DT_OrderInfo a
inner join DT_OrderGoods b on a.OrderId=b.OrderId
inner join HW_GoodsDetail c on b.DetailId=c.DetailId
inner join HW_GoodsInfo d on c.GoodsId=d.GoodsId
where a.State>0 and a.State<3 and DATEDIFF(day,a.OrderDate,'" + InDate.Value.ToString("yyyy-MM-dd") + @"')=0 group by a.ShopId)d on a.ShopId=d.ShopId
where a.CompanyId=1 " + tj1 + " order by " + Sort;
DataTable dt = obj.GetReportData(sql);
DD_OrderData data = new DD_OrderData();
if (dt != null)
{
decimal f1 = 0;
decimal f2 = 0;
decimal f3 = 0;
decimal f4 = 0;
decimal f5 = 0;
decimal f6 = 0;
decimal cyxs = 0;
decimal cyyj = 0;
decimal hwcb = 0;
decimal hwtc = 0;
decimal hwyf = 0;
decimal hwyf1 = 0;
decimal hwyf2 = 0;
int yf1 = 0;
int yf2 = 0;
// int ds = 0;
// decimal f9 = 0;
for (int i = 0; i < dt.Rows.Count; i++)
{
decimal MRate = Convert.ToDecimal((double)6.5);
List<JC_Money> list7 = new BaseService().GetMoneyList2();
var olist = DataNew.GetListShopList2(Convert.ToInt32(dt.Rows[i]["ShopId"]), InDate);
string ids = "";
if (olist != null)
{
foreach (var order in olist)
{
ids += order.OrderId.ToString() + ",";
}
}
if (ids != "")
{
// List<DT_OrderGoods> orderGoodsListPP = DataNew.GetOrderGoodsListPP(ids.Trim(','));
List<DT_OrderGoods> orderGoodsList = DataNew.GetOrderGoodsList(ids.Trim(','));
if (orderGoodsList != null)
{
//ds += orderGoodsList.Count;
//foreach (var md in orderGoodsList)
//{
// f9 += md.GoodsPrice.Value * md.GoodsNum.Value;
//}
foreach (var md in olist)
{
List<DT_OrderGoods> gmd = null;
if (gmd == null)
gmd = orderGoodsList.FindAll(n => n.OrderId == md.OrderId);
md.GoodsList = gmd;
}
}
}
decimal lr = 0;
string AddrType = "";
decimal tweight = 0;
if (olist != null)
{
foreach (var md in olist)
{
//if (md.PlatOrderCode == "2793358899439")
//{
// string cc = "";
//}
JC_Money money = list7.Find(n => n.MCode == "USD" && n.PlatId == md.PlatId);
if (money != null)
{
MRate = money.MRate.Value;
}
else
{
money = list7.Find(n => n.MCode == "USD");
MRate = money.MRate.Value;
}
decimal TotalPrice = md.TotalPrice.Value;
decimal yj = 0M;
yj = TotalPrice * Convert.ToDecimal((double)0.15);
int PlatType = md.PlatId.Value;
if (PlatType == 1)
{
yj = TotalPrice * Convert.ToDecimal((double)0.05);
}
else if (PlatType == 4)
{
yj = 0;
}
else if (PlatType == 5)
{
yj = TotalPrice * Convert.ToDecimal((double)0.1);
}
f1 += TotalPrice;
f2 += yj;
decimal GoodsPrice = 0M;
decimal TCFee = 0M;
decimal TCFee2 = 0M;
decimal SolidFee = 0M;
decimal GoodsPrice2 = 0M;
tweight = 0;
if (md.GoodsList != null)
{
if (md.GoodsList.Count > 0)
{
AddrType = md.GoodsList[0].JoinOrderCode;
}
if (md.GoodsList != null)
{
foreach (DT_OrderGoods goods in md.GoodsList)
{
//if (goods.GoodsFee.HasValue && (goods.GoodsFee.Value > 0M))
//{
// GoodsPrice += goods.GoodsFee.Value;
//}
//else
if (goods.Weight != null)
{
tweight += goods.Weight.Value * goods.GoodsNum.Value;
}
if (goods.GoodsPrice.HasValue)
{
GoodsPrice2 += goods.GoodsPrice.Value * goods.GoodsNum.Value;
//f9 += goods.GoodsPrice.Value * goods.GoodsNum.Value;
}
// ds++;
if (goods.TCFee != null && goods.TCFee > 0 && goods.GoodsPrice != null)//税费
{
GoodsPrice2 += goods.GoodsPrice.Value * goods.GoodsNum.Value * goods.TCFee.Value * Convert.ToDecimal(0.01);
}
//if (goods.Solid != null && goods.Solid > 0)//匹配的头程费
//{
// TCFee2 += goods.Solid.Value * goods.GoodsNum.Value;
//}
//else
if (goods.Solid2.HasValue)
{
SolidFee += goods.Solid2.Value * goods.GoodsNum.Value;
}
}
}
}
if (GoodsPrice2 > 0M)
{
GoodsPrice = GoodsPrice2 / MRate;
}
f4 += GoodsPrice;
decimal escrowFee = 0M;
if ((TCFee == 0M) && (SolidFee > 0M))
{
TCFee = Convert.ToDecimal(65) * SolidFee;
}
// TCFee += TCFee2;
f5 += TCFee;// +TCFee2;
//if (md.escrowFee.HasValue)
//{
// escrowFee = md.escrowFee.Value;
//}
decimal num10 = 0M;
if (md.PostFee.HasValue)
{
num10 = md.PostFee.Value;
}
decimal num11 = 0M;
decimal num12 = 0M;
decimal num13 = 0M;
//if (md.Post == 222 || md.Post == 226 || md.Post == 227)
//{
// num13 = num10 * Convert.ToDecimal((double)0.1);
//}
decimal num14 = 0M;
if (md.StoreId == 11)
{
if (md.Fee11 != null && md.Fee11 > 0)
{
num14 = md.Fee11.Value;
}
if (num14 == 0 && md.Fee12 != null && md.Fee12 > 0)
num14 = md.Fee12.Value;
if (md.Fee12 != null && md.Fee12 > 0 && md.Fee12 < num14)
{
num14 = md.Fee12.Value;
}
if (num14 == 0 && md.Fee13 != null && md.Fee13 > 0)
num14 = md.Fee13.Value;
if (md.Fee13 != null && md.Fee13 > 0 && md.Fee13 < num14)
{
num14 = md.Fee13.Value;
}
if (AddrType == "Residential" || AddrType == "RESIDENTIAL")
{
if (md.Fee11 != null && md.Fee13 != null && md.Fee11 > 0 && md.Fee11 < md.Fee13)
{
num14 = md.Fee11.Value;
}
else if (md.Fee11 != null && md.Fee13 != null && md.Fee13 > 0 && md.Fee11 > md.Fee13)
{
num14 = md.Fee13.Value;
}
}
if (AddrType == "Commercial" || AddrType == "OFFICE")
{
if (md.Fee11 != null && md.Fee12 != null && md.Fee11 > 0 && md.Fee11 < md.Fee12)
{
num14 = md.Fee11.Value;
}
else if (md.Fee11 != null && md.Fee12 != null && md.Fee12 > 0 && md.Fee11 > md.Fee12)
{
num14 = md.Fee12.Value;
}
}
if (md.Fee12 != null && tweight >= 1120 && md.Fee12 > 0)
num14 = md.Fee12.Value;
if (num14 > 0)
{
hwyf1 += num14;
yf1++;
// DD_OrderData.GetGoodsFee2(md.OrderId.Value, num14);
}
}
else
{
if (md.Fee6 != null && md.Fee6 > 0)
{
num14 = md.Fee6.Value;
}
if (num14 == 0 && md.Fee7 != null && md.Fee7 > 0)
num14 = md.Fee7.Value;
if (md.Fee7 != null && md.Fee7 > 0 && md.Fee7 < num14)
{
num14 = md.Fee7.Value;
}
if (num14 == 0 && md.Fee8 != null && md.Fee8 > 0)
num14 = md.Fee8.Value;
if (md.Fee8 != null && md.Fee8 > 0 && md.Fee8 < num14)
{
num14 = md.Fee8.Value;
}
if (AddrType == "Residential" || AddrType == "RESIDENTIAL")
{
if (md.Fee6 != null && md.Fee8 != null && md.Fee6 > 0 && md.Fee6 < md.Fee8)
{
num14 = md.Fee6.Value;
}
else if (md.Fee6 != null && md.Fee8 != null && md.Fee8 > 0 && md.Fee6 > md.Fee8)
{
num14 = md.Fee8.Value;
}
}
if (AddrType == "Commercial" || AddrType == "OFFICE")
{
if (md.Fee6 != null && md.Fee7 != null && md.Fee6 > 0 && md.Fee6 < md.Fee7)
{
num14 = md.Fee6.Value;
}
else if (md.Fee6 != null && md.Fee7 != null && md.Fee7 > 0 && md.Fee6 > md.Fee7)
{
num14 = md.Fee7.Value;
}
}
if (md.Fee7 != null && tweight >= 1120 && md.Fee7 > 0)
num14 = md.Fee7.Value;
if (num14 > 0)
{
hwyf2 += num14;
yf2++;
// DD_OrderData.GetGoodsFee2(md.OrderId.Value, num14);
}
}
f6 += num14;
md.PostFee = new decimal?(num10);
md.BoxFee = new decimal?(num14);
//decimal num15 = 0M;
decimal num16 = 0M;
// DD_OrderData.GetGoodsFee2(md.OrderId.Value, TCFee);
num16 = ((((((TotalPrice - yj) - GoodsPrice) - escrowFee) - num14) - TCFee) - num11) - num12;
if (num14 > 0 && GoodsPrice > 0)
{
//cyxs += TotalPrice;
//cyyj += yj;
//hwcb += GoodsPrice;
//hwtc += TCFee;
//hwyf += num14;
lr += num16;
}
}
}
dt.Rows[i]["LR"] = lr;
}
//decimal f0 = f1 - f2 - f4 - f5 - f6;
}
return GetExcelReport(dt, 18);
}
#endregion
#region 报表
public string GetReport3(DataTable dt, int ReportId)
{
PagesNew.Login(this.Session);
var obj = new BaseService();
var rmd = BaseService.GetReportModel(ReportId);
var rlist = obj.GetRepoartColsList(ReportId);
if (rmd == null || rlist == null)
return "";
StringBuilder html = new StringBuilder();
html.Append("<tr class='HeaderStyle'><th>序号</th>");
foreach (var md in rlist)
{
html.Append("<th>" + md.ColName + "</th>");
}
html.Append("</tr>");
if (dt != null)
{
DataRow row = null;
for (int i = 0; i < dt.Rows.Count; i++)
{
html.Append("<tr class='DataGridRowStyle'><td>" + (i + 1).ToString() + "</td>");
int rowindex = 1;
foreach (var md in rlist)
{
if (dt.Columns.Contains(md.ColValue) == false)
{
html.Append("<td rowindex='" + rowindex + "' rowtr='" + i + "' rname='"+md.ColName+"'></td>");
rowindex++;
continue;
}
if (md.IsSum == 1 && i == 0)
{
if (row == null)
row = dt.NewRow();
if (md.ColType == "int")
{
try
{
row[md.ColValue] = Convert.ToInt32(dt.Compute("sum(" + md.ColValue + ")", "" + md.ColValue + " is not null"));
}
catch
{
row[md.ColValue] = 0;
}
}
else if (md.ColType == "dec")
{
try
{
row[md.ColValue] = Convert.ToDecimal(dt.Compute("sum(" + md.ColValue + ")", "" + md.ColValue + ">0"));
}
catch
{
row[md.ColValue] = 0;
}
}
}
if (dt.Rows[i][md.ColValue] != null && dt.Rows[i][md.ColValue].ToString() != "")
{
string csscolor = "";
if (md.ContionType == "=" && dt.Rows[i][md.ColValue].ToString() == md.SValue)
{
csscolor = md.ColColor;
}
else
if (md.ContionType == ">" && Convert.ToDecimal(dt.Rows[i][md.ColValue]) > Convert.ToDecimal(md.SValue) && Convert.ToDecimal(dt.Rows[i][md.ColValue]) < Convert.ToDecimal(md.EValue))
{
csscolor = md.ColColor;
}
else
if (md.ContionType == ">=" && Convert.ToDecimal(dt.Rows[i][md.ColValue]) >= Convert.ToDecimal(md.SValue) && Convert.ToDecimal(dt.Rows[i][md.ColValue]) <= Convert.ToDecimal(md.EValue))
{
csscolor = md.ColColor;
}
if (csscolor != "")
csscolor = "style='color:" + csscolor + "'";
string datav = "";
if (md.ColType == "date1")
datav = Convert.ToDateTime(dt.Rows[i][md.ColValue]).ToString("yyyy-MM-dd");
else
if (md.ColType == "date2")
datav = Convert.ToDateTime(dt.Rows[i][md.ColValue]).ToString("yyyy-MM-dd HH:mm");
else
datav = dt.Rows[i][md.ColValue].ToString();
html.Append("<td " + csscolor + " rowindex='" + rowindex + "' rowtr='" + i + "' rname='" + md.ColName + "'>" + datav + "</td>");
}
else
html.Append("<td rowindex='" + rowindex + "' rowtr='" + i + "' rname='" + md.ColName + "'></td>");
rowindex++;
}
html.Append("</tr>");
}
int hj = 0;
if (row != null)
{
html.Append("<tr class='DataGridRowStyle'><td>合计:</td>");
foreach (var md in rlist)
{
if (dt.Columns.Contains(md.ColValue) == false)
{
html.Append("<td></td>");
continue;
}
if (md.IsSum == 1 && row[md.ColValue] != null)
{
if (hj == 0)
{
hj = 1;
html.Append("<td rtype='hj' rname='" + md.ColName + "'>" + row[md.ColValue] + "</td>");
}
else
html.Append("<td rtype='hj' rname='" + md.ColName + "'>" + row[md.ColValue] + "</td>");
}
else
html.Append("<td></td>");
}
html.Append("</tr>");
}
}
return html.ToString();
}
#endregion
#region 导出报表
public string GetExcelReport(DataTable dt, int ReportId)
{
PagesNew.Login(this.Session);
var obj = new BaseService();
TableColumnCollection listColumns = new TableColumnCollection();
var rmd = BaseService.GetReportModel(ReportId);
var rlist = obj.GetRepoartColsList(ReportId);
if (rmd == null || rlist == null || dt == null)
return "";
DataRow row = null;
int hj = 0;
foreach (var md in rlist)
{
if (md.IsExcel == 1)
listColumns.Add(md.ColValue, md.ColName, DbType.String, "");
if (md.IsSum == 1)
{
if (row == null)
row = dt.NewRow();
if (md.ColType == "int" && dt != null && dt.Rows.Count > 0)
row[md.ColValue] = Convert.ToInt32(dt.Compute("sum(" + md.ColValue + ")", ""));
else if (md.ColType == "dec" && dt != null && dt.Rows.Count > 0)
row[md.ColValue] = Convert.ToDecimal(dt.Compute("sum(" + md.ColValue + ")", ""));
}
else if (hj == 0 && md.ColType == "str")
{
if (row == null)
row = dt.NewRow();
row[md.ColValue] = "合计:";
}
}
if (row != null)
dt.Rows.Add(row);
MicrosoftExcel obj2 = new MicrosoftExcel();
return obj2.Export(dt, listColumns);
}
#endregion
#region 计算当天
[WebMethod(EnableSession = true)]
public void GetCountSum()
{
PagesNew.Login(this.Session);
DataNew.GetCountSum(DateTime.Today);
}
#endregion
#region 订单统计
[WebMethod(EnableSession = true)]
public DT_OrderNum GetOrderCountReport1(int Type, int ShopId, int PlatId, DateTime? SDate, DateTime? EDate, Int32? TJ1, Int32? TJ2, Int32? TJ3, Int32? TJ4, Int32? TJ5, Int32? TJ6, Int32? TJ7, Int32? TJ8, Int32? TJ9, Int32? TJ10)
{
PagesNew.Login(this.Session);
int CompanyId = Convert.ToInt32(Session["CompanyId"]);
var obj = new DD_OrderData();
string Ids = "";
string[] categories = null;
DT_OrderNum md = new DT_OrderNum();
var list = new List<DT_OrderCountData>();
TimeSpan ts = EDate.Value - SDate.Value;
int days = ts.Days + 1;
List<DT_CountListFromDay> countlist = new List<DT_CountListFromDay>();
List<DT_CountListFromDay> countlist2 = new List<DT_CountListFromDay>();
List<DT_CountListFromDay> countlist3 = new List<DT_CountListFromDay>();
List<DT_CountListFromDay> countlist4 = new List<DT_CountListFromDay>();
List<DT_CountListFromDay> countlist5 = new List<DT_CountListFromDay>();
List<DT_CountListFromDay> countlist6 = new List<DT_CountListFromDay>();
List<DT_CountListFromDay> countlist7 = new List<DT_CountListFromDay>();
List<DT_CountListFromDay> countlist8 = new List<DT_CountListFromDay>();
List<DT_CountListFromDay> countlist9 = new List<DT_CountListFromDay>();
List<DT_CountListFromDay> countlist10 = new List<DT_CountListFromDay>();
if (TJ1 == 1)
countlist = DataNew.GetCountListReport(Type, PlatId, ShopId, SDate.Value, EDate.Value.AddDays(1), CompanyId);
if (TJ2 == 1)
countlist2 = DataNew.GetCountListReport2(Type, PlatId, ShopId, SDate.Value, EDate.Value.AddDays(1), CompanyId);
if (TJ3 == 1)
countlist3 = DataNew.GetCountListReport3(Type, PlatId, ShopId, SDate.Value, EDate.Value.AddDays(1), CompanyId);
if (TJ4 == 1)
countlist4 = DataNew.GetCountListReport4(Type, PlatId, ShopId, SDate.Value, EDate.Value.AddDays(1), CompanyId);
if (TJ5 == 1)
countlist5 = DataNew.GetCountListReport5(Type, PlatId, ShopId, SDate.Value, EDate.Value.AddDays(1), CompanyId);
if (TJ6 == 1)
countlist6 = DataNew.GetCountListReport6(Type, PlatId, ShopId, SDate.Value, EDate.Value.AddDays(1), CompanyId);
if (TJ7 == 1)
countlist7 = DataNew.GetCountListReport7(Type, PlatId, ShopId, SDate.Value, EDate.Value.AddDays(1), CompanyId);
if (TJ8 == 1)
countlist8 = DataNew.GetCountListReport8(Type, PlatId, ShopId, SDate.Value, EDate.Value.AddDays(1), CompanyId);
if (TJ9 == 1)
countlist9 = DataNew.GetCountListReport9(Type, PlatId, ShopId, SDate.Value, EDate.Value.AddDays(1), CompanyId);
if (TJ10 == 1)
countlist10 = DataNew.GetCountListReport10(Type, PlatId, ShopId, SDate.Value, EDate.Value.AddDays(1), CompanyId);
categories = new string[days];
if (days > 0)
{
for (int i = 0; i < days; i++)
{
categories[i] = (SDate.Value.AddDays(i)).ToString("MM月dd日");
}
}
if (TJ10 == 1)
{
decimal[] data = new decimal[days];
if (days > 0)
{
for (int j = 0; j < days; j++)
{
if (countlist10 != null)
{
var countmd = countlist10.Find(n => n.OrderDate == SDate.Value.AddDays(j).ToString("yyyy-MM-dd"));
if (countmd != null)
data[j] = countmd.Price.Value;
else
data[j] = 0;
}
else
data[j] = 0;
}
}
var datamd = new DT_OrderCountData();
datamd.name = "总销售额";
datamd.data = data;
list.Add(datamd);
}
if (TJ1 == 1)
{
decimal[] data = new decimal[days];
if (days > 0)
{
for (int j = 0; j < days; j++)
{
if (countlist != null)
{
var countmd = countlist.Find(n => n.OrderDate == SDate.Value.AddDays(j).ToString("yyyy-MM-dd"));
if (countmd != null)
data[j] = countmd.Price.Value;
else
data[j] = 0;
}
else
data[j] = 0;
}
}
var datamd = new DT_OrderCountData();
datamd.name = "总销售额扣除佣金";
datamd.data = data;
list.Add(datamd);
}
if (TJ2 == 1)
{
decimal[] data = new decimal[days];
if (days > 0)
{
for (int j = 0; j < days; j++)
{
if (countlist2 != null)
{
var countmd = countlist2.Find(n => n.OrderDate == SDate.Value.AddDays(j).ToString("yyyy-MM-dd"));
if (countmd != null)
data[j] = countmd.Price.Value;
else
data[j] = 0;
}
else
data[j] = 0;
}
}
var datamd = new DT_OrderCountData();
datamd.name = "参与预估销售额";
datamd.data = data;
list.Add(datamd);
}
if (TJ3 == 1)
{
decimal[] data = new decimal[days];
if (days > 0)
{
for (int j = 0; j < days; j++)
{
if (countlist3 != null)
{
var countmd = countlist3.Find(n => n.OrderDate == SDate.Value.AddDays(j).ToString("yyyy-MM-dd"));
if (countmd != null)
data[j] = countmd.Price.Value;
else
data[j] = 0;
}
else
data[j] = 0;
}
}
var datamd = new DT_OrderCountData();
datamd.name = "参与实际销售额";
datamd.data = data;
list.Add(datamd);
}
if (TJ4 == 1)
{
decimal[] data = new decimal[days];
if (days > 0)
{
for (int j = 0; j < days; j++)
{
if (countlist4 != null)
{
var countmd = countlist4.Find(n => n.OrderDate == SDate.Value.AddDays(j).ToString("yyyy-MM-dd"));
if (countmd != null)
data[j] = countmd.Price.Value;
else
data[j] = 0;
}
else
data[j] = 0;
}
}
var datamd = new DT_OrderCountData();
datamd.name = "预估货物成本";
datamd.data = data;
list.Add(datamd);
}
if (TJ5 == 1)
{
decimal[] data = new decimal[days];
if (days > 0)
{
for (int j = 0; j < days; j++)
{
if (countlist5 != null)
{
var countmd = countlist5.Find(n => n.OrderDate == SDate.Value.AddDays(j).ToString("yyyy-MM-dd"));
if (countmd != null)
data[j] = countmd.Price.Value;
else
data[j] = 0;
}
else
data[j] = 0;
}
}
var datamd = new DT_OrderCountData();
datamd.name = "实际货物成本";
datamd.data = data;
list.Add(datamd);
}
if (TJ6 == 1)
{
decimal[] data = new decimal[days];
if (days > 0)
{
for (int j = 0; j < days; j++)
{
if (countlist6 != null)
{
var countmd = countlist6.Find(n => n.OrderDate == SDate.Value.AddDays(j).ToString("yyyy-MM-dd"));
if (countmd != null)
data[j] = countmd.Price.Value;
else
data[j] = 0;
}
else
data[j] = 0;
}
}
var datamd = new DT_OrderCountData();
datamd.name = "预估运费";
datamd.data = data;
list.Add(datamd);
}
if (TJ7 == 1)
{
decimal[] data = new decimal[days];
if (days > 0)
{
for (int j = 0; j < days; j++)
{
if (countlist7 != null)
{
var countmd = countlist7.Find(n => n.OrderDate == SDate.Value.AddDays(j).ToString("yyyy-MM-dd"));
if (countmd != null)
data[j] = countmd.Price.Value;
else
data[j] = 0;
}
else
data[j] = 0;
}
}
var datamd = new DT_OrderCountData();
datamd.name = "实际运费";
datamd.data = data;
list.Add(datamd);
}
if (TJ8 == 1)
{
decimal[] data = new decimal[days];
if (days > 0)
{
for (int j = 0; j < days; j++)
{
if (countlist8 != null)
{
var countmd = countlist8.Find(n => n.OrderDate == SDate.Value.AddDays(j).ToString("yyyy-MM-dd"));
if (countmd != null)
data[j] = countmd.Price.Value;
else
data[j] = 0;
}
else
data[j] = 0;
}
}
var datamd = new DT_OrderCountData();
datamd.name = "预估利润";
datamd.data = data;
list.Add(datamd);
}
if (TJ9 == 1)
{
decimal[] data = new decimal[days];
if (days > 0)
{
for (int j = 0; j < days; j++)
{
if (countlist9 != null)
{
var countmd = countlist9.Find(n => n.OrderDate == SDate.Value.AddDays(j).ToString("yyyy-MM-dd"));
if (countmd != null)
data[j] = countmd.Price.Value;
else
data[j] = 0;
}
else
data[j] = 0;
}
}
var datamd = new DT_OrderCountData();
datamd.name = "实际利润";
datamd.data = data;
list.Add(datamd);
}
md.categories = categories;
JavaScriptSerializer JsonConvert = new JavaScriptSerializer();
string postmessage = JsonConvert.Serialize(list);
md.Data = postmessage;
return md;
}
#endregion
#region 订单统计
[WebMethod(EnableSession = true)]
public DT_OrderNum GetOrderCountReportNew1(int Type, string ShopIds, int PlatId, DateTime? SDate, DateTime? EDate, Int32? TJ1, Int32? TJ2, Int32? TJ3, Int32? TJ4, Int32? TJ5, Int32? TJ6, Int32? TJ7, Int32? TJ8, Int32? TJ9, Int32? TJ10)
{
PagesNew.Login(this.Session);
int CompanyId = Convert.ToInt32(Session["CompanyId"]);
var obj = new DD_OrderData();
string Ids = "";
string[] categories = null;
DT_OrderNum md = new DT_OrderNum();
var list = new List<DT_OrderCountData>();
TimeSpan ts = EDate.Value - SDate.Value;
int days = ts.Days + 1;
int ShopId = 0;
if (ShopIds.StartsWith("-1") == false)
ShopId = 1;
ShopIds = ShopIds.TrimEnd(',');
List<DT_CountListFromDay> countlist = new List<DT_CountListFromDay>();
List<DT_CountListFromDay> countlist2 = new List<DT_CountListFromDay>();
List<DT_CountListFromDay> countlist3 = new List<DT_CountListFromDay>();
List<DT_CountListFromDay> countlist4 = new List<DT_CountListFromDay>();
List<DT_CountListFromDay> countlist5 = new List<DT_CountListFromDay>();
List<DT_CountListFromDay> countlist6 = new List<DT_CountListFromDay>();
List<DT_CountListFromDay> countlist7 = new List<DT_CountListFromDay>();
List<DT_CountListFromDay> countlist8 = new List<DT_CountListFromDay>();
List<DT_CountListFromDay> countlist9 = new List<DT_CountListFromDay>();
List<DT_CountListFromDay> countlist10 = new List<DT_CountListFromDay>();
if (TJ1 == 1)
countlist = DataNew.GetCountListReportNew(Type, PlatId, ShopId, ShopIds, SDate.Value, EDate.Value.AddDays(1), CompanyId);
if (TJ2 == 1)
countlist2 = DataNew.GetCountListReportNew2(Type, PlatId, ShopId, ShopIds, SDate.Value, EDate.Value.AddDays(1), CompanyId);
if (TJ3 == 1)
countlist3 = DataNew.GetCountListReportNew3(Type, PlatId, ShopId, ShopIds, SDate.Value, EDate.Value.AddDays(1), CompanyId);
if (TJ4 == 1)
countlist4 = DataNew.GetCountListReportNew4(Type, PlatId, ShopId, ShopIds, SDate.Value, EDate.Value.AddDays(1), CompanyId);
if (TJ5 == 1)
countlist5 = DataNew.GetCountListReportNew5(Type, PlatId, ShopId, ShopIds, SDate.Value, EDate.Value.AddDays(1), CompanyId);
if (TJ6 == 1)
countlist6 = DataNew.GetCountListReportNew6(Type, PlatId, ShopId, ShopIds, SDate.Value, EDate.Value.AddDays(1), CompanyId);
if (TJ7 == 1)
countlist7 = DataNew.GetCountListReportNew7(Type, PlatId, ShopId, ShopIds, SDate.Value, EDate.Value.AddDays(1), CompanyId);
if (TJ8 == 1)
countlist8 = DataNew.GetCountListReportNew8(Type, PlatId, ShopId, ShopIds, SDate.Value, EDate.Value.AddDays(1), CompanyId);
if (TJ9 == 1)
countlist9 = DataNew.GetCountListReportNew9(Type, PlatId, ShopId, ShopIds, SDate.Value, EDate.Value.AddDays(1), CompanyId);
if (TJ10 == 1)
countlist10 = DataNew.GetCountListReportNew10(Type, PlatId, ShopId, ShopIds, SDate.Value, EDate.Value.AddDays(1), CompanyId);
categories = new string[days];
if (days > 0)
{
for (int i = 0; i < days; i++)
{
categories[i] = (SDate.Value.AddDays(i)).ToString("MM月dd日");
}
}
var shoplist = DataNew.GetShopAllList(1, PlatId);
if (ShopIds.StartsWith("-1") == true)
{
ShopIds = "";
foreach (var smd in shoplist)
{
ShopIds += smd.ShopId + ",";
}
ShopIds = ShopIds.TrimEnd(',');
}
string[] shops = ShopIds.Split(',');
if (TJ10 == 1)
{
for (int m = 0; m < shops.Length; m++)
{
var shopmd = shoplist.Find(n => n.ShopId == Convert.ToInt32(shops[m]));
if (shopmd == null)
continue;
decimal[] data = new decimal[days];
if (days > 0)
{
for (int j = 0; j < days; j++)
{
if (countlist10 != null)
{
var countmd = countlist10.Find(n => n.PlatId == shopmd.ShopId && n.OrderDate == SDate.Value.AddDays(j).ToString("yyyy-MM-dd"));
if (countmd != null)
data[j] = countmd.Price.Value;
else
data[j] = 0;
}
else
data[j] = 0;
}
}
var datamd = new DT_OrderCountData();
datamd.name = shopmd.ShopName;// "总销售额";
datamd.data = data;
list.Add(datamd);
}
var datamdz = new DT_OrderCountData();
decimal[] dataz = new decimal[days];
datamdz.name = "合计";
if (days > 0)
{
for (int j = 0; j < days; j++)
{
if (countlist10 != null)
{
var countmdall = countlist10.FindAll(n => n.OrderDate == SDate.Value.AddDays(j).ToString("yyyy-MM-dd"));
decimal tzj = 0;
if (countmdall != null)
{
foreach (var cmd in countmdall)
{
if (cmd.Price != null)
tzj += cmd.Price.Value;
}
}
dataz[j] = tzj;
}
}
}
datamdz.data = dataz;
list.Add(datamdz);
}
if (TJ1 == 1)
{
for (int m = 0; m < shops.Length; m++)
{
var shopmd = shoplist.Find(n => n.ShopId == Convert.ToInt32(shops[m]));
if (shopmd == null)
continue;
decimal[] data = new decimal[days];
if (days > 0)
{
for (int j = 0; j < days; j++)
{
if (countlist != null)
{
var countmd = countlist.Find(n => n.PlatId == shopmd.ShopId && n.OrderDate == SDate.Value.AddDays(j).ToString("yyyy-MM-dd"));
if (countmd != null)
data[j] = countmd.Price.Value;
else
data[j] = 0;
}
else
data[j] = 0;
}
}
var datamd = new DT_OrderCountData();
datamd.name = shopmd.ShopName;// "总销售额扣除佣金";
datamd.data = data;
list.Add(datamd);
var datamdz = new DT_OrderCountData();
decimal[] dataz = new decimal[days];
datamdz.name = "合计";
if (days > 0)
{
for (int j = 0; j < days; j++)
{
if (countlist != null)
{
var countmdall = countlist.FindAll(n => n.OrderDate == SDate.Value.AddDays(j).ToString("yyyy-MM-dd"));
decimal tzj = 0;
if (countmdall != null)
{
foreach (var cmd in countmdall)
{
if (cmd.Price != null)
tzj += cmd.Price.Value;
}
}
dataz[j] = tzj;
}
}
}
datamdz.data = dataz;
list.Add(datamdz);
}
}
if (TJ2 == 1)
{
for (int m = 0; m < shops.Length; m++)
{
var shopmd = shoplist.Find(n => n.ShopId == Convert.ToInt32(shops[m]));
if (shopmd == null)
continue;
decimal[] data = new decimal[days];
if (days > 0)
{
for (int j = 0; j < days; j++)
{
if (countlist2 != null)
{
var countmd = countlist2.Find(n => n.PlatId == shopmd.ShopId && n.OrderDate == SDate.Value.AddDays(j).ToString("yyyy-MM-dd"));
if (countmd != null)
data[j] = countmd.Price.Value;
else
data[j] = 0;
}
else
data[j] = 0;
}
}
var datamd = new DT_OrderCountData();
datamd.name = shopmd.ShopName;// "参与预估销售额";
datamd.data = data;
list.Add(datamd);
var datamdz = new DT_OrderCountData();
decimal[] dataz = new decimal[days];
datamdz.name = "合计";
if (days > 0)
{
for (int j = 0; j < days; j++)
{
if (countlist2 != null)
{
var countmdall = countlist2.FindAll(n => n.OrderDate == SDate.Value.AddDays(j).ToString("yyyy-MM-dd"));
decimal tzj = 0;
if (countmdall != null)
{
foreach (var cmd in countmdall)
{
if (cmd.Price != null)
tzj += cmd.Price.Value;
}
}
dataz[j] = tzj;
}
}
}
datamdz.data = dataz;
list.Add(datamdz);
}
}
if (TJ3 == 1)
{
for (int m = 0; m < shops.Length; m++)
{
var shopmd = shoplist.Find(n => n.ShopId == Convert.ToInt32(shops[m]));
if (shopmd == null)
continue;
decimal[] data = new decimal[days];
if (days > 0)
{
for (int j = 0; j < days; j++)
{
if (countlist3 != null)
{
var countmd = countlist3.Find(n => n.PlatId == shopmd.ShopId && n.OrderDate == SDate.Value.AddDays(j).ToString("yyyy-MM-dd"));
if (countmd != null)
data[j] = countmd.Price.Value;
else
data[j] = 0;
}
else
data[j] = 0;
}
}
var datamd = new DT_OrderCountData();
datamd.name = shopmd.ShopName;// "参与实际销售额";
datamd.data = data;
list.Add(datamd);
var datamdz = new DT_OrderCountData();
decimal[] dataz = new decimal[days];
datamdz.name = "合计";
if (days > 0)
{
for (int j = 0; j < days; j++)
{
if (countlist3 != null)
{
var countmdall = countlist3.FindAll(n => n.OrderDate == SDate.Value.AddDays(j).ToString("yyyy-MM-dd"));
decimal tzj = 0;
if (countmdall != null)
{
foreach (var cmd in countmdall)
{
if (cmd.Price != null)
tzj += cmd.Price.Value;
}
}
dataz[j] = tzj;
}
}
}
datamdz.data = dataz;
list.Add(datamdz);
}
}
if (TJ4 == 1)
{
for (int m = 0; m < shops.Length; m++)
{
var shopmd = shoplist.Find(n => n.ShopId == Convert.ToInt32(shops[m]));
if (shopmd == null)
continue;
decimal[] data = new decimal[days];
if (days > 0)
{
for (int j = 0; j < days; j++)
{
if (countlist4 != null)
{
var countmd = countlist4.Find(n => n.PlatId == shopmd.ShopId && n.OrderDate == SDate.Value.AddDays(j).ToString("yyyy-MM-dd"));
if (countmd != null)
data[j] = countmd.Price.Value;
else
data[j] = 0;
}
else
data[j] = 0;
}
}
var datamd = new DT_OrderCountData();
datamd.name = shopmd.ShopName;// "预估货物成本";
datamd.data = data;
list.Add(datamd);
}
var datamdz = new DT_OrderCountData();
decimal[] dataz = new decimal[days];
datamdz.name = "合计";
if (days > 0)
{
for (int j = 0; j < days; j++)
{
if (countlist4 != null)
{
var countmdall = countlist4.FindAll(n => n.OrderDate == SDate.Value.AddDays(j).ToString("yyyy-MM-dd"));
decimal tzj = 0;
if (countmdall != null)
{
foreach (var cmd in countmdall)
{
if (cmd.Price != null)
tzj += cmd.Price.Value;
}
}
dataz[j] = tzj;
}
}
}
datamdz.data = dataz;
list.Add(datamdz);
}
if (TJ5 == 1)
{
for (int m = 0; m < shops.Length; m++)
{
var shopmd = shoplist.Find(n => n.ShopId == Convert.ToInt32(shops[m]));
if (shopmd == null)
continue;
decimal[] data = new decimal[days];
if (days > 0)
{
for (int j = 0; j < days; j++)
{
if (countlist5 != null)
{
var countmd = countlist5.Find(n => n.PlatId == shopmd.ShopId && n.OrderDate == SDate.Value.AddDays(j).ToString("yyyy-MM-dd"));
if (countmd != null)
data[j] = countmd.Price.Value;
else
data[j] = 0;
}
else
data[j] = 0;
}
}
var datamd = new DT_OrderCountData();
datamd.name = shopmd.ShopName;// "实际货物成本";
datamd.data = data;
list.Add(datamd);
}
var datamdz = new DT_OrderCountData();
decimal[] dataz = new decimal[days];
datamdz.name = "合计";
if (days > 0)
{
for (int j = 0; j < days; j++)
{
if (countlist5 != null)
{
var countmdall = countlist5.FindAll(n => n.OrderDate == SDate.Value.AddDays(j).ToString("yyyy-MM-dd"));
decimal tzj = 0;
if (countmdall != null)
{
foreach (var cmd in countmdall)
{
if (cmd.Price != null)
tzj += cmd.Price.Value;
}
}
dataz[j] = tzj;
}
}
}
datamdz.data = dataz;
list.Add(datamdz);
}
if (TJ6 == 1)
{
for (int m = 0; m < shops.Length; m++)
{
var shopmd = shoplist.Find(n => n.ShopId == Convert.ToInt32(shops[m]));
if (shopmd == null)
continue;
decimal[] data = new decimal[days];
if (days > 0)
{
for (int j = 0; j < days; j++)
{
if (countlist6 != null)
{
var countmd = countlist6.Find(n => n.PlatId == shopmd.ShopId && n.OrderDate == SDate.Value.AddDays(j).ToString("yyyy-MM-dd"));
if (countmd != null)
data[j] = countmd.Price.Value;
else
data[j] = 0;
}
else
data[j] = 0;
}
}
var datamd = new DT_OrderCountData();
datamd.name = shopmd.ShopName;// "预估运费";
datamd.data = data;
list.Add(datamd);
}
var datamdz = new DT_OrderCountData();
decimal[] dataz = new decimal[days];
datamdz.name = "合计";
if (days > 0)
{
for (int j = 0; j < days; j++)
{
if (countlist6 != null)
{
var countmdall = countlist6.FindAll(n => n.OrderDate == SDate.Value.AddDays(j).ToString("yyyy-MM-dd"));
decimal tzj = 0;
if (countmdall != null)
{
foreach (var cmd in countmdall)
{
if (cmd.Price != null)
tzj += cmd.Price.Value;
}
}
dataz[j] = tzj;
}
}
}
datamdz.data = dataz;
list.Add(datamdz);
}
if (TJ7 == 1)
{
for (int m = 0; m < shops.Length; m++)
{
var shopmd = shoplist.Find(n => n.ShopId == Convert.ToInt32(shops[m]));
if (shopmd == null)
continue;
decimal[] data = new decimal[days];
if (days > 0)
{
for (int j = 0; j < days; j++)
{
if (countlist7 != null)
{
var countmd = countlist7.Find(n => n.PlatId == shopmd.ShopId && n.OrderDate == SDate.Value.AddDays(j).ToString("yyyy-MM-dd"));
if (countmd != null)
data[j] = countmd.Price.Value;
else
data[j] = 0;
}
else
data[j] = 0;
}
}
var datamd = new DT_OrderCountData();
datamd.name = shopmd.ShopName;// "实际运费";
datamd.data = data;
list.Add(datamd);
}
var datamdz = new DT_OrderCountData();
decimal[] dataz = new decimal[days];
datamdz.name = "合计";
if (days > 0)
{
for (int j = 0; j < days; j++)
{
if (countlist7 != null)
{
var countmdall = countlist7.FindAll(n => n.OrderDate == SDate.Value.AddDays(j).ToString("yyyy-MM-dd"));
decimal tzj = 0;
if (countmdall != null)
{
foreach (var cmd in countmdall)
{
if (cmd.Price != null)
tzj += cmd.Price.Value;
}
}
dataz[j] = tzj;
}
}
}
datamdz.data = dataz;
list.Add(datamdz);
}
if (TJ8 == 1)
{
for (int m = 0; m < shops.Length; m++)
{
var shopmd = shoplist.Find(n => n.ShopId == Convert.ToInt32(shops[m]));
if (shopmd == null)
continue;
decimal[] data = new decimal[days];
if (days > 0)
{
for (int j = 0; j < days; j++)
{
if (countlist8 != null)
{
var countmd = countlist8.Find(n => n.PlatId == shopmd.ShopId && n.OrderDate == SDate.Value.AddDays(j).ToString("yyyy-MM-dd"));
if (countmd != null)
data[j] = countmd.Price.Value;
else
data[j] = 0;
}
else
data[j] = 0;
}
}
var datamd = new DT_OrderCountData();
datamd.name = shopmd.ShopName;// "预估利润";
datamd.data = data;
list.Add(datamd);
}
var datamdz = new DT_OrderCountData();
decimal[] dataz = new decimal[days];
datamdz.name = "合计";
if (days > 0)
{
for (int j = 0; j < days; j++)
{
if (countlist8 != null)
{
var countmdall = countlist8.FindAll(n => n.OrderDate == SDate.Value.AddDays(j).ToString("yyyy-MM-dd"));
decimal tzj = 0;
if (countmdall != null)
{
foreach (var cmd in countmdall)
{
if (cmd.Price != null)
tzj += cmd.Price.Value;
}
}
dataz[j] = tzj;
}
}
}
datamdz.data = dataz;
list.Add(datamdz);
}
if (TJ9 == 1)
{
for (int m = 0; m < shops.Length; m++)
{
var shopmd = shoplist.Find(n => n.ShopId == Convert.ToInt32(shops[m]));
if (shopmd == null)
continue;
decimal[] data = new decimal[days];
if (days > 0)
{
for (int j = 0; j < days; j++)
{
if (countlist9 != null)
{
var countmd = countlist9.Find(n => n.PlatId == shopmd.ShopId && n.OrderDate == SDate.Value.AddDays(j).ToString("yyyy-MM-dd"));
if (countmd != null)
data[j] = countmd.Price.Value;
else
data[j] = 0;
}
else
data[j] = 0;
}
}
var datamd = new DT_OrderCountData();
datamd.name = shopmd.ShopName;// "实际利润";
datamd.data = data;
list.Add(datamd);
}
var datamdz = new DT_OrderCountData();
decimal[] dataz = new decimal[days];
datamdz.name = "合计";
if (days > 0)
{
for (int j = 0; j < days; j++)
{
if (countlist9!= null)
{
var countmdall = countlist9.FindAll(n => n.OrderDate == SDate.Value.AddDays(j).ToString("yyyy-MM-dd"));
decimal tzj = 0;
if (countmdall != null)
{
foreach (var cmd in countmdall)
{
if (cmd.Price != null)
tzj += cmd.Price.Value;
}
}
dataz[j] = tzj;
}
}
}
datamdz.data = dataz;
list.Add(datamdz);
}
md.categories = categories;
JavaScriptSerializer JsonConvert = new JavaScriptSerializer();
string postmessage = JsonConvert.Serialize(list);
md.Data = postmessage;
return md;
}
#endregion
#region 订单统计
[WebMethod(EnableSession = true)]
public DT_OrderNum GetOrderCountReportNew2(int Type, int PlatId, string ShopIds, int SYear, int SMonth, int EYear, int EMonth, Int32? TJ1, Int32? TJ2, Int32? TJ3, Int32? TJ4, Int32? TJ5, Int32? TJ6, Int32? TJ7, Int32? TJ8, Int32? TJ9, Int32? TJ10)
{
PagesNew.Login(this.Session);
int CompanyId = Convert.ToInt32(Session["CompanyId"]);
var obj = new DD_OrderData();
string Ids = "";
string[] categories = null;
DT_OrderNum md = new DT_OrderNum();
var list = new List<DT_OrderCountData>();
int ShopId = 0;
if (ShopIds.StartsWith("-1") == false)
ShopId = 1;
ShopIds = ShopIds.TrimEnd(',');
string sm = SMonth.ToString();
if (SMonth < 10)
sm = "0" + SMonth.ToString();
string em = (EMonth + 1).ToString();
if (EMonth < 9)
em = "0" + (EMonth + 1).ToString();
DateTime? SDate = Convert.ToDateTime(SYear.ToString() + "-" + sm + "-01");
DateTime? EDate = Convert.ToDateTime(EYear.ToString() + "-" + em + "-01");
List<DT_CountListFromDay> countlist = new List<DT_CountListFromDay>();
List<DT_CountListFromDay> countlist2 = new List<DT_CountListFromDay>();
List<DT_CountListFromDay> countlist3 = new List<DT_CountListFromDay>();
List<DT_CountListFromDay> countlist4 = new List<DT_CountListFromDay>();
List<DT_CountListFromDay> countlist5 = new List<DT_CountListFromDay>();
List<DT_CountListFromDay> countlist6 = new List<DT_CountListFromDay>();
List<DT_CountListFromDay> countlist7 = new List<DT_CountListFromDay>();
List<DT_CountListFromDay> countlist8 = new List<DT_CountListFromDay>();
List<DT_CountListFromDay> countlist9 = new List<DT_CountListFromDay>();
List<DT_CountListFromDay> countlist10 = new List<DT_CountListFromDay>();
if (TJ1 == 1)
countlist = DataNew.GetCountListReportNew(Type, PlatId, ShopId, ShopIds, SDate.Value, EDate.Value.AddDays(1), CompanyId);
if (TJ2 == 1)
countlist2 = DataNew.GetCountListReportNew2(Type, PlatId, ShopId, ShopIds, SDate.Value, EDate.Value.AddDays(1), CompanyId);
if (TJ3 == 1)
countlist3 = DataNew.GetCountListReportNew3(Type, PlatId, ShopId, ShopIds, SDate.Value, EDate.Value.AddDays(1), CompanyId);
if (TJ4 == 1)
countlist4 = DataNew.GetCountListReportNew4(Type, PlatId, ShopId, ShopIds, SDate.Value, EDate.Value.AddDays(1), CompanyId);
if (TJ5 == 1)
countlist5 = DataNew.GetCountListReportNew5(Type, PlatId, ShopId, ShopIds, SDate.Value, EDate.Value.AddDays(1), CompanyId);
if (TJ6 == 1)
countlist6 = DataNew.GetCountListReportNew6(Type, PlatId, ShopId, ShopIds, SDate.Value, EDate.Value.AddDays(1), CompanyId);
if (TJ7 == 1)
countlist7 = DataNew.GetCountListReportNew7(Type, PlatId, ShopId, ShopIds, SDate.Value, EDate.Value.AddDays(1), CompanyId);
if (TJ8 == 1)
countlist8 = DataNew.GetCountListReportNew8(Type, PlatId, ShopId, ShopIds, SDate.Value, EDate.Value.AddDays(1), CompanyId);
if (TJ9 == 1)
countlist9 = DataNew.GetCountListReportNew9(Type, PlatId, ShopId, ShopIds, SDate.Value, EDate.Value.AddDays(1), CompanyId);
if (TJ10 == 1)
countlist10 = DataNew.GetCountListReportNew10(Type, PlatId, ShopId, ShopIds, SDate.Value, EDate.Value.AddDays(1), CompanyId);
int days = 0;
if (SYear == EYear)
days = EMonth - SMonth + 1;
else
days = 12 - SMonth + EMonth + 1;
var shoplist = DataNew.GetShopAllList(1, PlatId);
if (ShopIds.StartsWith("-1") == true)
{
ShopIds = "";
foreach (var smd in shoplist)
{
ShopIds += smd.ShopId + ",";
}
ShopIds = ShopIds.TrimEnd(',');
}
string[] shops = ShopIds.Split(',');
categories = new string[days];
if (days > 0)
{
for (int i = 0; i < days; i++)
{
categories[i] = (SDate.Value.AddMonths(i)).ToString("yyyy年MM月");
}
}
if (TJ10 == 1)
{
for (int m = 0; m < shops.Length; m++)
{
var shopmd = shoplist.Find(n => n.ShopId == Convert.ToInt32(shops[m]));
if (shopmd == null)
continue;
decimal[] data = new decimal[days];
if (days > 0)
{
for (int j = 0; j < days; j++)
{
if (countlist10 != null)
{
var countmd = countlist10.Find(n =>n.PlatId==shopmd.ShopId&&n.OrderDate == SDate.Value.AddMonths(j).ToString("yyyy-MM"));
if (countmd != null)
data[j] = countmd.Price.Value;
else
data[j] = 0;
}
else
data[j] = 0;
}
}
var datamd = new DT_OrderCountData();
datamd.name = shopmd.ShopName;// "总销售额";
datamd.data = data;
list.Add(datamd);
}
var datamdz = new DT_OrderCountData();
decimal[] dataz = new decimal[days];
datamdz.name = "合计";
if (days > 0)
{
for (int j = 0; j < days; j++)
{
if (countlist10 != null)
{
var countmdall = countlist10.FindAll(n => n.OrderDate== SDate.Value.AddMonths(j).ToString("yyyy-MM"));
decimal tzj = 0;
if (countmdall != null)
{
foreach (var cmd in countmdall)
{
if (cmd.Price != null)
tzj += cmd.Price.Value;
}
}
dataz[j] = tzj;
}
}
}
datamdz.data = dataz;
list.Add(datamdz);
}
if (TJ1 == 1)
{
for (int m = 0; m < shops.Length; m++)
{
var shopmd = shoplist.Find(n => n.ShopId == Convert.ToInt32(shops[m]));
if (shopmd == null)
continue;
decimal[] data = new decimal[days];
if (days > 0)
{
for (int j = 0; j < days; j++)
{
if (countlist != null)
{
var countmd = countlist.Find(n => n.PlatId == shopmd.ShopId && n.OrderDate == SDate.Value.AddMonths(j).ToString("yyyy-MM"));
if (countmd != null)
data[j] = countmd.Price.Value;
else
data[j] = 0;
}
else
data[j] = 0;
}
}
var datamd = new DT_OrderCountData();
datamd.name = shopmd.ShopName;// "总销售额扣除佣金";
datamd.data = data;
list.Add(datamd);
}
var datamdz = new DT_OrderCountData();
decimal[] dataz = new decimal[days];
datamdz.name = "合计";
if (days > 0)
{
for (int j = 0; j < days; j++)
{
if (countlist!= null)
{
var countmdall = countlist.FindAll(n => n.OrderDate == SDate.Value.AddMonths(j).ToString("yyyy-MM"));
decimal tzj = 0;
if (countmdall != null)
{
foreach (var cmd in countmdall)
{
if (cmd.Price != null)
tzj += cmd.Price.Value;
}
}
dataz[j] = tzj;
}
}
}
datamdz.data = dataz;
list.Add(datamdz);
}
if (TJ2 == 1)
{
for (int m = 0; m < shops.Length; m++)
{
var shopmd = shoplist.Find(n => n.ShopId == Convert.ToInt32(shops[m]));
if (shopmd == null)
continue;
decimal[] data = new decimal[days];
if (days > 0)
{
for (int j = 0; j < days; j++)
{
if (countlist2 != null)
{
var countmd = countlist2.Find(n => n.PlatId == shopmd.ShopId && n.OrderDate == SDate.Value.AddMonths(j).ToString("yyyy-MM"));
if (countmd != null)
data[j] = countmd.Price.Value;
else
data[j] = 0;
}
else
data[j] = 0;
}
}
var datamd = new DT_OrderCountData();
datamd.name = shopmd.ShopName;// "参与预估销售额";
datamd.data = data;
list.Add(datamd);
}
var datamdz = new DT_OrderCountData();
decimal[] dataz = new decimal[days];
datamdz.name = "合计";
if (days > 0)
{
for (int j = 0; j < days; j++)
{
if (countlist2 != null)
{
var countmdall = countlist2.FindAll(n => n.OrderDate == SDate.Value.AddMonths(j).ToString("yyyy-MM"));
decimal tzj = 0;
if (countmdall != null)
{
foreach (var cmd in countmdall)
{
if (cmd.Price != null)
tzj += cmd.Price.Value;
}
}
dataz[j] = tzj;
}
}
}
datamdz.data = dataz;
list.Add(datamdz);
}
if (TJ3 == 1)
{
for (int m = 0; m < shops.Length; m++)
{
var shopmd = shoplist.Find(n => n.ShopId == Convert.ToInt32(shops[m]));
if (shopmd == null)
continue;
decimal[] data = new decimal[days];
if (days > 0)
{
for (int j = 0; j < days; j++)
{
if (countlist3 != null)
{
var countmd = countlist3.Find(n => n.PlatId == shopmd.ShopId && n.OrderDate == SDate.Value.AddMonths(j).ToString("yyyy-MM"));
if (countmd != null)
data[j] = countmd.Price.Value;
else
data[j] = 0;
}
else
data[j] = 0;
}
}
var datamd = new DT_OrderCountData();
datamd.name = shopmd.ShopName;// "参与实际销售额";
datamd.data = data;
list.Add(datamd);
}
var datamdz = new DT_OrderCountData();
decimal[] dataz = new decimal[days];
datamdz.name = "合计";
if (days > 0)
{
for (int j = 0; j < days; j++)
{
if (countlist3 != null)
{
var countmdall = countlist3.FindAll(n => n.OrderDate == SDate.Value.AddMonths(j).ToString("yyyy-MM"));
decimal tzj = 0;
if (countmdall != null)
{
foreach (var cmd in countmdall)
{
if (cmd.Price != null)
tzj += cmd.Price.Value;
}
}
dataz[j] = tzj;
}
}
}
datamdz.data = dataz;
list.Add(datamdz);
}
if (TJ4 == 1)
{
for (int m = 0; m < shops.Length; m++)
{
var shopmd = shoplist.Find(n => n.ShopId == Convert.ToInt32(shops[m]));
if (shopmd == null)
continue;
decimal[] data = new decimal[days];
if (days > 0)
{
for (int j = 0; j < days; j++)
{
if (countlist4 != null)
{
var countmd = countlist4.Find(n => n.PlatId == shopmd.ShopId && n.OrderDate == SDate.Value.AddMonths(j).ToString("yyyy-MM"));
if (countmd != null)
data[j] = countmd.Price.Value;
else
data[j] = 0;
}
else
data[j] = 0;
}
}
var datamd = new DT_OrderCountData();
datamd.name = shopmd.ShopName;// "预估货物成本";
datamd.data = data;
list.Add(datamd);
}
var datamdz = new DT_OrderCountData();
decimal[] dataz = new decimal[days];
datamdz.name = "合计";
if (days > 0)
{
for (int j = 0; j < days; j++)
{
if (countlist4 != null)
{
var countmdall = countlist4.FindAll(n => n.OrderDate == SDate.Value.AddMonths(j).ToString("yyyy-MM"));
decimal tzj = 0;
if (countmdall != null)
{
foreach (var cmd in countmdall)
{
if (cmd.Price != null)
tzj += cmd.Price.Value;
}
}
dataz[j] = tzj;
}
}
}
datamdz.data = dataz;
list.Add(datamdz);
}
if (TJ5 == 1)
{
for (int m = 0; m < shops.Length; m++)
{
var shopmd = shoplist.Find(n => n.ShopId == Convert.ToInt32(shops[m]));
if (shopmd == null)
continue;
decimal[] data = new decimal[days];
if (days > 0)
{
for (int j = 0; j < days; j++)
{
if (countlist5 != null)
{
var countmd = countlist5.Find(n => n.PlatId == shopmd.ShopId && n.OrderDate == SDate.Value.AddMonths(j).ToString("yyyy-MM"));
if (countmd != null)
data[j] = countmd.Price.Value;
else
data[j] = 0;
}
else
data[j] = 0;
}
}
var datamd = new DT_OrderCountData();
datamd.name = shopmd.ShopName;// "实际货物成本";
datamd.data = data;
list.Add(datamd);
}
var datamdz = new DT_OrderCountData();
decimal[] dataz = new decimal[days];
datamdz.name = "合计";
if (days > 0)
{
for (int j = 0; j < days; j++)
{
if (countlist5 != null)
{
var countmdall = countlist5.FindAll(n => n.OrderDate == SDate.Value.AddMonths(j).ToString("yyyy-MM"));
decimal tzj = 0;
if (countmdall != null)
{
foreach (var cmd in countmdall)
{
if (cmd.Price != null)
tzj += cmd.Price.Value;
}
}
dataz[j] = tzj;
}
}
}
datamdz.data = dataz;
list.Add(datamdz);
}
if (TJ6 == 1)
{
for (int m = 0; m < shops.Length; m++)
{
var shopmd = shoplist.Find(n => n.ShopId == Convert.ToInt32(shops[m]));
if (shopmd == null)
continue;
decimal[] data = new decimal[days];
if (days > 0)
{
for (int j = 0; j < days; j++)
{
if (countlist6 != null)
{
var countmd = countlist6.Find(n => n.PlatId == shopmd.ShopId && n.OrderDate == SDate.Value.AddMonths(j).ToString("yyyy-MM"));
if (countmd != null)
data[j] = countmd.Price.Value;
else
data[j] = 0;
}
else
data[j] = 0;
}
}
var datamd = new DT_OrderCountData();
datamd.name = shopmd.ShopName;// "预估运费";
datamd.data = data;
list.Add(datamd);
}
var datamdz = new DT_OrderCountData();
decimal[] dataz = new decimal[days];
datamdz.name = "合计";
if (days > 0)
{
for (int j = 0; j < days; j++)
{
if (countlist6 != null)
{
var countmdall = countlist6.FindAll(n => n.OrderDate == SDate.Value.AddMonths(j).ToString("yyyy-MM"));
decimal tzj = 0;
if (countmdall != null)
{
foreach (var cmd in countmdall)
{
if (cmd.Price != null)
tzj += cmd.Price.Value;
}
}
dataz[j] = tzj;
}
}
}
datamdz.data = dataz;
list.Add(datamdz);
}
if (TJ7 == 1)
{
for (int m = 0; m < shops.Length; m++)
{
var shopmd = shoplist.Find(n => n.ShopId == Convert.ToInt32(shops[m]));
if (shopmd == null)
continue;
decimal[] data = new decimal[days];
if (days > 0)
{
for (int j = 0; j < days; j++)
{
if (countlist7 != null)
{
var countmd = countlist7.Find(n => n.PlatId == shopmd.ShopId && n.OrderDate == SDate.Value.AddMonths(j).ToString("yyyy-MM"));
if (countmd != null)
data[j] = countmd.Price.Value;
else
data[j] = 0;
}
else
data[j] = 0;
}
}
var datamd = new DT_OrderCountData();
datamd.name = shopmd.ShopName;// "实际运费";
datamd.data = data;
list.Add(datamd);
}
var datamdz = new DT_OrderCountData();
decimal[] dataz = new decimal[days];
datamdz.name = "合计";
if (days > 0)
{
for (int j = 0; j < days; j++)
{
if (countlist7 != null)
{
var countmdall = countlist7.FindAll(n => n.OrderDate == SDate.Value.AddMonths(j).ToString("yyyy-MM"));
decimal tzj = 0;
if (countmdall != null)
{
foreach (var cmd in countmdall)
{
if (cmd.Price != null)
tzj += cmd.Price.Value;
}
}
dataz[j] = tzj;
}
}
}
datamdz.data = dataz;
list.Add(datamdz);
}
if (TJ8 == 1)
{
for (int m = 0; m < shops.Length; m++)
{
var shopmd = shoplist.Find(n => n.ShopId == Convert.ToInt32(shops[m]));
if (shopmd == null)
continue;
decimal[] data = new decimal[days];
if (days > 0)
{
for (int j = 0; j < days; j++)
{
if (countlist8 != null)
{
var countmd = countlist8.Find(n => n.PlatId == shopmd.ShopId && n.OrderDate == SDate.Value.AddMonths(j).ToString("yyyy-MM"));
if (countmd != null)
data[j] = countmd.Price.Value;
else
data[j] = 0;
}
else
data[j] = 0;
}
}
var datamd = new DT_OrderCountData();
datamd.name = shopmd.ShopName;// "预估利润";
datamd.data = data;
list.Add(datamd);
}
var datamdz = new DT_OrderCountData();
decimal[] dataz = new decimal[days];
datamdz.name = "合计";
if (days > 0)
{
for (int j = 0; j < days; j++)
{
if (countlist8 != null)
{
var countmdall = countlist8.FindAll(n => n.OrderDate == SDate.Value.AddMonths(j).ToString("yyyy-MM"));
decimal tzj = 0;
if (countmdall != null)
{
foreach (var cmd in countmdall)
{
if (cmd.Price != null)
tzj += cmd.Price.Value;
}
}
dataz[j] = tzj;
}
}
}
datamdz.data = dataz;
list.Add(datamdz);
}
if (TJ9 == 1)
{
for (int m = 0; m < shops.Length; m++)
{
var shopmd = shoplist.Find(n => n.ShopId == Convert.ToInt32(shops[m]));
if (shopmd == null)
continue;
decimal[] data = new decimal[days];
if (days > 0)
{
for (int j = 0; j < days; j++)
{
if (countlist9 != null)
{
var countmd = countlist9.Find(n => n.PlatId == shopmd.ShopId && n.OrderDate == SDate.Value.AddMonths(j).ToString("yyyy-MM"));
if (countmd != null)
data[j] = countmd.Price.Value;
else
data[j] = 0;
}
else
data[j] = 0;
}
}
var datamd = new DT_OrderCountData();
datamd.name = "实际利润";
datamd.data = data;
list.Add(datamd);
}
var datamdz = new DT_OrderCountData();
decimal[] dataz = new decimal[days];
datamdz.name = "合计";
if (days > 0)
{
for (int j = 0; j < days; j++)
{
if (countlist9 != null)
{
var countmdall = countlist9.FindAll(n => n.OrderDate == SDate.Value.AddMonths(j).ToString("yyyy-MM"));
decimal tzj = 0;
if (countmdall != null)
{
foreach (var cmd in countmdall)
{
if (cmd.Price != null)
tzj += cmd.Price.Value;
}
}
dataz[j] = tzj;
}
}
}
datamdz.data = dataz;
list.Add(datamdz);
}
md.categories = categories;
JavaScriptSerializer JsonConvert = new JavaScriptSerializer();
string postmessage = JsonConvert.Serialize(list);
md.Data = postmessage;
return md;
}
#endregion
#region 订单统计
[WebMethod(EnableSession = true)]
public DT_OrderNum GetOrderCountReport2(int Type, int PlatId, int ShopId, int SYear, int SMonth, int EYear, int EMonth, Int32? TJ1, Int32? TJ2, Int32? TJ3, Int32? TJ4, Int32? TJ5, Int32? TJ6, Int32? TJ7, Int32? TJ8, Int32? TJ9, Int32? TJ10)
{
PagesNew.Login(this.Session);
int CompanyId = Convert.ToInt32(Session["CompanyId"]);
var obj = new DD_OrderData();
string Ids = "";
string[] categories = null;
DT_OrderNum md = new DT_OrderNum();
var list = new List<DT_OrderCountData>();
string sm = SMonth.ToString();
if (SMonth < 10)
sm = "0" + SMonth.ToString();
string em = (EMonth + 1).ToString();
if (EMonth < 9)
em = "0" + (EMonth + 1).ToString();
DateTime? SDate = Convert.ToDateTime(SYear.ToString() + "-" + sm + "-01");
DateTime? EDate = Convert.ToDateTime(EYear.ToString() + "-" + em + "-01");
List<DT_CountListFromDay> countlist = new List<DT_CountListFromDay>();
List<DT_CountListFromDay> countlist2 = new List<DT_CountListFromDay>();
List<DT_CountListFromDay> countlist3 = new List<DT_CountListFromDay>();
List<DT_CountListFromDay> countlist4 = new List<DT_CountListFromDay>();
List<DT_CountListFromDay> countlist5 = new List<DT_CountListFromDay>();
List<DT_CountListFromDay> countlist6 = new List<DT_CountListFromDay>();
List<DT_CountListFromDay> countlist7 = new List<DT_CountListFromDay>();
List<DT_CountListFromDay> countlist8 = new List<DT_CountListFromDay>();
List<DT_CountListFromDay> countlist9 = new List<DT_CountListFromDay>();
List<DT_CountListFromDay> countlist10 = new List<DT_CountListFromDay>();
if (TJ1 == 1)
countlist = DataNew.GetCountListReport(Type, PlatId, ShopId, SDate.Value, EDate.Value.AddDays(1), CompanyId);
if (TJ2 == 1)
countlist2 = DataNew.GetCountListReport2(Type, PlatId, ShopId, SDate.Value, EDate.Value.AddDays(1), CompanyId);
if (TJ3 == 1)
countlist3 = DataNew.GetCountListReport3(Type, PlatId, ShopId, SDate.Value, EDate.Value.AddDays(1), CompanyId);
if (TJ4 == 1)
countlist4 = DataNew.GetCountListReport4(Type, PlatId, ShopId, SDate.Value, EDate.Value.AddDays(1), CompanyId);
if (TJ5 == 1)
countlist5 = DataNew.GetCountListReport5(Type, PlatId, ShopId, SDate.Value, EDate.Value.AddDays(1), CompanyId);
if (TJ6 == 1)
countlist6 = DataNew.GetCountListReport6(Type, PlatId, ShopId, SDate.Value, EDate.Value.AddDays(1), CompanyId);
if (TJ7 == 1)
countlist7 = DataNew.GetCountListReport7(Type, PlatId, ShopId, SDate.Value, EDate.Value.AddDays(1), CompanyId);
if (TJ8 == 1)
countlist8 = DataNew.GetCountListReport8(Type, PlatId, ShopId, SDate.Value, EDate.Value.AddDays(1), CompanyId);
if (TJ9 == 1)
countlist9 = DataNew.GetCountListReport9(Type, PlatId, ShopId, SDate.Value, EDate.Value.AddDays(1), CompanyId);
if (TJ10 == 1)
countlist10 = DataNew.GetCountListReport10(Type, PlatId, ShopId, SDate.Value, EDate.Value.AddDays(1), CompanyId);
int days = 0;
if (SYear == EYear)
days = EMonth - SMonth + 1;
else
days = 12 - SMonth + EMonth + 1;
categories = new string[days];
if (days > 0)
{
for (int i = 0; i < days; i++)
{
categories[i] = (SDate.Value.AddMonths(i)).ToString("yyyy年MM月");
}
}
if (TJ10 == 1)
{
decimal[] data = new decimal[days];
if (days > 0)
{
for (int j = 0; j < days; j++)
{
if (countlist10 != null)
{
var countmd = countlist10.Find(n => n.OrderDate == SDate.Value.AddMonths(j).ToString("yyyy-MM"));
if (countmd != null)
data[j] = countmd.Price.Value;
else
data[j] = 0;
}
else
data[j] = 0;
}
}
var datamd = new DT_OrderCountData();
datamd.name = "总销售额";
datamd.data = data;
list.Add(datamd);
}
if (TJ1 == 1)
{
decimal[] data = new decimal[days];
if (days > 0)
{
for (int j = 0; j < days; j++)
{
if (countlist != null)
{
var countmd = countlist.Find(n => n.OrderDate == SDate.Value.AddMonths(j).ToString("yyyy-MM"));
if (countmd != null)
data[j] = countmd.Price.Value;
else
data[j] = 0;
}
else
data[j] = 0;
}
}
var datamd = new DT_OrderCountData();
datamd.name = "总销售额扣除佣金";
datamd.data = data;
list.Add(datamd);
}
if (TJ2 == 1)
{
decimal[] data = new decimal[days];
if (days > 0)
{
for (int j = 0; j < days; j++)
{
if (countlist2 != null)
{
var countmd = countlist2.Find(n => n.OrderDate == SDate.Value.AddMonths(j).ToString("yyyy-MM"));
if (countmd != null)
data[j] = countmd.Price.Value;
else
data[j] = 0;
}
else
data[j] = 0;
}
}
var datamd = new DT_OrderCountData();
datamd.name = "参与预估销售额";
datamd.data = data;
list.Add(datamd);
}
if (TJ3 == 1)
{
decimal[] data = new decimal[days];
if (days > 0)
{
for (int j = 0; j < days; j++)
{
if (countlist3 != null)
{
var countmd = countlist3.Find(n => n.OrderDate == SDate.Value.AddMonths(j).ToString("yyyy-MM"));
if (countmd != null)
data[j] = countmd.Price.Value;
else
data[j] = 0;
}
else
data[j] = 0;
}
}
var datamd = new DT_OrderCountData();
datamd.name = "参与实际销售额";
datamd.data = data;
list.Add(datamd);
}
if (TJ4 == 1)
{
decimal[] data = new decimal[days];
if (days > 0)
{
for (int j = 0; j < days; j++)
{
if (countlist4 != null)
{
var countmd = countlist4.Find(n => n.OrderDate == SDate.Value.AddMonths(j).ToString("yyyy-MM"));
if (countmd != null)
data[j] = countmd.Price.Value;
else
data[j] = 0;
}
else
data[j] = 0;
}
}
var datamd = new DT_OrderCountData();
datamd.name = "预估货物成本";
datamd.data = data;
list.Add(datamd);
}
if (TJ5 == 1)
{
decimal[] data = new decimal[days];
if (days > 0)
{
for (int j = 0; j < days; j++)
{
if (countlist5 != null)
{
var countmd = countlist5.Find(n => n.OrderDate == SDate.Value.AddMonths(j).ToString("yyyy-MM"));
if (countmd != null)
data[j] = countmd.Price.Value;
else
data[j] = 0;
}
else
data[j] = 0;
}
}
var datamd = new DT_OrderCountData();
datamd.name = "实际货物成本";
datamd.data = data;
list.Add(datamd);
}
if (TJ6 == 1)
{
decimal[] data = new decimal[days];
if (days > 0)
{
for (int j = 0; j < days; j++)
{
if (countlist6 != null)
{
var countmd = countlist6.Find(n => n.OrderDate == SDate.Value.AddMonths(j).ToString("yyyy-MM"));
if (countmd != null)
data[j] = countmd.Price.Value;
else
data[j] = 0;
}
else
data[j] = 0;
}
}
var datamd = new DT_OrderCountData();
datamd.name = "预估运费";
datamd.data = data;
list.Add(datamd);
}
if (TJ7 == 1)
{
decimal[] data = new decimal[days];
if (days > 0)
{
for (int j = 0; j < days; j++)
{
if (countlist7 != null)
{
var countmd = countlist7.Find(n => n.OrderDate == SDate.Value.AddMonths(j).ToString("yyyy-MM"));
if (countmd != null)
data[j] = countmd.Price.Value;
else
data[j] = 0;
}
else
data[j] = 0;
}
}
var datamd = new DT_OrderCountData();
datamd.name = "实际运费";
datamd.data = data;
list.Add(datamd);
}
if (TJ8 == 1)
{
decimal[] data = new decimal[days];
if (days > 0)
{
for (int j = 0; j < days; j++)
{
if (countlist8 != null)
{
var countmd = countlist8.Find(n => n.OrderDate == SDate.Value.AddMonths(j).ToString("yyyy-MM"));
if (countmd != null)
data[j] = countmd.Price.Value;
else
data[j] = 0;
}
else
data[j] = 0;
}
}
var datamd = new DT_OrderCountData();
datamd.name = "预估利润";
datamd.data = data;
list.Add(datamd);
}
if (TJ9 == 1)
{
decimal[] data = new decimal[days];
if (days > 0)
{
for (int j = 0; j < days; j++)
{
if (countlist9 != null)
{
var countmd = countlist9.Find(n => n.OrderDate == SDate.Value.AddMonths(j).ToString("yyyy-MM"));
if (countmd != null)
data[j] = countmd.Price.Value;
else
data[j] = 0;
}
else
data[j] = 0;
}
}
var datamd = new DT_OrderCountData();
datamd.name = "实际利润";
datamd.data = data;
list.Add(datamd);
}
md.categories = categories;
JavaScriptSerializer JsonConvert = new JavaScriptSerializer();
string postmessage = JsonConvert.Serialize(list);
md.Data = postmessage;
return md;
}
#endregion
#region 个人订单列表
[WebMethod(EnableSession = true)]
public JsonModel<List<DT_OrderUserListNew>> GetUserOrderList2(int BJState, int UserId, int OrderState, int PlatId, int ShopId, DateTime? SDate, DateTime? EDate, string GoodsCode, decimal? GDFee, decimal YJRate, string OrderCode, string Name, string TrackCode, int OffType, decimal? Offfee, int PageSize, int PageIndex)
{
PagesNew.Login(this.Session);
try
{
int CompanyId = Convert.ToInt32(Session["CompanyId"]);
var obj = new DD_OrderData();
List<DT_OrderUserNew> dlist = null;
var slist = obj.Get_ShopList(CompanyId);
if (UserId > 0)
dlist = DataNew.Get_OrderUser(BJState, CompanyId, OrderState, PlatId, ShopId, UserId, SDate, EDate.Value.AddDays(1), GoodsCode, OrderCode, TrackCode, Name, OffType, Offfee);
else
dlist = DataNew.Get_OrderUser2(BJState, CompanyId, OrderState, PlatId, ShopId, SDate, EDate.Value.AddDays(1), GoodsCode, OrderCode, TrackCode, Name, OffType, Offfee);
List<DT_OrderUserNew> glist = null;
if (UserId > 0)
glist = DataNew.Get_OrderGoods(CompanyId, PlatId, ShopId, UserId, SDate, EDate.Value.AddDays(1), GoodsCode);
else
glist = DataNew.Get_OrderGoods2(CompanyId, PlatId, ShopId, SDate, EDate.Value.AddDays(1), GoodsCode);
// ErrorFollow.TraceWrite("GetUserOrderList2", "", dlist.Count().ToString() + " " + glist.Count().ToString());
if (dlist == null || glist == null)
return null;
decimal USDRate = Convert.ToDecimal(6.5);
var obj2 = new BaseService();
var mlist = obj2.GetMoneyList2();
List<DT_OrderUserListNew> olist = new List<DT_OrderUserListNew>();
int rowindex = 1;
string Ids = "";
string Ids2 = "";
if (dlist != null)
{
foreach (var md in dlist)
{
Ids2 += md.OrderId.Value + ",";
if (md.OrderState2 == 1)
Ids += md.OrderId.Value + ",";
}
}
var backorderlist = new List<DT_OrderBackMoneyApply>();
if (Ids != "")
{
backorderlist = DataNew.GetListOrderBackMoneyApply(Ids.Trim(','));
}
var trackorderlist = new List<DT_TrackCodeApply>();
if (Ids2 != "")
{
trackorderlist = DataNew.GetListOrderTrackCodeApply(Ids2.Trim(','));
}
if (dlist != null)
{
decimal hj1 = 0;
decimal hj11 = 0;
decimal hj21 = 0;
decimal hj2 = 0;
decimal hj3 = 0;
decimal hj4 = 0;
decimal hj5 = 0;
decimal hj51 = 0;
decimal hj6 = 0;
decimal hj7 = 0;
decimal hj8 = 0;
decimal hj9 = 0;//赔款
decimal hj10 = 0;//我们承担运费
decimal Tckfee = 0;//
decimal Tmdfee = 0;//
decimal Tadfee = 0;//
decimal TDR_BackFee = 0;//
decimal TDR_PostFee = 0;//
decimal TDR_SSFee = 0;//
int hjsl = 0;
foreach (var md in dlist)
{
var mmd = mlist.Find(n => n.PlatId == md.PlatId && n.MCode == "USD");
if (mmd != null)
USDRate = mmd.MRate.Value;
decimal? Lr = 0;
DT_OrderUserListNew model = new DT_OrderUserListNew();
model.BJState = md.BJState;
model.OrderId = md.OrderId;
model.StateName = "正常订单";
int BackType = 0;//退款类型
int BackOrderState = 0;//订单类型
int? GoodsBackType = 0;//退款类型
int IsBackOrder = 0;//是否退货订单
int GoodsState = 0;//是否退货订单
decimal PKPrice = 0;//赔款金额
decimal OurPostFee = 0;//退货运费
string TrackCode2 = "";
if (trackorderlist != null && trackorderlist.Count > 0)
{
var tlist = trackorderlist.FindAll(n => n.OrderId == md.OrderId);
if (tlist != null)
{
foreach (var tmd in tlist)
{
TrackCode2 += tmd.TrackCode + "<br/>";
}
}
}
if (md.OrderState2 == 1 && backorderlist != null)
{
var bmd = backorderlist.Find(n => n.OrderId == md.OrderId);
if (bmd != null)
{
IsBackOrder = 1;
model.StateName = "退货赔款订单";
// <option value="0">退款退货</option>
//<option value="1">退款不退货</option>
//<option value="2">赔款不退货</option>
//<option value="3">赔款退货</option>
// <option value="0">取消订单收取佣金20%</option>
//<option value="1">订单和佣金正常</option>
if (bmd.FactPrice != null)
PKPrice = bmd.FactPrice.Value;
if (bmd.GoodState != null)
GoodsState = bmd.GoodState.Value;
if (bmd.PostFee != null && bmd.PostFee > 0)
OurPostFee = bmd.PostFee.Value;
GoodsBackType = bmd.BackState;
if (bmd.BackType != null)
{
BackType = bmd.BackType.Value;
if (bmd.BackType == 0)
{
model.Remark = "退款/退货";
}
else if (bmd.BackType == 1)
{
model.Remark = "退款/不退货";
}
else if (bmd.BackType == 2)
{
model.Remark = "部分赔款/不退货";
}
else if (bmd.BackType == 3)
{
model.Remark = "部分赔款/退货";
}
else if (bmd.BackType == 6)
{
model.Remark = "补发配件";
}
}
if (bmd.OrderState != null)
{
BackOrderState = bmd.OrderState.Value;
if (bmd.OrderState == 0)
{
model.Remark += "取消订单收取佣金20%";
}
else if (bmd.OrderState == 1)
{
model.Remark += "订单和佣金正常";
}
}
}
}
var shopmd = slist.Find(n => n.ShopId == md.ShopId);
if (shopmd != null)
{
model.PlatName = shopmd.PlatName + "|" + shopmd.ShopName;
}
else
model.PlatName = "";
model.RevName = md.RevName;
model.RevProvince = md.RevProvince;
model.TrackCode = TrackCode2;// md.TrackCode2;
model.PlatOrderCode = md.PlatOrderCode;
model.JoinOrderCode = md.JoinOrderCode;
model.CountryName = md.CountryName;
model.OrderDate = md.OrderDate.Value.ToString("yyyy-MM-dd");
if (md.PostDate != null)
model.PostDate = md.PostDate.Value.ToString("yyyy-MM-dd");
else
model.PostDate = "";
model.PostInfo = md.PostInfo;
model.GoodsNum = md.GoodsNum;
hjsl += md.GoodsNum.Value;
var gglist = glist.FindAll(n => n.OrderId == md.OrderId);
decimal hwcb = 0;
decimal tc = 0;
decimal sf = 0;
decimal ckfee = 0;//
decimal mdfee = 0;//
decimal adfee = 0;//
decimal DR_BackFee = 0;//
decimal DR_PostFee = 0;//
decimal DR_SSFee = 0;//
//var admd = DataNew.GetModel_OrderFee(md.OrderId.Value);///仓储 面单 广告费
//if (admd != null)
//{
// ckfee = admd.ckfee.Value;
// mdfee = admd.mdfee.Value;
// adfee = admd.adfee.Value;
// DR_BackFee = admd.DR_BackFee.Value;
// DR_PostFee = admd.DR_PostFee.Value;
// DR_SSFee = admd.DR_SSFee.Value;
// Lr -= ckfee;
// Lr -= mdfee;
// Lr -= adfee;
// Lr -= DR_BackFee;
// Lr -= DR_PostFee;
// Lr += DR_SSFee;
//}
string ghtml = "";
if (gglist != null)
{
foreach (var ggmd in gglist)
{
if (ggmd.GoodsFee != null)
{
hwcb += ggmd.GoodsFee.Value;
if (ggmd.FeeRate != null)
sf += ggmd.GoodsFee.Value * ggmd.FeeRate.Value / 100;
}
if (ggmd.TCFee != null)
{
tc += ggmd.TCFee.Value;
}
decimal hwcb2 = 0;
if (ggmd.GoodsFee != null && ggmd.GoodsNum != null && ggmd.GoodsNum.Value > 0)
hwcb2 = ggmd.GoodsFee.Value / ggmd.GoodsNum.Value;
ghtml += "<a gid='" + ggmd.Id + "' gcb='" + hwcb2 + "'>" + ggmd.GoodsCode + "</a>" + ggmd.TypeDesc + "数量:" + ggmd.GoodsNum + "";
if (ggmd.GoodsFee != null)
{
ghtml += "成本:" + (ggmd.GoodsFee.Value / USDRate).ToString("0.00") + "";
}
else
ghtml += "成本0";
if (ggmd.FeeRate != null)
{
ghtml += "税率:" + ggmd.FeeRate.Value + "%";
// if (ggmd.GoodsFee != null)
// ghtml += "税费:" + (ggmd.GoodsFee.Value * ggmd.FeeRate.Value / 100 / USDRate).ToString("0.00") +"";
// else
// ghtml += "税费0";
}
else
{
ghtml += "税率0";
// ghtml += "税费0";
}
//if (ggmd.TCFee != null)
//{
// ghtml += "头程:" + ggmd.TCFee.Value.ToString("0.00") + "<br/>";
//}
//else
// ghtml += "头程0<br/>";
if (ggmd.ckfee != null)
ckfee += ggmd.ckfee.Value;
if (ggmd.mdfee != null)
mdfee += ggmd.mdfee.Value;
if (ggmd.adfee != null)
adfee += ggmd.adfee.Value;
Lr -= ckfee;
Lr -= mdfee;
Lr -= adfee;
}
}
model.GoodsCode = ghtml;
Tckfee += ckfee;//
Tmdfee += mdfee;//
Tadfee += adfee;//
if (md.DR_BackFee != null)
DR_BackFee = md.DR_BackFee.Value;
if (md.DR_PostFee != null)
DR_PostFee = md.DR_PostFee.Value;
if (md.DR_SSFee != null)
DR_SSFee = md.DR_SSFee.Value;
Lr -= DR_BackFee;
Lr -= DR_PostFee;
Lr += DR_SSFee;
TDR_BackFee += DR_BackFee;//
TDR_PostFee += DR_PostFee;//
TDR_SSFee += DR_SSFee;//
//if @PlatId=1 set @escrowFee=0.95else if @PlatId=2 or @PlatId=3set @escrowFee=0.85else if @PlatId=5 set @escrowFee=0.9
decimal ptyjrate = 0;
if (md.PlatId == 1)
ptyjrate = Convert.ToDecimal(0.05);
else if (md.PlatId == 2 || md.PlatId == 3 || md.PlatId == 6)
ptyjrate = Convert.ToDecimal(0.15);
else if (md.PlatId == 5)
ptyjrate = Convert.ToDecimal((double)0.1);
else if (md.PlatId == 18)
ptyjrate = Convert.ToDecimal((double)0.06);
if (md.TotalPrice != null)
{
if (md.MoneyCode != "USD")
{
var opmd = mlist.Find(n => n.MCode == md.MoneyCode);
var opmd2 = mlist.Find(n => n.MCode == "USD");
if (opmd != null)
md.TotalPrice = opmd.MRate * md.TotalPrice / opmd2.MRate;
}
if (IsBackOrder == 1 && BackOrderState == 0)//取消订单
{
model.TotalPrice = "0";
model.YJPrice = (md.TotalPrice.Value * ptyjrate * Convert.ToDecimal(0.2)).ToString("0.00");
model.escrowFee = md.escrowFee.Value.ToString("0.00");
decimal yj = md.TotalPrice.Value * ptyjrate * Convert.ToDecimal(0.2);
if (md.PlatId == 15)
yj = (md.TotalPrice.Value * Convert.ToDecimal((double)0.029) + 0.3M) * Convert.ToDecimal(0.2);
Lr -= yj;
Lr -= md.escrowFee.Value;
hj11 += yj;
hj21 += md.escrowFee.Value;
}
else
{
model.TotalPrice = md.TotalPrice.Value.ToString("0.00");
decimal yj = md.TotalPrice.Value * ptyjrate;
if (md.PlatId == 15)
yj = (md.TotalPrice.Value * Convert.ToDecimal((double)0.029) + 0.3M);
model.YJPrice = yj.ToString("0.00");
if (md.PlatId == 15)
model.YJPrice = (md.TotalPrice.Value * Convert.ToDecimal((double)0.029) + 0.3M).ToString("0.00");
model.escrowFee = md.escrowFee.Value.ToString("0.00");
Lr += md.TotalPrice.Value;
Lr -= md.TotalPrice.Value * ptyjrate;
Lr -= md.escrowFee.Value;
hj1 += md.TotalPrice.Value;
hj11 += yj;
hj21 += md.escrowFee.Value;
}
}
else
{
model.TotalPrice = "";
model.YJPrice = "";
model.escrowFee = "";
}
if (IsBackOrder == 1 && (GoodsBackType == 1 || GoodsBackType == 2))//退货已经入库 不计成本
{
model.GoodsFee = "0";
model.Fee1 = "0";
model.Fee3 = "0";
}
else
{
if (md.Fee4 != null) //货物成本
{
model.GoodsFee = md.Fee4.Value.ToString("0.00");
hj2 += md.Fee4.Value;
Lr -= md.Fee4.Value;
}
else
if (hwcb > 0)
{
model.GoodsFee = (hwcb / USDRate).ToString("0.00");
hj2 += hwcb / USDRate;
Lr -= hwcb / USDRate;
}
else
model.GoodsFee = "0";
// html.Append("<td></td>");
if (sf > 0)
{
model.Fee1 = (sf / USDRate).ToString("0.00");
hj3 += sf / USDRate;
Lr -= sf / USDRate;
}
else
model.Fee1 = "";
if (md.Fee3 != null) //头程
{
tc = md.Fee3.Value;
}
if (tc > 0)
{
model.Fee3 = tc.ToString("0.00");
Lr -= tc;
hj4 += tc;
}
else
model.Fee3 = "0";
}
decimal yjyf = 0;
if (md.StoreId == 6 || md.StoreId == 9)
{
if (md.Fee6 != null && md.Fee6 > 0)
yjyf = md.Fee6.Value;
else if (md.Fee7 != null && md.Fee7 > 0)
yjyf = md.Fee7.Value;
else if (md.Fee8 != null && md.Fee8 > 0)
yjyf = md.Fee8.Value;
if (md.Fee6 != null && md.Fee6 > 0 && md.Fee6 < yjyf)
yjyf = md.Fee6.Value;
if (md.Fee7 != null && md.Fee7 > 0 && md.Fee7 < yjyf)
yjyf = md.Fee7.Value;
if (md.Fee8 != null && md.Fee8 > 0 && md.Fee8 < yjyf)
yjyf = md.Fee8.Value;
if (md.RevFax == "Commercial" || md.RevFax == "OFFICE")
{
if (md.Fee6 != null && md.Fee6 > 0 && md.Fee6 < md.Fee7)
{
yjyf = md.Fee6.Value;
}
if (md.Fee7 != null && md.Fee7 > 0 && md.Fee7 < md.Fee6)
{
yjyf = md.Fee7.Value;
}
}
else if (md.RevFax == "Residential" || md.RevFax == "RESIDENTIAL")
{
if (md.Fee6 != null && md.Fee6 > 0 && md.Fee6 < md.Fee8)
{
yjyf = md.Fee8.Value;
}
if (md.Fee8 != null && md.Fee8 > 0 && md.Fee8 < md.Fee6)
{
yjyf = md.Fee8.Value;
}
}
}
else
{
if (md.Fee11 != null && md.Fee11 > 0)
yjyf = md.Fee11.Value;
else if (md.Fee12 != null && md.Fee12 > 0)
yjyf = md.Fee12.Value;
else if (md.Fee13 != null && md.Fee13 > 0)
yjyf = md.Fee13.Value;
if (md.Fee11 != null && md.Fee11 > 0 && md.Fee11 < yjyf)
yjyf = md.Fee6.Value;
if (md.Fee12 != null && md.Fee12 > 0 && md.Fee12 < yjyf)
yjyf = md.Fee12.Value;
if (md.Fee13 != null && md.Fee13 > 0 && md.Fee13 < yjyf)
yjyf = md.Fee13.Value;
if (md.RevFax == "Commercial" || md.RevFax == "OFFICE")
{
if (md.Fee11 != null && md.Fee11 > 0 && md.Fee11 < md.Fee12)
{
yjyf = md.Fee11.Value;
}
if (md.Fee12 != null && md.Fee12 > 0 && md.Fee12 < md.Fee11)
{
yjyf = md.Fee12.Value;
}
}
else if (md.RevFax == "Residential" || md.RevFax == "RESIDENTIAL")
{
if (md.Fee11 != null && md.Fee11 > 0 && md.Fee11 < md.Fee13)
{
yjyf = md.Fee11.Value;
}
if (md.Fee13 != null && md.Fee13 > 0 && md.Fee13 < md.Fee11)
{
yjyf = md.Fee13.Value;
}
}
}
md.Fee2 = yjyf;
if (md.Fee2 != null)
{
model.Fee2 = (md.Fee2.Value).ToString("0.00");
hj51 += md.Fee2.Value;
}
else
model.Fee2 = "0";
if (md.PostFee != null)
{
model.PostFee = (md.PostFee.Value).ToString("0.00");
Lr -= md.PostFee.Value;
hj5 += md.PostFee.Value;
}
else
model.PostFee = "0";
if (md.PostInfo != null && md.PostInfo.Contains("Fedex") && md.PostFee != null)
{
model.Fee4 = (md.PostFee.Value * YJRate / 100).ToString("0.00");
Lr -= md.PostFee.Value * YJRate / 100;
hj6 += md.PostFee.Value * YJRate / 100;
}
else
model.Fee4 = "0";
if (md.GDFee != null)
{
model.GDFee = md.GDFee.Value.ToString("0.00");
Lr -= md.GDFee.Value;
hj7 += md.GDFee.Value;
}
else
model.GDFee = "";
model.BackPostFee = OurPostFee.ToString("0.00");
Lr -= OurPostFee;
hj10 += OurPostFee;
if (IsBackOrder == 1 && PKPrice > 0)
{
model.BackMoney = PKPrice.ToString("0.00");
Lr -= PKPrice;
hj9 += PKPrice;
}
model.CCFee = ckfee.ToString("0.00");
model.MDFee = mdfee.ToString("0.00");
model.GGFee = adfee.ToString("0.00");
model.DR_BackFee = DR_BackFee.ToString("0.00");
model.DR_PostFee = DR_PostFee.ToString("0.00");
model.DR_SSFee = DR_SSFee.ToString("0.00");
model.LRFee = Lr.Value.ToString("0.00");
hj8 += Lr.Value;
if (Lr.Value > 0 && md.TotalPrice != null && md.TotalPrice > 0)
model.LRRate = ((Lr.Value / md.TotalPrice.Value) * 100).ToString("0.00") + "%";
else if (Lr.Value == 0)
model.LRRate = "0%";
if (Lr.Value < 0 && md.TotalPrice != null && md.TotalPrice > 0)
model.LRRate = "-" + ((Lr.Value * -1 / md.TotalPrice.Value) * 100).ToString("0.00") + "%";
if (rowindex > PageSize * (PageIndex - 1) && rowindex <= PageSize * PageIndex)
olist.Add(model);
rowindex++;
}
DT_OrderUserListNew model2 = new DT_OrderUserListNew();
model2.GoodsCode = "合计:";
model2.GoodsNum = hjsl;
model2.TotalPrice = hj1.ToString("0.00");
model2.YJPrice = hj11.ToString("0.00");
model2.GoodsFee = hj2.ToString("0.00");
model2.escrowFee = hj21.ToString("0.00");
model2.Fee1 = hj3.ToString("0.00");
model2.Fee3 = hj4.ToString("0.00");
model2.PostFee = hj5.ToString("0.00");
model2.Fee4 = hj6.ToString("0.00");
model2.BackPostFee = hj10.ToString("0.00");
model2.BackMoney = hj9.ToString("0.00");
model2.LRFee = hj8.ToString("0.00");
model2.CCFee = Tckfee.ToString("0.00");
model2.MDFee = Tmdfee.ToString("0.00");
model2.GGFee = Tadfee.ToString("0.00");
model2.DR_BackFee = TDR_BackFee.ToString("0.00");
model2.DR_PostFee = TDR_PostFee.ToString("0.00");
model2.DR_SSFee = TDR_SSFee.ToString("0.00");
if (hj8 > 0 && hj1 > 0)
model2.LRRate = (hj8 / hj1 * 100).ToString("0.00") + "%";
else if (hj8 == 0)
model2.LRRate = "0%";
else if (hj1 > 0)
model2.LRRate = "<font color='red'>-" + (hj8 * -1 / hj1 * 100).ToString("0.00") + "%<font>";
olist.Add(model2);
// html.Append("<tr class='DataGridRowStyle'><td></td>");
// html.Append("<td></td>");
// html.Append("<td></td>");
// html.Append("<td></td>");
// html.Append("<td></td>");
// html.Append("<td></td>");
// html.Append("<td></td>");
// html.Append("<td></td>");
//model2. 合计:</td>");
// html.Append("<td>" + hj1.ToString("0.00") + "</td>");
// html.Append("<td>" + hj2.ToString("0.00") + "</td>");
// // html.Append("<td></td>");
// html.Append("<td>" + hj3.ToString("0.00") + "</td>");
// html.Append("<td>" + hj4.ToString("0.00") + "</td>");
// html.Append("<td>" + hj51.ToString("0.00") + "</td>");
// html.Append("<td>" + hj5.ToString("0.00") + "</td>");
// html.Append("<td>" + hj6.ToString("0.00") + "</td>");
// html.Append("<td>" + hj7.ToString("0.00") + "</td>");
// html.Append("<td>" + hj8.ToString("0.00") + "</td>");
// if (hj8 > 0)
// html.Append("<td>" + (hj8 / hj1 * 100).ToString("0.00") + "%</td>");
// else if (hj8 == 0)
// html.Append("<td>0%</td>");
// else
// html.Append("<td>-" + (hj8 * -1 / hj1 * 100).ToString("0.00") + "%</td>");
// html.Append("</tr>");
}
JsonModel<List<DT_OrderUserListNew>> resultModel = new JsonModel<List<DT_OrderUserListNew>>();
int RowCount = 0;
resultModel.DataSource = olist;
resultModel.RowCount = rowindex;
return resultModel;
}
catch (Exception ex)
{
ErrorFollow.TraceWrite("GetUserOrderList2", "", ex.Message);
}
return null;
}
#endregion
#region 个人订单列表
[WebMethod(EnableSession = true)]
public string GetUserOrderExcel2(int BJState, int UserId, int OrderState, int PlatId, int ShopId, DateTime? SDate, DateTime? EDate, string GoodsCode, decimal? GDFee, decimal YJRate, string OrderCode, string Name, string TrackCode, int OffType, decimal? Offfee)
{
PagesNew.Login(this.Session);
try
{
int CompanyId = Convert.ToInt32(Session["CompanyId"]);
var obj = new DD_OrderData();
List<DT_OrderUserNew> dlist = null;
var slist = obj.Get_ShopList(CompanyId);
if (UserId > 0)
dlist = DataNew.Get_OrderUser(BJState, CompanyId, OrderState, PlatId, ShopId, UserId, SDate, EDate.Value.AddDays(1), GoodsCode, OrderCode, TrackCode, Name, OffType, Offfee);
else
dlist = DataNew.Get_OrderUser2(BJState, CompanyId, OrderState, PlatId, ShopId, SDate, EDate.Value.AddDays(1), GoodsCode, OrderCode, TrackCode, Name, OffType, Offfee);
List<DT_OrderUserNew> glist = null;
if (UserId > 0)
glist = DataNew.Get_OrderGoods(CompanyId, PlatId, ShopId, UserId, SDate, EDate.Value.AddDays(1), GoodsCode);
else
glist = DataNew.Get_OrderGoods2(CompanyId, PlatId, ShopId, SDate, EDate.Value.AddDays(1), GoodsCode);
// ErrorFollow.TraceWrite("GetUserOrderList2", "", dlist.Count().ToString() + " " + glist.Count().ToString());
if (dlist == null || glist == null)
return null;
decimal USDRate = Convert.ToDecimal(6.5);
var obj2 = new BaseService();
var mlist = obj2.GetMoneyList2();
List<DT_OrderUserListNew> olist = new List<DT_OrderUserListNew>();
int rowindex = 1;
string Ids = "";
string Ids2 = "";
if (dlist != null)
{
foreach (var md in dlist)
{
Ids2 += md.OrderId.Value + ",";
if (md.OrderState2 == 1)
Ids += md.OrderId.Value + ",";
}
}
var backorderlist = new List<DT_OrderBackMoneyApply>();
if (Ids != "")
{
backorderlist = DataNew.GetListOrderBackMoneyApply(Ids.Trim(','));
}
var trackorderlist = new List<DT_TrackCodeApply>();
if (Ids2 != "")
{
trackorderlist = DataNew.GetListOrderTrackCodeApply(Ids2.Trim(','));
}
if (dlist != null)
{
decimal hj1 = 0;
decimal hj11 = 0;
decimal hj21 = 0;
decimal hj2 = 0;
decimal hj3 = 0;
decimal hj4 = 0;
decimal hj5 = 0;
decimal hj51 = 0;
decimal hj6 = 0;
decimal hj7 = 0;
decimal hj8 = 0;
decimal hj9 = 0;//赔款
decimal hj10 = 0;//我们承担运费
decimal Tckfee = 0;//
decimal Tmdfee = 0;//
decimal Tadfee = 0;//
decimal TDR_BackFee = 0;//
decimal TDR_PostFee = 0;//
decimal TDR_SSFee = 0;//
int hjsl = 0;
foreach (var md in dlist)
{
var mmd = mlist.Find(n => n.PlatId == md.PlatId && n.MCode == "USD");
if (mmd != null)
USDRate = mmd.MRate.Value;
decimal? Lr = 0;
DT_OrderUserListNew model = new DT_OrderUserListNew();
model.BJState = md.BJState;
model.OrderId = md.OrderId;
model.StateName = "正常订单";
int BackType = 0;//退款类型
int BackOrderState = 0;//订单类型
int? GoodsBackType = 0;//退款类型
int IsBackOrder = 0;//是否退货订单
int GoodsState = 0;//是否退货订单
decimal PKPrice = 0;//赔款金额
decimal OurPostFee = 0;//退货运费
string TrackCode2 = "";
if (trackorderlist != null && trackorderlist.Count > 0)
{
var tlist = trackorderlist.FindAll(n => n.OrderId == md.OrderId);
if (tlist != null)
{
foreach (var tmd in tlist)
{
TrackCode2 += tmd.TrackCode + ",";
}
}
}
if (md.OrderState2 == 1 && backorderlist != null)
{
var bmd = backorderlist.Find(n => n.OrderId == md.OrderId);
if (bmd != null)
{
IsBackOrder = 1;
model.StateName = "退货赔款订单";
// <option value="0">退款退货</option>
//<option value="1">退款不退货</option>
//<option value="2">赔款不退货</option>
//<option value="3">赔款退货</option>
// <option value="0">取消订单收取佣金20%</option>
//<option value="1">订单和佣金正常</option>
if (bmd.FactPrice != null)
PKPrice = bmd.FactPrice.Value;
if (bmd.GoodState != null)
GoodsState = bmd.GoodState.Value;
if (bmd.PostFee != null && bmd.PostFee > 0)
OurPostFee = bmd.PostFee.Value;
GoodsBackType = bmd.BackState;
if (bmd.BackType != null)
{
BackType = bmd.BackType.Value;
if (bmd.BackType == 0)
{
model.Remark = "退款/退货";
}
else if (bmd.BackType == 1)
{
model.Remark = "退款/不退货";
}
else if (bmd.BackType == 2)
{
model.Remark = "部分赔款/不退货";
}
else if (bmd.BackType == 3)
{
model.Remark = "部分赔款/退货";
}
else if (bmd.BackType == 6)
{
model.Remark = "补发配件";
}
}
if (bmd.OrderState != null)
{
BackOrderState = bmd.OrderState.Value;
if (bmd.OrderState == 0)
{
model.Remark += "取消订单收取佣金20%";
}
else if (bmd.OrderState == 1)
{
model.Remark += "订单和佣金正常";
}
}
}
}
var shopmd = slist.Find(n => n.ShopId == md.ShopId);
if (shopmd != null)
{
model.PlatName = shopmd.PlatName + "|" + shopmd.ShopName;
}
else
model.PlatName = "";
model.RevName = md.RevName;
model.RevProvince = md.RevProvince;
model.TrackCode = TrackCode2;// md.TrackCode2;
model.PlatOrderCode = md.PlatOrderCode;
model.JoinOrderCode = md.JoinOrderCode;
model.CountryName = md.CountryName;
model.OrderDate = md.OrderDate.Value.ToString("yyyy-MM-dd");
if (md.PostDate != null)
model.PostDate = md.PostDate.Value.ToString("yyyy-MM-dd");
else
model.PostDate = "";
model.PostInfo = md.PostInfo;
model.GoodsNum = md.GoodsNum;
hjsl += md.GoodsNum.Value;
var gglist = glist.FindAll(n => n.OrderId == md.OrderId);
decimal hwcb = 0;
decimal tc = 0;
decimal sf = 0;
decimal ckfee = 0;//
decimal mdfee = 0;//
decimal adfee = 0;//
decimal DR_BackFee = 0;//
decimal DR_PostFee = 0;//
decimal DR_SSFee = 0;//
//var admd = DataNew.GetModel_OrderFee(md.OrderId.Value);///仓储 面单 广告费
//if (admd != null)
//{
// ckfee = admd.ckfee.Value;
// mdfee = admd.mdfee.Value;
// adfee = admd.adfee.Value;
// DR_BackFee = admd.DR_BackFee.Value;
// DR_PostFee = admd.DR_PostFee.Value;
// DR_SSFee = admd.DR_SSFee.Value;
// Lr -= ckfee;
// Lr -= mdfee;
// Lr -= adfee;
// Lr -= DR_BackFee;
// Lr -= DR_PostFee;
// Lr += DR_SSFee;
//}
string ghtml = "";
if (gglist != null)
{
foreach (var ggmd in gglist)
{
if (ggmd.GoodsFee != null)
{
hwcb += ggmd.GoodsFee.Value;
if (ggmd.FeeRate != null)
sf += ggmd.GoodsFee.Value * ggmd.FeeRate.Value / 100;
}
if (ggmd.TCFee != null)
{
tc += ggmd.TCFee.Value;
}
decimal hwcb2 = 0;
if (ggmd.GoodsFee != null && ggmd.GoodsNum != null && ggmd.GoodsNum.Value > 0)
hwcb2 = ggmd.GoodsFee.Value / ggmd.GoodsNum.Value;
ghtml += ggmd.GoodsCode + " " + ggmd.TypeDesc + " 数量:" + ggmd.GoodsNum;
//if (ggmd.TCFee != null)
//{
// ghtml += "头程:" + ggmd.TCFee.Value.ToString("0.00") + "<br/>";
//}
//else
// ghtml += "头程0<br/>";
if (ggmd.ckfee != null)
ckfee += ggmd.ckfee.Value;
if (ggmd.mdfee != null)
mdfee += ggmd.mdfee.Value;
if (ggmd.adfee != null)
adfee += ggmd.adfee.Value;
Lr -= ckfee;
Lr -= mdfee;
Lr -= adfee;
model.SortName = ggmd.SortName;
}
}
model.GoodsCode = ghtml;
Tckfee += ckfee;//
Tmdfee += mdfee;//
Tadfee += adfee;//
if (md.DR_BackFee != null)
DR_BackFee = md.DR_BackFee.Value;
if (md.DR_PostFee != null)
DR_PostFee = md.DR_PostFee.Value;
if (md.DR_SSFee != null)
DR_SSFee = md.DR_SSFee.Value;
Lr -= DR_BackFee;
Lr -= DR_PostFee;
Lr += DR_SSFee;
TDR_BackFee += DR_BackFee;//
TDR_PostFee += DR_PostFee;//
TDR_SSFee += DR_SSFee;//
//if @PlatId=1 set @escrowFee=0.95else if @PlatId=2 or @PlatId=3set @escrowFee=0.85else if @PlatId=5 set @escrowFee=0.9
decimal ptyjrate = 0;
if (md.PlatId == 1)
ptyjrate = Convert.ToDecimal(0.05);
else if (md.PlatId == 2 || md.PlatId == 3 || md.PlatId == 6)
ptyjrate = Convert.ToDecimal(0.15);
else if (md.PlatId == 5)
ptyjrate = Convert.ToDecimal((double)0.1);
else if (md.PlatId == 18)
ptyjrate = Convert.ToDecimal((double)0.06);
if (md.TotalPrice != null)
{
if (md.MoneyCode != "USD")
{
var opmd = mlist.Find(n => n.MCode == md.MoneyCode);
var opmd2 = mlist.Find(n => n.MCode == "USD");
if (opmd != null)
md.TotalPrice = opmd.MRate * md.TotalPrice / opmd2.MRate;
}
if (IsBackOrder == 1 && BackOrderState == 0)//取消订单
{
model.TotalPrice = "0";
model.YJPrice = (md.TotalPrice.Value * ptyjrate * Convert.ToDecimal(0.2)).ToString("0.00");
model.escrowFee = md.escrowFee.Value.ToString("0.00");
decimal yj = md.TotalPrice.Value * ptyjrate * Convert.ToDecimal(0.2);
if (md.PlatId == 15)
yj = (md.TotalPrice.Value * Convert.ToDecimal((double)0.029) + 0.3M) * Convert.ToDecimal(0.2);
Lr -= yj;
Lr -= md.escrowFee.Value;
hj11 += yj;
hj21 += md.escrowFee.Value;
}
else
{
model.TotalPrice = md.TotalPrice.Value.ToString("0.00");
decimal yj = md.TotalPrice.Value * ptyjrate;
if (md.PlatId == 15)
yj = (md.TotalPrice.Value * Convert.ToDecimal((double)0.029) + 0.3M);
model.YJPrice = yj.ToString("0.00");
if (md.PlatId == 15)
model.YJPrice = (md.TotalPrice.Value * Convert.ToDecimal((double)0.029) + 0.3M).ToString("0.00");
model.escrowFee = md.escrowFee.Value.ToString("0.00");
Lr += md.TotalPrice.Value;
Lr -= md.TotalPrice.Value * ptyjrate;
Lr -= md.escrowFee.Value;
hj1 += md.TotalPrice.Value;
hj11 += yj;
hj21 += md.escrowFee.Value;
}
}
else
{
model.TotalPrice = "";
model.YJPrice = "";
model.escrowFee = "";
}
if (IsBackOrder == 1 && (GoodsBackType == 1 || GoodsBackType == 2))//退货已经入库 不计成本
{
model.GoodsFee = "0";
model.Fee1 = "0";
model.Fee3 = "0";
}
else
{
if (md.Fee4 != null) //货物成本
{
model.GoodsFee = md.Fee4.Value.ToString("0.00");
hj2 += md.Fee4.Value;
Lr -= md.Fee4.Value;
}
else
if (hwcb > 0)
{
model.GoodsFee = (hwcb / USDRate).ToString("0.00");
hj2 += hwcb / USDRate;
Lr -= hwcb / USDRate;
}
else
model.GoodsFee = "0";
// html.Append("<td></td>");
if (sf > 0)
{
model.Fee1 = (sf / USDRate).ToString("0.00");
hj3 += sf / USDRate;
Lr -= sf / USDRate;
}
else
model.Fee1 = "";
if (md.Fee3 != null) //头程
{
tc = md.Fee3.Value;
}
if (tc > 0)
{
model.Fee3 = tc.ToString("0.00");
Lr -= tc;
hj4 += tc;
}
else
model.Fee3 = "0";
}
decimal yjyf = 0;
if (md.StoreId == 6 || md.StoreId == 9)
{
if (md.Fee6 != null && md.Fee6 > 0)
yjyf = md.Fee6.Value;
else if (md.Fee7 != null && md.Fee7 > 0)
yjyf = md.Fee7.Value;
else if (md.Fee8 != null && md.Fee8 > 0)
yjyf = md.Fee8.Value;
if (md.Fee6 != null && md.Fee6 > 0 && md.Fee6 < yjyf)
yjyf = md.Fee6.Value;
if (md.Fee7 != null && md.Fee7 > 0 && md.Fee7 < yjyf)
yjyf = md.Fee7.Value;
if (md.Fee8 != null && md.Fee8 > 0 && md.Fee8 < yjyf)
yjyf = md.Fee8.Value;
if (md.RevFax == "Commercial" || md.RevFax == "OFFICE")
{
if (md.Fee6 != null && md.Fee6 > 0 && md.Fee6 < md.Fee7)
{
yjyf = md.Fee6.Value;
}
if (md.Fee7 != null && md.Fee7 > 0 && md.Fee7 < md.Fee6)
{
yjyf = md.Fee7.Value;
}
}
else if (md.RevFax == "Residential" || md.RevFax == "RESIDENTIAL")
{
if (md.Fee6 != null && md.Fee6 > 0 && md.Fee6 < md.Fee8)
{
yjyf = md.Fee8.Value;
}
if (md.Fee8 != null && md.Fee8 > 0 && md.Fee8 < md.Fee6)
{
yjyf = md.Fee8.Value;
}
}
}
else
{
if (md.Fee11 != null && md.Fee11 > 0)
yjyf = md.Fee11.Value;
else if (md.Fee12 != null && md.Fee12 > 0)
yjyf = md.Fee12.Value;
else if (md.Fee13 != null && md.Fee13 > 0)
yjyf = md.Fee13.Value;
if (md.Fee11 != null && md.Fee11 > 0 && md.Fee11 < yjyf)
yjyf = md.Fee6.Value;
if (md.Fee12 != null && md.Fee12 > 0 && md.Fee12 < yjyf)
yjyf = md.Fee12.Value;
if (md.Fee13 != null && md.Fee13 > 0 && md.Fee13 < yjyf)
yjyf = md.Fee13.Value;
if (md.RevFax == "Commercial" || md.RevFax == "OFFICE")
{
if (md.Fee11 != null && md.Fee11 > 0 && md.Fee11 < md.Fee12)
{
yjyf = md.Fee11.Value;
}
if (md.Fee12 != null && md.Fee12 > 0 && md.Fee12 < md.Fee11)
{
yjyf = md.Fee12.Value;
}
}
else if (md.RevFax == "Residential" || md.RevFax == "RESIDENTIAL")
{
if (md.Fee11 != null && md.Fee11 > 0 && md.Fee11 < md.Fee13)
{
yjyf = md.Fee11.Value;
}
if (md.Fee13 != null && md.Fee13 > 0 && md.Fee13 < md.Fee11)
{
yjyf = md.Fee13.Value;
}
}
}
md.Fee2 = yjyf;
if (md.Fee2 != null)
{
model.Fee2 = (md.Fee2.Value).ToString("0.00");
hj51 += md.Fee2.Value;
}
else
model.Fee2 = "0";
if (md.PostFee != null)
{
model.PostFee = (md.PostFee.Value).ToString("0.00");
Lr -= md.PostFee.Value;
hj5 += md.PostFee.Value;
}
else
model.PostFee = "0";
if (md.PostInfo != null && md.PostInfo.Contains("Fedex") && md.PostFee != null)
{
model.Fee4 = (md.PostFee.Value * YJRate / 100).ToString("0.00");
Lr -= md.PostFee.Value * YJRate / 100;
hj6 += md.PostFee.Value * YJRate / 100;
}
else
model.Fee4 = "0";
if (md.GDFee != null)
{
model.GDFee = md.GDFee.Value.ToString("0.00");
Lr -= md.GDFee.Value;
hj7 += md.GDFee.Value;
}
else
model.GDFee = "";
model.BackPostFee = OurPostFee.ToString("0.00");
Lr -= OurPostFee;
hj10 += OurPostFee;
if (IsBackOrder == 1 && PKPrice > 0)
{
model.BackMoney = PKPrice.ToString("0.00");
Lr -= PKPrice;
hj9 += PKPrice;
}
model.CCFee = ckfee.ToString("0.00");
model.MDFee = mdfee.ToString("0.00");
model.GGFee = adfee.ToString("0.00");
model.DR_BackFee = DR_BackFee.ToString("0.00");
model.DR_PostFee = DR_PostFee.ToString("0.00");
model.DR_SSFee = DR_SSFee.ToString("0.00");
model.LRFee = Lr.Value.ToString("0.00");
hj8 += Lr.Value;
if (Lr.Value > 0 && md.TotalPrice != null && md.TotalPrice > 0)
model.LRRate = ((Lr.Value / md.TotalPrice.Value) * 100).ToString("0.00") + "%";
else if (Lr.Value == 0)
model.LRRate = "0%";
if (Lr.Value < 0 && md.TotalPrice != null && md.TotalPrice > 0)
model.LRRate = "-" + ((Lr.Value * -1 / md.TotalPrice.Value) * 100).ToString("0.00") + "%";
olist.Add(model);
rowindex++;
}
DT_OrderUserListNew model2 = new DT_OrderUserListNew();
model2.GoodsCode = "合计:";
model2.GoodsNum = hjsl;
model2.TotalPrice = hj1.ToString("0.00");
model2.YJPrice = hj11.ToString("0.00");
model2.GoodsFee = hj2.ToString("0.00");
model2.escrowFee = hj21.ToString("0.00");
model2.Fee1 = hj3.ToString("0.00");
model2.Fee3 = hj4.ToString("0.00");
model2.PostFee = hj5.ToString("0.00");
model2.Fee4 = hj6.ToString("0.00");
model2.BackPostFee = hj10.ToString("0.00");
model2.BackMoney = hj9.ToString("0.00");
model2.LRFee = hj8.ToString("0.00");
model2.CCFee = Tckfee.ToString("0.00");
model2.MDFee = Tmdfee.ToString("0.00");
model2.GGFee = Tadfee.ToString("0.00");
model2.DR_BackFee = TDR_BackFee.ToString("0.00");
model2.DR_PostFee = TDR_PostFee.ToString("0.00");
model2.DR_SSFee = TDR_SSFee.ToString("0.00");
if (hj8 > 0 && hj1 > 0)
model2.LRRate = (hj8 / hj1 * 100).ToString("0.00") + "%";
else if (hj8 == 0)
model2.LRRate = "0%";
else if (hj1 > 0)
model2.LRRate = "<font color='red'>-" + (hj8 * -1 / hj1 * 100).ToString("0.00") + "%<font>";
olist.Add(model2);
}
if (olist == null)
return "";
DataTable tb = olist.ToDataTable<DT_OrderUserListNew>();
TableColumnCollection listColumns = new TableColumnCollection();
listColumns.Add("PlatName", "平台|店铺", DbType.String, "");
listColumns.Add("PlatOrderCode", "订单号", DbType.String, "");
listColumns.Add("CountryName", "国家", DbType.String, "");
listColumns.Add("RevProvince", "州省", DbType.String, "");
listColumns.Add("OrderDate", "订单日期", DbType.String, "");
listColumns.Add("PostDate", "发货日期", DbType.String, "");
listColumns.Add("RevName", "收件人", DbType.String, "");
listColumns.Add("PostInfo", "物流方式", DbType.String, "");
listColumns.Add("TrackCode", "跟踪码", DbType.String, "");
listColumns.Add("SortName", "产品分类", DbType.String, "");
listColumns.Add("GoodsCode", "货物编号", DbType.String, "");
listColumns.Add("GoodsNum", "货物数量", DbType.String, "");
listColumns.Add("TotalPrice", "订单金额$", DbType.String, "");
listColumns.Add("YJPrice", "佣金$", DbType.String, "");
listColumns.Add("escrowFee", "税费$", DbType.String, "");
listColumns.Add("GoodsFee", "货物成本", DbType.String, "");
listColumns.Add("Fee1", "关税", DbType.String, "");
listColumns.Add("Fee3", "头程费用", DbType.String, "");
listColumns.Add("Fee2", "预估运费", DbType.String, "");
listColumns.Add("PostFee", "运费", DbType.String, "");
listColumns.Add("Fee4", "运费佣金", DbType.String, "");
listColumns.Add("BackPostFee", "我们承担的运费", DbType.String, "");
listColumns.Add("GDFee", "固定成本", DbType.String, "");
listColumns.Add("CCFee", "仓储费", DbType.String, "");
listColumns.Add("MDFee", "面单费", DbType.String, "");
listColumns.Add("GGFee", "广告费", DbType.String, "");
listColumns.Add("DR_BackFee", "退款费", DbType.String, "");
listColumns.Add("DR_PostFee", "退货运费", DbType.String, "");
listColumns.Add("DR_SSFee", "物流申诉费", DbType.String, "");
listColumns.Add("LRRate", "利润率", DbType.String, "");
MicrosoftExcel obj3 = new MicrosoftExcel();
return obj3.Export(tb, listColumns);
}
catch (Exception ex)
{
ErrorFollow.TraceWrite("GetUserOrderList2", "", ex.Message);
}
return null;
}
#endregion
private string Excelout(DataTable ds, string path)
{
try
{
long totalCount = ds.Rows.Count;
long rowRead = 0;
float percent = 0;
StreamWriter sw = new StreamWriter(path, true, Encoding.GetEncoding("gb2312"));
StringBuilder sb = new StringBuilder();
for (int k = 0; k < ds.Columns.Count; k++)
{
sb.Append(ds.Columns[k].ColumnName.ToString() + "\t");
}
sb.Append(Environment.NewLine);
for (int i = 0; i < ds.Rows.Count; i++)
{
rowRead++;
percent = ((float)(100 * rowRead)) / totalCount;
// textBox1.Text = "正在写入[" + percent.ToString("0.00") + "%]...的数据";
//System.Windows.Forms.Application.DoEvents();
// DateTime time = DateTime.Now;
// sb.Append(time.ToString("HH:mm:ss") + "\t");
for (int j = 0; j < ds.Columns.Count; j++)
{
//if (ds.Rows[i][j] == null)
//{
// sb.Append("\t");
//}
//else
//{
string pattern = "^[0-9]*$";
Regex rx = new Regex(pattern);
string zz = ds.Rows[i][j].ToString().Replace(Environment.NewLine, "");
if (zz.Length > 10)
{
bool a = rx.IsMatch(zz); //bool类型
if (a == true)
zz = "'" + zz;
}
sb.Append(zz + "\t");
//}
}
sb.Append(Environment.NewLine);
}
sw.WriteLine(sb.ToString());
sw.Flush();
sw.Close();
return "";
//MessageBox.Show("已经生成指定Excel文件!");
}
catch (Exception ex)
{
return ex.Message;
// MessageBox.Show(ex.Message);
}
}
#region 个人订单列表
[WebMethod(EnableSession = true)]
public JsonModel<List<DT_OrderUserListNew>> GetUserOrderList22222(int BJState, int UserId, int OrderState, int PlatId, int ShopId, DateTime? SDate, DateTime? EDate, string GoodsCode, decimal? GDFee, decimal YJRate, string OrderCode, string Name, string TrackCode,int OffType,decimal? Offfee, int PageSize, int PageIndex)
{
PagesNew.Login(this.Session);
try
{
int CompanyId = Convert.ToInt32(Session["CompanyId"]);
var obj = new DD_OrderData();
List<DT_OrderUserNew> dlist = null;
var slist = obj.Get_ShopList(CompanyId);
if (UserId > 0)
dlist = DataNew.Get_OrderUser(BJState, CompanyId, OrderState, PlatId, ShopId, UserId, SDate, EDate.Value.AddDays(1), GoodsCode, OrderCode, TrackCode, Name,OffType, Offfee);
else
dlist = DataNew.Get_OrderUser2(BJState, CompanyId, OrderState, PlatId, ShopId, SDate, EDate.Value.AddDays(1), GoodsCode, OrderCode, TrackCode, Name, OffType, Offfee);
List<DT_OrderUser> glist = null;
if (UserId > 0)
glist = obj.Get_OrderGoods(CompanyId, PlatId, ShopId, UserId, SDate, EDate.Value.AddDays(1), GoodsCode);
else
glist = obj.Get_OrderGoods2(CompanyId, PlatId, ShopId, SDate, EDate.Value.AddDays(1), GoodsCode);
// ErrorFollow.TraceWrite("GetUserOrderList2", "", dlist.Count().ToString() + " " + glist.Count().ToString());
if (dlist == null || glist == null)
return null;
decimal USDRate = Convert.ToDecimal(6.5);
var obj2 = new BaseService();
var mlist = obj2.GetMoneyList2();
List<DT_OrderUserListNew> olist = new List<DT_OrderUserListNew>();
int rowindex = 1;
string Ids = "";
string Ids2 = "";
if (dlist != null)
{
foreach (var md in dlist)
{
Ids2 += md.OrderId.Value + ",";
if (md.OrderState2 == 1)
Ids += md.OrderId.Value + ",";
}
}
var backorderlist = new List<DT_OrderBackMoneyApply>();
if (Ids != "")
{
backorderlist = DataNew.GetListOrderBackMoneyApply(Ids.Trim(','));
}
var trackorderlist = new List<DT_TrackCodeApply>();
if (Ids2 != "")
{
trackorderlist = DataNew.GetListOrderTrackCodeApply(Ids2.Trim(','));
}
if (dlist != null)
{
decimal hj1 = 0;
decimal hj11 = 0;
decimal hj21 = 0;
decimal hj2 = 0;
decimal hj3 = 0;
decimal hj4 = 0;
decimal hj5 = 0;
decimal hj51 = 0;
decimal hj6 = 0;
decimal hj7 = 0;
decimal hj8 = 0;
decimal hj9 = 0;//赔款
decimal hj10 = 0;//我们承担运费
int hjsl = 0;
foreach (var md in dlist)
{
var mmd = mlist.Find(n => n.PlatId == md.PlatId && n.MCode == "USD");
if (mmd != null)
USDRate = mmd.MRate.Value;
decimal? Lr = 0;
DT_OrderUserListNew model = new DT_OrderUserListNew();
model.BJState = md.BJState;
model.OrderId = md.OrderId;
model.StateName = "正常订单";
int BackType = 0;//退款类型
int BackOrderState = 0;//订单类型
int? GoodsBackType = 0;//退款类型
int IsBackOrder = 0;//是否退货订单
int GoodsState = 0;//是否退货订单
decimal PKPrice = 0;//赔款金额
decimal OurPostFee = 0;//退货运费
string TrackCode2 = "";
if (trackorderlist != null && trackorderlist.Count > 0)
{
var tlist = trackorderlist.FindAll(n => n.OrderId == md.OrderId);
if (tlist != null)
{
foreach (var tmd in tlist)
{
TrackCode2 += tmd.TrackCode + "<br/>";
}
}
}
if (md.OrderState2 == 1 && backorderlist != null)
{
var bmd = backorderlist.Find(n => n.OrderId == md.OrderId);
if (bmd != null)
{
IsBackOrder = 1;
model.StateName = "退货赔款订单";
// <option value="0">退款退货</option>
//<option value="1">退款不退货</option>
//<option value="2">赔款不退货</option>
//<option value="3">赔款退货</option>
// <option value="0">取消订单收取佣金20%</option>
//<option value="1">订单和佣金正常</option>
if (bmd.FactPrice != null)
PKPrice = bmd.FactPrice.Value;
if (bmd.GoodState != null)
GoodsState = bmd.GoodState.Value;
if (bmd.PostFee != null && bmd.PostFee > 0)
OurPostFee = bmd.PostFee.Value;
GoodsBackType = bmd.BackState;
if (bmd.BackType != null)
{
BackType = bmd.BackType.Value;
if (bmd.BackType == 0)
{
model.Remark = "退款/退货";
}
else if (bmd.BackType == 1)
{
model.Remark = "退款/不退货";
}
else if (bmd.BackType == 2)
{
model.Remark = "部分赔款/不退货";
}
else if (bmd.BackType == 3)
{
model.Remark = "部分赔款/不退货";
}
else if (bmd.BackType == 6)
{
model.Remark = "补发配件";
}
}
if (bmd.OrderState != null)
{
BackOrderState = bmd.OrderState.Value;
if (bmd.OrderState == 0)
{
model.Remark += "取消订单收取佣金20%";
}
else if (bmd.OrderState == 1)
{
model.Remark += "订单和佣金正常";
}
}
}
}
var shopmd = slist.Find(n => n.ShopId == md.ShopId);
if (shopmd != null)
{
model.PlatName = shopmd.PlatName + "|" + shopmd.ShopName;
}
else
model.PlatName = "";
model.RevName = md.RevName;
model.RevProvince = md.RevProvince;
model.TrackCode = TrackCode2;// md.TrackCode2;
model.PlatOrderCode = md.PlatOrderCode;
model.JoinOrderCode = md.JoinOrderCode;
model.CountryName = md.CountryName;
model.OrderDate = md.OrderDate.Value.ToString("yyyy-MM-dd");
if (md.PostDate != null)
model.PostDate = md.PostDate.Value.ToString("yyyy-MM-dd");
else
model.PostDate = "";
model.PostInfo = md.PostInfo;
model.GoodsNum = md.GoodsNum;
hjsl += md.GoodsNum.Value;
var gglist = glist.FindAll(n => n.OrderId == md.OrderId);
decimal hwcb = 0;
decimal tc = 0;
decimal sf = 0;
string ghtml = "";
if (gglist != null)
{
foreach (var ggmd in gglist)
{
if (ggmd.GoodsFee != null)
{
hwcb += ggmd.GoodsFee.Value;
if (ggmd.FeeRate != null)
sf += ggmd.GoodsFee.Value * ggmd.FeeRate.Value / 100;
}
if (ggmd.TCFee != null)
{
tc += ggmd.TCFee.Value;
}
decimal hwcb2 = 0;
if (ggmd.GoodsFee != null && ggmd.GoodsNum != null && ggmd.GoodsNum.Value > 0)
hwcb2 = ggmd.GoodsFee.Value / ggmd.GoodsNum.Value;
ghtml += "<a gid='" + ggmd.Id + "' gcb='" + hwcb2 + "'>" + ggmd.GoodsCode + "</a>" + ggmd.TypeDesc + "数量:" + ggmd.GoodsNum + "";
if (ggmd.GoodsFee != null)
{
ghtml += "成本:" + (ggmd.GoodsFee.Value / USDRate).ToString("0.00") + "";
}
else
ghtml += "成本0";
if (ggmd.FeeRate != null)
{
ghtml += "税率:" + ggmd.FeeRate.Value + "%";
// if (ggmd.GoodsFee != null)
// ghtml += "税费:" + (ggmd.GoodsFee.Value * ggmd.FeeRate.Value / 100 / USDRate).ToString("0.00") +"";
// else
// ghtml += "税费0";
}
else
{
ghtml += "税率0";
// ghtml += "税费0";
}
//if (ggmd.TCFee != null)
//{
// ghtml += "头程:" + ggmd.TCFee.Value.ToString("0.00") + "<br/>";
//}
//else
// ghtml += "头程0<br/>";
}
}
model.GoodsCode = ghtml;
//if @PlatId=1 set @escrowFee=0.95else if @PlatId=2 or @PlatId=3set @escrowFee=0.85else if @PlatId=5 set @escrowFee=0.9
decimal ptyjrate = 0;
if (md.PlatId == 1)
ptyjrate = Convert.ToDecimal(0.05);
else if (md.PlatId == 2 || md.PlatId == 3 || md.PlatId == 6)
ptyjrate = Convert.ToDecimal(0.15);
else if (md.PlatId == 5)
ptyjrate = Convert.ToDecimal(0.1);
if (md.TotalPrice != null)
{
if (md.MoneyCode != "USD")
{
var opmd = mlist.Find(n => n.MCode == md.MoneyCode);
var opmd2 = mlist.Find(n => n.MCode == "USD");
if (opmd != null)
md.TotalPrice = opmd.MRate * md.TotalPrice / opmd2.MRate;
}
if (IsBackOrder == 1 && BackOrderState == 0)//取消订单
{
model.TotalPrice = "0";
model.YJPrice = (md.TotalPrice.Value * ptyjrate * Convert.ToDecimal(0.2)).ToString("0.00");
model.escrowFee = md.escrowFee.Value.ToString("0.00");
Lr -= md.TotalPrice.Value * ptyjrate * Convert.ToDecimal(0.2);
Lr -= md.escrowFee.Value;
hj11 += md.TotalPrice.Value * ptyjrate * Convert.ToDecimal(0.2);
hj21 += md.escrowFee.Value;
}
else
{
model.TotalPrice = md.TotalPrice.Value.ToString("0.00");
model.YJPrice = (md.TotalPrice.Value * ptyjrate).ToString("0.00");
model.escrowFee = md.escrowFee.Value.ToString("0.00");
Lr += md.TotalPrice.Value;
Lr -= md.TotalPrice.Value * ptyjrate;
Lr -= md.escrowFee.Value;
hj1 += md.TotalPrice.Value;
hj11 += md.TotalPrice.Value * ptyjrate;
hj21 += md.escrowFee.Value;
}
}
else
{
model.TotalPrice = "";
model.YJPrice = "";
model.escrowFee = "";
}
if (IsBackOrder == 1 && (GoodsBackType == 1 || GoodsBackType == 2))//退货已经入库 不计成本
{
model.GoodsFee = "0";
model.Fee1 = "0";
model.Fee3 = "0";
}
else
{
if (md.Fee4 != null) //货物成本
{
model.GoodsFee = md.Fee4.Value.ToString("0.00");
hj2 += md.Fee4.Value;
Lr -= md.Fee4.Value;
}
else
if (hwcb > 0)
{
model.GoodsFee = (hwcb / USDRate).ToString("0.00");
hj2 += hwcb / USDRate;
Lr -= hwcb / USDRate;
}
else
model.GoodsFee = "0";
// html.Append("<td></td>");
if (sf > 0)
{
model.Fee1 = (sf / USDRate).ToString("0.00");
hj3 += sf / USDRate;
Lr -= sf / USDRate;
}
else
model.Fee1 = "";
if (md.Fee3 != null) //头程
{
tc = md.Fee3.Value;
}
if (tc > 0)
{
model.Fee3 = tc.ToString("0.00");
Lr -= tc;
hj4 += tc;
}
else
model.Fee3 = "0";
}
decimal yjyf = 0;
if (md.Fee6 != null && md.Fee6 > 0)
yjyf = md.Fee6.Value;
else if (md.Fee7 != null && md.Fee7 > 0)
yjyf = md.Fee7.Value;
else if (md.Fee8 != null && md.Fee8 > 0)
yjyf = md.Fee8.Value;
if (md.Fee6 != null && md.Fee6 > 0 && md.Fee6 < yjyf)
yjyf = md.Fee6.Value;
if (md.Fee7 != null && md.Fee7 > 0 && md.Fee7 < yjyf)
yjyf = md.Fee7.Value;
if (md.Fee8 != null && md.Fee8 > 0 && md.Fee8 < yjyf)
yjyf = md.Fee8.Value;
md.Fee2 = yjyf;
if (md.Fee2 != null)
{
model.Fee2 = (md.Fee2.Value).ToString("0.00");
hj51 += md.Fee2.Value;
}
else
model.Fee2 = "0";
if (md.PostFee != null)
{
model.PostFee = (md.PostFee.Value).ToString("0.00");
Lr -= md.PostFee.Value;
hj5 += md.PostFee.Value;
}
else
model.PostFee = "0";
if (md.PostInfo != null && md.PostInfo.Contains("Fedex") && md.PostFee != null)
{
model.Fee4 = (md.PostFee.Value * YJRate / 100).ToString("0.00");
Lr -= md.PostFee.Value * YJRate / 100;
hj6 += md.PostFee.Value * YJRate / 100;
}
else
model.Fee4 = "0";
if (md.GDFee != null)
{
model.GDFee = md.GDFee.Value.ToString("0.00");
Lr -= md.GDFee.Value;
hj7 += md.GDFee.Value;
}
else
model.GDFee = "";
model.BackPostFee = OurPostFee.ToString("0.00");
Lr -= OurPostFee;
hj10 += OurPostFee;
if (IsBackOrder == 1 && PKPrice > 0)
{
model.BackMoney = PKPrice.ToString("0.00");
Lr -= PKPrice;
hj9 += PKPrice;
}
model.LRFee = Lr.Value.ToString("0.00");
hj8 += Lr.Value;
if (Lr.Value > 0 && md.TotalPrice != null && md.TotalPrice > 0)
model.LRRate = ((Lr.Value / md.TotalPrice.Value) * 100).ToString("0.00") + "%";
else if (Lr.Value == 0)
model.LRRate = "0%";
if (Lr.Value < 0 && md.TotalPrice != null && md.TotalPrice > 0)
model.LRRate = "-" + ((Lr.Value * -1 / md.TotalPrice.Value) * 100).ToString("0.00") + "%";
if (rowindex > PageSize * (PageIndex - 1) && rowindex <= PageSize * PageIndex)
olist.Add(model);
rowindex++;
}
DT_OrderUserListNew model2 = new DT_OrderUserListNew();
model2.GoodsCode = "合计:";
model2.GoodsNum = hjsl;
model2.TotalPrice = hj1.ToString("0.00");
model2.YJPrice = hj11.ToString("0.00");
model2.GoodsFee = hj2.ToString("0.00");
model2.escrowFee = hj21.ToString("0.00");
model2.Fee1 = hj3.ToString("0.00");
model2.Fee3 = hj4.ToString("0.00");
model2.PostFee = hj5.ToString("0.00");
model2.Fee4 = hj6.ToString("0.00");
model2.BackPostFee = hj10.ToString("0.00");
model2.BackMoney = hj9.ToString("0.00");
model2.LRFee = hj8.ToString("0.00");
if (hj8 > 0 && hj1 > 0)
model2.LRRate = (hj8 / hj1 * 100).ToString("0.00") + "%";
else if (hj8 == 0)
model2.LRRate = "0%";
else if (hj1 > 0)
model2.LRRate = "<font color='red'>-" + (hj8 * -1 / hj1 * 100).ToString("0.00") + "%<font>";
olist.Add(model2);
// html.Append("<tr class='DataGridRowStyle'><td></td>");
// html.Append("<td></td>");
// html.Append("<td></td>");
// html.Append("<td></td>");
// html.Append("<td></td>");
// html.Append("<td></td>");
// html.Append("<td></td>");
// html.Append("<td></td>");
//model2. 合计:</td>");
// html.Append("<td>" + hj1.ToString("0.00") + "</td>");
// html.Append("<td>" + hj2.ToString("0.00") + "</td>");
// // html.Append("<td></td>");
// html.Append("<td>" + hj3.ToString("0.00") + "</td>");
// html.Append("<td>" + hj4.ToString("0.00") + "</td>");
// html.Append("<td>" + hj51.ToString("0.00") + "</td>");
// html.Append("<td>" + hj5.ToString("0.00") + "</td>");
// html.Append("<td>" + hj6.ToString("0.00") + "</td>");
// html.Append("<td>" + hj7.ToString("0.00") + "</td>");
// html.Append("<td>" + hj8.ToString("0.00") + "</td>");
// if (hj8 > 0)
// html.Append("<td>" + (hj8 / hj1 * 100).ToString("0.00") + "%</td>");
// else if (hj8 == 0)
// html.Append("<td>0%</td>");
// else
// html.Append("<td>-" + (hj8 * -1 / hj1 * 100).ToString("0.00") + "%</td>");
// html.Append("</tr>");
}
JsonModel<List<DT_OrderUserListNew>> resultModel = new JsonModel<List<DT_OrderUserListNew>>();
int RowCount = 0;
resultModel.DataSource = olist;
resultModel.RowCount = rowindex;
return resultModel;
}
catch (Exception ex)
{
ErrorFollow.TraceWrite("GetUserOrderList2", "", ex.Message);
}
return null;
}
#endregion
#region 报表27
[WebMethod(EnableSession = true)]
public string GetReportTable27(int Type, DateTime? SDate, DateTime? EDate, int StoreId)
{
var obj = new BaseService();
string CompanyId = Session["CompanyId"].ToString();
string tj = "";
//if (StoreId > 0)
//{
// tj = " and b.StoreId=" + StoreId;
//}
if (SDate != null)
tj += " and a.OrderDate>='" + SDate.Value.ToString("yyyy-MM-dd") + "' ";
if (EDate != null)
tj += " and a.OrderDate<'" + EDate.Value.AddDays(1).ToString("yyyy-MM-dd") + "' ";
string sql = @"select OrderDate=CONVERT(varchar(10),a.OrderDate, 120),Solid=sum(isnull(d.Solid,0)) from DT_OrderInfo a
inner join DT_OrderGoods b on a.OrderId=b.OrderId
inner join HW_GoodsDetail c on b.DetailId=c.DetailId
inner join HW_GoodsInfo d on c.GoodsId=d.GoodsId
where a.state>0 and a.State<3 " + tj + " group by CONVERT(varchar(10),a.OrderDate, 120)";
if (Type == 2)
sql = @"select OrderDate=CONVERT(varchar(10),a.PostDate, 120),Solid=sum(isnull(d.Solid,0)) from DT_OrderInfo a
inner join DT_OrderGoods b on a.OrderId=b.OrderId
inner join HW_GoodsDetail c on b.DetailId=c.DetailId
inner join HW_GoodsInfo d on c.GoodsId=d.GoodsId
where a.PostState=1 " + tj + " group by CONVERT(varchar(10),a.PostDate, 120)";
DataTable dt = obj.GetReportData(sql);
return GetReport3(dt, 38);
}
#endregion
#region 报表27
[WebMethod(EnableSession = true)]
public string GetExcelTable27(int Type, DateTime? SDate, DateTime? EDate, int StoreId)
{
var obj = new BaseService();
string CompanyId = Session["CompanyId"].ToString();
string tj = "";
//if (StoreId > 0)
//{
// tj = " and b.StoreId=" + StoreId;
//}
if (SDate != null)
tj += " and a.OrderDate>='" + SDate.Value.ToString("yyyy-MM-dd") + "' ";
if (EDate != null)
tj += " and a.OrderDate<'" + EDate.Value.AddDays(1).ToString("yyyy-MM-dd") + "' ";
string sql = @"select OrderDate=CONVERT(varchar(10),a.OrderDate, 120),Solid=sum(isnull(d.Solid,0)) from DT_OrderInfo a
inner join DT_OrderGoods b on a.OrderId=b.OrderId
inner join HW_GoodsDetail c on b.DetailId=c.DetailId
inner join HW_GoodsInfo d on c.GoodsId=d.GoodsId
where a.state>0 and a.State<3 " + tj + " group by CONVERT(varchar(10),a.OrderDate, 120)";
if (Type == 2)
sql = @"select OrderDate=CONVERT(varchar(10),a.PostDate, 120),Solid=sum(isnull(d.Solid,0)) from DT_OrderInfo a
inner join DT_OrderGoods b on a.OrderId=b.OrderId
inner join HW_GoodsDetail c on b.DetailId=c.DetailId
inner join HW_GoodsInfo d on c.GoodsId=d.GoodsId
where a.PostState=1 " + tj + " group by CONVERT(varchar(10),a.PostDate, 120)";
DataTable dt = obj.GetReportData(sql);
return GetExcelReport(dt, 38);
}
#endregion
#region 首页订单统计
[WebMethod(EnableSession = true)]
public DT_OrderNum GetDefaultOrderCountMonth(List<DT_OrderCountContent> listshop, int Type)
{
PagesNew.Login(this.Session);
int CompanyId = Convert.ToInt32(Session["CompanyId"]);
var obj = new DD_OrderData();
string Ids = "";
string[] categories = null;
DT_OrderNum md = new DT_OrderNum();
var list = new List<DT_OrderCountData>();
DateTime SDate = Convert.ToDateTime(DateTime.Today.ToString("yyyy-MM-01")).AddMonths(-11);
DateTime EDate = DateTime.Today;
List<DT_CountForMonth> countlist = new List<DT_CountForMonth>();
if (Type == 1)
countlist = DataNew.GetDefaultCountListFromMonth(SDate, EDate.AddDays(1), CompanyId);
else
countlist = DataNew.GetDefaultCountListFromMonthPrice(SDate, EDate.AddDays(1), CompanyId);
List<DT_CountForMonth> countlist2 = new List<DT_CountForMonth>();
if (Type == 1)
countlist2 = DataNew.GetDefaultCountListFromMonth2(SDate, EDate.AddDays(1), CompanyId);
else
countlist2 = DataNew.GetDefaultCountListFromMonthPrice2(SDate, EDate.AddDays(1), CompanyId);
categories = new string[12];
int m = 11;
for (int i = 0; i<12; i++)
{
categories[i] = (DateTime.Today.AddMonths(-1 * m).Month).ToString() + "月";
m--;
}
if (Type == 1)
{
var smd = new DT_OrderCountContent();
smd.Id = 0;
smd.Name = "总单量";
listshop.Insert(0, smd);
}
else
if (Type == 2)
{
var smd = new DT_OrderCountContent();
smd.Id = 0;
smd.Name = "总销售额";
listshop.Insert(0, smd);
}
if (listshop != null && listshop.Count > 0)
{
for (int i = 0; i < listshop.Count; i++)
{
decimal[] data = new decimal[12];
int m2 = 11;
for (int j = 0; j<12; j++)
{
if (listshop[i].Id == 0)
{
if (countlist2 != null)
{
var countmd2 = countlist2.Find(n => n.Month == DateTime.Today.AddMonths(-1 * m2).Month);
if (countmd2 != null)
{
if (Type == 1)
data[j] = countmd2.Num.Value;
else
data[j] = countmd2.Price.Value;
}
else
data[j] = 0;
}
else
data[j] = 0;
}
else
{
if (countlist != null)
{
var countmd = countlist.Find(n => n.ShopId == listshop[i].Id && n.Month == DateTime.Today.AddMonths(-1 * m2).Month);
if (countmd != null)
{
if (Type == 1)
data[j] = countmd.Num.Value;
else
data[j] = countmd.Price.Value;
}
else
data[j] = 0;
}
else
data[j] = 0;
}
m2--;
}
var datamd = new DT_OrderCountData();
datamd.name = listshop[i].Name;
datamd.data = data;
list.Add(datamd);
}
}
md.categories = categories;
JavaScriptSerializer JsonConvert = new JavaScriptSerializer();
string postmessage = JsonConvert.Serialize(list);
md.Data = postmessage;
return md;
}
#endregion
#region 首页订单统计
[WebMethod(EnableSession = true)]
public DT_OrderNum GetDefaultOrderCountMonth2(List<DT_OrderCountContent> listshop, int Type)
{
PagesNew.Login(this.Session);
int CompanyId = Convert.ToInt32(Session["CompanyId"]);
var obj = new DD_OrderData();
string Ids = "";
string[] categories = null;
DT_OrderNum md = new DT_OrderNum();
var list = new List<DT_OrderCountData>();
DateTime SDate = Convert.ToDateTime(DateTime.Today.ToString("yyyy-MM-01")).AddMonths(-11);
DateTime EDate = DateTime.Today;
List<DT_CountForMonth> countlist = new List<DT_CountForMonth>();
if (Type == 1)
countlist = DataNew.GetDefaultCountListFromMonthPT(SDate, EDate.AddDays(1), CompanyId);
else
countlist = DataNew.GetDefaultCountListFromMonthPTPrice(SDate, EDate.AddDays(1), CompanyId);
List<DT_CountForMonth> countlist2 = new List<DT_CountForMonth>();
if (Type == 1)
countlist2 = DataNew.GetDefaultCountListFromMonth2(SDate, EDate.AddDays(1), CompanyId);
else
countlist2 = DataNew.GetDefaultCountListFromMonthPrice2(SDate, EDate.AddDays(1), CompanyId);
categories = new string[12];
int m = 11;
for (int i = 0; i < 12; i++)
{
categories[i] = (DateTime.Today.AddMonths(-1 * m).Month).ToString() + "月";
m--;
}
if (Type == 1)
{
var smd = new DT_OrderCountContent();
smd.Id = 0;
smd.Name = "总单量";
listshop.Insert(0, smd);
}
else
if (Type == 2)
{
var smd = new DT_OrderCountContent();
smd.Id = 0;
smd.Name = "总销售额";
listshop.Insert(0, smd);
}
if (listshop != null && listshop.Count > 0)
{
for (int i = 0; i < listshop.Count; i++)
{
decimal[] data = new decimal[12];
int m2 = 11;
for (int j = 0; j < 12; j++)
{
if (listshop[i].Id == 0)
{
if (countlist2 != null)
{
var countmd2 = countlist2.Find(n => n.Month == DateTime.Today.AddMonths(-1 * m2).Month);
if (countmd2 != null)
{
if (Type == 1)
data[j] = countmd2.Num.Value;
else
data[j] = countmd2.Price.Value;
}
else
data[j] = 0;
}
else
data[j] = 0;
}
else
{
if (countlist != null)
{
var countmd = countlist.Find(n => n.PlatId == listshop[i].Id && n.Month == DateTime.Today.AddMonths(-1 * m2).Month);
if (countmd != null)
{
if (Type == 1)
data[j] = countmd.Num.Value;
else
data[j] = countmd.Price.Value;
}
else
data[j] = 0;
}
else
data[j] = 0;
}
m2--;
}
var datamd = new DT_OrderCountData();
datamd.name = listshop[i].Name;
datamd.data = data;
list.Add(datamd);
}
}
md.categories = categories;
JavaScriptSerializer JsonConvert = new JavaScriptSerializer();
string postmessage = JsonConvert.Serialize(list);
md.Data = postmessage;
return md;
}
#endregion
#region 首页货物销量
[WebMethod(EnableSession = true)]
public DT_OrderNum GetOrderCountGoods(string GoodsCode, DateTime? SDate, DateTime? EDate, int Type)
{
PagesNew.Login(this.Session);
int CompanyId = Convert.ToInt32(Session["CompanyId"]);
var obj = new DD_OrderData();
string[] categories = null;
DT_OrderNum md = new DT_OrderNum();
var list = new List<DT_OrderCountData>();
EDate = EDate.Value.AddDays(1);
List<DT_Order> countlist = DataNew.Get_OrderGoodsNum(CompanyId, SDate, EDate, GoodsCode);
if (countlist == null)
countlist = new List<DT_Order>();
TimeSpan ts = EDate.Value - SDate.Value;
int days = ts.Days + 1;
if (Type == 2)//10天
days = ts.Days / 10 + 1;
if (Type == 3)//月
{
int year = EDate.Value.Year - SDate.Value.Year;
int month = EDate.Value.Month - SDate.Value.Month;
int total = year * 12 + month;
days = total + 1;
}
categories = new string[days];
for (int i = 0; i < days; i++)
{
if (Type == 1)
categories[i] = SDate.Value.AddDays(i).ToString("MM月dd日");
else if (Type == 2)
categories[i] = SDate.Value.AddDays(i * 10).ToString("MM月dd日") + "-" + SDate.Value.AddDays((i + 1) * 10-1).ToString("MM月dd日");
else if (Type == 3)
categories[i] = SDate.Value.AddMonths(i).ToString("MM月");
}
decimal[] data = new decimal[days];
for (int j = 0; j < days; j++)
{
List<DT_Order> glist = new List<DT_Order>();
if (Type == 1)
glist = countlist.FindAll(n => n.OrderDate >= SDate.Value.AddDays(j) && n.OrderDate < SDate.Value.AddDays(j + 1));
else
if (Type == 2)
glist = countlist.FindAll(n => n.OrderDate >= SDate.Value.AddDays(j * 10) && n.OrderDate < SDate.Value.AddDays((j + 1) * 10));
if (Type == 3)
glist = countlist.FindAll(n => n.OrderDate >= Convert.ToDateTime(SDate.Value.AddMonths(j).ToString("yyyy-MM-01")) && n.OrderDate < Convert.ToDateTime(SDate.Value.AddMonths(j + 1).ToString("yyyy-MM-01")));
int GNum = 0;
if (glist != null)
{
foreach (var gmd in glist)
{
GNum += gmd.GoodsNum.Value;
}
}
data[j] = GNum;
}
var datamd = new DT_OrderCountData();
datamd.name = GoodsCode;
datamd.data = data;
list.Add(datamd);
md.categories = categories;
JavaScriptSerializer JsonConvert = new JavaScriptSerializer();
string postmessage = JsonConvert.Serialize(list);
md.Data = postmessage;
return md;
}
#endregion
#region 发货立方
[WebMethod(EnableSession = true)]
public DT_OrderNum GetOrderCountGoodsSoild(DateTime? SDate, DateTime? EDate, int Type)
{
PagesNew.Login(this.Session);
int CompanyId = Convert.ToInt32(Session["CompanyId"]);
var obj = new DD_OrderData();
string[] categories = null;
DT_OrderNum md = new DT_OrderNum();
var list = new List<DT_OrderCountData>();
string tj = "";
if (Type == 1)
{
if (SDate != null)
tj += " and a.OrderDate>='" + SDate.Value.ToString("yyyy-MM-dd") + "' ";
if (EDate != null)
tj += " and a.OrderDate<'" + EDate.Value.AddDays(1).ToString("yyyy-MM-dd") + "' ";
}
else
{
if (SDate != null)
tj += " and a.PostDate>='" + SDate.Value.ToString("yyyy-MM-dd") + "' ";
if (EDate != null)
tj += " and a.PostDate<'" + EDate.Value.AddDays(1).ToString("yyyy-MM-dd") + "' ";
}
string sql = @"select OrderDate=CONVERT(varchar(10),a.OrderDate, 120),Solid=sum(isnull(d.Solid,0)*b.GoodsNum) from DT_OrderInfo a
inner join DT_OrderGoods b on a.OrderId=b.OrderId
inner join HW_GoodsDetail c on b.DetailId=c.DetailId
inner join HW_GoodsInfo d on c.GoodsId=d.GoodsId
where a.state>0 and a.State<3 " + tj + " group by CONVERT(varchar(10),a.OrderDate, 120)";
if (Type == 2)
sql = @"select OrderDate=CONVERT(varchar(10),a.PostDate, 120),Solid=sum(isnull(d.Solid,0)*b.GoodsNum) from DT_OrderInfo a
inner join DT_OrderGoods b on a.OrderId=b.OrderId
inner join HW_GoodsDetail c on b.DetailId=c.DetailId
inner join HW_GoodsInfo d on c.GoodsId=d.GoodsId
where a.PostState=1 " + tj + " group by CONVERT(varchar(10),a.PostDate, 120)";
var obj2 = new BaseService();
DataTable dt = obj2.GetReportData(sql);
List<OrderSoild> countlist = new List<OrderSoild>();
if (dt != null)
countlist = dt.ToList<OrderSoild>();
TimeSpan ts = EDate.Value - SDate.Value;
int days = ts.Days + 1;
categories = new string[days];
for (int i = 0; i < days; i++)
{
categories[i] = SDate.Value.AddDays(i).ToString("MM月dd日");
}
decimal[] data = new decimal[days];
for (int j = 0; j < days; j++)
{
var glist = countlist.Find(n => n.OrderDate == SDate.Value.AddDays(j).ToString("yyyy-MM-dd"));
if (glist== null)
{
data[j] = 0;
}
else
data[j] = glist.Solid.Value;
}
var datamd = new DT_OrderCountData();
datamd.name = "货物立方";
datamd.data = data;
list.Add(datamd);
md.categories = categories;
JavaScriptSerializer JsonConvert = new JavaScriptSerializer();
string postmessage = JsonConvert.Serialize(list);
md.Data = postmessage;
return md;
}
#endregion
#region 发货立方
[WebMethod(EnableSession = true)]
public DT_OrderNum GetOrderCountGoodsSoildDay()
{
PagesNew.Login(this.Session);
int CompanyId = Convert.ToInt32(Session["CompanyId"]);
var obj = new DD_OrderData();
string[] categories = null;
DT_OrderNum md = new DT_OrderNum();
var list = new List<DT_OrderCountData>();
string tj = "";
DateTime SDate = DateTime.Today.AddDays(-30);
DateTime EDate = DateTime.Today.AddDays(1);
if (SDate != null)
tj += " and a.OrderDate>='" + SDate.ToString("yyyy-MM-dd") + "' ";
if (EDate != null)
tj += " and a.OrderDate<'" + EDate.AddDays(1).ToString("yyyy-MM-dd") + "' ";
string sql = @"select OrderDate=CONVERT(varchar(10),a.OrderDate, 120),Solid=sum(isnull(d.Solid,0)*b.GoodsNum) from DT_OrderInfo a
inner join DT_OrderGoods b on a.OrderId=b.OrderId
inner join HW_GoodsDetail c on b.DetailId=c.DetailId
inner join HW_GoodsInfo d on c.GoodsId=d.GoodsId
where a.state>0 and a.State<3 " + tj + " group by CONVERT(varchar(10),a.OrderDate, 120)";
var obj2 = new BaseService();
DataTable dt = obj2.GetReportData(sql);
List<OrderSoild> countlist = new List<OrderSoild>();
if (dt != null)
countlist = dt.ToList<OrderSoild>();
TimeSpan ts = EDate - SDate;
int days = ts.Days + 1;
categories = new string[days];
for (int i = 0; i < days; i++)
{
categories[i] = SDate.AddDays(i).ToString("MM月dd日");
}
decimal[] data = new decimal[days];
for (int j = 0; j < days; j++)
{
var glist = countlist.Find(n => n.OrderDate == SDate.AddDays(j).ToString("yyyy-MM-dd"));
if (glist == null)
{
data[j] = 0;
}
else
data[j] = glist.Solid.Value;
}
var datamd = new DT_OrderCountData();
datamd.name = "货物立方";
datamd.data = data;
list.Add(datamd);
md.categories = categories;
JavaScriptSerializer JsonConvert = new JavaScriptSerializer();
string postmessage = JsonConvert.Serialize(list);
md.Data = postmessage;
return md;
}
#endregion
#region 发货立方
[WebMethod(EnableSession = true)]
public DT_OrderNum GetOrderCountGoodsSoildMonth()
{
PagesNew.Login(this.Session);
int CompanyId = Convert.ToInt32(Session["CompanyId"]);
var obj = new DD_OrderData();
string[] categories = null;
DT_OrderNum md = new DT_OrderNum();
var list = new List<DT_OrderCountData>();
string tj = "";
DateTime SDate = Convert.ToDateTime(DateTime.Today.ToString("yyyy-MM-01")).AddMonths(-11);
DateTime EDate = DateTime.Today.AddDays(1);
if (SDate != null)
tj += " and a.OrderDate>='" + SDate.ToString("yyyy-MM-dd") + "' ";
if (EDate != null)
tj += " and a.OrderDate<'" + EDate.AddDays(1).ToString("yyyy-MM-dd") + "' ";
string sql = @"select OrderDate=cast(DATEPART(month,OrderDate) as nvarchar(10)),Solid=sum(isnull(d.Solid,0)*b.GoodsNum) from DT_OrderInfo a
inner join DT_OrderGoods b on a.OrderId=b.OrderId
inner join HW_GoodsDetail c on b.DetailId=c.DetailId
inner join HW_GoodsInfo d on c.GoodsId=d.GoodsId
where a.state>0 and a.State<3 " + tj + " group by DATEPART(month,OrderDate)";
var obj2 = new BaseService();
DataTable dt = obj2.GetReportData(sql);
List<OrderSoild> countlist = new List<OrderSoild>();
if (dt != null)
countlist = dt.ToList<OrderSoild>();
int days = 12;
categories = new string[days];
for (int i = 0; i < days; i++)
{
categories[i] = SDate.AddMonths(i).ToString("MM月");
}
decimal[] data = new decimal[days];
for (int j = 0; j < days; j++)
{
var glist = countlist.Find(n => n.OrderDate == SDate.AddMonths(j).Month.ToString());
if (glist == null)
{
data[j] = 0;
}
else
data[j] = glist.Solid.Value;
}
var datamd = new DT_OrderCountData();
datamd.name = "货物立方";
datamd.data = data;
list.Add(datamd);
md.categories = categories;
JavaScriptSerializer JsonConvert = new JavaScriptSerializer();
string postmessage = JsonConvert.Serialize(list);
md.Data = postmessage;
return md;
}
#endregion
#region 保存-用户信息
[WebMethod(EnableSession = true)]
public int Save_JC_UserInfoHWC(JC_UserInfo Model)
{
PagesNew.Login(this.Session);
// int CompanyID = Convert.ToInt32(Session["CompanyId"]);
// Model.CompanyId = CompanyID;
return DataNew.SaveUserInfo(Model);
}
#endregion
#region 分页查询-用户信息
[WebMethod(EnableSession = true)]
public JsonModel<List<JC_UserInfo>> GetListJC_UserInfo(int CompanyID, string Name, int PageIndex, int PageSize)
{
PagesNew.Login(this.Session);
JsonModel<List<JC_UserInfo>> resultModel = new JsonModel<List<JC_UserInfo>>();
int RowCount = 0;
string Sort = "";
// CompanyID = Convert.ToInt32(Session["CompanyId"]);
RefParameterCollection param = new RefParameterCollection();
if(CompanyID>0) param.Add("a.CompanyID", "=", CompanyID, DbType.Int32);
param.Add("a.State", ">", 0, DbType.Int32);
param.Add("(UserType", "=", "H", DbType.String);
param.Add("UserType", "=", "M", "or", ")", DbType.String);
if (string.IsNullOrEmpty(Name) == false)
{
param.Add("(Name", "like", Name, DbType.String);
param.Add("UserName", "like", Name, "or", ")", DbType.String);
}
resultModel.DataSource = DataNew.GetListJC_UserInfo(param, PageIndex, PageSize, Sort, out RowCount);
resultModel.RowCount = RowCount;
return resultModel;
}
#endregion
#region 分页查询-用户信息
[WebMethod(EnableSession = true)]
public JsonModel<List<JC_UserInfoNew>> GetListJC_UserInfoForTM(int CompanyID, int DeptID, string Name, int State, int IsRoom, string HuKou, string EmployeeType, int PageIndex, int PageSize)
{
PagesNew.Login(this.Session);
JsonModel<List<JC_UserInfoNew>> resultModel = new JsonModel<List<JC_UserInfoNew>>();
int RowCount = 0;
string Sort = "UserId";
CompanyID = Convert.ToInt32(Session["CompanyId"]);
RefParameterCollection param = new RefParameterCollection();
param.Add("a.CompanyID", "=", CompanyID, DbType.Int32);
if (DeptID > 0)
param.Add("a.DeptId", "=", DeptID, DbType.Int32);
param.Add("a.State", "=", State, DbType.Int32);
if (IsRoom > -1)
param.Add("a.IsRoom", "=", IsRoom, DbType.Int32);
if (HuKou != "-1")
param.Add("a.HuKou", "=", HuKou, DbType.String);
if (EmployeeType != "-1")
param.Add("a.EmployeeType", "=", EmployeeType, DbType.String);
if (string.IsNullOrEmpty(Name) == false)
{
param.Add("(Name", "like", Name, DbType.String);
param.Add("UserName", "like", Name, "or", ")", DbType.String);
}
param.Add("(UserType", "=", "P", DbType.String);
param.Add("UserType", "=", "M", "or", ")", DbType.String);
resultModel.DataSource = DataNew.GetListJC_UserInfoForTM(param, PageIndex, PageSize, Sort, out RowCount);
resultModel.RowCount = RowCount;
if (resultModel.DataSource != null)
{
foreach (var md in resultModel.DataSource)
{
var rlist = JC_RoleInfoService.GetUserRoleList(md.UserId.Value);
if (rlist != null && rlist.Count > 0)
md.RoleId = rlist[0].RoleId;
}
}
return resultModel;
}
#endregion
#region 保存
[WebMethod(EnableSession = true)]
public int SetGroupName(int guserid, int userid, string groupname)
{
PagesNew.Login(this.Session);
DataNew.SetGroupName(guserid, userid, groupname);
return 1;
}
#endregion
#region 保存
[WebMethod(EnableSession = true)]
public int Save_CompanyNew(JC_CompanyNew Model)
{
PagesNew.Login(this.Session);
int Id = DataNew.Save_Company(Model);
JC_UserInfo2 umd = new JC_UserInfo2();
umd.CompanyId = Id;
umd.UserName = Model.UserName;
umd.Password = Model.Password;
umd.UserType = "H";
umd.State = 1;
umd.InDate = DateTime.Now;
umd.IsLogin = 1;
umd.Name = Model.CompanyName;
DataNew.SaveUserInfo2(umd);
return Id;
}
#endregion
#region 登陆
[WebMethod(EnableSession = true)]
public bool LoginNew2(string UserName, string PassWord)
{
var list = DataNew.LoginNew2(UserName, PassWord);
if (list == null)
{
string Content = "登陆用户名:" + UserName + "密码:" + PassWord + "登陆时间:" + DateTime.Now.ToString() + "登陆ip";
PagesNew.SaveLog(0, "登陆日志", Content, 0);
return false;
}
UserModel model = new UserModel();
if (list.CompanyId > 0) model.CompanyID = list.CompanyId.Value;
model.Name = list.Name;
model.UserID = list.UserId.Value;
model.UserType = list.UserType;
model.UserName = UserName;
model.PassWord = PassWord;
model.CompanyName = list.CompanyName;
if (list.DeptId != null)
model.DeptId = list.DeptId.Value;
else
model.DeptId = 0;
model.Duty = list.Duty;
Session["PT"] = "hwc";
Session["CompanyId"] = model.CompanyID;
Session["DeptId"] = model.DeptId;
Session["Name"] = model.Name;
Session["UserId"] = model.UserID;
Session["UserName"] = model.UserName;
Session["UserType"] = model.UserType;
Session["CompanyName"] = model.CompanyName;
Session["Duty"] = model.Duty;
Session["Login_UserModel"] = model;
//string Content1="登陆用户名:"+UserName+"姓名:"+model.Name+"登陆时间:"+DateTime.Now.ToString()+"登陆ip"+ LoginIp+"";
//Pages.SaveLog(model.UserID,"登陆日志",Content1,0);
//JC_ExpressService.InitExpress(model.CompanyID);
return true;
}
#endregion
#region 登陆
[WebMethod(EnableSession = true)]
public bool LoginNew(string UserName, string PassWord, string ul, string LoginIp)
{
//HttpContext.Current.Request.UserHostAddress
//HttpContext.Current.Request.ServerVariables.GetValues("REMOTE_ADDR")[0]
//string LoginIp = HttpContext.Current.Request.ServerVariables.GetValues("REMOTE_ADDR")[0];
int IsNb = 0;
if (ul.Contains("192.168."))
IsNb = 1;
var list = DataNew.LoginNew(UserName, PassWord, LoginIp, IsNb);
if (list == null)
{
string Content = "登陆用户名:" + UserName + "密码:" + PassWord + "登陆时间:" + DateTime.Now.ToString() + "登陆ip" + LoginIp + "";
PagesNew.SaveLog(0, "登陆日志", Content, 0);
return false;
}
UserModel model = new UserModel();
if (list.CompanyId > 0) model.CompanyID = list.CompanyId.Value;
model.Name = list.Name;
model.UserID = list.UserId.Value;
model.UserType = list.UserType;
model.UserName = UserName;
model.PassWord = PassWord;
model.CompanyName = list.CompanyName;
if (list.Mobile3 != null && list.Mobile3 != "")
{
Session["KTSKU"] = list.Mobile3;
}
else
Session["KTSKU"] = "";
if (list.DeptId != null)
model.DeptId = list.DeptId.Value;
else
model.DeptId = 0;
model.Duty = list.Duty;
Session["CompanyId"] = model.CompanyID;
Session["DeptId"] = model.DeptId;
Session["Name"] = model.Name;
Session["UserId"] = model.UserID;
Session["UserName"] = model.UserName;
Session["UserType"] = model.UserType;
Session["CompanyName"] = model.CompanyName;
Session["Duty"] = model.Duty;
Session["AllShop"] = list.UserCard;//是否查询所有店铺
Session["Login_UserModel"] = model;
//string Content1="登陆用户名:"+UserName+"姓名:"+model.Name+"登陆时间:"+DateTime.Now.ToString()+"登陆ip"+ LoginIp+"";
//Pages.SaveLog(model.UserID,"登陆日志",Content1,0);
//JC_ExpressService.InitExpress(model.CompanyID);
return true;
}
#endregion
#region 普通查询列表
[WebMethod(EnableSession = true)]
public List<JC_UserInfo> GetAllListJC_UserInfo()
{
PagesNew.Login(this.Session);
var ListModel = JC_ShopService.GetListUserInfo();
return ListModel;
}
#endregion
#region 普通查询列表
[WebMethod(EnableSession = true)]
public List<JC_UserInfo> GetListUserInfoFromDept(int deptid)
{
PagesNew.Login(this.Session);
var ListModel = JC_ShopService.GetListUserInfoFromDept(deptid);
return ListModel;
}
#endregion
#region 普通查询列表
[WebMethod(EnableSession = true)]
public List<JC_UserInfo> GetListUserInfoFromGroup2(int iscp)
{
PagesNew.Login(this.Session);
int UserId = Convert.ToInt32(Session["UserId"]);
var ListModel = DataNew.GetListUserInfoFromGroup2(UserId, iscp);
return ListModel;
}
#endregion
#region 读取全部或单个客户经理
[WebMethod(EnableSession = true)]
public List<BaseModel> GetListCustom()
{
PagesNew.Login(this.Session);
int UserId = Convert.ToInt32(Session["UserId"]);
return DataNew.GetListCustom(UserId);
}
#endregion
#region 分页查询
[WebMethod(EnableSession = true)]
public JsonModel<List<JC_CompanyNew>> GetListCompanyList(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<JC_CompanyNew>>();
int RowCount = 0;
resultModel.DataSource = DataNew.GetListCompany(where, PageIndex, PageSize, "", out RowCount);
resultModel.RowCount = RowCount;
if (resultModel.DataSource != null)
{
foreach (var md in resultModel.DataSource)
{
var umd = DataNew.GetUserInfoMd(md.CompanyID.Value);
if (umd != null)
{
md.UserName = umd.UserName;
md.Password = umd.Password;
}
}
}
return resultModel;
}
#endregion
#region 读取全部或单个机构
[WebMethod(EnableSession = true)]
public List<BaseModel> GetListCompany()
{
PagesNew.Login(this.Session);
int CompanyID = Convert.ToInt32(Session["CompanyId"]);
int UserId = Convert.ToInt32(Session["UserId"]);
return DataNew.GetListCompany1(CompanyID, UserId);
}
#endregion
#region 读取全部或单个机构
[WebMethod(EnableSession = true)]
public List<BaseModel> GetListCompany3()
{
PagesNew.Login(this.Session);
int CompanyID = Convert.ToInt32(Session["CompanyId"]);
int UserId = Convert.ToInt32(Session["UserId"]);
return DataNew.GetListCompany3(CompanyID, UserId);
}
#endregion
#region 读取全部或单个机构
[WebMethod(EnableSession = true)]
public List<BaseModel> GetListCompany2()
{
PagesNew.Login(this.Session);
int CompanyID = Convert.ToInt32(Session["CompanyId"]);
int UserId = Convert.ToInt32(Session["UserId"]);
return DataNew.GetListCompany2(CompanyID, UserId);
}
#endregion
#region 读取菜单
[WebMethod(EnableSession = true)]
public List<JC_MenuList2> GetListMenu2()
{
Pages.Login(this.Session);
int UserID = Convert.ToInt32(Session["UserId"]);
int CompanyId = Convert.ToInt32(Session["CompanyId"]);
return DataNew.GetListMenu2(UserID, CompanyId);
}
#endregion
#region 读取菜单
[WebMethod(EnableSession = true)]
public void DeleteJC_Company(int CompanyId)
{
PagesNew.Login(this.Session);
DataNew.DeleteJC_Company(CompanyId);
}
#endregion
#region 报表40
[WebMethod(EnableSession = true)]
public string GetReportTable40(DateTime? SDate, DateTime? EDate, int UserId, string GoodsCode)
{
var obj = new BaseService();
int CompanyId = Convert.ToInt32(Session["CompanyId"]);
string tj = "";
string tj2 = "";
if (SDate != null)
{
tj += " and OrderDate>='" + SDate.Value.ToString("yyyy-MM-dd") + "' ";
// tj2 += " b.LastOrderDate>='" + SDate.Value.ToString("yyyy-MM-dd") + "' ";
}
if (EDate != null)
{
tj += " and OrderDate<'" + EDate.Value.AddDays(1).ToString("yyyy-MM-dd") + "' ";
// tj2 += " and b.LastOrderDate<'" + EDate.Value.AddDays(1).ToString("yyyy-MM-dd") + "' ";
}
if (UserId > 0)
{
tj2 += " and a.UserId=" + UserId + " ";
}
if (GoodsCode != "")
tj2 += " and e.GoodsCode='" + GoodsCode + "' ";
string sql = @"
select * into #DT_OrderInfoUser from DT_OrderInfo with(nolock) where CompanyId=1 and State>0 and State<3 " + tj + @"
select a.UserId,Num=COUNT(distinct a.GoodsId) into #DT_OrderInfoUser3 from HW_GoodsUser a with(nolock)
inner join HW_GoodsInfo b with(nolock) on a.GoodsId=b.GoodsId
inner join HW_GoodsDetail e with(nolock) on b.GoodsId=e.GoodsId
inner join DT_OrderGoods c with(nolock) on e.DetailId=c.DetailId
inner join #DT_OrderInfoUser d with(nolock) on c.OrderId=d.OrderId and a.ShopId=d.ShopId
where d.CompanyId=1 " + tj2 + @" group by a.UserId
select b.UserId,b.Num,Price=dbo.MoneyUSDChange(a.TotalPrice,a.MoneyCode,a.CompanyId) into #DT_OrderInfoUser2 from #DT_OrderInfoUser a inner join (
select a.UserId,d.OrderId,Num=SUM(c.GoodsNum) from HW_GoodsUser a with(nolock)
inner join HW_GoodsInfo b with(nolock) on a.GoodsId=b.GoodsId
inner join HW_GoodsDetail e with(nolock) on b.GoodsId=e.GoodsId
inner join DT_OrderGoods c with(nolock) on e.DetailId=c.DetailId
inner join #DT_OrderInfoUser d on c.OrderId=d.OrderId and a.ShopId=d.ShopId
where d.CompanyId=1 " + tj2 + @"
group by a.UserId,d.OrderId)b on a.OrderId=b.OrderId
select c.Name,c.UserName,a.*,GoodsNum=d.Num,OutGoods=isnull(e.Num,0),Rate=case when d.Num>0 then isnull(e.Num,0)*1.0/d.Num else 0 end,NoGoods=d.Num-isnull(e.Num,0) from (
select UserId,Num=sum(Num),OrderNum=COUNT(0),Price=SUM(Price) from #DT_OrderInfoUser2
group by UserId)a
inner join JC_UserInfo c on a.UserId=c.UserId
inner join (select UserId,Num=COUNT(distinct GoodsId) from HW_GoodsUser with(nolock)
group by UserId)d on c.UserId=d.UserId
left join #DT_OrderInfoUser3 e on c.UserId=e.UserId
drop table #DT_OrderInfoUser, #DT_OrderInfoUser2, #DT_OrderInfoUser3
";
DataTable dt = obj.GetReportData(sql);
return GetReport2(dt, 40);
}
#endregion
#region 报表
public string GetReport2(DataTable dt, int ReportId)
{
PagesNew.Login(this.Session);
var obj = new BaseService();
var rmd = BaseService.GetReportModel(ReportId);
var rlist = obj.GetRepoartColsList(ReportId);
if (rmd == null || rlist == null)
return "";
StringBuilder html = new StringBuilder();
html.Append("<tr class='HeaderStyle'><th>序号</th>");
foreach (var md in rlist)
{
html.Append("<th>" + md.ColName + "</th>");
}
html.Append("</tr>");
if (dt != null)
{
DataRow row = null;
for (int i = 0; i < dt.Rows.Count; i++)
{
html.Append("<tr class='DataGridRowStyle'><td>" + (i + 1).ToString() + "</td>");
int rowindex = 1;
foreach (var md in rlist)
{
if (dt.Columns.Contains(md.ColValue) == false)
{
html.Append("<td rowindex='" + rowindex + "' rowtr='" + i + "'></td>");
rowindex++;
continue;
}
if (md.IsSum == 1 && i == 0)
{
if (row == null)
row = dt.NewRow();
if (md.ColType == "int")
{
try
{
row[md.ColValue] = Convert.ToInt32(dt.Compute("sum(" + md.ColValue + ")", "" + md.ColValue + " is not null"));
}
catch
{
row[md.ColValue] = 0;
}
}
else if (md.ColType == "dec")
{
try
{
row[md.ColValue] = Convert.ToDecimal(dt.Compute("sum(" + md.ColValue + ")", "" + md.ColValue + ">0"));
}
catch
{
row[md.ColValue] = 0;
}
}
}
if (dt.Rows[i][md.ColValue] != null && dt.Rows[i][md.ColValue].ToString() != "")
{
string csscolor = "";
if (md.ContionType == "=" && dt.Rows[i][md.ColValue].ToString() == md.SValue)
{
csscolor = md.ColColor;
}
else
if (md.ContionType == ">" && Convert.ToDecimal(dt.Rows[i][md.ColValue]) > Convert.ToDecimal(md.SValue) && Convert.ToDecimal(dt.Rows[i][md.ColValue]) < Convert.ToDecimal(md.EValue))
{
csscolor = md.ColColor;
}
else
if (md.ContionType == ">=" && Convert.ToDecimal(dt.Rows[i][md.ColValue]) >= Convert.ToDecimal(md.SValue) && Convert.ToDecimal(dt.Rows[i][md.ColValue]) <= Convert.ToDecimal(md.EValue))
{
csscolor = md.ColColor;
}
if (csscolor != "")
csscolor = "style='color:" + csscolor + "'";
string datav = "";
if (md.ColType == "date1")
datav = Convert.ToDateTime(dt.Rows[i][md.ColValue]).ToString("yyyy-MM-dd");
else
if (md.ColType == "date2")
datav = Convert.ToDateTime(dt.Rows[i][md.ColValue]).ToString("yyyy-MM-dd HH:mm");
else if (md.ColType == "dec")
{
datav = Convert.ToDecimal(dt.Rows[i][md.ColValue]).ToString("0.00");
}
else
datav = dt.Rows[i][md.ColValue].ToString();
html.Append("<td " + csscolor + " rowindex='" + rowindex + "' rowtr='" + i + "'><a uid='" + dt.Rows[i]["UserId"].ToString() + "'>" + datav + "<a></td>");
}
else
html.Append("<td rowindex='" + rowindex + "' rowtr='" + i + "'></td>");
rowindex++;
}
html.Append("</tr>");
}
int hj = 0;
if (row != null)
{
html.Append("<tr class='DataGridRowStyle'><td>合计:</td>");
foreach (var md in rlist)
{
if (dt.Columns.Contains(md.ColValue) == false)
{
html.Append("<td></td>");
continue;
}
if (md.IsSum == 1 && row[md.ColValue] != null)
{
if (hj == 0)
{
hj = 1;
html.Append("<td>" + row[md.ColValue] + "</td>");
}
else
html.Append("<td>" + row[md.ColValue] + "</td>");
}
else
html.Append("<td></td>");
}
html.Append("</tr>");
}
}
return html.ToString();
}
#endregion
#region 分页查询店铺
[WebMethod(EnableSession = true)]
public JsonModel<List<JC_Shop>> GetListJC_ShopForHWC(int CompanyID, int PlatType, string ShopName, int PageIndex, int PageSize)
{
Pages.Login(this.Session);
if (CompanyID == 0) CompanyID = Convert.ToInt32(Session["CompanyId"]);
JsonModel<List<JC_Shop>> resultModel = new JsonModel<List<JC_Shop>>();
int RowCount = 0;
string Sort = "a.DeptId";
RefParameterCollection param = new RefParameterCollection();
param.Add("a.CompanyID", "=", CompanyID, DbType.Int32);
if (PlatType > 0)
param.Add("PlatType", "=", PlatType, DbType.Int32);
if (string.IsNullOrEmpty(ShopName) == false)
param.Add("ShopName", "like", ShopName, DbType.String);
resultModel.DataSource = DataNew.GetListJC_ShopForHWC(param, PageIndex, PageSize, Sort, out RowCount);
resultModel.RowCount = RowCount;
return resultModel;
}
#endregion
#region 保存店铺
[WebMethod(EnableSession = true)]
public string Save_ShopHWC(JC_Shop Model)
{
Pages.Login(this.Session);
Model.InDate = DateTime.Now;
int ShopId = JC_ShopService.SaveShop(Model);
return "成功";
}
#endregion
#region 平台店铺
[WebMethod(EnableSession = true)]
public List<JC_Shop> GetShopList(int PlatType, int CompanyId)
{
PagesNew.Login(this.Session);
var list = DataNew.GetShopList(CompanyId, PlatType);
return list;
}
#endregion
#region 报表16
[WebMethod(EnableSession = true)]
public string GetReportTable16(DateTime? SDate, DateTime? EDate, int DeptId, int ShopId, int PlatId, string MoneyCode, string Sort)
{
var obj = new BaseService();
if (EDate == null)
EDate = DateTime.Now;
string tj = "";
string tj1 = "";
if (DeptId > 0)
{
tj += " and b.DeptId=" + DeptId + " ";
tj1 += " and a.DeptId=" + DeptId + " ";
}
if (PlatId > 0)
{
tj += " and b.PlatType=" + PlatId + " ";
tj1 += " and a.PlatType=" + PlatId + " ";
}
if (ShopId > 0)
{
tj += " and b.ShopId=" + ShopId + " ";
tj1 += " and a.ShopId=" + ShopId + " ";
}
string endtime = Convert.ToDateTime(EDate.ToString()).AddDays(1).ToString();
if (MoneyCode != "0")
tj += " and a.MoneyCode='" + MoneyCode + "' ";
string sql = @"
select a.ShopName,OrderNum=isnull(c.OrderNum,0),USDMoney=isnull(c.USDMoney,0),RMBMoney=isnull(c.RMBMoney,0),AvgPrice=case when c.OrderNum is null or c.USDMoney is null or c.OrderNum=0 then 0 else c.USDMoney/c.OrderNum end from JC_Shop a
inner join (select b.ShopId,OrderNum=COUNT(0),USDMoney=SUM(dbo.MoneyUSDChange(TotalPrice,a.MoneyCode,a.CompanyId)),RMBMoney=SUM(dbo.MoneyChange(TotalPrice,a.MoneyCode,a.CompanyId)) from DT_OrderInfo a
inner join JC_Shop b on a.ShopId=b.ShopId
where a.State>0 " + tj + " and a.State<3 and a.OrderDate>='" + SDate + "' and a.OrderDate<'" + endtime + @"' group by b.ShopId)c on a.ShopId=c.ShopId
where a.CompanyId=1 " + tj1 + " order by " + Sort;
DataTable dt = obj.GetReportData(sql);
return GetReport3(dt, 16);
}
#endregion
#region 报表16
[WebMethod(EnableSession = true)]
public string GetReportExcel16(DateTime? SDate, DateTime? EDate, int DeptId, int ShopId, int PlatId, string MoneyCode, string Sort)
{
var obj = new BaseService();
string tj = "";
string tj1 = "";
if (DeptId > 0)
{
tj += " and b.DeptId=" + DeptId + " ";
tj1 += " and a.DeptId=" + DeptId + " ";
}
if (PlatId > 0)
{
tj += " and b.PlatType=" + PlatId + " ";
tj1 += " and a.PlatType=" + PlatId + " ";
}
if (ShopId > 0)
{
tj += " and b.ShopId=" + ShopId + " ";
tj1 += " and a.ShopId=" + ShopId + " ";
}
string endtime = Convert.ToDateTime(EDate.ToString()).AddDays(1).ToString();
if (MoneyCode != "0")
tj += " and a.MoneyCode='" + MoneyCode + "' ";
string sql = @"
select a.ShopName,OrderNum=isnull(c.OrderNum,0),USDMoney=isnull(c.USDMoney,0),RMBMoney=isnull(c.RMBMoney,0),AvgPrice=case when c.OrderNum is null or c.USDMoney is null or c.OrderNum=0 then 0 else c.USDMoney/c.OrderNum end from JC_Shop a
inner join (select b.ShopId,OrderNum=COUNT(0),USDMoney=SUM(dbo.MoneyUSDChange(TotalPrice,a.MoneyCode,a.CompanyId)),RMBMoney=SUM(dbo.MoneyChange(TotalPrice,a.MoneyCode,a.CompanyId)) from DT_OrderInfo a
inner join JC_Shop b on a.ShopId=b.ShopId
where a.State>0 " + tj + " and a.State<3 and a.OrderDate>='" + SDate + "' and a.OrderDate<='" + endtime + @"' group by b.ShopId)c on a.ShopId=c.ShopId
where a.CompanyId=1 " + tj1 + " order by " + Sort;
DataTable dt = obj.GetReportData(sql);
return GetExcelReport(dt, 16);
}
#endregion
[WebMethod(EnableSession = true)]
public JsonModel<List<DT_OrderBackMoneyApply>> GetListJC_OrderBack2(int ShopId, string Reason1, string Name, int CheckState1, int CheckState2, DateTime? SDate, DateTime? EDate, int PageIndex, int PageSize)
{
Pages.Login(base.Session);
DD_OrderData data = new DD_OrderData();
int num = Convert.ToInt32(base.Session["UserId"]);
int num2 = Convert.ToInt32(base.Session["DeptId"]);
string str = Convert.ToString(base.Session["Name"]);
string str2 = Convert.ToString(base.Session["Duty"]);
RefParameterCollection where = new RefParameterCollection();
if (((str2 != "副总经理") && (str2 != "总经理")) && (str2 != "经理"))
{
where.Add("a.InUserId", "=", num, DbType.Int32);
}
if (ShopId > 0)
{
where.Add("a.ShopId", "=", ShopId, DbType.String);
}
if (CheckState1 != -1)
{
where.Add("a.State", "=", CheckState1, DbType.Int32);
}
if (CheckState2 == 1)
{
where.Add("a.CompanyAgree2", "=", "同意赔款", DbType.String);
}
else if (CheckState2 == 2)
{
where.Add("a.CompanyAgree2", "=", "不同意赔款", DbType.String);
}
else if (CheckState2 == 0)
{
where.Add("isnull(a.CompanyAgree2,'')", "=", "", DbType.String);
}
if (Name != "")
{
where.Add("(a.InName", "like", Name, DbType.String);
where.Add("a.OrderCode", "like", Name, "or", DbType.String);
where.Add("a.GoodsCode", "like", Name, "or", ")", DbType.String);
}
if (SDate.HasValue)
{
where.Add("a.InDate", ">=", SDate, DbType.DateTime);
}
if (EDate.HasValue)
{
where.Add("a.InDate", "<", EDate.Value.AddDays(1.0), DbType.DateTime);
}
if (Reason1 != "0")
{
where.Add("a.BackReason1", "=", Reason1, DbType.String);
}
JsonModel<List<DT_OrderBackMoneyApply>> model = new JsonModel<List<DT_OrderBackMoneyApply>>();
int rowCount = 0;
string sort = "c.OrderDate desc";
model.DataSource = data.GetListDT_OrderBackMoneyApply2(where, PageIndex, PageSize, sort, out rowCount);
model.RowCount = rowCount;
if (model.DataSource != null)
{
string str4 = "";
List<DT_OrderUser> list = new List<DT_OrderUser>();
List<DT_OrderUser> list2 = new List<DT_OrderUser>();
foreach (DT_OrderBackMoneyApply apply in model.DataSource)
{
str4 = str4 + apply.OrderId.Value.ToString() + ",";
}
if (str4 != "")
{
list = DataNew.Get_OrderGoodsForBack(str4.TrimEnd(new char[] { ',' }));
list2 = data.Get_OrderGoodsForBack2(str4.TrimEnd(new char[] { ',' }));
}
if (list == null)
{
list = new List<DT_OrderUser>();
}
if (list2 == null)
{
list2 = new List<DT_OrderUser>();
}
decimal num4 = Convert.ToDecimal((double)6.5);
List<JC_Money> list3 = new BaseService().GetMoneyList2();
using (List<DT_OrderBackMoneyApply>.Enumerator enumerator = model.DataSource.GetEnumerator())
{
Predicate<JC_Money> match = null;
Predicate<DT_OrderUser> predicate2 = null;
Predicate<DT_OrderUser> predicate3 = null;
DT_OrderBackMoneyApply md;
while (enumerator.MoveNext())
{
decimal? nullable2;
decimal num12;
md = enumerator.Current;
decimal num5 = 0M;
if (match == null)
{
match = n => (n.PlatId == md.PlatId) && (n.MCode == "USD");
}
JC_Money money = list3.Find(match);
if (money != null)
{
num4 = money.MRate.Value;
}
decimal num6 = 0M;
int? platId = md.PlatId;
if ((platId.GetValueOrDefault() == 1) && platId.HasValue)
{
num6 = Convert.ToDecimal((double)0.05);
}
else
{
platId = md.PlatId;
if (((platId.GetValueOrDefault() == 2) && platId.HasValue) || (((platId = md.PlatId).GetValueOrDefault() == 3) && platId.HasValue))
{
num6 = Convert.ToDecimal((double)0.15);
}
else
{
platId = md.PlatId;
if ((platId.GetValueOrDefault() == 5) && platId.HasValue)
{
num6 = Convert.ToDecimal((double)0.1);
}
}
}
if (md.OrderPrice.HasValue)
{
num12 = md.OrderPrice.Value * num6;
md.YJPrice = new decimal?(Convert.ToDecimal(num12.ToString("0.00")));
}
else
{
md.YJPrice = 0;
}
decimal num7 = md.OrderPrice.Value;
platId = md.OrderState;
if ((platId.GetValueOrDefault() == 0) && platId.HasValue)
{
num12 = md.YJPrice.Value * Convert.ToDecimal((double)0.2);
md.YJPrice = new decimal?(Convert.ToDecimal(num12.ToString("0.00")));
num7 = 0M;
}
if (predicate2 == null)
{
predicate2 = n => n.OrderId == md.OrderId;
}
List<DT_OrderUser> list4 = list.FindAll(predicate2);
if (predicate3 == null)
{
predicate3 = n => n.OrderId == md.OrderId;
}
List<DT_OrderUser> list5 = list2.FindAll(predicate3);
decimal num8 = 0M;
if (list4 != null)
{
foreach (DT_OrderUser user in list4)
{
num12 = (user.GDFee.Value + user.Fee1.Value) / num4;
num8 += Convert.ToDecimal(num12.ToString("0.00")) + user.Fee2.Value;
}
}
md.GoodsFee = new decimal?(num8);
platId = md.BackState;
if (((platId.GetValueOrDefault() == 1) && platId.HasValue) || (((platId = md.BackState).GetValueOrDefault() == 3) && platId.HasValue))
{
md.GoodsFee = 0;
}
md.OnePostFee = 0;
md.PostRate = 0;
if ((list5 != null) && (list5.Count > 0))
{
md.OnePostFee = list5[0].Fee1;
if (list5[0].PostId == 0x41)
{
md.PostRate = new decimal?(list5[0].Fee1.Value * Convert.ToDecimal((double)0.1));
}
}
decimal num9 = 0M;
if (md.PostFee.HasValue && (((nullable2 = md.PostFee).GetValueOrDefault() > 0M) && nullable2.HasValue))
{
num9 = md.PostFee.Value;
}
decimal num10 = 0M;
if (md.FactPrice.HasValue && (((nullable2 = md.FactPrice).GetValueOrDefault() > 0M) && nullable2.HasValue))
{
num10 = md.FactPrice.Value;
}
num5 = ((((((num7 - md.YJPrice.Value) - md.escrowFee.Value) - md.GoodsFee.Value) - md.OnePostFee.Value) - md.PostRate.Value) - num10) - num9;
md.LRFee = new decimal?(num5);
}
}
}
return model;
}
[WebMethod(EnableSession = true)]
public string GetListJC_OrderBackExcel(int ShopId, string Reason1, string Name, int CheckState1, int CheckState2, DateTime? SDate, DateTime? EDate, int PageIndex, int PageSize)
{
Pages.Login(base.Session);
DD_OrderData data = new DD_OrderData();
int num = Convert.ToInt32(base.Session["UserId"]);
int num2 = Convert.ToInt32(base.Session["DeptId"]);
string str = Convert.ToString(base.Session["Name"]);
string str2 = Convert.ToString(base.Session["Duty"]);
RefParameterCollection where = new RefParameterCollection();
if (((str2 != "副总经理") && (str2 != "总经理")) && (str2 != "经理"))
{
where.Add("a.InUserId", "=", num, DbType.Int32);
}
if (ShopId > 0)
{
where.Add("a.ShopId", "=", ShopId, DbType.String);
}
if (CheckState1 != -1)
{
where.Add("a.State", "=", CheckState1, DbType.Int32);
}
if (CheckState2 == 1)
{
where.Add("a.CompanyAgree2", "=", "同意赔款", DbType.String);
}
else if (CheckState2 == 2)
{
where.Add("a.CompanyAgree2", "=", "不同意赔款", DbType.String);
}
else if (CheckState2 == 0)
{
where.Add("isnull(a.CompanyAgree2,'')", "=", "", DbType.String);
}
if (Name != "")
{
where.Add("(a.InName", "like", Name, DbType.String);
where.Add("a.OrderCode", "like", Name, "or", DbType.String);
where.Add("a.GoodsCode", "like", Name, "or", ")", DbType.String);
}
if (SDate.HasValue)
{
where.Add("a.InDate", ">=", SDate, DbType.DateTime);
}
if (EDate.HasValue)
{
where.Add("a.InDate", "<", EDate.Value.AddDays(1.0), DbType.DateTime);
}
if (Reason1 != "0")
{
where.Add("a.BackReason1", "=", Reason1, DbType.String);
}
int rowCount = 0;
string sort = "c.OrderDate desc";
List<DT_OrderBackMoneyApply> listModel = data.GetListDT_OrderBackMoneyApply2(where, PageIndex, PageSize, sort, out rowCount);
if (listModel != null)
{
string str4 = "";
List<DT_OrderUser> list2 = new List<DT_OrderUser>();
List<DT_OrderUser> list3 = new List<DT_OrderUser>();
foreach (DT_OrderBackMoneyApply apply in listModel)
{
str4 = str4 + apply.OrderId.Value.ToString() + ",";
}
if (str4 != "")
{
list2 = DataNew.Get_OrderGoodsForBack(str4.TrimEnd(new char[] { ',' }));
list3 = data.Get_OrderGoodsForBack2(str4.TrimEnd(new char[] { ',' }));
}
if (list2 == null)
{
list2 = new List<DT_OrderUser>();
}
if (list3 == null)
{
list3 = new List<DT_OrderUser>();
}
decimal num4 = Convert.ToDecimal((double)6.5);
List<JC_Money> list4 = new BaseService().GetMoneyList2();
using (List<DT_OrderBackMoneyApply>.Enumerator enumerator = listModel.GetEnumerator())
{
Predicate<JC_Money> match = null;
Predicate<DT_OrderUser> predicate2 = null;
Predicate<DT_OrderUser> predicate3 = null;
DT_OrderBackMoneyApply md;
while (enumerator.MoveNext())
{
decimal? nullable2;
decimal num12;
md = enumerator.Current;
decimal num5 = 0M;
if (match == null)
{
match = n => (n.PlatId == md.PlatId) && (n.MCode == "USD");
}
JC_Money money = list4.Find(match);
if (money != null)
{
num4 = money.MRate.Value;
}
decimal num6 = 0M;
int? platId = md.PlatId;
if ((platId.GetValueOrDefault() == 1) && platId.HasValue)
{
num6 = Convert.ToDecimal((double)0.05);
}
else
{
platId = md.PlatId;
if (((platId.GetValueOrDefault() == 2) && platId.HasValue) || (((platId = md.PlatId).GetValueOrDefault() == 3) && platId.HasValue))
{
num6 = Convert.ToDecimal((double)0.15);
}
else
{
platId = md.PlatId;
if ((platId.GetValueOrDefault() == 5) && platId.HasValue)
{
num6 = Convert.ToDecimal((double)0.1);
}
}
}
if (md.OrderPrice.HasValue)
{
num12 = md.OrderPrice.Value * num6;
md.YJPrice = new decimal?(Convert.ToDecimal(num12.ToString("0.00")));
}
else
{
md.YJPrice = 0;
}
decimal num7 = md.OrderPrice.Value;
platId = md.OrderState;
if ((platId.GetValueOrDefault() == 0) && platId.HasValue)
{
num12 = md.YJPrice.Value * Convert.ToDecimal((double)0.2);
md.YJPrice = new decimal?(Convert.ToDecimal(num12.ToString("0.00")));
num7 = 0M;
}
if (predicate2 == null)
{
predicate2 = n => n.OrderId == md.OrderId;
}
List<DT_OrderUser> list5 = list2.FindAll(predicate2);
if (predicate3 == null)
{
predicate3 = n => n.OrderId == md.OrderId;
}
List<DT_OrderUser> list6 = list3.FindAll(predicate3);
decimal num8 = 0M;
if (list5 != null)
{
foreach (DT_OrderUser user in list5)
{
num12 = (user.GDFee.Value + user.Fee1.Value) / num4;
num8 += Convert.ToDecimal(num12.ToString("0.00")) + user.Fee2.Value;
}
}
md.GoodsFee = new decimal?(num8);
platId = md.BackState;
if (((platId.GetValueOrDefault() == 1) && platId.HasValue) || (((platId = md.BackState).GetValueOrDefault() == 3) && platId.HasValue))
{
md.GoodsFee = 0;
}
md.OnePostFee = 0;
md.PostRate = 0;
if ((list6 != null) && (list6.Count > 0))
{
md.OnePostFee = list6[0].Fee1;
if (list6[0].PostId == 0x41)
{
md.PostRate = new decimal?(list6[0].Fee1.Value * Convert.ToDecimal((double)0.1));
}
}
decimal num9 = 0M;
if (md.PostFee.HasValue && (((nullable2 = md.PostFee).GetValueOrDefault() > 0M) && nullable2.HasValue))
{
num9 = md.PostFee.Value;
}
decimal num10 = 0M;
if (md.FactPrice.HasValue && (((nullable2 = md.FactPrice).GetValueOrDefault() > 0M) && nullable2.HasValue))
{
num10 = md.FactPrice.Value;
}
num5 = ((((((num7 - md.YJPrice.Value) - md.escrowFee.Value) - md.GoodsFee.Value) - md.OnePostFee.Value) - md.PostRate.Value) - num10) - num9;
md.LRFee = new decimal?(num5);
}
}
}
DataTable tb = listModel.ToDataTable<DT_OrderBackMoneyApply>();
TableColumnCollection columns = new TableColumnCollection();
columns.Add("ShopName", "店铺", DbType.String, "");
columns.Add("OrderCode", "订单号", DbType.String, "");
columns.Add("GoodsCode", "货物编号", DbType.String, "");
columns.Add("BackReason1", "订单日期", DbType.String, "");
columns.Add("OrderDate", "赔款原因", DbType.String, "yyyy-MM-dd");
columns.Add("BackAdvise", "赔款初步方案", DbType.String, "");
columns.Add("BackAdvise2", "赔款最终方案", DbType.String, "");
columns.Add("OrderStateName", "订单状态", DbType.String, "");
columns.Add("OrderPrice", "订单原金额", DbType.String, "");
columns.Add("YJPrice", "佣金$", DbType.String, "");
columns.Add("escrowFee", "税费", DbType.String, "");
columns.Add("GoodsFee", "货物成本", DbType.String, "");
columns.Add("OnePostFee", "首次运费", DbType.String, "");
columns.Add("PostRate", "运费佣金", DbType.String, "");
columns.Add("FactPrice", "实际赔款", DbType.String, "");
columns.Add("PostFee", "我们承担退货运费", DbType.String, "");
columns.Add("LRFee", "利润", DbType.String, "");
columns.Add("BackStateName", "退货仓库验货", DbType.String, "");
columns.Add("StateName", "处理状态", DbType.String, "");
columns.Add("InName", "提交人", DbType.String, "");
columns.Add("CompanyRemark", "领导意见1", DbType.String, "");
columns.Add("CompanyRemark2", "领导意见2", DbType.String, "");
MicrosoftExcel excel = new MicrosoftExcel();
return excel.Export(tb, columns);
}
#region 普通查询列表
[WebMethod(EnableSession = true)]
public List<JC_Shop> GetListShop22()
{
PagesNew.Login(this.Session);
var ListModel = DataNew.GetMyShop22();
return ListModel;
}
#endregion
#region 报表41
[WebMethod(EnableSession = true)]
public List<HW_GoodsUserNew> GetReportTable41(DateTime? InDate, DateTime? EDate, int ShopId, int PlatId, string Name, string Sort)
{
var obj = new BaseService();
var slist = DataNew.GetListGoodsUserFee(PlatId, ShopId, Name);
if (slist == null)
return null;
var glist = DataNew.GetListGoodsUserOrder(PlatId, ShopId, InDate, EDate.Value.AddDays(1));
var olist = DataNew.GetListGoodsUserOrder2(PlatId, ShopId, InDate, EDate.Value.AddDays(1));
if (olist == null)
olist = new List<DT_OrderGoodsUser>();
decimal MRate = Convert.ToDecimal((double)6.5);
List<JC_Money> mlist = new BaseService().GetMoneyList2();
if (mlist != null)
{
var umd = mlist.Find(n => n.MCode == "USD");
if (umd != null)
MRate = umd.MRate.Value;
}
decimal hj = DataNew.GetListTotalPrice2(InDate.Value, EDate.Value.AddDays(1));
TimeSpan ts = EDate.Value.AddDays(1) - InDate.Value;
int days = ts.Days;
decimal thj = 100000 * 12 * days / 365;//每月10w 每天平摊仓储费
decimal fje = 0;
if (hj > 0)
fje = thj * 1.00M / hj;
decimal TotalPrice0 = 0;
decimal TotalRMBPrice0 = 0;
decimal YJFee0 = 0;
decimal GoodsFee0 = 0;
decimal TCFee0 = 0;
decimal PostFee0 = 0;
decimal RateFee0 = 0;
decimal TLR0 = 0;
decimal TLR02 = 0;
decimal hjft = 0;
int GNum0 = 0;
foreach (var md in slist)
{
if (glist != null)
{
var olistmd = olist.Find(n => n.ShopId == md.ShopId && n.UserId == md.UserId);
var gmd = glist.FindAll(n => n.ShopId == md.ShopId && n.UserId == md.UserId);
if (gmd != null)
{
decimal TotalPrice = 0;
decimal TotalRMBPrice = 0;
decimal YJFee = 0;
decimal GoodsFee = 0;
decimal TCFee = 0;
decimal PostFee = 0;
decimal RateFee = 0;
decimal TLR = 0;
int GNum = 0;
foreach (var ggmd in gmd)
{
decimal TotalPrice2 = 0;
decimal TotalRMBPrice2 = 0;
decimal YJFee2 = 0;
decimal GoodsFee2 = 0;
decimal TCFee2 = 0;
decimal PostFee2 = 0;
decimal PostFee3 = 0;
decimal RateFee2 = 0;
decimal TLR2 = 0;
int GNum2 = 0;
int DNum2 = 0;
if (ggmd.GoodsNum2 <= 1 && ggmd.TotalPrice != null)
TotalPrice2 = ggmd.TotalPrice.Value;
else if (ggmd.GoodsNum2 > 1 && ggmd.TotalPrice != null && ggmd.GoodsOrderFee > 0)
{
TotalPrice2 = ggmd.GoodsOrderFee.Value;
}
else if (ggmd.GoodsNum2 > 1 && ggmd.TotalPrice != null && ggmd.GoodsOrderFee == 0)
{
TotalPrice2 = (ggmd.TotalPrice.Value / ggmd.GoodsNum2.Value) * ggmd.GoodsNum.Value;
}
if (ggmd.PlatId == 1)
YJFee2 = TotalPrice2 * Convert.ToDecimal((double)0.05);
else
YJFee2 = TotalPrice2 * Convert.ToDecimal((double)0.15);
if (ggmd.InPrice != null)
GoodsFee2 = ggmd.InPrice.Value * ggmd.GoodsNum.Value / MRate;
if (ggmd.Solid != null)
TCFee2 = ggmd.Solid.Value * ggmd.GoodsNum.Value * Convert.ToDecimal(65);
string AddrType = ggmd.RevFax;//签收类型
if (AddrType == "Residential" || AddrType == "RESIDENTIAL" || AddrType == "")
{
if (ggmd.Fee6 != null && ggmd.Fee8 != null && ggmd.Fee6 > 0 && ggmd.Fee6 < ggmd.Fee8)
{
PostFee2 = ggmd.Fee6.Value;
}
else if (ggmd.Fee6 != null && ggmd.Fee8 != null && ggmd.Fee8 > 0 && ggmd.Fee6 > ggmd.Fee8)
{
PostFee2 = ggmd.Fee8.Value;
}
}
if (AddrType == "Commercial" || AddrType == "OFFICE")
{
if (ggmd.Fee6 != null && ggmd.Fee7 != null && ggmd.Fee6 > 0 && ggmd.Fee6 < ggmd.Fee7)
{
PostFee2 = ggmd.Fee6.Value;
}
else if (ggmd.Fee6 != null && ggmd.Fee7 != null && ggmd.Fee7 > 0 && ggmd.Fee6 > ggmd.Fee7)
{
PostFee2 = ggmd.Fee7.Value;
}
}
if (AddrType == "Residential" || AddrType == "RESIDENTIAL" || AddrType == "")
{
if (ggmd.Fee11 != null && ggmd.Fee13 != null && ggmd.Fee11 > 0 && ggmd.Fee11 < ggmd.Fee13)
{
PostFee3 = ggmd.Fee11.Value;
}
else if (ggmd.Fee11 != null && ggmd.Fee13 != null && ggmd.Fee13 > 0 && ggmd.Fee11 > ggmd.Fee13)
{
PostFee3 = ggmd.Fee13.Value;
}
}
if (AddrType == "Commercial" || AddrType == "OFFICE")
{
if (ggmd.Fee11 != null && ggmd.Fee12 != null && ggmd.Fee11 > 0 && ggmd.Fee11 < ggmd.Fee12)
{
PostFee3 = ggmd.Fee11.Value;
}
else if (ggmd.Fee11 != null && ggmd.Fee12 != null && ggmd.Fee12 > 0 && ggmd.Fee11 > ggmd.Fee12)
{
PostFee3 = ggmd.Fee12.Value;
}
}
decimal tweight = 0;
if (ggmd.Weight != null)
tweight = ggmd.Weight.Value * ggmd.GoodsNum.Value;
if (ggmd.Fee7 != null && tweight >= 1120 && ggmd.Fee7 > 0)
PostFee2 = ggmd.Fee7.Value;
if (ggmd.Fee12 != null && tweight >= 1120 && ggmd.Fee12 > 0)
PostFee3 = ggmd.Fee12.Value;
if (PostFee2 == 0)
PostFee2 = PostFee3;
if (PostFee3 > 0 && PostFee2 > PostFee3)
PostFee2 = PostFee3;
if (ggmd.GoodsNum2 > 1 && PostFee2 > 0)
{
PostFee2 = (PostFee2 / ggmd.GoodsNum2.Value) * ggmd.GoodsNum.Value;
}
if (ggmd.FeeRate > 0 && GoodsFee2 > 0)
RateFee2 = ggmd.FeeRate.Value * 0.01M * GoodsFee2;
if (TotalPrice2 > 0)
TotalRMBPrice2 = TotalPrice2 * MRate;
if (GoodsFee2 > 0 && PostFee2 > 0)
{
TLR2 = TotalPrice2 - YJFee2 - GoodsFee2 - PostFee2 - TCFee2 - RateFee2;
}
GNum2 = ggmd.GoodsNum.Value;
GNum += GNum2;
TotalPrice += TotalPrice2;
TotalRMBPrice += TotalRMBPrice2;
YJFee += YJFee2;
GoodsFee += GoodsFee2;
TCFee += TCFee2;
PostFee += PostFee2;
RateFee += RateFee2;
TLR += TLR2;
}
GNum0 += GNum;
TotalPrice0 += TotalPrice;
TotalRMBPrice0 += TotalRMBPrice;
YJFee0 += YJFee;
GoodsFee0 += GoodsFee;
TCFee0 += TCFee;
PostFee0 += PostFee;
RateFee0 += RateFee;
TLR0 += TLR;
md.TotalPrice = TotalPrice.ToString("0.00");
decimal ftfee = TotalPrice * fje;
hjft += ftfee;
md.ftkcfee =Convert.ToDecimal(ftfee.ToString("0.00"));
if (olistmd != null)
md.mdfee = 0.6M * olistmd.GoodsNum;
else
md.mdfee = 0;
md.TotalRMBPrice = TotalRMBPrice.ToString("0.00");
md.GoodsFee = GoodsFee.ToString("0.00");
md.GoodsNum = GNum;
md.LR = TLR.ToString("0.00");
decimal lr2 = TLR - md.ftkcfee.Value - md.mdfee.Value;
md.LR2 = lr2.ToString("0.00");
TLR02 += lr2;
if (GoodsFee > 0)
md.PGRate = (TotalPrice / GoodsFee).ToString("0.00");
}
}
}
var tmd = new HW_GoodsUserNew();
tmd.Name = "合计:";
tmd.TotalPrice = TotalPrice0.ToString("0.00");
tmd.TotalRMBPrice = TotalRMBPrice0.ToString("0.00");
tmd.GoodsFee = GoodsFee0.ToString("0.00");
tmd.GoodsNum = GNum0;
tmd.ftkcfee = Convert.ToDecimal(hjft.ToString("0.00"));
tmd.LR = TLR0.ToString("0.00");
tmd.LR2 = TLR02.ToString("0.00");
slist.Add(tmd);
return slist;
}
#endregion
#region 报表41
[WebMethod(EnableSession = true)]
public string GetReportExcel41(DateTime? InDate,DateTime? EDate, int ShopId, int PlatId, string Name, string Sort)
{
var obj = new BaseService();
var slist = DataNew.GetListGoodsUserFee(PlatId, ShopId, Name);
if (slist == null)
return null;
var glist = DataNew.GetListGoodsUserOrder(PlatId, ShopId, InDate, EDate.Value.AddDays(1));
decimal MRate = Convert.ToDecimal((double)6.5);
List<JC_Money> mlist = new BaseService().GetMoneyList2();
if (mlist != null)
{
var umd = mlist.Find(n => n.MCode == "USD");
if (umd != null)
MRate = umd.MRate.Value;
}
decimal TotalPrice0 = 0;
decimal TotalRMBPrice0 = 0;
decimal YJFee0 = 0;
decimal GoodsFee0 = 0;
decimal TCFee0 = 0;
decimal PostFee0 = 0;
decimal RateFee0 = 0;
decimal TLR0 = 0;
int GNum0 = 0;
int DNum0 = 0;
foreach (var md in slist)
{
if (glist != null)
{
var gmd = glist.FindAll(n => n.ShopId == md.ShopId && n.UserId == md.UserId);
if (gmd != null)
{
decimal TotalPrice = 0;
decimal TotalRMBPrice = 0;
decimal YJFee = 0;
decimal GoodsFee = 0;
decimal TCFee = 0;
decimal PostFee = 0;
decimal RateFee = 0;
decimal TLR = 0;
int GNum = 0;
int DNum = 0;
foreach (var ggmd in gmd)
{
decimal TotalPrice2 = 0;
decimal TotalRMBPrice2 = 0;
decimal YJFee2 = 0;
decimal GoodsFee2 = 0;
decimal TCFee2 = 0;
decimal PostFee2 = 0;
decimal RateFee2 = 0;
decimal TLR2 = 0;
int GNum2 = 0;
int DNum2 = 0;
if (ggmd.GoodsNum2 <= 1 && ggmd.TotalPrice != null)
TotalPrice2 = ggmd.TotalPrice.Value;
else if (ggmd.GoodsNum2 > 1 && ggmd.TotalPrice != null && ggmd.GoodsOrderFee > 0)
{
TotalPrice2 = ggmd.GoodsOrderFee.Value;
}
else if (ggmd.GoodsNum2 > 1 && ggmd.TotalPrice != null && ggmd.GoodsOrderFee == 0)
{
TotalPrice2 = (ggmd.TotalPrice.Value / ggmd.GoodsNum2.Value) * ggmd.GoodsNum.Value;
}
if (ggmd.PlatId == 1)
YJFee2 = TotalPrice2 * Convert.ToDecimal((double)0.05);
else
YJFee2 = TotalPrice2 * Convert.ToDecimal((double)0.15);
if (ggmd.InPrice != null)
GoodsFee2 = ggmd.InPrice.Value * ggmd.GoodsNum.Value / MRate;
if (ggmd.Solid != null)
TCFee2 = ggmd.Solid.Value * ggmd.GoodsNum.Value * Convert.ToDecimal(65);
string AddrType = ggmd.RevFax;//签收类型
if (AddrType == "Residential" || AddrType == "RESIDENTIAL" || AddrType == "")
{
if (ggmd.Fee6 != null && ggmd.Fee8 != null && ggmd.Fee6 > 0 && ggmd.Fee6 < ggmd.Fee8)
{
PostFee2 = ggmd.Fee6.Value;
}
else if (ggmd.Fee6 != null && ggmd.Fee8 != null && ggmd.Fee8 > 0 && ggmd.Fee6 > ggmd.Fee8)
{
PostFee2 = ggmd.Fee8.Value;
}
}
if (AddrType == "Commercial" || AddrType == "OFFICE")
{
if (ggmd.Fee6 != null && ggmd.Fee7 != null && ggmd.Fee6 > 0 && ggmd.Fee6 < ggmd.Fee7)
{
PostFee2 = ggmd.Fee6.Value;
}
else if (ggmd.Fee6 != null && ggmd.Fee7 != null && ggmd.Fee7 > 0 && ggmd.Fee6 > ggmd.Fee7)
{
PostFee2 = ggmd.Fee7.Value;
}
}
decimal tweight = 0;
if (ggmd.Weight != null)
tweight = ggmd.Weight.Value * ggmd.GoodsNum.Value;
if (ggmd.Fee7 != null && tweight >= 1120 && ggmd.Fee7 > 0)
PostFee2 = ggmd.Fee7.Value;
if (ggmd.GoodsNum2 > 1 && PostFee2 > 0)
{
PostFee2 = (PostFee2 / ggmd.GoodsNum2.Value) * ggmd.GoodsNum.Value;
}
if (ggmd.FeeRate > 0 && GoodsFee2 > 0)
RateFee2 = ggmd.FeeRate.Value * 0.01M * GoodsFee2;
if (TotalPrice2 > 0)
TotalRMBPrice2 = TotalPrice2 *MRate;
if (GoodsFee2 > 0 && PostFee2 > 0)
TLR2 = TotalPrice2 - YJFee2 - GoodsFee2 - PostFee2 - TCFee2 - RateFee2;
GNum2 = ggmd.GoodsNum.Value;
GNum += GNum2;
TotalPrice += TotalPrice2;
TotalRMBPrice += TotalRMBPrice2;
YJFee += YJFee2;
GoodsFee += GoodsFee2;
TCFee += TCFee2;
PostFee += PostFee2;
RateFee += RateFee2;
TLR += TLR2;
}
GNum0 += GNum;
TotalPrice0 += TotalPrice;
TotalRMBPrice0 += TotalRMBPrice;
YJFee0 += YJFee;
GoodsFee0 += GoodsFee;
TCFee0 += TCFee;
PostFee0 += PostFee;
RateFee0 += RateFee;
TLR0 += TLR;
md.TotalPrice = TotalPrice.ToString("0.00");
md.TotalRMBPrice = TotalRMBPrice.ToString("0.00");
md.GoodsFee = GoodsFee.ToString("0.00");
md.GoodsNum = GNum;
md.LR = TLR.ToString("0.00");
if (GoodsFee > 0)
md.PGRate = (TotalPrice / GoodsFee).ToString("0.00");
}
}
}
var tmd = new HW_GoodsUserNew();
tmd.Name = "合计:";
tmd.TotalPrice = TotalPrice0.ToString("0.00");
tmd.TotalRMBPrice = TotalRMBPrice0.ToString("0.00");
tmd.GoodsFee = GoodsFee0.ToString("0.00");
tmd.GoodsNum = GNum0;
tmd.LR = TLR0.ToString("0.00");
slist.Add(tmd);
TableColumnCollection columns = new TableColumnCollection();
columns.Add("ShopName", "店铺", DbType.String, "");
columns.Add("Name", "人员", DbType.String, "");
columns.Add("GNum", "分配货号数", DbType.String, "");
columns.Add("TotalRMBPrice", "销售额RMB", DbType.String, "");
columns.Add("TotalPrice", "销售额USD", DbType.String, "");
columns.Add("GoodsNum", "销售数量", DbType.String, "");
columns.Add("GoodsFee", "货物成本", DbType.String, "");
columns.Add("PGRate", "营业额/货物成本", DbType.String, "");
columns.Add("LR", "预估利润", DbType.String, "");
MicrosoftExcel excel = new MicrosoftExcel();
return excel.Export(slist, columns);
}
#endregion
#region wish店铺授权
[WebMethod(EnableSession = true)]
public string WishGetAccessToken(int ShopId, string client_id, string client_secret, string code, string redirect_uri)
{
Pages.Login(this.Session);
WishNew obj = new WishNew();
obj.ShopId = ShopId;
obj.client_id = client_id;
obj.client_secret = client_secret;
obj.code = code;
obj.grant_type = "authorization_code";
obj.redirect_uri = redirect_uri;
string errormess = "";
string mess = obj.GetTokenV3(out errormess);
if (errormess != "")
return "错误:" + errormess;
return mess;
}
#endregion
#region 首页订单数
[WebMethod(EnableSession = true)]
public DT_DefaultDataNew GetDefaultDataForTM3()
{
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");
var model = DataNew.GetDefaultDataForTM3(CompanyId, sdate, sdate2, edate2);
//if (model != null)
//{
// model.AddPrice = model.TotalPrice * MRate;
//}
return model;
}
#endregion
#region 首页订单数
[WebMethod(EnableSession = true)]
public DT_DefaultDataNew GetDefaultDataForTM2(DateTime? st, Decimal MRate)
{
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 = Convert.ToDateTime(DateTime.Today.AddDays(-1).ToString("yyyy-MM-dd") + " 08:00");
DateTime edate = Convert.ToDateTime(DateTime.Today.ToString("yyyy-MM-dd") + " 08:00");
var model = DataNew.GetDefaultDataForTM2(CompanyId, st, st.Value.AddDays(-1), sdate, edate);
//if (model != null)
//{
// model.AddPrice = model.TotalPrice * MRate;
//}
return model;
}
#endregion
#region 读取菜单
[WebMethod(EnableSession = true)]
public List<JC_MenuListNew> GetListMenuNew()
{
Pages.Login(this.Session);
int UserID = Convert.ToInt32(Session["UserId"]);
int CompanyId = Convert.ToInt32(Session["CompanyId"]);
return DataNew.GetListMenuNew(UserID, CompanyId);
}
#endregion
#region 报表25
[WebMethod(EnableSession = true)]
public string GetReportTable25(DateTime? SDate, DateTime? EDate)
{
var obj = new BaseService();
string CompanyId = Session["CompanyId"].ToString();
string tj = "";
if (SDate != null)
tj += " a.InDate>='" + SDate.Value.ToString("yyyy-MM-dd") + "' ";
if (EDate != null)
tj += " and a.InDate<'" + EDate.Value.AddDays(1).ToString("yyyy-MM-dd") + "' ";
string sql = @"select InDate=CONVERT(varchar(10), a.indate, 23),b.Name,Num=count(distinct TrackCode) from DT_TrackCodeScan a
inner join JC_UserInfo b on a.BagUserId=b.UserId
where " + tj + " group by CONVERT(varchar(10), a.indate, 23),b.Name";
DataTable dt = obj.GetReportData(sql);
return GetReport3(dt, 28);
}
#endregion
#region 报表25
[WebMethod(EnableSession = true)]
public string GetExcelTable25(DateTime? SDate, DateTime? EDate)
{
var obj = new BaseService();
string CompanyId = Session["CompanyId"].ToString();
string tj = "";
if (SDate != null)
tj += " a.InDate>='" + SDate.Value.ToString("yyyy-MM-dd") + "' ";
if (EDate != null)
tj += " and a.InDate<'" + EDate.Value.AddDays(1).ToString("yyyy-MM-dd") + "' ";
string sql = @"select InDate=CONVERT(varchar(10), a.indate, 23),b.Name,Num=count(distinct TrackCode) from DT_TrackCodeScan a
inner join JC_UserInfo b on a.BagUserId=b.UserId
where " + tj + " group by CONVERT(varchar(10), a.indate, 23),b.Name";
DataTable dt = obj.GetReportData(sql);
return GetExcelReport(dt, 28);
}
#endregion
#region 计算费用
[WebMethod(EnableSession = true)]
public int GetModel_OrderFee2()
{
PagesNew.Login(this.Session);
int a = DataNew.GetModel_OrderFee2();
return a;
}
#endregion
#region 货物SKU
[WebMethod(EnableSession = true)]
public string GetGoodSKUKC(string GoodsCode)
{
PagesNew.Login(this.Session);
try
{
var obj = new BaseService();
string CompanyId = Session["CompanyId"].ToString();
string tj = "";
if (GoodsCode != "")
{
tj += " and (b.SKU1='" + GoodsCode + "' or b.SKU2='" + GoodsCode + "' or b.SKU3='" + GoodsCode + "' or b.SKU4='" + GoodsCode + "' ) ";
}
string sql = @"
select SKU1,KCNum=SUM(a.KCNum) from HW_GoodsInDetail a with(nolock)
inner join HW_GoodsDetail b with(nolock) on a.DetailId=b.DetailId
where a.storeid in (6,9,11) and a.OrderGoodsId=0 and a.KCNum>0 " + tj + " group by b.sku1 ";
ErrorFollow.TraceWrite("GetFedex", "", sql);
DataTable dt = obj.GetReportData(sql);
return GetReport2(dt, 22);
}
catch (Exception ex)
{
ErrorFollow.TraceWrite("GetFedex", "", ex.Message);
return "";
}
}
#endregion
#region 货物SKU
[WebMethod(EnableSession = true)]
public string GetExcelGoodSKUKC(string GoodsCode)
{
PagesNew.Login(this.Session);
var obj = new BaseService();
string CompanyId = Session["CompanyId"].ToString();
string tj = "";
if (GoodsCode != "")
{
tj += " and (b.SKU1='" + GoodsCode + "' or b.SKU2='" + GoodsCode + "' or b.SKU3='" + GoodsCode + "' or b.SKU4='" + GoodsCode + "' ) ";
}
string sql = @"
select SKU1,KCNum=SUM(a.KCNum) from HW_GoodsInDetail a with(nolock)
inner join HW_GoodsDetail b with(nolock) on a.DetailId=b.DetailId
where a.storeid in (6,9,11) and a.OrderGoodsId=0 and a.KCNum>0 " + tj + " group by b.sku1 ";
DataTable dt = obj.GetReportData(sql);
return GetExcelReport(dt, 22);
}
#endregion
}
}