LlEventController.php 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158
  1. <?php
  2. namespace hd\controllers;
  3. use bizHd\ll\classes\LlEventClass;
  4. use common\components\imgUtil;
  5. use common\components\stringUtil;
  6. use common\components\util;
  7. use Yii;
  8. class LlEventController extends BaseController
  9. {
  10. public $guestAccess = [];
  11. public function actionAddMobile()
  12. {
  13. $post = Yii::$app->request->post();
  14. $id = $post['id'] ?? 0;
  15. $mobile = $post['mobile'] ?? '';
  16. if (empty($mobile)) {
  17. util::fail('没有手机号');
  18. }
  19. if (!stringUtil::isMobile($mobile)) {
  20. util::fail('手机号错误');
  21. }
  22. $event = LlEventClass::getById($id, true);
  23. if (empty($event)) {
  24. util::fail('没有找到');
  25. }
  26. $shopId = $this->shopId;
  27. if (!isset($event['launchShopId']) || $event['launchShopId'] != $shopId) {
  28. util::fail('不是你提交的');
  29. }
  30. LlEventClass::addMobile($event, $mobile);
  31. util::complete('添加成功');
  32. }
  33. //添加微信
  34. public function actionAddWx()
  35. {
  36. $post = Yii::$app->request->post();
  37. $id = $post['id'] ?? 0;
  38. $wx = $post['mobile'] ?? '';
  39. if (empty($wx)) {
  40. util::fail('没有微信');
  41. }
  42. $event = LlEventClass::getById($id, true);
  43. if (empty($event)) {
  44. util::fail('没有找到');
  45. }
  46. $shopId = $this->shopId;
  47. if (!isset($event['launchShopId']) || $event['launchShopId'] != $shopId) {
  48. util::fail('不是你提交的');
  49. }
  50. LlEventClass::addWx($event, $wx);
  51. util::complete('添加成功');
  52. }
  53. //添加身份证号
  54. public function actionAddNo()
  55. {
  56. $post = Yii::$app->request->post();
  57. $id = $post['id'] ?? 0;
  58. $no = $post['no'] ?? '';
  59. if (empty($no)) {
  60. util::fail('没有身份证号');
  61. }
  62. $event = LlEventClass::getById($id, true);
  63. if (empty($event)) {
  64. util::fail('没有找到');
  65. }
  66. $shopId = $this->shopId;
  67. if (!isset($event['launchShopId']) || $event['launchShopId'] != $shopId) {
  68. util::fail('不是你提交的');
  69. }
  70. LlEventClass::addNo($event, $no);
  71. util::complete('添加成功');
  72. }
  73. public function actionDetail()
  74. {
  75. $get = Yii::$app->request->get();
  76. $id = $get['id'] ?? 0;
  77. $event = LlEventClass::getById($id);
  78. if (empty($event)) {
  79. util::fail('没有找到');
  80. }
  81. $shopId = $this->shopId;
  82. if (!isset($event['launchShopId']) || $event['launchShopId'] != $shopId) {
  83. util::fail('不是你提交的');
  84. }
  85. $proveJson = $event['prove'] ?? '';
  86. $proveData = json_decode($proveJson, true);
  87. $proveShort = [];
  88. $proveBig = [];
  89. $proveSmall = [];
  90. if (!empty($proveData)) {
  91. foreach ($proveData as $url) {
  92. $proveShort[] = $url;
  93. $small = imgUtil::groupImg($url) . "?x-oss-process=image/resize,m_fill,h_130,w_130";
  94. $big = imgUtil::groupImg($url) . "?x-oss-process=image/resize,m_fill,h_700,w_700";
  95. $proveBig[] = $big;
  96. $proveSmall[] = $small;
  97. }
  98. }
  99. $event['proveShort'] = $proveShort;
  100. $event['proveBig'] = $proveBig;
  101. $event['proveSmall'] = $proveSmall;
  102. util::success(['event' => $event]);
  103. }
  104. public function actionList()
  105. {
  106. $get = Yii::$app->request->get();
  107. $requestType = $get['requestType'] ?? '';
  108. $where = [];
  109. $sensitive = true;
  110. if ($requestType == 'my') {
  111. $shopId = $this->shopId;
  112. $where['launchShopId'] = $shopId;
  113. $sensitive = false;
  114. }
  115. $respond = LlEventClass::getEventList($where, $sensitive);
  116. util::success($respond);
  117. }
  118. public function actionAdd()
  119. {
  120. $post = Yii::$app->request->post();
  121. $name = $post['name'] ?? '';
  122. if (empty($name)) {
  123. util::fail('请填写店名或姓名');
  124. }
  125. $no = $post['no'] ?? '';
  126. if (!empty($no)) {
  127. $pattern = '/^(?:\d{15}|\d{17}[\dxX])$/';
  128. $valid = preg_match($pattern, $no);
  129. if ($valid == false) {
  130. util::fail('身份证号错误');
  131. }
  132. }
  133. $mobile = $post['mobile'] ?? '';
  134. $wx = $post['wx'] ?? '';
  135. if (empty($wx) && empty($mobile) && empty($no)) {
  136. util::fail('手机号、微信号、身份证必填一项');
  137. }
  138. $prove = $post['prove'] ?? [];
  139. if (empty($prove)) {
  140. util::fail('证据最少要一张');
  141. }
  142. $shop = $this->shop;
  143. $respond = LlEventClass::addEvent($post, $shop);
  144. util::success($respond);
  145. }
  146. }