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

import com.tmerclub.cloud.common.constant.Constant;
import com.tmerclub.cloud.common.database.dto.PageDTO;
import com.tmerclub.cloud.common.database.vo.PageVO;
import com.tmerclub.cloud.common.response.ServerResponseEntity;
import com.tmerclub.cloud.common.security.AuthUserContext;
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.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.Objects;

/**
 * 商家提现申请信息
 *
 * @Author lth
 * @Date 2021/6/11 9:23
 */
@RestController("adminShopWithdrawCashController")
@RequestMapping("/mp/shopWithdrawApply")
@Tag(name = "admin-商家提现申请信息")
public class ShopWithdrawCashController {

    @Autowired
    private ShopWithdrawCashService shopWithdrawCashService;

    @GetMapping("/page")
    @Operation(summary = "分页获取商家提现记录信息", description = "分页获取商家提现记录信息")
    public ServerResponseEntity<PageVO<ShopWithdrawCashVO>> page(PageDTO pageDTO, ShopWithdrawCashDTO shopWithdrawCashDTO) {
        Long shopId = AuthUserContext.get().getTenantId();
        if (!Objects.equals(shopId, Constant.PLATFORM_SHOP_ID)) {
            shopWithdrawCashDTO.setShopId(shopId);
        }
        PageVO<ShopWithdrawCashVO> pageVO = shopWithdrawCashService.pageByParam(pageDTO, shopWithdrawCashDTO);
        return ServerResponseEntity.success(pageVO);
    }

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