|
|
@@ -79,7 +79,7 @@ public class WxOrderGroupServiceImpl implements WxOrderGroupService { |
|
|
if (!grouppeopleLock) { |
|
|
if (!grouppeopleLock) { |
|
|
throw new MallinkException(ErrorCode.ORDER_GROUP_COOPERATING_FAILD.getCode(),"参团锁定失败,请稍后再试。"); |
|
|
throw new MallinkException(ErrorCode.ORDER_GROUP_COOPERATING_FAILD.getCode(),"参团锁定失败,请稍后再试。"); |
|
|
} |
|
|
} |
|
|
//此处拼团数量应从订单总数查询,支付成功的就算一个,没支付成功的不算 |
|
|
|
|
|
|
|
|
//此处拼团数量应从订单总数查询,支付成功的就算一个,没支付成功的不算. 提高拼团的成功率 |
|
|
int ordercount = wxOrderService.countGroupOrder(order.getOrderGroupId(),true); |
|
|
int ordercount = wxOrderService.countGroupOrder(order.getOrderGroupId(),true); |
|
|
Integer remainPeople = wxCoupon.getPressLimitNum()-ordercount-1; |
|
|
Integer remainPeople = wxCoupon.getPressLimitNum()-ordercount-1; |
|
|
//Integer remainPeople = wxOrderGroup.getRemainPeople()-1; |
|
|
//Integer remainPeople = wxOrderGroup.getRemainPeople()-1; |
|
|
@@ -142,6 +142,8 @@ public class WxOrderGroupServiceImpl implements WxOrderGroupService { |
|
|
logger.error("更新订单信息失败", e); |
|
|
logger.error("更新订单信息失败", e); |
|
|
throw new MallinkException(ErrorCode.ORDER_GROUP_COOPERATING_FAILD); |
|
|
throw new MallinkException(ErrorCode.ORDER_GROUP_COOPERATING_FAILD); |
|
|
} |
|
|
} |
|
|
|
|
|
//此时会出现临界情况,remainPeople是已支付的数量 |
|
|
|
|
|
//此时如果最后的位置,同时多个人点了,去支付,最先支付的会把后面的取消掉。 |
|
|
if (remainPeople == 0) { |
|
|
if (remainPeople == 0) { |
|
|
actionAfterOrderGroupSuccess(order, orderGroupId); |
|
|
actionAfterOrderGroupSuccess(order, orderGroupId); |
|
|
} |
|
|
} |
|
|
@@ -191,6 +193,13 @@ public class WxOrderGroupServiceImpl implements WxOrderGroupService { |
|
|
* @param orderGroupId |
|
|
* @param orderGroupId |
|
|
*/ |
|
|
*/ |
|
|
private void actionAfterOrderGroupSuccess(WxOrder order, Long orderGroupId) { |
|
|
private void actionAfterOrderGroupSuccess(WxOrder order, Long orderGroupId) { |
|
|
|
|
|
//拼团完成,只能执行一次。 |
|
|
|
|
|
boolean isFirstSet = redisLock.setOrderGroupComplateLock(orderGroupId); |
|
|
|
|
|
//如果没有设置成功,则不是第一次处理,后续的忽略,防止并发 |
|
|
|
|
|
if (!isFirstSet) { |
|
|
|
|
|
return; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
// 拼团完成 |
|
|
// 拼团完成 |
|
|
// 得到所有拼团的order |
|
|
// 得到所有拼团的order |
|
|
WxOrder wxOrder = new WxOrder(); |
|
|
WxOrder wxOrder = new WxOrder(); |
|
|
@@ -224,7 +233,10 @@ public class WxOrderGroupServiceImpl implements WxOrderGroupService { |
|
|
//去库存 |
|
|
//去库存 |
|
|
wxOrderService.updateOrderStatus(temp); |
|
|
wxOrderService.updateOrderStatus(temp); |
|
|
//拼团取消 |
|
|
//拼团取消 |
|
|
temp.setOrderStatus(EnumOrderStatus.ORDER_STATUS_COOPERATING_BREAK.getCode()); |
|
|
|
|
|
|
|
|
//temp.setOrderStatus(EnumOrderStatus.ORDER_STATUS_COOPERATING_BREAK.getCode()); |
|
|
|
|
|
|
|
|
|
|
|
//拼团失败。定时会处理退款 |
|
|
|
|
|
temp.setOrderStatus(EnumOrderStatus.ORDER_STATUS_COOPERATING_FAILD.getCode()); |
|
|
wxOrderMapper.updateById(temp); |
|
|
wxOrderMapper.updateById(temp); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|