| | |
| | | |
| | | import javax.annotation.Resource; |
| | | |
| | | import com.yeshi.fanli.util.mq.rabbit.RabbitmqManager; |
| | | import org.slf4j.Logger; |
| | | import org.slf4j.LoggerFactory; |
| | | import org.springframework.stereotype.Service; |
| | |
| | | @Resource |
| | | private RocketMQManager rocketMQManager; |
| | | |
| | | @Resource |
| | | private HongBaoRecieveCMQManager hongBaoRecieveCMQManager; |
| | | |
| | | // 下级被封禁,红包失效 |
| | | private void invalidHongBaoForbidden(HongBaoV2 hongBaoV2) throws TeamRewardDebtException { |
| | | if (hongBaoV2.getState() == HongBaoV2.STATE_SHIXIAO || hongBaoV2.getState() == HongBaoV2.STATE_YILINGQU || hongBaoV2.getState() == HongBaoV2.STATE_LINGQUING) |
| | | return; |
| | | //如果在偿还里面就先偿还,然后再失效 |
| | | TeamRewardDebt debt = teamRewardDebtService.selectBySourceId(hongBaoV2.getId()); |
| | | if (debt != null && debt.getLeftMoney().compareTo(hongBaoV2.getMoney()) <= 0) { |
| | | if (debt != null &&debt.getLeftMoney().compareTo(new BigDecimal(0))>0 && debt.getLeftMoney().compareTo(hongBaoV2.getMoney()) <= 0) { |
| | | teamRewardDebtService.repayDebt(debt.getId(), hongBaoV2.getMoney(), "封禁失效,先偿还再失效"); |
| | | } |
| | | |
| | |
| | | public void inviteSettleVipShop(Long uid, Date maxPregetTime) throws OrderMoneySettleException { |
| | | // 查询UID的一二级邀请赚 |
| | | int sourceType = Constant.SOURCE_TYPE_VIP; |
| | | inviteSettle(uid, sourceType, maxPregetTime); |
| | | } |
| | | |
| | | @Override |
| | | public void inviteSettleDY(Long uid, Date maxPregetTime) throws OrderMoneySettleException { |
| | | // 查询UID的一二级邀请赚 |
| | | int sourceType = Constant.SOURCE_TYPE_DY; |
| | | inviteSettle(uid, sourceType, maxPregetTime); |
| | | } |
| | | |
| | |
| | | try { |
| | | invalidHongBaoForbidden(item); |
| | | } catch (TeamRewardDebtException e) { |
| | | e.printStackTrace(); |
| | | throw new OrderMoneySettleException(10, "偿还出错"); |
| | | } |
| | | hongBaoList.remove(i); |
| | |
| | | @Override |
| | | public TransactionStatus execute(Message arg0, Object arg1) { |
| | | try { |
| | | fanLiShareTB(hongBaoList, uid, taskKey); |
| | | fanLiShareTB(hongBaoList, uid, taskKey,maxPregetTime); |
| | | } catch (TaoBaoWeiQuanException e) { |
| | | return TransactionStatus.RollbackTransaction; |
| | | } |
| | |
| | | orderTransactionProducer.send(msg, new LocalTransactionExecuter() { |
| | | @Override |
| | | public TransactionStatus execute(Message arg0, Object arg1) { |
| | | fanLiShareOther(hongBaoList, uid, sourceType, taskKey); |
| | | fanLiShareOther(hongBaoList, uid, sourceType, taskKey,maxPregetTime); |
| | | return TransactionStatus.CommitTransaction; |
| | | } |
| | | }, null); |
| | |
| | | @Override |
| | | public void shareSettleSuning(Long uid, Date maxPregetTime) throws OrderMoneySettleException { |
| | | shareSettle(Constant.SOURCE_TYPE_SUNING, uid, maxPregetTime); |
| | | } |
| | | |
| | | @Override |
| | | public void shareSettleDY(Long uid, Date maxPregetTime) throws OrderMoneySettleException { |
| | | shareSettle(Constant.SOURCE_TYPE_DY, uid, maxPregetTime); |
| | | } |
| | | |
| | | private void shareSettle(int sourceType, Long uid, Date maxPregetTime) throws OrderMoneySettleException { |
| | |
| | | orderTransactionProducer.send(msg, new LocalTransactionExecuter() { |
| | | @Override |
| | | public TransactionStatus execute(Message arg0, Object arg1) { |
| | | fanLiShareOther(hongBaoList, uid, sourceType, taskKey); |
| | | fanLiShareOther(hongBaoList, uid, sourceType, taskKey,maxPregetTime); |
| | | return TransactionStatus.CommitTransaction; |
| | | } |
| | | }, null); |
| | |
| | | Map<Long, Integer> userGoodsCount = new HashMap<>(); |
| | | for (CommonOrder co : orderList) { |
| | | HongBaoOrder hongBaoOrder = hongBaoOrderMapper.selectByCommonOrderId(co.getId()); |
| | | if (hongBaoOrder == null) { |
| | | continue; |
| | | } |
| | | hongBaoList.add(hongBaoOrder.getHongBaoV2()); |
| | | Long uid = co.getUserInfo().getId(); |
| | | if (userGoodsCount.get(uid) == null) |
| | |
| | | hbIdList.add(v2.getId()); |
| | | accountDetailsHongBaoMapService.saveAccountDetailsHongBaoMap(v2.getId(), userMoneyDetail.getId()); |
| | | try { |
| | | HongBaoRecieveCMQManager.getInstance().addHongBaoRecieveMsg(v2.getId()); |
| | | hongBaoRecieveCMQManager.addHongBaoRecieveMsg(v2.getId()); |
| | | } catch (Exception e) { |
| | | LogHelper.errorDetailInfo(e); |
| | | } |
| | |
| | | for (Long hongBaoId : hbIdList) { |
| | | try { |
| | | if (Constant.ENABLE_MQ) |
| | | HongBaoRecieveCMQManager.getInstance().addHongBaoRecieveMsg(hongBaoId); |
| | | hongBaoRecieveCMQManager.addHongBaoRecieveMsg(hongBaoId); |
| | | } catch (Exception e) { |
| | | LogHelper.errorDetailInfo(e); |
| | | } |
| | |
| | | * @param uid |
| | | * @throws TaoBaoWeiQuanException |
| | | */ |
| | | private void fanLiShareTB(List<HongBaoV2> hongBaoList, Long uid, String key) throws TaoBaoWeiQuanException { |
| | | private void fanLiShareTB(List<HongBaoV2> hongBaoList, Long uid, String key,Date recieveMonth) throws TaoBaoWeiQuanException { |
| | | BigDecimal sharemoney = new BigDecimal(0); |
| | | List<Long> hbIdList = new ArrayList<>(); |
| | | Set<String> drawBackOrders = new HashSet<String>(); |
| | |
| | | // 添加新版详情记录 |
| | | try { |
| | | UserMoneyDetail userMoneyDetail = UserMoneyDetailFactory.createShare(uid, Constant.SOURCE_TYPE_TAOBAO, |
| | | sharemoney, new Date()); |
| | | sharemoney,recieveMonth); |
| | | // 添加资金 |
| | | userMoneyService.addUserMoney(uid, sharemoney, userMoneyDetail); |
| | | |
| | |
| | | for (Long hongBaoId : recieveHongBaoIds) { |
| | | try { |
| | | if (Constant.ENABLE_MQ) |
| | | HongBaoRecieveCMQManager.getInstance().addHongBaoRecieveMsg(hongBaoId); |
| | | hongBaoRecieveCMQManager.addHongBaoRecieveMsg(hongBaoId); |
| | | } catch (Exception e) { |
| | | LogHelper.errorDetailInfo(e); |
| | | } |
| | |
| | | * @param uid |
| | | * @param sourceType |
| | | */ |
| | | private void fanLiShareOther(List<HongBaoV2> hongBaoList, Long uid, int sourceType, String key) { |
| | | private void fanLiShareOther(List<HongBaoV2> hongBaoList, Long uid, int sourceType, String key,Date recieveMonth) { |
| | | BigDecimal sharemoney = new BigDecimal(0); |
| | | List<Long> hbIdList = new ArrayList<>(); |
| | | List<Long> recieveHongBaoIds = new ArrayList<>(); |
| | |
| | | // 添加新版详情记录 |
| | | try { |
| | | UserMoneyDetail userMoneyDetail = UserMoneyDetailFactory.createShare(uid, sourceType, sharemoney, |
| | | new Date()); |
| | | recieveMonth); |
| | | // 添加资金 |
| | | userMoneyService.addUserMoney(uid, sharemoney, userMoneyDetail); |
| | | |
| | |
| | | for (Long hongBaoId : recieveHongBaoIds) { |
| | | try { |
| | | if (Constant.ENABLE_MQ) |
| | | HongBaoRecieveCMQManager.getInstance().addHongBaoRecieveMsg(hongBaoId); |
| | | hongBaoRecieveCMQManager.addHongBaoRecieveMsg(hongBaoId); |
| | | } catch (Exception e) { |
| | | LogHelper.errorDetailInfo(e); |
| | | } |