Commit 0ec7867b 0ec7867b2481e3e2f806dee80da46e6be004d200 by xianghan

1.调整部分项目文件结构,删除不需要的文件

1 parent 33ef06bb
Showing 34 changed files with 177 additions and 517 deletions
1 package com.topdraw.config; 1 package com.topdraw.business;
2 2
3 public class LocalConstants { 3 public class LocalConstants {
4 4
......
1 package com.topdraw.business.module.coupon.service.impl; 1 package com.topdraw.business.module.coupon.service.impl;
2 2
3 import com.topdraw.business.module.coupon.domain.Coupon; 3 import com.topdraw.business.module.coupon.domain.Coupon;
4 import com.topdraw.config.RedisKeyConstants; 4 import com.topdraw.business.RedisKeyConstants;
5 import com.topdraw.exception.GlobeExceptionMsg; 5 import com.topdraw.exception.GlobeExceptionMsg;
6 import com.topdraw.utils.ValidationUtil;
7 import com.topdraw.business.module.coupon.repository.CouponRepository; 6 import com.topdraw.business.module.coupon.repository.CouponRepository;
8 import com.topdraw.business.module.coupon.service.CouponService; 7 import com.topdraw.business.module.coupon.service.CouponService;
9 import com.topdraw.business.module.coupon.service.dto.CouponDTO; 8 import com.topdraw.business.module.coupon.service.dto.CouponDTO;
......
1 package com.topdraw.business.module.member.level.service.impl; 1 package com.topdraw.business.module.member.level.service.impl;
2 2
3 import com.topdraw.business.module.member.level.domain.MemberLevel; 3 import com.topdraw.business.module.member.level.domain.MemberLevel;
4 import com.topdraw.config.RedisKeyConstants; 4 import com.topdraw.business.RedisKeyConstants;
5 import com.topdraw.utils.ValidationUtil; 5 import com.topdraw.utils.ValidationUtil;
6 import com.topdraw.business.module.member.level.repository.MemberLevelRepository; 6 import com.topdraw.business.module.member.level.repository.MemberLevelRepository;
7 import com.topdraw.business.module.member.level.service.MemberLevelService; 7 import com.topdraw.business.module.member.level.service.MemberLevelService;
...@@ -14,8 +14,6 @@ import org.springframework.transaction.annotation.Propagation; ...@@ -14,8 +14,6 @@ import org.springframework.transaction.annotation.Propagation;
14 import org.springframework.transaction.annotation.Transactional; 14 import org.springframework.transaction.annotation.Transactional;
15 import com.topdraw.utils.StringUtils; 15 import com.topdraw.utils.StringUtils;
16 16
17 import java.util.List;
18
19 /** 17 /**
20 * @author XiangHan 18 * @author XiangHan
21 * @date 2021-10-22 19 * @date 2021-10-22
......
...@@ -15,7 +15,7 @@ import com.topdraw.business.module.member.service.dto.MemberDTO; ...@@ -15,7 +15,7 @@ import com.topdraw.business.module.member.service.dto.MemberDTO;
15 import com.topdraw.business.module.member.service.dto.MemberSimpleDTO; 15 import com.topdraw.business.module.member.service.dto.MemberSimpleDTO;
16 import com.topdraw.business.module.member.service.mapper.MemberMapper; 16 import com.topdraw.business.module.member.service.mapper.MemberMapper;
17 import com.topdraw.business.module.member.service.mapper.MemberSimpleMapper; 17 import com.topdraw.business.module.member.service.mapper.MemberSimpleMapper;
18 import com.topdraw.config.RedisKeyConstants; 18 import com.topdraw.business.RedisKeyConstants;
19 import com.topdraw.exception.BadRequestException; 19 import com.topdraw.exception.BadRequestException;
20 import com.topdraw.exception.GlobeExceptionMsg; 20 import com.topdraw.exception.GlobeExceptionMsg;
21 import com.topdraw.utils.RedisUtils; 21 import com.topdraw.utils.RedisUtils;
...@@ -28,7 +28,6 @@ import org.springframework.stereotype.Service; ...@@ -28,7 +28,6 @@ import org.springframework.stereotype.Service;
28 import org.springframework.transaction.annotation.Propagation; 28 import org.springframework.transaction.annotation.Propagation;
29 import org.springframework.transaction.annotation.Transactional; 29 import org.springframework.transaction.annotation.Transactional;
30 30
31 import javax.validation.constraints.NotNull;
32 import java.util.*; 31 import java.util.*;
33 import java.util.stream.Collectors; 32 import java.util.stream.Collectors;
34 33
......
1 package com.topdraw.business.module.rights.service.impl; 1 package com.topdraw.business.module.rights.service.impl;
2 2
3 import com.topdraw.business.module.rights.domain.Rights; 3 import com.topdraw.business.module.rights.domain.Rights;
4 import com.topdraw.config.RedisKeyConstants; 4 import com.topdraw.business.RedisKeyConstants;
5 import com.topdraw.utils.*; 5 import com.topdraw.utils.*;
6 import com.topdraw.business.module.rights.repository.RightsRepository; 6 import com.topdraw.business.module.rights.repository.RightsRepository;
7 import com.topdraw.business.module.rights.service.RightsService; 7 import com.topdraw.business.module.rights.service.RightsService;
......
1 package com.topdraw.business.module.task.progress.service.impl; 1 package com.topdraw.business.module.task.progress.service.impl;
2 2
3 import cn.hutool.core.map.MapUtil;
4 import com.topdraw.business.module.task.progress.domain.TrTaskProgress; 3 import com.topdraw.business.module.task.progress.domain.TrTaskProgress;
5 import com.topdraw.config.RedisKeyConstants; 4 import com.topdraw.business.RedisKeyConstants;
6 import com.topdraw.utils.RedisUtils; 5 import com.topdraw.utils.RedisUtils;
7 import com.topdraw.utils.ValidationUtil;
8 import com.topdraw.business.module.task.progress.repository.TrTaskProgressRepository; 6 import com.topdraw.business.module.task.progress.repository.TrTaskProgressRepository;
9 import com.topdraw.business.module.task.progress.service.TrTaskProgressService; 7 import com.topdraw.business.module.task.progress.service.TrTaskProgressService;
10 import com.topdraw.business.module.task.progress.service.dto.TrTaskProgressDTO; 8 import com.topdraw.business.module.task.progress.service.dto.TrTaskProgressDTO;
11 import com.topdraw.business.module.task.progress.service.mapper.TrTaskProgressMapper; 9 import com.topdraw.business.module.task.progress.service.mapper.TrTaskProgressMapper;
12 import lombok.extern.slf4j.Slf4j; 10 import lombok.extern.slf4j.Slf4j;
13 import org.springframework.beans.factory.annotation.Autowired; 11 import org.springframework.beans.factory.annotation.Autowired;
14 import org.springframework.cache.annotation.CachePut;
15 import org.springframework.cache.annotation.Cacheable;
16 import org.springframework.stereotype.Service; 12 import org.springframework.stereotype.Service;
17 import org.springframework.transaction.annotation.Propagation; 13 import org.springframework.transaction.annotation.Propagation;
18 import org.springframework.transaction.annotation.Transactional; 14 import org.springframework.transaction.annotation.Transactional;
...@@ -21,10 +17,7 @@ import org.springframework.util.Assert; ...@@ -21,10 +17,7 @@ import org.springframework.util.Assert;
21 import org.springframework.util.CollectionUtils; 17 import org.springframework.util.CollectionUtils;
22 18
23 import java.time.LocalDate; 19 import java.time.LocalDate;
24 import java.time.LocalDateTime;
25 import java.util.*; 20 import java.util.*;
26 import java.util.stream.Collectors;
27 import java.util.stream.Stream;
28 21
29 /** 22 /**
30 * @author XiangHan 23 * @author XiangHan
......
1 package com.topdraw.business.module.task.service.impl; 1 package com.topdraw.business.module.task.service.impl;
2 2
3 import com.alibaba.fastjson.JSON;
4 import com.alibaba.fastjson.JSONArray; 3 import com.alibaba.fastjson.JSONArray;
5 import com.topdraw.business.module.task.domain.Task; 4 import com.topdraw.business.module.task.domain.Task;
6 import com.topdraw.business.module.task.repository.TaskRepository; 5 import com.topdraw.business.module.task.repository.TaskRepository;
7 import com.topdraw.business.module.task.service.TaskService; 6 import com.topdraw.business.module.task.service.TaskService;
8 import com.topdraw.business.module.task.service.dto.TaskDTO; 7 import com.topdraw.business.module.task.service.dto.TaskDTO;
9 import com.topdraw.business.module.task.service.mapper.TaskMapper; 8 import com.topdraw.business.module.task.service.mapper.TaskMapper;
10 import com.topdraw.config.RedisKeyConstants; 9 import com.topdraw.business.RedisKeyConstants;
11 import com.topdraw.utils.RedisUtils; 10 import com.topdraw.utils.RedisUtils;
12 import lombok.extern.slf4j.Slf4j; 11 import lombok.extern.slf4j.Slf4j;
13 import org.springframework.beans.factory.annotation.Autowired; 12 import org.springframework.beans.factory.annotation.Autowired;
14 import org.springframework.cache.annotation.CacheConfig;
15 import org.springframework.cache.annotation.Cacheable;
16 import org.springframework.stereotype.Service; 13 import org.springframework.stereotype.Service;
17 import org.springframework.transaction.annotation.Propagation; 14 import org.springframework.transaction.annotation.Propagation;
18 import org.springframework.transaction.annotation.Transactional; 15 import org.springframework.transaction.annotation.Transactional;
......
...@@ -10,7 +10,7 @@ import com.topdraw.business.module.user.iptv.domain.UserTvSimple; ...@@ -10,7 +10,7 @@ import com.topdraw.business.module.user.iptv.domain.UserTvSimple;
10 import com.topdraw.business.module.user.iptv.repository.UserTvSimpleRepository; 10 import com.topdraw.business.module.user.iptv.repository.UserTvSimpleRepository;
11 import com.topdraw.business.module.user.iptv.service.dto.UserTvSimpleDTO; 11 import com.topdraw.business.module.user.iptv.service.dto.UserTvSimpleDTO;
12 import com.topdraw.business.module.user.iptv.service.mapper.UserTvSimpleMapper; 12 import com.topdraw.business.module.user.iptv.service.mapper.UserTvSimpleMapper;
13 import com.topdraw.config.RedisKeyConstants; 13 import com.topdraw.business.RedisKeyConstants;
14 import com.topdraw.exception.EntityNotFoundException; 14 import com.topdraw.exception.EntityNotFoundException;
15 import com.topdraw.exception.GlobeExceptionMsg; 15 import com.topdraw.exception.GlobeExceptionMsg;
16 import com.topdraw.utils.RedisUtils; 16 import com.topdraw.utils.RedisUtils;
...@@ -22,9 +22,7 @@ import com.topdraw.business.module.user.iptv.service.mapper.UserTvMapper; ...@@ -22,9 +22,7 @@ import com.topdraw.business.module.user.iptv.service.mapper.UserTvMapper;
22 import lombok.extern.slf4j.Slf4j; 22 import lombok.extern.slf4j.Slf4j;
23 import org.apache.commons.lang3.StringUtils; 23 import org.apache.commons.lang3.StringUtils;
24 import org.springframework.aop.framework.AopContext; 24 import org.springframework.aop.framework.AopContext;
25 import org.springframework.beans.BeanUtils;
26 import org.springframework.beans.factory.annotation.Autowired; 25 import org.springframework.beans.factory.annotation.Autowired;
27 import org.springframework.cache.annotation.Cacheable;
28 import org.springframework.stereotype.Service; 26 import org.springframework.stereotype.Service;
29 import org.springframework.transaction.annotation.Propagation; 27 import org.springframework.transaction.annotation.Propagation;
30 import org.springframework.transaction.annotation.Transactional; 28 import org.springframework.transaction.annotation.Transactional;
...@@ -32,7 +30,6 @@ import org.springframework.dao.EmptyResultDataAccessException; ...@@ -32,7 +30,6 @@ import org.springframework.dao.EmptyResultDataAccessException;
32 import org.springframework.util.Assert; 30 import org.springframework.util.Assert;
33 31
34 import java.time.LocalDateTime; 32 import java.time.LocalDateTime;
35 import java.util.HashMap;
36 import java.util.Map; 33 import java.util.Map;
37 import java.util.Objects; 34 import java.util.Objects;
38 import java.util.Optional; 35 import java.util.Optional;
......
...@@ -12,7 +12,7 @@ import com.topdraw.business.process.domian.TempPoints; ...@@ -12,7 +12,7 @@ import com.topdraw.business.process.domian.TempPoints;
12 import com.topdraw.business.process.service.dto.CustomPointsResult; 12 import com.topdraw.business.process.service.dto.CustomPointsResult;
13 import com.topdraw.business.process.service.PointsOperationService; 13 import com.topdraw.business.process.service.PointsOperationService;
14 import com.topdraw.common.ResultInfo; 14 import com.topdraw.common.ResultInfo;
15 import com.topdraw.config.LocalConstants; 15 import com.topdraw.business.LocalConstants;
16 import com.topdraw.exception.BadRequestException; 16 import com.topdraw.exception.BadRequestException;
17 import com.topdraw.exception.GlobeExceptionMsg; 17 import com.topdraw.exception.GlobeExceptionMsg;
18 import io.swagger.annotations.Api; 18 import io.swagger.annotations.Api;
......
...@@ -17,6 +17,7 @@ import com.topdraw.business.module.user.app.service.dto.UserAppSimpleDTO; ...@@ -17,6 +17,7 @@ import com.topdraw.business.module.user.app.service.dto.UserAppSimpleDTO;
17 import com.topdraw.business.module.user.iptv.domain.UserTv; 17 import com.topdraw.business.module.user.iptv.domain.UserTv;
18 import com.topdraw.business.module.user.iptv.growreport.domain.GrowthReport; 18 import com.topdraw.business.module.user.iptv.growreport.domain.GrowthReport;
19 import com.topdraw.business.module.user.iptv.growreport.service.dto.GrowthReportRequest; 19 import com.topdraw.business.module.user.iptv.growreport.service.dto.GrowthReportRequest;
20 import com.topdraw.business.module.user.iptv.service.UserTvService;
20 import com.topdraw.business.module.user.iptv.service.dto.UserTvDTO; 21 import com.topdraw.business.module.user.iptv.service.dto.UserTvDTO;
21 import com.topdraw.business.module.user.weixin.domain.UserWeixin; 22 import com.topdraw.business.module.user.weixin.domain.UserWeixin;
22 import com.topdraw.business.module.user.weixin.service.dto.UserWeixinDTO; 23 import com.topdraw.business.module.user.weixin.service.dto.UserWeixinDTO;
...@@ -25,7 +26,8 @@ import com.topdraw.business.process.domian.weixin.*; ...@@ -25,7 +26,8 @@ import com.topdraw.business.process.domian.weixin.*;
25 import com.topdraw.business.process.service.UserOperationService; 26 import com.topdraw.business.process.service.UserOperationService;
26 import com.topdraw.business.process.service.member.MemberOperationService; 27 import com.topdraw.business.process.service.member.MemberOperationService;
27 import com.topdraw.common.ResultInfo; 28 import com.topdraw.common.ResultInfo;
28 import com.topdraw.config.RedisKeyUtil; 29 import com.topdraw.util.RedisKeyUtil;
30 import com.topdraw.config.WechatConfig;
29 import com.topdraw.exception.BadRequestException; 31 import com.topdraw.exception.BadRequestException;
30 import com.topdraw.exception.EntityNotFoundException; 32 import com.topdraw.exception.EntityNotFoundException;
31 import com.topdraw.exception.GlobeExceptionMsg; 33 import com.topdraw.exception.GlobeExceptionMsg;
...@@ -33,8 +35,7 @@ import com.topdraw.resttemplate.RestTemplateClient; ...@@ -33,8 +35,7 @@ import com.topdraw.resttemplate.RestTemplateClient;
33 import com.topdraw.util.Base64Util; 35 import com.topdraw.util.Base64Util;
34 import com.topdraw.util.JSONUtil; 36 import com.topdraw.util.JSONUtil;
35 import com.topdraw.utils.RedisUtils; 37 import com.topdraw.utils.RedisUtils;
36 import com.topdraw.weixin.util.WeChatConstants; 38 import com.topdraw.weixin.service.WeChatConstants;
37 import com.topdraw.weixin.util.WeixinUtil;
38 import io.swagger.annotations.Api; 39 import io.swagger.annotations.Api;
39 import io.swagger.annotations.ApiOperation; 40 import io.swagger.annotations.ApiOperation;
40 import lombok.extern.slf4j.Slf4j; 41 import lombok.extern.slf4j.Slf4j;
...@@ -46,6 +47,7 @@ import org.springframework.util.CollectionUtils; ...@@ -46,6 +47,7 @@ import org.springframework.util.CollectionUtils;
46 import org.springframework.validation.annotation.Validated; 47 import org.springframework.validation.annotation.Validated;
47 import org.springframework.web.bind.annotation.*; 48 import org.springframework.web.bind.annotation.*;
48 49
50 import javax.naming.ConfigurationException;
49 import java.io.IOException; 51 import java.io.IOException;
50 import java.net.URLDecoder; 52 import java.net.URLDecoder;
51 import java.sql.Timestamp; 53 import java.sql.Timestamp;
...@@ -64,9 +66,13 @@ public class UserOperationController { ...@@ -64,9 +66,13 @@ public class UserOperationController {
64 private UserOperationService userOperationService; 66 private UserOperationService userOperationService;
65 @Autowired 67 @Autowired
66 private MemberOperationService memberOperationService; 68 private MemberOperationService memberOperationService;
69 @Autowired
70 private UserTvService userTvService;
67 71
68 @Autowired 72 @Autowired
69 private RedisUtils redisUtils; 73 private RedisUtils redisUtils;
74 @Autowired
75 private WechatConfig weixinInfoConfig;
70 76
71 private static final String SUBSCRIBE = "subscribe"; 77 private static final String SUBSCRIBE = "subscribe";
72 private static final String UNSUBSCRIBE = "unsubscribe"; 78 private static final String UNSUBSCRIBE = "unsubscribe";
...@@ -265,12 +271,8 @@ public class UserOperationController { ...@@ -265,12 +271,8 @@ public class UserOperationController {
265 log.error("小屏解绑失败,参数错误,memberId不存在"); 271 log.error("小屏解绑失败,参数错误,memberId不存在");
266 return ResultInfo.failure("参数错误,会员id不存在"); 272 return ResultInfo.failure("参数错误,会员id不存在");
267 } 273 }
268 boolean b = this.userOperationService.minaUnbind(weixinUnBindBean); 274
269 if (b) { 275 return this.userOperationService.minaUnbind(weixinUnBindBean);
270 return ResultInfo.success("解绑成功");
271 } else {
272 return ResultInfo.failure("解绑失败");
273 }
274 } 276 }
275 277
276 278
...@@ -378,7 +380,7 @@ public class UserOperationController { ...@@ -378,7 +380,7 @@ public class UserOperationController {
378 @PostMapping("/subscribe") 380 @PostMapping("/subscribe")
379 @ApiOperation("微信公众号关注") 381 @ApiOperation("微信公众号关注")
380 @AnonymousAccess 382 @AnonymousAccess
381 public ResultInfo subscribe(@Validated @RequestBody SubscribeBeanEvent data) throws IOException { 383 public ResultInfo subscribe(@Validated @RequestBody SubscribeBeanEvent data) throws Exception {
382 log.info("UserOperationController ==> subscribe ==>> param ==> [{}]",data); 384 log.info("UserOperationController ==> subscribe ==>> param ==> [{}]",data);
383 385
384 SubscribeBean subscribeBean = JSONUtil.parseMsg2Object(data.getContent(), SubscribeBean.class); 386 SubscribeBean subscribeBean = JSONUtil.parseMsg2Object(data.getContent(), SubscribeBean.class);
...@@ -397,7 +399,7 @@ public class UserOperationController { ...@@ -397,7 +399,7 @@ public class UserOperationController {
397 * @param subscribeBean 399 * @param subscribeBean
398 * @throws IOException 400 * @throws IOException
399 */ 401 */
400 private void parseSubscribe(SubscribeBean subscribeBean) throws IOException { 402 private void parseSubscribe(SubscribeBean subscribeBean) throws Exception {
401 403
402 // appId 404 // appId
403 String appId = subscribeBean.getAppid(); 405 String appId = subscribeBean.getAppid();
...@@ -410,7 +412,7 @@ public class UserOperationController { ...@@ -410,7 +412,7 @@ public class UserOperationController {
410 Assert.notNull(openId, GlobeExceptionMsg.UNION_ID_IS_NULL); 412 Assert.notNull(openId, GlobeExceptionMsg.UNION_ID_IS_NULL);
411 413
412 // 匹配配置文件中的微信列表信息 414 // 匹配配置文件中的微信列表信息
413 Map<String, String> wxInfoMap = WeixinUtil.getWeixinInfoByAppid(appId); 415 Map<String, String> wxInfoMap = this.getWeixinInfoByAppid(appId);
414 416
415 // 程序类型 417 // 程序类型
416 String appType = wxInfoMap.get("appType"); 418 String appType = wxInfoMap.get("appType");
...@@ -471,6 +473,24 @@ public class UserOperationController { ...@@ -471,6 +473,24 @@ public class UserOperationController {
471 473
472 } 474 }
473 475
476 /**
477 * 获取配置的微信应用列表
478 * @param appid 应用Id
479 * @return
480 * @throws ConfigurationException
481 */
482 private Map<String, String> getWeixinInfoByAppid(String appid) throws ConfigurationException {
483 if (com.topdraw.utils.StringUtils.isBlank(appid)) {
484 throw new RuntimeException("wxAppid can not be null");
485 }
486 List<Map<String, String>> list = weixinInfoConfig.getWechatAppList();
487 Optional<Map<String, String>> weixinInfoOptional = list.stream().filter(o -> o.get("appid").equals(appid)).findFirst();
488 if (!weixinInfoOptional.isPresent()) {
489 throw new RuntimeException("wxAppid error, appid is : " + appid);
490 }
491 return weixinInfoOptional.get();
492 }
493
474 @PostMapping("/unsubscribe") 494 @PostMapping("/unsubscribe")
475 @ApiOperation("微信公众号取关") 495 @ApiOperation("微信公众号取关")
476 @AnonymousAccess 496 @AnonymousAccess
...@@ -516,19 +536,16 @@ public class UserOperationController { ...@@ -516,19 +536,16 @@ public class UserOperationController {
516 @ApiOperation("小屏解绑") 536 @ApiOperation("小屏解绑")
517 @AnonymousAccess 537 @AnonymousAccess
518 public ResultInfo minaUnbind(@Validated(value = {UnbindGroup.class}) @RequestBody WeixinUnBindBean weixinUnBindBean) { 538 public ResultInfo minaUnbind(@Validated(value = {UnbindGroup.class}) @RequestBody WeixinUnBindBean weixinUnBindBean) {
519 log.info("UserOperationController ==> minaUnbind ==>> param ==> [{}]", weixinUnBindBean); 539 log.info("小屏解绑,参数 ==> [minaUnbind#{}]", weixinUnBindBean);
520 540
521 Long memberId = weixinUnBindBean.getMemberId(); 541 Long memberId = weixinUnBindBean.getMemberId();
522 if (Objects.isNull(memberId)) { 542 if (Objects.isNull(memberId)) {
523 log.error("小屏解绑失败,参数错误,memberId不存在"); 543 log.error("小屏解绑失败,参数错误,memberId不存在");
524 return ResultInfo.failure("参数错误,会员id不存在"); 544 return ResultInfo.failure("参数错误,无会员id");
525 }
526 boolean b = this.userOperationService.minaUnbind(weixinUnBindBean);
527 if (b) {
528 return ResultInfo.success("解绑成功");
529 } else {
530 return ResultInfo.failure("解绑失败");
531 } 545 }
546
547 return this.userOperationService.minaUnbind(weixinUnBindBean);
548
532 } 549 }
533 550
534 /** 551 /**
......
...@@ -14,6 +14,7 @@ import com.topdraw.business.process.domian.weixin.BindBean; ...@@ -14,6 +14,7 @@ import com.topdraw.business.process.domian.weixin.BindBean;
14 import com.topdraw.business.process.domian.weixin.SubscribeBean; 14 import com.topdraw.business.process.domian.weixin.SubscribeBean;
15 import com.topdraw.business.process.domian.weixin.TvUnBindBean; 15 import com.topdraw.business.process.domian.weixin.TvUnBindBean;
16 import com.topdraw.business.process.domian.weixin.WeixinUnBindBean; 16 import com.topdraw.business.process.domian.weixin.WeixinUnBindBean;
17 import com.topdraw.common.ResultInfo;
17 18
18 19
19 public interface UserOperationService { 20 public interface UserOperationService {
...@@ -150,7 +151,7 @@ public interface UserOperationService { ...@@ -150,7 +151,7 @@ public interface UserOperationService {
150 * 小屏解绑 151 * 小屏解绑
151 * @param weixinUnBindBean 152 * @param weixinUnBindBean
152 */ 153 */
153 boolean minaUnbind(WeixinUnBindBean weixinUnBindBean); 154 ResultInfo minaUnbind(WeixinUnBindBean weixinUnBindBean);
154 155
155 /** 156 /**
156 * 157 *
......
...@@ -4,7 +4,6 @@ import com.topdraw.aspect.AsyncMqSend; ...@@ -4,7 +4,6 @@ import com.topdraw.aspect.AsyncMqSend;
4 import com.topdraw.business.module.coupon.history.domain.CouponHistory; 4 import com.topdraw.business.module.coupon.history.domain.CouponHistory;
5 import com.topdraw.business.module.coupon.history.service.CouponHistoryService; 5 import com.topdraw.business.module.coupon.history.service.CouponHistoryService;
6 import com.topdraw.business.module.coupon.service.CouponService; 6 import com.topdraw.business.module.coupon.service.CouponService;
7 import com.topdraw.business.module.exp.detail.domain.ExpDetail;
8 import com.topdraw.business.module.member.domain.Member; 7 import com.topdraw.business.module.member.domain.Member;
9 import com.topdraw.business.module.member.service.MemberService; 8 import com.topdraw.business.module.member.service.MemberService;
10 import com.topdraw.business.module.member.service.dto.MemberDTO; 9 import com.topdraw.business.module.member.service.dto.MemberDTO;
...@@ -12,7 +11,7 @@ import com.topdraw.business.process.service.CouponOperationService; ...@@ -12,7 +11,7 @@ import com.topdraw.business.process.service.CouponOperationService;
12 import com.topdraw.business.process.service.member.MemberOperationService; 11 import com.topdraw.business.process.service.member.MemberOperationService;
13 import com.topdraw.business.process.domian.TempCoupon; 12 import com.topdraw.business.process.domian.TempCoupon;
14 import com.topdraw.business.process.service.RightsOperationService; 13 import com.topdraw.business.process.service.RightsOperationService;
15 import com.topdraw.config.RedisKeyConstants; 14 import com.topdraw.business.RedisKeyConstants;
16 import com.topdraw.util.TimestampUtil; 15 import com.topdraw.util.TimestampUtil;
17 import com.topdraw.utils.RedisUtils; 16 import com.topdraw.utils.RedisUtils;
18 import lombok.extern.slf4j.Slf4j; 17 import lombok.extern.slf4j.Slf4j;
...@@ -22,7 +21,6 @@ import org.springframework.beans.factory.annotation.Autowired; ...@@ -22,7 +21,6 @@ import org.springframework.beans.factory.annotation.Autowired;
22 import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor; 21 import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
23 import org.springframework.stereotype.Service; 22 import org.springframework.stereotype.Service;
24 23
25 import java.time.LocalDate;
26 import java.time.LocalDateTime; 24 import java.time.LocalDateTime;
27 import java.util.List; 25 import java.util.List;
28 import java.util.Objects; 26 import java.util.Objects;
......
...@@ -11,7 +11,7 @@ import com.topdraw.business.module.member.service.dto.MemberSimpleDTO; ...@@ -11,7 +11,7 @@ import com.topdraw.business.module.member.service.dto.MemberSimpleDTO;
11 import com.topdraw.business.process.service.ExpOperationService; 11 import com.topdraw.business.process.service.ExpOperationService;
12 import com.topdraw.business.process.service.member.MemberOperationService; 12 import com.topdraw.business.process.service.member.MemberOperationService;
13 import com.topdraw.business.process.domian.TempExp; 13 import com.topdraw.business.process.domian.TempExp;
14 import com.topdraw.config.RedisKeyConstants; 14 import com.topdraw.business.RedisKeyConstants;
15 import com.topdraw.util.TimestampUtil; 15 import com.topdraw.util.TimestampUtil;
16 import com.topdraw.utils.RedisUtils; 16 import com.topdraw.utils.RedisUtils;
17 import com.topdraw.utils.StringUtils; 17 import com.topdraw.utils.StringUtils;
......
...@@ -14,7 +14,7 @@ import com.topdraw.business.process.service.dto.CustomPointsResult; ...@@ -14,7 +14,7 @@ import com.topdraw.business.process.service.dto.CustomPointsResult;
14 import com.topdraw.business.process.service.member.MemberOperationService; 14 import com.topdraw.business.process.service.member.MemberOperationService;
15 import com.topdraw.business.process.service.PointsOperationService; 15 import com.topdraw.business.process.service.PointsOperationService;
16 import com.topdraw.business.process.domian.TempPoints; 16 import com.topdraw.business.process.domian.TempPoints;
17 import com.topdraw.config.RedisKeyConstants; 17 import com.topdraw.business.RedisKeyConstants;
18 import com.topdraw.util.DateUtil; 18 import com.topdraw.util.DateUtil;
19 import com.topdraw.util.IdWorker; 19 import com.topdraw.util.IdWorker;
20 import com.topdraw.util.TimestampUtil; 20 import com.topdraw.util.TimestampUtil;
......
1 package com.topdraw.business.process.service.impl; 1 package com.topdraw.business.process.service.impl;
2 2
3 import cn.hutool.core.map.MapUtil;
4 import com.alibaba.fastjson.JSON; 3 import com.alibaba.fastjson.JSON;
5 import com.alibaba.fastjson.JSONObject; 4 import com.alibaba.fastjson.JSONObject;
6 import com.topdraw.aspect.AsyncMqSend; 5 import com.topdraw.aspect.AsyncMqSend;
...@@ -33,10 +32,10 @@ import com.topdraw.business.module.task.template.service.TaskTemplateService; ...@@ -33,10 +32,10 @@ import com.topdraw.business.module.task.template.service.TaskTemplateService;
33 import com.topdraw.business.process.domian.*; 32 import com.topdraw.business.process.domian.*;
34 import com.topdraw.business.process.service.UserOperationService; 33 import com.topdraw.business.process.service.UserOperationService;
35 import com.topdraw.common.ResultInfo; 34 import com.topdraw.common.ResultInfo;
36 import com.topdraw.config.LocalConstants; 35 import com.topdraw.business.LocalConstants;
37 import com.topdraw.business.module.rights.constant.RightTypeConstants; 36 import com.topdraw.business.module.rights.constant.RightTypeConstants;
38 import com.topdraw.business.module.task.template.constant.TaskEventType; 37 import com.topdraw.business.module.task.template.constant.TaskEventType;
39 import com.topdraw.config.RedisKeyConstants; 38 import com.topdraw.business.RedisKeyConstants;
40 import com.topdraw.mq.module.mq.DataSyncMsg; 39 import com.topdraw.mq.module.mq.DataSyncMsg;
41 import com.topdraw.util.*; 40 import com.topdraw.util.*;
42 import com.topdraw.utils.RedisUtils; 41 import com.topdraw.utils.RedisUtils;
......
...@@ -46,9 +46,10 @@ import com.topdraw.business.process.service.UserOperationService; ...@@ -46,9 +46,10 @@ import com.topdraw.business.process.service.UserOperationService;
46 import com.topdraw.business.process.service.dto.MemberAndUserTvDTO; 46 import com.topdraw.business.process.service.dto.MemberAndUserTvDTO;
47 import com.topdraw.business.process.service.dto.MemberAndWeixinUserDTO; 47 import com.topdraw.business.process.service.dto.MemberAndWeixinUserDTO;
48 import com.topdraw.business.process.service.mapper.CollectionMq2DetailMapper; 48 import com.topdraw.business.process.service.mapper.CollectionMq2DetailMapper;
49 import com.topdraw.config.LocalConstants; 49 import com.topdraw.business.LocalConstants;
50 import com.topdraw.config.RedisKeyConstants; 50 import com.topdraw.business.RedisKeyConstants;
51 import com.topdraw.config.RedisKeyUtil; 51 import com.topdraw.common.ResultInfo;
52 import com.topdraw.util.RedisKeyUtil;
52 import com.topdraw.exception.BadRequestException; 53 import com.topdraw.exception.BadRequestException;
53 import com.topdraw.exception.EntityNotFoundException; 54 import com.topdraw.exception.EntityNotFoundException;
54 import com.topdraw.exception.GlobeExceptionMsg; 55 import com.topdraw.exception.GlobeExceptionMsg;
...@@ -1508,24 +1509,25 @@ public class UserOperationServiceImpl implements UserOperationService { ...@@ -1508,24 +1509,25 @@ public class UserOperationServiceImpl implements UserOperationService {
1508 } 1509 }
1509 1510
1510 @Override 1511 @Override
1511 public boolean minaUnbind(WeixinUnBindBean weixinUnBindBean) { 1512 public ResultInfo minaUnbind(WeixinUnBindBean weixinUnBindBean) {
1512 1513
1513 Long memberId = weixinUnBindBean.getMemberId(); 1514 Long memberId = weixinUnBindBean.getMemberId();
1515
1514 MemberDTO memberDTO = this.memberService.findById(memberId); 1516 MemberDTO memberDTO = this.memberService.findById(memberId);
1515 if (Objects.isNull(memberDTO.getId())) { 1517 if (Objects.isNull(memberDTO.getId())) {
1516 log.error("小屏解绑失败,会员信息不存在 memberId ==>> {}", memberId); 1518 log.error("小屏解绑失败,会员信息不存在, minaUnbind# ==>> {}", memberId);
1517 return false; 1519 return ResultInfo.failure("小屏解绑失败,当前会员信息不存在");
1518 } 1520 }
1519 1521
1520 if (Objects.isNull(memberDTO.getUserIptvId())) { 1522 if (Objects.isNull(memberDTO.getUserIptvId())) {
1521 log.error("小屏解绑失败,未查询到大屏的大屏信息, memberId ==>> {}", memberId); 1523 log.error("小屏解绑失败,无绑定的大屏, memberId ==>> {}", memberId);
1522 return false; 1524 return ResultInfo.failure("小屏解绑失败,无绑定的大屏");
1523 } 1525 }
1524 1526
1525 UserTvDTO userTvDTO = this.userTvService.findById(memberDTO.getUserIptvId()); 1527 UserTvDTO userTvDTO = this.userTvService.findById(memberDTO.getUserIptvId());
1526 if (Objects.isNull(userTvDTO.getId())) { 1528 if (Objects.isNull(userTvDTO.getPlatformAccount())) {
1527 log.info("小屏解绑失败,绑定的大屏账号不存在 userIptvId ==>> {}", memberDTO.getUserIptvId()); 1529 log.info("小屏解绑失败,绑定的大屏账号不存在 minaUnbind# ==>> userIptvId ==>> {}", memberDTO.getUserIptvId());
1528 return false; 1530 return ResultInfo.failure("小屏解绑失败,大屏信息不存在请联系客服");
1529 } 1531 }
1530 1532
1531 // 解绑(置空大屏信息) 1533 // 解绑(置空大屏信息)
...@@ -1585,7 +1587,7 @@ public class UserOperationServiceImpl implements UserOperationService { ...@@ -1585,7 +1587,7 @@ public class UserOperationServiceImpl implements UserOperationService {
1585 this.updateUserTvSimplePriorityMemberCodeRedis(userTvDTO.getPlatformAccount(), ""); 1587 this.updateUserTvSimplePriorityMemberCodeRedis(userTvDTO.getPlatformAccount(), "");
1586 } 1588 }
1587 1589
1588 return true; 1590 return ResultInfo.success("解绑成功");
1589 } 1591 }
1590 1592
1591 1593
......
...@@ -16,18 +16,15 @@ import com.topdraw.business.module.user.weixin.service.UserWeixinService; ...@@ -16,18 +16,15 @@ import com.topdraw.business.module.user.weixin.service.UserWeixinService;
16 import com.topdraw.business.module.user.weixin.service.dto.UserWeixinDTO; 16 import com.topdraw.business.module.user.weixin.service.dto.UserWeixinDTO;
17 import com.topdraw.business.process.domian.member.MemberOperationBean; 17 import com.topdraw.business.process.domian.member.MemberOperationBean;
18 import com.topdraw.business.process.service.member.MemberOperationService; 18 import com.topdraw.business.process.service.member.MemberOperationService;
19 import com.topdraw.config.RedisKeyConstants; 19 import com.topdraw.business.RedisKeyConstants;
20 import com.topdraw.util.TimestampUtil; 20 import com.topdraw.util.TimestampUtil;
21 import lombok.extern.slf4j.Slf4j; 21 import lombok.extern.slf4j.Slf4j;
22 import org.springframework.aop.framework.AopContext; 22 import org.springframework.aop.framework.AopContext;
23 import org.springframework.beans.BeanUtils; 23 import org.springframework.beans.BeanUtils;
24 import org.springframework.beans.factory.annotation.Autowired; 24 import org.springframework.beans.factory.annotation.Autowired;
25 import org.springframework.cache.annotation.CacheConfig; 25 import org.springframework.cache.annotation.CacheConfig;
26 import org.springframework.cache.annotation.CachePut;
27 import org.springframework.stereotype.Service; 26 import org.springframework.stereotype.Service;
28 import org.springframework.util.Assert;
29 27
30 import javax.validation.constraints.NotNull;
31 import java.sql.Timestamp; 28 import java.sql.Timestamp;
32 import java.util.List; 29 import java.util.List;
33 import java.util.Objects; 30 import java.util.Objects;
......
1 package com.topdraw.mq.config; 1 package com.topdraw.config;
2 2
3 import org.apache.commons.lang3.StringUtils; 3 import org.apache.commons.lang3.StringUtils;
4 import org.springframework.amqp.core.*; 4 import org.springframework.amqp.core.*;
5 import org.springframework.amqp.rabbit.core.RabbitTemplate;
6 import org.springframework.beans.factory.annotation.Autowired;
5 import org.springframework.beans.factory.annotation.Value; 7 import org.springframework.beans.factory.annotation.Value;
6 import org.springframework.context.annotation.Bean; 8 import org.springframework.context.annotation.Bean;
7 import org.springframework.context.annotation.Configuration; 9 import org.springframework.context.annotation.Configuration;
...@@ -12,35 +14,35 @@ public class RabbitMqConfig { ...@@ -12,35 +14,35 @@ public class RabbitMqConfig {
12 public static final String UCE_EXCHANGE = "uce.exchange"; 14 public static final String UCE_EXCHANGE = "uce.exchange";
13 public static final String UCE_QUEUE = "uce.queue"; 15 public static final String UCE_QUEUE = "uce.queue";
14 16
15 @Value("${service.mq.exchange}") 17 @Autowired
16 private String exchange; 18 private RabbitTemplate rabbitTemplate;
17 19
18 @Value("${service.mq.queue}") 20 public String getExchange() {
19 private String queue;
20 21
21 public String getExchange(){ 22 String exchange = this.rabbitTemplate.getExchange();
22 if (StringUtils.isEmpty(this.exchange)) { 23 if (StringUtils.isNotBlank(exchange)) {
23 this.exchange = UCE_EXCHANGE; 24 return exchange;
24 } 25 }
25 26
26 return this.exchange; 27 return UCE_EXCHANGE;
27 } 28 }
28 29
29 public String getQueue() { 30 public String getQueue() {
30 if (StringUtils.isEmpty(this.queue)) { 31 String queue = this.rabbitTemplate.getRoutingKey();
31 this.queue = UCE_QUEUE; 32 if (StringUtils.isNotBlank(queue)) {
33 return queue;
32 } 34 }
33 35
34 return this.queue; 36 return UCE_QUEUE;
35 } 37 }
36 38
37 @Bean 39 @Bean
38 DirectExchange directExchange(){ 40 DirectExchange directExchange(){
39 return ExchangeBuilder.directExchange(getExchange()).build(); 41 return ExchangeBuilder.directExchange(this.getExchange()).build();
40 } 42 }
41 43
42 @Bean 44 @Bean
43 Queue queue(){ return new Queue(getQueue()); } 45 Queue queue(){ return new Queue(this.getQueue()); }
44 46
45 @Bean 47 @Bean
46 Binding binding(DirectExchange directExchange , Queue queue) { 48 Binding binding(DirectExchange directExchange , Queue queue) {
......
1 package com.topdraw.config;
2
3
4 import org.springframework.scheduling.annotation.EnableScheduling;
5 import org.springframework.stereotype.Component;
6
7 @Component
8
9 public class ScheduledTaskConfig {
10 }
1 package com.topdraw.config;
2
3 import cn.hutool.core.map.MapUtil;
4 import lombok.Data;
5 import org.springframework.boot.context.properties.ConfigurationProperties;
6 import org.springframework.context.annotation.Configuration;
7 import org.springframework.util.CollectionUtils;
8
9 import javax.naming.ConfigurationException;
10 import java.util.ArrayList;
11 import java.util.List;
12 import java.util.Map;
13
14 @Configuration
15 @Data
16 @ConfigurationProperties(prefix = "wechat", ignoreInvalidFields = true)
17 public class WechatConfig {
18
19 private Map<String, String> miniprogram;
20
21 private Map<String, String> subscribe;
22
23 public List<Map<String, String>> getWechatAppList() throws ConfigurationException {
24 Map<String, String> miniprogram = this.miniprogram;
25 Map<String, String> subscribe = this.subscribe;
26
27 List<Map<String, String>> list = new ArrayList<>();
28 if (MapUtil.isNotEmpty(miniprogram)) {
29 list.add(miniprogram);
30 }
31 if (MapUtil.isNotEmpty(subscribe)) {
32 list.add(subscribe);
33 }
34
35 if (CollectionUtils.isEmpty(list)) {
36 throw new ConfigurationException("配置错误,未配置微信应用");
37 }
38
39 return list;
40 }
41 }
1 package com.topdraw.config;
2
3 import lombok.Data;
4 import org.springframework.boot.context.properties.ConfigurationProperties;
5 import org.springframework.context.annotation.Configuration;
6
7 import java.util.List;
8 import java.util.Map;
9
10 @Configuration
11 @Data
12 @ConfigurationProperties(prefix = "weixin")
13 public class WeixinInfoConfig {
14
15 private List<Map<String, String>> list;
16 }
1 package com.topdraw.security; 1 package com.topdraw.util;
2 2
3 import com.alibaba.fastjson.JSONObject; 3 import com.alibaba.fastjson.JSONObject;
4 import com.topdraw.utils.StringUtils; 4 import com.topdraw.utils.StringUtils;
......
1 package com.topdraw.config; 1 package com.topdraw.util;
2 2
3 import cn.hutool.core.util.StrUtil; 3 import cn.hutool.core.util.StrUtil;
4 4
......
1 package com.topdraw.weixin.beans;
2
3 import lombok.Data;
4
5 @Data
6 public class ActionInfo {
7 private Scene scene;
8 }
1 package com.topdraw.weixin.beans;
2
3 import com.alibaba.fastjson.annotation.JSONField;
4 import lombok.Data;
5
6 @Data
7 public class QrCode {
8
9 @JSONField(name = "action_name")
10 private String actionName;
11
12 @JSONField(name = "expire_seconds")
13 private Integer expireSeconds;
14
15 @JSONField(name = "action_info")
16 private ActionInfo actionInfo;
17
18
19
20 }
1 package com.topdraw.weixin.beans;
2
3 import com.alibaba.fastjson.annotation.JSONField;
4 import lombok.Data;
5
6 @Data
7 public class Scene {
8 @JSONField(name = "scene_id")
9 private Long sceneId;
10
11 @JSONField(name = "scene_str")
12 private String sceneStr;
13 }
1 package com.topdraw.weixin.beans;
2
3 import com.alibaba.fastjson.annotation.JSONField;
4 import lombok.Data;
5
6 import java.util.Map;
7
8 @Data
9 public class WeiXinNotice {
10
11 @JSONField(serialize=false)
12 private String appid;
13
14 @JSONField(serialize=false)
15 private Long userId;
16
17 //目标用户
18 @JSONField(name = "touser")
19 private String toUser;
20
21 // 模板code
22 @JSONField(serialize=false)
23 private String code;
24
25 // 模板id
26 @JSONField(name = "template_id")
27 private String templateId;
28
29 // 点击通知跳转页面
30 private String page;
31
32 // 小程序版本
33 @JSONField(name = "miniprogram_state")
34 private String miniprogramState;
35
36 // 填充数据
37 private Map<String, Object> data;
38 }
1 package com.topdraw.weixin.service;
2
3 public class WeChatConstants {
4
5 // 订阅号
6 public static final String WX_SUBSCRIPTION = "subscription";
7
8
9 }
1 package com.topdraw.weixin.util;
2
3 public class WeChatConstants {
4
5 public static String HTTPS_AUTHORIZE_WITH_SNSAPI_USERINFO = "https://open.weixin.qq.com/connect/oauth2/authorize?appid=APPID&redirect_uri=REDIRECT_URI&response_type=code&scope=snsapi_userinfo&state=STATE#wechat_redirect";
6
7 public static final String HTTPS_TOKEN = "https://api.weixin.qq.com/cgi-bin/token";
8
9 public static final String HTTPS_TICKET_GETTICKET = "https://api.weixin.qq.com/cgi-bin/ticket/getticket";
10
11 public static final String HTTPS_SNS_OAUTH2_ACCESS_TOKEN = "https://api.weixin.qq.com/sns/oauth2/access_token";
12
13 public static final String HTTPS_SNS_USERINFO = "https://api.weixin.qq.com/sns/userinfo";
14
15 public static final String CODE2SESSION = "https://api.weixin.qq.com/sns/jscode2session?appid=APPID&secret=SECRET&js_code=JSCODE&grant_type=authorization_code";
16
17 /**
18 * 把媒体文件上传到微信服务器。目前仅支持图片。用于发送客服消息或被动回复用户消息。
19 */
20 public static String UPLOAD_URL = "https://api.weixin.qq.com/cgi-bin/media/upload?access_token={0}&type=image";
21
22 /**
23 * 获取客服消息内的临时素材。即下载临时的多媒体文件。
24 */
25 public static String GET_MEDIA = "https://api.weixin.qq.com/cgi-bin/media/get?access_token={0}&media_id={1}";
26
27 /**
28 * 用于向微信服务端申请二维码的url
29 */
30 public static String URL_QR_CODE = "https://api.weixin.qq.com/wxa/getwxacodeunlimit?access_token={0}";
31
32 /**
33 * 用于聊天时向用户发送消息的url
34 */
35 public static String CUSTOM_SEND_URL = "https://api.weixin.qq.com/cgi-bin/message/custom/send?access_token={0}";
36
37 /**
38 * 发送小程序订阅消息
39 */
40 public static final String SUBSCRIBE_SEND_URL = "https://api.weixin.qq.com/cgi-bin/message/subscribe/send?access_token={0}";
41
42 /**
43 * 生成带参数二维码
44 */
45 public static final String QR_CODE_URL = "https://api.weixin.qq.com/cgi-bin/qrcode/create?access_token={0}";
46
47 /**
48 * 获取用户基本信息
49 */
50 public static final String GET_USER_INFO = "https://api.weixin.qq.com/cgi-bin/user/info?access_token={0}&openid={1}&lang=zh_CN";
51
52
53 // 批量获取关注者列表
54 public static final String GET_USER_LIST = "https://api.weixin.qq.com/cgi-bin/user/get?access_token={0}&next_openid={1}";
55
56 /**
57 * 成功
58 */
59 public static String SUCCESS = "SUCCESS";
60
61 /**
62 * 微信系统错误
63 */
64 public static String SYSTEMERROR = "SYSTEMERROR";
65
66 /**
67 * 失败 (注意:微信有的接口返回的失败用FAIL字符串表示,有的接口用FAILED表示)
68 */
69 public static String FAIL = "FAIL";
70
71 /**
72 * 微信企业付款到个人失败 (注意:微信有的接口返回的失败用FAIL字符串表示,有的接口用FAILED表示)
73 */
74 public static String FAILED = "FAILED";
75
76 public static String ACCESS_TOKEN = "access_token";
77
78 public static String ERR_CODE = "errcode";
79
80 /**
81 * 微信请求时,返回ACCESS_TOKEN错误码
82 */
83 public static final String ACCESS_TOKEN_INVALID_CODE = "40001";
84
85
86 /**
87 * 文本消息
88 */
89 public static String MSG_TYPE_TEXT = "text";
90
91 public static String MSG_TYPE_MINIPROGRAMPAGE = "miniprogrampage";
92
93 public static String MSG_TYPE_LINK = "link";
94
95 public static String MSG_TYPE_IMAGE = "image";
96
97 /**
98 * 事件消息
99 */
100 public static String MSG_TYPE_EVENT = "event";
101
102
103 /**
104 * 二维码类型,临时的整型参数值
105 */
106 public static String QR_SCENE = "QR_SCENE";
107
108 /**
109 * 二维码类型,临时的字符串参数值
110 */
111 public static String QR_STR_SCENE = "QR_STR_SCENE";
112
113 /**
114 * 二维码类型,永久的整型参数值
115 */
116 public static String QR_LIMIT_SCENE = "QR_LIMIT_SCENE";
117
118 /**
119 * 二维码类型,永久的字符串参数值
120 */
121 public static String QR_LIMIT_STR_SCENE = "QR_LIMIT_STR_SCENE";
122
123
124 /******** 事件推送事件类型BEGIN********/
125
126 /**
127 * 取消订阅
128 */
129 public static final String EVENT_UNSUBSCRIBE = "unsubscribe";
130
131
132 /**
133 * 订阅
134 */
135 public static final String EVENT_SUBSCRIBE = "subscribe";
136
137 /**
138 * 扫描带参数二维码事件,用户已关注时的事件推送
139 */
140 public static final String EVENT_SCAN = "SCAN";
141
142 /**
143 * 上报地理位置事件
144 */
145 public static final String EVENT_LOCATION = "LOCATION";
146
147 /**
148 * 自定义菜单事件
149 */
150 public static final String EVENT_CLICK = "CLICK";
151
152 /******** 事件推送事件类型END********/
153
154
155 /**
156 * 微信ACCESS_TOKEN缓存KEY
157 */
158 public static final String TOKEN_KEY = "GLOBAL_WX_ACCESS_TOKEN_";
159
160
161 /**
162 * 微信临时素材缓存KEY
163 */
164 public static final String WEIXIN_MEDIA_KEY = "WEIXIN_MEDIA_KEY_";
165
166 // 微信应用类型 小程序 服务号 订阅号
167 // 小程序
168 public static final String WX_APPLET = "applet";
169 // 服务号
170 public static final String WX_SERVICE = "service";
171 // 订阅号
172 public static final String WX_SUBSCRIPTION = "subscription";
173
174
175 }
1 package com.topdraw.weixin.util;
2
3 import com.topdraw.config.WeixinInfoConfig;
4 import com.topdraw.utils.StringUtils;
5 import lombok.extern.slf4j.Slf4j;
6 import org.springframework.beans.factory.annotation.Autowired;
7 import org.springframework.stereotype.Component;
8
9 import javax.servlet.ServletOutputStream;
10 import javax.servlet.http.HttpServletRequest;
11 import javax.servlet.http.HttpServletResponse;
12 import java.io.IOException;
13 import java.io.UnsupportedEncodingException;
14 import java.security.MessageDigest;
15 import java.security.NoSuchAlgorithmException;
16 import java.util.Arrays;
17 import java.util.List;
18 import java.util.Map;
19 import java.util.Optional;
20
21
22 @Component
23 @Slf4j
24 public class WeixinUtil {
25
26
27 private static WeixinInfoConfig WEIXININFOCONFIG;
28
29 @Autowired
30 public void setWeixinInfoConfig(WeixinInfoConfig weixinInfoConfig) {
31 WEIXININFOCONFIG = weixinInfoConfig;
32 }
33
34 public static Map<String, String> getWeixinInfoByAppid(String appid) {
35 if (StringUtils.isBlank(appid)) {
36 throw new RuntimeException("wxAppid can not be null");
37 }
38 List<Map<String, String>> list = WEIXININFOCONFIG.getList();
39 Optional<Map<String, String>> weixinInfoOptional = list.stream().filter(o -> o.get("appid").equals(appid)).findFirst();
40 if (!weixinInfoOptional.isPresent()) {
41 throw new RuntimeException("wxAppid error, appid is : " + appid);
42 }
43 return weixinInfoOptional.get();
44 }
45
46
47 public static Map<String, String> getWeixinInfoByIndex(Integer index) {
48 List<Map<String, String>> list = WEIXININFOCONFIG.getList();
49 if (list.size() < index + 1) {
50 throw new RuntimeException("wxinfo error, index out of range : {}" + index);
51 }
52 return list.get(index);
53 }
54 /**
55 * 使用SHA1算法对字符串数组进行加密
56 *
57 * @param strList
58 * @return
59 */
60 public static String encodeUsingSHA1(String... strList) {
61 //将strList的值进行字典排序
62 Arrays.sort(strList);
63 StringBuilder content = new StringBuilder();
64 for (int i = 0; i < strList.length; i++) {
65 content.append(strList[i]);
66 }
67
68 return doEncodeUsingSHA1(content.toString());
69 }
70
71
72 /**
73 * SHA1实现
74 *
75 * @return sha1加密后的字符串
76 */
77 private static String doEncodeUsingSHA1(String inStr) {
78 byte[] byteArray ;
79
80 try {
81 MessageDigest sha = MessageDigest.getInstance("SHA-1");
82 byteArray = sha.digest(inStr.getBytes("UTF-8"));
83 } catch (NoSuchAlgorithmException e) {
84 throw new RuntimeException("no sha-1 algorithm");
85 } catch (UnsupportedEncodingException e) {
86 throw new RuntimeException("unsupported utf-8 encoding");
87 }
88
89 StringBuilder sb = new StringBuilder();
90 for (int i = 0; i < byteArray.length; i++) {
91 sb.append(Integer.toString((byteArray[i] & 0xff) + 0x100, 16).substring(1));
92 }
93 return sb.toString();
94 }
95
96 /**
97 * 公众号,小程序后台配置服务器,初次检验时使用
98 * @throws IOException
99 */
100 public static void doGet(HttpServletRequest request, HttpServletResponse response, Map<String, String> weixinInfo) throws IOException {
101 log.info("doGet receive WeChat server request parameters:{}", request.getParameterMap());
102 String signature = request.getParameter("signature");
103 String timestamp = request.getParameter("timestamp");
104 String nonce = request.getParameter("nonce");
105 String echoStr = request.getParameter("echostr");
106 String[] arr = new String[]{weixinInfo.get("token"), timestamp, nonce};
107 String encrypt = WeixinUtil.encodeUsingSHA1(arr);
108 if (encrypt.equals(signature)) {
109 ServletOutputStream outputStream = response.getOutputStream();
110 outputStream.write(echoStr.getBytes());
111 outputStream.flush();
112 }
113 }
114
115
116 }
...@@ -2,12 +2,12 @@ ...@@ -2,12 +2,12 @@
2 spring: 2 spring:
3 datasource: 3 datasource:
4 # 测试/演示库url: 4 # 测试/演示库url:
5 url: jdbc:log4jdbc:mysql://122.112.214.149:3306/tj_user_admin?serverTimezone=Asia/Shanghai&characterEncoding=utf8&useSSL=false 5 # url: jdbc:log4jdbc:mysql://122.112.214.149:3306/tj_user_admin?serverTimezone=Asia/Shanghai&characterEncoding=utf8&useSSL=false
6 username: root
7 password: root
8 # url: jdbc:log4jdbc:mysql://139.196.145.150:3306/ucs_admin_chongshu?serverTimezone=Asia/Shanghai&characterEncoding=utf8&useSSL=false
9 # username: root 6 # username: root
10 # password: Tjlh@2021 7 # password: root
8 url: jdbc:log4jdbc:mysql://139.196.145.150:3306/ucs_admin_chongshu?serverTimezone=Asia/Shanghai&characterEncoding=utf8&useSSL=false
9 username: root
10 password: Tjlh@2021
11 11
12 driverClassName: net.sf.log4jdbc.sql.jdbcapi.DriverSpy 12 driverClassName: net.sf.log4jdbc.sql.jdbcapi.DriverSpy
13 #Druid 13 #Druid
...@@ -37,12 +37,15 @@ spring: ...@@ -37,12 +37,15 @@ spring:
37 web-stat-filter: 37 web-stat-filter:
38 url-pattern: /* 38 url-pattern: /*
39 exclusions: "*.js,*.gif,*.jpg,*.bmp,*.png,*.css,*.ico,/druid/*" 39 exclusions: "*.js,*.gif,*.jpg,*.bmp,*.png,*.css,*.ico,/druid/*"
40
40 jackson: 41 jackson:
41 time-zone: GMT+8 42 time-zone: GMT+8
43
42 data: 44 data:
43 redis: 45 redis:
44 repositories: 46 repositories:
45 enabled: false 47 enabled: false
48
46 #配置 Jpa 49 #配置 Jpa
47 jpa: 50 jpa:
48 properties: 51 properties:
...@@ -51,11 +54,13 @@ spring: ...@@ -51,11 +54,13 @@ spring:
51 ddl-auto: none 54 ddl-auto: none
52 open-in-view: true 55 open-in-view: true
53 show-sql: false 56 show-sql: false
57
54 servlet: 58 servlet:
55 multipart: 59 multipart:
56 file-size-threshold: 2KB 60 file-size-threshold: 2KB
57 max-file-size: 100MB 61 max-file-size: 100MB
58 max-request-size: 200MB 62 max-request-size: 200MB
63
59 # redis 64 # redis
60 redis: 65 redis:
61 #数据库索引 66 #数据库索引
...@@ -65,6 +70,7 @@ spring: ...@@ -65,6 +70,7 @@ spring:
65 password: redis123 70 password: redis123
66 #连接超时时间 71 #连接超时时间
67 timeout: 5000 72 timeout: 5000
73
68 rabbitmq: 74 rabbitmq:
69 # host: 139.196.145.150 # rabbitmq的连接地址 75 # host: 139.196.145.150 # rabbitmq的连接地址
70 # port: 5672 # rabbitmq的连接端口号 76 # port: 5672 # rabbitmq的连接端口号
...@@ -78,26 +84,14 @@ spring: ...@@ -78,26 +84,14 @@ spring:
78 username: guest # rabbitmq的用户名 84 username: guest # rabbitmq的用户名
79 password: guest # rabbitmq的密码 85 password: guest # rabbitmq的密码
80 publisher-confirms: true #如果对异步消息需要回调必须设置为true 86 publisher-confirms: true #如果对异步消息需要回调必须设置为true
87 template:
88 exchange: uce.exchange
89 routing-key: uce.queue
81 90
82 #jwt。依赖的common中有需要jwt的部分属性。 91 #是否允许生成代码,生产环境设置为false
83 jwt:
84 header: Authorization
85 secret: mySecret
86 # token 过期时间/毫秒,6小时 1小时 = 3600000 毫秒
87 expiration: 7200000
88 # 在线用户key
89 online: online-token
90 # 验证码
91 codeKey: code-key
92 # token 续期检查时间范围(60分钟,单位毫秒),在token即将过期的一段时间内用户操作了,则给用户的token续期
93 detect: 3600000
94 # 续期时间,2小时,单位毫秒
95 renew: 7200000
96
97 #是否允许生成代码,生产环境设置为false
98 generator: 92 generator:
99 enabled: false 93 enabled: false
100 94
101 #是否开启 swagger-ui 95 #是否开启 swagger-ui
102 swagger: 96 swagger:
103 enabled: false 97 enabled: false
...\ No newline at end of file ...\ No newline at end of file
......
...@@ -6,15 +6,26 @@ spring: ...@@ -6,15 +6,26 @@ spring:
6 profiles: 6 profiles:
7 active: dev 7 active: dev
8 8
9 #mq 9 #jwt。依赖的common中有需要jwt的部分属性。
10 service: 10 jwt:
11 mq: 11 header: Authorization
12 exchange: uce.exchange 12 secret: mySecret
13 queue: uce.queue 13 # token 过期时间/毫秒,6小时 1小时 = 3600000 毫秒
14 expiration: 7200000
15 # 在线用户key
16 online: online-token
17 # 验证码
18 codeKey: code-key
19 # token 续期检查时间范围(60分钟,单位毫秒),在token即将过期的一段时间内用户操作了,则给用户的token续期
20 detect: 3600000
21 # 续期时间,2小时,单位毫秒
22 renew: 7200000
14 23
15 weixin: 24 # 微信
16 list: 25 wechat:
17 - appid: wxfaa765183a332521 26 # 小程序
27 miniprogram:
28 appid: wxfaa765183a332521
18 secret: b5c1c39cb95b45b599a02fd68b5fcf17 29 secret: b5c1c39cb95b45b599a02fd68b5fcf17
19 token: 30 token:
20 encodingAesKey: 31 encodingAesKey:
...@@ -26,8 +37,10 @@ weixin: ...@@ -26,8 +37,10 @@ weixin:
26 # 生成带参数二维码的有效期 37 # 生成带参数二维码的有效期
27 qrCodeExpireSeconds: 86400 38 qrCodeExpireSeconds: 86400
28 env: dev 39 env: dev
40
29 # 订阅号 41 # 订阅号
30 - appid: wx5d88c7fe99f89f32 42 subscribe:
43 appid: wx5d88c7fe99f89f32
31 secret: b213afe99a469d4be576f330dad643b8 44 secret: b213afe99a469d4be576f330dad643b8
32 token: topdraw 45 token: topdraw
33 encodingAesKey: g3mYB6yx2ZiebxwKcI1H2iw3LlYNBHb7PqsVYFHUQzi 46 encodingAesKey: g3mYB6yx2ZiebxwKcI1H2iw3LlYNBHb7PqsVYFHUQzi
...@@ -42,6 +55,7 @@ weixin: ...@@ -42,6 +55,7 @@ weixin:
42 qrCodeExpireSeconds: 300 55 qrCodeExpireSeconds: 300
43 env: dev 56 env: dev
44 57
58
45 #第三方接口 59 #第三方接口
46 api: 60 api:
47 # ucs 61 # ucs
......
...@@ -62,8 +62,7 @@ public class UserOperationControllerTest extends BaseTest { ...@@ -62,8 +62,7 @@ public class UserOperationControllerTest extends BaseTest {
62 try { 62 try {
63 WeixinUnBindBean bindBean = new WeixinUnBindBean(); 63 WeixinUnBindBean bindBean = new WeixinUnBindBean();
64 // 小屏会员 64 // 小屏会员
65 bindBean.setMemberId(4L); 65 bindBean.setMemberId(21821L);
66 bindBean.setAutoModel(true);
67 ResultInfo weixinUserAndMember = this.userOperationController.minaUnbind(bindBean); 66 ResultInfo weixinUserAndMember = this.userOperationController.minaUnbind(bindBean);
68 System.out.println(weixinUserAndMember); 67 System.out.println(weixinUserAndMember);
69 } catch (Exception e) { 68 } catch (Exception e) {
......