每日任务增长率调整

main
limu 1 year ago
parent 4ed6477157
commit ad7139e19f
  1. 39
      app/command/dayUserValue.php
  2. 3
      crmeb/jobs/OrderPartnerJob.php

@ -4,6 +4,8 @@ declare (strict_types=1);
namespace app\command;
use app\common\model\system\config\SystemConfig;
use app\common\model\system\config\SystemConfigValue;
use Swoole\Coroutine\MySQL\Exception;
use think\console\Command;
use think\console\Input;
@ -33,6 +35,12 @@ class dayUserValue extends Command
{
$config = systemConfig('brand_config');
$config_start = systemConfig('brand_config') ?? 1;
$config_growth = systemConfig('brand_growth');
if (empty($config)) {
echo '无配置';
exit;
}
$resConfig = [];
foreach (explode('/', $config) as $k => $v) {
$newConfig = explode(',', $v);
@ -41,22 +49,29 @@ class dayUserValue extends Command
$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) {
if (empty($v['growth_rate'])) {
$growth_rate = $rv['bili'];
} else {
$growth_rate = bcadd($v['growth_rate'], $rv['bili'], 2);
}
$growth_rate = 0;
$days = $config_start + 1;
foreach ($resConfig as $rk => $rv) {
if ($days >= $rv['start'] && $rv['bili'] > 0) {
if ($config_growth) {
$growth_rate = $rv['bili'];
} else {
$growth_rate = bcadd($v['growth_rate'], $rv['bili'], 2);
}
}
}
$user = userModel::getDB()->where('status', 1)->select()->toArray();
foreach ($user as $k => $v) {
userModel::getDB()->where('uid', $v['uid'])->update(['super_days' => $days, 'growth_rate' => $growth_rate]);
}
$system_1 = SystemConfigValue::getDB()->where('config_key', 'brand_start')->find();
$system_1->value = $system_1->value + 1;
$system_1->save();
$system_2 = SystemConfigValue::getDB()->where('config_key', 'brand_growth')->find();
$system_2->value = $growth_rate;
$system_2->save();
} catch (\Exception $e) {
print_r($e->getMessage());
}

@ -14,6 +14,7 @@
namespace crmeb\jobs;
use app\common\model\system\config\SystemConfig;
use app\common\model\system\config\SystemConfigValue;
use crmeb\interfaces\JobInterface;
use think\Exception;
use think\facade\Log;
@ -102,7 +103,7 @@ class OrderPartnerJob implements JobInterface
//将总毛利的70% 计入总奖池
$all_value = bcmul($total_price, '0.7', 2);
$system = SystemConfig::getDB()->where('config_key', 'all_award')->find();
$system = SystemConfigValue::getDB()->where('config_key', 'all_award')->find();
$system->value = $system->value + $all_value;
$system->save();

Loading…
Cancel
Save