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

Commit 95404e1d authored by 胡佳晨's avatar 胡佳晨

修改逻辑

parent 74b1ebe8
...@@ -88,7 +88,7 @@ public class GoblinOrderServiceImpl implements IGoblinOrderService { ...@@ -88,7 +88,7 @@ public class GoblinOrderServiceImpl implements IGoblinOrderService {
List<GoblinOrderStoreParam> goblinOrderStoreParamList = param.getGoblinOrderStoreParamList();//分订单 List<GoblinOrderStoreParam> goblinOrderStoreParamList = param.getGoblinOrderStoreParamList();//分订单
boolean isMember; boolean isMember;
AddressVo addressesVo = null; AddressVo addressesVo = null;
if (noZhengzaiOrder(uid)) { if (orderUtils.noZhengzaiOrder(uid)) {
addressesVo = param.getAddressesVo(); addressesVo = param.getAddressesVo();
long time3 = System.currentTimeMillis(); long time3 = System.currentTimeMillis();
if (orderUtils.getMember(uid) != null) { if (orderUtils.getMember(uid) != null) {
...@@ -96,7 +96,7 @@ public class GoblinOrderServiceImpl implements IGoblinOrderService { ...@@ -96,7 +96,7 @@ public class GoblinOrderServiceImpl implements IGoblinOrderService {
} else { } else {
isMember = false; isMember = false;
} }
log.error("获取会员信息:"+(System.currentTimeMillis()-time3)+"ms"); log.error("获取会员信息:" + (System.currentTimeMillis() - time3) + "ms");
} else { } else {
isMember = false; isMember = false;
} }
...@@ -104,19 +104,15 @@ public class GoblinOrderServiceImpl implements IGoblinOrderService { ...@@ -104,19 +104,15 @@ public class GoblinOrderServiceImpl implements IGoblinOrderService {
String orderId = IDGenerator.nextSnowId(); String orderId = IDGenerator.nextSnowId();
String orderCode = IDGenerator.storeCode(orderId); String orderCode = IDGenerator.storeCode(orderId);
for (GoblinOrderSkuParam skuParam : storeParam.getGoblinOrderSkuParamArrayList()) {//商品维度循环 for (GoblinOrderSkuParam skuParam : storeParam.getGoblinOrderSkuParamArrayList()) {//商品维度循环
Long time3 = System.currentTimeMillis();
String skuId = skuParam.getSkuId(); String skuId = skuParam.getSkuId();
int number = skuParam.getNumber(); int number = skuParam.getNumber();
String pre = GoblinStatusConst.MarketPreStatus.getPre(skuId); String pre = GoblinStatusConst.MarketPreStatus.getPre(skuId);
// GoblinGoodsSkuInfoVo skuVo = redisUtils.getGoodsSkuInfoVo(skuId);
log.error("获取skuVo" + (System.currentTimeMillis() - time3) + "ms");
int surplusGeneral = redisUtils.decrSkuStock(pre, skuId, number); int surplusGeneral = redisUtils.decrSkuStock(pre, skuId, number);
skuAndPreListAndNumber.add(skuId + "," + pre + "," + number); skuAndPreListAndNumber.add(skuId + "," + pre + "," + number);
log.error("判断逻辑 " + (System.currentTimeMillis() - time3) + "ms");
//库存回滚 //库存回滚
if (surplusGeneral < 0) { if (surplusGeneral < 0) {
redisUtils.incrSkuStock(pre, skuId, number); return orderUtils.orderException(skuAndPreListAndNumber, platformCodeList, storeCodeList, uid, "库存不足");
throw new Exception("库存不足"); // throw new Exception("库存不足");
} }
}//GoblinOrderSkuParam }//GoblinOrderSkuParam
//下单 //下单
...@@ -133,7 +129,8 @@ public class GoblinOrderServiceImpl implements IGoblinOrderService { ...@@ -133,7 +129,8 @@ public class GoblinOrderServiceImpl implements IGoblinOrderService {
orderSqlParams.add(sqlParam); orderSqlParams.add(sqlParam);
}//GoblinOrderStoreParam }//GoblinOrderStoreParam
if (preParam.getOrderIdList().equals("")) { if (preParam.getOrderIdList().equals("")) {
throw new Exception("参数异常"); return orderUtils.orderException(skuAndPreListAndNumber, platformCodeList, storeCodeList, uid, "参数异常");
// throw new Exception("参数异常");
} }
return payOrder(preParam, orderSqlParams, uid); return payOrder(preParam, orderSqlParams, uid);
} catch (Exception e) { } catch (Exception e) {
...@@ -146,7 +143,7 @@ public class GoblinOrderServiceImpl implements IGoblinOrderService { ...@@ -146,7 +143,7 @@ public class GoblinOrderServiceImpl implements IGoblinOrderService {
String pre = array[1]; String pre = array[1];
int number = Integer.parseInt(array[2]); int number = Integer.parseInt(array[2]);
redisUtils.incrSkuStock(pre, skuId, number); redisUtils.incrSkuStock(pre, skuId, number);
if (noZhengzaiOrder(uid)) { if (orderUtils.noZhengzaiOrder(uid)) {
redisUtils.decrSkuCountByUid(uid, skuId, number); redisUtils.decrSkuCountByUid(uid, skuId, number);
} }
} }
...@@ -217,13 +214,16 @@ public class GoblinOrderServiceImpl implements IGoblinOrderService { ...@@ -217,13 +214,16 @@ public class GoblinOrderServiceImpl implements IGoblinOrderService {
Long time3 = System.currentTimeMillis(); 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())) {
throw new Exception("非法参数");
}
if (!(skuVo.getStatus().equals("3") && skuVo.getShelvesStatus().equals("3")) || skuVo.getDelFlg().equals("1")) { if (!(skuVo.getStatus().equals("3") && skuVo.getShelvesStatus().equals("3")) || skuVo.getDelFlg().equals("1")) {
throw new Exception("不可购买"); throw new Exception("不可购买");
} }
// 判断库存 // 判断库存
int limitCount = skuVo.getBuyLimit() == 0 ? Integer.MAX_VALUE : skuVo.getBuyLimit(); int limitCount = skuVo.getBuyLimit() == 0 ? Integer.MAX_VALUE : skuVo.getBuyLimit();
//判断限购 //判断限购
if (noZhengzaiOrder(uid)) { if (orderUtils.noZhengzaiOrder(uid)) {
String res1 = orderUtils.judgeOrderLimit(uid, skuParam.getSkuId(), skuParam.getNumber(), limitCount); String res1 = orderUtils.judgeOrderLimit(uid, skuParam.getSkuId(), skuParam.getNumber(), limitCount);
if (!res1.equals("")) { if (!res1.equals("")) {
throw new Exception("已超出限购数量"); throw new Exception("已超出限购数量");
...@@ -234,10 +234,7 @@ public class GoblinOrderServiceImpl implements IGoblinOrderService { ...@@ -234,10 +234,7 @@ public class GoblinOrderServiceImpl implements IGoblinOrderService {
throw new Exception("无权购买"); throw new Exception("无权购买");
} }
} }
log.error("获取会员sku&spu:"+(System.currentTimeMillis()-time3)+"ms"); log.error("获取会员sku&spu:" + (System.currentTimeMillis() - time3) + "ms");
if (!spuVo.getStoreId().equals(storeParam.getStoreId()) || !skuVo.getStoreId().equals(storeParam.getStoreId())) {
throw new Exception("非法参数");
}
marketId = spuVo.getMarketId(); marketId = spuVo.getMarketId();
marketType = pre; marketType = pre;
skuName = skuName.concat(skuVo.getName()).concat(","); skuName = skuName.concat(skuVo.getName()).concat(",");
...@@ -349,7 +346,7 @@ public class GoblinOrderServiceImpl implements IGoblinOrderService { ...@@ -349,7 +346,7 @@ public class GoblinOrderServiceImpl implements IGoblinOrderService {
} }
long time3 = System.currentTimeMillis(); long time3 = System.currentTimeMillis();
GoblinStoreInfoVo storeInfoVo = redisUtils.getStoreInfoVo(storeId); GoblinStoreInfoVo storeInfoVo = redisUtils.getStoreInfoVo(storeId);
log.error("获取店铺信息:"+(System.currentTimeMillis()-time3)+"ms"); log.error("获取店铺信息:" + (System.currentTimeMillis() - time3) + "ms");
//生成订单 //生成订单
GoblinStoreOrder storeOrder = GoblinStoreOrder.getNew(); GoblinStoreOrder storeOrder = GoblinStoreOrder.getNew();
storeOrder.setMasterOrderCode(orderMasterCode); storeOrder.setMasterOrderCode(orderMasterCode);
...@@ -567,7 +564,7 @@ public class GoblinOrderServiceImpl implements IGoblinOrderService { ...@@ -567,7 +564,7 @@ public class GoblinOrderServiceImpl implements IGoblinOrderService {
log.error("保存数据:" + (System.currentTimeMillis() - time2) + "ms"); log.error("保存数据:" + (System.currentTimeMillis() - time2) + "ms");
time2 = System.currentTimeMillis(); time2 = System.currentTimeMillis();
//redis 订单列表 //redis 订单列表
if (noZhengzaiOrder(uid)) { if (orderUtils.noZhengzaiOrder(uid)) {
if (orderVo.getMarketType() == null) { if (orderVo.getMarketType() == null) {
redisUtils.addOrderList(uid, orderVo.getOrderId()); redisUtils.addOrderList(uid, orderVo.getOrderId());
} else if (orderVo.getMarketType().equals(GoblinStatusConst.MarketPreStatus.MARKET_PRE_ZHENGZAI.getValue())) { } else if (orderVo.getMarketType().equals(GoblinStatusConst.MarketPreStatus.MARKET_PRE_ZHENGZAI.getValue())) {
...@@ -835,7 +832,7 @@ public class GoblinOrderServiceImpl implements IGoblinOrderService { ...@@ -835,7 +832,7 @@ public class GoblinOrderServiceImpl implements IGoblinOrderService {
// ); // );
// } // }
//加分 //加分
if (noZhengzaiOrder(uid)) { if (orderUtils.noZhengzaiOrder(uid)) {
orderUtils.doTask(uid, priceActual); orderUtils.doTask(uid, priceActual);
} }
} }
...@@ -1000,8 +997,4 @@ public class GoblinOrderServiceImpl implements IGoblinOrderService { ...@@ -1000,8 +997,4 @@ public class GoblinOrderServiceImpl implements IGoblinOrderService {
} }
return "success"; return "success";
} }
private boolean noZhengzaiOrder(String uid) {
return !uid.equals("zhengzai");
}
} }
...@@ -4,6 +4,7 @@ import com.alibaba.fastjson.JSON; ...@@ -4,6 +4,7 @@ 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.adam.dto.vo.AdamRscPolymer01Vo;
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;
import com.liquidnet.service.base.constant.MQConst; import com.liquidnet.service.base.constant.MQConst;
...@@ -51,29 +52,6 @@ public class GoblinOrderUtils { ...@@ -51,29 +52,6 @@ public class GoblinOrderUtils {
@Autowired @Autowired
GoblinMongoUtils goblinMongoUtils; GoblinMongoUtils goblinMongoUtils;
public AdamRscPolymer01Vo adamAddressEnterMember(String uid, String enterIds, String addressId) {
try {
MultiValueMap<String, String> header = CollectionUtil.linkedMultiValueMapStringString();
header.add("Accept", "application/json;charset=UTF-8");
MultiValueMap<String, String> params = CollectionUtil.linkedMultiValueMapStringString();
params.add("addressId", addressId);
params.add("entersIds", enterIds);
params.add("uid", uid);
String resultData = HttpUtil.post(adamUrl + "/adam/rsc/inquire/of_buy_ticket", params, header);
ResponseDto<AdamRscPolymer01Vo> vo = JsonUtils.fromJson(resultData, new TypeReference<ResponseDto<AdamRscPolymer01Vo>>() {
});
if (null != vo.getData()) {
return vo.getData();
} else {
return null;
}
} catch (Exception e) {
log.error("获取用户信息,e:{}", e);
e.printStackTrace();
return null;
}
}
//判断 数量限购 //判断 数量限购
public String judgeOrderLimit(String uid, String skuId, int number, int limitCount) { public String judgeOrderLimit(String uid, String skuId, int number, int limitCount) {
int buyCount = redisUtils.getSkuCountByUid(uid, skuId); int buyCount = redisUtils.getSkuCountByUid(uid, skuId);
...@@ -401,9 +379,9 @@ public class GoblinOrderUtils { ...@@ -401,9 +379,9 @@ public class GoblinOrderUtils {
backOrderLog.getMessage(), backOrderLog.getOperationName(), backOrderLog.getStatus(), now backOrderLog.getMessage(), backOrderLog.getOperationName(), backOrderLog.getStatus(), now
) )
); );
if(success){ if (success) {
return true; return true;
}else{ } else {
log.error("退款失败:" + message); log.error("退款失败:" + message);
return false; return false;
} }
...@@ -428,8 +406,8 @@ public class GoblinOrderUtils { ...@@ -428,8 +406,8 @@ public class GoblinOrderUtils {
params.add("paymentType", orderVo.getPaymentType()); params.add("paymentType", orderVo.getPaymentType());
params.add("price", String.valueOf(price)); params.add("price", String.valueOf(price));
BigDecimal totalPrice = BigDecimal.ZERO; BigDecimal totalPrice = BigDecimal.ZERO;
String[] orderIds = redisUtils.getMasterCode( orderVo.getOrderId()); String[] orderIds = redisUtils.getMasterCode(orderVo.getOrderId());
for (String orderId:orderIds){ for (String orderId : orderIds) {
GoblinStoreOrderVo vo = redisUtils.getGoblinOrder(orderId); GoblinStoreOrderVo vo = redisUtils.getGoblinOrder(orderId);
totalPrice = totalPrice.add(vo.getPriceActual()); totalPrice = totalPrice.add(vo.getPriceActual());
} }
...@@ -441,4 +419,45 @@ public class GoblinOrderUtils { ...@@ -441,4 +419,45 @@ public class GoblinOrderUtils {
log.debug("REFUND DATA = " + returnString); log.debug("REFUND DATA = " + returnString);
return returnString; return returnString;
} }
//订单异常处理
public ResponseDto<GoblinPayInnerResultVo> orderException(List<String> skuAndPreListAndNumber, List<String> platformCodeList, List<String> storeCodeList, String uid, String message) {
long time3 = System.currentTimeMillis();
//回顾限购 回滚库存
for (String item : skuAndPreListAndNumber) {
String[] array = item.split(",");
String skuId = array[0];
String pre = array[1];
int number = Integer.parseInt(array[2]);
redisUtils.incrSkuStock(pre, skuId, number);
if (noZhengzaiOrder(uid)) {
redisUtils.decrSkuCountByUid(uid, skuId, number);
}
}
//回退平台券
for (String platformCode : platformCodeList) {
backCoupon(platformCode, uid);
}
//回退店铺券
List<com.liquidnet.service.goblin.param.BackCouponParam> params = ObjectUtil.getBackCouponParam();
for (String storeCode : storeCodeList) {
com.liquidnet.service.goblin.param.BackCouponParam backCouponParam = com.liquidnet.service.goblin.param.BackCouponParam.getNew();
backCouponParam.setuCouponIds(storeCode);
backCouponParam.setUid(uid);
params.add(backCouponParam);
}
if (params.size() > 0) {
backStoreCoupon(params);
}
log.info("回滚逻辑 " + (System.currentTimeMillis() - time3) + "ms");
if (message == null && !message.equals("")) {
return ResponseDto.failure(ErrorMapping.get("20018"));//乱七八糟异常
} else {
return ResponseDto.failure(message);//乱七八糟异常
}
}
public boolean noZhengzaiOrder(String uid) {
return !uid.equals("zhengzai");
}
} }
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