MerchantApplymentsValidate.php 10 KB

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