/// <summary> /// 如果是送货到家,根据订单和用户ID来给总金额和实际支付金额加上运费 /// </summary> /// <param name="OrderId"></param> /// <returns></returns> public void UpdateOrderAddDeliveryAmount(string OrderId, string CustomerId) { //取订单信息 OnlineShoppingItemBLL serer = new OnlineShoppingItemBLL(base.loggingSessionInfo); JIT.CPOS.BS.Entity.Interface.SetOrderEntity orderInfo = serer.GetOrderOnline(OrderId); //如果订单状态不为100,return; if (orderInfo.Status != "100")//状态为100时,才是正式的订单,才进行下面的操作 { return; } OnlineShoppingItemService tInoutDAO = new OnlineShoppingItemService(base.loggingSessionInfo); #region 如果订单已产生配送费 TOrderCustomerDeliveryStrategyMappingEntity[] mappingList = Query(new IWhereCondition[] { new EqualsCondition() { FieldName = "OrderId", Value = OrderId } }, null); if (mappingList.Count() > 0) { mappingList[0].IsDelete = 1; Delete(mappingList[0]); //逻辑删除订单的配送费 //修改订单金额 orderInfo.TotalAmount = orderInfo.TotalAmount - mappingList[0].DeliveryAmount.Value; orderInfo.ActualAmount = orderInfo.ActualAmount - mappingList[0].DeliveryAmount.Value; tInoutDAO.UpdateOrderAddDeliveryAmount(orderInfo); } #endregion //根据totalAmount和customerID取对应的运费 CustomerDeliveryStrategyBLL customerDeliveryStrategyBLL = new CustomerDeliveryStrategyBLL(base.loggingSessionInfo); JIT.CPOS.BS.Entity.CustomerDeliveryStrategyEntity customerDeliveryStrategyEntity = customerDeliveryStrategyBLL.GetDeliveryAmount(CustomerId, orderInfo.TotalAmount, orderInfo.DeliveryId); if (customerDeliveryStrategyEntity.Id != null) { //更新订单主表totalAmount和actual_amount decimal DeliveryAmount = customerDeliveryStrategyEntity.DeliveryAmount == null ? 0 : Convert.ToDecimal(customerDeliveryStrategyEntity.DeliveryAmount); orderInfo.TotalAmount = orderInfo.TotalAmount + DeliveryAmount; orderInfo.ActualAmount = orderInfo.ActualAmount + DeliveryAmount; // serer.UpdateWEventByPhone tInoutDAO.UpdateOrderAddDeliveryAmount(orderInfo); //插入“订单与配送策略关系表” JIT.CPOS.BS.Entity.TOrderCustomerDeliveryStrategyMappingEntity tOrderCustomerDelivery = new TOrderCustomerDeliveryStrategyMappingEntity(); // tOrderCustomerDelivery.MappingId tOrderCustomerDelivery.OrderId = OrderId; tOrderCustomerDelivery.DSId = customerDeliveryStrategyEntity.Id; tOrderCustomerDelivery.DeliveryAmount = customerDeliveryStrategyEntity.DeliveryAmount; tOrderCustomerDelivery.CreateBy = loggingSessionInfo.CurrentUser.User_Name; tOrderCustomerDelivery.IsDelete = 0; //TOrderCustomerDeliveryStrategyMappingBLL tOrderCustomerDeliveryBLL = new TOrderCustomerDeliveryStrategyMappingBLL(loggingSessionInfo); _currentDAO.Create(tOrderCustomerDelivery); } }
/// <summary> /// 获取电商订单详细信息 /// </summary> /// <param name="OrderId"></param> /// <returns></returns> public JIT.CPOS.BS.Entity.Interface.SetOrderEntity GetOrderOnline(string OrderId) { JIT.CPOS.BS.Entity.Interface.SetOrderEntity orderInfo = new JIT.CPOS.BS.Entity.Interface.SetOrderEntity(); DataSet ds = new DataSet(); OnlineShoppingItemService onlineShoppingItemService = new OnlineShoppingItemService(loggingSessionInfo); ds = onlineShoppingItemService.GetOrderOnline(OrderId); if (ds != null && ds.Tables[0].Rows.Count > 0) { orderInfo = DataTableToObject.ConvertToObject <JIT.CPOS.BS.Entity.Interface.SetOrderEntity>(ds.Tables[0].Rows[0]); } return(orderInfo); }