|
@@ -477,9 +477,6 @@ public class GptRechargeServiceImpl implements GptRechargeService {
|
|
|
if (CollUtil.isEmpty(req.getOrderNos())) {
|
|
if (CollUtil.isEmpty(req.getOrderNos())) {
|
|
|
throw BusinessRuntimeException.getInstance("订单号不能为空");
|
|
throw BusinessRuntimeException.getInstance("订单号不能为空");
|
|
|
}
|
|
}
|
|
|
- if (req.getNum() == null || req.getNum() == 0) {
|
|
|
|
|
- throw BusinessRuntimeException.getInstance("变更次数不能为空");
|
|
|
|
|
- }
|
|
|
|
|
CmsUser cmsUser = cmsUserMapper.selectById(adminId);
|
|
CmsUser cmsUser = cmsUserMapper.selectById(adminId);
|
|
|
String operator = cmsUser != null ? cmsUser.getNickname() : null;
|
|
String operator = cmsUser != null ? cmsUser.getNickname() : null;
|
|
|
return req.getOrderNos().stream()
|
|
return req.getOrderNos().stream()
|
|
@@ -499,11 +496,16 @@ public class GptRechargeServiceImpl implements GptRechargeService {
|
|
|
GroupsRelation relation = relationMapper.selectById(orderDon.getRelationId());
|
|
GroupsRelation relation = relationMapper.selectById(orderDon.getRelationId());
|
|
|
Assert.notNull(relation, "代充车票不存在");
|
|
Assert.notNull(relation, "代充车票不存在");
|
|
|
resp.setRelationId(relation.getId());
|
|
resp.setRelationId(relation.getId());
|
|
|
- if (relation.getRechargeNum() == null || relation.getRechargeRemainNum() == null) {
|
|
|
|
|
- throw BusinessRuntimeException.getInstance("代充次数不存在");
|
|
|
|
|
|
|
+ if (relation.getRechargeStatus() == null) {
|
|
|
|
|
+ throw BusinessRuntimeException.getInstance("非代充类型车票");
|
|
|
}
|
|
}
|
|
|
GoodsDonSku sku = skuMapper.selectById(orderDon.getSkuId());
|
|
GoodsDonSku sku = skuMapper.selectById(orderDon.getSkuId());
|
|
|
Assert.notNull(sku, "车票规格不存在");
|
|
Assert.notNull(sku, "车票规格不存在");
|
|
|
|
|
+ if (relation.getRechargeNum() == null || relation.getRechargeRemainNum() == null) {
|
|
|
|
|
+ batchSyncRechargeOrder(orderDon, relation, sku, req, operator, resp);
|
|
|
|
|
+ resp.setSuccess(Boolean.TRUE);
|
|
|
|
|
+ return null;
|
|
|
|
|
+ }
|
|
|
boolean needShip = relation.getStartTime() == null
|
|
boolean needShip = relation.getStartTime() == null
|
|
|
&& (relation.getRechargeStatus() == GroupsRelation.RechargeStatus.waiting
|
|
&& (relation.getRechargeStatus() == GroupsRelation.RechargeStatus.waiting
|
|
|
|| relation.getRechargeStatus() == GroupsRelation.RechargeStatus.recharge_error);
|
|
|| relation.getRechargeStatus() == GroupsRelation.RechargeStatus.recharge_error);
|
|
@@ -544,6 +546,33 @@ public class GptRechargeServiceImpl implements GptRechargeService {
|
|
|
return orderDon;
|
|
return orderDon;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ private void batchSyncRechargeOrder(OrderDon orderDon, GroupsRelation relation, GoodsDonSku sku, BatchRechargeRemainNumReq req, String operator, BatchRechargeRemainNumResp resp) {
|
|
|
|
|
+ resp.setHandleType("sync");
|
|
|
|
|
+ DateTime now = DateTime.now();
|
|
|
|
|
+ orderDon.setStatus(OrderDon.Status.complete);
|
|
|
|
|
+ orderDonMapper.updateById(orderDon);
|
|
|
|
|
+
|
|
|
|
|
+ relation.setRechargeStatus(GroupsRelation.RechargeStatus.complete);
|
|
|
|
|
+ relation.setOperator(operator);
|
|
|
|
|
+ relation.setSubmitTime(relation.getSubmitTime() != null ? relation.getSubmitTime() : now);
|
|
|
|
|
+ relation.setSendTime(now);
|
|
|
|
|
+ if (relation.getStartTime() == null) {
|
|
|
|
|
+ relation.setStartTime(now);
|
|
|
|
|
+ DateTime expiryTime;
|
|
|
|
|
+ if (sku.getDays() != null && sku.getDays() > 0) {
|
|
|
|
|
+ expiryTime = DateUtil.offsetDay(relation.getStartTime(), sku.getDays());
|
|
|
|
|
+ } else {
|
|
|
|
|
+ expiryTime = DateUtil.offsetMonth(relation.getStartTime(), sku.getMonths());
|
|
|
|
|
+ }
|
|
|
|
|
+ relation.setExpiryTime(expiryTime);
|
|
|
|
|
+ }
|
|
|
|
|
+ if (StrUtil.isNotBlank(req.getCardKey())) {
|
|
|
|
|
+ relation.setCardKey(req.getCardKey());
|
|
|
|
|
+ }
|
|
|
|
|
+ relationMapper.updateById(relation);
|
|
|
|
|
+ resp.setMessage("同步成功");
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
private void batchShipRechargeOrder(OrderDon orderDon, GroupsRelation relation, GoodsDonSku sku, BatchRechargeRemainNumReq req, String operator, BatchRechargeRemainNumResp resp) {
|
|
private void batchShipRechargeOrder(OrderDon orderDon, GroupsRelation relation, GoodsDonSku sku, BatchRechargeRemainNumReq req, String operator, BatchRechargeRemainNumResp resp) {
|
|
|
Integer subRechargeNum = getRechargeSubNum(sku);
|
|
Integer subRechargeNum = getRechargeSubNum(sku);
|
|
|
Integer rechargeRemainNum = relation.getRechargeRemainNum();
|
|
Integer rechargeRemainNum = relation.getRechargeRemainNum();
|
|
@@ -588,6 +617,9 @@ public class GptRechargeServiceImpl implements GptRechargeService {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
private void batchUpdateRechargeNum(GroupsRelation relation, BatchRechargeRemainNumReq req, String operator, BatchRechargeRemainNumResp resp) {
|
|
private void batchUpdateRechargeNum(GroupsRelation relation, BatchRechargeRemainNumReq req, String operator, BatchRechargeRemainNumResp resp) {
|
|
|
|
|
+ if (req.getNum() == null || req.getNum() == 0) {
|
|
|
|
|
+ throw BusinessRuntimeException.getInstance("变更次数不能为空");
|
|
|
|
|
+ }
|
|
|
Integer rechargeRemainNum = relation.getRechargeRemainNum();
|
|
Integer rechargeRemainNum = relation.getRechargeRemainNum();
|
|
|
Integer afterRemainNum = rechargeRemainNum + req.getNum();
|
|
Integer afterRemainNum = rechargeRemainNum + req.getNum();
|
|
|
if (afterRemainNum < 0) {
|
|
if (afterRemainNum < 0) {
|