LlEventController.php 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. <?php
  2. namespace hd\controllers;
  3. use bizHd\ll\classes\LlEventClass;
  4. use common\components\util;
  5. use Yii;
  6. class LlEventController extends BaseController
  7. {
  8. public $guestAccess = [];
  9. public function actionList()
  10. {
  11. $get = Yii::$app->request->get();
  12. $requestType = $get['requestType'] ?? '';
  13. if ($requestType == 'my') {
  14. $shopId = $this->shopId;
  15. $where = ['launchShopId' => $shopId];
  16. } else {
  17. $where = [];
  18. }
  19. $respond = LlEventClass::getEventList($where);
  20. util::success($respond);
  21. }
  22. public function actionAdd()
  23. {
  24. $post = Yii::$app->request->post();
  25. $name = $post['name']??'';
  26. if(empty($name)){
  27. util::fail('请填写店名或姓名');
  28. }
  29. $no = $post['no']??'';
  30. if(!empty($no)){
  31. $pattern = '/^(?:\d{15}|\d{17}[\dxX])$/';
  32. $valid = preg_match($pattern, $no);
  33. if($valid == false){
  34. util::fail('身份证号错误');
  35. }
  36. }
  37. $mobile = $post['mobile']??'';
  38. $wx = $post['wx']??'';
  39. if(empty($wx) && empty($mobile) && empty($no)){
  40. util::fail('手机号、微信号、身份证必填一项');
  41. }
  42. $prove = $post['prove']??[];
  43. if(empty($prove)){
  44. util::fail('证据最少要一张');
  45. }
  46. $respond = LlEventClass::addEvent($post);
  47. util::success($respond);
  48. }
  49. }