zoujiajian 1 year ago
parent
commit
e0febf897d

+ 24 - 23
netflix-service/src/main/java/com/cyksj/service/coin/impl/UserGalaxyCoinServiceImpl.java

@@ -33,24 +33,30 @@ public class UserGalaxyCoinServiceImpl implements UserGalaxyCoinService {
 	@Override
 	public void sendGalaxyCoinRecord(Long userId, Integer galaxyCoin, String remark, Boolean isLottery) {
 		if (!isLottery) {
-			if (galaxyCoin <= 0) {
-				return;
+			sendGalaxyCoinHandle(userId, null, galaxyCoin, remark, true);
+		}
+	}
+
+	public void sendGalaxyCoinHandle(Long userId, Long orderId, Integer galaxyCoin, String remark, Boolean isRecord) {
+		if (galaxyCoin <= 0) {
+			return;
+		}
+		while (true) {
+			User user = userMapper.selectById(userId);
+			if (user == null) {
+				log.error("用户:{}不存在,无法发送银河币", userId);
+				break;
 			}
-			while (true) {
-				User user = userMapper.selectById(userId);
-				if (user == null) {
-					log.error("用户:{}不存在,无法发送银河币", userId);
-					break;
-				}
-				BigDecimal userGalaxyCoin = user.getGalaxyCoin();
-				int update = userMapper.update(null, Wrappers.lambdaUpdate(User.class)
-						.set(User::getGalaxyCoin, userGalaxyCoin.add(BigDecimal.valueOf(galaxyCoin)))
-						.eq(User::getId, user.getId())
-						.eq(User::getGalaxyCoin, userGalaxyCoin));
-				if (update == 1) {
-					recordSendGalaxyCoin(userId, galaxyCoin, remark);
-					break;
+			BigDecimal userGalaxyCoin = user.getGalaxyCoin();
+			int update = userMapper.update(null, Wrappers.lambdaUpdate(User.class)
+					.set(User::getGalaxyCoin, userGalaxyCoin.add(BigDecimal.valueOf(galaxyCoin)))
+					.eq(User::getId, user.getId())
+					.eq(User::getGalaxyCoin, userGalaxyCoin));
+			if (update == 1) {
+				if (isRecord) {
+					recordUseRecord(userId, orderId, BigDecimal.valueOf(galaxyCoin), remark);
 				}
+				break;
 			}
 		}
 	}
@@ -97,13 +103,8 @@ public class UserGalaxyCoinServiceImpl implements UserGalaxyCoinService {
 			log.info("该笔订单:{}银河币有效期:{}已过", orderId, userGalaxyCoinRecord.getExpiryTime());
 			return;
 		}
-		recordUseRecord(orderId, userId, galaxyCoin, PointsRecordConst.ORDER_REFUND);
+		//发送银河币
+		sendGalaxyCoinHandle(userId, orderId, galaxyCoin.intValue(), PointsRecordConst.ORDER_REFUND, true);
 	}
 
-	/**
-	 * 记录发送银河币
-	 */
-	private void recordSendGalaxyCoin(Long userId, Integer galaxyCoin, String remark) {
-		recordUseRecord(null, userId, BigDecimal.valueOf(galaxyCoin), remark);
-	}
 }