Ejemplo n.º 1
0
        public void Deal(EventContract msg)
        {
            var     bus = MqBusMgr.GetInstance();
            OptEnum operation;

            Enum.TryParse(msg.Operation.ToString(), out operation);
            operation = OptEnum.Create;
            var sysVipCardType = new SysVipCardTypeContract()
            {
                Operation     = operation,
                VipCardTypeID = Convert.ToInt32(msg.Id)
            };

            if (msg.Operation != Zmind.EventBus.Contract.OptEnum.Delete)
            {
                var sysVipCardTypeFacade = new SysVipCardTypeFacade();
                var result = sysVipCardTypeFacade.GetCardTypeIDByTypeId(sysVipCardType.VipCardTypeID);
                if (result == null)
                {
                    return;
                }
                sysVipCardType.VipCardTypeName = result.VipCardTypeName;
                sysVipCardType.VipCardLevel    = result.VipCardLevel.ToString();
            }
            bus.Publish <IZmindToXgx>(sysVipCardType);
        }
Ejemplo n.º 2
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);
        }
Ejemplo n.º 3
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;
            }
        }