From 98b1a0affd69bbe63223c21fdd2c404e8bedfccb Mon Sep 17 00:00:00 2001
From: admin <weikou2014>
Date: 星期三, 20 五月 2020 17:25:08 +0800
Subject: [PATCH] Merge remote-tracking branch 'origin/div' into 2.1.2

---
 fanli/src/main/java/com/yeshi/fanli/service/impl/order/config/HongBaoManageServiceImpl.java |  172 +++++++++++++--------------------------------------------
 1 files changed, 40 insertions(+), 132 deletions(-)

diff --git a/fanli/src/main/java/com/yeshi/fanli/service/impl/order/config/HongBaoManageServiceImpl.java b/fanli/src/main/java/com/yeshi/fanli/service/impl/order/config/HongBaoManageServiceImpl.java
index 8718a37..45b1b16 100644
--- a/fanli/src/main/java/com/yeshi/fanli/service/impl/order/config/HongBaoManageServiceImpl.java
+++ b/fanli/src/main/java/com/yeshi/fanli/service/impl/order/config/HongBaoManageServiceImpl.java
@@ -13,10 +13,8 @@
 
 import com.yeshi.fanli.dao.mybatis.HongBaoManageMapper;
 import com.yeshi.fanli.dto.ConfigParamsDTO;
-import com.yeshi.fanli.dto.order.OrderHongBaoRateParams;
 import com.yeshi.fanli.entity.bus.user.HongBaoManage;
-import com.yeshi.fanli.entity.order.CommonOrder;
-import com.yeshi.fanli.exception.order.HongBaoException;
+import com.yeshi.fanli.entity.bus.user.vip.UserLevelEnum;
 import com.yeshi.fanli.log.LogHelper;
 import com.yeshi.fanli.service.inter.order.config.HongBaoManageService;
 import com.yeshi.fanli.util.Constant;
@@ -39,7 +37,7 @@
 	public String get(final String key) {
 		HongBaoManage hongBaoManage = hongBaoManageMapper.selectByKey(key);
 		if (hongBaoManage != null)
-			hongBaoManage.getValue();
+			return hongBaoManage.getValue();
 		return null;
 	}
 
@@ -61,6 +59,11 @@
 		return null;
 	}
 
+	@Cacheable(value = "homeBaoManage", key = "'getByKeyAndMaxTime-'+#key+'-'+#time")
+	public BigDecimal getByKeyAndMaxTimeCache(String key, Long time) {
+		return getByKeyAndMaxTime(key, time);
+	}
+
 	@Cacheable(value = "homeBaoManage", key = "'convertMap'")
 	public Map<String, String> convertMap() {
 		List<HongBaoManage> list = hongBaoManageMapper.listAll();
@@ -72,38 +75,34 @@
 	}
 
 	@Override
-	public BigDecimal getFanLiRate(long time) {
-		String key = "hongbao_goods_proportion";
+	public BigDecimal getFanLiRate(UserLevelEnum level, long time) {
 
-		HongBaoManage hongBaoManage = hongBaoManageMapper.selectByKeyAndMaxValidTime(key, time);
-		if (hongBaoManage == null)
-			hongBaoManage = hongBaoManageMapper.selectByKey(key);
-		if (hongBaoManage != null)
-			return new BigDecimal(hongBaoManage.getValue());
-		LogHelper.error("鑾峰彇杩斿埄鍒嗘垚姣斾緥鍑洪敊");
-		return null;
+		return getBaseFanliRate(time).add(new BigDecimal(get("official_subsidy_zigou_" + level.getLevel())));
 	}
 
 	@Override
-	public BigDecimal getShareRate(long time) {
-		String key = "share_proportion";
-		HongBaoManage hongBaoManage = hongBaoManageMapper.selectByKeyAndMaxValidTime(key, time);
-		if (hongBaoManage == null)
-			hongBaoManage = hongBaoManageMapper.selectByKey(key);
-		if (hongBaoManage != null)
-			return new BigDecimal(hongBaoManage.getValue());
-		LogHelper.error("鑾峰彇鍒嗕韩璧氬垎鎴愭瘮渚嬪嚭閿�");
-		return null;
+	public BigDecimal getShareRate(UserLevelEnum level, long time) {
+		return getBaseFanliRate(time).add(new BigDecimal(get("official_subsidy_share_" + level.getLevel())));
+	}
+
+	@Override
+	public BigDecimal getFanLiRate(UserLevelEnum level) {
+		return getFanLiRate(level, System.currentTimeMillis());
 	}
 
 	@Override
 	public BigDecimal getFanLiRate() {
-		return getFanLiRate(System.currentTimeMillis());
+		return getFanLiRate(UserLevelEnum.daRen);
+	}
+
+	@Override
+	public BigDecimal getShareRate(UserLevelEnum level) {
+		return getShareRate(level, System.currentTimeMillis());
 	}
 
 	@Override
 	public BigDecimal getShareRate() {
-		return getShareRate(System.currentTimeMillis());
+		return getShareRate(UserLevelEnum.daRen);
 	}
 
 	@Override
@@ -236,122 +235,25 @@
 	}
 
 	@Override
-	public BigDecimal getVIPFanLiRate(long time) {
-		String key = "hongbao_goods_proportion_vip";
-		HongBaoManage hongBaoManage = hongBaoManageMapper.selectByKeyAndMaxValidTime(key, time);
-		if (hongBaoManage == null)
-			hongBaoManage = hongBaoManageMapper.selectByKey(key);
-		if (hongBaoManage != null)
-			return new BigDecimal(hongBaoManage.getValue());
-		LogHelper.error("鑾峰彇杩斿埄鍒嗘垚姣斾緥鍑洪敊");
-		return null;
-	}
+	public ConfigParamsDTO getShowComputeRate(String platform, String version, UserLevelEnum userLevel) {
 
-	@Override
-	public BigDecimal getVIPShareRate(long time) {
-		String key = "share_proportion_vip";
-		HongBaoManage hongBaoManage = hongBaoManageMapper.selectByKeyAndMaxValidTime(key, time);
-		if (hongBaoManage == null)
-			hongBaoManage = hongBaoManageMapper.selectByKey(key);
-		if (hongBaoManage != null)
-			return new BigDecimal(hongBaoManage.getValue());
-		LogHelper.error("鑾峰彇杩斿埄鍒嗘垚姣斾緥鍑洪敊");
-		return null;
-	}
-
-	@Override
-	public BigDecimal getVIPFanLiRate() {
-		return getVIPFanLiRate(System.currentTimeMillis());
-	}
-
-	@Override
-	public BigDecimal getVIPShareRate() {
-		return getVIPShareRate(System.currentTimeMillis());
-	}
-
-	/**
-	 * 鑾峰彇姣斾緥
-	 * 
-	 * @param level
-	 *            0-鏈骇 1-涓嬬骇 2-涓嬩笅绾�
-	 * @param orderType
-	 * @param isVip鏈骇鏄惁涓篤IP
-	 * @param isWorkerVip涓嬬骇鏄惁涓篤IP
-	 * @return
-	 */
-	public BigDecimal getRate(OrderHongBaoRateParams params) throws HongBaoException {
-		if (params == null)
-			throw new HongBaoException(1, "姣斾緥鍙傛暟閿欒");
-
-		long time = params.getOrderCreateTime().getTime();
-
-		if (params.getLevel() == 0) {// 鏈骇
-
-			if (params.getOrderType() == CommonOrder.ORDER_TYPE_ZIGOU) {
-				if (params.isVip())
-					return getVIPFanLiRate(time);
-				else
-					return getFanLiRate(time);
-			} else {
-				if (params.isVip())
-					return getVIPShareRate(time);
-				else
-					return getShareRate(time);
-			}
-
-		} else if (params.getLevel() == 1) {// 涓婄骇
-			if (params.getOrderType() == CommonOrder.ORDER_TYPE_ZIGOU) {// 鑷喘
-				if (params.isSubsidy()) {// 琛ヨ创姣斾緥
-					if (params.isVip()) {// 涓嬬骇涓轰細鍛樹笉琛ヨ创
-						return new BigDecimal("0");
-					} else {
-						return getInviteFirstLevelSubsidyRate(time);
-					}
-				} else {// 濂栭噾姣斾緥
-					if (params.isVip()) {
-						return getByKeyAndMaxTime("new_invite_vip_6", time);
-					} else {
-						return getByKeyAndMaxTime("new_invite_6", time);
-					}
-				}
-			} else {// 鍒嗕韩
-				if (params.isVip()) {
-					return getByKeyAndMaxTime("new_share_vip_21", time);
-				} else {
-					return getByKeyAndMaxTime("new_share_21", time);
-				}
-			}
-		} else if (params.getLevel() == 2) {// 涓婁笂绾�
-			if (params.getOrderType() == CommonOrder.ORDER_TYPE_ZIGOU) {// 鑷喘
-				if (params.isSubsidy()) {// 琛ヨ创姣斾緥
-					if (params.isVip()) {// 涓嬩笅绾т负浼氬憳涓嶈ˉ璐�
-						return new BigDecimal("0");
-					} else {
-						return getInviteSecondLevelSubsidyRate(time);
-					}
-				} else {// 濂栭噾姣斾緥
-					if (params.isVip())
-						return new BigDecimal("0");
-					else
-						return getByKeyAndMaxTime("new_invite_7", time);
-				}
-			} else {// 鍒嗕韩
-				if (params.isVip())
-					return new BigDecimal("0");
-				else
-					return getByKeyAndMaxTime("new_share_22", time);
-			}
+		BigDecimal fanLiRate = getFanLiRate(userLevel);
+		BigDecimal shareRate = getShareRate(userLevel);
+		ConfigParamsDTO paramsDTO = new ConfigParamsDTO(fanLiRate, shareRate, Constant.MAX_REWARD_RATE,
+				getFanLiRate(UserLevelEnum.superVIP));
+		if (VersionUtil.greaterThan_2_0_5(platform, version)) {
+			paramsDTO.setMaxRewardRate(null);
 		}
-		throw new HongBaoException(2, "鏈尮閰嶅埌姣斾緥鍙傛暟");
+		return paramsDTO;
 	}
 
 	@Override
 	public ConfigParamsDTO getShowComputeRate(String platform, String version) {
 
-		BigDecimal fanLiRate = getFanLiRate();
-		BigDecimal shareRate = getShareRate();
+		BigDecimal fanLiRate = getFanLiRate(UserLevelEnum.daRen);
+		BigDecimal shareRate = getShareRate(UserLevelEnum.daRen);
 		ConfigParamsDTO paramsDTO = new ConfigParamsDTO(fanLiRate, shareRate, Constant.MAX_REWARD_RATE,
-				getVIPFanLiRate());
+				getFanLiRate(UserLevelEnum.superVIP));
 		if (VersionUtil.greaterThan_2_0_5(platform, version)) {
 			paramsDTO.setMaxRewardRate(null);
 		}
@@ -374,5 +276,11 @@
 	public BigDecimal getBaseFanliRate() {
 		return getBaseFanliRate(System.currentTimeMillis());
 	}
+	
+	@Cacheable(value = "homeBaoManage", key = "'getBaseFanliRate'+#time")
+	@Override
+	public BigDecimal getBaseFanliRateCache(long time) {
+		return getBaseFanliRate(System.currentTimeMillis());
+	}
 
 }

--
Gitblit v1.8.0