parent
82ea25f1fe
commit
a4734f7415
@ -0,0 +1,60 @@ |
|||||||
|
<?php |
||||||
|
|
||||||
|
declare (strict_types=1); |
||||||
|
|
||||||
|
namespace app\command; |
||||||
|
|
||||||
|
use think\facade\Db; |
||||||
|
use app\api\model\User; |
||||||
|
use think\console\Input; |
||||||
|
use think\console\Output; |
||||||
|
use app\api\model\PreSale; |
||||||
|
use think\console\Command; |
||||||
|
use app\api\model\PreSaleLog; |
||||||
|
use app\api\model\PreSaleMessage; |
||||||
|
use app\api\model\{Goods as GoodsModel}; |
||||||
|
use app\common\enum\user\UserTypeEnum; |
||||||
|
|
||||||
|
// /www/server/php/74/bin/php /server/wwwroot/yanzong/think CalDealerTime |
||||||
|
class CalDealerTime extends Command |
||||||
|
{ |
||||||
|
protected function configure() |
||||||
|
{ |
||||||
|
// 指令配置 |
||||||
|
$this->setName('CalDealerTime') |
||||||
|
->setDescription('自动计算分销时间'); |
||||||
|
} |
||||||
|
|
||||||
|
protected function execute(Input $input, Output $output) |
||||||
|
{ |
||||||
|
//todo wmc这边代码需要优化 |
||||||
|
//$list = User::where('status', 1) |
||||||
|
$list = User::where('user_type', 'in', [UserTypeEnum::MEMBER,UserTypeEnum::DEALER]) |
||||||
|
->where('is_delete', '=', 0) |
||||||
|
//->where('store_id',10001) |
||||||
|
->select(); |
||||||
|
// print '<pre>'; |
||||||
|
// print_r($list->toArray()); |
||||||
|
// print '</pre>'; |
||||||
|
// die; |
||||||
|
foreach ($list as $item) { |
||||||
|
//如果分销商到期,改成会员 |
||||||
|
if(strtotime($item['fx_effective_time']) <= strtotime(date('Y-m-d'))){ |
||||||
|
User::where('user_id',$item['user_id'])->update([ |
||||||
|
'user_type'=>UserTypeEnum::MEMBER |
||||||
|
]); |
||||||
|
} |
||||||
|
//如果会员到期,但是分销商没到期,还是分销商;分销商到期了,改成普通用户 |
||||||
|
if((strtotime($item['effective_time']) <= strtotime(date('Y-m-d'))) && (strtotime($item['fx_effective_time']) <= strtotime(date('Y-m-d')))){ |
||||||
|
User::where('user_id',$item['user_id'])->update([ |
||||||
|
'user_type'=>UserTypeEnum::NORMAL |
||||||
|
]); |
||||||
|
} |
||||||
|
|
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
} |
||||||
|
|
||||||
|
|
||||||
|
} |
Loading…
Reference in new issue