/*
package com.bohuikeji.delivery.backstage.service.third;

import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.bohuikeji.delivery.backstage.controller.api.customer.CustomerV2Api;
import com.bohuikeji.delivery.backstage.entity.TConfig;
import com.bohuikeji.delivery.backstage.entity.TCustomerTemplate;
import com.bohuikeji.delivery.backstage.entity.TMaltField;
import com.bohuikeji.delivery.backstage.entity.TOrder;
import com.bohuikeji.delivery.backstage.service.ITConfigService;
import com.bohuikeji.delivery.backstage.service.ITCustomerService;
import com.bohuikeji.delivery.backstage.service.ITCustomerTemplateService;
import com.bohuikeji.delivery.backstage.service.ITMaltFieldService;
import com.bohuikeji.frame.module.admin.entity.vo.AddressVo;
import com.bohuikeji.frame.module.admin.utils.MapUtils;
import com.bohuikeji.frame.module.admin.utils.StringUtils;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

import java.math.BigDecimal;

@Slf4j
@Component
@RequiredArgsConstructor
public class MaiYaTianUtils {
    final CustomerV2Api customerV2Api;
    final ITCustomerTemplateService customerTemplateService;
    final ITCustomerService customerService;
    final ITConfigService configService;
    final ITMaltFieldService maltFieldService;

    public TOrder getEstimate(JSONObject data) {
        TMaltField maltField = maltFieldService.getOne(new QueryWrapper<TMaltField>().eq("shop_id",Integer.valueOf(data.getString("shop_id"))));
        JSONObject sender = data.getJSONObject("sender");//发货门店
        JSONObject receiver = data.getJSONObject("receiver");//收获人
        JSONObject orderInfo = data.getJSONObject("order_info");//订单信息
        JSONObject goodsList = orderInfo.getJSONArray("goods_list").getJSONObject(0);//商品信息
      */
/*  Integer times = data.getInteger("delay_delivery_time");//预计送达时间
        ZoneId zoneId = ZoneId.systemDefault();
        LocalDateTime localDateTime = Instant.ofEpochMilli(Long.valueOf(times)).atZone(zoneId).toLocalDateTime();
        log.info("预计送达时间：{}",localDateTime);*//*

        TOrder order = new TOrder();
        order.setMailingName(sender.getString("name"));
        AddressVo maiAddressVo= MapUtils.getAddressGeo(sender.getString("address"));
        maiAddressVo.setDetail(sender.getString("address_detail"));
        order.setMailingAddress(maiAddressVo);
        order.setMailingPhone(sender.getString("phone"));

        order.setReceiptName(receiver.getString("name"));
        AddressVo recAddressVo= MapUtils.getAddressGeo(receiver.getString("address"));
        recAddressVo.setDetail(receiver.getString("address_detail"));
        order.setReceiptAddress(recAddressVo);
        order.setReceiptPhone(receiver.getString("phone"));

        order.setOrderChannel("麦芽田");
        order.setMaltFieldNum(data.getString("source_order_no"));
        order.setPlayerId(maltField.getCusId());
        order.setType("WALLET");
        order.setCargoWeight(orderInfo.getInteger("weight"));
        order.setWorthName(String.valueOf(goodsList.getInteger("price")));
        order.setOrderRemarks(data.getString("remark"));
        order.setPickTime("今天/一小时内");
        order.setOrdertTip(new BigDecimal(data.getInteger("tips")));
       */
/* for(int i=0;i<goodsList.size();i++){
            JSONObject job = goodsList.getJSONObject(i);

        }*//*

        order=this.openOrderInit(maltField.getCusId(),order);
        return order;
    }

    */
/**
     * 开放平台创建订单初始化
     *
     * @param customerId 客户ID
     * @return
     *//*

    public TOrder openOrderInit(Integer customerId,TOrder order) {
        //获取客户计费模板ID
        Integer templateId=customerService.selectColumnById(customerId,"template_id",Integer.class);
        if(StringUtils.isBlank(order.getMailingAddress().getLat())||StringUtils.isBlank(order.getMailingAddress().getLng())){
            order.setMailingAddress(order.getMailingAddress().fillAddress());
        }
        if(StringUtils.isBlank(order.getReceiptAddress().getLat())||StringUtils.isBlank(order.getReceiptAddress().getLng())){
            order.setReceiptAddress(order.getReceiptAddress().fillAddress());
        }
        if(templateId!=null){
            //获取计费客户模板Code
            String templateCode=customerTemplateService.selectColumnById(templateId,"template_code",String.class);
            //设置车辆计费项目
            TCustomerTemplate tmp=customerTemplateService.getOpenConfigByCode(templateCode,"car_type_ddc");
            order.setVehicleConfigId(tmp.getTemplateId());
            order.setVehicleName(tmp.getConfigName());
            //设置物品类型计费项
            tmp=customerTemplateService.getOpenConfigByCode(templateCode,"cargo_type");
            order.setCargoConfigId(tmp.getTemplateId());
            order.setCargoName(tmp.getConfigName());
            //设置运输方式给计费项
            tmp=customerTemplateService.getOpenConfigByCode(templateCode,"service_type");
            order.setWayConfigId(tmp.getTemplateId());
            order.setWayName(tmp.getConfigName());

            //设置计费方式
            tmp=customerTemplateService.getOpenConfigByCode(templateCode,"payment_method");

            //暂时先走平台己寄付
            order.setPaymentConfigId(31);
            order.setPaymentType("寄付");
        }
        else {
            */
/**
             * 如果没有计费模板则按，当地加盟商默认计费规则进行计费。
             *//*

            String location=order.getMailingAddress().getLocation();
            //设置物品计费项目
            if(StringUtils.isBlank(order.getCargoName())){
                order.setCargoName("生活用品");
            }
            TConfig cargoConfig=configService.getOpenConfigByGroup(order.getCargoName(),"cargo_type",location);
            order.setCargoConfigId(cargoConfig.getId());
            order.setCargoName(cargoConfig.getConfigName());
            //设置车辆类型计费项
            TConfig vehConfig=configService.getOpenConfigByGroup("电动车","car_type_ddc",location);
            order.setVehicleConfigId(vehConfig.getId());
            order.setVehicleName(vehConfig.getConfigName());
            //设置服务类型计费项
            TConfig wayConfig=configService.getOpenConfigByGroup("极送-平均1小时","service_type",location);
            order.setWayConfigId(wayConfig.getId());
            order.setWayName(wayConfig.getConfigName());
            //暂时先走平台己寄付
            order.setPaymentConfigId(31);
            order.setPaymentType("寄付");
        }
        return order;
    }
}
*/
