MerchantApplymentsValidate.php 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297
  1. <?php
  2. // +----------------------------------------------------------------------
  3. // | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
  4. // +----------------------------------------------------------------------
  5. // | Copyright (c) 2016~2022 https://www.crmeb.com All rights reserved.
  6. // +----------------------------------------------------------------------
  7. // | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权
  8. // +----------------------------------------------------------------------
  9. // | Author: CRMEB Team <admin@crmeb.com>
  10. // +----------------------------------------------------------------------
  11. namespace app\validate\merchant;
  12. use think\Validate;
  13. class MerchantApplymentsValidate extends Validate
  14. {
  15. protected $failException = true;
  16. //2401:小微商户,指无营业执照的个人商家。
  17. //2500:个人卖家,指无营业执照,已持续从事电子商务经营活动满6个月,且期间经营收入累计超过20万元的个人商家。(若选择该主体,请在“补充说明”填写相关描述)
  18. //4:个体工商户,营业执照上的主体类型一般为个体户、个体工商户、个体经营。
  19. //2:企业,营业执照上的主体类型一般为有限公司、有限责任公司。
  20. //3:党政、机关及事业单位,包括国内各级、各类政府机构、事业单位等(如:公安、党 团、司法、交通、旅游、工商税务、市政、医疗、教育、学校等机构)。
  21. //1708:其他组织,不属于企业、政府/事业单位的组织机构(如社会团体、民办非企业、基 金会),要求机构已办理组织机构代码证。
  22. protected $rule = [
  23. 'organization_type|主体类型' => 'require|in:2,3,4,2401,2500,1708',
  24. 'business_license_info|营业执照/登记证书信息' => 'checkBusinessInfo',
  25. // 'organization_cert_info|组织机构代码证信息' => 'checkOrganization',
  26. 'id_doc_type|证件类型' => 'require|in:1,2,3,4,5,6,7,8',
  27. 'id_card_info|经营者/法人身份证信息' => 'checkIdCardInfo',
  28. 'id_doc_info|经营者/法人身份证信息' => 'checkIdDocInfo',
  29. // 'need_account_info|是否填写结算银行账户' => 'require|in:true,false', 废弃字段
  30. 'account_info|结算银行账户' => 'getAccountInfo',
  31. 'contact_info|超级管理员信息' => 'getContactInfo',
  32. 'sales_scene_info|店铺信息'=>'checkSalesSceneInfo',
  33. 'merchant_shortname|商户简称' => 'require',
  34. 'business_addition_desc' => 'checkBusinessAdditionDesc',
  35. ];
  36. /**
  37. * TODO 营业执照/登记证书信息
  38. * @param $item
  39. * @param $rule
  40. * @param $data
  41. * @return bool|string
  42. * @author Qinii
  43. * @day 6/22/21
  44. */
  45. protected function checkBusinessInfo($item,$rule,$data)
  46. {
  47. if(!in_array($data['organization_type'],['2401','2500'])){
  48. if(empty($item)) return '营业执照/登记证书信息为空';
  49. if(!isset($item['business_license_copy']) || empty($item['business_license_copy'])) return '证件扫描件为空';
  50. if(!isset($item['business_license_number']) || empty($item['business_license_number'])) return '证件注册号为空';
  51. if(!isset($item['merchant_name']) || empty($item['merchant_name'])) return '商户名称为空';
  52. if(!isset($item['legal_person']) || empty($item['legal_person'])) return '经营者/法定代表人姓名为空';
  53. if(isset($item['business_time'])) {
  54. $statr = $item['business_time'][0];
  55. $end = $item['business_time'][1];
  56. if ($end !== '长期') {
  57. $statr = strtotime($statr);
  58. $end = strtotime($end);
  59. $t = $end - $statr;
  60. if (($t / (3600 * 24)) <= 60) return '营业执照/登记证书有效期必须大于60天,即结束时间距当前时间需超过60天';
  61. }
  62. }
  63. }
  64. return true;
  65. }
  66. /**
  67. * TODO 组织机构代码证信息
  68. * @param $item
  69. * @param $rule
  70. * @param $data
  71. * @return bool|string
  72. * @author Qinii
  73. * @day 6/22/21
  74. */
  75. protected function checkOrganization($item,$rule,$data)
  76. {
  77. $len = strlen($data['business_license_info']['business_license_number']);
  78. if(!in_array($data['organization_type'],['4','2401','2500']) && $len === 18){
  79. if(empty($item)) return '组织机构代码证信息为空';
  80. if(!isset($item['organization_copy']) || empty($item['organization_copy'])) return '组织机构代码证照片为空';
  81. if(!isset($item['organization_number']) || empty($item['organization_number'])) return '组织机构代码为空';
  82. if(!isset($item['organization_time']) || empty($item['organization_time'])) return '组织机构代码有效期限为空';
  83. // list($statr,$end) = explode(',',$item['organization_time']);
  84. $statr = $item['organization_time'][0];
  85. $end = $item['organization_time'][1];
  86. if($end !== '长期') {
  87. $statr = strtotime($statr);
  88. $end = strtotime($end);
  89. $t = $end - $statr;
  90. if(($t/(3600 * 24)) <= 60) return '组织机构代码证有效期必须大于60天,即结束时间距当前时间需超过60天';
  91. }
  92. }
  93. return true;
  94. }
  95. /**
  96. * TODO 经营者/法人身份证信息/身份证
  97. * @param $item
  98. * @param $rule
  99. * @param $data
  100. * @return bool|string
  101. * @author Qinii
  102. * @day 6/22/21
  103. */
  104. protected function checkIdCardInfo($item,$rule,$data)
  105. {
  106. if($data['id_doc_type'] == 1){
  107. if(empty($item)) return '经营者/法人身份证信息为空';
  108. if(!isset($item['id_card_copy']) || empty($item['id_card_copy'])) return '身份证人像面照片为空';
  109. if(!isset($item['id_card_national']) || empty($item['id_card_national'])) return '身份证国徽面照片为空';
  110. if(!isset($item['id_card_name']) || empty($item['id_card_name'])) return '身份证姓名为空';
  111. if(!isset($item['id_card_number']) || empty($item['id_card_number'])) return '身份证号码为空';
  112. if(!isset($item['id_card_valid_time_begin']) || empty($item['id_card_valid_time_begin'])) return '经营者/法人身份证信息身份证开始时间为空';
  113. if(!isset($item['id_card_valid_time']) || empty($item['id_card_valid_time'])) return '经营者/法人身份证信息身份证有效期限为空';
  114. if($item['id_card_valid_time'] !== '长期') {
  115. $statr = time();
  116. $end = strtotime($item['id_card_valid_time']);
  117. $t = $end - $statr;
  118. if(($t/(3600 * 24)) <= 60) return '经营者/法人身份证信息证件结束日期必须大于60天,即结束时间距当前时间需超过60天';
  119. if(strtotime($item['id_card_valid_time_begin']) >= strtotime($item['id_card_valid_time'])) return '经营者/法人身份证信息证件结束日期必须大于证件开始时间';
  120. }
  121. if($data['organization_type'] === 2){
  122. if(!isset($item['id_card_address']) || empty($item['id_card_address'])) return '经营者/法人身份证信息身份证居住地址为空';
  123. }
  124. };
  125. return true;
  126. }
  127. /**
  128. * TODO 经营者/法人身份证信息/通行证
  129. * @param $item
  130. * @param $rule
  131. * @param $data
  132. * @return bool|string
  133. * @author Qinii
  134. * @day 6/22/21
  135. */
  136. protected function checkIdDocInfo($item,$rule,$data)
  137. {
  138. if(in_array($data['organization_type'],['2401','2500']) && !empty($item)) return '小微/个人卖家可选证件类型:身份证';
  139. if($data['id_doc_type'] !== 1){
  140. if(empty($item)) return '经营者/法人身份证信息为空';
  141. if(!isset($item['id_doc_name']) || empty($item['id_doc_name'])) return '证件姓名为空';
  142. if(!isset($item['id_doc_number']) || empty($item['id_doc_number'])) return '证件号码为空';
  143. if(!isset($item['id_doc_copy']) || empty($item['id_doc_copy'])) return '经营者/法人其他类型证件信息证件正面照片为空';
  144. if($data['id_doc_type'] !== 2) //护照不需要传反面
  145. {
  146. if(!isset($item['id_doc_copy_back']) || empty($item['id_doc_copy_back'])) return '经营者/法人其他类型证件信息证件反面照片为空';
  147. }
  148. if(!isset($item['doc_period_begin']) || empty($item['doc_period_begin'])) return '经营者/法人其他类型证件信息证件有效期开始时间为空';
  149. if(!isset($item['doc_period_end']) || empty($item['doc_period_end'])) return '经营者/法人其他类型证件信息证件结束日期为空';
  150. if($item['doc_period_end'] !== '长期') {
  151. $statr = time();
  152. $end = strtotime($item['doc_period_end']);
  153. $t = $end - $statr;
  154. if(($t/(3600 * 24)) <= 60) return '经营者/法人其他类型证件信息证件结束日期必须大于60天,即结束时间距当前时间需超过60天';
  155. if(strtotime($item['doc_period_begin']) >= strtotime($item['doc_period_end'])) return '经营者/法人其他类型证件信息证件结束日期必须大于证件开始时间';
  156. if($data['organization_type'] === 2){
  157. if(!isset($item['id_doc_address']) || empty($item['id_doc_address'])) return '经营者/法人其他类型证件信息证件居住地址为空';
  158. }
  159. }
  160. }
  161. return true;
  162. }
  163. /**
  164. * TODO 结算银行账户
  165. * @param $item
  166. * @param $rule
  167. * @param $data
  168. * @return bool|string
  169. * @author Qinii
  170. * @day 6/22/21
  171. */
  172. protected function getAccountInfo($item,$rule,$data)
  173. {
  174. // if($data['need_account_info']){
  175. if(empty($item)) return '结算银行账户信息为空';
  176. if(!isset($item['bank_account_type']) || empty($item['bank_account_type'])) return '账户类型为空';
  177. if(!isset($item['account_bank']) || empty($item['account_bank'])) return '开户银行为空';
  178. if(!isset($item['account_name']) || empty($item['account_name'])) return '开户名称为空';
  179. if(!isset($item['bank_address_code']) || empty($item['bank_address_code'])) return '开户银行省市编码为空';
  180. if(!isset($item['account_number']) || empty($item['account_number'])) return '银行帐号为空';
  181. // }
  182. return true;
  183. }
  184. /**
  185. * TODO 超级管理员信息
  186. * @param $item
  187. * @param $rule
  188. * @param $data
  189. * @return bool|string
  190. * @author Qinii
  191. * @day 6/22/21
  192. */
  193. protected function getContactInfo($item,$rule,$data)
  194. {
  195. if(empty($item)) return '超级管理员信息信息为空';
  196. if(!isset($item['contact_type']) || empty($item['contact_type'])) return '超级管理员类型为空';
  197. if(!isset($item['contact_name']) || empty($item['contact_name'])) return '超级管理员姓名为空';
  198. if(!isset($item['contact_id_card_number']) || empty($item['contact_id_card_number'])) return '超级管理员身份证件号码为空';
  199. if(!isset($item['mobile_phone']) || empty($item['mobile_phone'])) return '超级管理员手机为空';
  200. if(!in_array($data['organization_type'],['2401','2500'])){
  201. if(!isset($item['contact_email']) || empty($item['contact_email'])) return '邮箱为空';
  202. }
  203. if($item['contact_type'] === 66) //当超级管理员类型为66(经办人时)
  204. {
  205. if(!isset($item['contact_id_doc_type']) || empty($item['contact_id_doc_type']) || !in_array($item['contact_id_doc_type'],[1,2,3,4,5,6,7,8])) return '超级管理员证件类型为空或不合法';
  206. if(!isset($item['contact_id_doc_copy']) || empty($item['contact_id_doc_copy'])) return '超级管理员信息证件正面照片为空';
  207. if($item['contact_id_doc_type'] !== 2) //护照不需要传反面
  208. {
  209. if(!isset($item['contact_id_doc_copy_back']) || empty($item['contact_id_doc_copy_back'])) return '超级管理员信息证件反面照片为空';
  210. }
  211. if(!isset($item['contact_id_doc_period_begin']) || empty($item['contact_id_doc_period_begin'])) return '超级管理员信息证件有效期开始时间为空';
  212. if(!isset($item['contact_id_doc_period_end']) || empty($item['contact_id_doc_period_end'])) return '超级管理员信息证件结束日期为空';
  213. if($item['contact_id_doc_period_end'] !== '长期') {
  214. $statr = time();
  215. $end = strtotime($item['contact_id_doc_period_end']);
  216. $t = $end - $statr;
  217. if(($t/(3600 * 24)) <= 60) return '超级管理员信息证件结束日期必须大于60天,即结束时间距当前时间需超过60天';
  218. if(strtotime($item['contact_id_doc_period_begin']) >= strtotime($item['contact_id_doc_period_end'])) return '超级管理员信息证件结束日期必须大于证件开始时间';
  219. }
  220. if(!isset($item['business_authorization_letter']) || empty($item['business_authorization_letter'])) return '超级管理员信息业务办理授权函为空';
  221. }
  222. return true;
  223. }
  224. /**
  225. * TODO 店铺信息
  226. * @param $item
  227. * @param $rule
  228. * @param $data
  229. * @return bool|string
  230. * @author Qinii
  231. * @day 6/22/21
  232. */
  233. protected function checkSalesSceneInfo($item,$rule,$data)
  234. {
  235. if(empty($item)) return '店铺信息为空';
  236. if(!isset($item['store_name']) || empty($item['store_name'])) return '店铺名称为空';
  237. if(!isset($item['store_url']) && !isset($item['store_url'])) return '店铺链接和店铺二维码二选一';
  238. return true;
  239. }
  240. /**
  241. * TODO 补充说明s
  242. * @param $item
  243. * @param $rule
  244. * @param $data
  245. * @return bool|string
  246. * @author Qinii
  247. * @day 6/24/21
  248. */
  249. protected function checkBusinessAdditionDesc($item,$rule,$data)
  250. {
  251. if($data['organization_type'] == 2500 && empty($item)) return '若主体为“个人卖家”:补充说明不能为空';
  252. return true;
  253. }
  254. }