예제 #1
0
        public static List <SPRecordWrapper> QueryRecord(SPChannelWrapper channel, SPCodeWrapper code, SPSClientWrapper client, string dataType, DateTime?startDate, DateTime?endDate, List <QueryFilter> filters, string orderByColumnName, bool isDesc)
        {
            SPChannelEntity channelEntity = null;

            if (channel != null)
            {
                channelEntity = channel.Entity;
            }

            SPCodeEntity codeEntity = null;

            if (code != null)
            {
                codeEntity = code.Entity;
            }

            SPSClientEntity clientEntity = null;

            if (client != null)
            {
                clientEntity = client.Entity;
            }

            return(ConvertToWrapperList(businessProxy.QueryRecord(channelEntity, codeEntity, clientEntity, dataType, startDate, endDate, filters, orderByColumnName, isDesc)));
        }
예제 #2
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);
        }
예제 #3
0
        public static void AutoMatch(int channelId, int codeId, int clientId, DateTime startDate, DateTime endDate)
        {
            SPChannelWrapper channel = SPChannelWrapper.FindById(channelId);

            SPCodeWrapper code = SPCodeWrapper.FindById(codeId);

            SPSClientWrapper client = SPSClientWrapper.FindById(clientId);

            List <SPRecordWrapper> records = SPRecordWrapper.QueryRecord(channel, code, client, SPRecordWrapper.DayReportType_AllUp, startDate, endDate, new List <QueryFilter>(), "", false);

            foreach (SPRecordWrapper record in records)
            {
                record.ReAutoMatch();
            }
        }
        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);
            }
        }
        public static DataSet QueryClientInvoiceReport(DateTime?startDate, DateTime?endDate, int?clientID, int?codeID)
        {
            DataSet ds = businessProxy.QueryClientInvoiceReport(startDate, endDate, clientID, codeID);

            ds.Tables[0].Columns.Add(new DataColumn("ClientName"));
            ds.Tables[0].Columns.Add(new DataColumn("MoName"));
            ds.Tables[0].Columns.Add(new DataColumn("Price", typeof(decimal)));

            ds.AcceptChanges();

            foreach (DataRow dataRow in ds.Tables[0].Rows)
            {
                dataRow["ClientName"] = SPSClientWrapper.FindById((int)dataRow["ClientId"]).Name;
                dataRow["MoName"]     = SPCodeWrapper.FindById((int)dataRow["CodeID"]).MoCode;
                dataRow["Price"]      = SPCodeWrapper.FindById((int)dataRow["CodeID"]).Price;
            }

            ds.AcceptChanges();

            return(ds);
        }
예제 #6
0
 public static List <SPClientCodeSycnParamsWrapper> FindAllByCodeID(SPCodeWrapper codeID)
 {
     return(ConvertToWrapperList(businessProxy.FindAllByCodeID(codeID.Entity)));
 }
예제 #7
0
 public static List <SPClientCodeSycnParamsWrapper> FindAllByOrderByAndFilterAndCodeID(string orderByColumnName, bool isDesc, SPCodeWrapper codeID, PageQueryParams pageQueryParams)
 {
     return(ConvertToWrapperList(businessProxy.FindAllByOrderByAndFilterAndCodeID(orderByColumnName, isDesc, codeID.Entity, pageQueryParams)));
 }
예제 #8
0
 public static List <SPRecordWrapper> FindAllSendRecordByClientAndCodeAndDateRange(SPSClientWrapper client, SPCodeWrapper code, DateTime startDate, DateTime endDate)
 {
     return(ConvertToWrapperList(businessProxy.FindAllSendRecordByClientAndCodeAndDateRange(client.Entity, code.Entity, startDate, endDate)));
 }
예제 #9
0
 public static List <SPCodeInfoWrapper> FindAllBySPCodeID(SPCodeWrapper sPCodeID)
 {
     return(ConvertToWrapperList(businessProxy.FindAllBySPCodeID(sPCodeID.Entity)));
 }
        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);
            }
        }