コード例 #1
0
        public void ReAutoMatch()
        {
            SPCodeWrapper matchCode = null;

            if (this.ChannelID.ChannelType == DictionaryConst.Dictionary_ChannelType_IVRChannel_Key)
            {
                matchCode = this.ChannelID.GetMatchCodeFromIVRRequest(this.ExtendInfo.GetHttpRequestLog(), this.SpNumber, this.Province, this.City);
            }
            else
            {
                matchCode = this.ChannelID.GetMatchCodeFromRequest(this.ExtendInfo.GetHttpRequestLog(), this.Mo, this.SpNumber, this.Province, this.City);
            }

            if (matchCode == null)
            {
                return;
            }

            SPClientCodeRelationWrapper clientCodeRelation = matchCode.GetRelateClientCodeRelation();


            //如果存在指令,但是不存在对应的分配关系,转到默认匹配
            if (clientCodeRelation == null)
            {
                clientCodeRelation = this.ChannelID.GetDefaultClientCodeRelation();

                //matchCode = clientCodeRelation.CodeID;
            }

            this.CodeID               = matchCode;
            this.ClientID             = clientCodeRelation.ClientID;
            this.ClientCodeRelationID = clientCodeRelation;

            Update(this);
        }
コード例 #2
0
        public void ChangeClient(SPSClientWrapper client,
                                 DateTime changeDate,
                                 int changeUserID,
                                 decimal price,
                                 decimal interceptRate,
                                 bool syncData,
                                 int sycnNotInterceptCount,
                                 string sycnRetryTimes,
                                 SPSDataSycnSettingWrapper dataSycnSetting)
        {
            //如果存在分配客户,终止上次指令分配记录。
            if (this.ClientCodeRelation != null)
            {
                if (this.ClientCodeRelation.ClientID.Id == client.Id)
                {
                    return;
                }

                this.ClientCodeRelation.IsEnable = false;
                this.ClientCodeRelation.EndDate  = changeDate;

                SPClientCodeRelationWrapper.Update(this.ClientCodeRelation);
            }

            SPClientCodeRelationWrapper obj = new SPClientCodeRelationWrapper();

            if (syncData)
            {
                SPSDataSycnSettingWrapper.Save(dataSycnSetting);
            }

            obj.Price         = price;
            obj.InterceptRate = interceptRate;
            obj.UseClientDefaultSycnSetting = false;
            obj.SyncData       = syncData;
            obj.ClientID       = client;
            obj.CodeID         = this;
            obj.SycnRetryTimes = sycnRetryTimes;
            if (obj.SyncData)
            {
                obj.SyncDataSetting = dataSycnSetting;
            }
            obj.StartDate             = changeDate;
            obj.EndDate               = null;
            obj.IsEnable              = true;
            obj.SycnNotInterceptCount = sycnNotInterceptCount;
            obj.CreateBy              = changeUserID;
            obj.CreateAt              = changeDate;
            obj.LastModifyBy          = changeUserID;
            obj.LastModifyAt          = changeDate;


            SPClientCodeRelationWrapper.Save(obj);
        }
コード例 #3
0
        public List <SPCodeWrapper> GetAllAssignedCode()
        {
            List <SPClientCodeRelationWrapper> spClientCodeRelations = SPClientCodeRelationWrapper.FindAllByClientID(this);

            List <SPCodeWrapper> spCodes = new List <SPCodeWrapper>();

            foreach (SPClientCodeRelationWrapper spClientCodeRelationWrapper in spClientCodeRelations)
            {
                if (!spCodes.Exists(p => (p.Id == spClientCodeRelationWrapper.ClientID.Id) && (!p.IsDiable)))
                {
                    spCodes.Add(spClientCodeRelationWrapper.CodeID);
                }
            }

            return(spCodes);
        }
コード例 #4
0
        private bool CaculteIsIntercept(SPCodeWrapper matchCode, SPClientCodeRelationWrapper clientCodeRelation)
        {
            if (clientCodeRelation == null)
            {
                return(false);
            }

            int addRate = 50;

            int maxInterceptRate = 80;

            if (clientCodeRelation.SycnNotInterceptCount > 0)
            {
                clientCodeRelation.SycnNotInterceptCount = clientCodeRelation.SycnNotInterceptCount - 1;

                SPClientCodeRelationWrapper.Update(clientCodeRelation);

                return(false);
            }

            int interceptRate = 0;

            interceptRate = Convert.ToInt32(clientCodeRelation.InterceptRate);

            //return CaculteRandom(interceptRate);

            if (interceptRate == 0)
            {
                return(false);
            }

            decimal rate = SPRecordWrapper.CaculteActualInterceptRate(clientCodeRelation, System.DateTime.Now.Date);

            if (rate < Convert.ToDecimal(interceptRate))
            {
                return(CaculteRandom(Math.Min(interceptRate + addRate, maxInterceptRate)));
            }
            else
            {
                return(false);
            }
        }
コード例 #5
0
        public SPClientCodeRelationWrapper GetRelateClientCodeRelation()
        {
            List <SPClientCodeRelationWrapper> findClientInCodes = SPClientCodeRelationWrapper.FindAllByCodeID(this);

            SPClientCodeRelationWrapper spClientCodeRelation = findClientInCodes.Find(p => (p.IsEnable));

            if (spClientCodeRelation != null)
            {
                return(spClientCodeRelation);
            }


            SPClientCodeRelationWrapper spDefaultClientCodeRelation = findClientInCodes.Find(p => (p.ClientID.IsDefaultClient.HasValue && p.ClientID.IsDefaultClient.Value));

            if (spDefaultClientCodeRelation != null)
            {
                return(spDefaultClientCodeRelation);
            }

            return(null);
        }
コード例 #6
0
 public static decimal CaculteActualInterceptRate(SPClientCodeRelationWrapper clientCodeRelation, DateTime date)
 {
     return(businessProxy.CaculteActualInterceptRate(clientCodeRelation.Entity, date));
 }
コード例 #7
0
        public bool ProcessRequest(IDataAdapter httpRequestLog, bool statusOk, out RequestErrorType requestError, out string errorMessage)
        {
            requestError = RequestErrorType.NoError;
            errorMessage = "";

            string linkid = GetLinkID(httpRequestLog);

            if (string.IsNullOrEmpty(linkid))
            {
                requestError = RequestErrorType.NoLinkID;
                errorMessage = " 通道 ‘" + Name + "’ 请求失败:没有LinkID .";
                return(false);
            }

            if (this.CheckLinkIDIsExisted(linkid))
            {
                requestError = RequestErrorType.RepeatLinkID;
                errorMessage = " 通道 ‘" + Name + "’ 请求失败:重复的LinkID (缓存检查) .";
                return(false);
            }

            string mo = this.ChannelParams.MoFromRequset(httpRequestLog);

            if (this.ChannelType == DictionaryConst.Dictionary_ChannelType_IVRChannel_Key)
            {
                mo = "ivr";
            }

            string spcode = this.ChannelParams.SPCodeFromRequset(httpRequestLog);
            string mobile = this.ChannelParams.MobileFromRequset(httpRequestLog);

            string province       = "";
            string city           = "";
            string mobileOperator = "";

            PhoneArea phoneArea = this.GetProvinceAndCity(mobile);

            if (phoneArea != null)
            {
                if (!string.IsNullOrEmpty(phoneArea.Province))
                {
                    province = phoneArea.Province;
                }
                else
                {
                    province = "";
                }
                if (!string.IsNullOrEmpty(phoneArea.City))
                {
                    city = phoneArea.City;
                }
                else
                {
                    city = "";
                }
                if (!string.IsNullOrEmpty(phoneArea.OperatorType))
                {
                    mobileOperator = phoneArea.OperatorType;
                }
                else
                {
                    mobileOperator = "";
                }
            }

            SPCodeWrapper matchCode = null;

            if (this.ChannelType == DictionaryConst.Dictionary_ChannelType_IVRChannel_Key)
            {
                matchCode = this.GetMatchCodeFromIVRRequest(httpRequestLog, spcode, province, city);
            }
            else
            {
                matchCode = this.GetMatchCodeFromRequest(httpRequestLog, mo, spcode, province, city);
            }


            if (matchCode == null)
            {
                requestError = RequestErrorType.NoChannelClientSetting;
                errorMessage = "请求失败:通道‘" + Name + "’请求未能找到匹配的代码设置。";
                return(false);
            }

            SPClientCodeRelationWrapper clientCodeRelation = matchCode.GetRelateClientCodeRelation();

            //如果存在指令,但是不存在对应的分配关系,转到默认匹配
            if (clientCodeRelation == null)
            {
                clientCodeRelation = this.GetDefaultClientCodeRelation();
                //如果是指令没有分配下家如何处理。
                //matchCode = clientCodeRelation.CodeID;
            }

            SPRecordWrapper record = new SPRecordWrapper();

            record.ChannelID            = this;
            record.CodeID               = matchCode;
            record.ClientID             = clientCodeRelation.ClientID;
            record.ClientCodeRelationID = clientCodeRelation;
            record.Mo           = mo;
            record.Mobile       = mobile;
            record.LinkID       = linkid;
            record.SpNumber     = spcode;
            record.Province     = province;
            record.City         = city;
            record.OperatorType = mobileOperator;
            record.CreateDate   = GetRecordTime(httpRequestLog);

            record.IsReport = false;


            record.IsStatOK = statusOk;

            record.IsIntercept = this.CaculteIsIntercept(matchCode, clientCodeRelation);

            if (record.IsIntercept)
            {
                record.IsSycnToClient  = false;
                record.IsSycnSuccessed = false;
                record.SycnRetryTimes  = 0;
            }
            else
            {
                if (!clientCodeRelation.SyncData)
                {
                    record.IsSycnToClient  = false;
                    record.IsSycnSuccessed = false;
                    record.SycnRetryTimes  = 0;
                }
                else
                {
                    record.IsSycnToClient  = true;
                    record.IsSycnSuccessed = false;
                    record.SycnRetryTimes  = 0;
                }
            }

            record.Price = clientCodeRelation.Price;


            record.Count = GetRecordCount(httpRequestLog);

            SPRecordExtendInfoWrapper spRecordExtendInfo = new SPRecordExtendInfoWrapper();

            spRecordExtendInfo.StartTime      = this.ChannelParams.StartTimeFromRequset(httpRequestLog);
            spRecordExtendInfo.EndTime        = this.ChannelParams.EndTimeFromRequset(httpRequestLog);
            spRecordExtendInfo.FeeTime        = this.ChannelParams.FeeTimeFromRequset(httpRequestLog);
            spRecordExtendInfo.State          = this.ChannelParams.StateFromRequset(httpRequestLog);
            spRecordExtendInfo.Ip             = httpRequestLog.RequestIp;
            spRecordExtendInfo.RequestContent = httpRequestLog.RequestData;
            spRecordExtendInfo.ExtendField1   = this.ChannelParams.ExtendField1FromRequset(httpRequestLog);
            spRecordExtendInfo.ExtendField2   = this.ChannelParams.ExtendField2FromRequset(httpRequestLog);
            spRecordExtendInfo.ExtendField3   = this.ChannelParams.ExtendField3FromRequset(httpRequestLog);
            spRecordExtendInfo.ExtendField4   = this.ChannelParams.ExtendField4FromRequset(httpRequestLog);
            spRecordExtendInfo.ExtendField5   = this.ChannelParams.ExtendField5FromRequset(httpRequestLog);
            spRecordExtendInfo.ExtendField6   = this.ChannelParams.ExtendField6FromRequset(httpRequestLog);
            spRecordExtendInfo.ExtendField7   = this.ChannelParams.ExtendField7FromRequset(httpRequestLog);
            spRecordExtendInfo.ExtendField8   = this.ChannelParams.ExtendField8FromRequset(httpRequestLog);
            spRecordExtendInfo.ExtendField9   = this.ChannelParams.ExtendField9FromRequset(httpRequestLog);
            spRecordExtendInfo.ExtendField10  = this.ChannelParams.ExtendField10FromRequset(httpRequestLog);

            try
            {
                bool result = SPRecordWrapper.InsertPayment(record, spRecordExtendInfo, out requestError, out errorMessage);

                if (!result && requestError == RequestErrorType.RepeatLinkID)
                {
                    requestError = RequestErrorType.RepeatLinkID;

                    errorMessage = " 通道 ‘" + Name + "’ 请求失败:重复的LinkID(查询排重 异常排重) .";

                    return(false);
                }

                requestError = RequestErrorType.NoError;
                errorMessage = "";
                try
                {
                    CacheProviderFactory.GetLinkIDCache().AddLinkIDs(linkid, this.Id);
                }
                catch (Exception ex)
                {
                    Logger.Error(ex.Message);
                }

                record.SycnToClient();

                return(true);
            }
            catch (Exception ex)
            {
                requestError = RequestErrorType.DataSaveError;
                errorMessage = "请求失败:插入数据失败,错误信息:" + ex.Message;
                return(false);
            }
        }