From 5591c18dc3500bd3e0719bb6b28b26f7f9e7cb58 Mon Sep 17 00:00:00 2001
From: username@email.com <yzy2002yzy@163.com>
Date: 星期三, 15 五月 2024 09:46:19 +0800
Subject: [PATCH] 计划订单

---
 CoreCms.Net.Model/Entities/Order/CoreCmsOrder.cs                      |   17 +
 CoreCms.Net.Services/Bill/CoreCmsBillRefundServices.cs                |   36 ++
 CoreCms.Net.IServices/Order/ICoreCmsOrderServices.cs                  |    3 
 CoreCms.Net.Services/Order/CoreCmsOrderServices.cs                    |  109 +++++++
 CoreCms.Net.Web.WebApi/Controllers/UserController.cs                  |    3 
 CoreCms.Net.Model/ViewModels/DTO/OrderDTO.cs                          |    9 
 CoreCms.Net.Web.Admin/wwwroot/views/corecmsplanorder/index.html       |   87 +++-
 CoreCms.Net.Repository/Order/CoreCmsPlanOrderRepository.cs            |    7 
 CoreCms.Net.Web.Admin/wwwroot/views/corecmsplanorder/details.html     |  121 +++++--
 CoreCms.Net.IServices/Order/ICoreCmsPlanOrderServices.cs              |    6 
 CoreCms.Net.Web.WebApi/Controllers/OrderController.cs                 |   39 ++
 CoreCms.Net.Web.Admin/Controllers/Order/CoreCmsPlanOrderController.cs |   67 +++
 CoreCms.Net.Configuration/GlobalEnumVars.cs                           |   15 
 CoreCms.Net.Web.Admin/wwwroot/views/corecmsplanorder/edit.html        |  103 ++++--
 CoreCms.Net.Services/Order/CoreCmsPlanOrderServices.cs                |  187 +++++++++++-
 CoreCms.Net.Model/Entities/User/CoreCmsUser.cs                        |   12 
 CoreCms.Net.Model/Entities/Order/CoreCmsPlanOrder.cs                  |   12 
 CoreCms.Net.Model/Entities/Order/CoreCmsPlanOrderItem.cs              |   18 +
 18 files changed, 698 insertions(+), 153 deletions(-)

diff --git a/CoreCms.Net.Configuration/GlobalEnumVars.cs b/CoreCms.Net.Configuration/GlobalEnumVars.cs
index 6d4795c..5b16d0a 100644
--- a/CoreCms.Net.Configuration/GlobalEnumVars.cs
+++ b/CoreCms.Net.Configuration/GlobalEnumVars.cs
@@ -667,10 +667,10 @@
         /// </summary>
         public enum PlanOrderTiJiao
         {
-            [Description("鏈彁浜�")]
-            鏈彁浜� = 1,
-            [Description("宸叉彁浜�")]
-            鎻愪氦 = 2
+            [Description("鏈攣鍗�")]
+            鏈攣鍗� = 1,
+            [Description("宸查攣鍗�")]
+            宸查攣鍗� = 2
         }
 
         /// <summary>
@@ -1025,7 +1025,12 @@
             /// 浣欓鏀粯
             /// </summary>
             [Description("浣欓鏀粯")]
-            balancepay = 4
+            balancepay = 4,
+            /// <summary>
+            /// 璁″垝璁㈠崟鏀粯
+            /// </summary>
+            [Description("璁″垝璁㈠崟鏀粯")]
+            planorderpay = 5
         }
         #endregion
 
diff --git a/CoreCms.Net.IServices/Order/ICoreCmsOrderServices.cs b/CoreCms.Net.IServices/Order/ICoreCmsOrderServices.cs
index 754c95e..28bdc99 100644
--- a/CoreCms.Net.IServices/Order/ICoreCmsOrderServices.cs
+++ b/CoreCms.Net.IServices/Order/ICoreCmsOrderServices.cs
@@ -81,10 +81,11 @@
         /// <param name="requireOrder">寰俊鑷畾涔夌粍浠讹紙鏄惁闇�瑕佹帹鍗曪紝1:闇�瑕侊紝0:涓嶉渶瑕侊級</param>
         /// <param name="requiredFundType">寰俊鑷畾涔夌粍浠讹紙requireOrder = 1鏃剁敓鏁堬紝0锛岄潪浜岀骇鍟嗘埛鍙疯鍗曪紝1锛屼簩绾у晢鎴峰彿璁㈠崟锛�2锛屼袱绉嶆柟寮忕殕鍙紙鍚庣画鍙細瀛樺湪1锛�)</param>
         /// <param name="traceId">寰俊鑷畾涔夌粍浠讹紙璺熻釜ID锛屾湁鏁堟湡鍗佸垎閽燂紝浼氬奖鍝嶄富鎾綊鍥犮�佸垎浜憳褰掑洜绛夛紝闇�鍒涘缓璁㈠崟鍓嶈皟鐢紝璋冪敤鐢熸垚璁㈠崟 api 鏃堕渶浼犲叆璇ュ弬鏁�)</param>
+        ///  <param name="planorderId">璁″垝璁㈠崟id</param>
         /// <returns></returns>
         Task<WebApiCallBack> ToAdd(int userId, int orderType, string cartIds, int receiptType, int ushipId, int storeId,
             string ladingName, string ladingMobile, string memo, int point, string couponCode,
-            int source, int scene, int taxType, string taxName, string taxCode, int objectId, int teamId, int requireOrder, int requiredFundType, string traceId);
+            int source, int scene, int taxType, string taxName, string taxCode, int objectId, int teamId, int requireOrder, int requiredFundType, string traceId, string planorderId);
 
         /// <summary>
         ///     鑾峰彇璁㈠崟淇℃伅
diff --git a/CoreCms.Net.IServices/Order/ICoreCmsPlanOrderServices.cs b/CoreCms.Net.IServices/Order/ICoreCmsPlanOrderServices.cs
index 77887fb..34866a5 100644
--- a/CoreCms.Net.IServices/Order/ICoreCmsPlanOrderServices.cs
+++ b/CoreCms.Net.IServices/Order/ICoreCmsPlanOrderServices.cs
@@ -55,14 +55,14 @@
         /// </summary>
         /// <param name="id"></param>
         /// <returns></returns>
-        Task<AdminUiCallBack> DeleteByIdAsync(object id);
+        Task<AdminUiCallBack> DeleteByIdAsync(object id, string userName);
 
         /// <summary>
         /// 閲嶅啓鍒犻櫎鎸囧畾ID闆嗗悎鐨勬暟鎹�(鎵归噺鍒犻櫎)
         /// </summary>
         /// <param name="ids"></param>
         /// <returns></returns>
-        Task<AdminUiCallBack> DeleteByIdsAsync(int[] ids);
+        Task<AdminUiCallBack> DeleteByIdsAsync(string[] ids, string userName);
 
         #endregion
 
@@ -98,7 +98,7 @@
         ///     鑾峰彇璁″垝璁㈠崟鍒楄〃寰俊灏忕▼搴�
         /// </summary>
         /// <returns></returns>
-        Task<WebApiCallBack> GetOrderList(int status = -1, int userId = 0, int page = 1, int limit = 5);
+        Task<WebApiCallBack> GetOrderList(int status = -1, int userId = 0, int page = 1, int limit = 5,int money = 0);
 
 
         /// <summary>
diff --git a/CoreCms.Net.Model/Entities/Order/CoreCmsOrder.cs b/CoreCms.Net.Model/Entities/Order/CoreCmsOrder.cs
index 47c08f9..31fd134 100644
--- a/CoreCms.Net.Model/Entities/Order/CoreCmsOrder.cs
+++ b/CoreCms.Net.Model/Entities/Order/CoreCmsOrder.cs
@@ -549,7 +549,20 @@
         
         
         public System.DateTime? updateTime  { get; set; }
-        
-		
+
+
+
+
+        /// <summary>
+        /// 璁″垝璁㈠崟id    ALTER TABLE [CoreCmsOrder] ADD  [planorderId] [nvarchar](255) NULL;
+        /// </summary>
+        [Display(Name = "璁″垝璁㈠崟id")]
+
+
+        [StringLength(maximumLength: 255, ErrorMessage = "{0}涓嶈兘瓒呰繃{1}瀛�")]
+
+
+        public System.String planorderId { get; set; }
+
     }
 }
diff --git a/CoreCms.Net.Model/Entities/Order/CoreCmsPlanOrder.cs b/CoreCms.Net.Model/Entities/Order/CoreCmsPlanOrder.cs
index cea3557..4bcee55 100644
--- a/CoreCms.Net.Model/Entities/Order/CoreCmsPlanOrder.cs
+++ b/CoreCms.Net.Model/Entities/Order/CoreCmsPlanOrder.cs
@@ -213,5 +213,17 @@
         /// </summary>
         [SugarColumn(IsIgnore = true)]
         public string statusText { get; set; }
+
+
+        /// <summary>
+        /// 宸茶姳璐归噾棰�
+        /// </summary>
+        [Display(Name = "宸茶姳璐归噾棰�")]
+
+        [Required(ErrorMessage = "璇疯緭鍏0}")]
+
+
+
+        public System.Decimal huaFeiAmount { get; set; }
     }
 }
diff --git a/CoreCms.Net.Model/Entities/Order/CoreCmsPlanOrderItem.cs b/CoreCms.Net.Model/Entities/Order/CoreCmsPlanOrderItem.cs
index 82038bb..113204f 100644
--- a/CoreCms.Net.Model/Entities/Order/CoreCmsPlanOrderItem.cs
+++ b/CoreCms.Net.Model/Entities/Order/CoreCmsPlanOrderItem.cs
@@ -94,5 +94,23 @@
 
 
 
+        /// <summary>
+        /// 鏁伴噺
+        /// </summary>
+        [SugarColumn(IsIgnore = true)]
+        public System.Int32 numsnew { get; set; }
+
+        /// <summary>
+        /// 鏁伴噺
+        /// </summary>
+        [SugarColumn(IsIgnore = true)]
+        public System.Decimal amountnew { get; set; }
+
+        /// <summary>
+        /// id
+        /// </summary>
+        [SugarColumn(IsIgnore = true)]
+        public System.Int32 idnew { get; set; }
+
     }
 }
diff --git a/CoreCms.Net.Model/Entities/User/CoreCmsUser.cs b/CoreCms.Net.Model/Entities/User/CoreCmsUser.cs
index e7090f3..275e591 100644
--- a/CoreCms.Net.Model/Entities/User/CoreCmsUser.cs
+++ b/CoreCms.Net.Model/Entities/User/CoreCmsUser.cs
@@ -153,5 +153,17 @@
         [SugarColumn(ColumnDescription = "鍒犻櫎鏍囧織 鏈夋暟鎹氨鏄垹闄�")]
         [Required(ErrorMessage = "璇疯緭鍏0}")]
         public System.Boolean isDelete { get; set; }
+
+
+        /// <summary>
+        /// 鏄惁鏄鍒掕鍗曠敤鎴�    ALTER TABLE [CoreCmsUser] ADD  [isplanorder] [nvarchar](255) NULL;
+        /// </summary>
+        [Display(Name = "璁″垝璁㈠崟id")]
+
+
+        [StringLength(maximumLength: 255, ErrorMessage = "{0}涓嶈兘瓒呰繃{1}瀛�")]
+
+
+        public System.String isplanorder { get; set; }
     }
 }
\ No newline at end of file
diff --git a/CoreCms.Net.Model/ViewModels/DTO/OrderDTO.cs b/CoreCms.Net.Model/ViewModels/DTO/OrderDTO.cs
index 022be77..c6a256a 100644
--- a/CoreCms.Net.Model/ViewModels/DTO/OrderDTO.cs
+++ b/CoreCms.Net.Model/ViewModels/DTO/OrderDTO.cs
@@ -185,6 +185,10 @@
         public int[] itemNumarray { get; set; }
 
 
+        /// <summary>
+        ///     璁″垝璁㈠崟id
+        /// </summary>
+        public string planorderId { get; set; }
     }
 
     /// <summary>
@@ -243,6 +247,11 @@
         ///     鐘舵��
         /// </summary>
         public int status { get; set; } = 0;
+
+        /// <summary>
+        ///     鏄惁澶т簬0
+        /// </summary>
+        public int money { get; set; } = 0;
     }
 
     /// <summary>
diff --git a/CoreCms.Net.Repository/Order/CoreCmsPlanOrderRepository.cs b/CoreCms.Net.Repository/Order/CoreCmsPlanOrderRepository.cs
index 4ecbd45..8d4409b 100644
--- a/CoreCms.Net.Repository/Order/CoreCmsPlanOrderRepository.cs
+++ b/CoreCms.Net.Repository/Order/CoreCmsPlanOrderRepository.cs
@@ -83,7 +83,8 @@
             oldModel.createBy = entity.createBy;
             oldModel.upDataBy = entity.upDataBy;
             oldModel.isdelete = entity.isdelete;
-            
+            oldModel.huaFeiAmount = entity.huaFeiAmount;
+
             //浜嬬墿澶勭悊杩囩▼缁撴潫
             var bl = await DbClient.Updateable(oldModel).ExecuteCommandHasChangeAsync();
             jm.code = bl ? 0 : 1;
@@ -189,6 +190,7 @@
                 shipMobile = p.shipMobile,
                 oldOrderAmount = p.oldOrderAmount,
                 keYongAmount = p.keYongAmount,
+                huaFeiAmount = p.huaFeiAmount,
                 createTime = p.createTime,
                 upDataTime = p.upDataTime,
                 createBy = p.createBy,
@@ -218,7 +220,8 @@
                 shipMobile = p.shipMobile,
                 oldOrderAmount = p.oldOrderAmount,
                 keYongAmount = p.keYongAmount,
-                createTime = p.createTime,
+                    huaFeiAmount = p.huaFeiAmount,
+                    createTime = p.createTime,
                 upDataTime = p.upDataTime,
                 createBy = p.createBy,
                 upDataBy = p.upDataBy,
diff --git a/CoreCms.Net.Services/Bill/CoreCmsBillRefundServices.cs b/CoreCms.Net.Services/Bill/CoreCmsBillRefundServices.cs
index 68d6321..626c4e3 100644
--- a/CoreCms.Net.Services/Bill/CoreCmsBillRefundServices.cs
+++ b/CoreCms.Net.Services/Bill/CoreCmsBillRefundServices.cs
@@ -39,10 +39,15 @@
         private readonly IBalancePayServices _balancePayServices;
         private readonly IAliPayServices _aliPayServices;
         private readonly IWeChatPayServices _weChatPayServices;
+        private readonly ICoreCmsPlanOrderServices _planOrderServices;
+        //private readonly ICoreCmsOrderServices _orderServices; 
 
 
         private readonly IUnitOfWork _unitOfWork;
-        public CoreCmsBillRefundServices(IUnitOfWork unitOfWork, ICoreCmsBillRefundRepository dal, ICoreCmsBillPaymentsServices billPaymentsServices, ICoreCmsMessageCenterServices messageCenterServices, ICoreCmsPaymentsServices paymentsServices, IBalancePayServices balancePayServices, IAliPayServices aliPayServices, IWeChatPayServices weChatPayServices)
+        public CoreCmsBillRefundServices(IUnitOfWork unitOfWork, ICoreCmsBillRefundRepository dal, ICoreCmsBillPaymentsServices billPaymentsServices, ICoreCmsMessageCenterServices messageCenterServices, ICoreCmsPaymentsServices paymentsServices, IBalancePayServices balancePayServices, IAliPayServices aliPayServices, IWeChatPayServices weChatPayServices
+            , ICoreCmsPlanOrderServices planOrderServices
+            //, ICoreCmsOrderServices orderServices
+            )
         {
             this._dal = dal;
             base.BaseDal = dal;
@@ -53,6 +58,8 @@
             _balancePayServices = balancePayServices;
             _aliPayServices = aliPayServices;
             _weChatPayServices = weChatPayServices;
+            _planOrderServices = planOrderServices;
+            //_orderServices = orderServices;
         }
 
 
@@ -236,6 +243,33 @@
             {
                 jm = await _balancePayServices.Refund(info, panyMentsInfo);
             }
+            ////璁″垝璁㈠崟閫�娆�
+            else if (panyMentsInfo.paymentCode == GlobalEnumVars.PaymentsTypes.planorderpay.ToString())
+            {
+                //    //鏌ヨ璁㈠崟
+
+                //  var order  =   await _orderServices.QueryByIdAsync(info.sourceId);
+                var order = await _unitOfWork.GetDbClient().Queryable<CoreCmsOrder>().Where(p => p.orderId == info.sourceId).FirstAsync();
+                if (order == null)
+                {
+                    _unitOfWork.RollbackTran();
+                    jm.msg = "璁㈠崟鑾峰彇澶辫触";
+                    return jm;
+                }
+                //鏌ヨ璁″垝璁㈠崟
+                var planOrder = await _planOrderServices.QueryByIdAsync(order.planorderId);
+                //涓婇潰淇濆瓨濂借鍗曡〃锛屼笅闈繚瀛樿鍗曠殑鍏朵粬淇℃伅
+                if (planOrder == null || planOrder.isdelete == true)
+                {
+                    _unitOfWork.RollbackTran();
+                    jm.msg = "璁″垝璁㈠崟鑾峰彇澶辫触";
+                    return jm;
+                }
+                planOrder.huaFeiAmount = planOrder.huaFeiAmount - panyMentsInfo.money;
+                //淇敼璁″垝璁㈠崟鐨勫凡鑺辫垂閲戦
+                await _planOrderServices.UpdateAsync(planOrder);
+
+            }
 
             if (jm.status)
             {
diff --git a/CoreCms.Net.Services/Order/CoreCmsOrderServices.cs b/CoreCms.Net.Services/Order/CoreCmsOrderServices.cs
index 6f44512..5a02e7e 100644
--- a/CoreCms.Net.Services/Order/CoreCmsOrderServices.cs
+++ b/CoreCms.Net.Services/Order/CoreCmsOrderServices.cs
@@ -81,6 +81,7 @@
         private readonly IRedisOperationRepository _redisOperationRepository;
         private readonly ICoreCmsUserWeChatInfoServices _userWeChatInfoServices;
         private readonly WeChat.Service.HttpClients.IWeChatApiHttpClientFactory _weChatApiHttpClientFactory;
+        private readonly ICoreCmsPlanOrderServices _planOrderServices;
 
         private IUnitOfWork _unitOfWork;
 
@@ -108,7 +109,8 @@
             , ICoreCmsPaymentsServices paymentsServices
             , ICoreCmsBillRefundServices billRefundServices
             , ICoreCmsBillLadingServices billLadingServices
-            , ICoreCmsBillReshipServices billReshipServices, ICoreCmsMessageCenterServices messageCenterServices, ICoreCmsGoodsCommentServices goodsCommentServices, ISysTaskLogServices taskLogServices, ICoreCmsPromotionRecordServices promotionRecordServices, IRedisOperationRepository redisOperationRepository, ICoreCmsUserWeChatInfoServices userWeChatInfoServices, IWeChatApiHttpClientFactory weChatApiHttpClientFactory, IUnitOfWork unitOfWork)
+            , ICoreCmsBillReshipServices billReshipServices, ICoreCmsMessageCenterServices messageCenterServices, ICoreCmsGoodsCommentServices goodsCommentServices, ISysTaskLogServices taskLogServices, ICoreCmsPromotionRecordServices promotionRecordServices, IRedisOperationRepository redisOperationRepository, ICoreCmsUserWeChatInfoServices userWeChatInfoServices, IWeChatApiHttpClientFactory weChatApiHttpClientFactory, IUnitOfWork unitOfWork
+            , ICoreCmsPlanOrderServices planOrderServices)
         {
             this._dal = dal;
             base.BaseDal = dal;
@@ -145,6 +147,7 @@
             _userWeChatInfoServices = userWeChatInfoServices;
             _weChatApiHttpClientFactory = weChatApiHttpClientFactory;
             _unitOfWork = unitOfWork;
+            _planOrderServices = planOrderServices;
         }
 
         #region 鏌ヨ鍥㈣喘绉掓潃涓嬪崟鏁伴噺锛堣幏鍙栬揣鍝佺殑绉掓潃鍥㈣喘鏁版嵁锛�
@@ -226,8 +229,9 @@
         /// <param name="requireOrder">寰俊鑷畾涔夌粍浠讹紙鏄惁闇�瑕佹帹鍗曪紝1:闇�瑕侊紝0:涓嶉渶瑕侊級</param>
         /// <param name="requiredFundType">寰俊鑷畾涔夌粍浠讹紙requireOrder = 1鏃剁敓鏁堬紝0锛岄潪浜岀骇鍟嗘埛鍙疯鍗曪紝1锛屼簩绾у晢鎴峰彿璁㈠崟锛�2锛屼袱绉嶆柟寮忕殕鍙紙鍚庣画鍙細瀛樺湪1锛�)</param>
         /// <param name="traceId">寰俊鑷畾涔夌粍浠讹紙璺熻釜ID锛屾湁鏁堟湡鍗佸垎閽燂紝浼氬奖鍝嶄富鎾綊鍥犮�佸垎浜憳褰掑洜绛夛紝闇�鍒涘缓璁㈠崟鍓嶈皟鐢紝璋冪敤鐢熸垚璁㈠崟 api 鏃堕渶浼犲叆璇ュ弬鏁�)</param>
+        /// <param name="planorderId">璁″垝璁㈠崟id</param>
         /// <returns></returns>
-        public async Task<WebApiCallBack> ToAdd(int userId, int orderType, string cartIds, int receiptType, int ushipId, int storeId, string ladingName, string ladingMobile, string memo, int point, string couponCode, int source, int scene, int taxType, string taxName, string taxCode, int objectId, int teamId, int requireOrder, int requiredFundType, string traceId)
+        public async Task<WebApiCallBack> ToAdd(int userId, int orderType, string cartIds, int receiptType, int ushipId, int storeId, string ladingName, string ladingMobile, string memo, int point, string couponCode, int source, int scene, int taxType, string taxName, string taxCode, int objectId, int teamId, int requireOrder, int requiredFundType, string traceId, string planorderId)
         {
             var jm = new WebApiCallBack() { methodDescription = "鍒涘缓璁㈠崟" };
             try
@@ -283,6 +287,7 @@
                 order.confirmStatus = (int)GlobalEnumVars.OrderConfirmStatus.ReceiptNotConfirmed;
                 order.createTime = DateTime.Now;
                 order.scene = scene;
+                order.planorderId = planorderId;
 
                 //涓婇潰淇濆瓨濂借鍗曡〃锛屼笅闈繚瀛樿鍗曠殑鍏朵粬淇℃伅
                 if (orderItems == null)
@@ -510,7 +515,105 @@
                 }
                 else
                 {
-                    await _messageCenterServices.SendMessage(order.userId, GlobalEnumVars.PlatformMessageTypes.CreateOrder.ToString(), JObject.FromObject(order));
+                    if (!string.IsNullOrEmpty(planorderId))
+                    {
+                        //鏌ヨ璁″垝璁㈠崟
+                      var planOrder = await _planOrderServices.QueryByIdAsync(planorderId);
+                        //涓婇潰淇濆瓨濂借鍗曡〃锛屼笅闈繚瀛樿鍗曠殑鍏朵粬淇℃伅
+                        if (planOrder == null || planOrder.isdelete == true)
+                        {
+                            _unitOfWork.RollbackTran();
+                            jm.msg = "璁″垝璁㈠崟鑾峰彇澶辫触";
+                            return jm;
+                        }
+                        if (planOrder.status != 2)
+                        {
+                            _unitOfWork.RollbackTran();
+                            jm.msg = "璁″垝璁㈠崟娌℃湁閿佸崟";
+                            return jm;
+                        }
+
+                        if ((planOrder.keYongAmount - planOrder.huaFeiAmount - order.orderAmount)<0)
+                        {
+                            _unitOfWork.RollbackTran();
+                            jm.msg = "璁″垝璁㈠崟鍙敤浣欓涓嶈冻";
+                            return jm;
+                        }
+                        planOrder.huaFeiAmount = planOrder.huaFeiAmount + order.orderAmount;
+                        //淇敼璁″垝璁㈠崟鐨勫凡鑺辫垂閲戦
+                       var crr  = await _planOrderServices.UpdateAsync(planOrder);
+
+
+
+                        //鍒涘缓鏀粯鍗�
+                        var billPayments = new CoreCmsBillPayments();
+                        billPayments.paymentId = CommonHelper.GetSerialNumberType((int)GlobalEnumVars.SerialNumberType.鏀粯鍗曠紪鍙�);
+                        billPayments.sourceId = order.orderId;
+                        billPayments.money = order.orderAmount;
+                        billPayments.userId = userId;
+                        billPayments.type = order.orderType;
+                        billPayments.status = (int)GlobalEnumVars.BillPaymentsStatus.Payed;
+                        billPayments.paymentCode = GlobalEnumVars.PaymentsTypes.planorderpay.ToString();
+                        billPayments.ip = _httpContextAccessor.HttpContext?.Connection.RemoteIpAddress != null ? _httpContextAccessor.HttpContext.Connection.RemoteIpAddress.MapToIPv4().ToString() : "127.0.0.1";
+                        billPayments.payedMsg = "璁″垝璁㈠崟鐩存帴鏀粯鎴愬姛";
+                        billPayments.parameters = "";
+                        billPayments.createTime = DateTime.Now;
+                        billPayments.updateTime = DateTime.Now;
+
+
+                        await _billPaymentsServices.InsertAsync(billPayments);
+
+                        //璋冩暣鐩存帴鏀粯鎴愬姛
+                        await _dal.UpdateAsync(p => new CoreCmsOrder()
+                        {
+                            payedAmount = order.orderAmount,
+                            paymentTime = DateTime.Now,
+                            updateTime = DateTime.Now,
+                            paymentCode = GlobalEnumVars.PaymentsTypes.planorderpay.ToString(),
+                            payStatus = (int)GlobalEnumVars.OrderPayStatus.Yes,
+                            orderAmount = order.orderAmount
+                        }, p => p.orderId == order.orderId);
+
+                        //璁板綍璁㈠崟鏃ュ織
+                        orderLog = new CoreCmsOrderLog
+                        {
+                            userId = userId,
+                            orderId = order.orderId,
+                            type = (int)GlobalEnumVars.OrderLogTypes.LOG_TYPE_PAY,
+                            msg = "璁″垝璁㈠崟鐩存帴鏀粯鎴愬姛",
+                            data = JsonConvert.SerializeObject(order),
+                            createTime = DateTime.Now
+                        };
+                        await _orderLogServices.InsertAsync(orderLog);
+
+                        //濡傛灉鏄棬搴楄嚜鎻愶紝搴旇鑷姩璺宠繃鍙戣揣锛岀敓鎴愭彁璐у崟淇℃伅锛屼娇鐢ㄦ彁璐у崟鏍搁攢銆�
+                        if (order.receiptType == (int)GlobalEnumVars.OrderReceiptType.SelfDelivery)
+                        {
+                            var allConfigs = await _settingServices.GetConfigDictionaries();
+                            var storeOrderAutomaticDelivery = CommonHelper
+                                .GetConfigDictionary(allConfigs, SystemSettingConstVars.StoreOrderAutomaticDelivery)
+                                .ObjectToInt(1);
+                            if (storeOrderAutomaticDelivery == 1)
+                            {
+                                //璁㈠崟鑷姩鍙戣揣
+                                await _redisOperationRepository.ListLeftPushAsync(RedisMessageQueueKey.OrderAutomaticDelivery, JsonConvert.SerializeObject(order));
+                            }
+                        }
+
+                        //鐢ㄦ埛鍗囩骇澶勭悊
+                       // await _redisOperationRepository.ListLeftPushAsync(RedisMessageQueueKey.UserUpGrade, JsonConvert.SerializeObject(order));
+                        //鍙戦�佹敮浠樻垚鍔熶俊鎭�,澧炲姞鍙戦�佸唴瀹�
+                        await _messageCenterServices.SendMessage(order.userId, GlobalEnumVars.PlatformMessageTypes.OrderPayed.ToString(), JObject.FromObject(order));
+                        await _messageCenterServices.SendMessage(order.userId, GlobalEnumVars.PlatformMessageTypes.SellerOrderNotice.ToString(), JObject.FromObject(order));
+                        //鏄撹仈浜戞墦鍗版満鎵撳嵃
+                        await _redisOperationRepository.ListLeftPushAsync(RedisMessageQueueKey.OrderPrint, JsonConvert.SerializeObject(order));
+
+                    }
+                    else
+                    {
+                        await _messageCenterServices.SendMessage(order.userId, GlobalEnumVars.PlatformMessageTypes.CreateOrder.ToString(), JObject.FromObject(order));
+                    }
+                      
                 }
 
                 _unitOfWork.CommitTran();
diff --git a/CoreCms.Net.Services/Order/CoreCmsPlanOrderServices.cs b/CoreCms.Net.Services/Order/CoreCmsPlanOrderServices.cs
index a4525c3..23c778f 100644
--- a/CoreCms.Net.Services/Order/CoreCmsPlanOrderServices.cs
+++ b/CoreCms.Net.Services/Order/CoreCmsPlanOrderServices.cs
@@ -36,6 +36,7 @@
 using static SKIT.FlurlHttpClient.Wechat.Api.Models.ScanProductAddV2Request.Types.Product.Types;
 using NPOI.SS.Formula.Functions;
 using CoreCms.Net.Model.FromBody;
+using Essensoft.Paylink.Alipay.Domain;
 
 
 namespace CoreCms.Net.Services
@@ -101,9 +102,72 @@
         /// </summary>
         /// <param name="id"></param>
         /// <returns></returns>
-        public async Task<AdminUiCallBack> DeleteByIdAsync(object id)
+        public async Task<AdminUiCallBack> DeleteByIdAsync(object id,string userName)
         {
-            return await _dal.DeleteByIdAsync(id);
+            var jm = new AdminUiCallBack() ;
+            try
+            {
+                //寮�濮嬩簨鍔″鐞�
+                _unitOfWork.BeginTran();
+                var order = await _dal.QueryByIdAsync(id);
+
+                if (order.status == 2)  //&& string.IsNullOrEmpty(houtai)
+                {
+                    _unitOfWork.RollbackTran();
+                    jm.code = 1;
+                    jm.msg = "璁㈠崟宸茬粡閿佸崟涓嶈兘閲嶅閿佸崟";
+                    return jm;
+                }
+
+                order.upDataBy = userName;
+                order.upDataTime = DateTime.Now;
+
+
+
+
+
+
+
+                //order.keYongAmount = order.oldOrderAmount - order.orderAmount;
+              
+
+                 
+                    order.status = 2;
+
+                //if (order.keYongAmount > 0)
+                //{
+                //    //淇敼鐢ㄦ埛浣欓
+
+                //    var jmsss = await _coreCmsUserServices.UpdateBalance(order.userId, order.keYongAmount, "鐢ㄦ埛璁″垝璁㈠崟" + order.orderId + "娆鹃」缁撲綑");
+                //}
+
+
+
+                //}
+
+
+                //鏍¢獙鍚庡啀鍒涘缓璁㈠崟
+                var jmss = await _dal.UpdateAsync(order);
+
+
+
+
+
+
+                _unitOfWork.CommitTran();
+
+                jm.code = 0;
+                jm.data = order;
+                jm.msg = "閿佸崟鎴愬姛";
+            }
+            catch (Exception e)
+            {
+                _unitOfWork.RollbackTran();
+                jm.code = 1;
+                jm.msg = e.ToString();
+            }
+            return jm;
+            //return await _dal.DeleteByIdAsync(id);
         }
 
         /// <summary>
@@ -111,9 +175,77 @@
         /// </summary>
         /// <param name="ids"></param>
         /// <returns></returns>
-        public async Task<AdminUiCallBack> DeleteByIdsAsync(int[] ids)
+        public async Task<AdminUiCallBack> DeleteByIdsAsync(string[] ids, string userName)
         {
-            return await _dal.DeleteByIdsAsync(ids);
+            var jm = new AdminUiCallBack();
+            try
+            {
+                //寮�濮嬩簨鍔″鐞�
+                _unitOfWork.BeginTran();
+                var orders = await _dal.QueryListByClauseAsync(p => ids.Contains(p.orderId), p => p.orderId, OrderByType.Asc, true);
+
+                foreach (var order in orders)
+                {
+                    if (order.status != 2)  //&& string.IsNullOrEmpty(houtai)
+                    {
+                        order.upDataBy = userName;
+                        order.upDataTime = DateTime.Now;
+                        order.status = 2;
+                        //鏍¢獙鍚庡啀鍒涘缓璁㈠崟
+                        var jmss = await _dal.UpdateAsync(order);
+                    }
+
+                    
+
+
+
+
+
+
+                    //order.keYongAmount = order.oldOrderAmount - order.orderAmount;
+
+
+
+
+
+                    //if (order.keYongAmount > 0)
+                    //{
+                    //    //淇敼鐢ㄦ埛浣欓
+
+                    //    var jmsss = await _coreCmsUserServices.UpdateBalance(order.userId, order.keYongAmount, "鐢ㄦ埛璁″垝璁㈠崟" + order.orderId + "娆鹃」缁撲綑");
+                    //}
+
+
+
+                    //}
+
+
+                    
+                }
+
+
+
+               
+
+
+
+
+
+
+                _unitOfWork.CommitTran();
+
+                jm.code = 0;
+                jm.data = orders;
+                jm.msg = "閿佸崟鎴愬姛";
+            }
+            catch (Exception e)
+            {
+                _unitOfWork.RollbackTran();
+                jm.code = 1;
+                jm.msg = e.ToString();
+            }
+            return jm;
+            //return await _dal.DeleteByIdsAsync(ids);
         }
 
         #endregion
@@ -155,7 +287,7 @@
         /// 鑾峰彇璁″垝璁㈠崟鍒楄〃寰俊灏忕▼搴�
         /// </summary>
         /// <returns></returns>
-        public async Task<WebApiCallBack> GetOrderList(int status = -1, int userId = 0, int page = 1, int limit = 5)
+        public async Task<WebApiCallBack> GetOrderList(int status = -1, int userId = 0, int page = 1, int limit = 5, int money = 0)
         {
             var jm = new WebApiCallBack { status = true };
 
@@ -171,6 +303,10 @@
 
                 where = where.And(p => p.userId == userId);
             }
+            if (money > 0)
+            {
+                where = where.And(p => p.keYongAmount > p.huaFeiAmount);
+            }
             var list = await _dal.QueryPageAsync(where, p => p.createTime, OrderByType.Desc, page, limit);
 
             if (list!=null && list.Count>0)
@@ -179,7 +315,7 @@
                 {
                     //鑾峰彇鐩稿叧鐘舵�佹弿杩拌鏄庤浆鎹�
                     order.statusText = EnumHelper.GetEnumDescriptionByValue<GlobalEnumVars.PlanOrderTiJiao>(order.status);
-                    
+                    order.keYongAmount = order.keYongAmount - order.huaFeiAmount;
                 }
             }
             jm.data = new
@@ -219,11 +355,11 @@
                 var order  = await _dal.QueryByIdAsync(orderId);
 
                 var oldorderAmount = order.orderAmount;
-                if (order.status == 2 && string.IsNullOrEmpty(houtai))
+                if (order.status == 2 && string.IsNullOrEmpty(houtai))   
                 {
                     _unitOfWork.RollbackTran();
                     jm.status = false;
-                    jm.otherData = "璁㈠崟宸茬粡鎻愪氦涓嶈兘淇敼";
+                    jm.otherData = "璁㈠崟宸茬粡閿佸崟涓嶈兘淇敼";
                     return jm;
                 }
 
@@ -249,32 +385,36 @@
                 }
 
                 order.orderAmount = orderAmount;
-                order.keYongAmount = order.oldOrderAmount - order.orderAmount;
+                order.keYongAmount = order.oldOrderAmount - order.orderAmount ;
 
-                if (order.keYongAmount < 0)
+                if (order.keYongAmount < order.huaFeiAmount)
                 {
                     _unitOfWork.RollbackTran();
                     jm.status = false;
-                    jm.otherData = "璁㈠崟閲戦瓒呭嚭璁″垝閲戦";
+                    jm.otherData = "鍙敤浣欓涓嶈冻";
                     return jm;
                 }
 
-                var keYongAmount = oldorderAmount - orderAmount;
+                //var keYongAmount = oldorderAmount - orderAmount;
+                //if (order.status == 1)
+                //{
+                //    keYongAmount = order.oldOrderAmount - order.orderAmount;
+                //}
 
-                if (status == 2)
-                {
-                    order.status = 2;
+                //if (status == 2)
+                //{
+                //    order.status = 2;
 
-                    if (keYongAmount != 0)
-                    {
-                        //淇敼鐢ㄦ埛浣欓
+                //    if (keYongAmount != 0)
+                //    {
+                //        //淇敼鐢ㄦ埛浣欓
 
-                        var jmsss = await _coreCmsUserServices.UpdateBalance(order.userId, keYongAmount, "鐢ㄦ埛璁″垝璁㈠崟"+ order.orderId + "娆鹃」缁撲綑");
-                    }
+                //        var jmsss = await _coreCmsUserServices.UpdateBalance(order.userId, keYongAmount, "鐢ㄦ埛璁″垝璁㈠崟"+ order.orderId + "娆鹃」缁撲綑");
+                //    }
                         
                     
                     
-                }
+                //}
 
 
                 //鏍¢獙鍚庡啀鍒涘缓璁㈠崟
@@ -337,6 +477,8 @@
                 if (user != null)
                 {
                     order.userId = user.id;
+                    user.isplanorder = "鏄�";
+                  var users = await _unitOfWork.GetDbClient().Updateable(user).ExecuteCommandAsync();
                 }
                 else
                 {
@@ -353,6 +495,8 @@
                     if (user != null)
                     {
                         order.userId = user.id;
+                        user.isplanorder = "鏄�";
+                        var users = await _unitOfWork.GetDbClient().Updateable(user).ExecuteCommandAsync();
                     }
                     else
                     {
@@ -428,6 +572,7 @@
                 order.orderAmount = orderAmount;
                 order.oldOrderAmount = orderAmount;
                 order.keYongAmount = 0;
+                order.huaFeiAmount = 0;
 
                 //鏍¢獙鍚庡啀鍒涘缓璁㈠崟
 
diff --git a/CoreCms.Net.Web.Admin/Controllers/Order/CoreCmsPlanOrderController.cs b/CoreCms.Net.Web.Admin/Controllers/Order/CoreCmsPlanOrderController.cs
index 31daf60..af80319 100644
--- a/CoreCms.Net.Web.Admin/Controllers/Order/CoreCmsPlanOrderController.cs
+++ b/CoreCms.Net.Web.Admin/Controllers/Order/CoreCmsPlanOrderController.cs
@@ -43,6 +43,7 @@
 using static SKIT.FlurlHttpClient.Wechat.Api.Models.CardCreateRequest.Types.MembershipCard.Types.Base.Types;
 using static SKIT.FlurlHttpClient.Wechat.Api.Models.CgibinExpressDeliveryOpenMessageGetDeliveryListResponse.Types;
 using System.Threading.Channels;
+using System.Collections.Generic;
 
 namespace CoreCms.Net.Web.Admin.Controllers
 {
@@ -64,6 +65,8 @@
         private readonly IHttpContextUser _user;
         private readonly ICoreCmsPlanOrderServices _planOrderServices;
         private readonly ICoreCmsAreaServices _areaServices;
+        private readonly ICoreCmsOrderServices _orderServices;
+        private readonly ICoreCmsOrderItemServices _orderItemServices;
 
 
         /// <summary>
@@ -76,6 +79,8 @@
             , IHttpContextUser user
             , ICoreCmsPlanOrderServices planOrderServices
             , ICoreCmsAreaServices areaServices
+              , ICoreCmsOrderServices orderServices
+         , ICoreCmsOrderItemServices orderItemServices
             )
         {
             _webHostEnvironment = webHostEnvironment;
@@ -85,6 +90,9 @@
             _user = user;
             _planOrderServices = planOrderServices;
             _areaServices = areaServices;
+            _orderServices = orderServices;
+            _orderItemServices = orderItemServices;
+
         }
 
         #region 鑾峰彇鍒楄〃============================================================
@@ -259,7 +267,7 @@
                 {
                     //鑾峰彇鐩稿叧鐘舵�佹弿杩拌鏄庤浆鎹�
                     order.statusText = EnumHelper.GetEnumDescriptionByValue<GlobalEnumVars.PlanOrderTiJiao>(order.status);
-
+                    order.keYongAmount = order.keYongAmount - order.huaFeiAmount;
                 }
             }
 
@@ -368,17 +376,27 @@
             }
             //鑾峰彇鐩稿叧鐘舵�佹弿杩拌鏄庤浆鎹�
             model.statusText = EnumHelper.GetEnumDescriptionByValue<GlobalEnumVars.PlanOrderTiJiao>(model.status);
-
+            model.keYongAmount = model.keYongAmount - model.huaFeiAmount;
 
             var modelItem1 = await _planOrderItemServices.QueryListByClauseAsync(p => p.orderId == entity.id && p.isOld == true, p => p.specification, OrderByType.Asc);
 
             var modelItem2 = await _planOrderItemServices.QueryListByClauseAsync(p => p.orderId == entity.id && 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;
+                }
+            }
+
             jm.data = new
             {
                 model,
-                modelItem1,
-                modelItem2
+                modelItem1
             };
             jm.code = 0;
            // jm.data = model;
@@ -471,7 +489,7 @@
                 jm.msg = GlobalConstVars.DataisNo;
 				return jm;
             }
-            jm = await _CoreCmsPlanOrderServices.DeleteByIdAsync(entity.id);
+            jm = await _CoreCmsPlanOrderServices.DeleteByIdAsync(entity.id , _user.Name);
 
             return jm;
         }
@@ -486,9 +504,9 @@
         /// <returns></returns>
         [HttpPost]
         [Description("鎵归噺鍒犻櫎")]
-        public async Task<AdminUiCallBack> DoBatchDelete([FromBody]FMArrayIntIds entity)
+        public async Task<AdminUiCallBack> DoBatchDelete([FromBody]FMArrayStringIds entity)
         {
-            var jm = await _CoreCmsPlanOrderServices.DeleteByIdsAsync(entity.id);
+            var jm = await _CoreCmsPlanOrderServices.DeleteByIdsAsync(entity.id, _user.Name);
             return jm;
         }
 
@@ -515,17 +533,46 @@
             }
             //鑾峰彇鐩稿叧鐘舵�佹弿杩拌鏄庤浆鎹�
             model.statusText = EnumHelper.GetEnumDescriptionByValue<GlobalEnumVars.PlanOrderTiJiao>(model.status);
+            model.keYongAmount = model.keYongAmount - model.huaFeiAmount;
 
 
             var modelItem1 = await _planOrderItemServices.QueryListByClauseAsync(p => p.orderId == entity.id && p.isOld == true, p => p.specification, OrderByType.Asc);
 
             var modelItem2 = await _planOrderItemServices.QueryListByClauseAsync(p => p.orderId == entity.id && 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 == model.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));
+
+            }
+
+           
+
+
             jm.data = new
             {
                 model,
-                modelItem1,
-                modelItem2
+                modelItem1 ,
+                coreCmsOrderItems
             };
             jm.code = 0;
             //jm.data = model;
diff --git a/CoreCms.Net.Web.Admin/wwwroot/views/corecmsplanorder/details.html b/CoreCms.Net.Web.Admin/wwwroot/views/corecmsplanorder/details.html
index 76a3cc6..8aaa265 100644
--- a/CoreCms.Net.Web.Admin/wwwroot/views/corecmsplanorder/details.html
+++ b/CoreCms.Net.Web.Admin/wwwroot/views/corecmsplanorder/details.html
@@ -7,16 +7,16 @@
         <tbody>
 
             <tr>
-                <td width="25%">
+                <td width="17%">
                     <label for="orderId">璁㈠崟鍙�</label>
                 </td>
-                <td width="25%">
+                <td width="34%" colspan="2">
                     {{ d.params.data.model.orderId || '' }}
                 </td>
-                <td width="25%">
+                <td width="17%">
                     <label for="shipAddress">瀛︽牎</label>
                 </td>
-                <td width="25%">
+                <td width="34%" colspan="2">
                     {{ d.params.data.model.shipAddress || '' }}
                 </td>
             </tr>
@@ -27,13 +27,13 @@
                 <td>
                     <label for="shi">甯�</label>
                 </td>
-                <td>
+                <td colspan="2">
                     {{ d.params.data.model.shi || '' }}
                 </td>
                 <td>
                     <label for="quxian">鍖哄幙</label>
                 </td>
-                <td>
+                <td colspan="2">
                     {{ d.params.data.model.quxian || '' }}
                 </td>
             </tr>
@@ -43,13 +43,13 @@
                 <td>
                     <label for="pianqu">鐗囧尯</label>
                 </td>
-                <td>
+                <td colspan="2">
                     {{ d.params.data.model.pianqu || '' }}
                 </td>
                 <td>
                     <label for="quxian">鏀惰揣鍦板潃</label>
                 </td>
-                <td>
+                <td colspan="2">
                     {{ d.params.data.model.shouhuoAddress || '' }}
                 </td>
             </tr>
@@ -58,13 +58,13 @@
                 <td>
                     <label for="shipName">鑱旂郴浜�</label>
                 </td>
-                <td>
+                <td colspan="2">
                     {{ d.params.data.model.shipName || '' }}
                 </td>
                 <td>
                     <label for="shipMobile">鑱旂郴鐢佃瘽</label>
                 </td>
-                <td>
+                <td colspan="2">
                     {{ d.params.data.model.shipMobile || '' }}
                 </td>
             </tr>
@@ -73,13 +73,13 @@
                 <td>
                     <label for="oldOrderAmount">璁″垝閲戦</label>
                 </td>
-                <td>
+                <td colspan="2">
                     {{ d.params.data.model.oldOrderAmount || '' }}
                 </td>
                 <td>
                     <label for="orderAmount">璋冩暣閲戦</label>
                 </td>
-                <td>
+                <td style="color:red;" colspan="2">
                     {{ d.params.data.model.orderAmount || '' }}
                 </td>
             </tr>
@@ -89,13 +89,13 @@
                 <td>
                     <label for="keYongAmount">鍙敤浣欓</label>
                 </td>
-                <td>
-                    {{ d.params.data.model.keYongAmount || '' }}
+                <td style="color:red;" colspan="2">
+                    {{ d.params.data.model.keYongAmount}}
                 </td>
                 <td>
                     <label for="status">璁㈠崟鐘舵��</label>
                 </td>
-                <td>
+                <td colspan="2">
                     {{ d.params.data.model.statusText || '' }}
                 </td>
             </tr>
@@ -104,23 +104,23 @@
                 <td>
                     <label for="createTime">寤虹珛鏃堕棿</label>
                 </td>
-                <td>
+                <td colspan="2">
                     {{ d.params.data.model.createTime || '' }}
                 </td>
                 <td>
                     <label for="upDataTime">淇敼鏃堕棿</label>
                 </td>
-                <td>
+                <td colspan="2">
                     {{ d.params.data.model.upDataTime || '' }}
                 </td>
             </tr>
 
-            <tr>
-                <td style="background-color:lightsteelblue;" colspan="4">
-                    鍘熻鍗�
-                </td>
+            <!--<tr>
+        <td style="background-color:lightsteelblue;" colspan="4">
+            鍘熻鍗�
+        </td>
 
-            </tr>
+    </tr>-->
             <tr>
                 <td style="background-color:lightsteelblue;">
                     鍟嗗搧鍚嶇О
@@ -129,10 +129,16 @@
                     鍗曚环锛堝厓锛�
                 </td>
                 <td style="background-color:lightsteelblue;">
-                    鏁伴噺
+                    璁″垝鏁伴噺
                 </td>
                 <td style="background-color:lightsteelblue;">
-                    鎬讳环锛堝厓锛�
+                    璁″垝閲戦锛堝厓锛�
+                </td>
+                <td style="background-color:lightsteelblue;">
+                    璋冩暣鏁伴噺
+                </td>
+                <td style="background-color:lightsteelblue;">
+                    璋冩暣閲戦锛堝厓锛�
                 </td>
             </tr>
 
@@ -150,14 +156,17 @@
                 <td>
                     {{ item.amount }}
                 </td>
+                <td>
+                    {{ item.numsnew }}
+                </td>
+                <td>
+                    {{ item.amountnew }}
+                </td>
             </tr>
             {{# }); }}
-
-
-
             <tr>
-                <td style="background-color:lightsteelblue;" colspan="4">
-                    淇敼璁㈠崟
+                <td style="background-color:lightsteelblue;" colspan="6">
+                    鏅�氬晢鍝�
                 </td>
 
             </tr>
@@ -172,14 +181,18 @@
                     鏁伴噺
                 </td>
                 <td style="background-color:lightsteelblue;">
-                    鎬讳环锛堝厓锛�
+                    閲戦锛堝厓锛�
+                </td>
+                <td style="background-color:lightsteelblue;">
+                </td>
+                <td style="background-color:lightsteelblue;">
                 </td>
             </tr>
 
-            {{# layui.each(d.params.data.modelItem2, function(index, item){ }}
+            {{# layui.each(d.params.data.coreCmsOrderItems, function(index, item){ }}
             <tr>
                 <td>
-                    {{ item.name }}   {{ item.specification }}
+                    {{ item.name }}  {{ item.addon }}
                 </td>
                 <td>
                     {{ item.price }}
@@ -190,9 +203,53 @@
                 <td>
                     {{ item.amount }}
                 </td>
+                <td>
+                   
+                </td>
+                <td>
+                    
+                </td>
             </tr>
             {{# }); }}
 
+            <!--<tr>
+         <td style="background-color:lightsteelblue;" colspan="4">
+             淇敼璁㈠崟
+         </td>
+
+     </tr>
+    <tr>
+         <td style="background-color:lightsteelblue;">
+             鍟嗗搧鍚嶇О
+         </td>
+         <td style="background-color:lightsteelblue;">
+             鍗曚环锛堝厓锛�
+         </td>
+         <td style="background-color:lightsteelblue;">
+             鏁伴噺
+         </td>
+         <td style="background-color:lightsteelblue;">
+             鎬讳环锛堝厓锛�
+         </td>
+     </tr>
+
+     {{# layui.each(d.params.data.modelItem2, function(index, item){ }}
+     <tr>
+         <td>
+             {{ item.name }}   {{ item.specification }}
+         </td>
+         <td>
+             {{ item.price }}
+         </td>
+         <td>
+             {{ item.nums }}
+         </td>
+         <td>
+             {{ item.amount }}
+         </td>
+     </tr>
+     {{# }); }}-->
+
         </tbody>
     </table>
 </script>
diff --git a/CoreCms.Net.Web.Admin/wwwroot/views/corecmsplanorder/edit.html b/CoreCms.Net.Web.Admin/wwwroot/views/corecmsplanorder/edit.html
index e26c624..b76dc4c 100644
--- a/CoreCms.Net.Web.Admin/wwwroot/views/corecmsplanorder/edit.html
+++ b/CoreCms.Net.Web.Admin/wwwroot/views/corecmsplanorder/edit.html
@@ -9,16 +9,16 @@
             <tbody>
 
                 <tr>
-                    <td width="25%">
+                    <td width="17%">
                         <label for="orderId">璁㈠崟鍙�</label>
                     </td>
-                    <td width="25%">
+                    <td width="34%" colspan="2">
                         {{ d.params.data.model.orderId || '' }}
                     </td>
-                    <td width="25%">
+                    <td width="17%">
                         <label for="shipAddress">瀛︽牎</label>
                     </td>
-                    <td width="25%">
+                    <td width="34%" colspan="2">
                         {{ d.params.data.model.shipAddress || '' }}
                     </td>
                 </tr>
@@ -29,13 +29,13 @@
                     <td>
                         <label for="shi">甯�</label>
                     </td>
-                    <td>
+                    <td  colspan="2">
                         {{ d.params.data.model.shi || '' }}
                     </td>
                     <td>
                         <label for="quxian">鍖哄幙</label>
                     </td>
-                    <td>
+                    <td  colspan="2">
                         {{ d.params.data.model.quxian || '' }}
                     </td>
                 </tr>
@@ -45,13 +45,13 @@
                     <td>
                         <label for="pianqu">鐗囧尯</label>
                     </td>
-                    <td>
+                    <td  colspan="2">
                         {{ d.params.data.model.pianqu || '' }}
                     </td>
                     <td>
                         <label for="quxian">鏀惰揣鍦板潃</label>
                     </td>
-                    <td>
+                    <td  colspan="2">
                         {{ d.params.data.model.shouhuoAddress || '' }}
                     </td>
                 </tr>
@@ -60,13 +60,13 @@
                     <td>
                         <label for="shipName">鑱旂郴浜�</label>
                     </td>
-                    <td>
+                    <td  colspan="2">
                         {{ d.params.data.model.shipName || '' }}
                     </td>
                     <td>
                         <label for="shipMobile">鑱旂郴鐢佃瘽</label>
                     </td>
-                    <td>
+                    <td  colspan="2">
                         {{ d.params.data.model.shipMobile || '' }}
                     </td>
                 </tr>
@@ -75,14 +75,14 @@
                     <td>
                         <label for="oldOrderAmount">璁″垝閲戦</label>
                     </td>
-                    <td >
+                    <td  colspan="2">
                         <input id="oldOrderAmount" name="oldOrderAmount" type="number" class="layui-input" value="{{ d.params.data.model.oldOrderAmount || '' }}" readonly="readonly" />   
                     </td>
                     <td>
                         <label for="orderAmount">璋冩暣閲戦</label>
                     </td>
-                    <td>
-                        <input  id="orderAmount" name="orderAmount" type="number" class="layui-input" value="{{ d.params.data.model.orderAmount || '' }}" readonly="readonly" />    
+                    <td  colspan="2">
+                        <input  id="orderAmount" style="color:red;" name="orderAmount" type="number" class="layui-input" value="{{ d.params.data.model.orderAmount || '' }}" readonly="readonly" />    
                     </td>
                 </tr>
 
@@ -91,13 +91,14 @@
                     <td >
                         <label for="keYongAmount">鍙敤浣欓</label>
                     </td>
-                    <td>
-                        <input id="keYongAmount" name="keYongAmount" type="number" class="layui-input" value="{{ d.params.data.model.keYongAmount || '' }}" readonly="readonly" />
+                    <td colspan="2">
+                        <input type="hidden" name="huaFeiAmount" id="huaFeiAmount" value="{{d.params.data.model.huaFeiAmount }}">
+                        <input id="keYongAmount" style="color:red;" name="keYongAmount" type="number" class="layui-input" value="{{ d.params.data.model.keYongAmount }}" readonly="readonly" />
                     </td>
                     <td>
                         <label for="status">璁㈠崟鐘舵��</label>
                     </td>
-                    <td>
+                    <td  colspan="2">
                         {{ d.params.data.model.statusText || '' }}
                     </td>
                 </tr>
@@ -106,23 +107,23 @@
                     <td>
                         <label for="createTime">寤虹珛鏃堕棿</label>
                     </td>
-                    <td>
+                    <td  colspan="2">
                         {{ d.params.data.model.createTime || '' }}
                     </td>
                     <td>
                         <label for="upDataTime">淇敼鏃堕棿</label>
                     </td>
-                    <td>
+                    <td  colspan="2">
                         {{ d.params.data.model.upDataTime || '' }}
                     </td>
                 </tr>
 
-                <tr>
+                <!--<tr>
                     <td style="background-color:lightsteelblue;" colspan="4">
                         鍘熻鍗�
                     </td>
 
-                </tr>
+                </tr>-->
                 <tr>
                     <td style="background-color:lightsteelblue;">
                         鍟嗗搧鍚嶇О
@@ -131,33 +132,49 @@
                         鍗曚环锛堝厓锛�
                     </td>
                     <td style="background-color:lightsteelblue;">
-                        鏁伴噺
+                        璁″垝鏁伴噺
                     </td>
                     <td style="background-color:lightsteelblue;">
-                        鎬讳环锛堝厓锛�
+                        璁″垝閲戦锛堝厓锛�
+                    </td>
+                    <td style="background-color:lightsteelblue;">
+                        璋冩暣鏁伴噺
+                    </td>
+                    <td style="background-color:lightsteelblue;">
+                        璋冩暣閲戦锛堝厓锛�
                     </td>
                 </tr>
 
                 {{# layui.each(d.params.data.modelItem1, function(index, item){ }}
-                <tr>
-                    <td>
-                        {{ item.name }}   {{ item.specification }}
-                    </td>
-                    <td>
-                        {{ item.price }}
-                    </td>
-                    <td>
-                        {{ item.nums }}
-                    </td>
-                    <td>
-                        {{ item.amount }}
-                    </td>
-                </tr>
+            <tr>
+                <td>
+                    <input type="hidden" name="itemIdarray" value="{{item.idnew || '' }}">
+                    {{ item.name }}   {{ item.specification }}
+                </td>
+                <td>
+                    {{ item.price }}
+                    <input type="hidden" name="price" value="{{item.price || '' }}">
+                </td>
+                <td>
+                    {{ item.nums }}
+                </td>
+                <td>
+                    {{ item.amount }}
+                </td>
+                <td>
+                    <input name="itemNumarray" lay-verType="tips" type="number" min="0" max="99999999" lay-verify="required|number" class="layui-input" placeholder="璇疯緭鍏ユ暟閲�" lay-reqText="璇疯緭鍏ユ暟閲�" value="{{ item.numsnew }}" onchange="changenum('{{ index }}')" />
+                </td>
+                <td>
+
+
+                    <input name="amount" type="number" class="layui-input" value="{{ item.amountnew }}" readonly="readonly" />
+                </td>
+            </tr>
                 {{# }); }}
 
 
 
-                <tr>
+                <!--<tr>
                     <td style="background-color:lightsteelblue;" colspan="4">
                         淇敼璁㈠崟
                     </td>
@@ -176,6 +193,7 @@
                     <td style="background-color:lightsteelblue;">
                         鎬讳环锛堝厓锛�
                     </td>
+
                 </tr>
 
                 {{# layui.each(d.params.data.modelItem2, function(index, item){ }}
@@ -197,7 +215,7 @@
                         <input name="amount"  type="number" class="layui-input" value="{{ item.amount }}" readonly="readonly"  />
                     </td>
                 </tr>
-                {{# }); }}
+                {{# }); }}-->
 
             </tbody>
         </table>
@@ -313,7 +331,7 @@
         var itemNumarray = $("input[name='itemNumarray']:eq(" + index + ")").val();
         var price = $("input[name='price']:eq(" + index + ")").val();
        
-
+        
       
         $("input[name='amount']:eq(" + index + ")").val((itemNumarray * price).toFixed(2));
 
@@ -327,16 +345,19 @@
            
         }
 
+        var huaFeiAmount = $('#huaFeiAmount').val();
+
+
         $('#orderAmount').val(zongjia);
        
 
       
-        var yue = (parseFloat($('#oldOrderAmount').val()) - zongjia).toFixed(2);
+        var yue = (parseFloat($('#oldOrderAmount').val()) - zongjia - parseFloat($('#huaFeiAmount').val())).toFixed(2);
         $('#keYongAmount').val(yue);
 
 
         if (yue < 0) {
-            layer.msg("璁㈠崟閲戦瓒呭嚭璁″垝閲戦");
+            layer.msg("鍙敤浣欓涓嶈冻");
         }
        
     }
diff --git a/CoreCms.Net.Web.Admin/wwwroot/views/corecmsplanorder/index.html b/CoreCms.Net.Web.Admin/wwwroot/views/corecmsplanorder/index.html
index 1646ddf..8a99b17 100644
--- a/CoreCms.Net.Web.Admin/wwwroot/views/corecmsplanorder/index.html
+++ b/CoreCms.Net.Web.Admin/wwwroot/views/corecmsplanorder/index.html
@@ -40,8 +40,8 @@
                 <div class="layui-input-inline">
                     <select name="status">
                         <option value="">璇烽�夋嫨</option>
-                        <option value="1">鏈彁浜�</option>
-                        <option value="2">宸叉彁浜�</option>
+                        <option value="1">鏈攣鍗�</option>
+                        <option value="2">宸查攣鍗�</option>
                     </select>
                 </div>
             </div>
@@ -144,27 +144,34 @@
             </select>
         </div>
     </div>-->
-            <div class="layui-inline">
+            <div class="layui-inline" >
                 <button class="layui-btn layui-btn-sm" lay-submit lay-filter="LAY-app-CoreCmsPlanOrder-search"><i class="layui-icon layui-icon-search"></i>绛涢��</button>
+                <button class="layui-btn layui-btn-sm" lay-submit lay-filter="LAY-app-doBatchDelete"><i class="layui-icon layui-icon-add-circle"></i>鎵归噺閿佸崟</button>
+                <button type="button" class="layui-btn layui-btn-sm" id="upIndexPopupWindowImageUrlBtn">涓婁紶璁″垝璁㈠崟</button>
+                <button class="layui-btn layui-btn-sm" lay-submit lay-filter="LAY-app-selectExportExcel"><i class="layui-icon layui-icon-add-circle"></i>閫夋嫨瀵煎嚭</button>
+                <button class="layui-btn layui-btn-sm" lay-submit lay-filter="LAY-app-queryExportExcel"><i class="layui-icon layui-icon-download-circle"></i>鏌ヨ瀵煎嚭</button>
+                <a class="layui-btn layui-btn-sm" href="/static/jihuageshi/涓婁紶璁″垝璁㈠崟.xlsx">涓婁紶妯℃澘</a>
             </div>
         </div>
     </div>
 </script>
 
 <script type="text/html" id="LAY-app-CoreCmsPlanOrder-pagebar">
+   
     <div class="layui-btn-container">
         <!--<button class="layui-btn layui-btn-sm" lay-event="addData"><i class="layui-icon layui-icon-add-1"></i>娣诲姞鏁版嵁</button>
-    <button class="layui-btn layui-btn-sm" lay-event="batchDelete"><i class="layui-icon layui-icon-delete"></i>鎵归噺鍒犻櫎</button>-->
-        <button type="button" class="layui-btn layui-btn-sm" id="upIndexPopupWindowImageUrlBtn">涓婁紶璁″垝璁㈠崟</button>
+        <button class="layui-btn layui-btn-sm" lay-event="batchDelete"><i class="layui-icon layui-icon-delete"></i>鎵归噺鍒犻櫎</button>-->
+        <!--<button type="button" class="layui-btn layui-btn-sm" id="upIndexPopupWindowImageUrlBtn">涓婁紶璁″垝璁㈠崟</button>
         <button class="layui-btn layui-btn-sm" lay-event="selectExportExcel"><i class="layui-icon layui-icon-add-circle"></i>閫夋嫨瀵煎嚭</button>
         <button class="layui-btn layui-btn-sm" lay-event="queryExportExcel"><i class="layui-icon layui-icon-download-circle"></i>鏌ヨ瀵煎嚭</button>
-        <a class="layui-btn layui-btn-sm" href="/static/jihuageshi/涓婁紶璁″垝璁㈠崟.xlsx"  >涓婁紶妯℃澘</a>
+        <a class="layui-btn layui-btn-sm" href="/static/jihuageshi/涓婁紶璁″垝璁㈠崟.xlsx"  >涓婁紶妯℃澘</a>-->
     </div>
 </script>
 
 <script type="text/html" id="LAY-app-CoreCmsPlanOrder-tableBox-bar">
     <a class="layui-btn layui-btn-primary layui-btn-xs" lay-event="detail">鏌ョ湅</a>
-    <a class="layui-btn layui-btn-xs" lay-event="edit">缂栬緫</a>
+    <a class="layui-btn layui-btn-xs" lay-event="edit">淇敼</a>
+    <a class="layui-btn layui-btn-xs" lay-event="del">閿佸崟</a>
     <!--<a class="layui-btn layui-btn-danger layui-btn-xs" data-dropdown="#CoreCmsPlanOrderTbDelDrop{{d.LAY_INDEX}}" no-shade="true">鍒犻櫎</a>-->
     <div class="dropdown-menu-nav dropdown-popconfirm dropdown-top-right layui-hide" id="CoreCmsPlanOrderTbDelDrop{{d.LAY_INDEX}}"
          style="max-width: 200px;white-space: normal;min-width: auto;margin-left: 10px;">
@@ -210,6 +217,26 @@
                         searchwhere = field;
                         //鎵ц閲嶈浇
                         table.reloadData('LAY-app-CoreCmsPlanOrder-tableBox',{ where: field });
+                    });
+
+                //鐩戝惉鎼滅储
+                form.on('submit(LAY-app-selectExportExcel)',
+                    function (data) {
+                        var checkStatus = table.checkStatus("LAY-app-CoreCmsPlanOrder-tableBox");
+                        doSelectExportExcel(checkStatus);
+                    });
+                //鐩戝惉鎼滅储
+                form.on('submit(LAY-app-doBatchDelete)',
+                    function (data) {
+                        var checkStatus = table.checkStatus("LAY-app-CoreCmsPlanOrder-tableBox");
+                        doBatchDelete(checkStatus);
+                    });
+                
+
+                //鐩戝惉鎼滅储
+                form.on('submit(LAY-app-queryExportExcel)',
+                    function (data) {
+                        doQueryExportexcel();
                     });
                 // 鐩戝惉鎻愪氦浜嬩欢
                 form.on('select(cityFilter)', function (data) {
@@ -260,24 +287,24 @@
                     cols: [
                         [
                             { type: "checkbox", fixed: "left" },
-						    { field: 'orderId', title: '璁㈠崟鍙�', sort: false,width: 115 },
+						    { field: 'orderId', title: '璁㈠崟鍙�', sort: false,width: 135 },
                             { field: 'shi', title: '甯�', sort: false, width: 50 },
                             { field: 'quxian', title: '鍖哄幙', sort: false, width: 50 },
                             { field: 'pianqu', title: '鐗囧尯', sort: false, width: 115 }, 
 						 /*   { field: 'userId', title: '鐢ㄦ埛ID 鍏宠仈user.id', sort: false,width: 105 },*/
-                            { field: 'shipAddress', title: '瀛︽牎', sort: false, width: 115 },
-						    { field: 'shipName', title: '鑱旂郴浜�', sort: false,width: 115 },
+                            { field: 'shipAddress', title: '瀛︽牎', sort: false, width: 135 },
+						    { field: 'shipName', title: '鑱旂郴浜�', sort: false,width: 55 },
                             { field: 'shipMobile', title: '鑱旂郴鐢佃瘽', sort: false, width: 115 },
-                            { field: 'shouhuoAddress', title: '鏀惰揣鍦板潃', sort: false, width: 115 },
-                            { field: 'oldOrderAmount', title: '璁″垝閲戦', sort: false, width: 115 },
-                            { field: 'orderAmount', title: '璋冩暣閲戦', sort: false, width: 115 },
-						    { field: 'keYongAmount', title: '鍙敤浣欓', sort: false,width: 115 },
-						    { field: 'createTime', title: '寤虹珛鏃堕棿', width: 140, sort: false},
-						    { field: 'upDataTime', title: '淇敼鏃堕棿', width: 140, sort: false},
+                            { field: 'shouhuoAddress', title: '鏀惰揣鍦板潃', sort: false, width: 265 },
+                            { field: 'oldOrderAmount', title: '璁″垝閲戦', sort: false, width: 75 },
+                            { field: 'orderAmount', title: '璋冩暣閲戦', sort: false, width: 75 },
+                            { field: 'keYongAmount', title: '鍙敤浣欓', sort: false, width: 75 },
+                            { field: 'createTime', title: '寤虹珛鏃堕棿', width: 95, sort: false},
+                            { field: 'upDataTime', title: '淇敼鏃堕棿', width: 95, sort: false},
 						    //{ field: 'createBy', title: '鍒涘缓浜�', sort: false,width: 105 },
 						    //{ field: 'upDataBy', title: '淇敼浜�', sort: false,width: 105 },
                             //{ field: 'isdelete', title: '鍒犻櫎鏍囧織', width: 95, templet: '#switch_isdelete', sort: false , unresize: true},
-                            { field: 'statusText', title: '璁㈠崟鐘舵��', sort: false, width: 115 },
+                            { field: 'statusText', title: '璁㈠崟鐘舵��', sort: false, width: 65 },
                             { width: 172, align: 'center', title:'鎿嶄綔', fixed: 'right', toolbar: '#LAY-app-CoreCmsPlanOrder-tableBox-bar' }
                         ]
                     ]
@@ -455,25 +482,29 @@
                     });
                 }
                 //鎵ц鍗曚釜鍒犻櫎
-                function doDelete(obj){
-                    coreHelper.Post("Api/CoreCmsPlanOrder/DoDelete", { id: obj.data.id }, function (e) {
-                            if (debug) { console.log(e); } //寮�鍚皟璇曡繑鍥炴暟鎹�
-                            table.reloadData('LAY-app-CoreCmsPlanOrder-tableBox');
-                            layer.msg(e.msg);
-                        });
+                function doDelete(obj) {
+                    layer.confirm('纭畾閿佸崟鍚楋紵鍒犻櫎鍚庡皢鏃犳硶淇敼銆�',
+                        function (index) {
+                            coreHelper.Post("Api/CoreCmsPlanOrder/DoDelete", { id: obj.data.orderId }, function (e) {
+                                if (debug) { console.log(e); } //寮�鍚皟璇曡繑鍥炴暟鎹�
+                                table.reloadData('LAY-app-CoreCmsPlanOrder-tableBox');
+                                layer.msg(e.msg);
+                            });
+});
+                
 			    }
                 //鎵ц鎵归噺鍒犻櫎
                 function doBatchDelete(checkStatus){
                     var checkData = checkStatus.data;
                     if (checkData.length === 0) {
-                        return layer.msg('璇烽�夋嫨瑕佸垹闄ょ殑鏁版嵁');
+                        return layer.msg('璇烽�夋嫨瑕侀攣鍗曠殑鏁版嵁');
                     }
-                    layer.confirm('纭畾鍒犻櫎鍚楋紵鍒犻櫎鍚庡皢鏃犳硶鎭㈠銆�',
+                    layer.confirm('纭畾閿佸崟鍚楋紵閿佸崟鍚庡皢鏃犳硶淇敼銆�',
                         function(index) {
                             var delidsStr = [];
                             layui.each(checkData,
                                 function(index, item) {
-                                    delidsStr.push(item.id);
+                                    delidsStr.push(item.orderId);
                                 });
                             coreHelper.Post("Api/CoreCmsPlanOrder/DoBatchDelete", { id: delidsStr }, function (e) {
                                     if (debug) { console.log(e); } //寮�鍚皟璇曡繑鍥炴暟鎹�
@@ -508,11 +539,11 @@
                             var delidsStr = [];
                             layui.each(checkData,
                                 function(index, item) {
-                                    delidsStr.push(item.id);
+                                    delidsStr.push(item.orderId);
                                 });
                             layer.close(index);
                             coreHelper.Post("Api/CoreCmsPlanOrder/SelectExportExcel", { id: delidsStr }, function (e) {
-                                    if (debug) { console.log(e); } //寮�鍚皟璇曡繑鍥炴暟鎹�
+                                if (debug) { console.log(e); } //寮�鍚皟璇曡繑鍥炴暟鎹�
                                     if (e.code === 0) {
                                         window.open(e.data);
                                     } else {
diff --git a/CoreCms.Net.Web.WebApi/Controllers/OrderController.cs b/CoreCms.Net.Web.WebApi/Controllers/OrderController.cs
index 2d20428..ef08f50 100644
--- a/CoreCms.Net.Web.WebApi/Controllers/OrderController.cs
+++ b/CoreCms.Net.Web.WebApi/Controllers/OrderController.cs
@@ -10,6 +10,7 @@
 
 
 using System;
+using System.Collections.Generic;
 using System.Linq;
 using System.Threading.Tasks;
 using CoreCms.Net.Auth.HttpContextUser;
@@ -54,6 +55,7 @@
         private readonly ICoreCmsInvoiceServices _invoiceServices;
         private readonly ICoreCmsPlanOrderServices _planOrderServices;
         private readonly ICoreCmsPlanOrderItemServices _planOrderItemServices;
+        private readonly ICoreCmsOrderItemServices _orderItemServices;
 
         /// <summary>
         /// 鏋勯�犲嚱鏁�
@@ -65,7 +67,8 @@
         , ICoreCmsAreaServices areaServices
         , ICoreCmsBillReshipServices reshipServices, ICoreCmsShipServices shipServices, ICoreCmsLogisticsServices logisticsServices, ICoreCmsOrderDistributionModelServices orderDistributionModelServices, IRedisOperationRepository redisOperationRepository, ICoreCmsUserServices userServices, ICoreCmsClerkServices clerkServices, ICoreCmsInvoiceServices invoiceServices
           , ICoreCmsPlanOrderServices planOrderServices
-            , ICoreCmsPlanOrderItemServices planOrderItemServices)
+            , ICoreCmsPlanOrderItemServices planOrderItemServices
+               , ICoreCmsOrderItemServices orderItemServices)
         {
             _user = user;
             _orderServices = orderServices;
@@ -82,6 +85,7 @@
             _invoiceServices = invoiceServices;
             _planOrderServices = planOrderServices;
             _planOrderItemServices = planOrderItemServices;
+            _orderItemServices = orderItemServices;
         }
 
 
@@ -229,7 +233,7 @@
                         entity.ushipId, entity.storeId, entity.ladingName, entity.ladingMobile, entity.memo,
                         entity.point, entity.couponCode, entity.source, entity.scene, entity.taxType, entity.taxName,
                         entity.taxCode, entity.objectId, entity.teamId, entity.requireOrder, entity.requiredFundType,
-                        entity.traceId);
+                        entity.traceId, entity.planorderId);
                 }
                 catch (Exception e)
                 {
@@ -387,7 +391,7 @@
         [Authorize]
         public async Task<WebApiCallBack> GetPlanOrderList([FromBody] GetOrderListPost entity)
         {
-            var jm = await _planOrderServices.GetOrderList(entity.status, _user.ID, entity.page, entity.limit);
+            var jm = await _planOrderServices.GetOrderList(entity.status, _user.ID, entity.page, entity.limit, entity.money);
             return jm;
         }
 
@@ -409,6 +413,7 @@
             var jm = new WebApiCallBack();
 
             var model = await _planOrderServices.QueryByIdAsync(entity.id);
+            
             if (model == null)
             {
                 jm.msg = "涓嶅瓨鍦ㄦ淇℃伅";
@@ -417,7 +422,34 @@
 
             //鑾峰彇鐩稿叧鐘舵�佹弿杩拌鏄庤浆鎹�
             model.statusText = EnumHelper.GetEnumDescriptionByValue<GlobalEnumVars.PlanOrderTiJiao>(model.status);
+            model.keYongAmount = model.keYongAmount - model.huaFeiAmount;
             var modelItem = await _planOrderItemServices.QueryListByClauseAsync(p => p.orderId == entity.id && p.isOld == false, p => p.specification, OrderByType.Asc);
+
+            var modelItem2 = await _planOrderItemServices.QueryListByClauseAsync(p => p.orderId == entity.id && p.isOld == true, p => p.specification, OrderByType.Asc);
+
+            foreach (var coreCmsPlanOrderItem in modelItem)
+            {
+                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 == model.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));
+
+            }
 
             jm.code = 0;
             jm.status = true;
@@ -425,6 +457,7 @@
             {
                 model,
                 modelItem,
+                coreCmsOrderItems
             };
 
             return jm;
diff --git a/CoreCms.Net.Web.WebApi/Controllers/UserController.cs b/CoreCms.Net.Web.WebApi/Controllers/UserController.cs
index 6d41ea4..c1195ab 100644
--- a/CoreCms.Net.Web.WebApi/Controllers/UserController.cs
+++ b/CoreCms.Net.Web.WebApi/Controllers/UserController.cs
@@ -1009,7 +1009,8 @@
                 userCouponCount,
                 orderCount,
                 footPrintCount,
-                collectionCount
+                collectionCount,
+                user.isplanorder
             };
             return jm;
         }

--
Gitblit v1.9.1