From 81feea14dbcfe3344961a435a37d24630bcbcc43 Mon Sep 17 00:00:00 2001
From: yujian <yujian@163.com>
Date: 星期二, 12 五月 2020 17:45:09 +0800
Subject: [PATCH] 队员统计
---
fanli/src/main/java/com/yeshi/fanli/service/impl/order/config/HongBaoManageServiceImpl.java | 199 +++++++++++++++++--------------------------------
1 files changed, 70 insertions(+), 129 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 86ab526..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
@@ -12,12 +12,13 @@
import org.springframework.transaction.annotation.Transactional;
import com.yeshi.fanli.dao.mybatis.HongBaoManageMapper;
-import com.yeshi.fanli.dto.order.OrderHongBaoRateParams;
+import com.yeshi.fanli.dto.ConfigParamsDTO;
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;
+import com.yeshi.fanli.util.VersionUtil;
@Service
public class HongBaoManageServiceImpl implements HongBaoManageService {
@@ -36,7 +37,7 @@
public String get(final String key) {
HongBaoManage hongBaoManage = hongBaoManageMapper.selectByKey(key);
if (hongBaoManage != null)
- hongBaoManage.getValue();
+ return hongBaoManage.getValue();
return null;
}
@@ -58,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();
@@ -69,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
@@ -233,113 +235,52 @@
}
@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(UserLevelEnum.daRen);
+ BigDecimal shareRate = getShareRate(UserLevelEnum.daRen);
+ ConfigParamsDTO paramsDTO = new ConfigParamsDTO(fanLiRate, shareRate, Constant.MAX_REWARD_RATE,
+ getFanLiRate(UserLevelEnum.superVIP));
+ if (VersionUtil.greaterThan_2_0_5(platform, version)) {
+ paramsDTO.setMaxRewardRate(null);
+ }
+ return paramsDTO;
+ }
+
+ @Override
+ public BigDecimal getBaseFanliRate(long time) {
+ String key = "base_fanli_rate";
+ 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 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