Exemplo n.º 1
0
        protected override void SendQuery()
        {
            if (string.IsNullOrEmpty(API_PushUrl))
            {
                WriteLog(-1, "No Push URL");
                return;
            }

            var ptr = new n8wan.Public.Model.CPDataPushModel();

            ptr.Mobile      = PushObject.GetValue(Logical.EPushField.Mobile);
            ptr.Servicecode = PushObject.GetValue(Logical.EPushField.ServiceCode);
            ptr.Linkid      = PushObject.GetValue(EPushField.LinkID);
            ptr.Msg         = PushObject.GetValue(EPushField.Msg);
            ptr.Port        = PushObject.GetValue(EPushField.port);
            ptr.Price       = decimal.ToInt32(Trone.price * 100);
            ptr.Cpparam     = _apiOrder.ExtrData;
            //ptr.ProvinceId = int.Parse(PushObject.GetValue(EPushField.province));
            ptr.PayCode       = _apiOrder.trone_order_id;
            ptr.PoolId        = _apiOrder.cp_pool_id;
            ptr.OrderNum      = string.Format("{0:yyyyMM}{1}", _apiOrder.FirstDate, _apiOrder.id);
            ptr.VirtualMobile = base.GetVirtualMobile();
            ptr.Url           = API_PushUrl;
            asyncSendData(ptr.ToString(), null);

            //var ptrs = new Dictionary<string, string>();
            //ptrs.Add("mobile", PushObject.GetValue(Logical.EPushField.Mobile));
            //ptrs.Add("servicecode", PushObject.GetValue(Logical.EPushField.ServiceCode));
            //ptrs.Add("linkid", PushObject.GetValue(Logical.EPushField.LinkID));
            //ptrs.Add("msg", PushObject.GetValue(Logical.EPushField.Msg));
            ////ptrs.Add("status", PushObject.GetValue(Logical.EPushField.Status));
            //ptrs.Add("port", PushObject.GetValue(Logical.EPushField.port));

            //ptrs.Add("price", (Trone.price * 100).ToString("0"));
            //ptrs.Add("cpparam", _apiOrder.ExtrData);
            //ptrs.Add("provinceId", PushObject.GetValue(EPushField.province));
            //if (_apiOrder.cp_pool_id == 0)
            //    ptrs.Add("paycode", _apiOrder.trone_order_id.ToString("100000"));
            //else
            //{//代码池同步,强制转换同步的paycode,msg,port
            //    ptrs.Add("paycode", "P" + _apiOrder.cp_pool_id.ToString("00000"));
            //    ptrs["msg"] = ptrs["paycode"];
            //    ptrs["port"] = ptrs["price"];
            //}
            //ptrs.Add("ordernum", string.Format("{0:yyyyMM}{1}", _apiOrder.FirstDate, _apiOrder.id));
            //ptrs.Add("virtualMobile", base.GetVirtualMobile());

            //string qs = UrlEncode(ptrs);
            //string url;
            //if (API_PushUrl.Contains('?'))
            //    url = API_PushUrl + "&" + qs;
            //else
            //    url = API_PushUrl + "?" + qs;

            //asyncSendData(url, null);
        }
Exemplo n.º 2
0
        private tbl_api_orderItem LoadApiOrder()
        {
            var l = tbl_api_orderItem.GetQueries(dBase);
            //l.Filter.AndFilters.Add(tbl_api_orderItem.Fields.trone_id, TroneId);
            string ptr;

            switch (_apiMatchAPI.match_field_E)
            {//订单匹配条件生成
            case tbl_sp_trone_apiItem.EMathcField.Cpprams:
                ptr = this.PushObject.GetValue(EPushField.cpParam);
                if (string.IsNullOrEmpty(ptr))
                {
                    return(null);   //同步配置错,SP并没有回传透传
                }
                l.Filter.AndFilters.Add(tbl_api_orderItem.Fields.api_exdata, this.PushObject.GetValue(EPushField.cpParam));
                break;

            case tbl_sp_trone_apiItem.EMathcField.LinkId:
                l.Filter.AndFilters.Add(tbl_api_orderItem.Fields.sp_linkid, this.PushObject.GetValue(EPushField.LinkID));
                break;

            case tbl_sp_trone_apiItem.EMathcField.Msg:
                l.Filter.AndFilters.Add(tbl_api_orderItem.Fields.msg, this.PushObject.GetValue(EPushField.Msg));
                l.Filter.AndFilters.Add(tbl_api_orderItem.Fields.port, this.PushObject.GetValue(EPushField.port));
                break;

            case tbl_sp_trone_apiItem.EMathcField.Msg_Not_Equal:    //同步指令与上行指令不一至时,使用“port,msg”拼接用逗号分隔,并在sp透传查找
                l.Filter.AndFilters.Add(tbl_api_orderItem.Fields.api_exdata,
                                        string.Format("{0},{1}", PushObject.GetValue(EPushField.port), this.PushObject.GetValue(EPushField.Msg)));
                break;
            }
            l.Filter.AndFilters.Add(tbl_api_orderItem.Fields.api_id, _apiMatchAPI.id);
            l.Filter.AndFilters.Add(tbl_api_orderItem.Fields.trone_id, Trone.id);
            //l.Filter.AndFilters.Add(tbl_api_orderItem.Fields.status, new int[] { 1011, 1013, 2023 });//一次成,2次成功,二次超时


            var t = l.GetRowByFilters();

            if (t != null)
            {
                return(t);
            }
            var sql = l.LastSqlExecute;

            if (string.IsNullOrEmpty(sql))
            {
                WriteTrackLog("api order not found,sql:null");
            }
            else
            {
                WriteTrackLog("api order not found,sql:" + sql);
            }
            return(null);
        }
Exemplo n.º 3
0
        /// <summary>
        /// 白名单检查
        /// </summary>
        /// <returns></returns>
        private bool IsWhite()
        {
            var mobile = PushObject.GetValue(EPushField.Mobile);

            if (string.IsNullOrEmpty(mobile))
            {
                return(false);
            }
            var q = LightDataModel.tbl_mobile_white_listItem.GetQueries(dBase);

            q.Filter.AndFilters.Add(LightDataModel.tbl_mobile_white_listItem.Fields.mobile, mobile);

            return(q.ExecuteScalar(LightDataModel.tbl_mobile_white_listItem.identifyField) != null);
        }
Exemplo n.º 4
0
        protected virtual void SendQuery()
        {
            if (string.IsNullOrEmpty(API_PushUrl))
            {
                WriteLog(-1, "No Push URL");
                return;
            }
            var pm = new CPDataPushModel();

            pm.Mobile      = PushObject.GetValue(Logical.EPushField.Mobile);
            pm.Servicecode = PushObject.GetValue(Logical.EPushField.ServiceCode);
            pm.Linkid      = _linkID;
            pm.Msg         = PushObject.GetValue(Logical.EPushField.Msg);
            pm.Port        = PushObject.GetValue(Logical.EPushField.port);
            pm.Price       = decimal.ToInt32(_trone.price * 100);
            pm.Cpparam     = PushObject.GetValue(Logical.EPushField.cpParam);
#pragma warning disable
            pm.ProvinceId = int.Parse(PushObject.GetValue(EPushField.province));
#pragma warning restore
            pm.PayCode       = _config.id;
            pm.VirtualMobile = GetVirtualMobile();
            pm.Url           = API_PushUrl;
            asyncSendData(pm.ToString(), null);
            //var ptrs = new Dictionary<string, string>();
            //ptrs.Add("mobile", PushObject.GetValue(Logical.EPushField.Mobile));
            //ptrs.Add("servicecode", PushObject.GetValue(Logical.EPushField.ServiceCode));
            //ptrs.Add("linkid", _linkID);
            //ptrs.Add("msg", PushObject.GetValue(Logical.EPushField.Msg));
            ////ptrs.Add("status", PushObject.GetValue(Logical.EPushField.Status));
            //ptrs.Add("port", PushObject.GetValue(Logical.EPushField.port));

            //ptrs.Add("price", (_trone.price * 100).ToString("0"));
            //ptrs.Add("cpparam", PushObject.GetValue(Logical.EPushField.cpParam));
            //ptrs.Add("provinceId", PushObject.GetValue(EPushField.province));
            //ptrs.Add("paycode", _config.id.ToString("100000"));

            //ptrs.Add("virtualMobile", GetVirtualMobile());

            //string qs = UrlEncode(ptrs);
            //string url;
            //if (API_PushUrl.Contains('?'))
            //    url = API_PushUrl + "&" + qs;
            //else
            //    url = API_PushUrl + "?" + qs;
            //asyncSendData(url, null);
        }
Exemplo n.º 5
0
        public override bool DoPush()
        {
            //bool isRecord = false;
            tbl_trone_orderItem defCfg = null;

            if (PushObject.cp_id > 0 && PushObject.cp_id != 34)
            {
                defCfg = tbl_trone_orderItem.GetRowByIdWithCache(dBase, PushObject.trone_order_id);
                if (defCfg == null)
                {
                    return(SetErrorMesage("已经绑定的渠道业务信息丢失"));
                }
                base.SetConfig(defCfg);
                return(base.DoPush());
            }

            tbl_trone_orderItem tOrder = null;
            int    matchCount          = 0;
            string rel = PushObject.GetValue(EPushField.Msg);

            foreach (var m in _allCfg)
            {
                if (m.is_unknow)
                {
                    if (defCfg != null)
                    {
                        base.WriteLog(-3, string.Format("存在多个默认CP! cfgId:{0} linkid:{1}", m.id.ToString(), PushObject.GetValue(EPushField.LinkID)));
                    }
                    defCfg = m;
                    continue;
                }
                if (!IsMatch(m, rel))
                {
                    continue;
                }

                if (tOrder == null)
                {
                    tOrder = m;
                }
                else
                {
                    base.WriteLog(-3, string.Format("配置有冲突! cfgId:{0} linkid:{1}", m.id.ToString(), PushObject.GetValue(EPushField.LinkID)));
                    WriteTrackLog(string.Format("配置有冲突! cfgId:{0} linkid:{1}", m.id.ToString(), PushObject.GetValue(EPushField.LinkID)));
                    continue;
                }
                //isRecord = true;
                matchCount++;
            }
            if (matchCount > 1)
            {
                SetErrorMesage(string.Format("匹配到{0}个CP业务", matchCount));
                return(false);//匹配到多个渠道
            }

            if (tOrder != null)
            {//匹配到一个渠道
                base.SetConfig(tOrder);
                base.DoPush();
                return(true);
            }

            if (PushObject.cp_id == 34)
            {
                WriteTrackLog("CP_id=34???");
                return(true);
            }
            if (defCfg == null)
            {
                defCfg = CreateDefaultTrone();
            }
            base.SetConfig(defCfg);
            base.DoPush();
            WriteTrackLog("未匹配CP");
            return(true);
        }
Exemplo n.º 6
0
        public override bool DoPush()
        {
            if (_apiMatchAPI == null)
            {
                return(false);
            }
            bool isNew;

            if (PushObject.cp_id > 0 && PushObject.cp_id != 34)
            {//已经关联的订单
                var apiID = PushObject.GetValue(EPushField.ApiOrderId);
                _apiOrder = LoadApiOrder(apiID);
                WriteTrackLog(string.Format("已经关联订单, api id={0}", apiID));
                isNew = false;
            }
            else
            {//未匹配的新订单
                _apiOrder = LoadApiOrder();
                isNew     = true;
            }

            if (_apiOrder == null)
            {
                return(false);
            }

            var apiStatus = _apiOrder.status % 10000;

            if (apiStatus != 1011 && apiStatus != 1013 && apiStatus != 2023)
            {
                WriteTrackLog("订单状态错误:" + apiStatus.ToString());
                return(false);//api 上量是状态错误,如有数据回传,有可能同步状态有问题
            }

            //var tOrder = tbl_trone_orderItem.GetQueries(dBase);
            //tOrder.Filter.AndFilters.Add(tbl_trone_orderItem.Fields.id, _apiOrder.trone_order_id);
            //tOrder.Filter.AndFilters.Add(tbl_trone_orderItem.Fields.disable, false);
            //var m = tOrder.GetRowByFilters();
            var m = tbl_trone_orderItem.GetRowByIdWithCache(dBase, _apiOrder.trone_order_id);

            if (m == null || m.disable)
            {
                return(false);
            }
            this.CP_Id = m.cp_id;
            SetConfig(m);//找到对应的渠道上量(相当于执行 base.LoadCPAPI())
            tbl_mrItem mr = null;

            if (PushObject is tbl_mrItem)
            {
                mr = ((tbl_mrItem)PushObject);
                mr.api_order_id = _apiOrder.id;
                mr.user_md10    = System.Web.Security.FormsAuthentication.HashPasswordForStoringInConfigFile(string.Format("{0}_{1}_{2}", _apiOrder.imsi, _apiOrder.imei, _apiOrder.mobile), "MD5");
                if (string.IsNullOrEmpty(mr.mobile) && !string.IsNullOrEmpty(_apiOrder.mobile))
                {
                    mr.mobile = _apiOrder.mobile;
                }
                if (string.IsNullOrEmpty(mr.imsi) && !string.IsNullOrEmpty(_apiOrder.imsi))
                {
                    mr.imsi = _apiOrder.imsi;
                }
                if (mr.province_id == 32 && (!string.IsNullOrEmpty(mr.mobile) || !string.IsNullOrEmpty(mr.imsi)))
                {
                    var city = Library.GetCityInfo(dBase, mr.mobile, mr.imsi);
                    mr.city_id     = city.id;
                    mr.province_id = city.province_id;
                }
            }


            var ret = base.DoPush();

            if (!ret)
            {
                return(false);
            }

            if (isNew)
            {
                UpdateTroneLimit();
            }

            _apiOrder.IgnoreEquals = true;

            var aStatus = apiStatus + (PushObject.syn_flag == 0 ? 10000 : 20000);

            //扣量和非扣量标识
            _apiOrder.status = aStatus;// apiStatus + (PushObject.syn_flag == 0 ? 10000 : 20000);
            try
            {
                _apiOrder.SaveToDatabase(dBase);
            }
            catch (Exception ex)
            {
                Shotgun.Library.SimpleLogRecord.WriteLog("api_push",
                                                         string.Format("linkid{0} 更新api.status 出错:{1}", PushObject.GetValue(EPushField.LinkID), ex.ToString()));
            }
            finally
            {
            }
            return(true);
        }
Exemplo n.º 7
0
        public virtual bool DoPush()
        {
            this._linkID = PushObject.GetValue(Logical.EPushField.LinkID);
            this._url    = null;

            if (PushObject.syn_flag == 1 && PushObject.cp_id != 34)
            {//已经同步的数据
                if (_cp_push_url.is_realtime)
                {
                    SendQuery();
                }
                return(SetSuccess());
            }

            //更新日月限数据
            TroneDayLimit.UpdateDayLimit(dBase, Trone.sp_trone_id, _config.cp_id, Trone.price);

            DateTime today = DateTime.Today;


            IHold_DataItem holdCfg;

            if (_config.hold_is_Custom)
            {
                holdCfg = _config;
            }
            else
            {
                holdCfg = _cp_push_url;
            }

            if (holdCfg.lastDate != DateTime.Today)
            {//重置昨日数据,为今日新数据
                holdCfg.lastDate   = today;
                holdCfg.amount     = 0;
                holdCfg.push_count = 0;
            }


            if (IsCycHidden())
            {//扣量处理
                try
                {
                    PushObject.SetHidden(dBase, _config);
                    dBase.SaveData(_cp_push_url);
                    dBase.SaveData(_config);
                }
                catch (System.Data.Common.DbException ex)
                {
                    WriteLog(-1, string.Format("扣量数据保存失败{0}", ex.Message));
                    return(SetErrorMesage(ex.Message));
                }
                WriteLog(-2, "扣量");
                return(SetSuccess());
            }
            holdCfg.push_count++;
            holdCfg.amount += _trone.price;

            try
            {
                var cpmr = PushObject.SetPushed(dBase, _config);
                cpmr.syn_status = _cp_push_url.is_realtime ? 1 : 0;

                dBase.SaveData(cpmr);


                if (holdCfg.hold_start > holdCfg.push_count || //未达到起扣数
                    (holdCfg.hold_amount != 0 && holdCfg.hold_amount > holdCfg.amount))    //未达到最大同步金额
                {
                    dBase.SaveData(_cp_push_url);
                    dBase.SaveData(_config);
                }
                var daily = cpmr.CopyToDailyCpMr(null);
                try
                {
                    dBase.SaveData(daily);
                }
                catch { }
            }
            catch (System.Data.Common.DbException ex)
            {
                WriteLog(-1, ex.Message);
                return(SetErrorMesage(ex.Message));
            }



            if (_cp_push_url.is_realtime)
            {
                SendQuery();
            }
            return(SetSuccess());
        }
Exemplo n.º 8
0
 protected string GetVirtualMobile()
 {
     return(CityToPhone.GetVirtualPhone(PushObject.GetValue(EPushField.Mobile), PushObject.province_id, PushObject.city_id));
 }