记得上下班打卡 | git大法好,push需谨慎

Commit 482e7cd4 authored by 胡佳晨's avatar 胡佳晨

订单增加 日志 打印当前时间

parent 037ac840
...@@ -11,7 +11,7 @@ liquidnet: ...@@ -11,7 +11,7 @@ liquidnet:
name: service-order name: service-order
config: classpath:logback-spring.xml config: classpath:logback-spring.xml
file-max-size: 200MB file-max-size: 200MB
level: info level: debug
mysql: mysql:
database-name: test_ln_scene database-name: test_ln_scene
mongodb: mongodb:
......
...@@ -3,7 +3,6 @@ package com.liquidnet.service.order.service.impl; ...@@ -3,7 +3,6 @@ package com.liquidnet.service.order.service.impl;
import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSON;
import com.fasterxml.jackson.core.type.TypeReference; import com.fasterxml.jackson.core.type.TypeReference;
import com.liquidnet.commons.lang.util.*; import com.liquidnet.commons.lang.util.*;
import com.liquidnet.service.adam.dto.vo.AdamRscPolymer01Vo;
import com.liquidnet.service.base.ErrorMapping; import com.liquidnet.service.base.ErrorMapping;
import com.liquidnet.service.base.ResponseDto; import com.liquidnet.service.base.ResponseDto;
import com.liquidnet.service.base.SqlMapping; import com.liquidnet.service.base.SqlMapping;
...@@ -53,8 +52,6 @@ public class GoblinOrderServiceImpl implements IGoblinOrderService { ...@@ -53,8 +52,6 @@ public class GoblinOrderServiceImpl implements IGoblinOrderService {
QueueUtils queueUtils; QueueUtils queueUtils;
@Autowired @Autowired
GoblinOrderUtils orderUtils; GoblinOrderUtils orderUtils;
// @Autowired
// FeignGoblinBaseClient feignGoblinBaseClient;
@Value("${liquidnet.service.order.url-pay.pay}") @Value("${liquidnet.service.order.url-pay.pay}")
private String payUrl; private String payUrl;
...@@ -90,13 +87,11 @@ public class GoblinOrderServiceImpl implements IGoblinOrderService { ...@@ -90,13 +87,11 @@ public class GoblinOrderServiceImpl implements IGoblinOrderService {
AddressVo addressesVo = null; AddressVo addressesVo = null;
if (orderUtils.noZhengzaiOrder(uid)) { if (orderUtils.noZhengzaiOrder(uid)) {
addressesVo = param.getAddressesVo(); addressesVo = param.getAddressesVo();
long time3 = System.currentTimeMillis();
if (orderUtils.getMember(uid) != null) { if (orderUtils.getMember(uid) != null) {
isMember = true; isMember = true;
} else { } else {
isMember = false; isMember = false;
} }
log.error("获取会员信息:" + (System.currentTimeMillis() - time3) + "ms");
} else { } else {
isMember = false; isMember = false;
} }
...@@ -162,7 +157,6 @@ public class GoblinOrderServiceImpl implements IGoblinOrderService { ...@@ -162,7 +157,6 @@ public class GoblinOrderServiceImpl implements IGoblinOrderService {
if (params.size() > 0) { if (params.size() > 0) {
orderUtils.backStoreCoupon(params); orderUtils.backStoreCoupon(params);
} }
log.info("回滚逻辑 " + (System.currentTimeMillis() - time3) + "ms");
if (e.getMessage() == null) { if (e.getMessage() == null) {
return ResponseDto.failure(ErrorMapping.get("20018"));//乱七八糟异常 return ResponseDto.failure(ErrorMapping.get("20018"));//乱七八糟异常
} else if (e.getMessage().equals("无权购买")) { } else if (e.getMessage().equals("无权购买")) {
...@@ -192,7 +186,6 @@ public class GoblinOrderServiceImpl implements IGoblinOrderService { ...@@ -192,7 +186,6 @@ public class GoblinOrderServiceImpl implements IGoblinOrderService {
} }
private GoblinOrderPreParam order(GoblinOrderParam param, GoblinOrderStoreParam storeParam, String uid, boolean isMember, AddressVo addressesVo, String orderMasterCode, String orderId, String orderCode, List<String> platformCodeList, List<String> storeCodeList) throws Exception { private GoblinOrderPreParam order(GoblinOrderParam param, GoblinOrderStoreParam storeParam, String uid, boolean isMember, AddressVo addressesVo, String orderMasterCode, String orderId, String orderCode, List<String> platformCodeList, List<String> storeCodeList) throws Exception {
long timeAll = System.currentTimeMillis();
String platVoucherCode = storeParam.getPlatVoucherCode(); String platVoucherCode = storeParam.getPlatVoucherCode();
String storeVoucherCode = storeParam.getStoreVoucherCode(); String storeVoucherCode = storeParam.getStoreVoucherCode();
String storeId = storeParam.getStoreId(); String storeId = storeParam.getStoreId();
...@@ -201,6 +194,7 @@ public class GoblinOrderServiceImpl implements IGoblinOrderService { ...@@ -201,6 +194,7 @@ public class GoblinOrderServiceImpl implements IGoblinOrderService {
String source = headerCliSource == null ? "" : headerCliSource; String source = headerCliSource == null ? "" : headerCliSource;
String version = headerCliVersion == null ? "" : headerCliVersion; String version = headerCliVersion == null ? "" : headerCliVersion;
LocalDateTime now = LocalDateTime.now(); LocalDateTime now = LocalDateTime.now();
log.debug("当前系统时间=" + now);
String skuName = ""; String skuName = "";
BigDecimal price;//sku应付价格 BigDecimal price;//sku应付价格
BigDecimal priceBase;//sku原价 BigDecimal priceBase;//sku原价
...@@ -211,7 +205,6 @@ public class GoblinOrderServiceImpl implements IGoblinOrderService { ...@@ -211,7 +205,6 @@ public class GoblinOrderServiceImpl implements IGoblinOrderService {
String marketType = ""; String marketType = "";
for (GoblinOrderSkuParam skuParam : storeParam.getGoblinOrderSkuParamArrayList()) { for (GoblinOrderSkuParam skuParam : storeParam.getGoblinOrderSkuParamArrayList()) {
String pre = GoblinStatusConst.MarketPreStatus.getPre(skuParam.getSkuId()); String pre = GoblinStatusConst.MarketPreStatus.getPre(skuParam.getSkuId());
Long time3 = System.currentTimeMillis();
GoblinGoodsSkuInfoVo skuVo = redisUtils.getGoodsSkuInfoVo(skuParam.getSkuId()); GoblinGoodsSkuInfoVo skuVo = redisUtils.getGoodsSkuInfoVo(skuParam.getSkuId());
GoblinGoodsInfoVo spuVo = redisUtils.getGoodsInfoVo(skuParam.getSpuId()); GoblinGoodsInfoVo spuVo = redisUtils.getGoodsInfoVo(skuParam.getSpuId());
if (!spuVo.getStoreId().equals(storeParam.getStoreId()) || !skuVo.getStoreId().equals(storeParam.getStoreId())) { if (!spuVo.getStoreId().equals(storeParam.getStoreId()) || !skuVo.getStoreId().equals(storeParam.getStoreId())) {
...@@ -234,7 +227,6 @@ public class GoblinOrderServiceImpl implements IGoblinOrderService { ...@@ -234,7 +227,6 @@ public class GoblinOrderServiceImpl implements IGoblinOrderService {
throw new Exception("无权购买"); throw new Exception("无权购买");
} }
} }
log.error("获取会员sku&spu:" + (System.currentTimeMillis() - time3) + "ms");
marketId = spuVo.getMarketId(); marketId = spuVo.getMarketId();
marketType = pre; marketType = pre;
skuName = skuName.concat(skuVo.getName()).concat(","); skuName = skuName.concat(skuVo.getName()).concat(",");
...@@ -309,7 +301,6 @@ public class GoblinOrderServiceImpl implements IGoblinOrderService { ...@@ -309,7 +301,6 @@ public class GoblinOrderServiceImpl implements IGoblinOrderService {
} }
} }
HashMap<String, Object> hashMap = orderUtils.useCoupon(platVoucherCode, "购买商品[" + orderCode + "]", storeTotalPrice, spuIds, uid); HashMap<String, Object> hashMap = orderUtils.useCoupon(platVoucherCode, "购买商品[" + orderCode + "]", storeTotalPrice, spuIds, uid);
//todo
if (hashMap != null) { if (hashMap != null) {
voucherPrice = (BigDecimal) hashMap.get("voucher"); voucherPrice = (BigDecimal) hashMap.get("voucher");
Integer typeVoucher = (Integer) hashMap.get("type"); Integer typeVoucher = (Integer) hashMap.get("type");
...@@ -344,9 +335,7 @@ public class GoblinOrderServiceImpl implements IGoblinOrderService { ...@@ -344,9 +335,7 @@ public class GoblinOrderServiceImpl implements IGoblinOrderService {
} }
} }
} }
long time3 = System.currentTimeMillis();
GoblinStoreInfoVo storeInfoVo = redisUtils.getStoreInfoVo(storeId); GoblinStoreInfoVo storeInfoVo = redisUtils.getStoreInfoVo(storeId);
log.error("获取店铺信息:" + (System.currentTimeMillis() - time3) + "ms");
//生成订单 //生成订单
GoblinStoreOrder storeOrder = GoblinStoreOrder.getNew(); GoblinStoreOrder storeOrder = GoblinStoreOrder.getNew();
storeOrder.setMasterOrderCode(orderMasterCode); storeOrder.setMasterOrderCode(orderMasterCode);
...@@ -413,13 +402,10 @@ public class GoblinOrderServiceImpl implements IGoblinOrderService { ...@@ -413,13 +402,10 @@ public class GoblinOrderServiceImpl implements IGoblinOrderService {
preParam.setStoreOrder(storeOrder); preParam.setStoreOrder(storeOrder);
preParam.setOrderAttr(orderAttr); preParam.setOrderAttr(orderAttr);
preParam.setOrderSkuList(goblinOrderSkuList); preParam.setOrderSkuList(goblinOrderSkuList);
log.info("订单生成耗时:" + (System.currentTimeMillis() - timeAll) + "ms");
return preParam; return preParam;
} }
private ResponseDto<GoblinPayInnerResultVo> payOrder(GoblinOrderPreParam private ResponseDto<GoblinPayInnerResultVo> payOrder(GoblinOrderPreParam preParam, List<GoblinOrderSqlParam> sqlParams, String uid) {
preParam, List<GoblinOrderSqlParam> sqlParams, String uid) {
long timeAll = System.currentTimeMillis();
//是否免费 //是否免费
boolean isFree = false; boolean isFree = false;
GoblinPayInnerResultVo payInnerResultVo; GoblinPayInnerResultVo payInnerResultVo;
...@@ -507,7 +493,6 @@ public class GoblinOrderServiceImpl implements IGoblinOrderService { ...@@ -507,7 +493,6 @@ public class GoblinOrderServiceImpl implements IGoblinOrderService {
} }
payInnerResultVo.setOrderMasterCode(preParam.getOrderMasterCode()); payInnerResultVo.setOrderMasterCode(preParam.getOrderMasterCode());
long time3 = System.currentTimeMillis();
LinkedList<String> sqls = CollectionUtil.linkedListString(); LinkedList<String> sqls = CollectionUtil.linkedListString();
sqls.add(SqlMapping.get("goblin.order.create.sku_insert")); sqls.add(SqlMapping.get("goblin.order.create.sku_insert"));
sqls.add(SqlMapping.get("goblin.order.create.order_insert")); sqls.add(SqlMapping.get("goblin.order.create.order_insert"));
...@@ -518,7 +503,6 @@ public class GoblinOrderServiceImpl implements IGoblinOrderService { ...@@ -518,7 +503,6 @@ public class GoblinOrderServiceImpl implements IGoblinOrderService {
List<GoblinStoreOrderVo> orderVoList = ObjectUtil.getGoblinStoreOrderVoArrayList(); List<GoblinStoreOrderVo> orderVoList = ObjectUtil.getGoblinStoreOrderVoArrayList();
List<GoblinOrderSkuVo> skuVoList = ObjectUtil.getGoblinOrderSkuVoArrayList(); List<GoblinOrderSkuVo> skuVoList = ObjectUtil.getGoblinOrderSkuVoArrayList();
for (GoblinOrderSqlParam item : sqlParams) { for (GoblinOrderSqlParam item : sqlParams) {
long time2 = System.currentTimeMillis();
List<String> goblinOrderSkuIdList = CollectionUtil.linkedListString(); List<String> goblinOrderSkuIdList = CollectionUtil.linkedListString();
for (GoblinOrderSku orderSku : item.getOrderSkuList()) { for (GoblinOrderSku orderSku : item.getOrderSkuList()) {
sqlDataSku.add(new Object[]{ sqlDataSku.add(new Object[]{
...@@ -531,7 +515,6 @@ public class GoblinOrderServiceImpl implements IGoblinOrderService { ...@@ -531,7 +515,6 @@ public class GoblinOrderServiceImpl implements IGoblinOrderService {
goblinOrderSkuIdList.add(orderSkuVo.getOrderSkuId()); goblinOrderSkuIdList.add(orderSkuVo.getOrderSkuId());
skuVoList.add(orderSkuVo); skuVoList.add(orderSkuVo);
} }
log.error("生成子订单逻辑:" + (System.currentTimeMillis() - time2) + "ms");
GoblinStoreOrder storeOrder = item.getStoreOrder(); GoblinStoreOrder storeOrder = item.getStoreOrder();
storeOrder.setPayCode(payCode); storeOrder.setPayCode(payCode);
sqlDataOrder.add(new Object[]{ sqlDataOrder.add(new Object[]{
...@@ -548,21 +531,16 @@ public class GoblinOrderServiceImpl implements IGoblinOrderService { ...@@ -548,21 +531,16 @@ public class GoblinOrderServiceImpl implements IGoblinOrderService {
//订单attr vo //订单attr vo
GoblinOrderAttrVo orderAttrVo = GoblinOrderAttrVo.getNew().copy(orderAttr); GoblinOrderAttrVo orderAttrVo = GoblinOrderAttrVo.getNew().copy(orderAttr);
time2 = System.currentTimeMillis();
//待支付发送队列 //待支付发送队列
queueUtils.sendMsgByRedisGoblinStock(orderVo.getMasterOrderCode(), storeOrder.getCreatedAt()); queueUtils.sendMsgByRedisGoblinStock(orderVo.getMasterOrderCode(), storeOrder.getCreatedAt());
log.error("发送队列 待支付订单:" + (System.currentTimeMillis() - time2) + "ms");
//redis 赋值 //redis 赋值
orderVo.setOrderAttrVo(orderAttrVo); orderVo.setOrderAttrVo(orderAttrVo);
orderVo.setOrderSkuVoIds(goblinOrderSkuIdList); orderVo.setOrderSkuVoIds(goblinOrderSkuIdList);
orderVo.setCreatedAt(getNowTime()); orderVo.setCreatedAt(getNowTime());
time2 = System.currentTimeMillis();
redisUtils.setGoblinOrder(orderVo.getOrderId(), orderVo); redisUtils.setGoblinOrder(orderVo.getOrderId(), orderVo);
redisUtils.setMasterCode(orderVo.getMasterOrderCode(), preParam.getOrderIdList().substring(1)); redisUtils.setMasterCode(orderVo.getMasterOrderCode(), preParam.getOrderIdList().substring(1));
orderVoList.add(orderVo); orderVoList.add(orderVo);
log.error("保存数据:" + (System.currentTimeMillis() - time2) + "ms");
time2 = System.currentTimeMillis();
//redis 订单列表 //redis 订单列表
if (orderUtils.noZhengzaiOrder(uid)) { if (orderUtils.noZhengzaiOrder(uid)) {
if (orderVo.getMarketType() == null) { if (orderVo.getMarketType() == null) {
...@@ -571,20 +549,15 @@ public class GoblinOrderServiceImpl implements IGoblinOrderService { ...@@ -571,20 +549,15 @@ public class GoblinOrderServiceImpl implements IGoblinOrderService {
redisUtils.addZhengzaiOrderList(uid, orderVo.getOrderId()); redisUtils.addZhengzaiOrderList(uid, orderVo.getOrderId());
} }
} }
log.error("判断是否正在下单:" + (System.currentTimeMillis() - time2) + "ms");
} }
log.error("店铺订单:" + (System.currentTimeMillis() - time3) + "ms");
time3 = System.currentTimeMillis();
mongoUtils.insertGoblinOrderSkuVoList(skuVoList); mongoUtils.insertGoblinOrderSkuVoList(skuVoList);
mongoUtils.insertGoblinStoreOrderVos(orderVoList); mongoUtils.insertGoblinStoreOrderVos(orderVoList);
log.error("MDB保存:" + (System.currentTimeMillis() - time3) + "ms");
//mysql 执行sql //mysql 执行sql
String sqlData = SqlMapping.gets(sqls, sqlDataSku, sqlDataOrder, sqlDataAttr); String sqlData = SqlMapping.gets(sqls, sqlDataSku, sqlDataOrder, sqlDataAttr);
queueUtils.sendMsgByRedis(MQConst.GoblinQueue.GOBLIN_ORDER_CREATE_PAY.getKey(), sqlData); queueUtils.sendMsgByRedis(MQConst.GoblinQueue.GOBLIN_ORDER_CREATE_PAY.getKey(), sqlData);
log.info(UserPathDto.setData("下单(唤起支付)", preParam, payInnerResultVo)); log.info(UserPathDto.setData("下单(唤起支付)", preParam, payInnerResultVo));
log.error("支付单接口耗时:" + (System.currentTimeMillis() - timeAll) + "ms");
if (isFree && preParam.getPayType().equals("huifu")) { if (isFree && preParam.getPayType().equals("huifu")) {
return ResponseDto.success(payInnerResultVo); return ResponseDto.success(payInnerResultVo);
} else if (isFree) { } else if (isFree) {
...@@ -609,13 +582,15 @@ public class GoblinOrderServiceImpl implements IGoblinOrderService { ...@@ -609,13 +582,15 @@ public class GoblinOrderServiceImpl implements IGoblinOrderService {
LocalDateTime now = LocalDateTime.now(); LocalDateTime now = LocalDateTime.now();
//检查订单时间 是否关闭 //检查订单时间 是否关闭
GoblinStoreOrderVo storeOrderVo = redisUtils.getGoblinOrder(param.getOrderId()); GoblinStoreOrderVo storeOrderVo = redisUtils.getGoblinOrder(param.getOrderId());
if (!storeOrderVo.getUserId().equals(uid)) {
return ResponseDto.failure(ErrorMapping.get("20003"));
}
if (storeOrderVo == null) { if (storeOrderVo == null) {
return ResponseDto.failure("订单不存在"); return ResponseDto.failure("订单不存在");
} }
if (!storeOrderVo.getUserId().equals(uid)) {
return ResponseDto.failure(ErrorMapping.get("20003"));
}
if (storeOrderVo.getStatus() != GoblinStatusConst.Status.ORDER_STATUS_0.getValue()) { if (storeOrderVo.getStatus() != GoblinStatusConst.Status.ORDER_STATUS_0.getValue()) {
return ResponseDto.failure("订单无法支付");//订单 return ResponseDto.failure("订单无法支付");//订单
} }
...@@ -709,12 +684,10 @@ public class GoblinOrderServiceImpl implements IGoblinOrderService { ...@@ -709,12 +684,10 @@ public class GoblinOrderServiceImpl implements IGoblinOrderService {
//支付时间 //支付时间
LocalDateTime now = LocalDateTime.now(); LocalDateTime now = LocalDateTime.now();
String[] array = redisUtils.getMasterCode(syncOrderParam.getOrderCode()); String[] array = redisUtils.getMasterCode(syncOrderParam.getOrderCode());
String uid = "0"; String uid ;
BigDecimal priceActual = BigDecimal.ZERO; BigDecimal priceActual = BigDecimal.ZERO;
for (String orderId : array) { for (String orderId : array) {
GoblinStoreOrderVo orderVo = redisUtils.getGoblinOrder(orderId); GoblinStoreOrderVo orderVo = redisUtils.getGoblinOrder(orderId);
priceActual = priceActual.add(orderVo.getPriceActual());
uid = orderVo.getUserId();
if (orderVo == null) { if (orderVo == null) {
log.error("订单号:" + syncOrderParam.getOrderCode() + " 订单不存在"); log.error("订单号:" + syncOrderParam.getOrderCode() + " 订单不存在");
return "fail";//订单不存在 return "fail";//订单不存在
...@@ -729,6 +702,8 @@ public class GoblinOrderServiceImpl implements IGoblinOrderService { ...@@ -729,6 +702,8 @@ public class GoblinOrderServiceImpl implements IGoblinOrderService {
// log.error("订单号:" + syncOrderParam.getOrderCode() + " 价格不符"); // log.error("订单号:" + syncOrderParam.getOrderCode() + " 价格不符");
// return "fail";//价格不符 // return "fail";//价格不符
// } // }
priceActual = priceActual.add(orderVo.getPriceActual());
uid = orderVo.getUserId();
LinkedList<String> sqls = CollectionUtil.linkedListString(); LinkedList<String> sqls = CollectionUtil.linkedListString();
LinkedList<Object[]> sqlDataOrder = CollectionUtil.linkedListObjectArr(); LinkedList<Object[]> sqlDataOrder = CollectionUtil.linkedListObjectArr();
LinkedList<Object[]> sqlDataSku = CollectionUtil.linkedListObjectArr(); LinkedList<Object[]> sqlDataSku = CollectionUtil.linkedListObjectArr();
......
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