zhuyiyi 8 months ago
parent
commit
6df64683e7

+ 38 - 27
SiteCore/Handler/sync.order.cs

@@ -34,6 +34,8 @@ using System.Security.Policy;
 using System.Text;
 using System.Text.RegularExpressions;
 using System.Threading;
+using System.Web.UI;
+using System.Web;
 using System.Web.UI.WebControls;
 using Utils;
 using Utils.Serialization;
@@ -12566,34 +12568,39 @@ namespace SiteCore.Handler
                 {
                     returnErrorMsg("文件地址为空");
                     return;
+
                 }
-                CeErpTrade ceErpTrade = CeErpTrade.Get(tid);
-                if (ceErpTrade == null)
-                {
-                    returnErrorMsg("找不到订单");
-                    return;
-                }
-                DataTable dt = DbHelper.DbConn.ExecuteDataset(string.Format("select OrderState from ce_erptradecell where tid = '{0}'", tid)).Tables[0];
-                bool isSend = false;
-                if (dt != null && dt.Rows.Count > 0)
+                CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(tid);
+                if (ceErpTradeCell != null)
                 {
-                    foreach (DataRow row in dt.Rows)
+                    CeErpTrade ceErpTrade = CeErpTrade.Get(ceErpTradeCell.tid);
+                    if (ceErpTrade == null)
                     {
-                        if (Convert.ToInt16(row["OrderState"]) > 6)
-                        {
-                            isSend = true;
-                        }
+                        returnErrorMsg("找不到订单");
+                        return;
                     }
-                    if (isSend)
+                    DataTable dt = DbHelper.DbConn.ExecuteDataset(string.Format("select OrderState from ce_erptradecell where tid = '{0}'", ceErpTradeCell.tid)).Tables[0];
+                    bool isSend = false;
+                    if (dt != null && dt.Rows.Count > 0)
                     {
-                        returnErrorMsg("已发货无法修改");
+                        foreach (DataRow row in dt.Rows)
+                        {
+                            if (Convert.ToInt16(row["OrderState"]) > 6 && tid.IndexOf("S_") == -1)
+                            {
+                                isSend = true;
+                            }
+                        }
+                        if (isSend)
+                        {
+                            returnErrorMsg("已发货无法修改");
+                            return;
+                        }
+                        ceErpTrade.Attachments = atta;
+                        ceErpTrade.Update();
+                        LogHelper.addLog(tid, CurrentUser.UserID, "上传文件地址", 6);
+                        returnSuccessMsg("上传成功!");
                         return;
                     }
-                    ceErpTrade.Attachments = atta;
-                    ceErpTrade.Update();
-                    LogHelper.addLog(tid, CurrentUser.UserID, "上传文件地址", 6);
-                    returnSuccessMsg("上传成功!");
-                    return;
                 }
             }
             returnErrorMsg("找不到订单");
@@ -12603,14 +12610,18 @@ namespace SiteCore.Handler
             string tid = GetPostString("tid");
             if (!string.IsNullOrEmpty(tid))
             {
-
-                CeErpTrade ceErpTrade = CeErpTrade.Get(tid);
-                if (ceErpTrade == null)
+                CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(tid);
+                if (ceErpTradeCell != null)
                 {
-                    returnErrorMsg("找不到订单");
+                    CeErpTrade ceErpTrade = CeErpTrade.Get(ceErpTradeCell.tid);
+                    if (ceErpTrade == null)
+                    {
+                        returnErrorMsg("找不到订单");
+                        return;
+                    }
+                    returnSuccess(JsonConvert.SerializeObject(new { url = ceErpTrade.Attachments }));
+                    return;
                 }
-                returnSuccess(JsonConvert.SerializeObject(new { url = ceErpTrade.Attachments }));
-                return;
             }
             returnErrorMsg("找不到订单");
         }

+ 54 - 0
SiteCore/taobao/jiemiUtils.cs

@@ -0,0 +1,54 @@
+using NPOI.OpenXmlFormats.Dml.Diagram;
+using NPOI.OpenXmlFormats.Shared;
+using System;
+using System.Collections.Generic;
+using System.IO;
+using System.Linq;
+using System.Runtime.InteropServices;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace SiteCore.taobao
+{
+    public class jiemiUtils
+    {
+        [DllImport("DrvInterface64.dll", CharSet = CharSet.Unicode)]
+        public static extern uint DecFile(string filename);
+
+        [DllImport("DrvInterface64.dll", CharSet = CharSet.Unicode)]
+        public static extern int IsFileEncrypted(string filename);//返回1为加密,0为未被加密
+        [DllImport("DrvInterface64.dll", CharSet = CharSet.Ansi)]
+        public static extern void CreateUserKey(StringBuilder key, int len);
+        [DllImport("DrvInterface64.dll", CharSet = CharSet.Ansi)]
+        public static extern int InitAesKey(StringBuilder key, int len);
+
+        [DllImport("DrvInterface64.dll")]
+        public static extern int IsInitedAesKey();
+
+        public static void ossFileDecrypt(string filePath)
+        {
+            int IsFileEncrypt = IsFileEncrypted(filePath);
+            if (IsFileEncrypt == 1 && File.Exists(filePath))
+            {
+                string key = "gBQnlxiBb7MthH9644V0W0pFwqYZgyy7";
+                var sb = new StringBuilder(key);
+
+                //Linux系统的接口要调用一次,Windows系统要调用两次
+                CreateUserKey(sb, key.Length);
+                CreateUserKey(sb, key.Length); //破解用dse生成的文件,需要调2次。
+                int result = InitAesKey(sb, sb.Length);
+                result = IsInitedAesKey();
+                if (result != 1)
+                {
+
+                }
+                uint a = DecFile(filePath);
+                if (a != 0)
+                {
+
+                }
+            }
+        }
+
+    }
+}

+ 47 - 2
Web/EDelivery/js/ChangeDelivery.js

@@ -152,7 +152,7 @@ function actionRenderer(e) {
         html += getGridBtn("edit", "成本登记", "showPriceWin('" + ctid + "','" + record.payment_cyt + "','" + record.SupplierName + "')");
     }
     if (!!record.attachments) {
-        html += getGridBtn("view", "下载附件", "downAtta('" + record.attachments + "')");
+        html += getGridBtn("view", "下载附件", "downAddressFile('" + record.attachments + "')");
     }
     return html;
 }
@@ -574,7 +574,6 @@ function newPageSearchFn() {
 }
 
 $(function () {
-    doConnect();
     if (openPageData != "") {
         var s = openPageData;
         grid.load({
@@ -626,5 +625,51 @@ function cancelWaybillFn() {
         resultShow(data, "grid.reload();");
     });
 }
+function downAddressFile(url) {
+    var pdata = "url=" + url;
+
+    var xhr = new XMLHttpRequest(); // 创建XMLHttpRequest实例
+    xhr.open('POST', "../plug/uploadFileOss.aspx"); // 打开下载文件请求
+    xhr.responseType = "blob";
+    xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded")
+    xhr.onloadstart = function () {
+    };
+    xhr.onprogress = function (event) {
+
+    };
+    xhr.onerror = function () {
+        progressHide();
+    }
+    xhr.ontimeout = function () {
+        progressHide();
+    }
+    xhr.onloadend = function () {
+        if (xhr.status === 200) {
+            try {
+                let blob = xhr.response;
+                let fileName = xhr.getResponseHeader("Content-Disposition").split('filename=')[1];
+                fileName = decodeURIComponent(fileName);
+
+                let url = URL.createObjectURL(blob);
+                let a = document.createElement('a');
+                a.href = url;
+                a.download = fileName;
+                document.body.appendChild(a);
+                a.click();
+                document.body.removeChild(a);
+                window.URL.revokeObjectURL(url);
+            } catch (e) {
+                progressHide();
+            }
+
+
+        } else {
+
+        }
+        progressHide();
+
+    };
+    xhr.send(pdata); // 发送下载文件请求
+}
 
 

+ 1 - 1
Web/EOrder/OrderList.aspx

@@ -701,7 +701,7 @@
             <tr>
                 <td class="td1"></td>
                 <td class="td2">
-                    <input type="file" id="address_file" accept="xlsx,xls" />
+                    <input type="file" id="address_file" accept="application/vnd.openxmlformats-officedocument.spreadsheetml.sheet,application/vnd.ms-excel " />
                 </td>
             </tr>
             <tr>

+ 1 - 1
Web/EOrder/js/p_order.js

@@ -55,7 +55,7 @@ function orderAction(e) {
         html += getGridBtn("edit", "spu", "changeSpuId('" + record.tid + "','" + id + "')");
     }
     if (record.OrderState < 7) {
-        html += getGridBtn("import", "上传地址", "uploaderAddress('" + record.tid + "')");
+        html += getGridBtn("word", "上传地址", "uploaderAddress('" + record.ctid + "')");
     }
     //html += getGridBtn("edit", "删除", "deleteFn('" + id + "')");
     //html += getGridBtn("edit", "重置", "resetFn('" + id + "')");

+ 16 - 0
Web/plug/uploadFileOss.aspx

@@ -0,0 +1,16 @@
+<%@ Page Language="C#" AutoEventWireup="true" CodeFile="uploadFileOss.aspx.cs" Inherits="plug_uploadFileOss" %>
+
+<!DOCTYPE html>
+
+<html xmlns="http://www.w3.org/1999/xhtml">
+<head runat="server">
+<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
+    <title></title>
+</head>
+<body>
+    <form id="form1" runat="server">
+        <div>
+        </div>
+    </form>
+</body>
+</html>

+ 76 - 0
Web/plug/uploadFileOss.aspx.cs

@@ -0,0 +1,76 @@
+using BizCom;
+using NPOI.SS.Formula.Functions;
+using SiteCore;
+using SiteCore.taobao;
+using System;
+using System.Collections.Generic;
+using System.IO;
+using System.Linq;
+using System.Net;
+using System.Text;
+using System.Web;
+using System.Web.UI;
+using System.Web.UI.WebControls;
+using Utils.ImageUtils;
+
+public partial class plug_uploadFileOss : System.Web.UI.Page
+{
+    protected void Page_Load(object sender, EventArgs e)
+    {
+        string file_url = Request["url"];
+        try
+        {
+            if (file_url == null)
+            {
+                Response.Write("{\"res\":\"0\",\"msg\":\"错误的下载访问!\"}");
+                Response.End();
+                return;
+            }
+            Uri uri = new Uri(file_url);
+
+            // 获取路径中的文件名(包含后缀)
+            string fileName = System.IO.Path.GetFileName(uri.AbsolutePath);
+            string filePath = "D://temp/" + fileName;
+            WebClient webClient = new WebClient();
+            if (Directory.Exists(filePath))
+            {
+                Directory.CreateDirectory(filePath);
+            }
+            webClient.DownloadFile(file_url, filePath);
+            jiemiUtils.ossFileDecrypt(filePath);
+            FileStream fs = new FileStream(filePath, FileMode.Open);
+            byte[] bytes = new byte[(int)fs.Length];
+            fs.Read(bytes, 0, bytes.Length);
+            fs.Close();
+            Response.Clear();
+            //
+            Response.ClearContent();
+            Response.ClearHeaders();
+
+            Response.ContentType = "application/octet-stream";
+            //通知浏览器下载文件而不是打开\\fileDownload=true; path=/
+            Response.AddHeader("Set-Cookie", "fileDownload=true; path=/;");
+            //Response.AddHeader("Cache-Control", "no-cache, no-store, must-revalidate");
+            Response.AddHeader("Content-Disposition", "attachment; filename=" + HttpUtility.UrlEncode(fileName, System.Text.Encoding.UTF8));
+            Response.AddHeader("Content-Length", bytes.Length.ToString());
+            Response.AddHeader("Access-Control-Expose-Headers", "Content-Disposition");
+            Response.BinaryWrite(bytes);
+            Response.Flush();
+            Response.End();
+
+            File.Delete(filePath);
+            return;
+        }
+        catch (Exception ex)
+        {
+            Response.Write("{\"res\":\"0\",\"msg\":\"发生错误!" + ex.Message + "!\"}");
+            Response.End();
+            return;
+        }
+
+    }
+
+
+
+
+}