فهرست منبع

修改下单异常逻辑

zhuyiyi 2 هفته پیش
والد
کامیت
4e4e52f4e0
4فایلهای تغییر یافته به همراه262 افزوده شده و 105 حذف شده
  1. 255 95
      SiteCore/Handler/sync.order.cs
  2. 1 4
      SiteCore/taobao/commonHelper.cs
  3. 5 5
      SiteCore/taobao/refundTmcHelper.cs
  4. 1 1
      ecomServer/MainForm.cs

+ 255 - 95
SiteCore/Handler/sync.order.cs

@@ -350,6 +350,7 @@ namespace SiteCore.Handler
             {
                 dStruct.Order = "";
             }
+            
             dStruct.MainWhere = string.Join(" and ", lw.ToArray());
             DataTable dt = null;
             string tablename = "view_orderlist";
@@ -368,6 +369,7 @@ namespace SiteCore.Handler
                     {
                         if (dr["refund_fees"] != null)
                         {
+
                             decimal total_fee = decimal.Parse(dr["total_fee"].ToString());  //原订单总金额
                             decimal refund_fees = decimal.Parse(dr["refund_fees"].ToString()); //原订单退款金额  
 
@@ -12834,6 +12836,37 @@ namespace SiteCore.Handler
             sql = string.Format("SELECT SupplierId, ProductId, seller_memo, ProductCount, ProductName, payment, SupplierName, UnusualTime, FinishPlaceTime, OrderState, FinishDeliveryTime, AfterSaleState=0,AfterSaleReason = '',delivery=1 FROM view_ErpTradeCell  WHERE orderstate = 6  AND IsSample = 0  AND SupplierId > 0  AND  FinishPlaceTime > '2025-11-01 00:00:31.000' AND IsRefund <= 1 AND status = 'NOT_SHIPPED' AND LEN( ProductName ) > 0 AND SupplierId not in (86,10,105,86)", startMonthDate, endMonthDate);
             DataTable deliveryData = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
             data.Merge(deliveryData);
+            //获取商品发货时间
+            string timer_sql = string.Format("select * from CE_ErpSupplierProductTime");
+            DataTable timer_data = DbHelper.DbConn.ExecuteDataset(timer_sql).Tables[0];
+
+            Dictionary<int, List<CeErpSupplierProductTime>> timer_map = new Dictionary<int, List<CeErpSupplierProductTime>>();
+            foreach (DataRow datarow in timer_data.Rows)
+            {
+                List<CeErpSupplierProductTime> list = null;
+                int supplierId = Convert.ToInt32(datarow["SupplierId"]);
+                if (timer_map.ContainsKey(supplierId))
+                {
+                    timer_map.TryGetValue(supplierId, out list);
+                }
+                else
+                {
+                    list = new List<CeErpSupplierProductTime>();
+                    timer_map.Add(supplierId, list);
+                    timer_map.TryGetValue(supplierId, out list);
+                }
+                CeErpSupplierProductTime ceErpSupplierProductTime = new CeErpSupplierProductTime();
+
+                ceErpSupplierProductTime.quantity = Convert.ToInt32(datarow["quantity"]);
+                ceErpSupplierProductTime.dayDeadLine = datarow["dayDeadLine"].ToString();
+                ceErpSupplierProductTime.deadLine = datarow["deadLine"].ToString();
+                ceErpSupplierProductTime.productId = datarow["productId"].ToString();
+                ceErpSupplierProductTime.craft = datarow["craft"].ToString();
+                ceErpSupplierProductTime.sendDay = Convert.ToInt32(datarow["sendDay"]);
+                list.Add(ceErpSupplierProductTime);
+
+            }
+
             //不干胶-----1,卡片-----29
             Dictionary<string, Dictionary<string, int>> other_map = new Dictionary<string, Dictionary<string, int>>();
             foreach (DataRow row in data.Rows)
@@ -12941,12 +12974,110 @@ namespace SiteCore.Handler
                 }
                 int afterSaleState = Convert.ToInt32(row["AfterSaleState"]);
                 int delivery = Convert.ToInt32(row["delivery"]);
+
+                DateTime palceTime = DateTime.Parse(row["FinishPlaceTime"].ToString());
+                DateTime palceTimeStart = DateTime.Parse(palceTime.ToString("yyyy-MM-dd 00:00:00"));
+                DateTime palceTimeEnd = DateTime.Parse(palceTime.ToString("yyyy-MM-dd 23:59:59"));
+                DateTime palceTimeTwoEnd = DateTime.Parse(palceTime.ToString("yyyy-MM-dd 23:59:59")).AddHours(2);
+
+                DateTime FinishPlaceTime = DateTime.Parse(row["FinishPlaceTime"].ToString());
+                //GD-CYT-----64
+                DateTime two = palceTimeStart.AddHours(14);
+                DateTime three = palceTimeStart.AddHours(15);
+                DateTime four = palceTimeStart.AddHours(16);
+                DateTime six = palceTimeStart.AddHours(18);
+                bool istoday = false;
+                if (supplierId == 64 && "不干胶".Equals(type) && !seller_memo.Contains("牙签"))
+                {
+                    //下午四点前 500-1000
+                    string count = row["ProductCount"].ToString();
+                    if (count != null && count.Length > 0)
+                    {
+                        int productCount = commonHelper.getPlaceProductCount(count);
+                        if (productCount >= 500 && productCount <= 1000)
+                        {
+
+                            if (DateTime.Compare(FinishPlaceTime, four) < 0)
+                            {
+                                istoday = true;
+                            }
+                        }
+
+                    }
+                }
+                //UV
+                else if ("uv".Equals(type))
+                {
+
+                    //ZT----70
+                    //ZHX----3
+
+                    if (DateTime.Compare(FinishPlaceTime, four) < 0 && (supplierId == 70 || supplierId == 3))
+                    {
+                        istoday = true;
+                    }
+                    //JK----97
+                    //HZX----105
+                    if (DateTime.Compare(FinishPlaceTime, two) < 0 && (supplierId == 97 || supplierId == 105))
+                    {
+                        istoday = true;
+                    }
+                    if (DateTime.Compare(FinishPlaceTime, six) < 0 && (supplierId == 126))
+                    {
+                        istoday = true;
+                    }
+
+                }
+                //帆布---52|条幅---27
+                else if ("帆布".Equals(type) || "条幅".Equals(type))
+                {
+                    //LHCY-----98
+                    if (DateTime.Compare(FinishPlaceTime, three) < 0 && (supplierId == 98))
+                    {
+                        istoday = true;
+                    }
+                }
+                //条幅
+                else if ("条幅".Equals(type))
+                {
+                    //XD-----90
+                    if (DateTime.Compare(FinishPlaceTime, two) < 0 && (supplierId == 90))
+                    {
+                        istoday = true;
+                    }
+                }
+                //桌布
+                else if ("桌布".Equals(type))
+                {
+                    //XD-----90
+                    if (DateTime.Compare(FinishPlaceTime, three) < 0 && (supplierId == 90))
+                    {
+                        istoday = true;
+                    }
+                }
+                //DL---10
+                //AYTW---119
+                //FS-CYT-DY ----80
+                //JK----97
+                else if (supplierId == 10 || supplierId == 119 || supplierId == 80 || supplierId == 97)
+                {
+                    if (DateTime.Compare(FinishPlaceTime, three) < 0)
+                    {
+                        istoday = true;
+                    }
+                }
+                // QC---121
+                else if (supplierId == 121)
+                {
+                    if (DateTime.Compare(FinishPlaceTime, six) < 0)
+                    {
+                        istoday = true;
+                    }
+                }
+
                 if (afterSaleState == 0 && delivery == 0)
                 {
-                    DateTime palceTime = DateTime.Parse(row["FinishPlaceTime"].ToString());
-                    DateTime palceTimeStart = DateTime.Parse(palceTime.ToString("yyyy-MM-dd 00:00:00"));
-                    DateTime palceTimeEnd = DateTime.Parse(palceTime.ToString("yyyy-MM-dd 23:59:59"));
-                    DateTime palceTimeTwoEnd = DateTime.Parse(palceTime.ToString("yyyy-MM-dd 23:59:59")).AddHours(2);
+
                     if (DateTime.Compare(start, palceTime) < 0 && DateTime.Compare(end, palceTime) > 0)
                     {
                         map["dayTotal"]++;
@@ -12961,7 +13092,6 @@ namespace SiteCore.Handler
                     {
                         map["payTotal"]++;
                     }
-                    bool istoday = false;
                     if (row["FinishDeliveryTime"].ToString() != null && row["FinishDeliveryTime"].ToString().Length > 0)
                     {
 
@@ -12985,122 +13115,152 @@ namespace SiteCore.Handler
                             else if (DateTime.Compare(palceTimeStart, FinishDeliveryTime) < 0 && DateTime.Compare(palceTimeEnd, FinishDeliveryTime) > 0)//当天发货
                             {
                                 map["today"]++;
-                                istoday = true;
+
                             }
                         }
                     }
-                    if (row["UnusualTime"].ToString() != null && row["UnusualTime"].ToString().Length > 0)
+                    if (istoday)
                     {
-                        map["unusua"]++;
-
+                        map["dayDev"]++;
                     }
-                    DateTime FinishPlaceTime = DateTime.Parse(row["FinishPlaceTime"].ToString());
-                    //GD-CYT-----64
-                    DateTime two = palceTimeStart.AddHours(14);
-                    DateTime three = palceTimeStart.AddHours(15);
-                    DateTime four = palceTimeStart.AddHours(16);
-                    DateTime six = palceTimeStart.AddHours(18);
-                    if (supplierId == 64 && "不干胶".Equals(type) && !seller_memo.Contains("牙签"))
-                    {
-                        //下午四点前 500-1000
-                        string count = row["ProductCount"].ToString();
-                        if (count != null && count.Length > 0)
-                        {
-                            int productCount = commonHelper.getPlaceProductCount(count);
-                            if (productCount >= 500 && productCount <= 1000)
-                            {
 
-                                if (DateTime.Compare(FinishPlaceTime, four) < 0)
-                                {
-                                    map["dayDev"]++;
-
-                                }
-                            }
-
-                        }
-                    }
-                    //UV
-                    else if ("uv".Equals(type))
+                }
+                else if (delivery == 0)
+                {
+                    if (row["AfterSaleReason"].ToString().Contains("车间责任"))
                     {
+                        map["aftersale"]++;
+                    }
 
-                        //ZT----70
-                        //ZHX----3
-
-                        if (DateTime.Compare(FinishPlaceTime, four) < 0 && (supplierId == 70 || supplierId == 3))
-                        {
-                            map["dayDev"]++;
-                        }
-                        //JK----97
-                        //HZX----105
-                        if (DateTime.Compare(FinishPlaceTime, two) < 0 && (supplierId == 97 || supplierId == 105))
+                }
+                else
+                {
+                    map["deliveryNum"]++;
+                    try
+                    {
+                        if (istoday)
                         {
-                            map["dayDev"]++;
+                            map["unusua"]++;
+                            continue;
                         }
-                        if (DateTime.Compare(FinishPlaceTime, six) < 0 && (supplierId == 126))
+                        if (supplierId == 0 || productId == 0)
                         {
-                            map["dayDev"]++;
+                            continue;
                         }
 
-                    }
-                    //帆布---52|条幅---27
-                    else if ("帆布".Equals(type) || "条幅".Equals(type))
-                    {
-                        //LHCY-----98
-                        if (DateTime.Compare(FinishPlaceTime, three) < 0 && (supplierId == 98))
+                        //没配置时间
+                        if (!timer_map.ContainsKey(supplierId))
                         {
-                            map["dayDev"]++;
+                            continue;
                         }
-                    }
-                    //条幅
-                    else if ("条幅".Equals(type))
-                    {
-                        //XD-----90
-                        if (DateTime.Compare(FinishPlaceTime, two) < 0 && (supplierId == 90))
+                        List<CeErpSupplierProductTime> timmerList = timer_map[supplierId];
+                        if (timmerList.Count == 0)
                         {
-                            map["dayDev"]++;
+                            continue;
                         }
-                    }
-                    //桌布
-                    else if ("桌布".Equals(type))
-                    {
-                        //XD-----90
-                        if (DateTime.Compare(FinishPlaceTime, three) < 0 && (supplierId == 90))
+                        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))
                         {
-                            map["dayDev"]++;
+                            continue;
                         }
-                    }
-                    //DL---10
-                    //AYTW---119
-                    //FS-CYT-DY ----80
-                    //JK----97
-                    else if (supplierId == 10 || supplierId == 119 || supplierId == 80 || supplierId == 97)
-                    {
-                        if (DateTime.Compare(FinishPlaceTime, three) < 0)
+                        placeTime = DateTime.Parse(finishPlaceTime);
+                        bool isSendTime = false;
+                        foreach (CeErpSupplierProductTime productTime in timmerList)
                         {
-                            map["dayDev"]++;
+                            string txtIds = productTime.productId;
+                            string[] crafts = { };
+                            int count = productTime.quantity;
+                            if (string.IsNullOrEmpty(txtIds))
+                            {
+                                continue;
+                            }
+                            if (count > 0)
+                            {
+                                int quantity = commonHelper.handleProductCount(txtCount, true);
+                                //订单数量大于写入的数量则跳过
+                                if (quantity > count)
+                                {
+                                    continue;
+                                }
+                            }
+                            productIds = txtIds.Split(',');
+                            if (productIds.Contains(productId.ToString()))
+                            {
+                                string textCraft = productTime.craft;
+                                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(productTime.deadLine);
+                                DateTime dayDeadLine = DateTime.Parse(productTime.dayDeadLine);
+
+                                int sendDay = productTime.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 00:00:00")).AddDays(sendDay);
+                                }
+                                else
+                                {
+                                    sendDay = Math.Max(1, sendDay - 1);
+                                    sendtime = DateTime.Parse(placeTime.ToString("yyyy-MM-dd 23:59:59")).AddDays(sendDay);
+                                }
+
+                                //判断有没有到发货日期大于0还没到发货时间
+                                if (DateTime.Compare(sendtime.Date, DateTime.Now.Date) < 0)
+                                {
+                                    //匹配到就不要继续匹配了   
+                                    isSendTime = true;
+                                    break;
+                                }
+                            }
                         }
-                    }
-                    // QC---121
-                    else if (supplierId == 121)
-                    {
-                        if (DateTime.Compare(FinishPlaceTime, six) < 0)
+                        if (isSendTime)
                         {
-                            map["dayDev"]++;
+                            map["unusua"]++;
+
                         }
                     }
-                }
-                else if (delivery == 0)
-                {
-                    if (row["AfterSaleReason"].ToString().Contains("车间责任"))
+                    catch (Exception ex)
                     {
-                        map["aftersale"]++;
+                        XLog.SaveLog(0, row["ctid"].ToString() + "更新发货异常订单错误:" + ex);
                     }
 
                 }
-                else
-                {
-                    map["deliveryNum"]++;
-                }
 
             }
 
@@ -14165,9 +14325,9 @@ namespace SiteCore.Handler
             if (!string.IsNullOrEmpty(ctids))
             {
                 string[] ctid_list = ctids.Split(',');
-                if (ctid_list.Length > 20)
+                if (ctid_list.Length > 100)
                 {
-                    returnErrorMsg("单次下载次数不能超过20个");
+                    returnErrorMsg("单次下载次数不能超过100个");
                     return;
                 }
                 string textCtids = "'" + ctids.Replace(",", "','") + "'";

+ 1 - 4
SiteCore/taobao/commonHelper.cs

@@ -36,10 +36,7 @@ namespace SiteCore
         public static void autoRefreshRefundState()
         {
             StringBuilder sql = new StringBuilder();
-            if (DateTime.Now < DateTime.Parse("2026-02-25"))
-            {
-                return;
-            }
+           
             sql.AppendFormat("update CE_ErpTradeRefund set RefundState=3 where RefundState=2 and DATEDIFF(hh,modified,getdate())>=72;");
             //sql.AppendFormat("update ce_erptradecell with(rowlock) set AfterSaleState=4,FinishAfterSaleTime=getdate() where AfterSaleState=3 and IsArbitrate=0 and DATEDIFF(hh,AfterSalePreTime,getdate())>=168;");
             //sql.AppendFormat("update ce_erptradecell with(rowlock) set AfterSaleSupplierState=1,set FinishAfterSaleTime=GETDATE(),set AfterSaleState=4  where AfterSaleSupplierState=0 and AfterSaleState>1 and AfterSaleResSupId>0 and DATEDIFF(hh,HandleTime,getdate())>=72;");

+ 5 - 5
SiteCore/taobao/refundTmcHelper.cs

@@ -283,15 +283,15 @@ namespace SiteCore
                         }
 
                     }
+                    StringBuilder sqlorder = new StringBuilder();
                     List<Api_tmc_refund_info_Obj.Lines> goodsItems = tObj.lines;
-                    foreach (Api_tmc_refund_info_Obj.Lines item in goodsItems)
+                    if (goodsItems != null)
                     {
-                        CeErpTradeOrder goods = CeErpTradeOrder.GetByOid(item.refOlId);
-                        if (goods != null)
+                        foreach (Api_tmc_refund_info_Obj.Lines item in goodsItems)
                         {
-                            goods.refund_status = item.refundStatus;
-                            goods.Update();
+                            sqlorder.AppendFormat("update CE_ErpTradeOrder set refund_status = '{1}' where oid = '{0}';", item.refOlId, item.refundStatus);
                         }
+                        CeErpDesignerBill.ExecuteNonQuery(sqlorder.ToString());
                     }
 
                     if (tObj.status == "WAIT_SELLER_AGREE")

+ 1 - 1
ecomServer/MainForm.cs

@@ -237,7 +237,7 @@ namespace ErpServer
                 WriteLog(string.Format("自动派单:" + hm));
                 disTimerCall(null);
                 syncDataSendOrder();
-                sendOrderInfo();
+                //sendOrderInfo();
                 connetUrl();
             }
             if (intHour == 2 && intMinute == 0)