username@email.com
2024-09-09 cc170291673472d3cda8d7ea77f6bd3a3b5dbb83
CoreCms.Net.Web.Admin/Controllers/Order/CoreCmsPlanOrderController.cs
@@ -44,6 +44,8 @@
using static SKIT.FlurlHttpClient.Wechat.Api.Models.CgibinExpressDeliveryOpenMessageGetDeliveryListResponse.Types;
using System.Threading.Channels;
using System.Collections.Generic;
using EnumsNET;
using NPOI.SS.Formula.Functions;
namespace CoreCms.Net.Web.Admin.Controllers
{
@@ -258,8 +260,9 @@
            {
                where = where.And(p => p.isdelete == false);
            }
            OtherData otherData = new OtherData();
            //获取数据
            var list = await _CoreCmsPlanOrderServices.QueryPageAsync(where, orderEx, orderBy, pageCurrent, pageSize, true);
            var list = await _CoreCmsPlanOrderServices.QueryPageAsync(where, orderEx, orderBy, otherData, pageCurrent, pageSize, true);
            if (list != null && list.Count > 0)
            {
@@ -276,6 +279,12 @@
            jm.code = 0;
            jm.count = list.TotalCount;
            jm.msg = "数据调用成功!";
            otherData.heji1 = list.Sum(x => x.oldOrderAmount);
            otherData.heji2 = list.Sum(x => x.orderAmount);
            otherData.heji3 = list.Sum(x => x.keYongAmount);
            jm.otherData = otherData;
            return jm;
        }
        #endregion
@@ -645,6 +654,70 @@
        }
        #endregion
        #region 选择导出============================================================
        // POST: Api/CoreCmsPlanOrder/SelectExportExcel/10
        /// <summary>
        /// 选择导出
        /// </summary>
        /// <param name="entity"></param>
        /// <returns></returns>
        [HttpPost]
        [Description("选择导出")]
        public async Task<AdminUiCallBack> Selectselectchakan([FromBody] FMArrayStringIds entity)
        {
            var jm = new AdminUiCallBack();
            //创建Excel文件的对象
            var book = new HSSFWorkbook();
            //添加一个sheet
            var mySheet = book.CreateSheet("Sheet1");
            //获取list数据
            var listModel = await _CoreCmsPlanOrderServices.QueryListByClauseAsync(p => entity.id.Contains(p.orderId), p => p.orderId, OrderByType.Asc, true);
            var coreCmsPlanOrderItems = new List<CoreCmsPlanOrderItem>();
            //将数据逐步写入sheet1各个行
            for (var i = 0; i < listModel.Count; i++)
            {
                var modelItem1 = await _planOrderItemServices.QueryListByClauseAsync(p => p.orderId == listModel[i].orderId && p.isOld == true, p => p.specification, OrderByType.Asc);
                var modelItem2 = await _planOrderItemServices.QueryListByClauseAsync(p => p.orderId == listModel[i].orderId && p.isOld == false, p => p.specification, OrderByType.Asc);
                foreach (var coreCmsPlanOrderItem in modelItem1)
                {
                    var coreCmsPlanOrderItem1 = modelItem2.Where(p => p.name == coreCmsPlanOrderItem.name && p.specification == coreCmsPlanOrderItem.specification).FirstOrDefault();
                    if (coreCmsPlanOrderItem1 != null)
                    {
                        coreCmsPlanOrderItem.idnew = coreCmsPlanOrderItem1.id;
                        coreCmsPlanOrderItem.numsnew = coreCmsPlanOrderItem1.nums;
                        coreCmsPlanOrderItem.amountnew = coreCmsPlanOrderItem1.amount;
                    }
                    coreCmsPlanOrderItems.Add(coreCmsPlanOrderItem);
                }
            }
            var groupedByMultipleFields = coreCmsPlanOrderItems.GroupBy(p => new { p.name, p.specification })
                .Select(p=>new CoreCmsPlanOrderItem
                {
                    name = p.Key.name,
                    specification = p.Key.specification,
                    nums = p.Sum(c => c.nums),
                    numsnew = p.Sum(c => c.numsnew),
                }).ToList();
            jm.data = groupedByMultipleFields;
            jm.code = 0;
            return jm;
        }
        #endregion
        #region 选择导出============================================================
        // POST: Api/CoreCmsPlanOrder/SelectExportExcel/10
        /// <summary>
@@ -676,19 +749,19 @@
            cellNum++;
            var cell1 = headerRow.CreateCell(cellNum);
            cell1.SetCellValue("调整订单金额");
            cell1.SetCellValue("市");
            cell1.CellStyle = headerStyle;
            mySheet.SetColumnWidth(cellNum, 10 * 256);
            cellNum++;
            var cell2 = headerRow.CreateCell(cellNum);
            cell2.SetCellValue("订单状态");
            cell2.SetCellValue("区县");
            cell2.CellStyle = headerStyle;
            mySheet.SetColumnWidth(cellNum, 10 * 256);
            cellNum++;
            var cell3 = headerRow.CreateCell(cellNum);
            cell3.SetCellValue("用户ID 关联user.id");
            cell3.SetCellValue("片区");
            cell3.CellStyle = headerStyle;
            mySheet.SetColumnWidth(cellNum, 10 * 256);
            cellNum++;
@@ -706,131 +779,219 @@
            cellNum++;
            var cell6 = headerRow.CreateCell(cellNum);
            cell6.SetCellValue("收货电话");
            cell6.SetCellValue("联系电话");
            cell6.CellStyle = headerStyle;
            mySheet.SetColumnWidth(cellNum, 10 * 256);
            cellNum++;
            var cell7 = headerRow.CreateCell(cellNum);
            cell7.SetCellValue("计划订单金额");
            cell7.SetCellValue("收货地址");
            cell7.CellStyle = headerStyle;
            mySheet.SetColumnWidth(cellNum, 10 * 256);
            cellNum++;
            var cell8 = headerRow.CreateCell(cellNum);
            cell8.SetCellValue("可用余额");
            cell8.SetCellValue("计划金额");
            cell8.CellStyle = headerStyle;
            mySheet.SetColumnWidth(cellNum, 10 * 256);
            cellNum++;
            var cell9 = headerRow.CreateCell(cellNum);
            cell9.SetCellValue("建立时间");
            cell9.SetCellValue("调整金额");
            cell9.CellStyle = headerStyle;
            mySheet.SetColumnWidth(cellNum, 10 * 256);
            cellNum++;
            var cell10 = headerRow.CreateCell(cellNum);
            cell10.SetCellValue("修改时间");
            cell10.SetCellValue("可用余额");
            cell10.CellStyle = headerStyle;
            mySheet.SetColumnWidth(cellNum, 10 * 256);
            cellNum++;
            var cell11 = headerRow.CreateCell(cellNum);
            cell11.SetCellValue("创建人");
            cell11.SetCellValue("商品名称");
            cell11.CellStyle = headerStyle;
            mySheet.SetColumnWidth(cellNum, 10 * 256);
            cellNum++;
            var cell12 = headerRow.CreateCell(cellNum);
            cell12.SetCellValue("修改人");
            cell12.SetCellValue("单价(元)");
            cell12.CellStyle = headerStyle;
            mySheet.SetColumnWidth(cellNum, 10 * 256);
            cellNum++;
            var cell13 = headerRow.CreateCell(cellNum);
            cell13.SetCellValue("删除标志");
            cell13.SetCellValue("计划数量");
            cell13.CellStyle = headerStyle;
            mySheet.SetColumnWidth(cellNum, 10 * 256);
            cellNum++;
            var cell14 = headerRow.CreateCell(cellNum);
            cell14.SetCellValue("计划金额(元)");
            cell14.CellStyle = headerStyle;
            mySheet.SetColumnWidth(cellNum, 10 * 256);
            cellNum++;
            var cell15 = headerRow.CreateCell(cellNum);
            cell15.SetCellValue("调整数量");
            cell15.CellStyle = headerStyle;
            mySheet.SetColumnWidth(cellNum, 10 * 256);
            cellNum++;
            var cell16 = headerRow.CreateCell(cellNum);
            cell16.SetCellValue("调整金额(元)");
            cell16.CellStyle = headerStyle;
            mySheet.SetColumnWidth(cellNum, 10 * 256);
            cellNum++;
            headerRow.Height = 30 * 20;
            var commonCellStyle = ExcelHelper.GetCommonStyle(book);
            var rows = 1;
            //将数据逐步写入sheet1各个行
            for (var i = 0; i < listModel.Count; i++)
            {
                var rowTemp = mySheet.CreateRow(i + 1);
                var cellNumTemp = 0;
                var modelItem1 = await _planOrderItemServices.QueryListByClauseAsync(p => p.orderId == listModel[i].orderId && p.isOld == true, p => p.specification, OrderByType.Asc);
                var modelItem2 = await _planOrderItemServices.QueryListByClauseAsync(p => p.orderId == listModel[i].orderId && p.isOld == false, p => p.specification, OrderByType.Asc);
                foreach (var coreCmsPlanOrderItem in modelItem1)
                {
                    var coreCmsPlanOrderItem1 = modelItem2.Where(p => p.name == coreCmsPlanOrderItem.name && p.specification == coreCmsPlanOrderItem.specification).FirstOrDefault();
                    if (coreCmsPlanOrderItem1 != null)
                    {
                        coreCmsPlanOrderItem.idnew = coreCmsPlanOrderItem1.id;
                        coreCmsPlanOrderItem.numsnew = coreCmsPlanOrderItem1.nums;
                        coreCmsPlanOrderItem.amountnew = coreCmsPlanOrderItem1.amount;
                    }
                }
                var coreCmsOrderItems = new List<CoreCmsOrderItem>();
                //查询用计划订单积分购买的订单
                var coreCmsOrders = await _orderServices.QueryListByClauseAsync(p => p.planorderId == listModel[i].orderId && p.isdel == false);
                if (coreCmsOrders != null && coreCmsOrders.Count > 0)
                {
                    var orderids = new List<string>();
                    foreach (var coreCmsOrder in coreCmsOrders)
                    {
                        orderids.Add(coreCmsOrder.orderId);
                    }
                    coreCmsOrderItems = await _orderItemServices.QueryListByClauseAsync(p => orderids.Contains(p.orderId));
                }
                foreach (var  coreCmsOrder1 in coreCmsOrderItems)
                {
                    var coreCmsPlanOrderItem = new CoreCmsPlanOrderItem();
                    coreCmsPlanOrderItem.name = coreCmsOrder1.name;
                    coreCmsPlanOrderItem.specification = coreCmsOrder1.addon;
                    coreCmsPlanOrderItem.price = coreCmsOrder1.price;
                    coreCmsPlanOrderItem.nums = 0;
                    coreCmsPlanOrderItem.amount = 0;
                    coreCmsPlanOrderItem.numsnew = coreCmsOrder1.nums;
                    coreCmsPlanOrderItem.amountnew = coreCmsOrder1.amount;
                    modelItem1.Add(coreCmsPlanOrderItem);
                }
                for (var j = 0; j < modelItem1.Count; j++)
                {
                    var rowTemp = mySheet.CreateRow(rows);//i + 1
                    var cellNumTemp = 0;
                    var rowTemp0 = rowTemp.CreateCell(cellNumTemp);
                        rowTemp0.SetCellValue(listModel[i].orderId.ToString());
                        rowTemp0.CellStyle = commonCellStyle;
                        cellNumTemp++;
                    rowTemp0.SetCellValue(listModel[i].orderId.ToString());
                    rowTemp0.CellStyle = commonCellStyle;
                    cellNumTemp++;
                    var rowTemp1 = rowTemp.CreateCell(cellNumTemp);
                        rowTemp1.SetCellValue(listModel[i].orderAmount.ToString());
                        rowTemp1.CellStyle = commonCellStyle;
                        cellNumTemp++;
                    rowTemp1.SetCellValue(listModel[i].shi.ToString());
                    rowTemp1.CellStyle = commonCellStyle;
                    cellNumTemp++;
                    var rowTemp2 = rowTemp.CreateCell(cellNumTemp);
                        rowTemp2.SetCellValue(listModel[i].status.ToString());
                        rowTemp2.CellStyle = commonCellStyle;
                        cellNumTemp++;
                    rowTemp2.SetCellValue(listModel[i].quxian.ToString());
                    rowTemp2.CellStyle = commonCellStyle;
                    cellNumTemp++;
                    var rowTemp3 = rowTemp.CreateCell(cellNumTemp);
                        rowTemp3.SetCellValue(listModel[i].userId.ToString());
                        rowTemp3.CellStyle = commonCellStyle;
                        cellNumTemp++;
                    rowTemp3.SetCellValue(listModel[i].pianqu.ToString());
                    rowTemp3.CellStyle = commonCellStyle;
                    cellNumTemp++;
                    var rowTemp4 = rowTemp.CreateCell(cellNumTemp);
                        rowTemp4.SetCellValue(listModel[i].shipAddress.ToString());
                        rowTemp4.CellStyle = commonCellStyle;
                        cellNumTemp++;
                    rowTemp4.SetCellValue(listModel[i].shipAddress.ToString());
                    rowTemp4.CellStyle = commonCellStyle;
                    cellNumTemp++;
                    var rowTemp5 = rowTemp.CreateCell(cellNumTemp);
                        rowTemp5.SetCellValue(listModel[i].shipName.ToString());
                        rowTemp5.CellStyle = commonCellStyle;
                        cellNumTemp++;
                    rowTemp5.SetCellValue(listModel[i].shipName.ToString());
                    rowTemp5.CellStyle = commonCellStyle;
                    cellNumTemp++;
                    var rowTemp6 = rowTemp.CreateCell(cellNumTemp);
                        rowTemp6.SetCellValue(listModel[i].shipMobile.ToString());
                        rowTemp6.CellStyle = commonCellStyle;
                        cellNumTemp++;
                    rowTemp6.SetCellValue(listModel[i].shipMobile.ToString());
                    rowTemp6.CellStyle = commonCellStyle;
                    cellNumTemp++;
                    var rowTemp7 = rowTemp.CreateCell(cellNumTemp);
                        rowTemp7.SetCellValue(listModel[i].oldOrderAmount.ToString());
                        rowTemp7.CellStyle = commonCellStyle;
                        cellNumTemp++;
                    rowTemp7.SetCellValue(listModel[i].shouhuoAddress.ToString());
                    rowTemp7.CellStyle = commonCellStyle;
                    cellNumTemp++;
                    var rowTemp8 = rowTemp.CreateCell(cellNumTemp);
                        rowTemp8.SetCellValue(listModel[i].keYongAmount.ToString());
                        rowTemp8.CellStyle = commonCellStyle;
                        cellNumTemp++;
                    rowTemp8.SetCellValue(listModel[i].oldOrderAmount.ToString());
                    rowTemp8.CellStyle = commonCellStyle;
                    cellNumTemp++;
                    var rowTemp9 = rowTemp.CreateCell(cellNumTemp);
                        rowTemp9.SetCellValue(listModel[i].createTime.ToString());
                        rowTemp9.CellStyle = commonCellStyle;
                        cellNumTemp++;
                    rowTemp9.SetCellValue(listModel[i].orderAmount.ToString());
                    rowTemp9.CellStyle = commonCellStyle;
                    cellNumTemp++;
                    var rowTemp10 = rowTemp.CreateCell(cellNumTemp);
                        rowTemp10.SetCellValue(listModel[i].upDataTime.ToString());
                        rowTemp10.CellStyle = commonCellStyle;
                        cellNumTemp++;
                    rowTemp10.SetCellValue(listModel[i].keYongAmount.ToString());
                    rowTemp10.CellStyle = commonCellStyle;
                    cellNumTemp++;
                    var rowTemp11 = rowTemp.CreateCell(cellNumTemp);
                        rowTemp11.SetCellValue(listModel[i].createBy.ToString());
                        rowTemp11.CellStyle = commonCellStyle;
                        cellNumTemp++;
                    rowTemp11.SetCellValue(modelItem1[j].name.ToString() + modelItem1[j].specification.ToString());
                    rowTemp11.CellStyle = commonCellStyle;
                    cellNumTemp++;
                    var rowTemp12 = rowTemp.CreateCell(cellNumTemp);
                        rowTemp12.SetCellValue(listModel[i].upDataBy.ToString());
                        rowTemp12.CellStyle = commonCellStyle;
                        cellNumTemp++;
                    rowTemp12.SetCellValue(modelItem1[j].price.ToString());
                    rowTemp12.CellStyle = commonCellStyle;
                    cellNumTemp++;
                    var rowTemp13 = rowTemp.CreateCell(cellNumTemp);
                        rowTemp13.SetCellValue(listModel[i].isdelete.ToString());
                        rowTemp13.CellStyle = commonCellStyle;
                        cellNumTemp++;
                    rowTemp13.SetCellValue(modelItem1[j].nums.ToString());
                    rowTemp13.CellStyle = commonCellStyle;
                    cellNumTemp++;
                    var rowTemp14 = rowTemp.CreateCell(cellNumTemp);
                    rowTemp14.SetCellValue(modelItem1[j].amount.ToString());
                    rowTemp14.CellStyle = commonCellStyle;
                    cellNumTemp++;
                    var rowTemp15 = rowTemp.CreateCell(cellNumTemp);
                    rowTemp15.SetCellValue(modelItem1[j].numsnew.ToString());
                    rowTemp15.CellStyle = commonCellStyle;
                    cellNumTemp++;
                    var rowTemp16 = rowTemp.CreateCell(cellNumTemp);
                    rowTemp16.SetCellValue(modelItem1[j].amountnew.ToString());
                    rowTemp16.CellStyle = commonCellStyle;
                    cellNumTemp++;
                    rows++;
                }
            }
            // 导出excel
@@ -876,8 +1037,26 @@
            {
                where = where.And(p => p.orderId.Contains(orderId));
            }
         //调整订单金额 decimal
         var orderAmount = Request.Form["orderAmount"].FirstOrDefault().ObjectToDecimal(0);
            //市 varchar
            var shi = Request.Form["shi"].FirstOrDefault().ObjectToInt(0);
            if (shi > 0)
            {
                where = where.And(p => p.shiId == shi);
            }
            //区县 varchar
            var quxian = Request.Form["quxian"].FirstOrDefault().ObjectToInt(0); ;
            if (quxian > 0)
            {
                where = where.And(p => p.quxianId == quxian);
            }
            //收货地址 varchar
            var shouhuoAddress = Request.Form["shouhuoAddress"].FirstOrDefault();
            if (!string.IsNullOrEmpty(shouhuoAddress))
            {
                where = where.And(p => p.shouhuoAddress.Contains(shouhuoAddress));
            }
            //调整订单金额 decimal
            var orderAmount = Request.Form["orderAmount"].FirstOrDefault().ObjectToDecimal(0);
            if (orderAmount > 0)
            {
                where = where.And(p => p.orderAmount == orderAmount);
@@ -993,170 +1172,257 @@
                var headerRow = mySheet.CreateRow(0);
            var headerStyle = ExcelHelper.GetHeaderStyle(book);
            var cellNum = 0;
            var cell0 = headerRow.CreateCell(cellNum);
            cell0.SetCellValue("订单号");
            cell0.CellStyle = headerStyle;
            mySheet.SetColumnWidth(cellNum, 10 * 256);
            cellNum++;
            var cell1 = headerRow.CreateCell(cellNum);
            cell1.SetCellValue("调整订单金额");
            cell1.SetCellValue("市");
            cell1.CellStyle = headerStyle;
            mySheet.SetColumnWidth(cellNum, 10 * 256);
            cellNum++;
            var cell2 = headerRow.CreateCell(cellNum);
            cell2.SetCellValue("订单状态");
            cell2.SetCellValue("区县");
            cell2.CellStyle = headerStyle;
            mySheet.SetColumnWidth(cellNum, 10 * 256);
            cellNum++;
            var cell3 = headerRow.CreateCell(cellNum);
            cell3.SetCellValue("用户ID 关联user.id");
            cell3.SetCellValue("片区");
            cell3.CellStyle = headerStyle;
            mySheet.SetColumnWidth(cellNum, 10 * 256);
            cellNum++;
            var cell4 = headerRow.CreateCell(cellNum);
            cell4.SetCellValue("学校");
            cell4.CellStyle = headerStyle;
            mySheet.SetColumnWidth(cellNum, 10 * 256);
            cellNum++;
            var cell5 = headerRow.CreateCell(cellNum);
            cell5.SetCellValue("联系人");
            cell5.CellStyle = headerStyle;
            mySheet.SetColumnWidth(cellNum, 10 * 256);
            cellNum++;
            var cell6 = headerRow.CreateCell(cellNum);
            cell6.SetCellValue("收货电话");
            cell6.SetCellValue("联系电话");
            cell6.CellStyle = headerStyle;
            mySheet.SetColumnWidth(cellNum, 10 * 256);
            cellNum++;
            var cell7 = headerRow.CreateCell(cellNum);
            cell7.SetCellValue("计划订单金额");
            cell7.SetCellValue("收货地址");
            cell7.CellStyle = headerStyle;
            mySheet.SetColumnWidth(cellNum, 10 * 256);
            cellNum++;
            var cell8 = headerRow.CreateCell(cellNum);
            cell8.SetCellValue("可用余额");
            cell8.SetCellValue("计划金额");
            cell8.CellStyle = headerStyle;
            mySheet.SetColumnWidth(cellNum, 10 * 256);
            cellNum++;
            var cell9 = headerRow.CreateCell(cellNum);
            cell9.SetCellValue("建立时间");
            cell9.SetCellValue("调整金额");
            cell9.CellStyle = headerStyle;
            mySheet.SetColumnWidth(cellNum, 10 * 256);
            cellNum++;
            var cell10 = headerRow.CreateCell(cellNum);
            cell10.SetCellValue("修改时间");
            cell10.SetCellValue("可用余额");
            cell10.CellStyle = headerStyle;
            mySheet.SetColumnWidth(cellNum, 10 * 256);
            cellNum++;
            var cell11 = headerRow.CreateCell(cellNum);
            cell11.SetCellValue("创建人");
            cell11.SetCellValue("商品名称");
            cell11.CellStyle = headerStyle;
            mySheet.SetColumnWidth(cellNum, 10 * 256);
            cellNum++;
            var cell12 = headerRow.CreateCell(cellNum);
            cell12.SetCellValue("修改人");
            cell12.SetCellValue("单价(元)");
            cell12.CellStyle = headerStyle;
            mySheet.SetColumnWidth(cellNum, 10 * 256);
            cellNum++;
            var cell13 = headerRow.CreateCell(cellNum);
            cell13.SetCellValue("删除标志");
            cell13.SetCellValue("计划数量");
            cell13.CellStyle = headerStyle;
            mySheet.SetColumnWidth(cellNum, 10 * 256);
            cellNum++;
            var cell14 = headerRow.CreateCell(cellNum);
            cell14.SetCellValue("计划金额(元)");
            cell14.CellStyle = headerStyle;
            mySheet.SetColumnWidth(cellNum, 10 * 256);
            cellNum++;
            var cell15 = headerRow.CreateCell(cellNum);
            cell15.SetCellValue("调整数量");
            cell15.CellStyle = headerStyle;
            mySheet.SetColumnWidth(cellNum, 10 * 256);
            cellNum++;
            var cell16 = headerRow.CreateCell(cellNum);
            cell16.SetCellValue("调整金额(元)");
            cell16.CellStyle = headerStyle;
            mySheet.SetColumnWidth(cellNum, 10 * 256);
            cellNum++;
            headerRow.Height = 30 * 20;
            var commonCellStyle = ExcelHelper.GetCommonStyle(book);
            var rows = 1;
            //将数据逐步写入sheet1各个行
            for (var i = 0; i < listModel.Count; i++)
            {
                var rowTemp = mySheet.CreateRow(i + 1);
                var cellNumTemp = 0;
                var modelItem1 = await _planOrderItemServices.QueryListByClauseAsync(p => p.orderId == listModel[i].orderId && p.isOld == true, p => p.specification, OrderByType.Asc);
            var rowTemp0 = rowTemp.CreateCell(cellNumTemp);
                rowTemp0.SetCellValue(listModel[i].orderId.ToString());
                rowTemp0.CellStyle = commonCellStyle;
                cellNumTemp++;
                var modelItem2 = await _planOrderItemServices.QueryListByClauseAsync(p => p.orderId == listModel[i].orderId && p.isOld == false, p => p.specification, OrderByType.Asc);
            var rowTemp1 = rowTemp.CreateCell(cellNumTemp);
                rowTemp1.SetCellValue(listModel[i].orderAmount.ToString());
                rowTemp1.CellStyle = commonCellStyle;
                cellNumTemp++;
            var rowTemp2 = rowTemp.CreateCell(cellNumTemp);
                rowTemp2.SetCellValue(listModel[i].status.ToString());
                rowTemp2.CellStyle = commonCellStyle;
                cellNumTemp++;
                foreach (var coreCmsPlanOrderItem in modelItem1)
                {
                    var coreCmsPlanOrderItem1 = modelItem2.Where(p => p.name == coreCmsPlanOrderItem.name && p.specification == coreCmsPlanOrderItem.specification).FirstOrDefault();
                    if (coreCmsPlanOrderItem1 != null)
                    {
                        coreCmsPlanOrderItem.idnew = coreCmsPlanOrderItem1.id;
                        coreCmsPlanOrderItem.numsnew = coreCmsPlanOrderItem1.nums;
                        coreCmsPlanOrderItem.amountnew = coreCmsPlanOrderItem1.amount;
                    }
                }
                var coreCmsOrderItems = new List<CoreCmsOrderItem>();
                //查询用计划订单积分购买的订单
                var coreCmsOrders = await _orderServices.QueryListByClauseAsync(p => p.planorderId == listModel[i].orderId && p.isdel == false);
                if (coreCmsOrders != null && coreCmsOrders.Count > 0)
                {
                    var orderids = new List<string>();
                    foreach (var coreCmsOrder in coreCmsOrders)
                    {
                        orderids.Add(coreCmsOrder.orderId);
                    }
                    coreCmsOrderItems = await _orderItemServices.QueryListByClauseAsync(p => orderids.Contains(p.orderId));
            var rowTemp3 = rowTemp.CreateCell(cellNumTemp);
                rowTemp3.SetCellValue(listModel[i].userId.ToString());
                rowTemp3.CellStyle = commonCellStyle;
                cellNumTemp++;
                }
                foreach (var coreCmsOrder1 in coreCmsOrderItems)
                {
                    var coreCmsPlanOrderItem = new CoreCmsPlanOrderItem();
                    coreCmsPlanOrderItem.name = coreCmsOrder1.name;
                    coreCmsPlanOrderItem.specification = coreCmsOrder1.addon;
                    coreCmsPlanOrderItem.price = coreCmsOrder1.price;
                    coreCmsPlanOrderItem.nums = 0;
                    coreCmsPlanOrderItem.amount = 0;
                    coreCmsPlanOrderItem.numsnew = coreCmsOrder1.nums;
                    coreCmsPlanOrderItem.amountnew = coreCmsOrder1.amount;
            var rowTemp4 = rowTemp.CreateCell(cellNumTemp);
                rowTemp4.SetCellValue(listModel[i].shipAddress.ToString());
                rowTemp4.CellStyle = commonCellStyle;
                cellNumTemp++;
                    modelItem1.Add(coreCmsPlanOrderItem);
                }
                for (var j = 0; j < modelItem1.Count; j++)
                {
                    var rowTemp = mySheet.CreateRow(rows);//i + 1
                    var cellNumTemp = 0;
                    var rowTemp0 = rowTemp.CreateCell(cellNumTemp);
                    rowTemp0.SetCellValue(listModel[i].orderId.ToString());
                    rowTemp0.CellStyle = commonCellStyle;
                    cellNumTemp++;
            var rowTemp5 = rowTemp.CreateCell(cellNumTemp);
                rowTemp5.SetCellValue(listModel[i].shipName.ToString());
                rowTemp5.CellStyle = commonCellStyle;
                cellNumTemp++;
                    var rowTemp1 = rowTemp.CreateCell(cellNumTemp);
                    rowTemp1.SetCellValue(listModel[i].shi.ToString());
                    rowTemp1.CellStyle = commonCellStyle;
                    cellNumTemp++;
            var rowTemp6 = rowTemp.CreateCell(cellNumTemp);
                rowTemp6.SetCellValue(listModel[i].shipMobile.ToString());
                rowTemp6.CellStyle = commonCellStyle;
                cellNumTemp++;
                    var rowTemp2 = rowTemp.CreateCell(cellNumTemp);
                    rowTemp2.SetCellValue(listModel[i].quxian.ToString());
                    rowTemp2.CellStyle = commonCellStyle;
                    cellNumTemp++;
            var rowTemp7 = rowTemp.CreateCell(cellNumTemp);
                rowTemp7.SetCellValue(listModel[i].oldOrderAmount.ToString());
                rowTemp7.CellStyle = commonCellStyle;
                cellNumTemp++;
                    var rowTemp3 = rowTemp.CreateCell(cellNumTemp);
                    rowTemp3.SetCellValue(listModel[i].pianqu.ToString());
                    rowTemp3.CellStyle = commonCellStyle;
                    cellNumTemp++;
            var rowTemp8 = rowTemp.CreateCell(cellNumTemp);
                rowTemp8.SetCellValue(listModel[i].keYongAmount.ToString());
                rowTemp8.CellStyle = commonCellStyle;
                cellNumTemp++;
                    var rowTemp4 = rowTemp.CreateCell(cellNumTemp);
                    rowTemp4.SetCellValue(listModel[i].shipAddress.ToString());
                    rowTemp4.CellStyle = commonCellStyle;
                    cellNumTemp++;
            var rowTemp9 = rowTemp.CreateCell(cellNumTemp);
                rowTemp9.SetCellValue(listModel[i].createTime.ToString());
                rowTemp9.CellStyle = commonCellStyle;
                cellNumTemp++;
                    var rowTemp5 = rowTemp.CreateCell(cellNumTemp);
                    rowTemp5.SetCellValue(listModel[i].shipName.ToString());
                    rowTemp5.CellStyle = commonCellStyle;
                    cellNumTemp++;
            var rowTemp10 = rowTemp.CreateCell(cellNumTemp);
                rowTemp10.SetCellValue(listModel[i].upDataTime.ToString());
                rowTemp10.CellStyle = commonCellStyle;
                cellNumTemp++;
                    var rowTemp6 = rowTemp.CreateCell(cellNumTemp);
                    rowTemp6.SetCellValue(listModel[i].shipMobile.ToString());
                    rowTemp6.CellStyle = commonCellStyle;
                    cellNumTemp++;
            var rowTemp11 = rowTemp.CreateCell(cellNumTemp);
                rowTemp11.SetCellValue(listModel[i].createBy.ToString());
                rowTemp11.CellStyle = commonCellStyle;
                cellNumTemp++;
                    var rowTemp7 = rowTemp.CreateCell(cellNumTemp);
                    rowTemp7.SetCellValue(listModel[i].shouhuoAddress.ToString());
                    rowTemp7.CellStyle = commonCellStyle;
                    cellNumTemp++;
            var rowTemp12 = rowTemp.CreateCell(cellNumTemp);
                rowTemp12.SetCellValue(listModel[i].upDataBy.ToString());
                rowTemp12.CellStyle = commonCellStyle;
                cellNumTemp++;
                    var rowTemp8 = rowTemp.CreateCell(cellNumTemp);
                    rowTemp8.SetCellValue(listModel[i].oldOrderAmount.ToString());
                    rowTemp8.CellStyle = commonCellStyle;
                    cellNumTemp++;
            var rowTemp13 = rowTemp.CreateCell(cellNumTemp);
                rowTemp13.SetCellValue(listModel[i].isdelete.ToString());
                rowTemp13.CellStyle = commonCellStyle;
                cellNumTemp++;
                    var rowTemp9 = rowTemp.CreateCell(cellNumTemp);
                    rowTemp9.SetCellValue(listModel[i].orderAmount.ToString());
                    rowTemp9.CellStyle = commonCellStyle;
                    cellNumTemp++;
                    var rowTemp10 = rowTemp.CreateCell(cellNumTemp);
                    rowTemp10.SetCellValue(listModel[i].keYongAmount.ToString());
                    rowTemp10.CellStyle = commonCellStyle;
                    cellNumTemp++;
                    var rowTemp11 = rowTemp.CreateCell(cellNumTemp);
                    rowTemp11.SetCellValue(modelItem1[j].name.ToString() + modelItem1[j].specification.ToString());
                    rowTemp11.CellStyle = commonCellStyle;
                    cellNumTemp++;
                    var rowTemp12 = rowTemp.CreateCell(cellNumTemp);
                    rowTemp12.SetCellValue(modelItem1[j].price.ToString());
                    rowTemp12.CellStyle = commonCellStyle;
                    cellNumTemp++;
                    var rowTemp13 = rowTemp.CreateCell(cellNumTemp);
                    rowTemp13.SetCellValue(modelItem1[j].nums.ToString());
                    rowTemp13.CellStyle = commonCellStyle;
                    cellNumTemp++;
                    var rowTemp14 = rowTemp.CreateCell(cellNumTemp);
                    rowTemp14.SetCellValue(modelItem1[j].amount.ToString());
                    rowTemp14.CellStyle = commonCellStyle;
                    cellNumTemp++;
                    var rowTemp15 = rowTemp.CreateCell(cellNumTemp);
                    rowTemp15.SetCellValue(modelItem1[j].numsnew.ToString());
                    rowTemp15.CellStyle = commonCellStyle;
                    cellNumTemp++;
                    var rowTemp16 = rowTemp.CreateCell(cellNumTemp);
                    rowTemp16.SetCellValue(modelItem1[j].amountnew.ToString());
                    rowTemp16.CellStyle = commonCellStyle;
                    cellNumTemp++;
                    rows++;
                }
            }
            // 写入到excel