feat:最多提交10次申请

This commit is contained in:
dzc committed 2025-06-25 14:25:30 +08:00
1 parent 449ab71c49
commit bb9f0dd5cd
11 files changed
+100 -15

No files matched your search

@@ -29,7 +29,7 @@ import java.util.Map;
@SpringBootTest(classes = ThirdPartyApp.class)
public class PayTest {
// private final String baseUrl = "http://123.156.230.15:8089/api";
// private final String baseUrl = "http://59.202.170.152:81/api";
// private final String baseUrl = "http://127.0.0.1:9999";
private final String baseUrl = "https://stgl.pj.gov.cn/api";
@@ -67,7 +67,7 @@ public class PayTest {
Map<String, Object> paramsMap = new HashMap<>();
paramsMap.put("signPhone", LbRetailSignUtils.sm4Encrypt("17683843144", appM4KeyProd));
// paramsMap.put("signPhone", "8KKubCKESDN5TlUl3i0HaQ==");
paramsMap.put("userId", 1875049673022279681L);
// paramsMap.put("userId", 1875049673022279681L);
String body = JSONUtil.toJsonStr(paramsMap);
// 发送请求
String res = HttpRequest.post(baseUrl + walletInfoUrl).contentType("application/json").header(apiCountersignProd(body)).body(body).execute().body();
@@ -10,7 +10,7 @@ import java.util.List;
@Getter
@AllArgsConstructor
public enum WalletBizRechargeEnum {
ADD("1", "添加"),
ADD("1", "充值"),
REDUCTION("2", "记账扣款"),
RETURN_CANTEEN("3", "退还各自食堂"),
;
@@ -0,0 +1,17 @@
package com.bsd.pjcloud.wallet.api.dto.recharge;
import com.bsd.pjcloud.wallet.api.vo.recharge.WalletRechargeInvoiceEntityVo;
import lombok.Data;
/**
* 充值记录绑定发票
*/
@Data
public class WalletRechargeBindInvoiceDto extends WalletRechargeInvoiceEntityVo {
/**
* 充值/扣款申请id
*/
private Long applyId;
}
@@ -40,6 +40,12 @@ public class WalletRechargeApplyEntity extends Model<WalletRechargeApplyEntity>
@Schema(description = "流程id")
private String processId;
/**
* 绑定发票id
*/
@Schema(description = "绑定发票id")
private Long invoiceId;
/**
* 流程状态
*/
@@ -88,9 +88,9 @@ public class WalletRechargeInvoiceEntity extends Model<WalletRechargeInvoiceEnti
private String status;
/**
* 发票图片地址
* 发票图片地址(不盖章)
*/
@Schema(description = "发票图片地址")
@Schema(description = "发票图片地址(不盖章)")
private String picUrl;
/**
@@ -54,7 +54,6 @@ public class WalletRechargeApplyController {
return R.ok(walletTransactionComposeService.pageJoin(page, dto));
}
@Operation(summary = "提交申请", description = "提交申请")
@SysLog("提交申请")
@GetMapping("/apply")
@@ -7,9 +7,11 @@ import com.baomidou.mybatisplus.core.toolkit.Wrappers;
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.dto.recharge.WalletRechargeBindInvoiceDto;
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 jakarta.validation.Valid;
import org.springframework.security.access.prepost.PreAuthorize;
import com.bsd.pjcloud.common.excel.annotation.ResponseExcel;
import io.swagger.v3.oas.annotations.security.SecurityRequirement;
@@ -21,7 +23,6 @@ import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;
import java.util.List;
import java.util.Objects;
/**
* 充值/扣款申请发票记录
@@ -41,6 +42,13 @@ public class WalletRechargeInvoiceController {
return R.ok(walletRechargeInvoiceService.getInvoice(id));
}
@PostMapping("/bind-invoice")
@Operation(summary = "绑定发票")
public R bindInvoice(@Valid @RequestBody WalletRechargeBindInvoiceDto dto) {
walletRechargeInvoiceService.bindInvoice(dto);
return R.ok();
}
@Operation(summary = "分页查询", description = "分页查询")
@GetMapping("/page")
@PreAuthorize("@pms.hasPermission('wallet_walletRechargeInvoice_view')")
@@ -1,8 +1,10 @@
package com.bsd.pjcloud.wallet.service;
import com.baomidou.mybatisplus.extension.service.IService;
import com.bsd.pjcloud.wallet.api.dto.recharge.WalletRechargeBindInvoiceDto;
import com.bsd.pjcloud.wallet.api.entity.recharge.WalletRechargeInvoiceEntity;
import com.bsd.pjcloud.wallet.api.vo.recharge.WalletRechargeInvoiceEntityVo;
import jakarta.validation.Valid;
public interface WalletRechargeInvoiceService extends IService<WalletRechargeInvoiceEntity> {
@@ -15,4 +17,9 @@ public interface WalletRechargeInvoiceService extends IService<WalletRechargeInv
* 获取发票代码
*/
String getInvoiceCode();
/**
* 绑定发票
*/
void bindInvoice(@Valid WalletRechargeBindInvoiceDto dto);
}
@@ -197,7 +197,7 @@ public class WalletRechargeApplyServiceImpl extends ServiceImpl<WalletRechargeAp
}
// 判断之前有没有在审核的
if (isCheckData(detail.getUserId())) {
throw new RuntimeException("最多提交3个申请,请勿重复提交");
throw new RuntimeException("最多提交10个申请,请勿重复提交");
}
// 查询用户
UserInfo user = userService.getInnerByUserId(detail.getUserId()).getData();
@@ -487,7 +487,7 @@ public class WalletRechargeApplyServiceImpl extends ServiceImpl<WalletRechargeAp
private boolean isCheckData(Long walletId) {
Long count = baseMapper.selectCount(new LambdaQueryWrapper<WalletRechargeApplyEntity>().eq(WalletRechargeApplyEntity::getUserId, walletId).eq(WalletRechargeApplyEntity::getProcessStatus, NodeStatusEnum.JXZ.getCode()));
return count >= 3;
return count >= 10;
}
/**
@@ -1,15 +1,19 @@
package com.bsd.pjcloud.wallet.service.impl.recharge;
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.date.DatePattern;
import cn.hutool.core.date.LocalDateTimeUtil;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.json.JSONUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
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.WalletBizRechargeEnum;
import com.bsd.pjcloud.wallet.api.constant.WalletRechargeInvoiceStatusEnum;
import com.bsd.pjcloud.wallet.api.dto.recharge.WalletRechargeBindInvoiceDto;
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;
@@ -17,6 +21,7 @@ import com.bsd.pjcloud.wallet.api.feign.RemoteWalletSettingService;
import com.bsd.pjcloud.wallet.api.vo.WalletSettingVo;
import com.bsd.pjcloud.wallet.api.vo.recharge.WalletRechargeInvoiceEntityItemVo;
import com.bsd.pjcloud.wallet.api.vo.recharge.WalletRechargeInvoiceEntityVo;
import com.bsd.pjcloud.wallet.mapper.recharge.WalletRechargeApplyMapper;
import com.bsd.pjcloud.wallet.mapper.recharge.WalletRechargeImportMapper;
import com.bsd.pjcloud.wallet.mapper.recharge.WalletRechargeInvoiceMapper;
import com.bsd.pjcloud.wallet.service.WalletRechargeApplyService;
@@ -24,8 +29,10 @@ import com.bsd.pjcloud.wallet.service.WalletRechargeInvoiceService;
import com.bsd.pjcloud.wallet.utils.ConvertCnPriceUtil;
import lombok.AllArgsConstructor;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.util.List;
/**
@@ -36,6 +43,7 @@ import java.util.List;
public class WalletRechargeInvoiceServiceImpl extends ServiceImpl<WalletRechargeInvoiceMapper, WalletRechargeInvoiceEntity> implements WalletRechargeInvoiceService {
private final WalletRechargeImportMapper importMapper;
private final WalletRechargeApplyMapper applyMapper;
private final WalletRechargeApplyService applyService;
@@ -49,8 +57,9 @@ public class WalletRechargeInvoiceServiceImpl extends ServiceImpl<WalletRecharge
public WalletRechargeInvoiceEntityVo getInvoice(Long id) {
// 查询申请记录
WalletRechargeApplyEntity applyDetail = applyService.getById(id);
WalletBizRechargeEnum bizEnum = WalletBizRechargeEnum.valueOfByType(applyDetail.getBizType());
if (ObjectUtil.isEmpty(applyDetail)) {
throw new RuntimeException(" 批量充值/扣款申请不存在");
throw new RuntimeException("批量充值/扣款申请不存在");
}
// 查询申请记录有没有编辑过
if (!ObjectUtil.isAllNotEmpty(applyDetail.getImportTime(), applyDetail.getWalletTypeId())) {
@@ -60,6 +69,20 @@ public class WalletRechargeInvoiceServiceImpl extends ServiceImpl<WalletRecharge
if (ObjectUtil.notEqual(applyDetail.getProcessStatus(), TaskCheckStatusEnum.PADDING.getCode())) {
throw new RuntimeException("只有申请中才能获取发票");
}
// 先去查询有没有已经生产的发票
WalletRechargeInvoiceEntityVo result = new WalletRechargeInvoiceEntityVo();
WalletRechargeInvoiceEntity InvoiceEntity = baseMapper.selectOne(new LambdaQueryWrapper<WalletRechargeInvoiceEntity>()
.eq(WalletRechargeInvoiceEntity::getApplyId, id)
.eq(WalletRechargeInvoiceEntity::getStatus, WalletRechargeInvoiceStatusEnum.DEFAULT.getCode())
);
if (ObjectUtil.isNotEmpty(InvoiceEntity)) {
result = BeanUtil.copyProperties(InvoiceEntity, WalletRechargeInvoiceEntityVo.class);
Double price = BigDecimal.valueOf(result.getTotalPrice()).divide(BigDecimal.valueOf(100), 2, RoundingMode.HALF_UP).doubleValue();
result.setTotalPriceCnStr(ConvertCnPriceUtil.convert(String.valueOf(price)));
return result;
}
// 获取配置
WalletSettingVo walletSetting = remoteWalletSettingService.get().getData();
// 查询申请人
@@ -79,13 +102,13 @@ public class WalletRechargeInvoiceServiceImpl extends ServiceImpl<WalletRecharge
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();
Double price = BigDecimal.valueOf(totalPrice).divide(BigDecimal.valueOf(100), 2, RoundingMode.HALF_UP).doubleValue();
// 生成款项
WalletRechargeInvoiceEntityItemVo item = new WalletRechargeInvoiceEntityItemVo();
item.setName(LocalDateTimeUtil.format(applyDetail.getImportTime(), DatePattern.NORM_MONTH_PATTERN));
String itemName = LocalDateTimeUtil.format(applyDetail.getImportTime(), DatePattern.NORM_DATE_PATTERN) + "," + bizEnum.getDesc() + price + "元";
item.setName(itemName);
item.setPrice(price);
WalletRechargeInvoiceEntityVo result = new WalletRechargeInvoiceEntityVo();
result.setApplyId(applyDetail.getId());
result.setCode(getInvoiceCode());
result.setTime(applyDetail.getApplyTime());
@@ -95,9 +118,9 @@ public class WalletRechargeInvoiceServiceImpl extends ServiceImpl<WalletRecharge
result.setPayeeDept(walletSetting.getTopupDeptStr());
result.setPayeeUser(payeeUser);
result.setStatus(WalletRechargeInvoiceStatusEnum.DEFAULT.getCode());
result.setItemJson(JSONUtil.toJsonStr(item));
result.setItemJson(JSONUtil.toJsonStr(List.of(item)));
result.setRemark("");
return null;
return result;
}
/**
@@ -109,4 +132,18 @@ public class WalletRechargeInvoiceServiceImpl extends ServiceImpl<WalletRecharge
count += 1;
return String.format("%07d", count);
}
/**
* 绑定发票
*/
@Override
@Transactional(rollbackFor = Exception.class)
public void bindInvoice(WalletRechargeBindInvoiceDto dto) {
WalletRechargeInvoiceEntity entity = BeanUtil.toBean(dto, WalletRechargeInvoiceEntityVo.class);
baseMapper.insertOrUpdate(entity);
LambdaUpdateWrapper<WalletRechargeApplyEntity> updateWrapper = new LambdaUpdateWrapper<WalletRechargeApplyEntity>()
.set(WalletRechargeApplyEntity::getInvoiceId, entity.getId())
.eq(WalletRechargeApplyEntity::getId, entity.getApplyId());
applyMapper.update(updateWrapper);
}
}
@@ -24,6 +24,13 @@ public class ConvertCnPriceUtil {
// 去掉分隔符
amount = amount.replace(",", "");
String[] split = amount.split("\\.");
if (split.length > 1) {
if (split[1].length() == 1) {
amount = amount + "0";
}
}
// 验证金额正确性
if (amount.equals("0.00")) {
throw new IllegalArgumentException("金额不能为零.");
@@ -89,4 +96,8 @@ public class ConvertCnPriceUtil {
}
return buffer.reverse().toString();
}
public static void main(String[] args) {
System.out.println(convert("55.00"));
}
}