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/redpack/RedPackForbidServiceImpl.java |  339 +++++++++++++++++++++++++++++---------------------------
 1 files changed, 177 insertions(+), 162 deletions(-)

diff --git a/fanli/src/main/java/com/yeshi/fanli/service/impl/redpack/RedPackForbidServiceImpl.java b/fanli/src/main/java/com/yeshi/fanli/service/impl/redpack/RedPackForbidServiceImpl.java
index 999197c..c57b80d 100644
--- a/fanli/src/main/java/com/yeshi/fanli/service/impl/redpack/RedPackForbidServiceImpl.java
+++ b/fanli/src/main/java/com/yeshi/fanli/service/impl/redpack/RedPackForbidServiceImpl.java
@@ -1,162 +1,177 @@
-package com.yeshi.fanli.service.impl.redpack;
-
-import java.math.BigDecimal;
-import java.util.Date;
-import java.util.List;
-
-import javax.annotation.Resource;
-
-import org.springframework.stereotype.Service;
-import org.springframework.transaction.annotation.Transactional;
-import org.yeshi.utils.DateUtil;
-
-import com.google.gson.Gson;
-import com.yeshi.fanli.dao.mybatis.redpack.RedPackForbidMapper;
-import com.yeshi.fanli.dto.msg.MsgRedPackExchangeContentDTO;
-import com.yeshi.fanli.entity.bus.msg.MsgMoneyDetail.MsgTypeMoneyTypeEnum;
-import com.yeshi.fanli.entity.redpack.RedPackBalance;
-import com.yeshi.fanli.entity.redpack.RedPackForbid;
-import com.yeshi.fanli.entity.redpack.RedPackForbidRecord;
-import com.yeshi.fanli.exception.redpack.RedPackBalanceException;
-import com.yeshi.fanli.exception.redpack.RedPackDetailException;
-import com.yeshi.fanli.exception.redpack.RedPackForbidException;
-import com.yeshi.fanli.service.inter.money.msg.UserMoneyMsgNotificationService;
-import com.yeshi.fanli.service.inter.redpack.RedPackBalanceService;
-import com.yeshi.fanli.service.inter.redpack.RedPackForbidRecordService;
-import com.yeshi.fanli.service.inter.redpack.RedPackForbidService;
-import com.yeshi.fanli.util.factory.RedPackDetailFactory;
-
-@Service
-public class RedPackForbidServiceImpl implements RedPackForbidService {
-
-	@Resource
-	private RedPackForbidMapper redPackForbidMapper;
-	
-	@Resource
-	private RedPackForbidRecordService redPackForbidRecordService;
-	
-	@Resource
-	private RedPackBalanceService redPackBalanceService;
-	
-	@Resource
-	private UserMoneyMsgNotificationService userMoneyMsgNotificationService;
-	
-	
-	@Override
-	@Transactional(rollbackFor = Exception.class)
-	public void addForbid(RedPackForbidRecord record) throws RedPackForbidException {
-		Long uid = record.getUid();
-		if (uid == null || uid <= 0)
-			throw new RedPackForbidException(1,"鐢ㄦ埛id涓嶈兘涓虹┖");
-		
-		Integer type = record.getType();
-		if (type == null)
-			throw new RedPackForbidException(1,"灏佺鏃堕棿涓嶈兘涓虹┖");
-		
-		String time = null;
-		Date endTime = null;
-		Date nowTime = new Date();
-		if (type == RedPackForbidRecord.TYPE_ONE_MONTH) {
-			time = "1涓湀";
-			endTime = DateUtil.plusMonths(nowTime, 1);
-		} else if (type == RedPackForbidRecord.TYPE_THREE_MONTH) {
-			time = "3涓湀";
-			endTime = DateUtil.plusMonths(nowTime, 3);
-		} else if (type == RedPackForbidRecord.TYPE_SIX_MONTH) {
-			time = "鍗婂勾";
-			endTime = DateUtil.plusMonths(nowTime, 6);
-		} else if (type == RedPackForbidRecord.TYPE_ONE_YEAR) {
-			time = "1骞�";
-			endTime = DateUtil.plusYears(nowTime, 1);
-		} else if (type == RedPackForbidRecord.TYPE_HUNDRED_YEAR) {
-			time = "姘镐箙";
-			endTime = DateUtil.plusYears(nowTime, 100);
-		} else {
-			throw new RedPackForbidException(1,"灏佺鏃堕棿绫诲瀷涓嶆纭�");
-		}
-	
-		// 鏌ヨ浣欓
-		BigDecimal balance = new BigDecimal(0);
-		RedPackBalance redPackBalance = redPackBalanceService.selectForUpdate(uid);
-		if (redPackBalance != null && redPackBalance.getMoney() != null)
-			balance = redPackBalance.getMoney();
-		
-		// 鍔犲叆灏佺
-		RedPackForbid redPackForbid = new RedPackForbid();
-		redPackForbid.setId(uid);
-		redPackForbid.setEndTime(endTime);
-		redPackForbid.setCreateTime(nowTime);
-		redPackForbidMapper.insertSelective(redPackForbid);
-		
-		// 鍔犲叆灏佺璁板綍
-		record.setEndTime(endTime);
-		record.setMoney(balance);
-		record.setCreateTime(nowTime);
-		redPackForbidRecordService.insertSelective(record);
-		
-		// 娓呯┖绾㈠寘
-		try {
-			redPackBalanceService.resetRedPack(uid, RedPackDetailFactory.createForbid(record));
-		} catch (RedPackBalanceException e) {
-			throw new RedPackForbidException(1, e.getMsg());
-		} catch (RedPackDetailException e) {
-			throw new RedPackForbidException(1, e.getMsg());
-		}
-		
-		//娑堟伅
-		MsgRedPackExchangeContentDTO dto = new MsgRedPackExchangeContentDTO();
-		dto.setTime(time);
-		dto.setReason("绾㈠寘浜х敓銆佷娇鐢ㄣ�佽禒閫佺幆鑺傛秹瀚岃繚瑙�");
-		dto.setHandle("娓呯┖鎵�鏈夌孩鍖呬綑棰�");
-		userMoneyMsgNotificationService.redPackMsg(record.getUid(), MsgTypeMoneyTypeEnum.redPackForbid, new Gson().toJson(dto), "灏佺淇℃伅鏃犳硶鐢宠瘔锛岃鎸夌収瑙勫垯浣跨敤绾㈠寘鍔熻兘");
-	}
-
-	
-	@Override
-	@Transactional(rollbackFor = Exception.class)
-	public void deduct(RedPackForbidRecord record) throws RedPackForbidException {
-		Long uid = record.getUid();
-		if (uid == null || uid <= 0)
-			throw new RedPackForbidException(1,"鐢ㄦ埛id涓嶈兘涓虹┖");
-		
-		BigDecimal money = record.getMoney();
-		if (money == null)
-			throw new RedPackForbidException(1,"鎵i櫎閲戦涓嶈兘涓虹┖");
-		
-		// 娓呯┖绾㈠寘
-		try {
-			redPackBalanceService.subRedPack(uid, money, RedPackDetailFactory.createDeduct(record));
-		} catch (RedPackBalanceException e) {
-			throw new RedPackForbidException(1, e.getMsg());
-		} catch (RedPackDetailException e) {
-			throw new RedPackForbidException(1, e.getMsg());
-		}
-	}
-	
-	@Override
-	public void delete(List<Long> idsList) {
-		if (idsList != null)
-			for (Long id : idsList)
-				redPackForbidMapper.deleteByPrimaryKey(id);
-
-	}
-	
-	@Override
-	public boolean verifyForbid(Long uid) {
-		if (uid != null) {
-			RedPackForbid redPackForbid = redPackForbidMapper.selectByPrimaryKey(uid);
-			if (redPackForbid != null) {
-				if (redPackForbid.getEndTime() == null || redPackForbid.getEndTime().getTime() > java.lang.System.currentTimeMillis()) {
-					return true;
-				} else {
-					// 鏃堕棿宸茶繃锛岃В闄ゅ皝绂�
-					redPackForbidMapper.deleteByPrimaryKey(uid);
-					return false;
-				}
-			}
-		}
-		return false;
-	}
-	
-	
-}
+package com.yeshi.fanli.service.impl.redpack;
+
+import java.math.BigDecimal;
+import java.util.Date;
+import java.util.List;
+
+import javax.annotation.Resource;
+
+import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
+import org.yeshi.utils.DateUtil;
+
+import com.google.gson.Gson;
+import com.yeshi.fanli.dao.mybatis.redpack.RedPackForbidMapper;
+import com.yeshi.fanli.dto.msg.MsgRedPackExchangeContentDTO;
+import com.yeshi.fanli.entity.bus.msg.MsgMoneyDetail.MsgTypeMoneyTypeEnum;
+import com.yeshi.fanli.entity.redpack.RedPackBalance;
+import com.yeshi.fanli.entity.redpack.RedPackForbid;
+import com.yeshi.fanli.entity.redpack.RedPackForbidRecord;
+import com.yeshi.fanli.exception.redpack.RedPackBalanceException;
+import com.yeshi.fanli.exception.redpack.RedPackDetailException;
+import com.yeshi.fanli.exception.redpack.RedPackForbidException;
+import com.yeshi.fanli.service.inter.money.msg.UserMoneyMsgNotificationService;
+import com.yeshi.fanli.service.inter.redpack.RedPackBalanceService;
+import com.yeshi.fanli.service.inter.redpack.RedPackForbidRecordService;
+import com.yeshi.fanli.service.inter.redpack.RedPackForbidService;
+import com.yeshi.fanli.util.factory.RedPackDetailFactory;
+
+@Service
+public class RedPackForbidServiceImpl implements RedPackForbidService {
+
+	@Resource
+	private RedPackForbidMapper redPackForbidMapper;
+	
+	@Resource
+	private RedPackForbidRecordService redPackForbidRecordService;
+	
+	@Resource
+	private RedPackBalanceService redPackBalanceService;
+	
+	@Resource
+	private UserMoneyMsgNotificationService userMoneyMsgNotificationService;
+	
+	
+	@Override
+	@Transactional(rollbackFor = Exception.class)
+	public void addForbid(RedPackForbidRecord record) throws RedPackForbidException {
+		Long uid = record.getUid();
+		if (uid == null || uid <= 0)
+			throw new RedPackForbidException(1,"鐢ㄦ埛id涓嶈兘涓虹┖");
+		
+		Integer type = record.getType();
+		if (type == null)
+			throw new RedPackForbidException(1,"灏佺鏃堕棿涓嶈兘涓虹┖");
+		
+		String time = null;
+		Date endTime = null;
+		Date nowTime = new Date();
+		if (type == RedPackForbidRecord.TYPE_ONE_MONTH) {
+			time = "1涓湀";
+			endTime = DateUtil.plusMonths(nowTime, 1);
+		} else if (type == RedPackForbidRecord.TYPE_THREE_MONTH) {
+			time = "3涓湀";
+			endTime = DateUtil.plusMonths(nowTime, 3);
+		} else if (type == RedPackForbidRecord.TYPE_SIX_MONTH) {
+			time = "鍗婂勾";
+			endTime = DateUtil.plusMonths(nowTime, 6);
+		} else if (type == RedPackForbidRecord.TYPE_ONE_YEAR) {
+			time = "1骞�";
+			endTime = DateUtil.plusYears(nowTime, 1);
+		} else if (type == RedPackForbidRecord.TYPE_HUNDRED_YEAR) {
+			time = "姘镐箙";
+			endTime = DateUtil.plusYears(nowTime, 100);
+		} else {
+			throw new RedPackForbidException(1,"灏佺鏃堕棿绫诲瀷涓嶆纭�");
+		}
+	
+		// 鏌ヨ浣欓
+		BigDecimal balance = new BigDecimal(0);
+		RedPackBalance redPackBalance = redPackBalanceService.selectForUpdate(uid);
+		if (redPackBalance != null && redPackBalance.getMoney() != null)
+			balance = redPackBalance.getMoney();
+		
+		// 鍔犲叆灏佺
+		RedPackForbid redPackForbid = new RedPackForbid();
+		redPackForbid.setId(uid);
+		redPackForbid.setEndTime(endTime);
+		redPackForbid.setCreateTime(nowTime);
+		redPackForbidMapper.insertSelective(redPackForbid);
+		
+		// 鍔犲叆灏佺璁板綍
+		record.setEndTime(endTime);
+		record.setMoney(balance);
+		record.setCreateTime(nowTime);
+		redPackForbidRecordService.insertSelective(record);
+		
+		// 娓呯┖绾㈠寘
+		try {
+			redPackBalanceService.resetRedPack(uid, RedPackDetailFactory.createForbid(record));
+		} catch (RedPackBalanceException e) {
+			throw new RedPackForbidException(1, e.getMsg());
+		} catch (RedPackDetailException e) {
+			throw new RedPackForbidException(1, e.getMsg());
+		}
+		
+		//娑堟伅
+		MsgRedPackExchangeContentDTO dto = new MsgRedPackExchangeContentDTO();
+		dto.setTime(time);
+		dto.setReason("绾㈠寘浜х敓銆佷娇鐢ㄣ�佽禒閫佺幆鑺傛秹瀚岃繚瑙�");
+		dto.setHandle("娓呯┖鎵�鏈夌孩鍖呬綑棰�");
+		userMoneyMsgNotificationService.redPackMsg(uid, MsgTypeMoneyTypeEnum.redPackForbid, new Gson().toJson(dto), "灏佺鏃犳硶鐢宠瘔锛岃鎸夌収瑙勫垯浣跨敤绾㈠寘鍔熻兘");
+	}
+
+	
+	@Override
+	@Transactional(rollbackFor = Exception.class)
+	public void deduct(RedPackForbidRecord record) throws RedPackForbidException {
+		Long uid = record.getUid();
+		if (uid == null || uid <= 0)
+			throw new RedPackForbidException(1,"鐢ㄦ埛id涓嶈兘涓虹┖");
+		
+		BigDecimal money = record.getMoney();
+		if (money == null)
+			throw new RedPackForbidException(1,"鎵i櫎閲戦涓嶈兘涓虹┖");
+		
+		// 娓呯┖绾㈠寘
+		try {
+			redPackBalanceService.subRedPack(uid, money, RedPackDetailFactory.createDeduct(record));
+		} catch (RedPackBalanceException e) {
+			throw new RedPackForbidException(1, e.getMsg());
+		} catch (RedPackDetailException e) {
+			throw new RedPackForbidException(1, e.getMsg());
+		}
+		
+		//娑堟伅
+		MsgRedPackExchangeContentDTO dto = new MsgRedPackExchangeContentDTO();
+		dto.setBalance(redPackBalanceService.getBalance(uid).setScale(2).toString());
+		dto.setMoney(money.setScale(2).toString());
+		dto.setReason("绾㈠寘浜х敓銆佷娇鐢ㄣ�佽禒閫佺幆鑺傛秹瀚岃繚瑙�");
+		userMoneyMsgNotificationService.redPackMsg(uid, MsgTypeMoneyTypeEnum.redPackDeduct, new Gson().toJson(dto), "鎵i櫎閲戦鏃犳硶鐢宠瘔锛岃鎸夌収瑙勫垯鑾峰緱绾㈠寘");
+	}
+	
+	@Override
+	public void delete(List<Long> idsList) {
+		if (idsList != null)
+			for (Long id : idsList) {
+				redPackForbidMapper.deleteByPrimaryKey(id);
+				//娑堟伅
+				MsgRedPackExchangeContentDTO dto = new MsgRedPackExchangeContentDTO();
+				dto.setReason("灏佺鏃堕棿鍒版湡锛岃嚜鍔ㄨВ灏�");
+				dto.setTime("宸插彲浠ラ噸鏂颁娇鐢ㄧ孩鍖呭姛鑳�");
+				dto.setHandle("宸茶娓呯┖");
+				userMoneyMsgNotificationService.redPackMsg(id, MsgTypeMoneyTypeEnum.redPackForbidRemove, 
+						new Gson().toJson(dto), null);
+			}
+
+	}
+	
+	@Override
+	public boolean verifyForbid(Long uid) {
+		if (uid != null) {
+			RedPackForbid redPackForbid = redPackForbidMapper.selectByPrimaryKey(uid);
+			if (redPackForbid != null) {
+				if (redPackForbid.getEndTime() == null || redPackForbid.getEndTime().getTime() > java.lang.System.currentTimeMillis()) {
+					return true;
+				} else {
+					// 鏃堕棿宸茶繃锛岃В闄ゅ皝绂�
+					redPackForbidMapper.deleteByPrimaryKey(uid);
+					return false;
+				}
+			}
+		}
+		return false;
+	}
+	
+	
+}

--
Gitblit v1.8.0