package com.fzm.mall.server.admin.finance_center.controller;

import com.fzm.mall.server.admin.annotation.AdminLog;
import com.fzm.mall.server.admin.enums.log.OperateModuleEnum;
import com.fzm.mall.server.admin.finance_center.entity.dto.PayModelDTO;
import com.fzm.mall.server.admin.finance_center.entity.vo.BaseIntegralDetailVO;
import com.fzm.mall.server.admin.finance_center.entity.vo.PayModeVO;
import com.fzm.mall.server.admin.finance_center.service.IMerchantPayModeService;
import com.fzm.mall.server.admin.finance_center.service.IPlatformIntegralService;
import com.fzm.mall.server.admin.home_page.enums.type.AdminTypeEnum;
import com.fzm.mall.server.admin.home_page.model.Admin;
import com.fzm.mall.server.admin.home_page.service.IAdminService;
import com.fzm.mall.server.admin.repo.ResponseFactory;
import com.fzm.mall.server.admin.repo.ResponseVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;
import java.util.List;

/**
 * @author wangp
 * @date 2021/4/26 15:53
 * @description 收付款方式
 * @since JDK 1.8
 */
@Api(tags = "财务中心-收付款方式")
@Validated
@RestController
@RequestMapping("/payMode")
@RequiredArgsConstructor(onConstructor = @__(@Autowired))
public class PayModeController {
    private final IMerchantPayModeService payModeService;
    private final ResponseFactory resFac;
    private final IAdminService adminService;
    private final IPlatformIntegralService platformIntegralService;

    //WAIT 提现审核

    @ApiOperation(value = "新增")
    //@AdminLog(description = "财务中心-新增商户收付款方式", module = OperateModuleEnum.FINANCE_CENTER)
    @PostMapping("/add")
    public ResponseVO add(@RequestBody @Valid List<PayModelDTO> dtos, @RequestHeader String adminId) {
        adminService.adminAuthChecks(adminId, AdminTypeEnum.getMerchantTypeArr());
        Admin admin = adminService.getByAdminId(adminId);
        payModeService.add(dtos, admin.getMerchantId());
        return resFac.getSimpleSuccessResponse();
    }

    @ApiOperation(value = "数字资产列表")
    @GetMapping("/digitAssetsList")
    public ResponseVO platformBaseIntegralDetail(@RequestHeader String adminId) {
        adminService.adminAuthChecks(adminId, AdminTypeEnum.getMerchantTypeArr());
        List<String> list = platformIntegralService.digitAssetsList();
        return resFac.getSuccessResponseWithData(list);
    }

    @ApiOperation(value = "查询支付方式")
    @GetMapping("/queryPayMode")
    public ResponseVO queryPayMode(@RequestHeader String adminId) {
        adminService.adminAuthChecks(adminId, AdminTypeEnum.getMerchantTypeArr());
        Admin admin = adminService.getByAdminId(adminId);
        List<PayModeVO> list = payModeService.queryPayMode(admin.getMerchantId());
        return resFac.getSuccessResponseWithData(list);
    }
}
