1.会员1.1
Showing
43 changed files
with
648 additions
and
153 deletions
| ... | @@ -45,6 +45,7 @@ public class DataSyncMsg implements Serializable { | ... | @@ -45,6 +45,7 @@ public class DataSyncMsg implements Serializable { |
| 45 | private Integer deviceType; //设备类型 1:大屏;2:小屏(微信)3.小屏(xx) | 45 | private Integer deviceType; //设备类型 1:大屏;2:小屏(微信)3.小屏(xx) |
| 46 | @NotNull | 46 | @NotNull |
| 47 | private String appCode; //用户对应的应用code | 47 | private String appCode; //用户对应的应用code |
| 48 | private String memberCode; | ||
| 48 | private Long accountId; // 账号id | 49 | private Long accountId; // 账号id |
| 49 | private Long orderId; | 50 | private Long orderId; |
| 50 | private Long activityId; | 51 | private Long activityId; | ... | ... |
| 1 | package com.topdraw; | 1 | package com.topdraw; |
| 2 | 2 | ||
| 3 | import com.topdraw.config.RedisKeyUtil; | ||
| 4 | import com.topdraw.utils.RedisUtils; | ||
| 3 | import com.topdraw.utils.SpringContextHolder; | 5 | import com.topdraw.utils.SpringContextHolder; |
| 6 | import org.springframework.beans.factory.annotation.Autowired; | ||
| 4 | import org.springframework.boot.SpringApplication; | 7 | import org.springframework.boot.SpringApplication; |
| 5 | import org.springframework.boot.autoconfigure.EnableAutoConfiguration; | 8 | import org.springframework.boot.autoconfigure.EnableAutoConfiguration; |
| 6 | import org.springframework.boot.autoconfigure.SpringBootApplication; | 9 | import org.springframework.boot.autoconfigure.SpringBootApplication; | ... | ... |
| 1 | package com.topdraw.business.module.common.domain; | ||
| 2 | |||
| 3 | import lombok.Data; | ||
| 4 | import lombok.experimental.Accessors; | ||
| 5 | import org.springframework.data.jpa.domain.support.AuditingEntityListener; | ||
| 6 | |||
| 7 | import javax.persistence.Entity; | ||
| 8 | import javax.persistence.EntityListeners; | ||
| 9 | import javax.persistence.Transient; | ||
| 10 | import java.io.Serializable; | ||
| 11 | |||
| 12 | /** | ||
| 13 | * @author : | ||
| 14 | * @description: | ||
| 15 | * @function : | ||
| 16 | * @date :Created in 2022/2/10 10:12 | ||
| 17 | * @version: : | ||
| 18 | * @modified By: | ||
| 19 | * @since : modified in 2022/2/10 10:12 | ||
| 20 | */ | ||
| 21 | @Data | ||
| 22 | @Accessors(chain = true) | ||
| 23 | public class DefaultAsyncMqModule { | ||
| 24 | |||
| 25 | @Transient | ||
| 26 | private String memberCode; | ||
| 27 | |||
| 28 | } |
| ... | @@ -11,6 +11,7 @@ import org.springframework.data.jpa.domain.support.AuditingEntityListener; | ... | @@ -11,6 +11,7 @@ import org.springframework.data.jpa.domain.support.AuditingEntityListener; |
| 11 | import java.sql.Timestamp; | 11 | import java.sql.Timestamp; |
| 12 | 12 | ||
| 13 | import java.io.Serializable; | 13 | import java.io.Serializable; |
| 14 | import java.time.LocalDateTime; | ||
| 14 | 15 | ||
| 15 | /** | 16 | /** |
| 16 | * @author XiangHan | 17 | * @author XiangHan |
| ... | @@ -87,12 +88,12 @@ public class MemberAddress implements Serializable { | ... | @@ -87,12 +88,12 @@ public class MemberAddress implements Serializable { |
| 87 | // 创建时间 | 88 | // 创建时间 |
| 88 | @CreatedDate | 89 | @CreatedDate |
| 89 | @Column(name = "create_time") | 90 | @Column(name = "create_time") |
| 90 | private Timestamp createTime; | 91 | private LocalDateTime createTime; |
| 91 | 92 | ||
| 92 | // 更新时间 | 93 | // 更新时间 |
| 93 | @LastModifiedDate | 94 | @LastModifiedDate |
| 94 | @Column(name = "update_time") | 95 | @Column(name = "update_time") |
| 95 | private Timestamp updateTime; | 96 | private LocalDateTime updateTime; |
| 96 | 97 | ||
| 97 | public void copy(MemberAddress source){ | 98 | public void copy(MemberAddress source){ |
| 98 | BeanUtil.copyProperties(source,this, CopyOptions.create().setIgnoreNullValue(true)); | 99 | BeanUtil.copyProperties(source,this, CopyOptions.create().setIgnoreNullValue(true)); | ... | ... |
| 1 | package com.topdraw.business.module.member.address.rest; | 1 | package com.topdraw.business.module.member.address.rest; |
| 2 | 2 | ||
| 3 | import com.topdraw.annotation.AnonymousAccess; | ||
| 3 | import com.topdraw.business.module.member.service.MemberService; | 4 | import com.topdraw.business.module.member.service.MemberService; |
| 4 | import com.topdraw.business.module.member.service.dto.MemberDTO; | 5 | import com.topdraw.business.module.member.service.dto.MemberDTO; |
| 5 | import com.topdraw.common.ResultInfo; | 6 | import com.topdraw.common.ResultInfo; |
| 6 | import com.topdraw.business.module.member.address.domain.MemberAddress; | 7 | import com.topdraw.business.module.member.address.domain.MemberAddress; |
| 7 | import com.topdraw.business.module.member.address.service.MemberAddressService; | 8 | import com.topdraw.business.module.member.address.service.MemberAddressService; |
| 8 | import com.topdraw.business.module.member.address.service.dto.MemberAddressQueryCriteria; | 9 | import com.topdraw.business.module.member.address.service.dto.MemberAddressQueryCriteria; |
| 10 | import lombok.extern.slf4j.Slf4j; | ||
| 9 | import org.springframework.beans.factory.annotation.Autowired; | 11 | import org.springframework.beans.factory.annotation.Autowired; |
| 10 | import org.springframework.data.domain.Pageable; | 12 | import org.springframework.data.domain.Pageable; |
| 11 | import org.springframework.util.Assert; | 13 | import org.springframework.util.Assert; |
| ... | @@ -21,8 +23,9 @@ import java.util.Objects; | ... | @@ -21,8 +23,9 @@ import java.util.Objects; |
| 21 | */ | 23 | */ |
| 22 | @Api(tags = "MemberAddress管理") | 24 | @Api(tags = "MemberAddress管理") |
| 23 | @RestController | 25 | @RestController |
| 24 | @RequestMapping("/api/MemberAddress") | 26 | @RequestMapping("/ucEngine/api/memberAddress") |
| 25 | @CrossOrigin | 27 | @CrossOrigin |
| 28 | @Slf4j | ||
| 26 | public class MemberAddressController { | 29 | public class MemberAddressController { |
| 27 | 30 | ||
| 28 | @Autowired | 31 | @Autowired |
| ... | @@ -44,14 +47,25 @@ public class MemberAddressController { | ... | @@ -44,14 +47,25 @@ public class MemberAddressController { |
| 44 | 47 | ||
| 45 | @PostMapping(value = "/create") | 48 | @PostMapping(value = "/create") |
| 46 | @ApiOperation("新增MemberAddress") | 49 | @ApiOperation("新增MemberAddress") |
| 50 | @AnonymousAccess | ||
| 47 | public ResultInfo create(@Validated @RequestBody MemberAddress resources) { | 51 | public ResultInfo create(@Validated @RequestBody MemberAddress resources) { |
| 52 | log.info("MemberAddressController ==>> create ===>>[{}]",resources); | ||
| 53 | |||
| 54 | Long memberId = resources.getMemberId(); | ||
| 55 | MemberDTO memberDTO = this.memberService.findById(memberId); | ||
| 56 | String code = memberDTO.getCode(); | ||
| 57 | resources.setMemberCode(code); | ||
| 48 | MemberAddressService.create(resources); | 58 | MemberAddressService.create(resources); |
| 49 | return ResultInfo.success(); | 59 | return ResultInfo.success(); |
| 50 | } | 60 | } |
| 51 | 61 | ||
| 52 | @PutMapping(value = "/update") | 62 | @PutMapping(value = "/update") |
| 53 | @ApiOperation("修改MemberAddress") | 63 | @ApiOperation("修改MemberAddress") |
| 64 | @AnonymousAccess | ||
| 54 | public ResultInfo update(@Validated @RequestBody MemberAddress resources) { | 65 | public ResultInfo update(@Validated @RequestBody MemberAddress resources) { |
| 66 | |||
| 67 | log.info("MemberAddressController ==>> update ===>>[{}]",resources); | ||
| 68 | |||
| 55 | Long memberId = resources.getMemberId(); | 69 | Long memberId = resources.getMemberId(); |
| 56 | Integer sequence = resources.getSequence(); | 70 | Integer sequence = resources.getSequence(); |
| 57 | Assert.notNull(memberId,"memberId can't be null"); | 71 | Assert.notNull(memberId,"memberId can't be null"); |
| ... | @@ -68,6 +82,7 @@ public class MemberAddressController { | ... | @@ -68,6 +82,7 @@ public class MemberAddressController { |
| 68 | 82 | ||
| 69 | @DeleteMapping(value = "/delete/{id}") | 83 | @DeleteMapping(value = "/delete/{id}") |
| 70 | @ApiOperation("删除MemberAddress") | 84 | @ApiOperation("删除MemberAddress") |
| 85 | @AnonymousAccess | ||
| 71 | public ResultInfo delete(@PathVariable Long id) { | 86 | public ResultInfo delete(@PathVariable Long id) { |
| 72 | MemberAddressService.delete(id); | 87 | MemberAddressService.delete(id); |
| 73 | return ResultInfo.success(); | 88 | return ResultInfo.success(); | ... | ... |
| ... | @@ -3,6 +3,7 @@ package com.topdraw.business.module.member.address.service.dto; | ... | @@ -3,6 +3,7 @@ package com.topdraw.business.module.member.address.service.dto; |
| 3 | import lombok.Data; | 3 | import lombok.Data; |
| 4 | import java.sql.Timestamp; | 4 | import java.sql.Timestamp; |
| 5 | import java.io.Serializable; | 5 | import java.io.Serializable; |
| 6 | import java.time.LocalDateTime; | ||
| 6 | 7 | ||
| 7 | 8 | ||
| 8 | /** | 9 | /** |
| ... | @@ -55,8 +56,8 @@ public class MemberAddressDTO implements Serializable { | ... | @@ -55,8 +56,8 @@ public class MemberAddressDTO implements Serializable { |
| 55 | private String zipCode; | 56 | private String zipCode; |
| 56 | 57 | ||
| 57 | // 创建时间 | 58 | // 创建时间 |
| 58 | private Timestamp createTime; | 59 | private LocalDateTime createTime; |
| 59 | 60 | ||
| 60 | // 更新时间 | 61 | // 更新时间 |
| 61 | private Timestamp updateTime; | 62 | private LocalDateTime updateTime; |
| 62 | } | 63 | } | ... | ... |
| ... | @@ -2,6 +2,7 @@ package com.topdraw.business.module.member.address.service.impl; | ... | @@ -2,6 +2,7 @@ package com.topdraw.business.module.member.address.service.impl; |
| 2 | 2 | ||
| 3 | import com.topdraw.aspect.AsyncMqSend; | 3 | import com.topdraw.aspect.AsyncMqSend; |
| 4 | import com.topdraw.business.module.member.address.domain.MemberAddress; | 4 | import com.topdraw.business.module.member.address.domain.MemberAddress; |
| 5 | import com.topdraw.business.module.member.service.MemberService; | ||
| 5 | import com.topdraw.utils.ValidationUtil; | 6 | import com.topdraw.utils.ValidationUtil; |
| 6 | import com.topdraw.business.module.member.address.repository.MemberAddressRepository; | 7 | import com.topdraw.business.module.member.address.repository.MemberAddressRepository; |
| 7 | import com.topdraw.business.module.member.address.service.MemberAddressService; | 8 | import com.topdraw.business.module.member.address.service.MemberAddressService; | ... | ... |
| ... | @@ -7,7 +7,9 @@ import com.topdraw.business.module.member.service.dto.MemberDTO; | ... | @@ -7,7 +7,9 @@ import com.topdraw.business.module.member.service.dto.MemberDTO; |
| 7 | import com.topdraw.common.ResultInfo; | 7 | import com.topdraw.common.ResultInfo; |
| 8 | import com.topdraw.business.module.member.profile.domain.MemberProfile; | 8 | import com.topdraw.business.module.member.profile.domain.MemberProfile; |
| 9 | import com.topdraw.business.module.member.profile.service.MemberProfileService; | 9 | import com.topdraw.business.module.member.profile.service.MemberProfileService; |
| 10 | import com.topdraw.util.Base64Util; | ||
| 10 | import com.topdraw.utils.StringUtils; | 11 | import com.topdraw.utils.StringUtils; |
| 12 | import lombok.extern.slf4j.Slf4j; | ||
| 11 | import org.springframework.beans.factory.annotation.Autowired; | 13 | import org.springframework.beans.factory.annotation.Autowired; |
| 12 | import org.springframework.util.Assert; | 14 | import org.springframework.util.Assert; |
| 13 | import org.springframework.validation.annotation.Validated; | 15 | import org.springframework.validation.annotation.Validated; |
| ... | @@ -24,6 +26,7 @@ import java.util.Objects; | ... | @@ -24,6 +26,7 @@ import java.util.Objects; |
| 24 | @RestController | 26 | @RestController |
| 25 | @RequestMapping("/ucEngine/api/memberProfile") | 27 | @RequestMapping("/ucEngine/api/memberProfile") |
| 26 | @CrossOrigin | 28 | @CrossOrigin |
| 29 | @Slf4j | ||
| 27 | public class MemberProfileController { | 30 | public class MemberProfileController { |
| 28 | 31 | ||
| 29 | @Autowired | 32 | @Autowired |
| ... | @@ -47,6 +50,8 @@ public class MemberProfileController { | ... | @@ -47,6 +50,8 @@ public class MemberProfileController { |
| 47 | @ApiOperation("新增MemberProfile") | 50 | @ApiOperation("新增MemberProfile") |
| 48 | @AnonymousAccess | 51 | @AnonymousAccess |
| 49 | public ResultInfo create(@Validated @RequestBody MemberProfile resources) { | 52 | public ResultInfo create(@Validated @RequestBody MemberProfile resources) { |
| 53 | log.info("MemberProfileServiceImpl ==>> create ==>> resources ===>> [{}]",resources); | ||
| 54 | String realname = resources.getRealname(); | ||
| 50 | MemberProfileService.create(resources); | 55 | MemberProfileService.create(resources); |
| 51 | return ResultInfo.success(); | 56 | return ResultInfo.success(); |
| 52 | } | 57 | } |
| ... | @@ -55,6 +60,9 @@ public class MemberProfileController { | ... | @@ -55,6 +60,9 @@ public class MemberProfileController { |
| 55 | @ApiOperation("修改MemberProfile") | 60 | @ApiOperation("修改MemberProfile") |
| 56 | @AnonymousAccess | 61 | @AnonymousAccess |
| 57 | public ResultInfo update(@Validated @RequestBody MemberProfile resources) { | 62 | public ResultInfo update(@Validated @RequestBody MemberProfile resources) { |
| 63 | |||
| 64 | log.info("MemberProfileServiceImpl ==>> update ==>> resources ===>> [{}]",resources); | ||
| 65 | |||
| 58 | Long memberId = resources.getMemberId(); | 66 | Long memberId = resources.getMemberId(); |
| 59 | Assert.notNull(memberId,"memberId can't be null"); | 67 | Assert.notNull(memberId,"memberId can't be null"); |
| 60 | MemberDTO memberDTO = this.memberService.findById(memberId); | 68 | MemberDTO memberDTO = this.memberService.findById(memberId); |
| ... | @@ -79,6 +87,7 @@ public class MemberProfileController { | ... | @@ -79,6 +87,7 @@ public class MemberProfileController { |
| 79 | @ApiOperation("修改MemberProfile") | 87 | @ApiOperation("修改MemberProfile") |
| 80 | @AnonymousAccess | 88 | @AnonymousAccess |
| 81 | public ResultInfo updateMemberProfileAndMember(@Validated @RequestBody MemberProfile resources) { | 89 | public ResultInfo updateMemberProfileAndMember(@Validated @RequestBody MemberProfile resources) { |
| 90 | log.info("MemberProfileServiceImpl ==>> update ==>> resources ===>> [{}]",resources); | ||
| 82 | this.MemberProfileService.updateMemberProfileAndMember(resources); | 91 | this.MemberProfileService.updateMemberProfileAndMember(resources); |
| 83 | return ResultInfo.success(); | 92 | return ResultInfo.success(); |
| 84 | } | 93 | } | ... | ... |
| ... | @@ -6,6 +6,7 @@ import com.topdraw.business.module.member.domain.Member; | ... | @@ -6,6 +6,7 @@ import com.topdraw.business.module.member.domain.Member; |
| 6 | import com.topdraw.business.module.member.profile.domain.MemberProfile; | 6 | import com.topdraw.business.module.member.profile.domain.MemberProfile; |
| 7 | import com.topdraw.business.module.member.profile.domain.MemberProfileBuild; | 7 | import com.topdraw.business.module.member.profile.domain.MemberProfileBuild; |
| 8 | import com.topdraw.business.module.member.repository.MemberRepository; | 8 | import com.topdraw.business.module.member.repository.MemberRepository; |
| 9 | import com.topdraw.business.module.member.service.MemberService; | ||
| 9 | import com.topdraw.utils.StringUtils; | 10 | import com.topdraw.utils.StringUtils; |
| 10 | import com.topdraw.utils.ValidationUtil; | 11 | import com.topdraw.utils.ValidationUtil; |
| 11 | import com.topdraw.business.module.member.profile.repository.MemberProfileRepository; | 12 | import com.topdraw.business.module.member.profile.repository.MemberProfileRepository; |
| ... | @@ -13,6 +14,7 @@ import com.topdraw.business.module.member.profile.service.MemberProfileService; | ... | @@ -13,6 +14,7 @@ import com.topdraw.business.module.member.profile.service.MemberProfileService; |
| 13 | import com.topdraw.business.module.member.profile.service.dto.MemberProfileDTO; | 14 | import com.topdraw.business.module.member.profile.service.dto.MemberProfileDTO; |
| 14 | import com.topdraw.business.module.member.profile.service.dto.MemberProfileQueryCriteria; | 15 | import com.topdraw.business.module.member.profile.service.dto.MemberProfileQueryCriteria; |
| 15 | import com.topdraw.business.module.member.profile.service.mapper.MemberProfileMapper; | 16 | import com.topdraw.business.module.member.profile.service.mapper.MemberProfileMapper; |
| 17 | import lombok.extern.slf4j.Slf4j; | ||
| 16 | import org.springframework.beans.factory.annotation.Autowired; | 18 | import org.springframework.beans.factory.annotation.Autowired; |
| 17 | import org.springframework.stereotype.Service; | 19 | import org.springframework.stereotype.Service; |
| 18 | import org.springframework.transaction.annotation.Propagation; | 20 | import org.springframework.transaction.annotation.Propagation; |
| ... | @@ -36,6 +38,7 @@ import java.util.Optional; | ... | @@ -36,6 +38,7 @@ import java.util.Optional; |
| 36 | */ | 38 | */ |
| 37 | @Service | 39 | @Service |
| 38 | @Transactional(propagation = Propagation.SUPPORTS, readOnly = true, rollbackFor = Exception.class) | 40 | @Transactional(propagation = Propagation.SUPPORTS, readOnly = true, rollbackFor = Exception.class) |
| 41 | @Slf4j | ||
| 39 | public class MemberProfileServiceImpl implements MemberProfileService { | 42 | public class MemberProfileServiceImpl implements MemberProfileService { |
| 40 | 43 | ||
| 41 | @Autowired | 44 | @Autowired |
| ... | @@ -46,6 +49,8 @@ public class MemberProfileServiceImpl implements MemberProfileService { | ... | @@ -46,6 +49,8 @@ public class MemberProfileServiceImpl implements MemberProfileService { |
| 46 | 49 | ||
| 47 | @Autowired | 50 | @Autowired |
| 48 | private MemberProfileMapper MemberProfileMapper; | 51 | private MemberProfileMapper MemberProfileMapper; |
| 52 | @Autowired | ||
| 53 | private MemberService memberService; | ||
| 49 | 54 | ||
| 50 | 55 | ||
| 51 | @Override | 56 | @Override |
| ... | @@ -70,12 +75,14 @@ public class MemberProfileServiceImpl implements MemberProfileService { | ... | @@ -70,12 +75,14 @@ public class MemberProfileServiceImpl implements MemberProfileService { |
| 70 | @Transactional(rollbackFor = Exception.class) | 75 | @Transactional(rollbackFor = Exception.class) |
| 71 | @AsyncMqSend() | 76 | @AsyncMqSend() |
| 72 | public MemberProfile create(MemberProfile resources) { | 77 | public MemberProfile create(MemberProfile resources) { |
| 78 | log.info("MemberProfileServiceImpl ==>> update ==>> resources ===>> [{}]",resources); | ||
| 73 | MemberProfileRepository.save(resources); | 79 | MemberProfileRepository.save(resources); |
| 74 | return resources; | 80 | return resources; |
| 75 | } | 81 | } |
| 76 | 82 | ||
| 77 | @Override | 83 | @Override |
| 78 | public MemberProfile createDefault(MemberProfile resources) { | 84 | public MemberProfile createDefault(MemberProfile resources) { |
| 85 | |||
| 79 | Long memberId = resources.getMemberId(); | 86 | Long memberId = resources.getMemberId(); |
| 80 | String realname = resources.getRealname(); | 87 | String realname = resources.getRealname(); |
| 81 | Integer gender = resources.getGender(); | 88 | Integer gender = resources.getGender(); |
| ... | @@ -88,9 +95,14 @@ public class MemberProfileServiceImpl implements MemberProfileService { | ... | @@ -88,9 +95,14 @@ public class MemberProfileServiceImpl implements MemberProfileService { |
| 88 | @Transactional(rollbackFor = Exception.class) | 95 | @Transactional(rollbackFor = Exception.class) |
| 89 | @AsyncMqSend() | 96 | @AsyncMqSend() |
| 90 | public void update(MemberProfile resources) { | 97 | public void update(MemberProfile resources) { |
| 98 | |||
| 99 | log.info("MemberProfileServiceImpl ==>> update ==>> resources ===>> [{}]",resources); | ||
| 100 | |||
| 91 | MemberProfile MemberProfile = MemberProfileRepository.findById(resources.getId()).orElseGet(MemberProfile::new); | 101 | MemberProfile MemberProfile = MemberProfileRepository.findById(resources.getId()).orElseGet(MemberProfile::new); |
| 92 | ValidationUtil.isNull( MemberProfile.getId(),"MemberProfile","id",resources.getId()); | 102 | ValidationUtil.isNull( MemberProfile.getId(),"MemberProfile","id",resources.getId()); |
| 93 | MemberProfile.copy(resources); | 103 | MemberProfile.copy(resources); |
| 104 | |||
| 105 | log.info("MemberProfileServiceImpl ==>> update ==>> copy ===>> resources ===>> [{}]",resources); | ||
| 94 | MemberProfileRepository.save(MemberProfile); | 106 | MemberProfileRepository.save(MemberProfile); |
| 95 | } | 107 | } |
| 96 | 108 | ||
| ... | @@ -117,6 +129,7 @@ public class MemberProfileServiceImpl implements MemberProfileService { | ... | @@ -117,6 +129,7 @@ public class MemberProfileServiceImpl implements MemberProfileService { |
| 117 | @Override | 129 | @Override |
| 118 | @Transactional(rollbackFor = Exception.class) | 130 | @Transactional(rollbackFor = Exception.class) |
| 119 | public void updateMemberProfileAndMember(MemberProfile resources) { | 131 | public void updateMemberProfileAndMember(MemberProfile resources) { |
| 132 | log.info("MemberProfileServiceImpl ==>> updateMemberProfileAndMember ==>> resources ===>> [{}]",resources); | ||
| 120 | String realname = resources.getRealname(); | 133 | String realname = resources.getRealname(); |
| 121 | String nickNameStr = ""; | 134 | String nickNameStr = ""; |
| 122 | if (StringUtils.isNotBlank(realname)) { | 135 | if (StringUtils.isNotBlank(realname)) { |
| ... | @@ -141,8 +154,9 @@ public class MemberProfileServiceImpl implements MemberProfileService { | ... | @@ -141,8 +154,9 @@ public class MemberProfileServiceImpl implements MemberProfileService { |
| 141 | member.setBirthday(DateUtil.format(resources.getBirthday(), "yyyy-MM-dd")); | 154 | member.setBirthday(DateUtil.format(resources.getBirthday(), "yyyy-MM-dd")); |
| 142 | member.setAvatarUrl(resources.getAvatarUrl()); | 155 | member.setAvatarUrl(resources.getAvatarUrl()); |
| 143 | 156 | ||
| 144 | memberRepository.save(member); | 157 | // memberRepository.save(member); |
| 145 | //memberService.update(member); | 158 | log.info("updateMemberProfileAndMember ==>> member ==>> [{}]",member); |
| 159 | memberService.update(member); | ||
| 146 | } | 160 | } |
| 147 | 161 | ||
| 148 | } | 162 | } | ... | ... |
| ... | @@ -49,6 +49,12 @@ public class MemberRelatedInfoController { | ... | @@ -49,6 +49,12 @@ public class MemberRelatedInfoController { |
| 49 | @ApiOperation("新增MemberRelatedInfo") | 49 | @ApiOperation("新增MemberRelatedInfo") |
| 50 | @AnonymousAccess | 50 | @AnonymousAccess |
| 51 | public ResultInfo create(@Validated @RequestBody MemberRelatedInfo resources) { | 51 | public ResultInfo create(@Validated @RequestBody MemberRelatedInfo resources) { |
| 52 | String name = resources.getName(); | ||
| 53 | if (StringUtils.hasText(name)) { | ||
| 54 | String nickNameEncode = Base64Util.encode(name); | ||
| 55 | resources.setName(nickNameEncode); | ||
| 56 | } | ||
| 57 | |||
| 52 | MemberRelatedInfoService.create(resources); | 58 | MemberRelatedInfoService.create(resources); |
| 53 | return ResultInfo.success(); | 59 | return ResultInfo.success(); |
| 54 | } | 60 | } | ... | ... |
| ... | @@ -53,6 +53,7 @@ public class MemberController { | ... | @@ -53,6 +53,7 @@ public class MemberController { |
| 53 | 53 | ||
| 54 | @PostMapping(value = "/create") | 54 | @PostMapping(value = "/create") |
| 55 | @ApiOperation("新增Member") | 55 | @ApiOperation("新增Member") |
| 56 | @AnonymousAccess | ||
| 56 | public ResultInfo create(@Validated @RequestBody Member resources) { | 57 | public ResultInfo create(@Validated @RequestBody Member resources) { |
| 57 | Long id = memberService.create(resources); | 58 | Long id = memberService.create(resources); |
| 58 | return ResultInfo.success(id); | 59 | return ResultInfo.success(id); | ... | ... |
| 1 | package com.topdraw.business.module.member.service; | 1 | package com.topdraw.business.module.member.service; |
| 2 | 2 | ||
| 3 | import com.topdraw.aspect.AsyncMqSend; | ||
| 3 | import com.topdraw.business.module.member.domain.Member; | 4 | import com.topdraw.business.module.member.domain.Member; |
| 4 | import com.topdraw.business.module.member.profile.service.dto.MemberProfileDTO; | 5 | import com.topdraw.business.module.member.profile.service.dto.MemberProfileDTO; |
| 5 | import com.topdraw.business.module.member.service.dto.MemberDTO; | 6 | import com.topdraw.business.module.member.service.dto.MemberDTO; |
| 6 | import com.topdraw.business.module.member.service.dto.MemberQueryCriteria; | 7 | import com.topdraw.business.module.member.service.dto.MemberQueryCriteria; |
| 7 | import org.springframework.data.domain.Pageable; | 8 | import org.springframework.data.domain.Pageable; |
| 9 | import org.springframework.transaction.annotation.Transactional; | ||
| 8 | 10 | ||
| 9 | import java.util.List; | 11 | import java.util.List; |
| 10 | import java.util.Map; | 12 | import java.util.Map; |
| ... | @@ -44,12 +46,17 @@ public interface MemberService { | ... | @@ -44,12 +46,17 @@ public interface MemberService { |
| 44 | */ | 46 | */ |
| 45 | Long create(Member resources); | 47 | Long create(Member resources); |
| 46 | 48 | ||
| 49 | Member createAndReturnMember(Member resources); | ||
| 50 | |||
| 47 | /** | 51 | /** |
| 48 | * | 52 | * |
| 49 | * @param resources | 53 | * @param resources |
| 50 | */ | 54 | */ |
| 51 | void update(Member resources); | 55 | void update(Member resources); |
| 52 | 56 | ||
| 57 | |||
| 58 | void unbind(Member resources); | ||
| 59 | |||
| 53 | /** | 60 | /** |
| 54 | * | 61 | * |
| 55 | * @param id | 62 | * @param id | ... | ... |
| ... | @@ -14,6 +14,8 @@ import java.time.LocalDateTime; | ... | @@ -14,6 +14,8 @@ import java.time.LocalDateTime; |
| 14 | @Data | 14 | @Data |
| 15 | public class MemberDTO implements Serializable { | 15 | public class MemberDTO implements Serializable { |
| 16 | 16 | ||
| 17 | private String platformAccount; | ||
| 18 | |||
| 17 | // iptv绑定的主会员 0:否 1:是 | 19 | // iptv绑定的主会员 0:否 1:是 |
| 18 | private Integer iptvMajor; | 20 | private Integer iptvMajor; |
| 19 | 21 | ... | ... |
| ... | @@ -78,12 +78,20 @@ public class MemberServiceImpl implements MemberService { | ... | @@ -78,12 +78,20 @@ public class MemberServiceImpl implements MemberService { |
| 78 | @Transactional(rollbackFor = Exception.class) | 78 | @Transactional(rollbackFor = Exception.class) |
| 79 | @AsyncMqSend | 79 | @AsyncMqSend |
| 80 | public Long create(Member resources) { | 80 | public Long create(Member resources) { |
| 81 | log.info("start=====>>>>>resources======>>>>接收到的数据 --->>>> " + resources); | ||
| 82 | Member member = this.checkMemberData(resources); | 81 | Member member = this.checkMemberData(resources); |
| 83 | memberRepository.save(member); | 82 | memberRepository.save(member); |
| 84 | return member.getId(); | 83 | return member.getId(); |
| 85 | } | 84 | } |
| 86 | 85 | ||
| 86 | @Override | ||
| 87 | @Transactional(rollbackFor = Exception.class) | ||
| 88 | @AsyncMqSend | ||
| 89 | public Member createAndReturnMember(Member resources) { | ||
| 90 | Member member = this.checkMemberData(resources); | ||
| 91 | memberRepository.save(member); | ||
| 92 | return resources; | ||
| 93 | } | ||
| 94 | |||
| 87 | private Member checkMemberData(Member member) { | 95 | private Member checkMemberData(Member member) { |
| 88 | Long defaultValue = 0L; | 96 | Long defaultValue = 0L; |
| 89 | String code = member.getCode(); | 97 | String code = member.getCode(); |
| ... | @@ -131,6 +139,25 @@ public class MemberServiceImpl implements MemberService { | ... | @@ -131,6 +139,25 @@ public class MemberServiceImpl implements MemberService { |
| 131 | } | 139 | } |
| 132 | } | 140 | } |
| 133 | 141 | ||
| 142 | @Override | ||
| 143 | @Transactional(rollbackFor = Exception.class) | ||
| 144 | @AsyncMqSend() | ||
| 145 | public void unbind(Member resources) { | ||
| 146 | RLock rLock = this.redissonClient.getLock("member::update::id" + resources.getId().toString()); | ||
| 147 | try { | ||
| 148 | RedissonUtil.lock(rLock); | ||
| 149 | Member member = memberRepository.findById(resources.getId()).orElseGet(Member::new); | ||
| 150 | ValidationUtil.isNull(member.getId(), "Member", "id", resources.getId()); | ||
| 151 | member.copy(resources); | ||
| 152 | this.save(member); | ||
| 153 | } catch (Exception e) { | ||
| 154 | e.printStackTrace(); | ||
| 155 | throw e; | ||
| 156 | } finally { | ||
| 157 | RedissonUtil.unlock(rLock); | ||
| 158 | } | ||
| 159 | } | ||
| 160 | |||
| 134 | private void save(Member member){ | 161 | private void save(Member member){ |
| 135 | memberRepository.save(member); | 162 | memberRepository.save(member); |
| 136 | } | 163 | } |
| ... | @@ -162,6 +189,7 @@ public class MemberServiceImpl implements MemberService { | ... | @@ -162,6 +189,7 @@ public class MemberServiceImpl implements MemberService { |
| 162 | } | 189 | } |
| 163 | 190 | ||
| 164 | @Override | 191 | @Override |
| 192 | @AsyncMqSend() | ||
| 165 | public void doUpdateMemberPoints(Member resources) { | 193 | public void doUpdateMemberPoints(Member resources) { |
| 166 | RLock rLock = this.redissonClient.getLock("member::update::id" + resources.getId().toString()); | 194 | RLock rLock = this.redissonClient.getLock("member::update::id" + resources.getId().toString()); |
| 167 | try { | 195 | try { | ... | ... |
| 1 | package com.topdraw.business.module.points.available.domain; | 1 | package com.topdraw.business.module.points.available.domain; |
| 2 | 2 | ||
| 3 | import com.topdraw.business.module.common.domain.DefaultAsyncMqModule; | ||
| 3 | import lombok.Data; | 4 | import lombok.Data; |
| 4 | import lombok.experimental.Accessors; | 5 | import lombok.experimental.Accessors; |
| 5 | import cn.hutool.core.bean.BeanUtil; | 6 | import cn.hutool.core.bean.BeanUtil; |
| ... | @@ -24,11 +25,7 @@ import java.io.Serializable; | ... | @@ -24,11 +25,7 @@ import java.io.Serializable; |
| 24 | @EntityListeners(AuditingEntityListener.class) | 25 | @EntityListeners(AuditingEntityListener.class) |
| 25 | @Accessors(chain = true) | 26 | @Accessors(chain = true) |
| 26 | @Table(name="uc_points_available") | 27 | @Table(name="uc_points_available") |
| 27 | public class PointsAvailable implements Serializable { | 28 | public class PointsAvailable extends DefaultAsyncMqModule implements Serializable { |
| 28 | |||
| 29 | /** 会员编号 */ | ||
| 30 | @Transient | ||
| 31 | private String memberCode; | ||
| 32 | 29 | ||
| 33 | // 主键 | 30 | // 主键 |
| 34 | @Id | 31 | @Id | ... | ... |
| 1 | package com.topdraw.business.module.rights.history.domain; | 1 | package com.topdraw.business.module.rights.history.domain; |
| 2 | 2 | ||
| 3 | import com.topdraw.business.module.common.domain.DefaultAsyncMqModule; | ||
| 3 | import lombok.Data; | 4 | import lombok.Data; |
| 4 | import lombok.experimental.Accessors; | 5 | import lombok.experimental.Accessors; |
| 5 | import cn.hutool.core.bean.BeanUtil; | 6 | import cn.hutool.core.bean.BeanUtil; |
| ... | @@ -22,7 +23,7 @@ import java.time.LocalDateTime; | ... | @@ -22,7 +23,7 @@ import java.time.LocalDateTime; |
| 22 | @EntityListeners(AuditingEntityListener.class) | 23 | @EntityListeners(AuditingEntityListener.class) |
| 23 | @Accessors(chain = true) | 24 | @Accessors(chain = true) |
| 24 | @Table(name="tr_rights_histroy") | 25 | @Table(name="tr_rights_histroy") |
| 25 | public class RightsHistory implements Serializable { | 26 | public class RightsHistory extends DefaultAsyncMqModule implements Serializable { |
| 26 | 27 | ||
| 27 | // 主键id | 28 | // 主键id |
| 28 | @Id | 29 | @Id | ... | ... |
| ... | @@ -66,7 +66,7 @@ public class RightsHistoryServiceImpl implements RightsHistoryService { | ... | @@ -66,7 +66,7 @@ public class RightsHistoryServiceImpl implements RightsHistoryService { |
| 66 | @AsyncMqSend() | 66 | @AsyncMqSend() |
| 67 | public void update(RightsHistory resources) { | 67 | public void update(RightsHistory resources) { |
| 68 | RightsHistory RightsHistory = RightsHistoryRepository.findById(resources.getId()).orElseGet(RightsHistory::new); | 68 | RightsHistory RightsHistory = RightsHistoryRepository.findById(resources.getId()).orElseGet(RightsHistory::new); |
| 69 | ValidationUtil.isNull( RightsHistory.getId(),"RightsHistory","id",resources.getId()); | 69 | ValidationUtil.isNull(RightsHistory.getId(),"RightsHistory","id",resources.getId()); |
| 70 | RightsHistory.copy(resources); | 70 | RightsHistory.copy(resources); |
| 71 | RightsHistoryRepository.save(RightsHistory); | 71 | RightsHistoryRepository.save(RightsHistory); |
| 72 | } | 72 | } | ... | ... |
| 1 | package com.topdraw.business.module.user.iptv.service; | 1 | package com.topdraw.business.module.user.iptv.service; |
| 2 | 2 | ||
| 3 | import com.topdraw.aspect.AsyncMqSend; | ||
| 3 | import com.topdraw.business.module.user.iptv.domain.UserTv; | 4 | import com.topdraw.business.module.user.iptv.domain.UserTv; |
| 4 | import com.topdraw.business.module.user.iptv.service.dto.UserTvDTO; | 5 | import com.topdraw.business.module.user.iptv.service.dto.UserTvDTO; |
| 5 | import com.topdraw.business.module.user.iptv.service.dto.UserTvQueryCriteria; | 6 | import com.topdraw.business.module.user.iptv.service.dto.UserTvQueryCriteria; |
| 6 | import org.springframework.data.domain.Pageable; | 7 | import org.springframework.data.domain.Pageable; |
| 8 | import org.springframework.transaction.annotation.Transactional; | ||
| 9 | |||
| 7 | import java.util.Map; | 10 | import java.util.Map; |
| 8 | import java.util.List; | 11 | import java.util.List; |
| 9 | 12 | ||
| ... | @@ -39,6 +42,8 @@ public interface UserTvService { | ... | @@ -39,6 +42,8 @@ public interface UserTvService { |
| 39 | 42 | ||
| 40 | void update(UserTv resources); | 43 | void update(UserTv resources); |
| 41 | 44 | ||
| 45 | void unbindPriorityMemberCode(UserTv resources); | ||
| 46 | |||
| 42 | void delete(Long id); | 47 | void delete(Long id); |
| 43 | 48 | ||
| 44 | UserTvDTO findByPlatformAccount(String platformAccount); | 49 | UserTvDTO findByPlatformAccount(String platformAccount); | ... | ... |
| ... | @@ -12,6 +12,8 @@ import java.io.Serializable; | ... | @@ -12,6 +12,8 @@ import java.io.Serializable; |
| 12 | @Data | 12 | @Data |
| 13 | public class UserTvDTO implements Serializable { | 13 | public class UserTvDTO implements Serializable { |
| 14 | 14 | ||
| 15 | private String memberCode; | ||
| 16 | |||
| 15 | /** 绑定的小屏账户会员编码 */ | 17 | /** 绑定的小屏账户会员编码 */ |
| 16 | private String priorityMemberCode; | 18 | private String priorityMemberCode; |
| 17 | 19 | ... | ... |
| ... | @@ -88,6 +88,16 @@ public class UserTvServiceImpl implements UserTvService { | ... | @@ -88,6 +88,16 @@ public class UserTvServiceImpl implements UserTvService { |
| 88 | @Override | 88 | @Override |
| 89 | @Transactional(rollbackFor = Exception.class) | 89 | @Transactional(rollbackFor = Exception.class) |
| 90 | @AsyncMqSend | 90 | @AsyncMqSend |
| 91 | public void unbindPriorityMemberCode(UserTv resources) { | ||
| 92 | UserTv UserTv = UserTvRepository.findById(resources.getId()).orElseGet(UserTv::new); | ||
| 93 | ValidationUtil.isNull( UserTv.getId(),"UserTv","id",resources.getId()); | ||
| 94 | UserTv.copy(resources); | ||
| 95 | UserTvRepository.save(UserTv); | ||
| 96 | } | ||
| 97 | |||
| 98 | @Override | ||
| 99 | @Transactional(rollbackFor = Exception.class) | ||
| 100 | @AsyncMqSend | ||
| 91 | public void delete(Long id) { | 101 | public void delete(Long id) { |
| 92 | Assert.notNull(id, "The given id must not be null!"); | 102 | Assert.notNull(id, "The given id must not be null!"); |
| 93 | UserTv UserTv = UserTvRepository.findById(id).orElseThrow( | 103 | UserTv UserTv = UserTvRepository.findById(id).orElseThrow( | ... | ... |
| ... | @@ -70,11 +70,13 @@ public class UserCollectionDetailServiceImpl implements UserCollectionDetailServ | ... | @@ -70,11 +70,13 @@ public class UserCollectionDetailServiceImpl implements UserCollectionDetailServ |
| 70 | } | 70 | } |
| 71 | 71 | ||
| 72 | @Override | 72 | @Override |
| 73 | @Transactional(rollbackFor = Exception.class) | ||
| 73 | public void deleteAllByUserCollectionId(Long id) { | 74 | public void deleteAllByUserCollectionId(Long id) { |
| 74 | this.userCollectionDetailRepository.deleteAllByUserCollectionId(id); | 75 | this.userCollectionDetailRepository.deleteAllByUserCollectionId(id); |
| 75 | } | 76 | } |
| 76 | 77 | ||
| 77 | @Override | 78 | @Override |
| 79 | @Transactional(rollbackFor = Exception.class) | ||
| 78 | public void deleteAll(List<UserCollectionDetail> userCollectionDetailOptional) { | 80 | public void deleteAll(List<UserCollectionDetail> userCollectionDetailOptional) { |
| 79 | this.userCollectionDetailRepository.deleteAll(userCollectionDetailOptional); | 81 | this.userCollectionDetailRepository.deleteAll(userCollectionDetailOptional); |
| 80 | } | 82 | } | ... | ... |
| 1 | package com.topdraw.business.module.user.weixin.domain; | 1 | package com.topdraw.business.module.user.weixin.domain; |
| 2 | 2 | ||
| 3 | import com.topdraw.business.module.common.domain.DefaultAsyncMqModule; | ||
| 3 | import lombok.Data; | 4 | import lombok.Data; |
| 4 | import lombok.experimental.Accessors; | 5 | import lombok.experimental.Accessors; |
| 5 | import cn.hutool.core.bean.BeanUtil; | 6 | import cn.hutool.core.bean.BeanUtil; |
| ... | @@ -21,7 +22,7 @@ import java.io.Serializable; | ... | @@ -21,7 +22,7 @@ import java.io.Serializable; |
| 21 | @EntityListeners(AuditingEntityListener.class) | 22 | @EntityListeners(AuditingEntityListener.class) |
| 22 | @Accessors(chain = true) | 23 | @Accessors(chain = true) |
| 23 | @Table(name="uc_user_weixin") | 24 | @Table(name="uc_user_weixin") |
| 24 | public class UserWeixin implements Serializable { | 25 | public class UserWeixin extends DefaultAsyncMqModule implements Serializable { |
| 25 | 26 | ||
| 26 | // ID | 27 | // ID |
| 27 | @Id | 28 | @Id | ... | ... |
| ... | @@ -3,7 +3,11 @@ package com.topdraw.business.module.user.weixin.repository; | ... | @@ -3,7 +3,11 @@ package com.topdraw.business.module.user.weixin.repository; |
| 3 | import com.topdraw.business.module.user.weixin.domain.UserWeixin; | 3 | import com.topdraw.business.module.user.weixin.domain.UserWeixin; |
| 4 | import org.springframework.data.jpa.repository.JpaRepository; | 4 | import org.springframework.data.jpa.repository.JpaRepository; |
| 5 | import org.springframework.data.jpa.repository.JpaSpecificationExecutor; | 5 | import org.springframework.data.jpa.repository.JpaSpecificationExecutor; |
| 6 | import org.springframework.data.jpa.repository.Modifying; | ||
| 7 | import org.springframework.data.jpa.repository.Query; | ||
| 8 | import org.springframework.data.repository.query.Param; | ||
| 6 | 9 | ||
| 10 | import javax.transaction.Transactional; | ||
| 7 | import java.util.Optional; | 11 | import java.util.Optional; |
| 8 | 12 | ||
| 9 | /** | 13 | /** |
| ... | @@ -21,4 +25,9 @@ public interface UserWeixinRepository extends JpaRepository<UserWeixin, Long>, J | ... | @@ -21,4 +25,9 @@ public interface UserWeixinRepository extends JpaRepository<UserWeixin, Long>, J |
| 21 | Optional<UserWeixin> findFirstByUnionid(String unionid); | 25 | Optional<UserWeixin> findFirstByUnionid(String unionid); |
| 22 | 26 | ||
| 23 | Optional<UserWeixin> findFirstByUnionidAndAppid(String unionid, String appId); | 27 | Optional<UserWeixin> findFirstByUnionidAndAppid(String unionid, String appId); |
| 28 | |||
| 29 | @Modifying | ||
| 30 | @Transactional | ||
| 31 | @Query(value = "update uc_user_weixin set update_time = :#{#resources.updateTime} where appid = :#{#resources.appid} and openid = :#{#resources.openid}" , nativeQuery = true) | ||
| 32 | void updateTime(@Param("resources") UserWeixin resources); | ||
| 24 | } | 33 | } | ... | ... |
| ... | @@ -40,6 +40,8 @@ public interface UserWeixinService { | ... | @@ -40,6 +40,8 @@ public interface UserWeixinService { |
| 40 | 40 | ||
| 41 | void update(UserWeixin resources); | 41 | void update(UserWeixin resources); |
| 42 | 42 | ||
| 43 | void updateTime(UserWeixin resources); | ||
| 44 | |||
| 43 | void delete(Long id); | 45 | void delete(Long id); |
| 44 | 46 | ||
| 45 | UserWeixinDTO findFirstByMemberIdAndAppid(Long memberId, String appid); | 47 | UserWeixinDTO findFirstByMemberIdAndAppid(Long memberId, String appid); | ... | ... |
| 1 | package com.topdraw.business.module.user.weixin.service.impl; | 1 | package com.topdraw.business.module.user.weixin.service.impl; |
| 2 | 2 | ||
| 3 | import com.topdraw.aspect.AsyncMqSend; | ||
| 3 | import com.topdraw.business.module.user.weixin.domain.UserWeixin; | 4 | import com.topdraw.business.module.user.weixin.domain.UserWeixin; |
| 4 | import com.topdraw.utils.ValidationUtil; | 5 | import com.topdraw.utils.ValidationUtil; |
| 5 | import com.topdraw.business.module.user.weixin.repository.UserWeixinRepository; | 6 | import com.topdraw.business.module.user.weixin.repository.UserWeixinRepository; |
| ... | @@ -55,6 +56,7 @@ public class UserWeixinServiceImpl implements UserWeixinService { | ... | @@ -55,6 +56,7 @@ public class UserWeixinServiceImpl implements UserWeixinService { |
| 55 | 56 | ||
| 56 | @Override | 57 | @Override |
| 57 | @Transactional(rollbackFor = Exception.class) | 58 | @Transactional(rollbackFor = Exception.class) |
| 59 | @AsyncMqSend | ||
| 58 | public UserWeixin create(UserWeixin resources) { | 60 | public UserWeixin create(UserWeixin resources) { |
| 59 | UserWeixinRepository.save(resources); | 61 | UserWeixinRepository.save(resources); |
| 60 | return resources; | 62 | return resources; |
| ... | @@ -62,6 +64,7 @@ public class UserWeixinServiceImpl implements UserWeixinService { | ... | @@ -62,6 +64,7 @@ public class UserWeixinServiceImpl implements UserWeixinService { |
| 62 | 64 | ||
| 63 | @Override | 65 | @Override |
| 64 | @Transactional(rollbackFor = Exception.class) | 66 | @Transactional(rollbackFor = Exception.class) |
| 67 | @AsyncMqSend | ||
| 65 | public void update(UserWeixin resources) { | 68 | public void update(UserWeixin resources) { |
| 66 | UserWeixin UserWeixin = UserWeixinRepository.findById(resources.getId()).orElseGet(UserWeixin::new); | 69 | UserWeixin UserWeixin = UserWeixinRepository.findById(resources.getId()).orElseGet(UserWeixin::new); |
| 67 | ValidationUtil.isNull( UserWeixin.getId(),"UserWeixin","id",resources.getId()); | 70 | ValidationUtil.isNull( UserWeixin.getId(),"UserWeixin","id",resources.getId()); |
| ... | @@ -70,6 +73,12 @@ public class UserWeixinServiceImpl implements UserWeixinService { | ... | @@ -70,6 +73,12 @@ public class UserWeixinServiceImpl implements UserWeixinService { |
| 70 | } | 73 | } |
| 71 | 74 | ||
| 72 | @Override | 75 | @Override |
| 76 | @AsyncMqSend | ||
| 77 | public void updateTime(UserWeixin resources) { | ||
| 78 | UserWeixinRepository.updateTime(resources); | ||
| 79 | } | ||
| 80 | |||
| 81 | @Override | ||
| 73 | @Transactional(rollbackFor = Exception.class) | 82 | @Transactional(rollbackFor = Exception.class) |
| 74 | public void delete(Long id) { | 83 | public void delete(Long id) { |
| 75 | Assert.notNull(id, "The given id must not be null!"); | 84 | Assert.notNull(id, "The given id must not be null!"); | ... | ... |
| ... | @@ -13,9 +13,10 @@ import java.sql.Timestamp; | ... | @@ -13,9 +13,10 @@ import java.sql.Timestamp; |
| 13 | @NoArgsConstructor | 13 | @NoArgsConstructor |
| 14 | public class TempIptvUser { | 14 | public class TempIptvUser { |
| 15 | 15 | ||
| 16 | private String unionid; | ||
| 17 | |||
| 16 | // 账户 | 18 | // 账户 |
| 17 | @Transient | 19 | @Transient |
| 18 | @NotNull(message = "platformAccount can't be null",groups = UnbindGroup.class) | ||
| 19 | private String platformAccount; | 20 | private String platformAccount; |
| 20 | 21 | ||
| 21 | // 分数 | 22 | // 分数 |
| ... | @@ -86,8 +87,6 @@ public class TempIptvUser { | ... | @@ -86,8 +87,6 @@ public class TempIptvUser { |
| 86 | // 会员id | 87 | // 会员id |
| 87 | private Long memberId; | 88 | private Long memberId; |
| 88 | 89 | ||
| 89 | // 会员编码 | ||
| 90 | @NotNull(message = "memberCode can't be null",groups = UnbindGroup.class) | ||
| 91 | private String memberCode; | 90 | private String memberCode; |
| 92 | 91 | ||
| 93 | 92 | ... | ... |
| 1 | package com.topdraw.business.process.domian.weixin; | 1 | package com.topdraw.business.process.domian.weixin; |
| 2 | 2 | ||
| 3 | 3 | import com.fasterxml.jackson.annotation.JsonFormat; | |
| 4 | import lombok.Data; | 4 | import lombok.Data; |
| 5 | 5 | ||
| 6 | import java.time.LocalDateTime; | ||
| 7 | |||
| 6 | /** | 8 | /** |
| 7 | * 微信账户信息 | 9 | * 微信账户信息 |
| 8 | * @author XiangHan | 10 | * @author XiangHan |
| ... | @@ -13,5 +15,8 @@ public class BuyVipBean extends WeiXinUserBean { | ... | @@ -13,5 +15,8 @@ public class BuyVipBean extends WeiXinUserBean { |
| 13 | 15 | ||
| 14 | private Integer vip; | 16 | private Integer vip; |
| 15 | 17 | ||
| 18 | @JsonFormat(shape = JsonFormat.Shape.STRING,pattern = "yyyy-MM-dd HH:mm:ss") | ||
| 19 | private LocalDateTime vipExpireTime; | ||
| 20 | |||
| 16 | 21 | ||
| 17 | } | 22 | } | ... | ... |
| ... | @@ -15,6 +15,18 @@ public class SubscribeBean extends WeiXinUserBean { | ... | @@ -15,6 +15,18 @@ public class SubscribeBean extends WeiXinUserBean { |
| 15 | 15 | ||
| 16 | private String event; | 16 | private String event; |
| 17 | 17 | ||
| 18 | |||
| 19 | /** */ | ||
| 20 | private String openId; | ||
| 21 | |||
| 22 | /** */ | ||
| 23 | private String appId; | ||
| 24 | |||
| 25 | /** */ | ||
| 18 | private String eventKey; | 26 | private String eventKey; |
| 19 | 27 | ||
| 28 | private String unionid; | ||
| 29 | private String nickname; | ||
| 30 | private String headimgurl; | ||
| 31 | |||
| 20 | } | 32 | } | ... | ... |
| 1 | package com.topdraw.business.process.rest; | 1 | package com.topdraw.business.process.rest; |
| 2 | 2 | ||
| 3 | import cn.hutool.core.util.ObjectUtil; | ||
| 3 | import com.topdraw.annotation.AnonymousAccess; | 4 | import com.topdraw.annotation.AnonymousAccess; |
| 4 | import com.topdraw.business.module.member.profile.service.dto.MemberProfileDTO; | 5 | import com.topdraw.business.module.member.profile.service.dto.MemberProfileDTO; |
| 6 | import com.topdraw.business.module.member.service.MemberService; | ||
| 5 | import com.topdraw.business.module.member.service.dto.MemberDTO; | 7 | import com.topdraw.business.module.member.service.dto.MemberDTO; |
| 8 | import com.topdraw.business.module.member.viphistory.domain.MemberVipHistory; | ||
| 9 | import com.topdraw.business.module.member.viphistory.service.MemberVipHistoryService; | ||
| 10 | import com.topdraw.business.module.user.weixin.service.UserWeixinService; | ||
| 11 | import com.topdraw.business.module.user.weixin.service.dto.UserWeixinDTO; | ||
| 6 | import com.topdraw.business.module.user.weixin.service.dto.UserWeixinQueryCriteria; | 12 | import com.topdraw.business.module.user.weixin.service.dto.UserWeixinQueryCriteria; |
| 7 | import com.topdraw.business.process.domian.weixin.BuyVipBean; | 13 | import com.topdraw.business.process.domian.weixin.BuyVipBean; |
| 8 | import com.topdraw.business.process.domian.weixin.WeiXinUserBean; | 14 | import com.topdraw.business.process.domian.weixin.WeiXinUserBean; |
| 9 | import com.topdraw.business.process.service.MemberOperationService; | 15 | import com.topdraw.business.process.service.MemberOperationService; |
| 10 | import com.topdraw.common.IResultInfo; | 16 | import com.topdraw.common.IResultInfo; |
| 11 | import com.topdraw.common.ResultInfo; | 17 | import com.topdraw.common.ResultInfo; |
| 18 | import com.topdraw.exception.BadRequestException; | ||
| 19 | import com.topdraw.weixin.util.WeChatConstants; | ||
| 12 | import io.swagger.annotations.Api; | 20 | import io.swagger.annotations.Api; |
| 13 | import io.swagger.annotations.ApiOperation; | 21 | import io.swagger.annotations.ApiOperation; |
| 14 | import org.springframework.beans.factory.annotation.Autowired; | 22 | import org.springframework.beans.factory.annotation.Autowired; |
| 15 | import org.springframework.web.bind.annotation.*; | 23 | import org.springframework.web.bind.annotation.*; |
| 16 | 24 | ||
| 25 | import java.time.LocalDateTime; | ||
| 26 | import java.util.Objects; | ||
| 27 | |||
| 17 | @Api("会员处理") | 28 | @Api("会员处理") |
| 18 | @RestController | 29 | @RestController |
| 19 | @RequestMapping(value = "/ucEngine/api/memberOperation") | 30 | @RequestMapping(value = "/ucEngine/api/memberOperation") |
| ... | @@ -21,6 +32,12 @@ public class MemberOperationController { | ... | @@ -21,6 +32,12 @@ public class MemberOperationController { |
| 21 | 32 | ||
| 22 | @Autowired | 33 | @Autowired |
| 23 | private MemberOperationService memberOperationService; | 34 | private MemberOperationService memberOperationService; |
| 35 | @Autowired | ||
| 36 | private MemberVipHistoryService memberVipHistoryService; | ||
| 37 | @Autowired | ||
| 38 | private UserWeixinService userWeixinService; | ||
| 39 | @Autowired | ||
| 40 | private MemberService memberService; | ||
| 24 | 41 | ||
| 25 | @GetMapping("/getMemberProfileAndCheckVip/{appId}/{memberId}") | 42 | @GetMapping("/getMemberProfileAndCheckVip/{appId}/{memberId}") |
| 26 | @ApiOperation("获取会员基本信息并且检查vip状态") | 43 | @ApiOperation("获取会员基本信息并且检查vip状态") |
| ... | @@ -34,9 +51,57 @@ public class MemberOperationController { | ... | @@ -34,9 +51,57 @@ public class MemberOperationController { |
| 34 | @ApiOperation("购买vip") | 51 | @ApiOperation("购买vip") |
| 35 | @AnonymousAccess | 52 | @AnonymousAccess |
| 36 | public ResultInfo buyVip(@RequestBody BuyVipBean buyVipBean) { | 53 | public ResultInfo buyVip(@RequestBody BuyVipBean buyVipBean) { |
| 54 | |||
| 55 | // 小程序账户id | ||
| 56 | Long id = buyVipBean.getId(); | ||
| 57 | if (Objects.isNull(id)) | ||
| 58 | throw new BadRequestException("参数异常: id is null !"); | ||
| 59 | |||
| 60 | // vip等级 | ||
| 61 | Integer vip = buyVipBean.getVip(); | ||
| 62 | if (Objects.isNull(vip) || vip <= 0) | ||
| 63 | throw new BadRequestException("vip 等级有误"); | ||
| 64 | |||
| 37 | MemberDTO memberDTO = memberOperationService.buyVip(buyVipBean); | 65 | MemberDTO memberDTO = memberOperationService.buyVip(buyVipBean); |
| 66 | |||
| 67 | LocalDateTime vipExpireTime = buyVipBean.getVipExpireTime(); | ||
| 68 | this.doInsertVipHistory(id,vip,vipExpireTime); | ||
| 38 | return ResultInfo.success(memberDTO); | 69 | return ResultInfo.success(memberDTO); |
| 39 | } | 70 | } |
| 71 | |||
| 72 | private void doInsertVipHistory(Long id,Integer vip,LocalDateTime vipExpireTime) { | ||
| 73 | |||
| 74 | UserWeixinDTO userWeixinDTO = this.userWeixinService.findById(id); | ||
| 75 | Long memberId = userWeixinDTO.getMemberId(); | ||
| 76 | |||
| 77 | MemberDTO member = this.memberService.findById(memberId); | ||
| 78 | |||
| 79 | LocalDateTime now = LocalDateTime.now(); | ||
| 80 | |||
| 81 | MemberVipHistory memberVipHistory = new MemberVipHistory(); | ||
| 82 | if (ObjectUtil.isNull(vipExpireTime)) { | ||
| 83 | LocalDateTime localDateTime = now.plusYears(1L); | ||
| 84 | member.setVipExpireTime(localDateTime); | ||
| 85 | } else { | ||
| 86 | //购买过 判断当前时间有没有过vip过期时间,没有过,失效时间加一年; 过了,当前时间加一年 | ||
| 87 | //区分是当前vip续费 还是买新的vip | ||
| 88 | if (ObjectUtil.equal(vip, member.getVip())) { | ||
| 89 | if (now.isBefore(vipExpireTime)) { | ||
| 90 | LocalDateTime localDateTime = vipExpireTime.plusYears(1L); | ||
| 91 | member.setVipExpireTime(localDateTime); | ||
| 92 | } else { | ||
| 93 | LocalDateTime localDateTime = now.plusYears(1L); | ||
| 94 | member.setVipExpireTime(localDateTime); | ||
| 95 | } | ||
| 96 | } else { | ||
| 97 | LocalDateTime localDateTime = now.plusYears(1L); | ||
| 98 | member.setVipExpireTime(localDateTime); | ||
| 99 | } | ||
| 100 | } | ||
| 101 | |||
| 102 | memberVipHistory.setVipExpireTime(member.getVipExpireTime()); | ||
| 103 | memberVipHistoryService.create(memberVipHistory); | ||
| 104 | } | ||
| 40 | } | 105 | } |
| 41 | 106 | ||
| 42 | 107 | ... | ... |
| 1 | package com.topdraw.business.process.rest; | 1 | package com.topdraw.business.process.rest; |
| 2 | 2 | ||
| 3 | import com.topdraw.annotation.AnonymousAccess; | ||
| 3 | import com.topdraw.business.module.member.service.MemberService; | 4 | import com.topdraw.business.module.member.service.MemberService; |
| 4 | import com.topdraw.business.module.member.service.dto.MemberDTO; | 5 | import com.topdraw.business.module.member.service.dto.MemberDTO; |
| 5 | import com.topdraw.business.module.points.available.service.PointsAvailableService; | 6 | import com.topdraw.business.module.points.available.service.PointsAvailableService; |
| ... | @@ -58,12 +59,14 @@ public class PointsOperationController { | ... | @@ -58,12 +59,14 @@ public class PointsOperationController { |
| 58 | 59 | ||
| 59 | @GetMapping(value = "/pagePointsDetails") | 60 | @GetMapping(value = "/pagePointsDetails") |
| 60 | @ApiOperation("查询PointsDetail") | 61 | @ApiOperation("查询PointsDetail") |
| 62 | @AnonymousAccess | ||
| 61 | public ResultInfo pagePointsDetails(PointsDetailQueryCriteria criteria, Pageable pageable) { | 63 | public ResultInfo pagePointsDetails(PointsDetailQueryCriteria criteria, Pageable pageable) { |
| 62 | return ResultInfo.successPage(pointsDetailService.queryAll(criteria,pageable)); | 64 | return ResultInfo.successPage(pointsDetailService.queryAll(criteria,pageable)); |
| 63 | } | 65 | } |
| 64 | 66 | ||
| 65 | @GetMapping(value = "/pageAvailablePoints") | 67 | @GetMapping(value = "/pageAvailablePoints") |
| 66 | @ApiOperation("查询PointsAvailable") | 68 | @ApiOperation("查询PointsAvailable") |
| 69 | @AnonymousAccess | ||
| 67 | public ResultInfo pageAvailablePoints(PointsAvailableQueryCriteria criteria, Pageable pageable) { | 70 | public ResultInfo pageAvailablePoints(PointsAvailableQueryCriteria criteria, Pageable pageable) { |
| 68 | PointsAvailableQueryType queryType = criteria.getQueryType(); | 71 | PointsAvailableQueryType queryType = criteria.getQueryType(); |
| 69 | // 可用 | 72 | // 可用 |
| ... | @@ -75,6 +78,7 @@ public class PointsOperationController { | ... | @@ -75,6 +78,7 @@ public class PointsOperationController { |
| 75 | 78 | ||
| 76 | @GetMapping(value = "/cleanInvalidPointsAndCalculateCurrentPoints/{id}") | 79 | @GetMapping(value = "/cleanInvalidPointsAndCalculateCurrentPoints/{id}") |
| 77 | @ApiOperation("清除过期积分并计算总积分,供客户端会员查询积分时调用") | 80 | @ApiOperation("清除过期积分并计算总积分,供客户端会员查询积分时调用") |
| 81 | @AnonymousAccess | ||
| 78 | public ResultInfo cleanInvalidPointsAndCalculateCurrentPoints(@PathVariable("id") Long id) { | 82 | public ResultInfo cleanInvalidPointsAndCalculateCurrentPoints(@PathVariable("id") Long id) { |
| 79 | Long aLong = this.pointsOperationService.cleanInvalidPointsAndCalculateCurrentPoints(id); | 83 | Long aLong = this.pointsOperationService.cleanInvalidPointsAndCalculateCurrentPoints(id); |
| 80 | return ResultInfo.success(Objects.isNull(aLong) ? 0L : aLong); | 84 | return ResultInfo.success(Objects.isNull(aLong) ? 0L : aLong); |
| ... | @@ -82,6 +86,7 @@ public class PointsOperationController { | ... | @@ -82,6 +86,7 @@ public class PointsOperationController { |
| 82 | 86 | ||
| 83 | @PostMapping(value = "/grantPointsByManual") | 87 | @PostMapping(value = "/grantPointsByManual") |
| 84 | @ApiOperation("手动发放积分") | 88 | @ApiOperation("手动发放积分") |
| 89 | @AnonymousAccess | ||
| 85 | public ResultInfo grantPointsByManual(@Validated @RequestBody TempPoints tempPoints) { | 90 | public ResultInfo grantPointsByManual(@Validated @RequestBody TempPoints tempPoints) { |
| 86 | Long memberId = tempPoints.getMemberId(); | 91 | Long memberId = tempPoints.getMemberId(); |
| 87 | Long points = tempPoints.getPoints(); | 92 | Long points = tempPoints.getPoints(); |
| ... | @@ -104,6 +109,7 @@ public class PointsOperationController { | ... | @@ -104,6 +109,7 @@ public class PointsOperationController { |
| 104 | */ | 109 | */ |
| 105 | @PostMapping(value = "/customPointsByUserTvPlatformAccount") | 110 | @PostMapping(value = "/customPointsByUserTvPlatformAccount") |
| 106 | @ApiOperation("通过大屏账户积分消耗") | 111 | @ApiOperation("通过大屏账户积分消耗") |
| 112 | @AnonymousAccess | ||
| 107 | public ResultInfo customPointsByUserTvPlatformAccount(@Validated @RequestBody TempCustomPointBean tempIptvUser) { | 113 | public ResultInfo customPointsByUserTvPlatformAccount(@Validated @RequestBody TempCustomPointBean tempIptvUser) { |
| 108 | String platformAccount = tempIptvUser.getPlatformAccount(); | 114 | String platformAccount = tempIptvUser.getPlatformAccount(); |
| 109 | Long points = tempIptvUser.getPoints(); | 115 | Long points = tempIptvUser.getPoints(); |
| ... | @@ -142,6 +148,7 @@ public class PointsOperationController { | ... | @@ -142,6 +148,7 @@ public class PointsOperationController { |
| 142 | */ | 148 | */ |
| 143 | @PostMapping(value = "/customPointsByUserId") | 149 | @PostMapping(value = "/customPointsByUserId") |
| 144 | @ApiOperation("积分消耗") | 150 | @ApiOperation("积分消耗") |
| 151 | @AnonymousAccess | ||
| 145 | public ResultInfo customPointsByUserId(@Validated @RequestBody TempPoints tempPoints) { | 152 | public ResultInfo customPointsByUserId(@Validated @RequestBody TempPoints tempPoints) { |
| 146 | Long userId = tempPoints.getUserId(); | 153 | Long userId = tempPoints.getUserId(); |
| 147 | // 设备类型 1:大屏;2:小屏(微信)3.小屏(xx) | 154 | // 设备类型 1:大屏;2:小屏(微信)3.小屏(xx) |
| ... | @@ -182,6 +189,7 @@ public class PointsOperationController { | ... | @@ -182,6 +189,7 @@ public class PointsOperationController { |
| 182 | 189 | ||
| 183 | @PostMapping(value = "/consumePoints") | 190 | @PostMapping(value = "/consumePoints") |
| 184 | @ApiOperation("积分消耗") | 191 | @ApiOperation("积分消耗") |
| 192 | @AnonymousAccess | ||
| 185 | public ResultInfo customPoints(@Validated @RequestBody TempPoints tempPoints) { | 193 | public ResultInfo customPoints(@Validated @RequestBody TempPoints tempPoints) { |
| 186 | Integer pointsType = tempPoints.getPointsType(); | 194 | Integer pointsType = tempPoints.getPointsType(); |
| 187 | if (Objects.isNull(pointsType)) { | 195 | if (Objects.isNull(pointsType)) { | ... | ... |
| ... | @@ -5,8 +5,11 @@ import cn.hutool.core.util.StrUtil; | ... | @@ -5,8 +5,11 @@ import cn.hutool.core.util.StrUtil; |
| 5 | import com.alibaba.fastjson.JSONObject; | 5 | import com.alibaba.fastjson.JSONObject; |
| 6 | import com.topdraw.annotation.AnonymousAccess; | 6 | import com.topdraw.annotation.AnonymousAccess; |
| 7 | import com.topdraw.business.module.member.profile.domain.MemberProfile; | 7 | import com.topdraw.business.module.member.profile.domain.MemberProfile; |
| 8 | import com.topdraw.business.module.member.service.MemberService; | ||
| 8 | import com.topdraw.business.module.member.service.dto.MemberDTO; | 9 | import com.topdraw.business.module.member.service.dto.MemberDTO; |
| 9 | import com.topdraw.business.module.user.iptv.domain.UserTv; | 10 | import com.topdraw.business.module.user.iptv.domain.UserTv; |
| 11 | import com.topdraw.business.module.user.iptv.service.UserTvService; | ||
| 12 | import com.topdraw.business.module.user.iptv.service.dto.UserTvDTO; | ||
| 10 | import com.topdraw.business.module.user.weixin.domain.UserWeixin; | 13 | import com.topdraw.business.module.user.weixin.domain.UserWeixin; |
| 11 | import com.topdraw.business.module.user.weixin.service.UserWeixinService; | 14 | import com.topdraw.business.module.user.weixin.service.UserWeixinService; |
| 12 | import com.topdraw.business.module.user.weixin.service.dto.UserWeixinDTO; | 15 | import com.topdraw.business.module.user.weixin.service.dto.UserWeixinDTO; |
| ... | @@ -17,15 +20,14 @@ import com.topdraw.business.process.domian.weixin.SubscribeBean; | ... | @@ -17,15 +20,14 @@ import com.topdraw.business.process.domian.weixin.SubscribeBean; |
| 17 | import com.topdraw.business.process.domian.weixin.SubscribeBeanEvent; | 20 | import com.topdraw.business.process.domian.weixin.SubscribeBeanEvent; |
| 18 | import com.topdraw.business.process.domian.weixin.WeiXinUserBean; | 21 | import com.topdraw.business.process.domian.weixin.WeiXinUserBean; |
| 19 | import com.topdraw.business.process.service.UserOperationService; | 22 | import com.topdraw.business.process.service.UserOperationService; |
| 20 | import com.topdraw.common.IResultInfo; | ||
| 21 | import com.topdraw.common.ResultInfo; | 23 | import com.topdraw.common.ResultInfo; |
| 22 | import com.topdraw.config.RedisKeyUtil; | 24 | import com.topdraw.config.RedisKeyUtil; |
| 23 | import com.topdraw.exception.BadRequestException; | 25 | import com.topdraw.exception.BadRequestException; |
| 26 | import com.topdraw.util.Base64Util; | ||
| 24 | import com.topdraw.util.JSONUtil; | 27 | import com.topdraw.util.JSONUtil; |
| 25 | import com.topdraw.utils.RedisUtils; | 28 | import com.topdraw.utils.RedisUtils; |
| 26 | import com.topdraw.utils.StringUtils; | 29 | import com.topdraw.utils.StringUtils; |
| 27 | import com.topdraw.weixin.util.WeChatConstants; | 30 | import com.topdraw.weixin.util.WeChatConstants; |
| 28 | import com.topdraw.weixin.util.WeiXinRequestUtil; | ||
| 29 | import com.topdraw.weixin.util.WeixinUtil; | 31 | import com.topdraw.weixin.util.WeixinUtil; |
| 30 | import io.swagger.annotations.Api; | 32 | import io.swagger.annotations.Api; |
| 31 | import io.swagger.annotations.ApiOperation; | 33 | import io.swagger.annotations.ApiOperation; |
| ... | @@ -37,6 +39,8 @@ import org.springframework.validation.annotation.Validated; | ... | @@ -37,6 +39,8 @@ import org.springframework.validation.annotation.Validated; |
| 37 | import org.springframework.web.bind.annotation.*; | 39 | import org.springframework.web.bind.annotation.*; |
| 38 | 40 | ||
| 39 | import java.io.IOException; | 41 | import java.io.IOException; |
| 42 | import java.net.URLDecoder; | ||
| 43 | import java.util.Base64; | ||
| 40 | import java.util.List; | 44 | import java.util.List; |
| 41 | import java.util.Map; | 45 | import java.util.Map; |
| 42 | import java.util.Objects; | 46 | import java.util.Objects; |
| ... | @@ -52,7 +56,9 @@ public class UserOperationController { | ... | @@ -52,7 +56,9 @@ public class UserOperationController { |
| 52 | @Autowired | 56 | @Autowired |
| 53 | private UserWeixinService userWeixinService; | 57 | private UserWeixinService userWeixinService; |
| 54 | @Autowired | 58 | @Autowired |
| 55 | private WeiXinRequestUtil weixinRequestUtil; | 59 | private UserTvService userTvService; |
| 60 | @Autowired | ||
| 61 | private MemberService memberService; | ||
| 56 | @Autowired | 62 | @Autowired |
| 57 | private RedisUtils redisUtils; | 63 | private RedisUtils redisUtils; |
| 58 | 64 | ||
| ... | @@ -134,23 +140,56 @@ public class UserOperationController { | ... | @@ -134,23 +140,56 @@ public class UserOperationController { |
| 134 | return ResultInfo.success(result); | 140 | return ResultInfo.success(result); |
| 135 | } | 141 | } |
| 136 | 142 | ||
| 137 | @PutMapping(value = "/unbind") | 143 | @RequestMapping(value = "/unbind") |
| 138 | @ApiOperation("大屏用户解绑") | 144 | @ApiOperation("大屏用户解绑") |
| 139 | @AnonymousAccess | 145 | @AnonymousAccess |
| 140 | public ResultInfo unbind(@Validated(value = {UnbindGroup.class}) @RequestBody TempIptvUser resources) { | 146 | public ResultInfo unbind(@Validated @RequestBody TempIptvUser resources) { |
| 141 | UserTv userTv = new UserTv(); | 147 | UserTv userTv = new UserTv(); |
| 142 | BeanUtils.copyProperties(resources,userTv); | 148 | BeanUtils.copyProperties(resources,userTv); |
| 149 | String unionid = resources.getUnionid(); | ||
| 150 | // Long memberId = resources.getMemberId(); | ||
| 151 | String memberCode1 = resources.getMemberCode(); | ||
| 152 | if (Objects.nonNull(memberCode1)) { | ||
| 153 | |||
| 154 | MemberDTO memberDTO = this.memberService.getByCode(memberCode1); | ||
| 155 | String memberCode = memberDTO.getCode(); | ||
| 156 | if (StringUtils.isNotBlank(memberCode)) { | ||
| 157 | userTv.setMemberCode(memberCode); | ||
| 143 | this.userTvOperationService.unbind(userTv); | 158 | this.userTvOperationService.unbind(userTv); |
| 159 | } | ||
| 160 | |||
| 161 | } else { | ||
| 162 | |||
| 163 | this.userTvOperationService.unbindByUnionId(userTv,unionid); | ||
| 164 | |||
| 165 | } | ||
| 166 | |||
| 144 | return ResultInfo.success(); | 167 | return ResultInfo.success(); |
| 145 | } | 168 | } |
| 146 | 169 | ||
| 147 | @PutMapping(value = "/changeMainAccount") | 170 | @RequestMapping(value = "/changeMainAccount") |
| 148 | @ApiOperation("大屏更换主账号") | 171 | @ApiOperation("大屏更换主账号") |
| 149 | @AnonymousAccess | 172 | @AnonymousAccess |
| 150 | public ResultInfo changeMainAccount(@Validated(value = {UnbindGroup.class}) @RequestBody TempIptvUser resources) { | 173 | public ResultInfo changeMainAccount(@Validated @RequestBody TempIptvUser resources) { |
| 151 | UserTv userTv = new UserTv(); | 174 | UserTv userTv = new UserTv(); |
| 152 | BeanUtils.copyProperties(resources,userTv); | 175 | BeanUtils.copyProperties(resources,userTv); |
| 176 | Long memberId = resources.getMemberId(); | ||
| 177 | String memberCode1 = resources.getMemberCode(); | ||
| 178 | if (Objects.nonNull(memberCode1)) { | ||
| 179 | |||
| 180 | MemberDTO memberDTO = this.memberService.getByCode(memberCode1); | ||
| 181 | |||
| 182 | String memberCode = memberDTO.getCode(); | ||
| 183 | if (StringUtils.isNotBlank(memberCode)) { | ||
| 184 | userTv.setMemberCode(memberCode); | ||
| 153 | this.userTvOperationService.changeMainAccount(userTv); | 185 | this.userTvOperationService.changeMainAccount(userTv); |
| 186 | } | ||
| 187 | |||
| 188 | } else { | ||
| 189 | String unionid = resources.getUnionid(); | ||
| 190 | this.userTvOperationService.changeMainAccountByUnionId(userTv,unionid); | ||
| 191 | } | ||
| 192 | |||
| 154 | return ResultInfo.success("update success"); | 193 | return ResultInfo.success("update success"); |
| 155 | } | 194 | } |
| 156 | 195 | ||
| ... | @@ -166,6 +205,7 @@ public class UserOperationController { | ... | @@ -166,6 +205,7 @@ public class UserOperationController { |
| 166 | @ApiOperation("微信小程序登录") | 205 | @ApiOperation("微信小程序登录") |
| 167 | @AnonymousAccess | 206 | @AnonymousAccess |
| 168 | public ResultInfo appletLogin(@Validated @RequestBody WeiXinUserBean resources) { | 207 | public ResultInfo appletLogin(@Validated @RequestBody WeiXinUserBean resources) { |
| 208 | |||
| 169 | UserWeixinDTO result = this.userTvOperationService.appletLogin(resources); | 209 | UserWeixinDTO result = this.userTvOperationService.appletLogin(resources); |
| 170 | return ResultInfo.success(result); | 210 | return ResultInfo.success(result); |
| 171 | } | 211 | } |
| ... | @@ -178,9 +218,13 @@ public class UserOperationController { | ... | @@ -178,9 +218,13 @@ public class UserOperationController { |
| 178 | if (StringUtils.isBlank(unionId)) | 218 | if (StringUtils.isBlank(unionId)) |
| 179 | Assert.state(StrUtil.isNotBlank(unionId), "跨屏绑定,请先进行授权"); | 219 | Assert.state(StrUtil.isNotBlank(unionId), "跨屏绑定,请先进行授权"); |
| 180 | 220 | ||
| 181 | Long platformUserId = resources.getPlatformUserId(); | 221 | String platformAccount = resources.getPlatformAccount(); |
| 182 | if (Objects.isNull(platformUserId)) | 222 | if (Objects.isNull(platformAccount)) |
| 183 | Assert.state(StrUtil.isNotBlank(unionId), "大屏id不得为空"); | 223 | Assert.state(StrUtil.isNotBlank(platformAccount), "大屏账户不得为空"); |
| 224 | |||
| 225 | UserTvDTO userTvDTO = this.userTvService.findByPlatformAccount(platformAccount); | ||
| 226 | resources.setPlatformUserId(userTvDTO.getId()); | ||
| 227 | resources.setPlatformAccount(platformAccount); | ||
| 184 | 228 | ||
| 185 | boolean result = this.userTvOperationService.appletBind(resources); | 229 | boolean result = this.userTvOperationService.appletBind(resources); |
| 186 | return ResultInfo.success(result); | 230 | return ResultInfo.success(result); |
| ... | @@ -190,12 +234,9 @@ public class UserOperationController { | ... | @@ -190,12 +234,9 @@ public class UserOperationController { |
| 190 | @ApiOperation("微信公众号关注") | 234 | @ApiOperation("微信公众号关注") |
| 191 | @AnonymousAccess | 235 | @AnonymousAccess |
| 192 | public ResultInfo subscribe(@Validated @RequestBody SubscribeBeanEvent data) throws IOException { | 236 | public ResultInfo subscribe(@Validated @RequestBody SubscribeBeanEvent data) throws IOException { |
| 193 | |||
| 194 | String content = data.getContent(); | 237 | String content = data.getContent(); |
| 195 | SubscribeBean subscribeBean = JSONUtil.parseMsg2Object(content, SubscribeBean.class); | 238 | SubscribeBean subscribeBean = JSONUtil.parseMsg2Object(content, SubscribeBean.class); |
| 196 | |||
| 197 | this.parseSubscribe(subscribeBean); | 239 | this.parseSubscribe(subscribeBean); |
| 198 | |||
| 199 | boolean result = this.userTvOperationService.subscribe(subscribeBean); | 240 | boolean result = this.userTvOperationService.subscribe(subscribeBean); |
| 200 | return ResultInfo.success(result); | 241 | return ResultInfo.success(result); |
| 201 | } | 242 | } |
| ... | @@ -209,18 +250,20 @@ public class UserOperationController { | ... | @@ -209,18 +250,20 @@ public class UserOperationController { |
| 209 | private void parseSubscribe(SubscribeBean subscribeBean) throws IOException { | 250 | private void parseSubscribe(SubscribeBean subscribeBean) throws IOException { |
| 210 | if (Objects.nonNull(subscribeBean)) { | 251 | if (Objects.nonNull(subscribeBean)) { |
| 211 | 252 | ||
| 212 | String appId = subscribeBean.getAppid(); | 253 | String appId = subscribeBean.getAppId(); |
| 213 | // appId不得为空 | 254 | // appId不得为空 |
| 214 | if (StringUtils.isBlank(appId)) | 255 | if (StringUtils.isBlank(appId)) |
| 215 | throw new BadRequestException("appId 不存在!"); | 256 | throw new BadRequestException("appId 不存在!"); |
| 216 | 257 | ||
| 217 | // openId | 258 | // openId |
| 218 | String openId = subscribeBean.getOpenid(); | 259 | String openId = subscribeBean.getOpenId(); |
| 219 | if (StringUtils.isBlank(openId)) | 260 | if (StringUtils.isBlank(openId)) |
| 220 | throw new BadRequestException("openId 不存在!"); | 261 | throw new BadRequestException("openId 不存在!"); |
| 221 | 262 | ||
| 222 | // unionId | 263 | // unionId |
| 223 | String unionId = null; | 264 | String unionId = subscribeBean.getUnionid(); |
| 265 | if (StringUtils.isBlank(unionId)) | ||
| 266 | throw new BadRequestException("unionId 不存在!"); | ||
| 224 | 267 | ||
| 225 | // 匹配配置文件中的微信列表信息 | 268 | // 匹配配置文件中的微信列表信息 |
| 226 | Map<String, String> wxInfoMap = WeixinUtil.getWeixinInfoByAppid(appId); | 269 | Map<String, String> wxInfoMap = WeixinUtil.getWeixinInfoByAppid(appId); |
| ... | @@ -231,23 +274,8 @@ public class UserOperationController { | ... | @@ -231,23 +274,8 @@ public class UserOperationController { |
| 231 | // 非订阅号,暂不处理。返回暂不支持 | 274 | // 非订阅号,暂不处理。返回暂不支持 |
| 232 | if (ObjectUtil.notEqual(appType, WeChatConstants.WX_SUBSCRIPTION)) | 275 | if (ObjectUtil.notEqual(appType, WeChatConstants.WX_SUBSCRIPTION)) |
| 233 | throw new BadRequestException("非订阅号"); | 276 | throw new BadRequestException("非订阅号"); |
| 234 | |||
| 235 | UserWeixinDTO userWeixinDTO = this.userWeixinService.findFirstByAppIdAndOpenId(appId, openId); | ||
| 236 | if (Objects.nonNull(userWeixinDTO.getId())) { | ||
| 237 | unionId = userWeixinDTO.getUnionid(); | ||
| 238 | } else { | ||
| 239 | JSONObject userInfo = this.weixinRequestUtil.getUserInfo(wxInfoMap, openId); | ||
| 240 | unionId = userInfo.getString("unionid"); | ||
| 241 | } | 277 | } |
| 242 | 278 | ||
| 243 | } | ||
| 244 | |||
| 245 | // unionId不得为空 | ||
| 246 | if (StringUtils.isBlank(unionId)) | ||
| 247 | throw new BadRequestException("unionId 不存在!"); | ||
| 248 | |||
| 249 | subscribeBean.setUnionid(unionId); | ||
| 250 | |||
| 251 | // 大屏账户信息 | 279 | // 大屏账户信息 |
| 252 | JSONObject iptvUserInfo = null; | 280 | JSONObject iptvUserInfo = null; |
| 253 | // 缓存的大屏信息,使用unionid即可 | 281 | // 缓存的大屏信息,使用unionid即可 |
| ... | @@ -255,7 +283,6 @@ public class UserOperationController { | ... | @@ -255,7 +283,6 @@ public class UserOperationController { |
| 255 | if (StringUtils.isNotBlank(content)) { | 283 | if (StringUtils.isNotBlank(content)) { |
| 256 | // 大屏信息 | 284 | // 大屏信息 |
| 257 | iptvUserInfo = JSONObject.parseObject(content); | 285 | iptvUserInfo = JSONObject.parseObject(content); |
| 258 | |||
| 259 | } else { | 286 | } else { |
| 260 | 287 | ||
| 261 | String eventKey = subscribeBean.getEventKey(); | 288 | String eventKey = subscribeBean.getEventKey(); |
| ... | @@ -272,6 +299,20 @@ public class UserOperationController { | ... | @@ -272,6 +299,20 @@ public class UserOperationController { |
| 272 | // 用户自己搜索关注就没有大屏信息的话,否则表示扫码关注 | 299 | // 用户自己搜索关注就没有大屏信息的话,否则表示扫码关注 |
| 273 | if (Objects.nonNull(iptvUserInfo)) { | 300 | if (Objects.nonNull(iptvUserInfo)) { |
| 274 | subscribeBean.setIptvUserInfo(iptvUserInfo); | 301 | subscribeBean.setIptvUserInfo(iptvUserInfo); |
| 302 | |||
| 303 | String headimgurl = iptvUserInfo.get("headimgurl").toString(); | ||
| 304 | String nickname = iptvUserInfo.get("nickname").toString(); | ||
| 305 | if (org.apache.commons.lang3.StringUtils.isNotBlank(nickname)) { | ||
| 306 | String nicknameDecode = URLDecoder.decode(nickname, "UTF-8"); | ||
| 307 | String nicknameEncode = Base64Util.encode(nicknameDecode); | ||
| 308 | subscribeBean.setNickname(nicknameEncode); | ||
| 309 | } | ||
| 310 | |||
| 311 | if (org.apache.commons.lang3.StringUtils.isNotBlank(headimgurl)) { | ||
| 312 | String headimgurlDecode = URLDecoder.decode(headimgurl, "UTF-8"); | ||
| 313 | subscribeBean.setHeadimgurl(headimgurlDecode); | ||
| 314 | } | ||
| 315 | |||
| 275 | } | 316 | } |
| 276 | 317 | ||
| 277 | } | 318 | } |
| ... | @@ -282,6 +323,8 @@ public class UserOperationController { | ... | @@ -282,6 +323,8 @@ public class UserOperationController { |
| 282 | @AnonymousAccess | 323 | @AnonymousAccess |
| 283 | public ResultInfo unsubscribe(@Validated @RequestBody SubscribeBeanEvent data) { | 324 | public ResultInfo unsubscribe(@Validated @RequestBody SubscribeBeanEvent data) { |
| 284 | String content = data.getContent(); | 325 | String content = data.getContent(); |
| 326 | log.info("content ==>> [{}]",content); | ||
| 327 | |||
| 285 | SubscribeBean subscribeBean = JSONUtil.parseMsg2Object(content, SubscribeBean.class); | 328 | SubscribeBean subscribeBean = JSONUtil.parseMsg2Object(content, SubscribeBean.class); |
| 286 | boolean result = this.userTvOperationService.unsubscribe(subscribeBean); | 329 | boolean result = this.userTvOperationService.unsubscribe(subscribeBean); |
| 287 | return ResultInfo.success(result); | 330 | return ResultInfo.success(result); |
| ... | @@ -310,7 +353,6 @@ public class UserOperationController { | ... | @@ -310,7 +353,6 @@ public class UserOperationController { |
| 310 | String unionid = json.getString("unionid"); | 353 | String unionid = json.getString("unionid"); |
| 311 | Assert.state(StrUtil.isNotBlank(unionid), "unionid不可为空"); | 354 | Assert.state(StrUtil.isNotBlank(unionid), "unionid不可为空"); |
| 312 | 355 | ||
| 313 | log.info("resources :[{}]",data); | ||
| 314 | String s = this.userTvOperationService.saveUserInfo(data); | 356 | String s = this.userTvOperationService.saveUserInfo(data); |
| 315 | 357 | ||
| 316 | return ResultInfo.success(s); | 358 | return ResultInfo.success(s); |
| ... | @@ -320,7 +362,6 @@ public class UserOperationController { | ... | @@ -320,7 +362,6 @@ public class UserOperationController { |
| 320 | @ApiOperation("保存用户手机号信息") | 362 | @ApiOperation("保存用户手机号信息") |
| 321 | @AnonymousAccess | 363 | @AnonymousAccess |
| 322 | public ResultInfo saveUserWeixinPhone(@RequestBody WeiXinUserBean resources) { | 364 | public ResultInfo saveUserWeixinPhone(@RequestBody WeiXinUserBean resources) { |
| 323 | log.info("resources :[{}]",resources); | ||
| 324 | MemberProfile s = this.userTvOperationService.saveUserWeixinPhone(resources); | 365 | MemberProfile s = this.userTvOperationService.saveUserWeixinPhone(resources); |
| 325 | return ResultInfo.success(s); | 366 | return ResultInfo.success(s); |
| 326 | } | 367 | } | ... | ... |
| ... | @@ -30,12 +30,26 @@ public interface UserOperationService { | ... | @@ -30,12 +30,26 @@ public interface UserOperationService { |
| 30 | void unbind(UserTv userTv); | 30 | void unbind(UserTv userTv); |
| 31 | 31 | ||
| 32 | /** | 32 | /** |
| 33 | * | ||
| 34 | * @param userTv | ||
| 35 | * @param unionId | ||
| 36 | */ | ||
| 37 | void unbindByUnionId(UserTv userTv,String unionId); | ||
| 38 | |||
| 39 | /** | ||
| 33 | * 大屏切换主账户(会员) | 40 | * 大屏切换主账户(会员) |
| 34 | * @param userTv | 41 | * @param userTv |
| 35 | */ | 42 | */ |
| 36 | void changeMainAccount(UserTv userTv); | 43 | void changeMainAccount(UserTv userTv); |
| 37 | 44 | ||
| 38 | /** | 45 | /** |
| 46 | * | ||
| 47 | * @param userTv | ||
| 48 | * @param unionId | ||
| 49 | */ | ||
| 50 | void changeMainAccountByUnionId(UserTv userTv,String unionId); | ||
| 51 | |||
| 52 | /** | ||
| 39 | * 微信小程序登录 | 53 | * 微信小程序登录 |
| 40 | * @param resources | 54 | * @param resources |
| 41 | * @return | 55 | * @return | ... | ... |
| 1 | package com.topdraw.business.process.service.impl; | 1 | package com.topdraw.business.process.service.impl; |
| 2 | 2 | ||
| 3 | import com.topdraw.aspect.AsyncMqSend; | ||
| 3 | import com.topdraw.business.module.coupon.history.domain.CouponHistory; | 4 | import com.topdraw.business.module.coupon.history.domain.CouponHistory; |
| 4 | import com.topdraw.business.module.coupon.history.service.CouponHistoryService; | 5 | import com.topdraw.business.module.coupon.history.service.CouponHistoryService; |
| 5 | import com.topdraw.business.module.coupon.service.CouponService; | 6 | import com.topdraw.business.module.coupon.service.CouponService; |
| ... | @@ -51,6 +52,7 @@ public class CouponOperationServiceImpl implements CouponOperationService { | ... | @@ -51,6 +52,7 @@ public class CouponOperationServiceImpl implements CouponOperationService { |
| 51 | private static final Integer EXPIRE_FACTOR_DAY = 30; | 52 | private static final Integer EXPIRE_FACTOR_DAY = 30; |
| 52 | 53 | ||
| 53 | @Override | 54 | @Override |
| 55 | @AsyncMqSend | ||
| 54 | public void grantCouponThroughTempCoupon(List<TempCoupon> tempCouponList) { | 56 | public void grantCouponThroughTempCoupon(List<TempCoupon> tempCouponList) { |
| 55 | // 优惠券领取、使用历史记录表 | 57 | // 优惠券领取、使用历史记录表 |
| 56 | for (TempCoupon tempCoupon : tempCouponList) { | 58 | for (TempCoupon tempCoupon : tempCouponList) { | ... | ... |
| 1 | package com.topdraw.business.process.service.impl; | 1 | package com.topdraw.business.process.service.impl; |
| 2 | 2 | ||
| 3 | import com.topdraw.aspect.AsyncMqSend; | ||
| 3 | import com.topdraw.business.module.exp.detail.domain.ExpDetail; | 4 | import com.topdraw.business.module.exp.detail.domain.ExpDetail; |
| 4 | import com.topdraw.business.module.exp.detail.service.ExpDetailService; | 5 | import com.topdraw.business.module.exp.detail.service.ExpDetailService; |
| 5 | import com.topdraw.business.module.member.domain.Member; | 6 | import com.topdraw.business.module.member.domain.Member; |
| ... | @@ -50,6 +51,7 @@ public class ExpOperationServiceImpl implements ExpOperationService { | ... | @@ -50,6 +51,7 @@ public class ExpOperationServiceImpl implements ExpOperationService { |
| 50 | ThreadPoolTaskExecutor threadPoolTaskExecutor; | 51 | ThreadPoolTaskExecutor threadPoolTaskExecutor; |
| 51 | 52 | ||
| 52 | @Override | 53 | @Override |
| 54 | @AsyncMqSend | ||
| 53 | public void grantPointsThroughTempExp(List<TempExp> tempExpList) { | 55 | public void grantPointsThroughTempExp(List<TempExp> tempExpList) { |
| 54 | 56 | ||
| 55 | for (TempExp tempExp : tempExpList) { | 57 | for (TempExp tempExp : tempExpList) { | ... | ... |
| ... | @@ -52,33 +52,45 @@ public class MemberOperationServiceImpl implements MemberOperationService { | ... | @@ -52,33 +52,45 @@ public class MemberOperationServiceImpl implements MemberOperationService { |
| 52 | 52 | ||
| 53 | @Override | 53 | @Override |
| 54 | public MemberDTO buyVip(BuyVipBean criteria) { | 54 | public MemberDTO buyVip(BuyVipBean criteria) { |
| 55 | // 小程序账户id | ||
| 56 | Long id = criteria.getId(); | ||
| 55 | 57 | ||
| 56 | // 查询微信账户 | 58 | // 过期时间 |
| 57 | UserWeixinDTO userWeixin = this.findWeiXinById(criteria.getId()); | 59 | LocalDateTime vipExpireTime1 = criteria.getVipExpireTime(); |
| 58 | 60 | Integer vip1 = criteria.getVip(); | |
| 59 | 61 | ||
| 62 | // 查询微信账户 | ||
| 63 | UserWeixinDTO userWeixin = this.findWeiXinById(id); | ||
| 60 | Long memberId = userWeixin.getMemberId(); | 64 | Long memberId = userWeixin.getMemberId(); |
| 61 | 65 | ||
| 66 | // | ||
| 62 | MemberDTO memberDTO = this.findById(memberId); | 67 | MemberDTO memberDTO = this.findById(memberId); |
| 63 | |||
| 64 | Integer vip = memberDTO.getVip(); | 68 | Integer vip = memberDTO.getVip(); |
| 65 | 69 | ||
| 66 | MemberVipHistory memberVipHistory = new MemberVipHistory(); | 70 | // |
| 67 | memberVipHistory.setMemberId(memberId).setVip(criteria.getVip()).setBeforeVip(vip); | 71 | LocalDateTime vipExpireTime = memberDTO.getVipExpireTime(); |
| 68 | if (ObjectUtil.equal(criteria.getVip(),vip)) { | 72 | if (Objects.nonNull(vipExpireTime1)) { |
| 69 | memberVipHistory.setStatus(1); | 73 | vipExpireTime = vipExpireTime1; |
| 70 | } | 74 | } |
| 71 | 75 | ||
| 72 | LocalDateTime vipExpireTime = memberDTO.getVipExpireTime(); | ||
| 73 | LocalDateTime now = LocalDateTime.now(); | ||
| 74 | //判断之前有没有买过,没买过,失效时间为一年后; | 76 | //判断之前有没有买过,没买过,失效时间为一年后; |
| 77 | if (Objects.isNull(vipExpireTime1)) { | ||
| 75 | if (ObjectUtil.isNull(vipExpireTime)) { | 78 | if (ObjectUtil.isNull(vipExpireTime)) { |
| 76 | LocalDateTime localDateTime = now.plusYears(1L); | 79 | LocalDateTime now = LocalDateTime.now(); |
| 77 | memberDTO.setVipExpireTime(localDateTime); | 80 | vipExpireTime = now.plusYears(1L); |
| 78 | } else { | 81 | } else { |
| 82 | vipExpireTime = vipExpireTime.plusYears(1L); | ||
| 83 | } | ||
| 84 | |||
| 85 | } | ||
| 86 | |||
| 87 | memberDTO.setVip(vip1); | ||
| 88 | memberDTO.setVipExpireTime(vipExpireTime); | ||
| 89 | |||
| 90 | /*if (){ | ||
| 79 | //购买过 判断当前时间有没有过vip过期时间,没有过,失效时间加一年; 过了,当前时间加一年 | 91 | //购买过 判断当前时间有没有过vip过期时间,没有过,失效时间加一年; 过了,当前时间加一年 |
| 80 | //区分是当前vip续费 还是买新的vip | 92 | //区分是当前vip续费 还是买新的vip |
| 81 | if (ObjectUtil.equal(criteria.getVip(), memberDTO.getVip())) { | 93 | if (ObjectUtil.equal(vip1, memberDTO.getVip())) { |
| 82 | if (now.isBefore(vipExpireTime)) { | 94 | if (now.isBefore(vipExpireTime)) { |
| 83 | LocalDateTime localDateTime = vipExpireTime.plusYears(1L); | 95 | LocalDateTime localDateTime = vipExpireTime.plusYears(1L); |
| 84 | memberDTO.setVipExpireTime(localDateTime); | 96 | memberDTO.setVipExpireTime(localDateTime); |
| ... | @@ -90,12 +102,17 @@ public class MemberOperationServiceImpl implements MemberOperationService { | ... | @@ -90,12 +102,17 @@ public class MemberOperationServiceImpl implements MemberOperationService { |
| 90 | LocalDateTime localDateTime = now.plusYears(1L); | 102 | LocalDateTime localDateTime = now.plusYears(1L); |
| 91 | memberDTO.setVipExpireTime(localDateTime); | 103 | memberDTO.setVipExpireTime(localDateTime); |
| 92 | } | 104 | } |
| 93 | } | 105 | }*/ |
| 94 | memberDTO.setVip(criteria.getVip()); | ||
| 95 | 106 | ||
| 96 | Member member = new Member(); | 107 | Member member = new Member(); |
| 97 | BeanUtils.copyProperties(memberDTO,member); | 108 | BeanUtils.copyProperties(memberDTO,member); |
| 98 | this.memberService.create(member); | 109 | this.memberService.create(member); |
| 110 | |||
| 111 | MemberVipHistory memberVipHistory = new MemberVipHistory(); | ||
| 112 | memberVipHistory.setMemberId(memberId).setVip(vip1).setBeforeVip(vip); | ||
| 113 | if (ObjectUtil.equal(vip1,vip)) { | ||
| 114 | memberVipHistory.setStatus(1); | ||
| 115 | } | ||
| 99 | memberVipHistory.setVipExpireTime(member.getVipExpireTime()); | 116 | memberVipHistory.setVipExpireTime(member.getVipExpireTime()); |
| 100 | memberVipHistoryService.create(memberVipHistory); | 117 | memberVipHistoryService.create(memberVipHistory); |
| 101 | 118 | ... | ... |
| ... | @@ -296,6 +296,7 @@ public class PointsOperationServiceImpl implements PointsOperationService { | ... | @@ -296,6 +296,7 @@ public class PointsOperationServiceImpl implements PointsOperationService { |
| 296 | */ | 296 | */ |
| 297 | @Override | 297 | @Override |
| 298 | @Transactional(rollbackFor = Exception.class) | 298 | @Transactional(rollbackFor = Exception.class) |
| 299 | @AsyncMqSend() | ||
| 299 | public void grantPointsThroughTempRightsList(List<TempPoints> tempPointsList){ | 300 | public void grantPointsThroughTempRightsList(List<TempPoints> tempPointsList){ |
| 300 | log.info("------->>grantPointsThroughTempRightsList start1"); | 301 | log.info("------->>grantPointsThroughTempRightsList start1"); |
| 301 | for (TempPoints tempPoints : tempPointsList){ | 302 | for (TempPoints tempPoints : tempPointsList){ | ... | ... |
| ... | @@ -102,6 +102,8 @@ public class RightsOperationServiceImpl implements RightsOperationService { | ... | @@ -102,6 +102,8 @@ public class RightsOperationServiceImpl implements RightsOperationService { |
| 102 | rightsHistory.setRightsId(value.getId()); | 102 | rightsHistory.setRightsId(value.getId()); |
| 103 | rightsHistory.setMemberId(value.getMemberId()); | 103 | rightsHistory.setMemberId(value.getMemberId()); |
| 104 | rightsHistory.setExpireTime(value.getExpireTime()); | 104 | rightsHistory.setExpireTime(value.getExpireTime()); |
| 105 | String memberCode = value.getMemberCode(); | ||
| 106 | rightsHistory.setMemberCode(memberCode); | ||
| 105 | rightsHistoryList.add(rightsHistory); | 107 | rightsHistoryList.add(rightsHistory); |
| 106 | }); | 108 | }); |
| 107 | 109 | ||
| ... | @@ -123,9 +125,7 @@ public class RightsOperationServiceImpl implements RightsOperationService { | ... | @@ -123,9 +125,7 @@ public class RightsOperationServiceImpl implements RightsOperationService { |
| 123 | * @param tempPointsList 权益列表 | 125 | * @param tempPointsList 权益列表 |
| 124 | */ | 126 | */ |
| 125 | private void grantPoint(List<TempPoints> tempPointsList) { | 127 | private void grantPoint(List<TempPoints> tempPointsList) { |
| 126 | log.info(Thread.currentThread().getName() + "=========>>grantPoint start"); | ||
| 127 | if (!CollectionUtils.isEmpty(tempPointsList)) | 128 | if (!CollectionUtils.isEmpty(tempPointsList)) |
| 128 | log.info("=======>> tempPointsList ======>> " + tempPointsList.toString()); | ||
| 129 | this.pointsOperationService.grantPointsThroughTempRightsList(tempPointsList); | 129 | this.pointsOperationService.grantPointsThroughTempRightsList(tempPointsList); |
| 130 | } | 130 | } |
| 131 | 131 | ... | ... |
| ... | @@ -99,7 +99,12 @@ public class TaskOperationServiceImpl implements TaskOperationService { | ... | @@ -99,7 +99,12 @@ public class TaskOperationServiceImpl implements TaskOperationService { |
| 99 | DataSyncMsg dataSyncMsg = JSONUtil.parseMsg2Object(content, DataSyncMsg.class); | 99 | DataSyncMsg dataSyncMsg = JSONUtil.parseMsg2Object(content, DataSyncMsg.class); |
| 100 | DataSyncMsg.MsgData msgData = dataSyncMsg.getMsg(); | 100 | DataSyncMsg.MsgData msgData = dataSyncMsg.getMsg(); |
| 101 | Integer event = msgData.getEvent(); | 101 | Integer event = msgData.getEvent(); |
| 102 | String memberCode = msgData.getMemberCode(); | ||
| 102 | Long memberId = msgData.getMemberId(); | 103 | Long memberId = msgData.getMemberId(); |
| 104 | if (StringUtils.hasText(memberCode)) { | ||
| 105 | MemberDTO memberDTO = this.memberService.getByCode(memberCode); | ||
| 106 | memberId = memberDTO.getId(); | ||
| 107 | } | ||
| 103 | 108 | ||
| 104 | // 检查当前会员的黑名单状态 | 109 | // 检查当前会员的黑名单状态 |
| 105 | boolean b = this.validatedMemberBlackStatus(memberId); | 110 | boolean b = this.validatedMemberBlackStatus(memberId); |
| ... | @@ -138,7 +143,7 @@ public class TaskOperationServiceImpl implements TaskOperationService { | ... | @@ -138,7 +143,7 @@ public class TaskOperationServiceImpl implements TaskOperationService { |
| 138 | * @return | 143 | * @return |
| 139 | */ | 144 | */ |
| 140 | private boolean checkRiskManagement(Long memberId , Map<RightType, Object> tempRightsMap) { | 145 | private boolean checkRiskManagement(Long memberId , Map<RightType, Object> tempRightsMap) { |
| 141 | 146 | // TODO 风控 | |
| 142 | return false; | 147 | return false; |
| 143 | } | 148 | } |
| 144 | 149 | ||
| ... | @@ -160,40 +165,6 @@ public class TaskOperationServiceImpl implements TaskOperationService { | ... | @@ -160,40 +165,6 @@ public class TaskOperationServiceImpl implements TaskOperationService { |
| 160 | } | 165 | } |
| 161 | 166 | ||
| 162 | /** | 167 | /** |
| 163 | * 永久权益 | ||
| 164 | * @param memberId 会员id | ||
| 165 | * @return PermanentRightsDTO 永久权益 | ||
| 166 | */ | ||
| 167 | @Deprecated | ||
| 168 | private PermanentRightsDTO getPermanentRights(Long memberId) { | ||
| 169 | PermanentRightsDTO permanentRights = null; | ||
| 170 | MemberDTO memberDTO = this.memberService.findById(memberId); | ||
| 171 | if (Objects.nonNull(memberDTO)) { | ||
| 172 | Integer level = memberDTO.getLevel(); | ||
| 173 | // 永久权益 | ||
| 174 | permanentRights = this.permanentRightsService.findByLevel(level); | ||
| 175 | } | ||
| 176 | return permanentRights; | ||
| 177 | } | ||
| 178 | |||
| 179 | /** | ||
| 180 | * 解析模板参数 | ||
| 181 | * @param taskTemplate 任务模板 | ||
| 182 | * @return Map<String, Object> 模板参数解析结果 | ||
| 183 | */ | ||
| 184 | @Deprecated | ||
| 185 | private Map<String, Object> parseTaskTemplateParam(TaskTemplate taskTemplate) { | ||
| 186 | if (Objects.nonNull(taskTemplate)) { | ||
| 187 | String params = taskTemplate.getParams(); | ||
| 188 | if (!StringUtils.isEmpty(params)) { | ||
| 189 | Map paramMap = JSONObject.parseObject(params,Map.class); | ||
| 190 | return paramMap; | ||
| 191 | } | ||
| 192 | } | ||
| 193 | return null; | ||
| 194 | } | ||
| 195 | |||
| 196 | /** | ||
| 197 | * 任务完成情况 | 168 | * 任务完成情况 |
| 198 | * @param resources 任务完成情况 | 169 | * @param resources 任务完成情况 |
| 199 | */ | 170 | */ |
| ... | @@ -320,13 +291,15 @@ public class TaskOperationServiceImpl implements TaskOperationService { | ... | @@ -320,13 +291,15 @@ public class TaskOperationServiceImpl implements TaskOperationService { |
| 320 | /** | 291 | /** |
| 321 | * 创建权益 | 292 | * 创建权益 |
| 322 | * @param memberId | 293 | * @param memberId |
| 294 | * @param memberCode | ||
| 323 | * @param rightsAmount | 295 | * @param rightsAmount |
| 324 | * @return | 296 | * @return |
| 325 | */ | 297 | */ |
| 326 | private TempRights tmpRightsBuild(Long memberId ,Integer rightsAmount,RightsDTO rightsDTO){ | 298 | private TempRights tmpRightsBuild(Long memberId ,String memberCode,Integer rightsAmount,RightsDTO rightsDTO){ |
| 327 | TempRights tempRights = new TempRights(); | 299 | TempRights tempRights = new TempRights(); |
| 328 | BeanUtils.copyProperties(rightsDTO,tempRights); | 300 | BeanUtils.copyProperties(rightsDTO,tempRights); |
| 329 | tempRights.setMemberId(memberId); | 301 | tempRights.setMemberId(memberId); |
| 302 | tempRights.setMemberCode(memberCode); | ||
| 330 | tempRights.setRightsAmount(rightsAmount); | 303 | tempRights.setRightsAmount(rightsAmount); |
| 331 | Long expireTime = rightsDTO.getExpireTime(); | 304 | Long expireTime = rightsDTO.getExpireTime(); |
| 332 | if (Objects.nonNull(expireTime)) | 305 | if (Objects.nonNull(expireTime)) |
| ... | @@ -337,14 +310,15 @@ public class TaskOperationServiceImpl implements TaskOperationService { | ... | @@ -337,14 +310,15 @@ public class TaskOperationServiceImpl implements TaskOperationService { |
| 337 | /** | 310 | /** |
| 338 | * 优惠券 | 311 | * 优惠券 |
| 339 | * @param memberId | 312 | * @param memberId |
| 340 | * @param rightsAmount | 313 | * @param memberCode |
| 341 | * @param rightsSendStrategy | 314 | * @param rightsSendStrategy |
| 342 | * @return | 315 | * @return |
| 343 | */ | 316 | */ |
| 344 | private TempCoupon tempCouponBuild(Long memberId ,Integer rightsAmount,Integer rightsSendStrategy,CouponDTO couponDTO,String nickname){ | 317 | private TempCoupon tempCouponBuild(Long memberId ,String memberCode , Integer rightsAmount,Integer rightsSendStrategy,CouponDTO couponDTO,String nickname){ |
| 345 | TempCoupon tempCoupon = new TempCoupon(); | 318 | TempCoupon tempCoupon = new TempCoupon(); |
| 346 | BeanUtils.copyProperties(couponDTO,tempCoupon); | 319 | BeanUtils.copyProperties(couponDTO,tempCoupon); |
| 347 | tempCoupon.setCode(couponDTO.getCode()); | 320 | tempCoupon.setCode(couponDTO.getCode()); |
| 321 | tempCoupon.setMemberCode(memberCode); | ||
| 348 | tempCoupon.setMemberId(memberId); | 322 | tempCoupon.setMemberId(memberId); |
| 349 | tempCoupon.setRightsAmount(rightsAmount); | 323 | tempCoupon.setRightsAmount(rightsAmount); |
| 350 | tempCoupon.setRightsSendStrategy(Objects.isNull(rightsSendStrategy) ? 0 : rightsSendStrategy); | 324 | tempCoupon.setRightsSendStrategy(Objects.isNull(rightsSendStrategy) ? 0 : rightsSendStrategy); |
| ... | @@ -426,12 +400,13 @@ public class TaskOperationServiceImpl implements TaskOperationService { | ... | @@ -426,12 +400,13 @@ public class TaskOperationServiceImpl implements TaskOperationService { |
| 426 | 400 | ||
| 427 | Long memberId = memberDTO.getId(); | 401 | Long memberId = memberDTO.getId(); |
| 428 | String nickname = memberDTO.getNickname(); | 402 | String nickname = memberDTO.getNickname(); |
| 403 | String memberCode = memberDTO.getCode(); | ||
| 429 | // 权益详情 | 404 | // 权益详情 |
| 430 | RightsDTO rightsDTO = this.getRight(rightsId); | 405 | RightsDTO rightsDTO = this.getRight(rightsId); |
| 431 | 406 | ||
| 432 | if (Objects.nonNull(rightsDTO)){ | 407 | if (Objects.nonNull(rightsDTO)){ |
| 433 | // 用以保存权益历史 | 408 | // 用以保存权益历史 |
| 434 | TempRights tempRights = this.tmpRightsBuild(memberId,rightsAmount,rightsDTO); | 409 | TempRights tempRights = this.tmpRightsBuild(memberId,memberCode,rightsAmount,rightsDTO); |
| 435 | rightsList.add(tempRights); | 410 | rightsList.add(tempRights); |
| 436 | 411 | ||
| 437 | // 权益类型 | 412 | // 权益类型 |
| ... | @@ -443,7 +418,7 @@ public class TaskOperationServiceImpl implements TaskOperationService { | ... | @@ -443,7 +418,7 @@ public class TaskOperationServiceImpl implements TaskOperationService { |
| 443 | CouponDTO couponDTO = this.findCouponById(entityId); | 418 | CouponDTO couponDTO = this.findCouponById(entityId); |
| 444 | if (Objects.nonNull(couponDTO)) { | 419 | if (Objects.nonNull(couponDTO)) { |
| 445 | // 优惠券 | 420 | // 优惠券 |
| 446 | TempCoupon tempCoupon = this.tempCouponBuild(memberId, rightsAmount, rightsSendStrategy, couponDTO, nickname); | 421 | TempCoupon tempCoupon = this.tempCouponBuild(memberId, memberCode,rightsAmount, rightsSendStrategy, couponDTO, nickname); |
| 447 | tempCouponList.add(tempCoupon); | 422 | tempCouponList.add(tempCoupon); |
| 448 | } | 423 | } |
| 449 | } | 424 | } |
| ... | @@ -484,6 +459,7 @@ public class TaskOperationServiceImpl implements TaskOperationService { | ... | @@ -484,6 +459,7 @@ public class TaskOperationServiceImpl implements TaskOperationService { |
| 484 | tempExp.setMemberId(memberId); | 459 | tempExp.setMemberId(memberId); |
| 485 | tempExp.setAppCode(msgData.getAppCode()); | 460 | tempExp.setAppCode(msgData.getAppCode()); |
| 486 | tempExp.setMemberId(msgData.getMemberId()); | 461 | tempExp.setMemberId(msgData.getMemberId()); |
| 462 | tempExp.setMemberCode(msgData.getMemberCode()); | ||
| 487 | tempExp.setItemId(msgData.getItemId()); | 463 | tempExp.setItemId(msgData.getItemId()); |
| 488 | tempExp.setAccountId(msgData.getAccountId()); | 464 | tempExp.setAccountId(msgData.getAccountId()); |
| 489 | tempExp.setRewardExp(task.getRewardExp()); | 465 | tempExp.setRewardExp(task.getRewardExp()); |
| ... | @@ -522,6 +498,7 @@ public class TaskOperationServiceImpl implements TaskOperationService { | ... | @@ -522,6 +498,7 @@ public class TaskOperationServiceImpl implements TaskOperationService { |
| 522 | } | 498 | } |
| 523 | tempPoints.setRewardPointsExpireTime(rewardPointsExpireTime); | 499 | tempPoints.setRewardPointsExpireTime(rewardPointsExpireTime); |
| 524 | tempPoints.setMemberId(memberId); | 500 | tempPoints.setMemberId(memberId); |
| 501 | tempPoints.setMemberCode(msgData.getMemberCode()); | ||
| 525 | tempPoints.setAppCode(msgData.getAppCode()); | 502 | tempPoints.setAppCode(msgData.getAppCode()); |
| 526 | tempPoints.setPoints(rewardPoints); | 503 | tempPoints.setPoints(rewardPoints); |
| 527 | tempPoints.setPointsType(pointsType); | 504 | tempPoints.setPointsType(pointsType); | ... | ... |
| ... | @@ -6,6 +6,7 @@ import cn.hutool.core.util.ObjectUtil; | ... | @@ -6,6 +6,7 @@ import cn.hutool.core.util.ObjectUtil; |
| 6 | import cn.hutool.core.util.StrUtil; | 6 | import cn.hutool.core.util.StrUtil; |
| 7 | import cn.hutool.http.HttpUtil; | 7 | import cn.hutool.http.HttpUtil; |
| 8 | import com.alibaba.fastjson.JSONObject; | 8 | import com.alibaba.fastjson.JSONObject; |
| 9 | import com.topdraw.aspect.AsyncMqSend; | ||
| 9 | import com.topdraw.business.module.member.domain.Member; | 10 | import com.topdraw.business.module.member.domain.Member; |
| 10 | import com.topdraw.business.module.member.domain.MemberBuilder; | 11 | import com.topdraw.business.module.member.domain.MemberBuilder; |
| 11 | import com.topdraw.business.module.member.profile.domain.MemberProfile; | 12 | import com.topdraw.business.module.member.profile.domain.MemberProfile; |
| ... | @@ -15,6 +16,8 @@ import com.topdraw.business.module.member.profile.service.dto.MemberProfileDTO; | ... | @@ -15,6 +16,8 @@ import com.topdraw.business.module.member.profile.service.dto.MemberProfileDTO; |
| 15 | import com.topdraw.business.module.member.service.MemberService; | 16 | import com.topdraw.business.module.member.service.MemberService; |
| 16 | import com.topdraw.business.module.member.service.dto.MemberDTO; | 17 | import com.topdraw.business.module.member.service.dto.MemberDTO; |
| 17 | import com.topdraw.business.module.member.service.dto.MemberQueryCriteria; | 18 | import com.topdraw.business.module.member.service.dto.MemberQueryCriteria; |
| 19 | import com.topdraw.business.module.member.viphistory.domain.MemberVipHistory; | ||
| 20 | import com.topdraw.business.module.member.viphistory.service.MemberVipHistoryService; | ||
| 18 | import com.topdraw.business.module.user.iptv.domain.UserConstant; | 21 | import com.topdraw.business.module.user.iptv.domain.UserConstant; |
| 19 | import com.topdraw.business.module.user.iptv.domain.UserTv; | 22 | import com.topdraw.business.module.user.iptv.domain.UserTv; |
| 20 | import com.topdraw.business.module.user.iptv.service.UserTvService; | 23 | import com.topdraw.business.module.user.iptv.service.UserTvService; |
| ... | @@ -60,6 +63,8 @@ import org.springframework.transaction.annotation.Propagation; | ... | @@ -60,6 +63,8 @@ import org.springframework.transaction.annotation.Propagation; |
| 60 | import org.springframework.transaction.annotation.Transactional; | 63 | import org.springframework.transaction.annotation.Transactional; |
| 61 | import org.springframework.util.CollectionUtils; | 64 | import org.springframework.util.CollectionUtils; |
| 62 | 65 | ||
| 66 | import java.nio.charset.StandardCharsets; | ||
| 67 | import java.sql.Timestamp; | ||
| 63 | import java.time.LocalDateTime; | 68 | import java.time.LocalDateTime; |
| 64 | import java.util.*; | 69 | import java.util.*; |
| 65 | import java.util.concurrent.TimeUnit; | 70 | import java.util.concurrent.TimeUnit; |
| ... | @@ -97,6 +102,8 @@ public class UserOperationServiceImpl implements UserOperationService { | ... | @@ -97,6 +102,8 @@ public class UserOperationServiceImpl implements UserOperationService { |
| 97 | private CollectionMq2DetailMapper collectionMq2DetailMapper; | 102 | private CollectionMq2DetailMapper collectionMq2DetailMapper; |
| 98 | @Autowired | 103 | @Autowired |
| 99 | private UserWeixinRepository userWeixinRepository; | 104 | private UserWeixinRepository userWeixinRepository; |
| 105 | @Autowired | ||
| 106 | private MemberVipHistoryService memberVipHistoryService; | ||
| 100 | 107 | ||
| 101 | 108 | ||
| 102 | 109 | ||
| ... | @@ -145,8 +152,10 @@ public class UserOperationServiceImpl implements UserOperationService { | ... | @@ -145,8 +152,10 @@ public class UserOperationServiceImpl implements UserOperationService { |
| 145 | @Override | 152 | @Override |
| 146 | public boolean subscribe(SubscribeBean resources) { | 153 | public boolean subscribe(SubscribeBean resources) { |
| 147 | String unionId = resources.getUnionid(); | 154 | String unionId = resources.getUnionid(); |
| 148 | String appId = resources.getAppid(); | 155 | String appId = resources.getAppId(); |
| 149 | String openId = resources.getOpenid(); | 156 | String openId = resources.getOpenId(); |
| 157 | String nickname = resources.getNickname(); | ||
| 158 | String headImgUrl = resources.getHeadimgurl(); | ||
| 150 | 159 | ||
| 151 | // 小屏账户 | 160 | // 小屏账户 |
| 152 | UserWeixinDTO userWeixinDTO = this.findFirstByUnionIdAndAppIdAndOpenId(unionId,appId, openId); | 161 | UserWeixinDTO userWeixinDTO = this.findFirstByUnionIdAndAppIdAndOpenId(unionId,appId, openId); |
| ... | @@ -157,17 +166,21 @@ public class UserOperationServiceImpl implements UserOperationService { | ... | @@ -157,17 +166,21 @@ public class UserOperationServiceImpl implements UserOperationService { |
| 157 | weiXinBeanDefinition.setUnionId(unionId); | 166 | weiXinBeanDefinition.setUnionId(unionId); |
| 158 | weiXinBeanDefinition.setAppid(appId); | 167 | weiXinBeanDefinition.setAppid(appId); |
| 159 | weiXinBeanDefinition.setOpenId(openId); | 168 | weiXinBeanDefinition.setOpenId(openId); |
| 160 | 169 | weiXinBeanDefinition.setNickname(nickname); | |
| 170 | weiXinBeanDefinition.setHeadImgUrl(headImgUrl); | ||
| 161 | // 创建会员和账户 | 171 | // 创建会员和账户 |
| 162 | this.doCreateUserWeiXinAndMember(weiXinBeanDefinition); | 172 | this.doCreateUserWeiXinAndMember(weiXinBeanDefinition); |
| 163 | 173 | ||
| 164 | } else { | 174 | } else { |
| 165 | 175 | ||
| 166 | // 修改账户和会员信息 | 176 | // 修改账户和会员信息 |
| 167 | this.doUpdateUserWeiXinAndMember(userWeixinDTO,appId,openId); | 177 | this.doUpdateUserWeiXinAndMember(userWeixinDTO,appId,openId,headImgUrl,nickname); |
| 168 | 178 | ||
| 169 | } | 179 | } |
| 170 | 180 | ||
| 181 | // 关注历史记录 | ||
| 182 | this.doInsertSubscribeHistory(appId,openId,WeChatConstants.EVENT_SUBSCRIBE); | ||
| 183 | |||
| 171 | // 大屏信息 | 184 | // 大屏信息 |
| 172 | JSONObject iptvUserInfo = resources.getIptvUserInfo(); | 185 | JSONObject iptvUserInfo = resources.getIptvUserInfo(); |
| 173 | if (Objects.nonNull(iptvUserInfo)) { | 186 | if (Objects.nonNull(iptvUserInfo)) { |
| ... | @@ -184,6 +197,8 @@ public class UserOperationServiceImpl implements UserOperationService { | ... | @@ -184,6 +197,8 @@ public class UserOperationServiceImpl implements UserOperationService { |
| 184 | throw new BadRequestException("大屏信息不存在!"); | 197 | throw new BadRequestException("大屏信息不存在!"); |
| 185 | } | 198 | } |
| 186 | 199 | ||
| 200 | memberDTO_0.setPlatformAccount(platformAccount); | ||
| 201 | |||
| 187 | // 大屏是否绑定主账号 | 202 | // 大屏是否绑定主账号 |
| 188 | this.bondPriorityMember(userTvDTO,memberDTO_0,"auto"); | 203 | this.bondPriorityMember(userTvDTO,memberDTO_0,"auto"); |
| 189 | 204 | ||
| ... | @@ -200,6 +215,35 @@ public class UserOperationServiceImpl implements UserOperationService { | ... | @@ -200,6 +215,35 @@ public class UserOperationServiceImpl implements UserOperationService { |
| 200 | } | 215 | } |
| 201 | 216 | ||
| 202 | /** | 217 | /** |
| 218 | * | ||
| 219 | * @param appId | ||
| 220 | * @param openId | ||
| 221 | */ | ||
| 222 | private void doInsertSubscribeHistory(String appId, String openId,String event) { | ||
| 223 | // 小屏会员 | ||
| 224 | MemberDTO member = this.findMemberByAppIdAndOpenId(appId,openId); | ||
| 225 | |||
| 226 | MemberVipHistory memberVipHistory = new MemberVipHistory(); | ||
| 227 | memberVipHistory.setMemberId(member.getId()).setStatus(1); | ||
| 228 | //小屏侧,理论上大屏不会收到该事件 | ||
| 229 | if (WeChatConstants.EVENT_SUBSCRIBE.equals(event)) {//关注 | ||
| 230 | memberVipHistory.setVip(1); | ||
| 231 | if (member.getVip() == 0) { | ||
| 232 | member.setVip(1); | ||
| 233 | memberVipHistory.setBeforeVip(0); | ||
| 234 | } | ||
| 235 | } else if (WeChatConstants.EVENT_UNSUBSCRIBE.equals(event)) {// 取消关注 | ||
| 236 | memberVipHistory.setVip(0); | ||
| 237 | if (member.getVip() == 1) { | ||
| 238 | member.setVip(0); | ||
| 239 | memberVipHistory.setBeforeVip(1); | ||
| 240 | } | ||
| 241 | } | ||
| 242 | memberVipHistory.setVipExpireTime(LocalDateTime.now()); | ||
| 243 | memberVipHistoryService.create(memberVipHistory); | ||
| 244 | } | ||
| 245 | |||
| 246 | /** | ||
| 203 | * 获取小屏账户 | 247 | * 获取小屏账户 |
| 204 | * @param unionId | 248 | * @param unionId |
| 205 | * @param appId | 249 | * @param appId |
| ... | @@ -216,13 +260,23 @@ public class UserOperationServiceImpl implements UserOperationService { | ... | @@ -216,13 +260,23 @@ public class UserOperationServiceImpl implements UserOperationService { |
| 216 | * @param appId | 260 | * @param appId |
| 217 | * @param openId | 261 | * @param openId |
| 218 | */ | 262 | */ |
| 219 | private void doUpdateUserWeiXinAndMember(UserWeixinDTO userWeixinDTO,String appId,String openId) { | 263 | private void doUpdateUserWeiXinAndMember(UserWeixinDTO userWeixinDTO,String appId,String openId,String headImgUrl,String nickName) { |
| 264 | |||
| 265 | userWeixinDTO.setAppid(appId); | ||
| 266 | userWeixinDTO.setOpenid(openId); | ||
| 267 | userWeixinDTO.setNickname(nickName); | ||
| 268 | userWeixinDTO.setHeadimgurl(headImgUrl); | ||
| 220 | // 修改微信账户关注状态 | 269 | // 修改微信账户关注状态 |
| 221 | this.doUpdateUserWeiXinStatus(userWeixinDTO,SUBSCRIBE_STATUS); | 270 | this.doUpdateUserWeiXinStatus(userWeixinDTO,SUBSCRIBE_STATUS); |
| 222 | 271 | ||
| 223 | // 小屏会员 | 272 | // 小屏会员 |
| 224 | MemberDTO memberDTO_0 = this.findMemberByAppIdAndOpenId(appId,openId); | 273 | MemberDTO memberDTO_0 = this.findMemberByAppIdAndOpenId(appId,openId); |
| 225 | 274 | ||
| 275 | if (StringUtils.isNotBlank(headImgUrl) && StringUtils.isNotBlank(nickName)) { | ||
| 276 | memberDTO_0.setAvatarUrl(headImgUrl); | ||
| 277 | memberDTO_0.setNickname(nickName); | ||
| 278 | } | ||
| 279 | |||
| 226 | this.doUpdateMemberVip(memberDTO_0,1); | 280 | this.doUpdateMemberVip(memberDTO_0,1); |
| 227 | } | 281 | } |
| 228 | 282 | ||
| ... | @@ -236,14 +290,15 @@ public class UserOperationServiceImpl implements UserOperationService { | ... | @@ -236,14 +290,15 @@ public class UserOperationServiceImpl implements UserOperationService { |
| 236 | UserWeixin userWeixin = this.generateUserWeiXin(weiXinBeanDefinition,SUBSCRIBE_STATUS); | 290 | UserWeixin userWeixin = this.generateUserWeiXin(weiXinBeanDefinition,SUBSCRIBE_STATUS); |
| 237 | 291 | ||
| 238 | // 保存会员 | 292 | // 保存会员 |
| 239 | Long memberId = this.doCreateMember(userWeixin,1); | 293 | // Long memberId = this.doCreateMember(userWeixin,1); |
| 294 | Member member = this.doCreateMemberAndReturnMember(userWeixin,1); | ||
| 240 | 295 | ||
| 241 | if (Objects.isNull(memberId)) { | 296 | if (Objects.isNull(member.getId())) { |
| 242 | throw new BadRequestException("会员创建保存失败"); | 297 | throw new BadRequestException("会员创建保存失败"); |
| 243 | } | 298 | } |
| 244 | 299 | ||
| 245 | // 保存或者修改,微信账户信息 | 300 | // 保存或者修改,微信账户信息 |
| 246 | this.doCreateUserWeiXin(userWeixin,memberId); | 301 | this.doCreateUserWeiXin(userWeixin,member); |
| 247 | 302 | ||
| 248 | } | 303 | } |
| 249 | 304 | ||
| ... | @@ -270,8 +325,8 @@ public class UserOperationServiceImpl implements UserOperationService { | ... | @@ -270,8 +325,8 @@ public class UserOperationServiceImpl implements UserOperationService { |
| 270 | @Override | 325 | @Override |
| 271 | public boolean unsubscribe(SubscribeBean resources) { | 326 | public boolean unsubscribe(SubscribeBean resources) { |
| 272 | 327 | ||
| 273 | String appId = resources.getAppid(); | 328 | String appId = resources.getAppId(); |
| 274 | String openId = resources.getOpenid(); | 329 | String openId = resources.getOpenId(); |
| 275 | 330 | ||
| 276 | // 修改关注状态 0:未关注 | 331 | // 修改关注状态 0:未关注 |
| 277 | UserWeixinDTO userWeixinDTO = this.doUpdateUserWeiXinStatus(appId, openId, UNSUBSCRIBE_STATUS); | 332 | UserWeixinDTO userWeixinDTO = this.doUpdateUserWeiXinStatus(appId, openId, UNSUBSCRIBE_STATUS); |
| ... | @@ -282,6 +337,9 @@ public class UserOperationServiceImpl implements UserOperationService { | ... | @@ -282,6 +337,9 @@ public class UserOperationServiceImpl implements UserOperationService { |
| 282 | // 修改会员vip,如果没有购买会员则取消团粉 | 337 | // 修改会员vip,如果没有购买会员则取消团粉 |
| 283 | this.doUpdateMemberVip(memberDTO,0); | 338 | this.doUpdateMemberVip(memberDTO,0); |
| 284 | 339 | ||
| 340 | // 关注历史记录 | ||
| 341 | this.doInsertSubscribeHistory(appId,openId,WeChatConstants.EVENT_UNSUBSCRIBE); | ||
| 342 | |||
| 285 | return true; | 343 | return true; |
| 286 | } | 344 | } |
| 287 | 345 | ||
| ... | @@ -312,6 +370,7 @@ public class UserOperationServiceImpl implements UserOperationService { | ... | @@ -312,6 +370,7 @@ public class UserOperationServiceImpl implements UserOperationService { |
| 312 | log.error(" saveUserInfo get an error || data: {} || msg: {} ", data, e.getMessage()); | 370 | log.error(" saveUserInfo get an error || data: {} || msg: {} ", data, e.getMessage()); |
| 313 | } | 371 | } |
| 314 | 372 | ||
| 373 | log.info("result ====>> [{}]",result); | ||
| 315 | return result; | 374 | return result; |
| 316 | } | 375 | } |
| 317 | 376 | ||
| ... | @@ -355,6 +414,7 @@ public class UserOperationServiceImpl implements UserOperationService { | ... | @@ -355,6 +414,7 @@ public class UserOperationServiceImpl implements UserOperationService { |
| 355 | private void doUpdateMemberVip(MemberDTO memberDTO,Integer vip1) { | 414 | private void doUpdateMemberVip(MemberDTO memberDTO,Integer vip1) { |
| 356 | 415 | ||
| 357 | Integer vip = memberDTO.getVip(); | 416 | Integer vip = memberDTO.getVip(); |
| 417 | vip = (vip == null ? 0 : vip); | ||
| 358 | // 未购买付费会员 | 418 | // 未购买付费会员 |
| 359 | if (vip <= 1) { | 419 | if (vip <= 1) { |
| 360 | 420 | ||
| ... | @@ -450,9 +510,18 @@ public class UserOperationServiceImpl implements UserOperationService { | ... | @@ -450,9 +510,18 @@ public class UserOperationServiceImpl implements UserOperationService { |
| 450 | @Override | 510 | @Override |
| 451 | @Transactional(propagation = Propagation.REQUIRES_NEW, readOnly = false, rollbackFor = Exception.class) | 511 | @Transactional(propagation = Propagation.REQUIRES_NEW, readOnly = false, rollbackFor = Exception.class) |
| 452 | public UserWeixinDTO appletLogin(WeiXinUserBean resources) { | 512 | public UserWeixinDTO appletLogin(WeiXinUserBean resources) { |
| 513 | String appid = resources.getAppid(); | ||
| 514 | String openid = resources.getOpenid(); | ||
| 515 | String headimgurl = resources.getHeadimgurl(); | ||
| 516 | String unionid = resources.getUnionid(); | ||
| 517 | |||
| 453 | 518 | ||
| 454 | // 解析 | 519 | // 解析 |
| 455 | DefaultWeiXinBeanDefinition weiXinBeanDefinition = this.parseAppletInfo(resources); | 520 | DefaultWeiXinBeanDefinition weiXinBeanDefinition = new DefaultWeiXinBeanDefinition();//this.parseAppletInfo(resources); |
| 521 | weiXinBeanDefinition.setAppid(appid); | ||
| 522 | weiXinBeanDefinition.setOpenId(openid); | ||
| 523 | weiXinBeanDefinition.setHeadImgUrl(headimgurl); | ||
| 524 | weiXinBeanDefinition.setUnionId(unionid); | ||
| 456 | 525 | ||
| 457 | if (Objects.isNull(weiXinBeanDefinition.getAppId())) { | 526 | if (Objects.isNull(weiXinBeanDefinition.getAppId())) { |
| 458 | throw new RuntimeException("微信信息解析失败!"); | 527 | throw new RuntimeException("微信信息解析失败!"); |
| ... | @@ -485,6 +554,44 @@ public class UserOperationServiceImpl implements UserOperationService { | ... | @@ -485,6 +554,44 @@ public class UserOperationServiceImpl implements UserOperationService { |
| 485 | return memberId; | 554 | return memberId; |
| 486 | } | 555 | } |
| 487 | 556 | ||
| 557 | private Member doCreateMemberAndReturnMember(UserWeixin userWeixin,Integer vip) { | ||
| 558 | Member memberReturn = null; | ||
| 559 | |||
| 560 | if(Objects.nonNull(userWeixin)) { | ||
| 561 | |||
| 562 | String unionid = userWeixin.getUnionid(); | ||
| 563 | |||
| 564 | // 新创建的小屏账户 | ||
| 565 | if(Objects.nonNull(unionid)) { | ||
| 566 | |||
| 567 | // 查询第一个账户是否关联了会员 | ||
| 568 | UserWeixinDTO userWeixinDTO = this.userWeixinService.findFirstByUnionId(unionid); | ||
| 569 | |||
| 570 | // 无账号,没有绑定会员 | ||
| 571 | if (Objects.isNull(userWeixinDTO.getMemberId())) { | ||
| 572 | // 默认会员 | ||
| 573 | Member member = MemberBuilder.build(LocalConstants.DEVICE_MOBILE,userWeixin.getHeadimgurl(), | ||
| 574 | userWeixin.getNickname(),vip); | ||
| 575 | |||
| 576 | memberReturn = this.memberService.createAndReturnMember(member); | ||
| 577 | |||
| 578 | } | ||
| 579 | |||
| 580 | // 如果绑定了会员 | ||
| 581 | if (Objects.nonNull(userWeixinDTO.getMemberId())) { | ||
| 582 | Long memberId = userWeixinDTO.getMemberId(); | ||
| 583 | MemberDTO memberDTO = this.findMemberById(memberId); | ||
| 584 | memberReturn = new Member(); | ||
| 585 | BeanUtils.copyProperties(memberDTO,memberReturn); | ||
| 586 | } | ||
| 587 | |||
| 588 | } | ||
| 589 | |||
| 590 | } | ||
| 591 | |||
| 592 | return memberReturn; | ||
| 593 | } | ||
| 594 | |||
| 488 | /** | 595 | /** |
| 489 | * 创建会员 | 596 | * 创建会员 |
| 490 | * @description 同一用户只有一个会员,通过unionId查询任意账户是否关联了会员,如果关联了就不用再创建 | 597 | * @description 同一用户只有一个会员,通过unionId查询任意账户是否关联了会员,如果关联了就不用再创建 |
| ... | @@ -538,20 +645,44 @@ public class UserOperationServiceImpl implements UserOperationService { | ... | @@ -538,20 +645,44 @@ public class UserOperationServiceImpl implements UserOperationService { |
| 538 | return userWeixinDTO; | 645 | return userWeixinDTO; |
| 539 | } | 646 | } |
| 540 | 647 | ||
| 648 | |||
| 649 | private UserWeixinDTO doCreateUserWeiXin(UserWeixin userWeixin,Member member) { | ||
| 650 | Long memberId = member.getId(); | ||
| 651 | String code = member.getCode(); | ||
| 652 | UserWeixinDTO userWeixinDTO = new UserWeixinDTO(); | ||
| 653 | if(Objects.isNull(userWeixin.getId()) && Objects.nonNull(memberId)) { | ||
| 654 | userWeixin.setMemberId(memberId); | ||
| 655 | userWeixin.setStatus(SUBSCRIBE_STATUS); | ||
| 656 | userWeixin.setSyncStatus(0); | ||
| 657 | userWeixin.setCreateBy("system"); | ||
| 658 | userWeixin.setUpdateBy("system"); | ||
| 659 | userWeixin.setAuthTime(TimestampUtil.now()); | ||
| 660 | userWeixin.setMemberCode(code); | ||
| 661 | userWeixin = this.userWeixinService.create(userWeixin); | ||
| 662 | } | ||
| 663 | |||
| 664 | BeanUtils.copyProperties(userWeixin,userWeixinDTO); | ||
| 665 | return userWeixinDTO; | ||
| 666 | } | ||
| 667 | |||
| 541 | /** | 668 | /** |
| 542 | * 保存微信账户信息 | 669 | * 保存微信账户信息 |
| 543 | * @param userWeixin | 670 | * @param userWeixin |
| 544 | * @param memberId | 671 | * @param memberId |
| 545 | */ | 672 | */ |
| 546 | private UserWeixinDTO doCreateUserWeiXin(UserWeixin userWeixin,Long memberId) { | 673 | private UserWeixinDTO doCreateUserWeiXin(UserWeixin userWeixin,Long memberId) { |
| 674 | |||
| 675 | MemberDTO memberDTO = this.findMemberById(memberId); | ||
| 676 | |||
| 547 | UserWeixinDTO userWeixinDTO = new UserWeixinDTO(); | 677 | UserWeixinDTO userWeixinDTO = new UserWeixinDTO(); |
| 548 | if(Objects.isNull(userWeixin.getId()) && Objects.nonNull(memberId)) { | 678 | if(Objects.isNull(userWeixin.getId()) && Objects.nonNull(memberId)) { |
| 549 | userWeixin.setMemberId(memberId); | 679 | userWeixin.setMemberId(memberId); |
| 550 | userWeixin.setStatus(1); | 680 | userWeixin.setStatus(SUBSCRIBE_STATUS); |
| 551 | userWeixin.setSyncStatus(0); | 681 | userWeixin.setSyncStatus(0); |
| 552 | userWeixin.setCreateBy("system"); | 682 | userWeixin.setCreateBy("system"); |
| 553 | userWeixin.setUpdateBy("system"); | 683 | userWeixin.setUpdateBy("system"); |
| 554 | userWeixin.setAuthTime(TimestampUtil.now()); | 684 | userWeixin.setAuthTime(TimestampUtil.now()); |
| 685 | userWeixin.setMemberCode(memberDTO.getCode()); | ||
| 555 | userWeixin = this.userWeixinService.create(userWeixin); | 686 | userWeixin = this.userWeixinService.create(userWeixin); |
| 556 | } | 687 | } |
| 557 | 688 | ||
| ... | @@ -726,12 +857,11 @@ public class UserOperationServiceImpl implements UserOperationService { | ... | @@ -726,12 +857,11 @@ public class UserOperationServiceImpl implements UserOperationService { |
| 726 | UserTvDTO userTvDTO_0 = this.findByPriorityMemberCode(memberCode); | 857 | UserTvDTO userTvDTO_0 = this.findByPriorityMemberCode(memberCode); |
| 727 | 858 | ||
| 728 | if (Objects.nonNull(userTvDTO_0)) { | 859 | if (Objects.nonNull(userTvDTO_0)) { |
| 729 | log.error("Param ==>> memberCode ==> [{}]",memberCode); | ||
| 730 | 860 | ||
| 731 | if (userTvDTO_0.getPriorityMemberCode().equalsIgnoreCase(memberCode)) | 861 | if (userTvDTO_0.getPriorityMemberCode().equalsIgnoreCase(memberCode)) |
| 732 | throw new BadRequestException("会员已是主账户,不能重复绑定"); | 862 | throw new BadRequestException("会员已是主账户"); |
| 733 | 863 | ||
| 734 | throw new BadRequestException("该会员已绑定其他账户,不能重复绑定"); | 864 | throw new BadRequestException("该会员已绑定其他账户"); |
| 735 | } | 865 | } |
| 736 | 866 | ||
| 737 | // 大屏账户 | 867 | // 大屏账户 |
| ... | @@ -745,6 +875,16 @@ public class UserOperationServiceImpl implements UserOperationService { | ... | @@ -745,6 +875,16 @@ public class UserOperationServiceImpl implements UserOperationService { |
| 745 | 875 | ||
| 746 | } | 876 | } |
| 747 | 877 | ||
| 878 | @Override | ||
| 879 | public void changeMainAccountByUnionId(UserTv userTv, String unionId) { | ||
| 880 | UserWeixinDTO userWeixinDTO = this.userWeixinService.findFirstByUnionId(unionId); | ||
| 881 | Long memberId = userWeixinDTO.getMemberId(); | ||
| 882 | MemberDTO memberDTO = this.findMemberById(memberId); | ||
| 883 | String code = memberDTO.getCode(); | ||
| 884 | userTv.setMemberCode(code); | ||
| 885 | this.changeMainAccount(userTv); | ||
| 886 | } | ||
| 887 | |||
| 748 | 888 | ||
| 749 | private UserTvDTO findByPriorityMemberCode(String memberCode) { | 889 | private UserTvDTO findByPriorityMemberCode(String memberCode) { |
| 750 | UserTvDTO userTvDTO = this.userTvService.findByPriorityMemberCode(memberCode); | 890 | UserTvDTO userTvDTO = this.userTvService.findByPriorityMemberCode(memberCode); |
| ... | @@ -761,7 +901,7 @@ public class UserOperationServiceImpl implements UserOperationService { | ... | @@ -761,7 +901,7 @@ public class UserOperationServiceImpl implements UserOperationService { |
| 761 | private void bondPriorityMember(UserTvDTO userTvDTO, MemberDTO memberDTO,String auto) { | 901 | private void bondPriorityMember(UserTvDTO userTvDTO, MemberDTO memberDTO,String auto) { |
| 762 | 902 | ||
| 763 | if (auto.equalsIgnoreCase("auto")) { | 903 | if (auto.equalsIgnoreCase("auto")) { |
| 764 | // 绑定的小屏编码 | 904 | // 主账户 |
| 765 | String priorityMemberCode = userTvDTO.getPriorityMemberCode(); | 905 | String priorityMemberCode = userTvDTO.getPriorityMemberCode(); |
| 766 | if (StringUtils.isNotEmpty(priorityMemberCode)) { | 906 | if (StringUtils.isNotEmpty(priorityMemberCode)) { |
| 767 | return; | 907 | return; |
| ... | @@ -800,6 +940,7 @@ public class UserOperationServiceImpl implements UserOperationService { | ... | @@ -800,6 +940,7 @@ public class UserOperationServiceImpl implements UserOperationService { |
| 800 | UserTvDTO userTvDTO = this.findByUserTv(resources); | 940 | UserTvDTO userTvDTO = this.findByUserTv(resources); |
| 801 | 941 | ||
| 802 | Long id = userTvDTO.getId(); | 942 | Long id = userTvDTO.getId(); |
| 943 | |||
| 803 | String memberCode = resources.getMemberCode(); | 944 | String memberCode = resources.getMemberCode(); |
| 804 | 945 | ||
| 805 | // 大屏会员 | 946 | // 大屏会员 |
| ... | @@ -812,6 +953,16 @@ public class UserOperationServiceImpl implements UserOperationService { | ... | @@ -812,6 +953,16 @@ public class UserOperationServiceImpl implements UserOperationService { |
| 812 | this.resetMainAccount(memberCode); | 953 | this.resetMainAccount(memberCode); |
| 813 | } | 954 | } |
| 814 | 955 | ||
| 956 | @Override | ||
| 957 | public void unbindByUnionId(UserTv userTv, String unionId) { | ||
| 958 | UserWeixinDTO userWeixinDTO = this.userWeixinService.findFirstByUnionId(unionId); | ||
| 959 | Long memberId = userWeixinDTO.getMemberId(); | ||
| 960 | MemberDTO memberDTO = this.findMemberById(memberId); | ||
| 961 | String code = memberDTO.getCode(); | ||
| 962 | userTv.setMemberCode(code); | ||
| 963 | this.unbind(userTv); | ||
| 964 | } | ||
| 965 | |||
| 815 | /** | 966 | /** |
| 816 | * 置空主账号 | 967 | * 置空主账号 |
| 817 | * @param memberCode | 968 | * @param memberCode |
| ... | @@ -824,7 +975,7 @@ public class UserOperationServiceImpl implements UserOperationService { | ... | @@ -824,7 +975,7 @@ public class UserOperationServiceImpl implements UserOperationService { |
| 824 | UserTv userTv = new UserTv(); | 975 | UserTv userTv = new UserTv(); |
| 825 | BeanUtils.copyProperties(userTvDTO,userTv); | 976 | BeanUtils.copyProperties(userTvDTO,userTv); |
| 826 | 977 | ||
| 827 | this.userTvService.update(userTv); | 978 | this.userTvService.unbindPriorityMemberCode(userTv); |
| 828 | } | 979 | } |
| 829 | } | 980 | } |
| 830 | 981 | ||
| ... | @@ -837,12 +988,14 @@ public class UserOperationServiceImpl implements UserOperationService { | ... | @@ -837,12 +988,14 @@ public class UserOperationServiceImpl implements UserOperationService { |
| 837 | if (CollUtil.isEmpty(memberDTOS)) | 988 | if (CollUtil.isEmpty(memberDTOS)) |
| 838 | return; | 989 | return; |
| 839 | 990 | ||
| 991 | |||
| 840 | Member member = new Member(); | 992 | Member member = new Member(); |
| 841 | memberDTOS.get(0).setBindIptvTime(null); | 993 | memberDTOS.get(0).setBindIptvTime(null); |
| 842 | memberDTOS.get(0).setUserIptvId(null); | 994 | memberDTOS.get(0).setUserIptvId(null); |
| 843 | memberDTOS.get(0).setBindIptvPlatformType(null); | 995 | memberDTOS.get(0).setBindIptvPlatformType(null); |
| 844 | BeanUtils.copyProperties(memberDTOS.get(0), member); | 996 | BeanUtils.copyProperties(memberDTOS.get(0), member); |
| 845 | this.memberService.update(member); | 997 | |
| 998 | this.memberService.unbind(member); | ||
| 846 | } | 999 | } |
| 847 | 1000 | ||
| 848 | /** | 1001 | /** |
| ... | @@ -961,6 +1114,8 @@ public class UserOperationServiceImpl implements UserOperationService { | ... | @@ -961,6 +1114,8 @@ public class UserOperationServiceImpl implements UserOperationService { |
| 961 | memberDTO.setUserIptvId(userIptvId); | 1114 | memberDTO.setUserIptvId(userIptvId); |
| 962 | memberDTO.setBindIptvTime(LocalDateTime.now()); | 1115 | memberDTO.setBindIptvTime(LocalDateTime.now()); |
| 963 | memberDTO.setBindIptvPlatformType(bindIptvPlatformType); | 1116 | memberDTO.setBindIptvPlatformType(bindIptvPlatformType); |
| 1117 | |||
| 1118 | this.doUpdateMemberByMemberDTO(memberDTO); | ||
| 964 | } | 1119 | } |
| 965 | 1120 | ||
| 966 | return memberDTO; | 1121 | return memberDTO; |
| ... | @@ -973,6 +1128,8 @@ public class UserOperationServiceImpl implements UserOperationService { | ... | @@ -973,6 +1128,8 @@ public class UserOperationServiceImpl implements UserOperationService { |
| 973 | private void doUpdateMemberByMemberDTO(MemberDTO memberDTO){ | 1128 | private void doUpdateMemberByMemberDTO(MemberDTO memberDTO){ |
| 974 | Member member = new Member(); | 1129 | Member member = new Member(); |
| 975 | BeanUtils.copyProperties(memberDTO,member); | 1130 | BeanUtils.copyProperties(memberDTO,member); |
| 1131 | member.setUpdateTime(LocalDateTime.now()); | ||
| 1132 | log.info("doUpdateMemberByMemberDTO=====?>>member ==>> [{}]",member); | ||
| 976 | this.doUpdateMember(member); | 1133 | this.doUpdateMember(member); |
| 977 | } | 1134 | } |
| 978 | 1135 | ||
| ... | @@ -1036,14 +1193,6 @@ public class UserOperationServiceImpl implements UserOperationService { | ... | @@ -1036,14 +1193,6 @@ public class UserOperationServiceImpl implements UserOperationService { |
| 1036 | Integer expireSeconds = jsonQrCode.getInteger("expire_seconds"); | 1193 | Integer expireSeconds = jsonQrCode.getInteger("expire_seconds"); |
| 1037 | this.redisUtils.set(key, url, expireSeconds, TimeUnit.SECONDS); | 1194 | this.redisUtils.set(key, url, expireSeconds, TimeUnit.SECONDS); |
| 1038 | } | 1195 | } |
| 1039 | /* HashMap<String, Object> map = new HashMap<>(); | ||
| 1040 | map.put("sessionId", sessionId); | ||
| 1041 | map.put("url", url); | ||
| 1042 | map.put("appid", appid); | ||
| 1043 | map.put("IPTVappid", IPTVappid); | ||
| 1044 | map.put("platformAccount", platformAccount); | ||
| 1045 | map.put("extraInfo", content); | ||
| 1046 | messageProducer.sendQrCodeMessage(JSONObject.toJSONString(map));*/ | ||
| 1047 | } catch (Exception e) { | 1196 | } catch (Exception e) { |
| 1048 | log.error("GetQrCodeConsumer || get qrCode error || {}", e.toString(), e); | 1197 | log.error("GetQrCodeConsumer || get qrCode error || {}", e.toString(), e); |
| 1049 | } | 1198 | } |
| ... | @@ -1051,10 +1200,10 @@ public class UserOperationServiceImpl implements UserOperationService { | ... | @@ -1051,10 +1200,10 @@ public class UserOperationServiceImpl implements UserOperationService { |
| 1051 | } | 1200 | } |
| 1052 | 1201 | ||
| 1053 | @Override | 1202 | @Override |
| 1203 | @AsyncMqSend | ||
| 1054 | public boolean deleteAllCollection(String content) { | 1204 | public boolean deleteAllCollection(String content) { |
| 1055 | try { | 1205 | try { |
| 1056 | 1206 | ||
| 1057 | log.info("receive UserCollection delete all message, content {}", content); | ||
| 1058 | JSONObject jsonObject = JSONObject.parseObject(content); | 1207 | JSONObject jsonObject = JSONObject.parseObject(content); |
| 1059 | String platformAccount = jsonObject.getString("platformAccount"); | 1208 | String platformAccount = jsonObject.getString("platformAccount"); |
| 1060 | Integer type = jsonObject.getInteger("collectionType"); | 1209 | Integer type = jsonObject.getInteger("collectionType"); |
| ... | @@ -1078,9 +1227,12 @@ public class UserOperationServiceImpl implements UserOperationService { | ... | @@ -1078,9 +1227,12 @@ public class UserOperationServiceImpl implements UserOperationService { |
| 1078 | } | 1227 | } |
| 1079 | 1228 | ||
| 1080 | @Override | 1229 | @Override |
| 1230 | @AsyncMqSend | ||
| 1081 | public boolean deleteCollection(String content) { | 1231 | public boolean deleteCollection(String content) { |
| 1082 | try { | 1232 | try { |
| 1083 | log.info("receive UserCollection delete message, content {}", content); | 1233 | |
| 1234 | log.info("receive UserCollection delete message, content [{}]", content); | ||
| 1235 | |||
| 1084 | JSONObject jsonObject = JSONObject.parseObject(content); | 1236 | JSONObject jsonObject = JSONObject.parseObject(content); |
| 1085 | String platformAccount = jsonObject.getString("platformAccount"); | 1237 | String platformAccount = jsonObject.getString("platformAccount"); |
| 1086 | String data = jsonObject.getString("data"); | 1238 | String data = jsonObject.getString("data"); |
| ... | @@ -1140,9 +1292,14 @@ public class UserOperationServiceImpl implements UserOperationService { | ... | @@ -1140,9 +1292,14 @@ public class UserOperationServiceImpl implements UserOperationService { |
| 1140 | } | 1292 | } |
| 1141 | 1293 | ||
| 1142 | @Override | 1294 | @Override |
| 1295 | @AsyncMqSend | ||
| 1143 | public boolean addCollection(String content) { | 1296 | public boolean addCollection(String content) { |
| 1144 | try { | 1297 | try { |
| 1298 | //处理接口调用 中文不显示问题 | ||
| 1299 | content = new String(Base64.getDecoder().decode(content.getBytes(StandardCharsets.UTF_8))); | ||
| 1300 | |||
| 1145 | log.info("receive UserCollection add message, content {}", content); | 1301 | log.info("receive UserCollection add message, content {}", content); |
| 1302 | |||
| 1146 | JSONObject jsonObject = JSONObject.parseObject(content); | 1303 | JSONObject jsonObject = JSONObject.parseObject(content); |
| 1147 | String platformAccount = jsonObject.getString("platformAccount"); | 1304 | String platformAccount = jsonObject.getString("platformAccount"); |
| 1148 | String data = jsonObject.getString("data"); | 1305 | String data = jsonObject.getString("data"); |
| ... | @@ -1178,6 +1335,7 @@ public class UserOperationServiceImpl implements UserOperationService { | ... | @@ -1178,6 +1335,7 @@ public class UserOperationServiceImpl implements UserOperationService { |
| 1178 | .setName(userCollectionMq.getName()) | 1335 | .setName(userCollectionMq.getName()) |
| 1179 | .setType(userCollectionMq.getType()) | 1336 | .setType(userCollectionMq.getType()) |
| 1180 | .setCount(userCollection.getCount() == null ? value.size() : userCollection.getCount() + value.size()); | 1337 | .setCount(userCollection.getCount() == null ? value.size() : userCollection.getCount() + value.size()); |
| 1338 | log.info("userCollection ==>> [{}]",userCollection); | ||
| 1181 | UserCollection userCollectionSave = this.userCollectionService.save(userCollection); | 1339 | UserCollection userCollectionSave = this.userCollectionService.save(userCollection); |
| 1182 | 1340 | ||
| 1183 | for (UserCollectionMq collectionMq : value) { | 1341 | for (UserCollectionMq collectionMq : value) { |
| ... | @@ -1264,7 +1422,7 @@ public class UserOperationServiceImpl implements UserOperationService { | ... | @@ -1264,7 +1422,7 @@ public class UserOperationServiceImpl implements UserOperationService { |
| 1264 | } else { | 1422 | } else { |
| 1265 | 1423 | ||
| 1266 | // 修改账户和会员信息 | 1424 | // 修改账户和会员信息 |
| 1267 | this.doUpdateUserWeiXinAndMember(userWeixinDTO,appId,openId); | 1425 | this.doUpdateUserWeiXinAndMember(userWeixinDTO,appId,openId,"",""); |
| 1268 | 1426 | ||
| 1269 | } | 1427 | } |
| 1270 | 1428 | ||
| ... | @@ -1278,6 +1436,8 @@ public class UserOperationServiceImpl implements UserOperationService { | ... | @@ -1278,6 +1436,8 @@ public class UserOperationServiceImpl implements UserOperationService { |
| 1278 | 1436 | ||
| 1279 | Long id = resources.getId(); | 1437 | Long id = resources.getId(); |
| 1280 | Long platformUserId = resources.getPlatformUserId(); | 1438 | Long platformUserId = resources.getPlatformUserId(); |
| 1439 | String unionid = resources.getUnionid(); | ||
| 1440 | String platformAccount = resources.getPlatformAccount(); | ||
| 1281 | 1441 | ||
| 1282 | // 大屏账户 | 1442 | // 大屏账户 |
| 1283 | UserTvDTO userTvDTO = this.findUserIptvById(platformUserId); | 1443 | UserTvDTO userTvDTO = this.findUserIptvById(platformUserId); |
| ... | @@ -1288,19 +1448,14 @@ public class UserOperationServiceImpl implements UserOperationService { | ... | @@ -1288,19 +1448,14 @@ public class UserOperationServiceImpl implements UserOperationService { |
| 1288 | throw new EntityNotFoundException(UserTvDTO.class,"id","大屏账户不存在!"); | 1448 | throw new EntityNotFoundException(UserTvDTO.class,"id","大屏账户不存在!"); |
| 1289 | } | 1449 | } |
| 1290 | 1450 | ||
| 1291 | // 是否绑定主账户 | 1451 | UserWeixinDTO userWeixinDTO = null; |
| 1292 | if (Objects.nonNull(userTvDTO.getId())) { | 1452 | // 微信账户 |
| 1293 | 1453 | if (Objects.nonNull(id)) { | |
| 1294 | // 主账户 | 1454 | userWeixinDTO = this.userWeixinService.findById(id); |
| 1295 | String priorityMemberCode = userTvDTO.getPriorityMemberCode(); | 1455 | } else { |
| 1296 | 1456 | userWeixinDTO = this.findFirstByUnionId(unionid); | |
| 1297 | if (StringUtils.isNotBlank(priorityMemberCode)) | ||
| 1298 | throw new BadRequestException("该账户已绑定其他会员,不能重复绑定"); | ||
| 1299 | |||
| 1300 | } | 1457 | } |
| 1301 | 1458 | ||
| 1302 | // 微信账户 | ||
| 1303 | UserWeixinDTO userWeixinDTO = this.userWeixinService.findById(id); | ||
| 1304 | // 账户是否存在 | 1459 | // 账户是否存在 |
| 1305 | if (Objects.isNull(userWeixinDTO.getId())) { | 1460 | if (Objects.isNull(userWeixinDTO.getId())) { |
| 1306 | log.error("param ==> id ==> [{}]",id); | 1461 | log.error("param ==> id ==> [{}]",id); |
| ... | @@ -1320,18 +1475,43 @@ public class UserOperationServiceImpl implements UserOperationService { | ... | @@ -1320,18 +1475,43 @@ public class UserOperationServiceImpl implements UserOperationService { |
| 1320 | throw new EntityNotFoundException(MemberDTO.class, "id", memberId.toString()); | 1475 | throw new EntityNotFoundException(MemberDTO.class, "id", memberId.toString()); |
| 1321 | } | 1476 | } |
| 1322 | 1477 | ||
| 1478 | // 主账户 | ||
| 1479 | String priorityMemberCode = userTvDTO.getPriorityMemberCode(); | ||
| 1480 | |||
| 1481 | if (StringUtils.isBlank(priorityMemberCode)) { | ||
| 1323 | // 主账户会员 | 1482 | // 主账户会员 |
| 1324 | String code = memberDTO.getCode(); | 1483 | String code = memberDTO.getCode(); |
| 1325 | userTvDTO.setPriorityMemberCode(code); | 1484 | userTvDTO.setPriorityMemberCode(code); |
| 1485 | } | ||
| 1486 | |||
| 1487 | // 更新小屏账户更新时间,epg需要根据修改时间来让绑定的二维码消失 | ||
| 1488 | this.doUpdateUserWeiXinUpdateTime(userWeixinDTO); | ||
| 1489 | |||
| 1326 | 1490 | ||
| 1327 | // 更新大屏信息 | 1491 | // 更新大屏信息 |
| 1492 | userTvDTO.setMemberCode(memberDTO.getCode()); | ||
| 1328 | this.doUpdateUserTv(userTvDTO); | 1493 | this.doUpdateUserTv(userTvDTO); |
| 1494 | |||
| 1495 | |||
| 1496 | memberDTO.setPlatformAccount(platformAccount); | ||
| 1329 | // 会员绑定大屏 | 1497 | // 会员绑定大屏 |
| 1330 | this.bindIptvId(memberDTO,userTvDTO); | 1498 | this.bindIptvId(memberDTO,userTvDTO); |
| 1331 | 1499 | ||
| 1332 | return true; | 1500 | return true; |
| 1333 | } | 1501 | } |
| 1334 | 1502 | ||
| 1503 | /** | ||
| 1504 | * 更新微信用户修改的时间 | ||
| 1505 | * @param userWeixinDTO | ||
| 1506 | */ | ||
| 1507 | private void doUpdateUserWeiXinUpdateTime(UserWeixinDTO userWeixinDTO) { | ||
| 1508 | UserWeixin userWeixin = new UserWeixin(); | ||
| 1509 | userWeixin.setAppid(userWeixinDTO.getAppid()); | ||
| 1510 | userWeixin.setOpenid(userWeixinDTO.getOpenid()); | ||
| 1511 | userWeixin.setUpdateTime(TimestampUtil.now()); | ||
| 1512 | this.userWeixinService.updateTime(userWeixin); | ||
| 1513 | } | ||
| 1514 | |||
| 1335 | @Override | 1515 | @Override |
| 1336 | public JSONObject getUnionIdByAppIdAndOpenId(String appId,String secret,String code) { | 1516 | public JSONObject getUnionIdByAppIdAndOpenId(String appId,String secret,String code) { |
| 1337 | // 链接微信服务器 | 1517 | // 链接微信服务器 |
| ... | @@ -1339,7 +1519,6 @@ public class UserOperationServiceImpl implements UserOperationService { | ... | @@ -1339,7 +1519,6 @@ public class UserOperationServiceImpl implements UserOperationService { |
| 1339 | .replace("SECRET", secret).replace("JSCODE", code); | 1519 | .replace("SECRET", secret).replace("JSCODE", code); |
| 1340 | 1520 | ||
| 1341 | String entityBody = HttpUtil.get(url); | 1521 | String entityBody = HttpUtil.get(url); |
| 1342 | log.info("entityBody [{}]",entityBody); | ||
| 1343 | 1522 | ||
| 1344 | JSONObject jsonObject = JSONObject.parseObject(entityBody); | 1523 | JSONObject jsonObject = JSONObject.parseObject(entityBody); |
| 1345 | 1524 | ||
| ... | @@ -1379,14 +1558,24 @@ public class UserOperationServiceImpl implements UserOperationService { | ... | @@ -1379,14 +1558,24 @@ public class UserOperationServiceImpl implements UserOperationService { |
| 1379 | 1558 | ||
| 1380 | userWeixinDTO1 = new UserWeixinDTO(); | 1559 | userWeixinDTO1 = new UserWeixinDTO(); |
| 1381 | BeanUtils.copyProperties(resources,userWeixinDTO1); | 1560 | BeanUtils.copyProperties(resources,userWeixinDTO1); |
| 1561 | |||
| 1382 | // 创建会员 | 1562 | // 创建会员 |
| 1383 | memberId = this.doCreateMember(userWeixinDTO1,vip); | 1563 | memberId = this.doCreateMember(userWeixinDTO1,vip); |
| 1384 | 1564 | ||
| 1385 | } | 1565 | } |
| 1386 | 1566 | ||
| 1567 | userWeixinDTO1.setId(null); | ||
| 1568 | userWeixinDTO1.setAppid(appId); | ||
| 1569 | userWeixinDTO1.setOpenid(openId); | ||
| 1570 | userWeixinDTO1.setUnionid(unionId); | ||
| 1571 | log.info("createWeixinUserAndCreateMember ==>> [{}]",userWeixinDTO1); | ||
| 1387 | // 保存微信账户 | 1572 | // 保存微信账户 |
| 1388 | userWeixinDTO1 = this.doCreateUserWeiXin(userWeixinDTO1,memberId); | 1573 | userWeixinDTO1 = this.doCreateUserWeiXin(userWeixinDTO1,memberId); |
| 1389 | 1574 | ||
| 1575 | log.info("userWeixinDTO1 ==>> [{}]",userWeixinDTO1); | ||
| 1576 | |||
| 1577 | MemberProfileDTO memberProfileDTO = this.memberProfileService.findByMemberId(memberId); | ||
| 1578 | if (Objects.isNull(memberProfileDTO)) | ||
| 1390 | // 创建会员属性信息 | 1579 | // 创建会员属性信息 |
| 1391 | this.createMemberProfile(userWeixinDTO1); | 1580 | this.createMemberProfile(userWeixinDTO1); |
| 1392 | 1581 | ||
| ... | @@ -1426,6 +1615,7 @@ public class UserOperationServiceImpl implements UserOperationService { | ... | @@ -1426,6 +1615,7 @@ public class UserOperationServiceImpl implements UserOperationService { |
| 1426 | private void doUpdateUserTv(UserTvDTO userTvDTO) { | 1615 | private void doUpdateUserTv(UserTvDTO userTvDTO) { |
| 1427 | UserTv userTv = new UserTv(); | 1616 | UserTv userTv = new UserTv(); |
| 1428 | BeanUtils.copyProperties(userTvDTO,userTv); | 1617 | BeanUtils.copyProperties(userTvDTO,userTv); |
| 1618 | userTv.setUpdateTime(TimestampUtil.now()); | ||
| 1429 | this.userTvService.update(userTv); | 1619 | this.userTvService.update(userTv); |
| 1430 | } | 1620 | } |
| 1431 | 1621 | ... | ... |
| ... | @@ -10,6 +10,7 @@ import org.springframework.boot.test.context.SpringBootTest; | ... | @@ -10,6 +10,7 @@ import org.springframework.boot.test.context.SpringBootTest; |
| 10 | import org.springframework.test.context.junit4.SpringRunner; | 10 | import org.springframework.test.context.junit4.SpringRunner; |
| 11 | 11 | ||
| 12 | import java.sql.Timestamp; | 12 | import java.sql.Timestamp; |
| 13 | import java.time.LocalDateTime; | ||
| 13 | import java.util.Collection; | 14 | import java.util.Collection; |
| 14 | import java.util.HashMap; | 15 | import java.util.HashMap; |
| 15 | import java.util.Map; | 16 | import java.util.Map; |
| ... | @@ -49,4 +50,6 @@ public class BaseTest { | ... | @@ -49,4 +50,6 @@ public class BaseTest { |
| 49 | } | 50 | } |
| 50 | 51 | ||
| 51 | 52 | ||
| 53 | |||
| 54 | |||
| 52 | } | 55 | } | ... | ... |
-
Please register or sign in to post a comment