#pragma once

#include "DataFields.h"

class DeviceSwapEntity;

namespace DMSwapRecord
{
    const string TABLENAME = "swap_record";
    const string ID = "id";
    const string USER_ID = "user_id";
    const string CAR_NUM = "car_no";
    const string SWAP_MODE = "swap_mode";
    const string BATT_MODEL = "batt_model";
    const string BATT_DOWN_ID = "batt_down_id";
    const string BATT_DOWN_SOC = "batt_down_soc";
    const string BATT_DOWN_POWER = "batt_down_power";
    const string BATT_ON_ID = "batt_on_id";
    const string BATT_ON_SOC = "batt_on_soc";
    const string BATT_ON_POWER = "batt_on_power";
    const string OPEN_TIME = "open_time";
    const string CLOSE_TIME = "close_time";
    const string START_TIME = "start_time";
    const string END_TIME = "end_time";
    const string DURATION = "duration";
    const string TOTAL_DURATION = "total_duration";
    const string STATUS = "status";
    const string CAUSE = "cause";
    const string FEE_ELECTRICE = "fee_electric";
    const string FEE_SERVICE = "fee_service";
    const string POWER = "power";
    const string CREATE_TIME = "create_time";
    const string UPDATE_TIME = "create_time";
}

class DaoSwap
{
public:
    /**
    * 创建换电业务订单
    */
    static std::string create_swap_record(std::string biz_id, DeviceSwapEntity* swap_entity);

    /**
    * 更新换电业务订单
    * @param: [std::string biz_id] 订单号
    * @param: [DataFields& fields] 要更新的字段
    * @return: [int] 0: 更新失败；其它表示更新成功
    */
    static int update_swap_record(std::string biz_id, DataFields& fields);

    /**
    * 写入换电业务节点状态执行记录
    */
    static void insert_swap_node_status();
};