Commit ed811c7e authored by 黎博's avatar 黎博

新增查询订单详情/api/order/selectJdOrder接口

parent 1b46f09e
......@@ -2,6 +2,8 @@ package cn.qg.holmes.controller.mock.keystone;
import cn.qg.holmes.bean.KeystoneService;
import cn.qg.holmes.entity.mock.keystone.*;
import cn.qg.holmes.utils.DateUtils;
import cn.qg.holmes.utils.RedisUtils;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
......@@ -25,6 +27,9 @@ public class OrderController {
@Autowired
KeystoneService keystoneService;
@Autowired
RedisUtils redisUtils;
/**
* 商品税率
*/
......@@ -35,6 +40,8 @@ public class OrderController {
*/
private final Integer SKU_CATEGORY = 15924;
private String QYG_ORDER_PREFIX = "qyg_order_";
/**
* 7.3 企业购提交订单
* @param submitOrderRequest 请求参数
......@@ -61,7 +68,8 @@ public class OrderController {
response.put("resultCode", "0001");
response.put("resultMessage", "下单成功");
JSONObject result = new JSONObject();
result.put("jdOrderId", RandomStringUtils.randomNumeric(12));
String jdOrderId = RandomStringUtils.randomNumeric(12);
result.put("jdOrderId", jdOrderId);
result.put("freight", calculateFreight(orderPrice));
result.put("orderPrice", orderPrice);
BigDecimal orderNakedPrice = orderPrice.divide(TAX.add(new BigDecimal(1)), BigDecimal.ROUND_HALF_UP);
......@@ -89,6 +97,8 @@ public class OrderController {
result.put("sku", bizSkuList);
result.put("orderTaxPrice", orderNakedPrice.multiply(TAX).setScale(2, BigDecimal.ROUND_HALF_UP));
response.put("result", result);
// 设置缓存,方便后面查询京东订单详情接口使用
redisUtils.set(QYG_ORDER_PREFIX + jdOrderId, response, 604800);
return response;
}
......@@ -119,6 +129,50 @@ public class OrderController {
return resposne;
}
/**
* 7.7 查询订单详情
*/
@PostMapping("/api/order/selectJdOrder")
public JSONObject qygOrderDetail(JdOrderDetailRequest request) {
String jdOrderId = request.getJdOrderId();
String queryExts = request.getQueryExts();
JSONObject orderInfo = JSONObject.parseObject(redisUtils.get(QYG_ORDER_PREFIX + jdOrderId).toString());
JSONObject response = new JSONObject();
response.put("success", true);
response.put("resultMessage", "");
response.put("resultCode", "0000");
JSONObject result = new JSONObject();
result.put("pOrder", 0);
result.put("orderState", 1);
result.put("jdOrderId", Long.valueOf(jdOrderId));
result.put("state", 1);
result.put("submitState", 1);
result.put("type", 1);
result.put("freight", orderInfo.get("freight"));
result.put("orderPrice", orderInfo.get("orderPrice"));
result.put("orderNakedPrice", orderInfo.get("orderNakedPrice"));
result.put("orderTaxPrice", orderInfo.get("orderTaxPrice"));
if (queryExts != null && queryExts.contains("orderType")) {
result.put("orderType", 1);
}
if (queryExts != null && queryExts.contains("createOrderTime")) {
result.put("createOrderTime", DateUtils.getCurrentDate("yyyy-MM-dd hh:mm:ss")); // todo
}
if (queryExts != null && queryExts.contains("finishTime")) {
result.put("finishTime", DateUtils.getCurrentDate("yyyy-MM-dd hh:mm:ss"));
}
if (queryExts != null && queryExts.contains("jdOrderState")) {
// 16-等待确认收货
result.put("jdOrderState", 16);
}
result.put("paymentType", 4);
result.put("sku", orderInfo.get("sku"));
response.put("result", result);
return response;
}
/**
* 11.1 查询推送消息
* @return
......
package cn.qg.holmes.entity.mock.keystone;
import lombok.Data;
/**
* 7.7 查询订单详情
*/
@Data
public class JdOrderDetailRequest {
private String token;
/**
* 京东的订单单号(下单返回的父订单号)
*/
private String jdOrderId;
private String queryExts = "orderType,jdOrderState,finishTime,createOrderTime,paymentType";
}
......@@ -266,10 +266,10 @@ public class YeebaoInterceptor implements HandlerInterceptor {
* 特殊处理 /tzt-api/api/bindcard/request
*/
public Map<String, Object> handleBindCardRequest(Map<String, Object> requestMap, Map<String, Object> responseMap) {
redisUtils.set(requestMap.get("requestno").toString(), responseMap);
redisUtils.set(requestMap.get("requestno").toString(), responseMap, 86400);
log.info("保存redis值, key: {}, value: {}", requestMap.get("requestno"), requestMap);
responseMap.put("yborderid", "TZAUba0c7b8" + requestMap.get("requestno") + "95c929ca802e");
redisUtils.set(requestMap.get("requestno").toString() + "_response", responseMap);
redisUtils.set(requestMap.get("requestno").toString() + "_response", responseMap, 86400);
log.info("保存redis值, key: {}, value: {}", requestMap.get("requestno").toString() + "_response", requestMap);
return responseMap;
}
......
......@@ -83,4 +83,8 @@ public class DateUtils {
return new Date(c.getTimeInMillis());
}
public static void main(String[] args) {
System.out.println(DateUtils.getCurrentTime());
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment