feat:生成批量充值/扣款发票信息
This commit is contained in:
1 parent
d430595a6e
commit
4791451af3
14 files changed
+260
-37
No files matched your search
+27
@@ -0,0 +1,27 @@
|
||||
package com.bsd.pjcloud.wallet.api.constant;
|
||||
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
// cancellation
|
||||
@Getter
|
||||
@AllArgsConstructor
|
||||
public enum WalletRechargeInvoiceStatusEnum {
|
||||
|
||||
DEFAULT("1", "默认"),
|
||||
CANCELLATION("2", "作废"),
|
||||
;
|
||||
private final String code;
|
||||
|
||||
private final String desc;
|
||||
|
||||
public static WalletRechargeInvoiceStatusEnum descOf(String description) {
|
||||
return Arrays.stream(WalletRechargeInvoiceStatusEnum.values())
|
||||
.filter(v -> ObjectUtil.equal(v.getDesc(), description))
|
||||
.findFirst().get();
|
||||
}
|
||||
|
||||
}
|
||||
+10
@@ -81,6 +81,16 @@ public class WalletSettingEntity extends Model<WalletSettingEntity> {
|
||||
@Schema(description = "退货理由")
|
||||
private String afterSaleReturnReasons;
|
||||
|
||||
/**
|
||||
* 充值收款单位
|
||||
*/
|
||||
private String topupDeptStr;
|
||||
|
||||
/**
|
||||
* 充值收款人
|
||||
*/
|
||||
private Long topupUserId;
|
||||
|
||||
/**
|
||||
* 创建人
|
||||
*/
|
||||
|
||||
-12
@@ -1,12 +0,0 @@
|
||||
package com.bsd.pjcloud.wallet.api.vo.recharge;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* 充值扣款发票信息
|
||||
*/
|
||||
@Data
|
||||
public class WalletApplyInvoiceVo {
|
||||
|
||||
|
||||
}
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
package com.bsd.pjcloud.wallet.api.vo.recharge;
|
||||
|
||||
import com.bsd.pjcloud.wallet.api.entity.recharge.WalletRechargeInvoiceEntity;
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class WalletRechargeInvoiceEntityVo extends WalletRechargeInvoiceEntity {
|
||||
|
||||
private String totalPriceCnStr;
|
||||
|
||||
}
|
||||
-6
@@ -14,7 +14,6 @@ import com.bsd.pjcloud.wallet.api.dto.recharge.WalletRechargeApplyDto;
|
||||
import com.bsd.pjcloud.wallet.api.dto.recharge.WalletRechargeImportDto;
|
||||
import com.bsd.pjcloud.wallet.api.dto.recharge.excel.WalletRechargeExcelDto;
|
||||
import com.bsd.pjcloud.wallet.api.entity.recharge.WalletRechargeApplyEntity;
|
||||
import com.bsd.pjcloud.wallet.api.vo.recharge.WalletApplyInvoiceVo;
|
||||
import com.bsd.pjcloud.wallet.api.vo.recharge.excel.WalletRechargeByApplyExcelVo;
|
||||
import com.bsd.pjcloud.wallet.service.WalletRechargeApplyService;
|
||||
import com.bsd.pjcloud.wallet.service.WalletRechargeApplyComposeService;
|
||||
@@ -55,11 +54,6 @@ public class WalletRechargeApplyController {
|
||||
return R.ok(walletTransactionComposeService.pageJoin(page, dto));
|
||||
}
|
||||
|
||||
@GetMapping("/get-invoice")
|
||||
@Operation(summary = "批量充值/扣款发票信息")
|
||||
public R<WalletApplyInvoiceVo> getInvoice(@RequestParam Long id) {
|
||||
return R.ok(walletRechargeApplyService.getInvoice(id));
|
||||
}
|
||||
|
||||
@Operation(summary = "提交申请", description = "提交申请")
|
||||
@SysLog("提交申请")
|
||||
|
||||
+7
@@ -8,6 +8,7 @@ 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.wallet.api.entity.recharge.WalletRechargeInvoiceEntity;
|
||||
import com.bsd.pjcloud.wallet.api.vo.recharge.WalletRechargeInvoiceEntityVo;
|
||||
import com.bsd.pjcloud.wallet.service.WalletRechargeInvoiceService;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import com.bsd.pjcloud.common.excel.annotation.ResponseExcel;
|
||||
@@ -34,6 +35,12 @@ public class WalletRechargeInvoiceController {
|
||||
|
||||
private final WalletRechargeInvoiceService walletRechargeInvoiceService;
|
||||
|
||||
@GetMapping("/get-invoice")
|
||||
@Operation(summary = "批量充值/扣款发票信息")
|
||||
public R<WalletRechargeInvoiceEntityVo> getInvoice(@RequestParam Long id) {
|
||||
return R.ok(walletRechargeInvoiceService.getInvoice(id));
|
||||
}
|
||||
|
||||
@Operation(summary = "分页查询", description = "分页查询")
|
||||
@GetMapping("/page")
|
||||
@PreAuthorize("@pms.hasPermission('wallet_walletRechargeInvoice_view')")
|
||||
|
||||
+4
@@ -7,4 +7,8 @@ import org.apache.ibatis.annotations.Mapper;
|
||||
@Mapper
|
||||
public interface WalletRechargeInvoiceMapper extends PjcloudBaseMapper<WalletRechargeInvoiceEntity> {
|
||||
|
||||
/**
|
||||
* 查询所有数量包括删除
|
||||
*/
|
||||
Long selectAllCount();
|
||||
}
|
||||
-1
@@ -2,7 +2,6 @@ package com.bsd.pjcloud.wallet.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.bsd.pjcloud.wallet.api.dto.recharge.WalletRechargeApplyDto;
|
||||
import com.bsd.pjcloud.wallet.api.vo.recharge.WalletApplyInvoiceVo;
|
||||
import com.bsd.pjcloud.wallet.api.vo.recharge.WalletRechargeApplyCompareAceVo;
|
||||
|
||||
public interface WalletRechargeApplyComposeService {
|
||||
|
||||
-6
@@ -8,7 +8,6 @@ import com.bsd.pjcloud.wallet.api.dto.recharge.WalletRechargeApplyDto;
|
||||
import com.bsd.pjcloud.wallet.api.dto.recharge.WalletRechargeImportDto;
|
||||
import com.bsd.pjcloud.wallet.api.dto.recharge.excel.WalletRechargeExcelDto;
|
||||
import com.bsd.pjcloud.wallet.api.entity.recharge.WalletRechargeApplyEntity;
|
||||
import com.bsd.pjcloud.wallet.api.vo.recharge.WalletApplyInvoiceVo;
|
||||
import com.bsd.pjcloud.wallet.api.vo.recharge.WalletRechargeApplyVo;
|
||||
import com.bsd.pjcloud.wallet.api.vo.recharge.excel.WalletRechargeByApplyExcelVo;
|
||||
import org.springframework.validation.BindingResult;
|
||||
@@ -22,11 +21,6 @@ public interface WalletRechargeApplyService extends IService<WalletRechargeApply
|
||||
|
||||
Boolean edit(WalletRechargeApplyDto dto);
|
||||
|
||||
/**
|
||||
* 批量充值/扣款发票信息
|
||||
*/
|
||||
WalletApplyInvoiceVo getInvoice(Long id);
|
||||
|
||||
/**
|
||||
* 通过id删除充值/扣款申请
|
||||
*/
|
||||
|
||||
+10
@@ -2,7 +2,17 @@ package com.bsd.pjcloud.wallet.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.bsd.pjcloud.wallet.api.entity.recharge.WalletRechargeInvoiceEntity;
|
||||
import com.bsd.pjcloud.wallet.api.vo.recharge.WalletRechargeInvoiceEntityVo;
|
||||
|
||||
public interface WalletRechargeInvoiceService extends IService<WalletRechargeInvoiceEntity> {
|
||||
|
||||
/**
|
||||
* 批量充值/扣款发票信息
|
||||
*/
|
||||
WalletRechargeInvoiceEntityVo getInvoice(Long id);
|
||||
|
||||
/**
|
||||
* 获取发票代码
|
||||
*/
|
||||
String getInvoiceCode();
|
||||
}
|
||||
-9
@@ -39,14 +39,12 @@ import com.bsd.pjcloud.wallet.api.dto.WalletTypeDto;
|
||||
import com.bsd.pjcloud.wallet.api.dto.recharge.WalletRechargeApplyDto;
|
||||
import com.bsd.pjcloud.wallet.api.dto.recharge.WalletRechargeImportDto;
|
||||
import com.bsd.pjcloud.wallet.api.dto.recharge.excel.WalletRechargeExcelDto;
|
||||
import com.bsd.pjcloud.wallet.api.entity.WalletFreezeEntity;
|
||||
import com.bsd.pjcloud.wallet.api.entity.WalletManageEntity;
|
||||
import com.bsd.pjcloud.wallet.api.entity.WalletTypeEntity;
|
||||
import com.bsd.pjcloud.wallet.api.entity.recharge.WalletRechargeApplyEntity;
|
||||
import com.bsd.pjcloud.wallet.api.entity.recharge.WalletRechargeImportEntity;
|
||||
import com.bsd.pjcloud.wallet.api.utils.WalletDataUtil;
|
||||
import com.bsd.pjcloud.wallet.api.vo.WalletManageVo;
|
||||
import com.bsd.pjcloud.wallet.api.vo.recharge.WalletApplyInvoiceVo;
|
||||
import com.bsd.pjcloud.wallet.api.vo.recharge.WalletRechargeApplyVo;
|
||||
import com.bsd.pjcloud.wallet.api.vo.recharge.WalletRechargeImportVo;
|
||||
import com.bsd.pjcloud.wallet.api.vo.recharge.excel.WalletRechargeByApplyExcelVo;
|
||||
@@ -125,13 +123,6 @@ public class WalletRechargeApplyServiceImpl extends ServiceImpl<WalletRechargeAp
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量充值/扣款发票信息
|
||||
*/
|
||||
@Override
|
||||
public WalletApplyInvoiceVo getInvoice(Long id) {
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过id删除充值/扣款申请
|
||||
|
||||
+90
@@ -1,13 +1,103 @@
|
||||
package com.bsd.pjcloud.wallet.service.impl.recharge;
|
||||
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.bsd.pjcloud.admin.api.dto.UserInfo;
|
||||
import com.bsd.pjcloud.admin.api.feign.RemoteUserService;
|
||||
import com.bsd.pjcloud.flow.task.constant.TaskCheckStatusEnum;
|
||||
import com.bsd.pjcloud.wallet.api.constant.WalletRechargeInvoiceStatusEnum;
|
||||
import com.bsd.pjcloud.wallet.api.entity.recharge.WalletRechargeApplyEntity;
|
||||
import com.bsd.pjcloud.wallet.api.entity.recharge.WalletRechargeImportEntity;
|
||||
import com.bsd.pjcloud.wallet.api.entity.recharge.WalletRechargeInvoiceEntity;
|
||||
import com.bsd.pjcloud.wallet.api.feign.RemoteWalletSettingService;
|
||||
import com.bsd.pjcloud.wallet.api.vo.WalletSettingVo;
|
||||
import com.bsd.pjcloud.wallet.api.vo.recharge.WalletRechargeInvoiceEntityVo;
|
||||
import com.bsd.pjcloud.wallet.mapper.recharge.WalletRechargeImportMapper;
|
||||
import com.bsd.pjcloud.wallet.mapper.recharge.WalletRechargeInvoiceMapper;
|
||||
import com.bsd.pjcloud.wallet.service.WalletRechargeApplyService;
|
||||
import com.bsd.pjcloud.wallet.service.WalletRechargeInvoiceService;
|
||||
import com.bsd.pjcloud.wallet.utils.ConvertCnPriceUtil;
|
||||
import lombok.AllArgsConstructor;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 充值/扣款申请发票记录
|
||||
*/
|
||||
@Service
|
||||
@AllArgsConstructor
|
||||
public class WalletRechargeInvoiceServiceImpl extends ServiceImpl<WalletRechargeInvoiceMapper, WalletRechargeInvoiceEntity> implements WalletRechargeInvoiceService {
|
||||
|
||||
private final WalletRechargeImportMapper importMapper;
|
||||
|
||||
private final WalletRechargeApplyService applyService;
|
||||
|
||||
private final RemoteUserService remoteUserService;
|
||||
private final RemoteWalletSettingService remoteWalletSettingService;
|
||||
|
||||
/**
|
||||
* 批量充值/扣款发票信息
|
||||
*/
|
||||
@Override
|
||||
public WalletRechargeInvoiceEntityVo getInvoice(Long id) {
|
||||
// 查询申请记录
|
||||
WalletRechargeApplyEntity applyDetail = applyService.getById(id);
|
||||
if (ObjectUtil.isEmpty(applyDetail)) {
|
||||
throw new RuntimeException(" 批量充值/扣款申请不存在");
|
||||
}
|
||||
// 查询申请记录有没有编辑过
|
||||
if (!ObjectUtil.isAllNotEmpty(applyDetail.getImportTime(), applyDetail.getWalletTypeId())) {
|
||||
throw new RuntimeException("请先编辑导入时间等信息");
|
||||
}
|
||||
// 只有申请中才能获取发票
|
||||
if (ObjectUtil.notEqual(applyDetail.getProcessStatus(), TaskCheckStatusEnum.PADDING.getCode())) {
|
||||
throw new RuntimeException("只有申请中才能获取发票");
|
||||
}
|
||||
// 获取配置
|
||||
WalletSettingVo walletSetting = remoteWalletSettingService.get().getData();
|
||||
// 查询申请人
|
||||
UserInfo userInfo = remoteUserService.getByUserId(applyDetail.getUserId()).getData();
|
||||
if (ObjectUtil.isEmpty(userInfo)) {
|
||||
throw new RuntimeException("申请用户不存在");
|
||||
}
|
||||
// 查询收款人
|
||||
String payeeUser = "";
|
||||
if (ObjectUtil.isNotEmpty(walletSetting.getTopupUserId())) {
|
||||
UserInfo payeeUserDetail = remoteUserService.getByUserId(walletSetting.getTopupUserId()).getData();
|
||||
if (ObjectUtil.isNotEmpty(payeeUserDetail)) {
|
||||
payeeUser = payeeUserDetail.getSysUser().getName();
|
||||
}
|
||||
}
|
||||
// 查询总金额
|
||||
List<WalletRechargeImportEntity> importList = importMapper.selectList(new LambdaQueryWrapper<WalletRechargeImportEntity>().eq(WalletRechargeImportEntity::getApplyId, id));
|
||||
Integer totalPrice = importList.stream().map(WalletRechargeImportEntity::getPrice).reduce(Integer::sum).orElse(0);
|
||||
// 转换为元
|
||||
double price = BigDecimal.valueOf(totalPrice).divide(BigDecimal.valueOf(100)).setScale(2, BigDecimal.ROUND_HALF_UP).doubleValue();
|
||||
|
||||
WalletRechargeInvoiceEntityVo result = new WalletRechargeInvoiceEntityVo();
|
||||
result.setApplyId(applyDetail.getId());
|
||||
result.setCode(getInvoiceCode());
|
||||
result.setTime(applyDetail.getApplyTime());
|
||||
result.setDeptOrUser(userInfo.getSysUser().getName());
|
||||
result.setTotalPrice(totalPrice);
|
||||
result.setTotalPriceCnStr(ConvertCnPriceUtil.convert(String.valueOf(price)));
|
||||
result.setPayeeDept(walletSetting.getTopupDeptStr());
|
||||
result.setPayeeUser(payeeUser);
|
||||
result.setStatus(WalletRechargeInvoiceStatusEnum.DEFAULT.getCode());
|
||||
result.setRemark("");
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取发票代码
|
||||
*/
|
||||
@Override
|
||||
public String getInvoiceCode() {
|
||||
Long count = baseMapper.selectAllCount();
|
||||
count += 1;
|
||||
return String.format("%07d", count);
|
||||
}
|
||||
}
|
||||
+92
@@ -0,0 +1,92 @@
|
||||
package com.bsd.pjcloud.wallet.utils;
|
||||
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
/**
|
||||
* 把数字金额转换为中文的大写金额
|
||||
*/
|
||||
public class ConvertCnPriceUtil {
|
||||
private static final Pattern AMOUNT_PATTERN = Pattern.compile("^(0|[1-9]\\d{0,11})\\.(\\d\\d)$"); // 不考虑分隔符的正确性
|
||||
private static final char[] RMB_NUMS = "零壹贰叁肆伍陆柒捌玖".toCharArray();
|
||||
private static final String[] UNITS = {"元", "角", "分", "整"};
|
||||
private static final String[] U1 = {"", "拾", "佰", "仟"};
|
||||
private static final String[] U2 = {"", "万", "亿"};
|
||||
|
||||
/**
|
||||
* 将金额(整数部分等于或少于12位,小数部分2位)转换为中文大写形式.
|
||||
*
|
||||
* @param amount 金额数字
|
||||
* @return 中文大写
|
||||
* @throws IllegalArgumentException
|
||||
*/
|
||||
public static String convert(String amount) throws IllegalArgumentException {
|
||||
// 去掉分隔符
|
||||
amount = amount.replace(",", "");
|
||||
|
||||
// 验证金额正确性
|
||||
if (amount.equals("0.00")) {
|
||||
throw new IllegalArgumentException("金额不能为零.");
|
||||
}
|
||||
Matcher matcher = AMOUNT_PATTERN.matcher(amount);
|
||||
if (!matcher.find()) {
|
||||
throw new IllegalArgumentException("输入金额有误.");
|
||||
}
|
||||
|
||||
String integer = matcher.group(1); // 整数部分
|
||||
String fraction = matcher.group(2); // 小数部分
|
||||
|
||||
String result = "";
|
||||
if (!integer.equals("0")) {
|
||||
result += integer2rmb(integer) + UNITS[0]; // 整数部分
|
||||
}
|
||||
if (fraction.equals("00")) {
|
||||
result += UNITS[3]; // 添加[整]
|
||||
} else if (fraction.startsWith("0") && integer.equals("0")) {
|
||||
result += fraction2rmb(fraction).substring(1); // 去掉分前面的[零]
|
||||
} else {
|
||||
result += fraction2rmb(fraction); // 小数部分
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
// 将金额小数部分转换为中文大写
|
||||
private static String fraction2rmb(String fraction) {
|
||||
char jiao = fraction.charAt(0); // 角
|
||||
char fen = fraction.charAt(1); // 分
|
||||
return (RMB_NUMS[jiao - '0'] + (jiao > '0' ? UNITS[1] : ""))
|
||||
+ (fen > '0' ? RMB_NUMS[fen - '0'] + UNITS[2] : "");
|
||||
}
|
||||
|
||||
// 将金额整数部分转换为中文大写
|
||||
private static String integer2rmb(String integer) {
|
||||
StringBuilder buffer = new StringBuilder();
|
||||
// 从个位数开始转换
|
||||
int i, j;
|
||||
for (i = integer.length() - 1, j = 0; i >= 0; i--, j++) {
|
||||
char n = integer.charAt(i);
|
||||
if (n == '0') {
|
||||
// 当n是0且n的右边一位不是0时,插入[零]
|
||||
if (i < integer.length() - 1 && integer.charAt(i + 1) != '0') {
|
||||
buffer.append(RMB_NUMS[0]);
|
||||
}
|
||||
// 插入[万]或者[亿]
|
||||
if (j % 4 == 0) {
|
||||
if (i > 0 && integer.charAt(i - 1) != '0'
|
||||
|| i > 1 && integer.charAt(i - 2) != '0'
|
||||
|| i > 2 && integer.charAt(i - 3) != '0') {
|
||||
buffer.append(U2[j / 4]);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if (j % 4 == 0) {
|
||||
buffer.append(U2[j / 4]); // 插入[万]或者[亿]
|
||||
}
|
||||
buffer.append(U1[j % 4]); // 插入[拾]、[佰]或[仟]
|
||||
buffer.append(RMB_NUMS[n - '0']); // 插入数字
|
||||
}
|
||||
}
|
||||
return buffer.reverse().toString();
|
||||
}
|
||||
}
|
||||
+9
-3
@@ -2,8 +2,8 @@
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
|
||||
<mapper namespace="com.bsd.pjcloud.wallet.mapper.recharge.WalletRechargeInvoiceMapper">
|
||||
|
||||
<resultMap id="walletRechargeInvoiceMap" type="com.bsd.pjcloud.wallet.api.entity.recharge.WalletRechargeInvoiceEntity">
|
||||
<resultMap id="walletRechargeInvoiceMap"
|
||||
type="com.bsd.pjcloud.wallet.api.entity.recharge.WalletRechargeInvoiceEntity">
|
||||
<id property="id" column="id"/>
|
||||
<result property="applyId" column="apply_id"/>
|
||||
<result property="code" column="code"/>
|
||||
@@ -20,5 +20,11 @@
|
||||
<result property="updateTime" column="update_time"/>
|
||||
<result property="delFlag" column="del_flag"/>
|
||||
<result property="tenantId" column="tenant_id"/>
|
||||
</resultMap>
|
||||
</resultMap>
|
||||
|
||||
<select id="selectAllCount" resultType="java.lang.Long">
|
||||
SELECT COUNT(0)
|
||||
FROM wallet_recharge_invoice
|
||||
</select>
|
||||
|
||||
</mapper>
|
||||
Reference in new issue
Block a user