增加门店钱包相关接口
This commit is contained in:
@ -0,0 +1,47 @@
|
||||
package com.sczx.store.controller;
|
||||
|
||||
|
||||
import com.sczx.store.common.Result;
|
||||
import com.sczx.store.dto.BaseWalletChangeDTO;
|
||||
import com.sczx.store.dto.BaseWalletDTO;
|
||||
import com.sczx.store.dto.WalletChangeQueryReq;
|
||||
import com.sczx.store.service.IWalletService;
|
||||
import com.sczx.store.util.JwtUtil;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 钱包信息 前端控制器
|
||||
* </p>
|
||||
*
|
||||
* @author zhangli
|
||||
* @since 2025-08-16 17:45:46
|
||||
*/
|
||||
@Api(value = "钱包控制器", tags = "钱包")
|
||||
@RestController
|
||||
@RequestMapping("/wallet")
|
||||
public class WalletController {
|
||||
|
||||
@Autowired
|
||||
private IWalletService walletService;
|
||||
|
||||
@Autowired
|
||||
private JwtUtil jwtUtil;
|
||||
|
||||
@ApiOperation(value = "获取钱包信息", notes = "获取钱包信息")
|
||||
@GetMapping("/walletInfo")
|
||||
public Result<BaseWalletDTO> walletInfo(@RequestParam(value = "userId") Long userId) {
|
||||
return Result.ok(walletService.getWalletInfo(userId));
|
||||
}
|
||||
|
||||
@ApiOperation(value = "获取钱包变更信息列表", notes = "获取钱包变更信息列表")
|
||||
@PostMapping("/listWalletChange")
|
||||
public Result<List<BaseWalletChangeDTO>> listWalletChange(@RequestBody WalletChangeQueryReq baseWalletChangeQueryReq) {
|
||||
return Result.ok(walletService.listWalletChange(baseWalletChangeQueryReq));
|
||||
}
|
||||
}
|
||||
@ -0,0 +1,17 @@
|
||||
package com.sczx.store.convert;
|
||||
|
||||
|
||||
import com.sczx.store.dto.BaseWalletChangeDTO;
|
||||
import com.sczx.store.po.BaseWalletChangePO;
|
||||
import org.mapstruct.Mapper;
|
||||
import org.mapstruct.factory.Mappers;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Mapper
|
||||
public interface BaseWalletChangeConvert {
|
||||
BaseWalletChangeConvert INSTANCE = Mappers.getMapper(BaseWalletChangeConvert.class);
|
||||
BaseWalletChangeDTO po2Dto(BaseWalletChangePO baseWalletPO);
|
||||
BaseWalletChangePO dto2Po(BaseWalletChangeDTO baseWalletDTO);
|
||||
List<BaseWalletChangeDTO> pos2Dtos(List<BaseWalletChangePO> baseWalletPOs);
|
||||
}
|
||||
13
src/main/java/com/sczx/store/convert/BaseWalletConvert.java
Normal file
13
src/main/java/com/sczx/store/convert/BaseWalletConvert.java
Normal file
@ -0,0 +1,13 @@
|
||||
package com.sczx.store.convert;
|
||||
|
||||
|
||||
import com.sczx.store.dto.BaseWalletDTO;
|
||||
import com.sczx.store.po.BaseWalletPO;
|
||||
import org.mapstruct.Mapper;
|
||||
import org.mapstruct.factory.Mappers;
|
||||
|
||||
@Mapper
|
||||
public interface BaseWalletConvert {
|
||||
BaseWalletConvert INSTANCE = Mappers.getMapper(BaseWalletConvert.class);
|
||||
BaseWalletDTO po2Dto(BaseWalletPO baseWalletPO);
|
||||
}
|
||||
37
src/main/java/com/sczx/store/dto/BaseWalletChangeDTO.java
Normal file
37
src/main/java/com/sczx/store/dto/BaseWalletChangeDTO.java
Normal file
@ -0,0 +1,37 @@
|
||||
package com.sczx.store.dto;
|
||||
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
@ApiModel(value = "BaseWalletChangeDTO对象", description = "钱包变更记录")
|
||||
@Data
|
||||
public class BaseWalletChangeDTO {
|
||||
@ApiModelProperty("id主键")
|
||||
private Long id;
|
||||
|
||||
@ApiModelProperty("用户id")
|
||||
private Long userId;
|
||||
|
||||
@ApiModelProperty("变更类型")
|
||||
private String changeType;
|
||||
|
||||
@ApiModelProperty("支付类型")
|
||||
private String payType;
|
||||
|
||||
@ApiModelProperty("变更时间")
|
||||
private LocalDateTime changeTime;
|
||||
|
||||
@ApiModelProperty("变更金额(元)")
|
||||
private BigDecimal changeAmount;
|
||||
|
||||
@ApiModelProperty("引荐订单")
|
||||
private String referralOrderNo;
|
||||
|
||||
@ApiModelProperty("审核状态")
|
||||
private String changeStatus;
|
||||
|
||||
}
|
||||
30
src/main/java/com/sczx/store/dto/BaseWalletDTO.java
Normal file
30
src/main/java/com/sczx/store/dto/BaseWalletDTO.java
Normal file
@ -0,0 +1,30 @@
|
||||
package com.sczx.store.dto;
|
||||
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
|
||||
@ApiModel(value = "BaseWalletDTO对象", description = "钱包信息")
|
||||
@Data
|
||||
public class BaseWalletDTO {
|
||||
|
||||
@ApiModelProperty("用户id")
|
||||
private Long userId;
|
||||
|
||||
@ApiModelProperty("用户名")
|
||||
private String userName;
|
||||
|
||||
@ApiModelProperty("手机号")
|
||||
private String phoneNumber;
|
||||
|
||||
@ApiModelProperty("余额(元)")
|
||||
private BigDecimal balance;
|
||||
|
||||
@ApiModelProperty("可用金额(元)")
|
||||
private BigDecimal availableAmount;
|
||||
|
||||
@ApiModelProperty("冻结金额(元)")
|
||||
private BigDecimal freezeAmount;
|
||||
}
|
||||
16
src/main/java/com/sczx/store/dto/WalletChangeQueryReq.java
Normal file
16
src/main/java/com/sczx/store/dto/WalletChangeQueryReq.java
Normal file
@ -0,0 +1,16 @@
|
||||
package com.sczx.store.dto;
|
||||
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
@ApiModel(value = "钱包变更记录查询请求对象")
|
||||
@Data
|
||||
public class WalletChangeQueryReq {
|
||||
|
||||
@ApiModelProperty("门店id")
|
||||
private Long userId;
|
||||
|
||||
@ApiModelProperty("变更类型")
|
||||
private String changeType;
|
||||
}
|
||||
@ -0,0 +1,16 @@
|
||||
package com.sczx.store.mapper;
|
||||
|
||||
import com.sczx.store.po.BaseWalletChangePO;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 钱包变更记录 Mapper 接口
|
||||
* </p>
|
||||
*
|
||||
* @author zhangli
|
||||
* @since 2025-08-24 12:52:11
|
||||
*/
|
||||
public interface BaseWalletChangeMapper extends BaseMapper<BaseWalletChangePO> {
|
||||
|
||||
}
|
||||
16
src/main/java/com/sczx/store/mapper/BaseWalletMapper.java
Normal file
16
src/main/java/com/sczx/store/mapper/BaseWalletMapper.java
Normal file
@ -0,0 +1,16 @@
|
||||
package com.sczx.store.mapper;
|
||||
|
||||
import com.sczx.store.po.BaseWalletPO;
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 钱包信息 Mapper 接口
|
||||
* </p>
|
||||
*
|
||||
* @author zhangli
|
||||
* @since 2025-08-24 12:48:45
|
||||
*/
|
||||
public interface BaseWalletMapper extends BaseMapper<BaseWalletPO> {
|
||||
|
||||
}
|
||||
66
src/main/java/com/sczx/store/po/BaseWalletChangePO.java
Normal file
66
src/main/java/com/sczx/store/po/BaseWalletChangePO.java
Normal file
@ -0,0 +1,66 @@
|
||||
package com.sczx.store.po;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.math.BigDecimal;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 钱包变更记录
|
||||
* </p>
|
||||
*
|
||||
* @author zhangli
|
||||
* @since 2025-08-24 12:52:11
|
||||
*/
|
||||
@Getter
|
||||
@Setter
|
||||
@TableName("zc_base_wallet_change")
|
||||
@ApiModel(value = "BaseWalletChangePO对象", description = "钱包变更记录")
|
||||
public class BaseWalletChangePO implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@ApiModelProperty("id主键")
|
||||
@TableId(value = "id", type = IdType.AUTO)
|
||||
private Long id;
|
||||
|
||||
@ApiModelProperty("用户id")
|
||||
private Long userId;
|
||||
|
||||
@ApiModelProperty("变更类型")
|
||||
private String changeType;
|
||||
|
||||
@ApiModelProperty("支付类型")
|
||||
private String payType;
|
||||
|
||||
@ApiModelProperty("变更时间")
|
||||
private LocalDateTime changeTime;
|
||||
|
||||
@ApiModelProperty("变更金额(元)")
|
||||
private BigDecimal changeAmount;
|
||||
|
||||
@ApiModelProperty("引荐订单")
|
||||
private String referralOrderNo;
|
||||
|
||||
@ApiModelProperty("审核状态")
|
||||
private String changeStatus;
|
||||
|
||||
@ApiModelProperty("删除标志(0代表存在 2代表删除)")
|
||||
private String delFlag;
|
||||
|
||||
@ApiModelProperty("创建时间")
|
||||
private LocalDateTime createTime;
|
||||
|
||||
@ApiModelProperty("更新时间")
|
||||
private LocalDateTime updateTime;
|
||||
|
||||
|
||||
}
|
||||
62
src/main/java/com/sczx/store/po/BaseWalletPO.java
Normal file
62
src/main/java/com/sczx/store/po/BaseWalletPO.java
Normal file
@ -0,0 +1,62 @@
|
||||
package com.sczx.store.po;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import java.io.Serializable;
|
||||
import java.math.BigDecimal;
|
||||
import java.time.LocalDateTime;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 钱包信息
|
||||
* </p>
|
||||
*
|
||||
* @author zhangli
|
||||
* @since 2025-08-24 12:48:45
|
||||
*/
|
||||
@Getter
|
||||
@Setter
|
||||
@TableName("zc_base_wallet")
|
||||
@ApiModel(value = "BaseWalletPO对象", description = "钱包信息")
|
||||
public class BaseWalletPO implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@ApiModelProperty("用户id主键")
|
||||
@TableId(value = "user_id", type = IdType.AUTO)
|
||||
private Long userId;
|
||||
|
||||
@ApiModelProperty("用户名")
|
||||
private String userName;
|
||||
|
||||
@ApiModelProperty("手机号")
|
||||
private String phoneNumber;
|
||||
|
||||
@ApiModelProperty("余额(元)")
|
||||
private BigDecimal balance;
|
||||
|
||||
@ApiModelProperty("可用金额(元)")
|
||||
private BigDecimal availableAmount;
|
||||
|
||||
@ApiModelProperty("冻结金额(元)")
|
||||
private BigDecimal freezeAmount;
|
||||
|
||||
@ApiModelProperty("钱包类型0门店1用户")
|
||||
private Integer walletType;
|
||||
|
||||
@ApiModelProperty("删除标志(0代表存在 2代表删除)")
|
||||
private String delFlag;
|
||||
|
||||
@ApiModelProperty("创建时间")
|
||||
private LocalDateTime createTime;
|
||||
|
||||
@ApiModelProperty("更新时间")
|
||||
private LocalDateTime updateTime;
|
||||
|
||||
|
||||
}
|
||||
@ -0,0 +1,16 @@
|
||||
package com.sczx.store.repository;
|
||||
|
||||
import com.sczx.store.po.BaseWalletChangePO;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 钱包变更记录 服务类
|
||||
* </p>
|
||||
*
|
||||
* @author zhangli
|
||||
* @since 2025-08-24 12:52:11
|
||||
*/
|
||||
public interface BaseWalletChangeRepo extends IService<BaseWalletChangePO> {
|
||||
|
||||
}
|
||||
16
src/main/java/com/sczx/store/repository/BaseWalletRepo.java
Normal file
16
src/main/java/com/sczx/store/repository/BaseWalletRepo.java
Normal file
@ -0,0 +1,16 @@
|
||||
package com.sczx.store.repository;
|
||||
|
||||
import com.sczx.store.po.BaseWalletPO;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 钱包信息 服务类
|
||||
* </p>
|
||||
*
|
||||
* @author zhangli
|
||||
* @since 2025-08-24 12:48:45
|
||||
*/
|
||||
public interface BaseWalletRepo extends IService<BaseWalletPO> {
|
||||
|
||||
}
|
||||
@ -0,0 +1,20 @@
|
||||
package com.sczx.store.repository.impl;
|
||||
|
||||
import com.sczx.store.po.BaseWalletChangePO;
|
||||
import com.sczx.store.mapper.BaseWalletChangeMapper;
|
||||
import com.sczx.store.repository.BaseWalletChangeRepo;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 钱包变更记录 服务实现类
|
||||
* </p>
|
||||
*
|
||||
* @author zhangli
|
||||
* @since 2025-08-24 12:52:11
|
||||
*/
|
||||
@Service
|
||||
public class BaseWalletChangeRepoImpl extends ServiceImpl<BaseWalletChangeMapper, BaseWalletChangePO> implements BaseWalletChangeRepo {
|
||||
|
||||
}
|
||||
@ -0,0 +1,20 @@
|
||||
package com.sczx.store.repository.impl;
|
||||
|
||||
import com.sczx.store.po.BaseWalletPO;
|
||||
import com.sczx.store.mapper.BaseWalletMapper;
|
||||
import com.sczx.store.repository.BaseWalletRepo;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 钱包信息 服务实现类
|
||||
* </p>
|
||||
*
|
||||
* @author zhangli
|
||||
* @since 2025-08-24 12:48:45
|
||||
*/
|
||||
@Service
|
||||
public class BaseWalletRepoImpl extends ServiceImpl<BaseWalletMapper, BaseWalletPO> implements BaseWalletRepo {
|
||||
|
||||
}
|
||||
26
src/main/java/com/sczx/store/service/IWalletService.java
Normal file
26
src/main/java/com/sczx/store/service/IWalletService.java
Normal file
@ -0,0 +1,26 @@
|
||||
package com.sczx.store.service;
|
||||
|
||||
|
||||
import com.sczx.store.dto.BaseWalletChangeDTO;
|
||||
import com.sczx.store.dto.BaseWalletDTO;
|
||||
import com.sczx.store.dto.WalletChangeQueryReq;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface IWalletService {
|
||||
|
||||
/**
|
||||
* 根据用户id获取钱包信息
|
||||
*
|
||||
* @param userId
|
||||
* @return
|
||||
*/
|
||||
BaseWalletDTO getWalletInfo(Long userId);
|
||||
|
||||
/**
|
||||
* 根据条件获取钱包变更记录
|
||||
* @param baseWalletChangeQueryReq
|
||||
* @return
|
||||
*/
|
||||
List<BaseWalletChangeDTO> listWalletChange(WalletChangeQueryReq baseWalletChangeQueryReq);
|
||||
}
|
||||
@ -0,0 +1,44 @@
|
||||
package com.sczx.store.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.sczx.store.convert.BaseWalletChangeConvert;
|
||||
import com.sczx.store.convert.BaseWalletConvert;
|
||||
import com.sczx.store.dto.BaseWalletChangeDTO;
|
||||
import com.sczx.store.dto.BaseWalletDTO;
|
||||
import com.sczx.store.dto.WalletChangeQueryReq;
|
||||
import com.sczx.store.po.BaseWalletChangePO;
|
||||
import com.sczx.store.po.BaseWalletPO;
|
||||
import com.sczx.store.repository.BaseWalletChangeRepo;
|
||||
import com.sczx.store.repository.BaseWalletRepo;
|
||||
import com.sczx.store.service.IWalletService;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Service
|
||||
public class WalletServiceImpl implements IWalletService {
|
||||
|
||||
@Autowired
|
||||
private BaseWalletRepo baseWalletRepo;
|
||||
|
||||
@Autowired
|
||||
private BaseWalletChangeRepo baseWalletChangeRepo;
|
||||
|
||||
@Override
|
||||
public BaseWalletDTO getWalletInfo(Long userId) {
|
||||
BaseWalletPO baseWalletPO = baseWalletRepo.getById(userId);
|
||||
return BaseWalletConvert.INSTANCE.po2Dto(baseWalletPO);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<BaseWalletChangeDTO> listWalletChange(WalletChangeQueryReq baseWalletChangeQueryReq) {
|
||||
LambdaQueryWrapper<BaseWalletChangePO> queryWrapper = new LambdaQueryWrapper<>();
|
||||
queryWrapper.eq(BaseWalletChangePO::getUserId, baseWalletChangeQueryReq.getUserId())
|
||||
.eq(StringUtils.isNotBlank(baseWalletChangeQueryReq.getChangeType()),BaseWalletChangePO::getChangeType, baseWalletChangeQueryReq.getChangeType())
|
||||
.orderByDesc(BaseWalletChangePO::getChangeTime);
|
||||
List<BaseWalletChangePO> baseWalletChangePOList = baseWalletChangeRepo.list(queryWrapper);
|
||||
return BaseWalletChangeConvert.INSTANCE.pos2Dtos(baseWalletChangePOList);
|
||||
}
|
||||
}
|
||||
5
src/main/resources/mapper/BaseWalletChangeMapper.xml
Normal file
5
src/main/resources/mapper/BaseWalletChangeMapper.xml
Normal file
@ -0,0 +1,5 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.sczx.store.mapper.BaseWalletChangeMapper">
|
||||
|
||||
</mapper>
|
||||
5
src/main/resources/mapper/BaseWalletMapper.xml
Normal file
5
src/main/resources/mapper/BaseWalletMapper.xml
Normal file
@ -0,0 +1,5 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.sczx.store.mapper.BaseWalletMapper">
|
||||
|
||||
</mapper>
|
||||
Reference in New Issue
Block a user