|
|
@@ -47,6 +47,7 @@ import org.springframework.validation.annotation.Validated;
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
|
|
|
import javax.servlet.http.HttpServletRequest;
|
|
|
+import java.util.Date;
|
|
|
import java.util.List;
|
|
|
import java.util.Optional;
|
|
|
import java.util.stream.Collectors;
|
|
|
@@ -268,6 +269,33 @@ public class CmsGroupRelationController {
|
|
|
return GatewayResponse.SUCCESS.newBuilder().toResult();
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 更新剩余次数 针对之前的代充账号
|
|
|
+ */
|
|
|
+ @PostMapping("/recharge/set/remainNumBf")
|
|
|
+ public Result<String> setRechargeRemainNumBf(@RequestBody RechargeRemainNumReq req) {
|
|
|
+ long adminId = StpUtil.getLoginIdAsLong();
|
|
|
+ Long relationId = req.getRelationId();
|
|
|
+ GroupsRelation relation = groupsRelationMapper.selectById(relationId);
|
|
|
+ if (relation.getRechargeRemainNum() == null) {
|
|
|
+ Integer num = req.getNum();
|
|
|
+ if (num <= 0) {
|
|
|
+ throw BusinessRuntimeException.getInstance("剩余次数需大于0");
|
|
|
+ }
|
|
|
+ relation.setRechargeNum(num);
|
|
|
+ relation.setRechargeRemainNum(num);
|
|
|
+ Date startTime = relation.getStartTime();
|
|
|
+ DateTime now = DateTime.now();
|
|
|
+ relation.setSubmitTime(startTime != null ? startTime : now);
|
|
|
+ relation.setSendTime(relation.getSubmitTime());
|
|
|
+ groupsRelationMapper.updateById(relation);
|
|
|
+ //记录gpt代充记录
|
|
|
+ CmsUser cmsUser = cmsUserMapper.selectById(adminId);
|
|
|
+ gptUserRechargeRecordService.recordGptUserRechargeNum(relation.getUserId(), relation.getId(), relation.getAccount(), req.getNum(), cmsUser != null ? cmsUser.getNickname() : null, req.getRemark());
|
|
|
+ }
|
|
|
+ return GatewayResponse.SUCCESS.newBuilder().toResult();
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* GPT代充卡密列表
|
|
|
*/
|