Form.php 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118
  1. <?php
  2. // +----------------------------------------------------------------------
  3. // | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
  4. // +----------------------------------------------------------------------
  5. // | Copyright (c) 2016~2024 https://www.crmeb.com All rights reserved.
  6. // +----------------------------------------------------------------------
  7. // | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权
  8. // +----------------------------------------------------------------------
  9. // | Author: CRMEB Team <admin@crmeb.com>
  10. // +----------------------------------------------------------------------
  11. namespace app\controller\api\store\form;
  12. use app\common\repositories\store\StoreActivityRelatedRepository;
  13. use app\common\repositories\store\StoreActivityRepository;
  14. use app\common\repositories\system\form\FormRepository;
  15. use app\common\repositories\user\UserMerchantRepository;
  16. use think\App;
  17. use crmeb\basic\BaseController;
  18. use think\exception\ValidateException;
  19. class Form extends BaseController
  20. {
  21. protected $repository;
  22. /**
  23. * ProductCategory constructor.
  24. * @param App $app
  25. * @param StoreActivityRepository $repository
  26. */
  27. public function __construct(App $app, StoreActivityRepository $repository)
  28. {
  29. parent::__construct($app);
  30. $this->repository = $repository;
  31. }
  32. /**
  33. * 报名活动列表
  34. * @return \think\response\Json
  35. * @author Qinii
  36. * @day 2023/10/8
  37. */
  38. public function lst()
  39. {
  40. [$page, $limit] = $this->getPage();
  41. $where['activity_type'] = $this->repository::ACTIVITY_TYPE_FORM;
  42. // $where['status'] = 1;
  43. $where['is_show'] = 1;
  44. return app('json')->success($this->repository->getList($where, $page, $limit));
  45. }
  46. /**
  47. * 报名活动详情
  48. * @Author:Qinii
  49. * @Date: 2020/5/29
  50. * @param $id
  51. * @return mixed
  52. */
  53. public function detail($id)
  54. {
  55. $info = $this->repository->getWhere([$this->repository->getPk() => $id], '*', ['systemForm']);
  56. if (!$info) return app('json')->fail('数据不存在');
  57. //$this->repository->verifyActivityStatus($info);
  58. $info->append(['time_status']);
  59. // 判断该用户有没有提交表单
  60. $info['activity_related_id'] = $this->repository->verifyActivityData((int)$this->request->uid(), (int)$id);
  61. $data['data'] = $info;
  62. return app('json')->encode($data);
  63. }
  64. /**
  65. * 获取报名数据
  66. * @param $form_id
  67. * @return \think\response\Json
  68. * @author wuhaotian
  69. * @email 442384644@qq.com
  70. * @date 2024/7/10
  71. */
  72. public function getFormInfo($form_id)
  73. {
  74. $info = app()->make(FormRepository::class)->getSearch(['form_id' => $form_id])->find();
  75. if (!$info) return app('json')->fail('数据不存在');
  76. return app('json')->encode($info);
  77. }
  78. /**
  79. * 分享报名
  80. * @param $id
  81. * @return \think\response\Json
  82. * @throws \think\db\exception\DataNotFoundException
  83. * @throws \think\db\exception\DbException
  84. * @throws \think\db\exception\ModelNotFoundException
  85. * @author wuhaotian
  86. * @email 442384644@qq.com
  87. * @date 2024/7/10
  88. */
  89. public function getSharePosters($id)
  90. {
  91. $type = $this->request->param('type');
  92. $user = $this->request->userInfo();
  93. $activity = $this->repository->get((int)$id);
  94. if (empty($activity)) {
  95. return app('json')->success('报名活动异常');
  96. }
  97. $qrcode = $type == 'routine'
  98. ? $this->repository->mpQrcode((int)$user['uid'], $activity)
  99. : $this->repository->wxQrcode((int)$user['uid'], $activity);
  100. $poster = $activity['images'];
  101. $nickname = $user['nickname'];
  102. $mark = '邀您一起参加' . $activity['activity_name'] ?? '活动';
  103. return app('json')->success(compact('qrcode', 'poster', 'nickname', 'mark'));
  104. }
  105. }