master
yulingwei 5 years ago
parent dfd274a667
commit 6daf38aa43

@ -324,4 +324,38 @@ class ConsoleController extends Think {
} }
); );
} }
public function divideWarnCheck()
{
$redis = new \Org\RedisSDK\Redis(['host'=>'127.0.0.1','port'=>6379],[]);
$warns = M('partner_divide_warn', 'tab_')->alias('pdw')
->field('pdw.*, cgr.ratio, sum(s.pay_amount) as total_amount')
->join('tab_game g on pdw.partner_id = g.partner_id')
->join('tab_cp_game_ratio cgr on cgr.game_id = g.id and begin_total_amount = 0 and is_del = 0')
->join('tab_spend s on s.game_id = g.id')
->where(['pdw.status'=>1, 's.pay_status'=>1])
->group('pdw.id')
->select();
if (!$warns) return;
foreach ($warns as $info) {
if (!$info['ratio']) return;
$total_amount = ceil(($info['ratio'] / 100) * $info['total_amount']);
$cacheKey = "divide:warn:check:{$info['partner_id']}";
if (!($lastStep = $redis->get($cacheKey))) {
$lastStep = 0;
}
if ($total_amount >= $info['warming_amount']) {
if ($total_amount - $lastStep >= $info['warn_frequency']) { // 达到预警
// 发送预警短信
echo "发送短信";
// 变换缓存值如果为0需要设置过期时间
if ($lastStep) {
$redis->set($cacheKey, $total_amount);
} else {
$redis->setex($cacheKey, 86400 * 30, $total_amount);
}
}
}
}
}
} }

@ -120,7 +120,6 @@
<block name="script"> <block name="script">
<script type="text/javascript"> <script type="text/javascript">
highlight_subnav('{:U('Game/devide_warn_edit')}'); highlight_subnav('{:U('Game/devide_warn_edit')}');
$(".select_gallery").select2();
$(".bnt_add").bind("click",function(){ $(".bnt_add").bind("click",function(){
var a= '<li class="warn-phone"><label>手机号</label><input type="text" class="txt table_text_input" name="phones[]" value="" placeholder=""><button type="button" class="bnt_remove"></button></li>'; var a= '<li class="warn-phone"><label>手机号</label><input type="text" class="txt table_text_input" name="phones[]" value="" placeholder=""><button type="button" class="bnt_remove"></button></li>';
$(".warn-phone:last").after(a); $(".warn-phone:last").after(a);

Loading…
Cancel
Save