Procházet zdrojové kódy

修改二次售后逻辑。订单金额0不推送,自动派单逻辑

zhuyiyi před 6 měsíci
rodič
revize
9ef41b4ed7

+ 21 - 7
SiteCore/Handler/sync.order.cs

@@ -89,22 +89,35 @@ namespace SiteCore.Handler
                 CeErpTrade ceErpTrade = CeErpTrade.Get(item.Replace("'", ""));
                 try
                 {
-                    string sql = string.Format("SELECT count(*) as number FROM [dbo].[Ce_ErpTrade] WITH(NOLOCK) WHERE (buyer_nick = '{0}' or buyer_id = '{1}' ) and status = 'COMPLETE' and seller_nick = '{2}' and tid <> '{3}' AND end_time < '{4}'", ceErpTrade.buyer_nick, ceErpTrade.buyer_id, ceErpTrade.seller_nick, ceErpTrade.tid, ceErpTrade.pay_time);
+                    string sql = string.Format("SELECT tid FROM [dbo].[CE_ErpTrade] 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 payment >= 20", ceErpTrade.buyer_nick, ceErpTrade.buyer_id, ceErpTrade.seller_nick, ceErpTrade.tid, ceErpTrade.pay_time);
                     DataTable dataTable = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
+                    List<string> tidList = new List<string>();
                     if (dataTable != null && dataTable.Rows.Count > 0)
                     {
-                        int count = Convert.ToInt32(dataTable.Rows[0]["number"]);
-                        if (count > 0)
+                        foreach (DataRow row in dataTable.Rows)
                         {
-                            Debug.WriteLine(index++);
-                            continue;
+                            tidList.Add("'" + row["tid"].ToString() + "'");
+                        }
+                    }
+                    if (tidList.Count > 0)
+                    {
+                        sql = string.Format("SELECT count(*) as number FROM [dbo].[CE_ErpTradeCell] WITH(NOLOCK) WHERE tid in ({0}) AND IsSample = 0 ", string.Join(",", tidList));
+                        dataTable = DbHelper.DbConn.ExecuteDataset(sql).Tables[0];
+                        if (dataTable != null && dataTable.Rows.Count > 0)
+                        {
+                            int count = Convert.ToInt32(dataTable.Rows[0]["number"]);
+                            if (count > 0)
+                            {
+                                Debug.WriteLine(index++);
+                                continue;
+                            }
                         }
                     }
                     File.AppendAllText(path1, ceErpTrade.tid + "\n");
                 }
                 catch (Exception e)
                 {
-                    File.AppendAllText(path1, ceErpTrade.tid + "\n");
+                    File.AppendAllText(path1, "e:" + ceErpTrade.tid + "\n");
                 }
                 Debug.WriteLine(index++);
             }*/
@@ -1642,6 +1655,7 @@ namespace SiteCore.Handler
                     entity.AfterSaleState = 1; //1待售后2售后主管审核3主管审核4完成售后
                     entity.UpdateTime = DateTime.Now;                        //entity.AfterSaleReason = reason;
                     entity.AfterSaleTime = DateTime.Now;
+                    entity.HandleTime = null;
                     entity.Update();
                     LogHelper.addLog(entity.ctid, CurrentUser.UserID, "标记售后-" + reason, entity.OrderState, 1);
                     returnSuccessMsg("转售后成功!");
@@ -3932,7 +3946,7 @@ namespace SiteCore.Handler
                 string needtids = string.Join(",", tLst.ToArray());
                 StringBuilder sql = new StringBuilder();
                 //sql.AppendFormat("update ce_erptradecell set IsVerifyToSupplier=1 where SupplierId!=0 and ctid in ({0});", needtids);
-                sql.AppendFormat("update ce_erptradecell set IsVerifyToSupplier=1,IsReturn=0,FinishPlaceTime=GETDATE(),PlaceUserId={1},IsHaveNewOrder=0 where SupplierId!=0 and ctid in ({0});", needtids, CurrentUser.UserID);
+                sql.AppendFormat("update ce_erptradecell set IsVerifyToSupplier=1,IsReturn=0,FinishPlaceTime=GETDATE(),PlaceUserId={1},IsHaveNewOrder=0 where SupplierId!=0 AND OrderState = 5 and ctid in ({0});", needtids, CurrentUser.UserID);
                 sql.AppendFormat("insert into CE_ErpTradeLog(tid,UserId,Con,OperateTime) select ctid,{1},'审核给供应商',getdate() from ce_erptradecell where ctid in({0});", needtids, CurrentUser.UserID);
                 DbHelper.DbConn.ExecuteNonQuery(sql.ToString());
                 returnSuccessMsg("操作成功!");

+ 1 - 1
SiteCore/taobao/commonHelper.cs

@@ -3187,7 +3187,7 @@ namespace SiteCore
                 return;
             }
 
-            string sql = string.Format("SELECT count(*) as number FROM [dbo].[Ce_ErpTrade] WITH(NOLOCK) WHERE (buyer_nick = '{0}' or buyer_id = '{1}' ) and status = 'COMPLETE' and seller_nick = '{2}' and tid <> '{3}' AND end_time < '{4}'", ceErpTrade.buyer_nick, ceErpTrade.buyer_id, ceErpTrade.seller_nick, ceErpTrade.tid, ceErpTrade.pay_time);
+            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)
             {

+ 3 - 0
Web/EDelivery/js/WaitingOrder.js

@@ -477,6 +477,9 @@ function downloadFileFn() {
             if (sels[i].SupplierId != 64) {
                 return mini.alert(sels[i].ctid + "不是彩印通订单");
             }
+            if (sels[i].payment == 0) {
+                return mini.alert(sels[i].ctid + "金额为0无法指派");
+            }
             pArr.push(sels[i].ctid);
         }
         progressShow();

+ 30 - 0
ecomServer/MainForm.cs

@@ -950,6 +950,36 @@ namespace ErpServer
                                     {
                                         continue;
                                     }
+                                    CeErpTrade ceErpTrade = CeErpTrade.Get(dr["tid"].ToString());
+                                    if (ceErpTrade != null && !string.IsNullOrEmpty(ceErpTrade.buyer_id) && !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);
+                                        DataTable dataTable = SqlHelper.ExecuteDataset(design_order_sql).Tables[0];
+                                        if (dataTable != null && dataTable.Rows != null && dataTable.Rows.Count > 0)
+                                        {
+                                            int designUserId = Convert.IsDBNull(dataTable.Rows[0]["DesignUserId"]) ? 0 : Convert.ToInt32(dataTable.Rows[0]["DesignUserId"]);
+                                            if (designUserId > 0)
+                                            {
+                                                CeErpUser ceErpUser = CeErpUser.Get(designUserId);
+                                                int onduty = 0;
+                                                string designUserName = "";
+                                                if (ceErpUser != null && ceErpUser.isOpen && ceErpUser.InfoID > 0)
+                                                {
+                                                    CeErpUserInfo ceErpUserInfo = CeErpUserInfo.Get(ceErpUser.InfoID);
+                                                    onduty = ceErpUserInfo.OnDuty;
+                                                    designUserName = ceErpUser.Name;
+                                                }
+
+                                                if (onduty > 0 && designUserId > 0)//设计师在线
+                                                {
+                                                    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;
+                                                }
+                                            }
+                                        }
+                                    }
                                     int[] uv_productIds = new int[] { 14, 43, 2487, 2531, 2654, 2656 };
                                     //指定店铺老客户和指定店铺单价500以上分给指定部门
                                     if (!uv_productIds.Contains(ProductId) && ((IsOldCustomer == "1" && userId == 241)))