Explorar o código

修改商品个数计算

zhuyiyi hai 5 meses
pai
achega
1369726247

+ 10 - 6
SiteCore/Handler/sync.order.cs

@@ -64,7 +64,7 @@ namespace SiteCore.Handler
             string poscode = CurrentUser.UserPost.Post.Code;
             DataStruct dStruct = GetPostStruct();
             //string a = SecurityHelper.DecryptSymmetric("YDaPXIhsKgw=");
-            //jiemiUtils.ossFileDecrypt("C:\\Users\\231010\\Downloads\\1754898828671价格配置数据.xlsx");
+            //jiemiUtils.ossFileDecrypt("C:\\Users\\231010\\Downloads\\opp袋.xlsx");
             //apiHelper.Api_SyncOrderByTime("598825");
             //apiHelper.API_GetWaybill("ZTO-CAINIAO-TZJK", "4233447147588233939");
             //apiHelper.Api_SyacOrder("2460143282114312263", "yujia");
@@ -93,6 +93,10 @@ namespace SiteCore.Handler
                 try
                 {
                     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);
+                    if (string.IsNullOrEmpty(ceErpTrade.buyer_nick))
+                    {
+                        sql = string.Format("SELECT tid FROM [dbo].[CE_ErpTrade] WITH(NOLOCK) WHERE (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)
@@ -894,10 +898,10 @@ namespace SiteCore.Handler
                         memo = memo.Replace("(", "(");
                         memo = memo.Replace(")", ")");
                     }
-                   /* if (entity.OrderState < 3)
-                    {
-                        entity.DispatchSort = 0;
-                    }*/
+                    /* if (entity.OrderState < 3)
+                     {
+                         entity.DispatchSort = 0;
+                     }*/
                     entity.seller_memo = memo;
                     entity.UpdateTime = DateTime.Now;
                     entity.Update();
@@ -12762,7 +12766,7 @@ namespace SiteCore.Handler
                         }
                         else
                         {
-                            
+
                         }
                     }
                 }

+ 6 - 2
SiteCore/taobao/apiShengda.cs

@@ -118,6 +118,7 @@ namespace SiteCore.Handler
             try
             {
                 string result = httpContent(postUrl, "", HttpMethod.Get);
+                XLog.SaveLog(0, "盛大回调查询订单" + result);
                 var item = JsonConvert.DeserializeAnonymousType(result, new { data = new { name = "" } });
                 string file_name = "";
                 if (item != null)
@@ -144,7 +145,7 @@ namespace SiteCore.Handler
             }
             catch (Exception ex)
             {
-
+                XLog.SaveLog(0, "盛大回调查询订单出错" + ex.Message);
             }
             return ctid;
         }
@@ -358,7 +359,10 @@ namespace SiteCore.Handler
                 sb.AppendLine(string.Format("update [dbo].[CE_ErpShengdaRequestDataBack] set message = '数据解析错误:{0}' where signature='{1}' and timestamp='{2}';", ex.Message, msgSignature, timeStamp));
                 XLog.SaveLog(0, "盛大数据解析错误:" + msgSignature);
             }
-            SqlHelper.ExecuteNonQuery(sb.ToString());
+            if (sb.Length > 0)
+            {
+                SqlHelper.ExecuteNonQuery(sb.ToString());
+            }
 
         }
 

+ 47 - 10
SiteCore/taobao/commonHelper.cs

@@ -2158,17 +2158,17 @@ namespace SiteCore
 
         public static void sendCytExpress(CeErpExpressInfo exinfo)
         {
+            if (exinfo == null)
+            {
+                return;
+            }
+            CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(exinfo.tid);
+            if (ceErpTradeCell == null)
+            {
+                return;
+            }
             try
             {
-                if (exinfo == null)
-                {
-                    return;
-                }
-                CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCtid(exinfo.tid);
-                if (ceErpTradeCell == null)
-                {
-                    return;
-                }
                 JObject jsonObject12 = new JObject
                             {
                                 { "Userid",cytUserId },
@@ -2185,7 +2185,7 @@ namespace SiteCore
             }
             catch (Exception ex)
             {
-                LogHelper.addLog(exinfo.tid, 0, "CYT打单推送:" + ex.ToString());
+                LogHelper.addLog(exinfo.tid, 0, "CYT打单推送:" + ceErpTradeCell.OrderSn + "," + ceErpTradeCell.ctid + "," + exinfo.out_sid + "," + exinfo.company_name + "," + ex.ToString());
             }
         }
 
@@ -3191,6 +3191,10 @@ namespace SiteCore
             if (ceErpTrade.payment > 20)
             {
                 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);
+                if (string.IsNullOrEmpty(ceErpTrade.buyer_nick))
+                {
+                    sql = string.Format("SELECT tid FROM [dbo].[CE_ErpTrade] WITH(NOLOCK) WHERE (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];
                 if (dataTable != null && dataTable.Rows.Count > 0)
                 {
@@ -3207,5 +3211,38 @@ namespace SiteCore
 
             return;
         }
+
+        public static string getProductCount(string txt)
+        {
+            txt = txt.Replace(",", ",");
+            string[] txtList = txt.Split(',');
+            int total = 0;
+            for (int i = 0; i < txtList.Length; i++)
+            {
+                string kuanPattern = @"(\d+)(?=款)";
+                Match kuanMatch = Regex.Match(txtList[i], kuanPattern);
+                string kuanNum = kuanMatch.Success ? kuanMatch.Groups[1].Value : "1";
+
+                // 提取"个"或"张"前面的数字
+                string unitPattern = @"(\d+)(?=个|张|本|套|件  )";
+                Match unitMatch = Regex.Match(txtList[i], unitPattern);
+                string unitNum = unitMatch.Success ? unitMatch.Groups[1].Value : "1";
+                int kuan = 1;
+                int unit = 1;
+                if (!int.TryParse(kuanNum, out kuan))
+                {
+                    return txt;
+                }
+                if (!int.TryParse(unitNum, out unit))
+                {
+                    return txt;
+                }
+                total += kuan * unit;
+
+            }
+
+
+            return (total).ToString();
+        }
     }
 }

+ 6 - 6
SiteCore/taobao/tmcHelper.cs

@@ -1877,7 +1877,7 @@ namespace SiteCore
             {
                 return;
             }
-            entity.ProductCount = count;// commonHelper.changeCountFromChiness(count); ;
+            entity.ProductCount = commonHelper.getProductCount(count);// commonHelper.changeCountFromChiness(count); ;
             if (isMulty)
             {
                 try
@@ -2111,7 +2111,7 @@ namespace SiteCore
             {
                 return;
             }
-            entity.ProductCount = count;// commonHelper.changeCountFromChiness(count); ;
+            entity.ProductCount = commonHelper.getProductCount(count); ;// commonHelper.changeCountFromChiness(count); ;
             entity.isDianziOrder = 1;//电子稿
             entity.pay_time = father.pay_time;
             if (isMulity)
@@ -2742,7 +2742,7 @@ namespace SiteCore
             }
             entity.Material = mt;
             entity.ProductSize = size;
-            entity.ProductCount = count;//commonHelper.changeCountFromChiness(count); ;
+            entity.ProductCount = commonHelper.getProductCount(count); ;//commonHelper.changeCountFromChiness(count); ;
             entity.Craft = ct;
             entity.pay_time = father.pay_time;
             string newmemo = "(" + entity.OrderSn + ")-";
@@ -2863,7 +2863,7 @@ namespace SiteCore
                     newOtherMemo += ",";
                 }
             }
-
+            entity.ProductCount = commonHelper.getProductCount(entity.ProductCount);
             string sName = getShopSNameByName(father.seller_nick);
             newmemo += (sName);
             if (father.buyer_nick.IndexOf("*") < 0)
@@ -3182,7 +3182,7 @@ namespace SiteCore
             }
             entity.Material = mt;
             entity.ProductSize = size;
-            entity.ProductCount = count;//commonHelper.changeCountFromChiness(count);
+            entity.ProductCount = commonHelper.getProductCount(count); ;//commonHelper.changeCountFromChiness(count);
             entity.Craft = ct;
             entity.pay_time = father.pay_time;
             if (itemMemo.IndexOf("电子稿") != -1)
@@ -3646,7 +3646,7 @@ namespace SiteCore
             }
             entity.Material = mt;
             entity.ProductSize = size;
-            entity.ProductCount = count;//commonHelper.changeCountFromChiness(count);
+            entity.ProductCount = commonHelper.getProductCount(count); ;//commonHelper.changeCountFromChiness(count);
             entity.Craft = ct;
             entity.pay_time = father.pay_time;
             if (product == "现货手提袋")

+ 3 - 3
ecomServer/MainForm.cs

@@ -612,7 +612,7 @@ namespace ErpServer
                                 }
                                 else
                                 {
-                                    XLog.SaveLog(0, dr["message"].ToString() + "------" + ex.Message);
+                                    XLog.SaveLog(0, dr["id"].ToString() + "------" + ex.Message);
                                     break;
                                 }
                             }
@@ -647,7 +647,7 @@ namespace ErpServer
                 if (dt != null && dt.Rows.Count > 0)
                 {
                     List<string> idLst = new List<string>();
-                    helper.writeLog(dt.Rows[0]["id"].ToString());
+                    helper.writeLog("盛大" + dt.Rows[0]["id"].ToString());
                     foreach (DataRow dr in dt.Rows)
                     {
                         idLst.Add(dr["id"].ToString());
@@ -674,7 +674,7 @@ namespace ErpServer
                                 }
                                 else
                                 {
-                                    XLog.SaveLog(0, dr["message"].ToString() + "------" + ex.Message);
+                                    XLog.SaveLog(0, dr["id"].ToString() + "------" + ex.Message);
                                     break;
                                 }
                             }