|
|
@@ -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
|