feat:app钱包接口

This commit is contained in:
dzc committed 2025-01-06 19:09:20 +08:00
1 parent 8d784b53a0
commit e85f331755
12 files changed
+101 -11

No files matched your search

@@ -23,10 +23,10 @@ public class QRCodeDto {
private Long userId;
// 订单类型
private Integer orderType;
private String orderType;
// 支付类型
private Integer payType;
private String payType;
// 过期时间 -1 代表没有限制
private Long exceedTime;
@@ -118,7 +118,6 @@ public class HardOrderSyncServiceImpl implements HardOrderSyncService {
return false;
}
public HardOrderEntity parseOrder(OfflineOrder order, Long hardwareId, Long merchantId, Long merchantDeptId) {
HardOrderEntity res = new HardOrderEntity();
res.setAndroidOrderCode(order.getUniqueCode());
@@ -7,6 +7,8 @@ import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import java.io.Serializable;
@Builder
@AllArgsConstructor
@NotEmpty
@@ -1,11 +1,24 @@
package com.bsd.pjcloud.wallet.api.dto;
import com.bsd.pjcloud.wallet.api.entity.WalletTransactionEntity;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;
@Data
public class WalletTransactionDto extends WalletTransactionEntity {
/**
* 类型 - 收入
*/
public static final Integer TYPE_INCOME = 1;
/**
* 类型 - 支出
*/
public static final Integer TYPE_EXPENSE = 2;
private Integer type;
/**
* 用户id
*/
@@ -16,6 +16,8 @@ public class WalletManageVo extends WalletManageEntity implements BaseUserInterf
private String walletTypeUniqueCode;
private String walletIcon;
/**
* 用户相关
*/
@@ -12,6 +12,8 @@ import com.bsd.pjcloud.common.core.util.MsgUtils;
import com.bsd.pjcloud.common.core.util.R;
import com.bsd.pjcloud.common.log.annotation.SysLog;
import com.bsd.pjcloud.common.security.annotation.Inner;
import com.bsd.pjcloud.common.security.service.PjcloudUser;
import com.bsd.pjcloud.common.security.util.SecurityUtils;
import com.bsd.pjcloud.wallet.api.constant.WalletTypeCodeEnum;
import com.bsd.pjcloud.wallet.api.dto.WalletManageDto;
import com.bsd.pjcloud.wallet.api.entity.WalletManageEntity;
@@ -74,16 +76,35 @@ public class WalletManageController {
@Inner
@GetMapping("/del-wallet")
public R<Object> delWallet(@RequestParam("userIds") List<Long> userIds){
public R<Object> delWallet(@RequestParam("userIds") List<Long> userIds) {
return R.ok(walletManageService.delWalletByUserIds(userIds));
}
@Inner
@GetMapping("/add-price")
public R<Object> addPrice(@RequestParam("userIds") List<Long> userIds){
public R<Object> addPrice(@RequestParam("userIds") List<Long> userIds) {
return R.ok(walletManageService.delWalletByUserIds(userIds));
}
/* ************************************* start 远程调用 start ************************************* */
/* ************************************* end 远程调用 end ************************************* */
/* ************************************* start app start ************************************* */
@Operation(summary = "分页查询", description = "分页查询")
@GetMapping("/app/get-all")
public R appGetAll(@ParameterObject Page page, @ParameterObject WalletManageEntity walletManage) {
PjcloudUser user = SecurityUtils.getUser();
WalletManageDto dto = new WalletManageDto();
dto.setUserId(user.getId());
return walletManageService.pageJoin(page, dto);
}
@Operation(summary = "分页查询", description = "分页查询")
@GetMapping("/app/detail")
public R appGetAll(@RequestParam Long walletId) {
PjcloudUser user = SecurityUtils.getUser();
return R.ok(walletManageService.join(user.getId(), walletId));
}
/* ************************************* end app end ************************************* */
@Operation(summary = "分页查询", description = "分页查询")
@GetMapping("/page")
@@ -9,12 +9,11 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.bsd.pjcloud.common.core.util.R;
import com.bsd.pjcloud.common.log.annotation.SysLog;
import com.bsd.pjcloud.common.security.annotation.Inner;
import com.bsd.pjcloud.wallet.api.constant.WalletTypeCodeEnum;
import com.bsd.pjcloud.common.security.service.PjcloudUser;
import com.bsd.pjcloud.common.security.util.SecurityUtils;
import com.bsd.pjcloud.wallet.api.dto.WalletBalanceTransactionDto;
import com.bsd.pjcloud.wallet.api.dto.WalletTransactionDto;
import com.bsd.pjcloud.wallet.api.entity.WalletManageEntity;
import com.bsd.pjcloud.wallet.api.entity.WalletTransactionEntity;
import com.bsd.pjcloud.wallet.service.WalletManageService;
import com.bsd.pjcloud.wallet.service.WalletTransactionService;
import jakarta.validation.Valid;
import org.springframework.security.access.prepost.PreAuthorize;
@@ -62,6 +61,16 @@ public class WalletTransactionController {
}
/* ************************************* end 远程调用 end ************************************* */
/* ************************************* start app start ************************************* */
@Operation(summary = "app查询消费记录", description = "app查询消费记录")
@GetMapping("/app/page")
public R appGetAll(@ParameterObject Page page, @ParameterObject WalletTransactionDto dto) {
PjcloudUser user = SecurityUtils.getUser();
dto.setUserId(user.getId());
return R.ok(walletTransactionService.pageJoin(page, dto));
}
/* ************************************* end app end ************************************* */
@PutMapping("/update-balance")
@Operation(summary = "更新会员用户余额")
public R<Boolean> updateWalletBalance(@RequestBody WalletTransactionDto dto) {
@@ -37,6 +37,14 @@ public class WalletRechargePackageController {
private final WalletRechargePackageService walletRechargePackageService;
/* ************************************* start app start ************************************* */
@Operation(summary = "查询全部", description = "查询全部")
@GetMapping("/app/list")
public R appList() {
return R.ok(walletRechargePackageService.list(new LambdaQueryWrapper<>()));
}
/* ************************************* end app end ************************************* */
@Operation(summary = "分页查询", description = "分页查询")
@GetMapping("/page")
@PreAuthorize("@pms.hasPermission('wallet_walletRechargePackage_view')")
@@ -34,6 +34,7 @@ public interface WalletManageMapper extends PjcloudBaseMapper<WalletManageEntity
.selectAll(WalletManageEntity.class)
.selectAs(WalletTypeEntity::getName, WalletManageVo::getWalletTypeName)
.selectAs(WalletTypeEntity::getUniqueCode, WalletManageVo::getWalletTypeUniqueCode)
.selectAs(WalletTypeEntity::getIcon, WalletManageVo::getWalletIcon)
.leftJoin(WalletTypeEntity.class, WalletTypeEntity::getId, WalletManageEntity::getWalletTypeId)
.eqIfExists(WalletManageEntity::getUserId, dto.getUserId())
.eqIfExists(WalletManageEntity::getWalletTypeId, dto.getWalletTypeId())
@@ -42,4 +43,15 @@ public interface WalletManageMapper extends PjcloudBaseMapper<WalletManageEntity
.in(ObjectUtil.isNotEmpty(dto.getUserIds()), WalletManageEntity::getUserId, dto.getUserIds());
return selectJoinPage(page, WalletManageVo.class, wrapper);
}
default WalletManageVo join(Long id) {
MPJLambdaWrapper<WalletManageEntity> wrapper = new MPJLambdaWrapper<WalletManageEntity>()
.selectAll(WalletManageEntity.class)
.selectAs(WalletTypeEntity::getName, WalletManageVo::getWalletTypeName)
.selectAs(WalletTypeEntity::getUniqueCode, WalletManageVo::getWalletTypeUniqueCode)
.selectAs(WalletTypeEntity::getIcon, WalletManageVo::getWalletIcon)
.leftJoin(WalletTypeEntity.class, WalletTypeEntity::getId, WalletManageEntity::getWalletTypeId)
.eqIfExists(WalletManageEntity::getId, id);
return selectJoinOne(WalletManageVo.class, wrapper);
}
}
@@ -1,5 +1,6 @@
package com.bsd.pjcloud.wallet.mapper;
import cn.hutool.core.util.ObjectUtil;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
@@ -12,13 +13,21 @@ import com.bsd.pjcloud.wallet.api.vo.WalletTransactionVo;
import com.github.yulichang.wrapper.MPJLambdaWrapper;
import org.apache.ibatis.annotations.Mapper;
import java.util.Objects;
@Mapper
public interface WalletTransactionMapper extends PjcloudBaseMapper<WalletTransactionEntity> {
default IPage<WalletTransactionVo> pageJoin(Page page, WalletTransactionDto dto) {
MPJLambdaWrapper<WalletTransactionEntity> wrapper = new MPJLambdaWrapper<WalletTransactionEntity>()
.eqIfExists(WalletTransactionEntity::getWalletId, dto.getWalletId());
if (ObjectUtil.equals(dto.getType(), WalletTransactionDto.TYPE_INCOME)) {
wrapper.gt(WalletTransactionEntity::getPrice, 0);
} else if (Objects.equals(dto.getType(), WalletTransactionDto.TYPE_EXPENSE)) {
wrapper.lt(WalletTransactionEntity::getPrice, 0);
}
return selectJoinPage(page, WalletTransactionVo.class, wrapper);
}
}
@@ -6,6 +6,7 @@ import com.bsd.pjcloud.common.core.util.R;
import com.bsd.pjcloud.wallet.api.constant.WalletTypeCodeEnum;
import com.bsd.pjcloud.wallet.api.dto.WalletManageDto;
import com.bsd.pjcloud.wallet.api.entity.WalletManageEntity;
import com.bsd.pjcloud.wallet.api.vo.WalletManageVo;
import jakarta.validation.constraints.NotEmpty;
import jakarta.validation.constraints.NotNull;
@@ -79,4 +80,6 @@ public interface WalletManageService extends IService<WalletManageEntity> {
* @return
*/
R pageJoin(Page page, WalletManageDto dto);
WalletManageVo join(Long id, Long walletId);
}
@@ -27,7 +27,6 @@ import com.bsd.pjcloud.wallet.service.WalletTypeService;
import jakarta.validation.constraints.NotNull;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.cache.annotation.CachePut;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.stereotype.Service;
@@ -173,6 +172,19 @@ public class WalletManageServiceImpl extends ServiceImpl<WalletManageMapper, Wal
return R.ok(list);
}
@Override
public WalletManageVo join(Long userId, Long walletId) {
WalletManageVo detail = baseMapper.join(walletId);
if (ObjectUtil.isNotEmpty(detail)) {
// 用户
UserInfo userInfo = userService.getByUserId(userId).getData();
if (ObjectUtil.isNotEmpty(userInfo)) {
DataUtil.convertUser(detail, userInfo.getSysUser());
}
}
return detail;
}
private WalletManageServiceImpl getSelf() {
return SpringUtil.getBean(getClass());
}