| | |
| | | otr_subsidy_id = #{0} |
| | | </select> |
| | | |
| | | <select id="listCanSettleByUid" resultMap="BaseResultMap" |
| | | parameterType="java.lang.Long">SELECT * FROM yeshi_ec_order_team_reward WHERE |
| | | <select id="listCanSettleByUid" resultMap="BaseResultMap">SELECT * FROM yeshi_ec_order_team_reward WHERE |
| | | otr_uid |
| | | =#{uid} AND otr_state=1 AND NOW()>otr_pre_get_time |
| | | limit |
| | |
| | | <select id="countCanSettle" resultType="java.lang.Long" |
| | | parameterType="java.lang.Long">SELECT count(*) FROM yeshi_ec_order_team_reward |
| | | WHERE |
| | | otr_uid =#{0} AND otr_state=1 AND NOW()>otr_pre_get_time |
| | | otr_uid =#{uid} AND otr_state=1 AND NOW()>otr_pre_get_time |
| | | </select> |
| | | |
| | | |
| | |
| | | import com.yeshi.fanli.entity.money.UserMoneyDetail;
|
| | | import com.yeshi.fanli.log.LogHelper;
|
| | | import com.yeshi.fanli.service.inter.money.UserMoneyService;
|
| | | import com.yeshi.fanli.util.Constant;
|
| | | import com.yeshi.fanli.util.cmq.UserMoneyChangeCMQManager;
|
| | |
|
| | | @Service
|
| | |
| | | userMoneyDetailMapper.insertSelective(detail);
|
| | | userInfoMapper.subHongBaoByUid(uid, money);
|
| | | try {
|
| | | UserMoneyChangeCMQManager.getInstance()
|
| | | .addUserMoneyChangeMsg(new UserMoneyChangeDTO(uid, new BigDecimal(0).subtract(money)));
|
| | | if (!Constant.IS_TEST)
|
| | | UserMoneyChangeCMQManager.getInstance()
|
| | | .addUserMoneyChangeMsg(new UserMoneyChangeDTO(uid, new BigDecimal(0).subtract(money)));
|
| | | } catch (Exception e) {
|
| | | try {
|
| | | LogHelper.errorDetailInfo(e);
|
| | |
| | | userMoneyDetailMapper.insertSelective(detail);
|
| | | userInfoMapper.addHongBaoByUid(uid, money);
|
| | | try {
|
| | | if (!Constant.IS_TEST)
|
| | | UserMoneyChangeCMQManager.getInstance().addUserMoneyChangeMsg(new UserMoneyChangeDTO(uid, money));
|
| | | } catch (Exception e) {
|
| | | try {
|
| | |
| | | detail.setUpdateTime(new Date());
|
| | | detail.setRead(false);
|
| | | msgMoneyDetailMapper.insertSelective(detail);
|
| | | } else if (detail.getMsgType() == MsgTypeMoneyTypeEnum.orderTeamReward) {
|
| | | if (detail.getMoney() == null || detail.getUser() == null)
|
| | | throw new MsgMoneyDetailException(2, "消息信息不全");
|
| | | detail.setCreateTime(new Date());
|
| | | detail.setUpdateTime(new Date());
|
| | | detail.setRead(false);
|
| | | msgMoneyDetailMapper.insertSelective(detail);
|
| | | }
|
| | | userMsgReadStateService.addMoneyMsgUnReadCount(detail.getUser().getId(), 1);
|
| | | }
|
| | |
| | | taoBaoWeiQuanDrawBackMapper.insertSelective(weiQuanDrawBack);// 加入返还记录
|
| | |
|
| | | // 加入邀请补贴返还记录
|
| | | doInviteOrderSubsidy(orderId, Constant.SOURCE_TYPE_TAOBAO, uid, settleMent, wqMoney,weiQuanOrder.getOrderItemId());
|
| | | doInviteOrderSubsidy(orderId, Constant.SOURCE_TYPE_TAOBAO, uid, settleMent, wqMoney,
|
| | | weiQuanOrder.getOrderItemId());
|
| | |
|
| | | // 如果资金大于0才扣除
|
| | |
|
| | |
| | | * @param sourceType
|
| | | */
|
| | | private void doInviteOrderSubsidy(String orderId, int sourceType, Long uid, BigDecimal settleMent,
|
| | | BigDecimal weiQuanMoney,String tradeId) throws TaoBaoWeiQuanException {
|
| | | BigDecimal weiQuanMoney, String tradeId) throws TaoBaoWeiQuanException {
|
| | | InviteOrderSubsidy subSidy = inviteOrderSubsidyService.getByOrderNoAndType(uid, orderId, sourceType);
|
| | | if (subSidy != null)// 添加借贷关系
|
| | | {
|
| | |
| | | debt.setOriginMoney(drawBackMoney);
|
| | | debt.setUid(uid);
|
| | | debt.setCreateTime(new Date());
|
| | | debt.setSourceId(subSidy.getId());
|
| | | debt.setTradeId(tradeId);
|
| | | try {
|
| | | inviteOrderSubsidyDebtService.addDebt(debt);
|
| | |
| | | throw new TaoBaoWeiQuanException(101, "邀请订单补贴异常");
|
| | | }
|
| | |
|
| | | doOrderTeamReard(subSidy.getId(), settleMent, weiQuanMoney,tradeId);
|
| | | doOrderTeamReard(subSidy.getId(), settleMent, weiQuanMoney, tradeId);
|
| | | }
|
| | | }
|
| | |
|
| | |
| | | * void 返回类型
|
| | | * @throws
|
| | | */
|
| | | private void doOrderTeamReard(Long subsidyId, BigDecimal settleMent, BigDecimal weiQuanMoney,String tradeId)
|
| | | private void doOrderTeamReard(Long subsidyId, BigDecimal settleMent, BigDecimal weiQuanMoney, String tradeId)
|
| | | throws TaoBaoWeiQuanException {
|
| | | List<OrderTeamReward> list = orderTeamRewardService.listBySubsidyId(subsidyId);
|
| | | if (list != null)
|
| | |
| | | debt.setUid(reward.getUid());
|
| | | debt.setCreateTime(new Date());
|
| | | debt.setTradeId(tradeId);
|
| | | debt.setSourceId(reward.getId());
|
| | | try {
|
| | | orderTeamRewardDebtService.addDebt(debt);
|
| | | } catch (OrderTeamRewardDebtException e) {
|
| | |
| | | |
| | | if (VersionUtil.greaterThan_2_1(acceptData.getPlatform(), acceptData.getVersion())) { |
| | | for (CommonOrderVO order : listOrder) { |
| | | |
| | | |
| | | if (order.getHongBaoType() == HongBaoV2.TYPE_YIJI || order.getHongBaoType() == HongBaoV2.TYPE_ERJI |
| | | || order.getHongBaoType() == HongBaoV2.TYPE_SHARE_ERJI |
| | | || order.getHongBaoType() == HongBaoV2.TYPE_SHARE_ERJI) { |
| | |
| | | String orderNo = order.getOrderNo(); |
| | | Integer sourceType = order.getSourceType(); |
| | | Integer hongBaoType = order.getHongBaoType(); |
| | | |
| | | |
| | | |
| | | BigDecimal totalPay = new BigDecimal(0); |
| | | BigDecimal totalActual = new BigDecimal(0); |
| | | // 商品信息组合 |
| | |
| | | commonGoodsVO.setActualPay("付款金额:¥" + totalSettlement); |
| | | |
| | | totalPay = MoneyBigDecimalUtil.add(totalPay, totalSettlement); |
| | | |
| | | |
| | | // 商品价格 |
| | | BigDecimal actualPrice = commonGoodsVO.getActualPrice(); |
| | | if (actualPrice != null) { |
| | | Integer totalCount = commonOrder.getTotalCount(); |
| | | totalActual = MoneyBigDecimalUtil.add(totalActual, |
| | | totalActual = MoneyBigDecimalUtil.add(totalActual, |
| | | MoneyBigDecimalUtil.mul(new BigDecimal(totalCount), actualPrice)); |
| | | } |
| | | |
| | | |
| | | // 邀请订单信息保护 |
| | | if (HongBaoV2.TYPE_YAOQING == hongBaoType || HongBaoV2.TYPE_YIJI == hongBaoType |
| | | || HongBaoV2.TYPE_ERJI == hongBaoType || HongBaoV2.TYPE_SHARE_YIJI == hongBaoType |
| | |
| | | order.getListOrderGoods().add(commonGoodsVO); |
| | | } |
| | | } |
| | | |
| | | |
| | | Date thirdCreateTime = order.getThirdCreateTime(); |
| | | order.setDownTime("下单时间:" + format.format(thirdCreateTime)); |
| | | order.setObtainTime(thirdCreateTime.getTime()); |
| | | |
| | | |
| | | // 2.1分享订单和返利订单实付金额大于或者小于券后价的时候,订单页面 只显示3天 下单时间开始 |
| | | if (VersionUtil.greaterThan_2_1(acceptData.getPlatform(), acceptData.getVersion())) { |
| | | if (HongBaoV2.TYPE_SHARE_YIJI == hongBaoType |
| | | if (HongBaoV2.TYPE_SHARE_YIJI == hongBaoType |
| | | && DateUtil.plusDayDate(3, thirdCreateTime).getTime() > nowTime |
| | | && totalPay.compareTo(totalActual) != 0) { |
| | | order.setFanliDesc("由实付金额*返利比计算而来"); |
| | |
| | | @Override |
| | | public List<CommonOrderVO> listQuery(long start, int count, Integer keyType, String key, Integer state, |
| | | Integer type, Integer orderState, String startTime, String endTime, Integer source, List<Long> listShopId, |
| | | List<Long> listGoodsId, Date minTime, BigDecimal money,BigDecimal payment) throws CommonOrderException { |
| | | List<Long> listGoodsId, Date minTime, BigDecimal money, BigDecimal payment) throws CommonOrderException { |
| | | |
| | | List<CommonOrderVO> list = null; |
| | | |
| | |
| | | startTime, endTime, source, payment); |
| | | } else { |
| | | list = commonOrderMapper.listQuery(start, count, keyType, key, state, type, orderState, startTime, endTime, |
| | | source, listShopId, listGoodsId, minTime, money,payment); |
| | | source, listShopId, listGoodsId, minTime, money, payment); |
| | | } |
| | | |
| | | if (list == null) { |
| | |
| | | @Override |
| | | public long countQuery(Integer keyType, String key, Integer state, Integer type, Integer orderState, |
| | | String startTime, String endTime, Integer source, List<Long> listShopId, List<Long> listGoodsId, |
| | | Date minTime, BigDecimal money,BigDecimal payment) throws CommonOrderException { |
| | | Date minTime, BigDecimal money, BigDecimal payment) throws CommonOrderException { |
| | | if (StringUtil.isNullOrEmpty(key) || keyType == 1) {// 搜索框无值或者按订单号搜索时都只搜索主订单 |
| | | return commonOrderMapper.countQueryWithNoChild(keyType, key, state, type, orderState, startTime, endTime, |
| | | source, payment); |
| | |
| | | } |
| | | |
| | | @Override |
| | | public List<CommonOrderVO> searchOrderByUid(AcceptData acceptData, int page, int size, Long uid, List<ESOrder> list) throws Exception { |
| | | public List<CommonOrderVO> searchOrderByUid(AcceptData acceptData, int page, int size, Long uid, List<ESOrder> list) |
| | | throws Exception { |
| | | List<CommonOrderVO> listVO = commonOrderMapper.searchOrderByUid((page - 1) * size, size, uid, list); |
| | | |
| | | // 订单信息为空 |
| | |
| | | * @param listGoods |
| | | * @param uid |
| | | */ |
| | | private void orderVOFactoryNew(AcceptData acceptData, List<CommonOrderVO> listOrder, List<CommonOrderVO> listGoods, Long uid) |
| | | throws Exception { |
| | | private void orderVOFactoryNew(AcceptData acceptData, List<CommonOrderVO> listOrder, List<CommonOrderVO> listGoods, |
| | | Long uid) throws Exception { |
| | | List<String> listTB = new ArrayList<String>(); |
| | | List<String> listJD = new ArrayList<String>(); |
| | | List<String> listPDD = new ArrayList<String>(); |
| | |
| | | } |
| | | } |
| | | } |
| | | |
| | | |
| | | } |
| | | } else { |
| | | // 设置是否为vip订单 |
| | |
| | | order.setVipOrderDesc("订单来源:由超级会员的粉丝产生"); |
| | | } |
| | | } |
| | | |
| | | |
| | | SimpleDateFormat format = new SimpleDateFormat("yyyy.MM.dd HH:mm"); |
| | | SimpleDateFormat formatday = new SimpleDateFormat("yyyy.MM.dd"); |
| | |
| | | boolean vip = userVIPInfoService.isVIP(uid); |
| | | // 是否存在奖励券 |
| | | boolean hasRewardCoupon = userSystemCouponService.getValidRebateCoupon(uid); |
| | | |
| | | |
| | | long nowTime = java.lang.System.currentTimeMillis(); |
| | | for (CommonOrderVO order : listOrder) { |
| | | String orderNo = order.getOrderNo(); |
| | | Integer sourceType = order.getSourceType(); |
| | | Integer hongBaoType = order.getHongBaoType(); |
| | | |
| | | |
| | | BigDecimal totalPay = new BigDecimal(0); |
| | | BigDecimal totalActual = new BigDecimal(0); |
| | | |
| | | |
| | | // 商品信息组合 |
| | | for (CommonOrderVO commonOrder : listGoods) { |
| | | CommonOrderGoods goods = commonOrder.getCommonOrderGoods(); |
| | |
| | | totalSettlement = commonOrder.getTotalPayment(); |
| | | } |
| | | commonGoodsVO.setActualPay("付款金额:¥" + totalSettlement); |
| | | |
| | | |
| | | totalPay = MoneyBigDecimalUtil.add(totalPay, totalSettlement); |
| | | |
| | | |
| | | // 商品价格 |
| | | BigDecimal actualPrice = commonGoodsVO.getActualPrice(); |
| | | if (actualPrice != null) { |
| | | Integer totalCount = commonOrder.getTotalCount(); |
| | | totalActual = MoneyBigDecimalUtil.add(totalActual, |
| | | totalActual = MoneyBigDecimalUtil.add(totalActual, |
| | | MoneyBigDecimalUtil.mul(new BigDecimal(totalCount), actualPrice)); |
| | | } |
| | | |
| | | |
| | | |
| | | // 邀请订单信息保护 |
| | | if (HongBaoV2.TYPE_YAOQING == hongBaoType || HongBaoV2.TYPE_YIJI == hongBaoType |
| | | || HongBaoV2.TYPE_ERJI == hongBaoType || HongBaoV2.TYPE_SHARE_YIJI == hongBaoType |
| | |
| | | |
| | | // 2.1分享订单和返利订单实付金额大于或者小于券后价的时候,订单页面 只显示3天 下单时间开始 |
| | | if (VersionUtil.greaterThan_2_1(acceptData.getPlatform(), acceptData.getVersion())) { |
| | | if (HongBaoV2.TYPE_SHARE_GOODS == hongBaoType |
| | | if (HongBaoV2.TYPE_SHARE_GOODS == hongBaoType |
| | | && DateUtil.plusDayDate(3, thirdCreateTime).getTime() > nowTime |
| | | && totalPay.compareTo(totalActual) != 0) { |
| | | order.setFanliDesc("由实付金额*返利比计算而来"); |
| | | order.setFanliDescLink(configService.get(ConfigKeyEnum.shareOrderRebateDescLink.getKey())); |
| | | } |
| | | } |
| | | |
| | | |
| | | Date settleTime = order.getSettleTime(); |
| | | if (settleTime != null) { |
| | | order.setReceiveTime("收货时间:" + format.format(settleTime)); |
| | |
| | | } |
| | | } |
| | | |
| | | @Override |
| | | public Date getThirdCreateTime(String orderId, int sourceType) { |
| | | List<CommonOrder> list = listBySourceTypeAndOrderId(sourceType, orderId); |
| | | if (list == null || list.size() == 0) |
| | | return null; |
| | | return list.get(0).getThirdCreateTime(); |
| | | } |
| | | |
| | | } |
| | |
| | | if (list != null && list.size() > 0) {
|
| | | // 必须是自购订单才返利
|
| | | HongBaoV2 parent = hongBaoV2Service.selectByPrimaryKey(list.get(0).getHongBaoV2().getId());
|
| | | if (parent != null && parent.getUrank() != UserLevelEnum.superVIP.getOrderRank()) {// 不是超级会员的自购/分享才补贴
|
| | | if (parent != null && parent.getUrank() != UserLevelEnum.superVIP.getOrderRank()
|
| | | && (parent.getType() == HongBaoV2.TYPE_SHARE_GOODS || parent.getType() == HongBaoV2.TYPE_ZIGOU)) {// 不是超级会员的自购/分享才补贴
|
| | | boolean isShare = (parent.getType() == HongBaoV2.TYPE_SHARE_GOODS);
|
| | |
|
| | | List<CommonOrder> orderList = commonOrderService.listBySourceTypeAndOrderId(sourceType, orderId);
|
| | | if (orderList == null || orderList.size() == 0)
|
| | |
| | | else
|
| | | orderSubsidy.setLevel(InviteOrderSubsidy.LEVEL_TWO);
|
| | | // 会员才能补贴
|
| | | if (userLevel != UserLevelEnum.daRen)
|
| | | if (userLevel != UserLevelEnum.daRen) {
|
| | | try {
|
| | | addOrderSubsidy(orderSubsidy);
|
| | | } catch (OrderTeamRewardException e) {
|
| | |
| | | } catch (CommonOrderException e) {
|
| | | throw new InviteOrderSubsidyException(e.getCode(), e.getMsg());
|
| | | }
|
| | | // 分享赚不能使用返利奖励券,不用等待5天
|
| | | if (isShare) {
|
| | | validByOrderIdAndSourceType(orderId, sourceType);
|
| | | }
|
| | | }
|
| | | }
|
| | | }
|
| | | }
|
| | |
| | | order.setOrderType(Constant.SOURCE_TYPE_TAOBAO);
|
| | | order.setUserInfo(new UserInfo(uid));
|
| | | try {
|
| | | PlaceOrderCMQManager.getInstance().addPlaceOrderMsg(order);
|
| | | if (!Constant.IS_TEST)
|
| | | PlaceOrderCMQManager.getInstance().addPlaceOrderMsg(order);
|
| | | } catch (Exception e) {
|
| | | }
|
| | | }
|
| | |
| | | @Lazy
|
| | | @Resource
|
| | | private UserSystemCouponService userSystemCouponService;
|
| | | |
| | |
|
| | | @Resource
|
| | | private UserVIPPreInfoService userVIPPreInfoService;
|
| | | |
| | |
|
| | | @Resource
|
| | | private MsgAccountDetailService msgAccountDetailService;
|
| | | |
| | | |
| | |
|
| | | @Override
|
| | | @Transactional(rollbackFor = Exception.class)
|
| | |
| | |
|
| | | @Override
|
| | | public boolean isVIP(Long uid) {
|
| | | return isVIP(uid, System.currentTimeMillis());
|
| | | }
|
| | |
|
| | | @Override
|
| | | public boolean isVIP(Long uid, Long time) {
|
| | | UserVIPInfo userInfo = userVIPInfoMapper.selectByPrimaryKey(uid);
|
| | | if (userInfo != null && userInfo.getState() == UserVIPInfo.STATE_SUCCESS)
|
| | | if (userInfo != null && userInfo.getState() == UserVIPInfo.STATE_SUCCESS
|
| | | && userInfo.getSuccessTime().getTime() < time)
|
| | | return true;
|
| | | else
|
| | | return false;
|
| | |
| | |
|
| | | // 1、直接粉丝(从 2020 年 1 月 1 日起直接粉丝产生有效订单)
|
| | | BigDecimal payMoney = new BigDecimal(userVipConfigService.getValueByKey("require_order_pay"));
|
| | | // long teamNum = hongBaoV2CountService.countValidOrderTeamUserByUid(uid,
|
| | | // TimeUtil.convertDateToTemp(Constant.VIP_ONLINE_TIME), payMoney);
|
| | | // long teamNum =
|
| | | // hongBaoV2CountService.countValidOrderTeamUserByUid(uid,
|
| | | // TimeUtil.convertDateToTemp(Constant.VIP_ONLINE_TIME), payMoney);
|
| | | long teamNum = 0L;
|
| | | long vipBegin = TimeUtil.convertDateToTemp(Constant.VIP_ONLINE_TIME);
|
| | | List<ThreeSale> listThreeSale = threeSaleSerivce.getValidWorkerIdsByTime(uid, vipBegin);
|
| | | if (listThreeSale != null && listThreeSale.size() > 0) {
|
| | | for (ThreeSale three: listThreeSale) {
|
| | | for (ThreeSale three : listThreeSale) {
|
| | | UserInfo worker = three.getWorker();
|
| | | if (worker == null || worker.getId() == null) {
|
| | | continue;
|
| | | }
|
| | | // 1、邀请关系成功后;2、单(分享 + 自购)实付款大于1元
|
| | | long countValid = hongBaoV2CountService.countValidOrderByUidAndTime(worker.getId(), three.getSucceedTime(), payMoney);
|
| | | long countValid = hongBaoV2CountService.countValidOrderByUidAndTime(worker.getId(),
|
| | | three.getSucceedTime(), payMoney);
|
| | | if (countValid > 0) {
|
| | | teamNum ++;
|
| | | teamNum++;
|
| | | }
|
| | | }
|
| | | }
|
| | | |
| | | |
| | | |
| | | |
| | | |
| | |
|
| | | // 区分老用户和新用户
|
| | | String limtDate = userVipConfigService.getValueByKey("vip_execute_time");
|
| | |
| | | }
|
| | | }
|
| | |
|
| | | |
| | | @Transactional(rollbackFor = Exception.class)
|
| | | @Override
|
| | | public void applyVIPNew(Long uid) throws UserVIPInfoException {
|
| | | UserVIPPreInfo latestProcess = userVIPPreInfoService.getLatestProcessInfo(uid);
|
| | | if (latestProcess == null || latestProcess.getProcess() != UserVIPPreInfo.PROCESS_2) {
|
| | | throw new UserVIPInfoException(1, "该用户还不是高级会员");
|
| | | } |
| | | |
| | | }
|
| | |
|
| | | if (!verifyVipNew(uid))
|
| | | throw new UserVIPInfoException(1, "系统验证:不满足升级条件");
|
| | | |
| | |
|
| | | UserVIPInfo userInfo = userVIPInfoMapper.selectByPrimaryKeyForUpdate(uid);
|
| | | if (userInfo == null) {
|
| | | userInfo = new UserVIPInfo();
|
| | |
| | | info.setState(UserVIPInfo.STATE_VERIFING);
|
| | | info.setUpdateTime(new Date());
|
| | | userVIPInfoMapper.updateByPrimaryKeySelective(info);
|
| | | |
| | | |
| | |
|
| | | MsgAccountDetail detail = new MsgAccountDetail();
|
| | | detail.setTitle("尊敬的高级会员,系统已收到你的超级会员升级申请,正在受理中");
|
| | | detail.setBeiZhu("如有疑问请联系我的-人工客服");
|
| | |
| | | e.printStackTrace();
|
| | | }
|
| | | }
|
| | | |
| | | |
| | | |
| | |
|
| | | @Transactional(rollbackFor = Exception.class)
|
| | | @Override
|
| | | public void passVIPApplyNew(Long uid) throws UserVIPInfoException {
|
| | |
| | | if (userVIPInfo.getState() != UserVIPInfo.STATE_VERIFING) {
|
| | | throw new UserVIPInfoException(2, "申请未处于审核状态");
|
| | | }
|
| | | |
| | |
|
| | | UserVIPPreInfo latestProcess = userVIPPreInfoService.getLatestProcessInfo(uid);
|
| | | if (latestProcess == null || latestProcess.getProcess() != UserVIPPreInfo.PROCESS_2) {
|
| | | throw new UserVIPInfoException(1, "该用户还不是高级会员");
|
| | | } |
| | | |
| | | }
|
| | |
|
| | | if (!verifyVipNew(uid))
|
| | | throw new UserVIPInfoException(1, "系统验证:不满足升级条件");
|
| | | |
| | |
|
| | | // 额外信息
|
| | | UserInfoExtra userInfoExtra = userInfoExtraService.getByUidForUpdate(uid);
|
| | | if (userInfoExtra == null)
|
| | |
| | | detail.setCreateTime(new Date());
|
| | | detail.setUniqueKey("VIP-" + uid);
|
| | | integralDetailService.insertSelective(detail);
|
| | | |
| | |
|
| | | try {
|
| | | // 奖励券
|
| | | BigDecimal percent = new BigDecimal(configService.get(ConfigKeyEnum.exchangeRebatePercent.getKey()));
|
| | |
| | | throw new UserVIPInfoException(1, "券赠送失败");
|
| | | }
|
| | |
|
| | | |
| | | // 消息
|
| | | MsgAccountVipDTO msgDto = new MsgAccountVipDTO();
|
| | | msgDto.setStatus("已将你的账户由高级会员升级为超级会员");
|
| | | msgDto.setEquity("从收到本消息起,你将获得全部超级会员权益");
|
| | | msgAccountDetailService.addMsgVIP(uid, "恭喜你!经人工审核你满足升级超级会员条件", "如有疑问请联系我的-人工客服", msgDto);
|
| | | }
|
| | | |
| | | |
| | |
|
| | | /**
|
| | | * 验证是否符合VIP
|
| | | * @param uid
|
| | |
| | | // 队员
|
| | | long firstTeam = threeSaleSerivce.countFirstTeam(uid, 1);
|
| | | long secondTeam = threeSaleSerivce.countSecondTeam(uid, 1);
|
| | | |
| | |
|
| | | if (countZiGou >= Constant.VIP_PROCESS_3_ZIGOU || countShare >= Constant.VIP_PROCESS_3_SHARE
|
| | | || (firstTeam >= Constant.VIP_PROCESS_3_TEAM && secondTeam >= Constant.VIP_PROCESS_3_TEAM_SECOND)) {
|
| | | return true;
|
| | | } |
| | | }
|
| | | return false;
|
| | | }
|
| | | |
| | | |
| | |
|
| | | @Transactional(rollbackFor = Exception.class)
|
| | | @Override
|
| | | public void rejectVIPApplyNew(Long uid, String reason) throws UserVIPInfoException {
|
| | |
| | | info.setState(UserVIPInfo.STATE_INVALID);
|
| | | info.setUpdateTime(new Date());
|
| | | userVIPInfoMapper.updateByPrimaryKeySelective(info);
|
| | | |
| | |
|
| | | // 消息
|
| | | MsgAccountVipDTO msgDto = new MsgAccountVipDTO();
|
| | | msgDto.setStatus("你的账号仍是高级会员");
|
| | | msgDto.setReason(reason);
|
| | | msgAccountDetailService.addMsgVIP(uid, "很抱歉!经人工审核你未满足或不符合升级超级会员的条件", "如有疑问请联系我的-人工客服", msgDto);
|
| | | }
|
| | |
|
| | | }
|
| | |
| | |
|
| | | @Resource
|
| | | private ThreeSaleSerivce threeSaleSerivce;
|
| | | |
| | |
|
| | | @Resource
|
| | | private MsgAccountDetailService msgAccountDetailService;
|
| | | |
| | | |
| | |
|
| | | @Override
|
| | | public void addUserVIPPreInfo(UserVIPPreInfo info) throws UserVIPPreInfoException {
|
| | |
| | | return infoList.get(0);
|
| | | }
|
| | |
|
| | | @Override
|
| | | public UserVIPPreInfo getProcessInfo(Long uid, Date time) {
|
| | | List<UserVIPPreInfo> infoList = userVIPPreInfoMapper.listByUid(uid);
|
| | | if (infoList == null || infoList.size() == 0)
|
| | | return null;
|
| | | Comparator<UserVIPPreInfo> cm = new Comparator<UserVIPPreInfo>() {
|
| | |
|
| | | @Override
|
| | | public int compare(UserVIPPreInfo o1, UserVIPPreInfo o2) {
|
| | | return o2.getProcess() - o1.getProcess();
|
| | | }
|
| | | };
|
| | | Collections.sort(infoList, cm);
|
| | |
|
| | | for (UserVIPPreInfo info : infoList) {
|
| | | if (time.getTime() >= info.getCreateTime().getTime())
|
| | | return info;
|
| | | }
|
| | | return null;
|
| | | }
|
| | |
|
| | | @RequestSerializableByKeyService(key = "#uid")
|
| | | @Transactional(rollbackFor = Exception.class)
|
| | | @Override
|
| | | public void verifyVipPreInfo(Long uid, boolean inviteSuccess) {
|
| | | if (uid == null || uid <= 0)
|
| | | return;
|
| | | |
| | |
|
| | | verifyCondition(uid);
|
| | | |
| | |
|
| | | // 验证上级
|
| | | if (inviteSuccess) {
|
| | | UserInfo boss = threeSaleSerivce.getBoss(uid);
|
| | |
| | | }
|
| | |
|
| | | // 邀请订单
|
| | | long countZiGou =hongBaoV2CountService.counOrderByUidAndOrderType(uid, Constant.VIP_ORDER_PAY,
|
| | | long countZiGou = hongBaoV2CountService.counOrderByUidAndOrderType(uid, Constant.VIP_ORDER_PAY,
|
| | | HongBaoV2.TYPE_ZIGOU);
|
| | | // 邀请订单
|
| | | long countShare = hongBaoV2CountService.counOrderByUidAndOrderType(uid, Constant.VIP_ORDER_PAY,
|
| | |
| | | String msg = "";
|
| | | if (countZiGou >= Constant.VIP_PROCESS_1_ZIGOU) {
|
| | | process = true;
|
| | | msg = "恭喜你!返利订单达到 "+ Constant.VIP_PROCESS_1_ZIGOU +"笔";
|
| | | msg = "恭喜你!返利订单达到 " + Constant.VIP_PROCESS_1_ZIGOU + "笔";
|
| | | } else if (countShare >= Constant.VIP_PROCESS_1_SHARE) {
|
| | | process = true;
|
| | | msg = "恭喜你!分享订单达到 "+ Constant.VIP_PROCESS_1_SHARE +"笔";
|
| | | msg = "恭喜你!分享订单达到 " + Constant.VIP_PROCESS_1_SHARE + "笔";
|
| | | } else if (firstTeam >= Constant.VIP_PROCESS_1_TEAM && secondTeam >= Constant.VIP_PROCESS_1_TEAM_SECOND) {
|
| | | process = true;
|
| | | msg = "直接粉丝达到"+ Constant.VIP_PROCESS_1_TEAM +"人,间接粉丝达到 "+ Constant.VIP_PROCESS_1_TEAM_SECOND +"人";
|
| | | msg = "直接粉丝达到" + Constant.VIP_PROCESS_1_TEAM + "人,间接粉丝达到 " + Constant.VIP_PROCESS_1_TEAM_SECOND + "人";
|
| | | }
|
| | | |
| | |
|
| | | if (process) {
|
| | | try {
|
| | | UserVIPPreInfo info = new UserVIPPreInfo();
|
| | |
| | | info.setCreateTime(new Date());
|
| | | info.setUpdateTime(new Date());
|
| | | addUserVIPPreInfo(info);
|
| | | |
| | |
|
| | | // 消息
|
| | | MsgAccountVipDTO msgDto = new MsgAccountVipDTO();
|
| | | msgDto.setStatus("系统已将你的账户由快省达人升级为普通会员");
|
| | |
| | | } catch (UserVIPPreInfoException e) {
|
| | | e.printStackTrace();
|
| | | }
|
| | | } |
| | | }
|
| | | return process;
|
| | | }
|
| | |
|
| | |
| | | String msg = "";
|
| | | if (countZiGou >= Constant.VIP_PROCESS_2_ZIGOU) {
|
| | | process = true;
|
| | | msg = "恭喜你!返利订单达到 "+ Constant.VIP_PROCESS_2_ZIGOU +"笔";
|
| | | msg = "恭喜你!返利订单达到 " + Constant.VIP_PROCESS_2_ZIGOU + "笔";
|
| | | } else if (countShare >= Constant.VIP_PROCESS_2_SHARE) {
|
| | | process = true;
|
| | | msg = "恭喜你!分享订单达到 "+ Constant.VIP_PROCESS_2_SHARE +"笔";
|
| | | msg = "恭喜你!分享订单达到 " + Constant.VIP_PROCESS_2_SHARE + "笔";
|
| | | } else if (firstTeam >= Constant.VIP_PROCESS_2_TEAM && secondTeam >= Constant.VIP_PROCESS_2_TEAM_SECOND) {
|
| | | process = true;
|
| | | msg = "直接粉丝达到"+ Constant.VIP_PROCESS_2_TEAM +"人,间接粉丝达到 "+ Constant.VIP_PROCESS_2_TEAM_SECOND +"人";
|
| | | msg = "直接粉丝达到" + Constant.VIP_PROCESS_2_TEAM + "人,间接粉丝达到 " + Constant.VIP_PROCESS_2_TEAM_SECOND + "人";
|
| | | }
|
| | | |
| | |
|
| | | if (process) {
|
| | | try {
|
| | | UserVIPPreInfo info = new UserVIPPreInfo();
|
| | |
| | | info.setCreateTime(new Date());
|
| | | info.setUpdateTime(new Date());
|
| | | addUserVIPPreInfo(info);
|
| | | |
| | |
|
| | | // 消息
|
| | | MsgAccountVipDTO msgDto = new MsgAccountVipDTO();
|
| | | msgDto.setStatus("系统已将你的账户由普通会员升级为高级会员");
|
| | |
| | | } catch (UserVIPPreInfoException e) {
|
| | | e.printStackTrace();
|
| | | }
|
| | | } |
| | | }
|
| | | return process;
|
| | | }
|
| | |
|
| | |
| | | public List<CommonOrderVO> searchOrderByUid(AcceptData acceptData, int page, int size, Long uid, List<ESOrder> list) throws Exception; |
| | | |
| | | public long countSearchOrderByUid(Long uid, List<ESOrder> list); |
| | | |
| | | /** |
| | | * 返回订单的第三方创建时间 |
| | | * @Title: getThirdCreateTime |
| | | * @Description: |
| | | * @param orderId |
| | | * @param sourceType |
| | | * @return |
| | | * Date 返回类型 |
| | | * @throws |
| | | */ |
| | | public Date getThirdCreateTime(String orderId,int sourceType); |
| | | |
| | | } |
| | |
| | | * @return
|
| | | */
|
| | | public boolean isVIP(Long uid);
|
| | | |
| | | |
| | | /**
|
| | | * 在某个时间是否为VIP
|
| | | * @Title: isVIP
|
| | | * @Description: |
| | | * @param uid
|
| | | * @param time
|
| | | * @return |
| | | * boolean 返回类型
|
| | | * @throws
|
| | | */
|
| | | public boolean isVIP(Long uid,Long time);
|
| | |
|
| | | /**
|
| | | * 根据UID检索
|
| | |
| | | package com.yeshi.fanli.service.inter.user.vip;
|
| | |
|
| | | import java.util.Date;
|
| | |
|
| | | import com.yeshi.fanli.entity.bus.user.vip.UserVIPPreInfo;
|
| | | import com.yeshi.fanli.exception.user.vip.UserVIPInfoException;
|
| | | import com.yeshi.fanli.exception.user.vip.UserVIPPreInfoException;
|
| | |
| | | * @return
|
| | | */
|
| | | public UserVIPPreInfo getLatestProcessInfo(Long uid);
|
| | | |
| | | /**
|
| | | * 获取某个时间的进度
|
| | | * |
| | | * @param uid
|
| | | * @return
|
| | | */
|
| | | public UserVIPPreInfo getProcessInfo(Long uid,Date time);
|
| | |
|
| | | /**
|
| | | * 会员等级添加并验证
|
| | |
| | | return level;
|
| | | return UserLevelEnum.daRen;
|
| | | }
|
| | | |
| | |
|
| | | /**
|
| | | * 获取当时的用户等级
|
| | | * @Title: getUserLevel
|
| | |
| | | * UserLevelEnum 返回类型
|
| | | * @throws
|
| | | */
|
| | | public UserLevelEnum getUserLevel(Long uid,Date date) {
|
| | | //TODO 按时间段获取
|
| | | if (userVIPInfoService.isVIP(uid))
|
| | | public UserLevelEnum getUserLevel(Long uid, Date date) {
|
| | | if (userVIPInfoService.isVIP(uid, date.getTime()))
|
| | | return UserLevelEnum.superVIP;
|
| | | UserVIPPreInfo info = userVIPPreInfoService.getLatestProcessInfo(uid);
|
| | | UserVIPPreInfo info = userVIPPreInfoService.getProcessInfo(uid, date);
|
| | | if (info != null)
|
| | | for (UserLevelEnum level : UserLevelEnum.values())
|
| | | if (level.getLevel() == info.getProcess())
|
| | |
| | | package com.yeshi.fanli.util.rocketmq.consumer.order;
|
| | |
|
| | | import java.util.Date;
|
| | | import java.util.List;
|
| | |
|
| | | import javax.annotation.Resource;
|
| | |
|
| | |
| | | import com.yeshi.fanli.dto.mq.user.body.UserSystemCouponUseMQMsg;
|
| | | import com.yeshi.fanli.entity.bus.user.UserSystemCouponRecord;
|
| | | import com.yeshi.fanli.entity.mq.MQUnSendInfo;
|
| | | import com.yeshi.fanli.entity.order.CommonOrder;
|
| | | import com.yeshi.fanli.entity.system.SystemCoupon;
|
| | | import com.yeshi.fanli.exception.money.OrderMoneySettleException;
|
| | | import com.yeshi.fanli.exception.mq.MQUnSendInfoException;
|
| | | import com.yeshi.fanli.exception.order.CommonOrderException;
|
| | | import com.yeshi.fanli.exception.order.InviteOrderSubsidyException;
|
| | | import com.yeshi.fanli.exception.order.OrderTeamRewardException;
|
| | | import com.yeshi.fanli.log.LogHelper;
|
| | | import com.yeshi.fanli.service.inter.mq.MQUnSendInfoService;
|
| | | import com.yeshi.fanli.service.inter.order.CommonOrderService;
|
| | | import com.yeshi.fanli.service.inter.order.InviteOrderSubsidyService;
|
| | | import com.yeshi.fanli.service.inter.order.InviteOrderSubsidyServiceV2;
|
| | | import com.yeshi.fanli.service.inter.order.OrderMoneySettleService;
|
| | | import com.yeshi.fanli.service.inter.user.UserSystemCouponRecordService;
|
| | | import com.yeshi.fanli.util.Constant;
|
| | | import com.yeshi.fanli.util.TimeUtil;
|
| | | import com.yeshi.fanli.util.rocketmq.MQMsgBodyFactory;
|
| | | import com.yeshi.fanli.util.rocketmq.MQTopicName;
|
| | |
|
| | |
| | | private InviteOrderSubsidyService inviteOrderSubsidyService;
|
| | |
|
| | | @Resource
|
| | | private InviteOrderSubsidyServiceV2 inviteOrderSubsidyServiceV2;
|
| | |
|
| | | @Resource
|
| | | private UserSystemCouponRecordService userSystemCouponRecordService;
|
| | |
|
| | | @Resource(name = "producer")
|
| | |
| | |
|
| | | @Resource
|
| | | private OrderMoneySettleService orderMoneySettleService;
|
| | |
|
| | | @Resource
|
| | | private CommonOrderService commonOrderService;
|
| | |
|
| | | // 团队奖励开始时间
|
| | | private static final long TEAM_REWARD_START_TIME = TimeUtil.convertToTimeTemp("2019-04-15", "yyyy-MM-dd");
|
| | |
|
| | | public InviteOrderSubsidyMessageListener() {
|
| | |
|
| | |
| | | // 查询上级红包
|
| | | OrderMQMsg dto = new Gson().fromJson(new String(message.getBody()), OrderMQMsg.class);
|
| | | if (dto != null) {
|
| | | try {
|
| | | inviteOrderSubsidyService.addOrUpdateByOrder(dto.getOrderId(), dto.getType());
|
| | | } catch (InviteOrderSubsidyException e) {
|
| | | // 查询出订单创建时间
|
| | | Date orderTime = commonOrderService.getThirdCreateTime(dto.getOrderId(), dto.getType());
|
| | | if (orderTime.getTime() >= TEAM_REWARD_START_TIME) {
|
| | | try {
|
| | | inviteOrderSubsidyServiceV2.addOrUpdateByOrder(dto.getOrderId(), dto.getType());
|
| | | return Action.CommitMessage;
|
| | | } catch (InviteOrderSubsidyException e) {
|
| | | e.printStackTrace();
|
| | | LogHelper.errorDetailInfo(e, new Gson().toJson(dto), "");
|
| | | } catch (OrderTeamRewardException e) {
|
| | | e.printStackTrace();
|
| | | LogHelper.errorDetailInfo(e, new Gson().toJson(dto), "");
|
| | | } catch (CommonOrderException e) {
|
| | | e.printStackTrace();
|
| | | LogHelper.errorDetailInfo(e, new Gson().toJson(dto), "");
|
| | | }
|
| | | return Action.ReconsumeLater;
|
| | | } else {
|
| | | try {
|
| | | inviteOrderSubsidyService.addOrUpdateByOrder(dto.getOrderId(), dto.getType());
|
| | | } catch (InviteOrderSubsidyException e) {
|
| | | LogHelper.errorDetailInfo(e, new Gson().toJson(dto), "");
|
| | | return Action.ReconsumeLater;
|
| | | }
|
| | | }
|
| | |
|
| | | }
|
| | | } else if (tag.equalsIgnoreCase(OrderTopicTagEnum.orderFanLiActual.name())) {
|
| | | OrderMoneyRecievedMQMsg dto = new Gson().fromJson(new String(message.getBody()),
|
| | |
| | | && record.getCouponType()
|
| | | .equalsIgnoreCase(SystemCoupon.CouponTypeEnum.rebatePercentCoupon.name())
|
| | | && record.getGoodSource() == dto.getSourceType()) {// 成功使用了奖励券
|
| | | inviteOrderSubsidyService.invalidByOrderIdAndSourceType(dto.getOrderId(),
|
| | | dto.getSourceType());
|
| | |
|
| | | Date orderTime = commonOrderService.getThirdCreateTime(dto.getOrderId(), dto.getType());
|
| | | if (orderTime.getTime() >= TEAM_REWARD_START_TIME) {
|
| | | inviteOrderSubsidyServiceV2.invalidByOrderIdAndSourceType(dto.getOrderId(),
|
| | | dto.getSourceType());
|
| | | } else
|
| | |
|
| | | inviteOrderSubsidyService.invalidByOrderIdAndSourceType(dto.getOrderId(),
|
| | | dto.getSourceType());
|
| | | } else {
|
| | | // 使数据有效
|
| | | try {
|
| | | inviteOrderSubsidyService.validByOrderIdAndSourceType(dto.getOrderId(),
|
| | | dto.getSourceType());
|
| | | Date orderTime = commonOrderService.getThirdCreateTime(dto.getOrderId(),
|
| | | dto.getType());
|
| | | if (orderTime.getTime() >= TEAM_REWARD_START_TIME) {
|
| | | inviteOrderSubsidyServiceV2.validByOrderIdAndSourceType(dto.getOrderId(),
|
| | | dto.getSourceType());
|
| | | } else
|
| | |
|
| | | inviteOrderSubsidyService.validByOrderIdAndSourceType(dto.getOrderId(),
|
| | | dto.getSourceType());
|
| | | } catch (InviteOrderSubsidyException e) {
|
| | | e.printStackTrace();
|
| | | return Action.ReconsumeLater;
|
| | |
| | | dto.getSourceType());
|
| | | if (count > 0) {
|
| | | // 使相关订单失效
|
| | | inviteOrderSubsidyService.invalidByOrderIdAndSourceType(dto.getOrderId(), dto.getSourceType());
|
| | | Date orderTime = commonOrderService.getThirdCreateTime(dto.getOrderId(), dto.getSourceType());
|
| | | if (orderTime.getTime() >= TEAM_REWARD_START_TIME) {
|
| | | inviteOrderSubsidyServiceV2.invalidByOrderIdAndSourceType(dto.getOrderId(),
|
| | | dto.getSourceType());
|
| | | } else
|
| | | inviteOrderSubsidyService.invalidByOrderIdAndSourceType(dto.getOrderId(),
|
| | | dto.getSourceType());
|
| | | }
|
| | | return Action.CommitMessage;
|
| | | }
|
| | |
| | | import com.yeshi.fanli.service.inter.hongbao.HongBaoV2SettleTempService;
|
| | | import com.yeshi.fanli.service.inter.order.CommonOrderService;
|
| | | import com.yeshi.fanli.service.inter.order.HongBaoOrderService;
|
| | | import com.yeshi.fanli.service.inter.order.InviteOrderSubsidyService;
|
| | | import com.yeshi.fanli.util.rocketmq.MQTopicName;
|
| | |
|
| | | @Component
|
| | |
| | |
|
| | | @Resource
|
| | | private HongBaoV2SettleTempService hongBaoV2SettleTempService;
|
| | |
|
| | | @Resource
|
| | | private InviteOrderSubsidyService inviteOrderSubsidyService;
|
| | |
|
| | | @Resource
|
| | | private CommonOrderService commonOrderService;
|