Commit d3f03540f8ea6512a8e75562e11f0edc993af189
Merge remote-tracking branch 'yudao/feature/mall_product' into feature/mall_product
Showing
32 changed files
with
180 additions
and
158 deletions
sql/mysql/pay_wallet.sql
| 1 | 1 | -- ---------------------------- |
| 2 | --- 会员钱包表 | |
| 3 | --- ---------------------------- | |
| 4 | -DROP TABLE IF EXISTS `pay_wallet`; | |
| 5 | -CREATE TABLE `pay_wallet` | |
| 6 | -( | |
| 7 | - `id` bigint NOT NULL AUTO_INCREMENT COMMENT '编号', | |
| 8 | - `user_id` bigint NOT NULL COMMENT '用户编号', | |
| 9 | - `user_type` tinyint NOT NULL DEFAULT 0 COMMENT '用户类型', | |
| 10 | - `balance` int NOT NULL DEFAULT 0 COMMENT '余额,单位分', | |
| 11 | - `total_expense` int NOT NULL DEFAULT 0 COMMENT '累计支出,单位分', | |
| 12 | - `total_recharge` int NOT NULL DEFAULT 0 COMMENT '累计充值,单位分', | |
| 13 | - `freeze_price` int NOT NULL DEFAULT 0 COMMENT '冻结金额,单位分', | |
| 14 | - `creator` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '' COMMENT '创建者', | |
| 15 | - `create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', | |
| 16 | - `updater` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '' COMMENT '更新者', | |
| 17 | - `update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间', | |
| 18 | - `deleted` bit(1) NOT NULL DEFAULT b'0' COMMENT '是否删除', | |
| 19 | - `tenant_id` bigint NOT NULL DEFAULT 0 COMMENT '租户编号', | |
| 20 | - PRIMARY KEY (`id`) USING BTREE | |
| 21 | -) ENGINE=InnoDB COMMENT='会员钱包表'; | |
| 22 | - | |
| 23 | --- ---------------------------- | |
| 24 | --- 会员钱包流水表 | |
| 25 | --- ---------------------------- | |
| 26 | -DROP TABLE IF EXISTS `pay_wallet_transaction`; | |
| 27 | -CREATE TABLE `pay_wallet_transaction` | |
| 28 | -( | |
| 29 | - `id` bigint NOT NULL AUTO_INCREMENT COMMENT '编号', | |
| 30 | - `wallet_id` bigint NOT NULL COMMENT '会员钱包 id', | |
| 31 | - `biz_type` tinyint NOT NULL COMMENT '关联类型', | |
| 32 | - `biz_id` varchar(64) NOT NULL COMMENT '关联业务编号', | |
| 33 | - `no` varchar(64) NOT NULL COMMENT '流水号', | |
| 34 | - `title` varchar(128) NOT NULL COMMENT '流水标题', | |
| 35 | - `price` int NOT NULL COMMENT '交易金额, 单位分', | |
| 36 | - `balance` int NOT NULL COMMENT '余额, 单位分', | |
| 37 | - `creator` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '' COMMENT '创建者', | |
| 38 | - `create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', | |
| 39 | - `updater` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '' COMMENT '更新者', | |
| 40 | - `update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间', | |
| 41 | - `deleted` bit(1) NOT NULL DEFAULT b'0' COMMENT '是否删除', | |
| 42 | - `tenant_id` bigint NOT NULL DEFAULT 0 COMMENT '租户编号', | |
| 43 | - PRIMARY KEY (`id`) USING BTREE | |
| 44 | -) ENGINE=InnoDB COMMENT='会员钱包流水表'; | |
| 45 | - | |
| 46 | --- ---------------------------- | |
| 47 | --- 会员钱包充值 | |
| 48 | --- ---------------------------- | |
| 49 | -DROP TABLE IF EXISTS `pay_wallet_recharge`; | |
| 50 | -CREATE TABLE `pay_wallet_recharge` | |
| 51 | -( | |
| 52 | - `id` bigint NOT NULL AUTO_INCREMENT COMMENT '编号', | |
| 53 | - `wallet_id` bigint NOT NULL COMMENT '会员钱包 id', | |
| 54 | - `total_price` int NOT NULL COMMENT '用户实际到账余额,例如充 100 送 20,则该值是 120', | |
| 55 | - `pay_price` int NOT NULL COMMENT '实际支付金额', | |
| 56 | - `bonus_price` int NOT NULL COMMENT '钱包赠送金额', | |
| 57 | - `pay_status` bit(1) NOT NULL DEFAULT b'0' COMMENT '是否已支付:[0:未支付 1:已经支付过]', | |
| 58 | - `pay_order_id` bigint NULL COMMENT '支付订单编号', | |
| 59 | - `pay_channel_code` varchar(16) NULL COMMENT '支付成功的支付渠道', | |
| 60 | - `pay_time` datetime NULL COMMENT '订单支付时间', | |
| 61 | - `pay_refund_id` bigint NULL COMMENT '支付退款单编号', | |
| 62 | - `refund_total_price` int NOT NULL DEFAULT 0 COMMENT '退款金额,包含赠送金额', | |
| 63 | - `refund_pay_price` int NOT NULL DEFAULT 0 COMMENT '退款支付金额', | |
| 64 | - `refund_bonus_price` int NOT NULL DEFAULT 0 COMMENT '退款钱包赠送金额', | |
| 65 | - `refund_time` datetime NULL COMMENT '退款时间', | |
| 66 | - `refund_status` int NOT NULL DEFAULT 0 COMMENT '退款状态', | |
| 67 | - `creator` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '' COMMENT '创建者', | |
| 68 | - `create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', | |
| 69 | - `updater` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '' COMMENT '更新者', | |
| 70 | - `update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间', | |
| 71 | - `deleted` bit(1) NOT NULL DEFAULT b'0' COMMENT '是否删除', | |
| 72 | - `tenant_id` bigint NOT NULL DEFAULT 0 COMMENT '租户编号', | |
| 73 | - PRIMARY KEY (`id`) USING BTREE | |
| 74 | -) ENGINE=InnoDB COMMENT='会员钱包充值'; | |
| 75 | - | |
| 76 | --- ---------------------------- | |
| 77 | 2 | -- 转账单表 |
| 78 | 3 | -- ---------------------------- |
| 79 | 4 | DROP TABLE IF EXISTS `pay_transfer`; | ... | ... |
yudao-framework/yudao-spring-boot-starter-web/src/main/java/cn/iocoder/yudao/framework/apilog/core/service/ApiAccessLog.java
yudao-framework/yudao-spring-boot-starter-web/src/main/java/cn/iocoder/yudao/framework/apilog/core/service/ApiErrorLog.java
yudao-module-infra/yudao-module-infra-biz/src/main/java/cn/iocoder/yudao/module/infra/service/job/JobLogServiceImpl.java
yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/controller/member/package-info.java renamed to yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/controller/admin/member/package-info.java
yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/controller/product/ProductStatisticsController.java renamed to yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/controller/admin/product/ProductStatisticsController.java
yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/controller/admin/trade/TradeStatisticsController.java
| ... | ... | @@ -32,6 +32,7 @@ public class TradeStatisticsController { |
| 32 | 32 | @Resource |
| 33 | 33 | private TradeStatisticsService tradeStatisticsService; |
| 34 | 34 | |
| 35 | + // TODO @疯狂:要不这个就是 /trend/summary 的特例,前端自己查询两次? | |
| 35 | 36 | @GetMapping("/summary") |
| 36 | 37 | @Operation(summary = "获得交易统计") |
| 37 | 38 | @PreAuthorize("@ss.hasPermission('statistics:trade:query')") |
| ... | ... | @@ -39,6 +40,7 @@ public class TradeStatisticsController { |
| 39 | 40 | return success(tradeStatisticsService.getTradeSummaryComparison()); |
| 40 | 41 | } |
| 41 | 42 | |
| 43 | + // TODO @疯狂:直接 comparison?主要 trend 和 comparison 二选一,一个是数据趋势,一个是数据对比哈; | |
| 42 | 44 | @GetMapping("/trend/summary") |
| 43 | 45 | @Operation(summary = "获得交易状况统计") |
| 44 | 46 | @PreAuthorize("@ss.hasPermission('statistics:trade:query')") | ... | ... |
yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/controller/admin/trade/vo/TradeTrendSummaryRespVO.java
yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/framework/pay/core/package-info.java renamed to yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/controller/app/package-info.java
yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/controller/package-info.java deleted
| 1 | -package cn.iocoder.yudao.module.statistics.controller; |
yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/service/trade/TradeStatisticsService.java
| ... | ... | @@ -26,7 +26,8 @@ public interface TradeStatisticsService { |
| 26 | 26 | * |
| 27 | 27 | * @return 统计数据对照 |
| 28 | 28 | */ |
| 29 | - TradeStatisticsComparisonRespVO<TradeTrendSummaryRespVO> getTradeTrendSummaryComparison(LocalDateTime beginTime, LocalDateTime endTime); | |
| 29 | + TradeStatisticsComparisonRespVO<TradeTrendSummaryRespVO> getTradeTrendSummaryComparison( | |
| 30 | + LocalDateTime beginTime, LocalDateTime endTime); | |
| 30 | 31 | |
| 31 | 32 | /** |
| 32 | 33 | * 获得交易状况明细 |
| ... | ... | @@ -34,4 +35,5 @@ public interface TradeStatisticsService { |
| 34 | 35 | * @return 统计数据列表 |
| 35 | 36 | */ |
| 36 | 37 | List<TradeTrendSummaryRespVO> getTradeStatisticsList(LocalDateTime beginTime, LocalDateTime endTime); |
| 38 | + | |
| 37 | 39 | } | ... | ... |
yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/service/trade/TradeStatisticsServiceImpl.java
| ... | ... | @@ -79,6 +79,7 @@ public class TradeStatisticsServiceImpl implements TradeStatisticsService { |
| 79 | 79 | * @return 交易数据 |
| 80 | 80 | */ |
| 81 | 81 | private TradeSummaryRespBO getTradeSummaryByMonths(int months) { |
| 82 | + // TODO @疯狂:可以在 LocalDateUtils 封装方法;获得月份的开始;以及结束两个方法;然后这里就可以直接调用了 | |
| 82 | 83 | // 月份开始时间 |
| 83 | 84 | LocalDateTime beginOfMonth = LocalDateTime.now() |
| 84 | 85 | .plusMonths(months) | ... | ... |
yudao-module-mall/yudao-module-statistics-biz/src/main/java/cn/iocoder/yudao/module/statistics/service/trade/bo/TradeSummaryRespBO.java
yudao-module-mall/yudao-module-statistics-biz/src/main/resources/mapper/trade/TradeStatisticsMapper.xml
| 1 | 1 | <?xml version="1.0" encoding="UTF-8"?> |
| 2 | 2 | <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> |
| 3 | 3 | <mapper namespace="cn.iocoder.yudao.module.statistics.dal.mysql.trade.TradeStatisticsMapper"> |
| 4 | + | |
| 4 | 5 | <select id="selectByTimeBetween" |
| 5 | 6 | resultType="cn.iocoder.yudao.module.statistics.controller.admin.trade.vo.TradeTrendSummaryRespVO"> |
| 6 | 7 | SELECT |
| ... | ... | @@ -35,4 +36,5 @@ |
| 35 | 36 | AND deleted = FALSE |
| 36 | 37 | GROUP BY date |
| 37 | 38 | </select> |
| 39 | + | |
| 38 | 40 | </mapper> | ... | ... |
yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/mysql/brokerage/BrokerageUserMapper.java
| ... | ... | @@ -139,7 +139,7 @@ public interface BrokerageUserMapper extends BaseMapperX<BrokerageUserDO> { |
| 139 | 139 | @Param("endTime") LocalDateTime endTime); |
| 140 | 140 | |
| 141 | 141 | IPage<AppBrokerageUserChildSummaryRespVO> selectSummaryPageByUserId(Page<?> page, |
| 142 | - @Param("ids") List<Long> ids, | |
| 142 | + @Param("ids") List<Long> ids, // BrokerageUser 的 ids 数组 | |
| 143 | 143 | @Param("bizType") Integer bizType, |
| 144 | 144 | @Param("status") Integer status, |
| 145 | 145 | @Param("bindUserIds") List<Long> bindUserIds, | ... | ... |
yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/brokerage/BrokerageUserServiceImpl.java
| ... | ... | @@ -230,12 +230,15 @@ public class BrokerageUserServiceImpl implements BrokerageUserService { |
| 230 | 230 | ? Collections.emptyList() |
| 231 | 231 | : convertList(memberUserApi.getUserListByNickname(pageReqVO.getNickname()), MemberUserRespDTO::getId); |
| 232 | 232 | // 1.2 生成推广员编号列表 |
| 233 | + // TODO @疯狂:是不是可以先 1.2 查询出来,然后查询对应的昵称,进行过滤?避免昵称过滤返回的 id 过多; | |
| 233 | 234 | List<Long> bindUserIds = buildBindUserIdsByLevel(userId, pageReqVO.getLevel()); |
| 235 | + | |
| 234 | 236 | // 2. 分页查询 |
| 235 | 237 | IPage<AppBrokerageUserChildSummaryRespVO> pageResult = brokerageUserMapper.selectSummaryPageByUserId( |
| 236 | 238 | MyBatisUtils.buildPage(pageReqVO), ids, BrokerageRecordBizTypeEnum.ORDER.getType(), |
| 237 | 239 | BrokerageRecordStatusEnum.SETTLEMENT.getStatus(), bindUserIds, pageReqVO.getSortingField() |
| 238 | 240 | ); |
| 241 | + | |
| 239 | 242 | // 3. 拼接数据并返回 |
| 240 | 243 | List<Long> userIds = convertList(pageResult.getRecords(), AppBrokerageUserChildSummaryRespVO::getId); |
| 241 | 244 | Map<Long, MemberUserRespDTO> userMap = memberUserApi.getUserMap(userIds); | ... | ... |
yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/order/TradeOrderQueryServiceImpl.java
yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/dal/dataobject/signin/MemberSignInRecordDO.java
yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/order/PayOrderController.java
| ... | ... | @@ -11,7 +11,7 @@ import cn.iocoder.yudao.module.pay.convert.order.PayOrderConvert; |
| 11 | 11 | import cn.iocoder.yudao.module.pay.dal.dataobject.app.PayAppDO; |
| 12 | 12 | import cn.iocoder.yudao.module.pay.dal.dataobject.order.PayOrderDO; |
| 13 | 13 | import cn.iocoder.yudao.module.pay.dal.dataobject.order.PayOrderExtensionDO; |
| 14 | -import cn.iocoder.yudao.module.pay.framework.pay.wallet.WalletPayClient; | |
| 14 | +import cn.iocoder.yudao.module.pay.framework.pay.core.WalletPayClient; | |
| 15 | 15 | import cn.iocoder.yudao.module.pay.service.app.PayAppService; |
| 16 | 16 | import cn.iocoder.yudao.module.pay.service.order.PayOrderService; |
| 17 | 17 | import com.google.common.collect.Maps; | ... | ... |
yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/admin/wallet/PayWalletRechargeController.java
| ... | ... | @@ -2,6 +2,7 @@ package cn.iocoder.yudao.module.pay.controller.admin.wallet; |
| 2 | 2 | |
| 3 | 3 | import cn.iocoder.yudao.framework.common.pojo.CommonResult; |
| 4 | 4 | import cn.iocoder.yudao.framework.operatelog.core.annotations.OperateLog; |
| 5 | +import cn.iocoder.yudao.module.pay.api.notify.dto.PayOrderNotifyReqDTO; | |
| 5 | 6 | import cn.iocoder.yudao.module.pay.api.notify.dto.PayRefundNotifyReqDTO; |
| 6 | 7 | import cn.iocoder.yudao.module.pay.service.wallet.PayWalletRechargeService; |
| 7 | 8 | import io.swagger.v3.oas.annotations.Operation; |
| ... | ... | @@ -13,6 +14,7 @@ import org.springframework.web.bind.annotation.*; |
| 13 | 14 | |
| 14 | 15 | import javax.annotation.Resource; |
| 15 | 16 | import javax.annotation.security.PermitAll; |
| 17 | +import javax.validation.Valid; | |
| 16 | 18 | |
| 17 | 19 | import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; |
| 18 | 20 | import static cn.iocoder.yudao.framework.common.util.servlet.ServletUtils.getClientIP; |
| ... | ... | @@ -27,12 +29,22 @@ public class PayWalletRechargeController { |
| 27 | 29 | @Resource |
| 28 | 30 | private PayWalletRechargeService walletRechargeService; |
| 29 | 31 | |
| 32 | + @PostMapping("/update-paid") | |
| 33 | + @Operation(summary = "更新钱包充值为已充值") // 由 pay-module 支付服务,进行回调,可见 PayNotifyJob | |
| 34 | + @PermitAll // 无需登录, 内部校验实现 | |
| 35 | + @OperateLog(enable = false) // 禁用操作日志,因为没有操作人 | |
| 36 | + public CommonResult<Boolean> updateWalletRechargerPaid(@Valid @RequestBody PayOrderNotifyReqDTO notifyReqDTO) { | |
| 37 | + walletRechargeService.updateWalletRechargerPaid(Long.valueOf(notifyReqDTO.getMerchantOrderId()), | |
| 38 | + notifyReqDTO.getPayOrderId()); | |
| 39 | + return success(true); | |
| 40 | + } | |
| 30 | 41 | |
| 42 | + // TODO @jason:发起退款,要 post 操作哈; | |
| 31 | 43 | @GetMapping("/refund") |
| 32 | 44 | @Operation(summary = "发起钱包充值退款") |
| 33 | 45 | @Parameter(name = "id", description = "编号", required = true, example = "1024") |
| 34 | 46 | public CommonResult<Boolean> refundWalletRecharge(@RequestParam("id") Long id) { |
| 35 | - walletRechargeService.refundWalletRecharge(id,getClientIP()); | |
| 47 | + walletRechargeService.refundWalletRecharge(id, getClientIP()); | |
| 36 | 48 | return success(true); |
| 37 | 49 | } |
| 38 | 50 | ... | ... |
yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/app/order/AppPayOrderController.java
| 1 | 1 | package cn.iocoder.yudao.module.pay.controller.app.order; |
| 2 | 2 | |
| 3 | 3 | import cn.iocoder.yudao.framework.common.pojo.CommonResult; |
| 4 | +import cn.iocoder.yudao.framework.pay.core.enums.channel.PayChannelEnum; | |
| 4 | 5 | import cn.iocoder.yudao.module.pay.controller.admin.order.vo.PayOrderRespVO; |
| 5 | 6 | import cn.iocoder.yudao.module.pay.controller.admin.order.vo.PayOrderSubmitRespVO; |
| 6 | 7 | import cn.iocoder.yudao.module.pay.controller.app.order.vo.AppPayOrderSubmitReqVO; |
| 7 | 8 | import cn.iocoder.yudao.module.pay.controller.app.order.vo.AppPayOrderSubmitRespVO; |
| 8 | 9 | import cn.iocoder.yudao.module.pay.convert.order.PayOrderConvert; |
| 10 | +import cn.iocoder.yudao.module.pay.framework.pay.core.WalletPayClient; | |
| 9 | 11 | import cn.iocoder.yudao.module.pay.service.order.PayOrderService; |
| 12 | +import com.google.common.collect.Maps; | |
| 10 | 13 | import io.swagger.v3.oas.annotations.Operation; |
| 11 | 14 | import io.swagger.v3.oas.annotations.Parameter; |
| 12 | 15 | import io.swagger.v3.oas.annotations.tags.Tag; |
| ... | ... | @@ -16,8 +19,13 @@ import org.springframework.web.bind.annotation.*; |
| 16 | 19 | |
| 17 | 20 | import javax.annotation.Resource; |
| 18 | 21 | |
| 22 | +import java.util.Map; | |
| 23 | +import java.util.Objects; | |
| 24 | + | |
| 19 | 25 | import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; |
| 20 | 26 | import static cn.iocoder.yudao.framework.common.util.servlet.ServletUtils.getClientIP; |
| 27 | +import static cn.iocoder.yudao.framework.web.core.util.WebFrameworkUtils.getLoginUserId; | |
| 28 | +import static cn.iocoder.yudao.framework.web.core.util.WebFrameworkUtils.getLoginUserType; | |
| 21 | 29 | |
| 22 | 30 | @Tag(name = "用户 APP - 支付订单") |
| 23 | 31 | @RestController |
| ... | ... | @@ -40,6 +48,16 @@ public class AppPayOrderController { |
| 40 | 48 | @PostMapping("/submit") |
| 41 | 49 | @Operation(summary = "提交支付订单") |
| 42 | 50 | public CommonResult<AppPayOrderSubmitRespVO> submitPayOrder(@RequestBody AppPayOrderSubmitReqVO reqVO) { |
| 51 | + // 1. 钱包支付事,需要额外传 user_id 和 user_type | |
| 52 | + if (Objects.equals(reqVO.getChannelCode(), PayChannelEnum.WALLET.getCode())) { | |
| 53 | + Map<String, String> channelExtras = reqVO.getChannelExtras() == null ? | |
| 54 | + Maps.newHashMapWithExpectedSize(2) : reqVO.getChannelExtras(); | |
| 55 | + channelExtras.put(WalletPayClient.USER_ID_KEY, String.valueOf(getLoginUserId())); | |
| 56 | + channelExtras.put(WalletPayClient.USER_TYPE_KEY, String.valueOf(getLoginUserType())); | |
| 57 | + reqVO.setChannelExtras(channelExtras); | |
| 58 | + } | |
| 59 | + | |
| 60 | + // 2. 提交支付 | |
| 43 | 61 | PayOrderSubmitRespVO respVO = payOrderService.submitOrder(reqVO, getClientIP()); |
| 44 | 62 | return success(PayOrderConvert.INSTANCE.convert3(respVO)); |
| 45 | 63 | } | ... | ... |
yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/app/wallet/AppPayWalletRechargeController.java
| 1 | 1 | package cn.iocoder.yudao.module.pay.controller.app.wallet; |
| 2 | 2 | |
| 3 | 3 | import cn.iocoder.yudao.framework.common.pojo.CommonResult; |
| 4 | -import cn.iocoder.yudao.framework.operatelog.core.annotations.OperateLog; | |
| 5 | -import cn.iocoder.yudao.module.pay.api.notify.dto.PayOrderNotifyReqDTO; | |
| 6 | 4 | import cn.iocoder.yudao.module.pay.controller.app.wallet.vo.recharge.AppPayWalletRechargeCreateReqVO; |
| 7 | 5 | import cn.iocoder.yudao.module.pay.controller.app.wallet.vo.recharge.AppPayWalletRechargeCreateRespVO; |
| 8 | 6 | import cn.iocoder.yudao.module.pay.convert.wallet.PayWalletRechargeConvert; |
| ... | ... | @@ -18,7 +16,6 @@ import org.springframework.web.bind.annotation.RequestMapping; |
| 18 | 16 | import org.springframework.web.bind.annotation.RestController; |
| 19 | 17 | |
| 20 | 18 | import javax.annotation.Resource; |
| 21 | -import javax.annotation.security.PermitAll; | |
| 22 | 19 | import javax.validation.Valid; |
| 23 | 20 | |
| 24 | 21 | import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; |
| ... | ... | @@ -44,13 +41,4 @@ public class AppPayWalletRechargeController { |
| 44 | 41 | return success(PayWalletRechargeConvert.INSTANCE.convert(walletRecharge)); |
| 45 | 42 | } |
| 46 | 43 | |
| 47 | - @PostMapping("/update-paid") | |
| 48 | - @Operation(summary = "更新钱包充值为已充值") // 由 pay-module 支付服务,进行回调,可见 PayNotifyJob | |
| 49 | - @PermitAll // 无需登录,安全由 内部校验实现 | |
| 50 | - @OperateLog(enable = false) // 禁用操作日志,因为没有操作人 | |
| 51 | - public CommonResult<Boolean> updateWalletRechargerPaid(@Valid @RequestBody PayOrderNotifyReqDTO notifyReqDTO) { | |
| 52 | - walletRechargeService.updateWalletRechargerPaid(Long.valueOf(notifyReqDTO.getMerchantOrderId()), | |
| 53 | - notifyReqDTO.getPayOrderId()); | |
| 54 | - return success(true); | |
| 55 | - } | |
| 56 | 44 | } | ... | ... |
yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/app/wallet/AppPayWalletRechargePackageController.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.pay.controller.app.wallet; | |
| 2 | + | |
| 3 | +import cn.iocoder.yudao.framework.common.pojo.CommonResult; | |
| 4 | +import cn.iocoder.yudao.module.pay.controller.app.wallet.vo.recharge.AppPayWalletPackageRespVO; | |
| 5 | +import io.swagger.v3.oas.annotations.Operation; | |
| 6 | +import io.swagger.v3.oas.annotations.tags.Tag; | |
| 7 | +import lombok.extern.slf4j.Slf4j; | |
| 8 | +import org.springframework.validation.annotation.Validated; | |
| 9 | +import org.springframework.web.bind.annotation.GetMapping; | |
| 10 | +import org.springframework.web.bind.annotation.RequestMapping; | |
| 11 | +import org.springframework.web.bind.annotation.RestController; | |
| 12 | + | |
| 13 | +import java.util.ArrayList; | |
| 14 | +import java.util.List; | |
| 15 | + | |
| 16 | +import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; | |
| 17 | + | |
| 18 | +@Tag(name = "用户 APP - 钱包充值套餐") | |
| 19 | +@RestController | |
| 20 | +@RequestMapping("/pay/wallet-recharge-package") | |
| 21 | +@Validated | |
| 22 | +@Slf4j | |
| 23 | +public class AppPayWalletRechargePackageController { | |
| 24 | + | |
| 25 | + @GetMapping("/list") | |
| 26 | + @Operation(summary = "获得钱包充值套餐列表") | |
| 27 | + public CommonResult<List<AppPayWalletPackageRespVO>> getWalletRechargePackageList() { | |
| 28 | + // 只查询开启;需要按照 payPrice 排序; | |
| 29 | + List<AppPayWalletPackageRespVO> list = new ArrayList<>(); | |
| 30 | + list.add(new AppPayWalletPackageRespVO().setId(1L).setName("土豆").setPayPrice(10).setBonusPrice(2)); | |
| 31 | + list.add(new AppPayWalletPackageRespVO().setId(2L).setName("番茄").setPayPrice(20).setBonusPrice(5)); | |
| 32 | + return success(list); | |
| 33 | + } | |
| 34 | + | |
| 35 | +} | ... | ... |
yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/app/wallet/vo/recharge/AppPayWalletPackageRespVO.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.pay.controller.app.wallet.vo.recharge; | |
| 2 | + | |
| 3 | +import io.swagger.v3.oas.annotations.media.Schema; | |
| 4 | +import lombok.Data; | |
| 5 | + | |
| 6 | +@Schema(description = "用户 APP - 用户充值套餐 Response VO") | |
| 7 | +@Data | |
| 8 | +public class AppPayWalletPackageRespVO { | |
| 9 | + | |
| 10 | + @Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") | |
| 11 | + private Long id; | |
| 12 | + @Schema(description = "套餐名", requiredMode = Schema.RequiredMode.REQUIRED, example = "小套餐") | |
| 13 | + private String name; | |
| 14 | + | |
| 15 | + @Schema(description = "支付金额", requiredMode = Schema.RequiredMode.REQUIRED, example = "10") | |
| 16 | + private Integer payPrice; | |
| 17 | + @Schema(description = "赠送金额", requiredMode = Schema.RequiredMode.REQUIRED, example = "20") | |
| 18 | + private Integer bonusPrice; | |
| 19 | + | |
| 20 | +} | ... | ... |
yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/app/wallet/vo/recharge/AppPayWalletRechargeCreateReqVO.java
| ... | ... | @@ -3,24 +3,27 @@ package cn.iocoder.yudao.module.pay.controller.app.wallet.vo.recharge; |
| 3 | 3 | import io.swagger.v3.oas.annotations.media.Schema; |
| 4 | 4 | import lombok.Data; |
| 5 | 5 | |
| 6 | -import javax.validation.constraints.DecimalMin; | |
| 7 | 6 | import javax.validation.constraints.Min; |
| 8 | -import javax.validation.constraints.NotNull; | |
| 9 | 7 | |
| 10 | 8 | @Schema(description = "用户 APP - 创建钱包充值 Request VO") |
| 11 | 9 | @Data |
| 12 | 10 | public class AppPayWalletRechargeCreateReqVO { |
| 13 | 11 | |
| 14 | 12 | @Schema(description = "支付金额", requiredMode = Schema.RequiredMode.REQUIRED, example = "1000") |
| 15 | - @NotNull(message = "支付金额不能为空") | |
| 13 | +// @NotNull(message = "支付金额不能为空") | |
| 16 | 14 | @Min(value = 1, message = "支付金额必须大于零") |
| 17 | 15 | private Integer payPrice; |
| 18 | 16 | |
| 19 | 17 | // TODO @jason:这个是不是后端计算出来呀?不然前端可以直接搞了。。。 |
| 20 | 18 | // TOTO 那是不是搞一个充值模板 |
| 21 | 19 | @Schema(description = "钱包赠送金额", requiredMode = Schema.RequiredMode.REQUIRED, example = "1000") |
| 22 | - @NotNull(message = "钱包赠送金额不能为空") | |
| 23 | - @DecimalMin(value = "0", message = "钱包赠送金额必须大于等于零") | |
| 24 | - private Integer bonusPrice; | |
| 20 | +// @NotNull(message = "钱包赠送金额不能为空") | |
| 21 | +// @DecimalMin(value = "0", message = "钱包赠送金额必须大于等于零") | |
| 22 | + private Integer bonusPrice = 0; | |
| 23 | + | |
| 24 | + @Schema(description = "充值套餐编号", example = "1024") | |
| 25 | + private Long packageId; | |
| 26 | + | |
| 27 | + // TODO @jason:可以改成 payPrice 和 packageId 两个至少一个不为空; | |
| 25 | 28 | |
| 26 | 29 | } | ... | ... |
yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/app/wallet/vo/wallet/AppPayWalletRespVO.java
| ... | ... | @@ -3,7 +3,7 @@ package cn.iocoder.yudao.module.pay.controller.app.wallet.vo.wallet; |
| 3 | 3 | import io.swagger.v3.oas.annotations.media.Schema; |
| 4 | 4 | import lombok.Data; |
| 5 | 5 | |
| 6 | -@Schema(description = "用户 APP - 获取用户钱包 Response VO") | |
| 6 | +@Schema(description = "用户 APP - 用户钱包 Response VO") | |
| 7 | 7 | @Data |
| 8 | 8 | public class AppPayWalletRespVO { |
| 9 | 9 | ... | ... |
yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/dal/dataobject/wallet/PayWalletRechargeDO.java
yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/dal/dataobject/wallet/PayWalletRechargePackageDO.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.pay.dal.dataobject.wallet; | |
| 2 | + | |
| 3 | +import com.baomidou.mybatisplus.annotation.KeySequence; | |
| 4 | +import com.baomidou.mybatisplus.annotation.TableId; | |
| 5 | +import com.baomidou.mybatisplus.annotation.TableName; | |
| 6 | +import lombok.Data; | |
| 7 | + | |
| 8 | +/** | |
| 9 | + * 会员钱包充值套餐 DO | |
| 10 | + * | |
| 11 | + * 通过套餐充值时,可以赠送一定金额; | |
| 12 | + * | |
| 13 | + * @author 芋道源码 | |
| 14 | + */ | |
| 15 | +@TableName(value ="pay_wallet_recharge_package") | |
| 16 | +@KeySequence("pay_wallet_recharge_package_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 | |
| 17 | +@Data | |
| 18 | +public class PayWalletRechargePackageDO { | |
| 19 | + | |
| 20 | + /** | |
| 21 | + * 编号 | |
| 22 | + */ | |
| 23 | + @TableId | |
| 24 | + private Long id; | |
| 25 | + /** | |
| 26 | + * 套餐名 | |
| 27 | + */ | |
| 28 | + private String name; | |
| 29 | + | |
| 30 | + /** | |
| 31 | + * 支付金额 | |
| 32 | + */ | |
| 33 | + private Integer payPrice; | |
| 34 | + /** | |
| 35 | + * 赠送金额 | |
| 36 | + */ | |
| 37 | + private Integer bonusPrice; | |
| 38 | + | |
| 39 | + /** | |
| 40 | + * 状态 | |
| 41 | + * | |
| 42 | + * 枚举 {@link cn.iocoder.yudao.framework.common.enums.CommonStatusEnum} | |
| 43 | + */ | |
| 44 | + private Integer status; | |
| 45 | + | |
| 46 | +} | ... | ... |
yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/framework/pay/wallet/WalletPayClient.java renamed to yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/framework/pay/core/WalletPayClient.java
yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/service/channel/PayChannelServiceImpl.java
| ... | ... | @@ -13,6 +13,7 @@ import cn.iocoder.yudao.module.pay.controller.admin.channel.vo.PayChannelUpdateR |
| 13 | 13 | import cn.iocoder.yudao.module.pay.convert.channel.PayChannelConvert; |
| 14 | 14 | import cn.iocoder.yudao.module.pay.dal.dataobject.channel.PayChannelDO; |
| 15 | 15 | import cn.iocoder.yudao.module.pay.dal.mysql.channel.PayChannelMapper; |
| 16 | +import cn.iocoder.yudao.module.pay.framework.pay.core.WalletPayClient; | |
| 16 | 17 | import com.google.common.cache.CacheLoader; |
| 17 | 18 | import com.google.common.cache.LoadingCache; |
| 18 | 19 | import lombok.Getter; |
| ... | ... | @@ -20,6 +21,7 @@ import lombok.extern.slf4j.Slf4j; |
| 20 | 21 | import org.springframework.stereotype.Service; |
| 21 | 22 | import org.springframework.validation.annotation.Validated; |
| 22 | 23 | |
| 24 | +import javax.annotation.PostConstruct; | |
| 23 | 25 | import javax.annotation.Resource; |
| 24 | 26 | import javax.validation.Validator; |
| 25 | 27 | import java.time.Duration; |
| ... | ... | @@ -68,6 +70,14 @@ public class PayChannelServiceImpl implements PayChannelService { |
| 68 | 70 | @Resource |
| 69 | 71 | private Validator validator; |
| 70 | 72 | |
| 73 | + /** | |
| 74 | + * 初始化,为了注册钱包 | |
| 75 | + */ | |
| 76 | + @PostConstruct | |
| 77 | + public void init() { | |
| 78 | + payClientFactory.registerPayClientClass(PayChannelEnum.WALLET, WalletPayClient.class); | |
| 79 | + } | |
| 80 | + | |
| 71 | 81 | @Override |
| 72 | 82 | public Long createChannel(PayChannelCreateReqVO reqVO) { |
| 73 | 83 | // 断言是否有重复的 | ... | ... |
yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/service/wallet/PayWalletRechargeServiceImpl.java
yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/util/PaySeqUtils.java deleted
| 1 | -package cn.iocoder.yudao.module.pay.util; | |
| 2 | - | |
| 3 | -import cn.hutool.core.date.DatePattern; | |
| 4 | -import cn.hutool.core.date.DateUtil; | |
| 5 | - | |
| 6 | -import java.time.LocalDateTime; | |
| 7 | -import java.util.concurrent.atomic.AtomicLong; | |
| 8 | - | |
| 9 | -/** | |
| 10 | - * 支付相关编号的生产 | |
| 11 | - */ | |
| 12 | -// TODO @jason:需要改造,基于 db; | |
| 13 | -public class PaySeqUtils { | |
| 14 | - | |
| 15 | - private static final AtomicLong REFUND_REQ_NO_SEQ = new AtomicLong(0L); | |
| 16 | - | |
| 17 | - private static final AtomicLong MER_REFUND_NO_SEQ = new AtomicLong(0L); | |
| 18 | - | |
| 19 | - private static final AtomicLong MER_ORDER_NO_SEQ = new AtomicLong(0L); | |
| 20 | - | |
| 21 | - // TODO 芋艿:需要看看 | |
| 22 | - /** | |
| 23 | - * 生成商户退款单号,用于测试,应该由商户系统生成 | |
| 24 | - * @return 商户退款单 | |
| 25 | - */ | |
| 26 | - public static String genMerchantRefundNo() { | |
| 27 | - return String.format("%s%s%04d", "MR", | |
| 28 | - DateUtil.format(LocalDateTime.now(), DatePattern.PURE_DATETIME_MS_PATTERN), | |
| 29 | - (int) MER_REFUND_NO_SEQ.getAndIncrement() % 10000); | |
| 30 | - } | |
| 31 | - | |
| 32 | - // TODO 芋艿:需要看看 | |
| 33 | - | |
| 34 | - /** | |
| 35 | - * 生成退款请求号 | |
| 36 | - * @return 退款请求号 | |
| 37 | - */ | |
| 38 | - public static String genRefundReqNo() { | |
| 39 | - return String.format("%s%s%04d", "RR", | |
| 40 | - DateUtil.format(LocalDateTime.now(), DatePattern.PURE_DATETIME_MS_PATTERN), | |
| 41 | - (int) REFUND_REQ_NO_SEQ.getAndIncrement() % 10000); | |
| 42 | - } | |
| 43 | - | |
| 44 | - /** | |
| 45 | - * 生成商户订单编号号 用于测试,应该由商户系统生成 | |
| 46 | - * @return 商户订单编号 | |
| 47 | - */ | |
| 48 | - public static String genMerchantOrderNo() { | |
| 49 | - return String.format("%s%s%04d", "MO", | |
| 50 | - DateUtil.format(LocalDateTime.now(), DatePattern.PURE_DATETIME_MS_PATTERN), | |
| 51 | - (int) MER_ORDER_NO_SEQ.getAndIncrement() % 10000); | |
| 52 | - } | |
| 53 | - | |
| 54 | -} |