CreateFz.php 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. <?php
  2. declare (strict_types = 1);
  3. namespace app\cxinv\command;
  4. use app\cxinv\model\ProductFz;use app\user\model\Business;use think\console\Command;
  5. use think\console\Input;
  6. use think\console\input\Argument;
  7. use think\console\input\Option;
  8. use think\console\Output;
  9. class CreateFz extends Command
  10. {
  11. protected function configure()
  12. {
  13. // 指令配置
  14. $this->setName('createfz')
  15. ->setDescription('the createfz command');
  16. }
  17. protected function execute(Input $input, Output $output)
  18. {
  19. $list = Business::where([["status","=",1],["is_del","=",0]])->select();
  20. foreach ($list as $item){
  21. $this->createFz($item);
  22. }
  23. // 指令输出
  24. $output->writeln('createfz');
  25. }
  26. public function createFz($item){
  27. $fz_date = date('Y-m');
  28. $fzInfo = ProductFz::where([['company_code','=',$item['inv_code']],['fz_date','=',$fz_date]])->findOrEmpty();
  29. if($fzInfo->isEmpty()){
  30. $fzInfo = [
  31. "fzCode"=>makeNo("CWFZ"),
  32. 'company_code'=>$item['inv_code'],
  33. 'company_name'=>$item['company'],
  34. 'fz_date'=>$fz_date,
  35. 'status'=>0,
  36. 'remark'=>'',
  37. ];
  38. (new ProductFz)->save($fzInfo);
  39. }
  40. }
  41. }