Commit dc92cdb4 dc92cdb47ec862073bd2dd522e583070f9038121 by xianghan

1.优化

1 parent e81bd386
Showing 14 changed files with 109 additions and 27 deletions
...@@ -12,6 +12,8 @@ import com.topdraw.common.ResultInfo; ...@@ -12,6 +12,8 @@ import com.topdraw.common.ResultInfo;
12 import io.swagger.annotations.Api; 12 import io.swagger.annotations.Api;
13 import io.swagger.annotations.ApiOperation; 13 import io.swagger.annotations.ApiOperation;
14 import lombok.extern.slf4j.Slf4j; 14 import lombok.extern.slf4j.Slf4j;
15 import org.apache.commons.lang3.StringUtils;
16 import org.springframework.beans.BeanUtils;
15 import org.springframework.beans.factory.annotation.Autowired; 17 import org.springframework.beans.factory.annotation.Autowired;
16 import org.springframework.validation.annotation.Validated; 18 import org.springframework.validation.annotation.Validated;
17 import org.springframework.web.bind.annotation.*; 19 import org.springframework.web.bind.annotation.*;
...@@ -61,6 +63,13 @@ public class MemberController { ...@@ -61,6 +63,13 @@ public class MemberController {
61 public ResultInfo update(@Validated(value = {UpdateGroup.class}) @RequestBody Member resources) { 63 public ResultInfo update(@Validated(value = {UpdateGroup.class}) @RequestBody Member resources) {
62 log.info("member ==>> update ==>> param ==>> [{}]",resources); 64 log.info("member ==>> update ==>> param ==>> [{}]",resources);
63 65
66 String code = resources.getCode();
67 if (StringUtils.isNotBlank(code)) {
68 MemberDTO memberDTO = this.memberOperationService.findByCode(code);
69 resources.setId(memberDTO.getId());
70 // BeanUtils.copyProperties(resources, memberDTO);
71 }
72
64 MemberDTO memberDTO = this.memberOperationService.update(resources); 73 MemberDTO memberDTO = this.memberOperationService.update(resources);
65 return ResultInfo.success(memberDTO); 74 return ResultInfo.success(memberDTO);
66 } 75 }
......
1 package com.topdraw.business.module.member.viphistory.rest; 1 package com.topdraw.business.module.member.viphistory.rest;
2 2
3 import com.topdraw.business.module.member.viphistory.domain.MemberVipHistory; 3 import com.topdraw.business.module.member.viphistory.domain.MemberVipHistory;
4 import com.topdraw.business.module.member.viphistory.service.MemberVipHistoryService;
5 import com.topdraw.business.process.service.member.MemberOperationService; 4 import com.topdraw.business.process.service.member.MemberOperationService;
6 import com.topdraw.common.ResultInfo; 5 import com.topdraw.common.ResultInfo;
7 import io.swagger.annotations.Api; 6 import io.swagger.annotations.Api;
......
...@@ -55,10 +55,12 @@ public class MemberVipHistoryServiceImpl implements MemberVipHistoryService { ...@@ -55,10 +55,12 @@ public class MemberVipHistoryServiceImpl implements MemberVipHistoryService {
55 @AsyncMqSend 55 @AsyncMqSend
56 public void create(MemberVipHistory resources) { 56 public void create(MemberVipHistory resources) {
57 log.info("MemberVipHistoryServiceImpl ==>> MemberVipHistoryServiceImpl ==>> param ==>> [{}]",resources); 57 log.info("MemberVipHistoryServiceImpl ==>> MemberVipHistoryServiceImpl ==>> param ==>> [{}]",resources);
58 this.checkMember(resources); 58 MemberDTO memberDTO = this.checkMember(resources);
59 59
60 MemberVipHistory memberVipHistory = MemberVipHistoryBuilder.build(resources); 60 MemberVipHistory memberVipHistory = MemberVipHistoryBuilder.build(resources);
61 this.memberVipHistoryRepository.save(memberVipHistory); 61 MemberVipHistory vipHistory = this.memberVipHistoryRepository.save(memberVipHistory);
62 vipHistory.setMemberCode(memberDTO.getCode());
63
62 } 64 }
63 65
64 @Override 66 @Override
......
...@@ -16,4 +16,5 @@ public interface UserCollectionRepository extends JpaRepository<UserCollection, ...@@ -16,4 +16,5 @@ public interface UserCollectionRepository extends JpaRepository<UserCollection,
16 16
17 List<UserCollection> findByUserIdAndType(Long userId, Integer type); 17 List<UserCollection> findByUserIdAndType(Long userId, Integer type);
18 18
19 Optional<UserCollection> findFirstByUserIdAndTypeAndName(Long userId, Integer type, String name);
19 } 20 }
......
...@@ -63,7 +63,7 @@ public interface UserCollectionService { ...@@ -63,7 +63,7 @@ public interface UserCollectionService {
63 * @param name 63 * @param name
64 * @return 64 * @return
65 */ 65 */
66 Optional<UserCollection> findFirstByUserIdAndTypeAndName(Long id, Integer type, String name); 66 UserCollection findFirstByUserIdAndTypeAndName(Long id, Integer type, String name);
67 67
68 /** 68 /**
69 * 69 *
......
...@@ -88,8 +88,10 @@ public class UserCollectionServiceImpl implements UserCollectionService { ...@@ -88,8 +88,10 @@ public class UserCollectionServiceImpl implements UserCollectionService {
88 } 88 }
89 89
90 @Override 90 @Override
91 public Optional<UserCollection> findFirstByUserIdAndTypeAndName(Long id, Integer type, String name) { 91 public UserCollection findFirstByUserIdAndTypeAndName(Long id, Integer type, String name) {
92 return Optional.empty(); 92 UserCollection userCollection =
93 this.userCollectionRepository.findFirstByUserIdAndTypeAndName(id, type, name).orElseGet(UserCollection::new);
94 return userCollection;
93 } 95 }
94 96
95 @Override 97 @Override
......
...@@ -16,6 +16,8 @@ import java.sql.Timestamp; ...@@ -16,6 +16,8 @@ import java.sql.Timestamp;
16 @Data 16 @Data
17 public class MemberOperationBean { 17 public class MemberOperationBean {
18 18
19 private String memberCode;
20
19 private Long memberId; 21 private Long memberId;
20 22
21 private Integer vip; 23 private Integer vip;
......
...@@ -54,6 +54,41 @@ public class MemberOperationController { ...@@ -54,6 +54,41 @@ public class MemberOperationController {
54 return ResultInfo.success(); 54 return ResultInfo.success();
55 } 55 }
56 56
57 @RequestMapping(value = "/updateVipByMemberCode")
58 @ApiOperation("手动修改vip")
59 @AnonymousAccess
60 public ResultInfo updateVipByMemberCode(@Validated(value = {UpdateGroup.class}) @RequestBody MemberOperationBean resources) {
61 log.info("member ==>> doUpdateVipByCode ==>> param ==>> [{}]",resources);
62 Integer vip = resources.getVip();
63 Timestamp vipExpireTime = resources.getVipExpireTime();
64 String memberCode = resources.getMemberCode();
65 MemberDTO memberDTO = this.memberOperationService.findByCode(memberCode);
66
67 Member member = new Member();
68 BeanUtils.copyProperties(memberDTO, member);
69 if (Objects.nonNull(vip)) {
70 member.setVip(vip);
71 }
72 if (Objects.nonNull(vipExpireTime)) {
73 member.setVipExpireTime(vipExpireTime);
74 }
75
76 this.createVipHistory(memberDTO.getId(), vip, vipExpireTime);
77
78 this.memberOperationService.update(member);
79 return ResultInfo.success();
80 }
81
82
83 private void createVipHistory(Long memberId, Integer vip , Timestamp vipExpireTime){
84 BuyVipBean buyVipBean = new BuyVipBean();
85 buyVipBean.setMemberId(memberId);
86 buyVipBean.setVip(vip);
87 buyVipBean.setVipExpireTime(vipExpireTime);
88 this.memberOperationService.buyVipByMemberId(buyVipBean);
89 }
90
91
57 @GetMapping("/getMemberProfileAndCheckVip/{appId}/{memberId}") 92 @GetMapping("/getMemberProfileAndCheckVip/{appId}/{memberId}")
58 @ApiOperation("获取会员基本信息并且检查vip状态") 93 @ApiOperation("获取会员基本信息并且检查vip状态")
59 @AnonymousAccess 94 @AnonymousAccess
...@@ -65,9 +100,10 @@ public class MemberOperationController { ...@@ -65,9 +100,10 @@ public class MemberOperationController {
65 @PutMapping("/buyVip") 100 @PutMapping("/buyVip")
66 @ApiOperation("购买vip") 101 @ApiOperation("购买vip")
67 @AnonymousAccess 102 @AnonymousAccess
103 @Deprecated
68 public ResultInfo buyVip(@RequestBody BuyVipBean buyVipBean) { 104 public ResultInfo buyVip(@RequestBody BuyVipBean buyVipBean) {
69 105
70 // 小程序账户id 106 /* // 小程序账户id
71 Long id = buyVipBean.getId(); 107 Long id = buyVipBean.getId();
72 if (Objects.isNull(id)) 108 if (Objects.isNull(id))
73 throw new BadRequestException("参数异常: id is null !"); 109 throw new BadRequestException("参数异常: id is null !");
...@@ -78,7 +114,8 @@ public class MemberOperationController { ...@@ -78,7 +114,8 @@ public class MemberOperationController {
78 throw new BadRequestException("vip 等级有误"); 114 throw new BadRequestException("vip 等级有误");
79 115
80 MemberDTO memberDTO = this.memberOperationService.buyVip(buyVipBean); 116 MemberDTO memberDTO = this.memberOperationService.buyVip(buyVipBean);
81 return ResultInfo.success(memberDTO); 117 return ResultInfo.success(memberDTO);*/
118 return null;
82 } 119 }
83 } 120 }
84 121
......
...@@ -81,6 +81,7 @@ public class UserOperationController { ...@@ -81,6 +81,7 @@ public class UserOperationController {
81 81
82 Integer vip = resources.getVip(); 82 Integer vip = resources.getVip();
83 Timestamp vipExpireTime = resources.getVipExpireTime(); 83 Timestamp vipExpireTime = resources.getVipExpireTime();
84 // 微信账号id
84 Long userId = resources.getUserId(); 85 Long userId = resources.getUserId();
85 UserWeixinDTO userWeixinDTO = this.userOperationService.findById(userId); 86 UserWeixinDTO userWeixinDTO = this.userOperationService.findById(userId);
86 87
...@@ -96,11 +97,22 @@ public class UserOperationController { ...@@ -96,11 +97,22 @@ public class UserOperationController {
96 member.setVipExpireTime(vipExpireTime); 97 member.setVipExpireTime(vipExpireTime);
97 } 98 }
98 99
100 this.createVipHistory(userId, vip, vipExpireTime);
101
99 this.memberOperationService.update(member); 102 this.memberOperationService.update(member);
100 103
101 return ResultInfo.success(); 104 return ResultInfo.success();
102 } 105 }
103 106
107
108 private void createVipHistory(Long weixinUserId, Integer vip , Timestamp vipExpireTime){
109 BuyVipBean buyVipBean = new BuyVipBean();
110 buyVipBean.setId(weixinUserId);
111 buyVipBean.setVip(vip);
112 buyVipBean.setVipExpireTime(vipExpireTime);
113 this.memberOperationService.buyVipByUserId(buyVipBean);
114 }
115
104 @PostMapping(value = "/createWeixinUserAndCreateMember") 116 @PostMapping(value = "/createWeixinUserAndCreateMember")
105 @ApiOperation("新增小屏账户同时创建会员信息") 117 @ApiOperation("新增小屏账户同时创建会员信息")
106 @AnonymousAccess 118 @AnonymousAccess
......
...@@ -61,6 +61,7 @@ import org.springframework.util.CollectionUtils; ...@@ -61,6 +61,7 @@ import org.springframework.util.CollectionUtils;
61 import springfox.documentation.spring.web.json.Json; 61 import springfox.documentation.spring.web.json.Json;
62 62
63 import java.net.URLDecoder; 63 import java.net.URLDecoder;
64 import java.nio.charset.StandardCharsets;
64 import java.util.*; 65 import java.util.*;
65 import java.util.stream.Collectors; 66 import java.util.stream.Collectors;
66 67
...@@ -708,6 +709,11 @@ public class UserOperationServiceImpl implements UserOperationService { ...@@ -708,6 +709,11 @@ public class UserOperationServiceImpl implements UserOperationService {
708 @Override 709 @Override
709 public boolean deleteCollection(String content) { 710 public boolean deleteCollection(String content) {
710 try { 711 try {
712 //处理接口调用 中文不显示问题
713 content = new String(Base64.getDecoder().decode(content.getBytes(StandardCharsets.UTF_8)));
714
715 log.info("receive addCollection add message, content {}", content);
716
711 JSONObject jsonObject = JSONObject.parseObject(content); 717 JSONObject jsonObject = JSONObject.parseObject(content);
712 String platformAccount = jsonObject.getString("platformAccount"); 718 String platformAccount = jsonObject.getString("platformAccount");
713 String data = jsonObject.getString("data"); 719 String data = jsonObject.getString("data");
...@@ -733,10 +739,9 @@ public class UserOperationServiceImpl implements UserOperationService { ...@@ -733,10 +739,9 @@ public class UserOperationServiceImpl implements UserOperationService {
733 userCollectionMq.setName("DEFAULT"); 739 userCollectionMq.setName("DEFAULT");
734 } 740 }
735 741
736 Optional<UserCollection> userCollectionOptional = 742 UserCollection userCollection =
737 this.userCollectionService.findFirstByUserIdAndTypeAndName(id, userCollectionMq.getType(), 743 this.userCollectionService.findFirstByUserIdAndTypeAndName(id, userCollectionMq.getType(),
738 userCollectionMq.getName()); 744 userCollectionMq.getName());
739 UserCollection userCollection = userCollectionOptional.orElseGet(UserCollection::new);
740 745
741 int count = 0; 746 int count = 0;
742 for (UserCollectionMq collectionMq : value) { 747 for (UserCollectionMq collectionMq : value) {
...@@ -770,9 +775,9 @@ public class UserOperationServiceImpl implements UserOperationService { ...@@ -770,9 +775,9 @@ public class UserOperationServiceImpl implements UserOperationService {
770 public boolean addCollection(String content) { 775 public boolean addCollection(String content) {
771 try { 776 try {
772 //处理接口调用 中文不显示问题 777 //处理接口调用 中文不显示问题
773 //content = new String(Base64.getDecoder().decode(content.getBytes(StandardCharsets.UTF_8))); 778 content = new String(Base64.getDecoder().decode(content.getBytes(StandardCharsets.UTF_8)));
774 779
775 log.info("receive UserCollection add message, content {}", content); 780 log.info("receive addCollection add message, content {}", content);
776 781
777 JSONObject jsonObject = JSONObject.parseObject(content); 782 JSONObject jsonObject = JSONObject.parseObject(content);
778 String platformAccount = jsonObject.getString("platformAccount"); 783 String platformAccount = jsonObject.getString("platformAccount");
...@@ -801,21 +806,25 @@ public class UserOperationServiceImpl implements UserOperationService { ...@@ -801,21 +806,25 @@ public class UserOperationServiceImpl implements UserOperationService {
801 806
802 807
803 UserCollection userCollection = this.userCollectionService 808 UserCollection userCollection = this.userCollectionService
804 .findFirstByUserIdAndTypeAndName(tvUserId, userCollectionMq.getType(), userCollectionMq.getName()).orElseGet(UserCollection::new); 809 .findFirstByUserIdAndTypeAndName(tvUserId, userCollectionMq.getType(), userCollectionMq.getName());
805 810
811
812 if (Objects.isNull(userCollection.getId())) {
806 userCollection.setAppId(userCollectionMq.getAppId()) 813 userCollection.setAppId(userCollectionMq.getAppId())
807 .setUserId(tvUserId) 814 .setUserId(tvUserId)
808 .setName(userCollectionMq.getName()) 815 .setName(userCollectionMq.getName())
809 .setType(userCollectionMq.getType()) 816 .setType(userCollectionMq.getType())
810 .setCount(userCollection.getCount() == null ? value.size() : userCollection.getCount() + value.size()); 817 .setCount(userCollection.getCount() == null ? value.size() : userCollection.getCount() + value.size());
811 log.info("userCollection ==>> [{}]",userCollection); 818 log.info("userCollection ==>> [{}]",userCollection);
812 UserCollection userCollectionSave = this.userCollectionService.save(userCollection); 819 userCollection = this.userCollectionService.save(userCollection);
820 }
813 821
814 for (UserCollectionMq collectionMq : value) { 822 for (UserCollectionMq collectionMq : value) {
815 823
816 UserCollectionDetail userCollectionDetail = collectionMq2DetailMapper.toEntity(collectionMq); 824 UserCollectionDetail userCollectionDetail = collectionMq2DetailMapper.toEntity(collectionMq);
817 Optional<UserCollectionDetail> userCollectionDetailOptional = userCollectionDetailRepository 825 Optional<UserCollectionDetail> userCollectionDetailOptional = userCollectionDetailRepository
818 .findByDetailIdAndDetailTypeAndUserCollectionId(userCollectionDetail.getDetailId(), userCollectionDetail.getDetailType(), userCollectionSave.getId()); 826 .findByDetailIdAndDetailTypeAndUserCollectionId(userCollectionDetail.getDetailId(),
827 userCollectionDetail.getDetailType(), userCollection.getId());
819 //观影记录同一天只存一条记录 828 //观影记录同一天只存一条记录
820 if (userCollectionDetailOptional.isPresent() && 829 if (userCollectionDetailOptional.isPresent() &&
821 DateUtil.isSameDay(new Date(userCollectionDetailOptional.get().getCreateTime().getTime()), new Date())) { 830 DateUtil.isSameDay(new Date(userCollectionDetailOptional.get().getCreateTime().getTime()), new Date())) {
...@@ -825,7 +834,7 @@ public class UserOperationServiceImpl implements UserOperationService { ...@@ -825,7 +834,7 @@ public class UserOperationServiceImpl implements UserOperationService {
825 } else { 834 } else {
826 835
827 userCollectionDetail.setId(null) 836 userCollectionDetail.setId(null)
828 .setUserCollectionId(userCollectionSave.getId()); 837 .setUserCollectionId(userCollection.getId());
829 838
830 } 839 }
831 840
......
...@@ -50,18 +50,23 @@ public class MemberOperationServiceImpl implements MemberOperationService { ...@@ -50,18 +50,23 @@ public class MemberOperationServiceImpl implements MemberOperationService {
50 50
51 // @CachePut(key = "#resources.memberId") 51 // @CachePut(key = "#resources.memberId")
52 @Override 52 @Override
53 public MemberDTO buyVip(BuyVipBean resources) { 53 public MemberDTO buyVipByUserId(BuyVipBean resources) {
54 // 小程序账户id 54 // 小程序账户id
55 Long id = resources.getId(); 55 Long id = resources.getId();
56
57 // 过期时间
58 Timestamp vipExpireTime1 = resources.getVipExpireTime();
59 Integer vip1 = resources.getVip();
60
61 // 查询微信账户 56 // 查询微信账户
62 UserWeixinDTO userWeixin = this.findWeiXinById(id); 57 UserWeixinDTO userWeixin = this.findWeiXinById(id);
63 Long memberId = userWeixin.getMemberId(); 58 Long memberId = userWeixin.getMemberId();
59 resources.setMemberId(memberId);
60 return this.buyVipByMemberId(resources);
61 }
62
63 @Override
64 public MemberDTO buyVipByMemberId(BuyVipBean resources) {
65
66 Timestamp vipExpireTime1 = resources.getVipExpireTime();
67 Integer vip1 = resources.getVip();
64 68
69 Long memberId = resources.getMemberId();
65 // 70 //
66 MemberDTO memberDTO = this.findById(memberId); 71 MemberDTO memberDTO = this.findById(memberId);
67 String memberCode = memberDTO.getCode(); 72 String memberCode = memberDTO.getCode();
......
...@@ -35,7 +35,14 @@ public interface MemberOperationService { ...@@ -35,7 +35,14 @@ public interface MemberOperationService {
35 * @param resources 35 * @param resources
36 * @return 36 * @return
37 */ 37 */
38 MemberDTO buyVip(BuyVipBean resources); 38 MemberDTO buyVipByUserId(BuyVipBean resources);
39
40 /**
41 *
42 * @param resources
43 * @return
44 */
45 MemberDTO buyVipByMemberId(BuyVipBean resources);
39 46
40 /** 47 /**
41 * 48 *
......
...@@ -22,9 +22,6 @@ public class DataSyncMsg implements Serializable { ...@@ -22,9 +22,6 @@ public class DataSyncMsg implements Serializable {
22 // 消息体 22 // 消息体
23 private MsgData msg; 23 private MsgData msg;
24 24
25 // 其他属性
26 private String extraData;
27
28 /** 25 /**
29 * 消息体 26 * 消息体
30 */ 27 */
......
...@@ -68,7 +68,7 @@ spring: ...@@ -68,7 +68,7 @@ spring:
68 # publisher-confirms: true #如果对异步消息需要回调必须设置为true 68 # publisher-confirms: true #如果对异步消息需要回调必须设置为true
69 host: 122.112.214.149 # rabbitmq的连接地址 69 host: 122.112.214.149 # rabbitmq的连接地址
70 port: 5672 # rabbitmq的连接端口号 70 port: 5672 # rabbitmq的连接端口号
71 virtual-host: member_center # rabbitmq的虚拟hosthhh 71 virtual-host: member_center_small_sichuan # rabbitmq的虚拟hosthhh
72 username: guest # rabbitmq的用户名 72 username: guest # rabbitmq的用户名
73 password: guest # rabbitmq的密码 73 password: guest # rabbitmq的密码
74 publisher-confirms: true #如果对异步消息需要回调必须设置为true 74 publisher-confirms: true #如果对异步消息需要回调必须设置为true
......