123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296 |
- package com.ydd.third.waimai;
- import com.alibaba.fastjson.JSONObject;
- import com.ydd.common.exception.BusinessException;
- import com.ydd.third.common.utils.HttpUtils;
- import com.ydd.third.common.utils.StringUtils;
- import com.ydd.third.common.vo.ResObject;
- import com.ydd.third.common.vo.waimai.*;
- import com.ydd.third.common.vo.waimai.meituan.RefundFoodItemVo;
- import com.ydd.third.waimai.eleRetai.EleRetaiClient;
- import com.ydd.third.waimai.eleme.ElemeClient;
- import com.ydd.third.waimai.meituan.MeituanClient;
- import lombok.extern.slf4j.Slf4j;
- import org.springframework.beans.factory.annotation.Autowired;
- import org.springframework.stereotype.Service;
- import java.math.BigDecimal;
- import java.util.List;
- /**
- * @ClassName Client
- * @Deacription TODO
- * @Author peakren
- * @Date 2/4/21 10:20 PM
- * @Version 1.0
- **/
- @Slf4j
- @Service("waimaiClient")
- public class Client {
- @Autowired
- MeituanClient meituanClient;
- @Autowired
- ElemeClient elemeClient;
- @Autowired
- EleRetaiClient eleRetaiClient;
- /**
- * ok
- * 查询订单
- * @param queryOrderVo
- * @return
- */
- public ResObject queryOrderById(QueryOrderVo queryOrderVo) {
- String client = queryOrderVo.getLbClient();
- if (StringUtils.isBlank(client)) {
- throw new BusinessException("未指定lbClient参数");
- }
- if (client.equals("meituan")) {
- ResObject<MeituanOrderResultVo> res = meituanClient.queryOrderById(queryOrderVo);
- return res;
- } else if (client.equals("eleme")) {
- ResObject<ElemeOrderResultVo> res = elemeClient.getOrder(queryOrderVo);
- return res;
- } else {
- throw new BusinessException("lb_client参数不正确");
- }
- }
- /**
- * ok
- * 对订单进行确认
- * @param confirmOrderVo
- * @return
- */
- public ResObject confirmOrder(ConfirmOrderVo confirmOrderVo){
- // JSONObject jsonParams = JSONObject.parseObject(jsonParamsStr);
- String client = confirmOrderVo.getLbClient(); //jsonParams.getString("lb_client");
- if (StringUtils.isBlank(client)) {
- throw new BusinessException("未指定lbClient参数");
- }
- ResObject res ;
- if (client.equals("meituan")) {
- res = meituanClient.confirmOrder(confirmOrderVo);
- } else if (client.equals("eleme")) {
- res = elemeClient.confirmOrder(confirmOrderVo);
- } else {
- throw new BusinessException("lbClient参数不正确");
- }
- return res;
- }
- /**
- * ok
- * 取消订单
- * @param cancelOrderVo
- * @return
- */
- public ResObject cancelOrder(CancelOrderVo cancelOrderVo) {
- // JSONObject jsonParams = JSONObject.parseObject(jsonParamsStr);
- String client = cancelOrderVo.getLbClient();
- if (StringUtils.isBlank(client)) {
- throw new BusinessException("未指定lbClient参数");
- }
- ResObject res;
- if (client.equals("meituan")) {
- res = meituanClient.cancelOrder(cancelOrderVo);
- } else if (client.equals("eleme")) {
- res = elemeClient.cancelOrder(cancelOrderVo);
- } else if (client.equals("elemeretail")) {
- res = eleRetaiClient.cancelOrder(cancelOrderVo);
- } else {
- throw new BusinessException("lbClient参数不正确");
- }
- return res;
- }
- /**
- * ok
- * 自配订单同步配送信息
- * @param syncRiderPositionVo
- * @return
- */
- public ResObject syncRiderPositionStatus(SyncRiderPositionStatusVo syncRiderPositionVo) { ;
- String client = syncRiderPositionVo.getLbClient();
- if (StringUtils.isBlank(client)) {
- throw new BusinessException("未指定lbClient参数");
- }
- ResObject res= new ResObject();
- if (client.equals("meituan")) {
- res = meituanClient.syncRiderPosition(syncRiderPositionVo);
- } else if (client.equals("eleme")) {
- //同步位置
- if(syncRiderPositionVo.getLongitude()!=null&&syncRiderPositionVo.getLongitude().compareTo(BigDecimal.ZERO)>0
- &&("DELIVERY_START".equals(syncRiderPositionVo.getDeliverState().name()))){
- res = elemeClient.selfDeliveryLocationSync(syncRiderPositionVo);
- }
- //同步状态
- res = elemeClient.selfDeliveryStateSync(syncRiderPositionVo);
- }else if (client.equals("elemeretail")){
- if(syncRiderPositionVo.getLogisticsStatus()==16){
- res= eleRetaiClient.complete(syncRiderPositionVo.getOrderId(),syncRiderPositionVo.getCourierPhone());
- }else{
- if(syncRiderPositionVo.getLongitude()!=null&&syncRiderPositionVo.getLongitude().compareTo(BigDecimal.ZERO)>0){
- eleRetaiClient.syncRiderPosition(syncRiderPositionVo);
- }
- if(syncRiderPositionVo.getLogisticsStatus().intValue()!=-1){
- res= eleRetaiClient.syncRiderPositionStatus(syncRiderPositionVo);
- }
- }
- }else if (client.equals("shantang")){
- String json = syncRiderPositionVo.getShanTangdto();
- res = new ResObject();
- try {
- String resp = HttpUtils.sendJsonPost("https://business-api.hsst100.com/order/delivery/delivery/callback",json);
- res.setCode(0);
- res.setMsg("操作成功"+resp);
- } catch (Exception e) {
- e.printStackTrace();
- }
- }
- else {
- throw new BusinessException("lb_client参数不正确");
- }
- return res;
- }
- /**
- * ok
- * 订单同意退款
- * @param agreeOrderRefundVo
- * @return
- */
- public ResObject agreeOrderRefund(AgreeOrderRefundVo agreeOrderRefundVo) {
- String client = agreeOrderRefundVo.getLbClient();
- if (StringUtils.isBlank(client)) {
- throw new BusinessException("未指定lbClient参数");
- }
- ResObject res;
- if (client.equals("meituan")) {
- res = meituanClient.agreeOrderRefund(agreeOrderRefundVo);
- } else if (client.equals("eleme")) {
- res = elemeClient.agreeRefundOrder(agreeOrderRefundVo);
- } else {
- throw new BusinessException("lbClient参数不正确");
- }
- return res;
- }
- /**
- * ok
- * 订单拒绝退款
- * @param rejectOrderRefundVo
- * @return
- */
- public ResObject rejectOrderRefund(RejectOrderRefundVo rejectOrderRefundVo) {
- String client = rejectOrderRefundVo.getLbClient(); //jsonParams.getString("lb_client");
- if (StringUtils.isBlank(client)) {
- throw new BusinessException("未指定lbClient参数");
- }
- ResObject res;
- if (client.equals("meituan")) {
- res = meituanClient.rejectOrderRefund(rejectOrderRefundVo);
- } else if (client.equals("eleme")) {
- res = elemeClient.disagreeRefundOrder(rejectOrderRefundVo);
- } else {
- throw new BusinessException("lbClient参数不正确");
- }
- return res;
- }
- /**
- * ok
- * 部分退款-查询部分退款商品
- * @param queryPartRefundFoodsVo
- * @return
- */
- public ResObject<List<RefundFoodItemVo>> queryPartRefundFoods(QueryPartRefundFoodsVo queryPartRefundFoodsVo) {
- String client = queryPartRefundFoodsVo.getLbClient(); //jsonParams.getString("lb_client");
- if (StringUtils.isBlank(client)) {
- throw new BusinessException("未指定lbClient参数");
- }
- ResObject<List<RefundFoodItemVo>> res;
- if (client.equals("meituan")) {
- res = meituanClient.queryPartRefundFoods(queryPartRefundFoodsVo);
- } else if (client.equals("eleme")) {
- res = new ResObject<>();
- res.setMsg("饿了么没有相应的接口");
- } else {
- throw new BusinessException("lbClient参数不正确");
- }
- return res;
- }
- /**
- * ok
- * 部分退款-申请部分退款
- * @param applyPartRefundVo
- * @return
- */
- public ResObject applyPartRefund(ApplyPartRefundVo applyPartRefundVo) {
- //JSONObject jsonParams = JSONObject.parseObject(jsonParamsStr);
- String client = applyPartRefundVo.getLbClient(); // .getLjsonParams.getString("lb_client");
- if (StringUtils.isBlank(client)) {
- throw new BusinessException("未指定lbClient参数");
- }
- ResObject res;
- if (client.equals("meituan")) {
- res = meituanClient.applyPartRefund(applyPartRefundVo);
- } else if (client.equals("eleme")) {
- res = elemeClient.refundParty(applyPartRefundVo); //商家部分退款
- } else {
- throw new BusinessException("lbClient参数不正确");
- }
- return res;
- }
- /**
- * ok
- * 催单回复
- * @param orderRemindReplyVo
- * @return
- */
- public ResObject orderRemindReply(OrderRemindReplyVo orderRemindReplyVo) {
- String client = orderRemindReplyVo.getLbClient(); //jsonParams.getString("lb_client");
- if (StringUtils.isBlank(client)) {
- throw new BusinessException("未指定lbClient参数");
- }
- ResObject res;
- if (client.equals("meituan")) {
- res = meituanClient.orderRemindReply(orderRemindReplyVo);
- } else if (client.equals("eleme")) {
- res = elemeClient.replyReminder(orderRemindReplyVo); //回复催单
- } else {
- throw new BusinessException("lbClient参数不正确");
- }
- return res;
- }
- /**
- * ok
- * 查询门店信息
- * @param jsonParamsStr
- * @return
- */
- public String queryShopInfo(String jsonParamsStr) {
- JSONObject jsonParams = JSONObject.parseObject(jsonParamsStr);
- String client = jsonParams.getString("lb_client");
- if (StringUtils.isBlank(client)) {
- throw new BusinessException("未指定lb_client参数");
- }
- String res = "";
- if (client.equals("meituan")) {
- res = meituanClient.queryPoiInfo(jsonParamsStr);
- } else if (client.equals("eleme")) {
- res = elemeClient.getShop(jsonParamsStr); //回复催单
- } else {
- throw new BusinessException("lb_client参数不正确");
- }
- return res;
- }
- }
|