LlEventController.php 4.7 KB

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