无关风月
2025-02-12 da124bc60214876ec2b00d00d865b14cf9bb9535
Merge branch 'master' of https://gitee.com/xiaochen991015/xizang
13个文件已修改
2个文件已添加
307 ■■■■■ 已修改文件
ruoyi-admin/src/main/java/com/ruoyi/web/controller/api/TBillController.java 11 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-admin/src/main/resources/application-test.yml 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-applet/src/main/java/com/ruoyi/web/controller/api/PayController.java 42 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-applet/src/main/java/com/ruoyi/web/controller/api/TBillController.java 40 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-system/src/main/java/com/ruoyi/system/dto/OfflinePayDto.java 36 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-system/src/main/java/com/ruoyi/system/dto/TBillDto.java 1 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-system/src/main/java/com/ruoyi/system/dto/TbillSaveDto.java 17 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-system/src/main/java/com/ruoyi/system/mapper/TBillMapper.java 13 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-system/src/main/java/com/ruoyi/system/model/TBill.java 2 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-system/src/main/java/com/ruoyi/system/model/TContract.java 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-system/src/main/java/com/ruoyi/system/service/TBillService.java 20 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-system/src/main/java/com/ruoyi/system/service/impl/TBillServiceImpl.java 45 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-system/src/main/java/com/ruoyi/system/vo/TBillVO.java 11 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-system/src/main/resources/mapper/system/TBillMapper.xml 63 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-system/src/main/resources/mapper/system/TContractMapper.xml 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-admin/src/main/java/com/ruoyi/web/controller/api/TBillController.java
@@ -3,11 +3,14 @@
import com.ruoyi.common.basic.PageInfo;
import com.ruoyi.common.core.domain.R;
import com.ruoyi.common.exception.ServiceException;
import com.ruoyi.system.dto.TBillDto;
import com.ruoyi.system.dto.TbillSaveDto;
import com.ruoyi.system.model.TBill;
import com.ruoyi.system.query.TBillQuery;
import com.ruoyi.system.service.TBillService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
@@ -34,6 +37,14 @@
        return R.ok(pageInfo);
    }
    @PostMapping("add")
    public R<PageInfo<TBillDto>> add(@Validated @RequestBody TbillSaveDto bill){
        tBillService.saveBill(bill);
        return R.ok();
    }
}
ruoyi-admin/src/main/resources/application-test.yml
@@ -21,7 +21,7 @@
  port: 8081
  servlet:
    # 应用的访问路径
    context-path: /admin
    context-path: /
  tomcat:
    # tomcat的URI编码
    uri-encoding: UTF-8
ruoyi-applet/src/main/java/com/ruoyi/web/controller/api/PayController.java
@@ -1,11 +1,20 @@
package com.ruoyi.web.controller.api;
import cn.hutool.core.collection.CollectionUtil;
import com.ruoyi.common.constant.AmountConstant;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.domain.R;
import com.ruoyi.system.dto.MakeOrderDto;
import com.ruoyi.system.dto.MakeOrderResp;
import com.ruoyi.system.dto.OfflinePayDto;
import com.ruoyi.system.model.TBill;
import com.ruoyi.system.model.TBillConfirm;
import com.ruoyi.system.service.TBillConfirmService;
import com.ruoyi.system.service.TBillService;
import com.ruoyi.system.service.TPayOrderService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.poi.ss.formula.functions.T;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
@@ -13,6 +22,12 @@
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.util.Collections;
import java.util.List;
@Api(value = "支付订单")
@RestController
@RequestMapping("/t-pay")
public class PayController {
@@ -22,6 +37,12 @@
    @Autowired
    TPayOrderService tPayOrderService;
    @Autowired
    TBillService tBillService;
    @Autowired
    TBillConfirmService tBillConfirmService;
    @ApiOperation(value = "创建支付订单")
    @PostMapping("makeOrder")
    public R<MakeOrderResp> makeOrder(@Validated @RequestBody MakeOrderDto dto){
@@ -29,7 +50,24 @@
        return R.ok(resp);
    }
    @ApiOperation(value = "线下支付")
    @PostMapping("offlinePay")
    public R offlinePay(@Validated @RequestBody OfflinePayDto dto){
        List<TBill> tBills = tBillService.listByIds(dto.getBillIds());
        for (TBill tBill : tBills) {
            TBill save = new TBill();
            save.setId(tBill.getId());
            save.setPayFeesType(2);
            save.setVoucher(dto.getVoucher());
            save.setPayFeesStatus("2");
            tBillService.lockAndUpdateInfo(save);
        }
        TBillConfirm confirm = new TBillConfirm();
        confirm.setBillId(CollectionUtil.join(dto.getBillIds(),","));
        confirm.setVoucher(dto.getVoucher());
        confirm.setPayFeesMoney(new BigDecimal(dto.getAmount()).divide(AmountConstant.b100).setScale(2, RoundingMode.HALF_DOWN).doubleValue());
        tBillConfirmService.save(confirm);
        return R.ok();
    }
}
ruoyi-applet/src/main/java/com/ruoyi/web/controller/api/TBillController.java
@@ -8,14 +8,12 @@
import com.ruoyi.common.exception.ServiceException;
import com.ruoyi.common.utils.DictUtils;
import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.framework.web.service.TokenService;
import com.ruoyi.system.dto.TBillDto;
import com.ruoyi.system.dto.TInvoiceDTO;
import com.ruoyi.system.model.*;
import com.ruoyi.system.query.TBillQuery;
import com.ruoyi.system.service.TBillDetailService;
import com.ruoyi.system.service.TBillService;
import com.ruoyi.system.service.TInvoiceService;
import com.ruoyi.system.service.TInvoiceToBillService;
import com.ruoyi.system.service.*;
import com.ruoyi.system.vo.TBillVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
@@ -44,9 +42,15 @@
    @Autowired
    TBillDetailService billDetailService;
    @Autowired
    TContractService contractService;
    @Autowired
    THouseService houseService;
    @Autowired
    TInvoiceService invoiceService;
    @Autowired
    TInvoiceToBillService invoiceToBillService;
    @Autowired
    TokenService tokenService;
    @ApiOperation(value = "缴费账单查询分页列表")
    @PostMapping("list")
@@ -56,6 +60,16 @@
        }
        PageInfo<TBillDto> pageInfo = tBillService.queryPage(query);
        return R.ok(pageInfo);
    }
    @ApiOperation(value = "缴费账单查询分页列表")
    @PostMapping("/getBillIds")
    public R<List<String>> getBillIds(@RequestBody TBillQuery query){
        if (StringUtils.isEmpty(query.getUserId())){
            throw new ServiceException("用户ID不能为空");
        }
        List<String> billIds = tBillService.getBillIds(query);
        return R.ok(billIds);
    }
    @ApiOperation(value = "查看缴费账单详情")
@@ -70,6 +84,13 @@
                    .eq(TBillDetail::getBillId, id));
            billVO.setBillDetailList(list);
        }
        // 查询合同信息
        contractService.lambdaQuery().eq(TContract::getId, bill.getContractId()).oneOpt().ifPresent(contract -> {
            // 查询房屋信息
            billVO.setHouse(houseService.getById(contract.getHouseId()));
            billVO.setMonthRent(contract.getMonthRent());
            billVO.setPayType(contract.getPayType());
        });
        billVO.setBillType(DictUtils.getDictLabel(DictConstants.DICT_TYPE_BILL_TYPE,billVO.getBillType()));
        billVO.setPayFeesStatus(DictUtils.getDictLabel(DictConstants.DICT_TYPE_PAY_FEES_STATUS,billVO.getPayFeesStatus()));
        return R.ok(billVO);
@@ -94,5 +115,16 @@
        return R.ok();
    }
    @ApiOperation(value = "缴费账单开票列表")
    @PostMapping(value = "/invoiceList")
    public R<PageInfo<TBillDto>> invoiceList(@RequestBody TBillQuery query) {
//        Long userId = tokenService.getLoginUser().getUserId();
        String userId = "1881967035070177281";
        query.setUserId(userId);
        PageInfo<TBillDto> pageInfo = tBillService.invoiceList(query);
        return R.ok(pageInfo);
    }
}
ruoyi-system/src/main/java/com/ruoyi/system/dto/OfflinePayDto.java
New file
@@ -0,0 +1,36 @@
package com.ruoyi.system.dto;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.NotNull;
import java.io.Serializable;
import java.util.List;
@Data
public class OfflinePayDto implements Serializable {
    /**
     * 用户ID
     */
    @ApiModelProperty(value = "用户ID")
    private String userId;
    @ApiModelProperty(value = "支付金额,单位:分")
    @NotNull(message = "金额不能为空")
    private Long amount;
    /**
     * 账单列表
     */
    @ApiModelProperty(value = "账单列表")
    @NotEmpty(message = "账单ID不能为空")
    private List<String> billIds;
    /**
     * 凭证文件ID
     */
    @ApiModelProperty(value = "凭证文件ID")
    @NotEmpty(message = "凭证文件不能为空")
    private String voucher;
}
ruoyi-system/src/main/java/com/ruoyi/system/dto/TBillDto.java
@@ -16,4 +16,5 @@
    private String houseName;
}
ruoyi-system/src/main/java/com/ruoyi/system/dto/TbillSaveDto.java
New file
@@ -0,0 +1,17 @@
package com.ruoyi.system.dto;
import com.ruoyi.system.model.TBill;
import com.ruoyi.system.model.TBillDetail;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.io.Serializable;
import java.util.List;
@Data
public class TbillSaveDto extends TBill implements Serializable {
    @ApiModelProperty(value = "水单费列表")
    private List<TBillDetail> details;
}
ruoyi-system/src/main/java/com/ruoyi/system/mapper/TBillMapper.java
@@ -5,8 +5,11 @@
import com.ruoyi.system.dto.TBillDto;
import com.ruoyi.system.model.TBill;
import com.ruoyi.system.query.TBillQuery;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import java.util.List;
/**
 * <p>
@@ -16,8 +19,18 @@
 * @author xiaochen
 * @since 2025-01-17
 */
@Mapper
public interface TBillMapper extends BaseMapper<TBill> {
    PageInfo<TBillDto> page(@Param("pageInfo") PageInfo<TBill> pageInfo, @Param("query") TBillQuery query);
    List<TBillDto> getBillList(@Param("query")TBillQuery query);
    /**
     * 获取开票列表
     * @param query
     * @param pageInfo
     * @return
     */
    List<TBillDto> invoiceList(@Param("query")TBillQuery query, @Param("pageInfo")PageInfo<TBillDto> pageInfo);
}
ruoyi-system/src/main/java/com/ruoyi/system/model/TBill.java
@@ -8,6 +8,7 @@
import java.time.LocalDateTime;
import com.baomidou.mybatisplus.annotation.TableField;
import java.io.Serializable;
import java.util.List;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.ruoyi.common.core.domain.BaseModel;
@@ -16,6 +17,7 @@
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.springframework.data.annotation.Transient;
/**
 * <p>
ruoyi-system/src/main/java/com/ruoyi/system/model/TContract.java
@@ -87,7 +87,7 @@
    @ApiModelProperty(value = "押金是否随租金递增递减 true=是 false=否")
    @TableField("isIncreasing_deposit")
    private Boolean isincreasingDeposit;
    private Boolean isIncreasingDeposit;
    @ApiModelProperty(value = "违约金比例")
    @TableField("proportion")
ruoyi-system/src/main/java/com/ruoyi/system/service/TBillService.java
@@ -3,8 +3,11 @@
import com.baomidou.mybatisplus.extension.service.IService;
import com.ruoyi.common.basic.PageInfo;
import com.ruoyi.system.dto.TBillDto;
import com.ruoyi.system.dto.TbillSaveDto;
import com.ruoyi.system.model.TBill;
import com.ruoyi.system.query.TBillQuery;
import java.util.List;
/**
 * <p>
@@ -18,4 +21,21 @@
    PageInfo<TBillDto> queryPage(TBillQuery query);
    Boolean lockAndUpdateInfo(TBill save);
    void saveBill(TbillSaveDto bill);
    /**
     * 查询账单id列表
     * @param query
     * @return
     */
    List<String> getBillIds(TBillQuery query);
    /**
     * 查询开票列表
     * @param query
     * @return
     */
    PageInfo<TBillDto> invoiceList(TBillQuery query);
}
ruoyi-system/src/main/java/com/ruoyi/system/service/impl/TBillServiceImpl.java
@@ -3,20 +3,29 @@
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.ruoyi.common.basic.PageInfo;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.domain.entity.SysRole;
import com.ruoyi.common.core.redis.RedisCache;
import com.ruoyi.common.exception.ServiceException;
import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.system.dto.TBillDto;
import com.ruoyi.system.dto.TbillSaveDto;
import com.ruoyi.system.mapper.TBillMapper;
import com.ruoyi.system.model.TBill;
import com.ruoyi.system.model.TBillDetail;
import com.ruoyi.system.model.TContract;
import com.ruoyi.system.model.THouse;
import com.ruoyi.system.query.TBillQuery;
import com.ruoyi.system.service.TBillDetailService;
import com.ruoyi.system.service.TBillService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import io.jsonwebtoken.lang.Assert;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.time.LocalDateTime;
import java.util.List;
import java.util.stream.Collectors;
/**
 * <p>
@@ -35,24 +44,56 @@
    @Autowired
    TBillMapper tBillMapper;
    @Autowired
    TBillDetailService tBillDetailService;
    public PageInfo<TBillDto> queryPage(TBillQuery query){
        PageInfo<TBill> pageInfo = new PageInfo<>(query.getPageNum(), query.getPageSize());
        PageInfo<TBillDto> info = tBillMapper.page(pageInfo, query);
        return info;
    }
    @Override
    public List<String> getBillIds(TBillQuery query) {
        List<TBillDto> billDtos = tBillMapper.getBillList(query);
        return billDtos.stream().map(TBillDto::getId).collect(Collectors.toList());
    }
    @Override
    public PageInfo<TBillDto> invoiceList(TBillQuery query) {
        PageInfo<TBillDto> pageInfo = new PageInfo<>(query.getPageNum(), query.getPageSize());
        List<TBillDto> list = tBillMapper.invoiceList(query,pageInfo);
        pageInfo.setRecords(list);
        return pageInfo;
    }
    /**
     * 传的金额
     * @param tBill
     * @return
     */
    public Boolean checkAndUpdateBill(TBill tBill){
    public Boolean lockAndUpdateInfo(TBill tBill){
        if (StringUtils.isEmpty(tBill.getId())){
            throw new ServiceException("账单主键ID不能为空");
        }
        return true;
    }
    @Override
    @Transactional(rollbackFor = Exception.class)
    public void saveBill(TbillSaveDto bill) {
        save(bill);
        if (bill.getBillType().equals("3")){
            if (bill.getDetails()==null || bill.getDetails().size()==0){
                throw new ServiceException("生活费用列表不能为空");
            }
            for (TBillDetail detail : bill.getDetails()) {
                detail.setBillId(bill.getId());
                tBillDetailService.save(detail);
            }
        }
    }
}
ruoyi-system/src/main/java/com/ruoyi/system/vo/TBillVO.java
@@ -1,11 +1,14 @@
package com.ruoyi.system.vo;
import com.baomidou.mybatisplus.annotation.TableField;
import com.ruoyi.system.model.TBill;
import com.ruoyi.system.model.TBillDetail;
import com.ruoyi.system.model.THouse;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.math.BigDecimal;
import java.util.List;
@Data
@@ -15,4 +18,12 @@
    @ApiModelProperty(value = "水电费明细")
    private List<TBillDetail> billDetailList;
    @ApiModelProperty(value = "房屋信息")
    private THouse house;
    @ApiModelProperty(value = "租金")
    private BigDecimal monthRent;
    @ApiModelProperty(value = "租金支付方式 月付 季付 年付")
    private String payType;
}
ruoyi-system/src/main/resources/mapper/system/TBillMapper.xml
@@ -42,6 +42,37 @@
            h.house_name as houseName
        FROM
            t_bill b
        LEFT JOIN t_contract c ON c.contract_number = b.contract_number and c.disabled=0
        LEFT JOIN t_house h ON h.id = c.house_id and h.disabled=0
        LEFT JOIN t_tenant t ON t.id = c.tenant_id and t.disabled=0
        <where>
            b.disabled=0
            <if test="query.payFeesStatus != null">
                and b.pay_fees_status = #{query.payFeesStatus}
            </if>
            <if test="query.phone != null and query.phone !=''">
                and t.phone = #{query.phone}
            </if>
            <if test="query.residentName != null and query.residentName !=''">
                and t.resident_name like concat('%',#{query.residentName},'%')
            </if>
            <if test="query.contractNumber != null and query.contractNumber !=''">
                and b.contract_number = #{query.contractNumber}
            </if>
            <if test="query.userId != null and query.userId !=''">
                and t.id = #{query.userId}
            </if>
        </where>
    </select>
    <select id="getBillList" resultType="com.ruoyi.system.dto.TBillDto">
        SELECT
        b.*,
        t.resident_name as residentName,
        t.phone,
        t.account,
        h.house_name as houseName
        FROM
        t_bill b
        LEFT JOIN t_contract c ON c.contract_number = b.contract_number
        LEFT JOIN t_house h ON h.id = c.house_id
        LEFT JOIN t_tenant t ON t.id = c.tenant_id
@@ -63,4 +94,36 @@
            </if>
        </where>
    </select>
    <select id="invoiceList" resultType="com.ruoyi.system.dto.TBillDto">
        SELECT
        b.*,
        t.resident_name as residentName,
        t.phone,
        t.account,
        h.house_name as houseName
        FROM
        t_bill b
        LEFT JOIN t_contract c ON c.contract_number = b.contract_number
        LEFT JOIN t_house h ON h.id = c.house_id
        LEFT JOIN t_tenant t ON t.id = c.tenant_id
        LEFT JOIN t_invoice_to_bill tb ON b.id = tb.bill_id
        <where>
            <if test="query.payFeesStatus != null">
                and b.pay_fees_status = #{query.payFeesStatus}
            </if>
            <if test="query.phone != null and query.phone !=''">
                and t.phone = #{query.phone}
            </if>
            <if test="query.residentName != null and query.residentName !=''">
                and t.resident_name like concat('%',#{query.residentName},'%')
            </if>
            <if test="query.contractNumber != null and query.contractNumber !=''">
                and b.contract_number = #{query.contractNumber}
            </if>
            <if test="query.userId != null and query.userId !=''">
                and t.id = #{query.userId}
            </if>
            and tb.invoice_id IS NULL
        </where>
    </select>
</mapper>
ruoyi-system/src/main/resources/mapper/system/TContractMapper.xml
@@ -14,7 +14,7 @@
        <result column="pay_type" property="payType" />
        <result column="first_pay_time" property="firstPayTime" />
        <result column="isIncreasing" property="isIncreasing" />
        <result column="isIncreasing_deposit" property="isincreasingDeposit" />
        <result column="isIncreasing_deposit" property="isIncreasingDeposit" />
        <result column="proportion" property="proportion" />
        <result column="house_id" property="houseId" />
        <result column="party_one_name" property="partyOneName" />