每日用户贡献值转增值积分

main
limu 11 months ago
parent e9f3486ab1
commit 7ebea57edd
  1. 53
      app/command/dayUserGrowth.php
  2. 3
      app/command/dayValue.php
  3. 2
      config/console.php

@ -0,0 +1,53 @@
<?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 dayUserGrowth
class dayUserGrowth 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)
{
try {
$user = userModel::getDB()->where('status', 1)->select()->toArray();
foreach ($user as $k => $v) {
if ($v['all_value'] > 0) {
$growth_num = bcdiv($v['all_value'], $v['growth_rate'], 2);
userModel::getDB()
->where('uid', $v['uid'])
->update(['all_value' => 0, 'brokerage_price' => $growth_num]);
}
}
} catch (\Exception $e) {
print_r($e->getMessage());
}
echo 'ok';
}
}

@ -38,8 +38,6 @@ class dayValue extends Command
{
$yesterdayStart = date('Y-m-d H:i:s', strtotime('yesterday'));
$yesterdayEnd = date('Y-m-d H:i:s', strtotime('tomorrow') - 1);
$yesterdayStart = '2023-12-18 00:00:00';
$yesterdayEnd = '2023-12-20 00:00:00';
$level = config('partner.community_level') ?? [];
$back_level = User::getDB()->where('community_level', '>', '0')->column('uid');
$userOrder = StoreOrderContribute::getDB()->field('uid,sum(order_profit) as user_profit')
@ -154,6 +152,7 @@ class dayValue extends Command
} catch (\Exception $e) {
print_r($e->getLine() . "-" . $e->getMessage());
}
echo '执行结束';
}

@ -43,5 +43,7 @@ return [
'dayValue' => 'app\command\dayValue',
//每日兑换率生成
'dayUserValue' => 'app\command\dayUserValue',
//每日贡献值转增值积分
'dayUserGrowth' => 'app\command\dayUserGrowth',
],
];

Loading…
Cancel
Save