mirror of
https://gitee.com/huangge1199_admin/vue-pro.git
synced 2024-11-22 23:31:52 +08:00
wallet:增加充值套餐
This commit is contained in:
parent
3489144757
commit
16cea61435
@ -1,78 +1,3 @@
|
|||||||
-- ----------------------------
|
|
||||||
-- 会员钱包表
|
|
||||||
-- ----------------------------
|
|
||||||
DROP TABLE IF EXISTS `pay_wallet`;
|
|
||||||
CREATE TABLE `pay_wallet`
|
|
||||||
(
|
|
||||||
`id` bigint NOT NULL AUTO_INCREMENT COMMENT '编号',
|
|
||||||
`user_id` bigint NOT NULL COMMENT '用户编号',
|
|
||||||
`user_type` tinyint NOT NULL DEFAULT 0 COMMENT '用户类型',
|
|
||||||
`balance` int NOT NULL DEFAULT 0 COMMENT '余额,单位分',
|
|
||||||
`total_expense` int NOT NULL DEFAULT 0 COMMENT '累计支出,单位分',
|
|
||||||
`total_recharge` int NOT NULL DEFAULT 0 COMMENT '累计充值,单位分',
|
|
||||||
`freeze_price` int NOT NULL DEFAULT 0 COMMENT '冻结金额,单位分',
|
|
||||||
`creator` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '' COMMENT '创建者',
|
|
||||||
`create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
|
|
||||||
`updater` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '' COMMENT '更新者',
|
|
||||||
`update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
|
|
||||||
`deleted` bit(1) NOT NULL DEFAULT b'0' COMMENT '是否删除',
|
|
||||||
`tenant_id` bigint NOT NULL DEFAULT 0 COMMENT '租户编号',
|
|
||||||
PRIMARY KEY (`id`) USING BTREE
|
|
||||||
) ENGINE=InnoDB COMMENT='会员钱包表';
|
|
||||||
|
|
||||||
-- ----------------------------
|
|
||||||
-- 会员钱包流水表
|
|
||||||
-- ----------------------------
|
|
||||||
DROP TABLE IF EXISTS `pay_wallet_transaction`;
|
|
||||||
CREATE TABLE `pay_wallet_transaction`
|
|
||||||
(
|
|
||||||
`id` bigint NOT NULL AUTO_INCREMENT COMMENT '编号',
|
|
||||||
`wallet_id` bigint NOT NULL COMMENT '会员钱包 id',
|
|
||||||
`biz_type` tinyint NOT NULL COMMENT '关联类型',
|
|
||||||
`biz_id` varchar(64) NOT NULL COMMENT '关联业务编号',
|
|
||||||
`no` varchar(64) NOT NULL COMMENT '流水号',
|
|
||||||
`title` varchar(128) NOT NULL COMMENT '流水标题',
|
|
||||||
`price` int NOT NULL COMMENT '交易金额, 单位分',
|
|
||||||
`balance` int NOT NULL COMMENT '余额, 单位分',
|
|
||||||
`creator` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '' COMMENT '创建者',
|
|
||||||
`create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
|
|
||||||
`updater` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '' COMMENT '更新者',
|
|
||||||
`update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
|
|
||||||
`deleted` bit(1) NOT NULL DEFAULT b'0' COMMENT '是否删除',
|
|
||||||
`tenant_id` bigint NOT NULL DEFAULT 0 COMMENT '租户编号',
|
|
||||||
PRIMARY KEY (`id`) USING BTREE
|
|
||||||
) ENGINE=InnoDB COMMENT='会员钱包流水表';
|
|
||||||
|
|
||||||
-- ----------------------------
|
|
||||||
-- 会员钱包充值
|
|
||||||
-- ----------------------------
|
|
||||||
DROP TABLE IF EXISTS `pay_wallet_recharge`;
|
|
||||||
CREATE TABLE `pay_wallet_recharge`
|
|
||||||
(
|
|
||||||
`id` bigint NOT NULL AUTO_INCREMENT COMMENT '编号',
|
|
||||||
`wallet_id` bigint NOT NULL COMMENT '会员钱包 id',
|
|
||||||
`total_price` int NOT NULL COMMENT '用户实际到账余额,例如充 100 送 20,则该值是 120',
|
|
||||||
`pay_price` int NOT NULL COMMENT '实际支付金额',
|
|
||||||
`bonus_price` int NOT NULL COMMENT '钱包赠送金额',
|
|
||||||
`pay_status` bit(1) NOT NULL DEFAULT b'0' COMMENT '是否已支付:[0:未支付 1:已经支付过]',
|
|
||||||
`pay_order_id` bigint NULL COMMENT '支付订单编号',
|
|
||||||
`pay_channel_code` varchar(16) NULL COMMENT '支付成功的支付渠道',
|
|
||||||
`pay_time` datetime NULL COMMENT '订单支付时间',
|
|
||||||
`pay_refund_id` bigint NULL COMMENT '支付退款单编号',
|
|
||||||
`refund_total_price` int NOT NULL DEFAULT 0 COMMENT '退款金额,包含赠送金额',
|
|
||||||
`refund_pay_price` int NOT NULL DEFAULT 0 COMMENT '退款支付金额',
|
|
||||||
`refund_bonus_price` int NOT NULL DEFAULT 0 COMMENT '退款钱包赠送金额',
|
|
||||||
`refund_time` datetime NULL COMMENT '退款时间',
|
|
||||||
`refund_status` int NOT NULL DEFAULT 0 COMMENT '退款状态',
|
|
||||||
`creator` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '' COMMENT '创建者',
|
|
||||||
`create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间',
|
|
||||||
`updater` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '' COMMENT '更新者',
|
|
||||||
`update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间',
|
|
||||||
`deleted` bit(1) NOT NULL DEFAULT b'0' COMMENT '是否删除',
|
|
||||||
`tenant_id` bigint NOT NULL DEFAULT 0 COMMENT '租户编号',
|
|
||||||
PRIMARY KEY (`id`) USING BTREE
|
|
||||||
) ENGINE=InnoDB COMMENT='会员钱包充值';
|
|
||||||
|
|
||||||
-- ----------------------------
|
-- ----------------------------
|
||||||
-- 转账单表
|
-- 转账单表
|
||||||
-- ----------------------------
|
-- ----------------------------
|
||||||
|
@ -2,6 +2,7 @@ package cn.iocoder.yudao.module.pay.controller.admin.wallet;
|
|||||||
|
|
||||||
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
|
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
|
||||||
import cn.iocoder.yudao.framework.operatelog.core.annotations.OperateLog;
|
import cn.iocoder.yudao.framework.operatelog.core.annotations.OperateLog;
|
||||||
|
import cn.iocoder.yudao.module.pay.api.notify.dto.PayOrderNotifyReqDTO;
|
||||||
import cn.iocoder.yudao.module.pay.api.notify.dto.PayRefundNotifyReqDTO;
|
import cn.iocoder.yudao.module.pay.api.notify.dto.PayRefundNotifyReqDTO;
|
||||||
import cn.iocoder.yudao.module.pay.service.wallet.PayWalletRechargeService;
|
import cn.iocoder.yudao.module.pay.service.wallet.PayWalletRechargeService;
|
||||||
import io.swagger.v3.oas.annotations.Operation;
|
import io.swagger.v3.oas.annotations.Operation;
|
||||||
@ -13,6 +14,7 @@ import org.springframework.web.bind.annotation.*;
|
|||||||
|
|
||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
import javax.annotation.security.PermitAll;
|
import javax.annotation.security.PermitAll;
|
||||||
|
import javax.validation.Valid;
|
||||||
|
|
||||||
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
|
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
|
||||||
import static cn.iocoder.yudao.framework.common.util.servlet.ServletUtils.getClientIP;
|
import static cn.iocoder.yudao.framework.common.util.servlet.ServletUtils.getClientIP;
|
||||||
@ -27,12 +29,22 @@ public class PayWalletRechargeController {
|
|||||||
@Resource
|
@Resource
|
||||||
private PayWalletRechargeService walletRechargeService;
|
private PayWalletRechargeService walletRechargeService;
|
||||||
|
|
||||||
|
@PostMapping("/update-paid")
|
||||||
|
@Operation(summary = "更新钱包充值为已充值") // 由 pay-module 支付服务,进行回调,可见 PayNotifyJob
|
||||||
|
@PermitAll // 无需登录, 内部校验实现
|
||||||
|
@OperateLog(enable = false) // 禁用操作日志,因为没有操作人
|
||||||
|
public CommonResult<Boolean> updateWalletRechargerPaid(@Valid @RequestBody PayOrderNotifyReqDTO notifyReqDTO) {
|
||||||
|
walletRechargeService.updateWalletRechargerPaid(Long.valueOf(notifyReqDTO.getMerchantOrderId()),
|
||||||
|
notifyReqDTO.getPayOrderId());
|
||||||
|
return success(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
// TODO @jason:发起退款,要 post 操作哈;
|
||||||
@GetMapping("/refund")
|
@GetMapping("/refund")
|
||||||
@Operation(summary = "发起钱包充值退款")
|
@Operation(summary = "发起钱包充值退款")
|
||||||
@Parameter(name = "id", description = "编号", required = true, example = "1024")
|
@Parameter(name = "id", description = "编号", required = true, example = "1024")
|
||||||
public CommonResult<Boolean> refundWalletRecharge(@RequestParam("id") Long id) {
|
public CommonResult<Boolean> refundWalletRecharge(@RequestParam("id") Long id) {
|
||||||
walletRechargeService.refundWalletRecharge(id,getClientIP());
|
walletRechargeService.refundWalletRecharge(id, getClientIP());
|
||||||
return success(true);
|
return success(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,8 +1,6 @@
|
|||||||
package cn.iocoder.yudao.module.pay.controller.app.wallet;
|
package cn.iocoder.yudao.module.pay.controller.app.wallet;
|
||||||
|
|
||||||
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
|
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
|
||||||
import cn.iocoder.yudao.framework.operatelog.core.annotations.OperateLog;
|
|
||||||
import cn.iocoder.yudao.module.pay.api.notify.dto.PayOrderNotifyReqDTO;
|
|
||||||
import cn.iocoder.yudao.module.pay.controller.app.wallet.vo.recharge.AppPayWalletRechargeCreateReqVO;
|
import cn.iocoder.yudao.module.pay.controller.app.wallet.vo.recharge.AppPayWalletRechargeCreateReqVO;
|
||||||
import cn.iocoder.yudao.module.pay.controller.app.wallet.vo.recharge.AppPayWalletRechargeCreateRespVO;
|
import cn.iocoder.yudao.module.pay.controller.app.wallet.vo.recharge.AppPayWalletRechargeCreateRespVO;
|
||||||
import cn.iocoder.yudao.module.pay.convert.wallet.PayWalletRechargeConvert;
|
import cn.iocoder.yudao.module.pay.convert.wallet.PayWalletRechargeConvert;
|
||||||
@ -18,7 +16,6 @@ import org.springframework.web.bind.annotation.RequestMapping;
|
|||||||
import org.springframework.web.bind.annotation.RestController;
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
import javax.annotation.security.PermitAll;
|
|
||||||
import javax.validation.Valid;
|
import javax.validation.Valid;
|
||||||
|
|
||||||
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
|
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
|
||||||
@ -44,13 +41,4 @@ public class AppPayWalletRechargeController {
|
|||||||
return success(PayWalletRechargeConvert.INSTANCE.convert(walletRecharge));
|
return success(PayWalletRechargeConvert.INSTANCE.convert(walletRecharge));
|
||||||
}
|
}
|
||||||
|
|
||||||
@PostMapping("/update-paid")
|
|
||||||
@Operation(summary = "更新钱包充值为已充值") // 由 pay-module 支付服务,进行回调,可见 PayNotifyJob
|
|
||||||
@PermitAll // 无需登录,安全由 内部校验实现
|
|
||||||
@OperateLog(enable = false) // 禁用操作日志,因为没有操作人
|
|
||||||
public CommonResult<Boolean> updateWalletRechargerPaid(@Valid @RequestBody PayOrderNotifyReqDTO notifyReqDTO) {
|
|
||||||
walletRechargeService.updateWalletRechargerPaid(Long.valueOf(notifyReqDTO.getMerchantOrderId()),
|
|
||||||
notifyReqDTO.getPayOrderId());
|
|
||||||
return success(true);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,35 @@
|
|||||||
|
package cn.iocoder.yudao.module.pay.controller.app.wallet;
|
||||||
|
|
||||||
|
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
|
||||||
|
import cn.iocoder.yudao.module.pay.controller.app.wallet.vo.recharge.AppPayWalletPackageRespVO;
|
||||||
|
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 java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
|
||||||
|
|
||||||
|
@Tag(name = "用户 APP - 钱包充值套餐")
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("/pay/wallet-recharge-package")
|
||||||
|
@Validated
|
||||||
|
@Slf4j
|
||||||
|
public class AppPayWalletRechargePackageController {
|
||||||
|
|
||||||
|
@GetMapping("/list")
|
||||||
|
@Operation(summary = "获得钱包充值套餐列表")
|
||||||
|
public CommonResult<List<AppPayWalletPackageRespVO>> getWalletRechargePackageList() {
|
||||||
|
// 只查询开启;需要按照 payPrice 排序;
|
||||||
|
List<AppPayWalletPackageRespVO> list = new ArrayList<>();
|
||||||
|
list.add(new AppPayWalletPackageRespVO().setId(1L).setName("土豆").setPayPrice(10).setBonusPrice(2));
|
||||||
|
list.add(new AppPayWalletPackageRespVO().setId(2L).setName("番茄").setPayPrice(20).setBonusPrice(5));
|
||||||
|
return success(list);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,20 @@
|
|||||||
|
package cn.iocoder.yudao.module.pay.controller.app.wallet.vo.recharge;
|
||||||
|
|
||||||
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
@Schema(description = "用户 APP - 用户充值套餐 Response VO")
|
||||||
|
@Data
|
||||||
|
public class AppPayWalletPackageRespVO {
|
||||||
|
|
||||||
|
@Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024")
|
||||||
|
private Long id;
|
||||||
|
@Schema(description = "套餐名", requiredMode = Schema.RequiredMode.REQUIRED, example = "小套餐")
|
||||||
|
private String name;
|
||||||
|
|
||||||
|
@Schema(description = "支付金额", requiredMode = Schema.RequiredMode.REQUIRED, example = "10")
|
||||||
|
private Integer payPrice;
|
||||||
|
@Schema(description = "赠送金额", requiredMode = Schema.RequiredMode.REQUIRED, example = "20")
|
||||||
|
private Integer bonusPrice;
|
||||||
|
|
||||||
|
}
|
@ -3,24 +3,27 @@ package cn.iocoder.yudao.module.pay.controller.app.wallet.vo.recharge;
|
|||||||
import io.swagger.v3.oas.annotations.media.Schema;
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
|
||||||
import javax.validation.constraints.DecimalMin;
|
|
||||||
import javax.validation.constraints.Min;
|
import javax.validation.constraints.Min;
|
||||||
import javax.validation.constraints.NotNull;
|
|
||||||
|
|
||||||
@Schema(description = "用户 APP - 创建钱包充值 Request VO")
|
@Schema(description = "用户 APP - 创建钱包充值 Request VO")
|
||||||
@Data
|
@Data
|
||||||
public class AppPayWalletRechargeCreateReqVO {
|
public class AppPayWalletRechargeCreateReqVO {
|
||||||
|
|
||||||
@Schema(description = "支付金额", requiredMode = Schema.RequiredMode.REQUIRED, example = "1000")
|
@Schema(description = "支付金额", requiredMode = Schema.RequiredMode.REQUIRED, example = "1000")
|
||||||
@NotNull(message = "支付金额不能为空")
|
// @NotNull(message = "支付金额不能为空")
|
||||||
@Min(value = 1, message = "支付金额必须大于零")
|
@Min(value = 1, message = "支付金额必须大于零")
|
||||||
private Integer payPrice;
|
private Integer payPrice;
|
||||||
|
|
||||||
// TODO @jason:这个是不是后端计算出来呀?不然前端可以直接搞了。。。
|
// TODO @jason:这个是不是后端计算出来呀?不然前端可以直接搞了。。。
|
||||||
// TOTO 那是不是搞一个充值模板
|
// TOTO 那是不是搞一个充值模板
|
||||||
@Schema(description = "钱包赠送金额", requiredMode = Schema.RequiredMode.REQUIRED, example = "1000")
|
@Schema(description = "钱包赠送金额", requiredMode = Schema.RequiredMode.REQUIRED, example = "1000")
|
||||||
@NotNull(message = "钱包赠送金额不能为空")
|
// @NotNull(message = "钱包赠送金额不能为空")
|
||||||
@DecimalMin(value = "0", message = "钱包赠送金额必须大于等于零")
|
// @DecimalMin(value = "0", message = "钱包赠送金额必须大于等于零")
|
||||||
private Integer bonusPrice;
|
private Integer bonusPrice = 0;
|
||||||
|
|
||||||
|
@Schema(description = "充值套餐编号", example = "1024")
|
||||||
|
private Long packageId;
|
||||||
|
|
||||||
|
// TODO @jason:可以改成 payPrice 和 packageId 两个至少一个不为空;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -3,7 +3,7 @@ package cn.iocoder.yudao.module.pay.controller.app.wallet.vo.wallet;
|
|||||||
import io.swagger.v3.oas.annotations.media.Schema;
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
|
||||||
@Schema(description = "用户 APP - 获取用户钱包 Response VO")
|
@Schema(description = "用户 APP - 用户钱包 Response VO")
|
||||||
@Data
|
@Data
|
||||||
public class AppPayWalletRespVO {
|
public class AppPayWalletRespVO {
|
||||||
|
|
||||||
|
@ -47,6 +47,7 @@ public class PayWalletRechargeDO extends BaseDO {
|
|||||||
* 钱包赠送金额
|
* 钱包赠送金额
|
||||||
*/
|
*/
|
||||||
private Integer bonusPrice;
|
private Integer bonusPrice;
|
||||||
|
// TODO @jason:如果有赠送金额,需要关联下 PayWalletPackageDO 的 id 字段
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 是否已支付
|
* 是否已支付
|
||||||
|
@ -0,0 +1,46 @@
|
|||||||
|
package cn.iocoder.yudao.module.pay.dal.dataobject.wallet;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.annotation.KeySequence;
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableId;
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableName;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 会员钱包充值套餐 DO
|
||||||
|
*
|
||||||
|
* 通过套餐充值时,可以赠送一定金额;
|
||||||
|
*
|
||||||
|
* @author 芋道源码
|
||||||
|
*/
|
||||||
|
@TableName(value ="pay_wallet_recharge_package")
|
||||||
|
@KeySequence("pay_wallet_recharge_package_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。
|
||||||
|
@Data
|
||||||
|
public class PayWalletRechargePackageDO {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 编号
|
||||||
|
*/
|
||||||
|
@TableId
|
||||||
|
private Long id;
|
||||||
|
/**
|
||||||
|
* 套餐名
|
||||||
|
*/
|
||||||
|
private String name;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 支付金额
|
||||||
|
*/
|
||||||
|
private Integer payPrice;
|
||||||
|
/**
|
||||||
|
* 赠送金额
|
||||||
|
*/
|
||||||
|
private Integer bonusPrice;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 状态
|
||||||
|
*
|
||||||
|
* 枚举 {@link cn.iocoder.yudao.framework.common.enums.CommonStatusEnum}
|
||||||
|
*/
|
||||||
|
private Integer status;
|
||||||
|
|
||||||
|
}
|
@ -40,6 +40,7 @@ import static cn.iocoder.yudao.module.pay.enums.refund.PayRefundStatusEnum.*;
|
|||||||
@Service
|
@Service
|
||||||
@Slf4j
|
@Slf4j
|
||||||
public class PayWalletRechargeServiceImpl implements PayWalletRechargeService {
|
public class PayWalletRechargeServiceImpl implements PayWalletRechargeService {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* TODO 放到 配置文件中
|
* TODO 放到 配置文件中
|
||||||
*/
|
*/
|
||||||
|
Loading…
Reference in New Issue
Block a user