ShopSettingsValidate.php 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  1. <?php
  2. // +----------------------------------------------------------------------
  3. // | likeshop100%开源免费商用商城系统
  4. // +----------------------------------------------------------------------
  5. // | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
  6. // | 开源版本可自由商用,可去除界面版权logo
  7. // | 商业版本务必购买商业授权,以免引起法律纠纷
  8. // | 禁止对系统程序代码以任何目的,任何形式的再发布
  9. // | gitee下载:https://gitee.com/likeshop_gitee
  10. // | github下载:https://github.com/likeshop-github
  11. // | 访问官网:https://www.likeshop.cn
  12. // | 访问社区:https://home.likeshop.cn
  13. // | 访问手册:http://doc.likeshop.cn
  14. // | 微信公众号:likeshop技术社区
  15. // | likeshop团队 版权所有 拥有最终解释权
  16. // +----------------------------------------------------------------------
  17. // | author: likeshopTeam
  18. // +----------------------------------------------------------------------
  19. namespace app\adminapi\validate\settings\shop;
  20. use app\common\validate\BaseValidate;
  21. use think\facade\Request;
  22. /**
  23. * 店铺设置验证器
  24. * Class ShopSettingsValidate
  25. * @package app\adminapi\validate\settings\shop
  26. */
  27. class ShopSettingsValidate extends BaseValidate
  28. {
  29. protected $rule = [
  30. 'name' => 'require',
  31. 'logo' => 'require',
  32. 'admin_login_image' => 'require',
  33. 'login_restrictions' => 'require|in:0,1',
  34. 'password_error_times' => 'requireIf:login_restrictions,1|integer|gt:0',
  35. 'limit_login_time' => 'requireIf:login_restrictions,1|integer|gt:0',
  36. 'status' => 'require|in:0,1',
  37. 'share_page' => 'require|in:1',
  38. 'mall_contact' => 'require',
  39. 'mall_contact_mobile' => 'require|mobile',
  40. // 'return_contact' => 'require',
  41. // 'return_contact_mobile' => 'require|mobile',
  42. // 'return_province' => 'require',
  43. // 'return_city' => 'require',
  44. // 'return_district' => 'require',
  45. // 'return_address' => 'require',
  46. 'document_status' => 'require|in:0,1|checkDocumentStatus',
  47. ];
  48. protected $message = [
  49. 'name.require' => '请输入商城名称',
  50. 'logo.require' => '请上传商城logo',
  51. 'admin_login_image.require' => '请上传管理后台登录页图片',
  52. 'login_restrictions.require' => '请选择管理后台登录限制',
  53. 'login_restrictions.in' => '管理后台登录限制状态值有误',
  54. 'password_error_times.requireIf' => '请输入密码错误次数',
  55. 'password_error_times.integer' => '密码错误次数须为整型',
  56. 'password_error_times.gt' => '密码错误次数须大于0',
  57. 'limit_login_time.requireIf' => '请输入限制登录分钟数',
  58. 'limit_login_time.integer' => '限制登录分钟数须为整型',
  59. 'limit_login_time.gt' => '限制登录分钟数须大于0',
  60. 'status.require' => '请选择商城状态',
  61. 'status.in' => '商城状态值有误',
  62. 'share_page.require' => '请选择分享页面',
  63. 'share_page.in' => '分享页面值有误',
  64. 'share_image.require' => '请上传分享图片',
  65. 'mall_contact.require' => '请输入联系人姓名',
  66. 'mall_contact_mobile.require' => '请输入联系人手机号',
  67. 'mall_contact_mobile.mobile' => '联系人手机号格式错误',
  68. // 'return_contact.require' => '请输入退货联系人',
  69. // 'return_contact_mobile.require' => '请输入退货联系人手机号',
  70. // 'return_contact_mobile.mobile' => '退货联系人手机号格式错误',
  71. // 'return_province.require' => '请选择退货省份',
  72. // 'return_city.require' => '请选择退货城市',
  73. // 'return_district.require' => '请选择退货地区',
  74. // 'return_address.require' => '请输入退货详细地址',
  75. 'document_status.require' => '请选择文档信息开关',
  76. 'document_status.in' => '文档信息值错误',
  77. ];
  78. /**
  79. * @notes 设置店铺信息场景
  80. * @return ShopSettingsValidate
  81. * @author Tab
  82. * @date 2021/7/28 14:50
  83. */
  84. public function sceneSetShopInfo()
  85. {
  86. return $this->only(['name', 'logo', 'admin_name', 'admin_logo', 'admin_login_image', 'login_restrictions', 'password_error_times', 'limit_login_time', 'status', 'mall_contact', 'mall_contact_mobile','document_status']);
  87. }
  88. /**
  89. * @notes 分享设置场景
  90. * @return ShopSettingsValidate
  91. * @author Tab
  92. * @date 2021/7/28 15:34
  93. */
  94. public function sceneSetShareSetting()
  95. {
  96. return $this->only(['share_page', 'share_image']);
  97. }
  98. /**
  99. * @notes 校验产品授权
  100. * @param $value
  101. * @param $rule
  102. * @param $data
  103. * @return bool|string
  104. * @author ljj
  105. * @date 2023/5/16 11:25 上午]
  106. */
  107. public function checkDocumentStatus($value,$rule,$data)
  108. {
  109. if ($value == 0) {
  110. $check_domain = config('project.check_domain');
  111. $product_code = config('project.product_code');
  112. $domain = $_SERVER['HTTP_HOST'];
  113. $result = \Requests::get($check_domain.'/api/version/productAuth?code='.$product_code.'&domain='.$domain);
  114. $result = json_decode($result->body,true);
  115. if (!$result['data']['result']) {
  116. return '产品未授权,要去官网授权才能操作';
  117. }
  118. }
  119. return true;
  120. }
  121. }