package com.community.huiju.controller;

import com.alibaba.fastjson.JSONObject;
import com.community.commom.mode.ResponseBean;
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.cloud.context.config.annotation.RefreshScope;
import org.springframework.web.bind.annotation.*;

@RestController
@RefreshScope
@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 = "车牌号")
    })
    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 = "车牌号")
    })
    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 = "车牌号")
    })
    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充值续费金额;")
    })
    public ResponseBean apiThirdPartyMonthCardPay(@RequestBody String parameter) {
        ResponseBean responseBean = new ResponseBean();
        JSONObject jsonObject = JSONObject.parseObject(parameter);
        responseBean = iFuShiService.apiThirdPartyMonthCardPay(jsonObject.getString("Phone"),
                jsonObject.getString("RenewDayType"),
                jsonObject.getString("RenewDay"),
                jsonObject.getString("PayStyle"),
                jsonObject.getString("CarNo"),
                jsonObject.getString("CardNo"),
                jsonObject.getString("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使用的优惠券列表")
    })
    public ResponseBean apiThirdPartyTemporaryCardPay(@RequestBody String parameter) {
        ResponseBean responseBean = new ResponseBean();
        JSONObject jsonObject = JSONObject.parseObject(parameter);
        responseBean = iFuShiService.apiThirdPartyTemporaryCardPay(jsonObject.getString("Amount"),
                jsonObject.getString("ActualAmount"),
                jsonObject.getString("DeductionAmount"),
                jsonObject.getString("Reason"),
                jsonObject.getString("PayStyle"),
                jsonObject.getString("CarNo"),
                jsonObject.getString("CardNo"),
                jsonObject.getString("CouponList"));
        return responseBean;
    }


    @RequestMapping(value = "/car/apiGetOfflineFee/{carNoOrCardNo}", method = RequestMethod.GET)
    @ApiOperation(value = "获取线下算费结果", notes = "获取线下算费结果")
    @ApiImplicitParams({
        @ApiImplicitParam(paramType = "path", dataTypeClass = String.class, name = "carNoOrCardNo" , value = "车牌号码或卡号")
    })
    public ResponseBean apiGetOfflineFee(@PathVariable("carNoOrCardNo") String carNoOrCardNo) {
        ResponseBean responseBean = new ResponseBean();
        responseBean = iFuShiService.apiGetOfflineFee(carNoOrCardNo);
        return responseBean;
    }

}
