Commit 75874035a458871fb4fa958dfce8fe78c22a2e57
Merge remote-tracking branch 'origin/feature/mall_product' into brokerate
Showing
25 changed files
with
354 additions
and
86 deletions
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,7 +39,7 @@ public interface ErrorCodeConstants { | ||
| 39 | ErrorCode SIGN_IN_CONFIG_EXISTS = new ErrorCode(1004009001, "签到天数规则已存在"); | 39 | ErrorCode SIGN_IN_CONFIG_EXISTS = new ErrorCode(1004009001, "签到天数规则已存在"); |
| 40 | 40 | ||
| 41 | //========== 签到配置 1004010000 ========== | 41 | //========== 签到配置 1004010000 ========== |
| 42 | - | 42 | + ErrorCode SIGN_IN_RECORD_TODAY_EXISTS = new ErrorCode(1004010000,"今日已签到,请勿重复签到"); |
| 43 | 43 | ||
| 44 | //========== 用户等级 1004011000 ========== | 44 | //========== 用户等级 1004011000 ========== |
| 45 | ErrorCode LEVEL_NOT_EXISTS = new ErrorCode(1004011000, "用户等级不存在"); | 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,4 +36,6 @@ public interface MemberSignInRecordConvert { | ||
| 36 | 36 | ||
| 37 | PageResult<AppMemberSignInRecordRespVO> convertPage02(PageResult<MemberSignInRecordDO> pageResult); | 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,7 +18,7 @@ public interface MemberSignInConfigMapper extends BaseMapperX<MemberSignInConfig | ||
| 18 | return selectOne(MemberSignInConfigDO::getDay, day); | 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 | return selectList(MemberSignInConfigDO::getStatus, status); | 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,6 +8,7 @@ import cn.iocoder.yudao.module.member.controller.admin.signin.vo.record.MemberSi | ||
| 8 | import cn.iocoder.yudao.module.member.dal.dataobject.signin.MemberSignInRecordDO; | 8 | import cn.iocoder.yudao.module.member.dal.dataobject.signin.MemberSignInRecordDO; |
| 9 | import org.apache.ibatis.annotations.Mapper; | 9 | import org.apache.ibatis.annotations.Mapper; |
| 10 | 10 | ||
| 11 | +import java.util.List; | ||
| 11 | import java.util.Set; | 12 | import java.util.Set; |
| 12 | 13 | ||
| 13 | /** | 14 | /** |
| @@ -33,4 +34,12 @@ public interface MemberSignInRecordMapper extends BaseMapperX<MemberSignInRecord | @@ -33,4 +34,12 @@ public interface MemberSignInRecordMapper extends BaseMapperX<MemberSignInRecord | ||
| 33 | .orderByDesc(MemberSignInRecordDO::getId)); | 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,6 +3,7 @@ package cn.iocoder.yudao.module.member.service.signin; | ||
| 3 | import cn.iocoder.yudao.framework.common.pojo.PageParam; | 3 | import cn.iocoder.yudao.framework.common.pojo.PageParam; |
| 4 | import cn.iocoder.yudao.framework.common.pojo.PageResult; | 4 | import cn.iocoder.yudao.framework.common.pojo.PageResult; |
| 5 | import cn.iocoder.yudao.module.member.controller.admin.signin.vo.record.MemberSignInRecordPageReqVO; | 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 | import cn.iocoder.yudao.module.member.dal.dataobject.signin.MemberSignInRecordDO; | 7 | import cn.iocoder.yudao.module.member.dal.dataobject.signin.MemberSignInRecordDO; |
| 7 | 8 | ||
| 8 | /** | 9 | /** |
| @@ -29,4 +30,21 @@ public interface MemberSignInRecordService { | @@ -29,4 +30,21 @@ public interface MemberSignInRecordService { | ||
| 29 | */ | 30 | */ |
| 30 | PageResult<MemberSignInRecordDO> getSignRecordPage(Long userId, PageParam pageParam); | 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 | package cn.iocoder.yudao.module.member.service.signin; | 1 | package cn.iocoder.yudao.module.member.service.signin; |
| 2 | 2 | ||
| 3 | +import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; | ||
| 3 | import cn.iocoder.yudao.framework.common.pojo.PageParam; | 4 | import cn.iocoder.yudao.framework.common.pojo.PageParam; |
| 4 | import cn.iocoder.yudao.framework.common.pojo.PageResult; | 5 | import cn.iocoder.yudao.framework.common.pojo.PageResult; |
| 6 | +import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; | ||
| 5 | import cn.iocoder.yudao.module.member.api.user.MemberUserApi; | 7 | import cn.iocoder.yudao.module.member.api.user.MemberUserApi; |
| 6 | import cn.iocoder.yudao.module.member.api.user.dto.MemberUserRespDTO; | 8 | import cn.iocoder.yudao.module.member.api.user.dto.MemberUserRespDTO; |
| 7 | import cn.iocoder.yudao.module.member.controller.admin.signin.vo.record.MemberSignInRecordPageReqVO; | 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 | import cn.iocoder.yudao.module.member.dal.dataobject.signin.MemberSignInRecordDO; | 12 | import cn.iocoder.yudao.module.member.dal.dataobject.signin.MemberSignInRecordDO; |
| 13 | +import cn.iocoder.yudao.module.member.dal.mysql.signin.MemberSignInConfigMapper; | ||
| 9 | import cn.iocoder.yudao.module.member.dal.mysql.signin.MemberSignInRecordMapper; | 14 | import cn.iocoder.yudao.module.member.dal.mysql.signin.MemberSignInRecordMapper; |
| 15 | +import cn.iocoder.yudao.module.member.enums.ErrorCodeConstants; | ||
| 10 | import org.apache.commons.lang3.StringUtils; | 16 | import org.apache.commons.lang3.StringUtils; |
| 11 | import org.springframework.stereotype.Service; | 17 | import org.springframework.stereotype.Service; |
| 12 | import org.springframework.util.CollectionUtils; | 18 | import org.springframework.util.CollectionUtils; |
| 13 | import org.springframework.validation.annotation.Validated; | 19 | import org.springframework.validation.annotation.Validated; |
| 14 | 20 | ||
| 15 | import javax.annotation.Resource; | 21 | import javax.annotation.Resource; |
| 22 | +import java.time.LocalDate; | ||
| 23 | +import java.time.temporal.ChronoUnit; | ||
| 16 | import java.util.List; | 24 | import java.util.List; |
| 17 | import java.util.Set; | 25 | import java.util.Set; |
| 18 | 26 | ||
| 27 | +import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; | ||
| 19 | import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertSet; | 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,17 +37,66 @@ import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils. | ||
| 28 | public class MemberSignInRecordServiceImpl implements MemberSignInRecordService { | 37 | public class MemberSignInRecordServiceImpl implements MemberSignInRecordService { |
| 29 | 38 | ||
| 30 | @Resource | 39 | @Resource |
| 31 | - private MemberSignInRecordMapper memberSignInRecordMapper; | 40 | + private MemberSignInRecordMapper signInRecordMapper; |
| 41 | + @Resource | ||
| 42 | + private MemberSignInConfigMapper signInConfigMapper; | ||
| 32 | 43 | ||
| 33 | @Resource | 44 | @Resource |
| 34 | private MemberUserApi memberUserApi; | 45 | private MemberUserApi memberUserApi; |
| 35 | 46 | ||
| 36 | @Override | 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 | if (StringUtils.isNotBlank(pageReqVO.getNickname())) { | 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 | if (CollectionUtils.isEmpty(users)) { | 101 | if (CollectionUtils.isEmpty(users)) { |
| 44 | return PageResult.empty(); | 102 | return PageResult.empty(); |
| @@ -46,12 +104,72 @@ public class MemberSignInRecordServiceImpl implements MemberSignInRecordService | @@ -46,12 +104,72 @@ public class MemberSignInRecordServiceImpl implements MemberSignInRecordService | ||
| 46 | userIds = convertSet(users, MemberUserRespDTO::getId); | 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 | @Override | 110 | @Override |
| 53 | public PageResult<MemberSignInRecordDO> getSignRecordPage(Long userId, PageParam pageParam) { | 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
| @@ -46,6 +46,9 @@ public interface ErrorCodeConstants { | @@ -46,6 +46,9 @@ public interface ErrorCodeConstants { | ||
| 46 | ErrorCode WALLET_TRANSACTION_NOT_FOUND = new ErrorCode(1007007002, "未找到对应的钱包交易"); | 46 | ErrorCode WALLET_TRANSACTION_NOT_FOUND = new ErrorCode(1007007002, "未找到对应的钱包交易"); |
| 47 | ErrorCode WALLET_REFUND_AMOUNT_ERROR = new ErrorCode(1007007003, "钱包退款金额不对"); | 47 | ErrorCode WALLET_REFUND_AMOUNT_ERROR = new ErrorCode(1007007003, "钱包退款金额不对"); |
| 48 | ErrorCode WALLET_REFUND_EXIST = new ErrorCode(1007007004, "已经存在钱包退款"); | 48 | ErrorCode WALLET_REFUND_EXIST = new ErrorCode(1007007004, "已经存在钱包退款"); |
| 49 | + | ||
| 50 | + // TODO @jason:把钱包充值,单独搞个错误码段哈; | ||
| 51 | + | ||
| 49 | ErrorCode WALLET_RECHARGE_NOT_FOUND = new ErrorCode(1007007005, "钱包充值记录不存在"); | 52 | ErrorCode WALLET_RECHARGE_NOT_FOUND = new ErrorCode(1007007005, "钱包充值记录不存在"); |
| 50 | ErrorCode WALLET_RECHARGE_UPDATE_PAID_STATUS_NOT_UNPAID = new ErrorCode(1007007006, "钱包充值更新支付状态失败,钱包充值记录不是【未支付】状态"); | 53 | ErrorCode WALLET_RECHARGE_UPDATE_PAID_STATUS_NOT_UNPAID = new ErrorCode(1007007006, "钱包充值更新支付状态失败,钱包充值记录不是【未支付】状态"); |
| 51 | ErrorCode WALLET_RECHARGE_UPDATE_PAID_PAY_ORDER_ID_ERROR = new ErrorCode(1007007007, "钱包充值更新支付状态失败,支付单编号不匹配"); | 54 | ErrorCode WALLET_RECHARGE_UPDATE_PAID_PAY_ORDER_ID_ERROR = new ErrorCode(1007007007, "钱包充值更新支付状态失败,支付单编号不匹配"); |
yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/app/wallet/AppPayWalletRechargeController.java
| @@ -33,13 +33,14 @@ import static cn.iocoder.yudao.framework.web.core.util.WebFrameworkUtils.getLogi | @@ -33,13 +33,14 @@ import static cn.iocoder.yudao.framework.web.core.util.WebFrameworkUtils.getLogi | ||
| 33 | public class AppPayWalletRechargeController { | 33 | public class AppPayWalletRechargeController { |
| 34 | 34 | ||
| 35 | @Resource | 35 | @Resource |
| 36 | - private PayWalletRechargeService payWalletRechargeService; | 36 | + private PayWalletRechargeService walletRechargeService; |
| 37 | 37 | ||
| 38 | @PostMapping("/create") | 38 | @PostMapping("/create") |
| 39 | - @Operation(summary = "创建钱包充值记录") | ||
| 40 | - public CommonResult<AppPayWalletRechargeCreateRespVO> createWalletRecharge(@Valid @RequestBody AppPayWalletRechargeCreateReqVO reqVO) { | ||
| 41 | - PayWalletRechargeDO walletRecharge = payWalletRechargeService.createWalletRecharge(getLoginUserId(), | ||
| 42 | - getLoginUserType(), reqVO); | 39 | + @Operation(summary = "创建钱包充值记录(发起充值)") |
| 40 | + public CommonResult<AppPayWalletRechargeCreateRespVO> createWalletRecharge( | ||
| 41 | + @Valid @RequestBody AppPayWalletRechargeCreateReqVO reqVO) { | ||
| 42 | + PayWalletRechargeDO walletRecharge = walletRechargeService.createWalletRecharge( | ||
| 43 | + getLoginUserId(), getLoginUserType(), reqVO); | ||
| 43 | return success(PayWalletRechargeConvert.INSTANCE.convert(walletRecharge)); | 44 | return success(PayWalletRechargeConvert.INSTANCE.convert(walletRecharge)); |
| 44 | } | 45 | } |
| 45 | 46 | ||
| @@ -47,9 +48,12 @@ public class AppPayWalletRechargeController { | @@ -47,9 +48,12 @@ public class AppPayWalletRechargeController { | ||
| 47 | @Operation(summary = "更新钱包充值为已充值") // 由 pay-module 支付服务,进行回调,可见 PayNotifyJob | 48 | @Operation(summary = "更新钱包充值为已充值") // 由 pay-module 支付服务,进行回调,可见 PayNotifyJob |
| 48 | @PermitAll // 无需登录,安全由 内部校验实现 | 49 | @PermitAll // 无需登录,安全由 内部校验实现 |
| 49 | @OperateLog(enable = false) // 禁用操作日志,因为没有操作人 | 50 | @OperateLog(enable = false) // 禁用操作日志,因为没有操作人 |
| 50 | - public CommonResult<Boolean> updateWalletRechargerPaid(@RequestBody PayOrderNotifyReqDTO notifyReqDTO) { | ||
| 51 | - payWalletRechargeService.updateWalletRechargerPaid(Long.valueOf(notifyReqDTO.getMerchantOrderId()), | 51 | + public CommonResult<Boolean> updateWalletRechargerPaid(@Valid @RequestBody PayOrderNotifyReqDTO notifyReqDTO) { |
| 52 | + walletRechargeService.updateWalletRechargerPaid(Long.valueOf(notifyReqDTO.getMerchantOrderId()), | ||
| 52 | notifyReqDTO.getPayOrderId()); | 53 | notifyReqDTO.getPayOrderId()); |
| 53 | return success(true); | 54 | return success(true); |
| 54 | } | 55 | } |
| 56 | + | ||
| 57 | + // TODO @jason:管理后台,是不是可以搞个发起退款; | ||
| 58 | + | ||
| 55 | } | 59 | } |
yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/app/wallet/vo/recharge/AppPayWalletRechargeCreateReqVO.java
| @@ -12,11 +12,14 @@ public class AppPayWalletRechargeCreateReqVO { | @@ -12,11 +12,14 @@ public class AppPayWalletRechargeCreateReqVO { | ||
| 12 | 12 | ||
| 13 | @Schema(description = "支付金额", requiredMode = Schema.RequiredMode.REQUIRED, example = "1000") | 13 | @Schema(description = "支付金额", requiredMode = Schema.RequiredMode.REQUIRED, example = "1000") |
| 14 | @NotNull(message = "支付金额不能为空") | 14 | @NotNull(message = "支付金额不能为空") |
| 15 | + // TODO @jason999:是不是 @Min 哈? | ||
| 15 | @DecimalMin(value = "0", inclusive = false, message = "支付金额必须大于零") | 16 | @DecimalMin(value = "0", inclusive = false, message = "支付金额必须大于零") |
| 16 | private Integer payPrice; | 17 | private Integer payPrice; |
| 17 | 18 | ||
| 19 | + // TODO @jason:这个是不是后端计算出来呀?不然前端可以直接搞了。。。 | ||
| 18 | @Schema(description = "钱包赠送金额", requiredMode = Schema.RequiredMode.REQUIRED, example = "1000") | 20 | @Schema(description = "钱包赠送金额", requiredMode = Schema.RequiredMode.REQUIRED, example = "1000") |
| 19 | @NotNull(message = "钱包赠送金额不能为空") | 21 | @NotNull(message = "钱包赠送金额不能为空") |
| 20 | @DecimalMin(value = "0", message = "钱包赠送金额必须大于等于零") | 22 | @DecimalMin(value = "0", message = "钱包赠送金额必须大于等于零") |
| 21 | private Integer walletBonus; | 23 | private Integer walletBonus; |
| 24 | + | ||
| 22 | } | 25 | } |
yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/controller/app/wallet/vo/recharge/AppPayWalletRechargeCreateRespVO.java
| @@ -12,4 +12,5 @@ public class AppPayWalletRechargeCreateRespVO { | @@ -12,4 +12,5 @@ public class AppPayWalletRechargeCreateRespVO { | ||
| 12 | 12 | ||
| 13 | @Schema(description = "支付订单编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "100") | 13 | @Schema(description = "支付订单编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "100") |
| 14 | private Long payOrderId; | 14 | private Long payOrderId; |
| 15 | + | ||
| 15 | } | 16 | } |
yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/convert/wallet/PayWalletRechargeConvert.java
| @@ -16,6 +16,7 @@ public interface PayWalletRechargeConvert { | @@ -16,6 +16,7 @@ public interface PayWalletRechargeConvert { | ||
| 16 | 16 | ||
| 17 | PayWalletRechargeDO convert(AppPayWalletRechargeCreateReqVO vo); | 17 | PayWalletRechargeDO convert(AppPayWalletRechargeCreateReqVO vo); |
| 18 | 18 | ||
| 19 | + // TODO @jason:好像 price 相加,可以写个表达式的,通过 @Mapping | ||
| 19 | default PayWalletRechargeDO convert(Long walletId, AppPayWalletRechargeCreateReqVO vo) { | 20 | default PayWalletRechargeDO convert(Long walletId, AppPayWalletRechargeCreateReqVO vo) { |
| 20 | PayWalletRechargeDO walletRecharge = convert(vo); | 21 | PayWalletRechargeDO walletRecharge = convert(vo); |
| 21 | return walletRecharge.setWalletId(walletId) | 22 | return walletRecharge.setWalletId(walletId) |
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,7 +3,7 @@ package cn.iocoder.yudao.module.pay.convert.wallet; | ||
| 3 | import cn.iocoder.yudao.framework.common.pojo.PageResult; | 3 | import cn.iocoder.yudao.framework.common.pojo.PageResult; |
| 4 | import cn.iocoder.yudao.module.pay.controller.app.wallet.vo.transaction.AppPayWalletTransactionRespVO; | 4 | import cn.iocoder.yudao.module.pay.controller.app.wallet.vo.transaction.AppPayWalletTransactionRespVO; |
| 5 | import cn.iocoder.yudao.module.pay.dal.dataobject.wallet.PayWalletTransactionDO; | 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 | import org.mapstruct.Mapper; | 7 | import org.mapstruct.Mapper; |
| 8 | import org.mapstruct.factory.Mappers; | 8 | import org.mapstruct.factory.Mappers; |
| 9 | 9 | ||
| @@ -14,6 +14,6 @@ public interface PayWalletTransactionConvert { | @@ -14,6 +14,6 @@ public interface PayWalletTransactionConvert { | ||
| 14 | 14 | ||
| 15 | PageResult<AppPayWalletTransactionRespVO> convertPage(PageResult<PayWalletTransactionDO> page); | 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
| 1 | package cn.iocoder.yudao.module.pay.dal.dataobject.wallet; | 1 | package cn.iocoder.yudao.module.pay.dal.dataobject.wallet; |
| 2 | 2 | ||
| 3 | import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; | 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; | ||
| 4 | import com.baomidou.mybatisplus.annotation.KeySequence; | 6 | import com.baomidou.mybatisplus.annotation.KeySequence; |
| 5 | import com.baomidou.mybatisplus.annotation.TableId; | 7 | import com.baomidou.mybatisplus.annotation.TableId; |
| 6 | import com.baomidou.mybatisplus.annotation.TableName; | 8 | import com.baomidou.mybatisplus.annotation.TableName; |
| @@ -23,40 +25,49 @@ public class PayWalletRechargeDO extends BaseDO { | @@ -23,40 +25,49 @@ public class PayWalletRechargeDO extends BaseDO { | ||
| 23 | private Long id; | 25 | private Long id; |
| 24 | 26 | ||
| 25 | /** | 27 | /** |
| 26 | - * 会员钱包 id | 28 | + * 钱包编号 |
| 29 | + * | ||
| 30 | + * 关联 {@link PayWalletDO#getId()} | ||
| 27 | */ | 31 | */ |
| 28 | private Long walletId; | 32 | private Long walletId; |
| 29 | 33 | ||
| 34 | + // TODO @jason:要不改成 totalPrice? | ||
| 30 | /** | 35 | /** |
| 31 | - * 用户实际到账余额,例如充 100 送 20,则该值是 120 | 36 | + * 用户实际到账余额 |
| 37 | + * | ||
| 38 | + * 例如充 100 送 20,则该值是 120 | ||
| 32 | */ | 39 | */ |
| 33 | private Integer price; | 40 | private Integer price; |
| 34 | - | ||
| 35 | /** | 41 | /** |
| 36 | * 实际支付金额 | 42 | * 实际支付金额 |
| 37 | */ | 43 | */ |
| 38 | private Integer payPrice; | 44 | private Integer payPrice; |
| 39 | - | 45 | + // TODO @jason:bonusPrice 哈,更统一一点; |
| 40 | /** | 46 | /** |
| 41 | * 钱包赠送金额 | 47 | * 钱包赠送金额 |
| 42 | */ | 48 | */ |
| 43 | private Integer walletBonus; | 49 | private Integer walletBonus; |
| 44 | 50 | ||
| 45 | /** | 51 | /** |
| 46 | - * 是否已支付:[0:未支付 1:已经支付过] | 52 | + * 是否已支付 |
| 53 | + * | ||
| 54 | + * true - 已支付 | ||
| 55 | + * false - 未支付 | ||
| 47 | */ | 56 | */ |
| 48 | private Boolean payStatus; | 57 | private Boolean payStatus; |
| 49 | 58 | ||
| 50 | /** | 59 | /** |
| 51 | * 支付订单编号 | 60 | * 支付订单编号 |
| 61 | + * | ||
| 62 | + * 关联 {@link PayOrderDO#getId()} | ||
| 52 | */ | 63 | */ |
| 53 | private Long payOrderId; | 64 | private Long payOrderId; |
| 54 | - | ||
| 55 | /** | 65 | /** |
| 56 | * 支付成功的支付渠道 | 66 | * 支付成功的支付渠道 |
| 67 | + * | ||
| 68 | + * 冗余 {@link PayOrderDO#getChannelCode()} | ||
| 57 | */ | 69 | */ |
| 58 | private String payChannelCode; | 70 | private String payChannelCode; |
| 59 | - | ||
| 60 | /** | 71 | /** |
| 61 | * 订单支付时间 | 72 | * 订单支付时间 |
| 62 | */ | 73 | */ |
| @@ -64,26 +75,27 @@ public class PayWalletRechargeDO extends BaseDO { | @@ -64,26 +75,27 @@ public class PayWalletRechargeDO extends BaseDO { | ||
| 64 | 75 | ||
| 65 | /** | 76 | /** |
| 66 | * 支付退款单编号 | 77 | * 支付退款单编号 |
| 78 | + * | ||
| 79 | + * 关联 {@link PayRefundDO#getId()} | ||
| 67 | */ | 80 | */ |
| 68 | private Long payRefundId; | 81 | private Long payRefundId; |
| 69 | - | 82 | + // TODO @jason:要不改成 refundTotalPrice? |
| 70 | /** | 83 | /** |
| 71 | * 退款金额,包含赠送金额 | 84 | * 退款金额,包含赠送金额 |
| 72 | */ | 85 | */ |
| 73 | private Integer refundPrice; | 86 | private Integer refundPrice; |
| 74 | - | ||
| 75 | /** | 87 | /** |
| 76 | * 退款支付金额 | 88 | * 退款支付金额 |
| 77 | */ | 89 | */ |
| 78 | private Integer refundPayPrice; | 90 | private Integer refundPayPrice; |
| 79 | - | 91 | + // TODO @jason:要不改成 refundBonusPrice? |
| 80 | /** | 92 | /** |
| 81 | * 退款钱包赠送金额 | 93 | * 退款钱包赠送金额 |
| 82 | */ | 94 | */ |
| 83 | private Integer refundWalletBonus; | 95 | private Integer refundWalletBonus; |
| 84 | - | ||
| 85 | /** | 96 | /** |
| 86 | * 退款时间 | 97 | * 退款时间 |
| 87 | */ | 98 | */ |
| 88 | private LocalDateTime refundTime; | 99 | private LocalDateTime refundTime; |
| 89 | -} | ||
| 90 | \ No newline at end of file | 100 | \ No newline at end of file |
| 101 | + | ||
| 102 | +} |
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,6 +14,8 @@ public interface PayWalletMapper extends BaseMapperX<PayWalletDO> { | ||
| 14 | PayWalletDO::getUserType, userType); | 14 | PayWalletDO::getUserType, userType); |
| 15 | } | 15 | } |
| 16 | 16 | ||
| 17 | + // TODO @jason:下面几个更新方法,把 id 放前面哈。一般来说,重要参数放前面; | ||
| 18 | + | ||
| 17 | /** | 19 | /** |
| 18 | * 当消费退款时候, 更新钱包 | 20 | * 当消费退款时候, 更新钱包 |
| 19 | * | 21 | * |
| @@ -55,6 +57,7 @@ public interface PayWalletMapper extends BaseMapperX<PayWalletDO> { | @@ -55,6 +57,7 @@ public interface PayWalletMapper extends BaseMapperX<PayWalletDO> { | ||
| 55 | .eq(PayWalletDO::getId, id); | 57 | .eq(PayWalletDO::getId, id); |
| 56 | return update(null, lambdaUpdateWrapper); | 58 | return update(null, lambdaUpdateWrapper); |
| 57 | } | 59 | } |
| 60 | + | ||
| 58 | } | 61 | } |
| 59 | 62 | ||
| 60 | 63 |
yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/dal/mysql/wallet/PayWalletRechargeMapper.java
| @@ -2,17 +2,17 @@ package cn.iocoder.yudao.module.pay.dal.mysql.wallet; | @@ -2,17 +2,17 @@ package cn.iocoder.yudao.module.pay.dal.mysql.wallet; | ||
| 2 | 2 | ||
| 3 | import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; | 3 | import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; |
| 4 | import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; | 4 | import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; |
| 5 | -import cn.iocoder.yudao.module.pay.dal.dataobject.demo.PayDemoOrderDO; | ||
| 6 | import cn.iocoder.yudao.module.pay.dal.dataobject.wallet.PayWalletRechargeDO; | 5 | import cn.iocoder.yudao.module.pay.dal.dataobject.wallet.PayWalletRechargeDO; |
| 7 | import org.apache.ibatis.annotations.Mapper; | 6 | import org.apache.ibatis.annotations.Mapper; |
| 8 | 7 | ||
| 9 | @Mapper | 8 | @Mapper |
| 10 | public interface PayWalletRechargeMapper extends BaseMapperX<PayWalletRechargeDO> { | 9 | public interface PayWalletRechargeMapper extends BaseMapperX<PayWalletRechargeDO> { |
| 11 | 10 | ||
| 12 | - default int updateByIdAndPaid(Long id, boolean wherePayed, PayWalletRechargeDO updateObj){ | 11 | + default int updateByIdAndPaid(Long id, boolean wherePayStatus, PayWalletRechargeDO updateObj){ |
| 13 | return update(updateObj, new LambdaQueryWrapperX<PayWalletRechargeDO>() | 12 | return update(updateObj, new LambdaQueryWrapperX<PayWalletRechargeDO>() |
| 14 | - .eq(PayWalletRechargeDO::getId, id).eq(PayWalletRechargeDO::getPayStatus, wherePayed)); | 13 | + .eq(PayWalletRechargeDO::getId, id).eq(PayWalletRechargeDO::getPayStatus, wherePayStatus)); |
| 15 | } | 14 | } |
| 15 | + | ||
| 16 | } | 16 | } |
| 17 | 17 | ||
| 18 | 18 |
yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/service/wallet/PayWalletRechargeService.java
| @@ -11,19 +11,22 @@ import cn.iocoder.yudao.module.pay.dal.dataobject.wallet.PayWalletRechargeDO; | @@ -11,19 +11,22 @@ import cn.iocoder.yudao.module.pay.dal.dataobject.wallet.PayWalletRechargeDO; | ||
| 11 | public interface PayWalletRechargeService { | 11 | public interface PayWalletRechargeService { |
| 12 | 12 | ||
| 13 | /** | 13 | /** |
| 14 | - * 创建钱包充值记录 | 14 | + * 创建钱包充值记录(发起充值) |
| 15 | + * | ||
| 15 | * @param userId 用户 id | 16 | * @param userId 用户 id |
| 16 | * @param userType 用户类型 | 17 | * @param userType 用户类型 |
| 17 | - * @param vo 钱包充值请求 vo | 18 | + * @param createReqVO 钱包充值请求 VO |
| 18 | * @return 钱包充值记录 | 19 | * @return 钱包充值记录 |
| 19 | */ | 20 | */ |
| 20 | - PayWalletRechargeDO createWalletRecharge(Long userId, Integer userType, AppPayWalletRechargeCreateReqVO vo); | ||
| 21 | - | 21 | + PayWalletRechargeDO createWalletRecharge(Long userId, Integer userType, |
| 22 | + AppPayWalletRechargeCreateReqVO createReqVO); | ||
| 22 | 23 | ||
| 23 | /** | 24 | /** |
| 24 | * 更新钱包充值成功 | 25 | * 更新钱包充值成功 |
| 25 | - * @param walletRechargeId 钱包充值 id | 26 | + * |
| 27 | + * @param id 钱包充值记录 id | ||
| 26 | * @param payOrderId 支付订单 id | 28 | * @param payOrderId 支付订单 id |
| 27 | */ | 29 | */ |
| 28 | - void updateWalletRechargerPaid(Long walletRechargeId, Long payOrderId); | 30 | + void updateWalletRechargerPaid(Long id, Long payOrderId); |
| 31 | + | ||
| 29 | } | 32 | } |
yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/service/wallet/PayWalletRechargeServiceImpl.java
| @@ -42,57 +42,61 @@ public class PayWalletRechargeServiceImpl implements PayWalletRechargeService { | @@ -42,57 +42,61 @@ public class PayWalletRechargeServiceImpl implements PayWalletRechargeService { | ||
| 42 | 42 | ||
| 43 | @Resource | 43 | @Resource |
| 44 | private PayWalletRechargeMapper walletRechargeMapper; | 44 | private PayWalletRechargeMapper walletRechargeMapper; |
| 45 | + | ||
| 45 | @Resource | 46 | @Resource |
| 46 | private PayWalletService payWalletService; | 47 | private PayWalletService payWalletService; |
| 47 | @Resource | 48 | @Resource |
| 48 | private PayOrderService payOrderService; | 49 | private PayOrderService payOrderService; |
| 49 | 50 | ||
| 50 | - | ||
| 51 | @Override | 51 | @Override |
| 52 | @Transactional(rollbackFor = Exception.class) | 52 | @Transactional(rollbackFor = Exception.class) |
| 53 | - public PayWalletRechargeDO createWalletRecharge(Long userId, Integer userType, AppPayWalletRechargeCreateReqVO vo) { | ||
| 54 | - // 1. 获取钱包 | 53 | + public PayWalletRechargeDO createWalletRecharge(Long userId, Integer userType, |
| 54 | + AppPayWalletRechargeCreateReqVO createReqVO) { | ||
| 55 | + // 1. 新增钱包充值记录 | ||
| 55 | PayWalletDO wallet = payWalletService.getOrCreateWallet(userId, userType); | 56 | PayWalletDO wallet = payWalletService.getOrCreateWallet(userId, userType); |
| 56 | - // 2. 新增钱包充值记录 | ||
| 57 | - PayWalletRechargeDO walletRecharge = PayWalletRechargeConvert.INSTANCE.convert(wallet.getId(), vo); | 57 | + PayWalletRechargeDO walletRecharge = PayWalletRechargeConvert.INSTANCE.convert(wallet.getId(), createReqVO); |
| 58 | walletRechargeMapper.insert(walletRecharge); | 58 | walletRechargeMapper.insert(walletRecharge); |
| 59 | - // 3.创建支付单 | 59 | + |
| 60 | + // 2.1 创建支付单 | ||
| 60 | Long payOrderId = payOrderService.createOrder(new PayOrderCreateReqDTO() | 61 | Long payOrderId = payOrderService.createOrder(new PayOrderCreateReqDTO() |
| 61 | .setAppId(WALLET_PAY_APP_ID).setUserIp(getClientIP()) | 62 | .setAppId(WALLET_PAY_APP_ID).setUserIp(getClientIP()) |
| 62 | .setMerchantOrderId(walletRecharge.getId().toString()) // 业务的订单编号 | 63 | .setMerchantOrderId(walletRecharge.getId().toString()) // 业务的订单编号 |
| 63 | .setSubject(WALLET_RECHARGE_ORDER_SUBJECT).setBody("").setPrice(walletRecharge.getPayPrice()) | 64 | .setSubject(WALLET_RECHARGE_ORDER_SUBJECT).setBody("").setPrice(walletRecharge.getPayPrice()) |
| 64 | .setExpireTime(addTime(Duration.ofHours(2L)))); | 65 | .setExpireTime(addTime(Duration.ofHours(2L)))); |
| 65 | - // 4.更新钱包充值记录中支付订单 | 66 | + // 2.2 更新钱包充值记录中支付订单 |
| 66 | walletRechargeMapper.updateById(new PayWalletRechargeDO().setPayOrderId(payOrderId) | 67 | walletRechargeMapper.updateById(new PayWalletRechargeDO().setPayOrderId(payOrderId) |
| 67 | .setId(walletRecharge.getId())); | 68 | .setId(walletRecharge.getId())); |
| 69 | + // TODO @jason:是不是你直接返回就好啦;然后 payOrderId 设置下; | ||
| 68 | return walletRechargeMapper.selectById(walletRecharge.getId()); | 70 | return walletRechargeMapper.selectById(walletRecharge.getId()); |
| 69 | } | 71 | } |
| 70 | 72 | ||
| 71 | @Override | 73 | @Override |
| 72 | @Transactional(rollbackFor = Exception.class) | 74 | @Transactional(rollbackFor = Exception.class) |
| 73 | - public void updateWalletRechargerPaid(Long walletRechargeId, Long payOrderId) { | ||
| 74 | - // 1. 获取钱包充值记录 | ||
| 75 | - PayWalletRechargeDO walletRecharge = walletRechargeMapper.selectById(walletRechargeId); | 75 | + public void updateWalletRechargerPaid(Long id, Long payOrderId) { |
| 76 | + // 1.1 获取钱包充值记录 | ||
| 77 | + PayWalletRechargeDO walletRecharge = walletRechargeMapper.selectById(id); | ||
| 76 | if (walletRecharge == null) { | 78 | if (walletRecharge == null) { |
| 77 | - log.error("[updateWalletRechargerPaid],钱包充值记录不存在,钱包充值 Id:{} ", walletRechargeId); | 79 | + log.error("[updateWalletRechargerPaid][钱包充值记录不存在,钱包充值记录 id({})]", id); |
| 78 | throw exception(WALLET_RECHARGE_NOT_FOUND); | 80 | throw exception(WALLET_RECHARGE_NOT_FOUND); |
| 79 | } | 81 | } |
| 80 | - // 2. 校验钱包充值是否可以支付 | 82 | + // 1.2 校验钱包充值是否可以支付 |
| 81 | PayOrderDO payOrderDO = validateWalletRechargerCanPaid(walletRecharge, payOrderId); | 83 | PayOrderDO payOrderDO = validateWalletRechargerCanPaid(walletRecharge, payOrderId); |
| 82 | - // 3. 更新钱包充值的支付状态 | ||
| 83 | - int updateCount = walletRechargeMapper.updateByIdAndPaid(walletRechargeId,false, new PayWalletRechargeDO().setId(walletRechargeId) | ||
| 84 | - .setPayStatus(true).setPayTime(LocalDateTime.now()) | 84 | + |
| 85 | + // 2. 更新钱包充值的支付状态 | ||
| 86 | + int updateCount = walletRechargeMapper.updateByIdAndPaid(id,false, | ||
| 87 | + new PayWalletRechargeDO().setId(id).setPayStatus(true).setPayTime(LocalDateTime.now()) | ||
| 85 | .setPayChannelCode(payOrderDO.getChannelCode())); | 88 | .setPayChannelCode(payOrderDO.getChannelCode())); |
| 86 | if (updateCount == 0) { | 89 | if (updateCount == 0) { |
| 87 | throw exception(WALLET_RECHARGE_UPDATE_PAID_STATUS_NOT_UNPAID); | 90 | throw exception(WALLET_RECHARGE_UPDATE_PAID_STATUS_NOT_UNPAID); |
| 88 | } | 91 | } |
| 89 | - // 4. 更新钱包余额 | ||
| 90 | - payWalletService.addWalletBalance(walletRecharge.getWalletId(), String.valueOf(walletRechargeId), | 92 | + |
| 93 | + // 3. 更新钱包余额 | ||
| 94 | + // TODO @jason:这样的话,未来提现会不会把充值的,也提现走哈。类似先充 100,送 110;然后提现 110; | ||
| 95 | + payWalletService.addWalletBalance(walletRecharge.getWalletId(), String.valueOf(id), | ||
| 91 | PayWalletBizTypeEnum.RECHARGE, walletRecharge.getPrice()); | 96 | PayWalletBizTypeEnum.RECHARGE, walletRecharge.getPrice()); |
| 92 | } | 97 | } |
| 93 | 98 | ||
| 94 | private PayOrderDO validateWalletRechargerCanPaid(PayWalletRechargeDO walletRecharge, Long payOrderId) { | 99 | private PayOrderDO validateWalletRechargerCanPaid(PayWalletRechargeDO walletRecharge, Long payOrderId) { |
| 95 | - | ||
| 96 | // 1.1 校验充值记录的支付状态 | 100 | // 1.1 校验充值记录的支付状态 |
| 97 | if (walletRecharge.getPayStatus()) { | 101 | if (walletRecharge.getPayStatus()) { |
| 98 | log.error("[validateWalletRechargerCanPaid][钱包({}) 不处于未支付状态! 钱包数据是:{}]", | 102 | log.error("[validateWalletRechargerCanPaid][钱包({}) 不处于未支付状态! 钱包数据是:{}]", |
| @@ -105,6 +109,7 @@ public class PayWalletRechargeServiceImpl implements PayWalletRechargeService { | @@ -105,6 +109,7 @@ public class PayWalletRechargeServiceImpl implements PayWalletRechargeService { | ||
| 105 | walletRecharge.getId(), payOrderId, toJsonString(walletRecharge)); | 109 | walletRecharge.getId(), payOrderId, toJsonString(walletRecharge)); |
| 106 | throw exception(WALLET_RECHARGE_UPDATE_PAID_PAY_ORDER_ID_ERROR); | 110 | throw exception(WALLET_RECHARGE_UPDATE_PAID_PAY_ORDER_ID_ERROR); |
| 107 | } | 111 | } |
| 112 | + | ||
| 108 | // 2.1 校验支付单是否存在 | 113 | // 2.1 校验支付单是否存在 |
| 109 | PayOrderDO payOrder = payOrderService.getOrder(payOrderId); | 114 | PayOrderDO payOrder = payOrderService.getOrder(payOrderId); |
| 110 | if (payOrder == null) { | 115 | if (payOrder == null) { |
| @@ -132,4 +137,5 @@ public class PayWalletRechargeServiceImpl implements PayWalletRechargeService { | @@ -132,4 +137,5 @@ public class PayWalletRechargeServiceImpl implements PayWalletRechargeService { | ||
| 132 | } | 137 | } |
| 133 | return payOrder; | 138 | return payOrder; |
| 134 | } | 139 | } |
| 140 | + | ||
| 135 | } | 141 | } |
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,7 +9,7 @@ import cn.iocoder.yudao.module.pay.dal.mysql.wallet.PayWalletMapper; | ||
| 9 | import cn.iocoder.yudao.module.pay.enums.member.PayWalletBizTypeEnum; | 9 | import cn.iocoder.yudao.module.pay.enums.member.PayWalletBizTypeEnum; |
| 10 | import cn.iocoder.yudao.module.pay.service.order.PayOrderService; | 10 | import cn.iocoder.yudao.module.pay.service.order.PayOrderService; |
| 11 | import cn.iocoder.yudao.module.pay.service.refund.PayRefundService; | 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 | import lombok.extern.slf4j.Slf4j; | 13 | import lombok.extern.slf4j.Slf4j; |
| 14 | import org.springframework.context.annotation.Lazy; | 14 | import org.springframework.context.annotation.Lazy; |
| 15 | import org.springframework.stereotype.Service; | 15 | import org.springframework.stereotype.Service; |
| @@ -84,6 +84,7 @@ public class PayWalletServiceImpl implements PayWalletService { | @@ -84,6 +84,7 @@ public class PayWalletServiceImpl implements PayWalletService { | ||
| 84 | Long walletId = validateWalletCanRefund(payRefund.getId(), payRefund.getChannelOrderNo(), refundPrice); | 84 | Long walletId = validateWalletCanRefund(payRefund.getId(), payRefund.getChannelOrderNo(), refundPrice); |
| 85 | PayWalletDO wallet = walletMapper.selectById(walletId); | 85 | PayWalletDO wallet = walletMapper.selectById(walletId); |
| 86 | Assert.notNull(wallet, "钱包 {} 不存在", walletId); | 86 | Assert.notNull(wallet, "钱包 {} 不存在", walletId); |
| 87 | + | ||
| 87 | // 2. 增加余额 | 88 | // 2. 增加余额 |
| 88 | return addWalletBalance(walletId, String.valueOf(payRefund.getId()), PAYMENT_REFUND, refundPrice); | 89 | return addWalletBalance(walletId, String.valueOf(payRefund.getId()), PAYMENT_REFUND, refundPrice); |
| 89 | } | 90 | } |
| @@ -137,42 +138,39 @@ public class PayWalletServiceImpl implements PayWalletService { | @@ -137,42 +138,39 @@ public class PayWalletServiceImpl implements PayWalletService { | ||
| 137 | } | 138 | } |
| 138 | // 2.2 生成钱包流水 | 139 | // 2.2 生成钱包流水 |
| 139 | Integer afterBalance = payWallet.getBalance() - price; | 140 | Integer afterBalance = payWallet.getBalance() - price; |
| 140 | - CreateWalletTransactionBO bo = new CreateWalletTransactionBO().setWalletId(payWallet.getId()) | 141 | + WalletTransactionCreateReqBO bo = new WalletTransactionCreateReqBO().setWalletId(payWallet.getId()) |
| 141 | .setPrice(-price).setBalance(afterBalance).setBizId(String.valueOf(bizId)) | 142 | .setPrice(-price).setBalance(afterBalance).setBizId(String.valueOf(bizId)) |
| 142 | .setBizType(bizType.getType()).setTitle(bizType.getDescription()); | 143 | .setBizType(bizType.getType()).setTitle(bizType.getDescription()); |
| 143 | return walletTransactionService.createWalletTransaction(bo); | 144 | return walletTransactionService.createWalletTransaction(bo); |
| 144 | } | 145 | } |
| 145 | 146 | ||
| 146 | @Override | 147 | @Override |
| 147 | - public PayWalletTransactionDO addWalletBalance(Long walletId, | ||
| 148 | - String bizId, PayWalletBizTypeEnum bizType, Integer price) { | ||
| 149 | - // 1. 获取钱包 | 148 | + public PayWalletTransactionDO addWalletBalance(Long walletId, String bizId, |
| 149 | + PayWalletBizTypeEnum bizType, Integer price) { | ||
| 150 | + // 1.1 获取钱包 | ||
| 150 | PayWalletDO payWallet = getWallet(walletId); | 151 | PayWalletDO payWallet = getWallet(walletId); |
| 151 | - | ||
| 152 | if (payWallet == null) { | 152 | if (payWallet == null) { |
| 153 | log.error("[addWalletBalance],用户钱包({})不存在.", walletId); | 153 | log.error("[addWalletBalance],用户钱包({})不存在.", walletId); |
| 154 | throw exception(WALLET_NOT_FOUND); | 154 | throw exception(WALLET_NOT_FOUND); |
| 155 | } | 155 | } |
| 156 | - | 156 | + // 1.2 更新钱包金额 |
| 157 | switch (bizType) { | 157 | switch (bizType) { |
| 158 | - case PAYMENT_REFUND: { | ||
| 159 | - // 退款更新 | 158 | + case PAYMENT_REFUND: { // 退款更新 |
| 160 | walletMapper.updateWhenConsumptionRefund(price, payWallet.getId()); | 159 | walletMapper.updateWhenConsumptionRefund(price, payWallet.getId()); |
| 161 | break; | 160 | break; |
| 162 | } | 161 | } |
| 163 | - case RECHARGE: { | ||
| 164 | - // 充值更新 | 162 | + case RECHARGE: { // 充值更新 |
| 165 | walletMapper.updateWhenRecharge(price, payWallet.getId()); | 163 | walletMapper.updateWhenRecharge(price, payWallet.getId()); |
| 166 | break; | 164 | break; |
| 167 | } | 165 | } |
| 168 | - // TODO 其它类型 | 166 | + // TODO 其它类型;这里可以先跑异常;避免有业务搞错; |
| 169 | } | 167 | } |
| 170 | 168 | ||
| 171 | // 2. 生成钱包流水 | 169 | // 2. 生成钱包流水 |
| 172 | - CreateWalletTransactionBO bo = new CreateWalletTransactionBO().setWalletId(payWallet.getId()) | ||
| 173 | - .setPrice(price).setBalance(payWallet.getBalance()+price).setBizId(bizId) | ||
| 174 | - .setBizType(bizType.getType()).setTitle(bizType.getDescription()); | ||
| 175 | - 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); | ||
| 176 | } | 174 | } |
| 177 | 175 | ||
| 178 | } | 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,7 +4,7 @@ import cn.iocoder.yudao.framework.common.pojo.PageResult; | ||
| 4 | import cn.iocoder.yudao.module.pay.controller.app.wallet.vo.transaction.AppPayWalletTransactionPageReqVO; | 4 | import cn.iocoder.yudao.module.pay.controller.app.wallet.vo.transaction.AppPayWalletTransactionPageReqVO; |
| 5 | import cn.iocoder.yudao.module.pay.dal.dataobject.wallet.PayWalletTransactionDO; | 5 | import cn.iocoder.yudao.module.pay.dal.dataobject.wallet.PayWalletTransactionDO; |
| 6 | import cn.iocoder.yudao.module.pay.enums.member.PayWalletBizTypeEnum; | 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 | import javax.validation.Valid; | 9 | import javax.validation.Valid; |
| 10 | 10 | ||
| @@ -31,7 +31,7 @@ public interface PayWalletTransactionService { | @@ -31,7 +31,7 @@ public interface PayWalletTransactionService { | ||
| 31 | * @param bo 创建钱包流水 bo | 31 | * @param bo 创建钱包流水 bo |
| 32 | * @return 新建的钱包 do | 32 | * @return 新建的钱包 do |
| 33 | */ | 33 | */ |
| 34 | - PayWalletTransactionDO createWalletTransaction(@Valid CreateWalletTransactionBO bo); | 34 | + PayWalletTransactionDO createWalletTransaction(@Valid WalletTransactionCreateReqBO bo); |
| 35 | 35 | ||
| 36 | /** | 36 | /** |
| 37 | * 根据 no,获取钱包余流水 | 37 | * 根据 no,获取钱包余流水 |
| @@ -48,5 +48,5 @@ public interface PayWalletTransactionService { | @@ -48,5 +48,5 @@ public interface PayWalletTransactionService { | ||
| 48 | * @return 钱包流水 | 48 | * @return 钱包流水 |
| 49 | */ | 49 | */ |
| 50 | PayWalletTransactionDO getWalletTransaction(String bizId, PayWalletBizTypeEnum type); | 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,7 +8,7 @@ import cn.iocoder.yudao.module.pay.dal.dataobject.wallet.PayWalletTransactionDO; | ||
| 8 | import cn.iocoder.yudao.module.pay.dal.mysql.wallet.PayWalletTransactionMapper; | 8 | import cn.iocoder.yudao.module.pay.dal.mysql.wallet.PayWalletTransactionMapper; |
| 9 | import cn.iocoder.yudao.module.pay.dal.redis.no.PayNoRedisDAO; | 9 | import cn.iocoder.yudao.module.pay.dal.redis.no.PayNoRedisDAO; |
| 10 | import cn.iocoder.yudao.module.pay.enums.member.PayWalletBizTypeEnum; | 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 | import lombok.extern.slf4j.Slf4j; | 12 | import lombok.extern.slf4j.Slf4j; |
| 13 | import org.springframework.stereotype.Service; | 13 | import org.springframework.stereotype.Service; |
| 14 | 14 | ||
| @@ -43,7 +43,7 @@ public class PayWalletTransactionServiceImpl implements PayWalletTransactionServ | @@ -43,7 +43,7 @@ public class PayWalletTransactionServiceImpl implements PayWalletTransactionServ | ||
| 43 | } | 43 | } |
| 44 | 44 | ||
| 45 | @Override | 45 | @Override |
| 46 | - public PayWalletTransactionDO createWalletTransaction(CreateWalletTransactionBO bo) { | 46 | + public PayWalletTransactionDO createWalletTransaction(WalletTransactionCreateReqBO bo) { |
| 47 | PayWalletTransactionDO transaction = PayWalletTransactionConvert.INSTANCE.convert(bo) | 47 | PayWalletTransactionDO transaction = PayWalletTransactionConvert.INSTANCE.convert(bo) |
| 48 | .setNo(noRedisDAO.generate(WALLET_NO_PREFIX)); | 48 | .setNo(noRedisDAO.generate(WALLET_NO_PREFIX)); |
| 49 | payWalletTransactionMapper.insert(transaction); | 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
| @@ -9,7 +9,7 @@ import lombok.Data; | @@ -9,7 +9,7 @@ import lombok.Data; | ||
| 9 | * @author jason | 9 | * @author jason |
| 10 | */ | 10 | */ |
| 11 | @Data | 11 | @Data |
| 12 | -public class CreateWalletTransactionBO { | 12 | +public class WalletTransactionCreateReqBO { |
| 13 | 13 | ||
| 14 | // TODO @jason:bo 的话,最好加个参数校验哈; | 14 | // TODO @jason:bo 的话,最好加个参数校验哈; |
| 15 | 15 |
yudao-server/src/main/resources/application-local.yaml
| @@ -44,31 +44,31 @@ spring: | @@ -44,31 +44,31 @@ spring: | ||
| 44 | primary: master | 44 | primary: master |
| 45 | datasource: | 45 | datasource: |
| 46 | master: | 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 | # 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 连接的示例 | 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 | # url: jdbc:postgresql://127.0.0.1:5432/${spring.datasource.dynamic.datasource.master.name} # PostgreSQL 连接的示例 | 50 | # url: jdbc:postgresql://127.0.0.1:5432/${spring.datasource.dynamic.datasource.master.name} # PostgreSQL 连接的示例 |
| 51 | # url: jdbc:oracle:thin:@127.0.0.1:1521:xe # Oracle 连接的示例 | 51 | # url: jdbc:oracle:thin:@127.0.0.1:1521:xe # Oracle 连接的示例 |
| 52 | # url: jdbc:sqlserver://127.0.0.1:1433;DatabaseName=${spring.datasource.dynamic.datasource.master.name} # SQLServer 连接的示例 | 52 | # url: jdbc:sqlserver://127.0.0.1:1433;DatabaseName=${spring.datasource.dynamic.datasource.master.name} # SQLServer 连接的示例 |
| 53 | username: root | 53 | username: root |
| 54 | - password: 123456 | 54 | + password: 1qaz!QAZ |
| 55 | # username: sa | 55 | # username: sa |
| 56 | # password: JSm:g(*%lU4ZAkz06cd52KqT3)i1?H7W | 56 | # password: JSm:g(*%lU4ZAkz06cd52KqT3)i1?H7W |
| 57 | slave: # 模拟从库,可根据自己需要修改 | 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 | # 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 连接的示例 | 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 | # url: jdbc:postgresql://127.0.0.1:5432/${spring.datasource.dynamic.datasource.slave.name} # PostgreSQL 连接的示例 | 61 | # url: jdbc:postgresql://127.0.0.1:5432/${spring.datasource.dynamic.datasource.slave.name} # PostgreSQL 连接的示例 |
| 62 | # url: jdbc:oracle:thin:@127.0.0.1:1521:xe # Oracle 连接的示例 | 62 | # url: jdbc:oracle:thin:@127.0.0.1:1521:xe # Oracle 连接的示例 |
| 63 | # url: jdbc:sqlserver://127.0.0.1:1433;DatabaseName=${spring.datasource.dynamic.datasource.slave.name} # SQLServer 连接的示例 | 63 | # url: jdbc:sqlserver://127.0.0.1:1433;DatabaseName=${spring.datasource.dynamic.datasource.slave.name} # SQLServer 连接的示例 |
| 64 | username: root | 64 | username: root |
| 65 | - password: 123456 | 65 | + password: 1qaz!QAZ |
| 66 | # username: sa | 66 | # username: sa |
| 67 | # password: JSm:g(*%lU4ZAkz06cd52KqT3)i1?H7W | 67 | # password: JSm:g(*%lU4ZAkz06cd52KqT3)i1?H7W |
| 68 | 68 | ||
| 69 | # Redis 配置。Redisson 默认的配置足够使用,一般不需要进行调优 | 69 | # Redis 配置。Redisson 默认的配置足够使用,一般不需要进行调优 |
| 70 | redis: | 70 | redis: |
| 71 | - host: 127.0.0.1 # 地址 | 71 | + host: 10.211.55.5 # 地址 |
| 72 | port: 6379 # 端口 | 72 | port: 6379 # 端口 |
| 73 | database: 0 # 数据库索引 | 73 | database: 0 # 数据库索引 |
| 74 | # password: dev # 密码,建议生产环境开启 | 74 | # password: dev # 密码,建议生产环境开启 |