|
@@ -7,6 +7,7 @@ import com.cyksj.mapper.enterprise.EnterprisePurchaseLeadPopupRecordMapper;
|
|
|
import com.cyksj.model.entity.EnterprisePurchaseLeadPopupRecord;
|
|
import com.cyksj.model.entity.EnterprisePurchaseLeadPopupRecord;
|
|
|
import com.cyksj.model.request.EnterprisePurchaseLeadSubmitReq;
|
|
import com.cyksj.model.request.EnterprisePurchaseLeadSubmitReq;
|
|
|
import com.cyksj.service.enterprise.EnterprisePurchaseLeadService;
|
|
import com.cyksj.service.enterprise.EnterprisePurchaseLeadService;
|
|
|
|
|
+import com.cyksj.service.user.UserBindRelationService;
|
|
|
import com.cyksj.web.util.StpUserUtil;
|
|
import com.cyksj.web.util.StpUserUtil;
|
|
|
import lombok.RequiredArgsConstructor;
|
|
import lombok.RequiredArgsConstructor;
|
|
|
import org.springframework.dao.DuplicateKeyException;
|
|
import org.springframework.dao.DuplicateKeyException;
|
|
@@ -18,6 +19,7 @@ import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
import org.springframework.web.bind.annotation.RestController;
|
|
import org.springframework.web.bind.annotation.RestController;
|
|
|
|
|
|
|
|
import javax.servlet.http.HttpServletRequest;
|
|
import javax.servlet.http.HttpServletRequest;
|
|
|
|
|
+import java.util.List;
|
|
|
|
|
|
|
|
@RestController
|
|
@RestController
|
|
|
@RequiredArgsConstructor
|
|
@RequiredArgsConstructor
|
|
@@ -30,6 +32,8 @@ public class EnterprisePurchaseLeadFrontController {
|
|
|
|
|
|
|
|
private final HttpServletRequest request;
|
|
private final HttpServletRequest request;
|
|
|
|
|
|
|
|
|
|
+ private final UserBindRelationService userBindRelationService;
|
|
|
|
|
+
|
|
|
@PostMapping
|
|
@PostMapping
|
|
|
public Result<Long> submit(@RequestBody @Validated EnterprisePurchaseLeadSubmitReq req) {
|
|
public Result<Long> submit(@RequestBody @Validated EnterprisePurchaseLeadSubmitReq req) {
|
|
|
Long id = enterprisePurchaseLeadService.submit(req, getClientIp(), request.getHeader("User-Agent"));
|
|
Long id = enterprisePurchaseLeadService.submit(req, getClientIp(), request.getHeader("User-Agent"));
|
|
@@ -42,26 +46,19 @@ public class EnterprisePurchaseLeadFrontController {
|
|
|
@GetMapping("/popup/visible")
|
|
@GetMapping("/popup/visible")
|
|
|
public Result<Boolean> popupVisible() {
|
|
public Result<Boolean> popupVisible() {
|
|
|
long userId = StpUserUtil.getLoginIdAsLong();
|
|
long userId = StpUserUtil.getLoginIdAsLong();
|
|
|
|
|
+ List<Long> userIdList = userBindRelationService.getRelationUserIdList(userId, null);
|
|
|
Integer selectCount = enterprisePurchaseLeadPopupRecordMapper.selectCount(Wrappers.lambdaQuery(EnterprisePurchaseLeadPopupRecord.class)
|
|
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() {
|
|
private String getClientIp() {
|