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.common.security.annotation.Inner;
import com.kxs.store.api.dto.kxsapp.storeRecycle.RecycleConfirmDTO;
import com.kxs.store.api.dto.kxsapp.storeRecycle.RecycleSubmitDTO;
import com.kxs.store.api.dto.kxsapp.storeRecycle.StoreRecycleMachineListDTO;
import com.kxs.store.api.dto.kxsapp.storeRecycle.UserReturnRecycleDTO;
import com.kxs.store.api.model.KxsMachineRecycle;
import com.kxs.store.api.vo.kxsapp.storeRecycle.NeedConfirmRecycleVO;
import com.kxs.store.api.vo.kxsapp.storeRecycle.RecycleUserListVO;
import com.kxs.store.api.vo.kxsapp.storeRecycle.StoreRecycleMachineListVO;
import com.kxs.store.biz.service.KxsMachineRecycleService;
import jakarta.validation.Valid;
import lombok.RequiredArgsConstructor;
import org.springdoc.core.annotations.ParameterObject;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 仓库模块(StoreRecycle)控制层
 *
 * @author 系统
 * @since 2024-01-08 11:15:03
 */
@RestController
@RequiredArgsConstructor
@RequestMapping("storeRecycle")
public class StoreRecycleController {

    /**
     * 服务对象
     */
    private final KxsMachineRecycleService kxsMachineRecycleService;



    /**
     * 待回收机具-列表
     *
     * @param page 分页对象
     * @return 待回收机具-列表
     */
    @Inner
    @GetMapping("/recycleMachineList")
    public R recycleMachineList(@ParameterObject Page<StoreRecycleMachineListVO> page, @Valid @ParameterObject StoreRecycleMachineListDTO param) {

        return R.ok(kxsMachineRecycleService.getByPage(page, param));
    }

    /**
     * 用户机具回收列表
     *
     * @return 用户机具回收列表
     */
    @GetMapping("/recycleSnList")
    public R recycleSnList() {

        return R.ok(kxsMachineRecycleService.recycleSnList());
    }

    /**
     * 待回收机具-确认收货
     *
     * @param param 确认收货
     * @return 待回收机具-确认收货
     */
    @PostMapping("/confirm")
    public R confirm(@Valid @RequestBody RecycleConfirmDTO param) {

        return kxsMachineRecycleService.confirm(param);
    }

    /**
     * 待回收机具-确认收货
     *
     * @param param 确认收货
     * @return 待回收机具-确认收货
     */
    @PostMapping("/cancel")
    public R cancel(@Valid @RequestBody RecycleConfirmDTO param) {

        return kxsMachineRecycleService.cancel(param);
    }


    /**
     * 待回收机具-数量接口
     *
     * @return 待回收机具-数量接口
     */
    @GetMapping("/recycleCount")
    public R recycleCount() {

        return R.ok(kxsMachineRecycleService.recycleCount());
    }


    /**
     * 机具回收-用户机具寄回
     *
     * @param param 机具寄回
     * @return 机具回收-机具寄回
     */
    @PostMapping("/userSubmit")
    public R userSubmit(@Valid @RequestBody RecycleSubmitDTO param) {

        return kxsMachineRecycleService.userSubmit(param);
    }

    /**
     * 机具回收-撤回
     *
     * @param param 撤回
     * @return 机具回收-撤回
     */
    @PostMapping("/userReturnRecycle")
    public R userReturnRecycle(@RequestBody UserReturnRecycleDTO param) {

        return kxsMachineRecycleService.userReturnRecycle(param);
    }

    /**
     * 机具回收-用户寄回记录
     *
     * @return 用户寄回记录
     */
    @GetMapping("/userList")
    public R userList(@ParameterObject Page<RecycleUserListVO> page) {

        return R.ok(kxsMachineRecycleService.userList(page));
    }

    /**
     * 机具回收-待确认列表
     *
     * @return 机具回收-待确认列表
     */
    @GetMapping("/needConfirmList")
    public R needConfirmList(@ParameterObject Page<NeedConfirmRecycleVO> page, @RequestParam("brandId") Integer brandId) {

        return R.ok(kxsMachineRecycleService.needConfirmList(page, brandId));
    }

    /**
     * 机具回收-可回收数量接口
     *
     * @return 可回收数量接口
     */
    @GetMapping("/recoverableData")
    public R recoverableData() {

        return R.ok(kxsMachineRecycleService.recoverableData());
    }

}

