/// <summary> /// 订单审批 /// </summary> /// <param name="pParams"></param> public void OrdersApprove(Dictionary <string, string> pParams) { TInoutEntity orderEntity = new TInoutEntity(); TInoutStatusEntity statusEntity = new TInoutStatusEntity(); TInoutDetailEntity[] orderDetailEntity = null; #region 拼接查询SQL StringBuilder strSearchSql = new StringBuilder(); strSearchSql.AppendFormat(@" select inout.order_id OrdersID ,inout.order_no OrdersNo ,ISNULL(store.UsedAmount,0) UsedAmount ,ISNULL(store.StockAmount,0) StockAmount ,store.* from T_Inout inout inner join T_Inout_Detail inout_detail on inout.order_id=inout_detail.order_id inner join StoreItemDailyStatus store on inout_detail.sku_id=store.SkuID where inout.customer_id='{0}' and inout.order_id='{1}' and store.StatusDate between cast(inout_detail.Field1 as datetime) and convert(char(10),dateadd(dd,-1,inout_detail.Field2),120) order by store.StatusDate", CurrentUserInfo.ClientID, pParams["pOrdersID"]); #endregion DataSet dsSource = this.SQLHelper.ExecuteDataset(strSearchSql.ToString()); StoreItemDailyStatusEntity[] storeEntity = ConvertHelper <StoreItemDailyStatusEntity> .ConvertToList(dsSource.Tables[0]).ToArray(); SqlTransaction tran = this.SQLHelper.CreateTransaction(); using (tran.Connection) { try { //更新订单主表信息 if (pParams.ContainsKey("pOrdersID")) { orderDetailEntity = new TInoutDetailDAO(CurrentUserInfo).QueryByEntity(new TInoutDetailEntity { order_id = pParams["pOrdersID"] }, null); orderEntity = GetByID(pParams["pOrdersID"]); orderEntity.Status = pParams["pOrdersStatus"]; orderEntity.StatusDesc = pParams["pOrdersDesc"]; orderEntity.Field7 = orderEntity.Status; orderEntity.Field10 = orderEntity.StatusDesc; if (pParams["pRemark"] != null && pParams["pRemark"] != "") { orderEntity.Remark = pParams["pRemark"]; } orderEntity.ModifyTime = DateTime.Now.ToString(); orderEntity.ModifyUserID = CurrentUserInfo.UserID; if (orderEntity.Status == "500" || orderEntity.Status == "400") { T_InoutEntity[] entity = new T_InoutDAO(CurrentUserInfo).QueryByEntity(new T_InoutEntity { order_id = pParams["pOrdersID"] }, null); new VipDAO(this.CurrentUserInfo).ProcSetCancelOrder(this.CurrentUserInfo.ClientID, pParams["pOrdersID"], entity[0].vip_no); } Update(orderEntity); } //更新房态 库存数量 if (storeEntity != null && storeEntity.Length > 0) { for (int i = 0; i < storeEntity.Length; i++) { if (pParams["pOrdersType"].ToString() == "1") { //1.审核通过 if (storeEntity[i].StockAmount != 0 && storeEntity[i].StockAmount > 0) { storeEntity[i].StockAmount = storeEntity[i].StockAmount - (int)Math.Round((decimal)orderDetailEntity[0].OrderQty, 0); } if (storeEntity[i].UsedAmount != 100 && storeEntity[i].UsedAmount < 100) { storeEntity[i].UsedAmount = storeEntity[i].UsedAmount + (int)Math.Round((decimal)orderDetailEntity[0].OrderQty, 0); } storeEntity[i].LastUpdateBy = CurrentUserInfo.UserID; storeEntity[i].LastUpdateTime = DateTime.Now; } else { //2.审核不通过 if (storeEntity[i].StockAmount != 100 && storeEntity[i].StockAmount < 100) { storeEntity[i].StockAmount += (int)Math.Round((decimal)orderDetailEntity[0].OrderQty, 0); } if (storeEntity[i].UsedAmount != 0 && storeEntity[i].UsedAmount > 0) { storeEntity[i].UsedAmount -= (int)Math.Round((decimal)orderDetailEntity[0].OrderQty, 0); } storeEntity[i].LastUpdateBy = CurrentUserInfo.UserID; storeEntity[i].LastUpdateTime = DateTime.Now; } new StoreItemDailyStatusDAO(CurrentUserInfo).Update(storeEntity[i]); } } //添加订单操作流水 statusEntity.OrderID = pParams["pOrdersID"]; statusEntity.OrderStatus = int.Parse(pParams["pOrdersStatus"]); if (pParams["pCheckResult"] != null && pParams["pCheckResult"] != "") { statusEntity.CheckResult = int.Parse(pParams["pCheckResult"]); } statusEntity.CustomerID = CurrentUserInfo.ClientID; statusEntity.CreateBy = CurrentUserInfo.UserID; new TInoutStatusDAO(CurrentUserInfo).Create(statusEntity); tran.Commit(); } catch (Exception ex) { Loggers.Exception(new ExceptionLogInfo() { ClientID = CurrentUserInfo.ClientID, UserID = CurrentUserInfo.UserID, ErrorMessage = ex.Message }); tran.Rollback(); } } }
/// <summary> /// 装载实体 /// </summary> /// <param name="pReader">向前只读器</param> /// <param name="pInstance">实体实例</param> protected void Load(IDataReader pReader, out T_RefundOrderEntity pInstance) { //将所有的数据从SqlDataReader中读取到Entity中 pInstance = new T_RefundOrderEntity(); pInstance.PersistenceHandle = new PersistenceHandle(); pInstance.PersistenceHandle.Load(); if (pReader["RefundID"] != DBNull.Value) { pInstance.RefundID = (Guid)pReader["RefundID"]; } if (pReader["SalesReturnID"] != DBNull.Value) { pInstance.SalesReturnID = (Guid)pReader["SalesReturnID"]; } if (pReader["RefundNo"] != DBNull.Value) { pInstance.RefundNo = Convert.ToString(pReader["RefundNo"]); } if (pReader["VipID"] != DBNull.Value) { pInstance.VipID = Convert.ToString(pReader["VipID"]); var vipDao = new VipDAO(this.CurrentUserInfo); var vipInfo = vipDao.GetByID(pInstance.VipID); if (vipInfo != null) { pInstance.VipName = vipInfo.VipName; } } if (pReader["DeliveryType"] != DBNull.Value) { pInstance.DeliveryType = Convert.ToInt32(pReader["DeliveryType"]); } if (pReader["OrderID"] != DBNull.Value) { pInstance.OrderID = Convert.ToString(pReader["OrderID"]); var inoutDAO = new T_InoutDAO(CurrentUserInfo); var inoutInfo = inoutDAO.GetByID(pInstance.OrderID); if (inoutInfo != null) { pInstance.OrderNo = inoutInfo.order_no; //订单号 pInstance.PayOrderID = inoutInfo.paymentcenter_id; //支付回调标识,商户单号 } } if (pReader["ItemID"] != DBNull.Value) { pInstance.ItemID = Convert.ToString(pReader["ItemID"]); } if (pReader["SkuID"] != DBNull.Value) { pInstance.SkuID = Convert.ToString(pReader["SkuID"]); } if (pReader["Qty"] != DBNull.Value) { pInstance.Qty = Convert.ToInt32(pReader["Qty"]); } if (pReader["ActualQty"] != DBNull.Value) { pInstance.ActualQty = Convert.ToInt32(pReader["ActualQty"]); } if (pReader["UnitID"] != DBNull.Value) { pInstance.UnitID = Convert.ToString(pReader["UnitID"]); } if (pReader["UnitName"] != DBNull.Value) { pInstance.UnitName = Convert.ToString(pReader["UnitName"]); } if (pReader["UnitTel"] != DBNull.Value) { pInstance.UnitTel = Convert.ToString(pReader["UnitTel"]); } if (pReader["Address"] != DBNull.Value) { pInstance.Address = Convert.ToString(pReader["Address"]); } if (pReader["Contacts"] != DBNull.Value) { pInstance.Contacts = Convert.ToString(pReader["Contacts"]); } if (pReader["Phone"] != DBNull.Value) { pInstance.Phone = Convert.ToString(pReader["Phone"]); } if (pReader["RefundAmount"] != DBNull.Value) { pInstance.RefundAmount = Convert.ToDecimal(pReader["RefundAmount"]); } if (pReader["ConfirmAmount"] != DBNull.Value) { pInstance.ConfirmAmount = Convert.ToDecimal(pReader["ConfirmAmount"]); } if (pReader["ActualRefundAmount"] != DBNull.Value) { pInstance.ActualRefundAmount = Convert.ToDecimal(pReader["ActualRefundAmount"]); } if (pReader["Points"] != DBNull.Value) { pInstance.Points = Convert.ToInt32(pReader["Points"]); } if (pReader["PointsAmount"] != DBNull.Value) { pInstance.PointsAmount = Convert.ToDecimal(pReader["PointsAmount"]); } if (pReader["ReturnAmount"] != DBNull.Value) { pInstance.ReturnAmount = Convert.ToDecimal(pReader["ReturnAmount"]); } if (pReader["Amount"] != DBNull.Value) { pInstance.Amount = Convert.ToDecimal(pReader["Amount"]); } if (pReader["CouponID"] != DBNull.Value) { pInstance.CouponID = Convert.ToString(pReader["CouponID"]); } if (pReader["PayOrderID"] != DBNull.Value) { pInstance.PayOrderID = Convert.ToString(pReader["PayOrderID"]); } if (pReader["Status"] != DBNull.Value) { pInstance.Status = Convert.ToInt32(pReader["Status"]); } if (pReader["CustomerID"] != DBNull.Value) { pInstance.CustomerID = Convert.ToString(pReader["CustomerID"]); } if (pReader["CreateTime"] != DBNull.Value) { pInstance.CreateTime = Convert.ToDateTime(pReader["CreateTime"]); } if (pReader["CreateBy"] != DBNull.Value) { pInstance.CreateBy = Convert.ToString(pReader["CreateBy"]); } if (pReader["LastUpdateTime"] != DBNull.Value) { pInstance.LastUpdateTime = Convert.ToDateTime(pReader["LastUpdateTime"]); } if (pReader["LastUpdateBy"] != DBNull.Value) { pInstance.LastUpdateBy = Convert.ToString(pReader["LastUpdateBy"]); } if (pReader["IsDelete"] != DBNull.Value) { pInstance.IsDelete = Convert.ToInt32(pReader["IsDelete"]); } }