1234567891011121314151617181920212223242526272829303132333435363738394041 |
- <?php
- namespace app\common\validate;
- use think\Db;
- use think\Validate;
- class DinnerWechat extends Validate{
- protected $rule = [
- 'org_id' => 'require|checkOrgId',
- 'app_id|开发者ID' => 'require',
- 'secret|开发者密码' => 'require',
- 'mch_id|商户号' => 'require',
- 'key|支付秘钥' => 'require',
- ];
- protected $message = [
- 'org_id.require' => '未选择项目'
- ];
- protected $scene = [
- ];
- protected function checkOrgId($value,$rule,$data=[])
- {
- if(isset($data['id']) && $data['id'] > 0){
- $ret = Db::name('dinner_wechat')
- ->where('org_id',$data['org_id'])
- ->where('id','<>',$data['id'])
- ->find();
- }else{
- $ret = Db::name('dinner_wechat')
- ->where('org_id',$data['org_id'])
- ->find();
- }
- return $ret?'该项目已有配置':true;
- }
- }
|