zhuyiyi 6 сар өмнө
parent
commit
f3c5fbc5c9

+ 86 - 89
SiteCore/Handler/sync.order.cs

@@ -6087,26 +6087,81 @@ namespace SiteCore.Handler
                         //string apires = apiHelper.API_LogisticsOnlineSend(entity.tid, mainEn.posCode, cpCode, codeObj.waybillCode);
                         //打单后发货
 
+                        StringBuilder sql = new StringBuilder();
+                        sql.AppendFormat("select ctid from CE_ErpTradeCell where SupplierId={0} ", entity.SupplierId);
+                        if (!string.IsNullOrEmpty(isTogether) && Convert.ToInt32(isTogether) > 0)
+                        {
+                            sql.AppendFormat(" and tid = '{0}'", mainEn.tid);
+                        }
+                        else
+                        {
+                            sql.AppendFormat(" and ctid = '{0}'", entity.ctid);
+                        }
+                        DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
 
-                        if (mainEn != null && entity.OrderState == 6 && apires.IndexOf("发货成功") != -1)
+                        foreach (DataRow row in dt.Rows)
                         {
-                            try
+                            entity = CeErpTradeCell.GetByCtid(row["ctid"].ToString());
+                            if (mainEn != null && entity.OrderState == 6 && apires.IndexOf("发货成功") != -1)
                             {
-                                btnType = "待发货";
-                                entity.OutSid = curUseWayBillCode;
-                                entity.OrderState = 7;
-                                entity.IsUrgency = false;
-                                entity.LastBillCpCode = "";
-                                entity.LastBillWaybillCode = "";
-                                entity.FinishDeliveryTime = DateTime.Now;
-                                entity.IsReturn = 0;
-                                entity.MemoOpt = 0;
+                                try
+                                {
+                                    btnType = "待发货";
+                                    entity.OutSid = curUseWayBillCode;
+                                    entity.OrderState = 7;
+                                    entity.IsUrgency = false;
+                                    entity.LastBillCpCode = "";
+                                    entity.LastBillWaybillCode = "";
+                                    entity.FinishDeliveryTime = DateTime.Now;
+                                    entity.IsReturn = 0;
+                                    entity.MemoOpt = 0;
+                                    entity.UpdateTime = DateTime.Now;
+                                    entity.Update();
+
+                                    commonHelper.aftersaleSend(entity.ctid, cpCode, curUseWayBillCode);
+
+                                    //还要插入快递信息到 快递信息表
+                                    CeErpExpressInfo exinfo = new CeErpExpressInfo();
+                                    exinfo.tid = entity.ctid;
+                                    exinfo.out_sid = curUseWayBillCode;
+                                    exinfo.company_code = cpCode;
+                                    exinfo.company_name = cpName;
+                                    exinfo.supplierUserName = supplierName;
+                                    exinfo.deliveryType = "发货成功";
+                                    exinfo.print_time = DateTime.Now;
+                                    exinfo.printUser = CurrentUser.UserName;
+                                    exinfo.postData = pData_str;
+                                    exinfo.Create();
+                                    commonHelper.UpdateRelationOrder(entity.ctid);
+                                    CeErpSukuraData.createInfo(ctid, 4);
+                                    commonHelper.insertToBuchaForDelivery(mainEn.tid, mainEn.posCode, cpCode, curUseWayBillCode);
+                                    if (entity.SupplierId == 64)
+                                    {
+                                        commonHelper.sendCytExpress(exinfo);
+                                    }
+                                    LogHelper.addLog(ctid, CurrentUser.UserID, "发货成功-" + cpCode + "-" + curUseWayBillCode);
+                                    //CeErpDataSendOrderInfo.createObject(entity.ctid);
+
+
+                                }
+                                catch (Exception ex)
+                                {
+                                    XLog.SaveLog(0, "发货成功后更新数据失败," + ex.Message);
+                                }
+
+                            }
+                            else if (mainEn.status == "SHIPPED" || mainEn.status == "PART_SHIPPED" || entity.OrderState >= 7) //已发货的不处理直接返回面单
+                            {
+                                entity.OutSid = (entity.OutSid + "," + curUseWayBillCode);
+                                if (entity.OrderState == 6)
+                                {
+                                    entity.OrderState = 7;
+                                }
                                 entity.UpdateTime = DateTime.Now;
+                                entity.FinishDeliveryTime = DateTime.Now;
+                                btnType = "已发货";
                                 entity.Update();
 
-                                commonHelper.aftersaleSend(entity.ctid, cpCode, curUseWayBillCode);
-
-                                //还要插入快递信息到 快递信息表
                                 CeErpExpressInfo exinfo = new CeErpExpressInfo();
                                 exinfo.tid = entity.ctid;
                                 exinfo.out_sid = curUseWayBillCode;
@@ -6119,90 +6174,32 @@ namespace SiteCore.Handler
                                 exinfo.postData = pData_str;
                                 exinfo.Create();
                                 commonHelper.UpdateRelationOrder(entity.ctid);
-                                CeErpSukuraData.createInfo(ctid, 4);
-                                commonHelper.insertToBuchaForDelivery(mainEn.tid, mainEn.posCode, cpCode, curUseWayBillCode);
+                                CeErpSukuraData.createInfo(entity.ctid, 4);
                                 if (entity.SupplierId == 64)
                                 {
                                     commonHelper.sendCytExpress(exinfo);
                                 }
-                                LogHelper.addLog(ctid, CurrentUser.UserID, "发货成功-" + cpCode + "-" + curUseWayBillCode);
-                                if (!string.IsNullOrEmpty(isTogether))
-                                {
-                                    if (Convert.ToInt32(isTogether) > 0)
-                                    {
-                                        StringBuilder sqlsb = new StringBuilder();
-                                        sqlsb.AppendFormat("update ce_erptradecell with(rowlock) set OrderState=7,OutSid='{2}' where tid='{0}' and OrderState=6 and SupplierId={1}", entity.tid, entity.SupplierId, curUseWayBillCode);
-                                        DbHelper.DbConn.ExecuteNonQuery(sqlsb.ToString());
-                                    }
-                                }
-                                //CeErpDataSendOrderInfo.createObject(entity.ctid);
-
-
-                            }
-                            catch (Exception ex)
-                            {
-                                XLog.SaveLog(0, "发货成功后更新数据失败," + ex.Message);
-                            }
-
-                        }
-                        else if (mainEn.status == "SHIPPED" || mainEn.status == "PART_SHIPPED" || entity.OrderState >= 7) //已发货的不处理直接返回面单
-                        {
-                            entity.OutSid = (entity.OutSid + "," + curUseWayBillCode);
-                            if (entity.OrderState == 6)
-                            {
-                                entity.OrderState = 7;
-                            }
-                            entity.UpdateTime = DateTime.Now;
-                            entity.FinishDeliveryTime = DateTime.Now;
-                            btnType = "已发货";
-                            entity.Update();
 
-                            CeErpExpressInfo exinfo = new CeErpExpressInfo();
-                            exinfo.tid = entity.ctid;
-                            exinfo.out_sid = curUseWayBillCode;
-                            exinfo.company_code = cpCode;
-                            exinfo.company_name = cpName;
-                            exinfo.supplierUserName = supplierName;
-                            exinfo.deliveryType = "发货成功";
-                            exinfo.print_time = DateTime.Now;
-                            exinfo.printUser = CurrentUser.UserName;
-                            exinfo.postData = pData_str;
-                            exinfo.Create();
-                            commonHelper.UpdateRelationOrder(entity.ctid);
-                            CeErpSukuraData.createInfo(entity.ctid, 4);
-                            if (entity.SupplierId == 64)
-                            {
-                                commonHelper.sendCytExpress(exinfo);
+                                //不处理
                             }
-                            if (!string.IsNullOrEmpty(isTogether))
+                            else
                             {
-                                if (Convert.ToInt32(isTogether) > 0)
+                                entity.UpdateTime = DateTime.Now;
+                                entity.LastBillCpCode = cpCode;
+                                entity.LastBillWaybillCode = curUseWayBillCode;
+                                entity.Update();
+                                string errmsg = commonHelper.KeepChinese(apires);
+                                var res_objz = new
                                 {
-                                    StringBuilder sqlsb = new StringBuilder();
-                                    sqlsb.AppendFormat("update ce_erptradecell with(rowlock) set OrderState=7,OutSid='{2}',FinishDeliveryTime=GETDATE(),UpdateTime=GETDATE() where tid='{0}' and OrderState=6 and SupplierId={1}", entity.tid, entity.SupplierId, curUseWayBillCode);
-                                    DbHelper.DbConn.ExecuteNonQuery(sqlsb.ToString());
-                                }
+                                    restype = 0,
+                                    data = "打单后发货失败"
+                                };
+                                string ro_jsonz = JsonConvert.SerializeObject(res_objz);
+                                returnSuccess(ro_jsonz);
+                                //returnErrorMsg("同步淘宝发货失败!"+ errmsg);
+                                XLog.SaveLog(0, "打单后发货失败," + entity.tid + "," + curUseWayBillCode + "," + apires);
+                                return;
                             }
-
-                            //不处理
-                        }
-                        else
-                        {
-                            entity.UpdateTime = DateTime.Now;
-                            entity.LastBillCpCode = cpCode;
-                            entity.LastBillWaybillCode = curUseWayBillCode;
-                            entity.Update();
-                            string errmsg = commonHelper.KeepChinese(apires);
-                            var res_objz = new
-                            {
-                                restype = 0,
-                                data = "打单后发货失败"
-                            };
-                            string ro_jsonz = JsonConvert.SerializeObject(res_objz);
-                            returnSuccess(ro_jsonz);
-                            //returnErrorMsg("同步淘宝发货失败!"+ errmsg);
-                            XLog.SaveLog(0, "打单后发货失败," + entity.tid + "," + curUseWayBillCode + "," + apires);
-                            return;
                         }
                     }
                     else if (!string.IsNullOrEmpty(isTogether) && Convert.ToInt32(isTogether) == 2)

+ 1 - 1
SiteCore/taobao/apiCaiYingTong.cs

@@ -600,7 +600,7 @@ namespace SiteCore.Handler
         //http://47.114.150.226:88/Handler/apiCaiYingTong.ashx?t=getMergeOrders    orderSn 
         public void getMergeOrders()
         {
-            string orderSn = GetPostString("orderSn");
+            string orderSn = GetString("orderSn");
             CeErpTradeCell ceErpTradeCell = CeErpTradeCell.GetByCode(orderSn);
             if (ceErpTradeCell == null)
             {

+ 8 - 5
SiteCore/taobao/commonHelper.cs

@@ -2753,19 +2753,22 @@ namespace SiteCore
         {
             string result = designHelper.API_CheckOrderTo(ceErpTradeCellExtend.ctid, ceErpTradeCellExtend.spu_id, ceErpTradeCell.ShopId);
             ceErpTradeCellExtend.ToType = result;
+            int dispatchSort = 0;
             if (spu_products.Contains(ceErpTradeCell.ProductId) || ceErpTradeCell.seller_memo.IndexOf("手绘") > -1 || ceErpTradeCell.seller_memo.IndexOf("电子稿") > -1 || ceErpTradeCell.isDianziOrder > 0)
             {
                 ceErpTradeCellExtend.ToType = "外协";
+                dispatchSort = 2;
             }
             if ((ceErpTradeCell.seller_memo.Contains("改稿") || ceErpTradeCell.OtherMemo.Contains("改稿")) && spu_shopIds.Contains(ceErpTradeCell.ShopId) && !spu_products.Contains(ceErpTradeCell.ProductId))
             {
                 ceErpTradeCellExtend.ToType = "内部";
+
+                dispatchSort = 0;
+
             }
-            if ("外协".Equals(ceErpTradeCellExtend.ToType))
-            {
-                string sql_pay = "update CE_ErpTradeCell with(rowlock) set DispatchSort=2 where ctid='" + ceErpTradeCellExtend.ctid + "';";
-                CeErpTradeCell.ExecuteNonQuery(sql_pay.ToString());
-            }
+
+            string sql_pay = string.Format("update CE_ErpTradeCell with(rowlock) set DispatchSort={0} where ctid='{1}';", dispatchSort, ceErpTradeCell.ctid);
+            CeErpTradeCell.ExecuteNonQuery(sql_pay.ToString());
             if (ceErpTradeCellExtend.ID > 0)
             {
                 ceErpTradeCellExtend.Update();