package com.xhpc.order.service;

import com.xhpc.common.core.domain.R;
import com.xhpc.common.core.web.domain.AjaxResult;
import com.xhpc.common.domain.XhpcRate;
import com.xhpc.order.domain.XhpcChargeOrder;
import com.xhpc.order.domain.XhpcOrderRedisRecord;
import org.apache.ibatis.annotations.Param;

import javax.servlet.http.HttpServletRequest;
import java.math.BigDecimal;
import java.util.Date;
import java.util.List;
import java.util.Map;

/**
 * @author yuyang
 * @date 2021/8/4 9:54
 */
public interface IXhpcChargeOrderService {


    /**
     * 判断实时订单
     *
     * @param
     * @return
     */
    AjaxResult getCYCHistotyChargeOrderMessage(Long userId, Integer userType, String tenantId,String thirdCode);


    /**
     * 判断实时订单
     *
     * @param
     * @return
     */
    AjaxResult getHistotyChargeOrderMessage(HttpServletRequest request);

    /**
     * 判断实时订单
     *
     * @param
     * @return
     */
    AjaxResult getUserHistotyChargeOrderMessage(HttpServletRequest request);


    /**
     * 实时订单
     *
     * @param userId
     * @return
     */
    Map<String, Object> getOrderMessage(Long userId);
    /**
     * 异常订单
     * @param
     * @return
     */
    List<Map<String, Object>> getHistotyChargeOrderStatusList(HttpServletRequest request);

    /**
     * 启动充电
     * @param userId
     * @param serialNumber   终端编码
     * @return
     */
    AjaxResult startUp(HttpServletRequest request, Long userId, String serialNumber, Integer type);

    /**
     * 停止充电
     * @param userId
     * @param serialNumber   终端编码
     * @return
     */
    AjaxResult stopUp(HttpServletRequest request,Long userId,String serialNumber,Long chargingOrderId);


    /**
     * 获取充电订单数据
     *
     * @param serialNumber 订单编号
     * @return
     */
    XhpcChargeOrder getSerialNumberMessage(String serialNumber);


    /**
     * 判断用户是第几次充电
     * @param userId
     * @return
     */
    int getCount(Long userId,Long chargeOrderId,Integer source,String tenantId);

    /**
     * 活动
     * @return
     */
    Map<String,Object> getPromotion();

    /**
     * 修改充电订单
     *
     * @param xhpcChargeOrder
     * @return
     */
    void updateXhpcChargeOrder(XhpcChargeOrder xhpcChargeOrder);


    /**
     * appUserId 查询用户信息
     * @param userId
     * @return
     */
    Map<String,Object> getUserMessage(Long userId);

    /**
     * 修改余额
     * @param userId
     * @param balance
     * @return
     */
    int updateUserBalance(Long userId, BigDecimal balance,Integer source,String tenantId);


    int updateeMotorcadeAmount(Long userId, BigDecimal surplusMoney,BigDecimal consumeMoney,Integer source,String tenantId);

    /**
     * 修改双枪余额
     */
    int updateUserSunchaBalance(Long userId, BigDecimal balance,Integer source,String tenantId,Integer sunchaStatus);

    /**
     * 获取运营商信息
     * @param chargingStationId
     * @return
     */
    Map<String,Object> getOperatorMessage( Long chargingStationId);


    /**
     * 添加redis数据到数据库
     */
    void addXhpcOrderRedisRecord(XhpcOrderRedisRecord xhpcOrderRedisRecord);

    /**
     * 添加流水
     * @param userId              用户id
     * @param amount              流水金额
     * @param remainingSum        余额
     * @param chargeOrderId       充电订单id
     * @param type                类型（1充值 2退款 3充电）
     * @param date                时间
     * @return
     */
    int addUserAccountStatement(Long userId, BigDecimal amount, BigDecimal remainingSum, Long chargeOrderId, Integer type,
                                Date date,Integer source);


    XhpcChargeOrder getChargingOrderId(Long chargingOrderId);

    /**
     * 获取费率
     */
    List<XhpcRate> getRateModelId(Long rateModelId);


    /**
     * 获取电桩信息
     * @param terminalId
     * @return
     */
    Map<String,Object> getXhpcChargingPile(Long terminalId);


    /**
     * 24小时异常结算
     */
    List<Map<String,Object>> getXhpcChargeOrderStatus(Integer status,Integer number);


    R startUpBy3rd(String internetSerialNumber, String driverId, Integer chargingAmt, String plateNum, Integer status, String connectorId);

    /**
     * 标记异常大于创建4小时，标记为异常
     */
    void updateStatus();


    void updateStatusNull();

    void updateStatusNegativeOne();

    /**
     * 查询是否有异常订单
     * @return
     */
    List<Map<String, Object>> getChargeOrderStatus();
    //获取桩信息
    Map<String,Object> getXhpcChargingPileById(Long chargingPileId);


    R cardStartup(Long userId,String serialNumber,Integer userType,String tenantId, Integer type, String grantOperator,String rateModelId);

    R pileVin(String serialNumber,String vinNumber);

    //根据终端号查询最近的一个在充电的订单
    Map<String,Object> getSerialNumberOrder(String serialNumber);

    void constantSoc(String orderNo,String soc);

    void zhbSoc(String orderNo,String soc);


    Map<String,Object> getXhpcBarrierGate(Long chargingStationId);


    /**
     * 启动充电
     * @param userId
     * @param serialNumber   终端编码
     * @return
     */
    R cycStartUp(HttpServletRequest request, Long userId, String serialNumber, Integer type,Integer source,BigDecimal money,String phone,String PlateNum);


    /**
     * 启动充电
     * @param userId
     * @param serialNumber   终端编码
     * @return
     */
    AjaxResult chargingCapacityStartUp(HttpServletRequest request, Long userId, String serialNumber, Integer type,Integer chargingCapacity);

    AjaxResult getUserOderMassage(HttpServletRequest request);
    /**
     * 判断用户是否在充电中
     */
    String countXhpcRealTimeOrder(Long userId,Integer source,String tenantId);

    int getBlacklistUser(String phone,String vin,String plateNnum,Long chargingStationId,String time);

    /**
     * 获取终端信息
     * @return
     */
    List<Map<String,Object>> getXhpcTerminalList(Long chargingStationId,Long chargingPileId,Integer type,Long userId);

    int getXhpcPlaceholderOrderNumber(Long userId, Integer source,String terminalId);

    AjaxResult getUserOrderMessage(Long userId, Integer source);

    void getAutomaticSettlement();

}
