ProductFz.php 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. <?php
  2. namespace app\cxinv\model;
  3. use think\Model;
  4. class ProductFz extends Base
  5. {
  6. //设置字段信息
  7. protected $schema = [
  8. 'id' =>'bigint',//
  9. 'fzCode' =>'varchar',//封账编号
  10. 'company_code' =>'varchar',//业务公司编号
  11. 'company_name' =>'varchar',//业务公司名称
  12. 'fz_date' =>'varchar',//封账月份
  13. 'remark' =>'varchar',
  14. 'status' =>'tinyint',//
  15. 'apply_id' =>'int',//
  16. 'apply_name' =>'varchar',//
  17. 'update_name' =>'varchar',//
  18. 'create_time' =>'datetime',//
  19. 'update_time' =>'datetime',//
  20. ];
  21. protected $createTime = 'create_time';
  22. protected $updateTime = 'update_time';
  23. public static function onAfterUpdate(Model $model): void
  24. {
  25. $change = $model->getChangedData();
  26. $origin = $model->getOrigin();
  27. if (isset($change['status']) && $change['status'] == 2 && $origin['status'] == 1) {
  28. $fz_date = date('Y-m',strtotime('+1 month',strtotime($model['fz_date'])));
  29. $ist =self::where([['fz_date','=',$fz_date],['company_code','=',$model['company_code']]])->findOrEmpty();
  30. if($ist->isEmpty()){
  31. $fzInfo = [
  32. "fzCode"=>makeNo("CWFZ"),
  33. 'company_code'=>$model['company_code'],
  34. 'company_name'=>$model['company_name'],
  35. 'fz_date'=>$fz_date,
  36. 'status'=>0,
  37. 'remark'=>'',
  38. ];
  39. (new ProductFz)->create($fzInfo);
  40. }
  41. }
  42. }
  43. }