Jelajahi Sumber

修改派单逻辑

zhuyiyi 5 bulan lalu
induk
melakukan
efcf1761ea
3 mengubah file dengan 47 tambahan dan 18 penghapusan
  1. 1 0
      SiteCore/Handler/sync.order.cs
  2. 14 8
      SiteCore/taobao/commonHelper.cs
  3. 32 10
      ecomServer/MainForm.cs

+ 1 - 0
SiteCore/Handler/sync.order.cs

@@ -121,6 +121,7 @@ namespace SiteCore.Handler
                 }
                 Debug.WriteLine(index++);
             }*/
+
             List<string> lw = new List<string>();
             string tid = GetPostString("ctid");
             string date1 = GetPostString("date1");

+ 14 - 8
SiteCore/taobao/commonHelper.cs

@@ -3186,19 +3186,25 @@ namespace SiteCore
             {
                 return;
             }
+            int VipCustomer = 2;
 
-            string sql = string.Format("SELECT count(*) as number FROM [dbo].[view_ErpTradeCell] WITH(NOLOCK) WHERE (buyer_nick = '{0}' or buyer_id = '{1}' ) and status = 'COMPLETE' and seller_nick = '{2}' and tid <> '{3}' AND end_time < '{4}' and IsSample = 0 and payment >= 20", ceErpTrade.buyer_nick, ceErpTrade.buyer_id, ceErpTrade.seller_nick, ceErpTrade.tid, ceErpTrade.pay_time);
-            DataTable dataTable = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
-            if (dataTable != null && dataTable.Rows.Count > 0)
+            if (ceErpTrade.payment > 20)
             {
-                int count = Convert.ToInt32(dataTable.Rows[0]["number"]);
-                int VipCustomer = 2;
-                if (count > 0)
+                string sql = string.Format("SELECT count(*) as number FROM [dbo].[view_ErpTradeCell] WITH(NOLOCK) WHERE (buyer_nick = '{0}' or buyer_id = '{1}' ) and status = 'COMPLETE' and seller_nick = '{2}' and tid <> '{3}' AND end_time < '{4}' and IsSample = 0 and payment >= 20", ceErpTrade.buyer_nick, ceErpTrade.buyer_id, ceErpTrade.seller_nick, ceErpTrade.tid, ceErpTrade.pay_time);
+                DataTable dataTable = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
+                if (dataTable != null && dataTable.Rows.Count > 0)
                 {
-                    VipCustomer = 1;
+                    int count = Convert.ToInt32(dataTable.Rows[0]["number"]);
+
+                    if (count > 0)
+                    {
+                        VipCustomer = 1;
+                    }
                 }
-                DbHelper.DbConn.ExecuteNonQuery(string.Format("UPDATE [dbo].[CE_ErpTradeCell] set VipCustomer = {1} WHERE tid='{0}';", ceErpTrade.tid, VipCustomer));
             }
+
+            DbHelper.DbConn.ExecuteNonQuery(string.Format("UPDATE [dbo].[CE_ErpTradeCell] set VipCustomer = {1} WHERE tid='{0}';", ceErpTrade.tid, VipCustomer));
+
             return;
         }
     }

+ 32 - 10
ecomServer/MainForm.cs

@@ -951,9 +951,9 @@ namespace ErpServer
                                         continue;
                                     }
                                     CeErpTrade ceErpTrade = CeErpTrade.Get(dr["tid"].ToString());
-                                    if (ceErpTrade != null && !string.IsNullOrEmpty(ceErpTrade.buyer_id) && !string.IsNullOrEmpty(ceErpTrade.buyer_nick))
+                                    if (ceErpTrade != null && !string.IsNullOrEmpty(ceErpTrade.buyer_nick))
                                     {
-                                        string design_order_sql = string.Format("SELECT top 1 DesignUserId FROM [dbo].[CE_ErpTradeCell] WHERE tid = (SELECT top 1 tid FROM [dbo].[CE_ErpTrade] WHERE (buyer_nick = '{0}' or buyer_id = '{1}' ) order by pay_time desc) and DesignUserId > 0;", ceErpTrade.buyer_nick, ceErpTrade.buyer_id);
+                                        string design_order_sql = string.Format("SELECT top 1 DesignUserId,DesignUserName,OnDuty,BeOnDuty FROM [dbo].[view_ErpTradeCell] WHERE (buyer_nick = '{0}' or buyer_id = '{1}' ) and seller_nick = '{2}' and DesignUserId > 0 order by pay_time desc;", ceErpTrade.buyer_nick, ceErpTrade.buyer_id, ceErpTrade.seller_nick);
                                         DataTable dataTable = SqlHelper.ExecuteDataset(design_order_sql).Tables[0];
                                         if (dataTable != null && dataTable.Rows != null && dataTable.Rows.Count > 0)
                                         {
@@ -961,18 +961,40 @@ namespace ErpServer
                                             if (designUserId > 0)
                                             {
                                                 CeErpUser ceErpUser = CeErpUser.Get(designUserId);
-                                                int onduty = 0;
-                                                string designUserName = "";
-                                                if (ceErpUser != null && ceErpUser.isOpen && ceErpUser.InfoID > 0)
+                                                int beOnDuty = Convert.IsDBNull(dataTable.Rows[0]["BeOnDuty"]) ? 0 : Convert.ToInt32(dataTable.Rows[0]["BeOnDuty"]);
+                                                int onduty = Convert.IsDBNull(dataTable.Rows[0]["OnDuty"]) ? 0 : Convert.ToInt32(dataTable.Rows[0]["OnDuty"]);
+                                                string designUserName = Convert.IsDBNull(dataTable.Rows[0]["DesignUserName"]) ? "" : dataTable.Rows[0]["DesignUserName"].ToString();
+                                                List<string> desingList = ceErpUser.pemDesign.Split(',').ToList();
+                                                bool isOnline = false;
+                                                if (selfTime.Hour < 12)
                                                 {
-                                                    CeErpUserInfo ceErpUserInfo = CeErpUserInfo.Get(ceErpUser.InfoID);
-                                                    onduty = ceErpUserInfo.OnDuty;
-                                                    designUserName = ceErpUser.Name;
+                                                    if (beOnDuty != 2)
+                                                    {                                                                                                                                              
+                                                        isOnline = true;
+                                                    }
+                                                }
+                                                else if ((selfTime.Hour >= 17 || (selfTime.Hour >= 16 && selfTime.Minute >= 35)))
+                                                {
+                                                    if (beOnDuty == 2)
+                                                    {
+                                                        isOnline = true;
+                                                    }
+                                                }
+                                                else if ((selfTime.Hour >= 16 || (selfTime.Hour >= 15 && selfTime.Minute >= 25)))
+                                                {
+                                                    if (beOnDuty != 1)
+                                                    {
+                                                        isOnline = true;
+                                                    }
+                                                }
+                                                else
+                                                {
+                                                    isOnline = true;
                                                 }
 
-                                                if (onduty > 0 && designUserId > 0)//设计师在线
+                                                if (onduty > 0 && designUserId > 0 && desingList.Contains(ProductId.ToString()) && isOnline)//设计师在线
                                                 {
-                                                    string update_sql = string.Format("update CE_ErpTradeCell set OrderState=3,IsAutoDispatch=1,WaitDesignTime=getdate(),UpdateTime=getdate(),DesignUserId={1},DispatchSort=0 where ctid='{0}' and OrderState=2; update view_ErpUser set DayOrderReceive=DayOrderReceive+1,DayOrderPer=CAST((CAST(((DayOrderReceive + 1)) as decimal(8,5))/DayOrderLimit) as decimal(8,3)) where id={1}; insert into CE_ErpTradeLog(tid,OrderState,UserId,OperateTime,Con) select ctid,OrderState,0,getdate(),'2自动派单:'+{2}+CONVERT(varchar,{1}) from ce_erptradecell where ctid='{0}';", dr["ctid"].ToString(), designUserId, designUserName);
+                                                    string update_sql = string.Format("update CE_ErpTradeCell set OrderState=3,IsAutoDispatch=1,WaitDesignTime=getdate(),UpdateTime=getdate(),DesignUserId={1},DispatchSort=0 where ctid='{0}' and OrderState=2; update view_ErpUser set DayOrderReceive=DayOrderReceive+1,DayOrderPer=CAST((CAST(((DayOrderReceive + 1)) as decimal(8,5))/DayOrderLimit) as decimal(8,3)) where id={1}; insert into CE_ErpTradeLog(tid,OrderState,UserId,OperateTime,Con) select ctid,OrderState,0,getdate(),'2自动派单:{2}'+CONVERT(varchar,{1}) from ce_erptradecell where ctid='{0}';", dr["ctid"].ToString(), designUserId, designUserName);
                                                     SqlHelper.ExecuteNonQuery(update_sql);
                                                     helper.writeLog("自动派单:原设计师在线-" + dr["ctid"].ToString() + "-" + res);
                                                     continue;