| | |
| | | */ |
| | | ThreeSale selectLatestByWorkerIdAndState(@Param("workerId") Long workerId,@Param("state") int state); |
| | | |
| | | |
| | | |
| | | /** |
| | | * 根据时间查询邀请关系 |
| | | * @param uid |
| | | * @param time |
| | | * @return |
| | | */ |
| | | ThreeSale getByWorkerIdAndTime(@Param("workerId") Long workerId, @Param("time") long time); |
| | | } |
| | |
| | | @Table("yeshi_ec_msg_invite")
|
| | | public class MsgInviteDetail {
|
| | | public enum MsgTypeInviteTypeEnum {
|
| | | invite("邀请消息"), exchangeCode("恭喜你,邀请码兑换成功"), receiveGift("领取礼品");
|
| | | invite("邀请消息"), exchangeCode("恭喜你,邀请码兑换成功"), receiveGift("领取礼品"),inviteNew("邀请消息-新版");
|
| | | private final String desc;
|
| | |
|
| | | private MsgTypeInviteTypeEnum(String desc) {
|
| | |
| | | <resultMap id="BaseResultMap" type="com.yeshi.fanli.entity.bus.user.ThreeSale"> |
| | | <id column="id" property="id" jdbcType="BIGINT" /> |
| | | <result column="state" property="state" jdbcType="BOOLEAN" /> |
| | | |
| | | <result column="succeedTime" property="succeedTime" jdbcType="BIGINT" /> |
| | | <result column="createTime" property="createTime" jdbcType="BIGINT" /> |
| | | <result column="updateTime" property="updateTime" jdbcType="BIGINT" /> |
| | | |
| | | <result column="expire" property="expire" jdbcType="INTEGER" /> |
| | | |
| | | <association property="boss" column="boss_id" |
| | |
| | | AND <![CDATA[t.createTime >= #{minTime} AND t.createTime <= #{maxTime}]]> |
| | | </select> |
| | | |
| | | <select id="getByWorkerIdAndTime" resultMap="BaseResultMap"> |
| | | SELECT * FROM yeshi_ec_threesale t |
| | | WHERE t.`worker_id` = #{workerId} AND t.`state` = 1 |
| | | <![CDATA[AND t.succeedTime >= #{time}]]> |
| | | </select> |
| | | |
| | | |
| | | </mapper> |
| | |
| | | import com.yeshi.fanli.dao.mybatis.redpack.RedPackWinInviteMapper;
|
| | | import com.yeshi.fanli.dto.msg.MsgRedPackAddContentDTO;
|
| | | import com.yeshi.fanli.entity.bus.msg.MsgMoneyDetail.MsgTypeMoneyTypeEnum;
|
| | | import com.yeshi.fanli.entity.bus.user.ThreeSale;
|
| | | import com.yeshi.fanli.entity.bus.user.UserActiveLog;
|
| | | import com.yeshi.fanli.entity.bus.user.UserExtraTaoBaoInfo;
|
| | | import com.yeshi.fanli.entity.bus.user.UserInfo;
|
| | |
| | | }
|
| | |
|
| | |
|
| | | @RedPackGetVersionLimit(uid = "#uid")
|
| | | @RequestSerializableByKeyService(key = "#uid")
|
| | | @Transactional(rollbackFor = Exception.class)
|
| | | @Override
|
| | | public void orderArriveReward(Long uid, Integer source, String orderNo) throws Exception {
|
| | | if (uid == null || source == null || orderNo == null)
|
| | | if (uid == null || source == null || StringUtil.isNullOrEmpty(orderNo))
|
| | | return;
|
| | |
|
| | | // 上一级的奖励
|
| | | UserInfo boss = threeSaleSerivce.getBoss(uid);
|
| | | if(boss != null) {
|
| | | UserActiveLog activeLog = userActiveLogService.getUserLatestActiveInfo(boss.getId());
|
| | | ThreeSale threeSale = threeSaleSerivce.getByWorkerIdAndTime(uid, Constant.RED_PACK_REWARD_TIME);
|
| | | if(threeSale == null)
|
| | | return;
|
| | | |
| | | Long bossId = threeSale.getBoss().getId();
|
| | | UserActiveLog activeLog = userActiveLogService.getUserLatestActiveInfo(bossId);
|
| | | if (activeLog == null)
|
| | | return;
|
| | |
|
| | |
| | | activeLog.getVersionCode()))
|
| | | return;
|
| | |
|
| | | bossReward(boss.getId(), uid, source, orderNo);
|
| | | }
|
| | | // 奖励上级
|
| | | bossReward(bossId, uid, source, orderNo);
|
| | | }
|
| | |
|
| | |
|
| | |
| | | * @param orderNo
|
| | | * @throws Exception
|
| | | */
|
| | | @RedPackGetVersionLimit(uid = "#uid")
|
| | | @Transactional
|
| | | private void bossReward(Long uid, Long teamUid, Integer source, String orderNo) throws Exception {
|
| | | firstSharedOrderRewardToBoss(uid, teamUid, source, orderNo);
|
| | |
| | |
|
| | | // 第一次到账的次月开始连续15个月 自然月获得(已到账)
|
| | | int monthSpace = DateUtil.getMonthSpace( order.getAccountTime(), firstorder.getAccountTime());
|
| | | if (monthSpace == 0 || monthSpace > Constant.RED_PACK_REWARd_MONTH) |
| | | if (monthSpace == 0 || monthSpace > Constant.RED_PACK_REWARD_MONTH) |
| | | return;
|
| | |
|
| | |
|
| | |
| | |
|
| | |
|
| | | @Override
|
| | | @RedPackGetVersionLimit(uid = "#uid")
|
| | | @RequestSerializableByKeyService(key = "#uid")
|
| | | @Transactional(rollbackFor = Exception.class)
|
| | | public void inviteSucceedReward(Long uid) throws Exception{
|
| | | // 验证是否存在上级
|
| | | UserInfo boss = threeSaleSerivce.getBoss(uid);
|
| | | if(boss == null) |
| | | ThreeSale threeSale = threeSaleSerivce.getByWorkerIdAndTime(uid, Constant.RED_PACK_REWARD_TIME);
|
| | | if (threeSale == null)
|
| | | return;
|
| | | // 上级id
|
| | | Long bossId = threeSale.getBoss().getId();
|
| | |
|
| | | UserActiveLog activeLog = userActiveLogService.getUserLatestActiveInfo(boss.getId());
|
| | | UserActiveLog activeLog = userActiveLogService.getUserLatestActiveInfo(bossId);
|
| | | if (activeLog == null)
|
| | | return;
|
| | |
|
| | |
| | | return;
|
| | |
|
| | | // 同一队员奖励一次
|
| | | long totalReward = redPackWinInviteMapper.countByUidAndTeamUidAndType(boss.getId(), uid, RedPackWinInviteTypeEnum.inviteSucceed.name());
|
| | | long totalReward = redPackWinInviteMapper.countByUidAndTeamUidAndType(bossId, uid, RedPackWinInviteTypeEnum.inviteSucceed.name());
|
| | | if (totalReward > 0)
|
| | | return;
|
| | |
|
| | |
| | | winInvite.setCreateTime(new Date());
|
| | | winInvite.setUpdateTime(new Date());
|
| | | winInvite.setType(RedPackWinInviteTypeEnum.inviteSucceed);
|
| | | winInvite.setUid(boss.getId());
|
| | | winInvite.setUid(bossId);
|
| | | winInvite.setTeamUid(uid);
|
| | | winInvite.setMoney(money);
|
| | | redPackWinInviteMapper.insertSelective(winInvite);
|
| | |
|
| | | // 增加红包
|
| | | redPackBalanceService.addRedPack(boss.getId(), money, RedPackDetailFactory.createInvite(winInvite));
|
| | | redPackBalanceService.addRedPack(bossId, money, RedPackDetailFactory.createInvite(winInvite));
|
| | |
|
| | | // 消息
|
| | | MsgRedPackAddContentDTO dto = new MsgRedPackAddContentDTO();
|
| | | dto.setTitle("红包增加");
|
| | | dto.setMoney("¥" + money.setScale(2));
|
| | | dto.setBalance("¥" + redPackBalanceService.getBalance(boss.getId()).setScale(2));
|
| | | userMoneyMsgNotificationService.redPackMsg(boss.getId(), MsgTypeMoneyTypeEnum.redPackInviteSucceed,
|
| | | dto.setBalance("¥" + redPackBalanceService.getBalance(bossId).setScale(2));
|
| | | userMoneyMsgNotificationService.redPackMsg(bossId, MsgTypeMoneyTypeEnum.redPackInviteSucceed,
|
| | | new Gson().toJson(dto), "请到“我的-红包”中查看");
|
| | | }
|
| | | }
|
| | |
| | | import com.yeshi.fanli.dto.mq.user.body.UserInviteMQMsg;
|
| | | import com.yeshi.fanli.entity.bus.user.ThreeSale;
|
| | | import com.yeshi.fanli.entity.bus.user.ThreeSaleExtraInfo;
|
| | | import com.yeshi.fanli.entity.bus.user.UserActiveLog;
|
| | | import com.yeshi.fanli.entity.bus.user.UserInfo;
|
| | | import com.yeshi.fanli.exception.user.ThreeSaleException;
|
| | | import com.yeshi.fanli.service.inter.order.config.HongBaoManageService;
|
| | |
| | | import com.yeshi.fanli.service.inter.user.invite.UserInviteMsgNotificationService;
|
| | | import com.yeshi.fanli.util.Constant;
|
| | | import com.yeshi.fanli.util.StringUtil;
|
| | | import com.yeshi.fanli.util.VersionUtil;
|
| | | import com.yeshi.fanli.util.rocketmq.MQTopicName;
|
| | |
|
| | | import net.sf.json.JSONArray;
|
| | |
| | | @Transactional
|
| | | private void inviteSuccess(Long bossId, Long workerId, ThreeSale threeSale) {
|
| | | // 邀请消息
|
| | | UserActiveLog activeLog = userActiveLogService.getUserLatestActiveInfo(bossId);
|
| | | if (activeLog != null) {
|
| | | if (VersionUtil.greaterThan_2_0_2("appstore".equalsIgnoreCase(activeLog.getChannel()) ? "ios" : "android",
|
| | | activeLog.getVersionCode())) { // 2.0.2版本以上
|
| | | userInviteMsgNotificationService.inviteSuccess2_0_2(bossId, threeSale);
|
| | | } else { // 最初消息
|
| | | userInviteMsgNotificationService.inviteSuccess(threeSale.getBoss().getId(), threeSale);
|
| | | }
|
| | | } else { // 最初消息
|
| | | userInviteMsgNotificationService.inviteSuccess(threeSale.getBoss().getId(), threeSale);
|
| | | }
|
| | | |
| | | executor.execute(new Runnable() {
|
| | | @Override
|
| | | public void run() {
|
| | |
| | |
|
| | | @Override
|
| | | public ThreeSale selectLatestByWorkerIdAndState(Long workerId, int state) {
|
| | |
|
| | | return threeSaleMapper.selectLatestByWorkerIdAndState(workerId, state);
|
| | | }
|
| | |
|
| | | @Override
|
| | | public ThreeSale getByWorkerIdAndTime(Long workerId, long time) {
|
| | | return threeSaleMapper.getByWorkerIdAndTime(workerId, time);
|
| | | }
|
| | | }
|
| | |
| | | }
|
| | | }
|
| | |
|
| | | |
| | | @Override
|
| | | public void inviteSuccess2_0_2(Long uid, ThreeSale sale) {
|
| | | MsgInviteDetail detail = MsgInviteDetailFactory.createInviteSuccess2_0_2(uid, sale);
|
| | | msgInviteDetailService.insertSelective(detail);
|
| | | PushContentDTO dto = PushMsgFactory.createInviteTeamSuccess(new Date(), sale.getWorker().getNickName());
|
| | | try {
|
| | | pushService.pushZNX(uid, dto.getTitle(), dto.getContent(), null, null);
|
| | | } catch (NumberFormatException e) {
|
| | | e.printStackTrace();
|
| | | } catch (PushException e) {
|
| | | e.printStackTrace();
|
| | | }
|
| | | }
|
| | |
|
| | | |
| | | @Override
|
| | | public void inviteFail(Long uid, ThreeSale sale) {
|
| | | MsgInviteDetail detail = MsgInviteDetailFactory.createInviteFail(sale, uid, null);
|
| | |
| | | */
|
| | | public List<ThreeSale> listSecondTeam(long start, int count, Long uid, Integer state);
|
| | |
|
| | | /**
|
| | | * 查询邀请关系 时间筛选
|
| | | * @param workerId 下级id
|
| | | * @param time
|
| | | * @return
|
| | | */
|
| | | public ThreeSale getByWorkerIdAndTime(Long workerId, long time);
|
| | |
|
| | | }
|
| | |
| | | * @param content
|
| | | */
|
| | | public void receiveGift(Long uid, String beizu, MsgInviteContentDTO content);
|
| | |
|
| | | /**
|
| | | * 2.0.2 版本新邀请消息
|
| | | * @param uid
|
| | | * @param sale
|
| | | */
|
| | | public void inviteSuccess2_0_2(Long uid, ThreeSale sale);
|
| | | }
|
| | |
| | | // 红包奖励订单实付款最低
|
| | | public static final BigDecimal RED_PACK_PAY_MIN = new BigDecimal("10");
|
| | | // 红包奖励分享订单连续奖励月数
|
| | | public static final int RED_PACK_REWARd_MONTH = 15;
|
| | | public static final int RED_PACK_REWARD_MONTH = 15;
|
| | | // 红包奖励-单位时间类累计产生≥200金币
|
| | | public static final long RED_PACK_GOLD_COIN = 200;
|
| | | // 红包奖励-邀请时间筛选 2019-11-14 11:51:43
|
| | | public static final long RED_PACK_REWARD_TIME = 1573703503000L;
|
| | |
|
| | | // 新人奖励连续天数
|
| | | public static final long RED_PACK_NEW_USER_DAYS = 7;
|
| | |
| | |
|
| | | return detail;
|
| | | }
|
| | | /**
|
| | | * 邀请成功
|
| | | * |
| | | * @param threeSale
|
| | | * @param uid
|
| | | * @return
|
| | | */
|
| | | public static MsgInviteDetail createInviteSuccess2_0_2(Long uid, ThreeSale threeSale) {
|
| | | if (threeSale == null || uid == null)
|
| | | return null;
|
| | |
|
| | | MsgInviteContentDTO content = new MsgInviteContentDTO();
|
| | | content.setMode("必要条件+选择条件(三选一) ");
|
| | | content.setCode("队员绑定电话号码+授权淘宝 ");
|
| | | content.setState("成功邀请一个队员,队员熟练使用App还可获得红包 ");
|
| | | content.setInviter("1.产生累计≥200金币/2.任意订单/3.成功邀请一个队员");
|
| | | |
| | | MsgInviteDetail detail = new MsgInviteDetail();
|
| | | detail.setBeiZhu("满足获得红包条件后系统将自动下发到“我的-红包”中");
|
| | | detail.setInviteUser(threeSale);
|
| | | detail.setCreateTime(new Date());
|
| | | detail.setUpdateTime(new Date());
|
| | | detail.setDesc(new Gson().toJson(content));
|
| | | detail.setMsgType(MsgTypeInviteTypeEnum.inviteNew);
|
| | | detail.setRead(false);
|
| | | detail.setUser(new UserInfo(uid));
|
| | | return detail;
|
| | | }
|
| | |
|
| | | /**
|
| | | * 扫描邀请二维码成功,但是未登录
|
| | |
| | | return detail;
|
| | | }
|
| | |
|
| | | |
| | | |
| | |
|
| | | /**
|
| | | * 邀请失败
|
| | | *
|
| | |
| | |
|
| | | return new UserMsgVO("http://img.flqapp.com/resource/msg/icon_msg_invite.png", dto.getTitle(),
|
| | | msg.getUpdateTime() == null ? msg.getCreateTime() : msg.getUpdateTime(), items);
|
| | | } else if (msgType == MsgTypeInviteTypeEnum.inviteNew) {
|
| | | if (StringUtil.isNullOrEmpty(msg.getDesc()))
|
| | | return null;
|
| | |
|
| | | MsgInviteContentDTO dto = new Gson().fromJson(msg.getDesc(), MsgInviteContentDTO.class);
|
| | | if (dto == null)
|
| | | return null;
|
| | |
|
| | | List<CommonMsgItemVO> items = new ArrayList<>();
|
| | | List<ClientTextStyleVO> contentList = new ArrayList<>();
|
| | | contentList.add(new ClientTextStyleVO(msg.getInviteUser().getWorker().getNickName() + "", COLOR_CONTENT,
|
| | | msg.getInviteUser().getWorker().getPortrait()));
|
| | | items.add(new CommonMsgItemVO(new ClientTextStyleVO("被邀请人", COLOR_TITLE), contentList));
|
| | | |
| | | contentList = new ArrayList<>();
|
| | | contentList.add(new ClientTextStyleVO(dto.getState() + "", COLOR_CONTENT));
|
| | | items.add(new CommonMsgItemVO(new ClientTextStyleVO("邀请状态", COLOR_TITLE), contentList));
|
| | |
|
| | | contentList = new ArrayList<>();
|
| | | contentList.add(new ClientTextStyleVO(dto.getMode() + "", COLOR_CONTENT));
|
| | | items.add(new CommonMsgItemVO(new ClientTextStyleVO("熟练使用", COLOR_TITLE), contentList));
|
| | | |
| | | contentList = new ArrayList<>();
|
| | | contentList.add(new ClientTextStyleVO(dto.getCode() + "", COLOR_CONTENT));
|
| | | items.add(new CommonMsgItemVO(new ClientTextStyleVO("必要条件", COLOR_TITLE), contentList));
|
| | |
|
| | | contentList = new ArrayList<>();
|
| | | contentList.add(new ClientTextStyleVO(dto.getInviter() + "", COLOR_CONTENT));
|
| | | items.add(new CommonMsgItemVO(new ClientTextStyleVO("选择条件", COLOR_TITLE), contentList));
|
| | |
|
| | | contentList = new ArrayList<>();
|
| | | contentList.add(new ClientTextStyleVO(StringUtil.isNullOrEmpty(msg.getBeiZhu()) ? "无" : msg.getBeiZhu(),
|
| | | COLOR_CONTENT));
|
| | | items.add(new CommonMsgItemVO(new ClientTextStyleVO("备 注", COLOR_TITLE), contentList));
|
| | |
|
| | | return new UserMsgVO("http://img.flqapp.com/resource/msg/icon_msg_invite.png", "邀请提醒 ",
|
| | | msg.getUpdateTime() == null ? msg.getCreateTime() : msg.getUpdateTime(), items);
|
| | | }
|
| | |
|
| | | if (msg.getInviteUser() == null || msg.getInviteUser().getWorker() == null)
|