yujian
2019-11-14 7bedd903b10c125660d25373ffea23201bed22cc
邀请成功新版消息
11个文件已修改
181 ■■■■ 已修改文件
fanli/src/main/java/com/yeshi/fanli/dao/mybatis/ThreeSaleMapper.java 9 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/entity/bus/msg/MsgInviteDetail.java 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/mapping/ThreeSaleMapper.xml 9 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/service/impl/redpack/RedPackWinInviteServiceImpl.java 40 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/service/impl/user/invite/ThreeSaleSerivceImpl.java 18 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/service/impl/user/invite/UserInviteMsgNotificationServiceImpl.java 16 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/service/inter/user/invite/ThreeSaleSerivce.java 8 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/service/inter/user/invite/UserInviteMsgNotificationService.java 7 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/util/Constant.java 4 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/util/factory/msg/MsgInviteDetailFactory.java 31 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/util/factory/msg/UserMsgVOFactory.java 37 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
fanli/src/main/java/com/yeshi/fanli/dao/mybatis/ThreeSaleMapper.java
@@ -257,6 +257,11 @@
     */
    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);
}
fanli/src/main/java/com/yeshi/fanli/entity/bus/msg/MsgInviteDetail.java
@@ -17,7 +17,7 @@
@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) {
fanli/src/main/java/com/yeshi/fanli/mapping/ThreeSaleMapper.xml
@@ -5,11 +5,9 @@
    <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"
@@ -502,4 +500,11 @@
             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>
fanli/src/main/java/com/yeshi/fanli/service/impl/redpack/RedPackWinInviteServiceImpl.java
@@ -14,6 +14,7 @@
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;
@@ -90,18 +91,19 @@
    }
    
    
    @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;
            
@@ -110,8 +112,8 @@
                    activeLog.getVersionCode()))
                return;
            
            bossReward(boss.getId(), uid, source, orderNo);
        }
        // 奖励上级
        bossReward(bossId, uid, source, orderNo);
    }
    
    
@@ -123,7 +125,6 @@
     * @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);
@@ -212,7 +213,7 @@
        
        // 第一次到账的次月开始连续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;
        
        
@@ -247,16 +248,17 @@
    
    
    @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;
        
@@ -266,7 +268,7 @@
            return;
        // 同一队员奖励一次
        long totalReward = redPackWinInviteMapper.countByUidAndTeamUidAndType(boss.getId(), uid, RedPackWinInviteTypeEnum.inviteSucceed.name());
        long totalReward = redPackWinInviteMapper.countByUidAndTeamUidAndType(bossId, uid, RedPackWinInviteTypeEnum.inviteSucceed.name());
        if (totalReward > 0)
            return;
        
@@ -310,20 +312,20 @@
            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), "请到“我的-红包”中查看");
        }
    }
fanli/src/main/java/com/yeshi/fanli/service/impl/user/invite/ThreeSaleSerivceImpl.java
@@ -22,6 +22,7 @@
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;
@@ -35,6 +36,7 @@
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;
@@ -600,7 +602,18 @@
    @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() {
@@ -652,8 +665,11 @@
    @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);
    }
}
fanli/src/main/java/com/yeshi/fanli/service/impl/user/invite/UserInviteMsgNotificationServiceImpl.java
@@ -56,6 +56,22 @@
        }
    }
    @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);
fanli/src/main/java/com/yeshi/fanli/service/inter/user/invite/ThreeSaleSerivce.java
@@ -291,4 +291,12 @@
     */
    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);
}
fanli/src/main/java/com/yeshi/fanli/service/inter/user/invite/UserInviteMsgNotificationService.java
@@ -42,4 +42,11 @@
     * @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);
}
fanli/src/main/java/com/yeshi/fanli/util/Constant.java
@@ -129,9 +129,11 @@
    // 红包奖励订单实付款最低
    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;
fanli/src/main/java/com/yeshi/fanli/util/factory/msg/MsgInviteDetailFactory.java
@@ -37,6 +37,34 @@
        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;
    }
    /**
     * 扫描邀请二维码成功,但是未登录
@@ -63,6 +91,9 @@
        return detail;
    }
    /**
     * 邀请失败
     * 
fanli/src/main/java/com/yeshi/fanli/util/factory/msg/UserMsgVOFactory.java
@@ -989,6 +989,43 @@
            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)