From 48e05e2c2cb9deecd8ab0d4efda2702fca80325f Mon Sep 17 00:00:00 2001 From: chenwenkai <1084072318@qq.com> Date: Tue, 14 Jan 2025 15:16:09 +0800 Subject: [PATCH] =?UTF-8?q?temu=E6=88=90=E6=9C=AC=E5=88=86=E9=85=8D?= =?UTF-8?q?=E4=BA=BA=E5=91=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- TradeManage/HuoWu/HW_GoodsAddForTM.aspx | 2 +- TradeManage/HuoWuServiceNew.asmx.cs | 2 +- TradeManageNew/DD_OrderServiceNew.asmx.cs | 4 +- TradeManageNew/DataNew.cs | 45 ++++++++++++-- TradeManageNew/HuoWuServiceNew.asmx.cs | 76 ++++++++++++++++++++++- TradeManageNew/ModelNew.cs | 30 +++++++++ 6 files changed, 149 insertions(+), 10 deletions(-) diff --git a/TradeManage/HuoWu/HW_GoodsAddForTM.aspx b/TradeManage/HuoWu/HW_GoodsAddForTM.aspx index 451872a..7d87bc3 100644 --- a/TradeManage/HuoWu/HW_GoodsAddForTM.aspx +++ b/TradeManage/HuoWu/HW_GoodsAddForTM.aspx @@ -671,7 +671,7 @@ success: function (data) { var JinJia = (GoodsModel.InPrice / usdfeerate).toFixed(2) var TouCheng = (GoodsModel.Solid * 130).toFixed(2) - var HuoWuShuiFei = (GoodsModel.Solid * 130).toFixed(2) + var HuoWuShuiFei = (GoodsModel.FeeRate * GoodsModel.InPrice * 0.01 / usdfeerate).toFixed(2) var YuGuJiaGe = Number(JinJia) + Number(TouCheng) + Number(HuoWuShuiFei) TemuChengBen = { JinJia: JinJia, diff --git a/TradeManage/HuoWuServiceNew.asmx.cs b/TradeManage/HuoWuServiceNew.asmx.cs index fbc2346..f664dfb 100644 --- a/TradeManage/HuoWuServiceNew.asmx.cs +++ b/TradeManage/HuoWuServiceNew.asmx.cs @@ -4606,7 +4606,7 @@ namespace TradeManage } #endregion - + #region 返回 [WebMethod(EnableSession = true)] public HW_GoodsDetailNew GetGoodsModelForBF(int detailid) diff --git a/TradeManageNew/DD_OrderServiceNew.asmx.cs b/TradeManageNew/DD_OrderServiceNew.asmx.cs index 239ac16..1146b96 100644 --- a/TradeManageNew/DD_OrderServiceNew.asmx.cs +++ b/TradeManageNew/DD_OrderServiceNew.asmx.cs @@ -26324,11 +26324,11 @@ namespace TradeManageNew } [WebMethod(EnableSession = true)] - public JsonModel> GetListTemuChengBen(int GoodsId) + public JsonModel> GetListTemuChengBen(int GoodsId) { PagesNew.Login(this.Session); - var resultModel = new JsonModel>(); + var resultModel = new JsonModel>(); resultModel.DataSource = DataNew.GetTemuChengBen(GoodsId); return resultModel; } diff --git a/TradeManageNew/DataNew.cs b/TradeManageNew/DataNew.cs index 1977aa0..7816203 100644 --- a/TradeManageNew/DataNew.cs +++ b/TradeManageNew/DataNew.cs @@ -18106,6 +18106,20 @@ else if @platid=23 begin update HW_GoodsInfo set guserid_temu=@userid,groupname_temu=@name where goodsid=@goodsid end +IF EXISTS ( select 1 FROM TemuChengBen where goodsid=@goodsid) + BEGIN + update TemuChengBen set mUserId=@userid where goodsid=@goodsid + END +else + BEGIN + insert into TemuChengBen([GoodsId],[JinJia],[YunFei],[TouCheng],[HuoWuShuiFei],[YuGuJiaGe] ,[CreateUserId],[CreateTime],[mUserId]) + select goodsid, CONVERT(DECIMAL(10, 2), InPrice/6.3) AS jinjia + ,null, CONVERT(DECIMAL(10, 2), Solid*130) AS shuifei,CONVERT(DECIMAL(10, 2), FeeRate*InPrice*0.01/6.3) AS shuifei,null,1,GETDATE(),@userid + from HW_GoodsInfo where GoodsId=@goodsid + END + + + "; Database db = DatabaseFactory.CreateDatabase(); DbCommand cmd = db.GetSqlStringCommand(tsql); @@ -26602,6 +26616,25 @@ end } + /// + /// 获取编号分配销量 + /// + /// + /// + public static List GetGoodsforPlan() + { + var sql = @" select a.GoodsCode,a.GoodsName,'https://www.kferp.net/'+ REPLACE((case when ISNULL(a.FirstImgUrl,'')='' then a.FirstImgUrl else a.FirstImgUrl end),'../','') FirstImgUrl,UserName=groupname_temu from HW_GoodsInfo a with(nolock) left join hw_goodsextra b with(nolock) on a.GoodsId=b.goodsid left join HW_GoodsUserPlanCount c with(nolock) on a.GoodsId = c.GoodsId where a.state=1 and a.companyid=1 and Isnull(a.IsYC,0)=0 and isnull(a.IsEnd,0)=0"; + + //var sql = @" select top " + count + " a.DetailId,a.SKU1 SKU,b.GoodsCode,b.GoodsName, case when ISNULL(a.FirstImgUrl,'')='' then b.FirstImgUrl else a.FirstImgUrl end FirstImgUrl,ISNULL(b.Solid,0) SingleSolid, ISNULL(WestNum,0) WestNum, ISNULL(WestNum,0)*ISNULL(b.Solid,0) WestSolids, ISNULL(EastNum,0) EastNum, ISNULL(EastNum,0)*ISNULL(b.Solid,0) EastSolids,ISNULL(WestNum,0)+ISNULL(EastNum,0) TotalNum, (ISNULL(WestNum,0)+ISNULL(EastNum,0))*ISNULL(b.Solid,0) TotalSolid from HW_GoodsDetail a with(nolock) inner join HW_GoodsInfo b on a.GoodsId=b.GoodsId order by (ISNULL(WestNum,0)+ISNULL(EastNum,0))*ISNULL(b.Solid,0) desc"; + + Database db = DatabaseFactory.CreateDatabase(); + DbCommand cmd = db.GetSqlStringCommand(sql); + + return db.ExecuteDataTable(cmd).ToList(); + } + + + #region 保存订单快递运费预估表 public static void SaveOrderPostFeeEstimate(OrderPostFeeEstimate md) { @@ -30577,12 +30610,12 @@ where a.OrderId in (" + orderids + ") "; { var sql = @"if @id>0 begin - update TemuChengBen set JinJia=@JinJia,YunFei=@YunFei,TouCheng=@TouCheng,HuoWuShuiFei=@HuoWuShuiFei,YuGuJiaGe=@YunFei,CreateTime=GETDATE(),CreateUserId=@CreateUserId where ID=@id + update TemuChengBen set JinJia=@JinJia,YunFei=@YunFei,TouCheng=@TouCheng,HuoWuShuiFei=@HuoWuShuiFei,YuGuJiaGe=@YunFei,CreateTime=GETDATE(),CreateUserId=@CreateUserId,mUserId=@mUserId where ID=@id end else begin - insert into TemuChengBen(GoodsId,JinJia,YunFei,TouCheng,HuoWuShuiFei,YuGuJiaGe,CreateUserId,CreateTime) values(@GoodsId,@JinJia,@YunFei,@TouCheng,@HuoWuShuiFei,@YuGuJiaGe,@createUserId,GETDATE()) + insert into TemuChengBen(GoodsId,JinJia,YunFei,TouCheng,HuoWuShuiFei,YuGuJiaGe,CreateUserId,CreateTime,mUserId) values(@GoodsId,@JinJia,@YunFei,@TouCheng,@HuoWuShuiFei,@YuGuJiaGe,@createUserId,GETDATE(),@mUserId) set @id=SCOPE_IDENTITY() end select @id"; @@ -30597,6 +30630,7 @@ select @id"; db.AddInParameter(cmd, "@HuoWuShuiFei", DbType.Decimal, md.HuoWuShuiFei); db.AddInParameter(cmd, "@YuGuJiaGe", DbType.Decimal, md.YuGuJiaGe); db.AddInParameter(cmd, "@createUserId", DbType.Int32, md.CreateUserId); + db.AddInParameter(cmd, "@mUserId", DbType.Int32, md.mUserId); int a = Convert.ToInt32(db.ExecuteScalar(cmd)); return a; //db.ExecuteNonQuery(cmd); @@ -30609,20 +30643,21 @@ select @id"; /// /// /// - public static List GetTemuChengBen(int GoodsId) + public static List GetTemuChengBen(int GoodsId) { try { string tsql = @" -SELECT top 1 a.[ID],a.[GoodsId],c.GoodsCode,[JinJia],[YunFei],[TouCheng],[HuoWuShuiFei],[YuGuJiaGe],[CreateUserId],[CreateTime] +SELECT top 1 a.[ID],a.[GoodsId],c.GoodsCode,[JinJia],[YunFei],[TouCheng],[HuoWuShuiFei],[YuGuJiaGe],[CreateUserId],[CreateTime],a.mUserId,u.Name as UserName FROM [dbo].[TemuChengBen] a inner join HW_GoodsInfo c on a.GoodsId=c.GoodsId +left join JC_UserInfo u on a.mUserId=u.UserId where a.GoodsId = @GoodsId order by a.CreateTime desc"; Database db = DatabaseFactory.CreateDatabase(); DbCommand cmd = db.GetSqlStringCommand(tsql); db.AddInParameter(cmd, "@GoodsId", DbType.Int32, GoodsId); DataTable tb = db.ExecuteDataTable(cmd); - return tb.ToList(); + return tb.ToList(); } catch (Exception ex) { diff --git a/TradeManageNew/HuoWuServiceNew.asmx.cs b/TradeManageNew/HuoWuServiceNew.asmx.cs index 3b2a81e..b891c94 100644 --- a/TradeManageNew/HuoWuServiceNew.asmx.cs +++ b/TradeManageNew/HuoWuServiceNew.asmx.cs @@ -5776,6 +5776,80 @@ namespace TradeManageNew return "ServerCookies/" + filename; } + + #region 导出编号分配销量 + [WebMethod(EnableSession = true)] + public string GetList_GoodsForPlan() + { + var obj = new HuoWuData(); + var list = DataNew.GetGoodsforPlan(); + if (list == null) + return ""; + + + //创建工作薄 + HSSFWorkbook workbook = new HSSFWorkbook(); + HSSFSheet sheet = (HSSFSheet)workbook.CreateSheet("Sheet1"); + sheet.SetColumnWidth(0, 18 * 256); + var drawing = sheet.CreateDrawingPatriarch(); + + //填充列标题以及样式 + int rowsNum = 0; //行号 + HSSFRow headerRow = (HSSFRow)sheet.CreateRow(rowsNum); + + headerRow.CreateCell(0, CellType.STRING).SetCellValue("图片"); + headerRow.CreateCell(1, CellType.STRING).SetCellValue("SKU"); + headerRow.CreateCell(4, CellType.STRING).SetCellValue("人员"); + + rowsNum = 1; //行号 + foreach (var link in list) + { + var pictureData = GetImageFromUrl(link.FirstImgUrl); + if (pictureData != null) + { + var pictureIndex = workbook.AddPicture(pictureData, PictureType.PNG); + + // 在每一行的第一列插入图片 + var pictureCell = sheet.CreateRow(rowsNum).CreateCell(0); + sheet.GetRow(rowsNum).Height = 80 * 20; + pictureCell.CellStyle = workbook.CreateCellStyle(); + var anchor = new HSSFClientAnchor(0, 0, 0, 0, 0, rowsNum, 1, rowsNum + 1); + anchor.AnchorType = 2; + var picture = drawing.CreatePicture(anchor, pictureIndex); + } + else + { + var _dataCell = sheet.CreateRow(rowsNum).CreateCell(0); + sheet.GetRow(rowsNum).Height = 80 * 20; + _dataCell.SetCellValue(""); + } + + + // 在每一行的第二列插入数据 + + sheet.GetRow(rowsNum).CreateCell(2).SetCellValue(link.GoodsCode); + sheet.GetRow(rowsNum).CreateCell(3).SetCellValue(link.GoodsName); + sheet.GetRow(rowsNum).CreateCell(4).SetCellValue(link.UserName); + + rowsNum++; + } + string filename = Guid.NewGuid().ToString() + ".xls"; + string DirectoryName = AppDomain.CurrentDomain.BaseDirectory + "ServerCookies"; + if (System.IO.Directory.Exists(DirectoryName) == false) System.IO.Directory.CreateDirectory(DirectoryName); + string ServerFileName = DirectoryName + "/" + filename; + //保存 + using (FileStream fs = new FileStream(ServerFileName, FileMode.Create, FileAccess.Write)) + { + workbook.Write(fs); + } + workbook.Dispose(); + return "ServerCookies/" + filename; + } + + + #endregion + + // 从URL获取图片数据 public byte[] GetImageFromUrl(string url) { @@ -7481,7 +7555,7 @@ namespace TradeManageNew return rmodel; } - + #endregion diff --git a/TradeManageNew/ModelNew.cs b/TradeManageNew/ModelNew.cs index 9f1ec11..9546a7a 100644 --- a/TradeManageNew/ModelNew.cs +++ b/TradeManageNew/ModelNew.cs @@ -8786,6 +8786,18 @@ namespace TradeManageNew public string UserName { get; set; } } + public class GoodsForGoodsPlan + { + + + public string GoodsCode { get; set; } + public string GoodsName { get; set; } + public string FirstImgUrl { get; set; } + public string UserName { get; set; } + } + + + /// /// 订单Fedex费用详情 /// @@ -11230,6 +11242,24 @@ namespace TradeManageNew public decimal? YuGuJiaGe { get; set; } public int? CreateUserId { get; set; } + public int? mUserId { get; set; } + + } + + public class TemuChengBen_List + { + public int ID { get; set; } + + public int GoodsId { get; set; } + public decimal? JinJia { get; set; } + public decimal? YunFei { get; set; } + public decimal? TouCheng { get; set; } + public decimal? HuoWuShuiFei { get; set; } + public decimal? YuGuJiaGe { get; set; } + public int? CreateUserId { get; set; } + public int? mUserId { get; set; } + public string UserName { get; set; } + }