package com.yuchen.saas.parking.api.feign;

import com.yuchen.saas.parking.api.entity.StaggeredMonthChargeRule;
import com.yuchen.saas.parking.api.entity.StaggeredMonthlyCardBillData;
import com.yuchen.saas.parking.api.vo.RefundCardVo;
import com.yuchen.saas.parking.api.vo.StaggeredMonthlyCardBillDataVo;
import com.yuchen.saas.parking.api.vo.StaggeredMonthlyCardDataVo;
import com.yuchen.saas.parking.api.vo.StaggeredMonthlyCardDetailVo;
import io.swagger.annotations.ApiOperation;
import org.nest.springwrap.core.launch.app.AppNameConstant;
import org.nest.springwrap.core.tool.api.R;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestParam;

import java.util.List;

/**
 * @ClassName StaggeredMonthlyCardClient
 * @Description 调用core-service的错时停车接口
 * @Author 肖润飞
 * @Date 2022/9/23 16:42
 */
@FeignClient(
        value = AppNameConstant.SAAS_PARKING,
        fallbackFactory = StaggeredMonthlyCardClientFallback.class
)
public interface StaggeredMonthlyCardClient {

    /**
     * 获取车辆错时停车分页数据
     * @param payUserId 移动端用户唯一ID
     * @param payUserId 移动端用户登陆的手机号
     * @param current 当前页码
     * @param size 每页数量
     * @return
     */
    @GetMapping("/staggered/card/page")
    R getAuditPage(@RequestParam String payUserId, @RequestParam String personPhone, @RequestParam Integer current,
                   @RequestParam Integer size);

    /**
     * 用户申请错时停车
     * @param cardDataVo 用户申请月卡相关数据
     * @return
     */
    @PostMapping("/staggered/card/add")
    R applyMonthlyCard(@RequestBody StaggeredMonthlyCardDataVo cardDataVo);
    /**
     * 用户申请错时停车免费
     * @param cardDataVo 用户申请月卡相关数据
     * @return
     */
    @PostMapping("/staggered/card/applyFree")
    R applyFree(@RequestBody StaggeredMonthlyCardDataVo cardDataVo);

    /**
     * 用户修改错时停车
     * @param cardDataVo 用户修改月卡相关数据
     * @return
     */
    @PostMapping("/staggered/card/update")
    R updateMonthlyCard(@RequestBody StaggeredMonthlyCardDataVo cardDataVo);
    /**
     * 用户删除错时停车
     * @param id 月卡ID
     * @return
     */
    @PostMapping("/staggered/card/delCardData")
    R delMonthlyCard(@RequestParam Long id);

    /**
     * 创建错时停车支付
     * @param payUserId 移动端用户唯一ID
     * @param id 月卡ID
     * @param number 月数量
     * @return
     */
    @GetMapping("/staggered/card/activate")
    R<StaggeredMonthlyCardBillData> createMonthlyCardPay(@RequestParam String payUserId, @RequestParam Long id,
                                                         @RequestParam Integer number);

    /**
     * 根据ID查询错时停车账单详细信息
     * @param payUserId 移动端用户唯一ID
     * @param id 包期账单表
     * @return
     */
    @GetMapping("/staggered/bill/details")
    R<StaggeredMonthlyCardBillDataVo> getMonthlyCardBill(@RequestParam String payUserId, @RequestParam Long id);

    /**
     * 错时停车支付完成回调
     * @param id 月卡支付ID
     * @return
     */
    @PostMapping("/staggered/card/pay_success")
    R monthlyCardPaySuccess(@RequestBody Long id);

    /**
     * 获取停车场错时停车规则
     * @param parkId 园区id
     * @return
     */
    @GetMapping("/staggered/rule/list")
    R<List<StaggeredMonthChargeRule>> getStaggeredRule(@RequestParam("parkId") Long parkId, @RequestParam("parkingId") Long parkingId);

    /**
     * 查询剩余车位(暂时没用)
     * @param parkId
     * @return
     */
    @GetMapping("/staggered/card/residue")
    R getResidueCard(@RequestParam Long parkId);

    /**
     * 查询剩余车位根据包期规则
     * @param parkId
     * @param ruleId
     * @return
     */
    @GetMapping("/staggered/card/residueByRuleId")
    R residueByRuleId(@RequestParam Long parkId,@RequestParam Long ruleId);

    /**
     * 获取退款信息
     * @param id 错时卡ID
     * @param refundTime 退款时间戳(秒)
     * @return
     */
    @GetMapping("/staggered/card/getRefundInfo")
    @ApiOperation(value = "获取退款信息", notes = "获取退款信息")
    R getRefundInfo(@RequestParam Long id, @RequestParam Long refundTime);

    /**
     * 获取退款信息
     * @param billId 错时卡账单ID
     * @param refundTime 退款时间戳(秒)
     * @return
     */
    @GetMapping("/staggered/card/getRefundMoney")
    @ApiOperation(value = "获取退款信息", notes = "获取退款信息")
    R<Long> getRefundMoney(@RequestParam Long billId, @RequestParam Long refundTime);

    /**
     * 错时退卡
     * @param refundCardVo 退卡信息
     * @return
     */
    @PostMapping("/staggered/card/refundCard")
    @ApiOperation(value = "错时退卡", notes = "错时退卡")
    R refundCard(@RequestBody RefundCardVo refundCardVo);

    // ------------------------------    小程序管理端    ------------------------------
    /**
     * 审核回显详情
     *
     * @param id
     * @return
     * @tag pauly-lyz
     */
    @GetMapping("/staggered/card//getAuditDetail")
    R<StaggeredMonthlyCardDetailVo>  getAuditDetail(@RequestParam(required = true) Long id);
}
