CreateFz.php 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  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. $fzInfo = ProductFz::where([['company_code','=',$item['inv_code']]])->order('fz_date desc')->findOrEmpty();
  28. if($fzInfo->status!=2){
  29. return false;
  30. }
  31. $fz_date = date('Y-m',strtotime('+1 month',strtotime($fzInfo['fz_date'])));
  32. if($fzInfo->isEmpty()){
  33. $fzInfo = [
  34. "fzCode"=>makeNo("CWFZ"),
  35. 'company_code'=>$item['inv_code'],
  36. 'company_name'=>$item['company'],
  37. 'fz_date'=>$fz_date,
  38. 'status'=>0,
  39. 'remark'=>'',
  40. ];
  41. (new ProductFz)->save($fzInfo);
  42. }
  43. }
  44. }