|
@@ -0,0 +1,78 @@
|
|
|
+package com.ydd.third.controller;
|
|
|
+
|
|
|
+import com.alibaba.fastjson.JSONObject;
|
|
|
+import com.ydd.common.core.controller.BaseController;
|
|
|
+import com.ydd.common.core.domain.BaseResult;
|
|
|
+import com.ydd.third.common.vo.ResObject;
|
|
|
+import com.ydd.third.delivery.meituan.sign.SignHelper;
|
|
|
+import com.ydd.third.delivery.meituan.util.HttpClient;
|
|
|
+import io.swagger.annotations.Api;
|
|
|
+import lombok.RequiredArgsConstructor;
|
|
|
+import lombok.extern.slf4j.Slf4j;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
+import org.springframework.web.bind.annotation.RequestMethod;
|
|
|
+import org.springframework.web.bind.annotation.RestController;
|
|
|
+
|
|
|
+import java.util.HashMap;
|
|
|
+import java.util.Map;
|
|
|
+
|
|
|
+
|
|
|
+/**
|
|
|
+ * 测试接口
|
|
|
+ */
|
|
|
+@Api(value = "测试", tags = {"测试接口"})
|
|
|
+@RestController
|
|
|
+@RequestMapping("/app/test")
|
|
|
+@RequiredArgsConstructor(onConstructor_ = @Autowired)
|
|
|
+@Slf4j
|
|
|
+public class TestApi extends BaseController {
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 美团配送模拟接单
|
|
|
+ */
|
|
|
+ @RequestMapping(value = "/orderArrangeMeiTuan", method = RequestMethod.POST)
|
|
|
+ public BaseResult<ResObject> orderArrangeMeiTuan(String orderSn, String mtPeisongId, Integer type) throws Exception {
|
|
|
+ Map<String, String> bizMap = new HashMap<>();
|
|
|
+ bizMap.put("delivery_id", orderSn);
|
|
|
+ bizMap.put("mt_peisong_id", mtPeisongId);
|
|
|
+ Map<String, String> params = new HashMap<>(8);
|
|
|
+ Long timestamp = System.currentTimeMillis() / 1000;
|
|
|
+ params.put("charset", "utf-8");
|
|
|
+ params.put("timestamp", String.valueOf(timestamp));
|
|
|
+ params.put("version", "2");
|
|
|
+ params.put("developerId", "106407");
|
|
|
+ params.put("businessId", "19");
|
|
|
+ params.put("biz", JSONObject.toJSONString(bizMap));
|
|
|
+ String sign = SignHelper.generateSign(params, "f6oknqt6fla2oguu");
|
|
|
+ params.put("sign", sign);
|
|
|
+ String url = "https://api-open-cater.meituan.com/peisong/test/orderArrange";
|
|
|
+ if (type == 1) {
|
|
|
+ url = "https://api-open-cater.meituan.com/peisong/test/orderPickup";//取货
|
|
|
+ }
|
|
|
+ if (type == 2) {
|
|
|
+ url = "https://api-open-cater.meituan.com/peisong/test/orderDeliver";//送达
|
|
|
+ }
|
|
|
+ if (type == 3) {
|
|
|
+ url = "https://api-open-cater.meituan.com/peisong/test/orderRearrange";//改派
|
|
|
+ }
|
|
|
+ if (type == 4) {
|
|
|
+ url = "https://api-open-cater.meituan.com/peisong/test/orderReportException";//模拟骑手上传异常
|
|
|
+ }
|
|
|
+ try {
|
|
|
+ if (type != 4){
|
|
|
+ log.info("*************美团模拟接单:" + JSONObject.toJSONString(params));
|
|
|
+ String res = HttpClient.post(url, params);
|
|
|
+ log.info("*************美团模拟接单返回---->>>>>:" + JSONObject.toJSONString(res));
|
|
|
+ }else {
|
|
|
+ log.info("*************美团模拟骑手上传异常:" + JSONObject.toJSONString(params));
|
|
|
+ String res = HttpClient.post(url, params);
|
|
|
+ log.info("*************美团模拟骑手上传异常---->>>>>:" + JSONObject.toJSONString(res));
|
|
|
+ }
|
|
|
+ } catch (Exception e) {
|
|
|
+ throw e;
|
|
|
+ }
|
|
|
+ return BaseResult.success();
|
|
|
+ }
|
|
|
+
|
|
|
+}
|