截流自动化的商城平台
您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

ShopApplyValidate.php 2.0KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. <?php
  2. namespace app\api\validate;
  3. use app\common\basics\Validate;
  4. use app\common\enum\NoticeEnum;
  5. use app\common\logic\SmsLogic;
  6. class ShopApplyValidate extends Validate
  7. {
  8. protected $rule = [
  9. 'cid' => 'require|number',
  10. 'name' => 'require|chsAlphaNum',
  11. 'nickname' => 'require|chsAlphaNum',
  12. 'mobile' => 'require|mobile',
  13. 'account' => 'require|unique:shop_apply,name&del|alphaNum|min:2|max:20',
  14. 'password' => 'require|alphaDash|min:6|max:32',
  15. 'license' => 'require|array',
  16. 'code' => 'require|checkCode'
  17. ];
  18. protected $message = [
  19. 'cid.require' => '请选择主营类目',
  20. 'cid.number' => 'cid参数必须为数字',
  21. 'name.require' => '请填写商家名称',
  22. 'nickname.require' => '请填写联系人姓名',
  23. 'mobile.require' => '请填写手机号码',
  24. 'mobile.mobile' => '请填写正确的手机号',
  25. 'account.require' => '请现在创建的账号',
  26. 'account.unique' => '该账号已存在',
  27. 'account.alphaNum' => '账号必须由数字或字母组成',
  28. 'account.min' => '账号长度不能少于2个字符',
  29. 'account.max' => '账号长度不能超过20个字符',
  30. 'password.require' => '请填写登录密码',
  31. 'license.require' => '请上传营业执照',
  32. 'license.array' => 'license参数需数组格式',
  33. 'code.require' => '请输入验证码'
  34. ];
  35. protected $scene = [
  36. 'apply' => ['cid', 'name', 'nickname', 'mobile', 'account', 'password', 'license', 'code']
  37. ];
  38. //验证手机验证码
  39. protected function checkCode($value, $rule, $data)
  40. {
  41. $message_key = NoticeEnum::SHOP_APPLY_CHECK_CODE;
  42. $res = SmsLogic::check($message_key, $data['mobile'], $value);
  43. if (false === $res) {
  44. return SmsLogic::getError();
  45. }
  46. return true;
  47. }
  48. }