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

import com.tmerclub.cloud.common.response.ServerResponseEntity;
import com.tmerclub.cloud.common.security.AuthUserContext;
import com.tmerclub.cloud.multishop.dto.ShopWithdrawCashConfigDto;
import com.tmerclub.cloud.multishop.dto.ShopWithdrawCashDTO;
import com.tmerclub.cloud.multishop.service.ShopWithdrawCashService;
import com.tmerclub.cloud.multishop.vo.ShopWithdrawCashVO;
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("platformShopWithdrawCashController")
@RequestMapping("/p/shop_withdraw_cash")
@Tag(name = "platform-商家提现申请信息")
public class ShopWithdrawCashController {

    @Autowired
    private ShopWithdrawCashService shopWithdrawCashService;

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

    @PutMapping("/audit")
    @Operation(summary = "审核商家提现信息", description = "审核商家提现信息")
    public ServerResponseEntity<Void> audit(@RequestBody ShopWithdrawCashDTO shopWithdrawCashDTO) {
        shopWithdrawCashService.auditWithdrawCash(shopWithdrawCashDTO, AuthUserContext.get().getUserId());
        return ServerResponseEntity.success();
    }

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

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