LlEventController.php 4.5 KB

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