1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950 |
- <?php
- declare (strict_types = 1);
- namespace app\cxinv\command;
- use app\cxinv\model\ProductFz;use app\user\model\Business;use think\console\Command;
- use think\console\Input;
- use think\console\input\Argument;
- use think\console\input\Option;
- use think\console\Output;
- class CreateFz extends Command
- {
- protected function configure()
- {
- // 指令配置
- $this->setName('createfz')
- ->setDescription('the createfz command');
- }
- protected function execute(Input $input, Output $output)
- {
- $list = Business::where([["status","=",1],["is_del","=",0]])->select();
- foreach ($list as $item){
- $this->createFz($item);
- }
- // 指令输出
- $output->writeln('createfz');
- }
- public function createFz($item){
- $fzInfo = ProductFz::where([['company_code','=',$item['inv_code']]])->order('fz_date desc')->findOrEmpty();
- if($fzInfo->status!=2){
- return false;
- }
- $fz_date = date('Y-m',strtotime('+1 month',strtotime($fzInfo['fz_date'])));
- if($fzInfo->isEmpty()){
- $fzInfo = [
- "fzCode"=>makeNo("CWFZ"),
- 'company_code'=>$item['inv_code'],
- 'company_name'=>$item['company'],
- 'fz_date'=>$fz_date,
- 'status'=>0,
- 'remark'=>'',
- ];
- (new ProductFz)->save($fzInfo);
- }
- }
- }
|