增加门店钱包相关接口

This commit is contained in:
2025-08-24 13:03:37 +08:00
parent 2a0bd99a0f
commit c208dcf29d
18 changed files with 472 additions and 0 deletions

View File

@ -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));
}
}

View File

@ -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);
}

View 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);
}

View 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;
}

View 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;
}

View 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;
}

View File

@ -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> {
}

View 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> {
}

View 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;
}

View 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;
}

View File

@ -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> {
}

View 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> {
}

View File

@ -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 {
}

View File

@ -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 {
}

View 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);
}

View File

@ -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);
}
}

View 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>

View 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>