package com.zfire.mall.manager.controller.k3;


import com.baomidou.mybatisplus.core.metadata.IPage;
import com.zfire.mall.manager.bean.ExcelData;
import com.zfire.mall.manager.bean.k3.KingDeePurchaseStockInBean;
import com.zfire.mall.manager.bean.k3.KingDeePurchaseStockInData;
import com.zfire.mall.manager.bean.k3.KingDeePurchaseStockOutAdd;
import com.zfire.mall.manager.bean.k3.KingDeePurchaseStockOutData;
import com.zfire.mall.manager.bean.stock.KingDeePurchaseStockInAdd;
import com.zfire.mall.manager.helper.ResponseHelper;
import com.zfire.mall.manager.logic.k3.K3PurchaseStockInLogic;
import com.zfire.mall.manager.logic.k3.K3PurchaseStockOutLogic;
import com.zfire.mall.manager.plus.entity.KingDeePurchaseStockOut;
import com.zfire.mall.manager.utils.excel.ExcelUtils;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * @author CHANGE
 */
@Slf4j
@RestController
@Api(value = "采购退料单", tags ={"采购退料单"} )
@RequestMapping(value = "/purchaseStockOut", produces = "application/json; charset=utf-8")
public class K3PurchaseStockOutController {


    @Autowired
    K3PurchaseStockOutLogic k3PurchaseStockOutLogic;


    @ApiOperation(value = "采购退料单详情")
    @PostMapping("/detail")
    public ResponseHelper<KingDeePurchaseStockOutData> detail(
            @ApiParam(required = true, value = "id") @RequestParam(required = true) String id
    ) throws Exception {
        KingDeePurchaseStockOutData kingDeePurchaseStockInData = k3PurchaseStockOutLogic.detail(id);
        return ResponseHelper.success(kingDeePurchaseStockInData);
    }




    @ApiOperation(value = "新增采购退料单")
    @PostMapping("/add")
    public ResponseHelper add(
            @RequestBody KingDeePurchaseStockOutAdd kingDeePurchaseStockInAdd
    ) throws Exception {
        k3PurchaseStockOutLogic.add(kingDeePurchaseStockInAdd);
        return ResponseHelper.success();
    }

    @ApiOperation(value = "修改采购退料单")
    @PostMapping("/updateCustomer")
    public ResponseHelper updateCustomer(
            @RequestBody KingDeePurchaseStockOutAdd kingDeePurchaseStockInAdd
    ) throws Exception {
        k3PurchaseStockOutLogic.update(kingDeePurchaseStockInAdd);
        return ResponseHelper.success();
    }



    @ApiOperation(value = "审批采购退料单")
    @PostMapping("/examine")
    public ResponseHelper examine(
            @ApiParam(required = false, value = "单据编号") @RequestParam(required = false) String billNo,
            @ApiParam(required = false, value = "  OK通过  WAIT待审 FAIL 不通过") @RequestParam(required = false) String cancelStatus
    ) throws Exception {
        k3PurchaseStockOutLogic.examine(billNo,cancelStatus);
        return ResponseHelper.success();
    }


}
