From a980cd04341d71216e0f59bd4b7327fe9fc50032 Mon Sep 17 00:00:00 2001
From: username@email.com <yzy2002yzy@163.com>
Date: 星期三, 21 五月 2025 11:41:46 +0800
Subject: [PATCH] 提交

---
 CY_ECommercePlatform/CY.WebForm/Pages/business/PlanOrderList.aspx.cs |  340 ++++++++++++++++++++++++++++++++++----------------------
 1 files changed, 206 insertions(+), 134 deletions(-)

diff --git a/CY_ECommercePlatform/CY.WebForm/Pages/business/PlanOrderList.aspx.cs b/CY_ECommercePlatform/CY.WebForm/Pages/business/PlanOrderList.aspx.cs
index 5a2c771..4e910a5 100644
--- a/CY_ECommercePlatform/CY.WebForm/Pages/business/PlanOrderList.aspx.cs
+++ b/CY_ECommercePlatform/CY.WebForm/Pages/business/PlanOrderList.aspx.cs
@@ -29,6 +29,7 @@
         //WorkBookTypeBLL _WorkBookTypeBLL = new WorkBookTypeBLL();
         CoreCmsPlanOrderItemBLL _coreCmsPlanOrderItemBLL = new CoreCmsPlanOrderItemBLL();
         EC_OrderPrintParameterBLL _OrderPrintParameterBLL = new EC_OrderPrintParameterBLL();
+        OA_CorporateClientsBLL bll_OA_CorporateClientsBLL = new OA_CorporateClientsBLL();
         public string orderkeyid = "";
 
         protected void Page_Load(object sender, EventArgs e)
@@ -90,7 +91,7 @@
             //{
             //    quxian = this.selectCounty.SelectedItem.Text;
             //}
-            this.RepSubjeSetctList.DataSource = _PlanOrderBLL.SelectModelPage(pa, HideKeyid.Value, selstatus.Value, sheng, shi
+            this.RepSubjeSetctList.DataSource = _PlanOrderBLL.SelectModelPage(pa, HideKeyid.Value, "", sheng, shi
                 , quxian, txtpianqu.Value ,txtshipAddress.Value,txtshipName.Value,txtshipMobile.Value,txtshouhuoAddress.Value,"","");
 
             this.RepSubjeSetctList.DataBind();
@@ -198,6 +199,7 @@
                 return;
             }
             var lie = new List<JiHuaOrder>();
+            var jiHuaOrderDetails = new List<JiHuaOrderDetail>();
             using (var fileStream = file.InputStream)
             {
                 // 浣跨敤HSSFWorkbook鎵撳紑.xls鏍煎紡鐨勬枃浠�
@@ -206,10 +208,41 @@
                 // 鑾峰彇绗竴涓伐浣滆〃
                 ISheet sheet = workbook.GetSheetAt(0);
 
-                // 杩唬宸ヤ綔琛ㄤ腑鐨勬墍鏈夎
-                for (int i = 1; i <= sheet.LastRowNum; i++)
+
+                //鑾峰彇琛ㄥご浣滀笟鏈悕绉�
+                for (int i = 0; i < 1; i++)
+                {
+                    IRow row = sheet.GetRow(i);
+                    int j = 5;
+                    while (true)
+                    {
+                        var jiHuaOrderDetail = new JiHuaOrderDetail();
+
+                        ICell cell1 = row.GetCell(j);
+                        if (cell1 == null)
+                        {
+                            break;
+                        }
+                        jiHuaOrderDetail.name = getcellvalue(cell1);
+                        if (string.IsNullOrEmpty(jiHuaOrderDetail.name))
+                        {
+                            break;
+                        }
+                        j += 1;
+                        jiHuaOrderDetails.Add(jiHuaOrderDetail);
+                    }
+                }
+
+
+
+
+                    // 杩唬宸ヤ綔琛ㄤ腑鐨勬墍鏈夎
+                    for (int i = 1; i <= sheet.LastRowNum; i++)
                 {
                     var hang = new JiHuaOrder();
+                    var jiHuaOrderDetails1 = new List<JiHuaOrderDetail>();
+
+
                     IRow row = sheet.GetRow(i);
                     if (row == null) continue; // 璺宠繃绌鸿
 
@@ -217,116 +250,95 @@
                     ICell cell0 = row.GetCell(0);
                     if (cell0 == null)
                     {
-                        JavaScript.MessageBox("绗�" + (i + 1) + "甯備笉鑳戒负绌�", this); 
+                        JavaScript.MessageBox("绗�" + (i + 1) + "鐗囧尯涓嶈兘涓虹┖", this); 
                         return;
                     }
-                    hang.shi = getcellvalue(cell0);
+                    hang.pianqu = getcellvalue(cell0);
 
                     ICell cell1 = row.GetCell(1);
                     if (cell1 == null)
                     {
-                        JavaScript.MessageBox("绗�" + (i + 1) + "鍖哄幙涓嶈兘涓虹┖", this);
+                        JavaScript.MessageBox("绗�" + (i + 1) + "瀛︽牎涓嶈兘涓虹┖", this);
                         return;
                     }
-                    hang.quxian = getcellvalue(cell1);
+                    hang.shipAddress = getcellvalue(cell1);
 
                     ICell cell2 = row.GetCell(2);
                     if (cell2 == null)
                     {
-                        JavaScript.MessageBox("绗�" + (i + 1) + "鐗囧尯涓嶈兘涓虹┖", this);
+                        JavaScript.MessageBox("绗�" + (i + 1) + "鑱旂郴浜轰笉鑳戒负绌�", this);
                         return;
                     }
-                    hang.pianqu = getcellvalue(cell2);
+                    hang.shipName = getcellvalue(cell2);
 
                     ICell cell3 = row.GetCell(3);
                     if (cell3 == null)
                     {
-                        JavaScript.MessageBox("绗�" + (i + 1) + "瀛︽牎涓嶈兘涓虹┖", this);
+                        JavaScript.MessageBox("绗�" + (i + 1) + "鑱旂郴鐢佃瘽涓嶈兘涓虹┖", this);
                         return;
                     }
-                    hang.shipAddress = getcellvalue(cell3);
+                    hang.shipMobile = getcellvalue(cell3);
 
                     ICell cell4 = row.GetCell(4);
                     if (cell4 == null)
                     {
-                        JavaScript.MessageBox("绗�" + (i + 1) + "鑱旂郴浜轰笉鑳戒负绌�", this);
-                        return;
-                    }
-                    hang.shipName = getcellvalue(cell4);
-
-                    ICell cell5 = row.GetCell(5);
-                    if (cell5 == null)
-                    {
-                        JavaScript.MessageBox("绗�" + (i + 1) + "鑱旂郴鐢佃瘽涓嶈兘涓虹┖", this);
-                        return;
-                    }
-                    hang.shipMobile = getcellvalue(cell5);
-                     
-                    ICell cell6 = row.GetCell(6);
-                    if (cell6 == null)
-                    {
                         JavaScript.MessageBox("绗�" + (i + 1) + "鏀惰揣鍦板潃涓嶈兘涓虹┖", this);
                         return;
                     }
-                    hang.shouhuoAddress = getcellvalue(cell6);
+                    hang.shouhuoAddress = getcellvalue(cell4);
 
-                    ICell cell7 = row.GetCell(7);
-                    if (cell7 == null)
+
+
+                    for(int j=0; j< jiHuaOrderDetails.Count; j++)
                     {
-                        JavaScript.MessageBox("绗�" + (i + 1) + "鍟嗗搧鍚嶇О涓嶈兘涓虹┖", this);
-                        return ;
-                    }
-                    hang.name = getcellvalue(cell7);
-                    
+                        var jiHuaOrderDetail = new JiHuaOrderDetail();
 
-                    ICell cell8 = row.GetCell(8);
-                    if (cell8 == null)
-                    {
-                        JavaScript.MessageBox("绗�" + (i + 1) + "瑙勬牸涓嶈兘涓虹┖", this);
-                        return ;
-                    }
-                    hang.specification = getcellvalue(cell8);
-                    
+                        jiHuaOrderDetail.name = jiHuaOrderDetails[j].name;
 
-                    //ICell cell9 = row.GetCell(9);
-                    //if (cell9 == null)
+                        ICell cell9 = row.GetCell(j+5);
+                        if (cell9 == null)
+                        {
+                            JavaScript.MessageBox("绗�" + (i + 1) + "鏁伴噺涓嶈兘涓虹┖", this);
+                            return;
+                        }
+                        int aaa = 0;
+                        int.TryParse(getcellvalue(cell9), out aaa);
+                        jiHuaOrderDetail.nums = aaa;
+
+                        jiHuaOrderDetails1.Add(jiHuaOrderDetail);
+                    }
+
+
+
+                    //ICell cell7 = row.GetCell(7);
+                    //if (cell7 == null)
                     //{
-                    //    JavaScript.MessageBox("绗�" + (i + 1) + "鍗曚环锛堝厓锛変笉鑳戒负绌�", this);
+                    //    JavaScript.MessageBox("绗�" + (i + 1) + "鍟嗗搧鍚嶇О涓嶈兘涓虹┖", this);
                     //    return ;
                     //}
-                    //hang.price = decimal.Parse(getcellvalue(cell9));
+                    //hang.name = getcellvalue(cell7);
 
 
-                    ICell cell9 = row.GetCell(9);
-                    if (cell9 == null)
-                    {
-                        JavaScript.MessageBox("绗�" + (i + 1) + "鏁伴噺涓嶈兘涓虹┖", this);
-                        return ;
-                    }
-                    int aaa = 0;
-                    int.TryParse(getcellvalue(cell9), out aaa);
-                    hang.nums = aaa;
+                    //ICell cell8 = row.GetCell(8);
+                    //if (cell8 == null)
+                    //{
+                    //    JavaScript.MessageBox("绗�" + (i + 1) + "瑙勬牸涓嶈兘涓虹┖", this);
+                    //    return ;
+                    //}
+                    //hang.specification = getcellvalue(cell8);
+
+
+
+
+
+                    hang.jiHuaOrderDetails = jiHuaOrderDetails1;
 
                     lie.Add(hang);
 
                 }
             }
-
-
             if (lie != null && lie.Count > 0)
             {
-                if (string.IsNullOrEmpty(lie[0].shi))
-                {
-                    JavaScript.MessageBox("绗�" + 1 + "甯備笉鑳戒负绌�", this);
-                    return;
-                }
-                if (string.IsNullOrEmpty(lie[0].quxian))
-                {
-                    JavaScript.MessageBox("绗�" + 1 + "鍖哄幙涓嶈兘涓虹┖", this);
-                    return;
-                }
-
-
                 for (int i = 0; i < lie.Count; i++)
                 {
                     if (!string.IsNullOrEmpty(lie[i].shipAddress))
@@ -337,26 +349,77 @@
                             return;
                         }
 
-                      
+
 
                     }
-                    if (string.IsNullOrEmpty(lie[i].name))
+
+                    for(int j = 0;j< lie[i].jiHuaOrderDetails.Count; j++)
                     {
-                        JavaScript.MessageBox("绗�" + (i + 1) + "鍟嗗搧鍚嶇О涓嶈兘涓虹┖", this);
-                        return;
+                        if (string.IsNullOrEmpty(lie[i].jiHuaOrderDetails[j].name))
+                        {
+                            JavaScript.MessageBox("绗�" + (i + 1) + "鍟嗗搧鍚嶇О涓嶈兘涓虹┖", this);
+                            return;
+                        }
                     }
 
-                    if (string.IsNullOrEmpty(lie[i].specification))
-                    {
-                        JavaScript.MessageBox("绗�" + (i + 1) + "瑙勬牸涓嶈兘涓虹┖", this);
-                        return;
-                    }
+
+                   
+
+                    //if (string.IsNullOrEmpty(lie[i].specification))
+                    //{
+                    //    JavaScript.MessageBox("绗�" + (i + 1) + "瑙勬牸涓嶈兘涓虹┖", this);
+                    //    return;
+                    //}
                 }
             }
+
+
+
+
+
+
+
+
+
+              
             var orderid = HideKeyid.Value;
             var sys_CitySites = bll_Sys_CitySiteBLL.SelectAllModel(null).ToList();
             var eC_OrderPrintParameter = _OrderPrintParameterBLL.GetModel(orderid.ToInt32().Value); ;
             InquiryCommonModel model = SerializationHelper.DeSerialize(typeof(InquiryCommonModel), eC_OrderPrintParameter.PrintParameter) as InquiryCommonModel;
+
+
+            var eC_OrderBasic = _eC_OrderBasicBLL.SelectModelById(orderid.ToInt32().Value);
+            var Province = "";
+            var City = "";
+            var County = "";
+            int Provinceid = 0;
+            int Cityid = 0;
+            int Countyid = 0;
+            if (eC_OrderBasic != null)
+            {
+
+                var customerCommunications = bll_OA_CorporateClientsBLL.GetModel_CustomerCommunications(eC_OrderBasic.BuyerId);
+                Province = customerCommunications.Province;
+                City = customerCommunications.City;
+                County = customerCommunications.County;
+
+                var sys_CitySite = bll_Sys_CitySiteBLL.GetModelByName(Province);
+                if (sys_CitySite != null)
+                {
+                    Provinceid = sys_CitySite.Keyid;
+                    var sys_CitySite1 = bll_Sys_CitySiteBLL.SelectAllNextModel(sys_CitySite.Keyid, 0, 2).FirstOrDefault(x => x.Name == City);
+                    if (sys_CitySite1 != null)
+                    {
+                        Cityid = sys_CitySite1.Keyid;
+                        var sys_CitySite2 = bll_Sys_CitySiteBLL.SelectAllNextModel(sys_CitySite.Keyid, sys_CitySite1.Keyid, 3).FirstOrDefault(x => x.Name == County);
+                        if (sys_CitySite2 != null)
+                        {
+                            Countyid = sys_CitySite2.Keyid;
+                        }
+                    }
+                }
+            }
+
 
             using (TransactionScope scope = new TransactionScope(TransactionScopeOption.Required,
         new TransactionOptions
@@ -370,72 +433,81 @@
                 string pianqu = "";
                 if (lie != null && lie.Count > 0)
                 {
-                    var order = new List<JiHuaOrder>();
-                    for (int i = 0; i < lie.Count; i++)
+                   
+                    for (int j = 0; j < lie.Count; j++)
                     {
-                        if (i == 0)
+                        var coreCmsPlanOrder = _PlanOrderBLL.GetModelByorderid(HideKeyid.Value.ToInt32().Value).Where(x => x.shipAddress == lie[j].shipAddress && x.shouhuoAddress == lie[j].shouhuoAddress).FirstOrDefault();
+                        if (coreCmsPlanOrder == null)
                         {
+                            CoreCmsPlanOrder order = new CoreCmsPlanOrder();
+                            order.status = 1;
+                            order.shipMobile = lie[j].shipMobile;
+                            order.shipAddress = lie[j].shipAddress;
+                            order.shipName = lie[j].shipName;
+                            order.shouhuoAddress = lie[j].shouhuoAddress;
+                            order.userMobile = lie[j].shipMobile;
+                            order.createBy = CurrentUser.ShortName;
+                            order.createTime = DateTime.Now;
+                            order.upDataBy = CurrentUser.ShortName;
+                            order.upDataTime = DateTime.Now;
+                            order.isdelete = false;
+                            order.orderkeyid = HideKeyid.Value.ToInt32();
+                            order.FirmId = CurrentUser.MemberId;
+                            order.sheng = Province;
+                            order.shi = City;
+                            order.quxian = County;
+                            order.shengId = Provinceid;
+                            order.shiId = Cityid;
+                            order.quxianId = Countyid;
 
-                            order.Add(lie[i]);
-                            pianqu = lie[i].pianqu;
 
-                        }
-                        else
-                        {
-                            if (string.IsNullOrEmpty(lie[i].shipAddress))
+                            order.pianqu = lie[j].pianqu;
+
+                            var jiHuaOrders = lie[j].jiHuaOrderDetails;
+                            decimal orderAmount = 0;
+                            var cmsPlanOrderItems = new List<CoreCmsPlanOrderItem>();
+                            for (int i = 0; i < jiHuaOrders.Count; i++)
                             {
-                                order.Add(lie[i]);
-                            }
-                            else
-                            {
-                                //淇濆瓨璁㈠崟
-                                //jm = await _coreCmsPlanOrderServices.ToAddJiHua(order, _user.ID, _user.Name);
-                                //if (jm.code == 1)
-                                //{
-                                //    return jm;
-                                //}
-                                string res = saveorder(order,model.InquiryWorkBookList,sys_CitySites);
-                                if (!string.IsNullOrEmpty(res))
+                                var workbook = model.InquiryWorkBookList.FirstOrDefault(x => (x.WorkBookSizeTxt + x.WorkBookNameTxt ) == jiHuaOrders[i].name || (x.WorkBookNameTxt + x.WorkBookSizeTxt ) == jiHuaOrders[i].name);
+                                if (workbook == null)
                                 {
-                                    JavaScript.MessageBox(res, this);
+                                     JavaScript.MessageBox(jiHuaOrders[i].name + "娌℃壘鍒板崟浠�", this);
                                     return;
                                 }
-                                order = new List<JiHuaOrder>();
-                                if (string.IsNullOrEmpty(lie[i].shi))
-                                {
-                                    lie[i].shi = lie[0].shi;
-                                }
-                                if (string.IsNullOrEmpty(lie[i].quxian))
-                                {
-                                    lie[i].quxian = lie[0].quxian;
-                                }
-                                if (string.IsNullOrEmpty(lie[i].pianqu))
-                                {
-                                    lie[i].pianqu = pianqu;
-                                }
-                                else
-                                {
-                                    pianqu = lie[i].pianqu;
-                                }
-                                order.Add(lie[i]);
+                                var item = new CoreCmsPlanOrderItem();
+                                item.orderId = 0;
+                                item.name = workbook.WorkBookNameTxt;
+                                item.specification = workbook.WorkBookSizeTxt;
+                                item.price = workbook.WorkBookPrice.ToDecimal2().Value;//jiHuaOrders[i].price;
+                                item.fengmian = string.IsNullOrEmpty(workbook.fengmian) ? "" : workbook.fengmian;
+                                item.neiye = string.IsNullOrEmpty(workbook.neiye) ? "" : workbook.neiye;
+                                item.nums = jiHuaOrders[i].nums; ;
+                                item.amount = item.price * (decimal)jiHuaOrders[i].nums;
+                                item.createBy = CurrentUser.ShortName;
+                                item.createTime = DateTime.Now;
+                                item.upDataBy = CurrentUser.ShortName;
+                                item.upDataTime = DateTime.Now;
+                                item.isdelete = false;
+                                item.isOld = true;
+                                cmsPlanOrderItems.Add(item);
+                                orderAmount += item.amount;
+                            }
+
+                            order.orderAmount = orderAmount;
+                            order.oldOrderAmount = orderAmount;
+                            order.keYongAmount = 0;
+                            order.huaFeiAmount = 0;
+
+
+                            var id = _PlanOrderBLL.InsertModelIden(order);
+                            var ssss = false;
+                            foreach (var cmsPlanOrderItem in cmsPlanOrderItems)
+                            {
+                                cmsPlanOrderItem.orderId = id;
+                                ssss = _PlanOrderBLL.insertModelOrderItem(cmsPlanOrderItem);
                             }
                         }
 
-                        if (i == lie.Count - 1)
-                        {
-                            //淇濆瓨璁㈠崟
-                            //jm = await _coreCmsPlanOrderServices.ToAddJiHua(order, _user.ID, _user.Name);
-                            //if (jm.code == 1)
-                            //{
-                            //    return jm;
-                            //}
-                          string res =  saveorder(order, model.InquiryWorkBookList, sys_CitySites);
-                            if (!string.IsNullOrEmpty(res))
-                            {
-                                JavaScript.MessageBox(res, this);
-                                return;
-                            }
-                        }
                     }
 
 

--
Gitblit v1.9.1