From afe61a27c4f77db65df66b0ff5dc93cbd3e0014b Mon Sep 17 00:00:00 2001
From: admin <weikou2014>
Date: 星期二, 09 六月 2020 17:49:57 +0800
Subject: [PATCH] Merge remote-tracking branch 'origin/div' into div
---
fanli/src/main/java/com/yeshi/fanli/service/impl/order/HongBaoV2ServiceImpl.java | 287 ++++++++++++++++++++++++++++++++++----------------------
1 files changed, 173 insertions(+), 114 deletions(-)
diff --git a/fanli/src/main/java/com/yeshi/fanli/service/impl/order/HongBaoV2ServiceImpl.java b/fanli/src/main/java/com/yeshi/fanli/service/impl/order/HongBaoV2ServiceImpl.java
index 25d557f..7303b65 100644
--- a/fanli/src/main/java/com/yeshi/fanli/service/impl/order/HongBaoV2ServiceImpl.java
+++ b/fanli/src/main/java/com/yeshi/fanli/service/impl/order/HongBaoV2ServiceImpl.java
@@ -13,6 +13,7 @@
import javax.annotation.Resource;
+import org.springframework.context.annotation.Lazy;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
@@ -25,18 +26,22 @@
import com.yeshi.fanli.dao.mybatis.taobao.TaoBaoWeiQuanOrderMapper;
import com.yeshi.fanli.dto.HongBao;
import com.yeshi.fanli.dto.HongBaoDTO;
+import com.yeshi.fanli.dto.order.HongBaoAddResult;
import com.yeshi.fanli.entity.bus.user.HongBaoV2;
import com.yeshi.fanli.entity.bus.user.ThreeSale;
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.order.CommonOrder;
import com.yeshi.fanli.entity.order.CommonOrderGoods;
import com.yeshi.fanli.entity.order.HongBaoOrder;
import com.yeshi.fanli.entity.order.ShareGoodsActivityOrder;
+import com.yeshi.fanli.entity.system.ConfigKeyEnum;
import com.yeshi.fanli.entity.taobao.TaoBaoOrder;
import com.yeshi.fanli.exception.order.HongBaoException;
import com.yeshi.fanli.exception.order.ShareGoodsActivityOrderException;
import com.yeshi.fanli.exception.share.UserShareGoodsRecordException;
+import com.yeshi.fanli.exception.user.UserAccountException;
import com.yeshi.fanli.log.LogHelper;
import com.yeshi.fanli.service.inter.config.ConfigService;
import com.yeshi.fanli.service.inter.order.CommonOrderService;
@@ -107,6 +112,7 @@
@Resource
private UserExtraTaoBaoInfoService userExtraTaoBaoInfoService;
+ @Lazy
@Resource
private UserSystemCouponService userSystemCouponService;
@@ -143,16 +149,19 @@
return hongBaoV2Mapper.selectByPrimaryKey(id);
}
- @Transactional
+ @Transactional(rollbackFor = Exception.class)
@Override
- public void addHongBao(List<CommonOrder> commonOrderList, int type) throws HongBaoException {
+ public HongBaoAddResult addHongBao(List<CommonOrder> commonOrderList, int type)
+ throws HongBaoException, UserAccountException {
Set<Integer> stateSet = new HashSet<>();// 璁㈠崟鐘舵�丼et
if (commonOrderList != null && commonOrderList.size() > 0) {
int orderType = commonOrderList.get(0).getSourceType();
+ boolean miandan = false;
Map<Integer, HongBaoOrder> notificationMap = new HashMap<>();
int goodsCount = 0;
boolean hasAdd = false;
+ boolean hasUpdate = false;
for (CommonOrder commonOrder : commonOrderList) {
stateSet.add(commonOrder.getState());
goodsCount += commonOrder.getCount();
@@ -160,12 +169,15 @@
throw new HongBaoException(1, "璁㈠崟淇℃伅涓嶅畬鏁�");
HongBaoOrder hongBaoOrder = hongBaoOrderMapper.selectByCommonOrderId(commonOrder.getId());
if (hongBaoOrder == null) {
- saveHongBao(commonOrder, type, notificationMap);
+ miandan = saveHongBao(commonOrder, type, notificationMap);
hasAdd = true;
} else {
- updateHongBao(hongBaoOrder, commonOrder, type, notificationMap);
+ boolean update = updateHongBao(hongBaoOrder, commonOrder, type, notificationMap);
+ if (update)
+ hasUpdate = true;
}
}
+
/**
* 閫氱煡鐢ㄦ埛鐨勮繑鍒╂儏鍐�
*/
@@ -182,68 +194,52 @@
switch (t) {
case HongBaoV2.TYPE_ZIGOU:
userOrderMsgNotificationService.orderFanLiStatistic(uid, orderId, orderType,
- commonOrder.getPayment(), money, goodsCount, state);
+ commonOrder.getPayment(), money, goodsCount, commonOrder.getState(),
+ commonOrder.getThirdCreateTime());
+
break;
case HongBaoV2.TYPE_SHARE_GOODS:
userOrderMsgNotificationService.orderShareStatistic(uid, orderId, orderType,
- commonOrder.getPayment(), money, goodsCount, state);
+ commonOrder.getPayment(), money, goodsCount, commonOrder.getState(),
+ commonOrder.getThirdCreateTime());
+
break;
case HongBaoV2.TYPE_YIJI:
-
userOrderMsgNotificationService.orderInviteStatistic(uid, orderId, orderType,
- commonOrder.getPayment(), money, goodsCount, state);
+ commonOrder.getPayment(), money, new BigDecimal(0), goodsCount, commonOrder.getState(),
+ commonOrder.getThirdCreateTime());
break;
case HongBaoV2.TYPE_ERJI:
-
userOrderMsgNotificationService.orderInviteStatistic(uid, orderId, orderType,
- commonOrder.getPayment(), money, goodsCount, state);
+ commonOrder.getPayment(), money, new BigDecimal(0), goodsCount, commonOrder.getState(),
+ commonOrder.getThirdCreateTime());
break;
case HongBaoV2.TYPE_SHARE_YIJI:
- userOrderMsgNotificationService.orderShareFirstLevelStatistic(uid, orderId, orderType,
- commonOrder.getPayment(), money, goodsCount, state, notify.getBeizhu());
+ userOrderMsgNotificationService.orderInviteStatistic(uid, orderId, orderType,
+ commonOrder.getPayment(), money, new BigDecimal(0), goodsCount, commonOrder.getState(),
+ commonOrder.getThirdCreateTime());
+
+ case HongBaoV2.TYPE_SHARE_ERJI:
+ userOrderMsgNotificationService.orderInviteStatistic(uid, orderId, orderType,
+ commonOrder.getPayment(), money, new BigDecimal(0), goodsCount, commonOrder.getState(),
+ commonOrder.getThirdCreateTime());
break;
}
}
}
- // 娣诲姞鏂扮増鏈�氱煡
-
- if (!hasAdd) {
- Iterator<Integer> its = notificationMap.keySet().iterator();
- while (its.hasNext()) {
- Integer t = its.next();
- HongBaoV2 notify = notificationMap.get(t).getHongBaoV2();
- CommonOrder commonOrder = notificationMap.get(t).getCommonOrder();
- String orderId = commonOrderList.get(0).getOrderNo();
- Long uid = notify.getUserInfo().getId();
- BigDecimal money = notify.getMoney();
- switch (t) {
- case HongBaoV2.TYPE_ZIGOU:
- userOrderMsgNotificationService.orderFanLiStateChanged(uid, orderId, orderType,
- commonOrder.getPayment(), money, state);
- break;
- case HongBaoV2.TYPE_SHARE_GOODS:
- userOrderMsgNotificationService.orderShareStateChanged(uid, orderId, orderType,
- commonOrder.getPayment(), money, state);
- break;
- case HongBaoV2.TYPE_YIJI:
- userOrderMsgNotificationService.orderInviteStateChanged(uid, orderId, orderType,
- commonOrder.getPayment(), money, state);
- break;
- case HongBaoV2.TYPE_ERJI:
- userOrderMsgNotificationService.orderInviteStateChanged(uid, orderId, orderType,
- commonOrder.getPayment(), money, state);
- break;
- case HongBaoV2.TYPE_SHARE_YIJI:
- userOrderMsgNotificationService.orderShareFirstLevelStateChanged(uid, orderId, orderType,
- commonOrder.getPayment(), money, state);
- }
- }
- }
+ int resultCode = 0;
+ if (hasAdd && hasUpdate)
+ return new HongBaoAddResult(HongBaoAddResult.CODE_ADD_AND_UPDATE, miandan);
+ else if (hasAdd)
+ return new HongBaoAddResult(HongBaoAddResult.CODE_ADD, miandan);
+ else if (hasUpdate)
+ return new HongBaoAddResult(HongBaoAddResult.CODE_UPDATE, miandan);
+ return new HongBaoAddResult(resultCode, miandan);
}
-
+ return new HongBaoAddResult(0, false);
}
private int getOrderState(Set<Integer> states) {
@@ -260,9 +256,9 @@
return CommonOrder.STATE_SX;
}
- @Transactional
- private void updateHongBao(HongBaoOrder hongBaoOrder, CommonOrder commonOrder, int type,
- Map<Integer, HongBaoOrder> notificationMap) throws HongBaoException {
+ @Transactional(rollbackFor = Exception.class)
+ private boolean updateHongBao(HongBaoOrder hongBaoOrder, CommonOrder commonOrder, int type,
+ Map<Integer, HongBaoOrder> notificationMap) throws HongBaoException, UserAccountException {
System.out.println(commonOrder.getOrderNo());
// 閿佽
HongBaoV2 oldHongBao = hongBaoV2Mapper.selectByPrimaryKeyForUpdate(hongBaoOrder.getHongBaoV2().getId());
@@ -270,10 +266,11 @@
throw new HongBaoException(10, "绾㈠寘瀵硅薄涓嶅瓨鍦�");
// 宸茬粡澶辨晥锛屽凡缁忛鍙栵紝鏂拌�佺姸鎬佷竴鑷寸殑绾㈠寘涓嶅仛澶勭悊
if (oldHongBao.getState() == HongBaoV2.STATE_SHIXIAO || oldHongBao.getState() == HongBaoV2.STATE_YILINGQU)
- return;
+ return false;
if (type == HongBaoV2.TYPE_ZIGOU) {// 鑾峰彇鑷喘鐨勮繑鍒╂瘮渚�
- BigDecimal fanliRate = hongBaoManageService.getFanLiRate(commonOrder.getCreateTime().getTime());
+ BigDecimal fanliRate = hongBaoManageService.getFanLiRate(UserLevelEnum.daRen,
+ commonOrder.getCreateTime().getTime());
// 鍏嶅崟澶勭悊
boolean mianDan = false;
List<CommonOrder> orderList = commonOrderService.listBySourceTypeAndOrderId(Constant.SOURCE_TYPE_TAOBAO,
@@ -298,7 +295,8 @@
MoneyBigDecimalUtil.mul(commonOrder.getEstimate(), fanliRate.divide(new BigDecimal(100))));
if (mianDan)
hongBao.setMoney(commonOrder.getPayment());
- } else if (commonOrder.getState() == CommonOrder.STATE_JS) {
+ } else if (commonOrder.getState() == CommonOrder.STATE_JS
+ || commonOrder.getState() == CommonOrder.STATE_WQ) {
hongBao.setState(HongBaoV2.STATE_KELINGQU);
hongBao.setMoney(
MoneyBigDecimalUtil.mul(commonOrder.geteIncome(), fanliRate.divide(new BigDecimal(100))));
@@ -317,7 +315,7 @@
// 鏂拌�佺孩鍖呯姸鎬佷竴鑷翠笉澶勭悊
if (oldHongBao.getState().intValue() == hongBao.getState())
- return;
+ return false;
if (hongBao.getState() == HongBaoV2.STATE_SHIXIAO) {
if (mianDan) {
@@ -354,6 +352,9 @@
List<HongBaoV2> children = hongBaoV2Mapper.listChildrenById(hongBao.getId());
if (children != null && children.size() > 0)
for (HongBaoV2 child : children) {
+ if (child.getState() == HongBaoV2.STATE_YILINGQU)
+ continue;
+
HongBaoV2 childUpdate = new HongBaoV2(child.getId());
childUpdate.setState(hongBao.getState());
childUpdate.setUpdateTime(new Date());
@@ -411,7 +412,7 @@
BigDecimal firstRate = hongBaoManageService
.getFirstInviteRate(boss.getRank() == null ? 0 : boss.getRank());
if (firstRate.compareTo(new BigDecimal(0)) <= 0)
- return;
+ return true;
HongBaoV2 firstHongbao = new HongBaoV2();
firstHongbao.setUserInfo(boss);
firstHongbao.setUrank(boss.getRank());
@@ -420,6 +421,7 @@
firstHongbao.setType(HongBaoV2.TYPE_YIJI);
firstHongbao.setVersion(2);
firstHongbao.setState(hongBao.getState());
+ firstHongbao.setOrderType(commonOrder.getSourceType());
if (hongBao.getState() == HongBaoV2.STATE_KELINGQU) {
firstHongbao.setMoney(
@@ -433,24 +435,31 @@
} else if (hongBao.getState() == HongBaoV2.STATE_BUKELINGQU) {
firstHongbao.setMoney(
MoneyBigDecimalUtil.mul(hongBao.getMoney(), firstRate.divide(new BigDecimal(100))));
+ } else if (hongBao.getState() == HongBaoV2.STATE_SHIXIAO) {
+ firstHongbao.setMoney(new BigDecimal(0));
}
- hongBaoV2Mapper.insertSelective(firstHongbao);
- // 鐢ㄦ埛閫氱煡
- if (notificationMap.get(HongBaoV2.TYPE_YIJI) == null) {
- HongBaoV2 tempHongBao = new HongBaoV2(firstHongbao.getId());
- tempHongBao.setUserInfo(firstHongbao.getUserInfo());
- tempHongBao.setMoney(firstHongbao.getMoney());
- CommonOrder tempCommonOrder = new CommonOrder(commonOrder.getId());
- tempCommonOrder.setPayment(commonOrder.getPayment());
- notificationMap.put(HongBaoV2.TYPE_YIJI, new HongBaoOrder(tempCommonOrder, tempHongBao));
- } else {
- // 澧炲姞浠樻閲戦涓庤祫閲�
- HongBaoOrder tempHongBaoOrder = notificationMap.get(HongBaoV2.TYPE_YIJI);
- tempHongBaoOrder.getCommonOrder().setPayment(
- tempHongBaoOrder.getCommonOrder().getPayment().add(commonOrder.getPayment()));
- tempHongBaoOrder.getHongBaoV2()
- .setMoney(tempHongBaoOrder.getHongBaoV2().getMoney().add(firstHongbao.getMoney()));
- notificationMap.put(HongBaoV2.TYPE_YIJI, tempHongBaoOrder);
+
+ if (firstHongbao.getMoney() != null
+ && firstHongbao.getMoney().compareTo(new BigDecimal(0)) > 0) {
+ hongBaoV2Mapper.insertSelective(firstHongbao);
+ // 鐢ㄦ埛閫氱煡
+ if (notificationMap.get(HongBaoV2.TYPE_YIJI) == null) {
+ HongBaoV2 tempHongBao = new HongBaoV2(firstHongbao.getId());
+ tempHongBao.setUserInfo(firstHongbao.getUserInfo());
+ tempHongBao.setMoney(firstHongbao.getMoney());
+ CommonOrder tempCommonOrder = new CommonOrder(commonOrder.getId());
+ tempCommonOrder.setPayment(commonOrder.getPayment());
+ notificationMap.put(HongBaoV2.TYPE_YIJI,
+ new HongBaoOrder(tempCommonOrder, tempHongBao));
+ } else {
+ // 澧炲姞浠樻閲戦涓庤祫閲�
+ HongBaoOrder tempHongBaoOrder = notificationMap.get(HongBaoV2.TYPE_YIJI);
+ tempHongBaoOrder.getCommonOrder().setPayment(
+ tempHongBaoOrder.getCommonOrder().getPayment().add(commonOrder.getPayment()));
+ tempHongBaoOrder.getHongBaoV2().setMoney(
+ tempHongBaoOrder.getHongBaoV2().getMoney().add(firstHongbao.getMoney()));
+ notificationMap.put(HongBaoV2.TYPE_YIJI, tempHongBaoOrder);
+ }
}
// 鎻掑叆浜岀骇瀛愮孩鍖�
@@ -459,7 +468,7 @@
BigDecimal secondRate = hongBaoManageService
.getSecondInviteRate(boss.getRank() == null ? 0 : boss.getRank());
if (secondRate.compareTo(new BigDecimal(0)) <= 0)
- return;
+ return true;
HongBaoV2 secondHongbao = new HongBaoV2();
secondHongbao.setUserInfo(boss);
secondHongbao.setUrank(boss.getRank());
@@ -468,6 +477,7 @@
secondHongbao.setType(HongBaoV2.TYPE_ERJI);
secondHongbao.setVersion(2);
secondHongbao.setState(hongBao.getState());
+ secondHongbao.setOrderType(commonOrder.getSourceType());
if (hongBao.getState() == HongBaoV2.STATE_KELINGQU) {
secondHongbao.setMoney(MoneyBigDecimalUtil.mul(hongBao.getMoney(),
secondRate.divide(new BigDecimal(100))));
@@ -480,26 +490,29 @@
} else if (hongBao.getState() == HongBaoV2.STATE_BUKELINGQU) {
secondHongbao.setMoney(MoneyBigDecimalUtil.mul(hongBao.getMoney(),
secondRate.divide(new BigDecimal(100))));
- }
- hongBaoV2Mapper.insertSelective(secondHongbao);
-
- // 鐢ㄦ埛閫氱煡
- if (notificationMap.get(HongBaoV2.TYPE_ERJI) == null) {
- HongBaoV2 tempHongBao = new HongBaoV2(secondHongbao.getId());
- tempHongBao.setUserInfo(secondHongbao.getUserInfo());
- tempHongBao.setMoney(secondHongbao.getMoney());
- CommonOrder tempCommonOrder = new CommonOrder(commonOrder.getId());
- tempCommonOrder.setPayment(commonOrder.getPayment());
- notificationMap.put(HongBaoV2.TYPE_ERJI,
- new HongBaoOrder(tempCommonOrder, tempHongBao));
- } else {
- // 澧炲姞浠樻閲戦涓庤祫閲�
- HongBaoOrder tempHongBaoOrder = notificationMap.get(HongBaoV2.TYPE_ERJI);
- tempHongBaoOrder.getCommonOrder().setPayment(
- tempHongBaoOrder.getCommonOrder().getPayment().add(commonOrder.getPayment()));
- tempHongBaoOrder.getHongBaoV2().setMoney(
- tempHongBaoOrder.getHongBaoV2().getMoney().add(secondHongbao.getMoney()));
- notificationMap.put(HongBaoV2.TYPE_ERJI, tempHongBaoOrder);
+ } else if (hongBao.getState() == HongBaoV2.STATE_SHIXIAO)
+ secondHongbao.setMoney(new BigDecimal(0));
+ if (secondHongbao.getMoney() != null
+ && secondHongbao.getMoney().compareTo(new BigDecimal(0)) > 0) {
+ hongBaoV2Mapper.insertSelective(secondHongbao);
+ // 鐢ㄦ埛閫氱煡
+ if (notificationMap.get(HongBaoV2.TYPE_ERJI) == null) {
+ HongBaoV2 tempHongBao = new HongBaoV2(secondHongbao.getId());
+ tempHongBao.setUserInfo(secondHongbao.getUserInfo());
+ tempHongBao.setMoney(secondHongbao.getMoney());
+ CommonOrder tempCommonOrder = new CommonOrder(commonOrder.getId());
+ tempCommonOrder.setPayment(commonOrder.getPayment());
+ notificationMap.put(HongBaoV2.TYPE_ERJI,
+ new HongBaoOrder(tempCommonOrder, tempHongBao));
+ } else {
+ // 澧炲姞浠樻閲戦涓庤祫閲�
+ HongBaoOrder tempHongBaoOrder = notificationMap.get(HongBaoV2.TYPE_ERJI);
+ tempHongBaoOrder.getCommonOrder().setPayment(tempHongBaoOrder.getCommonOrder()
+ .getPayment().add(commonOrder.getPayment()));
+ tempHongBaoOrder.getHongBaoV2().setMoney(
+ tempHongBaoOrder.getHongBaoV2().getMoney().add(secondHongbao.getMoney()));
+ notificationMap.put(HongBaoV2.TYPE_ERJI, tempHongBaoOrder);
+ }
}
}
}
@@ -511,7 +524,8 @@
&& commonOrder.getSourcePosition().equalsIgnoreCase(TaoBaoConstant.TAOBAO_TLJ_RELATION_PID_DEFAULT))
fanliRate = hongBaoManageService.getTLJShareRate(commonOrder.getCreateTime().getTime());
else
- fanliRate = hongBaoManageService.getShareRate(commonOrder.getCreateTime().getTime());
+ fanliRate = hongBaoManageService.getShareRate(UserLevelEnum.daRen,
+ commonOrder.getCreateTime().getTime());
List<ShareGoodsActivityOrder> list = shareGoodsActivityOrderService
.listByOrderIdAndUid(commonOrder.getUserInfo().getId(), commonOrder.getOrderNo());
@@ -526,7 +540,8 @@
hongBao.setState(HongBaoV2.STATE_BUKELINGQU);
hongBao.setMoney(
MoneyBigDecimalUtil.mul(commonOrder.getEstimate(), fanliRate.divide(new BigDecimal(100))));
- } else if (commonOrder.getState() == CommonOrder.STATE_JS) {
+ } else if (commonOrder.getState() == CommonOrder.STATE_JS
+ || commonOrder.getState() == CommonOrder.STATE_WQ) {
hongBao.setState(HongBaoV2.STATE_KELINGQU);
hongBao.setMoney(
MoneyBigDecimalUtil.mul(commonOrder.geteIncome(), fanliRate.divide(new BigDecimal(100))));
@@ -562,6 +577,9 @@
List<HongBaoV2> children = hongBaoV2Mapper.listChildrenById(hongBao.getId());
if (children != null)
for (HongBaoV2 child : children) {
+ if (child.getState() == HongBaoV2.STATE_YILINGQU)
+ continue;
+
HongBaoV2 childUpdate = new HongBaoV2(child.getId());
// 缁熶竴璁剧疆鐘舵��
childUpdate.setState(hongBao.getState());
@@ -574,7 +592,8 @@
}
// 浠ュ疄闄呮敹鍏ヤ负鍑嗚绠楅浼版敹鐩�
- if (CommonOrder.STATE_JS == commonOrder.getState()) {
+ if (CommonOrder.STATE_JS == commonOrder.getState()
+ || CommonOrder.STATE_WQ == commonOrder.getState()) {
childUpdate.setMoney(
MoneyBigDecimalUtil.mul(hongBao.getMoney(), rate.divide(new BigDecimal(100))));
if (commonOrder.getThirdCreateTime().getTime() > TimeUtil.convertToTimeTemp("2019-04-16",
@@ -622,13 +641,16 @@
}
} else
throw new HongBaoException(2, "type閿欒");
+
+ return true;
}
- @Transactional
- private void saveHongBao(CommonOrder commonOrder, int type, Map<Integer, HongBaoOrder> notificationMap)
- throws HongBaoException {
+ @Transactional(rollbackFor = Exception.class)
+ private boolean saveHongBao(CommonOrder commonOrder, int type, Map<Integer, HongBaoOrder> notificationMap)
+ throws HongBaoException, UserAccountException {
if (type == HongBaoV2.TYPE_ZIGOU) {// 鑾峰彇鑷喘鐨勮繑鍒╂瘮渚�
- BigDecimal fanliRate = hongBaoManageService.getFanLiRate(commonOrder.getCreateTime().getTime());
+ BigDecimal fanliRate = hongBaoManageService.getFanLiRate(UserLevelEnum.daRen,
+ commonOrder.getCreateTime().getTime());
// 鏌ヨ鏄惁鏈夊厤鍗曡鍒�
BigDecimal mianDanMoney = null;
if (commonOrder.getState() == CommonOrder.STATE_JS || commonOrder.getState() == CommonOrder.STATE_FK) {
@@ -642,7 +664,6 @@
CommonOrderGoods goods = commonOrderGoodsMapper
.selectByPrimaryKey(commonOrder.getCommonOrderGoods().getId());
if (goods != null) {
-
try {
if (userSystemCouponService.updateCouponRecordUsed(commonOrder.getUserInfo().getId(),
commonOrder.getOrderNo(), payMent, Long.parseLong(goods.getGoodsId())))
@@ -673,7 +694,8 @@
hongBao.setState(HongBaoV2.STATE_BUKELINGQU);
hongBao.setMoney(
MoneyBigDecimalUtil.mul(commonOrder.getEstimate(), fanliRate.divide(new BigDecimal(100))));
- } else if (commonOrder.getState() == CommonOrder.STATE_JS) {
+ } else if (commonOrder.getState() == CommonOrder.STATE_JS
+ || CommonOrder.STATE_WQ == commonOrder.getState()) {
hongBao.setState(HongBaoV2.STATE_KELINGQU);
hongBao.setMoney(
MoneyBigDecimalUtil.mul(commonOrder.geteIncome(), fanliRate.divide(new BigDecimal(100))));
@@ -693,7 +715,10 @@
hongBao.setMoney(mianDanMoney);
UserInfo user = userInfoService.getUserById(commonOrder.getUserInfo().getId());
+ if (user == null)
+ throw new UserAccountException(1001, "鐢ㄦ埛涓嶅瓨鍦�/琚皝绂�");
hongBao.setUrank(user.getRank());
+ hongBao.setOrderType(commonOrder.getSourceType());
hongBaoV2Mapper.insertSelective(hongBao);
// 娣诲姞绾㈠寘涓庤鍗曠殑鏄犲皠
HongBaoOrder hongBaoOrder = new HongBaoOrder();
@@ -726,7 +751,7 @@
BigDecimal firstRate = hongBaoManageService
.getFirstInviteRate(boss.getRank() == null ? 0 : boss.getRank());
if (firstRate.compareTo(new BigDecimal(0)) <= 0)
- return;
+ return mianDanMoney != null;
HongBaoV2 firstHongbao = new HongBaoV2();
firstHongbao.setUserInfo(boss);
firstHongbao.setUrank(boss.getRank());
@@ -735,6 +760,7 @@
firstHongbao.setType(HongBaoV2.TYPE_YIJI);
firstHongbao.setVersion(2);
firstHongbao.setState(hongBao.getState());
+ firstHongbao.setOrderType(commonOrder.getSourceType());
if (hongBao.getState() == HongBaoV2.STATE_KELINGQU) {
firstHongbao.setMoney(
@@ -751,7 +777,7 @@
}
// 杩斿埄涓�0鐨勪笉閫氱煡
if (firstHongbao.getMoney() == null || firstHongbao.getMoney().compareTo(new BigDecimal(0)) <= 0)
- return;
+ return mianDanMoney != null;
hongBaoV2Mapper.insertSelective(firstHongbao);
// 鐢ㄦ埛閫氱煡
@@ -778,7 +804,7 @@
BigDecimal secondRate = hongBaoManageService
.getSecondInviteRate(boss.getRank() == null ? 0 : boss.getRank());
if (secondRate.compareTo(new BigDecimal(0)) <= 0)
- return;
+ return mianDanMoney != null;
HongBaoV2 secondHongbao = new HongBaoV2();
secondHongbao.setUserInfo(boss);
secondHongbao.setUrank(boss.getRank());
@@ -787,6 +813,7 @@
secondHongbao.setType(HongBaoV2.TYPE_ERJI);
secondHongbao.setVersion(2);
secondHongbao.setState(hongBao.getState());
+ secondHongbao.setOrderType(commonOrder.getSourceType());
if (hongBao.getState() == HongBaoV2.STATE_KELINGQU) {
secondHongbao.setMoney(
MoneyBigDecimalUtil.mul(hongBao.getMoney(), secondRate.divide(new BigDecimal(100))));
@@ -803,7 +830,7 @@
// 杩斿埄涓�0鐨勪笉缁熻
if (secondHongbao.getMoney() == null || secondHongbao.getMoney().compareTo(new BigDecimal(0)) <= 0)
- return;
+ return mianDanMoney != null;
hongBaoV2Mapper.insertSelective(secondHongbao);
@@ -827,21 +854,22 @@
}
}
-
+ return mianDanMoney != null;
} else if (type == HongBaoV2.TYPE_SHARE_GOODS) {
// 鍒嗕韩璧氫笉鍔犲叆澶辨晥鐨勮鍗�
if (commonOrder.getState() == CommonOrder.STATE_SX || commonOrder.getState() == CommonOrder.STATE_WQ)
- return;
+ return false;
// 鍒嗕韩璧�
BigDecimal shareRate = null;
if (commonOrder.getSourceType() == Constant.SOURCE_TYPE_TAOBAO
&& commonOrder.getSourcePosition().equalsIgnoreCase(TaoBaoConstant.TAOBAO_TLJ_RELATION_PID_DEFAULT))// 鏉ヨ嚜浜庢窐绀奸噾鐨勫垎浜�
shareRate = hongBaoManageService.getTLJShareRate(commonOrder.getCreateTime().getTime());
else
- shareRate = hongBaoManageService.getShareRate(commonOrder.getCreateTime().getTime());
+ shareRate = hongBaoManageService.getShareRate(UserLevelEnum.daRen,
+ commonOrder.getCreateTime().getTime());
// 鍒ゆ柇璁㈠崟鍒嗕韩娲诲姩鏄惁寮�鍚�
- if ("1".equalsIgnoreCase(configService.get("share_goods_activity_open"))) {
+ if ("1".equalsIgnoreCase(configService.get(ConfigKeyEnum.shareGoodsActivityOpen.getKey()))) {
// 娌℃湁璁㈠崟锛屽苟涓旀槸娓犻亾ID鏉ョ殑锛屽苟涓�
UserExtraTaoBaoInfo taoBaoExtraInfo = userExtraTaoBaoInfoService
.getByUid(commonOrder.getUserInfo().getId());
@@ -877,7 +905,8 @@
hongBao.setState(HongBaoV2.STATE_BUKELINGQU);
hongBao.setMoney(
MoneyBigDecimalUtil.mul(commonOrder.getEstimate(), shareRate.divide(new BigDecimal(100))));
- } else if (commonOrder.getState() == CommonOrder.STATE_JS) {
+ } else if (commonOrder.getState() == CommonOrder.STATE_JS
+ || commonOrder.getState() == CommonOrder.STATE_WQ) {
hongBao.setState(HongBaoV2.STATE_KELINGQU);
hongBao.setMoney(
MoneyBigDecimalUtil.mul(commonOrder.geteIncome(), shareRate.divide(new BigDecimal(100))));
@@ -888,8 +917,11 @@
calendar.get(Calendar.YEAR) + "-" + (calendar.get(Calendar.MONTH) + 1) + "-25", "yyyy-M-dd")));
}
UserInfo user = userInfoService.getUserById(commonOrder.getUserInfo().getId());
+ if (user == null)
+ throw new UserAccountException(1001, "鐢ㄦ埛涓嶅瓨鍦�/琚皝绂�");
hongBao.setUrank(user.getRank());
hongBao.setUserInfo(user);
+ hongBao.setOrderType(commonOrder.getSourceType());
hongBaoV2Mapper.insertSelective(hongBao);
// 鎻掑叆绾㈠寘涓庤鍗曟槧灏�
HongBaoOrder hongBaoOrder = new HongBaoOrder();
@@ -928,7 +960,8 @@
child.setState(HongBaoV2.STATE_BUKELINGQU);
child.setMoney(MoneyBigDecimalUtil.mul(commonOrder.getEstimate(),
firstLevelRate.divide(new BigDecimal(100))));
- } else if (commonOrder.getState() == CommonOrder.STATE_JS) {
+ } else if (commonOrder.getState() == CommonOrder.STATE_JS
+ || commonOrder.getState() == CommonOrder.STATE_WQ) {
child.setState(HongBaoV2.STATE_KELINGQU);
child.setMoney(MoneyBigDecimalUtil.mul(commonOrder.geteIncome(),
firstLevelRate.divide(new BigDecimal(100))));
@@ -943,7 +976,8 @@
child.setUrank(boss.getRank());
child.setVersion(2);
child.setCreateTime(new Date());
- if (child.getMoney().compareTo(new BigDecimal(0)) > 0) {
+ child.setOrderType(commonOrder.getSourceType());
+ if (child.getMoney() != null && child.getMoney().compareTo(new BigDecimal(0)) > 0) {
hongBaoV2Mapper.insertSelective(child);
// 娣诲姞閫氱煡
if (notificationMap.get(HongBaoV2.TYPE_SHARE_YIJI) == null) {
@@ -988,9 +1022,10 @@
e1.printStackTrace();
}
}
-
} else
throw new HongBaoException(2, "type閿欒");
+
+ return false;
}
@Override
@@ -1067,6 +1102,13 @@
}
@Override
+ public List<HongBaoV2> listChildrenByIds(List<Long> idList) {
+ if (idList == null || idList.size() == 0)
+ return null;
+ return hongBaoV2Mapper.listChildrenByIds(idList);
+ }
+
+ @Override
public List<Long> getUidByNear30DayShareSucceed() {
return hongBaoV2Mapper.getUidByNear30DayShareSucceed();
}
@@ -1115,4 +1157,21 @@
return hongBaoV2List.get(0);
return null;
}
+
+ @Override
+ public List<HongBaoV2> listByIds(List<Long> idList) {
+ return hongBaoV2Mapper.listByIds(idList);
+ }
+
+ @Override
+ public List<HongBaoDTO> listByOrderTradeId(String tradeId) {
+ return hongBaoV2Mapper.listByOrderTradeId(tradeId);
+ }
+
+ @Override
+ public Integer getDirectBossUrankByPid(Long pid) {
+ return hongBaoV2Mapper.getDirectBossUrankByPid(pid);
+ }
+
+
}
--
Gitblit v1.8.0