HouseContractPay.php 838 B

12345678910111213141516171819202122232425262728293031
  1. <?php
  2. namespace app\common\validate;
  3. use think\Validate;
  4. use think\Db;
  5. class HouseContractPay extends Validate{
  6. protected $rule = [
  7. 'contract_id' => 'require',
  8. // 'sn|编号' => 'require|checkUnique',
  9. // 'intro|说明' => 'require',
  10. // 'pay_date|缴费时间' => 'require|date',
  11. ];
  12. protected $scene = [
  13. 'contract_id.require' => '参数错误'
  14. ];
  15. protected function checkUnique($value,$rule,$data=[])
  16. {
  17. $info = Db::name('house_contract_pay')->where('sn',$value)->where('del',0)->where('org_id',$data['org_id'])->find();
  18. if($data['id'] <= 0 && $info){
  19. return '编号已被使用';
  20. }
  21. if($info && $data['id'] > 0 && $info['id'] != $data['id']){
  22. return '编号已被使用';
  23. }
  24. return true;
  25. }
  26. }