/// <summary> /// 用户日月限判断 /// </summary> /// <param name="spTrone"></param> /// <returns>1:日限,2:月限</returns> int IsCustomLimited(tbl_sp_troneItem spTrone) { int day = 0, month = 0; bool isCount = spTrone.limit_type == 1; day = decimal.ToInt32(spTrone.user_day_limit * (isCount ? 1 : 100)); month = decimal.ToInt32(spTrone.user_month_limit * (isCount ? 1 : 100)); if (day == 0 && month == 0) { return(0);//不限量 } if (month == 0) { month = int.MaxValue; } else if (day == 0) { day = int.MaxValue; } var customId = _orderInfo.imsi; if (spTrone.up_data_type == 2 || spTrone.up_data_type == 3) {//联网验证码 ,联网验证码(手机回复) customId = _orderInfo.mobile; } if (string.IsNullOrEmpty(customId)) { return(0); } var cli = Dao.CustomFee.QueryLimit(dBase, spTrone.id, customId);//此处应该正确选选择用户标识 //以下假设此次计费成功,是否会超限 if (isCount) { if (cli.DayCount >= day) { return(1); } return(cli.MonthCount >= month ? 2 : 0); } if ((cli.DayAmount + _poolInfo.fee) > day) { return(1); } return((cli.MonthAmount + _poolInfo.fee) > month ? 2 : 0); }
int IsSpTroneLimited(tbl_sp_troneItem spTrone) { int day = 0, month = 0; bool isCount = spTrone.limit_type == 1; day = decimal.ToInt32(spTrone.day_limit * (isCount ? 1 : 100)); month = decimal.ToInt32(spTrone.month_limit * (isCount ? 1 : 100)); if (day == 0 && month == 0) { return(0);//不限量 } if (month == 0) { month = int.MaxValue; } else if (day == 0) { day = int.MaxValue; } var cli = Dao.CustomFee.QueryLimit(dBase, spTrone.id, null);//此处应该正确选选择用户标识 //以下假设此次计费成功,是否会超限 if (isCount) { if (cli.DayCount >= day) { return(1); } return(cli.MonthCount >= month ? 2 : 0); } if ((cli.DayAmount + _poolInfo.fee) > day) { return(1); } return((cli.MonthAmount + _poolInfo.fee) > month ? 2 : 0); }
/// <summary> /// 用于更新api通道的计费信息 /// </summary> private void UpdateTroneLimit() { var targetUrl = System.Configuration.ConfigurationManager.AppSettings["apiTroneLimit"]; if (string.IsNullOrEmpty(targetUrl)) { return; } var mr = this.PushObject as tbl_mrItem; if (mr == null || mr.sp_trone_id == 0) { return; } tbl_sp_troneItem spTrone = tbl_sp_troneItem.GetRowById(dBase, mr.sp_trone_id); if (spTrone == null) { return; } var customId = spTrone.GetCustomId(_apiOrder.mobile, _apiOrder.imsi); var sql = string.Format("insert daily_log.tbl_custom_fee_count(custom_id, trone_id, fee_date, count,city_id) " + "values('{0}',{1},'{2:yyyy-MM-dd}',1,{3}) on duplicate key update count=count+1;", dBase.SqlEncode(customId), this._apiOrder.trone_id, this._apiOrder.FirstDate, this._apiOrder.city); try { dBase.ExecuteNonQuery(sql); } catch (System.Data.DataException) { } var data = string.Format("troneId={0}&mrDate={1:yyyy-MM-dd}&city_id={2}&customId={3}&sptroneId={4}", _apiOrder.trone_id, _apiOrder.FirstDate, _apiOrder.city, customId, spTrone.id); Shotgun.Library.AsyncRemoteRequest.RequestOnly(targetUrl, ASCIIEncoding.Default.GetBytes(data)); }