You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
70 lines
2.3 KiB
70 lines
2.3 KiB
<?php
|
|
|
|
declare (strict_types=1);
|
|
|
|
namespace app\command;
|
|
|
|
use Swoole\Coroutine\MySQL\Exception;
|
|
use think\console\Command;
|
|
use app\common\model\store\order\StoreOrderContribute;
|
|
use think\console\Input;
|
|
use think\console\input\Argument;
|
|
use think\console\input\Option;
|
|
use app\common\model\user\User as userModel;
|
|
use app\common\model\user\ValueContributionLog;
|
|
use app\common\model\store\product\Spu;
|
|
use app\common\model\store\order\StoreOrder;
|
|
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 dayValue extends Command
|
|
{
|
|
protected function configure()
|
|
{
|
|
// 指令配置
|
|
$this->setName('dayValue')
|
|
->addArgument('dayValue', Argument::OPTIONAL, 'php think menu [1] / [2]')
|
|
->setDescription('社区等级结算');
|
|
}
|
|
|
|
protected function execute(Input $input, Output $output)
|
|
{
|
|
$currentDate = date('Y-m-01'); // 获取当前月的第一天
|
|
//判断当月第一天
|
|
if (date('Y-m-d') === $currentDate) {
|
|
//获取上个月时间
|
|
list($start, $end) = $this->getLastMonth();
|
|
//根据社区等级分配贡献值
|
|
//重置社区等级
|
|
}
|
|
}
|
|
|
|
public function getLastMonth()
|
|
{
|
|
// 获取当前日期
|
|
$currentDate = date('Y-m-d');
|
|
// 提取当前日期的年、月和日
|
|
$currentYear = date('Y', strtotime($currentDate));
|
|
$currentMonth = date('m', strtotime($currentDate));
|
|
// 计算上个月的年份和月份
|
|
$lastMonthYear = $currentYear - 1;
|
|
$lastMonth = $currentMonth - 1;
|
|
// 处理特殊情况:如果上个月的月份小于1,则年份减1,月份设为12
|
|
if ($lastMonth < 1) {
|
|
$lastMonthYear--;
|
|
$lastMonth = 12;
|
|
}
|
|
// 获取上个月的第一天和最后一天
|
|
$firstDayOfLastMonth = date('Y-m-01', strtotime("$lastMonthYear-$lastMonth-01"));
|
|
$lastDayOfLastMonth = date('Y-m-t', strtotime("$lastMonthYear-$lastMonth-01"));
|
|
return [$firstDayOfLastMonth, $lastDayOfLastMonth];
|
|
}
|
|
|
|
|
|
}
|
|
|