package com.kxs.store.biz.controller.kxsapp;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.kxs.common.core.util.R;
import com.kxs.store.api.dto.kxsapp.storeAdvance.StoreAdvanceAddAdvanceDTO;
import com.kxs.store.api.model.KxsMachineAdvance;
import com.kxs.store.api.model.KxsMachineAdvanceInfo;
import com.kxs.store.api.model.KxsWarehouseLimit;
import com.kxs.store.api.vo.kxsapp.storeAdvance.UserWarehouseListVO;
import com.kxs.store.biz.mapper.KxsWarehouseLimitMapper;
import com.kxs.store.biz.service.KxsMachineAdvanceService;
import com.kxs.store.biz.service.KxsWarehouseLimitService;
import com.kxs.store.biz.service.KxsWarehouseUserService;
import jakarta.validation.Valid;
import lombok.RequiredArgsConstructor;
import org.springdoc.core.annotations.ParameterObject;
import org.springframework.web.bind.annotation.*;

import java.math.BigDecimal;
import java.util.List;

/**
 * 仓库模块(StoreAdvance)控制层
 *
 * @author 系统
 * @since 2024-01-10 11:43:19
 */
@RestController
@RequiredArgsConstructor
@RequestMapping("storeAdvance")
public class StoreAdvanceController {

    /**
     * 服务对象
     */
    private final KxsWarehouseUserService kxsWarehouseUserService;
    private final KxsMachineAdvanceService kxsMachineAdvanceService;
    private final KxsWarehouseLimitService kxsWarehouseLimitService;



    /**
     * 小分仓-列表
     *
     * @param page 分页对象
     * @return 小分仓-列表
     */
    @GetMapping("/getUserWareHouseList")
    public R getUserWareHouseList(@ParameterObject Page<UserWarehouseListVO> page) {

        return R.ok(kxsMachineAdvanceService.getUserWareHouseList(page));
    }


    /**
     * 小分仓-撤回机具
     *
     * @param advance sn号
     * @return 小分仓-撤回机具
     */
    @PostMapping("/cancelAdvance")
    public R cancelAdvance(@RequestBody KxsMachineAdvanceInfo advance){

        return kxsMachineAdvanceService.cancelAdvance(advance);
    }


    /**
     * 小分仓-预发货到小分仓
     *
     * @param param 实体对象
     * @return 小分仓-预发货到小分仓
     */
    @PostMapping("/addAdvance")
    public R addAdvance(@Valid @RequestBody StoreAdvanceAddAdvanceDTO param) {

        return kxsMachineAdvanceService.addAdvanceMachine(param);
    }


    /**
     * 小分仓-查询用户
     *
     * @param userCode 用户编号
     * @return 小分仓-查询用户
     */
    @GetMapping("/getUserDetail")
    public R getUserDetail(@RequestParam("userCode") String userCode, @RequestParam("amount") BigDecimal amount) {

        return R.ok(kxsWarehouseLimitService.getUserDetail(userCode, amount));
    }





}

