Selaa lähdekoodia

Merge branch 'master' into pre

# Conflicts:
#	netflix-common/src/main/java/com/cyksj/common/constant/Constant.java
#	netflix-service/src/main/java/com/cyksj/service/order/impl/OrderDonServiceImpl.java
zoujiajian 2 vuotta sitten
vanhempi
sitoutus
b9b4bb1eb0

+ 1 - 1
netflix-common/src/main/java/com/cyksj/common/constant/Constant.java

@@ -298,5 +298,5 @@ public interface Constant {
 	/**
 	 * 设备客服活码用户分销专用
 	 */
-	Long EP_AC_CODE_ID = 5l;
+	Long EP_AC_CODE_ID = 7l;
 }

+ 1 - 1
netflix-dao/src/main/java/com/cyksj/mapper/corp/CorpCustomerAcquisitionLinkMapper.java

@@ -18,5 +18,5 @@ public interface CorpCustomerAcquisitionLinkMapper extends BaseMapper<CorpCustom
 
 	List<CorpCustomerAcquisitionLink> selectActiveCodeByFollowIndx(@Param("list") List<Integer> updateFollowIndx);
 
-	List<Long> selectAcLinkCorpTemplateCouponIdsByTagIds(@Param("tagIds") List<Long> tagIds);
+	List<String> selectAcLinkCorpTemplateCouponIdsByTagIds(@Param("tagIds") List<Long> tagIds);
 }

+ 4 - 1
netflix-dao/src/main/java/com/cyksj/model/views/GoodsDonSkuFrontView.java

@@ -1,6 +1,5 @@
 package com.cyksj.model.views;
 
-import com.ejlchina.searcher.bean.DbField;
 import com.ejlchina.searcher.bean.DbIgnore;
 import com.ejlchina.searcher.bean.SearchBean;
 import com.fasterxml.jackson.annotation.JsonInclude;
@@ -140,4 +139,8 @@ public class GoodsDonSkuFrontView {
 	 * 限制时间
 	 */
 	private Long gptLimitTime;
+
+	private Boolean isCar;
+
+	private Boolean isMirror;
 }

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

@@ -136,4 +136,10 @@ public class YhShopGoodsSkuFrontView {
 	 */
 	@DbField("sku.gpt_limit_time")
 	private Long gptLimitTime;
+
+	@DbField("sku.is_car")
+	private Boolean isCar;
+
+	@DbField("sku.is_mirror")
+	private Boolean isMirror;
 }

+ 1 - 1
netflix-dao/src/main/resources/mapper/CorpCustomerAcquisitionLinkMapper.xml

@@ -12,7 +12,7 @@
         </foreach>
     </select>
 
-    <select id="selectAcLinkCorpTemplateCouponIdsByTagIds" resultType="java.lang.Long">
+    <select id="selectAcLinkCorpTemplateCouponIdsByTagIds" resultType="java.lang.String">
         select distinct ct.coupon_ids from (select msg_id from corp_customer_acquisition_link
         where msg_id != 0 and tags != '[]' and
         <foreach collection="tagIds" item="item" open="(" separator="OR" close=")">

+ 0 - 1
netflix-service/src/main/java/com/cyksj/redis/RedisService.java

@@ -821,7 +821,6 @@ public class RedisService {
         CLOSE_ORDER_TIME_KEY("close_order_time_key:", "关闭订单key", 3 * 60),
         CHATGPT_CONVERSATION_LIMIT("chatgpt:conversation:limit:", "chatGpt 对话限制", 3 * 60 * 60L),
 
-        CHATGPT_CAR_CONVERSATION_LIMIT("chatgpt:conversation:car:", "chatGpt 车队对话数量", 3 * 60 * 60L),
         CHATGPT_CAR_SCORES("chatgpt:car:scores","chatGpt 车队分数", 48 * 60 * 60L),
         CHATGPT_CAR_HIGH_CHAT("chatgpt:car:high:chat:","chatGpt gpt4 对话次数", 48 * 60 * 60L),
         CHATGPT_CAR_LOW_CHAT("chatgpt:car:low:chat:","chatGpt 3.5 对话次数", 48 * 60 * 60L),

+ 10 - 43
netflix-service/src/main/java/com/cyksj/service/chatgpt/impl/ChatGptAccountServiceImpl.java

@@ -211,6 +211,9 @@ public class ChatGptAccountServiceImpl implements ChatGptAccountService {
 
         if (goodsDonSku != null && goodsDonSku.getIsMirror()) {
             ChatgptUser chatgptUser = getChatgptUser(userId, relationId, groupsRelation, groupsTrips, goodsDonSku);
+            if(214610L == relationId){
+                 return "https://cdn.galaxydvd.com/login_token?access_token=" + chatgptUser.getUserToken();
+            }
             return GPT_DOMAIN + "/login_token?access_token=" + chatgptUser.getUserToken();
         } else {
             throw BusinessRuntimeException.getInstance("服务器出了点问题");
@@ -396,8 +399,8 @@ public class ChatGptAccountServiceImpl implements ChatGptAccountService {
         chatgptUserConversationRecord.setModel(conversationRequest.getModel());
         chatgptUserConversationRecordMapper.insert(chatgptUserConversationRecord);
 
-        if(StringUtils.isNotBlank(conversationRequest.getCarId())){
-            updateExperienceAndScore(conversationRequest.getCarId(), !"text-davinci-002-render-sha".equals(conversationRequest.getModel()), System.currentTimeMillis());
+        if(StringUtils.isNotBlank(chatgptSession.getCarId())){
+            updateExperienceAndScore(chatgptSession.getCarId(), !"text-davinci-002-render-sha".equals(conversationRequest.getModel()), System.currentTimeMillis());
         }
 
     }
@@ -412,21 +415,6 @@ public class ChatGptAccountServiceImpl implements ChatGptAccountService {
             if (chatgptUser.getIsCar()) {
                 conversationLimitResponse = isConversationAllowed(userToken, chatgptUser.getLimitNum(), chatgptUser.getLimitTime());
             }
-            if(carId == null){
-                if (StringUtils.isNotBlank(userToken)) {
-                    if (chatgptUser.getSessionId() != null) {
-                        ChatgptSession chatgptSession = chatgptSessionMapper.selectById(chatgptUser.getSessionId());
-                        if(chatgptSession != null){
-                            carId = chatgptSession.getCarId();
-                        }
-                    }
-                }
-            }
-            //车队次数记录
-            String finalCarId = carId;
-            TASK_EXECUTOR.execute(() -> {
-                cardConversationRecord(finalCarId);
-            });
         }
 
         return conversationLimitResponse;
@@ -470,29 +458,6 @@ public class ChatGptAccountServiceImpl implements ChatGptAccountService {
     }
 
 
-    /**
-     * 记录车队的提问次数
-     */
-    public boolean cardConversationRecord(String carid) {
-        String key = RedisService.key.CHATGPT_CAR_CONVERSATION_LIMIT.getName() + ":" + carid;
-        long currentTimeMillis = System.currentTimeMillis();
-        long windowStartMillis = currentTimeMillis - (WINDOW_SIZE) * 1000;
-
-        // 清除时间窗口之前的请求记录
-        redisService.zRemoveRangeByScore(key, 0, windowStartMillis);
-
-        Long currentSize = redisService.zCard(key);
-        if (currentSize != null && currentSize >= MAX_REQUESTS) {
-            // 如果当前请求次数超过限制,则拒绝请求
-            return false;
-        } else {
-            // 如果未超过限制,记录当前请求的时间戳
-            redisService.zAdd(key, currentTimeMillis, currentTimeMillis);
-            // 设置ZSet的过期时间,窗口大小加上一段冗余时间
-            redisService.expire(key, (WINDOW_SIZE * 60 * 60) + 20);
-            return true;
-        }
-    }
 
     /**
      * 获取指定用户ID在滑动窗口内的提问次数
@@ -521,9 +486,11 @@ public class ChatGptAccountServiceImpl implements ChatGptAccountService {
      * @return 滑动窗口内的请求次数
      */
     private Long getCarConversationCount(String carId, Long limitTime) {
-        String key = RedisService.key.CHATGPT_CAR_CONVERSATION_LIMIT.getName() + ":" + carId;
-        long currentTimeMillis = System.currentTimeMillis();
-        long windowStartMillis = currentTimeMillis - (limitTime * 60 * 60) * 1000;
+        // 定义键名
+        String key = RedisService.key.CHATGPT_CAR_HIGH_CHAT.getName() + carId;
+        long timestamp = System.currentTimeMillis();
+
+        long windowStartMillis = timestamp - (limitTime * 60 * 60 * 1000);
 
         // 清除时间窗口之前的请求记录(可选,根据需要决定是否在此处清理过期记录)
         redisService.zRemoveRangeByScore(key, 0, windowStartMillis);

+ 1 - 0
netflix-service/src/main/java/com/cyksj/service/corp/impl/CorpWelcomeTemplateServiceImpl.java

@@ -1,6 +1,7 @@
 package com.cyksj.service.corp.impl;
 
 import cn.hutool.core.collection.CollUtil;
+import cn.hutool.core.util.StrUtil;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.cyksj.common.exception.BusinessRuntimeException;
 import com.cyksj.common.util.Jsons;

+ 1 - 1
netflix-service/src/main/java/com/cyksj/service/user/BadIntentionOpService.java

@@ -3,7 +3,7 @@ package com.cyksj.service.user;
 import javax.servlet.http.HttpServletRequest;
 
 public interface BadIntentionOpService {
-    void checkHandleBadUserOp(String phone);
+    void checkHandleBadUserOp(HttpServletRequest request, String phone);
 
     void isBadOpLoginPhone(HttpServletRequest request, String phone);
 }

+ 10 - 4
netflix-service/src/main/java/com/cyksj/service/user/impl/BadIntentionOpServiceImpl.java

@@ -23,12 +23,16 @@ public class BadIntentionOpServiceImpl implements BadIntentionOpService {
     private static final int PHONE_LOGIN_CODE_RETRY = 10;
 
     @Override
-    public void checkHandleBadUserOp(String phone) {
+    public void checkHandleBadUserOp(HttpServletRequest request, String phone) {
         if ("13662979985".equals(phone)) {
             throw BusinessRuntimeException.getInstance("异常手机号");
         }
+        String clientIP = ServletUtil.getClientIP(request);
+        String ipAddress = StringUtil.getInternalAddressByIP(clientIP);
+        log.info("--------------获取手机验证码------- ip:{} address:{}", clientIP, ipAddress);
         String dayKey = RedisService.key.PHONE_CODE_USER_NUM_KEY_DAY.getName() + phone;
         if (redisService.hasKey(RedisService.key.PHONE_CODE_BALCK_KEY.getName() + phone)) {
+            log.error("--------------黑名单 手机号------- ip:{} address:{}", clientIP, ipAddress);
             throw BusinessRuntimeException.getInstance("异常手机号");
         }
         if (redisService.hasKey(dayKey)) {
@@ -49,8 +53,10 @@ public class BadIntentionOpServiceImpl implements BadIntentionOpService {
 
     @Override
     public void isBadOpLoginPhone(HttpServletRequest request, String phone) {
-        String ip = StringUtil.getInternalAddressByIP(ServletUtil.getClientIP(request));
-        String blackIpKey = RedisService.key.BALCK_USER_IP_KEY + ip;
+        String clientIP = ServletUtil.getClientIP(request);
+        String ipAddress = StringUtil.getInternalAddressByIP(clientIP);
+        log.info("--------------校验ip 是否黑名单------- ip:{} ipAddress:{}", clientIP, ipAddress);
+        String blackIpKey = RedisService.key.BALCK_USER_IP_KEY + clientIP;
         if (redisService.hasKey(blackIpKey)) {
             throw BusinessRuntimeException.getInstance("检测到您操作异常,请联系客服");
         }
@@ -59,7 +65,7 @@ public class BadIntentionOpServiceImpl implements BadIntentionOpService {
             int i = Integer.parseInt(redisService.get(RetryTimeKey).toString());
             if (i >= PHONE_LOGIN_CODE_RETRY) {
                 //锁住他的ip
-                redisService.setNx(blackIpKey, ip, RedisService.key.BALCK_USER_IP_KEY.getTimeout());
+                redisService.setNx(blackIpKey, clientIP, RedisService.key.BALCK_USER_IP_KEY.getTimeout());
                 throw BusinessRuntimeException.getInstance("检测到您操作异常,请联系客服");
             } else {
                 redisService.incr(RetryTimeKey, 1l);

+ 8 - 3
netflix-service/src/main/java/com/cyksj/service/user/impl/UserServiceImpl.java

@@ -701,10 +701,15 @@ public class UserServiceImpl extends ServiceImpl<UserMapper, User> implements Us
 			//是否有对应获客链接的标签
 			List<Long> tagIds = corpUserTagMapper.getTagIdByCorpUserId(corpUser.getId());
 			if (CollUtil.isNotEmpty(tagIds)) {
-				List<Long> couponIds = corpCustomerAcquisitionLinkMapper.selectAcLinkCorpTemplateCouponIdsByTagIds(tagIds);
-				if (CollUtil.isNotEmpty(couponIds)) {
+				List<String> couponIdsStrList = corpCustomerAcquisitionLinkMapper.selectAcLinkCorpTemplateCouponIdsByTagIds(tagIds);
+				if (CollUtil.isNotEmpty(couponIdsStrList)) {
 					log.info("用户userId:{}存在获客链接标记的标签:{}", fUid, tagIds);
-					couponIds.forEach(couponId -> couponCommonService.sendCouponToUser(fUid, couponId, 0l, 0l, 0l, CouponUser.Channel.customer_link));
+					couponIdsStrList.forEach(couponIdsStr -> {
+						try {
+							Jsons.parseList(couponIdsStr, Long.class).forEach(couponId -> couponCommonService.sendCouponToUser(fUid, couponId, 0l, 0l, 0l, CouponUser.Channel.customer_link));
+						} catch (Exception e) {
+						}
+					});
 				}
 			}
 		}

+ 0 - 2
netflix-web/src/main/java/com/cyksj/web/controller/manage/account/CmsGptCarController.java

@@ -86,7 +86,6 @@ public class CmsGptCarController {
 					if (StrUtil.isNotBlank(carId)) {
 						chatgptSessionMapper.deleteById(e.getId());
 
-						String carConversationKey = RedisService.key.CHATGPT_CAR_CONVERSATION_LIMIT.getName() + ":" + carId;
 						String highCarChatKey = RedisService.key.CHATGPT_CAR_HIGH_CHAT.getName() + carId;
 						String lowCarChatKey = RedisService.key.CHATGPT_CAR_LOW_CHAT.getName() + carId;
 						//从zSet中删除车队
@@ -94,7 +93,6 @@ public class CmsGptCarController {
 						redisService.zRemove(carScoresKey, carId);
 						redisService.del(highCarChatKey);
 						redisService.del(lowCarChatKey);
-						redisService.del(carConversationKey);
 					}
 				});
 		return GatewayResponse.SUCCESS.newBuilder().toResult();

+ 11 - 0
netflix-web/src/main/java/com/cyksj/web/controller/market/TaskFrontController.java

@@ -12,13 +12,16 @@ import com.cyksj.model.request.UserBindInfoReq;
 import com.cyksj.model.views.TaskFrontView;
 import com.cyksj.service.market.MarketFrontService;
 import com.cyksj.service.market.task.BindTaskService;
+import com.cyksj.service.user.BadIntentionOpService;
 import com.cyksj.service.user.UserBindRelationService;
 import com.cyksj.service.user.UserService;
 import com.cyksj.web.util.StpUserUtil;
 import com.ejlchina.searcher.BeanSearcher;
 import com.ejlchina.searcher.SearchResult;
 import com.ejlchina.searcher.util.MapUtils;
+import com.ejlchina.searcher.util.StringUtils;
 import lombok.RequiredArgsConstructor;
+import lombok.extern.slf4j.Slf4j;
 import org.springframework.validation.annotation.Validated;
 import org.springframework.web.bind.annotation.*;
 
@@ -31,6 +34,7 @@ import javax.servlet.http.HttpServletResponse;
  *创建者: JavaZou
  *创建时间:2022/12/28 13:51
  */
+@Slf4j
 @RestController
 @RequestMapping("/applets/market/task")
 @RequiredArgsConstructor
@@ -48,6 +52,9 @@ public class TaskFrontController {
 
 	private final UserBindRelationService userBindRelationService;
 
+	private final BadIntentionOpService badIntentionOpService;
+
+	private final HttpServletRequest request;
 	/**
 	 * 任务列表
 	 */
@@ -82,6 +89,10 @@ public class TaskFrontController {
 	@Deprecated
 	public Result<String> bindPhone(@RequestBody LoginReq phoneReq) {
 		Long userId = StpUserUtil.getLoginIdAsLong();
+		log.info("绑定手机号 userId:{}, params:{}", userId, phoneReq);
+		if(StringUtils.isNotBlank(phoneReq.getPhone())){
+			badIntentionOpService.isBadOpLoginPhone(request, phoneReq.getPhone());
+		}
 		User user = userMapper.selectById(userId);
 		bindTaskService.bindPhone(user, phoneReq.getPhone(), phoneReq.getCode());
 		return GatewayResponse.SUCCESS.newBuilder().toResult("绑定手机号成功");

+ 1 - 1
netflix-web/src/main/java/com/cyksj/web/controller/user/AuthorizationController.java

@@ -379,7 +379,7 @@ public class AuthorizationController {
             throw BusinessRuntimeException.getInstance("短信验证码未失效");
         }
         //是否是恶意用户
-        badIntentionOpService.checkHandleBadUserOp(phone);
+        badIntentionOpService.checkHandleBadUserOp(request, phone);
         String code = StringUtil.getRandomCodeStr(digit);
         Boolean isFlag;
         if (!isFree) {