package com.community.huiju.controller;

import com.alibaba.fastjson.JSONObject;
import com.community.commom.mode.ResponseBean;
import com.community.huiju.common.base.BaseController;
import com.community.huiju.service.IFuShiService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/")
@Api(value = "车辆操作API", description = "车辆操作API")
public class FSController extends BaseController {

    @Autowired
    private IFuShiService iFuShiService;

    @RequestMapping(value = "/car/getParkInfoByCarNo/{carNo}", method = RequestMethod.GET)
    @ApiOperation(value = "获取停车信息（通过车牌号）", notes = "获取停车信息（通过车牌号）")
    @ApiImplicitParams({
            @ApiImplicitParam(dataTypeClass = String.class, paramType = "path", name = "carNo", value = "车牌号"),
            @ApiImplicitParam(dataTypeClass = String.class, paramType = "query", name = "appid", value = "appid"),
            @ApiImplicitParam(dataTypeClass = String.class, paramType = "query", name = "datetime", value = "时间戳"),
            @ApiImplicitParam(dataTypeClass = String.class, paramType = "query", name = "encrypt", value = "加密方式"),
            @ApiImplicitParam(dataTypeClass = String.class, paramType = "query", name = "sign", value = "签名"),
    })
    public ResponseBean getParkInfoByCarNo(@PathVariable("carNo") String carNo) {
        ResponseBean responseBean = new ResponseBean();
        responseBean = iFuShiService.getParkInfoByCarNo(carNo);
        return responseBean;
    }

    @RequestMapping(value = "/car/parkGetMonthCardInfoByCarNo/{carNo}", method = RequestMethod.GET)
    @ApiOperation(value = "获取月租车信息（通过车牌号）", notes = "获取月租车信息（通过车牌号）")
    @ApiImplicitParams({
            @ApiImplicitParam(dataTypeClass = String.class, paramType = "path", name = "carNo", value = "车牌号"),
            @ApiImplicitParam(dataTypeClass = String.class, paramType = "query", name = "appid", value = "appid"),
            @ApiImplicitParam(dataTypeClass = String.class, paramType = "query", name = "datetime", value = "时间戳"),
            @ApiImplicitParam(dataTypeClass = String.class, paramType = "query", name = "encrypt", value = "加密方式"),
            @ApiImplicitParam(dataTypeClass = String.class, paramType = "query", name = "sign", value = "签名"),
    })
    public ResponseBean parkGetMonthCardInfoByCarNo(@PathVariable("carNo") String carNo) {
        ResponseBean responseBean = new ResponseBean();
        responseBean = iFuShiService.parkGetMonthCardInfoByCarNo(carNo);
        return responseBean;
    }

    @RequestMapping(value = "/car/parkGetTempCarPaymentInfoByCarNo/{carNo}", method = RequestMethod.GET)
    @ApiOperation(value = "获取临时车信息（通过车牌号）", notes = "获取临时车信息（通过车牌号）")
    @ApiImplicitParams({
            @ApiImplicitParam(dataTypeClass = String.class, paramType = "path", name = "carNo", value = "车牌号"),
            @ApiImplicitParam(dataTypeClass = String.class, paramType = "query", name = "appid", value = "appid"),
            @ApiImplicitParam(dataTypeClass = String.class, paramType = "query", name = "datetime", value = "时间戳"),
            @ApiImplicitParam(dataTypeClass = String.class, paramType = "query", name = "encrypt", value = "加密方式"),
            @ApiImplicitParam(dataTypeClass = String.class, paramType = "query", name = "sign", value = "签名"),
    })
    public ResponseBean parkGetTempCarPaymentInfoByCarNo(@PathVariable("carNo") String carNo) {
        ResponseBean responseBean = new ResponseBean();
        responseBean = iFuShiService.parkGetTempCarPaymentInfoByCarNo(carNo);
        return responseBean;
    }

    @RequestMapping(value = "/car/apiThirdPartyMonthCardPay", method = RequestMethod.POST)
    @ApiOperation(value = "月卡续费", notes = "月卡续费")
    @ApiImplicitParams({
//            @ApiImplicitParam(dataTypeClass = String.class, paramType = "body", name = "parameter", value = "Phone手机号;RenewDayType续费日期类型( 3:年 2:月 1:日, 选入对应的数字);" +
//                    "RenewDay续费日期数目;" +
//                    "PayStyle交易方式(中文描述)，例如：微信、 支付宝、 银联;" +
//                    "CarNo车牌号;" +
//                    "CardNo停车卡号;" +
//                    "RechargeAmt充值续费金额;"),
            @ApiImplicitParam(dataTypeClass = String.class, paramType = "form", name = "appid", value = "appid"),
            @ApiImplicitParam(dataTypeClass = String.class, paramType = "form", name = "datetime", value = "时间戳"),
            @ApiImplicitParam(dataTypeClass = String.class, paramType = "form", name = "encrypt", value = "加密方式"),
            @ApiImplicitParam(dataTypeClass = String.class, paramType = "form", name = "sign", value = "签名"),
            @ApiImplicitParam(dataTypeClass = String.class, paramType = "form", name = "Phone", value = "手机号"),
            @ApiImplicitParam(dataTypeClass = String.class, paramType = "form", name = "RenewDayType", value = "续费日期类型( 3:年 2:月 1:日, 选入对应的数字)"),
            @ApiImplicitParam(dataTypeClass = String.class, paramType = "form", name = "RenewDay", value = "续费日期数目"),
            @ApiImplicitParam(dataTypeClass = String.class, paramType = "form", name = "PayStyle", value = "交易方式(中文描述)，例如：微信、 支付宝、 银联"),
            @ApiImplicitParam(dataTypeClass = String.class, paramType = "form", name = "CarNo", value = "车牌号"),
            @ApiImplicitParam(dataTypeClass = String.class, paramType = "form", name = "CardNo", value = "停车卡号"),
            @ApiImplicitParam(dataTypeClass = String.class, paramType = "form", name = "RechargeAmt", value = "充值续费金额"),
    })
    public ResponseBean apiThirdPartyMonthCardPay(@RequestParam(value = "Phone") String Phone,
                                                  @RequestParam(value = "RenewDayType") String RenewDayType,
                                                  @RequestParam(value = "RenewDay") String RenewDay,
                                                  @RequestParam(value = "PayStyle") String PayStyle,
                                                  @RequestParam(value = "CarNo") String CarNo,
                                                  @RequestParam(value = "CardNo", required = false) String CardNo,
                                                  @RequestParam(value = "RechargeAmt") String RechargeAmt) {
        ResponseBean responseBean = new ResponseBean();
        responseBean = iFuShiService.apiThirdPartyMonthCardPay(Phone, RenewDayType,
                RenewDay, PayStyle, CarNo, CardNo, RechargeAmt);
        return responseBean;
    }

    @RequestMapping(value = "/car/apiThirdPartyTemporaryCardPay", method = RequestMethod.POST)
    @ApiOperation(value = "第三方临时卡上发缴费", notes = "第三方临时卡上发缴费")
    @ApiImplicitParams({
//            @ApiImplicitParam(dataTypeClass = String.class, paramType = "body", name = "parameter", value = "Amount应缴金额（单位元）;" +
//                    "ActualAmount实缴金额（单位元）;" +
//                    "DeductionAmount抵扣金额（单位元）;" +
//                    "Reason抵扣原因;" +
//                    "PayStyle交易方式(汉字描述)，例如：微信、支付宝、银联;" +
//                    "CarNo车牌号;" +
//                    "CardNo停车卡号;" +
//                    "CouponList使用的优惠券列表"),
            @ApiImplicitParam(dataTypeClass = String.class, paramType = "form", name = "appid", value = "appid"),
            @ApiImplicitParam(dataTypeClass = String.class, paramType = "form", name = "datetime", value = "时间戳"),
            @ApiImplicitParam(dataTypeClass = String.class, paramType = "form", name = "encrypt", value = "加密方式"),
            @ApiImplicitParam(dataTypeClass = String.class, paramType = "form", name = "sign", value = "签名"),
            @ApiImplicitParam(dataTypeClass = String.class, paramType = "form", name = "Amount", value = "应缴金额（单位元）"),
            @ApiImplicitParam(dataTypeClass = String.class, paramType = "form", name = "ActualAmount", value = "实缴金额（单位元）"),
            @ApiImplicitParam(dataTypeClass = String.class, paramType = "form", name = "DeductionAmount", value = "抵扣金额（单位元）"),
            @ApiImplicitParam(dataTypeClass = String.class, paramType = "form", name = "Reason", value = "抵扣原因"),
            @ApiImplicitParam(dataTypeClass = String.class, paramType = "form", name = "PayStyle", value = "交易方式(汉字描述)，例如：微信、支付宝、银联"),
            @ApiImplicitParam(dataTypeClass = String.class, paramType = "form", name = "CarNo", value = "车牌号"),
            @ApiImplicitParam(dataTypeClass = String.class, paramType = "form", name = "CardNo", value = "停车卡号"),
            @ApiImplicitParam(dataTypeClass = String.class, paramType = "form", name = "CouponList", value = "使用的优惠券列表"),
    })
    public ResponseBean apiThirdPartyTemporaryCardPay(@RequestParam(value = "Amount") String Amount,
                                                      @RequestParam(value = "ActualAmount") String ActualAmount,
                                                      @RequestParam(value = "DeductionAmount") String DeductionAmount,
                                                      @RequestParam(value = "Reason", required = false) String Reason,
                                                      @RequestParam(value = "PayStyle") String PayStyle,
                                                      @RequestParam(value = "CarNo") String CarNo,
                                                      @RequestParam(value = "CardNo",  required = false) String CardNo,
                                                      @RequestParam(value = "CouponList", required = false) String CouponList) {
        ResponseBean responseBean = new ResponseBean();
        responseBean = iFuShiService.apiThirdPartyTemporaryCardPay(Amount, ActualAmount, DeductionAmount,
                Reason, PayStyle, CarNo, CardNo, CouponList);
        return responseBean;
    }


    @RequestMapping(value = "/car/apiGetOfflineFee/{carNoOrCardNo}", method = RequestMethod.GET)
    @ApiOperation(value = "获取线下算费结果", notes = "获取线下算费结果")
    @ApiImplicitParams({
        @ApiImplicitParam(paramType = "path", dataTypeClass = String.class, name = "carNoOrCardNo" , value = "车牌号码或卡号"),
            @ApiImplicitParam(dataTypeClass = String.class, paramType = "query", name = "appid", value = "appid"),
            @ApiImplicitParam(dataTypeClass = String.class, paramType = "query", name = "datetime", value = "时间戳"),
            @ApiImplicitParam(dataTypeClass = String.class, paramType = "query", name = "encrypt", value = "加密方式"),
            @ApiImplicitParam(dataTypeClass = String.class, paramType = "query", name = "sign", value = "签名"),
    })
    public ResponseBean apiGetOfflineFee(@PathVariable("carNoOrCardNo") String carNoOrCardNo) {
        ResponseBean responseBean = new ResponseBean();
        responseBean = iFuShiService.apiGetOfflineFee(carNoOrCardNo);
        return responseBean;
    }

}
