package com.jsowell.api.thirdparty;

import com.jsowell.common.annotation.Anonymous;
import com.jsowell.common.core.controller.BaseController;
import com.jsowell.common.exception.BusinessException;
import com.jsowell.common.response.RestApiResponse;
import com.jsowell.thirdparty.platform.service.ThirdPartyPlatformService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.web.bind.annotation.*;

/**
 * 宁波电刑平台
 *
 * @author Lemon
 * @Date 2024/5/10 9:21:59
 */
@Anonymous
@RestController
@RequestMapping("/dianxing")
public class DianXingPlatformController extends BaseController {
    @Autowired
    @Qualifier("dianXingPlatformServiceImpl")
    private ThirdPartyPlatformService dianXingService;


    /**
     * 推送充电记录
     * @param orderCode
     * @return
     */
    @GetMapping("/pushChargeRecord/{orderCode}")
    public RestApiResponse<?> pushChargeRecordInfo(@PathVariable("orderCode") String orderCode) {
        RestApiResponse<?> response = null;
        try {
            String result = dianXingService.notificationChargeOrderInfo(orderCode);
            response = new RestApiResponse<>(result);
        } catch (BusinessException e) {
            logger.error("点行平台推送充电记录 error:{}, {}", e.getCode(), e.getMessage());
            response = new RestApiResponse<>(e);
        } catch (Exception e) {
            logger.error("点行平台推送充电记录 error", e);
        }
        logger.info("点行平台推送充电记录 result:{}", response);
        return response;
    }
}
