|
|
@@ -141,32 +141,25 @@ public class LiveOrderOptServiceImpl implements ILiveOrderOptService {
|
|
|
|
|
|
@Override
|
|
|
@Transactional(rollbackFor = Throwable.class)
|
|
|
- public R createStoreOrder(LiveOrder param) {
|
|
|
- return doCreateStoreOrder(param, false);
|
|
|
- }
|
|
|
-
|
|
|
- @Override
|
|
|
- @Transactional(rollbackFor = Throwable.class)
|
|
|
- public R createStoreOrderTest(LiveOrder param) {
|
|
|
- return doCreateStoreOrder(param, true);
|
|
|
- }
|
|
|
-
|
|
|
- private R doCreateStoreOrder(LiveOrder liveOrder, boolean testMode) {
|
|
|
- long start = System.currentTimeMillis();
|
|
|
+ public R createStoreOrder(LiveOrder liveOrder) {
|
|
|
+ OptStepTimer timer = new OptStepTimer("create", liveOrder.getOrderKey());
|
|
|
try {
|
|
|
- if (!testMode) {
|
|
|
- String orderKey = redisCache.getCacheObject("orderKey:" + liveOrder.getOrderKey());
|
|
|
- if (StringUtils.isEmpty(orderKey)) {
|
|
|
- return R.error("订单已过期");
|
|
|
- }
|
|
|
- String creatingKey = LiveOrderOptConstants.LOCK_ORDER_KEY_CREATING + liveOrder.getOrderKey();
|
|
|
- if (!redisCache.setIfAbsent(creatingKey, "1", 30, TimeUnit.SECONDS)) {
|
|
|
- return R.error("订单正在创建中,请勿重复提交");
|
|
|
- }
|
|
|
+ String orderKey = redisCache.getCacheObject("orderKey:" + liveOrder.getOrderKey());
|
|
|
+ if (StringUtils.isEmpty(orderKey)) {
|
|
|
+ timer.finish("fail:orderKeyExpired");
|
|
|
+ return R.error("订单已过期");
|
|
|
+ }
|
|
|
+ String creatingKey = LiveOrderOptConstants.LOCK_ORDER_KEY_CREATING + liveOrder.getOrderKey();
|
|
|
+ if (!redisCache.setIfAbsent(creatingKey, "1", 30, TimeUnit.SECONDS)) {
|
|
|
+ timer.finish("fail:orderCreating");
|
|
|
+ return R.error("订单正在创建中,请勿重复提交");
|
|
|
}
|
|
|
+ timer.step("orderKeyCheck");
|
|
|
|
|
|
R validateResult = validateCreateParam(liveOrder);
|
|
|
+ timer.step("validateParam");
|
|
|
if (validateResult != null) {
|
|
|
+ timer.finish("fail:validate");
|
|
|
return validateResult;
|
|
|
}
|
|
|
|
|
|
@@ -174,29 +167,37 @@ public class LiveOrderOptServiceImpl implements ILiveOrderOptService {
|
|
|
Integer purchaseNum = Integer.parseInt(liveOrder.getTotalNum());
|
|
|
|
|
|
LiveGoods goods = getLiveGoodsCached(liveOrder.getLiveId(), liveOrder.getProductId());
|
|
|
+ timer.step("loadLiveGoods");
|
|
|
if (goods == null) {
|
|
|
+ timer.finish("fail:goodsNotFound");
|
|
|
return R.error("当前商品不存在");
|
|
|
}
|
|
|
|
|
|
- if (!testMode) {
|
|
|
- R stockResult = deductStockIfNeeded(liveOrder, goods);
|
|
|
- if (stockResult != null) {
|
|
|
- return stockResult;
|
|
|
- }
|
|
|
+ R stockResult = deductStockIfNeeded(liveOrder, goods);
|
|
|
+ timer.step("deductStock");
|
|
|
+ if (stockResult != null) {
|
|
|
+ timer.finish("fail:stock");
|
|
|
+ return stockResult;
|
|
|
}
|
|
|
|
|
|
if (liveService.selectLiveByLiveId(liveOrder.getLiveId()) == null) {
|
|
|
+ timer.finish("fail:liveNotFound");
|
|
|
return R.error("当前直播不存在");
|
|
|
}
|
|
|
+ timer.step("loadLive");
|
|
|
|
|
|
FsStoreProductScrm fsStoreProduct = fsStoreProductService.selectFsStoreRedisProductById(liveOrder.getProductId());
|
|
|
+ timer.step("loadProduct");
|
|
|
if (fsStoreProduct == null) {
|
|
|
+ timer.finish("fail:productNotFound");
|
|
|
return R.error("商品不存在,购买失败");
|
|
|
}
|
|
|
if (fsStoreProduct.getIsShow() == 0 || goods.getStatus() == 0) {
|
|
|
+ timer.finish("fail:productOffShelf");
|
|
|
return R.error("商品已下架,购买失败");
|
|
|
}
|
|
|
if (!"1".equals(fsStoreProduct.getIsAudit())) {
|
|
|
+ timer.finish("fail:productNotAudit");
|
|
|
return R.error("商品已下架,购买失败");
|
|
|
}
|
|
|
|
|
|
@@ -204,18 +205,23 @@ public class LiveOrderOptServiceImpl implements ILiveOrderOptService {
|
|
|
if (liveOrder.getAttrValueId() != null) {
|
|
|
attrValue = getProductAttrValueCached(liveOrder.getAttrValueId());
|
|
|
}
|
|
|
+ timer.step("loadAttrValue");
|
|
|
|
|
|
checkPurchaseLimit(userId, fsStoreProduct, purchaseNum);
|
|
|
+ timer.step("checkPurchaseLimit");
|
|
|
|
|
|
- if (!testMode) {
|
|
|
- publishStockUpdate(goods.getGoodsId(), purchaseNum);
|
|
|
- }
|
|
|
+ publishStockUpdate(goods.getGoodsId(), purchaseNum);
|
|
|
+ timer.step("publishStockUpdate");
|
|
|
|
|
|
- FsStoreOrderScrm storeOrder = buildStoreOrder(liveOrder, fsStoreProduct, attrValue, goods, testMode);
|
|
|
+ FsStoreOrderScrm storeOrder = buildStoreOrder(liveOrder, fsStoreProduct, attrValue, goods);
|
|
|
+ timer.step("buildStoreOrder");
|
|
|
LiveCouponUser couponToUse = resolveCoupon(liveOrder, userId, storeOrder);
|
|
|
+ timer.step("resolveCoupon");
|
|
|
|
|
|
Integer flag = fsStoreOrderScrmMapper.insertFsStoreOrder(storeOrder);
|
|
|
+ timer.step("insertOrder");
|
|
|
if (flag == null || flag == 0) {
|
|
|
+ timer.finish("fail:insertOrder");
|
|
|
return R.error("订单创建失败");
|
|
|
}
|
|
|
|
|
|
@@ -225,23 +231,27 @@ public class LiveOrderOptServiceImpl implements ILiveOrderOptService {
|
|
|
liveCouponUserService.updateLiveCouponUser(couponToUse);
|
|
|
redisCache.deleteObject(LiveOrderOptConstants.CACHE_LIVE_COUPON_USER + couponToUse.getId());
|
|
|
}
|
|
|
+ timer.step("updateCoupon");
|
|
|
|
|
|
insertOrderItem(storeOrder, fsStoreProduct, attrValue, liveOrder.getTotalNum());
|
|
|
+ timer.step("insertOrderItem");
|
|
|
orderStatusService.create(storeOrder.getId(), OrderLogEnum.CREATE_ORDER.getValue(),
|
|
|
OrderLogEnum.CREATE_ORDER.getDesc());
|
|
|
+ timer.step("orderStatusLog");
|
|
|
|
|
|
StoreConfig config = getStoreConfigCached();
|
|
|
+ timer.step("loadStoreConfig");
|
|
|
String redisKey = StoreConstants.REDIS_ORDER_OUTTIME_UNPAY + storeOrder.getId();
|
|
|
if (config != null && config.getUnPayTime() != null && config.getUnPayTime() > 0) {
|
|
|
redisCache.setCacheObject(redisKey, storeOrder.getId(), config.getUnPayTime(), TimeUnit.MINUTES);
|
|
|
} else {
|
|
|
redisCache.setCacheObject(redisKey, storeOrder.getId(), 30, TimeUnit.MINUTES);
|
|
|
}
|
|
|
+ timer.step("redisUnpayKey");
|
|
|
|
|
|
- if (!testMode) {
|
|
|
- redisCache.deleteObject("orderKey:" + liveOrder.getOrderKey());
|
|
|
- redisCache.deleteObject(LiveOrderOptConstants.LOCK_ORDER_KEY_CREATING + liveOrder.getOrderKey());
|
|
|
- }
|
|
|
+ redisCache.deleteObject("orderKey:" + liveOrder.getOrderKey());
|
|
|
+ redisCache.deleteObject(LiveOrderOptConstants.LOCK_ORDER_KEY_CREATING + liveOrder.getOrderKey());
|
|
|
+ timer.step("cleanupOrderKey");
|
|
|
|
|
|
Calendar calendar = Calendar.getInstance();
|
|
|
calendar.setTime(storeOrder.getCreateTime());
|
|
|
@@ -250,83 +260,81 @@ public class LiveOrderOptServiceImpl implements ILiveOrderOptService {
|
|
|
}
|
|
|
String payLimitTime = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(calendar.getTime());
|
|
|
|
|
|
- log.info("[createOpt] testMode={} orderId={} cost={}ms", testMode, storeOrder.getId(),
|
|
|
- System.currentTimeMillis() - start);
|
|
|
+ timer.finish("ok orderId=" + storeOrder.getId());
|
|
|
return R.ok("下单成功").put("order", storeOrder).put("payLimitTime", payLimitTime);
|
|
|
} catch (CustomException e) {
|
|
|
+ timer.finish("fail:" + e.getMessage());
|
|
|
throw e;
|
|
|
} catch (Exception e) {
|
|
|
- log.error("[createOpt] 订单创建失败 testMode={}", testMode, e);
|
|
|
+ timer.finish("fail:" + e.getMessage());
|
|
|
+ log.error("[createOpt] 订单创建失败", e);
|
|
|
return R.error("订单创建失败:" + e.getMessage());
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
public R handleStoreOrderPay(LiveOrderPayParam param) {
|
|
|
- return doPay(param, false);
|
|
|
- }
|
|
|
-
|
|
|
- @Override
|
|
|
- public R handleStoreOrderPayTest(LiveOrderPayParam param) {
|
|
|
- return doPay(param, true);
|
|
|
- }
|
|
|
-
|
|
|
- private R doPay(LiveOrderPayParam param, boolean testMode) {
|
|
|
- long start = System.currentTimeMillis();
|
|
|
Long orderId = param.getOrderId();
|
|
|
+ OptStepTimer timer = new OptStepTimer("pay", orderId);
|
|
|
RLock lock = redissonClient.getLock(String.format(LOCK_KEY_PAY, orderId));
|
|
|
try {
|
|
|
boolean locked = lock.tryLock(500, 30000, TimeUnit.MILLISECONDS);
|
|
|
+ timer.step("tryLock");
|
|
|
if (!locked) {
|
|
|
+ timer.finish("fail:lockBusy");
|
|
|
return R.error("订单正在处理中,请勿重复提交");
|
|
|
}
|
|
|
|
|
|
FsStoreOrderScrm order = fsStoreOrderScrmService.selectFsStoreOrderById(orderId);
|
|
|
+ timer.step("loadOrder");
|
|
|
if (order == null) {
|
|
|
+ timer.finish("fail:orderNotFound");
|
|
|
return R.error("订单不存在");
|
|
|
}
|
|
|
if (order.getStatus() != null && order.getStatus() != OrderInfoEnum.STATUS_0.getValue()) {
|
|
|
+ timer.finish("fail:orderPaid");
|
|
|
return R.error("当前订单已支付");
|
|
|
}
|
|
|
- if (testMode && !isTestOrder(order)) {
|
|
|
- return R.error("测试支付仅支持测试订单(order_create_type=99)");
|
|
|
- }
|
|
|
|
|
|
String payingFlag = redisCache.getCacheObject("isPaying:" + orderId);
|
|
|
+ timer.step("checkPayingFlag");
|
|
|
if (StringUtils.isNotEmpty(payingFlag) && payingFlag.equals(order.getId().toString())) {
|
|
|
+ timer.finish("fail:paying");
|
|
|
return R.error("正在支付中...");
|
|
|
}
|
|
|
|
|
|
R preCheck = checkExistingPayments(orderId);
|
|
|
+ timer.step("checkExistingPayments");
|
|
|
if (preCheck != null) {
|
|
|
+ timer.finish("fail:existingPayment");
|
|
|
return preCheck;
|
|
|
}
|
|
|
|
|
|
FsUserScrm user = getUserCached(order.getUserId());
|
|
|
+ timer.step("loadUser");
|
|
|
if (user == null) {
|
|
|
+ timer.finish("fail:userNotFound");
|
|
|
return R.error("用户OPENID不存在");
|
|
|
}
|
|
|
|
|
|
applyPayTypeAmount(order, param);
|
|
|
fsStoreOrderScrmService.updateFsStoreOrder(order);
|
|
|
+ timer.step("applyPayTypeAndUpdateOrder");
|
|
|
|
|
|
- if (testMode) {
|
|
|
- R testResult = createTestPayment(order, user, param);
|
|
|
- log.info("[payTest] orderId={} cost={}ms", orderId, System.currentTimeMillis() - start);
|
|
|
- return testResult;
|
|
|
- }
|
|
|
-
|
|
|
- R payResult = invokeThirdPartyPay(order, user, param);
|
|
|
- log.info("[payOpt] orderId={} cost={}ms", orderId, System.currentTimeMillis() - start);
|
|
|
+ R payResult = invokeThirdPartyPay(order, user, param, timer);
|
|
|
+ timer.finish("pay");
|
|
|
return payResult;
|
|
|
} catch (InterruptedException e) {
|
|
|
Thread.currentThread().interrupt();
|
|
|
+ timer.finish("fail:interrupted");
|
|
|
return R.error("支付处理被中断,请稍后重试");
|
|
|
} catch (CustomException e) {
|
|
|
redisCache.deleteObject("isPaying:" + orderId);
|
|
|
+ timer.finish("fail:" + e.getMessage());
|
|
|
throw e;
|
|
|
} catch (Exception e) {
|
|
|
redisCache.deleteObject("isPaying:" + orderId);
|
|
|
+ timer.finish("fail:" + e.getMessage());
|
|
|
log.error("[payOpt] 支付异常 orderId={}", orderId, e);
|
|
|
return R.error("支付失败:" + e.getMessage());
|
|
|
} finally {
|
|
|
@@ -385,7 +393,7 @@ public class LiveOrderOptServiceImpl implements ILiveOrderOptService {
|
|
|
}
|
|
|
|
|
|
private FsStoreOrderScrm buildStoreOrder(LiveOrder liveOrder, FsStoreProductScrm fsStoreProduct,
|
|
|
- FsStoreProductAttrValueScrm attrValue, LiveGoods goods, boolean testMode) {
|
|
|
+ FsStoreProductAttrValueScrm attrValue, LiveGoods goods) {
|
|
|
FsStoreOrderScrm storeOrder = new FsStoreOrderScrm();
|
|
|
storeOrder.setUserId(Long.parseLong(liveOrder.getUserId()));
|
|
|
storeOrder.setRealName(liveOrder.getUserName());
|
|
|
@@ -396,10 +404,7 @@ public class LiveOrderOptServiceImpl implements ILiveOrderOptService {
|
|
|
storeOrder.setMark(liveOrder.getRemark());
|
|
|
storeOrder.setRemark(String.valueOf(liveOrder.getLiveId()));
|
|
|
|
|
|
- if (testMode) {
|
|
|
- storeOrder.setOrderCreateType(LiveOrderOptConstants.ORDER_CREATE_TYPE_LIVE_TEST);
|
|
|
- storeOrder.setMark(LiveOrderOptConstants.TEST_ORDER_MARK);
|
|
|
- } else if (liveOrder.getOrderCreateType() != null) {
|
|
|
+ if (liveOrder.getOrderCreateType() != null) {
|
|
|
storeOrder.setOrderCreateType(liveOrder.getOrderCreateType());
|
|
|
}
|
|
|
|
|
|
@@ -575,21 +580,8 @@ public class LiveOrderOptServiceImpl implements ILiveOrderOptService {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- private R createTestPayment(FsStoreOrderScrm order, FsUserScrm user, LiveOrderPayParam param) {
|
|
|
- String payCode = SnowflakeUtil.nextIdStr();
|
|
|
- FsStorePaymentScrm storePayment = buildBasePayment(order, user, param, payCode);
|
|
|
- storePayment.setRemark(LiveOrderOptConstants.TEST_PAYMENT_REMARK);
|
|
|
- storePayment.setTradeNo("TEST-" + payCode);
|
|
|
- fsStorePaymentScrmMapper.insertFsStorePayment(storePayment);
|
|
|
- redisCache.setCacheObject("isPaying:" + order.getId(), order.getId().toString(), 1, TimeUnit.MINUTES);
|
|
|
- Map<String, Object> mockPay = new HashMap<>();
|
|
|
- mockPay.put("testMode", true);
|
|
|
- mockPay.put("paymentId", storePayment.getPaymentId());
|
|
|
- mockPay.put("payCode", payCode);
|
|
|
- return R.ok().put("payType", param.getPayType()).put("result", mockPay).put("isTest", true);
|
|
|
- }
|
|
|
-
|
|
|
- private R invokeThirdPartyPay(FsStoreOrderScrm order, FsUserScrm user, LiveOrderPayParam param) {
|
|
|
+ private R invokeThirdPartyPay(FsStoreOrderScrm order, FsUserScrm user, LiveOrderPayParam param,
|
|
|
+ OptStepTimer timer) {
|
|
|
if (StringUtils.isBlank(param.getAppId())) {
|
|
|
return R.error("appId不能为空");
|
|
|
}
|
|
|
@@ -597,6 +589,7 @@ public class LiveOrderOptServiceImpl implements ILiveOrderOptService {
|
|
|
if ("3".equals(order.getPayType())) {
|
|
|
IFsStoreOrderScrmService proxy = (IFsStoreOrderScrmService) AopContext.currentProxy();
|
|
|
proxy.payConfirm(2, order.getId(), null, null, null, null);
|
|
|
+ timer.step("payConfirmOffline");
|
|
|
return R.ok().put("payType", param.getPayType());
|
|
|
}
|
|
|
return R.error("支付金额异常");
|
|
|
@@ -604,8 +597,11 @@ public class LiveOrderOptServiceImpl implements ILiveOrderOptService {
|
|
|
if (order.getPayMoney().compareTo(BigDecimal.ZERO) <= 0) {
|
|
|
return R.error("支付金额异常");
|
|
|
}
|
|
|
+ timer.step("payAmountValidate");
|
|
|
|
|
|
MiniAppPayBundle bundle = getMiniAppPayBundleCached(param.getAppId());
|
|
|
+ timer.step("loadMiniAppPayBundle");
|
|
|
+
|
|
|
String payCode = SnowflakeUtil.nextIdStr();
|
|
|
FsStorePaymentScrm storePayment = buildBasePayment(order, user, param, payCode);
|
|
|
storePayment.setRemark("直播订单支付");
|
|
|
@@ -613,19 +609,20 @@ public class LiveOrderOptServiceImpl implements ILiveOrderOptService {
|
|
|
storePayment.setMerConfigId(bundle.getMerchantAppConfig().getId());
|
|
|
storePayment.setAppId(bundle.getPlayConfig().getAppid() == null ? "" : bundle.getPlayConfig().getAppid());
|
|
|
fsStorePaymentScrmMapper.insertFsStorePayment(storePayment);
|
|
|
+ timer.step("insertPayment");
|
|
|
|
|
|
MerchantAppConfig merchantAppConfig = bundle.getMerchantAppConfig();
|
|
|
if ("hf".equals(merchantAppConfig.getMerchantType())) {
|
|
|
- return invokeHuiFuPay(order, user, param, storePayment, bundle.getPayConfig());
|
|
|
+ return invokeHuiFuPay(order, user, param, storePayment, bundle.getPayConfig(), timer);
|
|
|
}
|
|
|
if ("wx".equals(merchantAppConfig.getMerchantType())) {
|
|
|
- return invokeWxPay(order, user, param, storePayment, bundle);
|
|
|
+ return invokeWxPay(order, user, param, storePayment, bundle, timer);
|
|
|
}
|
|
|
return R.error("不支持的支付方式");
|
|
|
}
|
|
|
|
|
|
private R invokeHuiFuPay(FsStoreOrderScrm order, FsUserScrm user, LiveOrderPayParam param,
|
|
|
- FsStorePaymentScrm storePayment, FsPayConfig fsPayConfig) {
|
|
|
+ FsStorePaymentScrm storePayment, FsPayConfig fsPayConfig, OptStepTimer timer) {
|
|
|
HuiFuCreateOrder o = new HuiFuCreateOrder();
|
|
|
o.setTradeType("T_MINIAPP");
|
|
|
o.setOpenid(user.getMaOpenId());
|
|
|
@@ -639,7 +636,9 @@ public class LiveOrderOptServiceImpl implements ILiveOrderOptService {
|
|
|
} catch (Exception e) {
|
|
|
log.error("分账出错 orderId={}", order.getId(), e);
|
|
|
}
|
|
|
+ timer.step("huiFuPrepareDiv");
|
|
|
HuifuCreateOrderResult result = huiFuService.createOrder(o);
|
|
|
+ timer.step("huiFuRemoteCreateOrder");
|
|
|
if (result.getResp_code() != null
|
|
|
&& ("00000000".equals(result.getResp_code()) || "00000100".equals(result.getResp_code()))) {
|
|
|
FsStorePaymentScrm mt = new FsStorePaymentScrm();
|
|
|
@@ -659,7 +658,7 @@ public class LiveOrderOptServiceImpl implements ILiveOrderOptService {
|
|
|
}
|
|
|
|
|
|
private R invokeWxPay(FsStoreOrderScrm order, FsUserScrm user, LiveOrderPayParam param,
|
|
|
- FsStorePaymentScrm storePayment, MiniAppPayBundle bundle) {
|
|
|
+ FsStorePaymentScrm storePayment, MiniAppPayBundle bundle, OptStepTimer timer) {
|
|
|
FsPayConfig fsPayConfig = bundle.getPayConfig();
|
|
|
WxPayConfig payConfig = new WxPayConfig();
|
|
|
payConfig.setAppId(bundle.getPlayConfig().getAppid());
|
|
|
@@ -668,6 +667,7 @@ public class LiveOrderOptServiceImpl implements ILiveOrderOptService {
|
|
|
payConfig.setKeyPath(fsPayConfig.getKeyPath());
|
|
|
payConfig.setNotifyUrl(fsPayConfig.getNotifyUrlScrm());
|
|
|
wxPayService.setConfig(payConfig);
|
|
|
+ timer.step("wxPrepareConfig");
|
|
|
WxPayUnifiedOrderRequest orderRequest = new WxPayUnifiedOrderRequest();
|
|
|
orderRequest.setOpenid(user.getMaOpenId());
|
|
|
orderRequest.setBody("直播订单支付");
|
|
|
@@ -677,6 +677,7 @@ public class LiveOrderOptServiceImpl implements ILiveOrderOptService {
|
|
|
orderRequest.setSpbillCreateIp(IpUtils.getIpAddr(ServletUtils.getRequest()));
|
|
|
try {
|
|
|
WxPayMpOrderResult orderResult = wxPayService.createOrder(orderRequest);
|
|
|
+ timer.step("wxRemoteCreateOrder");
|
|
|
redisCache.setCacheObject("isPaying:" + order.getId(), order.getId().toString(), 1, TimeUnit.MINUTES);
|
|
|
return R.ok().put("result", orderResult).put("type", "wx").put("isPay", 0).put("payType", param.getPayType());
|
|
|
} catch (WxPayException e) {
|
|
|
@@ -708,11 +709,6 @@ public class LiveOrderOptServiceImpl implements ILiveOrderOptService {
|
|
|
return "1".equals(payType) || "2".equals(payType) || "3".equals(payType) || "5".equals(payType);
|
|
|
}
|
|
|
|
|
|
- private boolean isTestOrder(FsStoreOrderScrm order) {
|
|
|
- return order.getOrderCreateType() != null
|
|
|
- && order.getOrderCreateType() == LiveOrderOptConstants.ORDER_CREATE_TYPE_LIVE_TEST;
|
|
|
- }
|
|
|
-
|
|
|
private String resolveStoreHouseCode(Long productId) {
|
|
|
if (productId != null && (productId.equals(3168L) || productId.equals(3184L) || productId.equals(3185L))) {
|
|
|
return "YDSP001";
|
|
|
@@ -999,4 +995,30 @@ public class LiveOrderOptServiceImpl implements ILiveOrderOptService {
|
|
|
private MerchantAppConfig merchantAppConfig;
|
|
|
private FsPayConfig payConfig;
|
|
|
}
|
|
|
+
|
|
|
+ /** 分步耗时统计 */
|
|
|
+ private static final class OptStepTimer {
|
|
|
+ private final long startMs = System.currentTimeMillis();
|
|
|
+ private long lastMs = startMs;
|
|
|
+ private final String biz;
|
|
|
+ private final Object bizId;
|
|
|
+
|
|
|
+ OptStepTimer(String biz, Object bizId) {
|
|
|
+ this.biz = biz;
|
|
|
+ this.bizId = bizId;
|
|
|
+ }
|
|
|
+
|
|
|
+ void step(String step) {
|
|
|
+ long now = System.currentTimeMillis();
|
|
|
+ log.info("[liveOrderOpt][{}] bizId={} step={} stepMs={} totalMs={}",
|
|
|
+ biz, bizId, step, now - lastMs, now - startMs);
|
|
|
+ lastMs = now;
|
|
|
+ }
|
|
|
+
|
|
|
+ void finish(String result) {
|
|
|
+ long now = System.currentTimeMillis();
|
|
|
+ log.info("[liveOrderOpt][{}] bizId={} step=FINISH result={} totalMs={}",
|
|
|
+ biz, bizId, result, now - startMs);
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|