package com.ydd.third.delivery; import com.ydd.third.common.exception.BusinessException; import com.ydd.third.common.utils.StringUtils; import com.ydd.third.common.vo.ResObject; import com.ydd.third.common.vo.shop.*; import com.ydd.third.common.vo.vo.order.*; import com.ydd.third.delivery.aipt.AiptClient; import com.ydd.third.delivery.dada.DadaClient; import com.ydd.third.delivery.dianwoda.DianwodaClient; import com.ydd.third.delivery.fengniao.FengniaoClient; import com.ydd.third.delivery.huolala.HuolalaClient; import com.ydd.third.delivery.kuaifu.KfClient; import com.ydd.third.delivery.meituan.MeituanClient; import com.ydd.third.delivery.shansong.ShansongClient; import com.ydd.third.delivery.shansong.ShansongSHClient; import com.ydd.third.delivery.shunfeng.ShunfengClient; import com.ydd.third.delivery.uupt.UuptClient; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; /** * @ClassName Client * @Deacription TODO * @Author peakren * @Date 2/4/21 10:20 PM * @Version 1.0 **/ @Slf4j @Service("deliverClient") public class Client { @Autowired MeituanClient dMeituanClient; @Autowired DadaClient dadaClient; // @Autowired // FengniaoClient fengniaoClient; @Autowired FengniaoClient fengniaoClient; @Autowired ShunfengClient shunfengClient; @Autowired ShansongSHClient shansongSHClient; @Autowired ShansongClient shansongClient; @Autowired DianwodaClient dianwodaClient; @Autowired UuptClient uuptClient; @Autowired AiptClient aiptClient; @Autowired KfClient kfClient; @Autowired HuolalaClient huolalaClient; /** * 下订单 * * @param order * @return */ public ResObject createOrder(OrderVo order) { // 声明公共参数,RequestSysParams构造方法接收两个参数,第一个为signkey,第二个为appAuthToken String client = order.getLbClient(); if (StringUtils.isBlank(client)) { throw new BusinessException("未指定lbClient参数"); } ResObject res; if (client.equals("meituan")) { res = dMeituanClient.createOrder(order); } else if (client.equals("meituanzb")) { res = dMeituanClient.createOrderZb(order); } else if (client.equals("dada")) { res = dadaClient.createOrder(order); //res = dadaClient.reAddOrder(order); }else if (client.equals("dadayz")) { res = dadaClient.createOrder(order); } else if (client.equals("fengniao")) { // res = fengniaoClient.createOrder(order); res = fengniaoClient.createOrder(order); } else if (client.equals("shansong")) { if (order.getIsMine() == 1) { res = shansongClient.createOrder(order); } else { res = shansongSHClient.createOrder(order); } } else if (client.equals("shunfeng")) { res = shunfengClient.createOrder(order); } else if (client.equals("dwd")) { res = dianwodaClient.dianwodaOrderCreate(order); } else if (client.equals("uupt")) { res = uuptClient.createOrder(order); } else if (client.equals("aipt")) { res = aiptClient.createOrder(order); } else if (client.equals("kuanfu")) { res = kfClient.createOrder(order); }else if (client.equals("huolala")){ res = huolalaClient.createOrder(order); } else { throw new BusinessException("lbClient参数不正确"); } return res; } /** * 查询订单运费/预下单 * * @param order * @return */ public ResObject queryOrderDeliverFee(OrderVo order) { // 声明公共参数,RequestSysParams构造方法接收两个参数,第一个为signkey,第二个为appAuthToken String client = order.getLbClient(); // jsonParams.getString("lb_client"); if (StringUtils.isBlank(client)) { throw new BusinessException("未指定lb_client参数"); } ResObject res = null; if (client.equals("meituan")) { res = dMeituanClient.queryOrderDeliverFee(order); } else if (client.equals("meituanzb")) { res = dMeituanClient.queryOrderDeliverZbFee(order); } else if (client.equals("dada")) { res = dadaClient.queryOrderDeliverFee(order); } else if (client.equals("dadayz")) { res = dadaClient.queryOrderDeliverFee(order); } else if (client.equals("fengniao")) { //res = fengniaoClient.queryPrice(jsonParamsStr); res = fengniaoClient.queryOrderDeliverFee(order); } else if (client.equals("shansong")) { //res = shansongClient.orderCalculate(order); //订单计费 if (order.getIsMine() == 1) { res = shansongClient.queryOrderDeliverFee(order); //订单计费 } else { res = shansongSHClient.queryOrderDeliverFee(order); //订单计费 } } else if (client.equals("shunfeng")) { res = shunfengClient.queryOrderDeliverFee(order); } else if (client.equals("dwd")) { res = dianwodaClient.dianwodaEstimateCost(order); } else if (client.equals("uupt")) { res = uuptClient.queryOrderDeliverFee(order); } else if (client.equals("aipt")) { res = aiptClient.queryOrderDeliverFee(order); } else if (client.equals("kuanfu")){ res = kfClient.queryOrderDeliverFee(order); } else if (client.equals("huolala")){ res =huolalaClient.queryOrderDeliverFee(order); } else { throw new BusinessException("lbClient参数不正确"); } return res; } /** * 取消订单 * * @param cancelOrderVo * @return */ public ResObject cancelOrder(CancelOrderVo cancelOrderVo) { String client = cancelOrderVo.getLbClient(); if (StringUtils.isBlank(client)) { throw new BusinessException("未指定lbClient参数"); } ResObject res = null; if (client.equals("meituan")) { res = dMeituanClient.cancelOrder(cancelOrderVo); } else if (client.equals("meituanzb")) { res = dMeituanClient.cancelZbOrder(cancelOrderVo); } else if (client.equals("dada")) { res = dadaClient.cancelOrder(cancelOrderVo); } else if (client.equals("dadayz")) { res = dadaClient.cancelOrder(cancelOrderVo); } else if (client.equals("fengniao")) { // res = fengniaoClient.cancelOrder(cancelOrderVo); res = fengniaoClient.cancelOrder(cancelOrderVo); } else if (client.equals("shansong")) { if (cancelOrderVo.getIsShansongSH()) { res = shansongClient.cancelOrder(cancelOrderVo);//商户,老吴命名错误 } else { res = shansongSHClient.cancelOrder(cancelOrderVo); } } else if (client.equals("shunfeng")) { res = shunfengClient.cancelOrder(cancelOrderVo); } else if (client.equals("dwd")) { res = dianwodaClient.dianwodaCancelOrder(cancelOrderVo); } else if (client.equals("uupt")) { res = uuptClient.cancelOrder(cancelOrderVo); } else if (client.equals("aipt")) { res = aiptClient.cancelOrder(cancelOrderVo); } else if (client.equals("kuanfu")) { res = kfClient.cancelOrder(cancelOrderVo); } else if (client.equals("huolala")){ res =huolalaClient.cancelOrder(cancelOrderVo); } else { throw new BusinessException("lbClient参数不正确"); } return res; } /** * 增加小费 * * @param orderTipsVo * @return */ public ResObject orderAddTip(OrderTipsVo orderTipsVo) { String client = orderTipsVo.getLbClient(); if (StringUtils.isBlank(client)) { throw new BusinessException("未指定lbClient参数"); } ResObject res = null; if (client.equals("meituan")) { // res = dMeituanClient.orderAddTip(orderTipsVo); res = new ResObject<>(); res.setCode(1); res.setMsg("美团配送不支持加小费接口"); } else if (client.equals("dada")) { res = dadaClient.orderAddTip(orderTipsVo); } else if (client.equals("dadayz")) { res = dadaClient.orderAddTip(orderTipsVo); } else if (client.equals("fengniao")) { res = fengniaoClient.orderAddTip(orderTipsVo); } else if (client.equals("shansong")) { if (orderTipsVo.getIsShansongSH()) { res = shansongClient.orderAddTip(orderTipsVo); //加价接口 } else { res = shansongSHClient.orderAddTip(orderTipsVo); //加价接口 } } else if (client.equals("shunfeng")) { res = shunfengClient.orderAddTip(orderTipsVo); } else if (client.equals("dwd")) { res = dianwodaClient.dianwodaAddTips(orderTipsVo); } else if (client.equals("uupt")) { res = uuptClient.orderAddTip(orderTipsVo); } else if (client.equals("kuanfu")) { res = kfClient.orderAddTip(orderTipsVo); } else if (client.equals("huolala")){ res =huolalaClient.orderAddTip(orderTipsVo); } else { throw new BusinessException("lbClient参数不正确"); } return res; } /** * 订单查询 * * @param orderQueryVo * @return */ public ResObject queryOrderInfo(OrderQueryVo orderQueryVo) { String client = orderQueryVo.getLbClient(); if (StringUtils.isBlank(client)) { throw new BusinessException("未指定lbClient参数"); } ResObject res; if (client.equals("meituan")) { res = dMeituanClient.queryOrderInfo(orderQueryVo); } else if (client.equals("dada")) { res = dadaClient.queryOrderInfo(orderQueryVo); } else if (client.equals("dadayz")) { res = dadaClient.queryOrderInfo(orderQueryVo); } else if (client.equals("fengniao")) { // res = fengniaoClient.queryOrder(orderQueryVo); res = fengniaoClient.queryOrderInfo(orderQueryVo); } else if (client.equals("shansong")) { if (orderQueryVo.getIsShansongSH()) { res = shansongClient.queryOrderInfo(orderQueryVo); } else { res = shansongSHClient.queryOrderInfo(orderQueryVo); } } else if (client.equals("shunfeng")) { res = shunfengClient.queryOrderInfo(orderQueryVo); } else if (client.equals("dwd")) { res = dianwodaClient.dianwodaOrderQuery(orderQueryVo); } else if (client.equals("uupt")) { res = uuptClient.queryOrderInfo(orderQueryVo); } else if (client.equals("aipt")) { res = aiptClient.queryOrderInfo(orderQueryVo); }else if (client.equals("kuanfu")) { res = kfClient.queryOrderInfo(orderQueryVo); }else if (client.equals("huolala")) { res = huolalaClient.queryOrderInfo(orderQueryVo); } else { throw new BusinessException("lbClient参数不正确"); } return res; } /** * 获取骑手当前位置(信息) * * @param riderLocationVo * @return */ public ResObject getRiderLocation(RiderLocationVo riderLocationVo) { String client = riderLocationVo.getLbClient(); if (StringUtils.isBlank(client)) { throw new BusinessException("未指定lbClient参数"); } ResObject res = null; if (client.equals("meituan")) { res = dMeituanClient.getRiderLocation(riderLocationVo); } else if (client.equals("dada")) { riderLocationVo.setIsDirectDelivery(0); res = dadaClient.getRiderLocation(riderLocationVo); } else if (client.equals("dadayz")) { riderLocationVo.setIsDirectDelivery(1); res = dadaClient.getRiderLocation(riderLocationVo); } else if (client.equals("fengniao")) { //res = fengniaoClient.queryCarrier(riderLocationVo); res = fengniaoClient.getRiderLocation(riderLocationVo); } else if (client.equals("shansong")) { if (riderLocationVo.getIsShansongSH()) { res = shansongClient.getRiderLocation(riderLocationVo); //加价接口 } else { res = shansongSHClient.getRiderLocation(riderLocationVo); //加价接口 } } else if (client.equals("shunfeng")) { res = shunfengClient.getRiderLocation(riderLocationVo); } else if (client.equals("dwd")) { res = dianwodaClient.dianwodaQueryPosition(riderLocationVo); } else { throw new BusinessException("lbClient参数不正确"); } return res; } /** * 创建门店 * * @param shopVo * @return */ public ResObject createShop(ShopVo shopVo) { String client = shopVo.getLbClient(); if (StringUtils.isBlank(client)) { throw new BusinessException("未指定lbClient参数"); } ResObject res = null; if (client.equals("meituan")) { res = dMeituanClient.createShop(shopVo); } else if (client.equals("meituanzb")) { res = new ResObject<>(); res.setCode(1); res.setMsg("众包没有相应的接口"); } else if (client.equals("dada")) { shopVo.setIsDirectDelivery(0); res = dadaClient.createShop(shopVo); } else if (client.equals("dadayz")) { shopVo.setIsDirectDelivery(1); res = dadaClient.createShop(shopVo); } else if (client.equals("fengniao")) { //res =fengniaoClient.addChainStore(shopVo); res = fengniaoClient.createShop(shopVo); } else if (client.equals("shansong")) { if (shopVo.getIsShansongSH()) { res = shansongClient.createShop(shopVo); } else { res = shansongSHClient.createShop(shopVo); } } else if (client.equals("shunfeng")) { res = new ResObject<>(); res.setCode(1); res.setMsg("顺丰没有相应的接口"); //顺丰没有相应的接口 // return null; } else if (client.equals("uupt")) { res = new ResObject<>(); res.setCode(1); res.setMsg("UU跑腿没有相应的接口"); } else if (client.equals("kuanfu")) { res = new ResObject<>(); res.setCode(1); res.setMsg("快服没有相应的接口"); } else if (client.equals("dwd")) { res = dianwodaClient.dianwodaCreateShop(shopVo); } else if (client.equals("huolala")) { res = new ResObject<>(); res.setCode(1); res.setMsg("货拉拉没有相应的接口"); } else { //顺丰没有相应的接口 throw new BusinessException("lbClient参数不正确"); } return res; } /** * 更新门店 * * @param shopVo * @return */ public ResObject updateShop(ShopVo shopVo) { String client = shopVo.getLbClient(); if (StringUtils.isBlank(client)) { throw new BusinessException("未指定lbClient参数"); } ResObject res = null; if (client.equals("meituan")) { res = dMeituanClient.updateShop(shopVo); }else if (client.equals("meituanzb")) { res = new ResObject<>(); res.setCode(1); res.setMsg("众包没有相应的接口"); } else if (client.equals("dada")) { shopVo.setIsDirectDelivery(0); res = dadaClient.updateShop(shopVo); } else if (client.equals("dadayz")) { shopVo.setIsDirectDelivery(1); res = dadaClient.updateShop(shopVo); } else if (client.equals("fengniao")) { res = fengniaoClient.updateShop(shopVo); } else if (client.equals("shansong")) { if (shopVo.getIsShansongSH()) { res = shansongClient.createShop(shopVo); } else { res = shansongSHClient.createShop(shopVo); } } else if (client.equals("shunfeng")) { res = new ResObject<>(); res.setCode(1); res.setMsg("顺丰没有相应的接口"); //顺丰没有相应的接口 } else if (client.equals("huolala")) { res = new ResObject<>(); res.setCode(1); res.setMsg("货拉拉没有相应的接口"); //顺丰没有相应的接口 } else { throw new BusinessException("lb_client参数不正确"); } return res; } /** * 查询门店 * * @param shopQueryVo * @return */ public ResObject queryShop(ShopQueryVo shopQueryVo) { //JSONObject jsonParams = JSONObject.parseObject(jsonParamsStr); String client = shopQueryVo.getLbClient(); if (StringUtils.isBlank(client)) { throw new BusinessException("未指定lbClient参数"); } ResObject res = null; if (client.equals("meituan")) { res = dMeituanClient.queryShop(shopQueryVo); } else if (client.equals("dada")) { shopQueryVo.setIsDirectDelivery(0); res = dadaClient.queryShop(shopQueryVo); } else if (client.equals("dadayz")) { shopQueryVo.setIsDirectDelivery(1); res = dadaClient.queryShop(shopQueryVo); } else if (client.equals("fengniao")) { // res = fengniaoClient.queryChainStore(shopQueryVo); res = fengniaoClient.queryShop(shopQueryVo); } else if (client.equals("shansong")) { if (shopQueryVo.getIsShansongSH()) { res = shansongClient.queryShop(shopQueryVo); } else { res = shansongSHClient.queryShop(shopQueryVo); } } else if (client.equals("shunfeng")) { res = new ResObject<>(); res.setCode(1); res.setMsg("顺丰没有相应的接口"); } else { throw new BusinessException("lbClient参数不正确"); } return res; } /** * 查询商户余额 * * @param queryAmount * @return */ public ResObject queryAmount(QueryAmount queryAmount) { String client = queryAmount.getLbClient(); if (StringUtils.isBlank(client)) { throw new BusinessException("未指定lbClient参数"); } ResObject res = null; String msg = ""; if (client.equals("meituan")) { msg = "美团没有相应的接口"; } else if (client.equals("meituanzb")) { msg = "美团众包没有相应的接口"; } else if (client.equals("dada")) { queryAmount.setIsDirectDelivery(0); res = dadaClient.queryAmount(queryAmount); } else if (client.equals("dadayz")) { queryAmount.setIsDirectDelivery(1); res = dadaClient.queryAmount(queryAmount); } else if (client.equals("fengniao")) { // res = fengniaoClient.queryOrder(orderQueryVo); res = fengniaoClient.queryAmount(queryAmount); } else if (client.equals("shansong")) { if (queryAmount.getIsShansongSH()) { res = shansongClient.queryAmount(queryAmount); } else { res = shansongSHClient.queryAmount(null); } } else if (client.equals("shunfeng")) { msg = "顺丰没有相应的接口"; } else if (client.equals("dwd")) { msg = "dwd没有相应的接口"; } else if (client.equals("uupt")) { res = uuptClient.queryAmount(queryAmount); } else if (client.equals("aipt")) { res = aiptClient.queryAmount(queryAmount); }else if (client.equals("kuanfu")) { msg = "快服没有相应的接口"; } else { throw new BusinessException("lbClient参数不正确"); } if (null == res) { res = new ResObject<>(); res.setCode(1); res.setMsg(msg); } return res; } }