PayWages.php 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. <?php
  2. namespace app\common\validate;
  3. use think\Db;
  4. use think\Validate;
  5. class PayWages extends Validate{
  6. protected $rule = [
  7. 'id' => 'require|gt:0',
  8. 'content' => 'require|checkContent',
  9. ];
  10. protected $message = [
  11. 'id.require' => '参数错误',
  12. 'id.gt' => '参数错误',
  13. 'content.require' => '参数错误',
  14. ];
  15. protected $scene = [
  16. ];
  17. protected function checkContent($value,$rule,$data=[])
  18. {
  19. $content = json_decode($data['content'],true);
  20. if(!$content){
  21. return '参数错误';
  22. }
  23. $info = Db::name('pay_wages')->where('id',$data['id'])->find();
  24. if(!$info){
  25. return '参数错误';
  26. }
  27. // if($info['company_id'] == 2 && $info['type'] == 3 && count($content) != 50){
  28. // return '参数错误';
  29. // }
  30. // if(($info['company_id'] == 1 || ($info['company_id'] == 2 && $info['type'] != 3)) && count($content) != 65){
  31. // return '参数错误';
  32. // }
  33. return true;
  34. }
  35. }