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

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

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

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