|
|
@@ -154,16 +154,17 @@ public class CmsGroupRelationController {
|
|
|
relation.setOperator(cmsUser.getNickname());
|
|
|
//邀请制家庭组链接
|
|
|
relation.setInviteLink(rechargeView.getInviteLink());
|
|
|
+ OrderDon orderDon = null;
|
|
|
if (rechargeStatus == GroupsRelation.RechargeStatus.complete) {
|
|
|
relation.setSendTime(DateTime.now());
|
|
|
- OrderDon orderDon = orderDonMapper.selectOne(Wrappers.lambdaQuery(OrderDon.class)
|
|
|
+ orderDon = orderDonMapper.selectOne(Wrappers.lambdaQuery(OrderDon.class)
|
|
|
.eq(OrderDon::getUserId, relation.getUserId())
|
|
|
.eq(OrderDon::getRelationId, relationId)
|
|
|
.notIn(OrderDon::getStatus, Constant.noOrderStatus)
|
|
|
.orderByDesc(OrderDon::getId)
|
|
|
.last("limit 1"));
|
|
|
if (orderDon == null) throw BusinessRuntimeException.getInstance("该代充订单不存在");
|
|
|
- if (orderDon.getStatus() == OrderDon.Status.refund){
|
|
|
+ if (orderDon.getStatus() == OrderDon.Status.refund) {
|
|
|
throw BusinessRuntimeException.getInstance("该代充订单已退款");
|
|
|
}
|
|
|
orderDon.setStatus(OrderDon.Status.complete);
|
|
|
@@ -179,25 +180,24 @@ public class CmsGroupRelationController {
|
|
|
expiryTime = DateUtil.offsetMonth(relation.getStartTime(), sku.getMonths());
|
|
|
}
|
|
|
relation.setExpiryTime(expiryTime);
|
|
|
-
|
|
|
- //GPT代充
|
|
|
- if (orderDon.getGoodsId() == Constant.GPT_RECHARGE_GOODS_ID) {
|
|
|
- //扣除次数
|
|
|
- Integer rechargeRemainNum = relation.getRechargeRemainNum();
|
|
|
- if (rechargeRemainNum != null && rechargeRemainNum > 0) {
|
|
|
- int update = groupsRelationMapper.update(null, Wrappers.lambdaUpdate(GroupsRelation.class)
|
|
|
- .set(GroupsRelation::getRechargeRemainNum, rechargeRemainNum - 1)
|
|
|
- .eq(GroupsRelation::getId, relationId)
|
|
|
- .eq(GroupsRelation::getRechargeRemainNum, rechargeRemainNum));
|
|
|
- if (update == 0) {
|
|
|
- throw BusinessRuntimeException.getInstance("更新用户代充剩余次数失败,请重试");
|
|
|
- }
|
|
|
- //记录gpt代充记录
|
|
|
- gptUserRechargeRecordService.recordGptUserRechargeNum(relation.getUserId(), relation.getId(), relation.getAccount(), 1, cmsUser != null ? cmsUser.getNickname() : null);
|
|
|
+ }
|
|
|
+ groupsRelationMapper.updateById(relation);
|
|
|
+ //GPT代充
|
|
|
+ if (orderDon != null && orderDon.getGoodsId() == Constant.GPT_RECHARGE_GOODS_ID) {
|
|
|
+ //扣除次数
|
|
|
+ Integer rechargeRemainNum = relation.getRechargeRemainNum();
|
|
|
+ if (rechargeRemainNum != null && rechargeRemainNum > 0) {
|
|
|
+ int update = groupsRelationMapper.update(null, Wrappers.lambdaUpdate(GroupsRelation.class)
|
|
|
+ .set(GroupsRelation::getRechargeRemainNum, rechargeRemainNum - 1)
|
|
|
+ .eq(GroupsRelation::getId, relationId)
|
|
|
+ .eq(GroupsRelation::getRechargeRemainNum, rechargeRemainNum));
|
|
|
+ if (update == 0) {
|
|
|
+ throw BusinessRuntimeException.getInstance("更新用户代充剩余次数失败,请重试");
|
|
|
}
|
|
|
+ //记录gpt代充记录
|
|
|
+ gptUserRechargeRecordService.recordGptUserRechargeNum(relation.getUserId(), relation.getId(), relation.getAccount(), 1, cmsUser != null ? cmsUser.getNickname() : null);
|
|
|
}
|
|
|
}
|
|
|
- groupsRelationMapper.updateById(relation);
|
|
|
return GatewayResponse.SUCCESS.newBuilder().toResult("状态修改成功");
|
|
|
}
|
|
|
|