Compare commits
2 Commits
e0b7148121
...
3e7ba69963
Author | SHA1 | Date | |
---|---|---|---|
3e7ba69963 | |||
734af91921 |
@ -0,0 +1,156 @@
|
||||
package cn.iocoder.yudao.module.trade.dal.dataobject.member;
|
||||
|
||||
import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum;
|
||||
import cn.iocoder.yudao.framework.common.enums.TerminalEnum;
|
||||
import cn.iocoder.yudao.framework.ip.core.Area;
|
||||
import cn.iocoder.yudao.framework.mybatis.core.type.LongListTypeHandler;
|
||||
import cn.iocoder.yudao.framework.tenant.core.db.TenantBaseDO;
|
||||
import cn.iocoder.yudao.module.system.enums.common.SexEnum;
|
||||
import com.baomidou.mybatisplus.annotation.KeySequence;
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import lombok.*;
|
||||
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 会员用户 DO
|
||||
*
|
||||
* uk_mobile 索引:基于 {@link #mobile} 字段
|
||||
*
|
||||
* @author 芋道源码
|
||||
*/
|
||||
@TableName(value = "member_user", autoResultMap = true)
|
||||
@KeySequence("member_user_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class TradeMemberUserDO extends TenantBaseDO {
|
||||
|
||||
// ========== 账号信息 ==========
|
||||
|
||||
/**
|
||||
* 用户ID
|
||||
*/
|
||||
@TableId
|
||||
private Long id;
|
||||
/**
|
||||
* 手机
|
||||
*/
|
||||
private String mobile;
|
||||
/**
|
||||
* 加密后的密码
|
||||
*
|
||||
* 因为目前使用 {@link BCryptPasswordEncoder} 加密器,所以无需自己处理 salt 盐
|
||||
*/
|
||||
private String password;
|
||||
/**
|
||||
* 帐号状态
|
||||
*
|
||||
* 枚举 {@link CommonStatusEnum}
|
||||
*/
|
||||
private Integer status;
|
||||
/**
|
||||
* 注册 IP
|
||||
*/
|
||||
private String registerIp;
|
||||
/**
|
||||
* 注册终端
|
||||
* 枚举 {@link TerminalEnum}
|
||||
*/
|
||||
private Integer registerTerminal;
|
||||
/**
|
||||
* 最后登录IP
|
||||
*/
|
||||
private String loginIp;
|
||||
/**
|
||||
* 最后登录时间
|
||||
*/
|
||||
private LocalDateTime loginDate;
|
||||
|
||||
// ========== 基础信息 ==========
|
||||
|
||||
/**
|
||||
* 用户昵称
|
||||
*/
|
||||
private String nickname;
|
||||
/**
|
||||
* 用户头像
|
||||
*/
|
||||
private String avatar;
|
||||
|
||||
/**
|
||||
* 真实名字
|
||||
*/
|
||||
private String name;
|
||||
/**
|
||||
* 性别
|
||||
*
|
||||
* 枚举 {@link SexEnum}
|
||||
*/
|
||||
private Integer sex;
|
||||
/**
|
||||
* 出生日期
|
||||
*/
|
||||
private LocalDateTime birthday;
|
||||
/**
|
||||
* 所在地
|
||||
*
|
||||
* 关联 {@link Area#getId()} 字段
|
||||
*/
|
||||
private Integer areaId;
|
||||
/**
|
||||
* 用户备注
|
||||
*/
|
||||
private String mark;
|
||||
|
||||
// ========== 其它信息 ==========
|
||||
|
||||
/**
|
||||
* 积分
|
||||
*/
|
||||
private Integer point;
|
||||
// TODO 疯狂:增加一个 totalPoint;个人信息接口要返回
|
||||
|
||||
/**
|
||||
* 会员标签列表,以逗号分隔
|
||||
*/
|
||||
@TableField(typeHandler = LongListTypeHandler.class)
|
||||
private List<Long> tagIds;
|
||||
|
||||
/**
|
||||
* 会员级别编号
|
||||
*
|
||||
* 关联 {@link MemberLevelDO#getId()} 字段
|
||||
*/
|
||||
private Long levelId;
|
||||
/**
|
||||
* 会员经验
|
||||
*/
|
||||
private Integer experience;
|
||||
/**
|
||||
* 用户分组编号
|
||||
*
|
||||
* 关联 {@link MemberGroupDO#getId()} 字段
|
||||
*/
|
||||
private Long groupId;
|
||||
|
||||
/**
|
||||
* 是否绑过卡,是否开通过会员(0:未开通,1:试用,2:有效期,3:永久)
|
||||
*/
|
||||
private Integer activate;
|
||||
|
||||
/**
|
||||
* 会员权益id
|
||||
*/
|
||||
private Long noticeInterestId;
|
||||
/**
|
||||
* 角色id(0:普通用户, 1:工作人员)
|
||||
*/
|
||||
private Integer roleId;
|
||||
}
|
@ -0,0 +1,157 @@
|
||||
package cn.iocoder.yudao.module.trade.dal.dataobject.member;
|
||||
|
||||
import cn.iocoder.yudao.framework.tenant.core.db.TenantBaseDO;
|
||||
import com.baomidou.mybatisplus.annotation.KeySequence;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import lombok.*;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
/**
|
||||
* 会员 DO
|
||||
*
|
||||
* @author 管理员
|
||||
*/
|
||||
@TableName("paid_member_user")
|
||||
@KeySequence("paid_member_user_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@ToString(callSuper = true)
|
||||
@Builder
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class TradePaidMemberUserDO extends TenantBaseDO {
|
||||
|
||||
/**
|
||||
* 编号
|
||||
*/
|
||||
@TableId
|
||||
private Long id;
|
||||
/**
|
||||
* 用户编号
|
||||
*/
|
||||
private Long uid;
|
||||
/**
|
||||
* 手机号
|
||||
*/
|
||||
private String mobile;
|
||||
/**
|
||||
* 密码
|
||||
*/
|
||||
private String password;
|
||||
/**
|
||||
* 状态
|
||||
*/
|
||||
private Integer status;
|
||||
/**
|
||||
* 注册 IP
|
||||
*/
|
||||
private String registerIp;
|
||||
/**
|
||||
* 注册终端
|
||||
*/
|
||||
private Integer registerTerminal;
|
||||
/**
|
||||
* 最后登录IP
|
||||
*/
|
||||
private String loginIp;
|
||||
/**
|
||||
* 最后登录时间
|
||||
*/
|
||||
private LocalDateTime loginDate;
|
||||
/**
|
||||
* 用户昵称
|
||||
*/
|
||||
private String nickname;
|
||||
/**
|
||||
* 头像
|
||||
*/
|
||||
private String avatar;
|
||||
/**
|
||||
* 真实名字
|
||||
*/
|
||||
private String name;
|
||||
/**
|
||||
* 性别
|
||||
*/
|
||||
private Integer sex;
|
||||
/**
|
||||
* 出生日期
|
||||
*/
|
||||
private LocalDateTime birthday;
|
||||
/**
|
||||
* 所在地
|
||||
*/
|
||||
private Integer areaId;
|
||||
/**
|
||||
* 用户备注
|
||||
*/
|
||||
private String mark;
|
||||
/**
|
||||
* 积分
|
||||
*/
|
||||
private Integer point;
|
||||
/**
|
||||
* 用户标签编号列表,以逗号分隔
|
||||
*/
|
||||
private String tagIds;
|
||||
/**
|
||||
* 等级编号
|
||||
*/
|
||||
private Long levelId;
|
||||
/**
|
||||
* 经验
|
||||
*/
|
||||
private Integer experience;
|
||||
/**
|
||||
* 用户分组编号
|
||||
*/
|
||||
private Long groupId;
|
||||
|
||||
/**
|
||||
* 是否支付,0:未支付,1:已支付
|
||||
* */
|
||||
private Boolean paid;
|
||||
|
||||
/*
|
||||
* 支付时间
|
||||
* */
|
||||
private LocalDateTime payTime;
|
||||
/**
|
||||
* 到期时间
|
||||
*/
|
||||
private LocalDateTime cardExpirationTime;
|
||||
/**
|
||||
* 支付金额,单位为分
|
||||
*/
|
||||
private Integer price;
|
||||
/**
|
||||
* 期限天数
|
||||
*/
|
||||
private String deadlineDay ;
|
||||
/**
|
||||
* 支付方式
|
||||
*/
|
||||
private String payType;
|
||||
/**
|
||||
* 支付渠道
|
||||
*/
|
||||
private String payChannel;
|
||||
/**
|
||||
* 订单号
|
||||
*/
|
||||
private String orderNo;
|
||||
/**
|
||||
* 支付订单编号
|
||||
*
|
||||
* 关联 {@link PayOrderDO#getId()}
|
||||
*/
|
||||
private Long payOrderId;
|
||||
/**
|
||||
* 会员类型
|
||||
*/
|
||||
private String payMemberType;
|
||||
|
||||
|
||||
}
|
@ -0,0 +1,72 @@
|
||||
package cn.iocoder.yudao.module.trade.dal.mysql.member;
|
||||
|
||||
import cn.hutool.core.lang.Assert;
|
||||
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
|
||||
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
|
||||
import cn.iocoder.yudao.module.trade.dal.dataobject.member.TradeMemberUserDO;
|
||||
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 会员 User Mapper
|
||||
*
|
||||
* @author 芋道源码
|
||||
*/
|
||||
@Mapper
|
||||
public interface TradeMemberUserMapper extends BaseMapperX<TradeMemberUserDO> {
|
||||
|
||||
default TradeMemberUserDO selectByMobile(String mobile) {
|
||||
return selectOne(TradeMemberUserDO::getMobile, mobile);
|
||||
}
|
||||
|
||||
default List<TradeMemberUserDO> selectListByNicknameLike(String nickname) {
|
||||
return selectList(new LambdaQueryWrapperX<TradeMemberUserDO>()
|
||||
.likeIfPresent(TradeMemberUserDO::getNickname, nickname));
|
||||
}
|
||||
|
||||
|
||||
default Long selectCountByGroupId(Long groupId) {
|
||||
return selectCount(TradeMemberUserDO::getGroupId, groupId);
|
||||
}
|
||||
|
||||
default Long selectCountByLevelId(Long levelId) {
|
||||
return selectCount(TradeMemberUserDO::getLevelId, levelId);
|
||||
}
|
||||
|
||||
default Long selectCountByTagId(Long tagId) {
|
||||
return selectCount(new LambdaQueryWrapperX<TradeMemberUserDO>()
|
||||
.apply("FIND_IN_SET({0}, tag_ids)", tagId));
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新用户积分(增加)
|
||||
*
|
||||
* @param id 用户编号
|
||||
* @param incrCount 增加积分(正数)
|
||||
*/
|
||||
default void updatePointIncr(Long id, Integer incrCount) {
|
||||
Assert.isTrue(incrCount > 0);
|
||||
LambdaUpdateWrapper<TradeMemberUserDO> lambdaUpdateWrapper = new LambdaUpdateWrapper<TradeMemberUserDO>()
|
||||
.setSql(" point = point + " + incrCount)
|
||||
.eq(TradeMemberUserDO::getId, id);
|
||||
update(null, lambdaUpdateWrapper);
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新用户积分(减少)
|
||||
*
|
||||
* @param id 用户编号
|
||||
* @param incrCount 增加积分(负数)
|
||||
* @return 更新行数
|
||||
*/
|
||||
default int updatePointDecr(Long id, Integer incrCount) {
|
||||
Assert.isTrue(incrCount < 0);
|
||||
LambdaUpdateWrapper<TradeMemberUserDO> lambdaUpdateWrapper = new LambdaUpdateWrapper<TradeMemberUserDO>()
|
||||
.setSql(" point = point + " + incrCount) // 负数,所以使用 + 号
|
||||
.eq(TradeMemberUserDO::getId, id);
|
||||
return update(null, lambdaUpdateWrapper);
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,14 @@
|
||||
package cn.iocoder.yudao.module.trade.dal.mysql.member;
|
||||
|
||||
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
|
||||
import cn.iocoder.yudao.module.trade.dal.dataobject.member.TradePaidMemberUserDO;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
/**
|
||||
* 会员 Mapper
|
||||
*
|
||||
* @author 管理员
|
||||
*/
|
||||
@Mapper
|
||||
public interface TradePaidMemberUserMapper extends BaseMapperX<TradePaidMemberUserDO> {
|
||||
}
|
@ -0,0 +1,26 @@
|
||||
package cn.iocoder.yudao.module.trade.service.member;
|
||||
|
||||
import cn.iocoder.yudao.module.trade.dal.dataobject.member.TradeMemberUserDO;
|
||||
|
||||
/**
|
||||
* 会员用户 Service 接口
|
||||
*
|
||||
* @author 芋道源码
|
||||
*/
|
||||
public interface TradeMemberUserService {
|
||||
|
||||
|
||||
/**
|
||||
* 通过用户 ID 查询用户
|
||||
*
|
||||
* @param id 用户ID
|
||||
* @return 用户对象信息
|
||||
*/
|
||||
TradeMemberUserDO getUser(Long id);
|
||||
|
||||
|
||||
void updateUserDo(TradeMemberUserDO user);
|
||||
|
||||
void updateActivate(String cardName);
|
||||
|
||||
}
|
@ -0,0 +1,107 @@
|
||||
package cn.iocoder.yudao.module.trade.service.member;
|
||||
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import cn.iocoder.yudao.module.trade.dal.dataobject.member.TradeMemberUserDO;
|
||||
import cn.iocoder.yudao.module.trade.dal.mysql.member.TradeMemberUserMapper;
|
||||
import com.google.common.annotations.VisibleForTesting;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.validation.Valid;
|
||||
|
||||
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
|
||||
import static cn.iocoder.yudao.framework.common.util.servlet.ServletUtils.getClientIP;
|
||||
import static cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils.getLoginUserId;
|
||||
import static cn.iocoder.yudao.module.member.enums.ErrorCodeConstants.*;
|
||||
|
||||
/**
|
||||
* 会员 User Service 实现类
|
||||
*
|
||||
* @author 芋道源码
|
||||
*/
|
||||
@Service
|
||||
@Valid
|
||||
@Slf4j
|
||||
public class TradeMemberUserServiceImpl implements TradeMemberUserService {
|
||||
|
||||
@Resource
|
||||
private TradeMemberUserMapper tradeMemberUserMapper;
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public TradeMemberUserDO getUser(Long id) {
|
||||
return tradeMemberUserMapper.selectById(id);
|
||||
}
|
||||
|
||||
|
||||
|
||||
private TradeMemberUserDO validateUserExists(String mobile) {
|
||||
TradeMemberUserDO user = tradeMemberUserMapper.selectByMobile(mobile);
|
||||
if (user == null) {
|
||||
throw exception(USER_MOBILE_NOT_EXISTS);
|
||||
}
|
||||
return user;
|
||||
}
|
||||
|
||||
|
||||
@VisibleForTesting
|
||||
TradeMemberUserDO validateUserExists(Long id) {
|
||||
if (id == null) {
|
||||
return null;
|
||||
}
|
||||
TradeMemberUserDO user = tradeMemberUserMapper.selectById(id);
|
||||
if (user == null) {
|
||||
throw exception(USER_NOT_EXISTS);
|
||||
}
|
||||
return user;
|
||||
}
|
||||
|
||||
@VisibleForTesting
|
||||
void validateMobileUnique(Long id, String mobile) {
|
||||
if (StrUtil.isBlank(mobile)) {
|
||||
return;
|
||||
}
|
||||
TradeMemberUserDO user = tradeMemberUserMapper.selectByMobile(mobile);
|
||||
if (user == null) {
|
||||
return;
|
||||
}
|
||||
// 如果 id 为空,说明不用比较是否为相同 id 的用户
|
||||
if (id == null) {
|
||||
throw exception(USER_MOBILE_USED, mobile);
|
||||
}
|
||||
if (!user.getId().equals(id)) {
|
||||
throw exception(USER_MOBILE_USED, mobile);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public void updateUserDo(TradeMemberUserDO tradeMemberUserDO) {
|
||||
// 校验存在
|
||||
validateUserExists(tradeMemberUserDO.getId());
|
||||
// 校验手机唯一
|
||||
validateMobileUnique(tradeMemberUserDO.getId(), tradeMemberUserDO.getMobile());
|
||||
|
||||
// 更新
|
||||
if(tradeMemberUserDO.getLevelId() != null && tradeMemberUserDO.getLevelId() == 5){
|
||||
tradeMemberUserDO.setLevelId(Long.parseLong("1"));
|
||||
}
|
||||
tradeMemberUserMapper.updateById(tradeMemberUserDO);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateActivate(String cardName) {
|
||||
TradeMemberUserDO tradeMemberUserDO = getUser(getLoginUserId());
|
||||
//设置个人信息的会员状态,0:未开通,1试用,2有效期,3永久
|
||||
if(cardName.equals("永久")){
|
||||
tradeMemberUserDO.setActivate(3);
|
||||
}else {
|
||||
tradeMemberUserDO.setActivate(2);
|
||||
}
|
||||
tradeMemberUserMapper.updateById(tradeMemberUserDO);
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,37 @@
|
||||
package cn.iocoder.yudao.module.trade.service.member;
|
||||
|
||||
import cn.iocoder.yudao.module.trade.dal.dataobject.member.TradePaidMemberUserDO;
|
||||
|
||||
import javax.validation.Valid;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
/**
|
||||
* 会员 Service 接口
|
||||
*
|
||||
* @author 管理员
|
||||
*/
|
||||
public interface TradePaidMemberUserService {
|
||||
|
||||
|
||||
|
||||
LocalDateTime getDeadLineDay(String cardName);
|
||||
|
||||
TradePaidMemberUserDO getPaidMemberUserByOrderNo(String orderNO);
|
||||
|
||||
/**
|
||||
* 判断当前支付方式
|
||||
* */
|
||||
String currentPayType(String payChannel);
|
||||
|
||||
/**
|
||||
* 更新会员
|
||||
*
|
||||
* @param updateReqVO 更新信息
|
||||
*/
|
||||
void update(@Valid TradePaidMemberUserDO updateReqVO);
|
||||
|
||||
|
||||
|
||||
TradePaidMemberUserDO getByIdAndPayOrderId(Long id, Long payOrderId);
|
||||
|
||||
}
|
@ -0,0 +1,95 @@
|
||||
package cn.iocoder.yudao.module.trade.service.member;
|
||||
|
||||
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
|
||||
import cn.iocoder.yudao.module.trade.dal.dataobject.member.TradePaidMemberUserDO;
|
||||
import cn.iocoder.yudao.module.trade.dal.mysql.member.TradePaidMemberUserMapper;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.temporal.ChronoUnit;
|
||||
|
||||
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
|
||||
import static cn.iocoder.yudao.module.member.enums.ErrorCodeConstants.PAID_MEMBER_ORDER_NOT_EXISTS;
|
||||
|
||||
/**
|
||||
* 会员 Service 实现类
|
||||
*
|
||||
* @author 管理员
|
||||
*/
|
||||
@Service
|
||||
@Validated
|
||||
public class TradeTradePaidMemberUserServiceImpl implements TradePaidMemberUserService {
|
||||
|
||||
@Resource
|
||||
private TradePaidMemberUserMapper tradePaidMemberUserMapper;
|
||||
|
||||
private void validateMemberUserExists(Long id) {
|
||||
if (tradePaidMemberUserMapper.selectById(id) == null) {
|
||||
throw exception(PAID_MEMBER_ORDER_NOT_EXISTS);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
//获取会员类型对应的过期时间
|
||||
@Override
|
||||
public LocalDateTime getDeadLineDay(String cardName) {
|
||||
LocalDateTime now = LocalDateTime.now();
|
||||
LocalDateTime deadlineDay;
|
||||
//判断是否具有过期时间,该操作为续费
|
||||
if (cardName.equals("试用")){
|
||||
deadlineDay = now.plus(1, ChronoUnit.DAYS);
|
||||
} else if (cardName.equals("月卡")) {
|
||||
deadlineDay = now.plus(1,ChronoUnit.MONTHS);
|
||||
} else if (cardName.equals("季卡")) {
|
||||
deadlineDay = now.plus(3,ChronoUnit.MONTHS);
|
||||
} else if (cardName.equals("年卡")) {
|
||||
deadlineDay = now.plus(1,ChronoUnit.YEARS);
|
||||
} else {
|
||||
//永久设置为一个非常远的的日期
|
||||
deadlineDay = LocalDateTime.of(9999,12,31,23,59,59);
|
||||
}
|
||||
return deadlineDay;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TradePaidMemberUserDO getPaidMemberUserByOrderNo(String orderNO) {
|
||||
TradePaidMemberUserDO tradePaidMemberUserDO = tradePaidMemberUserMapper.selectOne(TradePaidMemberUserDO::getOrderNo,orderNO);
|
||||
return tradePaidMemberUserDO;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String currentPayType(String payChannel) {
|
||||
String payType = null;
|
||||
if (payChannel.equals("wallet")){
|
||||
payType = "余额";
|
||||
} else if(payChannel.startsWith("wx")){
|
||||
payType = "微信";
|
||||
} else if (payChannel.startsWith("alipay")) {
|
||||
payType = "支付宝";
|
||||
} else {
|
||||
payType = "模拟支付";
|
||||
}
|
||||
return payType;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void update(TradePaidMemberUserDO updateReqVO) {
|
||||
// 校验存在
|
||||
validateMemberUserExists(updateReqVO.getId());
|
||||
tradePaidMemberUserMapper.updateById(updateReqVO);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public TradePaidMemberUserDO getByIdAndPayOrderId(Long id, Long payOrderId) {
|
||||
TradePaidMemberUserDO tradePaidMemberUserDO = tradePaidMemberUserMapper.selectOne(
|
||||
new LambdaQueryWrapperX<TradePaidMemberUserDO>().eqIfPresent(TradePaidMemberUserDO::getId,id)
|
||||
.eqIfPresent(TradePaidMemberUserDO::getPayOrderId,payOrderId));
|
||||
return tradePaidMemberUserDO;
|
||||
}
|
||||
|
||||
}
|
@ -22,7 +22,6 @@ import cn.iocoder.yudao.module.pay.enums.order.PayOrderStatusEnum;
|
||||
import cn.iocoder.yudao.module.product.api.comment.ProductCommentApi;
|
||||
import cn.iocoder.yudao.module.product.api.comment.dto.ProductCommentCreateReqDTO;
|
||||
import cn.iocoder.yudao.module.product.api.spu.ProductSpuApi;
|
||||
import cn.iocoder.yudao.module.product.api.spu.dto.ProductSpuRespDTO;
|
||||
import cn.iocoder.yudao.module.promotion.dal.dataobject.pointorder.PointOrderDO;
|
||||
import cn.iocoder.yudao.module.promotion.dal.mysql.pointorder.PointOrderMapper;
|
||||
import cn.iocoder.yudao.module.system.api.social.SocialUserApi;
|
||||
@ -38,6 +37,8 @@ import cn.iocoder.yudao.module.trade.controller.app.order.vo.item.AppTradeOrderI
|
||||
import cn.iocoder.yudao.module.trade.convert.order.TradeOrderConvert;
|
||||
import cn.iocoder.yudao.module.trade.dal.dataobject.cart.CartDO;
|
||||
import cn.iocoder.yudao.module.trade.dal.dataobject.delivery.DeliveryExpressDO;
|
||||
import cn.iocoder.yudao.module.trade.dal.dataobject.member.TradeMemberUserDO;
|
||||
import cn.iocoder.yudao.module.trade.dal.dataobject.member.TradePaidMemberUserDO;
|
||||
import cn.iocoder.yudao.module.trade.dal.dataobject.order.TradeOrderDO;
|
||||
import cn.iocoder.yudao.module.trade.dal.dataobject.order.TradeOrderItemDO;
|
||||
import cn.iocoder.yudao.module.trade.dal.mysql.order.TradeOrderItemMapper;
|
||||
@ -50,6 +51,8 @@ import cn.iocoder.yudao.module.trade.framework.order.core.annotations.TradeOrder
|
||||
import cn.iocoder.yudao.module.trade.framework.order.core.utils.TradeOrderLogUtils;
|
||||
import cn.iocoder.yudao.module.trade.service.cart.CartService;
|
||||
import cn.iocoder.yudao.module.trade.service.delivery.DeliveryExpressService;
|
||||
import cn.iocoder.yudao.module.trade.service.member.TradeMemberUserService;
|
||||
import cn.iocoder.yudao.module.trade.service.member.TradePaidMemberUserService;
|
||||
import cn.iocoder.yudao.module.trade.service.message.TradeMessageService;
|
||||
import cn.iocoder.yudao.module.trade.service.message.bo.TradeOrderMessageWhenDeliveryOrderReqBO;
|
||||
import cn.iocoder.yudao.module.trade.service.order.handler.TradeOrderHandler;
|
||||
@ -75,6 +78,7 @@ import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionU
|
||||
import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.*;
|
||||
import static cn.iocoder.yudao.framework.common.util.date.LocalDateTimeUtils.minusTime;
|
||||
import static cn.iocoder.yudao.framework.common.util.servlet.ServletUtils.getClientIP;
|
||||
import static cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils.getLoginUserId;
|
||||
import static cn.iocoder.yudao.framework.web.core.util.WebFrameworkUtils.getTerminal;
|
||||
import static cn.iocoder.yudao.module.trade.enums.ErrorCodeConstants.*;
|
||||
import static cn.iocoder.yudao.module.trade.enums.ErrorCodeConstants.ORDER_NOT_FOUND;
|
||||
@ -128,6 +132,12 @@ public class TradeOrderUpdateServiceImpl implements TradeOrderUpdateService {
|
||||
@Resource
|
||||
private ProductSpuApi productSpuApi;
|
||||
|
||||
@Resource
|
||||
private TradeMemberUserService tradeMemberUserService;
|
||||
|
||||
@Resource
|
||||
private TradePaidMemberUserService tradePaidMemberUserService;
|
||||
|
||||
|
||||
// =================== Order ===================
|
||||
|
||||
@ -325,6 +335,25 @@ public class TradeOrderUpdateServiceImpl implements TradeOrderUpdateService {
|
||||
TradeOrderDO order = orderResult.getKey();
|
||||
PayOrderRespDTO payOrder = orderResult.getValue();
|
||||
|
||||
//会员用户信息,支付状态修改
|
||||
TradeMemberUserDO tradeMemberUserDO = tradeMemberUserService.getUser(getLoginUserId());
|
||||
TradePaidMemberUserDO tradePaidMemberUserDO = tradePaidMemberUserService.getByIdAndPayOrderId(id,payOrderId);
|
||||
if(tradePaidMemberUserDO != null && tradeMemberUserDO != null){
|
||||
tradePaidMemberUserDO.setPayTime(LocalDateTime.now());
|
||||
tradePaidMemberUserDO.setPaid(true);
|
||||
//过期时间
|
||||
LocalDateTime cardExpirationTime = tradePaidMemberUserService.getDeadLineDay(tradePaidMemberUserDO.getPayMemberType());
|
||||
tradePaidMemberUserDO.setCardExpirationTime(cardExpirationTime);
|
||||
tradePaidMemberUserDO.setPayChannel(payOrder.getChannelCode());
|
||||
//支付方式
|
||||
String payType = tradePaidMemberUserService.currentPayType(payOrder.getChannelCode());
|
||||
tradePaidMemberUserDO.setPayType(payType);
|
||||
//更新会员订单
|
||||
tradePaidMemberUserService.update(tradePaidMemberUserDO);
|
||||
//更新用户会员状态
|
||||
tradeMemberUserService.updateActivate(tradePaidMemberUserDO.getPayMemberType());
|
||||
}
|
||||
|
||||
// 2. 更新 TradeOrderDO 状态为已支付,等待发货
|
||||
int updateCount = tradeOrderMapper.updateByIdAndStatus(id, order.getStatus(),
|
||||
new TradeOrderDO().setStatus(TradeOrderStatusEnum.UNDELIVERED.getStatus()).setPayStatus(true)
|
||||
|
@ -189,4 +189,6 @@ public interface MemberUserService {
|
||||
|
||||
void updateUserDo(MemberUserDO user);
|
||||
|
||||
void updateActivate(String cardName);
|
||||
|
||||
}
|
||||
|
@ -38,6 +38,7 @@ import java.util.List;
|
||||
|
||||
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
|
||||
import static cn.iocoder.yudao.framework.common.util.servlet.ServletUtils.getClientIP;
|
||||
import static cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils.getLoginUserId;
|
||||
import static cn.iocoder.yudao.module.member.enums.ErrorCodeConstants.*;
|
||||
|
||||
/**
|
||||
@ -328,4 +329,16 @@ public class MemberUserServiceImpl implements MemberUserService {
|
||||
memberUserMapper.updateById(memberUserDO);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateActivate(String cardName) {
|
||||
MemberUserDO memberUserDO = getUser(getLoginUserId());
|
||||
//设置个人信息的会员状态,0:未开通,1试用,2有效期,3永久
|
||||
if(cardName.equals("永久")){
|
||||
memberUserDO.setActivate(3);
|
||||
}else {
|
||||
memberUserDO.setActivate(2);
|
||||
}
|
||||
memberUserMapper.updateById(memberUserDO);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -61,6 +61,11 @@ public interface PaidMemberUserService {
|
||||
|
||||
PaidMemberUserDO getPaidMemberUserByOrderNo(String orderNO);
|
||||
|
||||
/**
|
||||
* 判断当前支付方式
|
||||
* */
|
||||
String currentPayType(String payChannel);
|
||||
|
||||
/**
|
||||
* 更新会员
|
||||
*
|
||||
@ -79,4 +84,6 @@ public interface PaidMemberUserService {
|
||||
*/
|
||||
PageResult<PaidMemberUserDO> getMemberUserPage(PaidMemberUserPageReqVO pageReqVO);
|
||||
|
||||
PaidMemberUserDO getByIdAndPayOrderId(Long id,Long payOrderId);
|
||||
|
||||
}
|
@ -146,6 +146,21 @@ public class PaidMemberUserServiceImpl implements PaidMemberUserService {
|
||||
return paidMemberUserDO;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String currentPayType(String payChannel) {
|
||||
String payType = null;
|
||||
if (payChannel.equals("wallet")){
|
||||
payType = "余额";
|
||||
} else if(payChannel.startsWith("wx")){
|
||||
payType = "微信";
|
||||
} else if (payChannel.startsWith("alipay")) {
|
||||
payType = "支付宝";
|
||||
} else {
|
||||
payType = "模拟支付";
|
||||
}
|
||||
return payType;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void update(PaidMemberUserDO updateReqVO) {
|
||||
// 校验存在
|
||||
@ -170,4 +185,12 @@ public class PaidMemberUserServiceImpl implements PaidMemberUserService {
|
||||
return paidMemberUserMapper.selectPage(pageReqVO);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PaidMemberUserDO getByIdAndPayOrderId(Long id, Long payOrderId) {
|
||||
PaidMemberUserDO paidMemberUserDO = paidMemberUserMapper.selectOne(
|
||||
new LambdaQueryWrapperX<PaidMemberUserDO>().eqIfPresent(PaidMemberUserDO::getId,id)
|
||||
.eqIfPresent(PaidMemberUserDO::getPayOrderId,payOrderId));
|
||||
return paidMemberUserDO;
|
||||
}
|
||||
|
||||
}
|
@ -175,25 +175,12 @@ public class AppPaidMembeController {
|
||||
LocalDateTime cardExpirationTime = paidMemberUserService.getDeadLineDay(notifyReqDTO.getCardName());
|
||||
paidMemberUserDO.setCardExpirationTime(cardExpirationTime);
|
||||
paidMemberUserDO.setPayChannel(notifyReqDTO.getPayChannel());
|
||||
if (notifyReqDTO.getPayChannel().equals("wallet")){
|
||||
paidMemberUserDO.setPayType("余额");
|
||||
} else if(notifyReqDTO.getPayChannel().startsWith("wx")){
|
||||
paidMemberUserDO.setPayType("微信");
|
||||
} else if (notifyReqDTO.getPayChannel().startsWith("alipay")) {
|
||||
paidMemberUserDO.setPayType("支付宝");
|
||||
} else {
|
||||
paidMemberUserDO.setPayType("模拟支付");
|
||||
}
|
||||
String payType = paidMemberUserService.currentPayType(notifyReqDTO.getPayChannel());
|
||||
paidMemberUserDO.setPayType(payType);
|
||||
//更新会员订单
|
||||
paidMemberUserService.update(paidMemberUserDO);
|
||||
//设置个人信息的会员状态,0:未开通,1试用,2有效期,3永久
|
||||
if(notifyReqDTO.getCardName().equals("永久")){
|
||||
memberUserDO.setActivate(3);
|
||||
}else {
|
||||
memberUserDO.setActivate(2);
|
||||
}
|
||||
//更新用户会员状态
|
||||
memberUserService.updateUserDo(memberUserDO);
|
||||
memberUserService.updateActivate(paidMemberUserDO.getPayMemberType());
|
||||
// return success(PayMemberOrderConvert.INSTANCE.convert(paidMemberUserDO.getId(),payOrderId
|
||||
// ,paidMemberUserDO.getCardExpirationTime(),memberUserDO.getActivate()));
|
||||
return success(true);
|
||||
|
Loading…
Reference in New Issue
Block a user