package com.hzya.frame.plugin.cinvoice.assembler;

import cn.hutool.core.util.StrUtil;
import com.alibaba.fastjson.JSONObject;
import com.hzya.frame.plugin.cinvoice.lexmis.entity.LexmiscivTrainticketEntity;

/**
 * @Description a2 纸质火车票参数组装
 * @Author xiangerlin
 * @Date 2025/4/21 10:20
 **/
public class TrainInvoiceAssembler implements ParamAssembler{

    private JSONObject jsonObject;

    public TrainInvoiceAssembler(JSONObject jsonObject) {
        this.jsonObject = jsonObject;
    }

    /**
     * 组装参数
     *
     * @return
     */
    @Override
    public JSONObject assembleParam() {
        JSONObject param = new JSONObject();
        String trainInvoice = jsonObject.getString("trainInvoice");
        if (StrUtil.isNotEmpty(trainInvoice)){
            LexmiscivTrainticketEntity trainticketEntity = JSONObject.parseObject(trainInvoice, LexmiscivTrainticketEntity.class);
            if (null != trainticketEntity){
                param.put("hcph", trainticketEntity.getTT_CODE()); // 火车票号
                param.put("ccrq", trainticketEntity.getTT_DATE()); // 乘车日期,yyyy-MM-dd
                param.put("ccsj", trainticketEntity.getTT_TIME()); // 乘车时间,HH:mm
                param.put("cfd", trainticketEntity.getTT_FSTATION()); // 出发地
                param.put("ddd", trainticketEntity.getTT_TSTATION()); // 到达地
                param.put("cc", trainticketEntity.getTT_NO()); // 车次
                param.put("ccrxm", trainticketEntity.getTT_CUSTOMER()); // 乘车人姓名
                param.put("sfzh", trainticketEntity.getTT_IDNO()); // 身份证号
                param.put("zwlx", trainticketEntity.getTT_CLASS()); // 座位类型
                param.put("je", trainticketEntity.getTT_AMOUNT()); // 金额
                param.put("fpxflx", ""); // 发票消费类型
                param.put("xlh", trainticketEntity.getTT_SERIALNO()); // 序列号
            }
        }
        return param;
    }
}
