会员(微信支付) #72

Merged
root merged 1 commits from khy1 into master 2024-10-24 18:39:36 +08:00
14 changed files with 742 additions and 17 deletions

View File

@ -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") // 用于 OraclePostgreSQLKingbaseDB2H2 数据库的主键自增如果是 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;
/**
* 角色id0普通用户 1工作人员
*/
private Integer roleId;
}

View File

@ -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") // 用于 OraclePostgreSQLKingbaseDB2H2 数据库的主键自增如果是 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;
}

View File

@ -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);
}
}

View File

@ -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> {
}

View File

@ -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);
}

View File

@ -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);
}
}

View File

@ -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);
}

View File

@ -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;
}
}

View File

@ -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.ProductCommentApi;
import cn.iocoder.yudao.module.product.api.comment.dto.ProductCommentCreateReqDTO; 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.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.dataobject.pointorder.PointOrderDO;
import cn.iocoder.yudao.module.promotion.dal.mysql.pointorder.PointOrderMapper; import cn.iocoder.yudao.module.promotion.dal.mysql.pointorder.PointOrderMapper;
import cn.iocoder.yudao.module.system.api.social.SocialUserApi; 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.convert.order.TradeOrderConvert;
import cn.iocoder.yudao.module.trade.dal.dataobject.cart.CartDO; 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.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.TradeOrderDO;
import cn.iocoder.yudao.module.trade.dal.dataobject.order.TradeOrderItemDO; import cn.iocoder.yudao.module.trade.dal.dataobject.order.TradeOrderItemDO;
import cn.iocoder.yudao.module.trade.dal.mysql.order.TradeOrderItemMapper; 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.framework.order.core.utils.TradeOrderLogUtils;
import cn.iocoder.yudao.module.trade.service.cart.CartService; 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.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.TradeMessageService;
import cn.iocoder.yudao.module.trade.service.message.bo.TradeOrderMessageWhenDeliveryOrderReqBO; import cn.iocoder.yudao.module.trade.service.message.bo.TradeOrderMessageWhenDeliveryOrderReqBO;
import cn.iocoder.yudao.module.trade.service.order.handler.TradeOrderHandler; 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.collection.CollectionUtils.*;
import static cn.iocoder.yudao.framework.common.util.date.LocalDateTimeUtils.minusTime; 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.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.framework.web.core.util.WebFrameworkUtils.getTerminal;
import static cn.iocoder.yudao.module.trade.enums.ErrorCodeConstants.*; import static cn.iocoder.yudao.module.trade.enums.ErrorCodeConstants.*;
import static cn.iocoder.yudao.module.trade.enums.ErrorCodeConstants.ORDER_NOT_FOUND; import static cn.iocoder.yudao.module.trade.enums.ErrorCodeConstants.ORDER_NOT_FOUND;
@ -128,6 +132,12 @@ public class TradeOrderUpdateServiceImpl implements TradeOrderUpdateService {
@Resource @Resource
private ProductSpuApi productSpuApi; private ProductSpuApi productSpuApi;
@Resource
private TradeMemberUserService tradeMemberUserService;
@Resource
private TradePaidMemberUserService tradePaidMemberUserService;
// =================== Order =================== // =================== Order ===================
@ -325,6 +335,25 @@ public class TradeOrderUpdateServiceImpl implements TradeOrderUpdateService {
TradeOrderDO order = orderResult.getKey(); TradeOrderDO order = orderResult.getKey();
PayOrderRespDTO payOrder = orderResult.getValue(); 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 状态为已支付等待发货 // 2. 更新 TradeOrderDO 状态为已支付等待发货
int updateCount = tradeOrderMapper.updateByIdAndStatus(id, order.getStatus(), int updateCount = tradeOrderMapper.updateByIdAndStatus(id, order.getStatus(),
new TradeOrderDO().setStatus(TradeOrderStatusEnum.UNDELIVERED.getStatus()).setPayStatus(true) new TradeOrderDO().setStatus(TradeOrderStatusEnum.UNDELIVERED.getStatus()).setPayStatus(true)

View File

@ -189,4 +189,6 @@ public interface MemberUserService {
void updateUserDo(MemberUserDO user); void updateUserDo(MemberUserDO user);
void updateActivate(String cardName);
} }

View File

@ -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.exception.util.ServiceExceptionUtil.exception;
import static cn.iocoder.yudao.framework.common.util.servlet.ServletUtils.getClientIP; 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.*; import static cn.iocoder.yudao.module.member.enums.ErrorCodeConstants.*;
/** /**
@ -328,4 +329,16 @@ public class MemberUserServiceImpl implements MemberUserService {
memberUserMapper.updateById(memberUserDO); 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);
}
} }

View File

@ -61,6 +61,11 @@ public interface PaidMemberUserService {
PaidMemberUserDO getPaidMemberUserByOrderNo(String orderNO); PaidMemberUserDO getPaidMemberUserByOrderNo(String orderNO);
/**
* 判断当前支付方式
* */
String currentPayType(String payChannel);
/** /**
* 更新会员 * 更新会员
* *
@ -79,4 +84,6 @@ public interface PaidMemberUserService {
*/ */
PageResult<PaidMemberUserDO> getMemberUserPage(PaidMemberUserPageReqVO pageReqVO); PageResult<PaidMemberUserDO> getMemberUserPage(PaidMemberUserPageReqVO pageReqVO);
PaidMemberUserDO getByIdAndPayOrderId(Long id,Long payOrderId);
} }

View File

@ -146,6 +146,21 @@ public class PaidMemberUserServiceImpl implements PaidMemberUserService {
return paidMemberUserDO; 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 @Override
public void update(PaidMemberUserDO updateReqVO) { public void update(PaidMemberUserDO updateReqVO) {
// 校验存在 // 校验存在
@ -170,4 +185,12 @@ public class PaidMemberUserServiceImpl implements PaidMemberUserService {
return paidMemberUserMapper.selectPage(pageReqVO); 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;
}
} }

View File

@ -175,25 +175,12 @@ public class AppPaidMembeController {
LocalDateTime cardExpirationTime = paidMemberUserService.getDeadLineDay(notifyReqDTO.getCardName()); LocalDateTime cardExpirationTime = paidMemberUserService.getDeadLineDay(notifyReqDTO.getCardName());
paidMemberUserDO.setCardExpirationTime(cardExpirationTime); paidMemberUserDO.setCardExpirationTime(cardExpirationTime);
paidMemberUserDO.setPayChannel(notifyReqDTO.getPayChannel()); paidMemberUserDO.setPayChannel(notifyReqDTO.getPayChannel());
if (notifyReqDTO.getPayChannel().equals("wallet")){ String payType = paidMemberUserService.currentPayType(notifyReqDTO.getPayChannel());
paidMemberUserDO.setPayType("余额"); paidMemberUserDO.setPayType(payType);
} else if(notifyReqDTO.getPayChannel().startsWith("wx")){
paidMemberUserDO.setPayType("微信");
} else if (notifyReqDTO.getPayChannel().startsWith("alipay")) {
paidMemberUserDO.setPayType("支付宝");
} else {
paidMemberUserDO.setPayType("模拟支付");
}
//更新会员订单 //更新会员订单
paidMemberUserService.update(paidMemberUserDO); 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 // return success(PayMemberOrderConvert.INSTANCE.convert(paidMemberUserDO.getId(),payOrderId
// ,paidMemberUserDO.getCardExpirationTime(),memberUserDO.getActivate())); // ,paidMemberUserDO.getCardExpirationTime(),memberUserDO.getActivate()));
return success(true); return success(true);