SettlementController.java 9.0 KB
Newer Older
苗卫卫 committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185
package com.boco.nbd.wios.manage.controller;

import cn.hutool.core.lang.Assert;
import com.boco.nbd.cams.core.constant.MessageConstant;
import com.boco.nbd.wios.manage.contants.WiosConstant;
import com.boco.nbd.wios.manage.entity.settlement.po.Settlement;
import com.boco.nbd.wios.manage.entity.settlement.po.SettlementDetail;
import com.boco.nbd.wios.manage.entity.settlement.po.SettlementDetailSupplier;
import com.boco.nbd.wios.manage.entity.settlement.vo.SettlementVo;
import com.boco.nbd.wios.manage.service.impl.SettlementService;
import com.ihidea.component.api.v2.BaseResponse;
import com.ihidea.core.support.exception.ServiceException;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import springfox.documentation.annotations.ApiIgnore;

import java.math.BigDecimal;
import java.text.ParseException;
import java.util.List;

/**
 * 结算相关接口
 * 
 * @author xgl
 * @version [版本号, 2020年9月28日]
 */
@RestController
@RequestMapping("api")
@Api(tags = "结算相关接口")
@ApiIgnore
public class SettlementController {
    @Autowired
    private SettlementService settlementService;
    
    /**
     * 确认信息
     *
     * @param id
     * @param totalTax
     * @param totalPriceActual
     * @param remark
     * @return
     */
    @PostMapping(value = "settlement/confirm")
    @ApiOperation(value = "确认信息")
    @ApiImplicitParams({@ApiImplicitParam(name = "id", value = "主键id", dataType = "int", paramType = "query", required = true),
        @ApiImplicitParam(name = "totalTaxActual", value = "实际结算总税金(元)", dataType = "double", paramType = "query", required = true),
        @ApiImplicitParam(name = "totalPriceActual", value = "实际结算总金额(元)不含税", dataType = "double", paramType = "query", required = true),
        @ApiImplicitParam(name = "remark", value = "备注", dataType = "String", paramType = "query", required = false),})
    public BaseResponse<Object> confirm(Integer id, BigDecimal totalTaxActual, BigDecimal totalPriceActual, String remark) {
        Assert.notNull(id, WiosConstant.EMPTY_ID);
        Assert.notNull(totalTaxActual, "totalTaxActual不能为空");
        Assert.notNull(totalPriceActual, "totalPriceActual不能为空");
        Settlement settlement = new Settlement();
        settlement.setTotalTaxActual(totalTaxActual);
        settlement.setTotalPriceActual(totalPriceActual);
        settlement.setRemark(remark);
        settlement.setStatus(2);
        settlementService.update(id, settlement);
        return new BaseResponse<Object>();
    }
    
    /**
     * 查询结算单列表
     *
     * @param settlement
     * @return
     */
    @GetMapping(value = "settlement/all")
    @ApiOperation(value = "查询结算单列表")
    @ApiImplicitParams({
        
        @ApiImplicitParam(name = "page", value = "一页显示数量", dataType = "int", paramType = "query", required = false),
        @ApiImplicitParam(name = "pagecount", value = "页码", dataType = "int", paramType = "query", required = false),
        @ApiImplicitParam(name = "settlementId", value = "结算单号", dataType = "String", paramType = "query", required = false),
        @ApiImplicitParam(name = "totalPrice", value = "总金额", dataType = "int", paramType = "query", required = false),
        @ApiImplicitParam(name = "totalPriceWithTax", value = "结算总金额(含税)", dataType = "int", paramType = "query", required = false),
        @ApiImplicitParam(name = "totalTax", value = "总税金", dataType = "int", paramType = "query", required = false),
        @ApiImplicitParam(name = "totalPriceActual", value = "实际结算金额", dataType = "int", paramType = "query", required = false),
        @ApiImplicitParam(name = "targetName", value = "名称", dataType = "String", paramType = "query", required = false),
    
    })
    public BaseResponse<List<SettlementVo>> getList(Settlement settlement) {
        return new BaseResponse<List<SettlementVo>>(settlementService.getList(settlement));
    }
    
    /**
     * 查询主机厂结算单详情列表
     *
     * @param settlement
     * @return
     */
    @GetMapping(value = "settlement/oem/detailList")
    @ApiOperation(value = "查询主机厂结算单详情列表")
    @ApiImplicitParams({@ApiImplicitParam(name = "page", value = "一页显示数量", dataType = "int", paramType = "query", required = false),
        @ApiImplicitParam(name = "pagecount", value = "页码", dataType = "int", paramType = "query", required = false),
        @ApiImplicitParam(name = "settlementId", value = "结算单号", dataType = "String", paramType = "query", required = true),})
    public BaseResponse<List<SettlementDetail>> getOemDetailList(String settlementId) {
        if (StringUtils.isEmpty(settlementId)) {
            throw new ServiceException(MessageConstant.MISSING_PARAM);
        }
        return new BaseResponse<>(settlementService.getDetailList(settlementId));
    }
    
    /**
     * 查询服务商结算单详情列表
     *
     * @param settlementId
     * @return
     */
    @GetMapping(value = "settlement/supplier/detailList")
    @ApiOperation(value = "查询服务商结算单详情列表")
    @ApiImplicitParams({@ApiImplicitParam(name = "page", value = "一页显示数量", dataType = "int", paramType = "query", required = false),
        @ApiImplicitParam(name = "pagecount", value = "页码", dataType = "int", paramType = "query", required = false),
        @ApiImplicitParam(name = "settlementId", value = "结算单号", dataType = "String", paramType = "query", required = true),})
    public BaseResponse<List<SettlementDetailSupplier>> getSupplierDetailList(String settlementId) {
        if (StringUtils.isEmpty(settlementId)) {
            throw new ServiceException(MessageConstant.MISSING_PARAM);
        }
        return new BaseResponse<>(settlementService.getDetailListForSupplier(settlementId));
    }
    
    /**
     * 查询主机厂结算单总价
     *
     * @param settlementId
     * @return
     */
    @GetMapping(value = "settlement/qryTotalPrice")
    @ApiOperation(value = "查询主机厂结算单总价")
    @ApiImplicitParams({
        @ApiImplicitParam(name = "settlementId", value = "结算单号", dataType = "String", paramType = "query", required = true),})
    public BaseResponse<BigDecimal> qryTotalPrice(String settlementId) {
        if (StringUtils.isEmpty(settlementId)) {
            throw new ServiceException(MessageConstant.MISSING_PARAM);
        }
        return new BaseResponse<>(settlementService.getOemTotalPrice(settlementId));
    }
    
    /**
     * 查询服务商结算单总价
     *
     * @param settlementId
     * @return
     */
    @GetMapping(value = "settlement/qrySupplierTotalPrice")
    @ApiOperation(value = "查询服务商结算单总价")
    @ApiImplicitParams({
        @ApiImplicitParam(name = "settlementId", value = "结算单号", dataType = "String", paramType = "query", required = true),})
    public BaseResponse<BigDecimal> qrySupplierTotalPrice(String settlementId) {
        if (StringUtils.isEmpty(settlementId)) {
            throw new ServiceException(MessageConstant.MISSING_PARAM);
        }
        return new BaseResponse<>(settlementService.getSupplierTotalPrice(settlementId));
    }

    /**
     * @Description 手动生成主机厂结算单
     * @Param [startDate, endDate, oemIds]
     * @author liwenxiang
     * @date 2021/7/29 13:42
     * @return com.ihidea.component.api.v2.BaseResponse<java.lang.Object>
     */
    @PostMapping(value = "settlement/generateOemSettlement")
    @ApiOperation(value = "手动生成主机厂结算单")
    @ApiImplicitParams({@ApiImplicitParam(name = "startDate", value = "开始日期,格式(YYYY-MM-DD)", dataType = "String", paramType = "query", required = true),
            @ApiImplicitParam(name = "endDate", value = "结束日期,格式(YYYY-MM-DD)", dataType = "String", paramType = "query", required = true),
            @ApiImplicitParam(name = "oemIds", value = "主机厂id(多个用逗号隔开)", dataType = "String", paramType = "query", required = true)})
    public BaseResponse<Object> generateOemSettlement(String startDate,String endDate,String oemIds) throws ParseException {
        //校验开始日期和结束日期格式(YYYY-MM-DD)、主机厂id
        Assert.notBlank(startDate,"开始日期不能为空");
        Assert.notBlank(endDate,"结束日期不能为空");
        Assert.notBlank(oemIds,"主机厂id不能为空");
        settlementService.generateOemSettlementById(startDate,endDate,oemIds);
        return new BaseResponse<Object>();
    }
}