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


import com.zfire.mall.manager.bean.k3.KingDeeOtherStockInAdd;
import com.zfire.mall.manager.bean.k3.KingDeeOtherStockInDetail;
import com.zfire.mall.manager.helper.ResponseHelper;
import com.zfire.mall.manager.logic.k3.K3OtherStockInLogic;

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.*;

/**
 * @author CHANGE
 */
@Slf4j
@RestController
@Api(value = "其他入库单", tags = {"其他入库单"})
@RequestMapping(value = "/otherStockIn", produces = "application/json; charset=utf-8")
public class K3OtherStockInController {


    @Autowired
    K3OtherStockInLogic k3OtherStockInLogic;


    @ApiOperation(value = "新增其他入库单")
    @PostMapping("/add")
    public ResponseHelper add(
            @RequestBody KingDeeOtherStockInAdd kingDeePurchaseStockInAdd
    ) throws Exception {
        k3OtherStockInLogic.add(kingDeePurchaseStockInAdd);
        return ResponseHelper.success();
    }


    @ApiOperation(value = "其他入库单详情")
    @PostMapping("/detail")
    public ResponseHelper<KingDeeOtherStockInDetail> detail(
            @ApiParam(required = true, value = "id") @RequestParam(required = true) String id
    ) throws Exception {
        KingDeeOtherStockInDetail kingDeePurchaseStockInAdd = k3OtherStockInLogic.detail(id);
        return ResponseHelper.success(kingDeePurchaseStockInAdd);
    }

    @ApiOperation(value = "修改其他入库单")
    @PostMapping("/updateCustomer")
    public ResponseHelper updateCustomer(
            @RequestBody KingDeeOtherStockInAdd kingDeePurchaseStockInAdd
    ) throws Exception {
        k3OtherStockInLogic.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 {
        k3OtherStockInLogic.examine(billNo, cancelStatus);
        return ResponseHelper.success();
    }


}
