Commit 5be4e9f5 5be4e9f5ea730683adc0c6aa3914ee88bbc0ad87 by xianghan

1.会员1.1

1 parent 546d2831
Showing 43 changed files with 417 additions and 112 deletions
......@@ -45,6 +45,7 @@ public class DataSyncMsg implements Serializable {
private Integer deviceType; //设备类型 1:大屏;2:小屏(微信)3.小屏(xx)
@NotNull
private String appCode; //用户对应的应用code
private String memberCode;
private Long accountId; // 账号id
private Long orderId;
private Long activityId;
......
package com.topdraw;
import com.topdraw.config.RedisKeyUtil;
import com.topdraw.utils.RedisUtils;
import com.topdraw.utils.SpringContextHolder;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.autoconfigure.SpringBootApplication;
......
package com.topdraw.business.module.common.domain;
import lombok.Data;
import lombok.experimental.Accessors;
import org.springframework.data.jpa.domain.support.AuditingEntityListener;
import javax.persistence.Entity;
import javax.persistence.EntityListeners;
import javax.persistence.Transient;
import java.io.Serializable;
/**
* @author :
* @description:
* @function :
* @date :Created in 2022/2/10 10:12
* @version: :
* @modified By:
* @since : modified in 2022/2/10 10:12
*/
@Data
@Accessors(chain = true)
public class DefaultAsyncMqModule {
@Transient
private String memberCode;
}
......@@ -11,6 +11,7 @@ import org.springframework.data.jpa.domain.support.AuditingEntityListener;
import java.sql.Timestamp;
import java.io.Serializable;
import java.time.LocalDateTime;
/**
* @author XiangHan
......@@ -87,12 +88,12 @@ public class MemberAddress implements Serializable {
// 创建时间
@CreatedDate
@Column(name = "create_time")
private Timestamp createTime;
private LocalDateTime createTime;
// 更新时间
@LastModifiedDate
@Column(name = "update_time")
private Timestamp updateTime;
private LocalDateTime updateTime;
public void copy(MemberAddress source){
BeanUtil.copyProperties(source,this, CopyOptions.create().setIgnoreNullValue(true));
......
package com.topdraw.business.module.member.address.rest;
import com.topdraw.annotation.AnonymousAccess;
import com.topdraw.business.module.member.service.MemberService;
import com.topdraw.business.module.member.service.dto.MemberDTO;
import com.topdraw.common.ResultInfo;
import com.topdraw.business.module.member.address.domain.MemberAddress;
import com.topdraw.business.module.member.address.service.MemberAddressService;
import com.topdraw.business.module.member.address.service.dto.MemberAddressQueryCriteria;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Pageable;
import org.springframework.util.Assert;
......@@ -21,8 +23,9 @@ import java.util.Objects;
*/
@Api(tags = "MemberAddress管理")
@RestController
@RequestMapping("/api/MemberAddress")
@RequestMapping("/ucEngine/api/memberAddress")
@CrossOrigin
@Slf4j
public class MemberAddressController {
@Autowired
......@@ -44,14 +47,25 @@ public class MemberAddressController {
@PostMapping(value = "/create")
@ApiOperation("新增MemberAddress")
@AnonymousAccess
public ResultInfo create(@Validated @RequestBody MemberAddress resources) {
log.info("MemberAddressController ==>> create ===>>[{}]",resources);
Long memberId = resources.getMemberId();
MemberDTO memberDTO = this.memberService.findById(memberId);
String code = memberDTO.getCode();
resources.setMemberCode(code);
MemberAddressService.create(resources);
return ResultInfo.success();
}
@PutMapping(value = "/update")
@ApiOperation("修改MemberAddress")
@AnonymousAccess
public ResultInfo update(@Validated @RequestBody MemberAddress resources) {
log.info("MemberAddressController ==>> update ===>>[{}]",resources);
Long memberId = resources.getMemberId();
Integer sequence = resources.getSequence();
Assert.notNull(memberId,"memberId can't be null");
......@@ -68,6 +82,7 @@ public class MemberAddressController {
@DeleteMapping(value = "/delete/{id}")
@ApiOperation("删除MemberAddress")
@AnonymousAccess
public ResultInfo delete(@PathVariable Long id) {
MemberAddressService.delete(id);
return ResultInfo.success();
......
......@@ -40,5 +40,4 @@ public interface MemberAddressService {
void update(MemberAddress resources);
void delete(Long id);
}
......
......@@ -3,6 +3,7 @@ package com.topdraw.business.module.member.address.service.dto;
import lombok.Data;
import java.sql.Timestamp;
import java.io.Serializable;
import java.time.LocalDateTime;
/**
......@@ -55,8 +56,8 @@ public class MemberAddressDTO implements Serializable {
private String zipCode;
// 创建时间
private Timestamp createTime;
private LocalDateTime createTime;
// 更新时间
private Timestamp updateTime;
private LocalDateTime updateTime;
}
......
......@@ -2,6 +2,7 @@ package com.topdraw.business.module.member.address.service.impl;
import com.topdraw.aspect.AsyncMqSend;
import com.topdraw.business.module.member.address.domain.MemberAddress;
import com.topdraw.business.module.member.service.MemberService;
import com.topdraw.utils.ValidationUtil;
import com.topdraw.business.module.member.address.repository.MemberAddressRepository;
import com.topdraw.business.module.member.address.service.MemberAddressService;
......
......@@ -7,7 +7,9 @@ import com.topdraw.business.module.member.service.dto.MemberDTO;
import com.topdraw.common.ResultInfo;
import com.topdraw.business.module.member.profile.domain.MemberProfile;
import com.topdraw.business.module.member.profile.service.MemberProfileService;
import com.topdraw.util.Base64Util;
import com.topdraw.utils.StringUtils;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.Assert;
import org.springframework.validation.annotation.Validated;
......@@ -24,6 +26,7 @@ import java.util.Objects;
@RestController
@RequestMapping("/ucEngine/api/memberProfile")
@CrossOrigin
@Slf4j
public class MemberProfileController {
@Autowired
......@@ -47,6 +50,8 @@ public class MemberProfileController {
@ApiOperation("新增MemberProfile")
@AnonymousAccess
public ResultInfo create(@Validated @RequestBody MemberProfile resources) {
log.info("MemberProfileServiceImpl ==>> create ==>> resources ===>> [{}]",resources);
String realname = resources.getRealname();
MemberProfileService.create(resources);
return ResultInfo.success();
}
......@@ -55,6 +60,9 @@ public class MemberProfileController {
@ApiOperation("修改MemberProfile")
@AnonymousAccess
public ResultInfo update(@Validated @RequestBody MemberProfile resources) {
log.info("MemberProfileServiceImpl ==>> update ==>> resources ===>> [{}]",resources);
Long memberId = resources.getMemberId();
Assert.notNull(memberId,"memberId can't be null");
MemberDTO memberDTO = this.memberService.findById(memberId);
......@@ -79,6 +87,7 @@ public class MemberProfileController {
@ApiOperation("修改MemberProfile")
@AnonymousAccess
public ResultInfo updateMemberProfileAndMember(@Validated @RequestBody MemberProfile resources) {
log.info("MemberProfileServiceImpl ==>> update ==>> resources ===>> [{}]",resources);
this.MemberProfileService.updateMemberProfileAndMember(resources);
return ResultInfo.success();
}
......
......@@ -6,6 +6,7 @@ import com.topdraw.business.module.member.domain.Member;
import com.topdraw.business.module.member.profile.domain.MemberProfile;
import com.topdraw.business.module.member.profile.domain.MemberProfileBuild;
import com.topdraw.business.module.member.repository.MemberRepository;
import com.topdraw.business.module.member.service.MemberService;
import com.topdraw.utils.StringUtils;
import com.topdraw.utils.ValidationUtil;
import com.topdraw.business.module.member.profile.repository.MemberProfileRepository;
......@@ -13,6 +14,7 @@ import com.topdraw.business.module.member.profile.service.MemberProfileService;
import com.topdraw.business.module.member.profile.service.dto.MemberProfileDTO;
import com.topdraw.business.module.member.profile.service.dto.MemberProfileQueryCriteria;
import com.topdraw.business.module.member.profile.service.mapper.MemberProfileMapper;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
......@@ -36,6 +38,7 @@ import java.util.Optional;
*/
@Service
@Transactional(propagation = Propagation.SUPPORTS, readOnly = true, rollbackFor = Exception.class)
@Slf4j
public class MemberProfileServiceImpl implements MemberProfileService {
@Autowired
......@@ -46,6 +49,8 @@ public class MemberProfileServiceImpl implements MemberProfileService {
@Autowired
private MemberProfileMapper MemberProfileMapper;
@Autowired
private MemberService memberService;
@Override
......@@ -70,12 +75,14 @@ public class MemberProfileServiceImpl implements MemberProfileService {
@Transactional(rollbackFor = Exception.class)
@AsyncMqSend()
public MemberProfile create(MemberProfile resources) {
log.info("MemberProfileServiceImpl ==>> update ==>> resources ===>> [{}]",resources);
MemberProfileRepository.save(resources);
return resources;
}
@Override
public MemberProfile createDefault(MemberProfile resources) {
Long memberId = resources.getMemberId();
String realname = resources.getRealname();
Integer gender = resources.getGender();
......@@ -88,9 +95,14 @@ public class MemberProfileServiceImpl implements MemberProfileService {
@Transactional(rollbackFor = Exception.class)
@AsyncMqSend()
public void update(MemberProfile resources) {
log.info("MemberProfileServiceImpl ==>> update ==>> resources ===>> [{}]",resources);
MemberProfile MemberProfile = MemberProfileRepository.findById(resources.getId()).orElseGet(MemberProfile::new);
ValidationUtil.isNull( MemberProfile.getId(),"MemberProfile","id",resources.getId());
MemberProfile.copy(resources);
log.info("MemberProfileServiceImpl ==>> update ==>> copy ===>> resources ===>> [{}]",resources);
MemberProfileRepository.save(MemberProfile);
}
......@@ -117,6 +129,7 @@ public class MemberProfileServiceImpl implements MemberProfileService {
@Override
@Transactional(rollbackFor = Exception.class)
public void updateMemberProfileAndMember(MemberProfile resources) {
log.info("MemberProfileServiceImpl ==>> updateMemberProfileAndMember ==>> resources ===>> [{}]",resources);
String realname = resources.getRealname();
String nickNameStr = "";
if (StringUtils.isNotBlank(realname)) {
......@@ -141,8 +154,9 @@ public class MemberProfileServiceImpl implements MemberProfileService {
member.setBirthday(DateUtil.format(resources.getBirthday(), "yyyy-MM-dd"));
member.setAvatarUrl(resources.getAvatarUrl());
memberRepository.save(member);
//memberService.update(member);
// memberRepository.save(member);
log.info("updateMemberProfileAndMember ==>> member ==>> [{}]",member);
memberService.update(member);
}
}
......
......@@ -49,6 +49,12 @@ public class MemberRelatedInfoController {
@ApiOperation("新增MemberRelatedInfo")
@AnonymousAccess
public ResultInfo create(@Validated @RequestBody MemberRelatedInfo resources) {
String name = resources.getName();
if (StringUtils.hasText(name)) {
String nickNameEncode = Base64Util.encode(name);
resources.setName(nickNameEncode);
}
MemberRelatedInfoService.create(resources);
return ResultInfo.success();
}
......
......@@ -53,6 +53,7 @@ public class MemberController {
@PostMapping(value = "/create")
@ApiOperation("新增Member")
@AnonymousAccess
public ResultInfo create(@Validated @RequestBody Member resources) {
Long id = memberService.create(resources);
return ResultInfo.success(id);
......
package com.topdraw.business.module.member.service;
import com.topdraw.aspect.AsyncMqSend;
import com.topdraw.business.module.member.domain.Member;
import com.topdraw.business.module.member.profile.service.dto.MemberProfileDTO;
import com.topdraw.business.module.member.service.dto.MemberDTO;
import com.topdraw.business.module.member.service.dto.MemberQueryCriteria;
import org.springframework.data.domain.Pageable;
import org.springframework.transaction.annotation.Transactional;
import java.util.List;
import java.util.Map;
......@@ -44,12 +46,17 @@ public interface MemberService {
*/
Long create(Member resources);
Member createAndReturnMember(Member resources);
/**
*
* @param resources
*/
void update(Member resources);
void unbind(Member resources);
/**
*
* @param id
......
......@@ -14,6 +14,8 @@ import java.time.LocalDateTime;
@Data
public class MemberDTO implements Serializable {
private String platformAccount;
// iptv绑定的主会员 0:否 1:是
private Integer iptvMajor;
......
......@@ -78,12 +78,20 @@ public class MemberServiceImpl implements MemberService {
@Transactional(rollbackFor = Exception.class)
@AsyncMqSend
public Long create(Member resources) {
log.info("start=====>>>>>resources======>>>>接收到的数据 --->>>> " + resources);
Member member = this.checkMemberData(resources);
memberRepository.save(member);
return member.getId();
}
@Override
@Transactional(rollbackFor = Exception.class)
@AsyncMqSend
public Member createAndReturnMember(Member resources) {
Member member = this.checkMemberData(resources);
memberRepository.save(member);
return resources;
}
private Member checkMemberData(Member member) {
Long defaultValue = 0L;
String code = member.getCode();
......@@ -131,6 +139,25 @@ public class MemberServiceImpl implements MemberService {
}
}
@Override
@Transactional(rollbackFor = Exception.class)
@AsyncMqSend()
public void unbind(Member resources) {
RLock rLock = this.redissonClient.getLock("member::update::id" + resources.getId().toString());
try {
RedissonUtil.lock(rLock);
Member member = memberRepository.findById(resources.getId()).orElseGet(Member::new);
ValidationUtil.isNull(member.getId(), "Member", "id", resources.getId());
member.copy(resources);
this.save(member);
} catch (Exception e) {
e.printStackTrace();
throw e;
} finally {
RedissonUtil.unlock(rLock);
}
}
private void save(Member member){
memberRepository.save(member);
}
......@@ -162,6 +189,7 @@ public class MemberServiceImpl implements MemberService {
}
@Override
@AsyncMqSend()
public void doUpdateMemberPoints(Member resources) {
RLock rLock = this.redissonClient.getLock("member::update::id" + resources.getId().toString());
try {
......
package com.topdraw.business.module.points.available.domain;
import com.topdraw.business.module.common.domain.DefaultAsyncMqModule;
import lombok.Data;
import lombok.experimental.Accessors;
import cn.hutool.core.bean.BeanUtil;
......@@ -24,11 +25,7 @@ import java.io.Serializable;
@EntityListeners(AuditingEntityListener.class)
@Accessors(chain = true)
@Table(name="uc_points_available")
public class PointsAvailable implements Serializable {
/** 会员编号 */
@Transient
private String memberCode;
public class PointsAvailable extends DefaultAsyncMqModule implements Serializable {
// 主键
@Id
......
package com.topdraw.business.module.rights.history.domain;
import com.topdraw.business.module.common.domain.DefaultAsyncMqModule;
import lombok.Data;
import lombok.experimental.Accessors;
import cn.hutool.core.bean.BeanUtil;
......@@ -22,7 +23,7 @@ import java.time.LocalDateTime;
@EntityListeners(AuditingEntityListener.class)
@Accessors(chain = true)
@Table(name="tr_rights_histroy")
public class RightsHistory implements Serializable {
public class RightsHistory extends DefaultAsyncMqModule implements Serializable {
// 主键id
@Id
......
......@@ -66,7 +66,7 @@ public class RightsHistoryServiceImpl implements RightsHistoryService {
@AsyncMqSend()
public void update(RightsHistory resources) {
RightsHistory RightsHistory = RightsHistoryRepository.findById(resources.getId()).orElseGet(RightsHistory::new);
ValidationUtil.isNull( RightsHistory.getId(),"RightsHistory","id",resources.getId());
ValidationUtil.isNull(RightsHistory.getId(),"RightsHistory","id",resources.getId());
RightsHistory.copy(resources);
RightsHistoryRepository.save(RightsHistory);
}
......
package com.topdraw.business.module.user.iptv.service;
import com.topdraw.aspect.AsyncMqSend;
import com.topdraw.business.module.user.iptv.domain.UserTv;
import com.topdraw.business.module.user.iptv.service.dto.UserTvDTO;
import com.topdraw.business.module.user.iptv.service.dto.UserTvQueryCriteria;
import org.springframework.data.domain.Pageable;
import org.springframework.transaction.annotation.Transactional;
import java.util.Map;
import java.util.List;
......@@ -39,6 +42,8 @@ public interface UserTvService {
void update(UserTv resources);
void unbindPriorityMemberCode(UserTv resources);
void delete(Long id);
UserTvDTO findByPlatformAccount(String platformAccount);
......
......@@ -12,6 +12,8 @@ import java.io.Serializable;
@Data
public class UserTvDTO implements Serializable {
private String memberCode;
/** 绑定的小屏账户会员编码 */
private String priorityMemberCode;
......
......@@ -88,6 +88,16 @@ public class UserTvServiceImpl implements UserTvService {
@Override
@Transactional(rollbackFor = Exception.class)
@AsyncMqSend
public void unbindPriorityMemberCode(UserTv resources) {
UserTv UserTv = UserTvRepository.findById(resources.getId()).orElseGet(UserTv::new);
ValidationUtil.isNull( UserTv.getId(),"UserTv","id",resources.getId());
UserTv.copy(resources);
UserTvRepository.save(UserTv);
}
@Override
@Transactional(rollbackFor = Exception.class)
@AsyncMqSend
public void delete(Long id) {
Assert.notNull(id, "The given id must not be null!");
UserTv UserTv = UserTvRepository.findById(id).orElseThrow(
......
......@@ -70,11 +70,13 @@ public class UserCollectionDetailServiceImpl implements UserCollectionDetailServ
}
@Override
@Transactional(rollbackFor = Exception.class)
public void deleteAllByUserCollectionId(Long id) {
this.userCollectionDetailRepository.deleteAllByUserCollectionId(id);
}
@Override
@Transactional(rollbackFor = Exception.class)
public void deleteAll(List<UserCollectionDetail> userCollectionDetailOptional) {
this.userCollectionDetailRepository.deleteAll(userCollectionDetailOptional);
}
......
package com.topdraw.business.module.user.weixin.domain;
import com.topdraw.business.module.common.domain.DefaultAsyncMqModule;
import lombok.Data;
import lombok.experimental.Accessors;
import cn.hutool.core.bean.BeanUtil;
......@@ -21,7 +22,7 @@ import java.io.Serializable;
@EntityListeners(AuditingEntityListener.class)
@Accessors(chain = true)
@Table(name="uc_user_weixin")
public class UserWeixin implements Serializable {
public class UserWeixin extends DefaultAsyncMqModule implements Serializable {
// ID
@Id
......
......@@ -3,7 +3,11 @@ package com.topdraw.business.module.user.weixin.repository;
import com.topdraw.business.module.user.weixin.domain.UserWeixin;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;
import javax.transaction.Transactional;
import java.util.Optional;
/**
......@@ -21,4 +25,9 @@ public interface UserWeixinRepository extends JpaRepository<UserWeixin, Long>, J
Optional<UserWeixin> findFirstByUnionid(String unionid);
Optional<UserWeixin> findFirstByUnionidAndAppid(String unionid, String appId);
@Modifying
@Transactional
@Query(value = "update uc_user_weixin set update_time = :#{#resources.updateTime} where appid = :#{#resources.appid} and openid = :#{#resources.openid}" , nativeQuery = true)
void updateTime(@Param("resources") UserWeixin resources);
}
......
......@@ -40,6 +40,8 @@ public interface UserWeixinService {
void update(UserWeixin resources);
void updateTime(UserWeixin resources);
void delete(Long id);
UserWeixinDTO findFirstByMemberIdAndAppid(Long memberId, String appid);
......
package com.topdraw.business.module.user.weixin.service.impl;
import com.topdraw.aspect.AsyncMqSend;
import com.topdraw.business.module.user.weixin.domain.UserWeixin;
import com.topdraw.utils.ValidationUtil;
import com.topdraw.business.module.user.weixin.repository.UserWeixinRepository;
......@@ -55,6 +56,7 @@ public class UserWeixinServiceImpl implements UserWeixinService {
@Override
@Transactional(rollbackFor = Exception.class)
@AsyncMqSend
public UserWeixin create(UserWeixin resources) {
UserWeixinRepository.save(resources);
return resources;
......@@ -62,6 +64,7 @@ public class UserWeixinServiceImpl implements UserWeixinService {
@Override
@Transactional(rollbackFor = Exception.class)
@AsyncMqSend
public void update(UserWeixin resources) {
UserWeixin UserWeixin = UserWeixinRepository.findById(resources.getId()).orElseGet(UserWeixin::new);
ValidationUtil.isNull( UserWeixin.getId(),"UserWeixin","id",resources.getId());
......@@ -70,6 +73,12 @@ public class UserWeixinServiceImpl implements UserWeixinService {
}
@Override
@AsyncMqSend
public void updateTime(UserWeixin resources) {
UserWeixinRepository.updateTime(resources);
}
@Override
@Transactional(rollbackFor = Exception.class)
public void delete(Long id) {
Assert.notNull(id, "The given id must not be null!");
......
......@@ -13,9 +13,10 @@ import java.sql.Timestamp;
@NoArgsConstructor
public class TempIptvUser {
private String unionid;
// 账户
@Transient
@NotNull(message = "platformAccount can't be null",groups = UnbindGroup.class)
private String platformAccount;
// 分数
......@@ -86,8 +87,6 @@ public class TempIptvUser {
// 会员id
private Long memberId;
// 会员编码
@NotNull(message = "memberCode can't be null",groups = UnbindGroup.class)
private String memberCode;
......
......@@ -9,4 +9,5 @@ public class BindBean extends WeiXinUserBean {
private Long platformUserId;
private String platformAccount;
}
......
package com.topdraw.business.process.domian.weixin;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Data;
import java.time.LocalDateTime;
/**
* 微信账户信息
* @author XiangHan
......@@ -13,5 +15,8 @@ public class BuyVipBean extends WeiXinUserBean {
private Integer vip;
@JsonFormat(shape = JsonFormat.Shape.STRING,pattern = "yyyy-MM-dd HH:mm:ss")
private LocalDateTime vipExpireTime;
}
......
......@@ -15,6 +15,18 @@ public class SubscribeBean extends WeiXinUserBean {
private String event;
/** */
private String openId;
/** */
private String appId;
/** */
private String eventKey;
private String unionid;
private String nickname;
private String headimgurl;
}
......
......@@ -53,4 +53,8 @@ public class WeiXinUserBean {
/** 推荐者id */
private Long sourceUser;
private String nikename;
private String headimgurl;
}
......
package com.topdraw.business.process.rest;
import cn.hutool.core.util.ObjectUtil;
import com.topdraw.annotation.AnonymousAccess;
import com.topdraw.business.module.member.profile.service.dto.MemberProfileDTO;
import com.topdraw.business.module.member.service.MemberService;
import com.topdraw.business.module.member.service.dto.MemberDTO;
import com.topdraw.business.module.member.viphistory.domain.MemberVipHistory;
import com.topdraw.business.module.member.viphistory.service.MemberVipHistoryService;
import com.topdraw.business.module.user.weixin.service.UserWeixinService;
import com.topdraw.business.module.user.weixin.service.dto.UserWeixinDTO;
import com.topdraw.business.module.user.weixin.service.dto.UserWeixinQueryCriteria;
import com.topdraw.business.process.domian.weixin.BuyVipBean;
import com.topdraw.business.process.domian.weixin.WeiXinUserBean;
import com.topdraw.business.process.service.MemberOperationService;
import com.topdraw.common.IResultInfo;
import com.topdraw.common.ResultInfo;
import com.topdraw.exception.BadRequestException;
import com.topdraw.weixin.util.WeChatConstants;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.time.LocalDateTime;
import java.util.Objects;
@Api("会员处理")
@RestController
@RequestMapping(value = "/ucEngine/api/memberOperation")
......@@ -21,6 +32,12 @@ public class MemberOperationController {
@Autowired
private MemberOperationService memberOperationService;
@Autowired
private MemberVipHistoryService memberVipHistoryService;
@Autowired
private UserWeixinService userWeixinService;
@Autowired
private MemberService memberService;
@GetMapping("/getMemberProfileAndCheckVip/{appId}/{memberId}")
@ApiOperation("获取会员基本信息并且检查vip状态")
......@@ -34,9 +51,57 @@ public class MemberOperationController {
@ApiOperation("购买vip")
@AnonymousAccess
public ResultInfo buyVip(@RequestBody BuyVipBean buyVipBean) {
// 小程序账户id
Long id = buyVipBean.getId();
if (Objects.isNull(id))
throw new BadRequestException("参数异常: id is null !");
// vip等级
Integer vip = buyVipBean.getVip();
if (Objects.isNull(vip) || vip <= 0)
throw new BadRequestException("vip 等级有误");
MemberDTO memberDTO = memberOperationService.buyVip(buyVipBean);
LocalDateTime vipExpireTime = buyVipBean.getVipExpireTime();
this.doInsertVipHistory(id,vip,vipExpireTime);
return ResultInfo.success(memberDTO);
}
private void doInsertVipHistory(Long id,Integer vip,LocalDateTime vipExpireTime) {
UserWeixinDTO userWeixinDTO = this.userWeixinService.findById(id);
Long memberId = userWeixinDTO.getMemberId();
MemberDTO member = this.memberService.findById(memberId);
LocalDateTime now = LocalDateTime.now();
MemberVipHistory memberVipHistory = new MemberVipHistory();
if (ObjectUtil.isNull(vipExpireTime)) {
LocalDateTime localDateTime = now.plusYears(1L);
member.setVipExpireTime(localDateTime);
} else {
//购买过 判断当前时间有没有过vip过期时间,没有过,失效时间加一年; 过了,当前时间加一年
//区分是当前vip续费 还是买新的vip
if (ObjectUtil.equal(vip, member.getVip())) {
if (now.isBefore(vipExpireTime)) {
LocalDateTime localDateTime = vipExpireTime.plusYears(1L);
member.setVipExpireTime(localDateTime);
} else {
LocalDateTime localDateTime = now.plusYears(1L);
member.setVipExpireTime(localDateTime);
}
} else {
LocalDateTime localDateTime = now.plusYears(1L);
member.setVipExpireTime(localDateTime);
}
}
memberVipHistory.setVipExpireTime(member.getVipExpireTime());
memberVipHistoryService.create(memberVipHistory);
}
}
......
package com.topdraw.business.process.rest;
import com.topdraw.annotation.AnonymousAccess;
import com.topdraw.business.module.member.service.MemberService;
import com.topdraw.business.module.member.service.dto.MemberDTO;
import com.topdraw.business.module.points.available.service.PointsAvailableService;
......@@ -58,12 +59,14 @@ public class PointsOperationController {
@GetMapping(value = "/pagePointsDetails")
@ApiOperation("查询PointsDetail")
@AnonymousAccess
public ResultInfo pagePointsDetails(PointsDetailQueryCriteria criteria, Pageable pageable) {
return ResultInfo.successPage(pointsDetailService.queryAll(criteria,pageable));
}
@GetMapping(value = "/pageAvailablePoints")
@ApiOperation("查询PointsAvailable")
@AnonymousAccess
public ResultInfo pageAvailablePoints(PointsAvailableQueryCriteria criteria, Pageable pageable) {
PointsAvailableQueryType queryType = criteria.getQueryType();
// 可用
......@@ -75,6 +78,7 @@ public class PointsOperationController {
@GetMapping(value = "/cleanInvalidPointsAndCalculateCurrentPoints/{id}")
@ApiOperation("清除过期积分并计算总积分,供客户端会员查询积分时调用")
@AnonymousAccess
public ResultInfo cleanInvalidPointsAndCalculateCurrentPoints(@PathVariable("id") Long id) {
Long aLong = this.pointsOperationService.cleanInvalidPointsAndCalculateCurrentPoints(id);
return ResultInfo.success(Objects.isNull(aLong) ? 0L : aLong);
......@@ -82,6 +86,7 @@ public class PointsOperationController {
@PostMapping(value = "/grantPointsByManual")
@ApiOperation("手动发放积分")
@AnonymousAccess
public ResultInfo grantPointsByManual(@Validated @RequestBody TempPoints tempPoints) {
Long memberId = tempPoints.getMemberId();
Long points = tempPoints.getPoints();
......@@ -104,6 +109,7 @@ public class PointsOperationController {
*/
@PostMapping(value = "/customPointsByUserTvPlatformAccount")
@ApiOperation("通过大屏账户积分消耗")
@AnonymousAccess
public ResultInfo customPointsByUserTvPlatformAccount(@Validated @RequestBody TempCustomPointBean tempIptvUser) {
String platformAccount = tempIptvUser.getPlatformAccount();
Long points = tempIptvUser.getPoints();
......@@ -142,6 +148,7 @@ public class PointsOperationController {
*/
@PostMapping(value = "/customPointsByUserId")
@ApiOperation("积分消耗")
@AnonymousAccess
public ResultInfo customPointsByUserId(@Validated @RequestBody TempPoints tempPoints) {
Long userId = tempPoints.getUserId();
// 设备类型 1:大屏;2:小屏(微信)3.小屏(xx)
......@@ -182,6 +189,7 @@ public class PointsOperationController {
@PostMapping(value = "/consumePoints")
@ApiOperation("积分消耗")
@AnonymousAccess
public ResultInfo customPoints(@Validated @RequestBody TempPoints tempPoints) {
Integer pointsType = tempPoints.getPointsType();
if (Objects.isNull(pointsType)) {
......
......@@ -5,8 +5,11 @@ import cn.hutool.core.util.StrUtil;
import com.alibaba.fastjson.JSONObject;
import com.topdraw.annotation.AnonymousAccess;
import com.topdraw.business.module.member.profile.domain.MemberProfile;
import com.topdraw.business.module.member.service.MemberService;
import com.topdraw.business.module.member.service.dto.MemberDTO;
import com.topdraw.business.module.user.iptv.domain.UserTv;
import com.topdraw.business.module.user.iptv.service.UserTvService;
import com.topdraw.business.module.user.iptv.service.dto.UserTvDTO;
import com.topdraw.business.module.user.weixin.domain.UserWeixin;
import com.topdraw.business.module.user.weixin.service.UserWeixinService;
import com.topdraw.business.module.user.weixin.service.dto.UserWeixinDTO;
......@@ -17,15 +20,14 @@ import com.topdraw.business.process.domian.weixin.SubscribeBean;
import com.topdraw.business.process.domian.weixin.SubscribeBeanEvent;
import com.topdraw.business.process.domian.weixin.WeiXinUserBean;
import com.topdraw.business.process.service.UserOperationService;
import com.topdraw.common.IResultInfo;
import com.topdraw.common.ResultInfo;
import com.topdraw.config.RedisKeyUtil;
import com.topdraw.exception.BadRequestException;
import com.topdraw.util.Base64Util;
import com.topdraw.util.JSONUtil;
import com.topdraw.utils.RedisUtils;
import com.topdraw.utils.StringUtils;
import com.topdraw.weixin.util.WeChatConstants;
import com.topdraw.weixin.util.WeiXinRequestUtil;
import com.topdraw.weixin.util.WeixinUtil;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
......@@ -37,6 +39,8 @@ import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import java.io.IOException;
import java.net.URLDecoder;
import java.util.Base64;
import java.util.List;
import java.util.Map;
import java.util.Objects;
......@@ -52,7 +56,9 @@ public class UserOperationController {
@Autowired
private UserWeixinService userWeixinService;
@Autowired
private WeiXinRequestUtil weixinRequestUtil;
private UserTvService userTvService;
@Autowired
private MemberService memberService;
@Autowired
private RedisUtils redisUtils;
......@@ -134,23 +140,56 @@ public class UserOperationController {
return ResultInfo.success(result);
}
@PutMapping(value = "/unbind")
@RequestMapping(value = "/unbind")
@ApiOperation("大屏用户解绑")
@AnonymousAccess
public ResultInfo unbind(@Validated(value = {UnbindGroup.class}) @RequestBody TempIptvUser resources) {
public ResultInfo unbind(@Validated @RequestBody TempIptvUser resources) {
UserTv userTv = new UserTv();
BeanUtils.copyProperties(resources,userTv);
String unionid = resources.getUnionid();
// Long memberId = resources.getMemberId();
String memberCode1 = resources.getMemberCode();
if (Objects.nonNull(memberCode1)) {
MemberDTO memberDTO = this.memberService.getByCode(memberCode1);
String memberCode = memberDTO.getCode();
if (StringUtils.isNotBlank(memberCode)) {
userTv.setMemberCode(memberCode);
this.userTvOperationService.unbind(userTv);
}
} else {
this.userTvOperationService.unbindByUnionId(userTv,unionid);
}
return ResultInfo.success();
}
@PutMapping(value = "/changeMainAccount")
@RequestMapping(value = "/changeMainAccount")
@ApiOperation("大屏更换主账号")
@AnonymousAccess
public ResultInfo changeMainAccount(@Validated(value = {UnbindGroup.class}) @RequestBody TempIptvUser resources) {
public ResultInfo changeMainAccount(@Validated @RequestBody TempIptvUser resources) {
UserTv userTv = new UserTv();
BeanUtils.copyProperties(resources,userTv);
Long memberId = resources.getMemberId();
String memberCode1 = resources.getMemberCode();
if (Objects.nonNull(memberCode1)) {
MemberDTO memberDTO = this.memberService.getByCode(memberCode1);
String memberCode = memberDTO.getCode();
if (StringUtils.isNotBlank(memberCode)) {
userTv.setMemberCode(memberCode);
this.userTvOperationService.changeMainAccount(userTv);
}
} else {
String unionid = resources.getUnionid();
this.userTvOperationService.changeMainAccountByUnionId(userTv,unionid);
}
return ResultInfo.success("update success");
}
......@@ -166,6 +205,7 @@ public class UserOperationController {
@ApiOperation("微信小程序登录")
@AnonymousAccess
public ResultInfo appletLogin(@Validated @RequestBody WeiXinUserBean resources) {
UserWeixinDTO result = this.userTvOperationService.appletLogin(resources);
return ResultInfo.success(result);
}
......@@ -178,9 +218,13 @@ public class UserOperationController {
if (StringUtils.isBlank(unionId))
Assert.state(StrUtil.isNotBlank(unionId), "跨屏绑定,请先进行授权");
Long platformUserId = resources.getPlatformUserId();
if (Objects.isNull(platformUserId))
Assert.state(StrUtil.isNotBlank(unionId), "大屏id不得为空");
String platformAccount = resources.getPlatformAccount();
if (Objects.isNull(platformAccount))
Assert.state(StrUtil.isNotBlank(platformAccount), "大屏账户不得为空");
UserTvDTO userTvDTO = this.userTvService.findByPlatformAccount(platformAccount);
resources.setPlatformUserId(userTvDTO.getId());
resources.setPlatformAccount(platformAccount);
boolean result = this.userTvOperationService.appletBind(resources);
return ResultInfo.success(result);
......@@ -190,12 +234,9 @@ public class UserOperationController {
@ApiOperation("微信公众号关注")
@AnonymousAccess
public ResultInfo subscribe(@Validated @RequestBody SubscribeBeanEvent data) throws IOException {
String content = data.getContent();
SubscribeBean subscribeBean = JSONUtil.parseMsg2Object(content, SubscribeBean.class);
this.parseSubscribe(subscribeBean);
boolean result = this.userTvOperationService.subscribe(subscribeBean);
return ResultInfo.success(result);
}
......@@ -209,18 +250,20 @@ public class UserOperationController {
private void parseSubscribe(SubscribeBean subscribeBean) throws IOException {
if (Objects.nonNull(subscribeBean)) {
String appId = subscribeBean.getAppid();
String appId = subscribeBean.getAppId();
// appId不得为空
if (StringUtils.isBlank(appId))
throw new BadRequestException("appId 不存在!");
// openId
String openId = subscribeBean.getOpenid();
String openId = subscribeBean.getOpenId();
if (StringUtils.isBlank(openId))
throw new BadRequestException("openId 不存在!");
// unionId
String unionId = null;
String unionId = subscribeBean.getUnionid();
if (StringUtils.isBlank(unionId))
throw new BadRequestException("unionId 不存在!");
// 匹配配置文件中的微信列表信息
Map<String, String> wxInfoMap = WeixinUtil.getWeixinInfoByAppid(appId);
......@@ -231,23 +274,8 @@ public class UserOperationController {
// 非订阅号,暂不处理。返回暂不支持
if (ObjectUtil.notEqual(appType, WeChatConstants.WX_SUBSCRIPTION))
throw new BadRequestException("非订阅号");
UserWeixinDTO userWeixinDTO = this.userWeixinService.findFirstByAppIdAndOpenId(appId, openId);
if (Objects.nonNull(userWeixinDTO.getId())) {
unionId = userWeixinDTO.getUnionid();
} else {
JSONObject userInfo = this.weixinRequestUtil.getUserInfo(wxInfoMap, openId);
unionId = userInfo.getString("unionid");
}
}
// unionId不得为空
if (StringUtils.isBlank(unionId))
throw new BadRequestException("unionId 不存在!");
subscribeBean.setUnionid(unionId);
// 大屏账户信息
JSONObject iptvUserInfo = null;
// 缓存的大屏信息,使用unionid即可
......@@ -255,7 +283,6 @@ public class UserOperationController {
if (StringUtils.isNotBlank(content)) {
// 大屏信息
iptvUserInfo = JSONObject.parseObject(content);
} else {
String eventKey = subscribeBean.getEventKey();
......@@ -272,6 +299,20 @@ public class UserOperationController {
// 用户自己搜索关注就没有大屏信息的话,否则表示扫码关注
if (Objects.nonNull(iptvUserInfo)) {
subscribeBean.setIptvUserInfo(iptvUserInfo);
String headimgurl = iptvUserInfo.get("headimgurl").toString();
String nickname = iptvUserInfo.get("nickname").toString();
if (org.apache.commons.lang3.StringUtils.isNotBlank(nickname)) {
String nicknameDecode = URLDecoder.decode(nickname, "UTF-8");
String nicknameEncode = Base64Util.encode(nicknameDecode);
subscribeBean.setNickname(nicknameEncode);
}
if (org.apache.commons.lang3.StringUtils.isNotBlank(headimgurl)) {
String headimgurlDecode = URLDecoder.decode(headimgurl, "UTF-8");
subscribeBean.setHeadimgurl(headimgurlDecode);
}
}
}
......@@ -282,6 +323,8 @@ public class UserOperationController {
@AnonymousAccess
public ResultInfo unsubscribe(@Validated @RequestBody SubscribeBeanEvent data) {
String content = data.getContent();
log.info("content ==>> [{}]",content);
SubscribeBean subscribeBean = JSONUtil.parseMsg2Object(content, SubscribeBean.class);
boolean result = this.userTvOperationService.unsubscribe(subscribeBean);
return ResultInfo.success(result);
......@@ -310,7 +353,6 @@ public class UserOperationController {
String unionid = json.getString("unionid");
Assert.state(StrUtil.isNotBlank(unionid), "unionid不可为空");
log.info("resources :[{}]",data);
String s = this.userTvOperationService.saveUserInfo(data);
return ResultInfo.success(s);
......@@ -320,7 +362,6 @@ public class UserOperationController {
@ApiOperation("保存用户手机号信息")
@AnonymousAccess
public ResultInfo saveUserWeixinPhone(@RequestBody WeiXinUserBean resources) {
log.info("resources :[{}]",resources);
MemberProfile s = this.userTvOperationService.saveUserWeixinPhone(resources);
return ResultInfo.success(s);
}
......
......@@ -30,12 +30,26 @@ public interface UserOperationService {
void unbind(UserTv userTv);
/**
*
* @param userTv
* @param unionId
*/
void unbindByUnionId(UserTv userTv,String unionId);
/**
* 大屏切换主账户(会员)
* @param userTv
*/
void changeMainAccount(UserTv userTv);
/**
*
* @param userTv
* @param unionId
*/
void changeMainAccountByUnionId(UserTv userTv,String unionId);
/**
* 微信小程序登录
* @param resources
* @return
......
package com.topdraw.business.process.service.impl;
import com.topdraw.aspect.AsyncMqSend;
import com.topdraw.business.module.coupon.history.domain.CouponHistory;
import com.topdraw.business.module.coupon.history.service.CouponHistoryService;
import com.topdraw.business.module.coupon.service.CouponService;
......@@ -51,6 +52,7 @@ public class CouponOperationServiceImpl implements CouponOperationService {
private static final Integer EXPIRE_FACTOR_DAY = 30;
@Override
@AsyncMqSend
public void grantCouponThroughTempCoupon(List<TempCoupon> tempCouponList) {
// 优惠券领取、使用历史记录表
for (TempCoupon tempCoupon : tempCouponList) {
......
package com.topdraw.business.process.service.impl;
import com.topdraw.aspect.AsyncMqSend;
import com.topdraw.business.module.exp.detail.domain.ExpDetail;
import com.topdraw.business.module.exp.detail.service.ExpDetailService;
import com.topdraw.business.module.member.domain.Member;
......@@ -50,6 +51,7 @@ public class ExpOperationServiceImpl implements ExpOperationService {
ThreadPoolTaskExecutor threadPoolTaskExecutor;
@Override
@AsyncMqSend
public void grantPointsThroughTempExp(List<TempExp> tempExpList) {
for (TempExp tempExp : tempExpList) {
......
......@@ -52,33 +52,45 @@ public class MemberOperationServiceImpl implements MemberOperationService {
@Override
public MemberDTO buyVip(BuyVipBean criteria) {
// 小程序账户id
Long id = criteria.getId();
// 查询微信账户
UserWeixinDTO userWeixin = this.findWeiXinById(criteria.getId());
// 过期时间
LocalDateTime vipExpireTime1 = criteria.getVipExpireTime();
Integer vip1 = criteria.getVip();
// 查询微信账户
UserWeixinDTO userWeixin = this.findWeiXinById(id);
Long memberId = userWeixin.getMemberId();
//
MemberDTO memberDTO = this.findById(memberId);
Integer vip = memberDTO.getVip();
MemberVipHistory memberVipHistory = new MemberVipHistory();
memberVipHistory.setMemberId(memberId).setVip(criteria.getVip()).setBeforeVip(vip);
if (ObjectUtil.equal(criteria.getVip(),vip)) {
memberVipHistory.setStatus(1);
//
LocalDateTime vipExpireTime = memberDTO.getVipExpireTime();
if (Objects.nonNull(vipExpireTime1)) {
vipExpireTime = vipExpireTime1;
}
LocalDateTime vipExpireTime = memberDTO.getVipExpireTime();
LocalDateTime now = LocalDateTime.now();
//判断之前有没有买过,没买过,失效时间为一年后;
if (Objects.isNull(vipExpireTime1)) {
if (ObjectUtil.isNull(vipExpireTime)) {
LocalDateTime localDateTime = now.plusYears(1L);
memberDTO.setVipExpireTime(localDateTime);
LocalDateTime now = LocalDateTime.now();
vipExpireTime = now.plusYears(1L);
} else {
vipExpireTime = vipExpireTime.plusYears(1L);
}
}
memberDTO.setVip(vip1);
memberDTO.setVipExpireTime(vipExpireTime);
/*if (){
//购买过 判断当前时间有没有过vip过期时间,没有过,失效时间加一年; 过了,当前时间加一年
//区分是当前vip续费 还是买新的vip
if (ObjectUtil.equal(criteria.getVip(), memberDTO.getVip())) {
if (ObjectUtil.equal(vip1, memberDTO.getVip())) {
if (now.isBefore(vipExpireTime)) {
LocalDateTime localDateTime = vipExpireTime.plusYears(1L);
memberDTO.setVipExpireTime(localDateTime);
......@@ -90,12 +102,17 @@ public class MemberOperationServiceImpl implements MemberOperationService {
LocalDateTime localDateTime = now.plusYears(1L);
memberDTO.setVipExpireTime(localDateTime);
}
}
memberDTO.setVip(criteria.getVip());
}*/
Member member = new Member();
BeanUtils.copyProperties(memberDTO,member);
this.memberService.create(member);
MemberVipHistory memberVipHistory = new MemberVipHistory();
memberVipHistory.setMemberId(memberId).setVip(vip1).setBeforeVip(vip);
if (ObjectUtil.equal(vip1,vip)) {
memberVipHistory.setStatus(1);
}
memberVipHistory.setVipExpireTime(member.getVipExpireTime());
memberVipHistoryService.create(memberVipHistory);
......
......@@ -296,6 +296,7 @@ public class PointsOperationServiceImpl implements PointsOperationService {
*/
@Override
@Transactional(rollbackFor = Exception.class)
@AsyncMqSend()
public void grantPointsThroughTempRightsList(List<TempPoints> tempPointsList){
log.info("------->>grantPointsThroughTempRightsList start1");
for (TempPoints tempPoints : tempPointsList){
......
......@@ -102,6 +102,8 @@ public class RightsOperationServiceImpl implements RightsOperationService {
rightsHistory.setRightsId(value.getId());
rightsHistory.setMemberId(value.getMemberId());
rightsHistory.setExpireTime(value.getExpireTime());
String memberCode = value.getMemberCode();
rightsHistory.setMemberCode(memberCode);
rightsHistoryList.add(rightsHistory);
});
......@@ -123,9 +125,7 @@ public class RightsOperationServiceImpl implements RightsOperationService {
* @param tempPointsList 权益列表
*/
private void grantPoint(List<TempPoints> tempPointsList) {
log.info(Thread.currentThread().getName() + "=========>>grantPoint start");
if (!CollectionUtils.isEmpty(tempPointsList))
log.info("=======>> tempPointsList ======>> " + tempPointsList.toString());
this.pointsOperationService.grantPointsThroughTempRightsList(tempPointsList);
}
......
......@@ -99,7 +99,12 @@ public class TaskOperationServiceImpl implements TaskOperationService {
DataSyncMsg dataSyncMsg = JSONUtil.parseMsg2Object(content, DataSyncMsg.class);
DataSyncMsg.MsgData msgData = dataSyncMsg.getMsg();
Integer event = msgData.getEvent();
String memberCode = msgData.getMemberCode();
Long memberId = msgData.getMemberId();
if (StringUtils.hasText(memberCode)) {
MemberDTO memberDTO = this.memberService.getByCode(memberCode);
memberId = memberDTO.getId();
}
// 检查当前会员的黑名单状态
boolean b = this.validatedMemberBlackStatus(memberId);
......@@ -138,7 +143,7 @@ public class TaskOperationServiceImpl implements TaskOperationService {
* @return
*/
private boolean checkRiskManagement(Long memberId , Map<RightType, Object> tempRightsMap) {
// TODO 风控
return false;
}
......@@ -160,40 +165,6 @@ public class TaskOperationServiceImpl implements TaskOperationService {
}
/**
* 永久权益
* @param memberId 会员id
* @return PermanentRightsDTO 永久权益
*/
@Deprecated
private PermanentRightsDTO getPermanentRights(Long memberId) {
PermanentRightsDTO permanentRights = null;
MemberDTO memberDTO = this.memberService.findById(memberId);
if (Objects.nonNull(memberDTO)) {
Integer level = memberDTO.getLevel();
// 永久权益
permanentRights = this.permanentRightsService.findByLevel(level);
}
return permanentRights;
}
/**
* 解析模板参数
* @param taskTemplate 任务模板
* @return Map<String, Object> 模板参数解析结果
*/
@Deprecated
private Map<String, Object> parseTaskTemplateParam(TaskTemplate taskTemplate) {
if (Objects.nonNull(taskTemplate)) {
String params = taskTemplate.getParams();
if (!StringUtils.isEmpty(params)) {
Map paramMap = JSONObject.parseObject(params,Map.class);
return paramMap;
}
}
return null;
}
/**
* 任务完成情况
* @param resources 任务完成情况
*/
......@@ -320,13 +291,15 @@ public class TaskOperationServiceImpl implements TaskOperationService {
/**
* 创建权益
* @param memberId
* @param memberCode
* @param rightsAmount
* @return
*/
private TempRights tmpRightsBuild(Long memberId ,Integer rightsAmount,RightsDTO rightsDTO){
private TempRights tmpRightsBuild(Long memberId ,String memberCode,Integer rightsAmount,RightsDTO rightsDTO){
TempRights tempRights = new TempRights();
BeanUtils.copyProperties(rightsDTO,tempRights);
tempRights.setMemberId(memberId);
tempRights.setMemberCode(memberCode);
tempRights.setRightsAmount(rightsAmount);
Long expireTime = rightsDTO.getExpireTime();
if (Objects.nonNull(expireTime))
......@@ -337,14 +310,15 @@ public class TaskOperationServiceImpl implements TaskOperationService {
/**
* 优惠券
* @param memberId
* @param rightsAmount
* @param memberCode
* @param rightsSendStrategy
* @return
*/
private TempCoupon tempCouponBuild(Long memberId ,Integer rightsAmount,Integer rightsSendStrategy,CouponDTO couponDTO,String nickname){
private TempCoupon tempCouponBuild(Long memberId ,String memberCode , Integer rightsAmount,Integer rightsSendStrategy,CouponDTO couponDTO,String nickname){
TempCoupon tempCoupon = new TempCoupon();
BeanUtils.copyProperties(couponDTO,tempCoupon);
tempCoupon.setCode(couponDTO.getCode());
tempCoupon.setMemberCode(memberCode);
tempCoupon.setMemberId(memberId);
tempCoupon.setRightsAmount(rightsAmount);
tempCoupon.setRightsSendStrategy(Objects.isNull(rightsSendStrategy) ? 0 : rightsSendStrategy);
......@@ -426,12 +400,13 @@ public class TaskOperationServiceImpl implements TaskOperationService {
Long memberId = memberDTO.getId();
String nickname = memberDTO.getNickname();
String memberCode = memberDTO.getCode();
// 权益详情
RightsDTO rightsDTO = this.getRight(rightsId);
if (Objects.nonNull(rightsDTO)){
// 用以保存权益历史
TempRights tempRights = this.tmpRightsBuild(memberId,rightsAmount,rightsDTO);
TempRights tempRights = this.tmpRightsBuild(memberId,memberCode,rightsAmount,rightsDTO);
rightsList.add(tempRights);
// 权益类型
......@@ -443,7 +418,7 @@ public class TaskOperationServiceImpl implements TaskOperationService {
CouponDTO couponDTO = this.findCouponById(entityId);
if (Objects.nonNull(couponDTO)) {
// 优惠券
TempCoupon tempCoupon = this.tempCouponBuild(memberId, rightsAmount, rightsSendStrategy, couponDTO, nickname);
TempCoupon tempCoupon = this.tempCouponBuild(memberId, memberCode,rightsAmount, rightsSendStrategy, couponDTO, nickname);
tempCouponList.add(tempCoupon);
}
}
......@@ -484,6 +459,7 @@ public class TaskOperationServiceImpl implements TaskOperationService {
tempExp.setMemberId(memberId);
tempExp.setAppCode(msgData.getAppCode());
tempExp.setMemberId(msgData.getMemberId());
tempExp.setMemberCode(msgData.getMemberCode());
tempExp.setItemId(msgData.getItemId());
tempExp.setAccountId(msgData.getAccountId());
tempExp.setRewardExp(task.getRewardExp());
......@@ -522,6 +498,7 @@ public class TaskOperationServiceImpl implements TaskOperationService {
}
tempPoints.setRewardPointsExpireTime(rewardPointsExpireTime);
tempPoints.setMemberId(memberId);
tempPoints.setMemberCode(msgData.getMemberCode());
tempPoints.setAppCode(msgData.getAppCode());
tempPoints.setPoints(rewardPoints);
tempPoints.setPointsType(pointsType);
......
......@@ -10,6 +10,7 @@ import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;
import java.sql.Timestamp;
import java.time.LocalDateTime;
import java.util.Collection;
import java.util.HashMap;
import java.util.Map;
......@@ -49,4 +50,6 @@ public class BaseTest {
}
}
......