Selaa lähdekoodia

用户购买设备意向

zoujiajian 2 vuotta sitten
vanhempi
sitoutus
ed5bd92a73

+ 13 - 0
netflix-dao/src/main/java/com/cyksj/mapper/corp/CorpUserPayIntentionMapper.java

@@ -0,0 +1,13 @@
+package com.cyksj.mapper.corp;
+
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.cyksj.model.entity.CorpUserPayIntention;
+
+/**
+ * 项目名: yhlxj
+ * 文件名: CorpUserPayIntentionMapper
+ * 创建者: JavaZou
+ * 创建时间:2024/5/7 17:04
+ */
+public interface CorpUserPayIntentionMapper extends BaseMapper<CorpUserPayIntention> {
+}

+ 21 - 0
netflix-dao/src/main/java/com/cyksj/model/entity/CorpUserPayIntention.java

@@ -0,0 +1,21 @@
+package com.cyksj.model.entity;
+
+import lombok.Getter;
+import lombok.Setter;
+
+/**
+ * 项目名: yhlxj
+ * 文件名: CorpUserPayIntention
+ * 创建者: JavaZou
+ * 创建时间:2024/5/7 17:01
+ */
+@Getter
+@Setter
+public class CorpUserPayIntention extends BaseEntity {
+	private String unionId;
+
+	/**
+	 * 意向 0无回复 1无意向 2.问相关问题 3有意向 4很有意向
+	 */
+	private Integer intention;
+}

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

@@ -22,7 +22,7 @@ public class CorpUserIntentionView {
 	private String nickname;
 
 	/**
-	 * 意向 0无意向 1有意向 2很有意向
+	 * 意向 0无回复 1无意向 2.问相关问题 3有意向 4很有意向
 	 */
 	private Integer intention;
 

+ 6 - 0
netflix-service/src/main/java/com/cyksj/service/corp/CorpService.java

@@ -3,6 +3,7 @@ package com.cyksj.service.corp;
 import com.cyksj.dto.CorpOauth2UserInfo;
 import com.cyksj.model.entity.CorpCustomerAcquistionCallback;
 import com.cyksj.model.entity.CorpFollow;
+import com.cyksj.model.entity.CorpUserPayIntention;
 import com.cyksj.model.request.corp.Attachments;
 
 /*
@@ -50,4 +51,9 @@ public interface CorpService {
 	 */
 	void upCallbackIntention(CorpCustomerAcquistionCallback corpCustomerAcquistionCallback);
 
+	/**
+	 * 修改用户购买意愿
+	 * @param corpUserPayIntention
+	 */
+	void updateUserIntention(CorpUserPayIntention corpUserPayIntention);
 }

+ 18 - 4
netflix-service/src/main/java/com/cyksj/service/corp/impl/CorpServiceImpl.java

@@ -15,11 +15,9 @@ import com.cyksj.config.corp.YHLXWxCorpConfig;
 import com.cyksj.dto.CorpOauth2UserInfo;
 import com.cyksj.mapper.corp.CorpCustomerAcquistionCallbackMapper;
 import com.cyksj.mapper.corp.CorpFollowMapper;
+import com.cyksj.mapper.corp.CorpUserPayIntentionMapper;
 import com.cyksj.model.dto.WxCorpEncryptDto;
-import com.cyksj.model.entity.CorpCustomerAcquistionCallback;
-import com.cyksj.model.entity.CorpFollow;
-import com.cyksj.model.entity.OrderDonPost;
-import com.cyksj.model.entity.WxCorpApp;
+import com.cyksj.model.entity.*;
 import com.cyksj.model.request.corp.Attachments;
 import com.cyksj.model.request.corp.CorpXmlMessage;
 import com.cyksj.model.request.corp.CorpXmlOutMessage;
@@ -36,6 +34,7 @@ import com.cyksj.util.WxCorpUtil;
 import lombok.extern.slf4j.Slf4j;
 import org.apache.commons.lang3.StringUtils;
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.dao.DuplicateKeyException;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
 
@@ -80,6 +79,9 @@ public class CorpServiceImpl implements CorpService {
 	@Autowired
 	private CorpCustomerAcquistionCallbackMapper corpCustomerAcquistionCallbackMapper;
 
+	@Autowired
+	private CorpUserPayIntentionMapper corpUserPayIntentionMapper;
+
 	@PostConstruct
 	private void init() {
 		corpMessageRouter = new CorpMessageRouter(this)
@@ -372,4 +374,16 @@ public class CorpServiceImpl implements CorpService {
 	public void upCallbackIntention(CorpCustomerAcquistionCallback corpCustomerAcquistionCallback) {
 		corpCustomerAcquistionCallbackMapper.update(null, Wrappers.lambdaUpdate(CorpCustomerAcquistionCallback.class).eq(CorpCustomerAcquistionCallback::getId, corpCustomerAcquistionCallback.getId()).set(CorpCustomerAcquistionCallback::getIntention, corpCustomerAcquistionCallback.getIntention()));
 	}
+
+	@Override
+	public void updateUserIntention(CorpUserPayIntention corpUserPayIntention) {
+		if (corpUserPayIntention.getId() == null) {
+			try {
+				corpUserPayIntentionMapper.insert(corpUserPayIntention);
+			} catch (DuplicateKeyException e) {
+			}
+			return;
+		}
+		corpUserPayIntentionMapper.updateById(corpUserPayIntention);
+	}
 }

+ 33 - 4
netflix-web/src/main/java/com/cyksj/web/controller/manage/corp/WxCorpController.java

@@ -21,10 +21,7 @@ import com.cyksj.mapper.GroupsRelationExpiryRecordMapper;
 import com.cyksj.mapper.corp.CorpUserAuthMapper;
 import com.cyksj.mapper.corp.CorpUserTagMapper;
 import com.cyksj.model.dto.AuthRedirect;
-import com.cyksj.model.entity.CorpCustomerAcquistionCallback;
-import com.cyksj.model.entity.CorpFollow;
-import com.cyksj.model.entity.CorpMsgFollowAssociation;
-import com.cyksj.model.entity.QyMsgContent;
+import com.cyksj.model.entity.*;
 import com.cyksj.model.manage.views.CorpQyMsgAuditChatView;
 import com.cyksj.model.request.corp.CorpCommonReq;
 import com.cyksj.model.views.CorpUserIntentionView;
@@ -339,6 +336,38 @@ public class WxCorpController {
 		return GatewayResponse.SUCCESS.newBuilder().toResult(corpCustomerAcquistionCallback);
 	}
 
+	/**
+	 * 查询用户 购买意愿
+	 */
+	@GetMapping("/get/user/intention")
+	public Result<CorpUserPayIntention> getUserIntention(String externalUserId) {
+		if (StrUtil.isEmpty(externalUserId)) {
+			return GatewayResponse.SUCCESS.newBuilder().toResult();
+		}
+		String unionId = corpUserAuthMapper.getUnionIdByExternalUserId(externalUserId);
+		if (StrUtil.isEmpty(unionId)) {
+			return GatewayResponse.SUCCESS.newBuilder().toResult();
+		}
+		MapBuilder builder = MapUtils.flatBuilder(request.getParameterMap()).field(CorpUserPayIntention::getUnionId, unionId);
+		CorpUserPayIntention corpUserPayIntention = Optional.ofNullable(beanSearcher.searchFirst(CorpUserPayIntention.class, builder.build()))
+				.orElseGet(() -> {
+					CorpUserPayIntention corpUserPayIntention1 = new CorpUserPayIntention();
+					corpUserPayIntention1.setUnionId(unionId);
+					corpUserPayIntention1.setIntention(0);
+					return corpUserPayIntention1;
+				});
+		return GatewayResponse.SUCCESS.newBuilder().toResult(corpUserPayIntention);
+	}
+
+	@PutMapping("/update/user/intention")
+	public Result<CorpUserPayIntention> updateUserIntention(@RequestBody CorpUserPayIntention corpUserPayIntention) {
+		if (corpUserPayIntention.getUnionId() == null || corpUserPayIntention.getIntention() == null) {
+			throw BusinessRuntimeException.getInstance("缺少必填参数.");
+		}
+		corpService.updateUserIntention(corpUserPayIntention);
+		return GatewayResponse.SUCCESS.newBuilder().toResult(corpUserPayIntention);
+	}
+
 	/**
 	 * 主动回传
 	 *