Browse Source

修改异常订单逻辑

zhuyiyi 1 week ago
parent
commit
ab558e821c

+ 1 - 1
BizCom/Dao/CeErpSupplierProductTime.cs

@@ -70,7 +70,7 @@ namespace BizCom
 
         private string _dayDeadLine = "00:00";
         /// <summary>
-        /// 当日截稿时间
+        /// 当日截稿时间设置0不用当日发货
         /// </summary>
         [Property]
         public string dayDeadLine

+ 4 - 0
SiteCore/taobao/apiHelper.cs

@@ -261,6 +261,10 @@ namespace SiteCore
                 XLog.SaveLog(0, "额外发货:" + orderid + "-" + comCode + "-" + out_Sid);
             }
             string res = Base_Request(ro_json, send_api);
+            if (dt != null && dt.Rows.Count > 0)
+            {
+                XLog.SaveLog(0, "额外发货:" + res);
+            }
             if (res.Contains("上传额外运单信息成功"))
             {
                 res = res.Replace("上传额外运单信息成功", "发货成功true");

+ 134 - 0
SiteCore/taobao/commonHelper.cs

@@ -487,6 +487,140 @@ namespace SiteCore
             return 0;
         }
 
+        public static void setDeliveryUnusualOrder2()
+        {
+            StringBuilder sql = new StringBuilder();
+            sql.AppendFormat("select ctid,IsSF,seller_memo,SupplierId,productId,FinishPlaceTime,ProductCount from view_ErpTradeCell where orderstate=6 and unusualTag=0 and FinishPlaceTime is not null AND DATEDIFF( HH, FinishPlaceTime, GETDATE( ) ) > 24 AND DATEDIFF( DAY, FinishPlaceTime, GETDATE( ) ) < 20  and IsXianHuo=0 and IsSample=0;");
+            DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
+            List<string> tLst = new List<string>();
+            if (dt != null && dt.Rows.Count > 0)
+            {
+                foreach (DataRow row in dt.Rows)
+                {
+                    try
+                    {
+
+                        int supplierId = Convert.ToInt32(row["SupplierId"]);
+                        int productId = Convert.ToInt32(row["productId"]);
+                        if (supplierId == 0 || productId == 0)
+                        {
+                            continue;
+                        }
+                        StringBuilder timerSql = new StringBuilder();
+                        timerSql.AppendFormat("SELECT * FROM CE_ErpSupplierProductTime WHERE supplierId={0}", supplierId);
+                        DataTable timerTable = DbHelper.DbConn.ExecuteDataset(timerSql.ToString()).Tables[0];
+                        //没配置时间
+                        if (timerTable == null || timerTable.Rows.Count == 0)
+                        {
+                            continue;
+                        }
+
+                        string[] productIds = null;
+                        string finishPlaceTime = row["FinishPlaceTime"].ToString();
+                        string sellmer_mome = row["seller_memo"].ToString();
+                        string txtCount = row["ProductCount"].ToString();
+                        DateTime placeTime = DateTime.Now;
+
+                        if (string.IsNullOrEmpty(finishPlaceTime))
+                        {
+                            continue;
+                        }
+                        placeTime = DateTime.Parse(finishPlaceTime);
+                        foreach (DataRow dr in timerTable.Rows)
+                        {
+                            string txtIds = dr["productId"].ToString();
+                            string[] crafts = { };
+                            int count = Convert.ToUInt16(dr["quantity"]);
+                            if (string.IsNullOrEmpty(txtIds))
+                            {
+                                continue;
+                            }
+                            if (count > 0)
+                            {
+                                int quantity = handleProductCount(txtCount, true);
+                                //订单数量大于写入的数量则跳过
+                                if (quantity > count)
+                                {
+                                    continue;
+                                }
+                            }
+                            productIds = txtIds.Split(',');
+                            if (productIds.Contains(productId.ToString()))
+                            {
+                                string textCraft = dr["craft"].ToString();
+                                textCraft = textCraft.Replace(",", ",");//统一格式
+                                if (!string.IsNullOrEmpty(textCraft))
+                                {
+                                    crafts = textCraft.Split(',');
+                                }
+                                if (crafts.Length > 0)
+                                {
+                                    bool isinCraft = false;
+                                    for (int i = 0; i < crafts.Length; i++)
+                                    {
+                                        if (sellmer_mome.IndexOf(crafts[i]) >= 0)
+                                        {
+                                            isinCraft = true;
+                                            break;
+                                        }
+                                    }
+                                    //有写工艺并且备注中没匹配中则跳过
+                                    if (!isinCraft)
+                                    {
+                                        continue;
+                                    }
+                                }
+                                DateTime deadLine = DateTime.Parse(dr["deadLine"].ToString());
+                                DateTime dayDeadLine = DateTime.Parse(dr["dayDeadLine"].ToString());
+
+                                int sendDay = Convert.ToInt16(dr["sendDay"]);
+
+                                //订单发货时间
+                                DateTime sendtime = placeTime;
+
+                                //下单时间小于当日发货时间则不用判断
+                                //当日发货必须发货
+                                if (dayDeadLine.Hour > 0 && dayDeadLine.Hour > placeTime.Hour)
+                                {
+                                    sendtime = DateTime.Parse(placeTime.ToString("yyyy-MM-dd 23:59:59"));
+                                }
+                                else if (deadLine.Hour > 0 && deadLine.Hour > placeTime.Hour)
+                                {
+                                    //在截稿时间之前下单的可以减去一天时间
+                                    sendDay = Math.Max(1, sendDay - 1);
+                                    sendtime = DateTime.Parse(placeTime.ToString("yyyy-MM-dd 23:59:59")).AddDays(sendDay);
+                                }
+                                else
+                                {
+                                    sendtime = DateTime.Parse(placeTime.ToString("yyyy-MM-dd 23:59:59")).AddDays(sendDay);
+                                }
+
+                                //判断有没有到发货日期大于0还没到发货时间
+                                if (DateTime.Compare(sendtime.Date, DateTime.Now.Date) < 0)
+                                {
+                                    tLst.Add(row["ctid"].ToString());
+                                    //匹配到就不要继续匹配了   
+                                    break;
+                                }
+                            }
+                        }
+                    }
+                    catch (Exception ex)
+                    {
+                        XLog.SaveLog(0, row["ctid"].ToString() + "更新发货异常订单错误:" + ex);
+                    }
+                }
+            }
+            if (tLst.Count > 0)
+            {
+                string needctids = string.Join(",", tLst.ToArray());
+                StringBuilder updsql = new StringBuilder();
+                //DateTime unusualTime = new DateTime();
+                updsql.AppendFormat("update ce_erptradecell with(rowlock) set unusualTag=5,UnusualTime=getDate() where ctid in ({0});", needctids);
+                DbHelper.DbConn.ExecuteNonQuery(updsql.ToString());
+            }
+        }
+
         public static void setDeliveryUnusualOrder()
         {
             try

+ 16 - 1
Web/EAfterSale/js/Handling.js

@@ -303,7 +303,7 @@ function handleFn(eid) {
 
     }
     showTxtInputReason();
-
+    setLastMiniComBo();
     let supplierResponsible_list = rec.supplierResponsible.split("-");
     if (supplierResponsible_list.length > 1) {
         $("#txtInputReason").val(supplierResponsible_list[1]);
@@ -1327,6 +1327,7 @@ function changeReason3Fn(e) {
     var reasonData = getSiteReason(v);
     mini.get("#txtReason4").setData(reasonData);
     changeDuctPrice();
+    setLastMiniComBo()
 }
 function changeReason4Fn(e) {
     var v = e.value;
@@ -1390,3 +1391,17 @@ function showTxtInputReason() {
     }
 }
 
+function setLastMiniComBo() {
+    let combo = mini.get("txtReason4")
+    let text1 = mini.get("txtReason1").getText();
+    let text2 = mini.get("txtReason2").getText();
+    let text3 = mini.get("txtReason3").getText();
+    let valuefromselect = true;
+    if (text1 == "客户问题" && text2 == "信息不全" && text3 == "无照片反馈问题") {
+        valuefromselect = false;
+    }
+    combo.set({
+        valueFromSelect: valuefromselect,
+    })
+}
+

+ 8 - 2
ecomServer/MainForm.cs

@@ -1625,19 +1625,24 @@ namespace ErpServer
             log.OperateTime = DateTime.Now;
             log.Create();
         }
-
+        bool isnUsualOrderSync = false;
         /// <summary>
         /// 更新异常订单状态
         /// </summary>
         /// <param name="obj"></param>
         private void unUsualOrderTimerCall(object obj)
         {
+            if (isnUsualOrderSync)
+            {
+                return;
+            }
+            isnUsualOrderSync = true;
             new Thread(new ThreadStart(delegate ()
             {
                 WriteLog(string.Format("更新异常订单 | {0} | {1}", DateTime.Now.ToString(), "开始更新异常订单状态!"));
                 try
                 {
-                    commonHelper.setDeliveryUnusualOrder();
+                    commonHelper.setDeliveryUnusualOrder2();
                     //StringBuilder sql = new StringBuilder();
                     //sql.AppendFormat("update ce_erptradecell with(rowlock) set unusualTag=3,UnusualTime=WaitDesignTime where orderstate<5 and unusualTag=0 and datediff(hh,WaitDesignTime,getdate())>(select sjzTime from CE_ErpProductHour where CE_ErpProductHour.ProductID=ce_erptradecell.ProductId);");
                     //sql.AppendFormat("update ce_erptradecell with(rowlock) set unusualTag=4,UnusualTime=FinishDesignTime where orderstate=5 and unusualTag=0 and datediff(hh,FinishDesignTime,getdate())>(select xdTime from CE_ErpProductHour where CE_ErpProductHour.ProductID=ce_erptradecell.ProductId);");
@@ -1650,6 +1655,7 @@ namespace ErpServer
                 {
                     WriteLog(string.Format("更新异常订单 | {0} | {1}", DateTime.Now.ToString(), "发生错误" + ex.Message + "!"));
                 }
+                isnUsualOrderSync = false;
 
             })).Start();
         }