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

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

修改 下单

parent 9054ce5d
......@@ -22,7 +22,11 @@ public class CollectionUtil {
private static final ArrayList<Object> OBJECT_ARRAY_LIST = new ArrayList<>();
private static final ArrayList<BigDecimal> BIG_DECIMALS_ARRAY_LIST = new ArrayList<>();
private static final ArrayList<BigDecimal> BIGDECIMAL_ARRAY_LIST = new ArrayList<>();
private static final String[] STRING_ARRAY = new String[]{};
public static String[] stringArray() {
return STRING_ARRAY.clone();
}
public static HashMap<String, String> mapStringString() {
return (HashMap<String, String>) STRING_STRING_HASH_MAP.clone();
}
......
......@@ -200,7 +200,7 @@ public abstract class AbstractOrderCloseReceiver implements StreamListener<Strin
String listId = (null == goblinListCollectVo) ? null : goblinListCollectVo.getListId();
log.debug("listId : {}", listId);
String mixId = nftOrder.getMixId();
if(mixId!=null && !mixId.equals("")){
if (mixId != null && !mixId.equals("")) {
listId = mixId;
log.debug("mixId : {}", listId);
}
......@@ -241,6 +241,9 @@ public abstract class AbstractOrderCloseReceiver implements StreamListener<Strin
String[] goblin = map.get("goblin");
for (String orderId : goblin) {
if("".equals(orderId)){
break;
}
GoblinStoreOrderVo orderVo = getGoblinOrder(orderId);
if (orderVo.getStatus().equals(GoblinStatusConst.Status.ORDER_STATUS_0.getValue())) {//订单回滚
LinkedList<String> sqls = CollectionUtil.linkedListString();
......@@ -288,6 +291,9 @@ public abstract class AbstractOrderCloseReceiver implements StreamListener<Strin
}
for (String orderId : nft) {
if("".equals(orderId)){
break;
}
checkNftOrderTime(orderId);
}
......@@ -403,8 +409,14 @@ public abstract class AbstractOrderCloseReceiver implements StreamListener<Strin
return null;
} else {
String[] a = ((String) obj).split("&&");
String[] nftA = a[0].split(",");
String[] goblinA = a[1].split(",");
String[] nftA = CollectionUtil.stringArray();
String[] goblinA = CollectionUtil.stringArray();
if (a.length > 0) {
nftA = a[0].split(",");
}
if (a.length > 1) {
goblinA = a[1].split(",");
}
HashMap<String, String[]> map = mixIdMap();
map.put("nft", nftA);
map.put("goblin", goblinA);
......
......@@ -139,6 +139,9 @@ public class GoblinMixAppServiceImpl implements IGoblinMixAppService {
List<GoblinNftOrderDetailsVo> nftOrderListVos = ObjectUtil.goblinNftOrderDetailsVoArrayList();
for (String orderId : nft) {
if("".equals(orderId)){
break;
}
// 订单信息
GoblinNftOrderVo orderVo = redisUtils.getGoblinNftOrder(orderId);
GoblinNftOrderDetailsVo orderDetails = GoblinNftOrderDetailsVo.getNew().copy(orderVo);
......@@ -149,6 +152,9 @@ public class GoblinMixAppServiceImpl implements IGoblinMixAppService {
nftOrderListVos.add(orderDetails);
}
for (String orderId : goblin) {
if("".equals(orderId)){
break;
}
GoblinStoreOrderVo orderVo = redisUtils.getGoblinOrder(orderId);
GoblinAppOrderListVo vos = GoblinAppOrderListVo.getNew();
BeanUtils.copyProperties(orderVo, vos);
......
......@@ -1614,8 +1614,14 @@ public class GoblinRedisUtils {
return null;
} else {
String[] a = ((String) obj).split("&&");
String[] nftA = a[0].split(",");
String[] goblinA = a[1].split(",");
String[] nftA = CollectionUtil.stringArray();
String[] goblinA = CollectionUtil.stringArray();
if (a.length > 0) {
nftA = a[0].split(",");
}
if (a.length > 1) {
goblinA = a[1].split(",");
}
HashMap<String, String[]> map = ObjectUtil.mixIdMap();
map.put("nft", nftA);
map.put("goblin", goblinA);
......
......@@ -77,6 +77,7 @@ public class MixOrderServiceImpl implements IMixOrderService {
boolean isUseLimit = false;//是否减限购
try {
GoblinMixDetailsVo mixVo = redisUtils.getMixDetails(param.getMixId());
String storeName = redisUtils.getStoreInfoVo(mixVo.getStoreId()).getStoreName();
String mobile = StringUtils.defaultString(((String) CurrentUtil.getTokenClaims().get(CurrentUtil.TOKEN_MOBILE)), "");
String nickName = StringUtils.defaultString(((String) CurrentUtil.getTokenClaims().get(CurrentUtil.TOKEN_NICKNAME)), "");
String headerCliSource = CurrentUtil.getHeaderCliSource(), headerCliVersion = CurrentUtil.getHeaderCliVersion();
......@@ -129,7 +130,7 @@ public class MixOrderServiceImpl implements IMixOrderService {
log.debug("stockId = " + boxSkuInfo.getSkuId() + " stock = " + itemVo.getCount());
canBuyIds.add(boxSkuInfo.getSkuId() + "," + itemVo.getCount());
}
boxSkuId.put(skuId, skuInfoVo.getSkuId());
boxSkuId.put(skuId, boxSkuInfo.getSkuId());
stockSkuId.put(skuId, skuInfoVo.getSkuId());
}
} else {//正常
......@@ -175,10 +176,16 @@ public class MixOrderServiceImpl implements IMixOrderService {
// }
//下单
//生成nft订单
List<GoblinNftOrder> nftOrderList = nftOrder(nftInfoList, nftMix, boxSkuId, mobile, source, version, nickName, nt, uid, param.getPayType(), param.getDeviceFrom());
List<GoblinNftOrder> nftOrderList = ObjectUtil.goblinNftOrderList();
if (nftInfoList.size() > 0) {
nftOrderList = nftOrder(nftInfoList, nftMix, boxSkuId, mobile, source, version, nickName, nt, uid, param.getPayType(), param.getDeviceFrom());
}
//生成goblin订单
GoblinOrderPreParam preParam = goblinOrder(skuInfoList, skuMix, param.getAddressesVo(), mobile, source, version, nickName, nt, uid, param.getPayType(), param.getDeviceFrom());
return ResponseDto.success(payOrder(nftOrderList, preParam, orderMasterCode, param.getShowUrl(), param.getReturnUrl(), param.getDeviceFrom(), param.getPayType(), mixId, mixVo.getName()));
GoblinOrderPreParam preParam = null;
if (skuInfoList.size() > 0) {
preParam = goblinOrder(skuInfoList, skuMix, param.getAddressesVo(), mobile, source, version, nickName, nt, uid, param.getPayType(), param.getDeviceFrom());
}
return ResponseDto.success(payOrder(nftOrderList, preParam, orderMasterCode, param.getShowUrl(), param.getReturnUrl(), param.getDeviceFrom(), param.getPayType(), mixId, mixVo.getName(), param.getOpenId(), nt,storeName));
} catch (Exception e) {
e.printStackTrace();
initStock(canBuyIds, mixId, isUseLimit, uid);
......@@ -348,7 +355,7 @@ public class MixOrderServiceImpl implements IMixOrderService {
}
private GoblinPayInnerResultVo payOrder(List<GoblinNftOrder> nftOrder, GoblinOrderPreParam preParam, String masterCode, String showUrl, String returnUrl, String deviceForm, String payType, String mixId, String mixName) {
private GoblinPayInnerResultVo payOrder(List<GoblinNftOrder> nftOrder, GoblinOrderPreParam preParam, String masterCode, String showUrl, String returnUrl, String deviceForm, String payType, String mixId, String mixName, String openId, LocalDateTime now, String storeName) {
GoblinPayInnerResultVo NftPayResultVo = GoblinPayInnerResultVo.getNew();
//是否免费
boolean isFree = false;
......@@ -365,16 +372,19 @@ public class MixOrderServiceImpl implements IMixOrderService {
nftOrderStr = nftOrderStr.concat(item.getOrderId()).concat(",");
}
details = details.concat(preParam.getSkuName()).substring(1);
orderStr = orderStr.concat(preParam.getOrderIdList());
payPrice = payPrice.add(preParam.getPriceActual());
if (preParam != null) {
details = details.concat(preParam.getSkuName()).substring(1);
orderStr = orderStr.concat(preParam.getOrderIdList());
payPrice = payPrice.add(preParam.getPriceActual());
storeName = preParam.getStoreName();
}
if (payPrice.compareTo(BigDecimal.valueOf(0)) > 0) {
// 调用支付
LinkedMultiValueMap<String, String> httpData = CollectionUtil.linkedMultiValueMapStringString();
httpData.add("type", "MIX");
httpData.add("price", payPrice.toString());
httpData.add("name", preParam.getStoreName());
httpData.add("name", storeName);
httpData.add("detail", details);
httpData.add("orderCode", masterCode);
httpData.add("orderId", nftOrderStr.concat(orderStr));
......@@ -386,7 +396,7 @@ public class MixOrderServiceImpl implements IMixOrderService {
httpData.add("deviceFrom", deviceForm);
if (deviceForm.equals("js") || deviceForm.equals("applet")) {
httpData.add("openId", preParam.getOpenId());
httpData.add("openId", openId);
}
httpData.add("showUrl", showUrl + masterCode);
httpData.add("returnUrl", returnUrl + masterCode);
......@@ -421,7 +431,7 @@ public class MixOrderServiceImpl implements IMixOrderService {
NftPayResultVo.setOrderMasterCode(masterCode);
// 待支付发送队列
queueUtils.sendMsgByRedisGoblinStock(masterCode, preParam.getStoreOrder().getCreatedAt(), "MIX", 5);
queueUtils.sendMsgByRedisGoblinStock(masterCode, now, "MIX", 5);
LinkedList<String> sqls = CollectionUtil.linkedListString();
sqls.add(SqlMapping.get("goblin_nft_order.insert"));
......@@ -454,38 +464,40 @@ public class MixOrderServiceImpl implements IMixOrderService {
LinkedList<Object[]> sqlDataGoblin = CollectionUtil.linkedListObjectArr();
LinkedList<Object[]> sqlDataAttr = CollectionUtil.linkedListObjectArr();
List<String> goblinOrderSkuIdList = CollectionUtil.linkedListString();
for (GoblinOrderSku orderSku : preParam.getOrderSkuList()) {
sqlDataSku.add(new Object[]{
orderSku.getOrderSkuId(), orderSku.getOrderId(), orderSku.getSpuId(), orderSku.getSpuName(), orderSku.getSpuPic(), orderSku.getSkuId(), orderSku.getNum(), orderSku.getSkuPrice(), orderSku.getSkuPriceActual(), orderSku.getSkuName(),
orderSku.getSkuNo(), orderSku.getSkuImage(), orderSku.getSkuSpecs(), orderSku.getPriceVoucher(), orderSku.getCreatedAt()
if (preParam != null) {
for (GoblinOrderSku orderSku : preParam.getOrderSkuList()) {
sqlDataSku.add(new Object[]{
orderSku.getOrderSkuId(), orderSku.getOrderId(), orderSku.getSpuId(), orderSku.getSpuName(), orderSku.getSpuPic(), orderSku.getSkuId(), orderSku.getNum(), orderSku.getSkuPrice(), orderSku.getSkuPriceActual(), orderSku.getSkuName(),
orderSku.getSkuNo(), orderSku.getSkuImage(), orderSku.getSkuSpecs(), orderSku.getPriceVoucher(), orderSku.getCreatedAt()
});
//订单 orderSku Vo
GoblinOrderSkuVo orderSkuVo = GoblinOrderSkuVo.getNew().copy(orderSku);
redisUtils.setGoblinOrderSku(orderSkuVo.getOrderSkuId(), orderSkuVo);
goblinOrderSkuIdList.add(orderSkuVo.getOrderSkuId());
}
GoblinStoreOrder storeOrder = preParam.getStoreOrder();
storeOrder.setPayCode(payCode);
sqlDataGoblin.add(new Object[]{
storeOrder.getMasterOrderCode(), storeOrder.getOrderId(), storeOrder.getStoreId(), storeOrder.getStoreName(), storeOrder.getOrderCode(), storeOrder.getUserId(), storeOrder.getUserName(), storeOrder.getUserMobile(), storeOrder.getPriceTotal(), storeOrder.getPayCode(),
storeOrder.getPriceActual(), storeOrder.getPriceRefund(), storeOrder.getPriceExpress(), storeOrder.getPriceCoupon(), storeOrder.getStorePriceCoupon(), storeOrder.getPriceVoucher(), storeOrder.getStatus(), storeOrder.getUcouponId(), storeOrder.getStoreCouponId(), storeOrder.getPayType(), storeOrder.getDeviceFrom(),
storeOrder.getSource(), storeOrder.getVersion(), storeOrder.getIsMember(), storeOrder.getOrderType(), storeOrder.getWriteOffCode(), storeOrder.getPayCountdownMinute(), storeOrder.getIpAddress(), storeOrder.getMarketId(), storeOrder.getMarketType(), storeOrder.getCreatedAt(), ""
});
//订单 orderSku Vo
GoblinOrderSkuVo orderSkuVo = GoblinOrderSkuVo.getNew().copy(orderSku);
redisUtils.setGoblinOrderSku(orderSkuVo.getOrderSkuId(), orderSkuVo);
goblinOrderSkuIdList.add(orderSkuVo.getOrderSkuId());
GoblinOrderAttr orderAttr = preParam.getOrderAttr();
sqlDataAttr.add(new Object[]{
orderAttr.getOrderAttrId(), orderAttr.getOrderId(), orderAttr.getExpressContacts(), orderAttr.getExpressAddress(), orderAttr.getExpressAddressDetail(), orderAttr.getExpressPhone(), orderAttr.getExpressType(), orderAttr.getCreatedAt()
});
//订单vo
GoblinStoreOrderVo orderVo = GoblinStoreOrderVo.getNew().copyMix(storeOrder, mixId, mixName);
//订单attr vo
GoblinOrderAttrVo orderAttrVo = GoblinOrderAttrVo.getNew().copy(orderAttr);
//redis 赋值
orderVo.setOrderAttrVo(orderAttrVo);
orderVo.setOrderSkuVoIds(goblinOrderSkuIdList);
orderVo.setCreatedAt(getNowTime());
redisUtils.setGoblinOrder(orderVo.getOrderId(), orderVo);
redisUtils.setMasterCode(orderVo.getMasterOrderCode(), orderStr);
queueUtils.setMongoList(GoblinStoreOrderVo.class.getSimpleName(), "orderId", orderVo.getOrderId(), GoblinRedisConst.REDIS_GOBLIN_ORDER, 1);
}
GoblinStoreOrder storeOrder = preParam.getStoreOrder();
storeOrder.setPayCode(payCode);
sqlDataGoblin.add(new Object[]{
storeOrder.getMasterOrderCode(), storeOrder.getOrderId(), storeOrder.getStoreId(), storeOrder.getStoreName(), storeOrder.getOrderCode(), storeOrder.getUserId(), storeOrder.getUserName(), storeOrder.getUserMobile(), storeOrder.getPriceTotal(), storeOrder.getPayCode(),
storeOrder.getPriceActual(), storeOrder.getPriceRefund(), storeOrder.getPriceExpress(), storeOrder.getPriceCoupon(), storeOrder.getStorePriceCoupon(), storeOrder.getPriceVoucher(), storeOrder.getStatus(), storeOrder.getUcouponId(), storeOrder.getStoreCouponId(), storeOrder.getPayType(), storeOrder.getDeviceFrom(),
storeOrder.getSource(), storeOrder.getVersion(), storeOrder.getIsMember(), storeOrder.getOrderType(), storeOrder.getWriteOffCode(), storeOrder.getPayCountdownMinute(), storeOrder.getIpAddress(), storeOrder.getMarketId(), storeOrder.getMarketType(), storeOrder.getCreatedAt(), ""
});
GoblinOrderAttr orderAttr = preParam.getOrderAttr();
sqlDataAttr.add(new Object[]{
orderAttr.getOrderAttrId(), orderAttr.getOrderId(), orderAttr.getExpressContacts(), orderAttr.getExpressAddress(), orderAttr.getExpressAddressDetail(), orderAttr.getExpressPhone(), orderAttr.getExpressType(), orderAttr.getCreatedAt()
});
//订单vo
GoblinStoreOrderVo orderVo = GoblinStoreOrderVo.getNew().copyMix(storeOrder, mixId, mixName);
//订单attr vo
GoblinOrderAttrVo orderAttrVo = GoblinOrderAttrVo.getNew().copy(orderAttr);
//redis 赋值
orderVo.setOrderAttrVo(orderAttrVo);
orderVo.setOrderSkuVoIds(goblinOrderSkuIdList);
orderVo.setCreatedAt(getNowTime());
redisUtils.setGoblinOrder(orderVo.getOrderId(), orderVo);
redisUtils.setMasterCode(orderVo.getMasterOrderCode(), orderStr);
queueUtils.setMongoList(GoblinStoreOrderVo.class.getSimpleName(), "orderId", orderVo.getOrderId(), GoblinRedisConst.REDIS_GOBLIN_ORDER, 1);
orderMixStr = orderMixStr.concat("&&").concat(orderStr);
redisUtils.setMasterCode(masterCode, orderMixStr);
......@@ -537,12 +549,18 @@ public class MixOrderServiceImpl implements IMixOrderService {
boolean isSuccess = true;
for (String orderId : nft) {
if("".equals(orderId)){
break;
}
String nftR = syncNft(orderId, code, status, paymentType, paymentId, paymentAt);
if ("fail".equals(nftR)) {
isSuccess = false;
}
}
for (String orderId : goblin) {
if("".equals(orderId)){
break;
}
String goblinR = syncGoblin(orderId, code, status, paymentType, paymentId, paymentAt);
if ("fail".equals(goblinR)) {
isSuccess = false;
......@@ -747,6 +765,9 @@ public class MixOrderServiceImpl implements IMixOrderService {
String[] goblin = map.get("goblin");
for (String orderId : nft) {
if("".equals(orderId)){
break;
}
String nftR = nftCheck(uid, orderId);
if ("订单不存在".equals(nftR)) {
return ResponseDto.failure("订单不存在");
......@@ -755,6 +776,9 @@ public class MixOrderServiceImpl implements IMixOrderService {
}
}
for (String orderId : goblin) {
if("".equals(orderId)){
break;
}
String goblinR = goblinCheck(uid, orderId);
if ("订单不存在".equals(goblinR)) {
return ResponseDto.failure("订单不存在");
......
......@@ -554,6 +554,7 @@ public class GoblinNftOrderUtils {
// String endListId = newListIds.get(index);
// 判断库存
int surplusGeneral = goblinRedisUtils.decrSkuStock(listId, goodsSkuInfoVo.getSkuId(), number);
log.error("剩余 skuId = "+surplusGeneral);
if (surplusGeneral < 0) {
goblinRedisUtils.incrSkuStock(listId, goodsSkuInfoVo.getSkuId(), number);
return lotteryDraw(skuIdList, number, nowTime, listId);
......
......@@ -468,8 +468,14 @@ public class GoblinRedisUtils {
return null;
} else {
String[] a = ((String) obj).split("&&");
String[] nftA = a[0].split(",");
String[] goblinA = a[1].split(",");
String[] nftA = CollectionUtil.stringArray();
String[] goblinA = CollectionUtil.stringArray();
if (a.length > 0) {
nftA = a[0].split(",");
}
if (a.length > 1) {
goblinA = a[1].split(",");
}
HashMap<String, String[]> map = ObjectUtil.mixIdMap();
map.put("nft", nftA);
map.put("goblin", goblinA);
......
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