예제 #1
0
 internal void Delete(SysVipCardTypeEntity dbEntity)
 {
     using (var conn = new SqlConnection(ConnectionString.XgxInsert))
     {
         conn.Open();
         conn.Delete(dbEntity);
     }
 }
예제 #2
0
 internal void Create(SysVipCardTypeEntity dbEntity)
 {
     using (var conn = new SqlConnection(ConnectionString.XgxInsert))
     {
         dbEntity.CreateTime = System.DateTime.Now;
         //dbEntity.CreateBy = "ERP";
         conn.Insert(dbEntity);
     }
 }
예제 #3
0
 internal void Update(SysVipCardTypeEntity dbEntity)
 {
     using (var conn = new SqlConnection(ConnectionString.XgxInsert))
     {
         dbEntity.LastUpdateTime = System.DateTime.Now;
         //dbEntity.LastUpdateBy = "ERP";
         conn.Open();
         conn.Update(dbEntity);
     }
 }
예제 #4
0
        public void Deal(EventContract msg)
        {
            var     bus = MqBusMgr.GetInstance();
            OptEnum operation;

            Enum.TryParse(msg.Operation.ToString(), out operation);
            var vipContract = new VipContract
            {
                Operation = operation,
                VipId     = msg.Id
            };

            if (msg.Operation != Zmind.EventBus.Contract.OptEnum.Delete)
            {
                var vipFacade = new VipFacade();
                var vipEntity = vipFacade.GetById(msg.Id);
                if (vipEntity == null)
                {
                    return;
                }
                vipContract.VipName    = vipEntity.VipName;
                vipContract.VipCode    = vipEntity.VipCode;
                vipContract.CreateTime = vipEntity.CreateTime;
                vipContract.ModifyTime = vipEntity.LastUpdateTime;

                vipContract.Phone    = vipEntity.Phone;
                vipContract.IdType   = vipEntity.IDType;
                vipContract.IdNumber = vipEntity.IDNumber;
                if (string.IsNullOrEmpty(vipEntity.Birthday))
                {
                    vipContract.Birthday = null;
                }
                else
                {
                    vipContract.Birthday = DateTime.Parse(vipEntity.Birthday);
                }
                vipContract.Gender   = vipEntity.Gender != null ? vipEntity.Gender.Value : 1;
                vipContract.Email    = vipEntity.Email;
                vipContract.OpenID   = vipEntity.WeiXinUserId;
                vipContract.WeiXinID = vipEntity.WeiXin;
                //  vipContract.VipLevel = vipEntity.VipLevel != null ? vipEntity.VipLevel.Value : 1;
                //获取会员对应的卡类别
                //查询最低等级的会员卡类型
                SysVipCardTypeFacade _SysVipCardTypeFacade = new SysVipCardTypeFacade();
                SysVipCardTypeEntity vipCardTypeInfo       = _SysVipCardTypeFacade.GetVipCardTypeByVipID(msg.Id);
                if (vipCardTypeInfo != null)
                {
                    vipContract.VipCardTypeID = (int)vipCardTypeInfo.VipCardTypeID;
                }
                vipContract.OldVipID = msg.OtherCon;
            }


            bus.Publish <IZmindToXgx>(vipContract);
        }
예제 #5
0
        protected override GetVipCardTypeListRD ProcessRequest(DTO.Base.APIRequest <GetVipCardTypeListRP> pRequest)
        {
            GetVipCardTypeListRP rp = pRequest.Parameters;
            GetVipCardTypeListRD rd = new GetVipCardTypeListRD();

            rd.VipCardTypeIdList = new List <VipCardTypeInfo>();


            VipCardBLL        vipCardBll        = new VipCardBLL(CurrentUserInfo);
            SysVipCardTypeBLL sysVipCardTypeBll = new SysVipCardTypeBLL(CurrentUserInfo);

            var vipCardInfo = vipCardBll.GetVipCardByVipMapping(rp.VipId);
            List <SysVipCardTypeEntity> sysVipCardTypeAllList = sysVipCardTypeBll.QueryByEntity(new SysVipCardTypeEntity()
            {
                CustomerID = CurrentUserInfo.ClientID
            }, null).ToList();

            if (sysVipCardTypeAllList != null && vipCardInfo != null)
            {
                SysVipCardTypeEntity sysVipCardTypeEntity = sysVipCardTypeBll.GetByID(vipCardInfo.VipCardTypeID);
                if (sysVipCardTypeEntity != null)
                {
                    List <SysVipCardTypeEntity> sysVipCardTypeList = sysVipCardTypeAllList.AsEnumerable().Where(t => t.VipCardLevel > sysVipCardTypeEntity.VipCardLevel).ToList();
                    if (sysVipCardTypeList != null)
                    {
                        foreach (var item in sysVipCardTypeList)
                        {
                            VipCardTypeInfo vipCardTypeInfo = new VipCardTypeInfo();
                            vipCardTypeInfo.VipCardTypeId   = item.VipCardTypeID.ToString();
                            vipCardTypeInfo.VipCardTypeName = item.VipCardTypeName.ToString();

                            rd.VipCardTypeIdList.Add(vipCardTypeInfo);
                        }
                    }
                }
            }
            return(rd);
        }
예제 #6
0
        protected override GetMakeVipCardListRD ProcessRequest(DTO.Base.APIRequest <GetMakeVipCardListRP> pRequest)
        {
            var rd   = new GetMakeVipCardListRD();
            var para = pRequest.Parameters;
            var loggingSessionInfo = new SessionManager().CurrentUserLoginInfo;
            var VipCardBatchBLL    = new VipCardBatchBLL(loggingSessionInfo);
            var SysVipCardTypeBLL  = new SysVipCardTypeBLL(loggingSessionInfo);
            //查询参数
            List <IWhereCondition> complexCondition = new List <IWhereCondition> {
            };

            if (!string.IsNullOrEmpty(para.VipCardTypeCode))
            {
                complexCondition.Add(new EqualsCondition()
                {
                    FieldName = "VipCardTypeCode", Value = para.VipCardTypeCode
                });
            }
            if (para.StareDate != null)
            {
                complexCondition.Add(new DirectCondition("a.BeginDate>='" + para.StareDate + "' "));
            }
            if (para.EndDate != null)
            {
                complexCondition.Add(new DirectCondition("a.EndDate<='" + para.EndDate + "' "));
            }

            //获取数据集
            var tempList = VipCardBatchBLL.PagedQuery(complexCondition.ToArray(), null, para.PageSize, para.PageIndex);

            rd.TotalPageCount = tempList.PageCount;
            rd.TotalCount     = tempList.RowCount;

            rd.VipCardBatchInfoList = tempList.Entities.Select(t => new VipCardBatchInfo()
            {
                BatchNo         = t.BatchNo == null ? 0 : t.BatchNo.Value,
                CardMedium      = t.CardMedium == null ? "" : t.CardMedium,
                VipCardTypeCode = t.VipCardTypeCode == null ? "" : t.VipCardTypeCode,
                CardPrefix      = t.CardPrefix == null ? "" : t.CardPrefix,
                StartCardNo     = t.StartCardNo == null ? "" : t.StartCardNo,
                EndCardNo       = t.EndCardNo == null ? "" : t.EndCardNo,
                CreateTime      = t.CreateTime == null ? "" : t.CreateTime.Value.ToString("yyyy-MM-dd"),
                Qty             = t.Qty == null ? 0 : t.Qty.Value,
                OutliersQty     = t.OutliersQty == null ? 0 : t.OutliersQty.Value,
                ImportQty       = t.ImportQty == null ? 0 : t.ImportQty.Value
            }).ToList();

            if (rd.VipCardBatchInfoList.Count > 0)
            {
                foreach (var item in rd.VipCardBatchInfoList)
                {
                    SysVipCardTypeEntity TypeDate = SysVipCardTypeBLL.QueryByEntity(new SysVipCardTypeEntity()
                    {
                        VipCardTypeCode = item.VipCardTypeCode
                    }, null).FirstOrDefault();
                    item.VipCardTypeName = TypeDate == null ? "" : TypeDate.VipCardTypeName;
                }
            }

            return(rd);
        }
예제 #7
0
        protected override EmptyResponseData ProcessRequest(DTO.Base.APIRequest <UpdateVipCardTypeSystemRP> pRequest)
        {
            var rd   = new EmptyResponseData();
            var para = pRequest.Parameters;
            var loggingSessionInfo   = new SessionManager().CurrentUserLoginInfo;
            var entitySysVipCardType = new SysVipCardTypeEntity();
            var bllSysVipCardType    = new SysVipCardTypeBLL(loggingSessionInfo);
            //卡分润规则
            var bllVipCardProfitRule = new VipCardProfitRuleBLL(loggingSessionInfo);
            //续费充值方式
            var VipCardReRechargeProfitRuleService = new VipCardReRechargeProfitRuleBLL(loggingSessionInfo);

            //编辑会员卡等级
            try
            {
                var SysVipCardTypeInfo = bllSysVipCardType.QueryByEntity(new SysVipCardTypeEntity()
                {
                    CustomerID = loggingSessionInfo.ClientID, VipCardTypeID = para.VipCardTypeID, IsDelete = 0
                }, null).FirstOrDefault();
                switch (para.OperateType)
                {
                //如果为1编辑会员卡等级信息
                case 1:
                    if (SysVipCardTypeInfo != null)
                    {
                        //获取当前会员信息
                        List <IWhereCondition> wheres = new List <IWhereCondition>();
                        wheres.Add(new EqualsCondition()
                        {
                            FieldName = "Category", Value = 0
                        });
                        wheres.Add(new EqualsCondition()
                        {
                            FieldName = "CustomerID", Value = loggingSessionInfo.ClientID
                        });
                        wheres.Add(new EqualsCondition()
                        {
                            FieldName = "VipCardTypeName", Value = para.VipCardTypeName
                        });
                        wheres.Add(new DirectCondition("VipCardLevel!='" + SysVipCardTypeInfo.VipCardLevel + "'"));
                        var ExistVipCardTypeResult = bllSysVipCardType.Query(wheres.ToArray(), null).FirstOrDefault();
                        if (ExistVipCardTypeResult != null)
                        {
                            throw new APIException("会员卡名称不能重复!")
                                  {
                                      ErrorCode = ERROR_CODES.INVALID_BUSINESS
                                  };
                        }
                        SysVipCardTypeInfo.VipCardTypeID   = para.VipCardTypeID;
                        SysVipCardTypeInfo.Category        = 0;
                        SysVipCardTypeInfo.VipCardTypeName = para.VipCardTypeName;
                        SysVipCardTypeInfo.VipCardLevel    = SysVipCardTypeInfo.VipCardLevel;
                        SysVipCardTypeInfo.IsPassword      = SysVipCardTypeInfo.IsPassword;
                        if (SysVipCardTypeInfo.VipCardLevel == 1)    //如果等级为1默认可充值
                        {
                            SysVipCardTypeInfo.Isprepaid = 1;
                        }
                        else
                        {
                            SysVipCardTypeInfo.Isprepaid = para.IsPrepaid;
                        }
                        SysVipCardTypeInfo.IsOnlineSales = para.IsOnlineSales;
                        SysVipCardTypeInfo.PicUrl        = para.PicUrl;
                        SysVipCardTypeInfo.CustomerID    = loggingSessionInfo.ClientID;
                        if (SysVipCardTypeInfo.VipCardLevel == 1)
                        {
                            SysVipCardTypeInfo.Prices           = 0;
                            SysVipCardTypeInfo.ExchangeIntegral = 0;
                            SysVipCardTypeInfo.IsExtraMoney     = 2;
                        }
                    }
                    //如果IsOnlineSales为0则需要逻辑删除分润规则数据
                    if (SysVipCardTypeInfo.IsOnlineSales == 0)
                    {
                        var VipCardProfitRuleInfo = bllVipCardProfitRule.QueryByEntity(new VipCardProfitRuleEntity()
                        {
                            VipCardTypeID = SysVipCardTypeInfo.VipCardTypeID, CustomerID = loggingSessionInfo.ClientID
                        }, null);
                        if (VipCardProfitRuleInfo.Length > 0)
                        {
                            bllVipCardProfitRule.Delete(VipCardProfitRuleInfo);
                        }
                    }

                    if (SysVipCardTypeInfo.Isprepaid == 0)     //不可充值
                    {
                        var VipCardUpgradeRuleService = new VipCardUpgradeRuleBLL(loggingSessionInfo);
                        //升级规则信息 永远只有一条信息
                        var CardUpgradeRuleEntity = VipCardUpgradeRuleService.QueryByEntity(new VipCardUpgradeRuleEntity()
                        {
                            VipCardTypeID = SysVipCardTypeInfo.VipCardTypeID
                        }, null);
                        if (CardUpgradeRuleEntity != null && CardUpgradeRuleEntity.FirstOrDefault() != null) //如果有设置了升级条件
                        {
                            if (CardUpgradeRuleEntity.FirstOrDefault().IsBuyUpgrade == 1)                    //消费升级+不可充值==>逻辑删除 会员卡销售激励规则
                            {
                                var Ids = bllVipCardProfitRule.QueryByEntity(new VipCardProfitRuleEntity()
                                {
                                    CustomerID = loggingSessionInfo.ClientID, VipCardTypeID = SysVipCardTypeInfo.VipCardTypeID
                                }, null).Select(m => m.CardBuyToProfitRuleId.Value.ToString()).ToArray();
                                if (Ids.Length > 0)
                                {
                                    bllVipCardProfitRule.Delete(Ids);
                                }
                            }
                        }

                        //将所有梯度信息 逻辑删除
                        string[] ProfitRuleIds = bllVipCardProfitRule.GetRechargeProfitRuleByIsPrepaid(loggingSessionInfo.ClientID, SysVipCardTypeInfo.VipCardTypeID);
                        if (ProfitRuleIds.Length > 0)
                        {
                            VipCardReRechargeProfitRuleService.Delete(ProfitRuleIds);
                        }
                    }
                    bllSysVipCardType.Update(SysVipCardTypeInfo);
                    //修改虚拟商品
#warning 商品代码注释 Bear
                    ItemService _ItemService = new ItemService(loggingSessionInfo);
                    _ItemService.SaveCardToOffenTItem(loggingSessionInfo, SysVipCardTypeInfo);
                    break;

                //如果为2编辑升级规则信息
                case 2:
                    var bllVipCardUpgradeRule = new VipCardUpgradeRuleBLL(loggingSessionInfo);
                    //升级类型不能为空 (1=购卡升级;2=充值升级;3=消费升级;)
                    if (para.UpGradeType != 0)
                    {
                        VipCardUpgradeRuleEntity vipCardUpgradeRuleEntity = new VipCardUpgradeRuleEntity();
                        if (para.OperateObjectID != null)
                        {
                            var VipCardUpgradeRuleInfo = bllVipCardUpgradeRule.QueryByEntity(new VipCardUpgradeRuleEntity()
                            {
                                CustomerID = loggingSessionInfo.ClientID, VipCardUpgradeRuleId = new Guid(para.OperateObjectID), VipCardTypeID = para.VipCardTypeID
                            }, null).FirstOrDefault();
                            if (VipCardUpgradeRuleInfo != null)
                            {
                                //先置为0 再进行更新
                                SysVipCardTypeInfo.IsExtraMoney           = 2;
                                SysVipCardTypeInfo.Prices                 = 0;
                                SysVipCardTypeInfo.ExchangeIntegral       = 0;
                                VipCardUpgradeRuleInfo.OnceRechargeAmount = 0;
                                VipCardUpgradeRuleInfo.OnceBuyAmount      = 0;
                                VipCardUpgradeRuleInfo.BuyAmount          = 0;
                                switch (para.UpGradeType)
                                {
                                case 1:
                                    VipCardUpgradeRuleInfo.IsPurchaseUpgrade = 1;
                                    //金额和积分 与可补差价在卡等级表里面
                                    SysVipCardTypeInfo.VipCardTypeID    = para.VipCardTypeID;
                                    SysVipCardTypeInfo.IsExtraMoney     = para.IsExtraMoney;
                                    SysVipCardTypeInfo.Prices           = para.Prices;
                                    SysVipCardTypeInfo.ExchangeIntegral = para.ExchangeIntegral;
                                    //充值升级归零
                                    VipCardUpgradeRuleInfo.IsRecharge = 0;
                                    //消费升级置零
                                    VipCardUpgradeRuleInfo.IsBuyUpgrade = 0;
                                    break;

                                case 2:
                                    VipCardUpgradeRuleInfo.IsPurchaseUpgrade  = 0;
                                    VipCardUpgradeRuleInfo.IsRecharge         = 1;
                                    VipCardUpgradeRuleInfo.IsBuyUpgrade       = 0;
                                    VipCardUpgradeRuleInfo.OnceRechargeAmount = para.OnceRechargeAmount;
                                    break;

                                case 3:
                                    VipCardUpgradeRuleInfo.IsPurchaseUpgrade = 0;
                                    VipCardUpgradeRuleInfo.IsRecharge        = 0;
                                    VipCardUpgradeRuleInfo.IsBuyUpgrade      = 1;
                                    VipCardUpgradeRuleInfo.OnceBuyAmount     = para.OnceBuyAmount;
                                    VipCardUpgradeRuleInfo.BuyAmount         = para.BuyAmount;
                                    //如果该卡为不可充值 那么就默认删除
                                    var syscardentity = bllSysVipCardType.GetByID(para.VipCardTypeID);
                                    if (syscardentity != null && syscardentity.Isprepaid == 0)         //消费升级 {不可充值} 默认删除该卡的激励规则
                                    {
                                        var Ids = bllVipCardProfitRule.QueryByEntity(new VipCardProfitRuleEntity()
                                        {
                                            CustomerID = loggingSessionInfo.ClientID, VipCardTypeID = para.VipCardTypeID
                                        }, null).Select(m => m.CardBuyToProfitRuleId.Value.ToString()).ToArray();
                                        if (Ids.Length > 0)
                                        {
                                            bllVipCardProfitRule.Delete(Ids);
                                        }
                                    }
                                    break;
                                }
                                //更新卡等级部分信息
                                bllSysVipCardType.Update(SysVipCardTypeInfo);
                                //修改虚拟商品
                                ItemService _ItemServices = new ItemService(loggingSessionInfo);
                                _ItemServices.SaveCardToOffenTItem(loggingSessionInfo, SysVipCardTypeInfo);
                                bllVipCardUpgradeRule.Update(VipCardUpgradeRuleInfo);
                            }
                        }
                        else
                        {
                            //先置为0 再进行更新
                            SysVipCardTypeInfo.IsExtraMoney             = 2;
                            SysVipCardTypeInfo.Prices                   = 0;
                            SysVipCardTypeInfo.ExchangeIntegral         = 0;
                            vipCardUpgradeRuleEntity.OnceRechargeAmount = 0;
                            vipCardUpgradeRuleEntity.OnceBuyAmount      = 0;
                            vipCardUpgradeRuleEntity.BuyAmount          = 0;
                            switch (para.UpGradeType)
                            {
                            case 1:
                                vipCardUpgradeRuleEntity.IsPurchaseUpgrade = 1;
                                vipCardUpgradeRuleEntity.VipCardTypeID     = para.VipCardTypeID;
                                //金额和积分 与可补差价在卡等级表里面
                                SysVipCardTypeInfo.VipCardTypeID    = para.VipCardTypeID;
                                SysVipCardTypeInfo.IsExtraMoney     = para.IsExtraMoney;
                                SysVipCardTypeInfo.Prices           = para.Prices;
                                SysVipCardTypeInfo.ExchangeIntegral = para.ExchangeIntegral;
                                //充值升级归零
                                vipCardUpgradeRuleEntity.IsRecharge = 0;
                                //消费升级置零
                                vipCardUpgradeRuleEntity.IsBuyUpgrade = 0;
                                break;

                            case 2:
                                vipCardUpgradeRuleEntity.IsPurchaseUpgrade  = 0;
                                vipCardUpgradeRuleEntity.IsRecharge         = 1;
                                vipCardUpgradeRuleEntity.IsBuyUpgrade       = 0;
                                vipCardUpgradeRuleEntity.OnceRechargeAmount = para.OnceRechargeAmount;
                                break;

                            case 3:          //消费升级
                                vipCardUpgradeRuleEntity.IsPurchaseUpgrade = 0;
                                vipCardUpgradeRuleEntity.IsRecharge        = 0;
                                vipCardUpgradeRuleEntity.IsBuyUpgrade      = 1;
                                vipCardUpgradeRuleEntity.OnceBuyAmount     = para.OnceBuyAmount;
                                vipCardUpgradeRuleEntity.BuyAmount         = para.BuyAmount;
                                break;
                            }
                            //更新卡等级部分信息
                            bllSysVipCardType.Update(SysVipCardTypeInfo);
                            //修改虚拟商品
                            ItemService _ItemServices = new ItemService(loggingSessionInfo);
                            _ItemServices.SaveCardToOffenTItem(loggingSessionInfo, SysVipCardTypeInfo);
                            //添加卡升级规则
                            vipCardUpgradeRuleEntity.VipCardUpgradeRuleId = Guid.NewGuid();
                            vipCardUpgradeRuleEntity.CustomerID           = loggingSessionInfo.ClientID;
                            bllVipCardUpgradeRule.Create(vipCardUpgradeRuleEntity);
                        }
                    }
                    else
                    {
                        throw new APIException("升级类型不能为空!")
                              {
                                  ErrorCode = ERROR_CODES.INVALID_BUSINESS
                              };
                    }

                    break;

                //如果为3编辑基本权益信息
                case 3:
                    var bllVipCardRule    = new VipCardRuleBLL(loggingSessionInfo);
                    var entityVipCardRule = new VipCardRuleEntity();
                    var VipCardRuleInfo   = bllVipCardRule.QueryByEntity(new VipCardRuleEntity()
                    {
                        CustomerID = loggingSessionInfo.ClientID, RuleID = Convert.ToInt32(para.OperateObjectID), VipCardTypeID = para.VipCardTypeID
                    }, null).FirstOrDefault();
                    if (VipCardRuleInfo != null)
                    {
                        entityVipCardRule.RuleID               = Convert.ToInt32(para.OperateObjectID);
                        entityVipCardRule.VipCardTypeID        = para.VipCardTypeID;
                        entityVipCardRule.CardDiscount         = para.CardDiscount * 10;
                        entityVipCardRule.PaidGivePoints       = para.PaidGivePoints;
                        entityVipCardRule.PaidGivePercetPoints = para.PaidGivePercetPoints;
                        entityVipCardRule.CustomerID           = loggingSessionInfo.ClientID;
                        bllVipCardRule.Update(entityVipCardRule);
                    }
                    break;
                }

                try
                {
                    var msg = new EventContract
                    {
                        Operation  = OptEnum.Update,
                        EntityType = EntityTypeEnum.VipCardType,
                        Id         = SysVipCardTypeInfo.VipCardTypeID.ToString()
                    };
                    var eventService = new EventService();
                    eventService.PublishMsg(msg);
                }
                catch (Exception)
                {
                    throw new Exception("RabbitMQ Error");
                }
            }
            catch (APIException ex)
            {
                throw ex;
            }

            return(rd);
        }
예제 #8
0
        public void Deal(VipContract contract)
        {
            var dbEntity = Convert(contract);
            var facade   = new VipFacade();

            if (contract.Operation != OptEnum.Delete)
            {
                if (facade.GetById(contract.VipId) == null)
                {
                    contract.Operation = OptEnum.Create;
                }
                else
                {
                    contract.Operation = OptEnum.Update;
                }
            }
            switch (contract.Operation)
            {
            case OptEnum.Create:
                facade.Create(dbEntity);
                //创建卡
                SysVipCardTypeFacade _SysVipCardTypeFacade = new SysVipCardTypeFacade();
                //查询最低等级的会员卡类型
                //  SysVipCardTypeEntity vipCardTypeInfo = _SysVipCardTypeFacade.GetMinVipCardType(ConfigMgr.CustomerId);
                //查询某个级别的卡,都用金卡
                SysVipCardTypeEntity vipCardTypeInfo = _SysVipCardTypeFacade.GetCardTypeIDByVipCardLevel(3, ConfigMgr.CustomerId);
                if (vipCardTypeInfo != null)
                {
                    var vipCardInfo = new VipCardEntity();
                    vipCardInfo.VipCardID       = Guid.NewGuid().ToString();
                    vipCardInfo.VipCardTypeID   = vipCardTypeInfo.VipCardTypeID;
                    vipCardInfo.VipCardName     = vipCardTypeInfo.VipCardTypeName;
                    vipCardInfo.VipCardCode     = dbEntity.VipCode;
                    vipCardInfo.VipCardStatusId = 1;    //正常
                    //  vipCardInfo.MembershipUnit = unitId;
                    //    vipCardInfo.MembershipTime = DateTime.Now;
                    vipCardInfo.CustomerID = ConfigMgr.CustomerId;
                    vipCardInfo.IsDelete   = 0;

                    var _VipCardFacade = new VipCardFacade();    //创建处理类
                    _VipCardFacade.Create(vipCardInfo);
                    //创建会员与卡之间的关系
                    //绑定会员卡和会员
                    var vipCardVipMappingEntity = new VipCardVipMappingEntity()
                    {
                        MappingID  = Guid.NewGuid().ToString().Replace("-", ""),
                        VIPID      = dbEntity.VIPID,
                        VipCardID  = vipCardInfo.VipCardID,
                        CustomerID = ConfigMgr.CustomerId,
                        IsDelete   = 0
                    };
                    var _VipCardVipMappingFacade = new VipCardVipMappingFacade();    //创建处理类
                    _VipCardVipMappingFacade.Create(vipCardVipMappingEntity);
                }

                break;

            case OptEnum.Update:
                facade.Update(dbEntity);
                break;

            case OptEnum.Delete:
                facade.Delete(dbEntity);
                break;
            }
        }
예제 #9
0
 public void Delete(SysVipCardTypeEntity dbEntity)
 {
     _cmd.Delete(dbEntity);
 }
예제 #10
0
 /// <summary>
 /// 分页根据实体条件查询实体
 /// </summary>
 /// <param name="pQueryEntity">以实体形式传入的参数</param>
 /// <param name="pOrderBys">排序组合</param>
 /// <returns>符合条件的实体集</returns>
 public PagedQueryResult <SysVipCardTypeEntity> PagedQueryByEntity(SysVipCardTypeEntity pQueryEntity, OrderBy[] pOrderBys, int pPageSize, int pCurrentPageIndex)
 {
     return(_currentDAO.PagedQueryByEntity(pQueryEntity, pOrderBys, pPageSize, pCurrentPageIndex));
 }
예제 #11
0
 /// <summary>
 /// 根据实体条件查询实体
 /// </summary>
 /// <param name="pQueryEntity">以实体形式传入的参数</param>
 /// <param name="pOrderBys">排序组合</param>
 /// <returns>符合条件的实体集</returns>
 public SysVipCardTypeEntity[] QueryByEntity(SysVipCardTypeEntity pQueryEntity, OrderBy[] pOrderBys)
 {
     return(_currentDAO.QueryByEntity(pQueryEntity, pOrderBys));
 }
예제 #12
0
 /// <summary>
 /// 删除
 /// </summary>
 /// <param name="pEntity"></param>
 public void Delete(SysVipCardTypeEntity pEntity)
 {
     _currentDAO.Delete(pEntity);
 }
예제 #13
0
 /// <summary>
 /// 更新
 /// </summary>
 /// <param name="pEntity">实体实例</param>
 public void Update(SysVipCardTypeEntity pEntity)
 {
     _currentDAO.Update(pEntity);
 }
예제 #14
0
        protected override SetSpecialDateRD ProcessRequest(DTO.Base.APIRequest <SetSysVipCardTypeRP> pRequest)
        {
            var rd   = new SetSpecialDateRD();
            var para = pRequest.Parameters;
            var loggingSessionInfo = new SessionManager().CurrentUserLoginInfo;
            var sysVipCardTypeBLL  = new SysVipCardTypeBLL(loggingSessionInfo);
            var vipCardRuleBLL     = new VipCardRuleBLL(loggingSessionInfo);
            SysVipCardTypeEntity sysVipCardTypeEntity = null;   //卡类型实体
            VipCardRuleEntity    vipCardRuleEntity    = null;   //卡类型规则实体

            SysVipCardTypeEntity[] vipcardList    = null;       //获取同种类的所有卡类型集合
            SysVipCardTypeEntity   typeCodeEntity = null;       //相同vipCardTypeCode对象
            SysVipCardTypeEntity   typeNameEntity = null;       //相同vipCardTypeName对象
            SysVipCardTypeEntity   levelEntity    = null;       //相同Level对象

            var pTran = sysVipCardTypeBLL.GetTran();            //事务

            //获取同种类的所有卡类型
            vipcardList = sysVipCardTypeBLL.QueryByEntity(new SysVipCardTypeEntity()
            {
                CustomerID = loggingSessionInfo.ClientID, Category = para.Category
            }, new OrderBy[] { new OrderBy()
                               {
                                   FieldName = "VipCardLevel", Direction = OrderByDirections.Desc
                               } });

            //判断编码是否重复
            if (!string.IsNullOrEmpty(para.VipCardTypeCode))
            {
                typeCodeEntity = vipcardList.Where(t => t.VipCardTypeCode == para.VipCardTypeCode).FirstOrDefault();
            }

            //判断名称是否重复
            if (!string.IsNullOrEmpty(para.VipCardTypeName))
            {
                typeNameEntity = vipcardList.Where(t => t.VipCardTypeName == para.VipCardTypeName).FirstOrDefault();
            }

            //判断级别是否重复
            levelEntity = vipcardList.Where(t => t.VipCardLevel == para.VipCardLevel).FirstOrDefault();

            using (pTran.Connection)
            {
                try
                {
                    if (para.VipCardTypeID == 0 || para.VipCardTypeID == null)//创建
                    {
                        //判断编码是否重复
                        if (typeCodeEntity != null)
                        {
                            throw new APIException("同一种卡类型编码已存在")
                                  {
                                      ErrorCode = ERROR_CODES.INVALID_BUSINESS
                                  }
                        }
                        ;
                        //判断编码是否重复
                        if (typeNameEntity != null)
                        {
                            throw new APIException("同一种卡类型名称已存在")
                                  {
                                      ErrorCode = ERROR_CODES.INVALID_BUSINESS
                                  }
                        }
                        ;
                        //创建会员卡时判断等级是否重复
                        if (levelEntity != null && para.Category == 0)
                        {
                            throw new APIException("同一种卡类型等级已存在")
                                  {
                                      ErrorCode = ERROR_CODES.INVALID_BUSINESS
                                  }
                        }
                        ;
                        //判断等级是否跨级创建
                        if (vipcardList != null && vipcardList.Count() > 0)
                        {
                            if (vipcardList[0].VipCardLevel + 1 < para.VipCardLevel)
                            {
                                throw new APIException("同一种卡类型不能跨等级创建,请创建等级" + (vipcardList[0].VipCardLevel + 1))
                                      {
                                          ErrorCode = ERROR_CODES.INVALID_BUSINESS
                                      }
                            }
                            ;
                        }
                        sysVipCardTypeEntity = new SysVipCardTypeEntity();   //卡类型实体
                        vipCardRuleEntity    = new VipCardRuleEntity();      //卡类型规则实体
                    }
                    else//编辑
                    {
                        //获取卡信息
                        sysVipCardTypeEntity = sysVipCardTypeBLL.GetByID(para.VipCardTypeID);
                        //判断编码是否重复
                        if (sysVipCardTypeEntity.VipCardTypeCode != para.VipCardTypeCode)
                        {
                            if (typeCodeEntity != null)
                            {
                                throw new APIException("同一种卡类型编码已存在")
                                      {
                                          ErrorCode = ERROR_CODES.INVALID_BUSINESS
                                      }
                            }
                            ;
                        }
                        //判断编码是否重复
                        if (sysVipCardTypeEntity.VipCardTypeName != para.VipCardTypeName)
                        {
                            if (typeNameEntity != null)
                            {
                                throw new APIException("同一种卡类型名称已存在")
                                      {
                                          ErrorCode = ERROR_CODES.INVALID_BUSINESS
                                      }
                            }
                            ;
                        }
                        if (sysVipCardTypeEntity.VipCardLevel != para.VipCardLevel)
                        {
                            //修改会员卡判断等级是否重复
                            if (levelEntity != null && para.Category == 0)
                            {
                                throw new APIException("同一种卡类型等级已存在")
                                      {
                                          ErrorCode = ERROR_CODES.INVALID_BUSINESS
                                      }
                            }
                            ;
                        }
                        //判断等级是否跨级创建
                        if (vipcardList != null && vipcardList.Count() > 0)
                        {
                            if (sysVipCardTypeEntity.VipCardLevel != para.VipCardLevel)
                            {
                                if (vipcardList[0].VipCardLevel + 1 < para.VipCardLevel)
                                {
                                    throw new APIException("卡等级不能修改")
                                          {
                                              ErrorCode = ERROR_CODES.INVALID_BUSINESS
                                          }
                                }
                                ;
                            }
                        }
                        //获取卡规则信息
                        vipCardRuleEntity = vipCardRuleBLL.QueryByEntity(new VipCardRuleEntity()
                        {
                            VipCardTypeID = para.VipCardTypeID
                        }, null).FirstOrDefault();
                    }

                    //卡类型
                    sysVipCardTypeEntity.VipCardTypeCode   = para.VipCardTypeCode;
                    sysVipCardTypeEntity.VipCardTypeName   = para.VipCardTypeName;
                    sysVipCardTypeEntity.PicUrl            = para.PicUrl;
                    sysVipCardTypeEntity.IsDiscount        = para.CardDiscount > 0 ? 1 : 0;   //是否可打折扣(0=不可用;1=可用)
                    sysVipCardTypeEntity.IsPoints          = para.PointsMultiple > 0 ? 1 : 0; //是否可积分(0=不可用;1=可用)
                    sysVipCardTypeEntity.IsOnlineRecharge  = para.ChargeFull > 0 ? 1 : 0;     //是否可线上充值(0=不可用;1=可用)
                    sysVipCardTypeEntity.IsPassword        = para.IsPassword;
                    sysVipCardTypeEntity.Category          = para.Category;
                    sysVipCardTypeEntity.VipCardLevel      = para.VipCardLevel;
                    sysVipCardTypeEntity.Prices            = para.Prices;
                    sysVipCardTypeEntity.IsExtraMoney      = para.IsExtraMoney;
                    sysVipCardTypeEntity.ExchangeIntegral  = para.ExchangeIntegral;
                    sysVipCardTypeEntity.UpgradeAmount     = para.UpgradeAmount;
                    sysVipCardTypeEntity.UpgradeOnceAmount = para.UpgradeOnceAmount;
                    sysVipCardTypeEntity.UpgradePoint      = para.UpgradePoint;
                    sysVipCardTypeEntity.CustomerID        = loggingSessionInfo.ClientID;

                    //卡规则
                    vipCardRuleEntity.CardDiscount    = para.CardDiscount;
                    vipCardRuleEntity.PointsMultiple  = para.PointsMultiple;
                    vipCardRuleEntity.ChargeFull      = para.ChargeFull;
                    vipCardRuleEntity.ChargeGive      = para.ChargeGive;
                    vipCardRuleEntity.PaidGivePoints  = para.PaidGivePoints;
                    vipCardRuleEntity.ReturnAmountPer = para.ReturnAmountPer;
                    vipCardRuleEntity.CustomerID      = loggingSessionInfo.ClientID;

                    if (para.VipCardTypeID == 0 || para.VipCardTypeID == null) //创建
                    {
                        sysVipCardTypeBLL.Create(sysVipCardTypeEntity, pTran);

                        vipCardRuleEntity.VipCardTypeID = sysVipCardTypeEntity.VipCardTypeID;
                        vipCardRuleBLL.Create(vipCardRuleEntity, pTran);
                    }
                    else //修改
                    {
                        sysVipCardTypeBLL.Update(sysVipCardTypeEntity, pTran);
                        vipCardRuleBLL.Update(vipCardRuleEntity, pTran);
                    }
                    pTran.Commit();  //提交事物
                    rd.VipCardTypeID = sysVipCardTypeEntity.VipCardTypeID;
                }
                catch (APIException apiEx)
                {
                    pTran.Rollback();//回滚事物
                    throw new APIException(apiEx.ErrorCode, apiEx.Message);
                }
                catch (Exception ex)
                {
                    pTran.Rollback();//回滚事物
                    throw new Exception(ex.Message);
                }
                return(rd);
            }
        }
예제 #15
0
        protected override GetVIPCardRD ProcessRequest(DTO.Base.APIRequest <GetVIPCardRP> pRequest)
        {
            GetVIPCardRD Data = new GetVIPCardRD();
            var          rd   = new GetVIPCardListRD();
            var          para = pRequest.Parameters;
            var          loggingSessionInfo = new SessionManager().CurrentUserLoginInfo;

            #region 业务对象
            //会员卡
            var VipCardBLL = new VipCardBLL(loggingSessionInfo);
            //会员
            var VipBLL = new VipBLL(loggingSessionInfo);
            //卡状态变更记录
            var VipCardStatusChangeLogBLL = new VipCardStatusChangeLogBLL(loggingSessionInfo);
            //卡与Vip关系
            var VipCardVipMappingBLL = new VipCardVipMappingBLL(loggingSessionInfo);
            //门店
            var unitBll = new t_unitBLL(loggingSessionInfo);
            //员工
            var UserBLL = new T_UserBLL(loggingSessionInfo);
            //卡类型
            var SysVipCardTypeBLL = new SysVipCardTypeBLL(loggingSessionInfo);
            //商户配置
            var CustomerBasicSettingBLL = new CustomerBasicSettingBLL(loggingSessionInfo);
            //积分
            var VipIntegralBLL = new VipIntegralBLL(loggingSessionInfo);
            #endregion



            #region 会员卡
            VipCardEntity resultData = null;
            if (!string.IsNullOrWhiteSpace(para.VipID))
            {
                //会员编号获取详情
                VipCardVipMappingEntity m_VipMappingData = VipCardVipMappingBLL.QueryByEntity(new VipCardVipMappingEntity()
                {
                    VIPID = para.VipID
                }, null).FirstOrDefault();
                if (m_VipMappingData != null && !string.IsNullOrWhiteSpace(m_VipMappingData.VipCardID))
                {
                    resultData = VipCardBLL.GetByID(para.VipCardID);
                }
            }
            else
            {
                if (!string.IsNullOrWhiteSpace(para.VipCardID))
                {
                    //卡ID获取详情
                    resultData = VipCardBLL.GetByID(para.VipCardID);
                }
                else
                {
                    //刷卡获取详情
                    List <IWhereCondition> complexCondition = new List <IWhereCondition> {
                    };
                    if (!string.IsNullOrEmpty(para.VipCardISN))
                    {
                        complexCondition.Add(new DirectCondition("VipCardCode='" + para.VipCardISN + "' or VipCardISN='" + para.VipCardISN.ToString() + "' "));
                    }
                    resultData = VipCardBLL.Query(complexCondition.ToArray(), null).FirstOrDefault();
                }
            }

            //try
            //{
            //    if (resultData == null)
            //        throw new APIException("该卡不存在!") { ErrorCode = ERROR_CODES.INVALID_BUSINESS };
            //}
            //catch (APIException apiEx)
            //{
            //    throw new APIException(apiEx.ErrorCode, apiEx.Message);
            //}
            #endregion

            #region 卡关系
            VipCardVipMappingEntity VipCardVipMappingData = null;
            if (resultData != null)
            {
                VipCardVipMappingData = VipCardVipMappingBLL.QueryByEntity(new VipCardVipMappingEntity()
                {
                    VipCardID = resultData.VipCardID
                }, null).FirstOrDefault();
            }
            //else
            //{
            //    return Data;
            //}
            #endregion

            #region 门店
            t_unitEntity unidData = null;
            if (resultData != null && !string.IsNullOrWhiteSpace(resultData.MembershipUnit))
            {
                unidData = unitBll.GetByID(resultData.MembershipUnit);
            }
            #endregion

            #region 会员,积分

            VipEntity         VipData      = null;
            VipIntegralEntity IntegralData = null;
            //string VIPID = VipCardVipMappingData == null ? "" : VipCardVipMappingData.VIPID;
            string VIPID = para.VipID;
            if (!string.IsNullOrWhiteSpace(VIPID))
            {
                VipData = VipBLL.NewGetByID(VIPID);
                //IntegralData = VipIntegralBLL.GetByID(VIPID);
                IntegralData = VipIntegralBLL.QueryByEntity(new VipIntegralEntity()
                {
                    VipID = VipData.VIPID, VipCardCode = VipData.VipCode
                }, null).FirstOrDefault();
            }
            #endregion

            #region 员工
            T_UserEntity UserData = null;
            if (resultData != null && !string.IsNullOrWhiteSpace(resultData.CreateBy))
            {
                UserData = UserBLL.GetByID(resultData.CreateBy);
            }
            #endregion

            #region 响应对象赋值
            if (resultData != null)
            {
                //卡
                Data.VipCardID      = resultData.VipCardID;
                Data.VipCardCode    = resultData.VipCardCode;
                Data.VipCardISN     = resultData.VipCardISN;
                Data.CraeteUserName = UserData == null ? "" : UserData.user_name;

                Data.VipCardStatusId    = resultData.VipCardStatusId.Value;
                Data.MembershipTime     = resultData.MembershipTime == null ? "" : resultData.MembershipTime.Value.ToString("yyyy-MM-dd");
                Data.MembershipUnitName = unidData == null ? "" : unidData.unit_name;
                //Data.TotalAmount = resultData.RechargeTotalAmount == null ? 0 : resultData.RechargeTotalAmount.Value;
                //Data.BalanceAmount = resultData.BalanceAmount == null ? 0 : resultData.BalanceAmount.Value;
                Data.BeginDate     = resultData.BeginDate;
                Data.EndDate       = "永久有效";
                Data.SalesUserName = resultData.SalesUserName == null ? "" : resultData.SalesUserName;
                #region 卡类型名称
                SysVipCardTypeEntity SysVipCardTypeData = SysVipCardTypeBLL.GetByID(resultData.VipCardTypeID);
                Data.VipCardName = SysVipCardTypeData == null ? "" : SysVipCardTypeData.VipCardTypeName;
                #endregion

                #region 状态变更记录列表

                var VipCardStatusChangeLogArray = VipCardStatusChangeLogBLL.Query
                                                      (new IWhereCondition[] { new EqualsCondition()
                                                                               {
                                                                                   FieldName = "VipCardID", Value = resultData.VipCardID
                                                                               } },
                                                      new OrderBy[] { new OrderBy()
                                                                      {
                                                                          FieldName = "CreateTime", Direction = OrderByDirections.Desc
                                                                      } }).ToList();
                //转换业务对象
                Data.StatusLogList = (from t in VipCardStatusChangeLogArray
                                      select new VipCardStatusChangeLog()
                {
                    CreateTime = t.CreateTime.Value.ToString("yyyy-MM-dd"),
                    UnitName = t.UnitName == null ? "" : t.UnitName,
                    Action = t.Action == null ? "" : t.Action,
                    ChangeReason = t.Reason == null ? "" : t.Reason,
                    Remark = t.Remark == null ? "" : t.Remark,
                    CreateBy = t.CreateByName,
                    ImageUrl = t.PicUrl == null ? "" : t.PicUrl
                }).ToList();
                #endregion
            }
            #region 会员
            if (VipData != null)
            {
                Data.VipID   = VipData.VIPID;
                Data.VipCode = VipData.VipCode;
                if (Data.VipCardCode == null)
                {
                    Data.VipCardCode = VipData.VipCode;
                }
                if (!string.IsNullOrWhiteSpace(VipData.VipRealName))
                {
                    Data.VipName = VipData.VipRealName;
                }
                else
                {
                    Data.VipName = VipData.VipName ?? "";
                }
                Data.Phone    = VipData.Phone;
                Data.Birthday = VipData.Birthday == null ? "" : VipData.Birthday;
                Data.Gender   = VipData.Gender ?? 0;
                //Data.Integration = VipData.Integration == null ? 0 : VipData.Integration.Value;
                //会员创建人姓名
                T_UserEntity VipUserData = null;
                if (resultData != null && !string.IsNullOrWhiteSpace(resultData.CreateBy))
                {
                    VipUserData = UserBLL.GetByID(resultData.CreateBy);
                }
                Data.VipCreateByName = VipUserData == null ? "" : VipUserData.user_name;
                Data.IDNumber        = VipData.IDNumber == null ? "" : VipData.IDNumber;

                #region 会员生日是否可修改字段赋值
                //Col22 字段赋值
                ////CustomerBasicSettingEntity SettingData = CustomerBasicSettingBLL.QueryByEntity(new CustomerBasicSettingEntity() { SettingCode = "FSR_NotTwoUpdateVipBirthday" }, null).FirstOrDefault();
                ////if (SettingData != null)
                Data.Col22 = VipData.Col22 == null ? "Y" : VipData.Col22;
                #endregion
            }
            #endregion

            #region 积分
            if (IntegralData != null)
            {
                Data.Integration        = IntegralData.ValidIntegral != null ? IntegralData.ValidIntegral.Value : 0;
                Data.CumulativeIntegral = IntegralData.CumulativeIntegral != null ? IntegralData.CumulativeIntegral.Value : 0;
            }
            #endregion

            #region 余额和返现
            var vipAmountBLL  = new VipAmountBLL(loggingSessionInfo);
            var vipAmountInfo = vipAmountBLL.QueryByEntity(new VipAmountEntity()
            {
                VipId = VipData.VIPID, VipCardCode = VipData.VipCode
            }, null).FirstOrDefault();
            if (vipAmountInfo != null)
            {
                Data.TotalAmount       = vipAmountInfo.TotalAmount == null ? 0 : vipAmountInfo.TotalAmount.Value;
                Data.BalanceAmount     = vipAmountInfo.EndAmount == null ? 0 : vipAmountInfo.EndAmount.Value;
                Data.ValidReturnAmount = vipAmountInfo.ValidReturnAmount == null ? 0 : vipAmountInfo.ValidReturnAmount.Value;
                Data.TotalReturnAmount = vipAmountInfo.TotalReturnAmount == null ? 0 : vipAmountInfo.TotalReturnAmount.Value;
            }
            #endregion


            #endregion
            return(Data);
        }
예제 #16
0
 /// <summary>
 /// 创建一个新实例
 /// </summary>
 /// <param name="pEntity">实体实例</param>
 public void Create(SysVipCardTypeEntity pEntity)
 {
     _currentDAO.Create(pEntity);
 }
예제 #17
0
 public void Update(SysVipCardTypeEntity dbEntity)
 {
     _cmd.Update(dbEntity);
 }
예제 #18
0
 /// <summary>
 /// 更新
 /// </summary>
 /// <param name="pEntity">实体实例</param>
 /// <param name="pTran">事务实例,可为null,如果为null,则不使用事务来更新</param>
 public void Update(SysVipCardTypeEntity pEntity, IDbTransaction pTran)
 {
     _currentDAO.Update(pEntity, pTran);
 }
예제 #19
0
 public void Create(SysVipCardTypeEntity dbEntity)
 {
     _cmd.Create(dbEntity);
 }
예제 #20
0
        protected override EmptyResponseData ProcessRequest(DTO.Base.APIRequest <SetVipCardTypeSystemRP> pRequest)
        {
            var rd   = new EmptyResponseData();
            var para = pRequest.Parameters;
            var loggingSessionInfo = new SessionManager().CurrentUserLoginInfo;
            //卡相关逻辑
            var bllVipCardType = new SysVipCardTypeBLL(loggingSessionInfo);

            //升级规则逻辑
            var bllVipCardUpgradeRule = new VipCardUpgradeRuleBLL(loggingSessionInfo);

            //基本权益逻辑
            var bllVipCardRule = new VipCardRuleBLL(loggingSessionInfo);

            //开卡礼逻辑
            var bllVipCardUpgradeReward = new VipCardUpgradeRewardBLL(loggingSessionInfo);
            //卡分润规则
            var bllVipCardProfitRule = new VipCardProfitRuleBLL(loggingSessionInfo);
            //续费充值方式
            var VipCardReRechargeProfitRuleService = new VipCardReRechargeProfitRuleBLL(loggingSessionInfo);

            string _CustomerId = loggingSessionInfo.ClientID;

            if (para.VipCardRelateList.Count > 0)
            {
                try
                {
                    foreach (var VipCardSystem in para.VipCardRelateList)
                    {
                        //获取当前会员信息
                        //List<IWhereCondition> wheres = new List<IWhereCondition>();
                        //wheres.Add(new EqualsCondition() { FieldName = "Category", Value = 0 });
                        //wheres.Add(new EqualsCondition() { FieldName = "CustomerID", Value = loggingSessionInfo.ClientID });
                        //wheres.Add(new EqualsCondition() { FieldName = "VipCardTypeName", Value = VipCardSystem.VipCardType.VipCardTypeName });
                        //wheres.Add(new DirectCondition("VipCardLevel!='" + VipCardSystem.VipCardType.VipCardLevel + "'"));
                        //var ExistVipCardTypeResult = bllVipCardType.Query(wheres.ToArray(), null).FirstOrDefault();
                        //if (ExistVipCardTypeResult != null)
                        //{
                        //    throw new APIException("会员卡名称不能重复!") { ErrorCode = ERROR_CODES.INVALID_BUSINESS };
                        //}
                        //获取当前待添加的卡等级数据
                        var VipCardTypeResult = bllVipCardType.QueryByEntity(new SysVipCardTypeEntity()
                        {
                            Category = 0, VipCardLevel = VipCardSystem.VipCardType.VipCardLevel, CustomerID = loggingSessionInfo.ClientID
                        }, null).FirstOrDefault();

                        if (VipCardTypeResult != null)
                        {
                            #region 编辑会员卡等级信息
                            //throw new APIException("卡等级不能重复!") { ErrorCode = ERROR_CODES.INVALID_BUSINESS };
                            //如果存在数据需要进行修改
                            VipCardTypeResult.VipCardTypeName = VipCardSystem.VipCardType.VipCardTypeName;
                            VipCardTypeResult.VipCardLevel    = VipCardSystem.VipCardType.VipCardLevel;
                            if (VipCardTypeResult.VipCardLevel == 1)//如果等级为1默认可充值
                            {
                                VipCardTypeResult.Isprepaid = 1;
                            }
                            else
                            {
                                VipCardTypeResult.Isprepaid = VipCardSystem.VipCardType.IsPrepaid;
                            }
                            VipCardTypeResult.IsOnlineSales = VipCardSystem.VipCardType.IsOnlineSales;
                            //如果IsOnlineSales为0则需要逻辑删除分润规则数据
                            if (VipCardTypeResult.IsOnlineSales == 0)
                            {
                                var VipCardProfitRuleInfo = bllVipCardProfitRule.QueryByEntity(new VipCardProfitRuleEntity()
                                {
                                    VipCardTypeID = VipCardTypeResult.VipCardTypeID, CustomerID = loggingSessionInfo.ClientID
                                }, null);
                                if (VipCardProfitRuleInfo.Length > 0)
                                {
                                    bllVipCardProfitRule.Delete(VipCardProfitRuleInfo);
                                }
                            }
                            VipCardTypeResult.PicUrl = VipCardSystem.VipCardType.PicUrl;
                            if (VipCardSystem.VipCardUpgradeRule != null)
                            {
                                if (VipCardSystem.VipCardUpgradeRule.IsPurchaseUpgrade == 1)
                                {
                                    VipCardTypeResult.Prices           = VipCardSystem.VipCardUpgradeRule.Prices;
                                    VipCardTypeResult.ExchangeIntegral = VipCardSystem.VipCardUpgradeRule.ExchangeIntegral;
                                    VipCardTypeResult.IsExtraMoney     = VipCardSystem.VipCardUpgradeRule.IsExtraMoney;
                                }
                                else
                                {
                                    VipCardTypeResult.Prices           = 0;
                                    VipCardTypeResult.ExchangeIntegral = 0;
                                    VipCardTypeResult.IsExtraMoney     = 2;
                                }
                            }
                            else
                            {
                                VipCardTypeResult.Prices           = 0;
                                VipCardTypeResult.ExchangeIntegral = 0;
                                VipCardTypeResult.IsExtraMoney     = 2;
                            }
                            //要先生成卡等级数据  不然取不到VipCardTypeID
                            if (VipCardSystem.VipCardType.VipCardLevel != 0)
                            {
                                bllVipCardType.Update(VipCardTypeResult);
                                //修改虚拟商品
#warning 商品代码注释 Bear
                                ItemService _ItemService = new ItemService(loggingSessionInfo);
                                _ItemService.SaveCardToOffenTItem(loggingSessionInfo, VipCardTypeResult);

                                try
                                {
                                    var msg = new EventContract
                                    {
                                        Operation  = OptEnum.Update,
                                        EntityType = EntityTypeEnum.VipCardType,
                                        Id         = VipCardTypeResult.VipCardTypeID.ToString()
                                    };
                                    var eventService = new EventService();
                                    eventService.PublishMsg(msg);
                                }
                                catch (Exception)
                                {
                                    throw new Exception("RabbitMQ Error");
                                }
                            }

                            #endregion
                            #region 编辑卡升级规则信息
                            //编辑卡升级规则
                            if (VipCardSystem.VipCardType.VipCardLevel != 1)
                            {
                                VipCardUpgradeRuleEntity vipCardUpgradeRuleEntity = new VipCardUpgradeRuleEntity();
                                var entityVipCardUpgradeRule = bllVipCardUpgradeRule.QueryByEntity(new VipCardUpgradeRuleEntity()
                                {
                                    CustomerID = loggingSessionInfo.ClientID, VipCardTypeID = VipCardTypeResult.VipCardTypeID
                                }, null).FirstOrDefault();
                                //entityVipCardUpgradeRule.VipCardUpgradeRuleId = System.Guid.NewGuid();
                                if (entityVipCardUpgradeRule != null)
                                {
                                    if (VipCardTypeResult.Isprepaid == 0) //不可充值
                                    {
                                        //将所有梯度信息 逻辑删除
                                        string[] ProfitRuleIds = bllVipCardProfitRule.GetRechargeProfitRuleByIsPrepaid(loggingSessionInfo.ClientID, VipCardTypeResult.VipCardTypeID);
                                        if (ProfitRuleIds.Length > 0)
                                        {
                                            VipCardReRechargeProfitRuleService.Delete(ProfitRuleIds);
                                        }
                                    }

                                    if (VipCardTypeResult != null && VipCardTypeResult.VipCardTypeID != null)
                                    {
                                        entityVipCardUpgradeRule.VipCardTypeID = VipCardTypeResult.VipCardTypeID;
                                    }
                                    //是否购卡升级
                                    if (VipCardSystem.VipCardUpgradeRule != null)
                                    {
                                        if (VipCardSystem.VipCardUpgradeRule.IsPurchaseUpgrade == 1)
                                        {
                                            entityVipCardUpgradeRule.IsPurchaseUpgrade = 1;
                                        }
                                        else
                                        {
                                            entityVipCardUpgradeRule.IsPurchaseUpgrade = 0;
                                        }
                                        //是否充值升级
                                        if (VipCardSystem.VipCardUpgradeRule.IsRecharge == 1)
                                        {
                                            entityVipCardUpgradeRule.IsRecharge         = 1;
                                            entityVipCardUpgradeRule.OnceRechargeAmount = VipCardSystem.VipCardUpgradeRule.OnceRechargeAmount;
                                        }
                                        else
                                        {
                                            entityVipCardUpgradeRule.IsRecharge         = 0;
                                            entityVipCardUpgradeRule.OnceRechargeAmount = 0;
                                        }
                                        //是否消费升级
                                        if (VipCardSystem.VipCardUpgradeRule.IsBuyUpgrade == 1)
                                        {
                                            entityVipCardUpgradeRule.IsBuyUpgrade  = 1;
                                            entityVipCardUpgradeRule.BuyAmount     = VipCardSystem.VipCardUpgradeRule.BuyAmount;
                                            entityVipCardUpgradeRule.OnceBuyAmount = VipCardSystem.VipCardUpgradeRule.OnceBuyAmount;
                                        }
                                        else
                                        {
                                            entityVipCardUpgradeRule.IsBuyUpgrade  = 0;
                                            entityVipCardUpgradeRule.BuyAmount     = 0;
                                            entityVipCardUpgradeRule.OnceBuyAmount = 0;
                                        }
                                    }
                                    else
                                    {
                                        throw new APIException("升级条件不能为空!")
                                              {
                                                  ErrorCode = ERROR_CODES.INVALID_BUSINESS
                                              };
                                    }
                                    entityVipCardUpgradeRule.CustomerID = loggingSessionInfo.ClientID;
                                }
                                else
                                {
                                    if (VipCardTypeResult != null && VipCardTypeResult.VipCardTypeID != null)
                                    {
                                        vipCardUpgradeRuleEntity.VipCardTypeID = VipCardTypeResult.VipCardTypeID;
                                    }
                                    //是否购卡升级
                                    if (VipCardSystem.VipCardUpgradeRule != null)
                                    {
                                        if (VipCardSystem.VipCardUpgradeRule.IsPurchaseUpgrade == 1)
                                        {
                                            vipCardUpgradeRuleEntity.IsPurchaseUpgrade = 1;
                                        }
                                        else
                                        {
                                            vipCardUpgradeRuleEntity.IsPurchaseUpgrade = 0;
                                        }
                                        //是否充值升级
                                        if (VipCardSystem.VipCardUpgradeRule.IsRecharge == 1)
                                        {
                                            vipCardUpgradeRuleEntity.IsRecharge         = 1;
                                            vipCardUpgradeRuleEntity.OnceRechargeAmount = VipCardSystem.VipCardUpgradeRule.OnceRechargeAmount;
                                        }
                                        else
                                        {
                                            vipCardUpgradeRuleEntity.IsRecharge         = 0;
                                            vipCardUpgradeRuleEntity.OnceRechargeAmount = 0;
                                        }
                                        //是否消费升级
                                        if (VipCardSystem.VipCardUpgradeRule.IsBuyUpgrade == 1)
                                        {
                                            vipCardUpgradeRuleEntity.IsBuyUpgrade  = 1;
                                            vipCardUpgradeRuleEntity.BuyAmount     = VipCardSystem.VipCardUpgradeRule.BuyAmount;
                                            vipCardUpgradeRuleEntity.OnceBuyAmount = VipCardSystem.VipCardUpgradeRule.OnceBuyAmount;
                                        }
                                        else
                                        {
                                            vipCardUpgradeRuleEntity.IsBuyUpgrade  = 0;
                                            vipCardUpgradeRuleEntity.BuyAmount     = 0;
                                            vipCardUpgradeRuleEntity.OnceBuyAmount = 0;
                                        }
                                    }
                                    else
                                    {
                                        throw new APIException("升级条件不能为空!")
                                              {
                                                  ErrorCode = ERROR_CODES.INVALID_BUSINESS
                                              };
                                    }
                                    vipCardUpgradeRuleEntity.CustomerID = loggingSessionInfo.ClientID;
                                }

                                //将卡升级规则进行入库
                                if (entityVipCardUpgradeRule != null)
                                {
                                    bllVipCardUpgradeRule.Update(entityVipCardUpgradeRule);
                                }
                                else
                                {
                                    vipCardUpgradeRuleEntity.VipCardUpgradeRuleId = Guid.NewGuid();
                                    bllVipCardUpgradeRule.Create(vipCardUpgradeRuleEntity);
                                }
                            }
                            #endregion
                            #region 编辑基本权益信息
                            //基本权益实体
                            var VipCardRuleInfo = bllVipCardRule.QueryByEntity(new VipCardRuleEntity()
                            {
                                VipCardTypeID = VipCardTypeResult.VipCardTypeID, CustomerID = loggingSessionInfo.ClientID
                            }, null).FirstOrDefault();
                            if (VipCardRuleInfo != null)
                            {
                                if (VipCardSystem.VipCardRule != null)
                                {
                                    VipCardRuleInfo.CardDiscount         = VipCardSystem.VipCardRule.CardDiscount * 10;//因为给的是整数 目前折扣这里乘10
                                    VipCardRuleInfo.PaidGivePoints       = VipCardSystem.VipCardRule.PaidGivePoints;
                                    VipCardRuleInfo.PaidGivePercetPoints = VipCardSystem.VipCardRule.PaidGivePercetPoints;
                                }
                                else
                                {
                                    VipCardRuleInfo.CardDiscount         = 0;//因为给的是整数 目前折扣这里乘10
                                    VipCardRuleInfo.PaidGivePoints       = 0;
                                    VipCardRuleInfo.PaidGivePercetPoints = 0;
                                }
                                //将基本权益数据进行入库
                                bllVipCardRule.Update(VipCardRuleInfo);
                            }
                            else
                            {
                                var vipCardRuleEntity = new VipCardRuleEntity();
                                vipCardRuleEntity.VipCardTypeID        = VipCardTypeResult.VipCardTypeID;
                                vipCardRuleEntity.CardDiscount         = VipCardSystem.VipCardRule.CardDiscount * 10;//因为给的是整数 目前折扣这里乘10
                                vipCardRuleEntity.PaidGivePoints       = VipCardSystem.VipCardRule.PaidGivePoints;
                                vipCardRuleEntity.PaidGivePercetPoints = VipCardSystem.VipCardRule.PaidGivePercetPoints;
                                vipCardRuleEntity.CustomerID           = loggingSessionInfo.ClientID;
                                bllVipCardRule.Create(vipCardRuleEntity);
                            }



                            #endregion
                            #region 编辑开卡礼信息
                            if (VipCardSystem.VipCardUpgradeRewardList != null)
                            {
                                //开卡礼处理
                                foreach (var Rewards in VipCardSystem.VipCardUpgradeRewardList)
                                {
                                    var entityVipCardUpgradeReward = new VipCardUpgradeRewardEntity();
                                    if (VipCardTypeResult != null && VipCardTypeResult.VipCardTypeID != null)
                                    {
                                        entityVipCardUpgradeReward.VipCardTypeID = VipCardTypeResult.VipCardTypeID;
                                    }
                                    entityVipCardUpgradeReward.CouponTypeId = new Guid(Rewards.CouponTypeID);
                                    entityVipCardUpgradeReward.CouponNum    = Rewards.CouponNum;
                                    entityVipCardUpgradeReward.CustomerID   = loggingSessionInfo.ClientID;
                                    if (!string.IsNullOrEmpty(Rewards.CardUpgradeRewardId))
                                    {
                                        entityVipCardUpgradeReward.CardUpgradeRewardId = new Guid(Rewards.CardUpgradeRewardId);
                                    }
                                    switch (Rewards.OperateType) //判断此处为何种操作(0=删除券;1=新增;2=修改;)
                                    {
                                    case 0:                      //删除券
                                        bllVipCardUpgradeReward.Delete(entityVipCardUpgradeReward);
                                        break;

                                    case 1:    //新增券
                                        var existVipCardUpgradeReward = bllVipCardUpgradeReward.QueryByEntity(new VipCardUpgradeRewardEntity()
                                        {
                                            CustomerID = loggingSessionInfo.ClientID, VipCardTypeID = VipCardTypeResult.VipCardTypeID, CouponTypeId = new Guid(Rewards.CouponTypeID)
                                        }, null).FirstOrDefault();
                                        if (existVipCardUpgradeReward != null)
                                        {
                                            existVipCardUpgradeReward.CouponTypeId = new Guid(Rewards.CouponTypeID);
                                            existVipCardUpgradeReward.CouponNum    = Rewards.CouponNum;
                                            existVipCardUpgradeReward.CustomerID   = loggingSessionInfo.ClientID;
                                            bllVipCardUpgradeReward.Update(existVipCardUpgradeReward);
                                        }
                                        else
                                        {
                                            entityVipCardUpgradeReward.CardUpgradeRewardId = Guid.NewGuid();
                                            bllVipCardUpgradeReward.Create(entityVipCardUpgradeReward);
                                        }
                                        break;

                                    case 2:    //修改
                                        bllVipCardUpgradeReward.Update(entityVipCardUpgradeReward);
                                        break;
                                    }
                                }
                            }
                            #endregion
                        }
                        else
                        {
                            #region 添加会员卡等级信息
                            //如果卡等级不重复则添加卡等级数据
                            var entityVipCardType = new SysVipCardTypeEntity();
                            entityVipCardType.Category        = 0;
                            entityVipCardType.VipCardTypeName = VipCardSystem.VipCardType.VipCardTypeName;
                            entityVipCardType.VipCardLevel    = VipCardSystem.VipCardType.VipCardLevel;
                            entityVipCardType.IsPassword      = 0;
                            if (entityVipCardType.VipCardLevel == 1)//如果等级为1默认可充值
                            {
                                entityVipCardType.Isprepaid = 1;
                            }
                            else
                            {
                                entityVipCardType.Isprepaid = VipCardSystem.VipCardType.IsPrepaid;
                            }
                            entityVipCardType.IsOnlineSales = VipCardSystem.VipCardType.IsOnlineSales;
                            entityVipCardType.PicUrl        = VipCardSystem.VipCardType.PicUrl;
                            entityVipCardType.CustomerID    = loggingSessionInfo.ClientID;
                            if (VipCardSystem.VipCardUpgradeRule != null)
                            {
                                if (VipCardSystem.VipCardUpgradeRule.IsPurchaseUpgrade == 1)
                                {
                                    entityVipCardType.Prices           = VipCardSystem.VipCardUpgradeRule.Prices;
                                    entityVipCardType.ExchangeIntegral = VipCardSystem.VipCardUpgradeRule.ExchangeIntegral;
                                    entityVipCardType.IsExtraMoney     = VipCardSystem.VipCardUpgradeRule.IsExtraMoney;
                                }
                                else
                                {
                                    entityVipCardType.Prices           = 0;
                                    entityVipCardType.ExchangeIntegral = 0;
                                    entityVipCardType.IsExtraMoney     = 2;
                                }
                            }
                            else
                            {
                                entityVipCardType.Prices           = 0;
                                entityVipCardType.ExchangeIntegral = 0;
                                entityVipCardType.IsExtraMoney     = 2;
                            }
                            var existVipCardType = bllVipCardType.QueryByEntity(new SysVipCardTypeEntity()
                            {
                                Category = 0, VipCardLevel = VipCardSystem.VipCardType.VipCardLevel, CustomerID = loggingSessionInfo.ClientID
                            }, null).FirstOrDefault();
                            if (existVipCardType == null)
                            {
                                //要先生成卡等级数据  不然取不到VipCardTypeID
                                if (VipCardSystem.VipCardType.VipCardLevel != 0 && VipCardSystem.VipCardType.VipCardLevel < 8)
                                {
                                    bllVipCardType.Create(entityVipCardType);
                                    //添加虚拟商品
#warning 商品代码注释 Bear
                                    ItemService _ItemService = new ItemService(loggingSessionInfo);
                                    _ItemService.SaveCardToOffenTItem(loggingSessionInfo, entityVipCardType);

                                    var tmp =
                                        bllVipCardType.QueryByEntity(
                                            new SysVipCardTypeEntity()
                                    {
                                        Category     = 0,
                                        VipCardLevel = entityVipCardType.VipCardLevel,
                                        CustomerID   = loggingSessionInfo.ClientID
                                    }, null).FirstOrDefault();


                                    try
                                    {
                                        var msg = new EventContract
                                        {
                                            Operation  = OptEnum.Create,
                                            EntityType = EntityTypeEnum.VipCardType,
                                            Id         = tmp.VipCardTypeID.ToString()
                                        };
                                        var eventService = new EventService();
                                        eventService.PublishMsg(msg);
                                    }
                                    catch (Exception)
                                    {
                                        throw new Exception("RabbitMQ Error");
                                    }
                                }
                                else
                                {
                                    throw new APIException("等级不能超过七级!")
                                          {
                                              ErrorCode = ERROR_CODES.INVALID_BUSINESS
                                          };
                                }
                            }
                            //else
                            //{
                            //    throw new APIException("会员卡名称不能重复!") { ErrorCode = ERROR_CODES.INVALID_BUSINESS };
                            //}

                            #endregion
                            //因为卡等级不能重复  所以这里根据卡等级获取VipCardTypeID的信息
                            var vipCardTypeInfo = bllVipCardType.QueryByEntity(new SysVipCardTypeEntity()
                            {
                                Category = 0, VipCardLevel = VipCardSystem.VipCardType.VipCardLevel, CustomerID = loggingSessionInfo.ClientID
                            }, null).FirstOrDefault();
                            //因为注册表单暂时没用上 如果卡等级不等于1时 就有升级条件数据存进去
                            if (VipCardSystem.VipCardType.VipCardLevel != 0)
                            {
                                #region 添加卡升级规则信息
                                if (VipCardSystem.VipCardType.VipCardLevel != 1)
                                {
                                    var entityVipCardUpgradeRule = new VipCardUpgradeRuleEntity();
                                    entityVipCardUpgradeRule.VipCardUpgradeRuleId = System.Guid.NewGuid();
                                    if (vipCardTypeInfo != null && vipCardTypeInfo.VipCardTypeID != null)
                                    {
                                        entityVipCardUpgradeRule.VipCardTypeID = vipCardTypeInfo.VipCardTypeID;
                                    }
                                    //是否购卡升级
                                    if (VipCardSystem.VipCardUpgradeRule != null)
                                    {
                                        if (VipCardSystem.VipCardUpgradeRule.IsPurchaseUpgrade == 1)
                                        {
                                            entityVipCardUpgradeRule.IsPurchaseUpgrade = 1;
                                        }
                                        else
                                        {
                                            entityVipCardUpgradeRule.IsPurchaseUpgrade  = 0;
                                            entityVipCardUpgradeRule.OnceRechargeAmount = 0;
                                        }
                                        //是否充值升级
                                        if (VipCardSystem.VipCardUpgradeRule.IsRecharge == 1)
                                        {
                                            entityVipCardUpgradeRule.IsRecharge         = 1;
                                            entityVipCardUpgradeRule.OnceRechargeAmount = VipCardSystem.VipCardUpgradeRule.OnceRechargeAmount;
                                        }
                                        else
                                        {
                                            entityVipCardUpgradeRule.IsRecharge         = 0;
                                            entityVipCardUpgradeRule.OnceRechargeAmount = 0;
                                        }
                                        //是否消费升级
                                        if (VipCardSystem.VipCardUpgradeRule.IsBuyUpgrade == 1)
                                        {
                                            entityVipCardUpgradeRule.IsBuyUpgrade  = 1;
                                            entityVipCardUpgradeRule.BuyAmount     = VipCardSystem.VipCardUpgradeRule.BuyAmount;
                                            entityVipCardUpgradeRule.OnceBuyAmount = VipCardSystem.VipCardUpgradeRule.OnceBuyAmount;
                                        }
                                        else
                                        {
                                            entityVipCardUpgradeRule.IsBuyUpgrade  = 0;
                                            entityVipCardUpgradeRule.BuyAmount     = 0;
                                            entityVipCardUpgradeRule.OnceBuyAmount = 0;
                                        }
                                    }
                                    else
                                    {
                                        throw new APIException("升级条件不能为空!")
                                              {
                                                  ErrorCode = ERROR_CODES.INVALID_BUSINESS
                                              };
                                    }
                                    entityVipCardUpgradeRule.CustomerID = loggingSessionInfo.ClientID;
                                    //将卡升级规则进行入库
                                    bllVipCardUpgradeRule.Create(entityVipCardUpgradeRule);
                                }
                                #endregion
                                #region 添加基本权益实体
                                //基本权益实体
                                var entityVipCardRule = new VipCardRuleEntity();
                                if (vipCardTypeInfo != null && vipCardTypeInfo.VipCardTypeID != null)
                                {
                                    entityVipCardRule.VipCardTypeID = vipCardTypeInfo.VipCardTypeID;
                                }
                                if (VipCardSystem.VipCardRule != null)
                                {
                                    entityVipCardRule.CardDiscount         = VipCardSystem.VipCardRule.CardDiscount * 10;//因为给的是整数 目前折扣这里乘10
                                    entityVipCardRule.PaidGivePoints       = VipCardSystem.VipCardRule.PaidGivePoints;
                                    entityVipCardRule.PaidGivePercetPoints = VipCardSystem.VipCardRule.PaidGivePercetPoints;
                                }
                                else
                                {
                                    entityVipCardRule.CardDiscount         = 0;//因为给的是整数 目前折扣这里乘10
                                    entityVipCardRule.PaidGivePoints       = 0;
                                    entityVipCardRule.PaidGivePercetPoints = 0;
                                }
                                entityVipCardRule.CustomerID = loggingSessionInfo.ClientID;
                                //将基本权益数据进行入库
                                bllVipCardRule.Create(entityVipCardRule);
                                #endregion
                                #region 添加开卡礼信息
                                if (VipCardSystem.VipCardUpgradeRewardList != null)
                                {
                                    //开卡礼处理
                                    foreach (var Rewards in VipCardSystem.VipCardUpgradeRewardList)
                                    {
                                        var entityVipCardUpgradeReward = new VipCardUpgradeRewardEntity();
                                        entityVipCardUpgradeReward.CardUpgradeRewardId = Guid.NewGuid();
                                        if (vipCardTypeInfo != null && vipCardTypeInfo.VipCardTypeID != null)
                                        {
                                            entityVipCardUpgradeReward.VipCardTypeID = vipCardTypeInfo.VipCardTypeID;
                                        }
                                        entityVipCardUpgradeReward.CouponTypeId = new Guid(Rewards.CouponTypeID);
                                        entityVipCardUpgradeReward.CouponNum    = Rewards.CouponNum;
                                        entityVipCardUpgradeReward.CustomerID   = loggingSessionInfo.ClientID;
                                        var existVipCardUpgradeReward = bllVipCardUpgradeReward.QueryByEntity(new VipCardUpgradeRewardEntity()
                                        {
                                            CustomerID = loggingSessionInfo.ClientID, VipCardTypeID = vipCardTypeInfo.VipCardTypeID, CouponTypeId = new Guid(Rewards.CouponTypeID)
                                        }, null).FirstOrDefault();
                                        if (existVipCardUpgradeReward != null)
                                        {
                                            existVipCardUpgradeReward.CouponTypeId = new Guid(Rewards.CouponTypeID);
                                            existVipCardUpgradeReward.CouponNum    = Rewards.CouponNum;
                                            existVipCardUpgradeReward.CustomerID   = loggingSessionInfo.ClientID;
                                            bllVipCardUpgradeReward.Update(existVipCardUpgradeReward);
                                        }
                                        else
                                        {
                                            bllVipCardUpgradeReward.Create(entityVipCardUpgradeReward);
                                        }
                                    }
                                }
                                #endregion
                            }
                        }
                    }
                }
                catch (APIException ex)
                {
                    //pTran.Rollback();
                    throw ex;
                }
            }
            return(rd);
        }