|
|
@@ -223,22 +223,26 @@ public class OrderDonServiceImpl extends ServiceImpl<OrderDonMapper, OrderDon> i
|
|
|
}
|
|
|
|
|
|
} else {
|
|
|
- //TODO 如果没指定座位,等待逻辑确认
|
|
|
- GroupsTrips groups = groupsMapper.selectOne(Wrappers.lambdaQuery(GroupsTrips.class).eq(GroupsTrips::getSkuId, payRequest.getSkuId()).gt(GroupsTrips::getAvailableNum, 0).last("limit 1").orderByAsc(GroupsTrips::getAvailableNum));
|
|
|
- if (groups == null) {
|
|
|
- relation = createNewGroupsTrips(sku, true);
|
|
|
- isNew = true;
|
|
|
- } else {
|
|
|
- //寻找快满编车队进行占座
|
|
|
- relation = groupsRelationMapper.selectOne(Wrappers.lambdaQuery(GroupsRelation.class)
|
|
|
- .eq(GroupsRelation::getGroupsId, groups.getId())
|
|
|
- .eq(GroupsRelation::getStatus, "none")
|
|
|
- .eq(GroupsRelation::getUserId, 0)
|
|
|
- .orderByAsc(GroupsRelation::getNum)
|
|
|
- .last("limit 1")
|
|
|
- );
|
|
|
- if (relation == null) {
|
|
|
- throw new BusinessRuntimeException(GROUP_INDEX_NOT_FIND.getCode(), GROUP_INDEX_NOT_FIND.getMsg());
|
|
|
+ //寻找差不多过期时间规格的车位
|
|
|
+ relation = getSimilarExpiredGroupRelation(sku.getId(), sku.getMonths());
|
|
|
+ if (relation == null) {
|
|
|
+ //TODO 如果没指定座位,等待逻辑确认
|
|
|
+ GroupsTrips groups = groupsMapper.selectOne(Wrappers.lambdaQuery(GroupsTrips.class).eq(GroupsTrips::getSkuId, payRequest.getSkuId()).gt(GroupsTrips::getAvailableNum, 0).last("limit 1").orderByAsc(GroupsTrips::getAvailableNum));
|
|
|
+ if (groups == null) {
|
|
|
+ relation = createNewGroupsTrips(sku, true);
|
|
|
+ isNew = true;
|
|
|
+ } else {
|
|
|
+ //寻找快满编车队进行占座
|
|
|
+ relation = groupsRelationMapper.selectOne(Wrappers.lambdaQuery(GroupsRelation.class)
|
|
|
+ .eq(GroupsRelation::getGroupsId, groups.getId())
|
|
|
+ .eq(GroupsRelation::getStatus, "none")
|
|
|
+ .eq(GroupsRelation::getUserId, 0)
|
|
|
+ .orderByAsc(GroupsRelation::getNum)
|
|
|
+ .last("limit 1")
|
|
|
+ );
|
|
|
+ if (relation == null) {
|
|
|
+ throw new BusinessRuntimeException(GROUP_INDEX_NOT_FIND.getCode(), GROUP_INDEX_NOT_FIND.getMsg());
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
@@ -350,6 +354,22 @@ public class OrderDonServiceImpl extends ServiceImpl<OrderDonMapper, OrderDon> i
|
|
|
return orderDon;
|
|
|
}
|
|
|
|
|
|
+ private GroupsRelation getSimilarExpiredGroupRelation(Long skuId, Integer months) {
|
|
|
+ DateTime expiryTime = DateUtil.offsetMonth(DateTime.now(), months);
|
|
|
+ DateTime minExpiryTime = DateUtil.offsetDay(expiryTime, -5);
|
|
|
+ Long groupsId = groupsRelationMapper.selectSimilarExpiredRelation(skuId, minExpiryTime);
|
|
|
+ if (groupsId == null) {
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+ GroupsRelation relation = groupsRelationMapper.selectOne(Wrappers.lambdaQuery(GroupsRelation.class)
|
|
|
+ .eq(GroupsRelation::getGroupsId, groupsId)
|
|
|
+ .eq(GroupsRelation::getStatus, GroupsRelation.Status.none)
|
|
|
+ .eq(GroupsRelation::getUserId, 0)
|
|
|
+ .orderByAsc(GroupsRelation::getNum)
|
|
|
+ .last("limit 1"));
|
|
|
+ return relation;
|
|
|
+ }
|
|
|
+
|
|
|
@Override
|
|
|
public H5JsPayParams pay(Long orderId, String tradeType) throws Exception {
|
|
|
log.info("调起微信支付[start] orderId:{}", orderId);
|