UpdateAgreementyi.php 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. <?php
  2. /**
  3. * Created by PhpStorm.
  4. * User: Elton
  5. * Date: 2019/12/3
  6. * Time: 17:56
  7. */
  8. namespace app\admin\command;
  9. use app\main\service\AdminService;
  10. use think\console\Command;
  11. use think\console\Input;
  12. use think\console\Output;
  13. use think\Request;
  14. class UpdateAgreementyi extends Command
  15. {
  16. protected $message = '';
  17. protected function configure()
  18. {
  19. $this->setName('UpdateAgreementyi')
  20. ->setDescription('更新乙方合同管理中的收益分成比例');
  21. }
  22. protected function execute(Input $input, Output $output)
  23. {
  24. $channel_map = null;
  25. //cli模式下无法获取到当前的项目模块,手动指定一下
  26. Request::instance()->module('admin');
  27. $agreementyiModel = model('Agreementyi');
  28. $res = $agreementyiModel->select();
  29. $output->writeln('总共'.count($res).'条数据开始执行:'.date('Y-m-d H:i:s', time()));
  30. if ($res) {
  31. foreach ($res as $k => $item) {
  32. $admin_id = $item['admin_id'];
  33. $adminExtendModel = AdminService::instance()->getAdminExtendModel();
  34. $adminExtendInfo = $adminExtendModel->getInfo($admin_id);
  35. $benefit = $adminExtendInfo['benefit'];
  36. $output->writeln('$benefit:'.$benefit);
  37. $agreementyiModel->update(['benefit'=>$benefit], ['admin_id'=> $admin_id]);
  38. }
  39. }
  40. $output->writeln('总共'.count($res).'条数据执行完成:'.date('Y-m-d H:i:s', time()));
  41. }
  42. }