package com.cool.store.controller.webc;

import com.cool.store.request.fees.WalletCancelPayRequest;
import com.cool.store.request.fees.WalletPayRequest;
import com.cool.store.request.fees.WalletRepayRequest;
import com.cool.store.response.ResponseResult;
import com.cool.store.service.fees.ShopAllocationInfoService;
import com.cool.store.service.fees.WalletPayInfoService;
import com.cool.store.vo.fees.ShopAllocationSimpleVO;
import com.cool.store.vo.fees.WalletPayInfoVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.validation.constraints.NotNull;
import java.util.List;

/**
 * <p>
 * mini门店分账信息 前端控制器
 * </p>
 *
 * @author wangff
 * @since 2026/1/30
 */
@RestController
@Api(tags ="mini门店缴费信息")
@RequestMapping({"/mini/fees/shopAllocation"})
@RequiredArgsConstructor
@Validated
public class MiniShopAllocationController {
    private final ShopAllocationInfoService shopAllocationInfoService;
    private final WalletPayInfoService walletPayInfoService;

    @ApiOperation("平安钱包缴纳加盟费明细")
    @GetMapping("/walletPaymentDetail")
    public ResponseResult<List<ShopAllocationSimpleVO>> walletPaymentDetail(@NotNull(message = "门店id不能为空") Long shopId) {
        return ResponseResult.success(shopAllocationInfoService.getSimpleInfo(shopId));
    }

    @ApiOperation("缴费")
    @PostMapping("/pay")
    public ResponseResult<Boolean> pay(@RequestBody @Validated WalletPayRequest request) {
        return ResponseResult.success(walletPayInfoService.pay(request, null));
    }

    @ApiOperation("重新缴费")
    @PostMapping("/rePay")
    public ResponseResult<Boolean> rePay(@RequestBody @Validated WalletRepayRequest request) {
        return ResponseResult.success(walletPayInfoService.rePay(request));
    }

    @ApiOperation("取消支付")
    @PostMapping("/cancel")
    public ResponseResult<Boolean> cancel(@RequestBody @Validated WalletCancelPayRequest request) {
        return ResponseResult.success(walletPayInfoService.cancelPay(request));
    }

    @ApiOperation("缴费信息列表")
    @GetMapping("/payInfoList")
    public ResponseResult<List<WalletPayInfoVO>> payInfoList(@NotNull(message = "门店id不能为空") Long shopId) {
        return ResponseResult.success(walletPayInfoService.payInfoList(shopId, null));
    }
}
