package com.trade.client.trade.salesorder.controller;

import javax.annotation.Resource;
import javax.validation.constraints.NotBlank;

import com.trade.service.trade.salesorder.vo.SalesOrderInvoiceDtlVO;
import org.springframework.http.HttpStatus;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseStatus;

import com.github.pagehelper.PageInfo;
import com.trade.client.security.utils.UserUtils;
import com.trade.common.core.domain.ResponseResult;
import com.trade.service.trade.salesorder.service.ISalesOrderInvoiceService;
import com.trade.service.trade.salesorder.vo.SalesOrderInvoiceSearch;
import com.trade.service.trade.salesorder.vo.SalesOrderInvoiceVO;
import org.springframework.web.bind.annotation.RestController;

/**
 * <p>
 * 销售订单发票 C端控制器
 * </p>
 */
@RestController
@RequestMapping("/salesOrderInvoice")
@Validated
public class SalesOrderInvoiceController {

    @Resource
    private ISalesOrderInvoiceService salesOrderInvoiceService;

    /**
     * 销售订单发票-list
     */
    @RequestMapping("/list")
    public ResponseResult<PageInfo<SalesOrderInvoiceVO>> list(SalesOrderInvoiceSearch search) {
        search.setCustomerUserId(UserUtils.getCustomerUserId());
        return ResponseResult.success(salesOrderInvoiceService.queryListBySearch(search));
    }

    /**
     * 销售订单发票-详情
     * 
     * @param invoiceNo 发票编号
     */
    @RequestMapping("/detail")
    public ResponseResult<SalesOrderInvoiceDtlVO> detail(@NotBlank(message = "发票编号不能为空") String invoiceNo) {
        return ResponseResult.success(salesOrderInvoiceService.getDetailByInvoiceNo(invoiceNo));
    }
}
