zoujiajian hace 2 meses
padre
commit
9815ed1133

+ 15 - 18
netflix-web/src/main/java/com/cyksj/web/controller/enterprise/EnterprisePurchaseLeadFrontController.java

@@ -7,6 +7,7 @@ import com.cyksj.mapper.enterprise.EnterprisePurchaseLeadPopupRecordMapper;
 import com.cyksj.model.entity.EnterprisePurchaseLeadPopupRecord;
 import com.cyksj.model.request.EnterprisePurchaseLeadSubmitReq;
 import com.cyksj.service.enterprise.EnterprisePurchaseLeadService;
+import com.cyksj.service.user.UserBindRelationService;
 import com.cyksj.web.util.StpUserUtil;
 import lombok.RequiredArgsConstructor;
 import org.springframework.dao.DuplicateKeyException;
@@ -18,6 +19,7 @@ import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RestController;
 
 import javax.servlet.http.HttpServletRequest;
+import java.util.List;
 
 @RestController
 @RequiredArgsConstructor
@@ -30,6 +32,8 @@ public class EnterprisePurchaseLeadFrontController {
 
     private final HttpServletRequest request;
 
+    private final UserBindRelationService userBindRelationService;
+
     @PostMapping
     public Result<Long> submit(@RequestBody @Validated EnterprisePurchaseLeadSubmitReq req) {
         Long id = enterprisePurchaseLeadService.submit(req, getClientIp(), request.getHeader("User-Agent"));
@@ -42,26 +46,19 @@ public class EnterprisePurchaseLeadFrontController {
     @GetMapping("/popup/visible")
     public Result<Boolean> popupVisible() {
         long userId = StpUserUtil.getLoginIdAsLong();
+        List<Long> userIdList = userBindRelationService.getRelationUserIdList(userId, null);
         Integer selectCount = enterprisePurchaseLeadPopupRecordMapper.selectCount(Wrappers.lambdaQuery(EnterprisePurchaseLeadPopupRecord.class)
-                .eq(EnterprisePurchaseLeadPopupRecord::getUserId, userId));
-        return GatewayResponse.SUCCESS.newBuilder().toResult(selectCount == 0);
-    }
-
-    /**
-     * 记录企业采购弹窗已展示
-     */
-    @PostMapping("/popup/record")
-    public Result<Boolean> recordPopup() {
-        long userId = StpUserUtil.getLoginIdAsLong();
-        EnterprisePurchaseLeadPopupRecord record = new EnterprisePurchaseLeadPopupRecord()
-                .setUserId(userId)
-                .setPopupCount(1);
-        try {
-            enterprisePurchaseLeadPopupRecordMapper.insert(record);
-            return GatewayResponse.SUCCESS.newBuilder().toResult(true);
-        } catch (DuplicateKeyException e) {
-            return GatewayResponse.SUCCESS.newBuilder().toResult(false);
+                .in(EnterprisePurchaseLeadPopupRecord::getUserId, userIdList));
+        if (selectCount == 0) {
+            EnterprisePurchaseLeadPopupRecord record = new EnterprisePurchaseLeadPopupRecord()
+                    .setUserId(userId)
+                    .setPopupCount(1);
+            try {
+                enterprisePurchaseLeadPopupRecordMapper.insert(record);
+            } catch (DuplicateKeyException e) {
+            }
         }
+        return GatewayResponse.SUCCESS.newBuilder().toResult(selectCount == 0);
     }
 
     private String getClientIp() {