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.bean.k3.KingDeeOtherStockOutAdd;
import com.zfire.mall.manager.bean.k3.KingDeeOtherStockOutDetail;
import com.zfire.mall.manager.helper.ResponseHelper;
import com.zfire.mall.manager.logic.k3.K3OtherStockInLogic;
import com.zfire.mall.manager.logic.k3.K3OtherStockOutLogic;
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 = "/otherStockOut", produces = "application/json; charset=utf-8")
public class K3OtherStockOutController {


    @Autowired
    K3OtherStockOutLogic k3OtherStockOutLogic;


    @ApiOperation(value = "新增其他出库单")
    @PostMapping("/add")
    public ResponseHelper add(
            @RequestBody KingDeeOtherStockOutAdd KingDeeOtherStockOutAdd
    ) throws Exception {
        k3OtherStockOutLogic.add(KingDeeOtherStockOutAdd);
        return ResponseHelper.success();
    }

    @ApiOperation(value = "修改其他出库单")
    @PostMapping("/updateCustomer")
    public ResponseHelper updateCustomer(
            @RequestBody KingDeeOtherStockOutAdd kingDeeOtherStockOutAdd
    ) throws Exception {
        k3OtherStockOutLogic.update(kingDeeOtherStockOutAdd);
        return ResponseHelper.success();
    }


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


    @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 {
        k3OtherStockOutLogic.examine(billNo, cancelStatus);
        return ResponseHelper.success();
    }


}
