|
|
@ -6,6 +6,7 @@ namespace Admin\Controller;
|
|
|
|
use Admin\Model\SpendModel;
|
|
|
|
use Admin\Model\SpendModel;
|
|
|
|
use Think\Think;
|
|
|
|
use Think\Think;
|
|
|
|
use Base\Tool\Printer;
|
|
|
|
use Base\Tool\Printer;
|
|
|
|
|
|
|
|
use Base\Tool\TaskClient;
|
|
|
|
use Base\Service\PromoteService;
|
|
|
|
use Base\Service\PromoteService;
|
|
|
|
use GuzzleHttp\Client;
|
|
|
|
use GuzzleHttp\Client;
|
|
|
|
|
|
|
|
|
|
|
@ -329,7 +330,8 @@ class ConsoleController extends Think {
|
|
|
|
{
|
|
|
|
{
|
|
|
|
$redis = new \Org\RedisSDK\Redis(['host'=>'127.0.0.1','port'=>6379],[]);
|
|
|
|
$redis = new \Org\RedisSDK\Redis(['host'=>'127.0.0.1','port'=>6379],[]);
|
|
|
|
$warns = M('partner_divide_warn', 'tab_')->alias('pdw')
|
|
|
|
$warns = M('partner_divide_warn', 'tab_')->alias('pdw')
|
|
|
|
->field('pdw.*, cgr.ratio, sum(s.pay_amount) as total_amount')
|
|
|
|
->field('pdw.*, cgr.ratio, sum(s.pay_amount) as total_amount, p.partner')
|
|
|
|
|
|
|
|
->join('tab_partner p on pdw.partner_id = p.id')
|
|
|
|
->join('tab_game g on pdw.partner_id = g.partner_id')
|
|
|
|
->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_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')
|
|
|
|
->join('tab_spend s on s.game_id = g.id')
|
|
|
@ -337,6 +339,8 @@ class ConsoleController extends Think {
|
|
|
|
->group('pdw.id')
|
|
|
|
->group('pdw.id')
|
|
|
|
->select();
|
|
|
|
->select();
|
|
|
|
if (!$warns) return;
|
|
|
|
if (!$warns) return;
|
|
|
|
|
|
|
|
$taskClient = new TaskClient();
|
|
|
|
|
|
|
|
$current_time = date('Y-m-d H:i:s');
|
|
|
|
foreach ($warns as $info) {
|
|
|
|
foreach ($warns as $info) {
|
|
|
|
if (!$info['ratio']) return;
|
|
|
|
if (!$info['ratio']) return;
|
|
|
|
$total_amount = ceil(($info['ratio'] / 100) * $info['total_amount']);
|
|
|
|
$total_amount = ceil(($info['ratio'] / 100) * $info['total_amount']);
|
|
|
@ -344,10 +348,14 @@ class ConsoleController extends Think {
|
|
|
|
if (!($lastStep = $redis->get($cacheKey))) {
|
|
|
|
if (!($lastStep = $redis->get($cacheKey))) {
|
|
|
|
$lastStep = 0;
|
|
|
|
$lastStep = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if ($total_amount >= $info['warming_amount']) {
|
|
|
|
if ((intval($info['advance_amount']) - intval($total_amount)) <= $info['warming_amount']) {
|
|
|
|
if ($total_amount - $lastStep >= $info['warn_frequency']) { // 达到预警
|
|
|
|
if ($total_amount - $lastStep >= $info['warn_frequency']) { // 达到预警
|
|
|
|
// 发送预警短信
|
|
|
|
// 发送预警短信
|
|
|
|
echo "发送短信";
|
|
|
|
$content = "{$info['partner']}的预付分成款已于{$current_time}余额不足{$info['warming_amount']}元,请尽快进行充值。";
|
|
|
|
|
|
|
|
$sendRes = $taskClient->sendSmsBatch(json_decode($info['phones'], true), $content);
|
|
|
|
|
|
|
|
if ($sendRes['code'] != TaskClient::SUCCESS) {
|
|
|
|
|
|
|
|
continue;
|
|
|
|
|
|
|
|
}
|
|
|
|
// 变换缓存值,如果为0,需要设置过期时间
|
|
|
|
// 变换缓存值,如果为0,需要设置过期时间
|
|
|
|
if ($lastStep) {
|
|
|
|
if ($lastStep) {
|
|
|
|
$redis->set($cacheKey, $total_amount);
|
|
|
|
$redis->set($cacheKey, $total_amount);
|
|
|
|