Example #1
0
        protected override EmptyResponseData ProcessRequest(DTO.Base.APIRequest <DelSysVipCardTypeRP> pRequest)
        {
            var rd   = new EmptyResponseData();
            var para = pRequest.Parameters;
            var loggingSessionInfo = new SessionManager().CurrentUserLoginInfo;
            var sysVipCardTypeBLL  = new SysVipCardTypeBLL(loggingSessionInfo);
            var vipCardBLL         = new VipCardBLL(loggingSessionInfo);

            var vipCardTypeInfo = sysVipCardTypeBLL.GetByID(para.VipCardTypeID);

            if (vipCardTypeInfo != null)
            {
                var vipCardInfo = vipCardBLL.QueryByEntity(new VipCardEntity()
                {
                    VipCardTypeID = para.VipCardTypeID
                }, null).FirstOrDefault();
                if (vipCardInfo == null)
                {
                    sysVipCardTypeBLL.Delete(para.VipCardTypeID, null);
                }
                else
                {
                    throw new APIException("卡类型正在使用不可以删除!")
                          {
                              ErrorCode = ERROR_CODES.INVALID_BUSINESS
                          }
                };
            }
            return(rd);
        }
    }
Example #2
0
        protected override EmptyResponseData ProcessRequest(DTO.Base.APIRequest <SetSpecialDateRP> pRequest)
        {
            var rd   = new EmptyResponseData();
            var para = pRequest.Parameters;
            var loggingSessionInfo = new SessionManager().CurrentUserLoginInfo;
            var sysVipCardTypeBLL  = new SysVipCardTypeBLL(loggingSessionInfo);
            var specialDateBLL     = new SpecialDateBLL(loggingSessionInfo);

            var specialDateEntity = specialDateBLL.QueryByEntity(new SpecialDateEntity()
            {
                VipCardTypeID = para.VipCardTypeID, HolidayID = para.HolidayID
            }, null).FirstOrDefault();

            if (specialDateEntity != null)
            {
                throw new APIException("该卡类型已添加此特殊日期")
                      {
                          ErrorCode = ERROR_CODES.INVALID_BUSINESS
                      }
            }
            ;
            specialDateEntity = new SpecialDateEntity()
            {
                VipCardTypeID       = para.VipCardTypeID,
                HolidayID           = para.HolidayID,
                NoAvailablePoints   = para.NoAvailablePoints,   //不可用积分(0=不可用;1=可用)
                NoAvailableDiscount = para.NoAvailableDiscount, //不可用折扣(0=不可用;1=可用)
                NoRewardPoints      = para.NoRewardPoints,      //不可回馈积分(0=不可用;1=可用)
                CustomerID          = loggingSessionInfo.ClientID
            };
            specialDateBLL.Create(specialDateEntity);
            return(rd);
        }
    }
        protected override GetSysVipCardTypeListsRD ProcessRequest(DTO.Base.APIRequest <GetSysVipCardTypeListRP> pRequest)
        {
            var rd = new GetSysVipCardTypeListsRD();
            var loggingSessionInfo = new SessionManager().CurrentUserLoginInfo;
            var sysVipCardTypeBLL  = new SysVipCardTypeBLL(loggingSessionInfo);
            var parameter          = pRequest.Parameters;

            //查询参数
            List <IWhereCondition> complexCondition = new List <IWhereCondition> {
            };

            //商户条件
            complexCondition.Add(new EqualsCondition()
            {
                FieldName = "vct.CustomerID", Value = loggingSessionInfo.ClientID
            });
            complexCondition.Add(new EqualsCondition()
            {
                FieldName = "vct.Category", Value = parameter.Category
            });

            //排序参数
            List <OrderBy> lstOrder = new List <OrderBy> {
            };

            lstOrder.Add(new OrderBy()
            {
                FieldName = "vct.VipCardLevel", Direction = OrderByDirections.Desc
            });
            lstOrder.Add(new OrderBy()
            {
                FieldName = "vct.CreateTime", Direction = OrderByDirections.Desc
            });


            var tempList = sysVipCardTypeBLL.GetVipCardList(complexCondition.ToArray(), lstOrder.ToArray());

            rd.SysVipCardTypeList = tempList.Select(t => new SysVipCardTypeInfos()
            {
                VipCardTypeID   = t.VipCardTypeID.Value,
                VipCardTypeCode = t.VipCardTypeCode,
                VipCardTypeName = t.VipCardTypeName,
                CardDiscount    = t.CardDiscount,
                PointsMultiple  = t.PointsMultiple,
                ChargeFull      = t.ChargeFull,
                ChargeGive      = t.ChargeGive,
                Price           = t.Prices
            }).ToList();

            return(rd);
        }
        /// <summary>
        /// 新闻类型
        /// </summary>
        public string GetVipCardTypeData()
        {
            var server           = new SysVipCardTypeBLL(new SessionManager().CurrentUserLoginInfo);
            var vipCardTypeArray = server.Query(null, null);

            string content = string.Empty;

            var jsonData = new JsonData();

            jsonData.totalCount = vipCardTypeArray.Length.ToString();
            jsonData.data       = vipCardTypeArray;

            content = jsonData.ToJSON();
            return(content);
        }
Example #5
0
        protected override GetSysVipCardTypeListRD ProcessRequest(DTO.Base.APIRequest <GetSysVipCardTypeListRP> pRequest)
        {
            var rd                 = new GetSysVipCardTypeListRD();
            var parameter          = pRequest.Parameters;
            var loggingSessionInfo = new SessionManager().CurrentUserLoginInfo;
            SysVipCardTypeBLL bll  = new SysVipCardTypeBLL(loggingSessionInfo);
            var models             = DataTableToObject.ConvertToList <SysVipCardTypeInfo>(bll.GetVipCardTypeByIsprepaid(loggingSessionInfo.ClientID, parameter.IsOnLineSale).Tables[0]);

            var lst = models.Select(m => new SysVipCardTypeInfo()
            {
                IsPrepaid = m.IsPrepaid, VipCardTypeID = m.VipCardTypeID, VipCardTypeName = m.VipCardTypeName, IsBuyUpgrade = m.IsBuyUpgrade, IsPurchaseUpgrade = m.IsPurchaseUpgrade, IsRecharge = m.IsRecharge
            }).ToList();

            rd.SysVipCardTypeList = lst.ToList();
            return(rd);
        }
        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);
        }
        protected override GetVipCardTypeRD ProcessRequest(APIRequest <GetVipCardTypeRP> pRequest)
        {
            var rd   = new GetVipCardTypeRD();
            var para = pRequest.Parameters;
            LoggingSessionInfo loggingSessionInfo = Default.GetBSLoggingSession(pRequest.CustomerID, pRequest.UserID);
            //声明卡等级相关逻辑
            var    bllVipCardType         = new SysVipCardTypeBLL(loggingSessionInfo);
            var    bllVip                 = new VipBLL(loggingSessionInfo);
            string strPhone               = string.Empty;
            int?   CurVipLevel            = 0;
            List <IWhereCondition> wheres = new List <IWhereCondition>();

            wheres.Add(new EqualsCondition()
            {
                FieldName = "clientid", Value = pRequest.CustomerID
            });
            wheres.Add(new EqualsCondition()
            {
                FieldName = "VipID", Value = pRequest.UserID
            });
            wheres.Add(new EqualsCondition()
            {
                FieldName = "Status", Value = 2
            });
            //wheres.Add(new DirectCondition("Phone!=''"));
            var vipInfo = bllVip.Query(wheres.ToArray(), null).FirstOrDefault();

            if (vipInfo != null)
            {
                strPhone = vipInfo.Phone;
                var vipCardVipMappingBLL = new VipCardVipMappingBLL(CurrentUserInfo);
                var vipCardBLL           = new VipCardBLL(CurrentUserInfo);
                var vipCardTypeBLL       = new SysVipCardTypeBLL(CurrentUserInfo);
                var vipCardMappingInfo   = vipCardVipMappingBLL.QueryByEntity(new VipCardVipMappingEntity()
                {
                    VIPID = pRequest.UserID, CustomerID = CurrentUserInfo.ClientID
                },
                                                                              new OrderBy[] { new OrderBy()
                                                                                              {
                                                                                                  FieldName = "CreateTime", Direction = OrderByDirections.Desc
                                                                                              } }).FirstOrDefault();
                if (vipCardMappingInfo != null)//根据当前会员与卡关联表获取当前会员等级
                {
                    var vipCardInfo = vipCardBLL.QueryByEntity(new VipCardEntity()
                    {
                        VipCardID = vipCardMappingInfo.VipCardID, VipCardStatusId = 1
                    }, null).FirstOrDefault();
                    if (vipCardInfo != null)
                    {
                        var vipCardTypeInfo = vipCardTypeBLL.QueryByEntity(new SysVipCardTypeEntity()
                        {
                            VipCardTypeID = vipCardInfo.VipCardTypeID
                        }, null).FirstOrDefault();
                        if (vipCardTypeInfo != null)//获取当前会员等级
                        {
                            CurVipLevel = vipCardTypeInfo.VipCardLevel;
                            if (CurVipLevel <= 1)
                            {
                                CurVipLevel = 1;
                            }
                        }
                    }
                }
            }
            else
            {
                strPhone = para.Phone;
            }
            try
            {
                //获取当前会员可绑卡列表
                var VipCardTypeSysInfoList = bllVipCardType.GetBindVipCardTypeInfo(loggingSessionInfo.ClientID, strPhone, pRequest.UserID, CurVipLevel);
                if (VipCardTypeSysInfoList != null && VipCardTypeSysInfoList.Tables[0].Rows.Count > 0)
                {
                    rd.VipCardTypeList = DataTableToObject.ConvertToList <VipCardRelateInfo>(VipCardTypeSysInfoList.Tables[0]);
                }
                else
                {
                    throw new APIException("未检测到实体卡!")
                          {
                              ErrorCode = ERROR_CODES.INVALID_BUSINESS
                          };
                }
            }
            catch (APIException ex)
            {
                throw ex;
            }

            return(rd);
        }
Example #8
0
        protected override SetRechargeOrderRD ProcessRequest(APIRequest <SetRechargeOrderRP> pRequest)
        {
            SetRechargeOrderRP rp = pRequest.Parameters;
            SetRechargeOrderRD rd = new SetRechargeOrderRD();

            var            rechargeOrderBll     = new RechargeOrderBLL(CurrentUserInfo);
            TUnitExpandBLL serviceUnitExpandBll = new TUnitExpandBLL(CurrentUserInfo);

            var vipBll = new VipBLL(CurrentUserInfo);
            var vipCardVipMappingBll  = new VipCardVipMappingBLL(CurrentUserInfo);
            var vipCardBll            = new VipCardBLL(CurrentUserInfo);
            var sysVipCardTypeBll     = new SysVipCardTypeBLL(CurrentUserInfo);
            var vipCardUpgradeRuleBll = new VipCardUpgradeRuleBLL(CurrentUserInfo);

            //获取会员信息
            VipEntity vipInfo;
            string    userId = "";

            //微信
            if (pRequest.ChannelId == "2")
            {
                vipInfo = vipBll.GetByID(pRequest.UserID);
                UnitService unitServer = new UnitService(CurrentUserInfo);
                rp.UnitId = unitServer.GetUnitByUnitTypeForWX("OnlineShopping", null).Id; //获取在线商城的门店标识
            }
            //掌柜App
            else
            {
                vipInfo = vipBll.GetByID(rp.VipId);
                userId  = pRequest.UserID;
            }

            string  OrderDesc     = "ReRecharge"; //"升级","充值"
            int?    VipCardTypeId = null;         //会员卡类型
            decimal returnAmount  = 0;            //赠送金额

            //会员卡类型条件
            List <IWhereCondition> complexConditionOne = new List <IWhereCondition> {
            };
            //获取会员与会员卡关系表
            var vipCardVipMappingEntity = vipCardVipMappingBll.QueryByEntity(new VipCardVipMappingEntity()
            {
                CustomerID = CurrentUserInfo.ClientID, VIPID = vipInfo.VIPID
            }, null).FirstOrDefault();

            //该会员有会员卡
            if (vipCardVipMappingEntity != null)
            {
                //获取该会员会员卡信息
                var vipCardEntity = vipCardBll.QueryByEntity(new VipCardEntity()
                {
                    CustomerID = CurrentUserInfo.ClientID, VipCardID = vipCardVipMappingEntity.VipCardID
                }, null).FirstOrDefault();

                //获取该会员卡类型
                var sysVipCardTypeEntity = sysVipCardTypeBll.GetByID(vipCardEntity.VipCardTypeID);
                VipCardTypeId = vipCardEntity.VipCardTypeID;

                //获取会员卡的会员活动
                var rechargeStrategyBLL = new RechargeStrategyBLL(CurrentUserInfo);
                var RechargeActivityDS  = rechargeStrategyBLL.GetRechargeActivityList(CurrentUserInfo.ClientID, VipCardTypeId.ToString(), 3);
                var RechargeStrategy    = new RechargeStrategyInfo();

                if (RechargeActivityDS != null && RechargeActivityDS.Tables[0].Rows.Count > 0)
                {
                    var RechargeStrategyList = DataTableToObject.ConvertToList <RechargeStrategyInfo>(RechargeActivityDS.Tables[0]);
                    //获取与充值金额最接近的活动
                    RechargeStrategy = RechargeStrategyList.Where(n => n.RechargeAmount <= rp.ActuallyPaid).OrderByDescending(n => n.RechargeAmount).FirstOrDefault();
                    if (RechargeStrategy != null)
                    {
                        //梯度
                        if (RechargeStrategy.RuleType == "Step")
                        {
                            //赠送金额 = 会员活动梯度设置赠送金额
                            returnAmount = RechargeStrategy.GiftAmount;
                        }
                        //叠加
                        if (RechargeStrategy.RuleType == "Superposition")
                        {
                            //赠送金额与满赠条件金额比例
                            decimal discount = RechargeStrategy.GiftAmount / RechargeStrategy.RechargeAmount;
                            //赠送金额 = 充值金额 * (设置赠送金额 / 设置满赠条件金额)
                            returnAmount = rp.ActuallyPaid * RechargeStrategy.GiftAmount / RechargeStrategy.RechargeAmount;
                        }
                    }
                }

                //获取等级高的会员卡类型条件
                complexConditionOne.Add(new MoreThanCondition()
                {
                    FieldName = "VipCardLevel", Value = sysVipCardTypeEntity.VipCardLevel, IncludeEquals = false
                });
                complexConditionOne.Add(new EqualsCondition()
                {
                    FieldName = "CustomerID", Value = CurrentUserInfo.ClientID
                });
            }
            //该会员没有会员卡
            else
            {
                //获取所有的会员卡类型条件
                complexConditionOne.Add(new EqualsCondition()
                {
                    FieldName = "CustomerID", Value = CurrentUserInfo.ClientID
                });
            }

            var sysVipCardTypeList = sysVipCardTypeBll.Query(complexConditionOne.ToArray(), null).ToList();

            if (sysVipCardTypeList == null)
            {
                throw new APIException("没有建立会员体系")
                      {
                          ErrorCode = 200
                      };
            }

            //获取会员卡类型升级规则
            List <IWhereCondition> complexConditionTwo = new List <IWhereCondition> {
            };

            complexConditionTwo.Add(new EqualsCondition()
            {
                FieldName = "CustomerID", Value = CurrentUserInfo.ClientID
            });
            complexConditionTwo.Add(new EqualsCondition()
            {
                FieldName = "IsRecharge", Value = 1
            });
            var vipCardUpgradeRuleList = vipCardUpgradeRuleBll.Query(complexConditionTwo.ToArray(), null);

            //将升级卡规则和可升级的会员卡匹配
            var vipCardTypeDetailList = vipCardUpgradeRuleList.Join(sysVipCardTypeList, n => n.VipCardTypeID, m => m.VipCardTypeID, (n, m) => new { n, m }).OrderByDescending(t => t.m.VipCardLevel).ToList();

            //判断是否满充值条件
            bool isUpgrade = false;


            for (int i = 0; i < vipCardTypeDetailList.Count; i++)
            {
                //实付金额 >= 可升级金额
                if (vipCardTypeDetailList[i].n.OnceRechargeAmount <= rp.ActuallyPaid)
                {
                    isUpgrade     = true;
                    VipCardTypeId = vipCardTypeDetailList[i].n.VipCardTypeID ?? 0;
                    break;
                }
            }
            if (isUpgrade)
            {
                OrderDesc = "Upgrade";  //升级
            }


            //充值订单
            var rechargeOrderEntity = new RechargeOrderEntity()
            {
                OrderID       = Guid.NewGuid(),
                OrderNo       = serviceUnitExpandBll.GetUnitOrderNo(),
                OrderDesc     = OrderDesc,
                VipID         = vipInfo.VIPID,
                VipCardNo     = vipInfo.VipCode,
                UnitId        = rp.UnitId,
                UserId        = userId,
                TotalAmount   = rp.ActuallyPaid,
                ActuallyPaid  = rp.ActuallyPaid,
                PosSourceName = rp.PosSourceName,
                ReturnAmount  = returnAmount,
                PayerID       = vipInfo.VIPID,
                Status        = 0,
                CustomerID    = CurrentUserInfo.ClientID,
                VipCardTypeId = VipCardTypeId
            };

            rechargeOrderBll.Create(rechargeOrderEntity);
            rd.orderId = rechargeOrderEntity.OrderID.ToString();

            //支付完成
            if (rp.PayStatus == 1)
            {
                //获取门店信息
                t_unitBLL    unitBLL  = new t_unitBLL(CurrentUserInfo);
                t_unitEntity unitInfo = null;
                if (!string.IsNullOrEmpty(rechargeOrderEntity.UnitId))
                {
                    unitInfo = unitBLL.GetByID(rechargeOrderEntity.UnitId);
                }
                //充值
                rechargeOrderBll.Recharge(rechargeOrderEntity, vipInfo, unitInfo, "");
            }

            return(rd);
        }
Example #9
0
        protected override GetVipCardTypeSystemRD ProcessRequest(DTO.Base.APIRequest <EmptyRequestParameter> pRequest)
        {
            var rd = new GetVipCardTypeSystemRD();
            var loggingSessionInfo = new SessionManager().CurrentUserLoginInfo;
            //声明卡等级相关逻辑
            var bllVipCardType = new SysVipCardTypeBLL(loggingSessionInfo);
            //获取卡等级相关信息(会员卡等级信息、升级条件、基本权益)
            var VipCardTypeSystemInfoList = bllVipCardType.GetVipCardTypeSystemList(loggingSessionInfo.ClientID);
            //处理会员开卡礼信息
            var VipCardUpgradeRewardInfoList = bllVipCardType.GetCardUpgradeRewardList(loggingSessionInfo.ClientID);
            List <VipCardUpgradeRewardInfo> VipCardUpgradeRewardList = new List <VipCardUpgradeRewardInfo>();
            List <VipCardTypeRelateInfo>    VipCardTypeRelateList    = new List <VipCardTypeRelateInfo>();

            if (VipCardTypeSystemInfoList != null && VipCardTypeSystemInfoList.Tables[0].Rows.Count > 0)
            {
                int flag = 0;//定义下面开卡礼能否进行循环(0=不进,1=进)
                if (VipCardUpgradeRewardInfoList != null && VipCardUpgradeRewardInfoList.Tables[0].Rows.Count > 0)
                {
                    flag = 1;
                    //获取开卡礼信息 为之后筛选数据使用
                    VipCardUpgradeRewardList = DataTableToObject.ConvertToList <VipCardUpgradeRewardInfo>(VipCardUpgradeRewardInfoList.Tables[0]);
                }

                var dt = VipCardTypeSystemInfoList.Tables[0];
                foreach (DataRow dr in dt.Rows)
                {
                    var DataInfo = new VipCardTypeRelateInfo();
                    //VipCardTypeRelateList = new List<VipCardTypeRelateInfo>();
                    DataInfo.VipCardType              = new VipCardTypeInfo();        //会员卡体系
                    DataInfo.VipCardUpgradeRule       = new VipCardUpgradeRuleInfo(); //会员卡升级规则
                    DataInfo.VipCardRule              = new VipCardRuleInfo();        //会员卡基本体系
                    DataInfo.VipCardUpgradeRewardList = new List <VipCardUpgradeRewardInfo>();
                    //var VipCardTypeData = new VipCardTypeInfo();
                    //给会员卡等级赋值
                    DataInfo.VipCardType.VipCardTypeID   = Convert.ToInt32(dr["VipCardTypeID"]);
                    DataInfo.VipCardType.VipCardLevel    = Convert.ToInt32(dr["VipCardLevel"]);
                    DataInfo.VipCardType.VipCardTypeName = dr["VipCardTypeName"].ToString();
                    DataInfo.VipCardType.PicUrl          = dr["PicUrl"].ToString();
                    DataInfo.VipCardType.IsPrepaid       = Convert.ToInt32(dr["IsPrepaid"]);
                    DataInfo.VipCardType.IsOnlineSales   = Convert.ToInt32(dr["IsOnlineSales"]);

                    //var VipCardUpgradeRuleData = new VipCardUpgradeRuleInfo();
                    DataInfo.VipCardUpgradeRule.VipCardTypeID        = Convert.ToInt32(dr["VipCardTypeID"]);
                    DataInfo.VipCardUpgradeRule.VipCardUpgradeRuleId = dr["VipCardUpgradeRuleId"] == null ? "" : dr["VipCardUpgradeRuleId"].ToString();
                    DataInfo.VipCardUpgradeRule.IsPurchaseUpgrade    = Convert.ToInt32(dr["IsPurchaseUpgrade"]);
                    DataInfo.VipCardUpgradeRule.IsExtraMoney         = Convert.ToInt32(dr["IsExtraMoney"]);
                    DataInfo.VipCardUpgradeRule.Prices             = Convert.ToDecimal(dr["Prices"]);
                    DataInfo.VipCardUpgradeRule.ExchangeIntegral   = Convert.ToInt32(dr["ExchangeIntegral"]);
                    DataInfo.VipCardUpgradeRule.IsRecharge         = Convert.ToInt32(dr["IsRecharge"]);
                    DataInfo.VipCardUpgradeRule.OnceRechargeAmount = Convert.ToDecimal(dr["OnceRechargeAmount"]);
                    DataInfo.VipCardUpgradeRule.IsBuyUpgrade       = Convert.ToInt32(dr["IsBuyUpgrade"]);
                    DataInfo.VipCardUpgradeRule.BuyAmount          = Convert.ToDecimal(dr["BuyAmount"]);
                    DataInfo.VipCardUpgradeRule.OnceBuyAmount      = Convert.ToDecimal(dr["OnceBuyAmount"]);

                    //var VipCardRuleData = new VipCardUpgradeRuleInfo();
                    DataInfo.VipCardRule.VipCardTypeID        = Convert.ToInt32(dr["VipCardTypeID"]);
                    DataInfo.VipCardRule.RuleID               = dr["RuleID"] == null ? 0 : Convert.ToInt32(dr["RuleID"]);
                    DataInfo.VipCardRule.CardDiscount         = Convert.ToDecimal(dr["CardDiscount"]);
                    DataInfo.VipCardRule.PaidGivePercetPoints = Convert.ToDecimal(dr["PaidGivePercetPoints"]);
                    DataInfo.VipCardRule.PaidGivePoints       = Convert.ToDecimal(dr["PaidGivePoints"]);
                    if (flag == 1)//当flag=1的时候进行开卡礼的展示
                    {
                        DataInfo.VipCardUpgradeRewardList = VipCardUpgradeRewardList.Where(m => m.VipCardTypeID == Convert.ToInt32(dr["VipCardTypeID"])).Select(
                            t => new VipCardUpgradeRewardInfo()
                        {
                            CardUpgradeRewardId = t.CardUpgradeRewardId,
                            VipCardTypeID       = t.VipCardTypeID,
                            CouponTypeID        = t.CouponTypeID,
                            CouponNum           = t.CouponNum,
                            CouponName          = t.CouponName,
                            ValidityPeriod      = t.BeginTime == null ? ("领取后" + (t.ServiceLife == 0 ? "1天内有效" : t.ServiceLife.ToString() + "天内有效")) : (t.BeginTime.Value.ToString("yyyy-MM-dd") + "至" + t.EndTime.Value.ToString("yyyy-MM-dd")),
                            BeginTime           = t.BeginTime,
                            EndTime             = t.EndTime,
                            BeginTimeDate       = t.BeginTime == null ? "" : t.BeginTime.Value.ToString("yyyy年MM月dd日"),
                            EndTimeDate         = t.EndTime == null ? "" : t.EndTime.Value.ToString("yyyy年MM月dd日"),
                            ServiceLife         = t.ServiceLife,
                        }).ToList();
                    }
                    VipCardTypeRelateList.Add(DataInfo);
                }
                rd.VipCardRelateList = VipCardTypeRelateList;
            }
            return(rd);
        }
Example #10
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);
            }
        }
Example #11
0
        protected override GetSysVipCardTypeByLevelRD ProcessRequest(DTO.Base.APIRequest <GetSysVipCardTypeByLevelRP> pRequest)
        {
            LoggingSessionInfo      loggingSessionInfo = Default.GetBSLoggingSession(pRequest.CustomerID, pRequest.UserID);
            SysVipCardTypeBLL       bll = new SysVipCardTypeBLL(loggingSessionInfo);
            VipCardRuleBLL          VipCardRuleService          = new VipCardRuleBLL(loggingSessionInfo);
            VipCardUpgradeRewardBLL VipCardUpgradeRewardService = new VipCardUpgradeRewardBLL(loggingSessionInfo);
            var rd         = new GetSysVipCardTypeByLevelRD();
            var parameter  = pRequest.Parameters;
            int?CardTypeId = 0;
            //获取等级为1的会员卡
            var model = bll.QueryByEntity(new SysVipCardTypeEntity()
            {
                CustomerID = loggingSessionInfo.ClientID, VipCardLevel = parameter.Level, IsDelete = 0
            }, null).FirstOrDefault();

            if (model != null)
            {
                //获取等级为1的升级规则信息
                var cardrulemodel = VipCardRuleService.QueryByEntity(new VipCardRuleEntity()
                {
                    VipCardTypeID = model.VipCardTypeID
                }, null).FirstOrDefault();
                if (cardrulemodel != null)
                {
                    CardTypeId = cardrulemodel.VipCardTypeID;
                    WXVipCardUpgradeRewardInfo _model = new WXVipCardUpgradeRewardInfo();

                    _model.VipCardTypeName = model.VipCardTypeName;
                    _model.Type            = 1;
                    if (cardrulemodel.CardDiscount > 0) //会员折扣
                    {
                        _model.Title          = "会员折扣";
                        _model.ImagesUrl      = "../../../images/common/vipCard/cardLegal.png";
                        _model.CouponTypeName = (Convert.ToDouble(cardrulemodel.CardDiscount) / 10.0).ToString("0.0") + "折";
                        rd.VipCardUpgradeRewardInfoList.Add(_model);
                    }

                    _model = new WXVipCardUpgradeRewardInfo();
                    _model.VipCardTypeName = model.VipCardTypeName;
                    _model.Type            = 1;
                    if (cardrulemodel.PaidGivePercetPoints > 0) //消费返积分
                    {
                        _model.Title          = "消费返积分";
                        _model.ImagesUrl      = "../../../images/common/vipCard/cardLegal2.png";
                        _model.CouponTypeName = Convert.ToInt32(cardrulemodel.PaidGivePercetPoints) + "%";
                        rd.VipCardUpgradeRewardInfoList.Add(_model);
                    }

                    if (cardrulemodel.PaidGivePoints > 0) //消费返积分
                    {
                        _model.Title          = "消费返积分";
                        _model.ImagesUrl      = "../../../images/common/vipCard/cardLegal2.png";
                        _model.CouponTypeName = "每" + Convert.ToInt32(cardrulemodel.PaidGivePoints) + "元获1积分";
                        rd.VipCardUpgradeRewardInfoList.Add(_model);
                    }
                }
            }
            //获取开卡礼
            var VipCardUpgradeRewardDs = VipCardUpgradeRewardService.GetVipCardUpgradeRewardList(CardTypeId, loggingSessionInfo.ClientID);

            if (VipCardUpgradeRewardDs != null && VipCardUpgradeRewardDs.Tables[0].Rows.Count > 0)
            {
                rd.VipCardUpgradeRewardInfoList.AddRange(DataTableToObject.ConvertToList <WXVipCardUpgradeRewardInfo>(VipCardUpgradeRewardDs.Tables[0]));
            }
            return(rd);
        }
        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);
        }
        protected override GetVipCardTypeVirtualItemRD ProcessRequest(DTO.Base.APIRequest <GetVipCardTypeVirtualItemRP> pRequest)
        {
            var rd   = new GetVipCardTypeVirtualItemRD();
            var para = pRequest.Parameters;
            LoggingSessionInfo loggingSessionInfo = Default.GetBSLoggingSession(pRequest.CustomerID, pRequest.UserID);
            var vipBLL               = new VipBLL(loggingSessionInfo);
            var vipIntegralBLL       = new VipIntegralBLL(loggingSessionInfo);
            var sysVipCardTypeBLL    = new SysVipCardTypeBLL(loggingSessionInfo);
            var vipCardVipMappingBLL = new VipCardVipMappingBLL(loggingSessionInfo);
            var vipCardBLL           = new VipCardBLL(loggingSessionInfo);
            var vipCardRuleBLL       = new VipCardRuleBLL(loggingSessionInfo);
            var vipT_InoutBLL        = new T_InoutBLL(loggingSessionInfo);
            List <VipCardUpgradeRewardInfo> VipCardUpgradeRewardList = new List <VipCardUpgradeRewardInfo>();
            List <VipCardTypeRelateInfo>    VipCardTypeRelateList    = new List <VipCardTypeRelateInfo>();
            //获取当前会员卡等级
            VipEntity VipInfo         = null;
            int?      CurVipCardLevel = 0;
            //处理会员开卡礼信息
            var VipCardUpgradeRewardInfoList = sysVipCardTypeBLL.GetCardUpgradeRewardList(loggingSessionInfo.ClientID);
            //定义卡体系信息
            DataSet VipCardTypeSystemInfoList = null;
            string  strVipID = string.Empty;

            switch (para.ApplicationType)
            {
            //为1是微信,为2时表示APP请求
            case "1":    //微信
                strVipID = pRequest.UserID;
                break;

            case "2":                  //APP
                strVipID = para.VipID; //获取会员信息
                break;
            }

            VipInfo = vipBLL.GetByID(strVipID);//获取会员信息
            if (VipInfo != null)
            {
                rd.HeadImgUrl = VipInfo.HeadImgUrl == null ? "" : VipInfo.HeadImgUrl;
                var vipIntegralInfo = vipIntegralBLL.QueryByEntity(new VipIntegralEntity()
                {
                    VipID = strVipID, VipCardCode = VipInfo.VipCode
                }, null).FirstOrDefault();
                if (vipIntegralInfo != null)//获取当前会员积分
                {
                    rd.Integration = vipIntegralInfo.ValidIntegral != null ? vipIntegralInfo.ValidIntegral.Value : 0;
                }
                //获取会员卡等级相关信息
                var vipCardMappingInfo = vipCardVipMappingBLL.QueryByEntity(new VipCardVipMappingEntity()
                {
                    VIPID = strVipID, CustomerID = loggingSessionInfo.ClientID
                },
                                                                            new OrderBy[] { new OrderBy()
                                                                                            {
                                                                                                FieldName = "CreateTime", Direction = OrderByDirections.Desc
                                                                                            } }).FirstOrDefault();
                if (vipCardMappingInfo != null)
                {
                    var vipCardInfo = vipCardBLL.QueryByEntity(new VipCardEntity()
                    {
                        VipCardID = vipCardMappingInfo.VipCardID, VipCardStatusId = 1
                    }, null).FirstOrDefault();
                    if (vipCardInfo != null)
                    {
                        var vipCardTypeInfo = sysVipCardTypeBLL.QueryByEntity(new SysVipCardTypeEntity()
                        {
                            VipCardTypeID = vipCardInfo.VipCardTypeID
                        }, null).FirstOrDefault();
                        if (vipCardTypeInfo != null)//获取当前会员卡等级信息
                        {
                            rd.VipCardTypeName = vipCardTypeInfo.VipCardTypeName != null ? vipCardTypeInfo.VipCardTypeName : "";
                            rd.VipCardLevel    = vipCardTypeInfo.VipCardLevel;
                            CurVipCardLevel    = vipCardTypeInfo.VipCardLevel;
                        }
                    }
                }
                else
                {
                    var vipCardTypeInfo = sysVipCardTypeBLL.QueryByEntity(new SysVipCardTypeEntity()
                    {
                        VipCardLevel = 1, CustomerID = loggingSessionInfo.ClientID
                    }, null).FirstOrDefault();
                    if (vipCardTypeInfo != null)
                    {
                        rd.VipCardTypeName = vipCardTypeInfo.VipCardTypeName != null ? vipCardTypeInfo.VipCardTypeName : "";
                        rd.VipCardLevel    = vipCardTypeInfo.VipCardLevel != null ? vipCardTypeInfo.VipCardLevel : 1;
                        CurVipCardLevel    = vipCardTypeInfo.VipCardLevel != null ? vipCardTypeInfo.VipCardLevel : 1;
                    }
                }
                //获取会员消费金额
                decimal VipConsumptionInfo = vipT_InoutBLL.GetVipSumAmount(strVipID);
                if (VipConsumptionInfo > 0)
                {
                    rd.VipConsumptionAmount = Convert.ToDecimal(VipConsumptionInfo).ToString("0.00");
                }
                else
                {
                    rd.VipConsumptionAmount = "0";
                }
                //获取卡等级相关信息(会员卡等级信息、升级条件、基本权益关联虚拟商品)
                VipCardTypeSystemInfoList = sysVipCardTypeBLL.GetVipCardTypeVirtualItemList(loggingSessionInfo.ClientID, CurVipCardLevel, para.ApplicationType, VipInfo.VIPID);
            }


            if (VipCardTypeSystemInfoList != null && VipCardTypeSystemInfoList.Tables[0].Rows.Count > 0)
            {
                int flag = 0;//定义下面开卡礼能否进行展示(0=不进,1=进)
                if (VipCardUpgradeRewardInfoList != null && VipCardUpgradeRewardInfoList.Tables[0].Rows.Count > 0)
                {
                    flag = 1;
                    //获取开卡礼信息 为之后筛选数据使用
                    VipCardUpgradeRewardList = DataTableToObject.ConvertToList <VipCardUpgradeRewardInfo>(VipCardUpgradeRewardInfoList.Tables[0]);
                }
                var dt = VipCardTypeSystemInfoList.Tables[0];
                foreach (DataRow dr in dt.Rows)
                {
                    var DataInfo = new VipCardTypeRelateInfo();
                    //VipCardTypeRelateList = new List<VipCardTypeRelateInfo>();
                    DataInfo.VipCardType              = new VipCardTypeInfo();        //会员卡体系
                    DataInfo.VipCardUpgradeRule       = new VipCardUpgradeRuleInfo(); //会员卡升级规则
                    DataInfo.VipCardRule              = new VipCardRuleInfo();        //会员卡基本体系
                    DataInfo.VipCardUpgradeRewardList = new List <VipCardUpgradeRewardInfo>();
                    //var VipCardTypeData = new VipCardTypeInfo();
                    //给会员卡等级赋值
                    DataInfo.VipCardType.VipCardTypeID   = Convert.ToInt32(dr["VipCardTypeID"]);
                    DataInfo.VipCardType.VipCardLevel    = Convert.ToInt32(dr["VipCardLevel"]);
                    DataInfo.VipCardType.VipCardTypeName = dr["VipCardTypeName"].ToString();
                    DataInfo.VipCardType.PicUrl          = dr["PicUrl"].ToString();
                    DataInfo.VipCardType.IsPrepaid       = Convert.ToInt32(dr["IsPrepaid"]);
                    DataInfo.VipCardType.IsOnlineSales   = Convert.ToInt32(dr["IsOnlineSales"]);
                    DataInfo.VipCardType.ItemID          = dr["ItemID"].ToString();
                    DataInfo.VipCardType.SkuID           = dr["SkuID"].ToString();
                    int cardStatus = 0;
                    //获取卡状态购买信息 0=没购买,1=已购买 pRequest.UserID
                    if (DataInfo.VipCardType.IsPrepaid != 1)//非可储值类型关联订单
                    {
                        cardStatus = vipT_InoutBLL.GetVirtualItemStatus(loggingSessionInfo.ClientID, strVipID, DataInfo.VipCardType.SkuID);
                    }
                    else//可储值类型关联充值订单
                    {
                        var RechargeOrderBll  = new RechargeOrderBLL(loggingSessionInfo);
                        var RechargeOrderInfo = RechargeOrderBll.QueryByEntity(new RechargeOrderEntity()
                        {
                            OrderDesc = "Upgrade", VipID = strVipID, VipCardTypeId = DataInfo.VipCardType.VipCardTypeID, Status = 1
                        }, null).FirstOrDefault();
                        if (RechargeOrderInfo != null)//如果为空需要在订单表里查找下记录
                        {
                            cardStatus = 1;
                        }
                        else
                        {
                            cardStatus = vipT_InoutBLL.GetVirtualItemStatus(loggingSessionInfo.ClientID, strVipID, DataInfo.VipCardType.SkuID);
                        }
                    }

                    DataInfo.VipCardType.Status = cardStatus;
                    //var VipCardUpgradeRuleData = new VipCardUpgradeRuleInfo();
                    DataInfo.VipCardUpgradeRule.VipCardTypeID        = Convert.ToInt32(dr["VipCardTypeID"]);
                    DataInfo.VipCardUpgradeRule.VipCardUpgradeRuleId = dr["VipCardUpgradeRuleId"].ToString();
                    DataInfo.VipCardUpgradeRule.IsPurchaseUpgrade    = Convert.ToInt32(dr["IsPurchaseUpgrade"]);
                    DataInfo.VipCardUpgradeRule.IsExtraMoney         = Convert.ToInt32(dr["IsExtraMoney"]);
                    DataInfo.VipCardUpgradeRule.Prices             = Convert.ToDecimal(dr["Prices"]);
                    DataInfo.VipCardUpgradeRule.ExchangeIntegral   = Convert.ToInt32(dr["ExchangeIntegral"]);
                    DataInfo.VipCardUpgradeRule.IsRecharge         = Convert.ToInt32(dr["IsRecharge"]);
                    DataInfo.VipCardUpgradeRule.OnceRechargeAmount = Convert.ToDecimal(dr["OnceRechargeAmount"]);
                    DataInfo.VipCardUpgradeRule.IsBuyUpgrade       = Convert.ToInt32(dr["IsBuyUpgrade"]);
                    DataInfo.VipCardUpgradeRule.BuyAmount          = Convert.ToDecimal(dr["BuyAmount"]);
                    DataInfo.VipCardUpgradeRule.OnceBuyAmount      = Convert.ToDecimal(dr["OnceBuyAmount"]);

                    //var VipCardRuleData = new VipCardUpgradeRuleInfo();
                    DataInfo.VipCardRule.VipCardTypeID        = Convert.ToInt32(dr["VipCardTypeID"]);
                    DataInfo.VipCardRule.RuleID               = Convert.ToInt32(dr["RuleID"]);
                    DataInfo.VipCardRule.CardDiscount         = Convert.ToDecimal(dr["CardDiscount"]);
                    DataInfo.VipCardRule.PaidGivePercetPoints = Convert.ToDecimal(dr["PaidGivePercetPoints"]);
                    DataInfo.VipCardRule.PaidGivePoints       = Convert.ToDecimal(dr["PaidGivePoints"]);
                    if (flag == 1)//当flag=1的时候进行开卡礼的展示
                    {
                        DataInfo.VipCardUpgradeRewardList = VipCardUpgradeRewardList.Where(m => m.VipCardTypeID == Convert.ToInt32(dr["VipCardTypeID"])).Select(
                            t => new VipCardUpgradeRewardInfo()
                        {
                            CardUpgradeRewardId = t.CardUpgradeRewardId,
                            VipCardTypeID       = t.VipCardTypeID,
                            CouponTypeID        = t.CouponTypeID,
                            CouponNum           = t.CouponNum,
                            CouponName          = t.CouponName,
                            ValidityPeriod      = t.BeginTime == null ? ("领取后" + (t.ServiceLife == 0 ? "1天内有效" : t.ServiceLife.ToString() + "天内有效")) : (t.BeginTime.Value.ToString("yyyy-MM-dd") + "至" + t.EndTime.Value.ToString("yyyy-MM-dd")),
                            BeginTime           = t.BeginTime,
                            EndTime             = t.EndTime,
                            BeginTimeDate       = t.BeginTime == null ? "" : t.BeginTime.Value.ToString("yyyy年MM月dd日"),
                            EndTimeDate         = t.EndTime == null ? "" : t.EndTime.Value.ToString("yyyy年MM月dd日"),
                            ServiceLife         = t.ServiceLife,
                            CouponDesc          = t.CouponDesc,
                            ParValue            = t.ParValue
                        }).ToList();
                    }
                    VipCardTypeRelateList.Add(DataInfo);
                }
                rd.VipCardTypeItemList = VipCardTypeRelateList;
            }
            return(rd);
        }
Example #14
0
        protected override GetMemberInfoRD ProcessRequest(DTO.Base.APIRequest <GetMemberInfoRP> pRequest)
        {
            GetMemberInfoRD rd = new GetMemberInfoRD();

            rd.MemberInfo = new MemberInfo();
            var vipLoginBLL = new VipBLL(base.CurrentUserInfo);

            //如果有一个查询标识非空,就用查询标识查,发现没有会员就报错
            if (!string.IsNullOrEmpty(pRequest.Parameters.SearchFlag))
            {
                List <IWhereCondition> complexCondition = new List <IWhereCondition> {
                };
                complexCondition.Add(new EqualsCondition()
                {
                    FieldName = "ClientID", Value = CurrentUserInfo.ClientID
                });
                var cond1 = new LikeCondition()
                {
                    FieldName = "VipName", Value = "%" + pRequest.Parameters.SearchFlag + "%"
                };
                var cond2 = new LikeCondition()
                {
                    FieldName = "VipRealName", Value = "%" + pRequest.Parameters.SearchFlag + "%"
                };
                var com1 = new ComplexCondition()
                {
                    Left = cond1, Right = cond2, Operator = LogicalOperators.Or
                };

                var cond3 = new EqualsCondition()
                {
                    FieldName = "Phone", Value = pRequest.Parameters.SearchFlag
                };
                var com2 = new ComplexCondition()
                {
                    Left = com1, Right = cond3, Operator = LogicalOperators.Or
                };
                complexCondition.Add(com2);
                complexCondition.Add(new DirectCondition("(WeiXinUserId!='' Or WeiXinUserId IS NOT NULL)"));
                var tempVipList = vipLoginBLL.Query(complexCondition.ToArray(), null);
                if (tempVipList != null && tempVipList.Length != 0)
                {
                    pRequest.UserID = pRequest.Parameters.MemberID = tempVipList[0].VIPID;
                }
            }

            string m_MemberID = "";

            if (!string.IsNullOrWhiteSpace(pRequest.Parameters.OwnerVipID))
            {
                m_MemberID = string.IsNullOrWhiteSpace(pRequest.Parameters.OwnerVipID) ? pRequest.UserID : pRequest.Parameters.OwnerVipID;
            }
            else
            {
                m_MemberID = string.IsNullOrWhiteSpace(pRequest.Parameters.MemberID) ? pRequest.UserID : pRequest.Parameters.MemberID;
            }

            string UserID       = m_MemberID;
            var    VipLoginInfo = vipLoginBLL.GetByID(UserID);

            if (VipLoginInfo == null)
            {
                throw new APIException("用户不存在")
                      {
                          ErrorCode = 330
                      }
            }
            ;
            #region 20140909 kun.zou 发现状态为0,改为1
            if (VipLoginInfo.Status.HasValue && VipLoginInfo.Status == 0)
            {
                VipLoginInfo.Status = 1;
                vipLoginBLL.Update(VipLoginInfo, false);
                var log = new VipLogEntity()
                {
                    Action       = "更新",
                    ActionRemark = "vip状态为0的改为1.",
                    CreateBy     = UserID,
                    CreateTime   = DateTime.Now,
                    VipID        = VipLoginInfo.VIPID,
                    LogID        = Guid.NewGuid().ToString("N")
                };
                var logBll = new VipLogBLL(base.CurrentUserInfo);
                logBll.Create(log);
            }
            #endregion
            int couponCount = vipLoginBLL.GetVipCoupon(UserID);

            rd.MemberInfo.Mobile      = VipLoginInfo.Phone;      //手机号码
            rd.MemberInfo.Name        = VipLoginInfo.UserName;   //姓名
            rd.MemberInfo.VipID       = VipLoginInfo.VIPID;      //组标识
            rd.MemberInfo.VipName     = VipLoginInfo.VipName;    //会员名
            rd.MemberInfo.ImageUrl    = VipLoginInfo.HeadImgUrl; //会员头像  add by Henry 2014-12-5
            rd.MemberInfo.VipRealName = VipLoginInfo.VipRealName;
            rd.MemberInfo.VipNo       = VipLoginInfo.VipCode;
            rd.MemberInfo.IsDealer    = VipLoginInfo.Col48 != null?int.Parse(VipLoginInfo.Col48) : 0;

            //超级分销体系配置表 为判断是否存在分销体系使用
            var T_SuperRetailTraderConfigbll = new T_SuperRetailTraderConfigBLL(CurrentUserInfo);
            //获取分销体系信息
            var T_SuperRetailTraderConfigInfo = T_SuperRetailTraderConfigbll.QueryByEntity(new T_SuperRetailTraderConfigEntity()
            {
                IsDelete = 0, CustomerId = CurrentUserInfo.CurrentUser.customer_id
            }, null).FirstOrDefault();
            if (T_SuperRetailTraderConfigInfo != null)
            {
                rd.MemberInfo.CanBeSuperRetailTrader = 1;
            }
            else
            {
                rd.MemberInfo.CanBeSuperRetailTrader = 0;
            }
            rd.MemberInfo.SuperRetailTraderID = VipLoginInfo.Col26;
            //rd.MemberInfo.Integration = VipLoginInfo.Integration ?? 0;//会员积分

            #region 会员有效积分
            var vipIntegralBLL  = new VipIntegralBLL(CurrentUserInfo);
            var vipIntegralInfo = vipIntegralBLL.QueryByEntity(new VipIntegralEntity()
            {
                VipID = UserID, VipCardCode = VipLoginInfo.VipCode
            }, null).FirstOrDefault();
            if (vipIntegralInfo != null)
            {
                rd.MemberInfo.Integration = vipIntegralInfo.ValidIntegral != null ? vipIntegralInfo.ValidIntegral.Value : 0;
            }
            #endregion

            //会员等级
            //rd.MemberInfo.VipLevelName = string.IsNullOrEmpty(vipLoginBLL.GetVipLeave(UserID)) ? null : vipLoginBLL.GetVipLeave(UserID);
            #region 会员卡名称
            var                vipCardVipMappingBLL = new VipCardVipMappingBLL(CurrentUserInfo);
            var                vipCardBLL           = new VipCardBLL(CurrentUserInfo);
            var                vipCardTypeBLL       = new SysVipCardTypeBLL(CurrentUserInfo);
            var                vipCardRuleBLL       = new VipCardRuleBLL(CurrentUserInfo);
            var                vipT_InoutBLL        = new T_InoutBLL(CurrentUserInfo);
            VipAmountBLL       vipAmountBLL         = new VipAmountBLL(CurrentUserInfo);
            ShoppingCartBLL    service     = new ShoppingCartBLL(CurrentUserInfo);
            ShoppingCartEntity queryEntity = new ShoppingCartEntity();
            queryEntity.VipId = UserID;
            int totalQty = service.GetListQty(queryEntity);
            rd.MemberInfo.ShopCartCount = totalQty;
            //定义当前自定义等级
            int?CurVipLevel        = 0;
            var vipCardMappingInfo = vipCardVipMappingBLL.QueryByEntity(new VipCardVipMappingEntity()
            {
                VIPID = UserID, CustomerID = CurrentUserInfo.ClientID
            },
                                                                        new OrderBy[] { new OrderBy()
                                                                                        {
                                                                                            FieldName = "CreateTime", Direction = OrderByDirections.Desc
                                                                                        } }).FirstOrDefault();
            if (vipCardMappingInfo != null)
            {
                var vipCardInfo = vipCardBLL.QueryByEntity(new VipCardEntity()
                {
                    VipCardID = vipCardMappingInfo.VipCardID, VipCardStatusId = 1
                }, null).FirstOrDefault();
                if (vipCardInfo != null)
                {
                    var vipCardTypeInfo = vipCardTypeBLL.QueryByEntity(new SysVipCardTypeEntity()
                    {
                        VipCardTypeID = vipCardInfo.VipCardTypeID
                    }, null).FirstOrDefault();
                    if (vipCardTypeInfo != null)
                    {
                        rd.MemberInfo.VipLevelName     = vipCardTypeInfo.VipCardTypeName != null ? vipCardTypeInfo.VipCardTypeName : "";
                        rd.MemberInfo.CardTypeImageUrl = vipCardTypeInfo.PicUrl != null ? vipCardTypeInfo.PicUrl : "";
                        rd.MemberInfo.CardTypePrice    = vipCardTypeInfo.Prices != null ? vipCardTypeInfo.Prices.Value : 0;
                        rd.MemberInfo.IsExtraMoney     = vipCardTypeInfo.IsExtraMoney != null ? vipCardTypeInfo.IsExtraMoney : 0;
                        CurVipLevel             = vipCardTypeInfo.VipCardLevel;
                        rd.MemberInfo.IsPrepaid = vipCardTypeInfo.Isprepaid;
                        if (CurVipLevel > 1)
                        {
                            var VipCardTypeSysInfo = vipCardTypeBLL.GetBindVipCardTypeInfo(CurrentUserInfo.ClientID, VipLoginInfo.Phone, pRequest.UserID, CurVipLevel);
                            if (VipCardTypeSysInfo == null || VipCardTypeSysInfo.Tables[0].Rows.Count == 0)
                            {
                                rd.MemberInfo.IsNeedCard = 2;
                            }
                        }
                        else
                        {
                            rd.MemberInfo.IsNeedCard = 1;
                        }
                        //因为卡等级不能重复,知道当前等级后查找相应的下一级是否是自动升级(消费升级)
                        var NextVipCardTypeInfo = vipCardTypeBLL.QueryByEntity(new SysVipCardTypeEntity()
                        {
                            VipCardLevel = CurVipLevel + 1, CustomerID = CurrentUserInfo.ClientID
                        }, null).FirstOrDefault();
                        if (NextVipCardTypeInfo != null)
                        {
                            //获取当前会员的消费金额信息
                            decimal CurVipConsumptionAmount = 0;
                            decimal VipConsumptionInfo      = vipT_InoutBLL.GetVipSumAmount(UserID);
                            if (VipConsumptionInfo > 0)
                            {
                                CurVipConsumptionAmount = Convert.ToDecimal(Convert.ToDecimal(VipConsumptionInfo).ToString("0.00"));
                            }
                            //知道下一等级后要判断,升级条件是否是消费升级
                            //定义累积消费金额
                            decimal AccumulatedAmount      = 0;
                            var     vipCardTypeUpGradeInfo = vipCardTypeBLL.GetVipCardTypeUpGradeInfo(CurrentUserInfo.ClientID, CurVipLevel);
                            if (vipCardTypeUpGradeInfo != null && vipCardTypeUpGradeInfo.Tables[0].Rows.Count > 0)
                            {
                                //判断拉取的所有卡等级里的最近的一级满足条件即可返回提示所需的值
                                int flag = 0;
                                foreach (DataRow dr in vipCardTypeUpGradeInfo.Tables[0].Rows)
                                {
                                    AccumulatedAmount = Convert.ToDecimal(Convert.ToDecimal(dr["BuyAmount"].ToString()).ToString("0.00"));
                                    //获取消费升级还需多少钱
                                    if (AccumulatedAmount > CurVipConsumptionAmount && flag == 0)
                                    {
                                        flag = 1;
                                        rd.MemberInfo.UpGradeNeedMoney = AccumulatedAmount - CurVipConsumptionAmount;
                                        if (rd.MemberInfo.UpGradeNeedMoney > 0)
                                        {
                                            rd.MemberInfo.UpgradePrompt = "还需要消费" + rd.MemberInfo.UpGradeNeedMoney + "元可以升级啦,快点通知会员!";
                                        }
                                    }
                                }
                            }
                        }

                        var VipCardRuleInfo = vipCardRuleBLL.QueryByEntity(new VipCardRuleEntity()
                        {
                            CustomerID = CurrentUserInfo.ClientID, VipCardTypeID = vipCardTypeInfo.VipCardTypeID
                        }, null).FirstOrDefault();
                        if (VipCardRuleInfo != null)
                        {
                            rd.MemberInfo.CardDiscount = Convert.ToDecimal(Convert.ToDecimal((VipCardRuleInfo.CardDiscount / 10)).ToString("0.00"));
                        }
                    }
                }
            }
            else
            {
                //表示需要领卡,并展示等级为1的默认卡
                rd.MemberInfo.IsNeedCard = 0;
                var VipCardTypeData = vipCardTypeBLL.QueryByEntity(new SysVipCardTypeEntity()
                {
                    VipCardLevel = 1, CustomerID = CurrentUserInfo.ClientID
                }, null).FirstOrDefault();
                if (VipCardTypeData != null)
                {
                    rd.MemberInfo.CardTypeImageUrl = VipCardTypeData.PicUrl != null ? VipCardTypeData.PicUrl : "";
                }
            }
            //获取红利/// decimal[0]=总收入(红利) decimal[2]=支出余额 decimal[1]=总提现金额
            decimal[] array = vipAmountBLL.GetVipSumAmountByCondition(UserID, CurrentUserInfo.ClientID, true);
            if (array[0] != null)
            {
                rd.MemberInfo.ProfitAmount = array[0];
            }
            //是否有付费的会员卡
            List <IWhereCondition> freeCardCon = new List <IWhereCondition> {
            };
            freeCardCon.Add(new EqualsCondition()
            {
                FieldName = "CustomerID", Value = CurrentUserInfo.ClientID
            });
            freeCardCon.Add(new DirectCondition("Prices>0"));
            var freeCardTypeInfo = vipCardTypeBLL.Query(freeCardCon.ToArray(), null).FirstOrDefault();
            if (freeCardTypeInfo != null)
            {
                rd.MemberInfo.IsCostCardType = 1;
            }
            else
            {
                rd.MemberInfo.IsCostCardType = 0;
            }

            #endregion

            rd.MemberInfo.Status       = VipLoginInfo.Status.HasValue ? VipLoginInfo.Status.Value : 1;
            rd.MemberInfo.CouponsCount = couponCount;
            rd.MemberInfo.IsActivate   = (VipLoginInfo.IsActivate.HasValue && VipLoginInfo.IsActivate.Value == 1 ? true : false);
            var customerBasicSettingBll = new CustomerBasicSettingBLL(CurrentUserInfo);
            rd.MemberInfo.MemberBenefits = customerBasicSettingBll.GetMemberBenefits(pRequest.CustomerID);



            //获取标签信息
            TagsBLL TagsBLL = new TagsBLL(base.CurrentUserInfo);


            var dsIdentity = TagsBLL.GetVipTagsList("", UserID);//“车主标签”  传7
            if (dsIdentity != null && dsIdentity.Tables.Count > 0 && dsIdentity.Tables[0].Rows.Count > 0)
            {
                rd.IdentityTagsList = DataTableToObject.ConvertToList <TagsInfo>(dsIdentity.Tables[0]).ToArray(); //“年龄段”  传8
            }


            #region 获取注册表单的列明和值

            var vipEntity = vipLoginBLL.QueryByEntity(new VipEntity()
            {
                VIPID = UserID
            }, null);

            if (vipEntity == null || vipEntity.Length == 0)
            {
                return(rd);
            }
            else
            {
                var ds = vipLoginBLL.GetVipColumnInfo(CurrentUserInfo.ClientID, "online005");

                var vipDs = vipLoginBLL.GetVipInfo(UserID);

                if (ds.Tables[0].Rows.Count > 0)
                {
                    var temp = ds.Tables[0].AsEnumerable().Select(t => new MemberControlInfo()
                    {
                        ColumnName  = t["ColumnName"].ToString(),
                        ControlType = Convert.ToInt32(t["ControlType"]),
                        ColumnValue = vipDs.Tables[0].Rows[0][t["ColumnName"].ToString()].ToString(),
                        ColumnDesc  = t["columnDesc"].ToString()
                    });

                    rd.MemberControlList = temp.ToArray();
                }
            }

            //var vipamountBll = new VipAmountBLL(this.CurrentUserInfo);

            //var vipAmountEntity = vipamountBll.GetByID(UserID);


            var unitBll = new UnitBLL(this.CurrentUserInfo);
            //Hashtable htPara = new Hashtable();
            //htPara["MemberID"] = UserID;
            //htPara["CustomerID"] = CurrentUserInfo.ClientID;
            //htPara["PageIndex"] = 1;
            //htPara["PageSize"] = 10;
            //DataSet dsMyAccount = unitBll.GetMyAccount(htPara);

            //if (dsMyAccount.Tables[0].Rows.Count > 0)
            //{
            //    //rd.AccountList = DataTableToObject.ConvertToList<AccountInfo>(dsMyAccount.Tables[0]);
            //    //rd.MemberInfo.Balance = Convert.ToDecimal(dsMyAccount.Tables[0].Rows[0]["Total"].ToString());
            //    //rd.TotalPageCount = int.Parse(dsMyAccount.Tables[0].Rows[0]["PageCount"].ToString());

            //}
            //else
            //    rd.MemberInfo.Balance = 0;

            //返现 add by Henry 2015-4-15
            var vipAmountBll = new VipAmountBLL(CurrentUserInfo);
            //var vipAmountInfo = vipAmountBll.GetByID(UserID);
            var vipAmountInfo = vipAmountBll.QueryByEntity(new VipAmountEntity()
            {
                VipId = UserID, VipCardCode = VipLoginInfo.VipCode
            }, null).FirstOrDefault();
            decimal returnAmount = 0;
            decimal amount       = 0;
            if (vipAmountInfo != null)
            {
                returnAmount = vipAmountInfo.ValidReturnAmount == null ? 0 : vipAmountInfo.ValidReturnAmount.Value;
                amount       = vipAmountInfo.EndAmount == null ? 0 : vipAmountInfo.EndAmount.Value;
            }
            rd.MemberInfo.ReturnAmount = returnAmount; //返现
            rd.MemberInfo.Balance      = amount;       //余额
            #endregion


            //获取订单的日期和订单的里的商品名称、商品单价、商品数量
            //先获取订单列表,再获取订单详细信息
            int?         pageSize     = 3; //rp.Parameters.PageSize;,只取三条记录
            int?         pageIndex    = 1; //rp.Parameters.PageIndex;
            string       OrderBy      = "";
            string       OrderType    = "";
            T_InoutBLL   T_InoutBLL   = new T_InoutBLL(CurrentUserInfo);
            InoutService InoutService = new InoutService(CurrentUserInfo);
            //只取状态为700的
            //根据订单列表取订单详情
            DataSet dsOrder = T_InoutBLL.GetOrdersByVipID(rd.MemberInfo.VipID, pageIndex ?? 1, pageSize ?? 15, OrderBy, OrderType);//获取会员信息
            if (dsOrder != null && dsOrder.Tables.Count != 0 && dsOrder.Tables[0].Rows.Count != 0)
            {
                List <JIT.CPOS.DTO.Module.VIP.Login.Response.OrderInfo> orderList = DataTableToObject.ConvertToList <JIT.CPOS.DTO.Module.VIP.Login.Response.OrderInfo>(dsOrder.Tables[1]);
                foreach (JIT.CPOS.DTO.Module.VIP.Login.Response.OrderInfo oi in orderList)
                {
                    IList <InoutDetailInfo> detailList = InoutService.GetInoutDetailInfoByOrderId(oi.order_id);
                    oi.DetailList = detailList;
                }
                rd.OrderList = orderList;
            }

            MessageInfo message = new MessageInfo();


            InnerGroupNewsBLL InnerGroupNewsService = new InnerGroupNewsBLL(CurrentUserInfo);
            SetoffToolsBLL    setofftoolsService    = new SetoffToolsBLL(CurrentUserInfo);

            //1=微信用户 2=APP员工
            int UnReadInnerMessageCount = InnerGroupNewsService.GetVipInnerGroupNewsUnReadCount(CurrentUserInfo.UserID, pRequest.CustomerID, 1, null, Convert.ToDateTime(VipLoginInfo.CreateTime));
            var setofftoolsMessageCount = setofftoolsService.GetUnReadSetoffToolsCount(CurrentUserInfo.UserID, pRequest.CustomerID, 1, 1);
            message.InnerGroupNewsCount = UnReadInnerMessageCount;
            message.SetoffToolsCount    = setofftoolsMessageCount;
            var VipUpNewsInfo = InnerGroupNewsService.GetVipInnerNewsInfo(CurrentUserInfo.ClientID, 2, 1, 3, 0);
            if (VipUpNewsInfo != null && VipUpNewsInfo.Tables[0].Rows.Count > 0)
            {
                message.UpGradeSucess = VipUpNewsInfo.Tables[0].Rows[0]["Text"] != null ? VipUpNewsInfo.Tables[0].Rows[0]["Text"].ToString() : "";
                //获取通知信息 并更新已读状态 数据如果不是一条进行更新所有数据
                var newsUserMappingBLL = new NewsUserMappingBLL(CurrentUserInfo);
                if (VipUpNewsInfo.Tables[0].Rows.Count > 1)//数据如果不是一条进行更新所有数据
                {
                    foreach (DataRow VipNewsdr in VipUpNewsInfo.Tables[0].Rows)
                    {
                        var vipNewsInfo = newsUserMappingBLL.QueryByEntity(new NewsUserMappingEntity()
                        {
                            CustomerId = CurrentUserInfo.ClientID, MappingID = VipNewsdr["MappingID"].ToString()
                        }, null).FirstOrDefault();
                        if (vipNewsInfo != null)
                        {
                            vipNewsInfo.HasRead = 1;
                            newsUserMappingBLL.Update(vipNewsInfo);
                        }
                    }
                }
                else
                {
                    var vipNewsInfo = newsUserMappingBLL.QueryByEntity(new NewsUserMappingEntity()
                    {
                        CustomerId = CurrentUserInfo.ClientID, MappingID = VipUpNewsInfo.Tables[0].Rows[0]["MappingID"].ToString()
                    }, null).FirstOrDefault();
                    if (vipNewsInfo != null)
                    {
                        vipNewsInfo.HasRead = 1;
                        newsUserMappingBLL.Update(vipNewsInfo);
                    }
                }
            }
            else
            {
                message.UpGradeSucess = "";
            }
            rd.MessageInfo = message;
            return(rd);
        }
    }
        protected override GetSysVipCardTypeDetailRD ProcessRequest(DTO.Base.APIRequest <DelSysVipCardTypeRP> pRequest)
        {
            var rd   = new GetSysVipCardTypeDetailRD();
            var para = pRequest.Parameters;
            var loggingSessionInfo = new SessionManager().CurrentUserLoginInfo;
            var sysVipCardTypeBLL  = new SysVipCardTypeBLL(loggingSessionInfo);
            var vipCardRuleBLL     = new VipCardRuleBLL(loggingSessionInfo);
            var specialDateBLL     = new SpecialDateBLL(loggingSessionInfo);

            //获取卡类型信息
            var vipCardTypeInfo = sysVipCardTypeBLL.GetByID(para.VipCardTypeID);

            if (vipCardTypeInfo != null)
            {
                rd.VipCardTypeID     = vipCardTypeInfo.VipCardTypeID;
                rd.VipCardTypeCode   = vipCardTypeInfo.VipCardTypeCode;
                rd.VipCardTypeName   = vipCardTypeInfo.VipCardTypeName;
                rd.PicUrl            = vipCardTypeInfo.PicUrl;
                rd.Category          = vipCardTypeInfo.Category;
                rd.IsPassword        = vipCardTypeInfo.IsPassword;
                rd.VipCardLevel      = vipCardTypeInfo.VipCardLevel;
                rd.Prices            = vipCardTypeInfo.Prices;
                rd.IsExtraMoney      = vipCardTypeInfo.IsExtraMoney;
                rd.ExchangeIntegral  = vipCardTypeInfo.ExchangeIntegral;
                rd.UpgradeAmount     = vipCardTypeInfo.UpgradeAmount;
                rd.UpgradeOnceAmount = vipCardTypeInfo.UpgradeOnceAmount;
                rd.UpgradePoint      = vipCardTypeInfo.UpgradePoint;

                //获取卡规则信息
                var vipCardRuleInfo = vipCardRuleBLL.QueryByEntity(new VipCardRuleEntity()
                {
                    VipCardTypeID = para.VipCardTypeID
                }, null).FirstOrDefault();
                if (vipCardRuleInfo != null)
                {
                    rd.CardDiscount    = vipCardRuleInfo.CardDiscount;
                    rd.PointsMultiple  = vipCardRuleInfo.PointsMultiple;
                    rd.ChargeFull      = vipCardRuleInfo.ChargeFull;
                    rd.ChargeGive      = vipCardRuleInfo.ChargeGive;
                    rd.PaidGivePoints  = vipCardRuleInfo.PaidGivePoints;
                    rd.ReturnAmountPer = vipCardRuleInfo.ReturnAmountPer;
                }
                //获取特殊日期设置信息
                //查询参数
                List <IWhereCondition> complexCondition = new List <IWhereCondition> {
                };
                complexCondition.Add(new EqualsCondition()
                {
                    FieldName = "sd.VipCardTypeID", Value = para.VipCardTypeID
                });
                var orderBy = new OrderBy[] { new OrderBy()
                                              {
                                                  FieldName = "sd.CreateTime", Direction = OrderByDirections.Asc
                                              } };                                                                               //排序字段
                var specialDateList = specialDateBLL.GetSpecialDateList(complexCondition.ToArray(), orderBy.ToArray());
                rd.SpecialDateList = specialDateList.Select(t => new SpecialDateInfo()
                {
                    SpecialID           = t.SpecialId,
                    HolidayName         = t.HolidayName,
                    BeginDate           = t.BeginDate.Value.ToString("yyyy-MM-dd"),
                    EndDate             = t.EndDate.Value.ToString("yyyy-MM-dd"),
                    NoAvailablePoints   = t.NoAvailablePoints,
                    NoAvailableDiscount = t.NoAvailableDiscount,
                    NoRewardPoints      = t.NoRewardPoints
                }).ToList();
            }
            return(rd);
        }
Example #16
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);
        }
Example #17
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);
        }
Example #18
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);
        }
Example #19
0
        protected override GetRechargeActivityListRD ProcessRequest(DTO.Base.APIRequest <GetRechargeActivityListRP> pRequest)
        {
            var rd   = new GetRechargeActivityListRD();
            var para = pRequest.Parameters;
            LoggingSessionInfo loggingSessionInfo = Default.GetBSLoggingSession(pRequest.CustomerID, pRequest.UserID);
            var vipBLL               = new VipBLL(loggingSessionInfo);
            var vipIntegralBLL       = new VipIntegralBLL(loggingSessionInfo);
            var sysVipCardTypeBLL    = new SysVipCardTypeBLL(loggingSessionInfo);
            var vipCardVipMappingBLL = new VipCardVipMappingBLL(loggingSessionInfo);
            var vipCardBLL           = new VipCardBLL(loggingSessionInfo);
            var vipCardRuleBLL       = new VipCardRuleBLL(loggingSessionInfo);
            var vipAmountBLL         = new VipAmountBLL(loggingSessionInfo);
            //获取当前会员卡等级
            VipEntity VipInfo         = null;
            int?      CurVipCardLevel = 0;

            VipInfo = vipBLL.GetByID(para.VipID);
            if (VipInfo != null)
            {
                rd.HeadImgUrl = VipInfo.HeadImgUrl == null ? "" : VipInfo.HeadImgUrl;
                rd.VipName    = VipInfo.VipName != null ? VipInfo.VipName : VipInfo.VipRealName != null ? VipInfo.VipRealName : "";
                //获取当前会员积分信息
                //var vipIntegralInfo = vipIntegralBLL.QueryByEntity(new VipIntegralEntity() { VipID = para.VipID, VipCardCode = VipInfo.VipCode }, null).FirstOrDefault();
                //if (vipIntegralInfo != null)
                //{
                //    rd.Integration = vipIntegralInfo.ValidIntegral != null ? vipIntegralInfo.ValidIntegral.Value : 0;
                //}
                //获取当前会员余额信息
                var vipAmountInfo = vipAmountBLL.QueryByEntity(new VipAmountEntity()
                {
                    VipId = para.VipID, VipCardCode = VipInfo.VipCode
                }, null).FirstOrDefault();
                if (vipAmountInfo != null)
                {
                    rd.VipAmount = vipAmountInfo.EndAmount != null ? vipAmountInfo.EndAmount : 0;
                }
                else
                {
                    rd.VipAmount = 0;
                }
                //获取当前关联信息
                var vipCardMappingInfo = vipCardVipMappingBLL.QueryByEntity(new VipCardVipMappingEntity()
                {
                    VIPID = para.VipID, CustomerID = loggingSessionInfo.ClientID
                },
                                                                            new OrderBy[] { new OrderBy()
                                                                                            {
                                                                                                FieldName = "CreateTime", Direction = OrderByDirections.Desc
                                                                                            } }).FirstOrDefault();
                if (vipCardMappingInfo != null)
                {
                    //获取卡等级主标识信息
                    var vipCardInfo = vipCardBLL.QueryByEntity(new VipCardEntity()
                    {
                        VipCardID = vipCardMappingInfo.VipCardID, VipCardStatusId = 1
                    }, null).FirstOrDefault();
                    if (vipCardInfo != null)
                    {
                        //获取卡等级信息
                        var vipCardTypeInfo = sysVipCardTypeBLL.QueryByEntity(new SysVipCardTypeEntity()
                        {
                            VipCardTypeID = vipCardInfo.VipCardTypeID
                        }, null).FirstOrDefault();
                        if (vipCardTypeInfo != null)
                        {
                            rd.VipCardTypeName = vipCardTypeInfo.VipCardTypeName != null ? vipCardTypeInfo.VipCardTypeName : "";
                            CurVipCardLevel    = vipCardTypeInfo.VipCardLevel;
                        }
                        //获取充值活动列表
                        var rechargeStrategyBLL  = new RechargeStrategyBLL(loggingSessionInfo);
                        var RechargeActivityInfo = rechargeStrategyBLL.GetRechargeActivityList(loggingSessionInfo.ClientID, vipCardInfo.VipCardTypeID.ToString(), 3);
                        if (RechargeActivityInfo != null && RechargeActivityInfo.Tables[0].Rows.Count > 0)
                        {
                            rd.RechargeStrategyList = DataTableToObject.ConvertToList <RechargeStrategyInfo>(RechargeActivityInfo.Tables[0]);
                        }
                    }
                }
            }
            return(rd);
        }
Example #20
0
        protected override GetVipIntegralInfoListRD ProcessRequest(DTO.Base.APIRequest <GetVipIntegralInfoListRP> pRequest)
        {
            LoggingSessionInfo loggingSessionInfo = Default.GetBSLoggingSession(pRequest.CustomerID, pRequest.UserID);
            SysVipCardTypeBLL  bll = new SysVipCardTypeBLL(loggingSessionInfo);
            VipCardRuleBLL     VipCardRuleService = new VipCardRuleBLL(loggingSessionInfo);
            var vipCardVipMappingBLL = new VipCardVipMappingBLL(loggingSessionInfo);
            var vipCardBLL           = new VipCardBLL(loggingSessionInfo);
            var vipCardTypeBLL       = new SysVipCardTypeBLL(loggingSessionInfo);
            var rd = new GetVipIntegralInfoListRD();

            string[] CustomerBaseSettingCode = new string[] { "IntegralAmountPer", "PointsRedeemLowestLimit", "PointsRedeemUpLimit", "PointsValidPeriod" };
            string[] CustomerBaseSettingDesc = new string[] { "积分抵扣比例", "账户积分累计满", "每单可使用积分上限", "积分有效期" };

            CustomerBasicSettingBLL CustomerBasicSettingService = new CustomerBasicSettingBLL(loggingSessionInfo);

            //循环获取积分信息
            for (int i = 0; i < CustomerBaseSettingCode.Length; i++)
            {
                var entity = CustomerBasicSettingService.QueryByEntity(new CustomerBasicSettingEntity()
                {
                    CustomerID = loggingSessionInfo.ClientID, IsDelete = 0, SettingCode = CustomerBaseSettingCode[i]
                }, null).FirstOrDefault();
                if (entity != null)
                {
                    rd.VipIntegralInfoList.Add(new VipIntegralInfo()
                    {
                        CustomerBaseSettingDesc = CustomerBaseSettingDesc[i], CustomerBaseSettingValue = entity.SettingValue
                    });
                }
                else
                {
                    rd.VipIntegralInfoList.Add(new VipIntegralInfo()
                    {
                        CustomerBaseSettingDesc = CustomerBaseSettingDesc[i], CustomerBaseSettingValue = "0"
                    });
                }
            }
            //获取会员 卡映射关系
            var vipCardMappingInfo = vipCardVipMappingBLL.QueryByEntity(new VipCardVipMappingEntity()
            {
                VIPID = pRequest.UserID, CustomerID = CurrentUserInfo.ClientID
            },
                                                                        new OrderBy[] { new OrderBy()
                                                                                        {
                                                                                            FieldName = "CreateTime", Direction = OrderByDirections.Desc
                                                                                        } }).FirstOrDefault();

            if (vipCardMappingInfo != null)
            {
                //获取卡信息
                var vipCardInfo = vipCardBLL.QueryByEntity(new VipCardEntity()
                {
                    VipCardID = vipCardMappingInfo.VipCardID, VipCardStatusId = 1
                }, null).FirstOrDefault();
                if (vipCardInfo != null)
                {
                    //获取会员卡信息
                    var vipCardTypeInfo = vipCardTypeBLL.QueryByEntity(new SysVipCardTypeEntity()
                    {
                        VipCardTypeID = vipCardInfo.VipCardTypeID
                    }, null).FirstOrDefault();
                    if (vipCardTypeInfo != null)
                    {
                        //获取卡升级规则信息
                        var cardrulemodel = VipCardRuleService.QueryByEntity(new VipCardRuleEntity()
                        {
                            VipCardTypeID = vipCardTypeInfo.VipCardTypeID
                        }, null).FirstOrDefault();
                        if (cardrulemodel != null)
                        {
                            if (cardrulemodel.PaidGivePoints > 0) //积分
                            {
                                rd.VipIntegralInfoList.Add(new VipIntegralInfo()
                                {
                                    CustomerBaseSettingDesc = "每消费" + Convert.ToInt32(cardrulemodel.PaidGivePoints) + "元返 1积分", CustomerBaseSettingValue = Convert.ToInt32(cardrulemodel.PaidGivePoints) + ""
                                });
                            }
                            if (cardrulemodel.PaidGivePercetPoints > 0) //积分比例
                            {
                                rd.VipIntegralInfoList.Add(new VipIntegralInfo()
                                {
                                    CustomerBaseSettingDesc = "消费返积分比例" + Convert.ToInt32(cardrulemodel.PaidGivePercetPoints) + "%", CustomerBaseSettingValue = Convert.ToInt32(cardrulemodel.PaidGivePercetPoints) + ""
                                });
                            }
                        }
                    }
                }
            }
            return(rd);
        }