Merge remote-tracking branch 'origin/feature/mall_product' into feature/mall_product

This commit is contained in:
YunaiV 2023-10-16 09:07:13 +08:00
commit 69268b525a
18 changed files with 239 additions and 17 deletions

View File

@ -125,3 +125,58 @@ CREATE TABLE `pay_wallet_recharge` (
`tenant_id` bigint(0) NOT NULL DEFAULT 0 COMMENT '租户编号',
PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 9 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_unicode_ci COMMENT = '会员钱包充值' ROW_FORMAT = Dynamic;
-- 钱包充值套餐菜单脚本
INSERT INTO system_menu(
name, permission, type, sort, parent_id,
path, icon, component, status, component_name
)
VALUES (
'钱包管理', '', 1, 5, 1117,
'wallet', 'ep:caret-right', '', 0, ''
);
SELECT @parentId := LAST_INSERT_ID();
INSERT INTO system_menu(
name, permission, type, sort, parent_id,
path, icon, component, status, component_name
)
VALUES (
'充值套餐', '', 2, 2, @parentId,
'wallet-recharge-package', 'fa:leaf', 'pay/wallet/rechargePackage/index', 0, 'WalletRechargePackage'
);
SELECT @parentId := LAST_INSERT_ID();
-- 按钮 SQL
INSERT INTO system_menu(
name, permission, type, sort, parent_id,
path, icon, component, status
)
VALUES (
'钱包充值套餐查询', 'pay:wallet-recharge-package:query', 3, 1, @parentId,
'', '', '', 0
);
INSERT INTO system_menu(
name, permission, type, sort, parent_id,
path, icon, component, status
)
VALUES (
'钱包充值套餐创建', 'pay:wallet-recharge-package:create', 3, 2, @parentId,
'', '', '', 0
);
INSERT INTO system_menu(
name, permission, type, sort, parent_id,
path, icon, component, status
)
VALUES (
'钱包充值套餐更新', 'pay:wallet-recharge-package:update', 3, 3, @parentId,
'', '', '', 0
);
INSERT INTO system_menu(
name, permission, type, sort, parent_id,
path, icon, component, status
)
VALUES (
'钱包充值套餐删除', 'pay:wallet-recharge-package:delete', 3, 4, @parentId,
'', '', '', 0
);

View File

@ -1,8 +1,10 @@
package cn.iocoder.yudao.module.pay.controller.admin.wallet;
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
import cn.iocoder.yudao.module.pay.controller.admin.wallet.vo.PayWalletRespVO;
import cn.iocoder.yudao.module.pay.controller.admin.wallet.vo.PayWalletUserReqVO;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.module.pay.controller.admin.wallet.vo.wallet.PayWalletPageReqVO;
import cn.iocoder.yudao.module.pay.controller.admin.wallet.vo.wallet.PayWalletRespVO;
import cn.iocoder.yudao.module.pay.controller.admin.wallet.vo.wallet.PayWalletUserReqVO;
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;
@ -16,6 +18,7 @@ import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import javax.annotation.Resource;
import javax.validation.Valid;
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
@ -37,4 +40,12 @@ public class PayWalletController {
return success(PayWalletConvert.INSTANCE.convert02(wallet));
}
@GetMapping("/page")
@Operation(summary = "获得会员钱包分页")
@PreAuthorize("@ss.hasPermission('pay:wallet:query')")
public CommonResult<PageResult<PayWalletRespVO>> getWalletPage(@Valid PayWalletPageReqVO pageVO) {
PageResult<PayWalletDO> pageResult = payWalletService.getWalletPage(pageVO);
return success(PayWalletConvert.INSTANCE.convertPage(pageResult));
}
}

View File

@ -0,0 +1,40 @@
package cn.iocoder.yudao.module.pay.controller.admin.wallet;
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.module.pay.controller.admin.wallet.vo.transaction.PayWalletTransactionPageReqVO;
import cn.iocoder.yudao.module.pay.controller.admin.wallet.vo.transaction.PayWalletTransactionRespVO;
import cn.iocoder.yudao.module.pay.convert.wallet.PayWalletTransactionConvert;
import cn.iocoder.yudao.module.pay.dal.dataobject.wallet.PayWalletTransactionDO;
import cn.iocoder.yudao.module.pay.service.wallet.PayWalletTransactionService;
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 javax.validation.Valid;
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
@Tag(name = "管理后台 - 钱包余额明细")
@RestController
@RequestMapping("/pay/wallet-transaction")
@Validated
@Slf4j
public class PayWalletTransactionController {
@Resource
private PayWalletTransactionService payWalletTransactionService;
@GetMapping("/page")
@Operation(summary = "获得钱包流水分页")
public CommonResult<PageResult<PayWalletTransactionRespVO>> getWalletTransactionPage(
@Valid PayWalletTransactionPageReqVO pageReqVO) {
PageResult<PayWalletTransactionDO> result = payWalletTransactionService.getWalletTransactionPage(pageReqVO);
return success(PayWalletTransactionConvert.INSTANCE.convertPage2(result));
}
}

View File

@ -0,0 +1,13 @@
package cn.iocoder.yudao.module.pay.controller.admin.wallet.vo.transaction;
import cn.iocoder.yudao.framework.common.pojo.PageParam;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
@Schema(description = "管理后台 - 钱包流水分页 Request VO")
@Data
public class PayWalletTransactionPageReqVO extends PageParam {
@Schema(description = "钱包编号", example = "1")
private Long walletId;
}

View File

@ -0,0 +1,29 @@
package cn.iocoder.yudao.module.pay.controller.admin.wallet.vo.transaction;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import java.time.LocalDateTime;
@Schema(description = "用户 APP - 钱包流水分页 Response VO")
@Data
public class PayWalletTransactionRespVO {
@Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
private Long id;
@Schema(description = "钱包编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "5")
private Long walletId;
@Schema(description = "业务分类", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
private Integer bizType;
@Schema(description = "交易金额,单位分", requiredMode = Schema.RequiredMode.REQUIRED, example = "100")
private Long price;
@Schema(description = "流水标题", requiredMode = Schema.RequiredMode.REQUIRED, example = "土豆土豆")
private String title;
@Schema(description = "交易时间", requiredMode = Schema.RequiredMode.REQUIRED)
private LocalDateTime createTime;
}

View File

@ -1,4 +1,4 @@
package cn.iocoder.yudao.module.pay.controller.admin.wallet.vo;
package cn.iocoder.yudao.module.pay.controller.admin.wallet.vo.wallet;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
@ -18,7 +18,7 @@ public class PayWalletBaseVO {
@Schema(description = "用户类型", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
@NotNull(message = "用户类型不能为空")
private Byte userType;
private Integer userType;
@Schema(description = "余额,单位分", requiredMode = Schema.RequiredMode.REQUIRED)
@NotNull(message = "余额,单位分不能为空")

View File

@ -0,0 +1,27 @@
package cn.iocoder.yudao.module.pay.controller.admin.wallet.vo.wallet;
import lombok.*;
import io.swagger.v3.oas.annotations.media.Schema;
import cn.iocoder.yudao.framework.common.pojo.PageParam;
import org.springframework.format.annotation.DateTimeFormat;
import java.time.LocalDateTime;
import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;
@Schema(description = "管理后台 - 会员钱包分页 Request VO")
@Data
@EqualsAndHashCode(callSuper = true)
@ToString(callSuper = true)
public class PayWalletPageReqVO extends PageParam {
@Schema(description = "用户编号", example = "14138")
private Long userId;
@Schema(description = "用户类型", example = "1")
private Integer userType;
@Schema(description = "创建时间")
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
private LocalDateTime[] createTime;
}

View File

@ -1,4 +1,4 @@
package cn.iocoder.yudao.module.pay.controller.admin.wallet.vo;
package cn.iocoder.yudao.module.pay.controller.admin.wallet.vo.wallet;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;

View File

@ -1,4 +1,4 @@
package cn.iocoder.yudao.module.pay.controller.admin.wallet.vo;
package cn.iocoder.yudao.module.pay.controller.admin.wallet.vo.wallet;
import cn.iocoder.yudao.framework.common.enums.UserTypeEnum;
import cn.iocoder.yudao.framework.common.validation.InEnum;

View File

@ -9,9 +9,6 @@ import java.time.LocalDateTime;
@Data
public class AppPayWalletTransactionRespVO {
@Schema(description = "交易金额, 单位分", requiredMode = Schema.RequiredMode.REQUIRED, example = "100")
private Integer amount;
@Schema(description = "业务分类", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
private Integer bizType;

View File

@ -1,6 +1,7 @@
package cn.iocoder.yudao.module.pay.convert.wallet;
import cn.iocoder.yudao.module.pay.controller.admin.wallet.vo.PayWalletRespVO;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.module.pay.controller.admin.wallet.vo.wallet.PayWalletRespVO;
import cn.iocoder.yudao.module.pay.controller.app.wallet.vo.wallet.AppPayWalletRespVO;
import cn.iocoder.yudao.module.pay.dal.dataobject.wallet.PayWalletDO;
import org.mapstruct.Mapper;
@ -14,4 +15,6 @@ public interface PayWalletConvert {
AppPayWalletRespVO convert(PayWalletDO bean);
PayWalletRespVO convert02(PayWalletDO wallet);
PageResult<PayWalletRespVO> convertPage(PageResult<PayWalletDO> page);
}

View File

@ -1,6 +1,7 @@
package cn.iocoder.yudao.module.pay.convert.wallet;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.module.pay.controller.admin.wallet.vo.transaction.PayWalletTransactionRespVO;
import cn.iocoder.yudao.module.pay.controller.app.wallet.vo.transaction.AppPayWalletTransactionRespVO;
import cn.iocoder.yudao.module.pay.dal.dataobject.wallet.PayWalletTransactionDO;
import cn.iocoder.yudao.module.pay.service.wallet.bo.WalletTransactionCreateReqBO;
@ -14,6 +15,8 @@ public interface PayWalletTransactionConvert {
PageResult<AppPayWalletTransactionRespVO> convertPage(PageResult<PayWalletTransactionDO> page);
PageResult<PayWalletTransactionRespVO> convertPage2(PageResult<PayWalletTransactionDO> page);
PayWalletTransactionDO convert(WalletTransactionCreateReqBO bean);
}

View File

@ -1,7 +1,10 @@
package cn.iocoder.yudao.module.pay.dal.mysql.wallet;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.iocoder.yudao.module.pay.controller.admin.wallet.vo.wallet.PayWalletPageReqVO;
import cn.iocoder.yudao.module.pay.dal.dataobject.wallet.PayWalletDO;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import org.apache.ibatis.annotations.Mapper;
@ -14,6 +17,14 @@ public interface PayWalletMapper extends BaseMapperX<PayWalletDO> {
PayWalletDO::getUserType, userType);
}
default PageResult<PayWalletDO> selectPage(PayWalletPageReqVO reqVO) {
return selectPage(reqVO, new LambdaQueryWrapperX<PayWalletDO>()
.eqIfPresent(PayWalletDO::getUserId, reqVO.getUserId())
.eqIfPresent(PayWalletDO::getUserType, reqVO.getUserType())
.betweenIfPresent(PayWalletDO::getCreateTime, reqVO.getCreateTime())
.orderByDesc(PayWalletDO::getId));
}
/**
* 当消费退款时候 更新钱包
*

View File

@ -1,6 +1,7 @@
package cn.iocoder.yudao.module.pay.dal.mysql.wallet;
import cn.iocoder.yudao.framework.common.pojo.PageParam;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
@ -13,17 +14,17 @@ import java.util.Objects;
@Mapper
public interface PayWalletTransactionMapper extends BaseMapperX<PayWalletTransactionDO> {
default PageResult<PayWalletTransactionDO> selectPage(Long walletId,
AppPayWalletTransactionPageReqVO pageReqVO) {
default PageResult<PayWalletTransactionDO> selectPage(Long walletId, Integer type,
PageParam pageParam) {
LambdaQueryWrapperX<PayWalletTransactionDO> query = new LambdaQueryWrapperX<PayWalletTransactionDO>()
.eq(PayWalletTransactionDO::getWalletId, walletId);
if (Objects.equals(pageReqVO.getType(), AppPayWalletTransactionPageReqVO.TYPE_INCOME)) {
.eqIfPresent(PayWalletTransactionDO::getWalletId, walletId);
if (Objects.equals(type, AppPayWalletTransactionPageReqVO.TYPE_INCOME)) {
query.gt(PayWalletTransactionDO::getPrice, 0);
} else if (Objects.equals(pageReqVO.getType(), AppPayWalletTransactionPageReqVO.TYPE_EXPENSE)) {
} else if (Objects.equals(type, AppPayWalletTransactionPageReqVO.TYPE_EXPENSE)) {
query.lt(PayWalletTransactionDO::getPrice, 0);
}
query.orderByDesc(PayWalletTransactionDO::getId);
return selectPage(pageReqVO, query);
return selectPage(pageParam, query);
}
default PayWalletTransactionDO selectByNo(String no) {

View File

@ -1,5 +1,7 @@
package cn.iocoder.yudao.module.pay.service.wallet;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.module.pay.controller.admin.wallet.vo.wallet.PayWalletPageReqVO;
import cn.iocoder.yudao.module.pay.dal.dataobject.wallet.PayWalletDO;
import cn.iocoder.yudao.module.pay.dal.dataobject.wallet.PayWalletTransactionDO;
import cn.iocoder.yudao.module.pay.enums.member.PayWalletBizTypeEnum;
@ -28,6 +30,15 @@ public interface PayWalletService {
*/
PayWalletDO getWallet(Long walletId);
/**
* 获得会员钱包分页
*
* @param pageReqVO 分页查询
* @return 会员钱包分页
*/
PageResult<PayWalletDO> getWalletPage(PayWalletPageReqVO pageReqVO);
/**
* 钱包订单支付
*

View File

@ -1,6 +1,8 @@
package cn.iocoder.yudao.module.pay.service.wallet;
import cn.hutool.core.lang.Assert;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.module.pay.controller.admin.wallet.vo.wallet.PayWalletPageReqVO;
import cn.iocoder.yudao.module.pay.dal.dataobject.order.PayOrderExtensionDO;
import cn.iocoder.yudao.module.pay.dal.dataobject.refund.PayRefundDO;
import cn.iocoder.yudao.module.pay.dal.dataobject.wallet.PayWalletDO;
@ -60,6 +62,11 @@ public class PayWalletServiceImpl implements PayWalletService {
return walletMapper.selectById(walletId);
}
@Override
public PageResult<PayWalletDO> getWalletPage(PayWalletPageReqVO pageReqVO) {
return walletMapper.selectPage(pageReqVO);
}
@Override
@Transactional(rollbackFor = Exception.class)
public PayWalletTransactionDO orderPay(Long userId, Integer userType, String outTradeNo, Integer price) {

View File

@ -1,6 +1,7 @@
package cn.iocoder.yudao.module.pay.service.wallet;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.module.pay.controller.admin.wallet.vo.transaction.PayWalletTransactionPageReqVO;
import cn.iocoder.yudao.module.pay.controller.app.wallet.vo.transaction.AppPayWalletTransactionPageReqVO;
import cn.iocoder.yudao.module.pay.dal.dataobject.wallet.PayWalletTransactionDO;
import cn.iocoder.yudao.module.pay.enums.member.PayWalletBizTypeEnum;
@ -25,6 +26,13 @@ public interface PayWalletTransactionService {
PageResult<PayWalletTransactionDO> getWalletTransactionPage(Long userId, Integer userType,
AppPayWalletTransactionPageReqVO pageVO);
/**
* 查询钱包余额流水分页
*
* @param pageVO 分页查询参数
*/
PageResult<PayWalletTransactionDO> getWalletTransactionPage(PayWalletTransactionPageReqVO pageVO);
/**
* 新增钱包余额流水
*

View File

@ -1,6 +1,7 @@
package cn.iocoder.yudao.module.pay.service.wallet;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.module.pay.controller.admin.wallet.vo.transaction.PayWalletTransactionPageReqVO;
import cn.iocoder.yudao.module.pay.controller.app.wallet.vo.transaction.AppPayWalletTransactionPageReqVO;
import cn.iocoder.yudao.module.pay.convert.wallet.PayWalletTransactionConvert;
import cn.iocoder.yudao.module.pay.dal.dataobject.wallet.PayWalletDO;
@ -39,7 +40,12 @@ public class PayWalletTransactionServiceImpl implements PayWalletTransactionServ
public PageResult<PayWalletTransactionDO> getWalletTransactionPage(Long userId, Integer userType,
AppPayWalletTransactionPageReqVO pageVO) {
PayWalletDO wallet = payWalletService.getOrCreateWallet(userId, userType);
return payWalletTransactionMapper.selectPage(wallet.getId(), pageVO);
return payWalletTransactionMapper.selectPage(wallet.getId(), pageVO.getType(), pageVO);
}
@Override
public PageResult<PayWalletTransactionDO> getWalletTransactionPage(PayWalletTransactionPageReqVO pageVO) {
return payWalletTransactionMapper.selectPage(pageVO.getWalletId(), null, pageVO);
}
@Override