From 30d8e227e8d823b6c38c3b9c90ac2df03b63befe Mon Sep 17 00:00:00 2001
From: admin <weikou2014>
Date: 星期二, 25 二月 2025 16:41:22 +0800
Subject: [PATCH] 淘宝转链接口更新

---
 fanli/src/main/java/com/yeshi/fanli/service/impl/user/invite/UserGetIntegralFromOrderRecordServiceImpl.java |  115 +++++++++++++++++++++++++++++++++------------------------
 1 files changed, 66 insertions(+), 49 deletions(-)

diff --git a/fanli/src/main/java/com/yeshi/fanli/service/impl/user/invite/UserGetIntegralFromOrderRecordServiceImpl.java b/fanli/src/main/java/com/yeshi/fanli/service/impl/user/invite/UserGetIntegralFromOrderRecordServiceImpl.java
index 10d1b51..6fce9fb 100644
--- a/fanli/src/main/java/com/yeshi/fanli/service/impl/user/invite/UserGetIntegralFromOrderRecordServiceImpl.java
+++ b/fanli/src/main/java/com/yeshi/fanli/service/impl/user/invite/UserGetIntegralFromOrderRecordServiceImpl.java
@@ -1,49 +1,66 @@
-package com.yeshi.fanli.service.impl.user.invite;
-
-import java.util.Date;
-
-import javax.annotation.Resource;
-
-import org.springframework.stereotype.Service;
-import org.springframework.transaction.annotation.Transactional;
-
-import com.yeshi.fanli.dao.mybatis.integral.UserGetIntegralFromOrderRecordMapper;
-import com.yeshi.fanli.entity.integral.UserGetIntegralFromOrderRecord;
-import com.yeshi.fanli.exception.integral.UserGetIntegralFromOrderRecordException;
-import com.yeshi.fanli.service.inter.user.integral.UserGetIntegralFromOrderRecordService;
-import com.yeshi.fanli.util.StringUtil;
-
-@Service
-public class UserGetIntegralFromOrderRecordServiceImpl implements UserGetIntegralFromOrderRecordService {
-
-	@Resource
-	private UserGetIntegralFromOrderRecordMapper userGetIntegralFromOrderRecordMapper;
-
-	@Override
-	public long countByEventTypeAndUidAndOrderInfo(int eventType, Long uid, String orderNo, int orderSourceType) {
-		UserGetIntegralFromOrderRecord record = new UserGetIntegralFromOrderRecord();
-		record.setEventType(eventType);
-		record.setOrderNo(orderNo);
-		record.setOrderSourceType(orderSourceType);
-		record.setUid(uid);
-		return userGetIntegralFromOrderRecordMapper.countByRecordInfo(record);
-	}
-
-	@Transactional
-	@Override
-	public void addRecord(UserGetIntegralFromOrderRecord record) throws UserGetIntegralFromOrderRecordException {
-		if (record == null || record.getUid() == null || record.getEventType() == null
-				|| StringUtil.isNullOrEmpty(record.getOrderNo()) || record.getOrderSourceType() == null)
-			throw new UserGetIntegralFromOrderRecordException(1, "淇℃伅涓嶅畬鏁�");
-
-		long count = countByEventTypeAndUidAndOrderInfo(record.getEventType(), record.getUid(), record.getOrderNo(),
-				record.getOrderSourceType());
-		if (count > 0)
-			throw new UserGetIntegralFromOrderRecordException(2, "璁板綍宸插瓨鍦�");
-
-		if (record.getCreateTime() == null)
-			record.setCreateTime(new Date());
-		userGetIntegralFromOrderRecordMapper.insertSelective(record);
-	}
-
-}
+package com.yeshi.fanli.service.impl.user.invite;
+
+import java.util.Date;
+
+import javax.annotation.Resource;
+
+import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
+
+import com.yeshi.fanli.dao.mybatis.integral.UserGetIntegralFromOrderRecordMapper;
+import com.yeshi.fanli.entity.integral.UserGetIntegralFromOrderRecord;
+import com.yeshi.fanli.exception.integral.UserGetIntegralFromOrderRecordException;
+import com.yeshi.fanli.manager.util.AtomMethodCallInterface;
+import com.yeshi.fanli.manager.util.AtomMethodCallManager;
+import com.yeshi.fanli.service.inter.user.integral.UserGetIntegralFromOrderRecordService;
+import com.yeshi.fanli.util.StringUtil;
+
+import redis.clients.jedis.Jedis;
+import redis.clients.jedis.JedisPool;
+
+@Service
+public class UserGetIntegralFromOrderRecordServiceImpl implements UserGetIntegralFromOrderRecordService {
+
+	@Resource
+	private UserGetIntegralFromOrderRecordMapper userGetIntegralFromOrderRecordMapper;
+
+	@Resource
+	private AtomMethodCallManager atomMethodCallManager;
+
+	@Override
+	public long countByEventTypeAndUidAndOrderInfo(int eventType, Long uid, String orderNo, int orderSourceType) {
+		UserGetIntegralFromOrderRecord record = new UserGetIntegralFromOrderRecord();
+		record.setEventType(eventType);
+		record.setOrderNo(orderNo);
+		record.setOrderSourceType(orderSourceType);
+		record.setUid(uid);
+		return userGetIntegralFromOrderRecordMapper.countByRecordInfo(record);
+	}
+
+	@Transactional(rollbackFor=Exception.class)
+	@Override
+	public void addRecord(UserGetIntegralFromOrderRecord record) throws UserGetIntegralFromOrderRecordException {
+		if (record == null || record.getUid() == null || record.getEventType() == null
+				|| StringUtil.isNullOrEmpty(record.getOrderNo()) || record.getOrderSourceType() == null)
+			throw new UserGetIntegralFromOrderRecordException(1, "淇℃伅涓嶅畬鏁�");
+
+		String key = String.format("rs-%s",
+				StringUtil.Md5(String.format("UserGetIntegralFromOrderRecord-addRecord-%s-%s-%s-%s", record.getUid(),
+						record.getEventType(), record.getOrderNo(), record.getOrderSourceType())));
+
+		atomMethodCallManager.excute(key, new AtomMethodCallInterface() {
+
+			@Override
+			public void excute() {
+				long count = countByEventTypeAndUidAndOrderInfo(record.getEventType(), record.getUid(),
+						record.getOrderNo(), record.getOrderSourceType());
+				if (count > 0)
+					return;
+				if (record.getCreateTime() == null)
+					record.setCreateTime(new Date());
+				userGetIntegralFromOrderRecordMapper.insertSelective(record);
+			}
+		});
+	}
+
+}

--
Gitblit v1.8.0