增长率生成

main
limu 11 months ago
parent 8a6ea46752
commit 46dff41c41
  1. 63
      app/command/dayUserValue.php
  2. 2
      config/console.php
  3. 3
      crmeb/jobs/OrderPartnerJob.php

@ -0,0 +1,63 @@
<?php
declare (strict_types=1);
namespace app\command;
use Swoole\Coroutine\MySQL\Exception;
use think\console\Command;
use think\console\Input;
use think\console\input\Argument;
use think\console\input\Option;
use app\common\model\user\User as userModel;
use think\console\Output;
use think\event\RouteLoaded;
use think\exception\ValidateException;
use think\facade\Cache;
use think\facade\Db;
use think\facade\Route;
use app\common\repositories\system\auth\MenuRepository;
// /www/server/php/74/bin/php /server/wwwroot/crmeb/think dayValue
class dayUserValue extends Command
{
protected function configure()
{
// 指令配置
$this->setName('dayUserValue')
->addArgument('dayValue', Argument::OPTIONAL, 'php think menu [1] / [2]')
->setDescription('用户每日兑换率生成');
}
protected function execute(Input $input, Output $output)
{
$config = systemConfig('brand_config');
$resConfig = [];
foreach (explode('/', $config) as $k => $v) {
$newConfig = explode(',', $v);
$resConfig[$k]['start'] = $newConfig[0];
$resConfig[$k]['end'] = $newConfig[1];
$resConfig[$k]['bili'] = $newConfig[2];
}
try {
$user = userModel::getDB()->where('status', 1)->select()->toArray();
foreach ($user as $k => $v) {
$growth_rate = 0;
$days = $v['super_days'] + 1;
foreach ($resConfig as $rk => $rv) {
if ($days >= $rv['start'] && $rv['bili'] > 0) {
$growth_rate = bcadd($v['growth_rate'], $rv['bili'], 2);
}
}
userModel::getDB()->where('uid', $v['uid'])->update(['super_days' => $days, 'growth_rate' => $growth_rate]);
}
} catch (\Exception $e) {
}
echo 'ok';
}
}

@ -41,5 +41,7 @@ return [
'brand' => 'app\command\brand',
//社区贡献值结算
'dayValue' => 'app\command\dayValue',
//每日兑换率生成
'dayUserValue' => 'app\command\dayUserValue',
],
];

@ -394,8 +394,9 @@ class OrderPartnerJob implements JobInterface
}
//贡献值转增值积分
public function addValue($uid,$num)
public function addValue($uid,$num,$user_start)
{
//读取用户当前贡献值增长率
}
}

Loading…
Cancel
Save