コード例 #1
0
        /// <summary>
        /// 返现处理
        /// </summary>
        /// <param name="vipInfo">会员信息</param>
        /// <param name="unitInfo">门店信息</param>
        /// <param name="detailInfo">余额变更明细</param>
        /// <param name="tran">事务</param>
        /// <param name="loggingSessionInfo">登录信息</param>
        /// <param name="amountSourceId"></param>
        public string AddReturnAmount(VipEntity vipInfo, t_unitEntity unitInfo, VipAmountEntity vipAmountInfo, ref VipAmountDetailEntity detailInfo, SqlTransaction tran, LoggingSessionInfo loggingSessionInfo)
        {
            string vipAmountDetailId       = string.Empty;//变更明细ID
            var    vipAmountDao            = new VipAmountBLL(loggingSessionInfo);
            var    vipAmountDetailDao      = new VipAmountDetailBLL(loggingSessionInfo);
            var    customerBasicSettingBLL = new CustomerBasicSettingBLL(loggingSessionInfo);

            //获取返现有效期
            int cashValidPeriod     = 2; //默认为1,业务处理时会减去1
            var cashValidPeriodInfo = customerBasicSettingBLL.QueryByEntity(new CustomerBasicSettingEntity()
            {
                SettingCode = "CashValidPeriod", CustomerID = loggingSessionInfo.ClientID
            }, null).FirstOrDefault();

            if (cashValidPeriodInfo != null)
            {
                cashValidPeriod = int.Parse(cashValidPeriodInfo.SettingValue);
            }

            //var vipAmountInfo = vipAmountDao.GetByID(vipId);
            try
            {
                if (vipAmountInfo == null)  //无账户数据
                {
                    vipAmountInfo = new VipAmountEntity
                    {
                        VipId                  = vipInfo.VIPID,
                        VipCardCode            = vipInfo.VipCode,
                        BeginAmount            = 0,
                        InAmount               = 0,
                        OutAmount              = 0,
                        EndAmount              = 0,
                        TotalAmount            = 0,
                        BeginReturnAmount      = 0,
                        InReturnAmount         = detailInfo.Amount,
                        OutReturnAmount        = 0,
                        ReturnAmount           = detailInfo.Amount,
                        ImminentInvalidRAmount = 0,
                        InvalidReturnAmount    = 0,
                        ValidReturnAmount      = detailInfo.Amount,
                        TotalReturnAmount      = detailInfo.Amount,
                        IsLocking              = 0,
                        CustomerID             = loggingSessionInfo.ClientID
                    };
                    vipAmountDao.Create(vipAmountInfo, tran);
                }
                else
                {
                    if (detailInfo.Amount > 0)
                    {
                        vipAmountInfo.InReturnAmount    = (vipAmountInfo.InReturnAmount == null ? 0 : vipAmountInfo.InReturnAmount.Value) + detailInfo.Amount;
                        vipAmountInfo.TotalReturnAmount = (vipAmountInfo.TotalReturnAmount == null ? 0 : vipAmountInfo.TotalReturnAmount.Value) + detailInfo.Amount;
                    }
                    else
                    {
                        vipAmountInfo.OutReturnAmount = (vipAmountInfo.OutReturnAmount == null ? 0 : vipAmountInfo.OutReturnAmount.Value) + System.Math.Abs(detailInfo.Amount.Value);
                    }
                    vipAmountInfo.ValidReturnAmount = (vipAmountInfo.ValidReturnAmount == null ? 0 : vipAmountInfo.ValidReturnAmount.Value) + detailInfo.Amount;
                    vipAmountInfo.ReturnAmount      = (vipAmountInfo.ReturnAmount == null ? 0 : vipAmountInfo.ReturnAmount.Value) + detailInfo.Amount;

                    vipAmountDao.Update(vipAmountInfo);
                }
                //创建变更记录
                var vipamountDetailBll    = new VipAmountDetailBLL(loggingSessionInfo);
                var vipAmountDetailEntity = new VipAmountDetailEntity
                {
                    VipAmountDetailId = Guid.NewGuid(),
                    VipId             = vipInfo.VIPID,
                    VipCardCode       = vipInfo.VipCode,
                    UnitID            = unitInfo != null ? unitInfo.unit_id : "",
                    UnitName          = unitInfo != null ? unitInfo.unit_name : "",
                    Amount            = detailInfo.Amount,
                    UsedReturnAmount  = 0,
                    Reason            = detailInfo.Reason,
                    Remark            = detailInfo.Remark,
                    EffectiveDate     = DateTime.Now,
                    DeadlineDate      = Convert.ToDateTime((DateTime.Now.Year + cashValidPeriod - 1) + "-12-31 23:59:59 "),//失效时间,
                    AmountSourceId    = detailInfo.AmountSourceId,
                    ObjectId          = detailInfo.ObjectId,
                    CustomerID        = loggingSessionInfo.ClientID
                };
                vipamountDetailBll.Create(vipAmountDetailEntity, tran);

                vipAmountDetailId = vipAmountDetailEntity.VipAmountDetailId.ToString();
            }
            catch (Exception ex)
            {
                tran.Rollback();
                throw new APIException(ex.ToString())
                      {
                          ErrorCode = 121
                      };
            }
            return(vipAmountDetailId);
        }
コード例 #2
0
        /// <summary>
        ///保存送货到家配置信息
        /// </summary>
        /// <param name="DeliveryStrategyEntity"></param>
        /// <param name="BasicSettingEntity"></param>
        /// add by donal 2014-10-22 13:29:07
        public void SaveDeliveryStrategyAndBasicSetting(CustomerDeliveryStrategyEntity DeliveryStrategyEntity, CustomerBasicSettingEntity BasicSettingEntity, LoggingSessionInfo loggingSessionInfo, string deliveryId)
        {
            TransactionHelper tranHelper = new TransactionHelper(loggingSessionInfo);
            IDbTransaction    tran       = tranHelper.CreateTransaction();

            CustomerBasicSettingBLL basicSettingBLL = new CustomerBasicSettingBLL(loggingSessionInfo);

            #region  除信息

            //此商户下送货到家信息
            CustomerDeliveryStrategyEntity[] DeliveryStrategyList = QueryByEntity(
                new CustomerDeliveryStrategyEntity
            {
                CustomerId = loggingSessionInfo.ClientID,
                DeliveryId = DeliveryStrategyEntity.DeliveryId
            },
                null
                );

            //此商户下基数设置(描述)信息
            CustomerBasicSettingEntity[] BasicSettingList = basicSettingBLL.QueryByEntity(new CustomerBasicSettingEntity
            {
                SettingCode = "DeliveryStrategy",
                CustomerID  = loggingSessionInfo.ClientID
            },
                                                                                          null
                                                                                          );

            //除本次保存数据的此商户下送货到家信息
            CustomerDeliveryStrategyEntity[] DeliveryStrategyList_d = DeliveryStrategyList.Where(m => m.Id != DeliveryStrategyEntity.Id).ToArray();
            //除本次保存数据的此商户下基数设置(描述)信息
            CustomerBasicSettingEntity[] BasicSettingList_d = BasicSettingList.Where(m => m.SettingID != BasicSettingEntity.SettingID).ToArray();

            if (DeliveryStrategyList_d != null && DeliveryStrategyList_d.Count() > 0)
            {
                Delete(DeliveryStrategyList_d, tran);
            }
            if (BasicSettingList_d != null && BasicSettingList_d.Count() > 0)
            {
                basicSettingBLL.Delete(BasicSettingList_d, tran);
            }
            #endregion

            #region 保存

            if (DeliveryStrategyEntity.Id == null || string.IsNullOrWhiteSpace(DeliveryStrategyEntity.Id.ToString()))
            {
                DeliveryStrategyEntity.Id = Guid.NewGuid();
                Create(DeliveryStrategyEntity, tran);
            }
            else
            {
                Update(DeliveryStrategyEntity, tran);
            }

            if (BasicSettingEntity.SettingID == null || string.IsNullOrWhiteSpace(BasicSettingEntity.SettingID.ToString()))
            {
                BasicSettingEntity.SettingID = Guid.NewGuid();
                basicSettingBLL.Create(BasicSettingEntity, tran);
            }
            else
            {
                basicSettingBLL.Update(BasicSettingEntity, tran);
            }

            //修改配送方式状态
            DeliveryBLL deliveryBll = new DeliveryBLL(loggingSessionInfo);
            deliveryBll.Update(
                new DeliveryEntity()
            {
                DeliveryId = deliveryId,
                Status     = DeliveryStrategyEntity.Status
            }
                , tran
                );
            #endregion
            tran.Commit();
        }