package com.jwipc.shopping.controller.pc;

import com.google.common.base.Strings;
import com.jwipc.log.annotation.AuditLogInter;
import com.jwipc.shopping.constant.ModuleConst;
import com.jwipc.shopping.entity.ShoppingInvoice;
import com.jwipc.shopping.logic.OnlineMallLogic;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.*;

import java.util.Date;
import java.util.List;

/**
 * 功能描述:
 *
 * @Author: zx
 * @Date: 2024/3/14 0014 20:08
 */
@Controller
@RequestMapping(ModuleConst.MODULE_ROOT + "/invoice/page")
@RequiredArgsConstructor
@Slf4j
public class ShoppingInvoicePageController {

    @Autowired
    OnlineMallLogic onlineMallLogic;

    /**
     * 发票信息维护页面
     *
     * @return 页面
     */
    @RequestMapping("/index")
    public String comparePriceIndex(){
        return ModuleConst.MODULE_ROOT +"/invoice/index";
    }


    /**
     * 详情页面
     */
    @AuditLogInter(value = "详情页面查询数据", module = "商城发票信息")
    @RequestMapping("/detail")
    public String detail(Model model, Long id) {
        ShoppingInvoice invoice;
        if (0L == id) {
            invoice = new ShoppingInvoice();
            invoice.setId(id);
        } else {
            invoice = onlineMallLogic.selectInvoiceDetailById(id);
        }
        model.addAttribute("data", invoice);
        return ModuleConst.MODULE_ROOT+"/invoice/detail";
    }


    /**
     * 商城比价中选择发票信息弹框
     *
     * @param model model
     * @param companyCode 公司代码
     * @param singleSelect 表格是否单选 0:多选 1:单选
     * @return 页面
     */
    @RequestMapping("/chose/invoice/dialog")
    public String choseSupDialog(Model model, String companyCode, Integer singleSelect){
        model.addAttribute("companyCode", companyCode);
        model.addAttribute("singleSelect", singleSelect);
        return ModuleConst.MODULE_ROOT+"/invoice/chose_invoice";
    }


}
