示例#1
0
 private ProvinceHoldConfg(IHold_DataItem defCfg, float percent, int idKey)
 {
     _defCfg      = defCfg;
     hold_percent = (int)(percent * 100);
     lock (_allData)
     {
         if (_allData.ContainsKey(idKey))
         {
             _data = _allData[idKey];
         }
         else
         {
             _data           = new ProvinceHoldData();
             _allData[idKey] = _data;
         }
     }
 }
示例#2
0
        /// <summary>
        /// 此次操作是否标记为扣量信息
        /// </summary>
        /// <returns></returns>
        protected bool IsCycHidden()
        {
            if (PushFlag == E_CP_SYNC_MODE.ForceHide)
            {
                return(true);
            }
            else if (PushFlag == E_CP_SYNC_MODE.ForcePush)
            {
                return(false);
            }

            if (_cp_push_url.cp_id == 34)
            {
                return(true);//未知CP的,直接隐藏
            }
            if (!_cp_push_url.is_realtime)
            {
                return(false);//非实时同步,不进行扣量操作
            }
            if (IsNoHidden)
            {
                return(false);
            }
            IHold_DataItem holdCfg = null;

            if (_config.hold_is_Custom)
            {
                var cpRate = LightDataModel.tbl_cp_trone_rateItem.QueryBySpTroneId(dBase, PushObject.sp_trone_id, _config.cp_id);
                holdCfg = LightDataModel.ProvinceHoldConfg.LoadProvinceData(_config, cpRate, PushObject.province_id);
                // holdCfg = _config;
            }
            else
            {
                holdCfg = _cp_push_url;
            }

            if (holdCfg.push_count < holdCfg.hold_start)
            {
                return(false);
            }

            if (IsWhite())
            {
                return(false);
            }

            if (holdCfg.hold_amount > 0)
            {
                if (holdCfg.amount >= holdCfg.hold_amount)
                {
                    return(DateTime.Now.Millisecond > 10);               //扣99%
                }
                else if ((holdCfg.amount / holdCfg.hold_amount) > 0.98m) //离满额只有2%时
                {
                    return(DateTime.Now.Millisecond > 500);              //扣50%
                }
            }


            if (holdCfg.hold_percent <= 0)
            {
                return(false);//不扣量
            }
            if (holdCfg.hold_percent >= 100)
            {
                return(true);//全扣量
            }
            var t = math2.GCD(holdCfg.hold_percent, 100);

            var cycHold  = holdCfg.hold_percent / t; //扣量条数
            var cycCount = 100 / t;                  //最小扣量周期


            //var max = _config.CycCount - _config.LastCycCount; //未处理的周期量
            var max = cycCount - holdCfg.hold_CycCount;
            //var p = _config.CycHidden - _config.LastCycHidden;//当前周期未扣除的数量
            var p = cycHold - holdCfg.hold_CycProc;//当前周期未扣除的数量


            if (max <= 0)
            {//跑完周期,需要重置
                holdCfg.hold_CycCount = 0;
                holdCfg.hold_CycProc  = 0;
                max = cycCount;
                p   = cycHold;
            }
            holdCfg.hold_CycCount++;
            if (p <= 0)
            {
                return(false);//已经扣完了
            }
            var r        = (DateTime.Now.Millisecond % 100) * max;
            var pre      = p * 100;
            var isHidden = r <= pre;

            if (isHidden)
            {
                holdCfg.hold_CycProc++;
            }
            return(isHidden);
        }