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/elme/ElmeOrderProcessServiceImpl.java |  304 +++++++++++++++++++++++++-------------------------
 1 files changed, 154 insertions(+), 150 deletions(-)

diff --git a/fanli/src/main/java/com/yeshi/fanli/service/impl/elme/ElmeOrderProcessServiceImpl.java b/fanli/src/main/java/com/yeshi/fanli/service/impl/elme/ElmeOrderProcessServiceImpl.java
index ec3536f..0cd9a9e 100644
--- a/fanli/src/main/java/com/yeshi/fanli/service/impl/elme/ElmeOrderProcessServiceImpl.java
+++ b/fanli/src/main/java/com/yeshi/fanli/service/impl/elme/ElmeOrderProcessServiceImpl.java
@@ -1,150 +1,154 @@
-package com.yeshi.fanli.service.impl.elme;
-
-import java.math.BigDecimal;
-import java.util.Date;
-
-import javax.annotation.Resource;
-
-import org.springframework.stereotype.Service;
-import org.springframework.transaction.annotation.Transactional;
-
-import com.yeshi.fanli.entity.bus.user.HongBaoV2;
-import com.yeshi.fanli.entity.bus.user.UserExtraTaoBaoInfo;
-import com.yeshi.fanli.entity.bus.user.UserInfo;
-import com.yeshi.fanli.entity.elme.ElmeHongBaoOrderMap;
-import com.yeshi.fanli.entity.elme.ElmeOrder;
-import com.yeshi.fanli.exception.elme.ElmeHongBaoOrderMapException;
-import com.yeshi.fanli.exception.elme.ElmeOrderException;
-import com.yeshi.fanli.service.inter.elme.ElmeHongBaoOrderMapService;
-import com.yeshi.fanli.service.inter.elme.ElmeOrderProcessService;
-import com.yeshi.fanli.service.inter.elme.ElmeOrderService;
-import com.yeshi.fanli.service.inter.order.HongBaoV2Service;
-import com.yeshi.fanli.service.inter.order.config.HongBaoManageService;
-import com.yeshi.fanli.service.inter.order.msg.UserOrderMsgNotificationService;
-import com.yeshi.fanli.service.inter.user.UserInfoService;
-import com.yeshi.fanli.service.inter.user.tb.UserExtraTaoBaoInfoService;
-import com.yeshi.fanli.util.Constant;
-import com.yeshi.fanli.util.MoneyBigDecimalUtil;
-import com.yeshi.fanli.util.StringUtil;
-import com.yeshi.fanli.util.elme.ElmeOrderUtil;
-
-@Service
-public class ElmeOrderProcessServiceImpl implements ElmeOrderProcessService {
-
-	@Resource
-	private ElmeOrderService elmeOrderService;
-
-	@Resource
-	private ElmeHongBaoOrderMapService elmeHongBaoOrderMapService;
-
-	@Resource
-	private UserInfoService userInfoService;
-
-	@Resource
-	private HongBaoManageService hongBaoManageService;
-
-	@Resource
-	private HongBaoV2Service hongBaoV2Service;
-
-	@Resource
-	private UserOrderMsgNotificationService userOrderMsgNotificationService;
-
-	@Resource
-	private UserExtraTaoBaoInfoService userExtraTaoBaoInfoService;
-
-	@Transactional(rollbackFor=Exception.class)
-	@Override
-	public void processOrder(ElmeOrder elmeOrder) throws ElmeOrderException {
-		try {
-			elmeOrderService.addOrder(elmeOrder);
-		} catch (ElmeOrderException e) {
-			return;
-		}
-
-		if (elmeOrder.getId() == null)
-			return;
-		// 鏌ヨ璁㈠崟鏄惁瀛樺湪
-		ElmeHongBaoOrderMap map = elmeHongBaoOrderMapService.selectByOrderId(elmeOrder.getId());
-		if (map == null)// 璁㈠崟涓嶅瓨鍦�
-		{
-			Long uid = null;
-			if (StringUtil.isNullOrEmpty(elmeOrder.getChannelId())) {//鏂扮増鏈�
-				UserExtraTaoBaoInfo extra = userExtraTaoBaoInfoService.getByRelationId(elmeOrder.getRid());
-				if (extra != null)
-					uid = extra.getUser().getId();
-			} else {//鑰佺増鏈�
-				uid = Long.parseLong(elmeOrder.getRid());
-			}
-
-			if (uid == null)
-				return;
-
-			// 鏌ヨ鏄犲皠鐢ㄦ埛
-			UserInfo user = userInfoService.selectByPKey(uid);
-			if (user == null)
-				return;
-			// 鍒堕�爃ongbao
-			HongBaoV2 hongBao = createHongBao(elmeOrder, user);
-			hongBao.setUpdateTime(new Date());
-			hongBaoV2Service.insertSelective(hongBao);
-			// 娣诲姞绾㈠寘鏄犲皠
-			ElmeHongBaoOrderMap newMap = new ElmeHongBaoOrderMap();
-			newMap.setCreateTime(new Date());
-			newMap.setElmeOrder(elmeOrder);
-			newMap.setHongBao(hongBao);
-			try {
-				elmeHongBaoOrderMapService.addHongBaoOrderMap(newMap);
-			} catch (ElmeHongBaoOrderMapException e) {
-				throw new ElmeOrderException(e.getCode(), e.getMsg());
-			}
-			
-		} else {// 璁㈠崟瀛樺湪
-			HongBaoV2 oldHongBao = hongBaoV2Service.selectByPrimaryKey(map.getHongBao().getId());
-			if (oldHongBao == null)
-				return;
-			// 澶辨晥涓庡埌璐︾姸鎬佺殑绾㈠寘涓嶉渶瑕佷慨鏀�
-			if (oldHongBao.getState() == HongBaoV2.STATE_SHIXIAO || oldHongBao.getState() == HongBaoV2.STATE_YILINGQU)
-				return;
-
-			HongBaoV2 hongBao = createHongBao(elmeOrder, null);
-			if (hongBao.getState() != oldHongBao.getState()) {// 鏄惁闇�瑕佷慨鏀圭孩鍖呯姸鎬�
-				HongBaoV2 update = new HongBaoV2(oldHongBao.getId());
-				update.setState(hongBao.getState());
-				update.setPreGetTime(hongBao.getPreGetTime());
-				update.setUpdateTime(new Date());
-				hongBaoV2Service.updateByPrimaryKeySelective(update);
-	
-			}
-		}
-
-	}
-
-	private HongBaoV2 createHongBao(ElmeOrder elmeOrder, UserInfo userInfo) {
-		BigDecimal fanliRate = hongBaoManageService.getFanLiRate(elmeOrder.getOrderDate().getTime());
-		HongBaoV2 hongBao = new HongBaoV2();
-		hongBao.setCreateTime(new Date());
-		hongBao.setGetTime(null);
-		hongBao.setMoney(MoneyBigDecimalUtil.div(
-				MoneyBigDecimalUtil.mul(ElmeOrderUtil.getCommission(elmeOrder.getPayMoney()), fanliRate),
-				new BigDecimal(100)));
-		if (elmeOrder.getIsSettle() == true)
-			hongBao.setPreGetTime(new Date(elmeOrder.getOrderDate().getTime() + 1000 * 60 * 60 * 24 * 15L));
-		if (elmeOrder.getPayMoney().compareTo(new BigDecimal(0)) <= 0||(elmeOrder.getState()!=null&&elmeOrder.getState()==0))
-			hongBao.setState(HongBaoV2.STATE_SHIXIAO);
-		else {
-			if (elmeOrder.getIsSettle() == true) {
-				hongBao.setState(HongBaoV2.STATE_KELINGQU);
-			} else {
-				hongBao.setState(HongBaoV2.STATE_BUKELINGQU);
-			}
-		}
-
-		hongBao.setType(HongBaoV2.TYPE_ELME);
-		if (userInfo != null)
-			hongBao.setUrank(userInfo.getRank());
-		hongBao.setUserInfo(userInfo);
-		hongBao.setVersion(2);
-		return hongBao;
-	}
-
-}
+package com.yeshi.fanli.service.impl.elme;
+
+import java.math.BigDecimal;
+import java.util.Date;
+
+import javax.annotation.Resource;
+
+import com.yeshi.fanli.entity.SystemEnum;
+import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
+
+import com.yeshi.fanli.entity.bus.user.HongBaoV2;
+import com.yeshi.fanli.entity.bus.user.UserExtraTaoBaoInfo;
+import com.yeshi.fanli.entity.bus.user.UserInfo;
+import com.yeshi.fanli.entity.bus.user.vip.UserLevelEnum;
+import com.yeshi.fanli.entity.elme.ElmeHongBaoOrderMap;
+import com.yeshi.fanli.entity.elme.ElmeOrder;
+import com.yeshi.fanli.exception.elme.ElmeHongBaoOrderMapException;
+import com.yeshi.fanli.exception.elme.ElmeOrderException;
+import com.yeshi.fanli.service.inter.elme.ElmeHongBaoOrderMapService;
+import com.yeshi.fanli.service.inter.elme.ElmeOrderProcessService;
+import com.yeshi.fanli.service.inter.elme.ElmeOrderService;
+import com.yeshi.fanli.service.inter.order.HongBaoV2Service;
+import com.yeshi.fanli.service.inter.order.config.HongBaoManageService;
+import com.yeshi.fanli.service.inter.order.msg.UserOrderMsgNotificationService;
+import com.yeshi.fanli.service.inter.user.UserInfoService;
+import com.yeshi.fanli.service.inter.user.tb.UserExtraTaoBaoInfoService;
+import org.yeshi.utils.MoneyBigDecimalUtil;
+import com.yeshi.fanli.util.StringUtil;
+import com.yeshi.fanli.util.elme.ElmeOrderUtil;
+
+@Service
+public class ElmeOrderProcessServiceImpl implements ElmeOrderProcessService {
+
+    @Resource
+    private ElmeOrderService elmeOrderService;
+
+    @Resource
+    private ElmeHongBaoOrderMapService elmeHongBaoOrderMapService;
+
+    @Resource
+    private UserInfoService userInfoService;
+
+    @Resource
+    private HongBaoManageService hongBaoManageService;
+
+    @Resource
+    private HongBaoV2Service hongBaoV2Service;
+
+    @Resource
+    private UserOrderMsgNotificationService userOrderMsgNotificationService;
+
+    @Resource
+    private UserExtraTaoBaoInfoService userExtraTaoBaoInfoService;
+
+    @Transactional(rollbackFor = Exception.class)
+    @Override
+    public void processOrder(ElmeOrder elmeOrder) throws ElmeOrderException {
+        try {
+            elmeOrderService.addOrder(elmeOrder);
+        } catch (ElmeOrderException e) {
+            return;
+        }
+
+        if (elmeOrder.getId() == null)
+            return;
+        // 鏌ヨ璁㈠崟鏄惁瀛樺湪
+        ElmeHongBaoOrderMap map = elmeHongBaoOrderMapService.selectByOrderId(elmeOrder.getId());
+        if (map == null)// 璁㈠崟涓嶅瓨鍦�
+        {
+            Long uid = null;
+            if (StringUtil.isNullOrEmpty(elmeOrder.getChannelId())) {// 鏂扮増鏈�
+                UserExtraTaoBaoInfo extra = userExtraTaoBaoInfoService.getByRelationId(elmeOrder.getRid(), null);
+                if (extra != null)
+                    uid = extra.getUser().getId();
+            } else {// 鑰佺増鏈�
+                uid = Long.parseLong(elmeOrder.getRid());
+            }
+
+            if (uid == null)
+                return;
+
+            // 鏌ヨ鏄犲皠鐢ㄦ埛
+            UserInfo user = userInfoService.selectByPKey(uid);
+            if (user == null)
+                return;
+            SystemEnum system = userInfoService.getUserSystem(uid);
+            // 鍒堕�爃ongbao
+            HongBaoV2 hongBao = createHongBao(elmeOrder, user, system);
+            hongBao.setUpdateTime(new Date());
+            hongBaoV2Service.insertSelective(hongBao);
+            // 娣诲姞绾㈠寘鏄犲皠
+            ElmeHongBaoOrderMap newMap = new ElmeHongBaoOrderMap();
+            newMap.setCreateTime(new Date());
+            newMap.setElmeOrder(elmeOrder);
+            newMap.setHongBao(hongBao);
+            try {
+                elmeHongBaoOrderMapService.addHongBaoOrderMap(newMap);
+            } catch (ElmeHongBaoOrderMapException e) {
+                throw new ElmeOrderException(e.getCode(), e.getMsg());
+            }
+
+        } else {// 璁㈠崟瀛樺湪
+            HongBaoV2 oldHongBao = hongBaoV2Service.selectByPrimaryKey(map.getHongBao().getId());
+            if (oldHongBao == null)
+                return;
+            // 澶辨晥涓庡埌璐︾姸鎬佺殑绾㈠寘涓嶉渶瑕佷慨鏀�
+            if (oldHongBao.getState() == HongBaoV2.STATE_SHIXIAO || oldHongBao.getState() == HongBaoV2.STATE_YILINGQU)
+                return;
+            SystemEnum system = userInfoService.getUserSystem(oldHongBao.getUserInfo().getId());
+            HongBaoV2 hongBao = createHongBao(elmeOrder, null, system);
+            if (hongBao.getState() != oldHongBao.getState()) {// 鏄惁闇�瑕佷慨鏀圭孩鍖呯姸鎬�
+                HongBaoV2 update = new HongBaoV2(oldHongBao.getId());
+                update.setState(hongBao.getState());
+                update.setPreGetTime(hongBao.getPreGetTime());
+                update.setUpdateTime(new Date());
+                hongBaoV2Service.updateByPrimaryKeySelective(update);
+
+            }
+        }
+
+    }
+
+    private HongBaoV2 createHongBao(ElmeOrder elmeOrder, UserInfo userInfo, SystemEnum system) {
+        BigDecimal fanliRate = hongBaoManageService.getFanLiRate(UserLevelEnum.daRen,
+                elmeOrder.getOrderDate().getTime(), system);
+        HongBaoV2 hongBao = new HongBaoV2();
+        hongBao.setCreateTime(new Date());
+        hongBao.setGetTime(null);
+        hongBao.setMoney(MoneyBigDecimalUtil.div(
+                MoneyBigDecimalUtil.mul(ElmeOrderUtil.getCommission(elmeOrder.getPayMoney()), fanliRate),
+                new BigDecimal(100)));
+        if (elmeOrder.getIsSettle() == true)
+            hongBao.setPreGetTime(new Date(elmeOrder.getOrderDate().getTime() + 1000 * 60 * 60 * 24 * 15L));
+        if (elmeOrder.getPayMoney().compareTo(new BigDecimal(0)) <= 0
+                || (elmeOrder.getState() != null && elmeOrder.getState() == 0))
+            hongBao.setState(HongBaoV2.STATE_SHIXIAO);
+        else {
+            if (elmeOrder.getIsSettle() == true) {
+                hongBao.setState(HongBaoV2.STATE_KELINGQU);
+            } else {
+                hongBao.setState(HongBaoV2.STATE_BUKELINGQU);
+            }
+        }
+
+        hongBao.setType(HongBaoV2.TYPE_ELME);
+        if (userInfo != null)
+            hongBao.setUrank(userInfo.getRank());
+        hongBao.setUserInfo(userInfo);
+        hongBao.setVersion(2);
+        return hongBao;
+    }
+
+}

--
Gitblit v1.8.0