|
@@ -0,0 +1,46 @@
|
|
|
+<?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){
|
|
|
+ $fz_date = date('Y-m');
|
|
|
+ $fzInfo = ProductFz::where([['company_code','=',$item['inv_code']],['fz_date','=',$fz_date]])->findOrEmpty();
|
|
|
+ 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);
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|