package com.zfire.mall.manager.utils;

import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.convert.Convert;
import cn.hutool.core.date.DateUtil;
import cn.hutool.crypto.SecureUtil;
import cn.hutool.http.HttpRequest;
import cn.hutool.json.JSONArray;
import cn.hutool.json.JSONUtil;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
import com.baomidou.mybatisplus.extension.exceptions.ApiException;
import com.zfire.mall.manager.bean.front.*;
import com.zfire.mall.manager.exception.RemoteServiceException;
import com.zfire.mall.manager.plus.entity.*;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Map;

@Slf4j
@Component
public class JiaXianUtils {

    @Value("${jiaxian.key}")
    private   String jiaxianKey;


    @Value("${jiaxian.secret}")
    private  String jiaxianSecret;


    @Value("${jiaxian.url}")
    private  String jiaxianUrl;


    @Value("${jiaxiandacang.url}")
    private  String jiaxianDaCangUrl;

    /**
     * 获得嘉贤sign
     *
     * @param
     * @return String
     */
    public  String getSign() throws ApiException {
        String format = DateUtil.format(new Date(), "yyyyMMdd");
        String substring = format.substring(2);
        String jia = jiaxianKey+substring+ jiaxianSecret;
        String s = SecureUtil.md5(jia);

        return s;
    }


    /**
     * 获得嘉贤toc物流轨迹同步接口
     *
     * @param
     * @return List<OrderTrackToc>
     */
    public  List<OrderTrackToc> getBranchTrack() throws ApiException {
        String body = HttpRequest.post(jiaxianUrl+"/saleEndApi/getBranchTrack")
                .header("key", jiaxianKey)
                .header("sign", getSign())
                .execute().body();

        Map<String,Object> smsRsp = JSON.parseObject(body);
        //获取数据
        String codeRes = smsRsp.get("code").toString();
        if(!codeRes.equals("200")) {
            log.error("失败同步,data:{}",smsRsp.get("message").toString());
            return null;
        }
        JSONArray jsonArray = JSONUtil.parseArray(JSON.parseObject(smsRsp.get("data").toString()).get("trackList"));
        List<CustomerOrderTrackTocBean> customerOrderTrackBeans = JSONUtil.toList(jsonArray, CustomerOrderTrackTocBean.class);
        if (CollectionUtils.isEmpty(customerOrderTrackBeans))
            return null;
        List<OrderTrackToc> orderTrackTocs = new ArrayList<>();
        for (CustomerOrderTrackTocBean customerOrderTrackBean : customerOrderTrackBeans) {
            OrderTrackToc orderTrackToc = new OrderTrackToc();
            orderTrackToc.setOrderTrackId(customerOrderTrackBean.getId());
            orderTrackToc.setBranchOrderCode(customerOrderTrackBean.getBranchOrderCode());
            orderTrackToc.setComment(customerOrderTrackBean.getComment());
            orderTrackToc.setStatus(customerOrderTrackBean.getStatus());
            orderTrackToc.setTime(DateUtil.date(Convert.toLong(customerOrderTrackBean.getCreateTime())));
            orderTrackToc.setSaleCode(customerOrderTrackBean.getSaleCode());
            orderTrackToc.setBranchOrderCode(customerOrderTrackBean.getBranchOrderCode());
            orderTrackToc.setStatusDetails(customerOrderTrackBean.getStatusDetails());
            orderTrackTocs.add(orderTrackToc);
        }
        return orderTrackTocs;

    }

    /**
     * 同步接口返回同步结果
     *
     * @param
     *
     */
    public  String callBackSyncStatus(CallBackItemDTO callBackItemDTO) throws ApiException {
        String json = JSONUtil.toJsonStr(callBackItemDTO);
        String body = HttpRequest.post(jiaxianUrl+"/saleEndApi/callBackSyncStatus")
                .header("key", jiaxianKey)
                .header("sign", getSign())
                .body(json)
                .execute().body();
        Map<String,Object> smsRsp = JSON.parseObject(body);
        //获取数据
        String codeRes = smsRsp.get("code").toString();
        if(!codeRes.equals("200")) {
            log.error("失败同步,data:{}",smsRsp.get("message").toString());
            return "OK";
        }

        return smsRsp.get("message").toString();

    }


    /**
     * 同步商家结算账单
     *
     * @param
     *
     */
    public  List<CostBill> getCostBill() throws ApiException {
        String body = HttpRequest.post(jiaxianUrl+"/saleEndApi/getCostBill")
                .header("key", jiaxianKey)
                .header("sign", getSign())
                .execute().body();

        Map<String,Object> smsRsp = JSON.parseObject(body);
        //获取数据
        String codeRes = smsRsp.get("code").toString();
        if(!codeRes.equals("200")) {
            log.error("失败同步,data:{}",smsRsp.get("message").toString());
            throw new RemoteServiceException("同步失败");
        }
        JSONArray jsonArray = JSONUtil.parseArray(JSON.parseObject(smsRsp.get("data").toString()).get("costBillItemList"));
        List<CostBillVO> costBillVOS = JSONUtil.toList(jsonArray, CostBillVO.class);
        if (CollectionUtils.isEmpty(costBillVOS))
            return null;
        List<CostBill> costBills = new ArrayList<>();
        for (CostBillVO costBillVO : costBillVOS) {
            Long createTime = costBillVO.getCreateTime();
            costBillVO.setCreateTime(null);
            CostBill costBill = BeanUtil.toBean(costBillVO, CostBill.class);
            costBill.setTime(createTime == null?null:DateUtil.date(Convert.toLong(createTime)));
            costBills.add(costBill);
        }
        return costBills;

    }


    /**
     * 同步商家对账账单
     *
     * @param
     *
     */
    public  List<CostMerchant> getSyncCostMerchant() throws ApiException {
        String body = HttpRequest.post(jiaxianUrl+"/saleEndApi/getSyncCostMerchant?syncTime=1673258365000")
                .header("key", jiaxianKey)
                .header("sign", getSign())
                .execute().body();

        Map<String,Object> smsRsp = JSON.parseObject(body);
        //获取数据
        String codeRes = smsRsp.get("code").toString();
        if(!codeRes.equals("200")) {
            log.error("失败同步,data:{}",smsRsp.get("message").toString());
            throw new RemoteServiceException("同步失败");
        }
        String s = smsRsp.get("data").toString();
        JSONArray jsonArray = JSONUtil.parseArray(s);
        List<CostMerchantVO> costMerchantVOS = JSONUtil.toList(jsonArray, CostMerchantVO.class);
        if (CollectionUtils.isEmpty(costMerchantVOS))
            return null;
        List<CostMerchant> costBills = new ArrayList<>();
        for (CostMerchantVO costMerchantVO : costMerchantVOS) {
            Long createTime = costMerchantVO.getCreateTime();
            Long updateTime = costMerchantVO.getUpdateTime();
            costMerchantVO.setCreateTime(null);
            costMerchantVO.setUpdateTime(null);
            CostMerchant costMerchant = BeanUtil.toBean(costMerchantVO, CostMerchant.class);
            costMerchant.setCostCreateTime(createTime == null?null:DateUtil.date(Convert.toLong(createTime)));
            costMerchant.setCostUpdateTime(updateTime == null?null:DateUtil.date(Convert.toLong(updateTime)));
            costMerchant.setCheckTimeSupply(costMerchant.getCheckTime() == null?null:DateUtil.date(Convert.toLong(costMerchant.getCheckTime())));
            costMerchant.setStartTimeSupply(costMerchant.getStartTime() == null?null:DateUtil.date(Convert.toLong(costMerchant.getStartTime())));
            costMerchant.setEndTimeSupply(costMerchant.getEndTime() == null?null:DateUtil.date(Convert.toLong(costMerchant.getEndTime())));
            costMerchant.setAutoCheckTimeSupply(costMerchant.getAutoCheckTime() == null?null:DateUtil.date(Convert.toLong(costMerchant.getAutoCheckTime())));
            costBills.add(costMerchant);
        }
        return costBills;

    }


    /**
     * 同步销司对账账单
     *
     * @param
     *
     */
    public  List<CostSales> getSyncCostSales() throws ApiException {
        String body = HttpRequest.post(jiaxianUrl+"/saleEndApi/getSyncCostSales?syncTime=1673258365000")
                .header("key", jiaxianKey)
                .header("sign", getSign())
                .execute().body();

        Map<String,Object> smsRsp = JSON.parseObject(body);
        //获取数据
        String codeRes = smsRsp.get("code").toString();
        if(!codeRes.equals("200")) {
            log.error("失败同步,data:{}",smsRsp.get("message").toString());
            throw new RemoteServiceException("同步失败");
        }
        JSONArray jsonArray = JSONUtil.parseArray(smsRsp.get("data").toString());
        List<CostSalesVO> costMerchantVOS = JSONUtil.toList(jsonArray, CostSalesVO.class);
        if (CollectionUtils.isEmpty(costMerchantVOS))
            return null;
        List<CostSales> costSales = new ArrayList<>();
        for (CostSalesVO costMerchantVO : costMerchantVOS) {
            Long createTime = costMerchantVO.getCreateTime();
            Long updateTime = costMerchantVO.getUpdateTime();
            costMerchantVO.setCreateTime(null);
            costMerchantVO.setUpdateTime(null);
            CostSales costMerchant = BeanUtil.toBean(costMerchantVO, CostSales.class);
            costMerchant.setCostCreateTime(createTime == null?null:DateUtil.date(Convert.toLong(createTime)));
            costMerchant.setCostUpdateTime(updateTime == null?null:DateUtil.date(Convert.toLong(updateTime)));
            costMerchant.setCheckTimeSupply(costMerchant.getCheckTime() == null?null:DateUtil.date(Convert.toLong(costMerchant.getCheckTime())));
            costMerchant.setStartTimeSupply(costMerchant.getStartTime() == null?null:DateUtil.date(Convert.toLong(costMerchant.getStartTime())));
            costMerchant.setEndTimeSupply(costMerchant.getEndTime() == null?null:DateUtil.date(Convert.toLong(costMerchant.getEndTime())));
            costMerchant.setAutoCheckTimeSupply(costMerchant.getAutoCheckTime() == null?null:DateUtil.date(Convert.toLong(costMerchant.getAutoCheckTime())));
            costSales.add(costMerchant);
        }
        return costSales;

    }


    /**
     * 同步异常工单
     *
     * @param
     *
     */
    public  List<CostTicketVO> getSyncCostTicket() throws ApiException {
        String body = HttpRequest.post(jiaxianUrl+"/saleEndApi/getSyncCostTicket")
                .header("key", jiaxianKey)
                .header("sign", getSign())
                .execute().body();

        Map<String,Object> smsRsp = JSON.parseObject(body);
        //获取数据
        String codeRes = smsRsp.get("code").toString();
        if(!codeRes.equals("200")) {
            log.error("失败同步,data:{}",smsRsp.get("message").toString());
            throw new RemoteServiceException("同步失败");
        }
        JSONArray jsonArray = JSONUtil.parseArray(JSON.parseObject(smsRsp.get("data").toString()));
        List<CostTicketVO> costMerchantVOS = JSONUtil.toList(jsonArray, CostTicketVO.class);
        if (CollectionUtils.isEmpty(costMerchantVOS))
            return null;

        return costMerchantVOS;

    }

    /**
     * 同步出库条码接口
     *
     * @param
     *
     */
    public  List<CustomerCode> getWMSScanBarCode() throws ApiException {
        String body = HttpRequest.post(jiaxianUrl+"/saleEndApi/getWMSScanBarCode")
                .header("key", jiaxianKey)
                .header("sign", getSign())
                .execute().body();

        Map<String,Object> smsRsp = JSON.parseObject(body);
        //获取数据
        String codeRes = smsRsp.get("code").toString();
        if(!codeRes.equals("200")) {
            log.error("失败同步,data:{}",smsRsp.get("message").toString());
            throw new RemoteServiceException("同步失败");
        }
        String data = smsRsp.get("data").toString();

        List<CustomerCode> customerCodes = JSONUtil.toList(data, CustomerCode.class);
        for (CustomerCode customerCode : customerCodes) {
            customerCode.setConsignerTimeV2(customerCode.getConsignerTime() != null?DateUtil.date(Convert.toLong(customerCode.getConsignerTime())*1000):null);
            customerCode.setDeliveryTimeV2(customerCode.getDeliveryTime()!=null?DateUtil.date(Convert.toLong(customerCode.getDeliveryTime())):null);
        }
        if (CollectionUtils.isEmpty(customerCodes))
            return null;

        return customerCodes;

    }

    /**
     * 同步大仓出库条码接口
     *
     * @param
     *
     */
    public  List<CustomerCode> getDaCangWMSScanBarCode() throws ApiException {
        String body = HttpRequest.post(jiaxianDaCangUrl+"/saleEndApi/getWMSScanBarCode")
                .header("key", jiaxianKey)
                .header("sign", getSign())
                .execute().body();

        Map<String,Object> smsRsp = JSON.parseObject(body);
        //获取数据
        String codeRes = smsRsp.get("code").toString();
        if(!codeRes.equals("200")) {
            log.error("失败同步,data:{}",smsRsp.get("message").toString());
            throw new RemoteServiceException("同步失败");
        }
        String data = smsRsp.get("data").toString();

        List<CustomerCode> customerCodes = JSONUtil.toList(data, CustomerCode.class);
        for (CustomerCode customerCode : customerCodes) {
            customerCode.setId(customerCode.getId()+"DACANG");
            customerCode.setConsignerTimeV2(customerCode.getConsignerTime() != null?DateUtil.date(Convert.toLong(customerCode.getConsignerTime())*1000):null);
            customerCode.setDeliveryTimeV2(customerCode.getDeliveryTime()!=null?DateUtil.date(Convert.toLong(customerCode.getDeliveryTime())):null);
            customerCode.setType("DACANG");
        }
        if (CollectionUtils.isEmpty(customerCodes))
            return null;

        return customerCodes;

    }

    /**
     * 同步接口返回同步结果
     *
     * @param
     *
     */
    public  String callBackDaCangSyncStatus(CallBackItemDTO callBackItemDTO) throws ApiException {
        String json = JSONUtil.toJsonStr(callBackItemDTO);
        String body = HttpRequest.post(jiaxianDaCangUrl+"/saleEndApi/callBackSyncStatus")
                .header("key", jiaxianKey)
                .header("sign", getSign())
                .body(json)
                .execute().body();
        Map<String,Object> smsRsp = JSON.parseObject(body);
        //获取数据
        String codeRes = smsRsp.get("code").toString();
        if(!codeRes.equals("200")) {
            log.error("失败同步,data:{}",smsRsp.get("message").toString());
            return "OK";
        }

        return smsRsp.get("message").toString();

    }



    /**
     * 销售订单新增接口
     *
     * @param
     *
     */
    public  List<String> apiSaleOrderSave(List<CustomerOrderJiaBean> list) throws ApiException {
        CustomerOrderJiaBeanList customerOrderJiaBeanList = new CustomerOrderJiaBeanList();
        customerOrderJiaBeanList.setList(list);
        String json = JSONUtil.toJsonStr(customerOrderJiaBeanList);

        String body = HttpRequest.post(jiaxianUrl+"/saleEndApi/apiSaleOrderSave")
                .header("key", jiaxianKey)
                .header("sign", getSign())
                .body(json)
                .execute().body();

        Map<String,Object> smsRsp = JSON.parseObject(body);
        //获取数据
        String codeRes = smsRsp.get("code").toString();
        if(!codeRes.equals("200")) {
            log.error("失败同步,data:{}",smsRsp.get("message").toString());
            throw new RemoteServiceException(smsRsp.get("message").toString());
        }

        String data = smsRsp.get("data").toString();

        List<String> strings = JSONUtil.toList(data, String.class);
        return strings;

    }



    /**
     * 销售订单删除接口
     *
     * @param
     *
     */
    public   void apiSaleOrderRemove(List<String> list) throws ApiException {

        CustomerOrderJiaRemoveBeanList customerOrderJiaBeanList = new CustomerOrderJiaRemoveBeanList();
        customerOrderJiaBeanList.setList(list);

        String json = JSONUtil.toJsonStr(customerOrderJiaBeanList);

        String body = HttpRequest.post(jiaxianUrl+"/saleEndApi/apiSaleOrderRemove")
                .header("key", jiaxianKey)
                .header("sign", getSign())
                .body(json)
                .execute().body();

        Map<String,Object> smsRsp = JSON.parseObject(body);
        //获取数据
        String codeRes = smsRsp.get("code").toString();
        if(!codeRes.equals("200")) {
            log.error("失败同步,data:{}",smsRsp.get("message").toString());
            throw new RemoteServiceException(smsRsp.get("message").toString());
        }

    }


    /**
     * 销售退货订单新增接口
     *
     * @param
     *
     */
    public   List<String> apiSaleOrderReturnSave(List<SaleOrderReturnJsonList> list) throws ApiException {
        CustomerOrderJiaReturnBeanList customerOrderJiaBeanList = new CustomerOrderJiaReturnBeanList();
        customerOrderJiaBeanList.setList(list);

        String json = JSONUtil.toJsonStr(customerOrderJiaBeanList);

        String body = HttpRequest.post(jiaxianUrl+"/saleEndApi/apiSaleOrderReturnSave")
                .header("key", jiaxianKey)
                .header("sign", getSign())
                .body(json)
                .execute().body();

        Map<String,Object> smsRsp = JSON.parseObject(body);
        //获取数据
        String codeRes = smsRsp.get("code").toString();
        if(!codeRes.equals("200")) {
            log.error("失败同步,data:{}",smsRsp.get("message").toString());
            throw new RemoteServiceException(smsRsp.get("message").toString());
        }

        String data = smsRsp.get("data").toString();

        List<String> strings = JSONUtil.toList(data, String.class);
        return strings;

    }



    /**
     * 销售退货订单删除接口
     *
     * @param
     *
     */
    public  void apiSaleOrderReturnRemove(List<String> list) throws ApiException {
        CustomerOrderJiaRemoveBeanList customerOrderJiaBeanList = new CustomerOrderJiaRemoveBeanList();
        customerOrderJiaBeanList.setList(list);

        String json = JSONUtil.toJsonStr(customerOrderJiaBeanList);

        String body = HttpRequest.post(jiaxianUrl+"/saleEndApi/apiSaleOrderReturnRemove")
                .header("key", jiaxianKey)
                .header("sign", getSign())
                .body(json)
                .execute().body();

        Map<String,Object> smsRsp = JSON.parseObject(body);
        //获取数据
        String codeRes = smsRsp.get("code").toString();
        if(!codeRes.equals("200")) {
            log.error("失败同步,data:{}",smsRsp.get("message").toString());
            throw new RemoteServiceException(smsRsp.get("message").toString());
        }

    }


    /**
     * 商家调拨单新增接口
     *
     * @param
     *
     */
    public   List<String> apiMerchantAllocationOrderSave(List<MerchantAllocationOrderMainJsonListDto> list) throws ApiException {
        CustomerTransferJiaBeanList customerTransferJiaBeanList = new CustomerTransferJiaBeanList();
        customerTransferJiaBeanList.setList(list);
        String json = JSONUtil.toJsonStr(customerTransferJiaBeanList);

        String body = HttpRequest.post(jiaxianUrl+"/saleEndApi/apiMerchantAllocationOrderSave")
                .header("key", jiaxianKey)
                .header("sign", getSign())
                .body(json)
                .execute().body();

        Map<String,Object> smsRsp = JSON.parseObject(body);
        //获取数据
        String codeRes = smsRsp.get("code").toString();
        if(!codeRes.equals("200")) {
            log.error("失败同步,data:{}",smsRsp.get("message").toString());
            throw new RemoteServiceException(smsRsp.get("message").toString());
        }

        String data = smsRsp.get("data").toString();

        List<String> strings = JSONUtil.toList(data, String.class);
        return strings;

    }



    /**
     * 商家调拨单删除接口
     *
     * @param
     *
     */
    public   void apiMerchantAllocationOrderRemove(List<String> list) throws ApiException {
        CustomerTransferJiaRemoveBeanList customerTransferJiaBeanList = new CustomerTransferJiaRemoveBeanList();
        customerTransferJiaBeanList.setList(list);
        String json = JSONUtil.toJsonStr(customerTransferJiaBeanList);

        String body = HttpRequest.post(jiaxianUrl+"/saleEndApi/apiMerchantAllocationOrderRemove")
                .header("key", jiaxianKey)
                .header("sign", getSign())
                .body(json)
                .execute().body();

        Map<String,Object> smsRsp = JSON.parseObject(body);
        //获取数据
        String codeRes = smsRsp.get("code").toString();
        if(!codeRes.equals("200")) {
            log.error("失败同步,data:{}",smsRsp.get("message").toString());
            throw new RemoteServiceException(smsRsp.get("message").toString());
        }

    }



    /**
     * 商家对账单审核通过
     *
     * @param
     *
     */
    public  void merchantCheck(List<String> list) throws ApiException {
        CostMerchantCheckCodeList customerOrderJiaBeanList = new CostMerchantCheckCodeList();
        customerOrderJiaBeanList.setCostMerchantCheckCodeList(list);
        String json = JSONUtil.toJsonStr(list);

        String body = HttpRequest.post(jiaxianUrl+"/saleEndApi/merchantCheck")
                .header("key", jiaxianKey)
                .header("sign", getSign())
                .body(json)
                .execute().body();

        Map<String,Object> smsRsp = JSON.parseObject(body);
        //获取数据
        String codeRes = smsRsp.get("code").toString();
        if(!codeRes.equals("200")) {
            log.error("失败同步,data:{}",smsRsp.get("message").toString());
            throw new RemoteServiceException(smsRsp.get("message").toString());
        }



    }


    /**
     * 销司对账单审核通过
     *
     * @param
     *
     */
    public  void salesCheck(List<String> list) throws ApiException {
        CostSalesCheckCodeList costSalesCheckCodeList = new CostSalesCheckCodeList();
        costSalesCheckCodeList.setCostSalesCheckCodeList(list);
        String json = JSONUtil.toJsonStr(list);

        String body = HttpRequest.post(jiaxianUrl+"/saleEndApi/salesCheck")
                .header("key", jiaxianKey)
                .header("sign", getSign())
                .body(json)
                .execute().body();

        Map<String,Object> smsRsp = JSON.parseObject(body);
        //获取数据
        String codeRes = smsRsp.get("code").toString();
        if(!codeRes.equals("200")) {
            log.error("失败同步,data:{}",smsRsp.get("message").toString());
            throw new RemoteServiceException(smsRsp.get("message").toString());
        }



    }

    /**
     * 创建异常工单
     *
     * @param
     *
     */
    public  String createTicketMain(CreateTicketMain createTicketMain) throws ApiException {

        String json = JSONUtil.toJsonStr(createTicketMain);

        String body = HttpRequest.post(jiaxianUrl+"/saleEndApi/createTicketMain")
                .header("key", jiaxianKey)
                .header("sign", getSign())
                .body(json)
                .execute().body();

        Map<String,Object> smsRsp = JSON.parseObject(body);
        //获取数据
        String codeRes = smsRsp.get("code").toString();
        if(!codeRes.equals("200")) {
            log.error("失败同步,data:{}",smsRsp.get("message").toString());
            throw new RemoteServiceException(smsRsp.get("message").toString());
        }

        String data = smsRsp.get("data").toString();

        return data;

    }


    /**
     * 修改异常工单
     *
     * @param
     *
     */
    public void updateTicket(CreateTicketBill createTicketBill) throws ApiException {

        String json = JSONUtil.toJsonStr(createTicketBill);

        String body = HttpRequest.post(jiaxianUrl+"/saleEndApi/updateTicket")
                .header("key", jiaxianKey)
                .header("sign", getSign())
                .body(json)
                .execute().body();

        Map<String,Object> smsRsp = JSON.parseObject(body);
        //获取数据
        String codeRes = smsRsp.get("code").toString();
        if(!codeRes.equals("200")) {
            log.error("失败同步,data:{}",smsRsp.get("message").toString());
            throw new RemoteServiceException(smsRsp.get("message").toString());
        }

    }

    /**
     * 将异常工单递交到审核状态
     *
     * @param
     *
     */
    public void ticketGoToReview(List<String> review) throws ApiException {

        String json = JSONUtil.toJsonStr(review);

        String body = HttpRequest.post(jiaxianUrl+"/saleEndApi/ticketGoToReview")
                .header("key", jiaxianKey)
                .header("sign", getSign())
                .body(json)
                .execute().body();

        Map<String,Object> smsRsp = JSON.parseObject(body);
        //获取数据
        String codeRes = smsRsp.get("code").toString();
        if(!codeRes.equals("200")) {
            log.error("失败同步,data:{}",smsRsp.get("message").toString());
            throw new RemoteServiceException(smsRsp.get("message").toString());
        }


    }

}
