yupeng
2025-04-11 00bba0d41598807255fd7217e9e829c7ef4ed06a
feat: 1.添加测试用例
2.修改账单更新返回对象营运部门ID设置顺序
1个文件已添加
2个文件已修改
79 ■■■■■ 已修改文件
ruoyi-admin/pom.xml 12 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-admin/src/test/java/com/ruoyi/web/test/BaseTest.java 63 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-system/src/main/java/com/ruoyi/system/service/impl/TBillServiceImpl.java 4 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
ruoyi-admin/pom.xml
@@ -37,7 +37,11 @@
            <artifactId>spring-boot-devtools</artifactId>
            <optional>true</optional> <!-- 表示依赖不会传递 -->
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-test</artifactId>
            <scope>test</scope>
        </dependency>
        <!-- swagger3-->
        <dependency>
            <groupId>io.springfox</groupId>
@@ -116,7 +120,6 @@
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-test</artifactId>
            <version>5.1.3.RELEASE</version>
        </dependency>
<!--        <dependency>-->
<!--            <groupId>org.apache.httpcomponents</groupId>-->
@@ -159,6 +162,11 @@
            <artifactId>dysmsapi20170525</artifactId>
            <version>2.0.10</version>
        </dependency>
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <scope>test</scope>
        </dependency>
    </dependencies>
ruoyi-admin/src/test/java/com/ruoyi/web/test/BaseTest.java
New file
@@ -0,0 +1,63 @@
package com.ruoyi.web.test;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.TypeReference;
import com.ruoyi.RuoYiApplication;
import com.ruoyi.system.service.TBillService;
import com.taxi591.bankapi.dto.ChargeBillRequest;
import lombok.extern.slf4j.Slf4j;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.boot.test.context.SpringBootTest.WebEnvironment;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;
import org.springframework.context.EnvironmentAware;
import org.springframework.core.env.Environment;
import org.springframework.test.context.junit4.SpringRunner;
@RunWith(SpringRunner.class)
@SpringBootTest(classes = RuoYiApplication.class,webEnvironment = WebEnvironment.MOCK)
@Slf4j
public class BaseTest implements ApplicationContextAware, EnvironmentAware {
    static {
        System.setProperty("spring.profiles.active","test");
    }
    protected ApplicationContext applicationContext;
    protected Environment environment;
    @Override
    public void setApplicationContext(ApplicationContext applicationContext) {
        this.applicationContext = applicationContext;
    }
    public ApplicationContext getApplicationContext() {
        return applicationContext;
    }
    @Override
    public void setEnvironment(Environment environment) {
        this.environment = environment;
    }
    public Environment getEnvironment() {
        return environment;
    }
    @Autowired
    TBillService tBillService;
    @Test
    public void test(){
        String params = "{\"format\":\"json\",\"message\":{\"head\":{\"channel\":\"OPEN\",\"transCode\":\"chargeBill\",\"transFlag\":\"01\",\"transSeqNum\":\"BP250411141205A19694\",\"timeStamp\":\"20250411141205218\",\"branchCode\":\"2540\"},\"info\":{\"epayCode\":\"JF-EPAY2025030510983\",\"merchantId\":\"103882597000441\",\"traceNo\":\"JF250411141154364902\",\"input1\":\"25041114115300100000000000069356\",\"userId\":\"o4mMu5Ry-Uv3hpLt81DrXVSCe9hA\",\"amtRule\":\"0\",\"payBillCount\":\"1\",\"payBillAmt\":\"0.01\",\"payBillNo\":\"25041114115300100000000000069356\",\"payType\":\"EP139\",\"transPaySeq\":\"4BEC2514080908013408\",\"transDate\":\"20250411\",\"transTime\":\"141205\",\"settleDate\":\"20250411\",\"clearType\":\"ZHSYT\",\"resendTimes\":\"0\",\"numOpenMerchantOrder\":\"10388259700044143807189441315960\"}}}";
        ChargeBillRequest chargeBillRequest = JSON.parseObject(params,
                new TypeReference<ChargeBillRequest>() {
                });
        tBillService.completePay(chargeBillRequest);
    }
}
ruoyi-system/src/main/java/com/ruoyi/system/service/impl/TBillServiceImpl.java
@@ -154,7 +154,7 @@
                if (presist.getPayFeesStatus().equals("3")){
                    throw new ServiceException("该账单已缴费完成");
                }
                save.setBusinessDeptId(presist.getBusinessDeptId());
                switch (type){
                    // 仅更新除金额字段外的属性
                    case 1:
@@ -211,6 +211,7 @@
                    break;
                }
                save.setBusinessDeptId(presist.getBusinessDeptId());
                updateById(save);
                return save;
            }finally {
@@ -419,6 +420,7 @@
    }
    /**
     * 根据发票编号查询账单列表
     * @param invoiceId