ApplyClass.php 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165
  1. <?php
  2. namespace bizHd\saas\classes;
  3. use biz\sj\classes\SjClass;
  4. use bizHd\admin\classes\AdminClass;
  5. use bizHd\admin\classes\ShopAdminClass;
  6. use bizHd\agent\classes\AgentAssetClass;
  7. use bizGhs\custom\classes\CustomClass;
  8. use biz\sj\classes\MerchantClass;
  9. use common\components\dict;
  10. use common\components\noticeUtil;
  11. use common\components\sms;
  12. use common\components\stringUtil;
  13. use common\components\util;
  14. use bizHd\base\classes\BaseClass;
  15. class ApplyClass extends BaseClass
  16. {
  17. public static $baseFile = '\bizHd\saas\models\Apply';
  18. //来自零售平台
  19. const FROM_RETAIL = 1;
  20. //来自供货商平台
  21. const FROM_GHS = 2;
  22. const STATUS_CHECKING = 1;
  23. const STATUS_PASS = 2;
  24. const STATUS_UN_PASS = 3;
  25. const STATUS_HAS_PAY = 4;
  26. const STATUS_EXPIRE = 5;
  27. //证件类型
  28. const CERT_TYPE_LICENSE = 1;
  29. const CERT_TYPE_PERSON = 2;
  30. const CERT_TYPE_MOBILE = 3;
  31. //更新申请 ssh 2021.2.27
  32. public static function updateRetail($data)
  33. {
  34. $customId = $data['customId'] ?? 0;
  35. $custom = CustomClass::getById($customId);
  36. $customSjId = $custom['customSjId'] ?? 0;
  37. $currentApply = ApplyClass::getByCondition(['sjId' => $customSjId]);
  38. if (empty($currentApply)) {
  39. util::fail('此客户没有申请开店记录,请排查');
  40. }
  41. $currentApplyId = $currentApply['id'] ?? 0;
  42. $licenseNo = $currentApply['licenseNo'] ?? '';
  43. if (!empty($licenseNo)) {
  44. util::fail('您已经申请过了');
  45. }
  46. $applyMobile = $currentApply['mobile'] ?? '';
  47. $mobile = $data['mobile'] ?? '';
  48. if ($mobile != $applyMobile) {
  49. noticeUtil::push("二次申请开店使用的手机号不一样 customId:{$customId}", '15280215347');
  50. util::fail('手机号错误,请联系管理员', '15280215347');
  51. }
  52. $data['status'] = ApplyClass::STATUS_CHECKING;
  53. ApplyClass::updateById($currentApplyId, $data);
  54. $licenseNo = $data['licenseNo'] ?? '';
  55. $mobile = $data['mobile'] ?? '';
  56. $extData = [
  57. 'licenseNo' => $licenseNo,
  58. 'mobile' => $mobile,
  59. ];
  60. ApplyExtendClass::updateByCondition(['applyId' => $currentApplyId], $extData);
  61. return true;
  62. }
  63. //新增申请开店 ssh 2021.2.27
  64. public static function addRetail($data)
  65. {
  66. $city = $data['city'] ?? '';
  67. $dist = $data['dist'] ?? '';
  68. $floor = $data['floor'] ?? '';
  69. $address = $data['address'] ?? '';
  70. $data['fullAddress'] = $city . $dist . $address . $floor;
  71. $data['style'] = SjClass::STYLE_RETAIL;
  72. $respond = self::addApply($data);
  73. //供货商添加客户的不需要通知
  74. if (isset($data['replace']) && $data['replace'] == 0) {
  75. $mobile = $data['mobile'];
  76. $text = "零售商 {$mobile} 已提交资料,";
  77. if (isset($data['introSjName']) && !empty($data['introSjName'])) {
  78. $text .= "介绍人:{$data['introSjName']},";
  79. }
  80. $text .= "请及时跟进";
  81. noticeUtil::push($text, '15280215347');
  82. }
  83. return $respond;
  84. }
  85. //新增申请开店 ssh 2021.2.27
  86. public static function addGhs($data)
  87. {
  88. $dist = $data['dist'] ?? '';
  89. $floor = $data['floor'] ?? '';
  90. $address = $data['address'] ?? '';
  91. $city = $data['city'] ?? '';
  92. $data['fullAddress'] = $city . $dist . $address . $floor;
  93. $data['style'] = SjClass::STYLE_SUPPLIER;
  94. $respond = self::addApply($data);
  95. if (isset($data['replace']) && $data['replace'] == 0) {
  96. $mobile = $data['mobile'];
  97. $text = "供货商 {$mobile} 已提交资料,";
  98. if (isset($data['introSjName']) && !empty($data['introSjName'])) {
  99. $text .= "介绍人:{$data['introSjName']},";
  100. }
  101. $text .= "请及时跟进";
  102. noticeUtil::push($text, '15280215347');
  103. }
  104. return $respond;
  105. }
  106. //新增申请开店 ssh 2021.2.27
  107. public static function addKmGhs($data)
  108. {
  109. $dist = $data['dist'] ?? '';
  110. $floor = $data['floor'] ?? '';
  111. $address = $data['address'] ?? '';
  112. $city = $data['city'] ?? '';
  113. $data['fullAddress'] = $city . $dist . $address . $floor;
  114. $data['style'] = dict::getDict('ptStyle', 'kmGhs');
  115. $respond = self::addApply($data);
  116. if (isset($data['replace']) && $data['replace'] == 0) {
  117. $mobile = $data['mobile'];
  118. $text = "供货商 {$mobile} 已提交资料,";
  119. if (isset($data['introSjName']) && !empty($data['introSjName'])) {
  120. $text .= "介绍人:{$data['introSjName']},";
  121. }
  122. $text .= "请及时跟进";
  123. noticeUtil::push($text, '15280215347');
  124. }
  125. return $respond;
  126. }
  127. //添加申请 ssh 2020.2.10
  128. public static function addApply($data)
  129. {
  130. //邀请人数+1
  131. $introSjId = isset($data['introSjId']) ? $data['introSjId'] : '';
  132. if (!empty($introSjId)) {
  133. $agent = AgentAssetClass::getByCondition(['sjId' => $introSjId], true);
  134. if (empty($agent)) {
  135. $agent = AgentAssetClass::add(['sjId' => $introSjId], true);
  136. }
  137. $agent->inviteNum += 1;
  138. $agent->save();
  139. }
  140. $name = $data['name'] ?? 0;
  141. $num = stringUtil::getWordNum($name);
  142. if ($num > 19) {
  143. util::fail('标题不能超过19个字');
  144. }
  145. $apply = self::add($data);
  146. $id = $apply['id'];
  147. $data['applyId'] = $id;
  148. ApplyExtendClass::add($data);
  149. return $apply;
  150. }
  151. }