From 2ff38cf4200a2235567e8ff6f5560a7026e1f1a6 Mon Sep 17 00:00:00 2001
From: admin <weikou2014>
Date: 星期四, 23 四月 2020 14:08:56 +0800
Subject: [PATCH] 返利比例兼容

---
 fanli/src/main/java/com/yeshi/fanli/service/impl/order/InviteOrderSubsidyServiceImpl.java |  106 +++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 106 insertions(+), 0 deletions(-)

diff --git a/fanli/src/main/java/com/yeshi/fanli/service/impl/order/InviteOrderSubsidyServiceImpl.java b/fanli/src/main/java/com/yeshi/fanli/service/impl/order/InviteOrderSubsidyServiceImpl.java
new file mode 100644
index 0000000..8fa12e3
--- /dev/null
+++ b/fanli/src/main/java/com/yeshi/fanli/service/impl/order/InviteOrderSubsidyServiceImpl.java
@@ -0,0 +1,106 @@
+package com.yeshi.fanli.service.impl.order;
+
+import java.math.BigDecimal;
+import java.util.ArrayList;
+import java.util.Calendar;
+import java.util.Date;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.concurrent.ConcurrentHashMap;
+
+import javax.annotation.Resource;
+
+import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
+
+import com.yeshi.fanli.dao.mybatis.order.InviteOrderSubsidyMapper;
+import com.yeshi.fanli.entity.bus.user.HongBaoV2;
+import com.yeshi.fanli.entity.bus.user.vip.UserLevelEnum;
+import com.yeshi.fanli.entity.order.CommonOrder;
+import com.yeshi.fanli.entity.order.HongBaoOrder;
+import com.yeshi.fanli.entity.order.InviteOrderSubsidy;
+import com.yeshi.fanli.exception.order.CommonOrderException;
+import com.yeshi.fanli.exception.order.InviteOrderSubsidyException;
+import com.yeshi.fanli.service.inter.order.CommonOrderService;
+import com.yeshi.fanli.service.inter.order.HongBaoOrderService;
+import com.yeshi.fanli.service.inter.order.HongBaoV2Service;
+import com.yeshi.fanli.service.inter.order.InviteOrderSubsidyService;
+import com.yeshi.fanli.service.inter.order.OrderHongBaoMapService;
+import com.yeshi.fanli.service.inter.order.OrderHongBaoMoneyComputeService;
+import com.yeshi.fanli.service.inter.order.config.HongBaoManageService;
+import com.yeshi.fanli.service.inter.user.invite.ThreeSaleSerivce;
+import com.yeshi.fanli.service.inter.user.vip.UserVIPInfoService;
+import com.yeshi.fanli.service.manger.user.UserLevelManager;
+import com.yeshi.fanli.util.Constant;
+import com.yeshi.fanli.util.StringUtil;
+import com.yeshi.fanli.util.TimeUtil;
+import com.yeshi.fanli.util.user.UserLevelUtil;
+
+@Service
+public class InviteOrderSubsidyServiceImpl implements InviteOrderSubsidyService {
+	@Resource
+	private InviteOrderSubsidyMapper inviteOrderSubsidyMapper;
+
+	@Resource
+	private HongBaoV2Service hongBaoV2Service;
+
+	@Resource
+	private HongBaoOrderService hongBaoOrderService;
+
+	@Resource
+	private OrderHongBaoMapService orderHongBaoMapService;
+
+	@Resource
+	private CommonOrderService commonOrderService;
+
+	@Resource
+	private HongBaoManageService hongBaoManageService;
+
+	@Resource
+	private UserVIPInfoService userVIPInfoService;
+
+	@Resource
+	private UserLevelManager userLevelManager;
+
+	@Resource
+	private OrderHongBaoMoneyComputeService orderHongBaoMoneyComputeService;
+
+	@Resource
+	private ThreeSaleSerivce threeSaleSerivce;
+
+	@Override
+	public InviteOrderSubsidy getByOrderNoAndType(Long uid, String orderNo, Integer type) {
+		return inviteOrderSubsidyMapper.getByOrderNoAndType(uid, orderNo, type);
+	}
+
+
+	private void addOrderSubsidy(InviteOrderSubsidy orderSubsidy)
+			throws InviteOrderSubsidyException, CommonOrderException {
+		if (orderSubsidy.getMoney() == null || StringUtil.isNullOrEmpty(orderSubsidy.getOrderNo())
+				|| orderSubsidy.getSourceType() == null || orderSubsidy.getUid() == null)
+			throw new InviteOrderSubsidyException(1, "鏁版嵁涓嶅畬鏁�");
+		InviteOrderSubsidy old = getByOrderNoAndType(orderSubsidy.getUid(), orderSubsidy.getOrderNo(),
+				orderSubsidy.getSourceType());
+		if (old != null) {// 淇敼
+			if (old.getState() == InviteOrderSubsidy.STATE_INVALID
+					|| old.getState() == InviteOrderSubsidy.STATE_SUBSIDIZED)
+				return;
+
+			// 淇敼鐘舵��
+			InviteOrderSubsidy update = new InviteOrderSubsidy(old.getId());
+			update.setMoney(orderSubsidy.getMoney());
+			if (old.getState() == InviteOrderSubsidy.STATE_UNKNOWN) {// 鐘舵�佹湭纭畾涔嬪墠鎵嶅彲浠ユ洿鏀瑰師濮嬭ˉ璐磋祫閲�
+				update.setOriginalMoney(orderSubsidy.getOriginalMoney());
+			}
+			update.setState(orderSubsidy.getState());
+			update.setUpdateTime(new Date());
+			inviteOrderSubsidyMapper.updateByPrimaryKeySelective(update);
+		} else {// 娣诲姞
+			if (orderSubsidy.getCreateTime() == null)
+				orderSubsidy.setCreateTime(new Date());
+			inviteOrderSubsidyMapper.insertSelective(orderSubsidy);
+		}
+	}
+
+}

--
Gitblit v1.8.0