package com.cweb.controller;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.github.pagehelper.PageInfo;
import com.hai.common.exception.ErrorCode;
import com.hai.common.exception.ErrorHelp;
import com.hai.common.exception.SysCode;
import com.hai.common.utils.CoordCommonUtil;
import com.hai.common.utils.PageUtil;
import com.hai.common.utils.ResponseMsgUtil;
import com.hai.config.CommonSysConst;
import com.hai.config.TuanYouConfig;
import com.hai.dao.HighGasOrderPushMapper;
import com.hai.entity.*;
import com.hai.enum_type.GasOilPriceStatusEnum;
import com.hai.enum_type.MerchantStoreSourceType;
import com.hai.model.HighMerchantStoreModel;
import com.hai.model.ResponseData;
import com.hai.service.*;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.apache.commons.collections4.MapUtils;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.math.BigDecimal;
import java.util.*;
import java.util.stream.Collectors;

@Controller
@RequestMapping(value = "/gasOrder")
@Api(value = "加油订单")
public class HighGasOrderController {

    private static Logger log = LoggerFactory.getLogger(HighGasOrderController.class);

    @Resource
    private HighGasOrderService gasOrderService;

    @RequestMapping(value="/getOrderByOrderNo",method = RequestMethod.GET)
    @ResponseBody
    @ApiOperation(value = "根据订单号查询")
    public ResponseData getOrderByOrderNo(@RequestParam(name = "orderNo", required = true) String orderNo) {
        try {

            return ResponseMsgUtil.success(gasOrderService.getDetailByOrderNo(orderNo));

        } catch (Exception e) {
            log.error("HighGasOrderController -> getOrderByOrderNo() error!",e);
            return ResponseMsgUtil.exception(e);
        }
    }

    @RequestMapping(value="/getOrderByChildOrderNo",method = RequestMethod.GET)
    @ResponseBody
    @ApiOperation(value = "根据子订单号查询")
    public ResponseData getOrderByChildOrderNo(@RequestParam(name = "childOrderNo", required = true) String childOrderNo) {
        try {

            return ResponseMsgUtil.success(gasOrderService.getDetailByChildOrderNo(childOrderNo));

        } catch (Exception e) {
            log.error("HighGasOrderController -> getOrderByChildOrderNo() error!",e);
            return ResponseMsgUtil.exception(e);
        }
    }


}
