zhuyiyi 8 months ago
parent
commit
7dc730d8d9

+ 226 - 125
SiteCore/Handler/sync.order.cs

@@ -56,7 +56,6 @@ namespace SiteCore.Handler
 
             string poscode = CurrentUser.UserPost.Post.Code;
             DataStruct dStruct = GetPostStruct();
-
             //apiHelper.Api_SyncOrderByTime("598825");
             //apiHelper.API_GetWaybill("ZTO-CAINIAO-TZJK", "4233447147588233939");
             //apiHelper.Api_SyacOrder("2460143282114312263", "yujia");
@@ -963,6 +962,7 @@ namespace SiteCore.Handler
                 if (eid != "") entity = CeErpTradeCell.GetByCtid(eid);
                 if (entity != null)
                 {
+                    ApiVo apiVo = new ApiVo();
                     if (entity.OrderState == 0)
                     {
                         returnErrorMsg("请先领单");
@@ -988,12 +988,12 @@ namespace SiteCore.Handler
                             }
                         }
                         entity.Update();
-                        work_core_vo.ApiVo api = new work_core_vo.ApiVo();
-                        api.orderNumber = entity.ctid;
-                        api.actionName = "followRemarks";
-                        api.orderRemarks = entity.seller_memo;
-                        api.isSf = entity.IsSF.ToString();
-                        designHelper.API_WorkCore(api);//followRemarks
+
+                        apiVo.orderNumber = entity.ctid;
+                        apiVo.actionName = "orderRemarks";
+                        apiVo.orderRemarks = entity.seller_memo;
+                        apiVo.isSf = entity.IsSF.ToString();
+                        designHelper.API_WorkCore(apiVo);//orderRemarks
                         LogHelper.addLog(entity.ctid, CurrentUser.UserID, "撤销标记顺丰", entity.OrderState, 1);
                         returnSuccessMsg("撤销成功!" + reMsg);
                         return;
@@ -1040,7 +1040,7 @@ namespace SiteCore.Handler
                     }
 
                     entity.Update();
-                    ApiVo apiVo = new ApiVo();
+                    apiVo = new ApiVo();
                     apiVo.orderNumber = entity.ctid;
                     apiVo.actionName = "orderRemarks";
                     apiVo.orderRemarks = entity.seller_memo;
@@ -1292,6 +1292,11 @@ namespace SiteCore.Handler
                             }
                         }
                     }
+                    if (entity.OrderState == -1)
+                    {
+                        returnErrorMsg("待审核订单无法领取!");
+                        return;
+                    }
                     entity.CustomerUserId = CurrentUser.UserID;
                     if (entity.OrderState < 2)
                     {
@@ -5731,6 +5736,11 @@ namespace SiteCore.Handler
                         returnErrorMsg("此单标记使用顺丰发货,不能使用其他快递");
                         return;
                     }
+                    if (entity.IsSF == 0 && cpCode.IndexOf("SF") > -1)
+                    {
+                        returnErrorMsg("此单未标记使用顺丰发货,不能使用其他快递");
+                        return;
+                    }
                 }
 
                 string res = "";
@@ -5867,7 +5877,7 @@ namespace SiteCore.Handler
                 //string pageUrl = apiHelper.API_GetPrintPage(codeObj.waybillCode,tempId,ctid);
                 //string msg = "{\"data\":\""+pageUrl+"\"}";
                 string btnType = "";
-
+                string errorMsg = "";
                 if (entity != null)
                 {
 
@@ -5876,162 +5886,235 @@ namespace SiteCore.Handler
                     //cpcode是 YTO-CAINIAO 
                     //string comCode = cpCode.Split('-')[0].ToString();
                     string apires = "";
-                    if (ctid.IndexOf("N") != -1)
+                    string supplierName = commonHelper.getSupplierNameById(entity.SupplierId);
+                    if (!string.IsNullOrEmpty(isTogether) && Convert.ToInt32(isTogether) == 1)
                     {
-                        apires = "发货成功";
-                    }
-                    else
-                    {
-                        apires = apiHelper.API_LogisticsOnlineSend(mainEn.tid, mainEn.posCode, cpCode, curUseWayBillCode);
-                    }
-                    //string apires = apiHelper.API_LogisticsOnlineSend(entity.tid, mainEn.posCode, cpCode, codeObj.waybillCode);
-                    //打单后发货
+                        if (ctid.IndexOf("N") != -1)
+                        {
+                            apires = "发货成功";
+                        }
+                        else
+                        {
+                            apires = apiHelper.API_LogisticsOnlineSend(mainEn.tid, mainEn.posCode, cpCode, curUseWayBillCode);
+                        }
+                        //string apires = apiHelper.API_LogisticsOnlineSend(entity.tid, mainEn.posCode, cpCode, codeObj.waybillCode);
+                        //打单后发货
 
-                    if (mainEn != null && entity.OrderState == 6 && apires.IndexOf("发货成功") != -1)
-                    {
-                        try
+
+                        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;
-                            entity.UpdateTime = DateTime.Now;
-                            entity.Update();
+                            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);
+                                StringBuilder sqlsb = new StringBuilder();
+                                sqlsb.AppendFormat("update ce_erptradecell with(rowlock) set OrderState=7,OutSid='{2}',FinishDeliveryTime=GETDATE(),UpdateTime=GETDATE(),IsReturn=0,MemoOpt=0 where tid='{0}' and OrderState=6 and SupplierId={1}", entity.tid, entity.SupplierId, curUseWayBillCode);
+                                DbHelper.DbConn.ExecuteNonQuery(sqlsb.ToString());
 
-                            commonHelper.aftersaleSend(entity.ctid, cpCode, curUseWayBillCode);
+                            }
+                            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 = commonHelper.getSupplierNameById(entity.SupplierId);
+                            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);
+                            CeErpSukuraData.createInfo(entity.ctid, 4);
                             if (entity.SupplierId == 64)
                             {
                                 commonHelper.sendCytExpress(exinfo);
                             }
-                            LogHelper.addLog(ctid, CurrentUser.UserID, "发货成功-" + cpCode + "-" + curUseWayBillCode);
-                            //CeErpDataSendOrderInfo.createObject(entity.ctid);
-                            CeErpDeliverMark ceErpDeliverMark = CeErpDeliverMark.GetByCtid(ctid);
                             if (!string.IsNullOrEmpty(isTogether))
                             {
-                                if (Convert.ToInt32(isTogether) > 0 && ceErpDeliverMark == null)
+                                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);
+                                    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());
                                 }
                             }
-                            if (ceErpDeliverMark != null)
-                            {
-                                DataTable dt1 = DbHelper.DbConn.ExecuteDataset(string.Format("select * from CE_ErpDeliverMark where isDel = 0 and markNumber = {0};", ceErpDeliverMark.markNumber)).Tables[0];
-                                if (dt1 != null && dt1.Rows != null && dt1.Rows.Count > 0)
-                                {
-                                    List<string> list = new List<string>();
-                                    foreach (DataRow row in dt1.Rows)
-                                    {
-                                        list.Add("'" + row["ctid"] + "'");
-                                    }
-                                    DbHelper.DbConn.ExecuteNonQuery(string.Format("update ce_erptradecell with(rowlock) set OrderState=7,OutSid='{2}' where ctid in ('{0}') and OrderState=6 and SupplierId={1}", string.Join(",", list), entity.SupplierId, curUseWayBillCode));
-                                }
-                                DbHelper.DbConn.ExecuteNonQuery(string.Format("update CE_ErpDeliverMark with(rowlock) set isDel=1 where markNumber='{0}' ", ceErpDeliverMark.markNumber));
-                            }
+
+                            //不处理
                         }
-                        catch (Exception ex)
+                        else
                         {
-                            XLog.SaveLog(0, "发货成功后更新数据失败," + ex.Message);
+                            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 (mainEn.status == "SHIPPED" || mainEn.status == "PART_SHIPPED" || entity.OrderState >= 7) //已发货的不处理直接返回面单
+                    else if (!string.IsNullOrEmpty(isTogether) && Convert.ToInt32(isTogether) == 2)
                     {
-                        entity.OutSid = (entity.OutSid + "," + curUseWayBillCode);
-                        if (entity.OrderState == 6)
+                        StringBuilder allSql = new StringBuilder();
+                        allSql.AppendFormat("select ctid,IsSF,seller_memo,OtherMemo,tid from view_ErpTradeCell where SupplierId={0} and orderstate=6", entity.SupplierId);
+                        if (string.IsNullOrEmpty(mainEn.receiverId))
                         {
-                            entity.OrderState = 7;
+                            allSql.AppendFormat(" and (tid='{0}');", entity.tid);
                         }
-                        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 = commonHelper.getSupplierNameById(entity.SupplierId);
-                        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)
+                        else
                         {
-                            commonHelper.sendCytExpress(exinfo);
+                            //查询同车间同状态下的收货地址相同的单子
+                            allSql.AppendFormat(" and (tid='{0}' or (receiverId = '{1}' and IsSF = '{2}') );", entity.tid, mainEn.receiverId, entity.IsSF);
                         }
-                        CeErpDeliverMark ceErpDeliverMark = CeErpDeliverMark.GetByCtid(ctid);
-                        if (!string.IsNullOrEmpty(isTogether))
+                        DataTable dt = DbHelper.DbConn.ExecuteDataset(allSql.ToString()).Tables[0];
+                        List<string> list = new List<string>();
+                        List<string> send_list = new List<string>();
+                        CeErpTradeCell ceErpTradeCell = new CeErpTradeCell();
+                        CeErpTrade ceErpTrade = new CeErpTrade();
+                        foreach (DataRow row in dt.Rows)
                         {
-                            if (Convert.ToInt32(isTogether) > 0 && ceErpDeliverMark == null)
+                            list.Add("'" + row["ctid"] + "'");
+                            ceErpTradeCell = CeErpTradeCell.GetByCtid(row["ctid"].ToString());
+                            ceErpTrade = CeErpTrade.Get(ceErpTradeCell.tid);
+
+                            if (ctid.IndexOf("N") != -1)
                             {
-                                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());
+                                apires = "发货成功";
                             }
-                        }
-                        if (ceErpDeliverMark != null)
-                        {
-                            DataTable dt1 = DbHelper.DbConn.ExecuteDataset(string.Format("select * from CE_ErpDeliverMark where isDel = 0 and markNumber = {0};", ceErpDeliverMark.markNumber)).Tables[0];
-                            if (dt1 != null && dt1.Rows != null && dt1.Rows.Count > 0)
+                            else
                             {
-                                List<string> list = new List<string>();
-                                foreach (DataRow row in dt1.Rows)
+                                if (!send_list.Contains(ceErpTrade.tid))
+                                {
+                                    apires = apiHelper.API_LogisticsOnlineSend(ceErpTrade.tid, ceErpTrade.posCode, cpCode, curUseWayBillCode);
+                                }
+                                else
                                 {
-                                    list.Add("'" + row["ctid"] + "'");
+                                    apires = "发货成功";
                                 }
-                                DbHelper.DbConn.ExecuteNonQuery(string.Format("update ce_erptradecell with(rowlock) set OrderState=7,OutSid='{2}' where ctid in ('{0}') and OrderState=6 and SupplierId={1}", string.Join(",", list), entity.SupplierId, curUseWayBillCode));
                             }
-                            DbHelper.DbConn.ExecuteNonQuery(string.Format("update CE_ErpDeliverMark with(rowlock) set isDel=1 where markNumber='{0}' ", ceErpDeliverMark.markNumber));
-                        }
 
+                            if (ceErpTrade != null && ceErpTradeCell.OrderState == 6 && apires.IndexOf("发货成功") != -1)
+                            {
+                                send_list.Add(ceErpTrade.tid);
 
-                        //不处理
-                    }
-                    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;
+                                try
+                                {
+                                    btnType = "待发货";
+                                    ceErpTradeCell.OutSid = curUseWayBillCode;
+                                    ceErpTradeCell.OrderState = 7;
+                                    ceErpTradeCell.IsUrgency = false;
+                                    ceErpTradeCell.LastBillCpCode = "";
+                                    ceErpTradeCell.LastBillWaybillCode = "";
+                                    ceErpTradeCell.FinishDeliveryTime = DateTime.Now;
+                                    ceErpTradeCell.IsReturn = 0;
+                                    ceErpTradeCell.MemoOpt = 0;
+                                    ceErpTradeCell.UpdateTime = DateTime.Now;
+                                    ceErpTradeCell.Update();
+
+                                    commonHelper.aftersaleSend(ceErpTradeCell.ctid, cpCode, curUseWayBillCode);
+
+                                    //还要插入快递信息到 快递信息表
+                                    CeErpExpressInfo exinfo = new CeErpExpressInfo();
+                                    exinfo.tid = ceErpTradeCell.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(ceErpTradeCell.ctid);
+                                    CeErpSukuraData.createInfo(ctid, 4);
+                                    commonHelper.insertToBuchaForDelivery(ceErpTrade.tid, ceErpTrade.posCode, cpCode, curUseWayBillCode);
+                                    if (ceErpTradeCell.SupplierId == 64)
+                                    {
+                                        commonHelper.sendCytExpress(exinfo);
+                                    }
+                                    LogHelper.addLog(ceErpTradeCell.ctid, CurrentUser.UserID, "发货成功-" + cpCode + "-" + curUseWayBillCode);
+                                    //CeErpDataSendOrderInfo.createObject(entity.ctid);
+
+                                }
+                                catch (Exception ex)
+                                {
+                                    XLog.SaveLog(0, "发货成功后更新数据失败," + ex.Message);
+                                }
+
+                            }
+                            else
+                            {
+                                ceErpTradeCell.UpdateTime = DateTime.Now;
+                                ceErpTradeCell.LastBillCpCode = cpCode;
+                                ceErpTradeCell.LastBillWaybillCode = curUseWayBillCode;
+                                ceErpTradeCell.Update();
+                                string errmsg = commonHelper.KeepChinese(apires);
+
+                                XLog.SaveLog(0, "打单后发货失败," + ceErpTradeCell.tid + "," + curUseWayBillCode + "," + apires);
+
+                                errorMsg += ceErpTradeCell.tid + ":" + apires + ";";
+                            }
+                        }
+
+                        DbHelper.DbConn.ExecuteNonQuery(string.Format("update CE_ErpDeliverMark with(rowlock) set isDel=1 where ctid in ({0})", string.Join(",", list)));
                     }
                 }
                 LogHelper.addLog(ctid, CurrentUser.UserID, btnType + "打单-" + cpCode + "-" + curUseWayBillCode);
@@ -6039,7 +6122,8 @@ namespace SiteCore.Handler
                 var res_obj = new
                 {
                     restype = 1,
-                    data = pData_str
+                    data = pData_str,
+                    errorMsg
                 };
                 string ro_json = JsonConvert.SerializeObject(res_obj);
                 ReturnSuccess(ro_json);
@@ -7459,7 +7543,7 @@ namespace SiteCore.Handler
                     //预完成给售后主管审核客户问题直接完成
                     if (entity.AfterSaleState == 1 && ceErpTradeAfterSaleExtend.DisagreeTime != null && num <= 1)
                     {
-                        if (DateTime.Compare(DateTime.Now.AddHours(-24), (DateTime)ceErpTradeAfterSaleExtend.DisagreeTime) >= 0)
+                        if (DateTime.Compare(DateTime.Now.AddHours(-48), (DateTime)ceErpTradeAfterSaleExtend.DisagreeTime) >= 0)
                         {
                             ceErpTradeAfterSaleExtend.DisagreeTimeOut += 1;
                         }
@@ -12930,7 +13014,8 @@ namespace SiteCore.Handler
                 string eid = GetPostString("ctid");
 
                 CeErpTradeCell entity = CeErpTradeCell.GetByCtid(eid);
-                if (entity != null)
+                CeErpTrade ceErpTrade = CeErpTrade.Get(entity.tid);
+                if (entity != null && ceErpTrade != null)
                 {
                     if (entity.OrderState > 6)
                     {
@@ -12938,7 +13023,15 @@ namespace SiteCore.Handler
                         return;
                     }
                     StringBuilder sql = new StringBuilder();
-                    sql.AppendFormat("select * from ce_erptradecell where SupplierId={0} and orderstate=6 and tid='{1}';", entity.SupplierId, entity.tid);
+                    sql.AppendFormat("select ctid,IsSF,seller_memo,OtherMemo from view_ErpTradeCell where SupplierId={0} and orderstate=6", entity.SupplierId);
+                    if (string.IsNullOrEmpty(ceErpTrade.receiverId))
+                    {
+                        sql.AppendFormat(" and (tid='{0}');", entity.tid);
+                    }
+                    else
+                    {
+                        sql.AppendFormat(" and (tid='{0}' or (receiverId = '{1}' and IsSF = '{2}'));", entity.tid, ceErpTrade.receiverId, entity.IsSF);
+                    }
                     DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
                     List<string> ids = new List<string>();
                     if (dt != null && dt.Rows.Count > 1)
@@ -13012,13 +13105,22 @@ namespace SiteCore.Handler
             CeErpTradeCell entity = CeErpTradeCell.GetByCtid(eid);
             if (entity != null)
             {
+                CeErpTrade ceErpTrade = CeErpTrade.Get(entity.tid);
                 CeErpDeliverMark ceErpDeliverMark = CeErpDeliverMark.GetByCtid(eid);
                 int current = 1;
 
                 if (ceErpDeliverMark == null)
                 {
                     StringBuilder sql = new StringBuilder();
-                    sql.AppendFormat("select * from ce_erptradecell where SupplierId={0} and orderstate=6 and tid='{1}';", entity.SupplierId, entity.tid);
+                    sql.AppendFormat("select ctid,IsSF,seller_memo,OtherMemo from view_ErpTradeCell where SupplierId={0} and orderstate=6", entity.SupplierId);
+                    if (string.IsNullOrEmpty(ceErpTrade.receiverId))
+                    {
+                        sql.AppendFormat(" and (tid='{0}');", entity.tid);
+                    }
+                    else
+                    {
+                        sql.AppendFormat(" and (tid='{0}' or (receiverId = '{1}' and IsSF = '{2}'));", entity.tid, ceErpTrade.receiverId, entity.IsSF);
+                    }
                     DataTable dt = DbHelper.DbConn.ExecuteDataset(sql.ToString()).Tables[0];
                     List<string> ids = new List<string>();
                     if (dt != null && dt.Rows.Count > 1)
@@ -13065,7 +13167,6 @@ namespace SiteCore.Handler
                         ceErpDeliverMark = new CeErpDeliverMark();
                         ceErpDeliverMark.ctid = eid;
                         ceErpDeliverMark.createtime = DateTime.Now;
-                        CeErpTrade ceErpTrade = CeErpTrade.Get(entity.tid);
                         if (ceErpTrade != null)
                         {
                             ceErpDeliverMark.nickName = ceErpTrade.buyer_nick;

+ 5 - 4
SiteCore/taobao/commonHelper.cs

@@ -1731,7 +1731,7 @@ namespace SiteCore
             }
         }
 
-        public static void setOrderDummyDelivery(string tid)
+        public static bool SetOrderDummyDelivery(string tid)
         {
             try
             {
@@ -1742,20 +1742,21 @@ namespace SiteCore
                     if (xuniapires.IndexOf("成功") != -1)
                     {
                         LogHelper.addLog(tid, 0, "电子稿自动发货");
-                        return;
+                        return true;
                     }
                     else if (xuniapires.IndexOf("失败") != -1)
                     {
                         string chiness = KeepChinese(xuniapires);
                         XLog.SaveLog(0, "setOrderDummyDelivery虚拟发货失败," + tid + "," + chiness);
-                        return;
+                        return false;
                     }
                 }
+                return false;
             }
             catch (Exception ex)
             {
                 XLog.SaveLog(0, "setOrderDummyDelivery虚拟发货出错," + tid + "," + ex.Message);
-                return;
+                return false;
             }
 
 

+ 11 - 2
SiteCore/taobao/preSalesHelper.cs

@@ -120,7 +120,12 @@ namespace SiteCore.Handler
                     entity.IsUrgency = true;
 
                     entity.Update();
-
+                    ApiVo apiVo = new ApiVo();
+                    apiVo.orderNumber = entity.ctid;
+                    apiVo.actionName = "changeDesign";
+                    apiVo.orderRemarks = entity.seller_memo;
+                    apiVo.remarkSign = 3;
+                    designHelper.API_WorkCore(apiVo);     //changeDesign
                     LogHelper.addLog(eid, UserID, name + "手动订单加急", 0, 1);
                     returnSuccessMsg("设置成功!");
                     return;
@@ -875,7 +880,11 @@ namespace SiteCore.Handler
                         entity.IsSF = 2;
                         sfTagMSg = "顺丰到付";
                     }
-
+                    ApiVo apiVo = new ApiVo();
+                    apiVo.orderNumber = entity.ctid;
+                    apiVo.actionName = "orderRemarks";
+                    apiVo.orderRemarks = entity.seller_memo;
+                    designHelper.API_WorkCore(apiVo);//changeDesign/orderRemarks
                     entity.Update();
                     LogHelper.addLog(entity.ctid, UserID, name + ":" + sfTagMSg + "--" + entity.seller_memo, entity.OrderState, 1);
                     returnSuccessMsg("标记成功!");

+ 13 - 3
Web/EDelivery/js/pddPrintBill.js

@@ -452,7 +452,7 @@ function sendPrintData(iTag) {
     let vend_list = supperIds == null ? [] : supperIds.split(",");
     //console.log("start" + billOrderList.length);
     var item = billOrderList[iTag];
-    let suppiers = ["97", "98"];
+    let suppiers = ["97", "98","119","3"];
     let intersection = vend_list.length == 0 ? [] : suppiers.filter(function (v) { return vend_list.indexOf(v) > -1 });
     if (intersection.length > 0) {
         checkOrderSplit(item, iTag)
@@ -491,6 +491,15 @@ function doRealGetPrintData(item, iTag, isTogether = 0) {
             errorMsg += ",";
         }
         else if (data.restype == 1) {
+            if (data.errorMsg != "") {
+                mini.showTips({
+                    content: data.errorMsg,
+                    state: "danger",
+                    x: "Center",
+                    y: "Center",
+                    timeout: 2000
+                });
+            }
             if (cpcode == "SFFQ-LY") {
                 doPrintSF(data, item.seller_memo);
             }
@@ -571,6 +580,7 @@ function checkOrderSplit(item, iTag) {
             let mome = "";
             let tableHtml = "";
             let isNumber = false;
+            let islast = true;
             if (data.data.length > 0) {
                 for (let i = 0; i < data.data.length; i++) {
                     let item = data.data[i];
@@ -617,13 +627,13 @@ function checkOrderSplit(item, iTag) {
                 </table>
             </div>
             <style>.mini-messagebox-content td{font-size:14px;padding: 5px;}.mini-panel-body{overflow-y: scroll !important;}</style>`;
-
+                let btns = islast ? ["合并打单", isNumber ? "同号等待" : "取号等待", "取消打印"] : [isNumber ? "同号等待" : "取号等待", "取消打印"];
                 mini.showMessageBox({
                     title: "合包提示!",
                     iconCls: "mini-messagebox-question",
                     maxWidth: 1200,
                     maxHeight: 500,
-                    buttons: ["合并打单", isNumber ? "同号等待" : "取号等待", "取消打印"],
+                    buttons: btns,
                     html,
                     callback: function (action) {
 

+ 14 - 2
Web/EDelivery/js/printBill.js

@@ -440,7 +440,7 @@ function sendPrintData(iTag) {
     let vend_list = supperIds == null ? [] : supperIds.split(",");
     //console.log("start" + billOrderList.length);
     var item = billOrderList[iTag];
-    let suppiers = ["97", "98"];
+    let suppiers = ["97", "98", "119", "3"];
     let intersection = vend_list.length == 0 ? [] : suppiers.filter(function (v) { return vend_list.indexOf(v) > -1 });
     if (intersection.length > 0) {
         checkOrderSplit(item, iTag);
@@ -479,6 +479,15 @@ function doRealGetPrintData(item, iTag, isTogether = 0) {
             errorMsg += ",\n";
         }
         else if (data.restype == 1) {
+            if (data.errorMsg != "") {
+                mini.showTips({
+                    content: data.errorMsg,
+                    state: "danger",
+                    x: "Center",
+                    y: "Center",
+                    timeout: 2000
+                });
+            }
             if (cpcode == "SFFQ-LY") {
                 doPrintSF(data, item.seller_memo);
             }
@@ -560,6 +569,7 @@ function checkOrderSplit(item, iTag) {
             let mome = "";
             let tableHtml = "";
             let isNumber = false;
+            let islast = true;
             if (data.data.length > 0) {
                 for (let i = 0; i < data.data.length; i++) {
                     let item = data.data[i];
@@ -573,6 +583,7 @@ function checkOrderSplit(item, iTag) {
                     }
                     if (item.dstate == 0) {
                         stateStr = "生产中";
+                        islast = false;
                     } else if (item.dstate == 1) {
                         stateStr = "此件";
                         mome = item.seller_memo;
@@ -607,12 +618,13 @@ function checkOrderSplit(item, iTag) {
             </div>
             <style>.mini-messagebox-content td{font-size:14px;padding: 5px;}.mini-panel-body{overflow-y: scroll !important;}</style>`;
 
+                let btns = islast ? ["合并打单", isNumber ? "同号等待" : "取号等待", "取消打印"] : [isNumber ? "同号等待" : "取号等待", "取消打印"];
                 mini.showMessageBox({
                     title: "合包提示!",
                     iconCls: "mini-messagebox-question",
                     maxWidth: 1200,
                     maxHeight: 500,
-                    buttons: ["合并打单", isNumber ? "同号等待" : "取号等待", "取消打印"],
+                    buttons: btns,
                     html,
                     callback: function (action) {
 

+ 1 - 0
Web/EOrder/OrderList.aspx

@@ -89,6 +89,7 @@
     <a id="btnOrderReset" runat="server" visible="false" class="mini-button mini-button-danger new_use_btn_red" iconcls="icon-reload" onclick="resetFn()">重置</a>
     <a id="btnOrderDelete" runat="server" visible="false" class="mini-button mini-button-danger new_use_btn_red" iconcls="icon-stop" onclick="deleteFn()">删除</a>
     <a id="btnClearRefund" runat="server" visible="false" class="mini-button mini-button-danger new_use_btn_red" iconcls="icon-remove" onclick="clearRefundFn()">清空退款状态</a>
+    <a id="btnDownTemplete" class="mini-button mini-button-danger new_use_btn_red" iconcls="icon-download" onclick="downTemplete()">上传地址模版</a>
     <div class="hz">
         <div style="margin-left: 10px;" id="id_gatherPayment">(0)</div>
     </div>

+ 4 - 0
Web/EOrder/js/p_order.js

@@ -1552,6 +1552,10 @@ function mymemoFn(eid) {
     mini.get("mymemo_win").show();
 }
 
+function downTemplete() {
+    window.open("https://dfdiyfile.oss-cn-fuzhou.aliyuncs.com/%E4%B8%8A%E4%BC%A0%E5%9C%B0%E5%9D%80%E6%A8%A1%E6%9D%BF.xls");
+}
+
 //保存备注
 function saveMyMemoFn() {
     var parms = new Object();

+ 1 - 1
ecomServer/MainForm.cs

@@ -328,7 +328,6 @@ namespace ErpServer
                                         }
                                     default:
                                         {
-
                                             DataTable dataTable = SqlHelper.ExecuteDataset(string.Format("SELECT orderFrom FROM [dbo].[Ce_ErpTradeCellExtend] WHERE ctid = '{0}'", dr["ctid"].ToString())).Tables[0];
                                             int num = Convert.ToInt16(dataTable.Rows[0]["orderFrom"]);
                                             SqlParameter[] sqlParameter ={
@@ -748,6 +747,7 @@ namespace ErpServer
                     //开始派单状态
                     if (isStart)
                     {
+
                         string sql = "select tid,ctid,IsOldCustomer,shopid,payment,ProductId,isDianziOrder from view_ErpTradeCell where orderstate=2 and productid<>0 and designuserid=0  and payment>0 and isrefund=0 order by IsUrgency desc,pay_time asc;";
                         DataTable dt = SqlHelper.ExecuteDataset(sql).Tables[0];
                         //object result = SqlHelper.ExecuteScalar(sql);