0
0

DinnerWechat.php 969 B

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. <?php
  2. namespace app\common\validate;
  3. use think\Db;
  4. use think\Validate;
  5. class DinnerWechat extends Validate{
  6. protected $rule = [
  7. 'org_id' => 'require|checkOrgId',
  8. 'app_id|开发者ID' => 'require',
  9. 'secret|开发者密码' => 'require',
  10. 'mch_id|商户号' => 'require',
  11. 'key|支付秘钥' => 'require',
  12. ];
  13. protected $message = [
  14. 'org_id.require' => '未选择项目'
  15. ];
  16. protected $scene = [
  17. ];
  18. protected function checkOrgId($value,$rule,$data=[])
  19. {
  20. if(isset($data['id']) && $data['id'] > 0){
  21. $ret = Db::name('dinner_wechat')
  22. ->where('org_id',$data['org_id'])
  23. ->where('id','<>',$data['id'])
  24. ->find();
  25. }else{
  26. $ret = Db::name('dinner_wechat')
  27. ->where('org_id',$data['org_id'])
  28. ->find();
  29. }
  30. return $ret?'该项目已有配置':true;
  31. }
  32. }