示例#1
0
        protected override GetSetOffIncentiveRD ProcessRequest(APIRequest <GetSetOffIncentiveRP> pRequest)
        {
            GetSetOffIncentiveRD incentiveRuleRD  = new GetSetOffIncentiveRD();
            IincentiveRuleBLL    incentiveRuleBLL = new IincentiveRuleBLL(CurrentUserInfo);
            var para = pRequest.Parameters;
            //根据平台类型获取激励信息
            var IncentiveRule = incentiveRuleBLL.GetIncentiveRule(para.PlatformType);

            if (IncentiveRule != null && IncentiveRule.Tables[0].Rows.Count > 0)
            {
                incentiveRuleRD.SetoffRegAwardType = Convert.ToInt32(IncentiveRule.Tables[0].Rows[0]["SetoffRegAwardType"]); //激励类型 积分或现金
                incentiveRuleRD.SetoffRegPrize     = IncentiveRule.Tables[0].Rows[0]["SetoffRegPrize"].ToString();           //奖励金额或积分数量
                incentiveRuleRD.SetoffOrderPer     = Convert.ToDecimal(IncentiveRule.Tables[0].Rows[0]["SetoffOrderPer"]);   //订单销售成功提成比例
            }
            return(incentiveRuleRD);
        }
示例#2
0
        protected override EmptyResponseData ProcessRequest(DTO.Base.APIRequest <SetOffActionRP> pRequest)
        {
            var rd   = new EmptyResponseData();
            var para = pRequest.Parameters;
            var loggingSessionInfo      = new SessionManager().CurrentUserLoginInfo;
            var SetoffEventBll          = new SetoffEventBLL(loggingSessionInfo);
            var IincentiveRuleBll       = new IincentiveRuleBLL(loggingSessionInfo);
            var ObjectImagesBll         = new ObjectImagesBLL(loggingSessionInfo);
            var SetoffToolsBll          = new SetoffToolsBLL(loggingSessionInfo);
            var SetoffPosterBll         = new SetoffPosterBLL(loggingSessionInfo);
            var CustomerBasicSettingBll = new CustomerBasicSettingBLL(loggingSessionInfo);
            //
            var    pTran       = SetoffEventBll.GetTran();
            string _CustomerId = loggingSessionInfo.ClientID;

            if (para.SetOffActionList.Count > 0)
            {
                //using (pTran.Connection)
                //{
                try
                {
                    foreach (var item in para.SetOffActionList)
                    {
                        List <CustomerBasicSettingEntity> settingList = new List <CustomerBasicSettingEntity>();  //基础配置数据

                        //获取已发布的集客行动
                        var SetoffEvenResult = SetoffEventBll.QueryByEntity(new SetoffEventEntity()
                        {
                            SetoffType = item.SetoffType, Status = "10", CustomerId = loggingSessionInfo.ClientID
                        }, null).ToList();
                        if (SetoffEvenResult.Count > 1)
                        {
                            throw new APIException("数据异常,只能有一种集客行动!")
                                  {
                                      ErrorCode = ERROR_CODES.INVALID_BUSINESS
                                  }
                        }
                        ;

                        if (SetoffEvenResult.Count > 0)
                        {
                            var Result   = SetoffEvenResult.First();  //集客行动
                            var RuleData = IincentiveRuleBll.QueryByEntity(new IincentiveRuleEntity()
                            {
                                SetoffEventID = Result.SetoffEventID, CustomerId = loggingSessionInfo.ClientID
                            }, null).FirstOrDefault();
                            if (RuleData == null)
                            {
                                throw new APIException("数据异常,找不到奖励规则!")
                                      {
                                          ErrorCode = ERROR_CODES.INVALID_BUSINESS
                                      }
                            }
                            ;
                            //判断奖励是否变动
                            if (item.SetoffRegAwardType != RuleData.SetoffRegAwardType ||
                                item.SetoffRegPrize != RuleData.SetoffRegPrize || item.SetoffOrderPer != RuleData.SetoffOrderPer ||
                                item.SetoffOrderTimers != RuleData.SetoffOrderTimers || item.IsEnabled != Convert.ToInt32(RuleData.Status))
                            {
                                //原集客行动状态设置为失效
                                SetoffEventBll.SetFailStatus(item.SetoffType, loggingSessionInfo.ClientID);

                                #region 规则变动,重新新建集客行动
                                //集客行动
                                //集客行动
                                var SetoffEvenData = new SetoffEventEntity();    //集客行动
                                SetoffEvenData.SetoffEventID = System.Guid.NewGuid();
                                SetoffEvenData.SetoffType    = item.SetoffType;
                                SetoffEvenData.Status        = "10";
                                SetoffEvenData.CustomerId    = _CustomerId;
                                SetoffEventBll.Create(SetoffEvenData);               //

                                var IincentiveRuleData = new IincentiveRuleEntity(); //奖励规则
                                IincentiveRuleData.IincentiveRuleID   = System.Guid.NewGuid();
                                IincentiveRuleData.SetoffEventID      = SetoffEvenData.SetoffEventID;
                                IincentiveRuleData.SetoffType         = item.SetoffType;
                                IincentiveRuleData.ApplyUnit          = 0;
                                IincentiveRuleData.SetoffRegAwardType = item.SetoffRegAwardType;
                                IincentiveRuleData.SetoffRegPrize     = item.SetoffRegPrize;
                                IincentiveRuleData.SetoffOrderPer     = item.SetoffOrderPer;
                                IincentiveRuleData.SetoffOrderTimers  = item.SetoffOrderTimers;
                                IincentiveRuleData.Status             = item.IsEnabled.ToString();
                                IincentiveRuleData.CustomerId         = _CustomerId;
                                IincentiveRuleBll.Create(IincentiveRuleData);    //

                                #region 新增集客海报、海报集客工具关系
                                foreach (var PosterItem in item.SetoffPosterList)
                                {
                                    //图片表
                                    var ObjectImageData = new ObjectImagesEntity();
                                    ObjectImageData.ImageId     = System.Guid.NewGuid().ToString("N");
                                    ObjectImageData.ImageURL    = PosterItem.ImageUrl;
                                    ObjectImageData.Description = "集客海报";
                                    ObjectImageData.CustomerId  = _CustomerId;
                                    ObjectImagesBll.Create(ObjectImageData);    //
                                    //集客海报
                                    var SetoffPosterData = new SetoffPosterEntity();
                                    SetoffPosterData.SetoffPosterID = System.Guid.NewGuid();
                                    SetoffPosterData.Name           = PosterItem.Name;
                                    SetoffPosterData.Desc           = "集客海报";
                                    SetoffPosterData.ImageId        = ObjectImageData.ImageId;
                                    SetoffPosterData.Status         = "10";
                                    SetoffPosterData.CustomerId     = _CustomerId;
                                    SetoffPosterBll.Create(SetoffPosterData);

                                    //海报工具关系
                                    var SetoffToolsData = new SetoffToolsEntity();
                                    SetoffToolsData.SetoffToolID  = System.Guid.NewGuid();
                                    SetoffToolsData.SetoffEventID = SetoffEvenData.SetoffEventID;
                                    SetoffToolsData.ToolType      = "SetoffPoster";
                                    SetoffToolsData.ObjectId      = SetoffPosterData.SetoffPosterID.ToString();
                                    SetoffToolsData.Status        = "10";
                                    SetoffToolsData.CustomerId    = _CustomerId;
                                    SetoffToolsBll.Create(SetoffToolsData);    //
                                }
                                #endregion

                                #region 新增集客工具关系
                                foreach (var ToolsItem in item.SetoffTools)
                                {
                                    //判断是否添加重复集客工具
                                    bool Flag = SetoffEventBll.IsToolsRepeat(SetoffEvenData.SetoffEventID.ToString(), ToolsItem.ObjectId);
                                    if (Flag)
                                    {
                                        throw new APIException("集客行动不能添加相同的集客工具!")
                                              {
                                                  ErrorCode = ERROR_CODES.INVALID_BUSINESS
                                              }
                                    }
                                    ;

                                    var SetoffToolsData = new SetoffToolsEntity();
                                    SetoffToolsData.SetoffToolID  = System.Guid.NewGuid();
                                    SetoffToolsData.SetoffEventID = SetoffEvenData.SetoffEventID;
                                    SetoffToolsData.ToolType      = ToolsItem.ToolType;
                                    SetoffToolsData.ObjectId      = ToolsItem.ObjectId;
                                    SetoffToolsData.Status        = "10";
                                    SetoffToolsData.CustomerId    = _CustomerId;
                                    SetoffToolsBll.Create(SetoffToolsData);    //
                                }
                                #endregion

                                #endregion

                                #region 更新配置奖励系数
                                //集客销售订单分润配置
                                //var SettingData = CustomerBasicSettingBll.QueryByEntity(new CustomerBasicSettingEntity() { SettingCode = "GetVipUserOrderPer", CustomerID = CurrentUserInfo.ClientID, IsDelete = 0 }, null).FirstOrDefault();
                                //if (SettingData != null)
                                //{
                                //    SettingData.SettingValue = IincentiveRuleData.SetoffOrderPer.ToString();
                                //    CustomerBasicSettingBll.Update(SettingData);
                                //}
                                if (IincentiveRuleData.SetoffType == 2)
                                {
                                    settingList.Add(new CustomerBasicSettingEntity()
                                    {
                                        SettingCode  = "GetVipUserOrderPer",
                                        SettingValue = (IincentiveRuleData.SetoffOrderPer ?? 0).ToString()
                                    });
                                }
                                if (IincentiveRuleData.SetoffRegAwardType == 2)
                                {
                                    settingList.Add(new CustomerBasicSettingEntity()
                                    {
                                        SettingCode  = "InvitePartnersPoints",
                                        SettingValue = (IincentiveRuleData.SetoffRegPrize ?? 0).ToString()
                                    });
                                }
                                CustomerBasicSettingBll.SaveCustomerBasicInfo(loggingSessionInfo.ClientID, settingList);
                                //集客注册奖励配置
                                #endregion
                            }
                            else
                            {
                                #region 新增集客海报、海报集客工具关系
                                foreach (var PosterItem in item.SetoffPosterList)
                                {
                                    //图片表
                                    var ObjectImageData = new ObjectImagesEntity();
                                    ObjectImageData.ImageId     = System.Guid.NewGuid().ToString("N");
                                    ObjectImageData.ImageURL    = PosterItem.ImageUrl;
                                    ObjectImageData.Description = "集客海报";
                                    ObjectImageData.CustomerId  = _CustomerId;
                                    ObjectImagesBll.Create(ObjectImageData);    //
                                    //集客海报
                                    var SetoffPosterData = new SetoffPosterEntity();
                                    SetoffPosterData.SetoffPosterID = System.Guid.NewGuid();
                                    SetoffPosterData.Name           = PosterItem.Name;
                                    SetoffPosterData.Desc           = "集客海报";
                                    SetoffPosterData.ImageId        = ObjectImageData.ImageId;
                                    SetoffPosterData.Status         = "10";
                                    SetoffPosterData.CustomerId     = _CustomerId;
                                    SetoffPosterBll.Create(SetoffPosterData);

                                    //海报工具关系
                                    var SetoffToolsData = new SetoffToolsEntity();
                                    SetoffToolsData.SetoffToolID  = System.Guid.NewGuid();
                                    SetoffToolsData.SetoffEventID = Result.SetoffEventID;
                                    SetoffToolsData.ToolType      = "SetoffPoster";
                                    SetoffToolsData.ObjectId      = SetoffPosterData.SetoffPosterID.ToString();
                                    SetoffToolsData.Status        = "10";
                                    SetoffToolsData.CustomerId    = _CustomerId;
                                    SetoffToolsBll.Create(SetoffToolsData);    //
                                }
                                #endregion

                                #region 新增集客工具关系
                                foreach (var ToolsItem in item.SetoffTools)
                                {
                                    //
                                    if (Result == null)
                                    {
                                        throw new APIException("数据异常,未找到集客行动!")
                                              {
                                                  ErrorCode = ERROR_CODES.INVALID_BUSINESS
                                              }
                                    }
                                    ;
                                    //判断是否添加重复集客工具
                                    bool Flag = SetoffEventBll.IsToolsRepeat(Result.SetoffEventID.ToString(), ToolsItem.ObjectId);
                                    if (Flag)
                                    {
                                        throw new APIException("集客行动不能添加相同的集客工具!")
                                              {
                                                  ErrorCode = ERROR_CODES.INVALID_BUSINESS
                                              }
                                    }
                                    ;

                                    var SetoffToolsData = new SetoffToolsEntity();
                                    SetoffToolsData.SetoffToolID  = System.Guid.NewGuid();
                                    SetoffToolsData.SetoffEventID = Result.SetoffEventID;
                                    SetoffToolsData.ToolType      = ToolsItem.ToolType;
                                    SetoffToolsData.ObjectId      = ToolsItem.ObjectId;
                                    SetoffToolsData.Status        = "10";
                                    SetoffToolsData.CustomerId    = _CustomerId;
                                    SetoffToolsBll.Create(SetoffToolsData);    //
                                }
                                #endregion
                            }
                        }
                        else
                        {
                            //原集客行动状态设置为失效
                            SetoffEventBll.SetFailStatus(item.SetoffType, loggingSessionInfo.ClientID);

                            #region 新建集客行动
                            //集客行动
                            var SetoffEvenData = new SetoffEventEntity();    //集客行动
                            SetoffEvenData.SetoffEventID = System.Guid.NewGuid();
                            SetoffEvenData.SetoffType    = item.SetoffType;
                            SetoffEvenData.Status        = "10";
                            SetoffEvenData.CustomerId    = _CustomerId;
                            SetoffEventBll.Create(SetoffEvenData);               //

                            var IincentiveRuleData = new IincentiveRuleEntity(); //奖励规则
                            IincentiveRuleData.IincentiveRuleID   = System.Guid.NewGuid();
                            IincentiveRuleData.SetoffEventID      = SetoffEvenData.SetoffEventID;
                            IincentiveRuleData.SetoffType         = item.SetoffType;
                            IincentiveRuleData.ApplyUnit          = 0;
                            IincentiveRuleData.SetoffRegAwardType = item.SetoffRegAwardType;
                            IincentiveRuleData.SetoffRegPrize     = item.SetoffRegPrize;
                            IincentiveRuleData.SetoffOrderPer     = item.SetoffOrderPer;
                            IincentiveRuleData.SetoffOrderTimers  = item.SetoffOrderTimers;
                            IincentiveRuleData.Status             = item.IsEnabled.ToString();
                            IincentiveRuleData.CustomerId         = _CustomerId;
                            IincentiveRuleBll.Create(IincentiveRuleData);    //

                            #region 新增集客海报、海报集客工具关系
                            foreach (var PosterItem in item.SetoffPosterList)
                            {
                                //图片表
                                var ObjectImageData = new ObjectImagesEntity();
                                ObjectImageData.ImageId     = System.Guid.NewGuid().ToString("N");
                                ObjectImageData.ImageURL    = PosterItem.ImageUrl;
                                ObjectImageData.Description = "集客海报";
                                ObjectImageData.CustomerId  = _CustomerId;
                                ObjectImagesBll.Create(ObjectImageData);    //
                                //集客海报
                                var SetoffPosterData = new SetoffPosterEntity();
                                SetoffPosterData.SetoffPosterID = System.Guid.NewGuid();
                                SetoffPosterData.Name           = PosterItem.Name;
                                SetoffPosterData.Desc           = "集客海报";
                                SetoffPosterData.ImageId        = ObjectImageData.ImageId;
                                SetoffPosterData.Status         = "10";
                                SetoffPosterData.CustomerId     = _CustomerId;
                                SetoffPosterBll.Create(SetoffPosterData);

                                //海报工具关系
                                var SetoffToolsData = new SetoffToolsEntity();
                                SetoffToolsData.SetoffToolID  = System.Guid.NewGuid();
                                SetoffToolsData.SetoffEventID = SetoffEvenData.SetoffEventID;
                                SetoffToolsData.ToolType      = "SetoffPoster";
                                SetoffToolsData.ObjectId      = SetoffPosterData.SetoffPosterID.ToString();
                                SetoffToolsData.Status        = "10";
                                SetoffToolsData.CustomerId    = _CustomerId;
                                SetoffToolsBll.Create(SetoffToolsData);    //
                            }
                            #endregion

                            #region 新增集客工具关系
                            foreach (var ToolsItem in item.SetoffTools)
                            {
                                //判断是否添加重复集客工具
                                bool Flag = SetoffEventBll.IsToolsRepeat(SetoffEvenData.SetoffEventID.ToString(), ToolsItem.ObjectId);
                                if (Flag)
                                {
                                    throw new APIException("集客行动不能添加相同的集客工具!")
                                          {
                                              ErrorCode = ERROR_CODES.INVALID_BUSINESS
                                          }
                                }
                                ;

                                var SetoffToolsData = new SetoffToolsEntity();
                                SetoffToolsData.SetoffToolID  = System.Guid.NewGuid();
                                SetoffToolsData.SetoffEventID = SetoffEvenData.SetoffEventID;
                                SetoffToolsData.ToolType      = ToolsItem.ToolType;
                                SetoffToolsData.ObjectId      = ToolsItem.ObjectId;
                                SetoffToolsData.Status        = "10";
                                SetoffToolsData.CustomerId    = _CustomerId;
                                SetoffToolsBll.Create(SetoffToolsData);    //
                            }
                            #endregion


                            #endregion


                            #region 更新配置奖励系数

                            if (IincentiveRuleData.SetoffType == 2)
                            {
                                //同步到原CustomerBasicSetting集客销售订单分润配置
                                //var SettingData = CustomerBasicSettingBll.QueryByEntity(new CustomerBasicSettingEntity() { SettingCode = "GetVipUserOrderPer", CustomerID = CurrentUserInfo.ClientID, IsDelete = 0 }, null).FirstOrDefault();
                                //if (SettingData != null)
                                //{
                                //    SettingData.SettingValue = (IincentiveRuleData.SetoffOrderPer ?? 0).ToString();
                                //    CustomerBasicSettingBll.Update(SettingData);
                                //}
                                settingList.Add(new CustomerBasicSettingEntity()
                                {
                                    SettingCode  = "GetVipUserOrderPer",
                                    SettingValue = (IincentiveRuleData.SetoffOrderPer ?? 0).ToString()
                                });
                            }
                            if (IincentiveRuleData.SetoffRegAwardType == 2)
                            {
                                //同步到原CustomerBasicSetting集客销售订单分润配置
                                //var SettingData = CustomerBasicSettingBll.QueryByEntity(new CustomerBasicSettingEntity() { SettingCode = "InvitePartnersPoints", CustomerID = CurrentUserInfo.ClientID, IsDelete = 0 }, null).FirstOrDefault();
                                //if (SettingData != null)
                                //{
                                //    SettingData.SettingValue = (IincentiveRuleData.SetoffRegPrize ?? 0).ToString();
                                //    CustomerBasicSettingBll.Update(SettingData);
                                //}
                                settingList.Add(new CustomerBasicSettingEntity()
                                {
                                    SettingCode  = "InvitePartnersPoints",
                                    SettingValue = (IincentiveRuleData.SetoffRegPrize ?? 0).ToString()
                                });
                            }
                            CustomerBasicSettingBll.SaveCustomerBasicInfo(loggingSessionInfo.ClientID, settingList);
                            #endregion
                        }
                    }
                    //
                    //pTran.Commit();
                }
                catch (APIException ex)
                {
                    //pTran.Rollback();
                    throw ex;
                }
                //}
            }
            return(rd);
        }
示例#3
0
        protected override GetSetOffActionRD ProcessRequest(DTO.Base.APIRequest <GetSetOffActionRP> pRequest)
        {
            var rd   = new GetSetOffActionRD();
            var para = pRequest.Parameters;
            var loggingSessionInfo = new SessionManager().CurrentUserLoginInfo;
            var SetoffEventBll     = new SetoffEventBLL(loggingSessionInfo);
            var SetoffToolsBll     = new SetoffToolsBLL(loggingSessionInfo);
            var SetoffPosterBll    = new SetoffPosterBLL(loggingSessionInfo);
            var IincentiveRuleBll  = new IincentiveRuleBLL(loggingSessionInfo);
            //集客行动主数据
            var SetoffEventResult = SetoffEventBll.QueryByEntity(new SetoffEventEntity()
            {
                Status = "10", CustomerId = loggingSessionInfo.ClientID
            }, null).ToList();

            //
            rd.GetSetOffActionInfoList = new List <GetSetOffActionInfo>();
            foreach (var item in SetoffEventResult)
            {
                //规则
                var RuleData = IincentiveRuleBll.QueryByEntity(new IincentiveRuleEntity()
                {
                    SetoffEventID = item.SetoffEventID, CustomerId = loggingSessionInfo.ClientID
                }, null).FirstOrDefault();

                var DataInfo = new GetSetOffActionInfo();
                DataInfo.SetoffEventID = item.SetoffEventID.ToString();
                DataInfo.SetoffType    = Convert.ToInt32(item.SetoffType);
                if (RuleData != null)
                {
                    DataInfo.SetoffRegAwardType   = RuleData.SetoffRegAwardType.Value;
                    DataInfo.SetoffRegPrize       = RuleData.SetoffRegPrize ?? 0;
                    DataInfo.SetoffOrderPer       = RuleData.SetoffOrderPer ?? 0;
                    DataInfo.SetoffOrderTimers    = RuleData.SetoffOrderTimers ?? 0;
                    DataInfo.IincentiveRuleStatus = Convert.ToInt32(RuleData.Status);
                }
                //集客工具关系
                var ToolsData = SetoffToolsBll.QueryByEntity(new SetoffToolsEntity()
                {
                    SetoffEventID = item.SetoffEventID, Status = "10", CustomerId = loggingSessionInfo.ClientID
                }, null).ToList();
                if (ToolsData != null)
                {
                    var ds = SetoffToolsBll.GetToolsDetails(item.SetoffEventID.ToString());
                    if (ds != null && ds.Tables[0].Rows.Count > 0)
                    {
                        DataInfo.GetSetoffToolsInfoList = new List <GetSetoffToolsInfo>();
                        var dt = ds.Tables[0];
                        foreach (DataRow dr in dt.Rows)
                        {
                            #region 过滤
                            if (dr["ToolType"].ToString().Equals("Coupon"))
                            {
                                if (string.IsNullOrWhiteSpace(dr["Name"].ToString()))
                                {
                                    continue;
                                }

                                if (dr["BeginData"] == DBNull.Value && dr["EndData"] == DBNull.Value)
                                {
                                    if (dr["ServiceLife"] != DBNull.Value)
                                    {
                                        if (Convert.ToInt32(dr["ServiceLife"]) <= 0)
                                        {
                                            continue;
                                        }
                                    }
                                }

                                //if (dr["SurplusCount"] != DBNull.Value)
                                //{
                                //    if (Convert.ToInt32(dr["SurplusCount"]) <= 0)
                                //        continue;
                                //}
                            }
                            #endregion

                            var Data = new GetSetoffToolsInfo();
                            Data.SetoffToolID = dr["SetoffToolID"].ToString();
                            Data.ToolType     = dr["ToolType"].ToString();
                            Data.Name         = dr["Name"].ToString();
                            Data.SurplusCount = Convert.ToInt32(dr["SurplusCount"]);
                            if (dr["ServiceLife"] != DBNull.Value)
                            {
                                Data.ServiceLife = Convert.ToInt32(dr["ServiceLife"]);
                            }
                            if (dr["BeginData"] != DBNull.Value)
                            {
                                Data.BeginData = Convert.ToDateTime(dr["BeginData"]).ToString("yyyy年MM月dd日");
                            }
                            if (dr["EndData"] != DBNull.Value)
                            {
                                Data.EndData = Convert.ToDateTime(dr["EndData"]).ToString("yyyy年MM月dd日");
                            }
                            if (dr["SetoffPosterUrl"] != DBNull.Value)
                            {
                                Data.SetoffPosterUrl = dr["SetoffPosterUrl"].ToString();
                            }
                            if (dr["ObjectId"] != DBNull.Value)
                            {
                                Data.ObjectId = dr["ObjectId"].ToString();
                            }

                            DataInfo.GetSetoffToolsInfoList.Add(Data);//
                        }
                    }
                }
                //
                rd.GetSetOffActionInfoList.Add(DataInfo);
            }


            return(rd);
        }
示例#4
0
        protected override GetSetoffToolsRD ProcessRequest(APIRequest <GetSetoffToolsRP> pRequest)
        {
            SetoffToolsBLL    setOffToolsBLL   = new SetoffToolsBLL(CurrentUserInfo);
            IincentiveRuleBLL incentiveRuleBLL = new IincentiveRuleBLL(CurrentUserInfo);
            var para = pRequest.Parameters;
            var setoffToolsEntity = new SetoffToolsEntity();

            if (para.ToolsType != null)
            {
                setoffToolsEntity.ToolType = para.ToolsType.ToString();
            }
            GetSetoffToolsRD setoffToolsRD = new GetSetoffToolsRD();
            var setoffEventBLL             = new SetoffEventBLL(CurrentUserInfo);
            //获取集客活动信息
            string NoticePlatType = string.Empty;

            if (string.IsNullOrEmpty(para.ApplicationType))
            {
                para.ApplicationType = "0";
            }
            else
            {
                switch (para.ApplicationType)
                {
                case "1":
                    NoticePlatType = "1";
                    break;

                case "2":
                    NoticePlatType = "2";
                    break;

                case "3":
                    NoticePlatType = "2";    //传3需要进行平台类型处理 等于3时获取员工集客行动平台
                    break;

                case "4":
                    NoticePlatType = "3";    //传4需要进行平台类型处理 等于4时获取超级分销商推广行动平台
                    break;
                }
            }
            var setOffEventInfo = setoffEventBLL.QueryByEntity(new SetoffEventEntity()
            {
                Status = "10", IsDelete = 0, SetoffType = Convert.ToInt32(NoticePlatType), CustomerId = CurrentUserInfo.CurrentUser.customer_id
            }, null);
            int     SetoffToolsTotalCount = 0;
            DataSet SetoffToolsList       = null;

            if (setOffEventInfo.Length != 0)
            {
                //获取集客活动工具数量
                SetoffToolsTotalCount = setOffToolsBLL.GeSetoffToolsListCount(setoffToolsEntity, para.ApplicationType, para.BeShareVipID, setOffEventInfo[0].SetoffEventID.ToString());
                //获取集客活动工具列表
                SetoffToolsList = setOffToolsBLL.GetSetoffToolsList(setoffToolsEntity, para.ApplicationType, para.BeShareVipID, para.PageIndex, para.PageSize, setOffEventInfo[0].SetoffEventID.ToString());
            }

            //获取集客奖励信息
            var IncentiveRule = incentiveRuleBLL.GetIncentiveRule(para.ApplicationType);

            setoffToolsRD.TotalCount = SetoffToolsTotalCount;
            int remainder = 0;

            if (para.PageSize == 0)
            {
                para.PageSize = 10;
            }
            setoffToolsRD.TotalPageCount = Math.DivRem(SetoffToolsTotalCount, para.PageSize, out remainder);
            if (remainder > 0)
            {
                setoffToolsRD.TotalPageCount++;
            }
            string strHost = ConfigurationManager.AppSettings["website_url"].Trim();

            if (SetoffToolsList != null && SetoffToolsList.Tables[0].Rows.Count > 0)
            {
                //为优惠券和海报添加图片路径
                SetoffToolsList.Tables[0].Columns.Add("ImageUrl", typeof(string));
                var CustomerBasicSettingBLL = new CustomerBasicSettingBLL(CurrentUserInfo);
                var CustomerBasicInfo       = CustomerBasicSettingBLL.QueryByEntity(new CustomerBasicSettingEntity()
                {
                    CustomerID = CurrentUserInfo.CurrentUser.customer_id, SettingCode = "SetoffPosterWeChatDefaultPhoto"
                }, null).FirstOrDefault();
                var    setOffPosterBLL  = new SetoffPosterBLL(CurrentUserInfo);
                var    ObjectImagesBLL  = new ObjectImagesBLL(CurrentUserInfo);
                var    T_CTW_LEventBLL  = new T_CTW_LEventBLL(CurrentUserInfo);
                var    wMaterialTextBLL = new WMaterialTextBLL(CurrentUserInfo);
                string SourceId         = string.Empty;
                if (!string.IsNullOrEmpty(para.ApplicationType))
                {
                    switch (para.ApplicationType)
                    {
                    case "1":
                        SourceId = "3";    //会员集客
                        break;

                    case "2":
                        SourceId = "1";    //APP会员服务;
                        break;

                    case "3":
                        SourceId = "3";    //APP会员服务;
                        break;

                    case "4":
                        SourceId = "4";    //超级分销商;
                        break;
                    }
                }
                string goUrl       = string.Empty;
                string goCouponUrl = strHost + "/HtmlApps/html/common/GatheringClient/Coupon.html?customerId=";                           //拼优惠券详细页面
                string goPosterUrl = strHost + "/HtmlApps/html/common/GatheringClient/poster.html?customerId=";                           //拼海报详细页面
                string strOAuthUrl = strHost + "/WXOAuth/AuthUniversal.aspx?scope=snsapi_userinfo&SourceId=" + SourceId + "&customerId="; //拼OAuth认证
                foreach (DataRow dr in SetoffToolsList.Tables[0].Rows)
                {
                    if (dr["ToolType"].ToString() == "Coupon")
                    {
                        if (CustomerBasicInfo != null)
                        {
                            dr["ImageUrl"] = CustomerBasicInfo.SettingValue;
                        }
                        if (para.ApplicationType == "4")
                        {
                            goUrl     = goCouponUrl + CurrentUserInfo.CurrentUser.customer_id + "&pushType=IsSuperRetail&ShareVipId=" + CurrentUserInfo.UserID + "&couponId=" + dr["ObjectId"] + "&version=";
                            dr["URL"] = strOAuthUrl + CurrentUserInfo.CurrentUser.customer_id + "&objectType=Coupon&ObjectID=" + dr["ObjectId"] + "&ShareVipID=" + CurrentUserInfo.UserID + "&goUrl=" + System.Web.HttpUtility.UrlEncode(goUrl);
                        }
                        else
                        {
                            //Oauth认证加商品详情页
                            goUrl     = goCouponUrl + CurrentUserInfo.CurrentUser.customer_id + "&ShareVipId=" + CurrentUserInfo.UserID + "&couponId=" + dr["ObjectId"] + "&version=";
                            dr["URL"] = strOAuthUrl + CurrentUserInfo.CurrentUser.customer_id + "&ShareVipID=" + CurrentUserInfo.UserID + "&goUrl=" + System.Web.HttpUtility.UrlEncode(goUrl);
                        }
                    }
                    if (dr["ToolType"].ToString() == "SetoffPoster")
                    {
                        var setOffPosterInfo = setOffPosterBLL.QueryByEntity(new SetoffPosterEntity()
                        {
                            SetoffPosterID = new Guid(dr["ObjectId"].ToString())
                        }, null).FirstOrDefault();
                        if (setOffPosterInfo != null)
                        {
                            var ObjectImgsInfo = ObjectImagesBLL.QueryByEntity(new ObjectImagesEntity()
                            {
                                ImageId = setOffPosterInfo.ImageId
                            }, null).FirstOrDefault();
                            if (ObjectImgsInfo != null)
                            {
                                dr["ImageUrl"] = ObjectImgsInfo.ImageURL;
                            }
                        }
                        if (para.ApplicationType == "4")
                        {
                            goUrl     = goPosterUrl + CurrentUserInfo.CurrentUser.customer_id + "&pushType=IsSuperRetail&ShareVipId=" + CurrentUserInfo.UserID + "&ObjectId=" + dr["ObjectId"] + "&version=";
                            dr["URL"] = strOAuthUrl + CurrentUserInfo.CurrentUser.customer_id + "&objectType=SetoffPoster&ObjectID=" + dr["ObjectId"] + "&ShareVipID=" + CurrentUserInfo.UserID + "&goUrl=" + System.Web.HttpUtility.UrlEncode(goUrl);
                        }
                        else
                        {
                            //Oauth认证加海报详情页
                            goUrl     = goPosterUrl + CurrentUserInfo.CurrentUser.customer_id + "&ShareVipId=" + CurrentUserInfo.UserID + "&ObjectId=" + dr["ObjectId"] + "&version=";
                            dr["URL"] = strOAuthUrl + CurrentUserInfo.CurrentUser.customer_id + "&ShareVipID=" + CurrentUserInfo.UserID + "&goUrl=" + System.Web.HttpUtility.UrlEncode(goUrl);
                        }
                    }
                    if (dr["ToolType"].ToString() == "CTW")
                    {
                        var T_CTW_LEventInfo = T_CTW_LEventBLL.QueryByEntity(new T_CTW_LEventEntity()
                        {
                            CTWEventId = new Guid(dr["ObjectId"].ToString())
                        }, null).FirstOrDefault();
                        if (T_CTW_LEventInfo != null)
                        {
                            dr["ImageUrl"] = T_CTW_LEventInfo.ImageURL;
                        }
                        if (para.ApplicationType == "4")
                        {
                            goUrl     = dr["URL"].ToString() + "&pushType=IsSuperRetail&ShareVipId=" + CurrentUserInfo.UserID + "&ObjectId=" + dr["ObjectId"] + "&version=";
                            dr["URL"] = strOAuthUrl + CurrentUserInfo.CurrentUser.customer_id + "&objectType=CTW&ObjectID=" + dr["ObjectId"] + "&ShareVipID=" + CurrentUserInfo.UserID + "&goUrl=" + System.Web.HttpUtility.UrlEncode(goUrl);
                        }
                        else
                        {
                            goUrl     = dr["URL"].ToString() + "&ShareVipId=" + CurrentUserInfo.UserID + "&ObjectId=" + dr["ObjectId"] + "&version=";
                            dr["URL"] = strOAuthUrl + CurrentUserInfo.CurrentUser.customer_id + "&ShareVipID=" + CurrentUserInfo.UserID + "&goUrl=" + System.Web.HttpUtility.UrlEncode(goUrl);
                        }
                    }
                    if (dr["ToolType"].ToString() == "Material")//如果是图文素材
                    {
                        var wMaterialTextInfo = wMaterialTextBLL.QueryByEntity(new WMaterialTextEntity()
                        {
                            TextId = dr["ObjectId"].ToString()
                        }, null).FirstOrDefault();
                        if (wMaterialTextInfo != null)
                        {
                            dr["ImageUrl"] = wMaterialTextInfo.CoverImageUrl;
                        }
                        goUrl     = dr["URL"].ToString();
                        dr["URL"] = strOAuthUrl + CurrentUserInfo.CurrentUser.customer_id + "&objectType=Material&ObjectID=" + dr["ObjectId"] + "&ShareVipID=" + CurrentUserInfo.UserID + "&goUrl=" + System.Web.HttpUtility.UrlEncode(goUrl);
                    }
                }
                setoffToolsRD.SetOffToolsList = DataTableToObject.ConvertToList <SetOffToolsInfo>(SetoffToolsList.Tables[0]);
            }
            if (IncentiveRule != null && IncentiveRule.Tables[0].Rows.Count > 0)
            {
                setoffToolsRD.SetoffRegAwardType = Convert.ToInt32(IncentiveRule.Tables[0].Rows[0]["SetoffRegAwardType"].ToString()); //激励类型
                setoffToolsRD.SetoffRegPrize     = IncentiveRule.Tables[0].Rows[0]["SetoffRegPrize"].ToString();                      //激励值
                setoffToolsRD.SetoffOrderPer     = Convert.ToDecimal(IncentiveRule.Tables[0].Rows[0]["SetoffOrderPer"].ToString());   //订单成交提成比例
            }
            return(setoffToolsRD);
        }
示例#5
0
        protected override EmptyResponseData ProcessRequest(DTO.Base.APIRequest <SetSalesSettingRP> pRequest)
        {
            var rd   = new EmptyResponseData();
            var para = pRequest.Parameters;
            var loggingSessionInfo      = new SessionManager().CurrentUserLoginInfo;
            var customerBasicSettingBLL = new CustomerBasicSettingBLL(loggingSessionInfo);

            var setoffEventBLL    = new SetoffEventBLL(loggingSessionInfo);    //集客行动业务层
            var iincentiveRuleBLL = new IincentiveRuleBLL(loggingSessionInfo); //集客奖励业务层

            ResponseData res = new ResponseData();
            List <CustomerBasicSettingEntity> list = new List <CustomerBasicSettingEntity>();

            //获取集客行动信息
            var setoffEventList = setoffEventBLL.QueryByEntity(new SetoffEventEntity()
            {
                CustomerId = loggingSessionInfo.ClientID, Status = "10"
            }, null);
            SetoffEventEntity setoffEventUser = setoffEventList.Where(t => t.SetoffType == 2).FirstOrDefault(); //员工集客活动设置
            SetoffEventEntity setoffEventVip  = setoffEventList.Where(t => t.SetoffType == 1).FirstOrDefault(); //会员集客活动设置

            var iincentiveRuleList = iincentiveRuleBLL.QueryByEntity(new IincentiveRuleEntity()
            {
                CustomerId = loggingSessionInfo.ClientID, Status = "10"
            }, null);
            IincentiveRuleEntity iincentiveRuleUser = null; //员工奖励
            IincentiveRuleEntity iincentiveRuleVip  = null; //会员奖励

            //获取员工奖励规则
            if (setoffEventUser != null)
            {
                iincentiveRuleUser = iincentiveRuleList.Where(t => t.SetoffEventID == setoffEventUser.SetoffEventID && t.SetoffType == 2).FirstOrDefault();
            }
            //获取会员奖励规则
            if (setoffEventVip != null)
            {
                iincentiveRuleVip = iincentiveRuleList.Where(t => t.SetoffEventID == setoffEventVip.SetoffEventID && t.SetoffType == 1).FirstOrDefault();
            }

            if (!string.IsNullOrEmpty(para.SocialSalesType.ToString()))
            {
                list.Add(new CustomerBasicSettingEntity()
                {
                    SettingCode  = "SocialSalesType",
                    SettingValue = para.SocialSalesType.ToString()
                });
            }
            if (!string.IsNullOrEmpty(para.EnableEmployeeSales.ToString()))
            {
                list.Add(new CustomerBasicSettingEntity()
                {
                    SettingCode  = "EnableEmployeeSales",
                    SettingValue = para.EnableEmployeeSales.ToString()
                });
            }
            if (!string.IsNullOrEmpty(para.EDistributionPricePer.ToString()))
            {
                list.Add(new CustomerBasicSettingEntity()
                {
                    SettingCode  = "EDistributionPricePer",
                    SettingValue = para.EDistributionPricePer.ToString()
                });
            }
            if (!string.IsNullOrEmpty(para.EOrderCommissionPer.ToString()))
            {
                list.Add(new CustomerBasicSettingEntity()
                {
                    SettingCode  = "EOrderCommissionPer",
                    SettingValue = para.EOrderCommissionPer.ToString()
                });
            }
            if (!string.IsNullOrEmpty(para.EnableVipSales.ToString()))
            {
                list.Add(new CustomerBasicSettingEntity()
                {
                    SettingCode  = "EnableVipSales",
                    SettingValue = para.EnableVipSales.ToString()
                });
            }
            if (!string.IsNullOrEmpty(para.VDistributionPricePer.ToString()))
            {
                list.Add(new CustomerBasicSettingEntity()
                {
                    SettingCode  = "VDistributionPricePer",
                    SettingValue = para.VDistributionPricePer.ToString()
                });
            }
            if (!string.IsNullOrEmpty(para.VOrderCommissionPer.ToString()))
            {
                list.Add(new CustomerBasicSettingEntity()
                {
                    SettingCode  = "VOrderCommissionPer",
                    SettingValue = para.VOrderCommissionPer.ToString()
                });
            }
            if (!string.IsNullOrEmpty(para.GetVipUserOrderPer.ToString()))
            {
                list.Add(new CustomerBasicSettingEntity()
                {
                    SettingCode  = "GetVipUserOrderPer",
                    SettingValue = para.GetVipUserOrderPer.ToString()
                });
                //同步到集客行动奖励设置(集客销售提成)
                if (iincentiveRuleUser != null)
                {
                    iincentiveRuleUser.SetoffOrderPer = Convert.ToDecimal(para.GetVipUserOrderPer);
                    iincentiveRuleBLL.Update(iincentiveRuleUser);
                }
            }
            if (!string.IsNullOrEmpty(para.InvitePartnersPoints.ToString()))
            {
                list.Add(new CustomerBasicSettingEntity()
                {
                    SettingCode  = "InvitePartnersPoints",
                    SettingValue = para.InvitePartnersPoints.ToString()
                });
                //同步到集客行动奖励设置(分享获得积分)
                if (iincentiveRuleVip != null)
                {
                    iincentiveRuleVip.SetoffRegPrize = Convert.ToDecimal(para.InvitePartnersPoints);
                    iincentiveRuleBLL.Update(iincentiveRuleVip);
                }
            }
            int i = customerBasicSettingBLL.SaveCustomerBasicInfo(loggingSessionInfo.ClientID, list);

            return(rd);
        }