|
|
@@ -20,6 +20,7 @@ import com.cyksj.mapper.manage.cms.CmsUserMapper;
|
|
|
import com.cyksj.model.entity.*;
|
|
|
import com.cyksj.model.manage.views.AccountView;
|
|
|
import com.cyksj.model.manage.views.GroupsRelationBackView;
|
|
|
+import com.cyksj.model.request.RechargeRemainNumReq;
|
|
|
import com.cyksj.model.views.DisableAccountView;
|
|
|
import com.cyksj.model.views.GroupsRelationIndependentView;
|
|
|
import com.cyksj.model.views.GroupsRelationRechargeView;
|
|
|
@@ -69,6 +70,8 @@ public class CmsGroupRelationController {
|
|
|
|
|
|
private final GroupRelationClearService groupRelationClearService;
|
|
|
|
|
|
+ private final GptRechargeCardKeyMapper gptRechargeCardKeyMapper;
|
|
|
+
|
|
|
@GetMapping("/get")
|
|
|
public Result<List<GroupsRelationBackView>> get(){
|
|
|
List<GroupsRelationBackView> search = beanSearcher.searchAll(GroupsRelationBackView.class, MapUtils.flatBuilder(request.getParameterMap())
|
|
|
@@ -173,6 +176,21 @@ 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("更新用户代充剩余次数失败,请重试");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
groupsRelationMapper.updateById(relation);
|
|
|
return GatewayResponse.SUCCESS.newBuilder().toResult("状态修改成功");
|
|
|
@@ -193,6 +211,82 @@ public class CmsGroupRelationController {
|
|
|
return GatewayResponse.SUCCESS.newBuilder().toResult(false);
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * GPT代充 设置剩余次数
|
|
|
+ */
|
|
|
+ @PutMapping("/recharge/update/remain/num")
|
|
|
+ public Result<String> updateRechargeRemainNum(@RequestBody RechargeRemainNumReq req) {
|
|
|
+ Long relationId = req.getRelationId();
|
|
|
+ Integer num = req.getNum();
|
|
|
+ GroupsRelation relation = groupsRelationMapper.selectById(relationId);
|
|
|
+ if (relation.getRechargeNum() != null) {
|
|
|
+ Integer rechargeRemainNum = relation.getRechargeRemainNum();
|
|
|
+ if (rechargeRemainNum == 0 && num < 0) {
|
|
|
+ throw BusinessRuntimeException.getInstance("剩余代充次数为0");
|
|
|
+ }
|
|
|
+ int update = groupsRelationMapper.update(null, Wrappers.lambdaUpdate(GroupsRelation.class)
|
|
|
+ .set(GroupsRelation::getRechargeRemainNum, rechargeRemainNum - num)
|
|
|
+ .eq(GroupsRelation::getId, relationId)
|
|
|
+ .eq(GroupsRelation::getRechargeRemainNum, rechargeRemainNum));
|
|
|
+ if (update == 0) {
|
|
|
+ throw BusinessRuntimeException.getInstance("修改用户代充次数错误,请重试");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return GatewayResponse.SUCCESS.newBuilder().toResult();
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * GPT代充卡密列表
|
|
|
+ */
|
|
|
+ @GetMapping("/get/gpt/cardKey")
|
|
|
+ public Result<SearchResult<GptRechargeCardKey>> getGptCardKey() {
|
|
|
+ SearchResult<GptRechargeCardKey> search = beanSearcher.search(GptRechargeCardKey.class, MapUtils.flatBuilder(request.getParameterMap()).build());
|
|
|
+ return GatewayResponse.SUCCESS.newBuilder().toResult(search);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 编辑GPT代充卡密
|
|
|
+ */
|
|
|
+ @GetMapping("/get/gpt/cardKey")
|
|
|
+ public Result<SearchResult<GptRechargeCardKey>> getGptCardKey(@RequestBody GptRechargeCardKey cardKey) {
|
|
|
+ Long id = cardKey.getId();
|
|
|
+ GptRechargeCardKey gptRechargeCardKey = gptRechargeCardKeyMapper.selectById(id);
|
|
|
+ if (gptRechargeCardKey == null) {
|
|
|
+ throw BusinessRuntimeException.getInstance("卡密不存在");
|
|
|
+ }
|
|
|
+ gptRechargeCardKeyMapper.updateById(cardKey);
|
|
|
+ return GatewayResponse.SUCCESS.newBuilder().toResult();
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 删除GPT代充卡密
|
|
|
+ */
|
|
|
+ @DeleteMapping("/del/gpt/cardKey/{id}")
|
|
|
+ public Result<SearchResult<GptRechargeCardKey>> deleteGptCardKeyById(@PathVariable Long id) {
|
|
|
+ GptRechargeCardKey gptRechargeCardKey = gptRechargeCardKeyMapper.selectById(id);
|
|
|
+ if (gptRechargeCardKey == null) {
|
|
|
+ throw BusinessRuntimeException.getInstance("卡密不存在");
|
|
|
+ }
|
|
|
+ if (gptRechargeCardKey.getStatus()) {
|
|
|
+ throw BusinessRuntimeException.getInstance("已使用的卡密不可删除");
|
|
|
+ }
|
|
|
+ gptRechargeCardKeyMapper.deleteById(id);
|
|
|
+ return GatewayResponse.SUCCESS.newBuilder().toResult();
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 新增GPT代充卡密
|
|
|
+ */
|
|
|
+ @PostMapping("/post/gpt/cardKey")
|
|
|
+ public Result<String> postGptCardKey(@RequestBody GptRechargeCardKey gptRechargeCardKey) {
|
|
|
+ gptRechargeCardKeyMapper.insert(gptRechargeCardKey);
|
|
|
+ return GatewayResponse.SUCCESS.newBuilder().toResult();
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* Chat GPT独立规格续费 列表
|
|
|
*/
|