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

import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import com.yuchen.saas.parking.api.dto.ParkingBillByCouponDTO;
import com.yuchen.saas.parking.api.entity.PmgBatParkBill;
import com.yuchen.saas.parking.api.entity.PmgBatParkBillLog;
import com.yuchen.saas.parking.api.entity.PmgBatParkParking;
import com.yuchen.saas.parking.api.entity.VehicleOccupancyFeeBill;
import com.yuchen.saas.parking.api.vo.*;
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.*;

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

/**
 * 车辆收费处理类
 * 收费流程相关的接口调用
 *
 * @author 刘碧清
 * @version 1.0
 * @date 2021-05-26 17:54
 */
@FeignClient(
        value = AppNameConstant.SAAS_PARKING,
        fallbackFactory = PmgBatCarChargeHandlerBack.class
)
public interface PmgBatCarChargeClient {

    /**
     * 公众号无牌车登记入场
     *
     * @param pmgBatParkBillVo 车辆数据
     * @return
     */
    @PostMapping("/parking/carChargeHandler/entranceSave")
    R entranceSave(@Valid @RequestBody PmgBatParkBillVo pmgBatParkBillVo);


    //region 账单相关

    /*    */

    /**
     * 结算账单
     * 公众号结算完账单后调用该方法
     *
     * @param paidCost 已支付账单金额 分
     * @return
     *//*
    @PostMapping("/parking/carChargeHandler/settleAccounts")
    R settleAccounts(@RequestParam(value = "billId") Long billId
            , @RequestParam(value = "paidCost") Long paidCost
            , @RequestParam(value = "paidPlaceIdleCost") Long paidPlaceIdleCost
            , @RequestParam(value = "payUserId") String payUserId
            , @RequestParam(value = "payType") String payType) ;*/
    @ApiOperationSupport(order = 4)
    @ApiOperation(value = "结算账单(公众号结算完账单后调用该方法)", notes = "结算账单(公众号结算完账单后调用该方法)")
    @PostMapping("/parking/carChargeHandler/settleAccounts")
    R settleAccounts(@RequestParam(value = "plateNo") String plateNo
            , @RequestParam(value = "parkingId") Long parkingId
            , @RequestParam(value = "paidCost") String paidCost);

    @ApiOperationSupport(order = 4)
    @ApiOperation(value = "临停结算账单", notes = "结算账单")
    @PostMapping("/parking/carChargeHandler/updateBillById")
    R updateBillById(@RequestBody PmgBatParkBill pmgBatParkBill);

    @ApiOperationSupport(order = 4)
    @ApiOperation(value = "结算账单(公众号结算完账单后调用该方法)", notes = "结算账单(公众号结算完账单后调用该方法)")
    @PostMapping("/parking/carChargeHandler/updatePaymentBill")
    R<ResultDTO> updatePaymentBill(@RequestParam(value = "billId") Long billId
            , @RequestParam(value = "paidCost") Long paidCost
            , @RequestParam(value = "paidPlaceIdleCost") Long paidPlaceIdleCost
            , @RequestParam(value = "payUserId") String payUserId
            , @RequestParam(value = "payType") String payType
            , @RequestParam(value = "tenantId") String tenantId
            , @RequestParam(value = "parkingId") Long parkingId);

    @PostMapping("/parking/carChargeHandler/updatePaymentBillV2")
    R<ResultDTO> updatePaymentBillV2(@RequestParam(value = "billId") Long billId
            , @RequestParam(value = "paidCost") Long paidCost
            , @RequestParam(value = "paidPlaceIdleCost") Long paidPlaceIdleCost
            , @RequestParam(value = "payUserId") String payUserId
            , @RequestParam(value = "payType") String payType
            , @RequestParam(value = "tenantId") String tenantId
            , @RequestParam(value = "parkingId") Long parkingId
            , @RequestParam(value = "couponCode") String couponCode);

    @ApiOperationSupport(order = 4)
    @ApiOperation(value = "结算账单(公众号结算完账单后调用该方法)", notes = "结算账单(公众号结算完账单后调用该方法)")
    @PostMapping("/parking/carChargeHandler/updateOccFeePaymentBill")
    R<ResultDTO> updateOccFeePaymentBill(@RequestParam(value = "billId") Long billId
            , @RequestParam(value = "paidCost") Long paidCost
            , @RequestParam(value = "paidPlaceIdleCost") Long paidPlaceIdleCost
            , @RequestParam(value = "payUserId") String payUserId
            , @RequestParam(value = "payType") String payType
            , @RequestParam(value = "tenantId") String tenantId
            , @RequestParam(value = "parkingId") Long parkingId);

    @ApiOperationSupport(order = 4)
    @ApiOperation(value = "占位费结算账单", notes = "占位费结算账单")
    @PostMapping("/parking/carChargeHandler/updateOccFeeBillById")
    R updateOccFeeBillById(@RequestBody VehicleOccupancyFeeBill vehicleOccupancyFeeBill);

    /**
     * 获取未结清所有账单
     * 有未结清的获取未结清的账单，没有获取最后一张已结清的账单
     *
     * @param parkingId 停车场id
     * @param plateNo   车牌号
     * @param noPlateId 无牌车id 无牌车必传，其他传空
     * @return
     */
    @GetMapping("/parking/carChargeHandler/getOneBill")
    R<PmgBatParkBill> getOneBill(@RequestParam Long parkingId, @RequestParam String plateNo, @RequestParam Long noPlateId);


    /**
     * 获取未结清所有账单(场中场显示两条,一个园区一个停车场的话显示一条)
     * 有未结清的获取未结清的账单，没有获取最后一张已结清的账单
     *
     * @param parkingId 停车场id
     * @param plateNo   车牌号
     * @param noPlateId 无牌车id 无牌车必传，其他传空
     * @return
     */
    @GetMapping("/parking/carChargeHandler/getQuickBill")
    R<List<ParkingSettleBillVo>> getBillList(@RequestParam Long parkingId, @RequestParam String plateNo, @RequestParam Long noPlateId);

    /**
     * 获取已出场未结清所有账单(场中场显示两条,一个园区一个停车场的话显示一条)
     *
     * @param parkingId 停车场id
     * @param plateNo   车牌号
     * @param noPlateId 无牌车id 无牌车必传，其他传空
     * @return
     */
    @GetMapping("/parking/carChargeHandler/getSupplementaryPaymentBillList")
    R<List<ParkingSettleBillVo>> getSupplementaryPaymentBillList(@RequestParam Long parkingId, @RequestParam String plateNo, @RequestParam Long noPlateId);

    /**
     * 获取未结清所有账单
     * 有未结清的获取未结清的账单，没有获取最后一张已结清的账单
     *
     * @param parkingId 停车场id
     * @param plateNo   车牌号
     * @param
     * @return
     */
    @GetMapping("/parking/carChargeHandler/getOneBillNoReSettlement")
    R<PmgBatParkBill> getOneBillNoReSettlement(@RequestParam Long parkingId, @RequestParam String plateNo);


    @PostMapping("/parking/carChargeHandler/getCarRuleConfigById")
    @ApiOperationSupport(order = 2)
    @ApiOperation(value = "公众号无牌车登记入场", notes = "公众号无牌车登记入场")
    R getCarRuleConfigById(@RequestParam(value = "ruleId") Long ruleId);

    /**
     * 结算前获取账单详细信息-用户确认订单前金额判断
     * 用于支付前调用
     */
    @GetMapping("/parking/carChargeHandler/getParkingBillByIdVerifyCost")
    R<PmgBatParkBill> getParkingBillByIdVerifyCost(@RequestParam String billId);

    /**
     * 结算前获取账单详细信息
     * 用于支付前调用
     *
     * @param billId 账单id
     * @return
     */
    @GetMapping("/parking/carChargeHandler/getBillById")
    R<PmgBatParkBill> createBillPayment(@RequestParam String billId);

    /**
     * 结算前获取账单详细信息
     * 用于支付前调用
     *
     * @param pmgBatParkBill 账单对象
     * @return
     */
    @PostMapping("/parking/carChargeHandler/updateBillPayment")
    R<PmgBatParkBill> updateBillPayment(@RequestBody PmgBatParkBill pmgBatParkBill);

    @GetMapping("/parking/carChargeHandler/getOccupancyBillByIdVerifyCost")
    R<VehicleOccupancyFeeBill> getOccupancyBillByIdVerifyCost(@RequestParam String billId);


    @GetMapping("/parking/carChargeHandler/getOccFeeBillById")
    R<VehicleOccupancyFeeBill> createOccFeeBillPayment(@RequestParam String billId);

    /**
     * 更新开票状态
     *
     * @param ids             月卡id集合
     * @param monthlyBill     1-月卡开票状态更新，0-其他开票账单更新
     * @param invoicingStatus 状态
     * @return
     */
    @PostMapping("/parking/carChargeHandler/updateInvoicingStatus")
    R updateInvoicingStatus(@RequestParam String ids, @RequestParam Integer monthlyBill, @RequestParam Integer invoicingStatus);

    /**
     * 获取已结清所有账单列表
     *
     * @param searchBillVo 查询条件
     * @return
     */
    @PostMapping("/parking/carChargeHandler/getBillPageList")
    R getBillPageList(@Valid @RequestBody SearchBillVo searchBillVo);

    /**
     * 获取已结清所有账单列表
     *
     * @param billIds 查询条件
     * @return
     */
    @PostMapping("/parking/carChargeHandler/getBillPageListNew")
    R getBillPageListNew(@Valid @RequestBody List<String> billIds);

    /**
     * 账单获取详细列表数据
     *
     * @param payUserId       用户id
     * @param invoicingStatus 开票状态
     * @param billIds         账单ids
     * @return
     */
    @GetMapping("/parking/carChargeHandler/getBillList")
    R<List<PmgBatParkBillLog>> getBillList(@RequestParam String payUserId, @RequestParam String invoicingStatus, @RequestParam String billIds);
    //endregion

    //region 月卡相关

    /**
     * 获取收费规则
     * 通过停车场ID、包期类型、车辆类型获取收费规则
     *
     * @param parkingId   停车场id
     * @param vehicleType 车辆类型（0：包月，1：包年，2：闲时月包）
     * @param ruleType    包期类型 闲时月包模板ID（0：工作日计划模板，1：周末计划模板）
     * @return
     */
    @GetMapping("/parking/chargeRule/getRuleDetails")
    R getRuleDetails(@RequestParam String parkingId, @RequestParam String vehicleType, @RequestParam String ruleType);

    /**
     * 根据停车场ID查询园区ID
     *
     * @param parkingId 停车场ID
     * @return
     */
    @GetMapping("/parking/carChargeHandler/getParkingInfo")
    R<PmgBatParkParking> getParkingInfo(@RequestParam Long parkingId);
    //endregion

    // --------------------------------     新代码     --------------------------------


    @ApiOperationSupport(order = 5)
    @ApiOperation(value = "获取未结清所有占位费账单", notes = "获取未结清所有账单")
    @GetMapping("/parking/carChargeHandler/getOccFeeBillsByPlateNo")
    R<List<VehicleOccupancyFeeBill>> getOccFeeBillsByPlateNo(@RequestParam String plateNo, @RequestParam String parkingId);

    @ApiOperationSupport(order = 5)
    @ApiOperation(value = "获取未结清所有账单", notes = "获取未结清所有账单")
    @GetMapping("/parking/carChargeHandler/getOneBillById")
    R<PmgBatParkBill> getOneBillById(@RequestParam String billId);

    @ApiOperationSupport(order = 5)
    @ApiOperation(value = "获取占位费账单", notes = "获取占位费账单")
    @GetMapping("/parking/carChargeHandler/getOccFeeOneBillById")
    R<VehicleOccupancyFeeBill> getOccFeeOneBillById(@RequestParam String billId);

    /**
     * 获取停车场账单
     *
     * @param parkingBillVo 停车场账单查询参数
     * @return
     */
    @ApiOperationSupport(order = 5)
    @ApiOperation(value = "获取停车场未结清的账单", notes = "获取停车场未结清的账单")
    @PostMapping("/parking/carChargeHandler/getParkingBill")
    R<PmgBatParkBill> getParkingBill(@RequestBody ParkingBillVo parkingBillVo);

    @ApiOperationSupport(order = 5)
    @ApiOperation(value = "根据优惠券二维码获取停车账单(优惠券直接抵扣)", notes = "根据优惠券二维码获取停车账单(优惠券直接抵扣)")
    @GetMapping("/parking/carChargeHandler/getBillByCoupon")
    R<ParkingSettleBillByCouponVo> getBillByCoupon(@RequestParam String plateNo, @RequestParam Long qrCodeId);

    @ApiOperationSupport(order = 5)
    @ApiOperation(value = "使用优惠卷直接抵扣账单", notes = "使用优惠卷直接抵扣账单")
    @PostMapping("/parking/carChargeHandler/settleBillByCoupon")
    R settleBillByCoupon(@RequestBody ParkingBillByCouponDTO parkingBillVo);

}
