Commit 04a391cd4bfb24bd2e0438f44406f43263cb2c9b
Merge remote-tracking branch 'yudao/feature/mall_product' into feature/mall_product
# Conflicts: # yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/api/combination/CombinationActivityApiImpl.java
Showing
38 changed files
with
1159 additions
and
56 deletions
sql/mysql/pay_wallet.sql
| ... | ... | @@ -4,18 +4,18 @@ |
| 4 | 4 | DROP TABLE IF EXISTS `pay_wallet`; |
| 5 | 5 | CREATE TABLE `pay_wallet` |
| 6 | 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 | - `creator` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '' COMMENT '创建者', | |
| 14 | - `create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', | |
| 15 | - `updater` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '' COMMENT '更新者', | |
| 16 | - `update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间', | |
| 17 | - `deleted` bit(1) NOT NULL DEFAULT b'0' COMMENT '是否删除', | |
| 18 | - `tenant_id` bigint NOT NULL DEFAULT 0 COMMENT '租户编号', | |
| 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 | + `creator` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '' COMMENT '创建者', | |
| 14 | + `create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', | |
| 15 | + `updater` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '' COMMENT '更新者', | |
| 16 | + `update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间', | |
| 17 | + `deleted` bit(1) NOT NULL DEFAULT b'0' COMMENT '是否删除', | |
| 18 | + `tenant_id` bigint NOT NULL DEFAULT 0 COMMENT '租户编号', | |
| 19 | 19 | PRIMARY KEY (`id`) USING BTREE |
| 20 | 20 | ) ENGINE=InnoDB COMMENT='会员钱包表'; |
| 21 | 21 | |
| ... | ... | @@ -41,3 +41,33 @@ CREATE TABLE `pay_wallet_transaction` |
| 41 | 41 | `tenant_id` bigint NOT NULL DEFAULT 0 COMMENT '租户编号', |
| 42 | 42 | PRIMARY KEY (`id`) USING BTREE |
| 43 | 43 | ) ENGINE=InnoDB COMMENT='会员钱包流水表'; |
| 44 | + | |
| 45 | +-- ---------------------------- | |
| 46 | +-- 会员钱包充值 | |
| 47 | +-- ---------------------------- | |
| 48 | +DROP TABLE IF EXISTS `pay_wallet_recharge`; | |
| 49 | +CREATE TABLE `pay_wallet_recharge` | |
| 50 | +( | |
| 51 | + `id` bigint NOT NULL AUTO_INCREMENT COMMENT '编号', | |
| 52 | + `wallet_id` bigint NOT NULL COMMENT '会员钱包 id', | |
| 53 | + `price` int NOT NULL COMMENT '用户实际到账余额,例如充 100 送 20,则该值是 120', | |
| 54 | + `pay_price` int NOT NULL COMMENT '实际支付金额', | |
| 55 | + `wallet_bonus` int NOT NULL COMMENT '钱包赠送金额', | |
| 56 | + `pay_status` bit(1) NOT NULL DEFAULT b'0' COMMENT '是否已支付:[0:未支付 1:已经支付过]', | |
| 57 | + `pay_order_id` bigint NULL COMMENT '支付订单编号', | |
| 58 | + `pay_channel_code` varchar(16) NULL COMMENT '支付成功的支付渠道', | |
| 59 | + `pay_time` datetime NULL COMMENT '订单支付时间', | |
| 60 | + `pay_refund_id` bigint NULL COMMENT '支付退款单编号', | |
| 61 | + `refund_price` int NOT NULL DEFAULT 0 COMMENT '退款金额,包含赠送金额', | |
| 62 | + `refund_pay_price` int NOT NULL DEFAULT 0 COMMENT '退款支付金额', | |
| 63 | + `refund_wallet_bonus` int NOT NULL DEFAULT 0 COMMENT '退款钱包赠送金额', | |
| 64 | + `refund_time` datetime NULL COMMENT '退款时间', | |
| 65 | + `creator` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '' COMMENT '创建者', | |
| 66 | + `create_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP COMMENT '创建时间', | |
| 67 | + `updater` varchar(64) CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci NULL DEFAULT '' COMMENT '更新者', | |
| 68 | + `update_time` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP COMMENT '更新时间', | |
| 69 | + `deleted` bit(1) NOT NULL DEFAULT b'0' COMMENT '是否删除', | |
| 70 | + `tenant_id` bigint NOT NULL DEFAULT 0 COMMENT '租户编号', | |
| 71 | + PRIMARY KEY (`id`) USING BTREE | |
| 72 | +) ENGINE=InnoDB COMMENT='会员钱包充值'; | |
| 73 | + | ... | ... |
yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/combination/CombinationActivityServiceImpl.java
| ... | ... | @@ -21,6 +21,7 @@ import cn.iocoder.yudao.module.promotion.dal.mysql.combination.CombinationActivi |
| 21 | 21 | import cn.iocoder.yudao.module.promotion.dal.mysql.combination.CombinationProductMapper; |
| 22 | 22 | import cn.iocoder.yudao.module.promotion.enums.combination.CombinationRecordStatusEnum; |
| 23 | 23 | import cn.iocoder.yudao.module.trade.api.order.TradeOrderApi; |
| 24 | +import org.springframework.context.annotation.Lazy; | |
| 24 | 25 | import org.springframework.stereotype.Service; |
| 25 | 26 | import org.springframework.transaction.annotation.Transactional; |
| 26 | 27 | import org.springframework.validation.annotation.Validated; |
| ... | ... | @@ -50,7 +51,9 @@ public class CombinationActivityServiceImpl implements CombinationActivityServic |
| 50 | 51 | private CombinationActivityMapper combinationActivityMapper; |
| 51 | 52 | @Resource |
| 52 | 53 | private CombinationProductMapper combinationProductMapper; |
| 54 | + | |
| 53 | 55 | @Resource |
| 56 | + @Lazy // TODO @puhui999:我感觉 validateCombination 可以挪到 CombinationRecordServiceImpl 中,因为它更偏向能不能创建拼团记录; | |
| 54 | 57 | private CombinationRecordService combinationRecordService; |
| 55 | 58 | |
| 56 | 59 | @Resource | ... | ... |
yudao-module-mall/yudao-module-trade-api/src/main/java/cn/iocoder/yudao/module/trade/enums/order/TradeOrderOperateTypeEnum.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.trade.enums.order; | |
| 2 | + | |
| 3 | +import lombok.Getter; | |
| 4 | +import lombok.RequiredArgsConstructor; | |
| 5 | + | |
| 6 | +/** | |
| 7 | + * 订单操作类型的枚举 | |
| 8 | + * | |
| 9 | + * @author 陈賝 | |
| 10 | + * @since 2023/7/6 15:31 | |
| 11 | + */ | |
| 12 | +@RequiredArgsConstructor | |
| 13 | +@Getter | |
| 14 | +public enum TradeOrderOperateTypeEnum { | |
| 15 | + | |
| 16 | + MEMBER_CREATE(1, "用户下单"), | |
| 17 | + TEST(2, "用户({nickname})做了({thing})"), | |
| 18 | + ; | |
| 19 | + | |
| 20 | + /** | |
| 21 | + * 类型 | |
| 22 | + */ | |
| 23 | + private final Integer type; | |
| 24 | + /** | |
| 25 | + * 类型 | |
| 26 | + */ | |
| 27 | + private final String content; | |
| 28 | + | |
| 29 | +} | ... | ... |
yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/controller/app/order/AppTradeOrderController.java
| 1 | 1 | package cn.iocoder.yudao.module.trade.controller.app.order; |
| 2 | 2 | |
| 3 | +import cn.hutool.core.map.MapUtil; | |
| 3 | 4 | import cn.iocoder.yudao.framework.common.pojo.CommonResult; |
| 4 | 5 | import cn.iocoder.yudao.framework.common.pojo.PageResult; |
| 5 | 6 | import cn.iocoder.yudao.framework.security.core.annotations.PreAuthenticated; |
| ... | ... | @@ -11,8 +12,11 @@ import cn.iocoder.yudao.module.trade.convert.order.TradeOrderConvert; |
| 11 | 12 | import cn.iocoder.yudao.module.trade.dal.dataobject.delivery.DeliveryExpressDO; |
| 12 | 13 | import cn.iocoder.yudao.module.trade.dal.dataobject.order.TradeOrderDO; |
| 13 | 14 | import cn.iocoder.yudao.module.trade.dal.dataobject.order.TradeOrderItemDO; |
| 15 | +import cn.iocoder.yudao.module.trade.enums.order.TradeOrderOperateTypeEnum; | |
| 14 | 16 | import cn.iocoder.yudao.module.trade.enums.order.TradeOrderStatusEnum; |
| 15 | 17 | import cn.iocoder.yudao.module.trade.framework.order.config.TradeOrderProperties; |
| 18 | +import cn.iocoder.yudao.module.trade.framework.order.core.annotations.TradeOrderLog; | |
| 19 | +import cn.iocoder.yudao.module.trade.framework.order.core.utils.TradeOrderLogUtils; | |
| 16 | 20 | import cn.iocoder.yudao.module.trade.service.delivery.DeliveryExpressService; |
| 17 | 21 | import cn.iocoder.yudao.module.trade.service.order.TradeOrderQueryService; |
| 18 | 22 | import cn.iocoder.yudao.module.trade.service.order.TradeOrderUpdateService; |
| ... | ... | @@ -61,7 +65,10 @@ public class AppTradeOrderController { |
| 61 | 65 | @PostMapping("/create") |
| 62 | 66 | @Operation(summary = "创建订单") |
| 63 | 67 | @PreAuthenticated |
| 68 | + @TradeOrderLog(operateType = TradeOrderOperateTypeEnum.TEST) | |
| 64 | 69 | public CommonResult<AppTradeOrderCreateRespVO> createOrder(@RequestBody AppTradeOrderCreateReqVO createReqVO) { |
| 70 | + TradeOrderLogUtils.setOrderInfo(10L, 1, 2, | |
| 71 | + MapUtil.<String, Object>builder().put("nickname", "小明").put("thing", "种土豆").build()); | |
| 65 | 72 | TradeOrderDO order = tradeOrderUpdateService.createOrder(getLoginUserId(), getClientIP(), createReqVO); |
| 66 | 73 | return success(new AppTradeOrderCreateRespVO().setId(order.getId()).setPayOrderId(order.getPayOrderId())); |
| 67 | 74 | } | ... | ... |
yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/dal/dataobject/order/TradeOrderLogDO.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.trade.dal.dataobject.order; | |
| 2 | + | |
| 3 | +import cn.iocoder.yudao.framework.common.enums.UserTypeEnum; | |
| 4 | +import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; | |
| 5 | +import cn.iocoder.yudao.module.trade.enums.order.TradeOrderOperateTypeEnum; | |
| 6 | +import com.baomidou.mybatisplus.annotation.KeySequence; | |
| 7 | +import com.baomidou.mybatisplus.annotation.TableId; | |
| 8 | +import com.baomidou.mybatisplus.annotation.TableName; | |
| 9 | +import lombok.*; | |
| 10 | + | |
| 11 | +/** | |
| 12 | + * 订单日志 DO | |
| 13 | + * | |
| 14 | + * @author 陈賝 | |
| 15 | + */ | |
| 16 | +@TableName("trade_order_log") | |
| 17 | +@KeySequence("trade_order_log_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 | |
| 18 | +@Data | |
| 19 | +@EqualsAndHashCode(callSuper = true) | |
| 20 | +@ToString(callSuper = true) | |
| 21 | +@Builder | |
| 22 | +@NoArgsConstructor | |
| 23 | +@AllArgsConstructor | |
| 24 | +public class TradeOrderLogDO extends BaseDO { | |
| 25 | + | |
| 26 | + /** | |
| 27 | + * 用户类型 - 系统 | |
| 28 | + * | |
| 29 | + * 例如说:Job 自动过期订单时,通过系统自动操作 | |
| 30 | + */ | |
| 31 | + public static final Integer USER_TYPE_SYSTEM = 0; | |
| 32 | + /** | |
| 33 | + * 用户编号 - 系统 | |
| 34 | + */ | |
| 35 | + public static final Long USER_ID_SYSTEM = 0L; | |
| 36 | + | |
| 37 | + /** | |
| 38 | + * 编号 | |
| 39 | + */ | |
| 40 | + @TableId | |
| 41 | + private Long id; | |
| 42 | + /** | |
| 43 | + * 用户编号 | |
| 44 | + * | |
| 45 | + * 关联 AdminUserDO 的 id 字段、或者 MemberUserDO 的 id 字段 | |
| 46 | + */ | |
| 47 | + private Long userId; | |
| 48 | + /** | |
| 49 | + * 用户类型 | |
| 50 | + * | |
| 51 | + * 枚举 {@link UserTypeEnum} | |
| 52 | + */ | |
| 53 | + private Integer userType; | |
| 54 | + | |
| 55 | + /** | |
| 56 | + * 订单号 | |
| 57 | + * | |
| 58 | + * 关联 {@link TradeOrderDO#getId()} | |
| 59 | + */ | |
| 60 | + private Long orderId; | |
| 61 | + /** | |
| 62 | + * 操作前状态 | |
| 63 | + */ | |
| 64 | + private Integer beforeStatus; | |
| 65 | + /** | |
| 66 | + * 操作后状态 | |
| 67 | + */ | |
| 68 | + private Integer afterStatus; | |
| 69 | + | |
| 70 | + /** | |
| 71 | + * 操作类型 | |
| 72 | + * | |
| 73 | + * {@link TradeOrderOperateTypeEnum} | |
| 74 | + */ | |
| 75 | + private Integer operateType; | |
| 76 | + /** | |
| 77 | + * 订单日志信息 | |
| 78 | + */ | |
| 79 | + private String content; | |
| 80 | + | |
| 81 | +} | ... | ... |
yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/framework/order/core/annotations/TradeOrderLog.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.trade.framework.order.core.annotations; | |
| 2 | + | |
| 3 | +import cn.iocoder.yudao.module.trade.enums.order.TradeOrderOperateTypeEnum; | |
| 4 | + | |
| 5 | +import java.lang.annotation.*; | |
| 6 | + | |
| 7 | +import static java.lang.annotation.ElementType.ANNOTATION_TYPE; | |
| 8 | +import static java.lang.annotation.ElementType.METHOD; | |
| 9 | + | |
| 10 | +/** | |
| 11 | + * 交易订单的操作日志 AOP 注解 | |
| 12 | + * | |
| 13 | + * @author 陈賝 | |
| 14 | + * @since 2023/7/6 15:37 | |
| 15 | + */ | |
| 16 | +@Target({METHOD, ANNOTATION_TYPE}) | |
| 17 | +@Retention(RetentionPolicy.RUNTIME) | |
| 18 | +@Documented | |
| 19 | +public @interface TradeOrderLog { | |
| 20 | + | |
| 21 | + /** | |
| 22 | + * 操作类型 | |
| 23 | + */ | |
| 24 | + TradeOrderOperateTypeEnum operateType(); | |
| 25 | + | |
| 26 | +} | ... | ... |
yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/framework/order/core/aop/TradeOrderLogAspect.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.trade.framework.order.core.aop; | |
| 2 | + | |
| 3 | + | |
| 4 | +import cn.hutool.core.util.ObjectUtil; | |
| 5 | +import cn.hutool.core.util.StrUtil; | |
| 6 | +import cn.iocoder.yudao.framework.web.core.util.WebFrameworkUtils; | |
| 7 | +import cn.iocoder.yudao.module.trade.dal.dataobject.order.TradeOrderLogDO; | |
| 8 | +import cn.iocoder.yudao.module.trade.framework.order.core.annotations.TradeOrderLog; | |
| 9 | +import cn.iocoder.yudao.module.trade.service.order.TradeOrderLogService; | |
| 10 | +import cn.iocoder.yudao.module.trade.service.order.bo.logger.TradeOrderLogCreateReqBO; | |
| 11 | +import lombok.extern.slf4j.Slf4j; | |
| 12 | +import org.aspectj.lang.JoinPoint; | |
| 13 | +import org.aspectj.lang.annotation.AfterReturning; | |
| 14 | +import org.aspectj.lang.annotation.Aspect; | |
| 15 | +import org.springframework.stereotype.Component; | |
| 16 | + | |
| 17 | +import javax.annotation.Resource; | |
| 18 | +import java.util.Map; | |
| 19 | + | |
| 20 | +import static cn.iocoder.yudao.framework.common.util.json.JsonUtils.toJsonString; | |
| 21 | +import static java.util.Collections.emptyMap; | |
| 22 | + | |
| 23 | +/** | |
| 24 | + * 交易订单的操作日志的记录 AOP 切面 | |
| 25 | + * | |
| 26 | + * @author 陈賝 | |
| 27 | + * @since 2023/6/13 13:54 | |
| 28 | + */ | |
| 29 | +@Component | |
| 30 | +@Aspect | |
| 31 | +@Slf4j | |
| 32 | +public class TradeOrderLogAspect { | |
| 33 | + | |
| 34 | + /** | |
| 35 | + * 订单编号 | |
| 36 | + */ | |
| 37 | + private static final ThreadLocal<Long> ORDER_ID = new ThreadLocal<>(); | |
| 38 | + /** | |
| 39 | + * 操作前的状态 | |
| 40 | + */ | |
| 41 | + private static final ThreadLocal<Integer> BEFORE_STATUS = new ThreadLocal<>(); | |
| 42 | + /** | |
| 43 | + * 操作后的状态 | |
| 44 | + */ | |
| 45 | + private static final ThreadLocal<Integer> AFTER_STATUS = new ThreadLocal<>(); | |
| 46 | + /** | |
| 47 | + * 拓展参数 Map,用于格式化操作内容 | |
| 48 | + */ | |
| 49 | + private static final ThreadLocal<Map<String, Object>> EXTS = new ThreadLocal<>(); | |
| 50 | + | |
| 51 | + public TradeOrderLogAspect() { | |
| 52 | + System.out.println(); | |
| 53 | + } | |
| 54 | + | |
| 55 | + @Resource | |
| 56 | + private TradeOrderLogService orderLogService; | |
| 57 | + | |
| 58 | + @AfterReturning("@annotation(orderLog)") | |
| 59 | + public void doAfterReturning(JoinPoint joinPoint, TradeOrderLog orderLog) { | |
| 60 | + try { | |
| 61 | + // 1.1 操作用户 | |
| 62 | + Integer userType = getUserType(); | |
| 63 | + Long userId = getUserId(); | |
| 64 | + // 1.2 订单信息 | |
| 65 | + Long orderId = ORDER_ID.get(); | |
| 66 | + Integer beforeStatus = BEFORE_STATUS.get(); | |
| 67 | + Integer afterStatus = AFTER_STATUS.get(); | |
| 68 | + Map<String, Object> exts = ObjectUtil.defaultIfNull(EXTS.get(), emptyMap()); | |
| 69 | + String content = StrUtil.format(orderLog.operateType().getContent(), exts); | |
| 70 | + | |
| 71 | + // 2.1 记录日志 | |
| 72 | + TradeOrderLogCreateReqBO createBO = new TradeOrderLogCreateReqBO() | |
| 73 | + .setUserId(userId).setUserType(userType) | |
| 74 | + .setOrderId(orderId).setBeforeStatus(beforeStatus).setAfterStatus(afterStatus) | |
| 75 | + .setOperateType(orderLog.operateType().getType()).setContent(content); | |
| 76 | + orderLogService.createOrderLog(createBO); | |
| 77 | + } catch (Exception ex) { | |
| 78 | + // todo 芋艿:清理上下文 | |
| 79 | + log.error("[doAfterReturning][orderLog({}) 订单日志错误]", toJsonString(orderLog), ex); | |
| 80 | + } | |
| 81 | + } | |
| 82 | + | |
| 83 | + /** | |
| 84 | + * 获得用户类型 | |
| 85 | + * | |
| 86 | + * 如果没有,则约定为 {@link TradeOrderLogDO#getUserType()} 系统 | |
| 87 | + * | |
| 88 | + * @return 用户类型 | |
| 89 | + */ | |
| 90 | + private static Integer getUserType() { | |
| 91 | + return ObjectUtil.defaultIfNull(WebFrameworkUtils.getLoginUserType(), TradeOrderLogDO.USER_TYPE_SYSTEM); | |
| 92 | + } | |
| 93 | + | |
| 94 | + /** | |
| 95 | + * 获得用户编号 | |
| 96 | + * | |
| 97 | + * 如果没有,则约定为 {@link TradeOrderLogDO#getUserId()} 系统 | |
| 98 | + * | |
| 99 | + * @return 用户类型 | |
| 100 | + */ | |
| 101 | + private static Long getUserId() { | |
| 102 | + return ObjectUtil.defaultIfNull(WebFrameworkUtils.getLoginUserId(), TradeOrderLogDO.USER_ID_SYSTEM); | |
| 103 | + } | |
| 104 | + | |
| 105 | + public static void setOrderInfo(Long id, Integer beforeStatus, Integer afterStatus, Map<String, Object> exts) { | |
| 106 | + ORDER_ID.set(id); | |
| 107 | + BEFORE_STATUS.set(beforeStatus); | |
| 108 | + AFTER_STATUS.set(afterStatus); | |
| 109 | + EXTS.set(exts); | |
| 110 | + } | |
| 111 | + | |
| 112 | +} | ... | ... |
yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/framework/order/core/utils/TradeOrderLogUtils.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.trade.framework.order.core.utils; | |
| 2 | + | |
| 3 | +import cn.iocoder.yudao.module.trade.framework.order.core.aop.TradeOrderLogAspect; | |
| 4 | + | |
| 5 | +import java.util.Map; | |
| 6 | + | |
| 7 | +/** | |
| 8 | + * 交易订单的操作日志 Utils | |
| 9 | + * | |
| 10 | + * @author 芋道源码 | |
| 11 | + */ | |
| 12 | +public class TradeOrderLogUtils { | |
| 13 | + | |
| 14 | + public static void setOrderInfo(Long id, Integer beforeStatus, Integer afterStatus) { | |
| 15 | + TradeOrderLogAspect.setOrderInfo(id, beforeStatus, afterStatus, null); | |
| 16 | + } | |
| 17 | + | |
| 18 | + public static void setOrderInfo(Long id, Integer beforeStatus, Integer afterStatus, | |
| 19 | + Map<String, Object> exts) { | |
| 20 | + TradeOrderLogAspect.setOrderInfo(id, beforeStatus, afterStatus, exts); | |
| 21 | + } | |
| 22 | + | |
| 23 | +} | ... | ... |
yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/order/TradeOrderLogService.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.trade.service.order; | |
| 2 | + | |
| 3 | +import cn.iocoder.yudao.module.trade.service.order.bo.logger.TradeOrderLogCreateReqBO; | |
| 4 | +import org.springframework.scheduling.annotation.Async; | |
| 5 | + | |
| 6 | +/** | |
| 7 | + * 交易下单日志 Service 接口 | |
| 8 | + * | |
| 9 | + * @author 陈賝 | |
| 10 | + * @since 2023/7/6 15:44 | |
| 11 | + */ | |
| 12 | +public interface TradeOrderLogService { | |
| 13 | + | |
| 14 | + /** | |
| 15 | + * 创建交易下单日志 | |
| 16 | + * | |
| 17 | + * @param logDTO 日志记录 | |
| 18 | + * @author 陈賝 | |
| 19 | + * @since 2023/7/6 15:45 | |
| 20 | + */ | |
| 21 | + @Async | |
| 22 | + void createOrderLog(TradeOrderLogCreateReqBO logDTO); | |
| 23 | + | |
| 24 | +} | ... | ... |
yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/order/TradeOrderLogServiceImpl.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.trade.service.order; | |
| 2 | + | |
| 3 | +import cn.iocoder.yudao.module.trade.service.order.bo.logger.TradeOrderLogCreateReqBO; | |
| 4 | +import org.springframework.stereotype.Service; | |
| 5 | + | |
| 6 | +/** | |
| 7 | + * 交易下单日志 Service 实现类 | |
| 8 | + * | |
| 9 | + * @author 陈賝 | |
| 10 | + * @since 2023/7/6 15:44 | |
| 11 | + */ | |
| 12 | +@Service | |
| 13 | +public class TradeOrderLogServiceImpl implements TradeOrderLogService { | |
| 14 | + | |
| 15 | + @Override | |
| 16 | + public void createOrderLog(TradeOrderLogCreateReqBO createReqBO) { | |
| 17 | + // TODO 芋艿:存储还没搞 | |
| 18 | + System.out.println(); | |
| 19 | + } | |
| 20 | + | |
| 21 | +} | ... | ... |
yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/order/bo/logger/TradeOrderLogCreateReqBO.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.trade.service.order.bo.logger; | |
| 2 | + | |
| 3 | +import lombok.Data; | |
| 4 | + | |
| 5 | +import javax.validation.constraints.NotNull; | |
| 6 | + | |
| 7 | +/** | |
| 8 | + * 订单日志的创建 Request BO | |
| 9 | + * | |
| 10 | + * @author 陈賝 | |
| 11 | + * @since 2023/7/6 15:27 | |
| 12 | + */ | |
| 13 | +@Data | |
| 14 | +public class TradeOrderLogCreateReqBO { | |
| 15 | + | |
| 16 | + /** | |
| 17 | + * 用户编号 | |
| 18 | + */ | |
| 19 | + @NotNull(message = "用户编号不能为空") | |
| 20 | + private Long userId; | |
| 21 | + /** | |
| 22 | + * 用户类型 | |
| 23 | + */ | |
| 24 | + @NotNull(message = "用户类型不能为空") | |
| 25 | + private Integer userType; | |
| 26 | + | |
| 27 | + /** | |
| 28 | + * 订单编号 | |
| 29 | + */ | |
| 30 | + @NotNull(message = "订单编号") | |
| 31 | + private Long orderId; | |
| 32 | + /** | |
| 33 | + * 操作前状态 | |
| 34 | + */ | |
| 35 | + private Integer beforeStatus; | |
| 36 | + /** | |
| 37 | + * 操作后状态 | |
| 38 | + */ | |
| 39 | + @NotNull(message = "操作后的状态不能为空") | |
| 40 | + private Integer afterStatus; | |
| 41 | + | |
| 42 | + /** | |
| 43 | + * 操作类型 | |
| 44 | + */ | |
| 45 | + private Integer operateType; | |
| 46 | + /** | |
| 47 | + * 操作明细 | |
| 48 | + */ | |
| 49 | + private String content; | |
| 50 | + | |
| 51 | +} | ... | ... |
yudao-module-member/yudao-module-member-api/src/main/java/cn/iocoder/yudao/module/member/enums/ErrorCodeConstants.java
| ... | ... | @@ -39,7 +39,7 @@ public interface ErrorCodeConstants { |
| 39 | 39 | ErrorCode SIGN_IN_CONFIG_EXISTS = new ErrorCode(1004009001, "签到天数规则已存在"); |
| 40 | 40 | |
| 41 | 41 | //========== 签到配置 1004010000 ========== |
| 42 | - | |
| 42 | + ErrorCode SIGN_IN_RECORD_TODAY_EXISTS = new ErrorCode(1004010000,"今日已签到,请勿重复签到"); | |
| 43 | 43 | |
| 44 | 44 | //========== 用户等级 1004011000 ========== |
| 45 | 45 | ErrorCode LEVEL_NOT_EXISTS = new ErrorCode(1004011000, "用户等级不存在"); | ... | ... |
yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/app/signin/AppMemberSignInController.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.member.controller.app.signin; | |
| 2 | + | |
| 3 | +import cn.iocoder.yudao.framework.common.pojo.CommonResult; | |
| 4 | +import cn.iocoder.yudao.module.member.convert.signin.MemberSignInRecordConvert; | |
| 5 | +import cn.iocoder.yudao.module.member.dal.dataobject.signin.MemberSignInRecordDO; | |
| 6 | +import cn.iocoder.yudao.module.member.service.signin.MemberSignInRecordService; | |
| 7 | +import io.swagger.v3.oas.annotations.Operation; | |
| 8 | +import io.swagger.v3.oas.annotations.tags.Tag; | |
| 9 | +import org.springframework.web.bind.annotation.GetMapping; | |
| 10 | +import org.springframework.web.bind.annotation.PostMapping; | |
| 11 | +import org.springframework.web.bind.annotation.RequestMapping; | |
| 12 | +import org.springframework.web.bind.annotation.RestController; | |
| 13 | + | |
| 14 | +import javax.annotation.Resource; | |
| 15 | + | |
| 16 | +import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; | |
| 17 | +import static cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils.getLoginUserId; | |
| 18 | + | |
| 19 | +// TODO @xiaqing:sign-in | |
| 20 | +@Tag(name = "签到APP - 签到") | |
| 21 | +@RestController | |
| 22 | +@RequestMapping("/member/signin") | |
| 23 | +public class AppMemberSignInController { | |
| 24 | + | |
| 25 | + @Resource | |
| 26 | + private MemberSignInRecordService signInRecordService; | |
| 27 | + | |
| 28 | + // TODO @xiaqing:泛型: | |
| 29 | + // TODO @xiaqing:合并到 AppMemberSignInRecordController 的 getSignInRecordSummary 里哈。 | |
| 30 | + @Operation(summary = "个人签到信息") | |
| 31 | + @GetMapping("/get-summary") | |
| 32 | + public CommonResult getUserSummary(){ | |
| 33 | + return success(signInRecordService.getSignInRecordSummary(getLoginUserId())); | |
| 34 | + } | |
| 35 | + | |
| 36 | + // TODO @xiaqing:泛型: | |
| 37 | + // TODO @xiaqing:合并到 AppMemberSignInRecordController 的 createSignInRecord 里哈。 | |
| 38 | + @Operation(summary = "会员签到") | |
| 39 | + @PostMapping("/create") | |
| 40 | + public CommonResult create(){ | |
| 41 | + MemberSignInRecordDO recordDO = signInRecordService.createSignRecord(getLoginUserId()); | |
| 42 | + return success(MemberSignInRecordConvert.INSTANCE.coverRecordToAppRecordVo(recordDO)); | |
| 43 | + } | |
| 44 | + | |
| 45 | +} | ... | ... |
yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/app/signin/vo/AppMemberSignInRecordRespVO.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.member.controller.app.signin.vo; | |
| 2 | + | |
| 3 | +import io.swagger.v3.oas.annotations.media.Schema; | |
| 4 | +import lombok.Data; | |
| 5 | + | |
| 6 | +import java.time.LocalDateTime; | |
| 7 | + | |
| 8 | +@Schema(description = "用户签到积分 Response VO") | |
| 9 | +@Data | |
| 10 | +public class AppMemberSignInRecordRespVO { | |
| 11 | + | |
| 12 | + @Schema(description = "第几天签到", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") | |
| 13 | + private Integer day; | |
| 14 | + | |
| 15 | + @Schema(description = "签到的分数", requiredMode = Schema.RequiredMode.REQUIRED, example = "10") | |
| 16 | + private Integer point; | |
| 17 | + | |
| 18 | + @Schema(description = "签到时间", requiredMode = Schema.RequiredMode.REQUIRED) | |
| 19 | + private LocalDateTime createTime; | |
| 20 | + | |
| 21 | +} | ... | ... |
yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/controller/app/signin/vo/AppMemberSignInSummaryRespVO.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.member.controller.app.signin.vo; | |
| 2 | + | |
| 3 | +import io.swagger.v3.oas.annotations.media.Schema; | |
| 4 | +import lombok.Data; | |
| 5 | + | |
| 6 | +import java.time.LocalDateTime; | |
| 7 | + | |
| 8 | +@Schema(description = "用户签到统计信息 Response VO") | |
| 9 | +@Data | |
| 10 | +public class AppMemberSignInSummaryRespVO { | |
| 11 | + | |
| 12 | + @Schema(description = "持续签到天数", requiredMode = Schema.RequiredMode.REQUIRED, example = "5") | |
| 13 | + private Integer continuousDay; | |
| 14 | + | |
| 15 | + @Schema(description = "总签到天数", requiredMode = Schema.RequiredMode.REQUIRED, example = "10") | |
| 16 | + private Integer totalDay; | |
| 17 | + | |
| 18 | + @Schema(description = "当天是否签到", requiredMode = Schema.RequiredMode.REQUIRED,example = "true") | |
| 19 | + private Boolean todaySignIn ; | |
| 20 | + | |
| 21 | +} | ... | ... |
yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/convert/signin/MemberSignInRecordConvert.java
| ... | ... | @@ -36,4 +36,6 @@ public interface MemberSignInRecordConvert { |
| 36 | 36 | |
| 37 | 37 | PageResult<AppMemberSignInRecordRespVO> convertPage02(PageResult<MemberSignInRecordDO> pageResult); |
| 38 | 38 | |
| 39 | + AppMemberSignInRecordRespVO coverRecordToAppRecordVo(MemberSignInRecordDO memberSignInRecordDO); | |
| 40 | + | |
| 39 | 41 | } | ... | ... |
yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/dal/mysql/signin/MemberSignInConfigMapper.java
| ... | ... | @@ -18,7 +18,7 @@ public interface MemberSignInConfigMapper extends BaseMapperX<MemberSignInConfig |
| 18 | 18 | return selectOne(MemberSignInConfigDO::getDay, day); |
| 19 | 19 | } |
| 20 | 20 | |
| 21 | - default List<MemberSignInConfigDO> selectListByStatus(Integer status) { | |
| 21 | + default List <MemberSignInConfigDO> selectListByStatus(Integer status) { | |
| 22 | 22 | return selectList(MemberSignInConfigDO::getStatus, status); |
| 23 | 23 | } |
| 24 | 24 | } | ... | ... |
yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/dal/mysql/signin/MemberSignInRecordMapper.java
| ... | ... | @@ -8,6 +8,7 @@ import cn.iocoder.yudao.module.member.controller.admin.signin.vo.record.MemberSi |
| 8 | 8 | import cn.iocoder.yudao.module.member.dal.dataobject.signin.MemberSignInRecordDO; |
| 9 | 9 | import org.apache.ibatis.annotations.Mapper; |
| 10 | 10 | |
| 11 | +import java.util.List; | |
| 11 | 12 | import java.util.Set; |
| 12 | 13 | |
| 13 | 14 | /** |
| ... | ... | @@ -33,4 +34,12 @@ public interface MemberSignInRecordMapper extends BaseMapperX<MemberSignInRecord |
| 33 | 34 | .orderByDesc(MemberSignInRecordDO::getId)); |
| 34 | 35 | } |
| 35 | 36 | |
| 37 | + | |
| 38 | + //获取用户的签到记录列表信息,根据签到时间倒序 | |
| 39 | + default List<MemberSignInRecordDO> selectListByUserId(Long userId){ | |
| 40 | + return selectList(new LambdaQueryWrapperX <MemberSignInRecordDO>() | |
| 41 | + .eq(MemberSignInRecordDO::getUserId, userId) | |
| 42 | + .orderByDesc(MemberSignInRecordDO::getCreateTime)); | |
| 43 | + } | |
| 44 | + | |
| 36 | 45 | } | ... | ... |
yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/service/signin/MemberSignInRecordService.java
| ... | ... | @@ -3,6 +3,7 @@ package cn.iocoder.yudao.module.member.service.signin; |
| 3 | 3 | import cn.iocoder.yudao.framework.common.pojo.PageParam; |
| 4 | 4 | import cn.iocoder.yudao.framework.common.pojo.PageResult; |
| 5 | 5 | import cn.iocoder.yudao.module.member.controller.admin.signin.vo.record.MemberSignInRecordPageReqVO; |
| 6 | +import cn.iocoder.yudao.module.member.controller.app.signin.vo.AppMemberSignInSummaryRespVO; | |
| 6 | 7 | import cn.iocoder.yudao.module.member.dal.dataobject.signin.MemberSignInRecordDO; |
| 7 | 8 | |
| 8 | 9 | /** |
| ... | ... | @@ -29,4 +30,21 @@ public interface MemberSignInRecordService { |
| 29 | 30 | */ |
| 30 | 31 | PageResult<MemberSignInRecordDO> getSignRecordPage(Long userId, PageParam pageParam); |
| 31 | 32 | |
| 33 | + /** | |
| 34 | + * 创建签到记录 | |
| 35 | + * | |
| 36 | + * @param userId 用户编号 | |
| 37 | + * @return 签到记录 | |
| 38 | + */ | |
| 39 | + MemberSignInRecordDO createSignRecord(Long userId); | |
| 40 | + | |
| 41 | + /** | |
| 42 | + * 根据用户编号,获得个人签到统计信息 | |
| 43 | + * | |
| 44 | + * @param userId 用户编号 | |
| 45 | + * @return 个人签到统计信息 | |
| 46 | + */ | |
| 47 | + AppMemberSignInSummaryRespVO getSignInRecordSummary(Long userId); | |
| 48 | + | |
| 49 | + | |
| 32 | 50 | } | ... | ... |
yudao-module-member/yudao-module-member-biz/src/main/java/cn/iocoder/yudao/module/member/service/signin/MemberSignInRecordServiceImpl.java
| 1 | 1 | package cn.iocoder.yudao.module.member.service.signin; |
| 2 | 2 | |
| 3 | +import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; | |
| 3 | 4 | import cn.iocoder.yudao.framework.common.pojo.PageParam; |
| 4 | 5 | import cn.iocoder.yudao.framework.common.pojo.PageResult; |
| 6 | +import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; | |
| 5 | 7 | import cn.iocoder.yudao.module.member.api.user.MemberUserApi; |
| 6 | 8 | import cn.iocoder.yudao.module.member.api.user.dto.MemberUserRespDTO; |
| 7 | 9 | import cn.iocoder.yudao.module.member.controller.admin.signin.vo.record.MemberSignInRecordPageReqVO; |
| 10 | +import cn.iocoder.yudao.module.member.controller.app.signin.vo.AppMemberSignInSummaryRespVO; | |
| 11 | +import cn.iocoder.yudao.module.member.dal.dataobject.signin.MemberSignInConfigDO; | |
| 8 | 12 | import cn.iocoder.yudao.module.member.dal.dataobject.signin.MemberSignInRecordDO; |
| 13 | +import cn.iocoder.yudao.module.member.dal.mysql.signin.MemberSignInConfigMapper; | |
| 9 | 14 | import cn.iocoder.yudao.module.member.dal.mysql.signin.MemberSignInRecordMapper; |
| 15 | +import cn.iocoder.yudao.module.member.enums.ErrorCodeConstants; | |
| 10 | 16 | import org.apache.commons.lang3.StringUtils; |
| 11 | 17 | import org.springframework.stereotype.Service; |
| 12 | 18 | import org.springframework.util.CollectionUtils; |
| 13 | 19 | import org.springframework.validation.annotation.Validated; |
| 14 | 20 | |
| 15 | 21 | import javax.annotation.Resource; |
| 22 | +import java.time.LocalDate; | |
| 23 | +import java.time.temporal.ChronoUnit; | |
| 16 | 24 | import java.util.List; |
| 17 | 25 | import java.util.Set; |
| 18 | 26 | |
| 27 | +import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; | |
| 19 | 28 | import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertSet; |
| 20 | 29 | |
| 21 | 30 | /** |
| ... | ... | @@ -28,17 +37,66 @@ import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils. |
| 28 | 37 | public class MemberSignInRecordServiceImpl implements MemberSignInRecordService { |
| 29 | 38 | |
| 30 | 39 | @Resource |
| 31 | - private MemberSignInRecordMapper memberSignInRecordMapper; | |
| 40 | + private MemberSignInRecordMapper signInRecordMapper; | |
| 41 | + @Resource | |
| 42 | + private MemberSignInConfigMapper signInConfigMapper; | |
| 32 | 43 | |
| 33 | 44 | @Resource |
| 34 | 45 | private MemberUserApi memberUserApi; |
| 35 | 46 | |
| 36 | 47 | @Override |
| 37 | - public PageResult<MemberSignInRecordDO> getSignInRecordPage(MemberSignInRecordPageReqVO pageReqVO) { | |
| 38 | - // 根据用户昵称查询出用户 ids | |
| 39 | - Set<Long> userIds = null; | |
| 48 | + public AppMemberSignInSummaryRespVO getSignInRecordSummary(Long userId) { | |
| 49 | + AppMemberSignInSummaryRespVO vo = new AppMemberSignInSummaryRespVO(); | |
| 50 | + vo.setTotalDay(0); | |
| 51 | + vo.setContinuousDay(0); | |
| 52 | + vo.setTodaySignIn(false); | |
| 53 | + //获取用户签到的记录,按照天数倒序获取 | |
| 54 | + List <MemberSignInRecordDO> signInRecordDOList = signInRecordMapper.selectListByUserId(userId); | |
| 55 | + // TODO @xiaqing:if 空的时候,直接 return;这样括号少,逻辑更简洁; | |
| 56 | + if(!CollectionUtils.isEmpty(signInRecordDOList)){ | |
| 57 | + //设置总签到天数 | |
| 58 | + vo.setTotalDay(signInRecordDOList.size()); // TODO @xiaqing:是不是不用读取 signInRecordDOList 所有的,而是 count下,然后另外再读取一条最后一条; | |
| 59 | + //判断当天是否有签到复用校验方法 | |
| 60 | + // TODO @xiaqing:不要用异常实现逻辑;还是判断哈; | |
| 61 | + try { | |
| 62 | + validSignDay(signInRecordDOList.get(0)); | |
| 63 | + vo.setTodaySignIn(false); | |
| 64 | + }catch (Exception e){ | |
| 65 | + vo.setTodaySignIn(true); | |
| 66 | + } | |
| 67 | + //如果当天签到了则说明连续签到天数有意义,否则直接用默认值0 | |
| 68 | + if(vo.getTodaySignIn()){ | |
| 69 | + //下方计算连续签到从2天开始,此处直接设置一天连续签到 | |
| 70 | + vo.setContinuousDay(1); | |
| 71 | + //判断连续签到天数 | |
| 72 | + // TODO @xiaqing:这里逻辑,想想怎么在简化下,可读性可以在提升下哈; | |
| 73 | + for (int i = 1; i < signInRecordDOList.size(); i++) { | |
| 74 | + //前一天减1等于当前天数则说明连续,继续循环 | |
| 75 | + LocalDate cur = signInRecordDOList.get(i).getCreateTime().toLocalDate(); | |
| 76 | + LocalDate pre = signInRecordDOList.get(i-1).getCreateTime().toLocalDate(); | |
| 77 | + if(1==daysBetween(cur,pre)){ | |
| 78 | + vo.setContinuousDay(i+1); | |
| 79 | + }else{ | |
| 80 | + break; | |
| 81 | + } | |
| 82 | + } | |
| 83 | + } | |
| 84 | + | |
| 85 | + | |
| 86 | + } | |
| 87 | + return vo; | |
| 88 | + } | |
| 89 | + | |
| 90 | + private long daysBetween(LocalDate date1,LocalDate date2){ | |
| 91 | + return ChronoUnit.DAYS.between(date1, date2); | |
| 92 | + } | |
| 93 | + | |
| 94 | + @Override | |
| 95 | + public PageResult <MemberSignInRecordDO> getSignInRecordPage(MemberSignInRecordPageReqVO pageReqVO) { | |
| 96 | + // 根据用户昵称查询出用户ids | |
| 97 | + Set <Long> userIds = null; | |
| 40 | 98 | if (StringUtils.isNotBlank(pageReqVO.getNickname())) { |
| 41 | - List<MemberUserRespDTO> users = memberUserApi.getUserListByNickname(pageReqVO.getNickname()); | |
| 99 | + List <MemberUserRespDTO> users = memberUserApi.getUserListByNickname(pageReqVO.getNickname()); | |
| 42 | 100 | // 如果查询用户结果为空直接返回无需继续查询 |
| 43 | 101 | if (CollectionUtils.isEmpty(users)) { |
| 44 | 102 | return PageResult.empty(); |
| ... | ... | @@ -46,12 +104,72 @@ public class MemberSignInRecordServiceImpl implements MemberSignInRecordService |
| 46 | 104 | userIds = convertSet(users, MemberUserRespDTO::getId); |
| 47 | 105 | } |
| 48 | 106 | // 分页查询 |
| 49 | - return memberSignInRecordMapper.selectPage(pageReqVO, userIds); | |
| 107 | + return signInRecordMapper.selectPage(pageReqVO, userIds); | |
| 50 | 108 | } |
| 51 | 109 | |
| 52 | 110 | @Override |
| 53 | 111 | public PageResult<MemberSignInRecordDO> getSignRecordPage(Long userId, PageParam pageParam) { |
| 54 | - return memberSignInRecordMapper.selectPage(userId, pageParam); | |
| 112 | + return signInRecordMapper.selectPage(userId, pageParam); | |
| 113 | + } | |
| 114 | + | |
| 115 | + @Override | |
| 116 | + public MemberSignInRecordDO createSignRecord(Long userId) { | |
| 117 | + // 获取当前用户签到的最大天数 | |
| 118 | + // TODO @xiaqing:db 操作,dou封装到 mapper 中; | |
| 119 | + // TODO @xiaqing:maxSignDay,是不是变量叫 lastRecord 会更容易理解哈; | |
| 120 | + MemberSignInRecordDO maxSignDay = signInRecordMapper.selectOne(new LambdaQueryWrapperX <MemberSignInRecordDO>() | |
| 121 | + .eq(MemberSignInRecordDO::getUserId, userId) | |
| 122 | + .orderByDesc(MemberSignInRecordDO::getDay) | |
| 123 | + .last("limit 1")); | |
| 124 | + // 判断是否重复签到 | |
| 125 | + validSignDay(maxSignDay); | |
| 126 | + | |
| 127 | + // TODO @xiaqing:可以使用 // 进行注释 | |
| 128 | + /**1.查询出当前签到的天数**/ | |
| 129 | + MemberSignInRecordDO sign = new MemberSignInRecordDO().setUserId(userId); // TODO @xiaqing:应该使用 record 变量,会更合适 | |
| 130 | + sign.setDay(1); // 设置签到初始化天数 | |
| 131 | + sign.setPoint(0); // 设置签到分数默认为 0 | |
| 132 | + // 如果不为空则修改当前签到对应的天数 | |
| 133 | + // TODO @xiaqing:应该是要判断连续哈,就是昨天; | |
| 134 | + if (maxSignDay != null) { | |
| 135 | + sign.setDay(maxSignDay.getDay() + 1); | |
| 136 | + } | |
| 137 | + /**2.获取签到对应的分数**/ | |
| 138 | + // 获取所有的签到规则,按照天数排序,只获取启用的 TODO @xiaqing:不要使用 signInConfigMapper 直接查询,而是要通过 SigninConfigService; | |
| 139 | + List <MemberSignInConfigDO> configDOList = signInConfigMapper.selectList(new LambdaQueryWrapperX <MemberSignInConfigDO>() | |
| 140 | + .eq(MemberSignInConfigDO::getStatus, CommonStatusEnum.ENABLE.getStatus()) | |
| 141 | + .orderByAsc(MemberSignInConfigDO::getDay)); | |
| 142 | + // 如果签到的天数大于最大启用的规则天数,直接给最大签到的分数 | |
| 143 | + // TODO @xiaqing:超过最大配置的天数,应该直接重置到第一天哈; | |
| 144 | + MemberSignInConfigDO lastConfig = configDOList.get(configDOList.size() - 1); | |
| 145 | + if (sign.getDay() > lastConfig.getDay()) { | |
| 146 | + sign.setPoint(lastConfig.getPoint()); | |
| 147 | + } else { | |
| 148 | + configDOList.forEach(el -> { | |
| 149 | + // 循环匹配对应天数,设置对应分数 | |
| 150 | + // TODO @xiaqing:使用 equals;另外,这种不应该去遍历比较,从可读性来说,应该 CollUtil.findOne() | |
| 151 | + if (el.getDay() == sign.getDay()) { | |
| 152 | + sign.setPoint(el.getPoint()); | |
| 153 | + } | |
| 154 | + | |
| 155 | + }); | |
| 156 | + } | |
| 157 | + | |
| 158 | + // 3. 插入当前签到获取的分数 | |
| 159 | + signInRecordMapper.insert(sign); | |
| 160 | + return sign; | |
| 161 | + } | |
| 162 | + | |
| 163 | + // TODO @xiaqing:校验使用 validate 动词哈;可以改成 validateSigned | |
| 164 | + private void validSignDay(MemberSignInRecordDO signInRecordDO) { | |
| 165 | + // TODO @xiaqing:代码格式:if () {} 要有括号哈 | |
| 166 | + if (signInRecordDO == null) | |
| 167 | + return; | |
| 168 | + // TODO @xiaqing:可以直接使用 DateUtils.isToday() | |
| 169 | + LocalDate today = LocalDate.now(); | |
| 170 | + if (today.equals(signInRecordDO.getCreateTime().toLocalDate())) { | |
| 171 | + throw exception(ErrorCodeConstants.SIGN_IN_RECORD_TODAY_EXISTS); | |
| 172 | + } | |
| 55 | 173 | } |
| 56 | 174 | |
| 57 | 175 | } | ... | ... |
yudao-module-pay/yudao-module-pay-api/src/main/java/cn/iocoder/yudao/module/pay/enums/ErrorCodeConstants.java
| ... | ... | @@ -47,6 +47,14 @@ public interface ErrorCodeConstants { |
| 47 | 47 | ErrorCode WALLET_REFUND_AMOUNT_ERROR = new ErrorCode(1007007003, "钱包退款金额不对"); |
| 48 | 48 | ErrorCode WALLET_REFUND_EXIST = new ErrorCode(1007007004, "已经存在钱包退款"); |
| 49 | 49 | |
| 50 | + // TODO @jason:把钱包充值,单独搞个错误码段哈; | |
| 51 | + | |
| 52 | + ErrorCode WALLET_RECHARGE_NOT_FOUND = new ErrorCode(1007007005, "钱包充值记录不存在"); | |
| 53 | + ErrorCode WALLET_RECHARGE_UPDATE_PAID_STATUS_NOT_UNPAID = new ErrorCode(1007007006, "钱包充值更新支付状态失败,钱包充值记录不是【未支付】状态"); | |
| 54 | + ErrorCode WALLET_RECHARGE_UPDATE_PAID_PAY_ORDER_ID_ERROR = new ErrorCode(1007007007, "钱包充值更新支付状态失败,支付单编号不匹配"); | |
| 55 | + ErrorCode WALLET_RECHARGE_UPDATE_PAID_PAY_ORDER_STATUS_NOT_SUCCESS = new ErrorCode(1007007008, "钱包充值更新支付状态失败,支付单状态不是【支付成功】状态"); | |
| 56 | + ErrorCode WALLET_RECHARGE_UPDATE_PAID_PAY_PRICE_NOT_MATCH = new ErrorCode(1007007009, "钱包充值更新支付状态失败,支付单金额不匹配"); | |
| 57 | + | |
| 50 | 58 | // ========== 示例订单 1007900000 ========== |
| 51 | 59 | ErrorCode DEMO_ORDER_NOT_FOUND = new ErrorCode(1007900000, "示例订单不存在"); |
| 52 | 60 | ErrorCode DEMO_ORDER_UPDATE_PAID_STATUS_NOT_UNPAID = new ErrorCode(1007900001, "示例订单更新支付状态失败,订单不是【未支付】状态"); | ... | ... |
yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/app/wallet/AppPayWalletRechargeController.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.framework.operatelog.core.annotations.OperateLog; | |
| 5 | +import cn.iocoder.yudao.module.pay.api.notify.dto.PayOrderNotifyReqDTO; | |
| 6 | +import cn.iocoder.yudao.module.pay.controller.app.wallet.vo.recharge.AppPayWalletRechargeCreateReqVO; | |
| 7 | +import cn.iocoder.yudao.module.pay.controller.app.wallet.vo.recharge.AppPayWalletRechargeCreateRespVO; | |
| 8 | +import cn.iocoder.yudao.module.pay.convert.wallet.PayWalletRechargeConvert; | |
| 9 | +import cn.iocoder.yudao.module.pay.dal.dataobject.wallet.PayWalletRechargeDO; | |
| 10 | +import cn.iocoder.yudao.module.pay.service.wallet.PayWalletRechargeService; | |
| 11 | +import io.swagger.v3.oas.annotations.Operation; | |
| 12 | +import io.swagger.v3.oas.annotations.tags.Tag; | |
| 13 | +import lombok.extern.slf4j.Slf4j; | |
| 14 | +import org.springframework.validation.annotation.Validated; | |
| 15 | +import org.springframework.web.bind.annotation.PostMapping; | |
| 16 | +import org.springframework.web.bind.annotation.RequestBody; | |
| 17 | +import org.springframework.web.bind.annotation.RequestMapping; | |
| 18 | +import org.springframework.web.bind.annotation.RestController; | |
| 19 | + | |
| 20 | +import javax.annotation.Resource; | |
| 21 | +import javax.annotation.security.PermitAll; | |
| 22 | +import javax.validation.Valid; | |
| 23 | + | |
| 24 | +import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; | |
| 25 | +import static cn.iocoder.yudao.framework.web.core.util.WebFrameworkUtils.getLoginUserId; | |
| 26 | +import static cn.iocoder.yudao.framework.web.core.util.WebFrameworkUtils.getLoginUserType; | |
| 27 | + | |
| 28 | +@Tag(name = "用户 APP - 钱包充值") | |
| 29 | +@RestController | |
| 30 | +@RequestMapping("/pay/wallet-recharge") | |
| 31 | +@Validated | |
| 32 | +@Slf4j | |
| 33 | +public class AppPayWalletRechargeController { | |
| 34 | + | |
| 35 | + @Resource | |
| 36 | + private PayWalletRechargeService walletRechargeService; | |
| 37 | + | |
| 38 | + @PostMapping("/create") | |
| 39 | + @Operation(summary = "创建钱包充值记录(发起充值)") | |
| 40 | + public CommonResult<AppPayWalletRechargeCreateRespVO> createWalletRecharge( | |
| 41 | + @Valid @RequestBody AppPayWalletRechargeCreateReqVO reqVO) { | |
| 42 | + PayWalletRechargeDO walletRecharge = walletRechargeService.createWalletRecharge( | |
| 43 | + getLoginUserId(), getLoginUserType(), reqVO); | |
| 44 | + return success(PayWalletRechargeConvert.INSTANCE.convert(walletRecharge)); | |
| 45 | + } | |
| 46 | + | |
| 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 | + | |
| 57 | + // TODO @jason:管理后台,是不是可以搞个发起退款; | |
| 58 | + | |
| 59 | +} | ... | ... |
yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/app/wallet/AppPayWalletTransactionController.java
| ... | ... | @@ -18,7 +18,6 @@ import org.springframework.web.bind.annotation.RestController; |
| 18 | 18 | |
| 19 | 19 | import javax.annotation.Resource; |
| 20 | 20 | import javax.validation.Valid; |
| 21 | - | |
| 22 | 21 | import java.time.LocalDateTime; |
| 23 | 22 | |
| 24 | 23 | import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; | ... | ... |
yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/app/wallet/vo/recharge/AppPayWalletRechargeCreateReqVO.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 | +import javax.validation.constraints.DecimalMin; | |
| 7 | +import javax.validation.constraints.NotNull; | |
| 8 | + | |
| 9 | +@Schema(description = "用户 APP - 创建钱包充值 Request VO") | |
| 10 | +@Data | |
| 11 | +public class AppPayWalletRechargeCreateReqVO { | |
| 12 | + | |
| 13 | + @Schema(description = "支付金额", requiredMode = Schema.RequiredMode.REQUIRED, example = "1000") | |
| 14 | + @NotNull(message = "支付金额不能为空") | |
| 15 | + // TODO @jason999:是不是 @Min 哈? | |
| 16 | + @DecimalMin(value = "0", inclusive = false, message = "支付金额必须大于零") | |
| 17 | + private Integer payPrice; | |
| 18 | + | |
| 19 | + // TODO @jason:这个是不是后端计算出来呀?不然前端可以直接搞了。。。 | |
| 20 | + @Schema(description = "钱包赠送金额", requiredMode = Schema.RequiredMode.REQUIRED, example = "1000") | |
| 21 | + @NotNull(message = "钱包赠送金额不能为空") | |
| 22 | + @DecimalMin(value = "0", message = "钱包赠送金额必须大于等于零") | |
| 23 | + private Integer walletBonus; | |
| 24 | + | |
| 25 | +} | ... | ... |
yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/app/wallet/vo/recharge/AppPayWalletRechargeCreateRespVO.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 - 创建钱包充值 Resp VO") | |
| 7 | +@Data | |
| 8 | +public class AppPayWalletRechargeCreateRespVO { | |
| 9 | + | |
| 10 | + @Schema(description = "钱包充值编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") | |
| 11 | + private Long id; | |
| 12 | + | |
| 13 | + @Schema(description = "支付订单编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "100") | |
| 14 | + private Long payOrderId; | |
| 15 | + | |
| 16 | +} | ... | ... |
yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/convert/wallet/PayWalletRechargeConvert.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.pay.convert.wallet; | |
| 2 | + | |
| 3 | +import cn.iocoder.yudao.module.pay.controller.app.wallet.vo.recharge.AppPayWalletRechargeCreateReqVO; | |
| 4 | +import cn.iocoder.yudao.module.pay.controller.app.wallet.vo.recharge.AppPayWalletRechargeCreateRespVO; | |
| 5 | +import cn.iocoder.yudao.module.pay.dal.dataobject.wallet.PayWalletRechargeDO; | |
| 6 | +import org.mapstruct.Mapper; | |
| 7 | +import org.mapstruct.factory.Mappers; | |
| 8 | + | |
| 9 | +/** | |
| 10 | + * @author jason | |
| 11 | + */ | |
| 12 | +@Mapper | |
| 13 | +public interface PayWalletRechargeConvert { | |
| 14 | + | |
| 15 | + PayWalletRechargeConvert INSTANCE = Mappers.getMapper(PayWalletRechargeConvert.class); | |
| 16 | + | |
| 17 | + PayWalletRechargeDO convert(AppPayWalletRechargeCreateReqVO vo); | |
| 18 | + | |
| 19 | + // TODO @jason:好像 price 相加,可以写个表达式的,通过 @Mapping | |
| 20 | + default PayWalletRechargeDO convert(Long walletId, AppPayWalletRechargeCreateReqVO vo) { | |
| 21 | + PayWalletRechargeDO walletRecharge = convert(vo); | |
| 22 | + return walletRecharge.setWalletId(walletId) | |
| 23 | + .setPrice(walletRecharge.getPayPrice() + walletRecharge.getWalletBonus()); | |
| 24 | + } | |
| 25 | + | |
| 26 | + AppPayWalletRechargeCreateRespVO convert(PayWalletRechargeDO bean); | |
| 27 | + | |
| 28 | +} | ... | ... |
yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/convert/wallet/PayWalletTransactionConvert.java
| ... | ... | @@ -3,7 +3,7 @@ package cn.iocoder.yudao.module.pay.convert.wallet; |
| 3 | 3 | import cn.iocoder.yudao.framework.common.pojo.PageResult; |
| 4 | 4 | import cn.iocoder.yudao.module.pay.controller.app.wallet.vo.transaction.AppPayWalletTransactionRespVO; |
| 5 | 5 | import cn.iocoder.yudao.module.pay.dal.dataobject.wallet.PayWalletTransactionDO; |
| 6 | -import cn.iocoder.yudao.module.pay.service.wallet.bo.CreateWalletTransactionBO; | |
| 6 | +import cn.iocoder.yudao.module.pay.service.wallet.bo.WalletTransactionCreateReqBO; | |
| 7 | 7 | import org.mapstruct.Mapper; |
| 8 | 8 | import org.mapstruct.factory.Mappers; |
| 9 | 9 | |
| ... | ... | @@ -14,6 +14,6 @@ public interface PayWalletTransactionConvert { |
| 14 | 14 | |
| 15 | 15 | PageResult<AppPayWalletTransactionRespVO> convertPage(PageResult<PayWalletTransactionDO> page); |
| 16 | 16 | |
| 17 | - PayWalletTransactionDO convert(CreateWalletTransactionBO bean); | |
| 17 | + PayWalletTransactionDO convert(WalletTransactionCreateReqBO bean); | |
| 18 | 18 | |
| 19 | 19 | } | ... | ... |
yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/dal/dataobject/wallet/PayWalletRechargeDO.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.pay.dal.dataobject.wallet; | |
| 2 | + | |
| 3 | +import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; | |
| 4 | +import cn.iocoder.yudao.module.pay.dal.dataobject.order.PayOrderDO; | |
| 5 | +import cn.iocoder.yudao.module.pay.dal.dataobject.refund.PayRefundDO; | |
| 6 | +import com.baomidou.mybatisplus.annotation.KeySequence; | |
| 7 | +import com.baomidou.mybatisplus.annotation.TableId; | |
| 8 | +import com.baomidou.mybatisplus.annotation.TableName; | |
| 9 | +import lombok.Data; | |
| 10 | + | |
| 11 | +import java.time.LocalDateTime; | |
| 12 | + | |
| 13 | +/** | |
| 14 | + * 会员钱包充值 | |
| 15 | + */ | |
| 16 | +@TableName(value ="pay_wallet_recharge") | |
| 17 | +@KeySequence("pay_wallet_recharge_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 | |
| 18 | +@Data | |
| 19 | +public class PayWalletRechargeDO extends BaseDO { | |
| 20 | + | |
| 21 | + /** | |
| 22 | + * 编号 | |
| 23 | + */ | |
| 24 | + @TableId | |
| 25 | + private Long id; | |
| 26 | + | |
| 27 | + /** | |
| 28 | + * 钱包编号 | |
| 29 | + * | |
| 30 | + * 关联 {@link PayWalletDO#getId()} | |
| 31 | + */ | |
| 32 | + private Long walletId; | |
| 33 | + | |
| 34 | + // TODO @jason:要不改成 totalPrice? | |
| 35 | + /** | |
| 36 | + * 用户实际到账余额 | |
| 37 | + * | |
| 38 | + * 例如充 100 送 20,则该值是 120 | |
| 39 | + */ | |
| 40 | + private Integer price; | |
| 41 | + /** | |
| 42 | + * 实际支付金额 | |
| 43 | + */ | |
| 44 | + private Integer payPrice; | |
| 45 | + // TODO @jason:bonusPrice 哈,更统一一点; | |
| 46 | + /** | |
| 47 | + * 钱包赠送金额 | |
| 48 | + */ | |
| 49 | + private Integer walletBonus; | |
| 50 | + | |
| 51 | + /** | |
| 52 | + * 是否已支付 | |
| 53 | + * | |
| 54 | + * true - 已支付 | |
| 55 | + * false - 未支付 | |
| 56 | + */ | |
| 57 | + private Boolean payStatus; | |
| 58 | + | |
| 59 | + /** | |
| 60 | + * 支付订单编号 | |
| 61 | + * | |
| 62 | + * 关联 {@link PayOrderDO#getId()} | |
| 63 | + */ | |
| 64 | + private Long payOrderId; | |
| 65 | + /** | |
| 66 | + * 支付成功的支付渠道 | |
| 67 | + * | |
| 68 | + * 冗余 {@link PayOrderDO#getChannelCode()} | |
| 69 | + */ | |
| 70 | + private String payChannelCode; | |
| 71 | + /** | |
| 72 | + * 订单支付时间 | |
| 73 | + */ | |
| 74 | + private LocalDateTime payTime; | |
| 75 | + | |
| 76 | + /** | |
| 77 | + * 支付退款单编号 | |
| 78 | + * | |
| 79 | + * 关联 {@link PayRefundDO#getId()} | |
| 80 | + */ | |
| 81 | + private Long payRefundId; | |
| 82 | + // TODO @jason:要不改成 refundTotalPrice? | |
| 83 | + /** | |
| 84 | + * 退款金额,包含赠送金额 | |
| 85 | + */ | |
| 86 | + private Integer refundPrice; | |
| 87 | + /** | |
| 88 | + * 退款支付金额 | |
| 89 | + */ | |
| 90 | + private Integer refundPayPrice; | |
| 91 | + // TODO @jason:要不改成 refundBonusPrice? | |
| 92 | + /** | |
| 93 | + * 退款钱包赠送金额 | |
| 94 | + */ | |
| 95 | + private Integer refundWalletBonus; | |
| 96 | + /** | |
| 97 | + * 退款时间 | |
| 98 | + */ | |
| 99 | + private LocalDateTime refundTime; | |
| 100 | + | |
| 101 | +} | ... | ... |
yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/dal/mysql/wallet/PayWalletMapper.java
| ... | ... | @@ -14,6 +14,8 @@ public interface PayWalletMapper extends BaseMapperX<PayWalletDO> { |
| 14 | 14 | PayWalletDO::getUserType, userType); |
| 15 | 15 | } |
| 16 | 16 | |
| 17 | + // TODO @jason:下面几个更新方法,把 id 放前面哈。一般来说,重要参数放前面; | |
| 18 | + | |
| 17 | 19 | /** |
| 18 | 20 | * 当消费退款时候, 更新钱包 |
| 19 | 21 | * |
| ... | ... | @@ -42,6 +44,20 @@ public interface PayWalletMapper extends BaseMapperX<PayWalletDO> { |
| 42 | 44 | .ge(PayWalletDO::getBalance, price); // cas 逻辑 |
| 43 | 45 | return update(null, lambdaUpdateWrapper); |
| 44 | 46 | } |
| 47 | + | |
| 48 | + /** | |
| 49 | + * 当充值的时候,更新钱包 | |
| 50 | + * @param price 钱包金额 | |
| 51 | + * @param id 钱包 id | |
| 52 | + */ | |
| 53 | + default int updateWhenRecharge(Integer price, Long id){ | |
| 54 | + LambdaUpdateWrapper<PayWalletDO> lambdaUpdateWrapper = new LambdaUpdateWrapper<PayWalletDO>() | |
| 55 | + .setSql(" balance = balance + " + price | |
| 56 | + + ", total_recharge = total_recharge + " + price) | |
| 57 | + .eq(PayWalletDO::getId, id); | |
| 58 | + return update(null, lambdaUpdateWrapper); | |
| 59 | + } | |
| 60 | + | |
| 45 | 61 | } |
| 46 | 62 | |
| 47 | 63 | ... | ... |
yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/dal/mysql/wallet/PayWalletRechargeMapper.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.pay.dal.mysql.wallet; | |
| 2 | + | |
| 3 | +import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; | |
| 4 | +import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; | |
| 5 | +import cn.iocoder.yudao.module.pay.dal.dataobject.wallet.PayWalletRechargeDO; | |
| 6 | +import org.apache.ibatis.annotations.Mapper; | |
| 7 | + | |
| 8 | +@Mapper | |
| 9 | +public interface PayWalletRechargeMapper extends BaseMapperX<PayWalletRechargeDO> { | |
| 10 | + | |
| 11 | + default int updateByIdAndPaid(Long id, boolean wherePayStatus, PayWalletRechargeDO updateObj){ | |
| 12 | + return update(updateObj, new LambdaQueryWrapperX<PayWalletRechargeDO>() | |
| 13 | + .eq(PayWalletRechargeDO::getId, id).eq(PayWalletRechargeDO::getPayStatus, wherePayStatus)); | |
| 14 | + } | |
| 15 | + | |
| 16 | +} | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | ... | ... |
yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/service/wallet/PayWalletRechargeService.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.pay.service.wallet; | |
| 2 | + | |
| 3 | +import cn.iocoder.yudao.module.pay.controller.app.wallet.vo.recharge.AppPayWalletRechargeCreateReqVO; | |
| 4 | +import cn.iocoder.yudao.module.pay.dal.dataobject.wallet.PayWalletRechargeDO; | |
| 5 | + | |
| 6 | +/** | |
| 7 | + * 钱包充值 Service 接口 | |
| 8 | + * | |
| 9 | + * @author jason | |
| 10 | + */ | |
| 11 | +public interface PayWalletRechargeService { | |
| 12 | + | |
| 13 | + /** | |
| 14 | + * 创建钱包充值记录(发起充值) | |
| 15 | + * | |
| 16 | + * @param userId 用户 id | |
| 17 | + * @param userType 用户类型 | |
| 18 | + * @param createReqVO 钱包充值请求 VO | |
| 19 | + * @return 钱包充值记录 | |
| 20 | + */ | |
| 21 | + PayWalletRechargeDO createWalletRecharge(Long userId, Integer userType, | |
| 22 | + AppPayWalletRechargeCreateReqVO createReqVO); | |
| 23 | + | |
| 24 | + /** | |
| 25 | + * 更新钱包充值成功 | |
| 26 | + * | |
| 27 | + * @param id 钱包充值记录 id | |
| 28 | + * @param payOrderId 支付订单 id | |
| 29 | + */ | |
| 30 | + void updateWalletRechargerPaid(Long id, Long payOrderId); | |
| 31 | + | |
| 32 | +} | ... | ... |
yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/service/wallet/PayWalletRechargeServiceImpl.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.pay.service.wallet; | |
| 2 | + | |
| 3 | +import cn.iocoder.yudao.module.pay.api.order.dto.PayOrderCreateReqDTO; | |
| 4 | +import cn.iocoder.yudao.module.pay.controller.app.wallet.vo.recharge.AppPayWalletRechargeCreateReqVO; | |
| 5 | +import cn.iocoder.yudao.module.pay.convert.wallet.PayWalletRechargeConvert; | |
| 6 | +import cn.iocoder.yudao.module.pay.dal.dataobject.order.PayOrderDO; | |
| 7 | +import cn.iocoder.yudao.module.pay.dal.dataobject.wallet.PayWalletDO; | |
| 8 | +import cn.iocoder.yudao.module.pay.dal.dataobject.wallet.PayWalletRechargeDO; | |
| 9 | +import cn.iocoder.yudao.module.pay.dal.mysql.wallet.PayWalletRechargeMapper; | |
| 10 | +import cn.iocoder.yudao.module.pay.enums.member.PayWalletBizTypeEnum; | |
| 11 | +import cn.iocoder.yudao.module.pay.enums.order.PayOrderStatusEnum; | |
| 12 | +import cn.iocoder.yudao.module.pay.service.order.PayOrderService; | |
| 13 | +import lombok.extern.slf4j.Slf4j; | |
| 14 | +import org.springframework.stereotype.Service; | |
| 15 | +import org.springframework.transaction.annotation.Transactional; | |
| 16 | + | |
| 17 | +import javax.annotation.Resource; | |
| 18 | +import java.time.Duration; | |
| 19 | +import java.time.LocalDateTime; | |
| 20 | + | |
| 21 | +import static cn.hutool.core.util.ObjectUtil.notEqual; | |
| 22 | +import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; | |
| 23 | +import static cn.iocoder.yudao.framework.common.util.date.LocalDateTimeUtils.addTime; | |
| 24 | +import static cn.iocoder.yudao.framework.common.util.json.JsonUtils.toJsonString; | |
| 25 | +import static cn.iocoder.yudao.framework.common.util.servlet.ServletUtils.getClientIP; | |
| 26 | +import static cn.iocoder.yudao.module.pay.enums.ErrorCodeConstants.*; | |
| 27 | + | |
| 28 | +/** | |
| 29 | + * 钱包充值 Service 实现类 | |
| 30 | + * | |
| 31 | + * @author jason | |
| 32 | + */ | |
| 33 | +@Service | |
| 34 | +@Slf4j | |
| 35 | +public class PayWalletRechargeServiceImpl implements PayWalletRechargeService { | |
| 36 | + /** | |
| 37 | + * TODO 放到 配置文件中 | |
| 38 | + */ | |
| 39 | + private static final Long WALLET_PAY_APP_ID = 8L; | |
| 40 | + | |
| 41 | + private static final String WALLET_RECHARGE_ORDER_SUBJECT = "钱包余额充值"; | |
| 42 | + | |
| 43 | + @Resource | |
| 44 | + private PayWalletRechargeMapper walletRechargeMapper; | |
| 45 | + | |
| 46 | + @Resource | |
| 47 | + private PayWalletService payWalletService; | |
| 48 | + @Resource | |
| 49 | + private PayOrderService payOrderService; | |
| 50 | + | |
| 51 | + @Override | |
| 52 | + @Transactional(rollbackFor = Exception.class) | |
| 53 | + public PayWalletRechargeDO createWalletRecharge(Long userId, Integer userType, | |
| 54 | + AppPayWalletRechargeCreateReqVO createReqVO) { | |
| 55 | + // 1. 新增钱包充值记录 | |
| 56 | + PayWalletDO wallet = payWalletService.getOrCreateWallet(userId, userType); | |
| 57 | + PayWalletRechargeDO walletRecharge = PayWalletRechargeConvert.INSTANCE.convert(wallet.getId(), createReqVO); | |
| 58 | + walletRechargeMapper.insert(walletRecharge); | |
| 59 | + | |
| 60 | + // 2.1 创建支付单 | |
| 61 | + Long payOrderId = payOrderService.createOrder(new PayOrderCreateReqDTO() | |
| 62 | + .setAppId(WALLET_PAY_APP_ID).setUserIp(getClientIP()) | |
| 63 | + .setMerchantOrderId(walletRecharge.getId().toString()) // 业务的订单编号 | |
| 64 | + .setSubject(WALLET_RECHARGE_ORDER_SUBJECT).setBody("").setPrice(walletRecharge.getPayPrice()) | |
| 65 | + .setExpireTime(addTime(Duration.ofHours(2L)))); | |
| 66 | + // 2.2 更新钱包充值记录中支付订单 | |
| 67 | + walletRechargeMapper.updateById(new PayWalletRechargeDO().setPayOrderId(payOrderId) | |
| 68 | + .setId(walletRecharge.getId())); | |
| 69 | + // TODO @jason:是不是你直接返回就好啦;然后 payOrderId 设置下; | |
| 70 | + return walletRechargeMapper.selectById(walletRecharge.getId()); | |
| 71 | + } | |
| 72 | + | |
| 73 | + @Override | |
| 74 | + @Transactional(rollbackFor = Exception.class) | |
| 75 | + public void updateWalletRechargerPaid(Long id, Long payOrderId) { | |
| 76 | + // 1.1 获取钱包充值记录 | |
| 77 | + PayWalletRechargeDO walletRecharge = walletRechargeMapper.selectById(id); | |
| 78 | + if (walletRecharge == null) { | |
| 79 | + log.error("[updateWalletRechargerPaid][钱包充值记录不存在,钱包充值记录 id({})]", id); | |
| 80 | + throw exception(WALLET_RECHARGE_NOT_FOUND); | |
| 81 | + } | |
| 82 | + // 1.2 校验钱包充值是否可以支付 | |
| 83 | + PayOrderDO payOrderDO = validateWalletRechargerCanPaid(walletRecharge, payOrderId); | |
| 84 | + | |
| 85 | + // 2. 更新钱包充值的支付状态 | |
| 86 | + int updateCount = walletRechargeMapper.updateByIdAndPaid(id,false, | |
| 87 | + new PayWalletRechargeDO().setId(id).setPayStatus(true).setPayTime(LocalDateTime.now()) | |
| 88 | + .setPayChannelCode(payOrderDO.getChannelCode())); | |
| 89 | + if (updateCount == 0) { | |
| 90 | + throw exception(WALLET_RECHARGE_UPDATE_PAID_STATUS_NOT_UNPAID); | |
| 91 | + } | |
| 92 | + | |
| 93 | + // 3. 更新钱包余额 | |
| 94 | + // TODO @jason:这样的话,未来提现会不会把充值的,也提现走哈。类似先充 100,送 110;然后提现 110; | |
| 95 | + payWalletService.addWalletBalance(walletRecharge.getWalletId(), String.valueOf(id), | |
| 96 | + PayWalletBizTypeEnum.RECHARGE, walletRecharge.getPrice()); | |
| 97 | + } | |
| 98 | + | |
| 99 | + private PayOrderDO validateWalletRechargerCanPaid(PayWalletRechargeDO walletRecharge, Long payOrderId) { | |
| 100 | + // 1.1 校验充值记录的支付状态 | |
| 101 | + if (walletRecharge.getPayStatus()) { | |
| 102 | + log.error("[validateWalletRechargerCanPaid][钱包({}) 不处于未支付状态! 钱包数据是:{}]", | |
| 103 | + walletRecharge.getId(), toJsonString(walletRecharge)); | |
| 104 | + throw exception(WALLET_RECHARGE_UPDATE_PAID_STATUS_NOT_UNPAID); | |
| 105 | + } | |
| 106 | + // 1.2 校验支付订单匹配 | |
| 107 | + if (notEqual(walletRecharge.getPayOrderId(), payOrderId)) { // 支付单号 | |
| 108 | + log.error("[validateWalletRechargerCanPaid][钱包({}) 支付单不匹配({}),请进行处理! 钱包数据是:{}]", | |
| 109 | + walletRecharge.getId(), payOrderId, toJsonString(walletRecharge)); | |
| 110 | + throw exception(WALLET_RECHARGE_UPDATE_PAID_PAY_ORDER_ID_ERROR); | |
| 111 | + } | |
| 112 | + | |
| 113 | + // 2.1 校验支付单是否存在 | |
| 114 | + PayOrderDO payOrder = payOrderService.getOrder(payOrderId); | |
| 115 | + if (payOrder == null) { | |
| 116 | + log.error("[validateWalletRechargerCanPaid][钱包({}) payOrder({}) 不存在,请进行处理!]", | |
| 117 | + walletRecharge.getId(), payOrderId); | |
| 118 | + throw exception(PAY_ORDER_NOT_FOUND); | |
| 119 | + } | |
| 120 | + // 2.2 校验支付单已支付 | |
| 121 | + if (!PayOrderStatusEnum.isSuccess(payOrder.getStatus())) { | |
| 122 | + log.error("[validateWalletRechargerCanPaid][钱包({}) payOrder({}) 未支付,请进行处理!payOrder 数据是:{}]", | |
| 123 | + walletRecharge.getId(), payOrderId, toJsonString(payOrder)); | |
| 124 | + throw exception(WALLET_RECHARGE_UPDATE_PAID_PAY_ORDER_STATUS_NOT_SUCCESS); | |
| 125 | + } | |
| 126 | + // 2.3 校验支付金额一致 | |
| 127 | + if (notEqual(payOrder.getPrice(), walletRecharge.getPayPrice())) { | |
| 128 | + log.error("[validateDemoOrderCanPaid][钱包({}) payOrder({}) 支付金额不匹配,请进行处理!钱包 数据是:{},payOrder 数据是:{}]", | |
| 129 | + walletRecharge.getId(), payOrderId, toJsonString(walletRecharge), toJsonString(payOrder)); | |
| 130 | + throw exception(WALLET_RECHARGE_UPDATE_PAID_PAY_PRICE_NOT_MATCH); | |
| 131 | + } | |
| 132 | + // 2.4 校验支付订单的商户订单匹配 | |
| 133 | + if (notEqual(payOrder.getMerchantOrderId(), walletRecharge.getId().toString())) { | |
| 134 | + log.error("[validateDemoOrderCanPaid][钱包({}) 支付单不匹配({}),请进行处理!payOrder 数据是:{}]", | |
| 135 | + walletRecharge.getId(), payOrderId, toJsonString(payOrder)); | |
| 136 | + throw exception(WALLET_RECHARGE_UPDATE_PAID_PAY_ORDER_ID_ERROR); | |
| 137 | + } | |
| 138 | + return payOrder; | |
| 139 | + } | |
| 140 | + | |
| 141 | +} | ... | ... |
yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/service/wallet/PayWalletService.java
| ... | ... | @@ -22,6 +22,13 @@ public interface PayWalletService { |
| 22 | 22 | PayWalletDO getOrCreateWallet(Long userId, Integer userType); |
| 23 | 23 | |
| 24 | 24 | /** |
| 25 | + * 获取钱包信息 | |
| 26 | + * | |
| 27 | + * @param walletId 钱包 id | |
| 28 | + */ | |
| 29 | + PayWalletDO getWallet(Long walletId); | |
| 30 | + | |
| 31 | + /** | |
| 25 | 32 | * 钱包订单支付 |
| 26 | 33 | * |
| 27 | 34 | * @param userId 用户 id |
| ... | ... | @@ -56,14 +63,13 @@ public interface PayWalletService { |
| 56 | 63 | /** |
| 57 | 64 | * 增加钱包余额 |
| 58 | 65 | * |
| 59 | - * @param userId 用户 id | |
| 60 | - * @param userType 用户类型 | |
| 66 | + * @param walletId 钱包 id | |
| 61 | 67 | * @param bizId 业务关联 id |
| 62 | 68 | * @param bizType 业务关联分类 |
| 63 | 69 | * @param price 增加金额 |
| 64 | 70 | * @return 钱包流水 |
| 65 | 71 | */ |
| 66 | - PayWalletTransactionDO addWalletBalance(Long userId, Integer userType, | |
| 67 | - Long bizId, PayWalletBizTypeEnum bizType, Integer price); | |
| 72 | + PayWalletTransactionDO addWalletBalance(Long walletId, String bizId, | |
| 73 | + PayWalletBizTypeEnum bizType, Integer price); | |
| 68 | 74 | |
| 69 | 75 | } | ... | ... |
yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/service/wallet/PayWalletServiceImpl.java
| ... | ... | @@ -9,7 +9,7 @@ import cn.iocoder.yudao.module.pay.dal.mysql.wallet.PayWalletMapper; |
| 9 | 9 | import cn.iocoder.yudao.module.pay.enums.member.PayWalletBizTypeEnum; |
| 10 | 10 | import cn.iocoder.yudao.module.pay.service.order.PayOrderService; |
| 11 | 11 | import cn.iocoder.yudao.module.pay.service.refund.PayRefundService; |
| 12 | -import cn.iocoder.yudao.module.pay.service.wallet.bo.CreateWalletTransactionBO; | |
| 12 | +import cn.iocoder.yudao.module.pay.service.wallet.bo.WalletTransactionCreateReqBO; | |
| 13 | 13 | import lombok.extern.slf4j.Slf4j; |
| 14 | 14 | import org.springframework.context.annotation.Lazy; |
| 15 | 15 | import org.springframework.stereotype.Service; |
| ... | ... | @@ -56,6 +56,11 @@ public class PayWalletServiceImpl implements PayWalletService { |
| 56 | 56 | } |
| 57 | 57 | |
| 58 | 58 | @Override |
| 59 | + public PayWalletDO getWallet(Long walletId) { | |
| 60 | + return walletMapper.selectById(walletId); | |
| 61 | + } | |
| 62 | + | |
| 63 | + @Override | |
| 59 | 64 | @Transactional(rollbackFor = Exception.class) |
| 60 | 65 | public PayWalletTransactionDO orderPay(Long userId, Integer userType, String outTradeNo, Integer price) { |
| 61 | 66 | // 1. 判断支付交易拓展单是否存 |
| ... | ... | @@ -79,8 +84,9 @@ public class PayWalletServiceImpl implements PayWalletService { |
| 79 | 84 | Long walletId = validateWalletCanRefund(payRefund.getId(), payRefund.getChannelOrderNo(), refundPrice); |
| 80 | 85 | PayWalletDO wallet = walletMapper.selectById(walletId); |
| 81 | 86 | Assert.notNull(wallet, "钱包 {} 不存在", walletId); |
| 87 | + | |
| 82 | 88 | // 2. 增加余额 |
| 83 | - return addWalletBalance(wallet.getUserId(), wallet.getUserType(), payRefund.getId(), PAYMENT_REFUND, refundPrice); | |
| 89 | + return addWalletBalance(walletId, String.valueOf(payRefund.getId()), PAYMENT_REFUND, refundPrice); | |
| 84 | 90 | } |
| 85 | 91 | |
| 86 | 92 | /** |
| ... | ... | @@ -132,34 +138,39 @@ public class PayWalletServiceImpl implements PayWalletService { |
| 132 | 138 | } |
| 133 | 139 | // 2.2 生成钱包流水 |
| 134 | 140 | Integer afterBalance = payWallet.getBalance() - price; |
| 135 | - CreateWalletTransactionBO bo = new CreateWalletTransactionBO().setWalletId(payWallet.getId()) | |
| 141 | + WalletTransactionCreateReqBO bo = new WalletTransactionCreateReqBO().setWalletId(payWallet.getId()) | |
| 136 | 142 | .setPrice(-price).setBalance(afterBalance).setBizId(String.valueOf(bizId)) |
| 137 | 143 | .setBizType(bizType.getType()).setTitle(bizType.getDescription()); |
| 138 | 144 | return walletTransactionService.createWalletTransaction(bo); |
| 139 | 145 | } |
| 140 | 146 | |
| 141 | 147 | @Override |
| 142 | - public PayWalletTransactionDO addWalletBalance(Long userId, Integer userType, | |
| 143 | - Long bizId, PayWalletBizTypeEnum bizType, Integer price) { | |
| 144 | - // 1. 获取钱包 | |
| 145 | - PayWalletDO payWallet = getOrCreateWallet(userId, userType); | |
| 148 | + public PayWalletTransactionDO addWalletBalance(Long walletId, String bizId, | |
| 149 | + PayWalletBizTypeEnum bizType, Integer price) { | |
| 150 | + // 1.1 获取钱包 | |
| 151 | + PayWalletDO payWallet = getWallet(walletId); | |
| 152 | + if (payWallet == null) { | |
| 153 | + log.error("[addWalletBalance],用户钱包({})不存在.", walletId); | |
| 154 | + throw exception(WALLET_NOT_FOUND); | |
| 155 | + } | |
| 156 | + // 1.2 更新钱包金额 | |
| 146 | 157 | switch (bizType) { |
| 147 | - case PAYMENT_REFUND: { | |
| 148 | - // 更新退款 | |
| 158 | + case PAYMENT_REFUND: { // 退款更新 | |
| 149 | 159 | walletMapper.updateWhenConsumptionRefund(price, payWallet.getId()); |
| 150 | 160 | break; |
| 151 | 161 | } |
| 152 | - case RECHARGE: { | |
| 153 | - //TODO | |
| 162 | + case RECHARGE: { // 充值更新 | |
| 163 | + walletMapper.updateWhenRecharge(price, payWallet.getId()); | |
| 154 | 164 | break; |
| 155 | 165 | } |
| 166 | + // TODO 其它类型;这里可以先跑异常;避免有业务搞错; | |
| 156 | 167 | } |
| 157 | 168 | |
| 158 | 169 | // 2. 生成钱包流水 |
| 159 | - CreateWalletTransactionBO bo = new CreateWalletTransactionBO().setWalletId(payWallet.getId()) | |
| 160 | - .setPrice(price).setBalance(payWallet.getBalance()+price).setBizId(String.valueOf(bizId)) | |
| 161 | - .setBizType(bizType.getType()).setTitle(bizType.getDescription()); | |
| 162 | - return walletTransactionService.createWalletTransaction(bo); | |
| 170 | + WalletTransactionCreateReqBO transactionCreateReqBO = new WalletTransactionCreateReqBO() | |
| 171 | + .setWalletId(payWallet.getId()).setPrice(price).setBalance(payWallet.getBalance() + price) | |
| 172 | + .setBizId(bizId).setBizType(bizType.getType()).setTitle(bizType.getDescription()); | |
| 173 | + return walletTransactionService.createWalletTransaction(transactionCreateReqBO); | |
| 163 | 174 | } |
| 164 | 175 | |
| 165 | 176 | } | ... | ... |
yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/service/wallet/PayWalletTransactionService.java
| ... | ... | @@ -4,7 +4,7 @@ import cn.iocoder.yudao.framework.common.pojo.PageResult; |
| 4 | 4 | import cn.iocoder.yudao.module.pay.controller.app.wallet.vo.transaction.AppPayWalletTransactionPageReqVO; |
| 5 | 5 | import cn.iocoder.yudao.module.pay.dal.dataobject.wallet.PayWalletTransactionDO; |
| 6 | 6 | import cn.iocoder.yudao.module.pay.enums.member.PayWalletBizTypeEnum; |
| 7 | -import cn.iocoder.yudao.module.pay.service.wallet.bo.CreateWalletTransactionBO; | |
| 7 | +import cn.iocoder.yudao.module.pay.service.wallet.bo.WalletTransactionCreateReqBO; | |
| 8 | 8 | |
| 9 | 9 | import javax.validation.Valid; |
| 10 | 10 | |
| ... | ... | @@ -31,7 +31,7 @@ public interface PayWalletTransactionService { |
| 31 | 31 | * @param bo 创建钱包流水 bo |
| 32 | 32 | * @return 新建的钱包 do |
| 33 | 33 | */ |
| 34 | - PayWalletTransactionDO createWalletTransaction(@Valid CreateWalletTransactionBO bo); | |
| 34 | + PayWalletTransactionDO createWalletTransaction(@Valid WalletTransactionCreateReqBO bo); | |
| 35 | 35 | |
| 36 | 36 | /** |
| 37 | 37 | * 根据 no,获取钱包余流水 |
| ... | ... | @@ -48,5 +48,5 @@ public interface PayWalletTransactionService { |
| 48 | 48 | * @return 钱包流水 |
| 49 | 49 | */ |
| 50 | 50 | PayWalletTransactionDO getWalletTransaction(String bizId, PayWalletBizTypeEnum type); |
| 51 | - | |
| 51 | + | |
| 52 | 52 | } | ... | ... |
yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/service/wallet/PayWalletTransactionServiceImpl.java
| ... | ... | @@ -8,7 +8,7 @@ import cn.iocoder.yudao.module.pay.dal.dataobject.wallet.PayWalletTransactionDO; |
| 8 | 8 | import cn.iocoder.yudao.module.pay.dal.mysql.wallet.PayWalletTransactionMapper; |
| 9 | 9 | import cn.iocoder.yudao.module.pay.dal.redis.no.PayNoRedisDAO; |
| 10 | 10 | import cn.iocoder.yudao.module.pay.enums.member.PayWalletBizTypeEnum; |
| 11 | -import cn.iocoder.yudao.module.pay.service.wallet.bo.CreateWalletTransactionBO; | |
| 11 | +import cn.iocoder.yudao.module.pay.service.wallet.bo.WalletTransactionCreateReqBO; | |
| 12 | 12 | import lombok.extern.slf4j.Slf4j; |
| 13 | 13 | import org.springframework.stereotype.Service; |
| 14 | 14 | |
| ... | ... | @@ -43,7 +43,7 @@ public class PayWalletTransactionServiceImpl implements PayWalletTransactionServ |
| 43 | 43 | } |
| 44 | 44 | |
| 45 | 45 | @Override |
| 46 | - public PayWalletTransactionDO createWalletTransaction(CreateWalletTransactionBO bo) { | |
| 46 | + public PayWalletTransactionDO createWalletTransaction(WalletTransactionCreateReqBO bo) { | |
| 47 | 47 | PayWalletTransactionDO transaction = PayWalletTransactionConvert.INSTANCE.convert(bo) |
| 48 | 48 | .setNo(noRedisDAO.generate(WALLET_NO_PREFIX)); |
| 49 | 49 | payWalletTransactionMapper.insert(transaction); | ... | ... |
yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/service/wallet/bo/CreateWalletTransactionBO.java renamed to yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/service/wallet/bo/WalletTransactionCreateReqBO.java
yudao-server/src/main/resources/application-local.yaml
| ... | ... | @@ -44,31 +44,31 @@ spring: |
| 44 | 44 | primary: master |
| 45 | 45 | datasource: |
| 46 | 46 | master: |
| 47 | - name: ruoyi-vue-pro | |
| 48 | - url: jdbc:mysql://127.0.0.1:3306/${spring.datasource.dynamic.datasource.master.name}?useSSL=false&serverTimezone=Asia/Shanghai&allowPublicKeyRetrieval=true&nullCatalogMeansCurrent=true # MySQL Connector/J 8.X 连接的示例 | |
| 47 | + name: mall | |
| 48 | + url: jdbc:mysql://10.211.55.5:3308/${spring.datasource.dynamic.datasource.slave.name}?useSSL=false&serverTimezone=Asia/Shanghai&allowPublicKeyRetrieval=true&nullCatalogMeansCurrent=true # MySQL Connector/J 8.X 连接的示例 | |
| 49 | 49 | # url: jdbc:mysql://127.0.0.1:3306/${spring.datasource.dynamic.datasource.master.name}?useSSL=false&allowPublicKeyRetrieval=true&useUnicode=true&characterEncoding=UTF-8&serverTimezone=CTT # MySQL Connector/J 5.X 连接的示例 |
| 50 | 50 | # url: jdbc:postgresql://127.0.0.1:5432/${spring.datasource.dynamic.datasource.master.name} # PostgreSQL 连接的示例 |
| 51 | 51 | # url: jdbc:oracle:thin:@127.0.0.1:1521:xe # Oracle 连接的示例 |
| 52 | 52 | # url: jdbc:sqlserver://127.0.0.1:1433;DatabaseName=${spring.datasource.dynamic.datasource.master.name} # SQLServer 连接的示例 |
| 53 | 53 | username: root |
| 54 | - password: 123456 | |
| 54 | + password: 1qaz!QAZ | |
| 55 | 55 | # username: sa |
| 56 | 56 | # password: JSm:g(*%lU4ZAkz06cd52KqT3)i1?H7W |
| 57 | 57 | slave: # 模拟从库,可根据自己需要修改 |
| 58 | - name: ruoyi-vue-pro | |
| 59 | - url: jdbc:mysql://127.0.0.1:3306/${spring.datasource.dynamic.datasource.master.name}?useSSL=false&serverTimezone=Asia/Shanghai&allowPublicKeyRetrieval=true&nullCatalogMeansCurrent=true # MySQL Connector/J 8.X 连接的示例 | |
| 58 | + name: mall | |
| 59 | + url: jdbc:mysql://10.211.55.5:3308/${spring.datasource.dynamic.datasource.slave.name}?useSSL=false&serverTimezone=Asia/Shanghai&allowPublicKeyRetrieval=true&nullCatalogMeansCurrent=true # MySQL Connector/J 8.X 连接的示例 | |
| 60 | 60 | # url: jdbc:mysql://127.0.0.1:3306/${spring.datasource.dynamic.datasource.slave.name}?useSSL=false&allowPublicKeyRetrieval=true&useUnicode=true&characterEncoding=UTF-8&serverTimezone=CTT # MySQL Connector/J 5.X 连接的示例 |
| 61 | 61 | # url: jdbc:postgresql://127.0.0.1:5432/${spring.datasource.dynamic.datasource.slave.name} # PostgreSQL 连接的示例 |
| 62 | 62 | # url: jdbc:oracle:thin:@127.0.0.1:1521:xe # Oracle 连接的示例 |
| 63 | 63 | # url: jdbc:sqlserver://127.0.0.1:1433;DatabaseName=${spring.datasource.dynamic.datasource.slave.name} # SQLServer 连接的示例 |
| 64 | 64 | username: root |
| 65 | - password: 123456 | |
| 65 | + password: 1qaz!QAZ | |
| 66 | 66 | # username: sa |
| 67 | 67 | # password: JSm:g(*%lU4ZAkz06cd52KqT3)i1?H7W |
| 68 | 68 | |
| 69 | 69 | # Redis 配置。Redisson 默认的配置足够使用,一般不需要进行调优 |
| 70 | 70 | redis: |
| 71 | - host: 127.0.0.1 # 地址 | |
| 71 | + host: 10.211.55.5 # 地址 | |
| 72 | 72 | port: 6379 # 端口 |
| 73 | 73 | database: 0 # 数据库索引 |
| 74 | 74 | # password: dev # 密码,建议生产环境开启 | ... | ... |