From 5e3fa361990b97bdc0f4d41b112ca1b713fab7ad Mon Sep 17 00:00:00 2001 From: 无关风月 <443237572@qq.com> Date: 星期三, 26 三月 2025 16:59:46 +0800 Subject: [PATCH] Merge branch 'master' of https://gitee.com/xiaochen991015/xizang --- ruoyi-admin/src/main/java/com/ruoyi/web/controller/api/ScreenController.java | 193 ++++++++++- ruoyi-common/src/main/java/com/ruoyi/common/utils/TencentMailUtil.java | 12 ruoyi-system/src/main/java/com/ruoyi/system/dto/TContractDTO.java | 2 ruoyi-admin/src/main/java/com/ruoyi/web/controller/api/BankOutController.java | 201 +++++++++++ ruoyi-system/src/main/java/com/ruoyi/system/service/impl/TBillServiceImpl.java | 113 +++--- ruoyi-system/src/main/java/com/ruoyi/system/vo/HouseMapDistributionVO.java | 35 ++ ruoyi-common/src/main/java/com/ruoyi/common/utils/SecurityUtils.java | 6 ruoyi-system/src/main/java/com/ruoyi/system/vo/RealTimeRentDataVO.java | 28 + ruoyi-admin/src/main/java/com/ruoyi/web/controller/api/TContractController.java | 232 ++++++++++--- ruoyi-system/src/main/java/com/ruoyi/system/service/impl/ScreenService.java | 3 ruoyi-system/src/main/java/com/ruoyi/system/vo/YearQuarter.java | 31 + ruoyi-system/src/main/java/com/ruoyi/system/service/impl/FlowListenerService.java | 24 + ruoyi-system/src/main/java/com/ruoyi/system/model/TTenant.java | 4 ruoyi-system/src/main/java/com/ruoyi/system/model/TContract.java | 19 ruoyi-system/src/main/java/com/ruoyi/system/dto/TerminateContractDTO.java | 6 15 files changed, 745 insertions(+), 164 deletions(-) diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/api/BankOutController.java b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/api/BankOutController.java index 56ef4cd..b45ecd7 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/api/BankOutController.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/api/BankOutController.java @@ -6,6 +6,7 @@ import com.alibaba.fastjson.TypeReference; import com.ruoyi.common.constant.AmountConstant; import com.ruoyi.common.enums.BillTypeEnum; +import com.ruoyi.common.exception.ServiceException; import com.ruoyi.common.utils.StringUtils; import com.ruoyi.system.dto.TBillDto; import com.ruoyi.system.model.TOrderBill; @@ -13,9 +14,7 @@ import com.ruoyi.system.service.TBillService; import com.ruoyi.system.service.TOrderBillService; import com.ruoyi.system.service.TPayOrderService; -import com.taxi591.bankapi.dto.CovertPayBackResult; -import com.taxi591.bankapi.dto.QueryBillRequest; -import com.taxi591.bankapi.dto.QueryBillResponse; +import com.taxi591.bankapi.dto.*; import com.taxi591.bankapi.service.BankService; import com.taxi591.bankapi.service.SignatureAndVerification; import lombok.extern.slf4j.Slf4j; @@ -28,9 +27,14 @@ import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; +import java.io.BufferedReader; +import java.io.IOException; +import java.io.InputStreamReader; import java.math.BigDecimal; import java.math.RoundingMode; import java.util.*; +import java.util.regex.Matcher; +import java.util.regex.Pattern; import java.util.stream.Collectors; import java.util.stream.Stream; @@ -54,13 +58,188 @@ @Autowired TPayOrderService payOrderService; + public static String getRequestBody(HttpServletRequest request) + throws IOException { + /** 读取httpbody内容 */ + StringBuilder httpBody = new StringBuilder(); + BufferedReader br = null; + try { + br = new BufferedReader(new InputStreamReader( + request.getInputStream())); + String line = null; + while ((line = br.readLine()) != null) { + httpBody.append(line); + } + } catch (IOException ex) { + throw ex; + } finally { + if (br != null) { + try { + br.close(); + } catch (IOException ex) { + ex.printStackTrace(); + } + } + } + return httpBody.toString(); + } + @PostMapping(value = "payCallback") - public @ResponseBody String payCallback(HttpServletRequest request){ - CovertPayBackResult result = bankService.covertPayCallBack(request, (billRequest) -> { - tBillService.completePay(billRequest); - return true; - }); - return result.getBack(); + public void payCallback(HttpServletRequest servletRequest,HttpServletResponse servletResponse){ + String request = null; + String responseJson = null; + try { + log.info("--------进入getRequest4Sale----------------------------------"); + // 接收报文 + String requestContent = getRequestBody(servletRequest).trim(); + String signatureString = requestContent.substring(0, + requestContent.indexOf("||")); + log.info("-----ChargeBillController------------截取报文的signatureString:{}", signatureString); + String requestBody = requestContent.substring(signatureString + .length() + 2); + log.info("-----ChargeBillController------------截取报文的requestBody:{}", requestBody); + //如果有双引号,则截取双引号内requestBody的内容 + Pattern p=Pattern.compile("\""); + Matcher m=p.matcher(requestBody); + while(m.find()){ + requestBody=requestBody.replace(m.group(), ""); + log.info("-----ChargeBillController------如果有双引号,则截取后的requestBody:{}", requestBody); + } + //requestBody是base64加密后的数据,需解析出来 + request = new String( + com.alibaba.fastjson.util.Base64.decodeFast(requestBody)); + log.info("-----ChargeBillController------------解析完成后的requestBody-------{}" + request); + ChargeBillRequest chargeBillRequest = JSON.parseObject(request, + new TypeReference<ChargeBillRequest>() { + }); + boolean b = signatureAndVerification.read_cer_and_verify_sign(requestBody, + signatureString); + if (!b){ + throw new ServiceException("验签失败"); + } + /** 销账报文重发次数,通过resendTimes此字段识别销账报文是否为重发的,0表示首次、1表示重发一次,2表示重发2次,最多重发3次*/ + if(chargeBillRequest!=null && "0".equals(chargeBillRequest.getMessage().getInfo().getResendTimes())){ + ChargeBillResponse chargeBillResponse = new ChargeBillResponse( + chargeBillRequest); + ChargeBillResponse.Message respMessage = chargeBillResponse + .getMessage(); + ChargeBillResponse.Message.Head respHead = chargeBillResponse + .getMessage().getHead(); + ChargeBillResponse.Message.Info respInfo = chargeBillResponse + .getMessage().getInfo(); + respHead.setTransFlag("02"); + respHead.setTimeStamp(DateUtil.format(new Date(),"yyyyMMddHHmmssSSS")); + // respHead.setChannel("MBNK"); + respHead.setChannel(chargeBillRequest.getMessage().getHead() + .getChannel()); + // respHead.setTranCode("chargeBill"); + respHead.setTransCode(chargeBillRequest.getMessage().getHead() + .getTransCode()); + respHead.setTransSeqNum(chargeBillRequest.getMessage().getHead() + .getTransSeqNum()); + //测试销账返回报文中,本来是销账成功的报文,但是不要送0000成功码 (JF190510134746710555这个流水号是在Demo的returnCode设置成null的时候产生的,流水状态为6;) + + String epayCode = chargeBillRequest.getMessage().getInfo() + .getEpayCode(); + String traceNo = chargeBillRequest.getMessage().getInfo() + .getTraceNo(); + String numOpenMerchantOrder = chargeBillRequest.getMessage() + .getInfo().getNumOpenMerchantOrder(); + respInfo.setNumOpenMerchantOrder(numOpenMerchantOrder); + respInfo.setEpayCode(epayCode); + respInfo.setTraceNo(traceNo); + + try{ + tBillService.completePay(chargeBillRequest); + respHead.setReturnCode("0000"); + respHead.setReturnMessage("账单缴费成功"); + }catch (Exception e){ + respHead.setReturnCode("1111"); + respHead.setReturnMessage("账单处理失败"); + log.error("支付第一次回调出现异常,{}",request,e); + } + //第一次处理失败,不退款 + respInfo.setRefundFlag("false"); + respMessage.setInfo(respInfo); + respMessage.setHead(respHead); + chargeBillResponse.setMessage(respMessage); + responseJson = JSON.toJSONString(chargeBillResponse); + //加签名 + String signatrue = signatureAndVerification + .signWhithsha1withrsa(responseJson); + log.info("-----ChargeBillController------------responseJson打印结果是(responseJson加密前):" + responseJson); + responseJson = signatrue + "||" + + new String(Base64.encodeBase64(responseJson.getBytes("utf-8"))); + log.info("-----ChargeBillController------------responseJson打印结果是(responseJson加密后):" + responseJson); + servletResponse.setCharacterEncoding("utf-8"); + servletResponse.setContentType("text/plain"); + servletResponse.getWriter().write(responseJson); + }else{ + //销账报文重发次数,通过resendTimes此字段识别销账报文是否为重发的,0表示首次、1表示重发一次,2表示重发2次,最多重发3次 + //商户端要注意销账重复通知的情况,要进行订单唯一性处理 + + + ChargeBillResponse chargeBillResponse = new ChargeBillResponse( + chargeBillRequest); + ChargeBillResponse.Message respMessage = chargeBillResponse + .getMessage(); + ChargeBillResponse.Message.Head respHead = chargeBillResponse + .getMessage().getHead(); + ChargeBillResponse.Message.Info respInfo = chargeBillResponse + .getMessage().getInfo(); + respHead.setTransFlag("02"); + respHead.setTimeStamp(DateUtil.format(new Date(),"yyyyMMddHHmmssSSS")); + // respHead.setChannel("MBNK"); + respHead.setChannel(chargeBillRequest.getMessage().getHead() + .getChannel()); + // respHead.setTranCode("chargeBill"); + respHead.setTransCode(chargeBillRequest.getMessage().getHead() + .getTransCode()); + respHead.setTransSeqNum(chargeBillRequest.getMessage().getHead() + .getTransSeqNum()); + try{ + tBillService.completePay(chargeBillRequest); + respHead.setReturnCode("0000"); + respHead.setReturnMessage("账单缴费成功"); + }catch (Exception e){ + respHead.setReturnCode("1111"); + respHead.setReturnMessage("账单处理失败"); + log.error("支付第一次回调出现异常,{}",request,e); + } + // 再次推送未处理成功,则返回退款标志 + if (!"0000".equals(respHead.getReturnCode())) { + respInfo.setRefundFlag("true"); + } + String epayCode = chargeBillRequest.getMessage().getInfo() + .getEpayCode(); + String traceNo = chargeBillRequest.getMessage().getInfo() + .getTraceNo(); + String numOpenMerchantOrder = chargeBillRequest.getMessage() + .getInfo().getNumOpenMerchantOrder(); + respInfo.setNumOpenMerchantOrder(numOpenMerchantOrder); + respInfo.setEpayCode(epayCode); + respInfo.setTraceNo(traceNo); + + respMessage.setInfo(respInfo); + respMessage.setHead(respHead); + chargeBillResponse.setMessage(respMessage); + responseJson = JSON.toJSONString(chargeBillResponse); + //加签名 + String signatrue = signatureAndVerification + .signWhithsha1withrsa(responseJson); + log.info("-----ChargeBillController------------responseJson打印结果是(responseJson加密前):" + responseJson); + responseJson = signatrue + "||" + + new String(Base64.encodeBase64(responseJson.getBytes("utf-8"))); + log.info("-----ChargeBillController------------responseJson打印结果是(responseJson加密后):" + responseJson); + servletResponse.setCharacterEncoding("utf-8"); + servletResponse.setContentType("text/plain"); + servletResponse.getWriter().write(responseJson); + + } + + }catch (Exception e) { + log.error("处理支付回调发生异常:返回内容:{}",request,e); + } } @PostMapping(value = "queryBill") @@ -99,8 +278,8 @@ .getInfo(); //缴费账单子账单 ArrayList<QueryBillResponse.Message.Info.Bill> respBills = new ArrayList<QueryBillResponse.Message.Info.Bill>(); - ArrayList<QueryBillResponse.Message.Info.Bill.DescDetail> respDescDetail = - new ArrayList<QueryBillResponse.Message.Info.Bill.DescDetail>(); +// ArrayList<QueryBillResponse.Message.Info.Bill.DescDetail> respDescDetail = +// new ArrayList<QueryBillResponse.Message.Info.Bill.DescDetail>(); QueryBillResponse.Message.Info.Bill respBill = respInfo.new Bill(); //缴费子商户账单 // ArrayList<QueryBillResponse.Message.Info.Bill.SplitSubMerInfo> splitSubMerInfos = new ArrayList<QueryBillResponse.Message.Info.Bill.SplitSubMerInfo>(); diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/api/ScreenController.java b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/api/ScreenController.java index 86431c2..d12d728 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/api/ScreenController.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/api/ScreenController.java @@ -2,13 +2,17 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.ruoyi.common.core.domain.R; +import com.ruoyi.common.utils.DateUtils; +import com.ruoyi.system.model.TBill; import com.ruoyi.system.model.TContract; +import com.ruoyi.system.model.THouse; +import com.ruoyi.system.model.TStreet; +import com.ruoyi.system.service.ITStreetService; +import com.ruoyi.system.service.TBillService; import com.ruoyi.system.service.TContractService; +import com.ruoyi.system.service.THouseService; import com.ruoyi.system.service.impl.ScreenService; -import com.ruoyi.system.vo.ScreenRentIncomeTrendVO; -import com.ruoyi.system.vo.ScreenRentRankVO; -import com.ruoyi.system.vo.ScreenTopStaticsDataVO; -import com.ruoyi.system.vo.TenantCountTrendVO; +import com.ruoyi.system.vo.*; import io.swagger.annotations.Api; import io.swagger.annotations.ApiModelProperty; import io.swagger.annotations.ApiOperation; @@ -18,8 +22,13 @@ import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RestController; +import java.math.BigDecimal; +import java.time.LocalDate; +import java.time.LocalDateTime; +import java.time.YearMonth; import java.time.format.DateTimeFormatter; -import java.util.List; +import java.time.temporal.ChronoUnit; +import java.util.*; import java.util.stream.Collectors; /** @@ -32,6 +41,11 @@ @RequiredArgsConstructor(onConstructor_ = {@Lazy}) public class ScreenController { private final ScreenService screenService; + private final TContractService contractService; + private final THouseService houseService; + private final ITStreetService streetService; + private final TBillService billService; + @GetMapping("/statics-data") @ApiOperation(value = "获取顶部统计数据") public R<ScreenTopStaticsDataVO> getTopStaticsData() { @@ -47,32 +61,171 @@ public R<ScreenRentIncomeTrendVO> rentIncomeTrend() { return R.ok(screenService.rentIncomeTrend()); } - private final TContractService contractService; + @GetMapping("/getTenantCountTrend") @ApiModelProperty(value = "租户数量趋势统计") - public R<?> getTenantCountTrend() { - // 获取所有签约时间不为空的合同 - List<TContract> contracts = contractService.list(new LambdaQueryWrapper<TContract>() - .isNotNull(TContract::getSignTime)); + public R<List<TenantCountTrendVO>> getTenantCountTrend() { - // 使用年-月格式化日期,并按此分组计算每个时间段的合同数量 - DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yy-M"); + Date currentDate = new Date(); + Date targetDate = DateUtils.addMonths(currentDate, -3 * 6); + Map<String, Date> startQuarterDate = DateUtils.getQuarterDate(targetDate); + + Date targetDate2 = DateUtils.addMonths(currentDate, 0); + Map<String, Date> endQuarterDate = DateUtils.getQuarterDate(targetDate2); + + List<TContract> contracts = contractService.list(new LambdaQueryWrapper<TContract>() + .isNotNull(TContract::getSignTime) + .between(TContract::getSignTime, startQuarterDate.get("first"), endQuarterDate.get("last")) + .orderByAsc(TContract::getSignTime)); + + // 创建季度格式化工具(示例:2025-Q1) + DateTimeFormatter quarterFormatter = DateTimeFormatter.ofPattern("yyyy-'Q'Q"); List<TenantCountTrendVO> trendData = contracts.stream() - .collect(Collectors.groupingBy(contract -> contract.getSignTime().toLocalDate() - .withDayOfMonth(1) // 将日期调整为该月的第一天,以便正确分组 - .atStartOfDay())) + .collect(Collectors.groupingBy(contract -> { + LocalDate date = contract.getSignTime().toLocalDate(); + int quarter = (date.getMonthValue() - 1) / 3 + 1; + return YearQuarter.from(date.withMonth(quarter * 3 - 2)); + }, TreeMap::new, Collectors.counting())) .entrySet().stream() - .map(entry -> { - String period = entry.getKey().format(formatter); - long count = entry.getValue().size(); - return new TenantCountTrendVO(period, count); - }) + .map(entry -> new TenantCountTrendVO( + entry.getKey().format(quarterFormatter), + entry.getValue())) .collect(Collectors.toList()); return R.ok(trendData); } + /** + * 实时租赁数据 + */ + @GetMapping("/getRealTimeRentData") + public R<List<RealTimeRentDataVO>> getRealTimeRentData() { + // 随机获取十条房源 + List<THouse> houses = houseService.list(new LambdaQueryWrapper<THouse>() + .last("ORDER BY RAND() LIMIT 10")); + + + // 提取streetIds + List<String> streetIds = houses.stream() + .map(THouse::getStreetId) + .collect(Collectors.toList()); + + // 获取街道信息 + Map<String, String> streetMap = streetService.listByIds(streetIds).stream() + .collect(Collectors.toMap(TStreet::getId, TStreet::getStreetName)); + + // 转换为返回格式 + List<RealTimeRentDataVO> result = houses.stream().map(house -> { + RealTimeRentDataVO vo = new RealTimeRentDataVO(); + vo.setStreetName(streetMap.getOrDefault(house.getStreetId(), "未知")); + vo.setRoomName(house.getRoomNumber()); + vo.setLeaseStatus(house.getLeaseStatus()); + return vo; + }).collect(Collectors.toList()); + + return R.ok(result); + } + + /** + * 获取房屋地图分布 + */ + @GetMapping("/getHouseMapDistribution") + public R<List<HouseMapDistributionVO>> getHouseMapDistribution() { + // 获取所有房屋信息 + List<THouse> houses = houseService.list(); + List<HouseMapDistributionVO> result = new ArrayList<>(); + for (THouse house : houses) { + HouseMapDistributionVO houseMapDistributionVO = new HouseMapDistributionVO(); + houseMapDistributionVO.setHouseName(house.getHouseName()); + houseMapDistributionVO.setHouseAddress(house.getHouseAddress()); + houseMapDistributionVO.setHouseStatus(house.getLeaseStatus()); + TContract contract = contractService.getOne(new LambdaQueryWrapper<TContract>() + .eq(TContract::getHouseId, house.getId())); + TBill bill = billService.getOne(new LambdaQueryWrapper<TBill>() + .eq(TBill::getContractId, contract.getId()) + .eq(TBill::getBillType, 1)); + + + houseMapDistributionVO.setTenant(contract.getPartyTwoName()); + + + LocalDateTime startTime = contract.getStartTime(); + LocalDateTime endTime = contract.getEndTime(); + BigDecimal monthRent = contract.getMonthRent(); + // 计算相差月份 + long monthsBetween = ChronoUnit.MONTHS.between(startTime, endTime); + BigDecimal payableFeesMoney = monthRent.multiply(new BigDecimal(monthsBetween)); + BigDecimal remainingPayment = bill.getPayableFeesMoney(); + BigDecimal paidAlready = payableFeesMoney.subtract(remainingPayment); + String rentStatus = String.format("%.2f/%.2f", paidAlready, payableFeesMoney); + houseMapDistributionVO.setRentStatus(rentStatus); + + String payType = contract.getPayType(); + String rent = ""; + LocalDateTime payFeesTime = bill.getPayFeesTime(); + switch (payType) { + case "1": + if (isCurrentMonth(payFeesTime)) { + rent = String.format("%.2f/%.2f", monthRent, monthRent); + } else { + rent = String.format("%.2f/%.2f", new BigDecimal("0"), monthRent); + } + break; + case "2": + // 季付价格 + BigDecimal quarterRent = monthRent.multiply(new BigDecimal(3)); + if (isCurrentQuarter(payFeesTime)) { + rent = String.format("%.2f/%.2f", quarterRent, quarterRent); + } else { + rent = String.format("%.2f/%.2f", new BigDecimal("0"), quarterRent); + } + break; + case "3": + // 年付价格 + BigDecimal yearRent = monthRent.multiply(new BigDecimal(12)); + if (isCurrentYear(payFeesTime)) { + rent = String.format("%.2f/%.2f", yearRent, yearRent); + } else { + rent = String.format("%.2f/%.2f", new BigDecimal("0"), yearRent); + } + break; + } + houseMapDistributionVO.setRent(rent); + houseMapDistributionVO.setLongitude(house.getLongitude()); + houseMapDistributionVO.setLatitude(house.getLatitude()); + result.add(houseMapDistributionVO); + } + return R.ok(result); + } + + + /** + * 判断是否是当前月份 + * @param dateTime 日期时间 + * @return boolean + */ + public static boolean isCurrentMonth(LocalDateTime dateTime) { + YearMonth currentYearMonth = YearMonth.now(); + YearMonth targetYearMonth = YearMonth.from(dateTime); + return currentYearMonth.equals(targetYearMonth); + } + + public static boolean isCurrentQuarter(LocalDateTime dateTime) { + int currentMonth = LocalDateTime.now().getMonthValue(); + int targetMonth = dateTime.getMonthValue(); + + // 计算当前季度和目标时间所属季度 + int currentQuarter = (currentMonth - 1) / 3 + 1; + int targetQuarter = (targetMonth - 1) / 3 + 1; + + return LocalDateTime.now().getYear() == dateTime.getYear() && currentQuarter == targetQuarter; + } + + public static boolean isCurrentYear(LocalDateTime dateTime) { + return LocalDateTime.now().getYear() == dateTime.getYear(); + } + } diff --git a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/api/TContractController.java b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/api/TContractController.java index 514ee6f..5e0643f 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/web/controller/api/TContractController.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/web/controller/api/TContractController.java @@ -3,6 +3,7 @@ import cn.afterturn.easypoi.excel.ExcelExportUtil; import cn.afterturn.easypoi.excel.entity.ExportParams; +import cn.hutool.core.bean.BeanUtil; import com.aizuda.bpm.engine.entity.FlwTask; import com.aizuda.bpm.mybatisplus.mapper.FlwTaskMapper; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; @@ -49,6 +50,7 @@ import javax.servlet.http.HttpServletResponse; import java.io.IOException; import java.math.BigDecimal; +import java.math.RoundingMode; import java.net.URLEncoder; import java.time.LocalDateTime; import java.time.temporal.ChronoUnit; @@ -297,69 +299,185 @@ List<TContract> list = contractService.lambdaQuery().in(TContract::getId, dto.getIds()).list(); List<String> res = new ArrayList<>(); for (TContract contract : list) { - String templateFileName = "1_yzj_租赁合同_个人.docx"; - TBill firstBill = billService.lambdaQuery().eq(TBill::getContractId, contract.getId()) - .orderByDesc(TBill::getStartTime).last("limit 1").one(); - TTenant tenant = tenantService.getById(contract.getTenantId()); - THouse tHouse = houseService.getById(contract.getHouseId()); - Map<String, Object> templateParam = new HashMap<>(5); - templateParam.put("${contractNumber}", contract.getContractNumber()); - templateParam.put("${partyOneName}", contract.getPartyOneName()); - templateParam.put("${partyTwoName}", contract.getPartyTwoName()); - if (Objects.nonNull(tenant)) { - templateParam.put("${mailAddress}", StringUtils.isNotBlank(tenant.getMailAddress()) ? tenant.getMailAddress() : ""); - templateParam.put("${idCard}", StringUtils.isNotBlank(tenant.getIdCard()) ? tenant.getIdCard() : ""); - //企业、政府机构、国有企业 - if (tenant.getTenantType().equals("2") || tenant.getTenantType().equals("5") || tenant.getTenantType().equals("7")){ - templateParam.put("${creditCode}", StringUtils.isNotBlank(tenant.getCreditCode()) ? tenant.getCreditCode() : ""); - templateParam.put("${legalPerson}", StringUtils.isNotBlank(tenant.getLegalPerson()) ? tenant.getLegalPerson() : ""); - templateFileName = "1_yzj_租赁合同_企业.docx"; - } - } - templateParam.put("${houseAddress}", tHouse.getHouseAddress()); - templateParam.put("${houseArea}", tHouse.getHouseArea()+"m²"); - long between = ChronoUnit.DAYS.between(contract.getStartTime(), contract.getStartPayTime())+1; - templateParam.put("${day}", between); - templateParam.put("${endTimeFree}", DateUtils.localDateTimeToStringYear(contract.getStartPayTime().plusDays(1))); - templateParam.put("${startPayTime}", DateUtils.localDateTimeToStringYear(contract.getStartPayTime())); - templateParam.put("${startTime}", DateUtils.localDateTimeToStringYear(contract.getStartTime())); - templateParam.put("${endTime}", DateUtils.localDateTimeToStringYear(contract.getEndTime())); - templateParam.put("${monthRent}", "¥"+contract.getMonthRent()+"元"); - templateParam.put("${monthRentString}", "人民币"+NumberToChineseUtils.numberToChinese(contract.getMonthRent().setScale(2, BigDecimal.ROUND_DOWN).doubleValue())); - String totalYear = Objects.nonNull(contract.getTotalYear())?contract.getTotalYear().toString():""; - templateParam.put("${totalYear}", "¥"+totalYear+"元"); - String totalYearString = StringUtils.isNotEmpty(totalYear)?NumberToChineseUtils.numberToChinese(contract.getTotalYear().setScale(2, BigDecimal.ROUND_DOWN).doubleValue()):""; - templateParam.put("${totalYearString}", "人民币"+totalYearString); - templateParam.put("${payType}", contract.getPayType().equals("1")?"月":contract.getPayType().equals("2")?"季":"年"); - if(firstBill!=null){ - templateParam.put("${firstRent}", "¥"+(firstBill.getPayableFeesMoney())+"元"); - }else{ - templateParam.put("${firstRent}", ""); - - } - templateParam.put("${firstRentString}", "人民币"+NumberToChineseUtils.numberToChinese((contract.getPayType().equals("1")?contract.getMonthRent():contract.getPayType().equals("2")?contract.getMonthRent().multiply(new BigDecimal("3")):contract.getMonthRent().multiply(new BigDecimal("12")).setScale(2,BigDecimal.ROUND_DOWN)).doubleValue())); - templateParam.put("${nextPayTime}", contract.getPayType().equals("1")?"月":contract.getPayType().equals("2")?"季":"年"); - templateParam.put("${deposit}", "¥"+contract.getDeposit()+"元"); - templateParam.put("${depositString}", NumberToChineseUtils.numberToChinese(contract.getDeposit().setScale(2, BigDecimal.ROUND_DOWN).doubleValue())); - templateParam.put("${partyOnePerson}", contract.getPartyOnePerson()); - templateParam.put("${partyOnePhone}", contract.getPartyOnePhone()); - templateParam.put("${partyTwoPerson}", contract.getPartyTwoPerson()); - templateParam.put("${partyTwoPhone}", contract.getPartyTwoPhone()); - // 验收时间 - TCheckAcceptRecord tCheckAcceptRecord = checkAcceptRecordService.lambdaQuery().eq(TCheckAcceptRecord::getContractId, contract.getId()).last("limit 1").one(); - if (tCheckAcceptRecord!=null &&tCheckAcceptRecord.getCheckTime()!=null ){ - templateParam.put("${checkTime}", DateUtils.localDateTimeToStringYear(tCheckAcceptRecord.getCheckTime())); - }else{ - templateParam.put("${checkTime}", ""); - - } - String url = wordUtil.generatePdf("/usr/local/project/file/", templateFileName, templateParam, "租赁合同", "/usr/local/project/file/"); + String url = generateContract(contract); res.add(url); } return R.ok(res); } + private String generateContract(TContract contract) { + String templateFileName = "1_yzj_租赁合同_个人.docx"; + String contractId = contract.getId(); + TBill firstBill = null; + TCheckAcceptRecord tCheckAcceptRecord = null; + + if (StringUtils.isNotEmpty(contractId)) { + firstBill = billService.lambdaQuery() + .eq(TBill::getContractId, contractId) + .orderByDesc(TBill::getStartTime) + .last("limit 1") + .one(); + tCheckAcceptRecord = checkAcceptRecordService.lambdaQuery() + .eq(TCheckAcceptRecord::getContractId, contractId) + .last("limit 1") + .one(); + } + + TTenant tenant = null; + THouse tHouse = null; + if (StringUtils.isNotEmpty(contract.getTenantId())) { + tenant = tenantService.getById(contract.getTenantId()); + tHouse = houseService.getById(contract.getHouseId()); + } + + Map<String, Object> templateParam = new HashMap<>(5); + fill(templateParam, "contractNumber", contract.getContractNumber()); + fill(templateParam, "partyOneName", contract.getPartyOneName()); + fill(templateParam, "partyTwoName", contract.getPartyTwoName()); + + if (Objects.nonNull(tenant)) { + fill(templateParam, "mailAddress", tenant.getMailAddress()); + fill(templateParam, "idCard", tenant.getIdCard()); + fill(templateParam, "residentName", tenant.getResidentName()); + fill(templateParam, "bankNumber", tenant.getBankNumber()); + fill(templateParam, "bankName", tenant.getBankName()); + + // 企业、政府机构、国有企业 + if (Objects.nonNull(tenant.getTenantType()) + && (tenant.getTenantType().equals("2") + || tenant.getTenantType().equals("5") + || tenant.getTenantType().equals("7"))) { + fill(templateParam, "creditCode", tenant.getCreditCode()); + fill(templateParam, "legalPerson", tenant.getLegalPerson()); + templateFileName = "1_yzj_租赁合同_企业.docx"; + } + } + + + + if (Objects.nonNull(tHouse)) { + fill(templateParam, "houseAddress", tHouse.getHouseAddress()); + fill(templateParam, "houseArea", tHouse.getHouseArea() + "m²"); + } + + // 日期相关参数处理 + fill(templateParam, "remark", contract.getRemark()); + fill(templateParam, "houseUseScope", contract.getHouseUseScope()); + fill(templateParam, "days", ChronoUnit.DAYS.between( + contract.getStartTime(), contract.getEndTime())); + + long between = ChronoUnit.DAYS.between( + contract.getStartTime(), contract.getStartPayTime()) + 1; + fill(templateParam, "day", between); + + // 财务相关参数处理 + fill(templateParam, "endTimeFree", DateUtils.localDateTimeToStringYear( + contract.getStartPayTime().plusDays(1))); + fill(templateParam, "startPayTime", DateUtils.localDateTimeToStringYear( + contract.getStartPayTime())); + fill(templateParam, "startTime", DateUtils.localDateTimeToStringYear( + contract.getStartTime())); + fill(templateParam, "endTime", DateUtils.localDateTimeToStringYear( + contract.getEndTime())); + + // 金额格式化处理 + fill(templateParam, "monthRent", "¥" + contract.getMonthRent() + "元"); + fill(templateParam, "monthRentString", "人民币" + NumberToChineseUtils.numberToChinese( + contract.getMonthRent().setScale(2, RoundingMode.DOWN).doubleValue())); + + String totalYear = Objects.nonNull(contract.getTotalYear()) + ? contract.getTotalYear().toString() + : ""; + fill(templateParam, "totalYear", "¥" + totalYear + "元"); + + String totalYearString = StringUtils.isNotEmpty(totalYear) + ? NumberToChineseUtils.numberToChinese( + contract.getTotalYear().setScale(2, RoundingMode.DOWN).doubleValue()) + : ""; + fill(templateParam, "totalYearString", "人民币" + totalYearString); + + // 支付类型处理 + String payType = contract.getPayType().equals("1") ? "月" + : contract.getPayType().equals("2") ? "季" + : "年"; + fill(templateParam, "payType", payType); + + // 首期租金处理 + if (firstBill != null) { + fill(templateParam, "firstRent", "¥" + firstBill.getPayableFeesMoney() + "元"); + } else { + fill(templateParam, "firstRent", ""); + } + + // 其他财务字段 + fill(templateParam, "firstRentString", "人民币" + NumberToChineseUtils.numberToChinese( + (contract.getPayType().equals("1") + ? contract.getMonthRent() + : contract.getPayType().equals("2") + ? contract.getMonthRent().multiply(new BigDecimal("3")) + : contract.getMonthRent().multiply(new BigDecimal("12"))) + .setScale(2, RoundingMode.DOWN).doubleValue())); + + fill(templateParam, "firstRentString", + "人民币"+NumberToChineseUtils.numberToChinese( + (contract.getPayType().equals("1") + ? contract.getMonthRent() + :contract.getPayType().equals("2") + ?contract.getMonthRent().multiply(new BigDecimal("3")) + :contract.getMonthRent().multiply(new BigDecimal("12")) + .setScale(2, RoundingMode.DOWN)).doubleValue())); + + + + + fill(templateParam, "nextPayTime", payType); + fill(templateParam, "deposit", "¥" + contract.getDeposit() + "元"); + fill(templateParam, "depositString", NumberToChineseUtils.numberToChinese( + contract.getDeposit().setScale(2, RoundingMode.DOWN).doubleValue())); + + // 联系方式 + fill(templateParam, "partyOnePerson", contract.getPartyOnePerson()); + fill(templateParam, "partyOnePhone", contract.getPartyOnePhone()); + fill(templateParam, "partyTwoPerson", contract.getPartyTwoPerson()); + fill(templateParam, "partyTwoPhone", contract.getPartyTwoPhone()); + + // 验收时间处理 + if (tCheckAcceptRecord != null && tCheckAcceptRecord.getCheckTime() != null) { + fill(templateParam, "checkTime", DateUtils.localDateTimeToStringYear( + tCheckAcceptRecord.getCheckTime())); + } else { + fill(templateParam, "checkTime", ""); + } + + return wordUtil.generatePdf( + "/usr/local/project/file/", + templateFileName, + templateParam, + "租赁合同", + "/usr/local/project/file/"); + } + + + private void fill(Map<String, Object> templateParam, String key, Object value) { + if (StringUtils.isEmpty(key)){ + throw new RuntimeException("key不能为空"); + } + templateParam.put(StringUtils.format("${{}}", "contractNumber"), value != null ? value : ""); + } + + /** + * 生成预览版合同附件 + */ + @ApiOperation(value = "生成预览版合同附件") + @PostMapping("/generateContractPreview") + public R<String> generateContractPreview(@RequestBody TContractDTO dto) + { + TContract contract = new TContract(); + BeanUtil.copyProperties(dto,contract); + return R.ok(generateContract(contract)); + } + /** * 导出 */ diff --git a/ruoyi-common/src/main/java/com/ruoyi/common/utils/SecurityUtils.java b/ruoyi-common/src/main/java/com/ruoyi/common/utils/SecurityUtils.java index adea656..89c8853 100644 --- a/ruoyi-common/src/main/java/com/ruoyi/common/utils/SecurityUtils.java +++ b/ruoyi-common/src/main/java/com/ruoyi/common/utils/SecurityUtils.java @@ -1,6 +1,7 @@ package com.ruoyi.common.utils; import com.ruoyi.common.core.domain.model.LoginUserApplet; +import lombok.extern.slf4j.Slf4j; import org.springframework.security.core.Authentication; import org.springframework.security.core.context.SecurityContextHolder; import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder; @@ -13,6 +14,7 @@ * * @author ruoyi */ +@Slf4j public class SecurityUtils { /** @@ -56,8 +58,10 @@ } catch (Exception e) { - throw new ServiceException("获取用户账户异常", HttpStatus.UNAUTHORIZED); + log.error("获取用户信息发生异常",e); +// throw new ServiceException("获取用户账户异常", HttpStatus.UNAUTHORIZED); } + return ""; } /** * 获取用户账户小程序 diff --git a/ruoyi-common/src/main/java/com/ruoyi/common/utils/TencentMailUtil.java b/ruoyi-common/src/main/java/com/ruoyi/common/utils/TencentMailUtil.java index 64d39bb..617c714 100644 --- a/ruoyi-common/src/main/java/com/ruoyi/common/utils/TencentMailUtil.java +++ b/ruoyi-common/src/main/java/com/ruoyi/common/utils/TencentMailUtil.java @@ -14,13 +14,11 @@ import java.io.IOException; import java.io.UnsupportedEncodingException; import java.net.MalformedURLException; +import java.nio.charset.StandardCharsets; import java.nio.file.Files; import java.nio.file.Path; import java.nio.file.Paths; -import java.util.ArrayList; -import java.util.List; -import java.util.Map; -import java.util.Properties; +import java.util.*; import java.util.concurrent.CompletableFuture; @Component @@ -149,9 +147,9 @@ tempFilePath.add(Paths.get(filePath)); FileDataSource source = new FileDataSource(filePath); messageBodyPart.setDataHandler(new DataHandler(source)); - String filenameEncode = MimeUtility.encodeText(fileName, "UTF-8", "base64"); - // String encodedFileName = Base64.getEncoder().encodeToString(fileName.getBytes(StandardCharsets.UTF_8)); - // String filenameEncode = MimeUtility.encodeText(encodedFileName); + // String filenameEncode = MimeUtility.encodeText(fileName, "UTF-8", "base64"); + String encodedFileName = Base64.getEncoder().encodeToString(fileName.getBytes(StandardCharsets.UTF_8)); + String filenameEncode = MimeUtility.encodeText(encodedFileName); messageBodyPart.setFileName(filenameEncode); messageBodyPart.setHeader("Content-Transfer-Encoding", "base64"); messageBodyPart.setHeader("Content-Disposition", "attachment"); diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/dto/TContractDTO.java b/ruoyi-system/src/main/java/com/ruoyi/system/dto/TContractDTO.java index 0659eb1..11206fd 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/system/dto/TContractDTO.java +++ b/ruoyi-system/src/main/java/com/ruoyi/system/dto/TContractDTO.java @@ -1,9 +1,7 @@ package com.ruoyi.system.dto; -import com.baomidou.mybatisplus.annotation.TableField; import com.fasterxml.jackson.annotation.JsonFormat; import com.ruoyi.system.model.TContract; -import com.ruoyi.system.model.TTenant; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; import lombok.Data; diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/dto/TerminateContractDTO.java b/ruoyi-system/src/main/java/com/ruoyi/system/dto/TerminateContractDTO.java index c2f05a3..cdc21ef 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/system/dto/TerminateContractDTO.java +++ b/ruoyi-system/src/main/java/com/ruoyi/system/dto/TerminateContractDTO.java @@ -3,8 +3,10 @@ import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; import lombok.Data; +import org.springframework.format.annotation.DateTimeFormat; import java.io.Serializable; +import java.util.Date; @Data @ApiModel(value = "终止合同DTO") @@ -16,4 +18,8 @@ @ApiModelProperty(value = "备注说明") private String terminateRemark; + @ApiModelProperty(value = "终止日期") + @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") + private Date terminateTime; + } diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/model/TContract.java b/ruoyi-system/src/main/java/com/ruoyi/system/model/TContract.java index 39db30b..01645ad 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/system/model/TContract.java +++ b/ruoyi-system/src/main/java/com/ruoyi/system/model/TContract.java @@ -1,14 +1,9 @@ package com.ruoyi.system.model; import com.baomidou.mybatisplus.annotation.IdType; -import com.baomidou.mybatisplus.annotation.TableName; -import com.baomidou.mybatisplus.annotation.TableId; - -import java.math.BigDecimal; -import java.time.LocalDateTime; import com.baomidou.mybatisplus.annotation.TableField; -import java.io.Serializable; - +import com.baomidou.mybatisplus.annotation.TableId; +import com.baomidou.mybatisplus.annotation.TableName; import com.fasterxml.jackson.annotation.JsonFormat; import com.ruoyi.common.core.domain.BaseModel; import io.swagger.annotations.ApiModel; @@ -17,6 +12,8 @@ import lombok.EqualsAndHashCode; import javax.validation.constraints.NotBlank; +import java.math.BigDecimal; +import java.time.LocalDateTime; /** * <p> @@ -183,4 +180,12 @@ @TableField(exist = false) private String instanceId; + @ApiModelProperty(value = "房屋使用范围") + @TableField("house_use_scope") + private String houseUseScope; + + @ApiModelProperty(value = "终止日期-前端传的") + @TableField("terminate_time") + private LocalDateTime terminateTime; + } diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/model/TTenant.java b/ruoyi-system/src/main/java/com/ruoyi/system/model/TTenant.java index f9e80a7..afa3846 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/system/model/TTenant.java +++ b/ruoyi-system/src/main/java/com/ruoyi/system/model/TTenant.java @@ -96,4 +96,8 @@ @TableField("credit_code") private String creditCode; + @ApiModelProperty(value = "开户行") + @TableField("bank_name") + private String bankName; + } diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/FlowListenerService.java b/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/FlowListenerService.java index 7b0d89d..a18f96b 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/FlowListenerService.java +++ b/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/FlowListenerService.java @@ -28,17 +28,23 @@ import com.google.common.collect.ImmutableMap; import com.ruoyi.common.core.domain.entity.SysRole; import com.ruoyi.common.enums.ProcessCategoryEnum; -import com.ruoyi.common.enums.SubmitStatusEnum; import com.ruoyi.common.exception.ServiceException; import com.ruoyi.system.mapper.TCheckAcceptRecordMapper; -import com.ruoyi.system.model.*; -import com.ruoyi.system.service.*; +import com.ruoyi.system.model.TBill; +import com.ruoyi.system.model.TCheckAcceptRecord; +import com.ruoyi.system.model.TContract; +import com.ruoyi.system.model.TContractRentType; +import com.ruoyi.system.model.THouse; +import com.ruoyi.system.service.ISysRoleService; +import com.ruoyi.system.service.TBillService; +import com.ruoyi.system.service.TContractRentTypeService; +import com.ruoyi.system.service.TContractService; +import com.ruoyi.system.service.THouseService; import com.ruoyi.system.task.base.QuartzManager; import com.ruoyi.system.task.base.TimeJobType; import com.ruoyi.system.task.jobs.StateProcessJob; import lombok.RequiredArgsConstructor; import lombok.extern.slf4j.Slf4j; -import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; import java.math.BigDecimal; @@ -46,7 +52,11 @@ import java.time.LocalDateTime; import java.time.temporal.ChronoUnit; import java.time.temporal.TemporalAdjusters; -import java.util.*; +import java.util.ArrayList; +import java.util.Date; +import java.util.List; +import java.util.Map; +import java.util.Objects; import java.util.function.Supplier; import java.util.stream.Collectors; @@ -992,6 +1002,10 @@ contractService.updateContractAuditStatus(processParameter.getString("projectId"), submitStatus); // 生成验收记录 TContract contract = contractService.getById(processParameter.getString("projectId")); + //更新合同结束时间 + contract.setEndTime(contract.getTerminateTime()); + contractService.updateById(contract); + TCheckAcceptRecord tCheckAcceptRecord = new TCheckAcceptRecord(); tCheckAcceptRecord.setContractId(contract.getId()); tCheckAcceptRecord.setHouseId(contract.getHouseId()); diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/ScreenService.java b/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/ScreenService.java index 28d1853..dd6307c 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/ScreenService.java +++ b/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/ScreenService.java @@ -126,4 +126,7 @@ vo.setIncomeData(incomeData); return vo; } + + + } diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/TBillServiceImpl.java b/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/TBillServiceImpl.java index 05bbd56..57597b2 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/TBillServiceImpl.java +++ b/ruoyi-system/src/main/java/com/ruoyi/system/service/impl/TBillServiceImpl.java @@ -144,6 +144,7 @@ if (isok){ try { TBill save = new TBill(); + save.setId(tBill.getId()); TBill presist = getById(tBill.getId()); //如果账单是已缴费状态,本方法不再进行更新账单 if (presist.getPayFeesStatus().equals("3")){ @@ -343,62 +344,66 @@ String uuid = UUID.fastUUID().toString(); boolean lock = redisCache.trylockLoop(CacheConstants.COMPLETE_PAY_LOCK_KEY + orderNo, uuid, 60); if (lock){ - TPayOrder order = tPayOrderService.getById(orderNo); - if (order==null){ - throw new ServiceException("订单不存在"); - } - if (StringUtils.isNotEmpty(order.getPayNo())){ - log.info("订单号已处理:{}",orderNo); - return; - } - /** - * 更新订单状态 - */ - TPayOrder save = new TPayOrder(); - save.setId(order.getId()); - save.setStatus(1); - save.setPayNo(billRequest.getMessage().getInfo().getTraceNo()); - save.setPayType(billRequest.getMessage().getHead().getChannel()); try { - save.setPayTime(DateUtils.parseDate(billRequest.getMessage().getHead().getTimeStamp(),"yyyyMMddHHmmssSSS")); - } catch (ParseException e) { - throw new ServiceException("日期格式化错误"); + TPayOrder order = tPayOrderService.getById(orderNo); + if (order==null){ + throw new ServiceException("订单不存在"); + } + if (StringUtils.isNotEmpty(order.getPayNo())){ + log.info("订单号已处理:{}",orderNo); + return; + } + /** + * 更新订单状态 + */ + TPayOrder save = new TPayOrder(); + save.setId(order.getId()); + save.setStatus(1); + save.setPayNo(billRequest.getMessage().getInfo().getTraceNo()); + save.setPayType(billRequest.getMessage().getHead().getChannel()); + try { + save.setPayTime(DateUtils.parseDate(billRequest.getMessage().getHead().getTimeStamp(),"yyyyMMddHHmmssSSS")); + } catch (ParseException e) { + throw new ServiceException("日期格式化错误"); + } + save.setCallbackTime(new Date()); + BigDecimal payAmount = new BigDecimal(billRequest.getMessage().getInfo().getPayBillAmt()); + save.setActPayAmount(payAmount + .multiply(AmountConstant.b100).longValue()); + save.setStatus(1); + save.setPayInfo(billRequest.getMessage().toString()); + tPayOrderService.updateById(save); + /** + * 更新账单状态 + */ + List<TOrderBill> orderBills = orderBillService.getByOrderNo(order.getId()); + List<TBill> bills = orderBills.stream().map(ob -> getById(ob.getBillId())).collect(Collectors.toList()); + lockAndUpdateByAmountBatch(bills,payAmount,(bill)->{ + TFlowManagement saveFlow = new TFlowManagement(); + saveFlow.setPayType(1); + saveFlow.setPayer(order.getUserId()); + saveFlow.setPayTime(DateUtils.dateToLocalDateTime(save.getPayTime())); + saveFlow.setSysSerialNumber(OrderNos.getDid(30)); + saveFlow.setBankSerialNumber(save.getPayNo()); + saveFlow.setFlowType(2); + saveFlow.setPaymentBillId(bill.getId()); + saveFlow.setDeductionMoney(bill.getDeductionMoney()); + saveFlow.setFlowMoney(payAmount); + saveFlow.setRemainingMoney(bill.getOutstandingMoney()); + saveFlow.setPreOutstand(bill.getPreOutstand()); + tFlowManagementService.save(saveFlow); + }); +// TBankFlow bankFlow = new TBankFlow(); +// bankFlow.setPayType(1); +// bankFlow.setPayer(order.getUserId()); +// bankFlow.setPayTime(DateUtils.dateToLocalDateTime(save.getPayTime())); +// bankFlow.setBankSerialNumber(save.getPayNo()); +// bankFlow.setFlowMoney(payAmount); +// bankFlow.setFlowStatus(1); +// tBankFlowService.save(bankFlow); + }finally { + redisCache.unlock(CacheConstants.COMPLETE_PAY_LOCK_KEY + orderNo,uuid); } - save.setCallbackTime(new Date()); - BigDecimal payAmount = new BigDecimal(billRequest.getMessage().getInfo().getPayBillAmt()); - save.setActPayAmount(payAmount - .multiply(AmountConstant.b100).longValue()); - save.setStatus(1); - save.setPayInfo(billRequest.getMessage().toString()); - tPayOrderService.updateById(save); - /** - * 更新账单状态 - */ - List<TOrderBill> orderBills = orderBillService.getByOrderNo(order.getId()); - List<TBill> bills = orderBills.stream().map(ob -> getById(ob.getBillId())).collect(Collectors.toList()); - lockAndUpdateByAmountBatch(bills,payAmount,(bill)->{ - TFlowManagement saveFlow = new TFlowManagement(); - saveFlow.setPayType(1); - saveFlow.setPayer(order.getUserId()); - saveFlow.setPayTime(DateUtils.dateToLocalDateTime(save.getPayTime())); - saveFlow.setSysSerialNumber(OrderNos.getDid(30)); - saveFlow.setBankSerialNumber(save.getPayNo()); - saveFlow.setFlowType(2); - saveFlow.setPaymentBillId(bill.getId()); - saveFlow.setDeductionMoney(bill.getDeductionMoney()); - saveFlow.setFlowMoney(payAmount); - saveFlow.setRemainingMoney(bill.getOutstandingMoney()); - saveFlow.setPreOutstand(bill.getPreOutstand()); - tFlowManagementService.save(saveFlow); - }); - TBankFlow bankFlow = new TBankFlow(); - bankFlow.setPayType(1); - bankFlow.setPayer(order.getUserId()); - bankFlow.setPayTime(DateUtils.dateToLocalDateTime(save.getPayTime())); - bankFlow.setBankSerialNumber(save.getPayNo()); - bankFlow.setFlowMoney(payAmount); - bankFlow.setFlowStatus(1); - tBankFlowService.save(bankFlow); } diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/vo/HouseMapDistributionVO.java b/ruoyi-system/src/main/java/com/ruoyi/system/vo/HouseMapDistributionVO.java new file mode 100644 index 0000000..5547a6d --- /dev/null +++ b/ruoyi-system/src/main/java/com/ruoyi/system/vo/HouseMapDistributionVO.java @@ -0,0 +1,35 @@ +package com.ruoyi.system.vo; + +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import java.math.BigDecimal; + +@Data +@ApiModel("房屋分布") +public class HouseMapDistributionVO { + @ApiModelProperty(value = "房屋名称") + private String houseName; + + @ApiModelProperty(value = "房屋地址") + private String houseAddress; + + @ApiModelProperty(value = "房屋状态 1=待出租 2=已出租 3=维修中") + private String houseStatus; + + @ApiModelProperty(value = "租户") + private String tenant; + + @ApiModelProperty(value = "租金状态") + private String rentStatus; + + @ApiModelProperty(value = "本季租金") + private String rent; + + @ApiModelProperty(value = "经度") + private BigDecimal longitude; + + @ApiModelProperty(value = "纬度") + private BigDecimal latitude; +} diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/vo/RealTimeRentDataVO.java b/ruoyi-system/src/main/java/com/ruoyi/system/vo/RealTimeRentDataVO.java new file mode 100644 index 0000000..1f7eedd --- /dev/null +++ b/ruoyi-system/src/main/java/com/ruoyi/system/vo/RealTimeRentDataVO.java @@ -0,0 +1,28 @@ +package com.ruoyi.system.vo; + +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +@Data +@ApiModel(value = "实时租赁数据") +public class RealTimeRentDataVO { + + @ApiModelProperty(value = "街道名称") + private String streetName; + + @ApiModelProperty(value = "房间名称") + private String roomName; + + @ApiModelProperty(value = "租赁状态 1=待出租 2=已出租 3=维修中") + private String leaseStatus; + + public RealTimeRentDataVO(String streetName, String roomName, String leaseStatus) { + this.streetName = streetName; + this.roomName = roomName; + this.leaseStatus = leaseStatus; + } + + public RealTimeRentDataVO() { + } +} diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/vo/YearQuarter.java b/ruoyi-system/src/main/java/com/ruoyi/system/vo/YearQuarter.java new file mode 100644 index 0000000..8e175c7 --- /dev/null +++ b/ruoyi-system/src/main/java/com/ruoyi/system/vo/YearQuarter.java @@ -0,0 +1,31 @@ +package com.ruoyi.system.vo; + +import lombok.AllArgsConstructor; +import lombok.Data; + +import java.time.LocalDate; +import java.time.format.DateTimeFormatter; +import java.util.Comparator; + +@Data +@AllArgsConstructor +public class YearQuarter implements Comparable<YearQuarter> { + private int year; + private int quarter; + + public static YearQuarter from(LocalDate date) { + int quarter = (date.getMonthValue() - 1) / 3 + 1; + return new YearQuarter(date.getYear(), quarter); + } + + public String format(DateTimeFormatter formatter) { + return formatter.format(LocalDate.of(year, quarter * 3 - 2, 1)); + } + + @Override + public int compareTo(YearQuarter other) { + return Comparator.comparingInt(YearQuarter::getYear) + .thenComparingInt(YearQuarter::getQuarter) + .compare(this, other); + } +} -- Gitblit v1.7.1