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

Commit f4c9eefb authored by 胡佳晨's avatar 胡佳晨

多订单退款

parent f3e4a1b4
......@@ -103,19 +103,17 @@ public class GoblinOrderServiceImpl implements IGoblinOrderService {
String orderId = IDGenerator.nextSnowId();
String orderCode = IDGenerator.storeCode(orderId);
for (GoblinOrderSkuParam skuParam : storeParam.getGoblinOrderSkuParamArrayList()) {//商品维度循环
Long time3 = System.currentTimeMillis();
String skuId = skuParam.getSkuId();
int number = skuParam.getNumber();
Long time3 = System.currentTimeMillis();
GoblinGoodsSkuInfoVo skuVo = redisUtils.getGoodsSkuInfoVo(skuId);
if (!(skuVo.getStatus().equals("3") && skuVo.getShelvesStatus().equals("3")) || skuVo.getDelFlg().equals("1")) {
throw new Exception("不可购买");
}
log.info("获取skuVo "+(time3-System.currentTimeMillis())+"ms");
// 判断库存
String pre = GoblinStatusConst.MarketPreStatus.getPre(skuId);
int limitCount = skuVo.getBuyLimit() == 0 ? Integer.MAX_VALUE : skuVo.getBuyLimit();
//判断限购
time3 = System.currentTimeMillis();
if (noZhengzaiOrder(uid)) {
String res1 = orderUtils.judgeOrderLimit(uid, skuId, number, limitCount);
if (!res1.equals("")) {
......@@ -127,11 +125,9 @@ public class GoblinOrderServiceImpl implements IGoblinOrderService {
throw new Exception("无权购买");
}
}
log.info("判断限购 "+(time3-System.currentTimeMillis())+"ms");
time3 = System.currentTimeMillis();
int surplusGeneral = redisUtils.decrSkuStock(pre, skuId, number);
log.info("获取剩余库存 "+(time3-System.currentTimeMillis())+"ms");
skuAndPreListAndNumber.add(skuId + "," + pre + "," + number);
log.info("判断逻辑 "+(System.currentTimeMillis()-time3)+"ms");
//库存回滚
if (surplusGeneral < 0) {
throw new Exception("库存不足");
......@@ -155,7 +151,8 @@ public class GoblinOrderServiceImpl implements IGoblinOrderService {
}
return payOrder(preParam, orderSqlParams, uid);
} catch (Exception e) {
log.error("Kylin Order Pay Error = {}", e);
// log.error("Kylin Order Pay Error = {}", e);
Long time3 = System.currentTimeMillis();
//回顾限购 回滚库存
for (String item : skuAndPreListAndNumber) {
String[] array = item.split(",");
......@@ -183,7 +180,7 @@ 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("无权购买")) {
......
......@@ -427,7 +427,13 @@ public class GoblinOrderUtils {
params.add("paymentId", orderVo.getPaymentId());
params.add("paymentType", orderVo.getPaymentType());
params.add("price", String.valueOf(price));
params.add("priceTotal", String.valueOf(orderVo.getPriceActual()));
BigDecimal totalPrice = BigDecimal.ZERO;
String[] orderIds = redisUtils.getMasterCode( orderVo.getOrderId());
for (String orderId:orderIds){
GoblinStoreOrderVo vo = redisUtils.getGoblinOrder(orderId);
totalPrice = totalPrice.add(vo.getPriceActual());
}
params.add("priceTotal", String.valueOf(totalPrice));
params.add("reason", "超时支付");
MultiValueMap<String, String> headers = CollectionUtil.linkedMultiValueMapStringString();
headers.add("Accept", "application/json;charset=UTF-8");
......
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