Merge remote-tracking branch 'origin/develop' into develop

This commit is contained in:
owen 2023-12-19 09:53:35 +08:00
commit 9c341be4ae
28 changed files with 316 additions and 49 deletions

View File

@ -60,14 +60,14 @@ public class AppMemberUserController {
@PutMapping("/update-password") @PutMapping("/update-password")
@Operation(summary = "修改用户密码", description = "用户修改密码时使用") @Operation(summary = "修改用户密码", description = "用户修改密码时使用")
@PreAuthenticated @PreAuthenticated
public CommonResult<Boolean> updatePassword(@RequestBody @Valid AppMemberUserUpdatePasswordReqVO reqVO) { public CommonResult<Boolean> updateUserPassword(@RequestBody @Valid AppMemberUserUpdatePasswordReqVO reqVO) {
userService.updateUserPassword(getLoginUserId(), reqVO); userService.updateUserPassword(getLoginUserId(), reqVO);
return success(true); return success(true);
} }
@PutMapping("/reset-password") @PutMapping("/reset-password")
@Operation(summary = "重置密码", description = "用户忘记密码时使用") @Operation(summary = "重置密码", description = "用户忘记密码时使用")
public CommonResult<Boolean> resetPassword(@RequestBody @Valid AppMemberUserResetPasswordReqVO reqVO) { public CommonResult<Boolean> resetUserPassword(@RequestBody @Valid AppMemberUserResetPasswordReqVO reqVO) {
userService.resetUserPassword(reqVO); userService.resetUserPassword(reqVO);
return success(true); return success(true);
} }

View File

@ -214,11 +214,17 @@ public class MemberAuthServiceImpl implements MemberAuthService {
} }
// 情况 2如果是重置密码场景需要校验手机号是存在的 // 情况 2如果是重置密码场景需要校验手机号是存在的
if (Objects.equals(reqVO.getScene(), SmsSceneEnum.MEMBER_RESET_PASSWORD.getScene())) { if (Objects.equals(reqVO.getScene(), SmsSceneEnum.MEMBER_RESET_PASSWORD.getScene())) {
MemberUserDO user= userService.getUserByMobile(reqVO.getMobile()); MemberUserDO user = userService.getUserByMobile(reqVO.getMobile());
if (user == null) { if (user == null) {
throw exception(USER_MOBILE_NOT_EXISTS); throw exception(USER_MOBILE_NOT_EXISTS);
} }
} }
// 情况 3如果是修改密码场景需要查询手机号无需前端传递
if (Objects.equals(reqVO.getScene(), SmsSceneEnum.MEMBER_UPDATE_PASSWORD.getScene())) {
MemberUserDO user = userService.getUser(userId);
// TODO 芋艿后续 member user 手机非强绑定这块需要做下调整
reqVO.setMobile(user.getMobile());
}
// 执行发送 // 执行发送
smsCodeApi.sendSmsCode(AuthConvert.INSTANCE.convert(reqVO).setCreateIp(getClientIP())); smsCodeApi.sendSmsCode(AuthConvert.INSTANCE.convert(reqVO).setCreateIp(getClientIP()));

View File

@ -78,6 +78,10 @@
<groupId>cn.iocoder.boot</groupId> <groupId>cn.iocoder.boot</groupId>
<artifactId>yudao-spring-boot-starter-excel</artifactId> <artifactId>yudao-spring-boot-starter-excel</artifactId>
</dependency> </dependency>
<dependency>
<groupId>cn.iocoder.boot</groupId>
<artifactId>yudao-spring-boot-starter-biz-dict</artifactId>
</dependency>
</dependencies> </dependencies>

View File

@ -6,7 +6,7 @@ import cn.iocoder.yudao.module.pay.controller.admin.wallet.vo.rechargepackage.Wa
import cn.iocoder.yudao.module.pay.controller.admin.wallet.vo.rechargepackage.WalletRechargePackagePageReqVO; import cn.iocoder.yudao.module.pay.controller.admin.wallet.vo.rechargepackage.WalletRechargePackagePageReqVO;
import cn.iocoder.yudao.module.pay.controller.admin.wallet.vo.rechargepackage.WalletRechargePackageRespVO; import cn.iocoder.yudao.module.pay.controller.admin.wallet.vo.rechargepackage.WalletRechargePackageRespVO;
import cn.iocoder.yudao.module.pay.controller.admin.wallet.vo.rechargepackage.WalletRechargePackageUpdateReqVO; import cn.iocoder.yudao.module.pay.controller.admin.wallet.vo.rechargepackage.WalletRechargePackageUpdateReqVO;
import cn.iocoder.yudao.module.pay.convert.wallet.WalletRechargePackageConvert; import cn.iocoder.yudao.module.pay.convert.wallet.PayWalletRechargePackageConvert;
import cn.iocoder.yudao.module.pay.dal.dataobject.wallet.PayWalletRechargePackageDO; import cn.iocoder.yudao.module.pay.dal.dataobject.wallet.PayWalletRechargePackageDO;
import cn.iocoder.yudao.module.pay.service.wallet.PayWalletRechargePackageService; import cn.iocoder.yudao.module.pay.service.wallet.PayWalletRechargePackageService;
import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.Operation;
@ -61,7 +61,7 @@ public class PayWalletRechargePackageController {
@PreAuthorize("@ss.hasPermission('pay:wallet-recharge-package:query')") @PreAuthorize("@ss.hasPermission('pay:wallet-recharge-package:query')")
public CommonResult<WalletRechargePackageRespVO> getWalletRechargePackage(@RequestParam("id") Long id) { public CommonResult<WalletRechargePackageRespVO> getWalletRechargePackage(@RequestParam("id") Long id) {
PayWalletRechargePackageDO walletRechargePackage = walletRechargePackageService.getWalletRechargePackage(id); PayWalletRechargePackageDO walletRechargePackage = walletRechargePackageService.getWalletRechargePackage(id);
return success(WalletRechargePackageConvert.INSTANCE.convert(walletRechargePackage)); return success(PayWalletRechargePackageConvert.INSTANCE.convert(walletRechargePackage));
} }
@GetMapping("/page") @GetMapping("/page")
@ -69,7 +69,7 @@ public class PayWalletRechargePackageController {
@PreAuthorize("@ss.hasPermission('pay:wallet-recharge-package:query')") @PreAuthorize("@ss.hasPermission('pay:wallet-recharge-package:query')")
public CommonResult<PageResult<WalletRechargePackageRespVO>> getWalletRechargePackagePage(@Valid WalletRechargePackagePageReqVO pageVO) { public CommonResult<PageResult<WalletRechargePackageRespVO>> getWalletRechargePackagePage(@Valid WalletRechargePackagePageReqVO pageVO) {
PageResult<PayWalletRechargePackageDO> pageResult = walletRechargePackageService.getWalletRechargePackagePage(pageVO); PageResult<PayWalletRechargePackageDO> pageResult = walletRechargePackageService.getWalletRechargePackagePage(pageVO);
return success(WalletRechargePackageConvert.INSTANCE.convertPage(pageResult)); return success(PayWalletRechargePackageConvert.INSTANCE.convertPage(pageResult));
} }
} }

View File

@ -1,24 +1,35 @@
package cn.iocoder.yudao.module.pay.controller.app.wallet; package cn.iocoder.yudao.module.pay.controller.app.wallet;
import cn.hutool.core.collection.CollUtil;
import cn.iocoder.yudao.framework.common.enums.UserTypeEnum;
import cn.iocoder.yudao.framework.common.pojo.CommonResult; import cn.iocoder.yudao.framework.common.pojo.CommonResult;
import cn.iocoder.yudao.framework.common.pojo.PageParam;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.module.pay.controller.app.wallet.vo.recharge.AppPayWalletRechargeCreateReqVO; import cn.iocoder.yudao.module.pay.controller.app.wallet.vo.recharge.AppPayWalletRechargeCreateReqVO;
import cn.iocoder.yudao.module.pay.controller.app.wallet.vo.recharge.AppPayWalletRechargeCreateRespVO; import cn.iocoder.yudao.module.pay.controller.app.wallet.vo.recharge.AppPayWalletRechargeCreateRespVO;
import cn.iocoder.yudao.module.pay.controller.app.wallet.vo.recharge.AppPayWalletRechargeRespVO;
import cn.iocoder.yudao.module.pay.convert.wallet.PayWalletConvert;
import cn.iocoder.yudao.module.pay.convert.wallet.PayWalletRechargeConvert; import cn.iocoder.yudao.module.pay.convert.wallet.PayWalletRechargeConvert;
import cn.iocoder.yudao.module.pay.dal.dataobject.order.PayOrderDO;
import cn.iocoder.yudao.module.pay.dal.dataobject.wallet.PayWalletRechargeDO; import cn.iocoder.yudao.module.pay.dal.dataobject.wallet.PayWalletRechargeDO;
import cn.iocoder.yudao.module.pay.service.order.PayOrderService;
import cn.iocoder.yudao.module.pay.service.wallet.PayWalletRechargeService; import cn.iocoder.yudao.module.pay.service.wallet.PayWalletRechargeService;
import com.google.common.collect.Lists;
import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag; import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.validation.annotation.Validated; import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.*;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import jakarta.annotation.Resource; import jakarta.annotation.Resource;
import jakarta.validation.Valid; import jakarta.validation.Valid;
import java.time.LocalDateTime;
import java.util.Arrays;
import java.util.List;
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertList;
import static cn.iocoder.yudao.framework.common.util.servlet.ServletUtils.getClientIP; import static cn.iocoder.yudao.framework.common.util.servlet.ServletUtils.getClientIP;
import static cn.iocoder.yudao.framework.web.core.util.WebFrameworkUtils.getLoginUserId; import static cn.iocoder.yudao.framework.web.core.util.WebFrameworkUtils.getLoginUserId;
import static cn.iocoder.yudao.framework.web.core.util.WebFrameworkUtils.getLoginUserType; import static cn.iocoder.yudao.framework.web.core.util.WebFrameworkUtils.getLoginUserType;
@ -32,14 +43,30 @@ public class AppPayWalletRechargeController {
@Resource @Resource
private PayWalletRechargeService walletRechargeService; private PayWalletRechargeService walletRechargeService;
@Resource
private PayOrderService payOrderService;
@PostMapping("/create") @PostMapping("/create")
@Operation(summary = "创建钱包充值记录(发起充值)") @Operation(summary = "创建钱包充值记录(发起充值)")
public CommonResult<AppPayWalletRechargeCreateRespVO> createWalletRecharge( public CommonResult<AppPayWalletRechargeCreateRespVO> createWalletRecharge(
@Valid @RequestBody AppPayWalletRechargeCreateReqVO reqVO) { @Valid @RequestBody AppPayWalletRechargeCreateReqVO reqVO) {
PayWalletRechargeDO walletRecharge = walletRechargeService.createWalletRecharge( PayWalletRechargeDO walletRecharge = walletRechargeService.createWalletRecharge(
getLoginUserId(), getLoginUserType(), getClientIP(), reqVO); getLoginUserId(), getLoginUserType(), getClientIP(), reqVO);
return success(PayWalletRechargeConvert.INSTANCE.convert(walletRecharge)); return success(PayWalletRechargeConvert.INSTANCE.convert(walletRecharge));
} }
@GetMapping("/page")
@Operation(summary = "获得钱包充值记录分页")
public CommonResult<PageResult<AppPayWalletRechargeRespVO>> getWalletRechargePage(@Valid PageParam pageReqVO) {
PageResult<PayWalletRechargeDO> pageResult = walletRechargeService.getWalletRechargePackagePage(
getLoginUserId(), UserTypeEnum.MEMBER.getValue(), pageReqVO, true);
if (CollUtil.isEmpty(pageResult.getList())) {
return success(PageResult.empty(pageResult.getTotal()));
}
// 拼接数据
List<PayOrderDO> payOrderList = payOrderService.getOrderList(
convertList(pageResult.getList(), PayWalletRechargeDO::getPayOrderId));
return success(PayWalletRechargeConvert.INSTANCE.convertPage(pageResult, payOrderList));
}
} }

View File

@ -1,16 +1,21 @@
package cn.iocoder.yudao.module.pay.controller.app.wallet; package cn.iocoder.yudao.module.pay.controller.app.wallet;
import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum;
import cn.iocoder.yudao.framework.common.pojo.CommonResult; import cn.iocoder.yudao.framework.common.pojo.CommonResult;
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
import cn.iocoder.yudao.module.pay.controller.app.wallet.vo.recharge.AppPayWalletPackageRespVO; import cn.iocoder.yudao.module.pay.controller.app.wallet.vo.recharge.AppPayWalletPackageRespVO;
import cn.iocoder.yudao.module.pay.dal.dataobject.wallet.PayWalletRechargePackageDO;
import cn.iocoder.yudao.module.pay.service.wallet.PayWalletRechargePackageService;
import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag; import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.annotation.Resource;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.validation.annotation.Validated; import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
import java.util.ArrayList; import java.util.Comparator;
import java.util.List; import java.util.List;
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
@ -22,14 +27,16 @@ import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
@Slf4j @Slf4j
public class AppPayWalletRechargePackageController { public class AppPayWalletRechargePackageController {
@Resource
private PayWalletRechargePackageService walletRechargePackageService;
@GetMapping("/list") @GetMapping("/list")
@Operation(summary = "获得钱包充值套餐列表") @Operation(summary = "获得钱包充值套餐列表")
public CommonResult<List<AppPayWalletPackageRespVO>> getWalletRechargePackageList() { public CommonResult<List<AppPayWalletPackageRespVO>> getWalletRechargePackageList() {
// 只查询开启需要按照 payPrice 排序 List<PayWalletRechargePackageDO> list = walletRechargePackageService.getWalletRechargePackageList(
List<AppPayWalletPackageRespVO> list = new ArrayList<>(); CommonStatusEnum.ENABLE.getStatus());
list.add(new AppPayWalletPackageRespVO().setId(1L).setName("土豆").setPayPrice(10).setBonusPrice(2)); list.sort(Comparator.comparingInt(PayWalletRechargePackageDO::getPayPrice));
list.add(new AppPayWalletPackageRespVO().setId(2L).setName("番茄").setPayPrice(20).setBonusPrice(5)); return success(BeanUtils.toBean(list, AppPayWalletPackageRespVO.class));
return success(list);
} }
} }

View File

@ -3,24 +3,30 @@ package cn.iocoder.yudao.module.pay.controller.app.wallet;
import cn.iocoder.yudao.framework.common.enums.UserTypeEnum; import cn.iocoder.yudao.framework.common.enums.UserTypeEnum;
import cn.iocoder.yudao.framework.common.pojo.CommonResult; import cn.iocoder.yudao.framework.common.pojo.CommonResult;
import cn.iocoder.yudao.framework.common.pojo.PageResult; import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
import cn.iocoder.yudao.module.pay.controller.app.wallet.vo.transaction.AppPayWalletTransactionSummaryRespVO;
import cn.iocoder.yudao.module.pay.controller.app.wallet.vo.transaction.AppPayWalletTransactionPageReqVO; import cn.iocoder.yudao.module.pay.controller.app.wallet.vo.transaction.AppPayWalletTransactionPageReqVO;
import cn.iocoder.yudao.module.pay.controller.app.wallet.vo.transaction.AppPayWalletTransactionRespVO; import cn.iocoder.yudao.module.pay.controller.app.wallet.vo.transaction.AppPayWalletTransactionRespVO;
import cn.iocoder.yudao.module.pay.convert.wallet.PayWalletTransactionConvert;
import cn.iocoder.yudao.module.pay.dal.dataobject.wallet.PayWalletTransactionDO; import cn.iocoder.yudao.module.pay.dal.dataobject.wallet.PayWalletTransactionDO;
import cn.iocoder.yudao.module.pay.service.wallet.PayWalletTransactionService; import cn.iocoder.yudao.module.pay.service.wallet.PayWalletTransactionService;
import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.tags.Tag; import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.format.annotation.DateTimeFormat;
import org.springframework.validation.annotation.Validated; import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
import jakarta.annotation.Resource; import jakarta.annotation.Resource;
import jakarta.validation.Valid; import jakarta.validation.Valid;
import java.time.LocalDateTime; import java.time.LocalDateTime;
import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;
import static cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils.getLoginUserId; import static cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils.getLoginUserId;
@Tag(name = "用户 APP - 钱包余额明细") @Tag(name = "用户 APP - 钱包余额明细")
@ -37,16 +43,19 @@ public class AppPayWalletTransactionController {
@Operation(summary = "获得钱包流水分页") @Operation(summary = "获得钱包流水分页")
public CommonResult<PageResult<AppPayWalletTransactionRespVO>> getWalletTransactionPage( public CommonResult<PageResult<AppPayWalletTransactionRespVO>> getWalletTransactionPage(
@Valid AppPayWalletTransactionPageReqVO pageReqVO) { @Valid AppPayWalletTransactionPageReqVO pageReqVO) {
if (true) { PageResult<PayWalletTransactionDO> pageResult = payWalletTransactionService.getWalletTransactionPage(
PageResult<AppPayWalletTransactionRespVO> result = new PageResult<>(10L); getLoginUserId(), UserTypeEnum.MEMBER.getValue(), pageReqVO);
result.getList().add(new AppPayWalletTransactionRespVO().setPrice(1L) return success(BeanUtils.toBean(pageResult, AppPayWalletTransactionRespVO.class));
.setTitle("测试").setCreateTime(LocalDateTime.now()));
result.getList().add(new AppPayWalletTransactionRespVO().setPrice(-1L)
.setTitle("测试2").setCreateTime(LocalDateTime.now()));
return success(result);
}
PageResult<PayWalletTransactionDO> result = payWalletTransactionService.getWalletTransactionPage(getLoginUserId(),
UserTypeEnum.MEMBER.getValue(), pageReqVO);
return success(PayWalletTransactionConvert.INSTANCE.convertPage(result));
} }
@GetMapping("/get-summary")
@Operation(summary = "获得钱包流水统计")
@Parameter(name = "times", description = "时间段", required = true)
public CommonResult<AppPayWalletTransactionSummaryRespVO> getWalletTransactionSummary(
@RequestParam("createTime") @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) LocalDateTime[] createTime) {
AppPayWalletTransactionSummaryRespVO summary = payWalletTransactionService.getWalletTransactionSummary(
getLoginUserId(), UserTypeEnum.MEMBER.getValue(), createTime);
return success(summary);
}
} }

View File

@ -22,4 +22,5 @@ public class AppPayWalletRechargeCreateReqVO {
public boolean isValidPayPriceAndPackageId() { public boolean isValidPayPriceAndPackageId() {
return Objects.nonNull(payPrice) || Objects.nonNull(packageId); return Objects.nonNull(payPrice) || Objects.nonNull(packageId);
} }
} }

View File

@ -0,0 +1,42 @@
package cn.iocoder.yudao.module.pay.controller.app.wallet.vo.recharge;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
import java.time.LocalDateTime;
@Schema(description = "用户 APP - 钱包充值记录 Resp VO")
@Data
public class AppPayWalletRechargeRespVO {
@Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
private Long id;
@Schema(description = "用户实际到账余额", requiredMode = Schema.RequiredMode.REQUIRED, example = "100")
private Integer totalPrice;
@Schema(description = "实际支付金额", requiredMode = Schema.RequiredMode.REQUIRED, example = "20")
private Integer payPrice;
@Schema(description = "钱包赠送金额", requiredMode = Schema.RequiredMode.REQUIRED, example = "80")
private Integer bonusPrice;
@Schema(description = "支付成功的支付渠道", requiredMode = Schema.RequiredMode.REQUIRED)
private String payChannelCode;
@Schema(description = "支付渠道名", example = "微信小程序支付")
private String payChannelName;
@Schema(description = "支付订单编号", requiredMode = Schema.RequiredMode.REQUIRED)
private Long payOrderId;
@Schema(description = "支付成功的外部订单号", requiredMode = Schema.RequiredMode.REQUIRED)
private String payOrderChannelOrderNo; // PayOrderDO channelOrderNo 字段
@Schema(description = "订单支付时间", requiredMode = Schema.RequiredMode.REQUIRED)
private LocalDateTime payTime;
@Schema(description = "退款状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "0")
private Integer refundStatus;
}

View File

@ -1,8 +1,12 @@
package cn.iocoder.yudao.module.pay.controller.app.wallet.vo.transaction; package cn.iocoder.yudao.module.pay.controller.app.wallet.vo.transaction;
import cn.iocoder.yudao.framework.common.pojo.PageParam; import cn.iocoder.yudao.framework.common.pojo.PageParam;
import cn.iocoder.yudao.framework.common.util.date.DateUtils;
import io.swagger.v3.oas.annotations.media.Schema; import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data; import lombok.Data;
import org.springframework.format.annotation.DateTimeFormat;
import java.time.LocalDateTime;
@Schema(description = "用户 APP - 钱包流水分页 Request VO") @Schema(description = "用户 APP - 钱包流水分页 Request VO")
@Data @Data
@ -20,4 +24,8 @@ public class AppPayWalletTransactionPageReqVO extends PageParam {
@Schema(description = "类型", example = "1") @Schema(description = "类型", example = "1")
private Integer type; private Integer type;
@Schema(description = "创建时间")
@DateTimeFormat(pattern = DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
private LocalDateTime[] createTime;
} }

View File

@ -0,0 +1,16 @@
package cn.iocoder.yudao.module.pay.controller.app.wallet.vo.transaction;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
@Schema(description = "用户 APP - 钱包流水统计 Request VO")
@Data
public class AppPayWalletTransactionSummaryRespVO {
@Schema(description = "累计支出,单位分", requiredMode = Schema.RequiredMode.REQUIRED, example = "1000")
private Integer totalExpense;
@Schema(description = "累计收入,单位分", requiredMode = Schema.RequiredMode.REQUIRED, example = "2000")
private Integer totalIncome;
}

View File

@ -7,13 +7,13 @@ import lombok.Data;
@Data @Data
public class AppPayWalletRespVO { public class AppPayWalletRespVO {
@Schema(description = "钱包余额,单位分", requiredMode = Schema.RequiredMode.REQUIRED, example = "100") @Schema(description = "钱包余额单位分", requiredMode = Schema.RequiredMode.REQUIRED, example = "100")
private Integer balance; private Integer balance;
@Schema(description = "累计支出, 单位分", requiredMode = Schema.RequiredMode.REQUIRED, example = "1000") @Schema(description = "累计支出单位分", requiredMode = Schema.RequiredMode.REQUIRED, example = "1000")
private Integer totalExpense; private Integer totalExpense;
@Schema(description = "累计充值, 单位分", requiredMode = Schema.RequiredMode.REQUIRED, example = "2000") @Schema(description = "累计充值单位分", requiredMode = Schema.RequiredMode.REQUIRED, example = "2000")
private Integer totalRecharge; private Integer totalRecharge;
} }

View File

@ -1,11 +1,23 @@
package cn.iocoder.yudao.module.pay.convert.wallet; package cn.iocoder.yudao.module.pay.convert.wallet;
import cn.hutool.core.collection.CollUtil;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils;
import cn.iocoder.yudao.framework.common.util.collection.MapUtils;
import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
import cn.iocoder.yudao.framework.dict.core.util.DictFrameworkUtils;
import cn.iocoder.yudao.module.pay.controller.app.wallet.vo.recharge.AppPayWalletRechargeCreateRespVO; import cn.iocoder.yudao.module.pay.controller.app.wallet.vo.recharge.AppPayWalletRechargeCreateRespVO;
import cn.iocoder.yudao.module.pay.controller.app.wallet.vo.recharge.AppPayWalletRechargeRespVO;
import cn.iocoder.yudao.module.pay.dal.dataobject.order.PayOrderDO;
import cn.iocoder.yudao.module.pay.dal.dataobject.wallet.PayWalletRechargeDO; import cn.iocoder.yudao.module.pay.dal.dataobject.wallet.PayWalletRechargeDO;
import cn.iocoder.yudao.module.pay.enums.DictTypeConstants;
import org.mapstruct.Mapper; import org.mapstruct.Mapper;
import org.mapstruct.Mapping; import org.mapstruct.Mapping;
import org.mapstruct.factory.Mappers; import org.mapstruct.factory.Mappers;
import java.util.List;
import java.util.Map;
@Mapper @Mapper
public interface PayWalletRechargeConvert { public interface PayWalletRechargeConvert {
@ -16,4 +28,17 @@ public interface PayWalletRechargeConvert {
AppPayWalletRechargeCreateRespVO convert(PayWalletRechargeDO bean); AppPayWalletRechargeCreateRespVO convert(PayWalletRechargeDO bean);
default PageResult<AppPayWalletRechargeRespVO> convertPage(PageResult<PayWalletRechargeDO> pageResult,
List<PayOrderDO> payOrderList) {
PageResult<AppPayWalletRechargeRespVO> voPageResult = BeanUtils.toBean(pageResult, AppPayWalletRechargeRespVO.class);
Map<Long, PayOrderDO> payOrderMap = CollectionUtils.convertMap(payOrderList, PayOrderDO::getId);
voPageResult.getList().forEach(recharge -> {
recharge.setPayChannelName(DictFrameworkUtils.getDictDataLabel(
DictTypeConstants.CHANNEL_CODE, recharge.getPayChannelCode()));
MapUtils.findAndThen(payOrderMap, recharge.getPayOrderId(),
order -> recharge.setPayOrderChannelOrderNo(order.getChannelOrderNo()));
});
return voPageResult;
}
} }

View File

@ -12,9 +12,9 @@ import org.mapstruct.Mapper;
import org.mapstruct.factory.Mappers; import org.mapstruct.factory.Mappers;
@Mapper @Mapper
public interface WalletRechargePackageConvert { public interface PayWalletRechargePackageConvert {
WalletRechargePackageConvert INSTANCE = Mappers.getMapper(WalletRechargePackageConvert.class); PayWalletRechargePackageConvert INSTANCE = Mappers.getMapper(PayWalletRechargePackageConvert.class);
PayWalletRechargePackageDO convert(WalletRechargePackageCreateReqVO bean); PayWalletRechargePackageDO convert(WalletRechargePackageCreateReqVO bean);

View File

@ -13,8 +13,6 @@ public interface PayWalletTransactionConvert {
PayWalletTransactionConvert INSTANCE = Mappers.getMapper(PayWalletTransactionConvert.class); PayWalletTransactionConvert INSTANCE = Mappers.getMapper(PayWalletTransactionConvert.class);
PageResult<AppPayWalletTransactionRespVO> convertPage(PageResult<PayWalletTransactionDO> page);
PageResult<PayWalletTransactionRespVO> convertPage2(PageResult<PayWalletTransactionDO> page); PageResult<PayWalletTransactionRespVO> convertPage2(PageResult<PayWalletTransactionDO> page);
PayWalletTransactionDO convert(WalletTransactionCreateReqBO bean); PayWalletTransactionDO convert(WalletTransactionCreateReqBO bean);

View File

@ -1,8 +1,11 @@
package cn.iocoder.yudao.module.pay.dal.mysql.wallet; package cn.iocoder.yudao.module.pay.dal.mysql.wallet;
import cn.iocoder.yudao.framework.common.pojo.PageParam;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.iocoder.yudao.module.pay.dal.dataobject.wallet.PayWalletRechargeDO; import cn.iocoder.yudao.module.pay.dal.dataobject.wallet.PayWalletRechargeDO;
import cn.iocoder.yudao.module.pay.dal.dataobject.wallet.PayWalletRechargePackageDO;
import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Mapper;
@Mapper @Mapper
@ -18,4 +21,10 @@ public interface PayWalletRechargeMapper extends BaseMapperX<PayWalletRechargeDO
.eq(PayWalletRechargeDO::getId, id).eq(PayWalletRechargeDO::getRefundStatus, whereRefundStatus)); .eq(PayWalletRechargeDO::getId, id).eq(PayWalletRechargeDO::getRefundStatus, whereRefundStatus));
} }
default PageResult<PayWalletRechargeDO> selectPage(PageParam pageReqVO, Long walletId, Boolean payStatus) {
return selectPage(pageReqVO, new LambdaQueryWrapperX<PayWalletRechargeDO>()
.eq(PayWalletRechargeDO::getWalletId, walletId)
.eq(PayWalletRechargeDO::getPayStatus, payStatus));
}
} }

View File

@ -8,6 +8,8 @@ import cn.iocoder.yudao.module.pay.controller.admin.wallet.vo.rechargepackage.Wa
import cn.iocoder.yudao.module.pay.dal.dataobject.wallet.PayWalletRechargePackageDO; import cn.iocoder.yudao.module.pay.dal.dataobject.wallet.PayWalletRechargePackageDO;
import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Mapper;
import java.util.List;
@Mapper @Mapper
public interface PayWalletRechargePackageMapper extends BaseMapperX<PayWalletRechargePackageDO> { public interface PayWalletRechargePackageMapper extends BaseMapperX<PayWalletRechargePackageDO> {
@ -19,9 +21,12 @@ public interface PayWalletRechargePackageMapper extends BaseMapperX<PayWalletRec
.orderByDesc(PayWalletRechargePackageDO::getPayPrice)); .orderByDesc(PayWalletRechargePackageDO::getPayPrice));
} }
// TODO @jason这里要有空格哈String name) { default PayWalletRechargePackageDO selectByName(String name) {
default PayWalletRechargePackageDO selectByName(String name){
return selectOne(PayWalletRechargePackageDO::getName, name); return selectOne(PayWalletRechargePackageDO::getName, name);
} }
default List<PayWalletRechargePackageDO> selectListByStatus(Integer status) {
return selectList(PayWalletRechargePackageDO::getStatus, status);
}
} }

View File

@ -1,32 +1,56 @@
package cn.iocoder.yudao.module.pay.dal.mysql.wallet; package cn.iocoder.yudao.module.pay.dal.mysql.wallet;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.map.MapUtil;
import cn.iocoder.yudao.framework.common.pojo.PageParam; import cn.iocoder.yudao.framework.common.pojo.PageParam;
import cn.iocoder.yudao.framework.common.pojo.PageResult; import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.iocoder.yudao.framework.mybatis.core.query.QueryWrapperX;
import cn.iocoder.yudao.module.pay.controller.app.wallet.vo.transaction.AppPayWalletTransactionPageReqVO; import cn.iocoder.yudao.module.pay.controller.app.wallet.vo.transaction.AppPayWalletTransactionPageReqVO;
import cn.iocoder.yudao.module.pay.dal.dataobject.wallet.PayWalletTransactionDO; import cn.iocoder.yudao.module.pay.dal.dataobject.wallet.PayWalletTransactionDO;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Mapper;
import java.time.LocalDateTime;
import java.util.List;
import java.util.Map;
import java.util.Objects; import java.util.Objects;
import java.util.function.Consumer;
import static cn.iocoder.yudao.module.pay.controller.app.wallet.vo.transaction.AppPayWalletTransactionPageReqVO.*;
@Mapper @Mapper
public interface PayWalletTransactionMapper extends BaseMapperX<PayWalletTransactionDO> { public interface PayWalletTransactionMapper extends BaseMapperX<PayWalletTransactionDO> {
default PageResult<PayWalletTransactionDO> selectPage(Long walletId, Integer type, default PageResult<PayWalletTransactionDO> selectPage(Long walletId, Integer type,
PageParam pageParam) { PageParam pageParam, LocalDateTime[] createTime) {
LambdaQueryWrapperX<PayWalletTransactionDO> query = new LambdaQueryWrapperX<PayWalletTransactionDO>() LambdaQueryWrapperX<PayWalletTransactionDO> query = new LambdaQueryWrapperX<PayWalletTransactionDO>()
.eqIfPresent(PayWalletTransactionDO::getWalletId, walletId); .eqIfPresent(PayWalletTransactionDO::getWalletId, walletId);
if (Objects.equals(type, AppPayWalletTransactionPageReqVO.TYPE_INCOME)) { if (Objects.equals(type, TYPE_INCOME)) {
query.gt(PayWalletTransactionDO::getPrice, 0); query.gt(PayWalletTransactionDO::getPrice, 0);
} else if (Objects.equals(type, AppPayWalletTransactionPageReqVO.TYPE_EXPENSE)) { } else if (Objects.equals(type, TYPE_EXPENSE)) {
query.lt(PayWalletTransactionDO::getPrice, 0); query.lt(PayWalletTransactionDO::getPrice, 0);
} }
query.betweenIfPresent(PayWalletTransactionDO::getCreateTime, createTime);
query.orderByDesc(PayWalletTransactionDO::getId); query.orderByDesc(PayWalletTransactionDO::getId);
return selectPage(pageParam, query); return selectPage(pageParam, query);
} }
default Integer selectPriceSum(Long walletId, Integer type, LocalDateTime[] createTime) {
// SQL sum 查询
List<Map<String, Object>> result = selectMaps(new QueryWrapperX<PayWalletTransactionDO>()
.select("SUM(price) AS priceSum")
.gt(Objects.equals(type, TYPE_INCOME), "price", 0) // 收入
.lt(Objects.equals(type, TYPE_EXPENSE), "price", 0) // 支出
.eq("wallet_id", walletId)
.between("create_time", createTime[0], createTime[1]));
// 获得 sum 结果
Map<String, Object> first = CollUtil.getFirst(result);
return MapUtil.getInt(first, "priceSum", 0);
}
default PayWalletTransactionDO selectByNo(String no) { default PayWalletTransactionDO selectByNo(String no) {
return selectOne(PayWalletTransactionDO::getNo, no); return selectOne(PayWalletTransactionDO::getNo, no);
} }

View File

@ -13,6 +13,7 @@ import cn.iocoder.yudao.module.pay.dal.dataobject.order.PayOrderExtensionDO;
import jakarta.validation.Valid; import jakarta.validation.Valid;
import jakarta.validation.constraints.NotEmpty; import jakarta.validation.constraints.NotEmpty;
import java.time.LocalDateTime; import java.time.LocalDateTime;
import java.util.Collection;
import java.util.List; import java.util.List;
/** /**
@ -39,6 +40,14 @@ public interface PayOrderService {
*/ */
PayOrderDO getOrder(Long appId, String merchantOrderId); PayOrderDO getOrder(Long appId, String merchantOrderId);
/**
* 获得支付订单列表
*
* @param ids 编号数组
* @return 支付订单列表
*/
List<PayOrderDO> getOrderList(Collection<Long> ids);
/** /**
* 获得指定应用的订单数量 * 获得指定应用的订单数量
* *

View File

@ -39,6 +39,8 @@ import org.springframework.validation.annotation.Validated;
import jakarta.annotation.Resource; import jakarta.annotation.Resource;
import java.time.LocalDateTime; import java.time.LocalDateTime;
import java.util.Collection;
import java.util.Collections;
import java.util.List; import java.util.List;
import java.util.Objects; import java.util.Objects;
@ -83,6 +85,14 @@ public class PayOrderServiceImpl implements PayOrderService {
return orderMapper.selectByAppIdAndMerchantOrderId(appId, merchantOrderId); return orderMapper.selectByAppIdAndMerchantOrderId(appId, merchantOrderId);
} }
@Override
public List<PayOrderDO> getOrderList(Collection<Long> ids) {
if (CollUtil.isEmpty(ids)) {
return Collections.emptyList();
}
return orderMapper.selectBatchIds(ids);
}
@Override @Override
public Long getOrderCountByAppId(Long appId) { public Long getOrderCountByAppId(Long appId) {
return orderMapper.selectCountByAppId(appId); return orderMapper.selectCountByAppId(appId);

View File

@ -60,4 +60,12 @@ public interface PayWalletRechargePackageService {
*/ */
PageResult<PayWalletRechargePackageDO> getWalletRechargePackagePage(WalletRechargePackagePageReqVO pageReqVO); PageResult<PayWalletRechargePackageDO> getWalletRechargePackagePage(WalletRechargePackagePageReqVO pageReqVO);
/**
* 获得充值套餐列表
*
* @param status 状态
* @return 充值套餐列表
*/
List<PayWalletRechargePackageDO> getWalletRechargePackageList(Integer status);
} }

View File

@ -6,13 +6,15 @@ import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.module.pay.controller.admin.wallet.vo.rechargepackage.WalletRechargePackageCreateReqVO; import cn.iocoder.yudao.module.pay.controller.admin.wallet.vo.rechargepackage.WalletRechargePackageCreateReqVO;
import cn.iocoder.yudao.module.pay.controller.admin.wallet.vo.rechargepackage.WalletRechargePackagePageReqVO; import cn.iocoder.yudao.module.pay.controller.admin.wallet.vo.rechargepackage.WalletRechargePackagePageReqVO;
import cn.iocoder.yudao.module.pay.controller.admin.wallet.vo.rechargepackage.WalletRechargePackageUpdateReqVO; import cn.iocoder.yudao.module.pay.controller.admin.wallet.vo.rechargepackage.WalletRechargePackageUpdateReqVO;
import cn.iocoder.yudao.module.pay.convert.wallet.WalletRechargePackageConvert; import cn.iocoder.yudao.module.pay.convert.wallet.PayWalletRechargePackageConvert;
import cn.iocoder.yudao.module.pay.dal.dataobject.wallet.PayWalletRechargePackageDO; import cn.iocoder.yudao.module.pay.dal.dataobject.wallet.PayWalletRechargePackageDO;
import cn.iocoder.yudao.module.pay.dal.mysql.wallet.PayWalletRechargePackageMapper; import cn.iocoder.yudao.module.pay.dal.mysql.wallet.PayWalletRechargePackageMapper;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import jakarta.annotation.Resource; import jakarta.annotation.Resource;
import java.util.List;
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
import static cn.iocoder.yudao.module.pay.enums.ErrorCodeConstants.*; import static cn.iocoder.yudao.module.pay.enums.ErrorCodeConstants.*;
@ -50,7 +52,7 @@ public class PayWalletRechargePackageServiceImpl implements PayWalletRechargePac
validateRechargePackageNameUnique(null, createReqVO.getName()); validateRechargePackageNameUnique(null, createReqVO.getName());
// 插入 // 插入
PayWalletRechargePackageDO walletRechargePackage = WalletRechargePackageConvert.INSTANCE.convert(createReqVO); PayWalletRechargePackageDO walletRechargePackage = PayWalletRechargePackageConvert.INSTANCE.convert(createReqVO);
walletRechargePackageMapper.insert(walletRechargePackage); walletRechargePackageMapper.insert(walletRechargePackage);
// 返回 // 返回
return walletRechargePackage.getId(); return walletRechargePackage.getId();
@ -64,7 +66,7 @@ public class PayWalletRechargePackageServiceImpl implements PayWalletRechargePac
validateRechargePackageNameUnique(updateReqVO.getId(), updateReqVO.getName()); validateRechargePackageNameUnique(updateReqVO.getId(), updateReqVO.getName());
// 更新 // 更新
PayWalletRechargePackageDO updateObj = WalletRechargePackageConvert.INSTANCE.convert(updateReqVO); PayWalletRechargePackageDO updateObj = PayWalletRechargePackageConvert.INSTANCE.convert(updateReqVO);
walletRechargePackageMapper.updateById(updateObj); walletRechargePackageMapper.updateById(updateObj);
} }
@ -103,4 +105,9 @@ public class PayWalletRechargePackageServiceImpl implements PayWalletRechargePac
return walletRechargePackageMapper.selectPage(pageReqVO); return walletRechargePackageMapper.selectPage(pageReqVO);
} }
@Override
public List<PayWalletRechargePackageDO> getWalletRechargePackageList(Integer status) {
return walletRechargePackageMapper.selectListByStatus(status);
}
} }

View File

@ -1,7 +1,10 @@
package cn.iocoder.yudao.module.pay.service.wallet; package cn.iocoder.yudao.module.pay.service.wallet;
import cn.iocoder.yudao.framework.common.pojo.PageParam;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.module.pay.controller.app.wallet.vo.recharge.AppPayWalletRechargeCreateReqVO; import cn.iocoder.yudao.module.pay.controller.app.wallet.vo.recharge.AppPayWalletRechargeCreateReqVO;
import cn.iocoder.yudao.module.pay.dal.dataobject.wallet.PayWalletRechargeDO; import cn.iocoder.yudao.module.pay.dal.dataobject.wallet.PayWalletRechargeDO;
import cn.iocoder.yudao.module.pay.dal.dataobject.wallet.PayWalletRechargePackageDO;
/** /**
* 钱包充值 Service 接口 * 钱包充值 Service 接口
@ -22,6 +25,18 @@ public interface PayWalletRechargeService {
PayWalletRechargeDO createWalletRecharge(Long userId, Integer userType, String userIp, PayWalletRechargeDO createWalletRecharge(Long userId, Integer userType, String userIp,
AppPayWalletRechargeCreateReqVO createReqVO); AppPayWalletRechargeCreateReqVO createReqVO);
/**
* 获得钱包充值记录分页
*
* @param userId 用户编号
* @param userType 用户类型
* @param pageReqVO 分页请求
* @param payStatus 是否支付
* @return 钱包充值记录分页
*/
PageResult<PayWalletRechargeDO> getWalletRechargePackagePage(Long userId, Integer userType,
PageParam pageReqVO, Boolean payStatus);
/** /**
* 更新钱包充值成功 * 更新钱包充值成功
* *

View File

@ -1,6 +1,8 @@
package cn.iocoder.yudao.module.pay.service.wallet; package cn.iocoder.yudao.module.pay.service.wallet;
import cn.hutool.core.lang.Assert; import cn.hutool.core.lang.Assert;
import cn.iocoder.yudao.framework.common.pojo.PageParam;
import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.pay.core.enums.refund.PayRefundStatusRespEnum; import cn.iocoder.yudao.framework.pay.core.enums.refund.PayRefundStatusRespEnum;
import cn.iocoder.yudao.module.pay.api.order.dto.PayOrderCreateReqDTO; import cn.iocoder.yudao.module.pay.api.order.dto.PayOrderCreateReqDTO;
import cn.iocoder.yudao.module.pay.api.refund.dto.PayRefundCreateReqDTO; import cn.iocoder.yudao.module.pay.api.refund.dto.PayRefundCreateReqDTO;
@ -64,7 +66,6 @@ public class PayWalletRechargeServiceImpl implements PayWalletRechargeService {
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
public PayWalletRechargeDO createWalletRecharge(Long userId, Integer userType, String userIp, public PayWalletRechargeDO createWalletRecharge(Long userId, Integer userType, String userIp,
AppPayWalletRechargeCreateReqVO reqVO) { AppPayWalletRechargeCreateReqVO reqVO) {
// 1.1 计算充值金额 // 1.1 计算充值金额
int payPrice; int payPrice;
int bonusPrice = 0; int bonusPrice = 0;
@ -93,6 +94,13 @@ public class PayWalletRechargeServiceImpl implements PayWalletRechargeService {
return recharge; return recharge;
} }
@Override
public PageResult<PayWalletRechargeDO> getWalletRechargePackagePage(Long userId, Integer userType,
PageParam pageReqVO, Boolean payStatus) {
PayWalletDO wallet = payWalletService.getOrCreateWallet(userId, userType);
return walletRechargeMapper.selectPage(pageReqVO, wallet.getId(), payStatus);
}
@Override @Override
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
public void updateWalletRechargerPaid(Long id, Long payOrderId) { public void updateWalletRechargerPaid(Long id, Long payOrderId) {

View File

@ -30,7 +30,6 @@ public interface PayWalletService {
*/ */
PayWalletDO getWallet(Long walletId); PayWalletDO getWallet(Long walletId);
/** /**
* 获得会员钱包分页 * 获得会员钱包分页
* *

View File

@ -3,12 +3,15 @@ package cn.iocoder.yudao.module.pay.service.wallet;
import cn.iocoder.yudao.framework.common.pojo.PageResult; import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.module.pay.controller.admin.wallet.vo.transaction.PayWalletTransactionPageReqVO; import cn.iocoder.yudao.module.pay.controller.admin.wallet.vo.transaction.PayWalletTransactionPageReqVO;
import cn.iocoder.yudao.module.pay.controller.app.wallet.vo.transaction.AppPayWalletTransactionPageReqVO; import cn.iocoder.yudao.module.pay.controller.app.wallet.vo.transaction.AppPayWalletTransactionPageReqVO;
import cn.iocoder.yudao.module.pay.controller.app.wallet.vo.transaction.AppPayWalletTransactionSummaryRespVO;
import cn.iocoder.yudao.module.pay.dal.dataobject.wallet.PayWalletTransactionDO; import cn.iocoder.yudao.module.pay.dal.dataobject.wallet.PayWalletTransactionDO;
import cn.iocoder.yudao.module.pay.enums.wallet.PayWalletBizTypeEnum; import cn.iocoder.yudao.module.pay.enums.wallet.PayWalletBizTypeEnum;
import cn.iocoder.yudao.module.pay.service.wallet.bo.WalletTransactionCreateReqBO; import cn.iocoder.yudao.module.pay.service.wallet.bo.WalletTransactionCreateReqBO;
import jakarta.validation.Valid; import jakarta.validation.Valid;
import java.time.LocalDateTime;
/** /**
* 钱包余额流水 Service 接口 * 钱包余额流水 Service 接口
* *
@ -57,4 +60,15 @@ public interface PayWalletTransactionService {
*/ */
PayWalletTransactionDO getWalletTransaction(String bizId, PayWalletBizTypeEnum type); PayWalletTransactionDO getWalletTransaction(String bizId, PayWalletBizTypeEnum type);
/**
* 获得钱包流水统计
*
* @param userId 用户编号
* @param userType 用户类型
* @param createTime 时间段
* @return 钱包流水统计
*/
AppPayWalletTransactionSummaryRespVO getWalletTransactionSummary(Long userId, Integer userType,
LocalDateTime[] createTime);
} }

View File

@ -3,6 +3,7 @@ package cn.iocoder.yudao.module.pay.service.wallet;
import cn.iocoder.yudao.framework.common.pojo.PageResult; import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.module.pay.controller.admin.wallet.vo.transaction.PayWalletTransactionPageReqVO; import cn.iocoder.yudao.module.pay.controller.admin.wallet.vo.transaction.PayWalletTransactionPageReqVO;
import cn.iocoder.yudao.module.pay.controller.app.wallet.vo.transaction.AppPayWalletTransactionPageReqVO; import cn.iocoder.yudao.module.pay.controller.app.wallet.vo.transaction.AppPayWalletTransactionPageReqVO;
import cn.iocoder.yudao.module.pay.controller.app.wallet.vo.transaction.AppPayWalletTransactionSummaryRespVO;
import cn.iocoder.yudao.module.pay.convert.wallet.PayWalletTransactionConvert; import cn.iocoder.yudao.module.pay.convert.wallet.PayWalletTransactionConvert;
import cn.iocoder.yudao.module.pay.dal.dataobject.wallet.PayWalletDO; import cn.iocoder.yudao.module.pay.dal.dataobject.wallet.PayWalletDO;
import cn.iocoder.yudao.module.pay.dal.dataobject.wallet.PayWalletTransactionDO; import cn.iocoder.yudao.module.pay.dal.dataobject.wallet.PayWalletTransactionDO;
@ -16,6 +17,11 @@ import org.springframework.validation.annotation.Validated;
import jakarta.annotation.Resource; import jakarta.annotation.Resource;
import java.time.LocalDateTime;
import static cn.iocoder.yudao.module.pay.controller.app.wallet.vo.transaction.AppPayWalletTransactionPageReqVO.TYPE_EXPENSE;
import static cn.iocoder.yudao.module.pay.controller.app.wallet.vo.transaction.AppPayWalletTransactionPageReqVO.TYPE_INCOME;
/** /**
* 钱包流水 Service 实现类 * 钱包流水 Service 实现类
* *
@ -42,12 +48,12 @@ public class PayWalletTransactionServiceImpl implements PayWalletTransactionServ
public PageResult<PayWalletTransactionDO> getWalletTransactionPage(Long userId, Integer userType, public PageResult<PayWalletTransactionDO> getWalletTransactionPage(Long userId, Integer userType,
AppPayWalletTransactionPageReqVO pageVO) { AppPayWalletTransactionPageReqVO pageVO) {
PayWalletDO wallet = payWalletService.getOrCreateWallet(userId, userType); PayWalletDO wallet = payWalletService.getOrCreateWallet(userId, userType);
return payWalletTransactionMapper.selectPage(wallet.getId(), pageVO.getType(), pageVO); return payWalletTransactionMapper.selectPage(wallet.getId(), pageVO.getType(), pageVO, pageVO.getCreateTime());
} }
@Override @Override
public PageResult<PayWalletTransactionDO> getWalletTransactionPage(PayWalletTransactionPageReqVO pageVO) { public PageResult<PayWalletTransactionDO> getWalletTransactionPage(PayWalletTransactionPageReqVO pageVO) {
return payWalletTransactionMapper.selectPage(pageVO.getWalletId(), null, pageVO); return payWalletTransactionMapper.selectPage(pageVO.getWalletId(), null, pageVO, null);
} }
@Override @Override
@ -68,4 +74,14 @@ public class PayWalletTransactionServiceImpl implements PayWalletTransactionServ
return payWalletTransactionMapper.selectByBiz(bizId, type.getType()); return payWalletTransactionMapper.selectByBiz(bizId, type.getType());
} }
@Override
public AppPayWalletTransactionSummaryRespVO getWalletTransactionSummary(Long userId, Integer userType, LocalDateTime[] createTime) {
PayWalletDO wallet = payWalletService.getOrCreateWallet(userId, userType);
AppPayWalletTransactionSummaryRespVO summary = new AppPayWalletTransactionSummaryRespVO()
.setTotalExpense(1).setTotalIncome(100);
return new AppPayWalletTransactionSummaryRespVO()
.setTotalExpense(payWalletTransactionMapper.selectPriceSum(wallet.getId(), TYPE_EXPENSE, createTime))
.setTotalIncome(payWalletTransactionMapper.selectPriceSum(wallet.getId(), TYPE_INCOME, createTime));
}
} }

View File

@ -18,7 +18,7 @@ public enum SmsSceneEnum implements IntArrayValuable {
MEMBER_LOGIN(1, "user-sms-login", "会员用户 - 手机号登陆"), MEMBER_LOGIN(1, "user-sms-login", "会员用户 - 手机号登陆"),
MEMBER_UPDATE_MOBILE(2, "user-update-mobile", "会员用户 - 修改手机"), MEMBER_UPDATE_MOBILE(2, "user-update-mobile", "会员用户 - 修改手机"),
MEMBER_UPDATE_PASSWORD(3, "user-update-mobile", "会员用户 - 修改密码"), MEMBER_UPDATE_PASSWORD(3, "user-update-password", "会员用户 - 修改密码"),
MEMBER_RESET_PASSWORD(4, "user-reset-password", "会员用户 - 忘记密码"), MEMBER_RESET_PASSWORD(4, "user-reset-password", "会员用户 - 忘记密码"),
ADMIN_MEMBER_LOGIN(21, "admin-sms-login", "后台用户 - 手机号登录"); ADMIN_MEMBER_LOGIN(21, "admin-sms-login", "后台用户 - 手机号登录");