
package com.tmerclub.cloud.supplier.controller.platform;

import com.tmerclub.cloud.common.response.ServerResponseEntity;
import com.tmerclub.cloud.common.security.AuthUserContext;
import com.tmerclub.cloud.supplier.dto.SupplierWithdrawCashConfigDto;
import com.tmerclub.cloud.supplier.dto.SupplierWithdrawCashDTO;
import com.tmerclub.cloud.supplier.service.SupplierWithdrawCashService;
import com.tmerclub.cloud.supplier.vo.SupplierWithdrawCashVO;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @Author lth
 * @Date 2021/6/11 9:28
 */
@RestController("platformSupplierWithdrawCashController")
@RequestMapping("/p/supplier_withdraw_cash")
@Tag(name = "platform-供应商提现申请信息")
public class SupplierWithdrawCashController {

    @Autowired
    private SupplierWithdrawCashService supplierWithdrawCashService;

    @GetMapping("/info")
    @Operation(summary = "根据提现记录id查看提现记录", description = "根据提现记录id查看提现记录")
    public ServerResponseEntity<SupplierWithdrawCashVO> getById(@RequestParam("cashId") Long cashId) {
        SupplierWithdrawCashVO supplierWithdrawCashVO = supplierWithdrawCashService.getDetailByCashId(cashId);
        return ServerResponseEntity.success(supplierWithdrawCashVO);
    }

    @PutMapping("/audit")
    @Operation(summary = "审核供应商提现信息", description = "审核供应商提现信息")
    public ServerResponseEntity<Void> audit(@RequestBody SupplierWithdrawCashDTO supplierWithdrawCashDTO) {
        supplierWithdrawCashService.auditWithdrawCash(supplierWithdrawCashDTO, AuthUserContext.get().getUserId());
        return ServerResponseEntity.success();
    }

    @PostMapping("/save")
    @Operation(summary = "设置提现金额", description = "设置提现金额")
    public ServerResponseEntity<Void> saveWithdrawCashConfig(@RequestBody SupplierWithdrawCashConfigDto supplierWithdrawCashConfigDto) {
        supplierWithdrawCashService.saveConfig(supplierWithdrawCashConfigDto);
        return ServerResponseEntity.success();
    }

    @GetMapping("/getWithdrawCash")
    public ServerResponseEntity<SupplierWithdrawCashConfigDto> getWithdrawCashConfig() {
        return ServerResponseEntity.success(supplierWithdrawCashService.getConfig());
    }

}
