瀏覽代碼

更新代充剩余次数;用户车票详情展示相关字段;独立会员购买时加入代充

zoujiajian 1 年之前
父節點
當前提交
86de4cfaba

+ 5 - 0
netflix-dao/src/main/java/com/cyksj/model/entity/GoodsDon.java

@@ -243,6 +243,11 @@ public class GoodsDon extends BaseEntity {
      */
     private Boolean isThirdGoods;
 
+    /**
+     * 用户端车票展示字段
+     */
+    private String showFieldInfo;
+
     @AllArgsConstructor
     @Getter
     public enum SpecialType {

+ 5 - 0
netflix-dao/src/main/java/com/cyksj/model/manage/request/ReqGoodsSpuInsert.java

@@ -159,4 +159,9 @@ public class ReqGoodsSpuInsert {
      * 是否隐藏
      */
     private Boolean isHide;
+
+    /**
+     * 用户端车票展示字段
+     */
+    private String showFieldInfo;
 }

+ 6 - 0
netflix-dao/src/main/java/com/cyksj/model/manage/views/GoodsDonViewer.java

@@ -182,6 +182,12 @@ public class GoodsDonViewer {
     @DbField("g.special_type")
     private GoodsDon.SpecialType specialType;
 
+    /**
+     * 用户端车票展示字段
+     */
+    @DbField("g.show_field_info")
+    private String showFieldInfo;
+
     @DbIgnore
     private List<GoodsDonSku> skus;
 

+ 6 - 0
netflix-dao/src/main/java/com/cyksj/model/views/RenewalView.java

@@ -106,6 +106,12 @@ public class RenewalView {
     @DbField("g.special_type")
     private GoodsDon.SpecialType specialType;
 
+    /**
+     * 用户端车票展示字段
+     */
+    @DbField("g.show_field_info")
+    private String showFieldInfo;
+
     @DbField("gt.status")
     private String groupsStatus;
 

+ 4 - 4
netflix-service/src/main/java/com/cyksj/server/recharge/impl/GptProxyRechargeServiceImpl.java

@@ -196,10 +196,10 @@ public class GptProxyRechargeServiceImpl implements GptProxyRechargeService {
 		}
 		GroupsTrips groupsTrips = groupsMapper.selectById(relation.getGroupsId());
 		GoodsDonSku sku = skuMapper.selectById(groupsTrips.getSkuId());
-		//GPT 代充
-		if (sku.getGoodsId() != Constant.GPT_RECHARGE_GOODS_ID) {
-			throw BusinessRuntimeException.getInstance("车票类型错误");
-		}
+//		//GPT 代充
+//		if (sku.getGoodsId() != Constant.GPT_RECHARGE_GOODS_ID) {
+//			throw BusinessRuntimeException.getInstance("车票类型错误");
+//		}
 		Integer rechargeRemainNum = relation.getRechargeRemainNum();
 		if (rechargeRemainNum == null || rechargeRemainNum <= 0) {
 			throw BusinessRuntimeException.getInstance("剩余可代充次数为0");

+ 3 - 0
netflix-service/src/main/java/com/cyksj/service/chatgpt/impl/GptUserRechargeRecordServiceImpl.java

@@ -21,6 +21,9 @@ public class GptUserRechargeRecordServiceImpl implements GptUserRechargeRecordSe
 
 	@Override
 	public void recordGptUserRechargeNum(Long userId, Long relationId, String account, Integer num, String operator, String remark) {
+		if (num == 0) {
+			return;
+		}
 		//记录代充记录
 		GptUserRechargeNumRecord gptUserRechargeNumRecord = new GptUserRechargeNumRecord();
 		gptUserRechargeNumRecord.setUserId(userId);

+ 26 - 0
netflix-service/src/main/java/com/cyksj/service/mange/group/CmsGroupServiceImpl.java

@@ -21,6 +21,7 @@ import com.cyksj.model.manage.views.GroupsRelationView;
 import com.cyksj.model.request.ReplaceTripsAccountReq;
 import com.cyksj.model.views.GroupsAccountView;
 import com.cyksj.redis.RedisService;
+import com.cyksj.service.chatgpt.GptUserRechargeRecordService;
 import com.cyksj.service.mange.AccountCommonService;
 import com.cyksj.service.mange.CmsGroupService;
 import com.cyksj.service.relation.GroupRelationClearService;
@@ -96,6 +97,8 @@ public class CmsGroupServiceImpl extends ServiceImpl<GroupsMapper,GroupsTrips> i
 
     private final NetflixUserAccountStatusRecordMapper netflixUserAccountStatusRecordMapper;
 
+    private final GptUserRechargeRecordService gptUserRechargeRecordService;
+
     private static final GlobalThreadPoolTaskExecutor TASK_EXECUTOR = GlobalThreadPoolTaskExecutor.getInstance();
 
 
@@ -339,6 +342,11 @@ public class CmsGroupServiceImpl extends ServiceImpl<GroupsMapper,GroupsTrips> i
 
         //HBO GO 满员,车队下架
         setDownIfFull(goodsDon, groupsTrips);
+
+        //是否是GPT独立会员
+        if (goodsDon.getId() == Constant.GPT_PLUS_GID && sku.getNum() == 1) {
+            setRelationRechargeRemainNumInfo(groupsTrips.getId(), sku.getMonths(), account.getAccount(), account.getPassword());
+        }
     }
 
     @Override
@@ -603,4 +611,22 @@ public class CmsGroupServiceImpl extends ServiceImpl<GroupsMapper,GroupsTrips> i
         }
         return null;
     }
+
+    private void setRelationRechargeRemainNumInfo(Long groupsId, Integer addNum, String account, String password) {
+        GroupsRelation relation = relationMapper.selectOne(Wrappers.lambdaQuery(GroupsRelation.class).eq(GroupsRelation::getGroupsId, groupsId).last("limit 1"));
+        if (relation.getStatus() == GroupsRelation.Status.validity) {
+            if (relation.getRechargeStatus() == null) {
+                relation.setRechargeStatus(GroupsRelation.RechargeStatus.complete);
+                relation.setRechargeNum(addNum);
+                relation.setRechargeRemainNum(addNum - 1);
+                relation.setSubmitTime(DateTime.now());
+                relation.setSendTime(relation.getSubmitTime());
+                relation.setAccount(account);
+                relation.setPassword(password);
+                relationMapper.updateById(relation);
+                //记录gpt代充记录
+                gptUserRechargeRecordService.recordGptUserRechargeNum(relation.getUserId(), relation.getId(), relation.getAccount(), relation.getRechargeRemainNum(), null, "下单");
+            }
+        }
+    }
 }

+ 13 - 0
netflix-service/src/main/java/com/cyksj/service/mange/impl/CmsOrderDonServiceImpl.java

@@ -820,6 +820,16 @@ public class CmsOrderDonServiceImpl extends ServiceImpl<OrderDonMapper,OrderDon>
             if (newRelation.getStatus() != GroupsRelation.Status.outside) {
                 newRelation.setStatus(GroupsRelation.Status.validity);
             }
+            //代充信息
+            newRelation.setRechargeStatus(relation.getRechargeStatus());
+            newRelation.setRechargeNum(relation.getRechargeNum());
+            newRelation.setRechargeRemainNum(relation.getRechargeRemainNum());
+            newRelation.setSubmitTime(relation.getSubmitTime());
+            newRelation.setSendTime(relation.getSendTime());
+            newRelation.setAccount(relation.getAccount());
+            newRelation.setPassword(relation.getPassword());
+            newRelation.setGptTaskId(relation.getGptTaskId());
+            newRelation.setCardKey(relation.getCardKey());
 
             //清除原先车票
             relation.setNewRelationId(newRelation.getId());
@@ -1760,6 +1770,9 @@ public class CmsOrderDonServiceImpl extends ServiceImpl<OrderDonMapper,OrderDon>
         List<Long> userIdList = userBindRelationService.getRelationUserIdList(userId, null);
         GroupsRelation relation = relationMapper.selectOne(Wrappers.lambdaQuery(GroupsRelation.class).eq(GroupsRelation::getId, relationId).in(GroupsRelation::getUserId, userIdList).gt(GroupsRelation::getExpiryTime, DateTime.now()));
         if (relation != null && relation.getRechargeStatus() != null) {
+            if (relation.getRechargeRemainNum() == 0) {
+                return;
+            }
             int update = 0;
             while (update == 0) {
                 Integer rechargeRemainNum = relation.getRechargeRemainNum();

+ 37 - 16
netflix-service/src/main/java/com/cyksj/service/order/impl/OrderDonServiceImpl.java

@@ -3135,8 +3135,8 @@ public class OrderDonServiceImpl extends ServiceImpl<OrderDonMapper, OrderDon> i
 		}
 
 		//GPT独立会员续费 若为代充类型 同步代充次数
-		if (orderDon.getGoodsId() == Constant.GPT_PLUS_GID && orderDon.getOrderType() == 2) {
-			incrGroupsRelationRechargeRemainIfRecharge(orderDon.getRelationId(), sku.getMonths());
+		if (orderDon.getGoodsId() == Constant.GPT_PLUS_GID) {
+			incrGroupsRelationRechargeRemainIfRecharge(orderDon.getRelationId(), sku.getMonths(), orderDon.getOrderType());
 		}
 	}
 
@@ -5178,22 +5178,43 @@ public class OrderDonServiceImpl extends ServiceImpl<OrderDonMapper, OrderDon> i
 		}
 	}
 
-	private void incrGroupsRelationRechargeRemainIfRecharge(Long relationId, Integer addNum) {
+	private void incrGroupsRelationRechargeRemainIfRecharge(Long relationId, Integer addNum, Integer orderType) {
 		GroupsRelation relation = groupsRelationMapper.selectById(relationId);
-		if (relation.getRechargeStatus() != null) {
-			//增加代充次数
-			Integer rechargeRemainNum = relation.getRechargeRemainNum();
-			Integer rechargeNum = relation.getRechargeNum();
-			int update = 0;
-			while (update == 0) {
-				update = groupsRelationMapper.update(null, Wrappers.lambdaUpdate(GroupsRelation.class)
-						.set(GroupsRelation::getRechargeRemainNum, rechargeRemainNum + addNum)
-						.set(GroupsRelation::getRechargeNum, rechargeNum + addNum)
-						.eq(GroupsRelation::getId, relationId)
-						.eq(GroupsRelation::getRechargeRemainNum, rechargeRemainNum));
-				if (update == 1) {
+		if (orderType == 1) {
+			//已发车
+			GroupsTrips groupsTrips = groupsMapper.selectById(relation.getGroupsId());
+			if (groupsTrips.getAccountId() != null) {
+				Account account = accountMapper.selectById(groupsTrips.getAccountId());
+				if (account != null) {
+					relation.setRechargeStatus(GroupsRelation.RechargeStatus.complete);
+					relation.setRechargeNum(addNum);
+					relation.setRechargeRemainNum(addNum - 1);
+					relation.setSubmitTime(DateTime.now());
+					relation.setSendTime(relation.getSubmitTime());
+					relation.setAccount(account.getAccount());
+					relation.setPassword(account.getPassword());
+					groupsRelationMapper.updateById(relation);
 					//记录gpt代充记录
-					gptUserRechargeRecordService.recordGptUserRechargeNum(relation.getUserId(), relation.getId(), relation.getAccount(), addNum, null, "订单续费");
+					gptUserRechargeRecordService.recordGptUserRechargeNum(relation.getUserId(), relation.getId(), relation.getAccount(), relation.getRechargeRemainNum(), null, "下单");
+				}
+			}
+		} else {
+			//续费订单
+			if (relation.getRechargeStatus() != null) {
+				//增加代充次数
+				Integer rechargeRemainNum = relation.getRechargeRemainNum();
+				Integer rechargeNum = relation.getRechargeNum();
+				int update = 0;
+				while (update == 0) {
+					update = groupsRelationMapper.update(null, Wrappers.lambdaUpdate(GroupsRelation.class)
+							.set(GroupsRelation::getRechargeRemainNum, rechargeRemainNum + addNum)
+							.set(GroupsRelation::getRechargeNum, rechargeNum + addNum)
+							.eq(GroupsRelation::getId, relationId)
+							.eq(GroupsRelation::getRechargeRemainNum, rechargeRemainNum));
+					if (update == 1) {
+						//记录gpt代充记录
+						gptUserRechargeRecordService.recordGptUserRechargeNum(relation.getUserId(), relation.getId(), relation.getAccount(), addNum, null, "订单续费");
+					}
 				}
 			}
 		}

+ 34 - 2
netflix-web/src/main/java/com/cyksj/web/controller/manage/group/CmsGroupRelationController.java

@@ -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代充卡密列表
      */
@@ -329,13 +357,17 @@ public class CmsGroupRelationController {
     @GetMapping("/get/recharge/operate/record")
     public Result<List<GptUserRechargeNumRecord>> getGptUserRechargeNumRecord(Long relationId, Long userId) {
         GroupsRelation relation = groupsRelationMapper.selectById(relationId);
-        if (relation.getStartTime() == null) {
+        if (relation.getSubmitTime() == null && relation.getStartTime() == null) {
             return GatewayResponse.SUCCESS.newBuilder().toResult();
         }
+        Date filterDate = relation.getSubmitTime();
+        if (filterDate == null) {
+            filterDate = relation.getStartTime();
+        }
         List<GptUserRechargeNumRecord> gptUserRechargeNumRecords = beanSearcher.searchAll(GptUserRechargeNumRecord.class, MapUtils.flatBuilder(request.getParameterMap())
                 .field(GptUserRechargeNumRecord::getRelationId, relationId)
                 .field(GptUserRechargeNumRecord::getUserId, userId)
-                .field(GptUserRechargeNumRecord::getCreatedTime, relation.getStartTime()).op(Operator.GreaterEqual)
+                .field(GptUserRechargeNumRecord::getCreatedTime, filterDate).op(Operator.GreaterEqual)
                 .build());
         return GatewayResponse.SUCCESS.newBuilder().toResult(gptUserRechargeNumRecords);
     }