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.storeLimit.ForAmountWithdrawDTO;
import com.kxs.store.api.dto.kxsapp.userAdvance.ConfirmAdvanceMachineDTO;
import com.kxs.store.api.model.KxsWarehouseLimit;
import com.kxs.store.api.vo.kxsapp.userAdvance.UserAdvanceListVO;
import com.kxs.store.biz.service.KxsForAmountWithdrawService;
import com.kxs.store.biz.service.KxsMachineAdvanceService;
import com.kxs.store.biz.service.KxsWarehouseLimitService;
import jakarta.validation.Valid;
import lombok.RequiredArgsConstructor;
import org.springdoc.core.annotations.ParameterObject;
import org.springframework.web.bind.annotation.*;

/**
 * 用户预发机(UserAdvance)控制层
 *
 * @author 系统
 * @since 2024-01-10 11:43:19
 */
@RestController
@RequiredArgsConstructor
@RequestMapping("userAdvance")
public class UserAdvanceController {

    /**
     * 服务对象
     */
    private final KxsWarehouseLimitService kxsWarehouseLimitService;
    private final KxsMachineAdvanceService kxsMachineAdvanceService;
    private final KxsForAmountWithdrawService kxsForAmountWithdrawService;

    /**
     * 25-29天预发机弹窗接口
     *
     * @return {@link R}
     */
    @GetMapping("/userPrePosModal")
    public R userPrePosModal() {

        return R.ok(kxsMachineAdvanceService.userPrePosModal());
    }

    /**
     * 预发机已绑定未申请弹窗
     *
     * @return {@link R}
     */
    @GetMapping("/userPrePosBindModal")
    public R userPrePosBindModal() {

        return R.ok(kxsMachineAdvanceService.userPrePosBindModal());
    }

    /**
     * 用户预发机额度初始化
     * 内部调用
     *
     * @return 预发机额度详情
     */
    @Inner
    @PostMapping("/addUserAdvanceLimit")
    public R addUserAdvanceLimit(@RequestBody KxsWarehouseLimit kxsWarehouseLimit) {

        return R.ok(kxsWarehouseLimitService.addUserAdvanceLimit(kxsWarehouseLimit));
    }

    /**
     * 预发机额度详情
     *
     * @return 预发机额度详情
     */
    @GetMapping("/advanceAmount")
    public R advanceAmount() {

        return R.ok(kxsWarehouseLimitService.advanceAmount());
    }


    /**
     * 预发机列表
     *
     * @return 预发机列表
     */
    @GetMapping("/advanceUserList")
    public R advanceUserList() {

        return R.ok(kxsMachineAdvanceService.advanceUserList());
    }


    /**
     * 临额提现
     *
     * @param param 实体对象
     * @return 临额提现
     */
    @PostMapping("/forAmountWithdraw")
    public R forAmountWithdraw(@RequestBody ForAmountWithdrawDTO param) {

        return kxsForAmountWithdrawService.forAmountWithdraw(param);
    }


    /**
     * 接收预发机弹窗
     *
     * @return 接收预发机弹窗
     */
    @GetMapping("/advanceDevModal")
    public R advanceDevModal() {

        return R.ok(kxsMachineAdvanceService.advanceDevModal());
    }


    /**
     * 接收预发机
     *
     * @param param 实体对象
     * @return 接收预发机
     */
    @PostMapping("/confirmAdvanceMachine")
    public R confirmAdvanceMachine(@Valid @RequestBody ConfirmAdvanceMachineDTO param) {

        return kxsMachineAdvanceService.confirmAdvanceMachine(param);
    }





}

