mirror of
https://gitee.com/hhyykk/ipms-sjy.git
synced 2025-07-24 16:05:08 +08:00
新增获得支付钱包接口
This commit is contained in:
@ -0,0 +1,41 @@
|
||||
package cn.iocoder.yudao.module.pay.controller.app.wallet;
|
||||
|
||||
import cn.iocoder.yudao.framework.common.enums.UserTypeEnum;
|
||||
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
|
||||
import cn.iocoder.yudao.module.pay.controller.app.wallet.vo.AppPayWalletRespVO;
|
||||
import cn.iocoder.yudao.module.pay.convert.wallet.PayWalletConvert;
|
||||
import cn.iocoder.yudao.module.pay.dal.dataobject.wallet.PayWalletDO;
|
||||
import cn.iocoder.yudao.module.pay.service.wallet.PayWalletService;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
||||
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
|
||||
import static cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils.getLoginUserId;
|
||||
|
||||
/**
|
||||
* @author jason
|
||||
*/
|
||||
@Tag(name = "用户 APP - 支付钱包")
|
||||
@RestController
|
||||
@RequestMapping("/pay/wallet")
|
||||
@Validated
|
||||
@Slf4j
|
||||
public class AppPayWalletController {
|
||||
|
||||
@Resource
|
||||
private PayWalletService payWalletService;
|
||||
|
||||
@GetMapping("/get")
|
||||
@Operation(summary = "获取支付钱包")
|
||||
public CommonResult<AppPayWalletRespVO> getPayWallet() {
|
||||
PayWalletDO payWallet = payWalletService.getPayWallet(getLoginUserId(), UserTypeEnum.MEMBER.getValue());
|
||||
return success(PayWalletConvert.INSTANCE.convert(payWallet));
|
||||
}
|
||||
}
|
@ -0,0 +1,21 @@
|
||||
package cn.iocoder.yudao.module.pay.controller.app.wallet.vo;
|
||||
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* @author jason
|
||||
*/
|
||||
@Schema(description = "用户 APP - 获取用户钱包 Response VO")
|
||||
@Data
|
||||
public class AppPayWalletRespVO {
|
||||
|
||||
@Schema(description = "钱包余额,单位分", requiredMode = Schema.RequiredMode.REQUIRED, example = "100")
|
||||
private Integer balance;
|
||||
|
||||
@Schema(description = "累计支出, 单位分", requiredMode = Schema.RequiredMode.REQUIRED, example = "1000")
|
||||
private Long totalExpense;
|
||||
|
||||
@Schema(description = "累计充值, 单位分", requiredMode = Schema.RequiredMode.REQUIRED, example = "1000")
|
||||
private Long totalRecharge;
|
||||
}
|
@ -0,0 +1,14 @@
|
||||
package cn.iocoder.yudao.module.pay.convert.wallet;
|
||||
|
||||
import cn.iocoder.yudao.module.pay.controller.app.wallet.vo.AppPayWalletRespVO;
|
||||
import cn.iocoder.yudao.module.pay.dal.dataobject.wallet.PayWalletDO;
|
||||
import org.mapstruct.Mapper;
|
||||
import org.mapstruct.factory.Mappers;
|
||||
|
||||
@Mapper
|
||||
public interface PayWalletConvert {
|
||||
|
||||
PayWalletConvert INSTANCE = Mappers.getMapper(PayWalletConvert.class);
|
||||
|
||||
AppPayWalletRespVO convert(PayWalletDO bean);
|
||||
}
|
@ -1,86 +0,0 @@
|
||||
package cn.iocoder.yudao.module.pay.dal.dataobject.member;
|
||||
|
||||
import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO;
|
||||
import cn.iocoder.yudao.module.pay.enums.member.WalletOperateTypeEnum;
|
||||
import cn.iocoder.yudao.module.pay.enums.member.WalletTransactionGategoryEnum;
|
||||
import com.baomidou.mybatisplus.annotation.KeySequence;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import lombok.Data;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
/**
|
||||
* 支付-会员钱包明细 DO
|
||||
*
|
||||
* @author jason
|
||||
*/
|
||||
@TableName(value ="pay_member_wallet_transaction")
|
||||
@KeySequence("pay_member_wallet_transaction_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。
|
||||
@Data
|
||||
public class MemberWalletTransactionDO extends BaseDO {
|
||||
|
||||
/**
|
||||
* 编号
|
||||
*/
|
||||
@TableId
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 会员钱包 id
|
||||
*
|
||||
* 关联 {@link MemberWalletDO#getId()}
|
||||
*/
|
||||
private Long walletId;
|
||||
|
||||
/**
|
||||
* 用户 id
|
||||
*
|
||||
* 关联 MemberUserDO 的 id 编号
|
||||
*/
|
||||
private Long userId;
|
||||
|
||||
/**
|
||||
* 交易单号 @芋艿 这里是关联交易单号, 还是订单号 , 退款单号! ??
|
||||
*/
|
||||
private String tradeNo;
|
||||
|
||||
/**
|
||||
* 交易分类
|
||||
*
|
||||
* 枚举 {@link WalletTransactionGategoryEnum#getCategory()}
|
||||
*/
|
||||
private Integer category;
|
||||
|
||||
/**
|
||||
* 操作分类
|
||||
*
|
||||
* 枚举 {@link WalletOperateTypeEnum#getType()}
|
||||
*/
|
||||
private Integer operateType;
|
||||
|
||||
/**
|
||||
* 操作详情
|
||||
*/
|
||||
private String operateDesc;
|
||||
|
||||
/**
|
||||
* 交易金额, 单位分
|
||||
*/
|
||||
private Integer price;
|
||||
|
||||
/**
|
||||
* 余额, 单位分
|
||||
*/
|
||||
private Integer balance;
|
||||
|
||||
/**
|
||||
* 备注
|
||||
*/
|
||||
private String mark;
|
||||
|
||||
/**
|
||||
* 交易时间
|
||||
*/
|
||||
private LocalDateTime transactionTime;
|
||||
}
|
@ -1,21 +1,21 @@
|
||||
package cn.iocoder.yudao.module.pay.dal.dataobject.member;
|
||||
package cn.iocoder.yudao.module.pay.dal.dataobject.wallet;
|
||||
|
||||
import cn.iocoder.yudao.framework.common.enums.UserTypeEnum;
|
||||
import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO;
|
||||
import com.baomidou.mybatisplus.annotation.KeySequence;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import lombok.Data;
|
||||
|
||||
// TODO @jason:修改 MemberWalletDO 为 PayWalletDO
|
||||
/**
|
||||
* 支付 - 会员钱包 DO
|
||||
*
|
||||
* @author jason
|
||||
*/
|
||||
@TableName(value ="pay_member_wallet")
|
||||
@KeySequence("pay_member_wallet_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。
|
||||
@TableName(value ="pay_wallet")
|
||||
@KeySequence("pay_wallet_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。
|
||||
@Data
|
||||
public class MemberWalletDO extends BaseDO {
|
||||
public class PayWalletDO extends BaseDO {
|
||||
|
||||
/**
|
||||
* 编号
|
||||
@ -23,7 +23,6 @@ public class MemberWalletDO extends BaseDO {
|
||||
@TableId
|
||||
private Long id;
|
||||
|
||||
// TODO @jaosn:增加 userType 字段;
|
||||
/**
|
||||
* 用户 id
|
||||
*
|
||||
@ -32,6 +31,13 @@ public class MemberWalletDO extends BaseDO {
|
||||
*/
|
||||
private Long userId;
|
||||
|
||||
/**
|
||||
* 用户类型, 预留 多商户转帐可能需要用到
|
||||
*
|
||||
* 关联 {@link UserTypeEnum}
|
||||
*/
|
||||
private Integer userType;
|
||||
|
||||
/**
|
||||
* 余额, 单位分
|
||||
*/
|
||||
@ -40,10 +46,10 @@ public class MemberWalletDO extends BaseDO {
|
||||
/**
|
||||
* 累计支出, 单位分
|
||||
*/
|
||||
private Integer totalSpending;
|
||||
private Long totalExpense;
|
||||
|
||||
/**
|
||||
* 累计充值, 单位分
|
||||
*/
|
||||
private Integer totalTopUp;
|
||||
private Long totalRecharge;
|
||||
}
|
@ -0,0 +1,79 @@
|
||||
package cn.iocoder.yudao.module.pay.dal.dataobject.wallet;
|
||||
|
||||
import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO;
|
||||
import cn.iocoder.yudao.module.pay.enums.member.WalletBizTypeEnum;
|
||||
import com.baomidou.mybatisplus.annotation.KeySequence;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import lombok.Data;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
/**
|
||||
* 支付-会员钱包明细 DO
|
||||
*
|
||||
* @author jason
|
||||
*/
|
||||
@TableName(value ="pay_wallet_transaction")
|
||||
@KeySequence("pay_wallet_transaction_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。
|
||||
@Data
|
||||
public class PayWalletTransactionDO extends BaseDO {
|
||||
|
||||
/**
|
||||
* 编号
|
||||
*/
|
||||
@TableId
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 会员钱包 id
|
||||
*
|
||||
* 关联 {@link PayWalletDO#getId()}
|
||||
*/
|
||||
private Long walletId;
|
||||
|
||||
/**
|
||||
* 用户 id
|
||||
*
|
||||
* 关联 MemberUserDO 的 id 编号
|
||||
*/
|
||||
private Long userId;
|
||||
|
||||
/**
|
||||
* 关联业务
|
||||
*
|
||||
* 枚举 {@link WalletBizTypeEnum#getBizType()}
|
||||
*/
|
||||
private Integer bizType;
|
||||
|
||||
/**
|
||||
* 关联业务编号
|
||||
*/
|
||||
private Long bizId;
|
||||
|
||||
/**
|
||||
* 流水号
|
||||
*/
|
||||
private String no;
|
||||
|
||||
/**
|
||||
* 附加说明
|
||||
*/
|
||||
private String description;
|
||||
|
||||
/**
|
||||
* 交易金额, 单位分
|
||||
* 正值表示余额增加,负值表示余额减少
|
||||
*/
|
||||
private Integer amount;
|
||||
|
||||
/**
|
||||
* 交易后余额,单位分
|
||||
*/
|
||||
private Integer balance;
|
||||
|
||||
/**
|
||||
* 交易时间
|
||||
*/
|
||||
private LocalDateTime transactionTime;
|
||||
}
|
@ -1,15 +0,0 @@
|
||||
package cn.iocoder.yudao.module.pay.dal.mysql.member;
|
||||
|
||||
|
||||
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
|
||||
import cn.iocoder.yudao.module.pay.dal.dataobject.member.MemberWalletDO;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
@Mapper
|
||||
public interface MemberWalletMapper extends BaseMapperX<MemberWalletDO> {
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
@ -1,15 +0,0 @@
|
||||
package cn.iocoder.yudao.module.pay.dal.mysql.member;
|
||||
|
||||
|
||||
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
|
||||
import cn.iocoder.yudao.module.pay.dal.dataobject.member.MemberWalletTransactionDO;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
@Mapper
|
||||
public interface MemberWalletTransactionMapper extends BaseMapperX<MemberWalletTransactionDO> {
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
@ -0,0 +1,18 @@
|
||||
package cn.iocoder.yudao.module.pay.dal.mysql.wallet;
|
||||
|
||||
|
||||
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
|
||||
import cn.iocoder.yudao.module.pay.dal.dataobject.wallet.PayWalletDO;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
@Mapper
|
||||
public interface PayWalletMapper extends BaseMapperX<PayWalletDO> {
|
||||
|
||||
default PayWalletDO selectByUserIdAndType(Long userId, Integer userType) {
|
||||
return selectOne(PayWalletDO::getUserId, userId, PayWalletDO::getUserType, userType);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
@ -0,0 +1,15 @@
|
||||
package cn.iocoder.yudao.module.pay.dal.mysql.wallet;
|
||||
|
||||
|
||||
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
|
||||
import cn.iocoder.yudao.module.pay.dal.dataobject.wallet.PayWalletTransactionDO;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
@Mapper
|
||||
public interface PayWalletTransactionMapper extends BaseMapperX<PayWalletTransactionDO> {
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
@ -0,0 +1,18 @@
|
||||
package cn.iocoder.yudao.module.pay.service.wallet;
|
||||
|
||||
import cn.iocoder.yudao.module.pay.dal.dataobject.wallet.PayWalletDO;
|
||||
|
||||
/**
|
||||
* 支付钱包 Service 接口
|
||||
*
|
||||
* @author jason
|
||||
*/
|
||||
public interface PayWalletService {
|
||||
|
||||
/**
|
||||
* 得到用户的支付钱包
|
||||
* @param userId 用户 id
|
||||
* @param userType 用户类型
|
||||
*/
|
||||
PayWalletDO getPayWallet(Long userId, Integer userType);
|
||||
}
|
@ -0,0 +1,24 @@
|
||||
package cn.iocoder.yudao.module.pay.service.wallet;
|
||||
|
||||
import cn.iocoder.yudao.module.pay.dal.dataobject.wallet.PayWalletDO;
|
||||
import cn.iocoder.yudao.module.pay.dal.mysql.wallet.PayWalletMapper;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
|
||||
/**
|
||||
* 支付钱包 Service 实现类
|
||||
*
|
||||
* @author jason
|
||||
*/
|
||||
@Service
|
||||
public class PayWalletServiceImpl implements PayWalletService {
|
||||
|
||||
@Resource
|
||||
private PayWalletMapper payWalletMapper;
|
||||
|
||||
@Override
|
||||
public PayWalletDO getPayWallet(Long userId, Integer userType) {
|
||||
return payWalletMapper.selectByUserIdAndType(userId, userType);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user