1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950 |
- <?php
- /**
- * Created by PhpStorm.
- * User: Elton
- * Date: 2019/12/3
- * Time: 17:56
- */
- namespace app\admin\command;
- use app\main\service\AdminService;
- use think\console\Command;
- use think\console\Input;
- use think\console\Output;
- use think\Request;
- class UpdateAgreementyi extends Command
- {
- protected $message = '';
- protected function configure()
- {
- $this->setName('UpdateAgreementyi')
- ->setDescription('更新乙方合同管理中的收益分成比例');
- }
- protected function execute(Input $input, Output $output)
- {
- $channel_map = null;
- //cli模式下无法获取到当前的项目模块,手动指定一下
- Request::instance()->module('admin');
- $agreementyiModel = model('Agreementyi');
- $res = $agreementyiModel->select();
- $output->writeln('总共'.count($res).'条数据开始执行:'.date('Y-m-d H:i:s', time()));
- if ($res) {
- foreach ($res as $k => $item) {
- $admin_id = $item['admin_id'];
- $adminExtendModel = AdminService::instance()->getAdminExtendModel();
- $adminExtendInfo = $adminExtendModel->getInfo($admin_id);
- $benefit = $adminExtendInfo['benefit'];
- $output->writeln('$benefit:'.$benefit);
- $agreementyiModel->update(['benefit'=>$benefit], ['admin_id'=> $admin_id]);
- }
- }
- $output->writeln('总共'.count($res).'条数据执行完成:'.date('Y-m-d H:i:s', time()));
- }
- }
|