mirror of
				https://gitee.com/hhyykk/ipms-sjy.git
				synced 2025-11-04 20:28:44 +08:00 
			
		
		
		
	wallet:增加充值套餐
This commit is contained in:
		@@ -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.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.service.wallet.PayWalletRechargeService;
 | 
			
		||||
import io.swagger.v3.oas.annotations.Operation;
 | 
			
		||||
@@ -13,6 +14,7 @@ import org.springframework.web.bind.annotation.*;
 | 
			
		||||
 | 
			
		||||
import javax.annotation.Resource;
 | 
			
		||||
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.util.servlet.ServletUtils.getClientIP;
 | 
			
		||||
@@ -27,12 +29,22 @@ public class PayWalletRechargeController {
 | 
			
		||||
    @Resource
 | 
			
		||||
    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")
 | 
			
		||||
    @Operation(summary = "发起钱包充值退款")
 | 
			
		||||
    @Parameter(name = "id", description = "编号", required = true, example = "1024")
 | 
			
		||||
    public CommonResult<Boolean> refundWalletRecharge(@RequestParam("id") Long id) {
 | 
			
		||||
        walletRechargeService.refundWalletRecharge(id,getClientIP());
 | 
			
		||||
        walletRechargeService.refundWalletRecharge(id, getClientIP());
 | 
			
		||||
        return success(true);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -1,8 +1,6 @@
 | 
			
		||||
package cn.iocoder.yudao.module.pay.controller.app.wallet;
 | 
			
		||||
 | 
			
		||||
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.AppPayWalletRechargeCreateRespVO;
 | 
			
		||||
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 javax.annotation.Resource;
 | 
			
		||||
import javax.annotation.security.PermitAll;
 | 
			
		||||
import javax.validation.Valid;
 | 
			
		||||
 | 
			
		||||
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
 | 
			
		||||
@@ -44,13 +41,4 @@ public class AppPayWalletRechargeController {
 | 
			
		||||
        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 lombok.Data;
 | 
			
		||||
 | 
			
		||||
import javax.validation.constraints.DecimalMin;
 | 
			
		||||
import javax.validation.constraints.Min;
 | 
			
		||||
import javax.validation.constraints.NotNull;
 | 
			
		||||
 | 
			
		||||
@Schema(description = "用户 APP - 创建钱包充值 Request VO")
 | 
			
		||||
@Data
 | 
			
		||||
public class AppPayWalletRechargeCreateReqVO {
 | 
			
		||||
 | 
			
		||||
    @Schema(description = "支付金额", requiredMode = Schema.RequiredMode.REQUIRED, example = "1000")
 | 
			
		||||
    @NotNull(message = "支付金额不能为空")
 | 
			
		||||
//    @NotNull(message = "支付金额不能为空")
 | 
			
		||||
    @Min(value = 1,  message = "支付金额必须大于零")
 | 
			
		||||
    private Integer payPrice;
 | 
			
		||||
 | 
			
		||||
    // TODO @jason:这个是不是后端计算出来呀?不然前端可以直接搞了。。。
 | 
			
		||||
    // TOTO 那是不是搞一个充值模板
 | 
			
		||||
    @Schema(description = "钱包赠送金额", requiredMode = Schema.RequiredMode.REQUIRED, example = "1000")
 | 
			
		||||
    @NotNull(message = "钱包赠送金额不能为空")
 | 
			
		||||
    @DecimalMin(value = "0",  message = "钱包赠送金额必须大于等于零")
 | 
			
		||||
    private Integer bonusPrice;
 | 
			
		||||
//    @NotNull(message = "钱包赠送金额不能为空")
 | 
			
		||||
//    @DecimalMin(value = "0",  message = "钱包赠送金额必须大于等于零")
 | 
			
		||||
    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 lombok.Data;
 | 
			
		||||
 | 
			
		||||
@Schema(description = "用户 APP - 获取用户钱包 Response VO")
 | 
			
		||||
@Schema(description = "用户 APP - 用户钱包 Response VO")
 | 
			
		||||
@Data
 | 
			
		||||
public class AppPayWalletRespVO {
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -47,6 +47,7 @@ public class PayWalletRechargeDO extends BaseDO {
 | 
			
		||||
     * 钱包赠送金额
 | 
			
		||||
     */
 | 
			
		||||
    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
 | 
			
		||||
@Slf4j
 | 
			
		||||
public class PayWalletRechargeServiceImpl implements PayWalletRechargeService {
 | 
			
		||||
    
 | 
			
		||||
    /**
 | 
			
		||||
     * TODO 放到 配置文件中
 | 
			
		||||
     */
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user