package com.zfire.mall.manager.controller.manage.product.price;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.zfire.mall.manager.bean.manage.product.price.ProductPriceBean;
import com.zfire.mall.manager.helper.ResponseHelper;
import com.zfire.mall.manager.logic.manage.product.price.ProductPriceLogic;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

@Slf4j
@RestController
@Api(value = "产品价格列表", tags ={"产品价格列表"} )
@RequestMapping(value = "/product-price", produces = "application/json; charset=utf-8")
public class ProductPriceController {

    @Resource
    ProductPriceLogic productPriceLogic;

    @ApiOperation(value = "产品调价单列表")
    @GetMapping("/list")
    public ResponseHelper<IPage<ProductPriceBean>> list(
            @ApiParam(value = "产品编码") @RequestParam(required = false) String materialOldNumber,
            @ApiParam(value = "物料编码",required = false) @RequestParam(required = false) String materialNumber,
            @ApiParam(value = "产品名称",required = false) @RequestParam(required = false) String materialName,
            @ApiParam(value = "生效日期",required = false) @RequestParam(required = false) String startDate,
            @ApiParam(value = "失效日期",required = false) @RequestParam(required = false) String endDate,
            @ApiParam(value = "销售类型",required = false) @RequestParam(required = false) String saleTypeId,
            @ApiParam(value = "产品品类id",required = false) @RequestParam(required = false) String mainId,
            @ApiParam(value = "金蝶产品分类编号",required = false) @RequestParam(required = false) String k3CategoryNumber,
            @ApiParam(value = "规格",required = false) @RequestParam(required = false) String specification,
            @ApiParam(value = "备注",required = false) @RequestParam(required = false) String remark,
            @ApiParam(value = "单据类型",required = false) @RequestParam(required = false, defaultValue = "GENERAL") String billType,
            @ApiParam(value = "页号",required = true)@RequestParam Integer pageNum,
            @ApiParam(value = "页大小",required = true)@RequestParam Integer pageSize
    ) throws Exception {
        IPage<ProductPriceBean> listPage = productPriceLogic.listPage(materialOldNumber,materialNumber, materialName,
                startDate, endDate, saleTypeId, mainId,k3CategoryNumber, specification,remark, billType, pageNum, pageSize);
        return ResponseHelper.success(listPage);
    }

    @ApiOperation(value = "批量作废产品调价单记录")
    @PostMapping("/revoke")
    public ResponseHelper revoke(
            @ApiParam(required = true, value = "产品调价单id") @RequestParam List<String> ids
    ) throws Exception {
        productPriceLogic.revoke(ids);
        return ResponseHelper.success();
    }

    @ApiOperation(value = "批量删除")
    @PostMapping("/delete")
    public ResponseHelper delete(
            @ApiParam(required = true, value = "产品调价单ids") @RequestParam List<String> ids
    ) throws Exception {
        productPriceLogic.delete(ids);
        return ResponseHelper.success();
    }


}
