| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289 |
- package com.linkwechat.web.controller.system;
- import com.baomidou.mybatisplus.core.metadata.IPage;
- import com.linkwechat.common.annotation.InnerAuth;
- import com.linkwechat.common.core.controller.BaseController;
- import com.linkwechat.common.core.domain.AjaxResult;
- import com.linkwechat.common.core.page.TableDataInfo;
- import com.linkwechat.common.utils.QrCodeGenerator;
- import com.linkwechat.common.utils.QrcodeUtils;
- import com.linkwechat.common.utils.createQrCode.CreateQRCodeByCodeVO;
- import com.linkwechat.common.utils.createQrCode.WxMiniProgramGetQRCodeByCommonUtil;
- import com.linkwechat.domain.weGroupFission.dto.DistDto;
- import com.linkwechat.domain.weGroupFission.dto.WeGroupFissionDetailDto;
- import com.linkwechat.domain.weGroupFission.dto.WeGroupFissionDto;
- import com.linkwechat.domain.weGroupFission.entity.WeGroupFission;
- import com.linkwechat.domain.weGroupFission.vo.CreateWechatGroupFissionUrlVo;
- import com.linkwechat.domain.weGroupFission.vo.WeGroupFissionAddVo;
- import com.linkwechat.domain.weGroupFission.vo.WeGroupFissionVo;
- import com.linkwechat.service.IWeGroupFissionService;
- import com.linkwechat.web.service.ISysUserService;
- import io.swagger.annotations.Api;
- import io.swagger.annotations.ApiOperation;
- import lombok.extern.slf4j.Slf4j;
- import me.chanjar.weixin.common.error.WxErrorException;
- import org.apache.commons.lang3.StringUtils;
- import org.springframework.beans.factory.annotation.Autowired;
- import org.springframework.beans.factory.annotation.Value;
- import org.springframework.http.HttpHeaders;
- import org.springframework.http.HttpStatus;
- import org.springframework.http.MediaType;
- import org.springframework.http.ResponseEntity;
- import org.springframework.web.bind.annotation.*;
- import javax.annotation.Resource;
- import javax.servlet.http.HttpServletRequest;
- import javax.servlet.http.HttpServletResponse;
- import javax.validation.Valid;
- import java.util.ArrayList;
- import java.util.List;
- /**
- * @Description: 群裂变活动表
- * @Author: jeecg-boot
- * @Date: 2026-01-28
- * @Version: V1.0
- */
- @Slf4j
- //@Api(tags="群裂变后台接口相关")
- @RestController
- @RequestMapping("system/weGroupFission")
- @CrossOrigin
- public class WeGroupFissionController extends BaseController {
- @Autowired
- private IWeGroupFissionService weGroupFissionService;
- @Autowired
- private ISysUserService sysUserService;
- @Resource
- private WxMiniProgramGetQRCodeByCommonUtil wxMiniProgramGetQRCodeByCommonUtil;
- //微信小程序的appid
- @Value("${wechat.app_id}")
- private String lifeWechatAppId;
- //微信小程序的appid
- @Value("${wechat.secret}")
- private String lifeWechatSecret;
- /**
- * @version
- * @author: hxl
- * @Date: 2026/1/28 10:43
- * @Description: 后台分页列表
- */
- //@ApiOperation(value="群裂变活动表-分页列表查询", notes="群裂变活动表-分页列表查询")
- @PostMapping(value = "/list")
- public TableDataInfo<?> queryPageList(@RequestBody WeGroupFissionVo weGroupFissionVo){
- return weGroupFissionService.getPageList(weGroupFissionVo);
- }
- /**
- * @version
- * @author: hxl
- * @Date: 2026/1/28 11:10
- * @Description:
- */
- //@ApiOperation(value="群裂变活动表-添加或者修改", notes="群裂变活动表-添加或者修改")
- @PostMapping(value = "/addOrUpdate")
- public AjaxResult addOrUpdate(@RequestBody @Valid WeGroupFissionAddVo weGroupFissionAddVo) {
- try{
- weGroupFissionService.addOrUpdate(weGroupFissionAddVo);
- return AjaxResult.success();
- }catch (Exception e){
- return AjaxResult.error(e.getMessage());
- }
- }
- /**
- * @version
- * @author: hxl
- * @Date: 2026/1/28 11:11
- * @Description: 详情接口
- */
- //@ApiOperation(value="群裂变活动表-详情接口", notes="群裂变活动表-详情接口")
- @GetMapping(value = "/queryById")
- public AjaxResult queryById(@RequestParam(name="id",required=true) String id) {
- try{
- WeGroupFissionDetailDto weGroupFissionDetailDto = weGroupFissionService.queryDetailById(id,"1");
- return AjaxResult.success(weGroupFissionDetailDto);
- }catch (Exception e){
- return AjaxResult.error(e.getMessage());
- }
- }
- /**
- * @version
- * @author: hxl
- * @Date: 2026/1/28 11:11
- * @Description: 通过id删除数据
- */
- //@ApiOperation(value="群裂变活动表-通过id删除", notes="群裂变活动表-通过id删除")
- @DeleteMapping(value = "/delete")
- public AjaxResult delete(@RequestParam(name="id",required=true) String id) {
- try{
- weGroupFissionService.deleteByWeGroupFissionId(id);
- return AjaxResult.success();
- }catch (Exception e){
- return AjaxResult.error(e.getMessage());
- }
- }
- /**
- * @version
- * @author: hxl
- * @Date: 2026/1/28 15:42
- * @Description: 生成小程序的群裂变页面加密链接
- */
- //@ApiOperation(value="群裂变活动表-群打卡微信小程序短链", notes="群裂变活动表-群打卡微信小程序短链")
- @PostMapping(value = "/getWechatGroupFissionUrl")
- public AjaxResult getWechatGroupFissionUrl(@RequestBody CreateWechatGroupFissionUrlVo createWechatGroupFissionUrlVo) {
- if(StringUtils.isBlank(createWechatGroupFissionUrlVo.getUrl())){
- return AjaxResult.error("生成页面路径不能为空");
- }
- if(StringUtils.isBlank(createWechatGroupFissionUrlVo.getGroupFissionId())){
- return AjaxResult.error("群裂变活动id不能为空");
- }
- if(StringUtils.isBlank(createWechatGroupFissionUrlVo.getVersion())){
- return AjaxResult.error("版本不能为空");
- }
- try{
- String url = weGroupFissionService.getWechatGroupFissionUrl(createWechatGroupFissionUrlVo);
- return AjaxResult.success(url);
- }catch (Exception e){
- return AjaxResult.error(e.getMessage());
- }
- }
- /**
- * @version
- * @author: hxl
- * @Date: 2026/1/28 16:36
- * @Description: 企业微信群列表
- */
- //@ApiOperation(value="群打卡活动app-企业微信群列表", notes="群打卡活动app-企业微信群列表")
- @GetMapping(value = "/getWecomGroupList")
- public AjaxResult getWecomGroupList() {
- try{
- List<DistDto> list = weGroupFissionService.getWecomGroupList();
- return AjaxResult.success(list);
- }catch (Exception e){
- return AjaxResult.error(e.getMessage());
- }
- }
- /**
- * @version
- * @author: hxl
- * @Date: 2026/1/28 16:36
- * @Description: 企业微信群列表
- */
- //@ApiOperation(value="群裂变活动表-企业微信员工列表", notes="群裂变活动表-企业微信员工列表")
- @GetMapping(value = "/getWecomEmployeeList")
- public AjaxResult getWecomEmployeeList() {
- try{
- List<DistDto> list = weGroupFissionService.getWecomEmployeeList();
- return AjaxResult.success(list);
- }catch (Exception e){
- return AjaxResult.error(e.getMessage());
- }
- }
- /**
- * @version
- * @author: hxl
- * @Date: 2026/1/31 16:19
- * @Description: 通过类型查询字典列表 type 1.商户 2.权益券 3.抽奖 4.负责人列表
- */
- @GetMapping(value = "/getDictListByType")
- public AjaxResult getDictListByType(@RequestParam(name="type",required=true) String type) {
- try{
- List<DistDto> list = new ArrayList<>();
- //商户字典
- if("1".equals(type)){
- //商户
- list = weGroupFissionService.getLocalMerchantInfoDictDtos();
- }else if("2".equals(type)){
- //权益券
- list = weGroupFissionService.getRightInfoDictDtos();
- }else if("3".equals(type)){
- //抽奖活动
- list = weGroupFissionService.getActivityDictDtos();
- }else if("4".equals(type)){
- //负责人
- list = weGroupFissionService.getUserDictDtos();
- }
- return AjaxResult.success(list);
- }catch (Exception e){
- return AjaxResult.error(e.getMessage());
- }
- }
- /**
- * @version
- * @author: hxl
- * @Date: 2026/2/9 8:34
- * @Description: 获取外部群二维码的链接
- */
- @GetMapping(value = "/getChartQrCodeByChatId")
- public AjaxResult getChartQrCodeByChatId(@RequestParam(name="chatId",required=true) String chatId,@RequestParam(name="activityId",required=false,defaultValue = "") String activityId) throws WxErrorException {
- try {
- String qrCode = weGroupFissionService.getChartQrCodeByChatId(chatId, activityId);
- return AjaxResult.success(qrCode);
- } catch (Exception e) {
- e.printStackTrace();
- return AjaxResult.error("二维码获取失败:"+e.getMessage());
- }
- }
- /**
- * @version
- * @author: hxl
- * @Date: 2026/2/9 8:34
- * @Description: 获取外部群二维码的链接二进制流
- */
- @GetMapping(value = "/getChartQrCodeByChatIdStream")
- public ResponseEntity<byte[]> getChartQrCodeByChatIdStream(@RequestParam(name="chatId",required=true) String chatId, @RequestParam(name="activityId",required=false,defaultValue = "") String activityId){
- try {
- String qrCode = weGroupFissionService.getChartQrCodeByChatId(chatId, activityId);
- byte[] qrcodeBytes = QrcodeUtils.qrcodeUrlToBytes(qrCode);
- return QrcodeUtils.returnQrcodeToFront(qrcodeBytes);
- } catch (Exception e) {
- e.printStackTrace();
- return ResponseEntity.status(HttpStatus.INTERNAL_SERVER_ERROR).body("二维码获取失败:".getBytes());
- }
- }
- /**
- * @version
- * @author: hxl
- * @Date: 2026/2/25 10:34
- * @Description: 获取短链二进制流
- */
- @PostMapping(value = "/getWechatGroupFissionUrlStream")
- public void getWechatGroupFissionUrlStream(@RequestBody CreateWechatGroupFissionUrlVo createWechatGroupFissionUrlVo,HttpServletResponse servletResponse){
- if(StringUtils.isBlank(createWechatGroupFissionUrlVo.getUrl())){
- throw new RuntimeException("生成页面路径不能为空");
- }
- if(StringUtils.isBlank(createWechatGroupFissionUrlVo.getGroupFissionId())){
- throw new RuntimeException("群裂变活动id不能为空");
- }
- if(StringUtils.isBlank(createWechatGroupFissionUrlVo.getVersion())){
- throw new RuntimeException("版本不能为空");
- }
- CreateQRCodeByCodeVO createQRCode = new CreateQRCodeByCodeVO();
- createQRCode.setKeyName("id");
- createQRCode.setKeyValue(createWechatGroupFissionUrlVo.getGroupFissionId());
- createQRCode.setSharePath(createWechatGroupFissionUrlVo.getUrl());
- createQRCode.setEnv_version(createWechatGroupFissionUrlVo.getVersion());
- createQRCode.setWidth(300); // 小程序码宽度
- createQRCode.setAuto_color(false); // 不自动配色
- createQRCode.setIs_hyaline(false); // 不透明
- try{
- wxMiniProgramGetQRCodeByCommonUtil.createQRCode(createQRCode,lifeWechatAppId,lifeWechatSecret,servletResponse);
- }catch (Exception e){
- throw new RuntimeException("生成二维码错误");
- }
- }
- }
|