| | |
| | | import com.google.gson.stream.JsonReader;
|
| | | import com.google.gson.stream.JsonWriter;
|
| | | import com.yeshi.fanli.entity.accept.AcceptData;
|
| | | import com.yeshi.fanli.entity.bus.user.UserInfo;
|
| | | import com.yeshi.fanli.entity.redpack.RedPackDetail.RedPackDetailTypeEnum;
|
| | | import com.yeshi.fanli.entity.redpack.RedPackExchange;
|
| | | import com.yeshi.fanli.entity.redpack.RedPackWinInvite;
|
| | | import com.yeshi.fanli.entity.redpack.RedPackWinInvite.RedPackWinInviteTypeEnum;
|
| | | import com.yeshi.fanli.exception.redpack.RedPackExchangeException;
|
| | | import com.yeshi.fanli.exception.redpack.RedPackGiveRecordException;
|
| | | import com.yeshi.fanli.service.inter.redpack.RedPackBalanceService;
|
| | |
| | | import com.yeshi.fanli.service.inter.redpack.RedPackDetailService;
|
| | | import com.yeshi.fanli.service.inter.redpack.RedPackExchangeService;
|
| | | import com.yeshi.fanli.service.inter.redpack.RedPackGiveRecordService;
|
| | | import com.yeshi.fanli.service.inter.redpack.RedPackWinInviteService;
|
| | | import com.yeshi.fanli.service.inter.user.UserInfoService;
|
| | | import com.yeshi.fanli.util.Constant;
|
| | | import com.yeshi.fanli.util.TimeUtil;
|
| | | import com.yeshi.fanli.vo.redpack.RedPackDetailVO;
|
| | | import com.yeshi.fanli.vo.redpack.RedPackWinInviteVO;
|
| | |
|
| | | import net.sf.json.JSONObject;
|
| | |
|
| | |
| | |
|
| | | @Resource
|
| | | private RedPackExchangeService redPackExchangeService;
|
| | | |
| | | @Resource |
| | | private RedPackWinInviteService redPackWinInviteService;
|
| | | |
| | | @Resource |
| | | private UserInfoService userInfoService;
|
| | | |
| | |
|
| | | /**
|
| | | * 统计淘礼金
|
| | | * 统计
|
| | | *
|
| | | * @param acceptData
|
| | | * @param uid
|
| | |
| | | out.print(JsonUtil.loadFalseResult(1, e.getMsg()));
|
| | | }
|
| | | }
|
| | | |
| | | |
| | | |
| | | @RequestMapping(value = "getRewardList", method = RequestMethod.POST)
|
| | | public void getRewardList(AcceptData acceptData, Integer page, Long uid, PrintWriter out) {
|
| | | if (uid == null || uid <= 0) {
|
| | | out.print(JsonUtil.loadFalseResult(1, "用户未登录"));
|
| | | return;
|
| | | }
|
| | | |
| | | if (page == null || page < 1) {
|
| | | out.print(JsonUtil.loadFalseResult(1, "页码不正确"));
|
| | | return;
|
| | | }
|
| | | |
| | | List<RedPackWinInviteVO> list = new ArrayList<RedPackWinInviteVO>();
|
| | | |
| | | List<RedPackWinInvite> listRecord = redPackWinInviteService.getRewardList((page - 1) * Constant.PAGE_SIZE, Constant.PAGE_SIZE, uid);
|
| | | if (listRecord != null && !listRecord.isEmpty()) {
|
| | | for (RedPackWinInvite record: listRecord) {
|
| | | UserInfo user = null;
|
| | | RedPackWinInviteVO winVO = new RedPackWinInviteVO();
|
| | | RedPackWinInviteTypeEnum type = record.getType();
|
| | | if (RedPackWinInviteTypeEnum.newUserReward == type) {
|
| | | user = userInfoService.selectByPKey(uid);
|
| | | } else {
|
| | | user = userInfoService.selectByPKey(record.getTeamUid());
|
| | | }
|
| | | winVO.setPortrait(user.getPortrait());
|
| | | winVO.setNickName(user.getNickName());
|
| | | winVO.setDesc(type.getDesc());
|
| | | winVO.setMoney(record.getMoney().toString());
|
| | | list.add(winVO);
|
| | | }
|
| | | }
|
| | | |
| | | JSONObject data = new JSONObject();
|
| | | data.put("count", redPackWinInviteService.countRewardRecord(uid));
|
| | | data.put("list", JsonUtil.getApiCommonGson().toJson(list));
|
| | | out.print(JsonUtil.loadTrueResult(data)); |
| | | }
|
| | | }
|
| | |
| | | */
|
| | | List<IntegralTaskRecord> listByUidAndTaskId(@Param("uid") Long uid, @Param("taskId") Long taskId,
|
| | | @Param("start") long start, @Param("count") int count);
|
| | | |
| | | /**
|
| | | * 统计总金币
|
| | | * @param uid
|
| | | * @return
|
| | | */
|
| | | long getTotalGoldCoinByUid(@Param("uid") Long uid);
|
| | | }
|
| | |
| | | package com.yeshi.fanli.dao.mybatis.redpack; |
| | | |
| | | import java.util.List; |
| | | |
| | | import org.apache.ibatis.annotations.Param; |
| | | |
| | | import com.yeshi.fanli.dao.BaseMapper; |
| | | import com.yeshi.fanli.entity.redpack.RedPackGiveRecord; |
| | | |
| | | public interface RedPackGiveRecordMapper extends BaseMapper<RedPackGiveRecord> { |
| | | |
| | | /** |
| | | * 口令失效 |
| | | * @param token |
| | | * @return |
| | | */ |
| | | List<RedPackGiveRecord> overdueList(@Param("count") int count); |
| | | } |
| | |
| | | package com.yeshi.fanli.dao.mybatis.redpack; |
| | | |
| | | import java.util.List; |
| | | |
| | | import org.apache.ibatis.annotations.Param; |
| | | |
| | | import com.yeshi.fanli.dao.BaseMapper; |
| | |
| | | * @return |
| | | */ |
| | | long countByUidAndType(@Param("uid")Long uid, @Param("type")String type); |
| | | |
| | | |
| | | /** |
| | | * 统计用户、下级、类型的数量 |
| | | * @param uid |
| | | * @param type |
| | | * @return |
| | | */ |
| | | long countByUidAndTeamUidAndType(@Param("uid")Long uid,@Param("teamUid")Long teamUid, @Param("type")String type); |
| | | |
| | | |
| | | /** |
| | | * 查询用户记录 |
| | | * @param start |
| | | * @param count |
| | | * @return |
| | | */ |
| | | List<RedPackWinInvite> getRewardList(@Param("start")int start, @Param("count")int count, @Param("uid")Long uid); |
| | | |
| | | |
| | | Long countRewardRecord(@Param("uid")Long uid); |
| | | } |
| | |
| | | private String title; // 标题
|
| | | private String userInfo; // 用户信息
|
| | | private String time; // 时间
|
| | | private String giveTime; // 赠送时间
|
| | | private String money; // 金额
|
| | |
|
| | | public String getTitle() {
|
| | |
| | | public void setMoney(String money) {
|
| | | this.money = money;
|
| | | }
|
| | |
|
| | | public String getGiveTime() {
|
| | | return giveTime;
|
| | | }
|
| | |
|
| | | public void setGiveTime(String giveTime) {
|
| | | this.giveTime = giveTime;
|
| | | }
|
| | | }
|
| | |
| | | subSidy("额外补贴"),
|
| | | redPackGiveOff("赠送红包完成"),
|
| | | redPackReceiveOff("赠送红包领取"),
|
| | | redPackGiveBack("红包退回"),
|
| | | redPackExchangePass("红包提现成功"),
|
| | | redPackExchangeReject("红包提现失败"),
|
| | | redPackNewUserReward("新人奖励-完成首笔订单"),
|
| | |
| | | musicRecharge("音乐会员充值", "http://img.flqapp.com/img/tlj/icon_tlj.png"),
|
| | | violation("红包涉嫌违规", "http://img.flqapp.com/img/tlj/icon_tlj.png"),
|
| | |
|
| | | giveOthers("红包赠送待领取中", "http://img.flqapp.com/img/tlj/icon_tlj.png"), |
| | | giveOthersSucceed("红包赠送领取成功", "http://img.flqapp.com/img/tlj/icon_tlj.png"), |
| | | giveOthersFail("红包赠送超时退回", "http://img.flqapp.com/img/tlj/icon_tlj.png"), |
| | | giveOthersReceive("好友赠送", "http://img.flqapp.com/img/tlj/icon_tlj.png"), |
| | | giveOthers("红包赠送待领取中", "http://img.flqapp.com/resource/msg/icon_hongbao_give.png"), |
| | | giveOthersSucceed("红包赠送领取成功", "http://img.flqapp.com/resource/msg/icon_hongbao_give.png"), |
| | | giveOthersFail("红包赠送超时退回", "http://img.flqapp.com/resource/msg/icon_hongbao_give.png"), |
| | | giveOthersReceive("好友赠送", "http://img.flqapp.com/resource/msg/icon_hongbao_give.png"), |
| | |
|
| | | redExchange("红包提现中", "http://img.flqapp.com/resource/msg/icon_hongbao_tixian.png"),
|
| | | redExchangePass("红包提现成功", "http://img.flqapp.com/resource/msg/icon_hongbao_tixian.png"),
|
| | |
| | | and #{maxTime}>ir_create_time
|
| | | </if>
|
| | | </select>
|
| | | |
| | | <select id="getTotalGoldCoinByUid" resultType="Long">
|
| | | select IFNULL(SUM(ir_gold_coin),0) from yeshi_ec_integral_task_record |
| | | where ir_uid=#{uid}
|
| | | </select>
|
| | |
|
| | | </mapper> |
| | |
| | | <if test="state != null">rpgr_state=#{state,jdbcType=INTEGER},</if> |
| | | </set> where rpgr_id = #{id,jdbcType=BIGINT} |
| | | </update> |
| | | |
| | | <select id="overdueList" resultMap="BaseResultMap"> |
| | | SELECT * FROM yeshi_red_pack_give_record |
| | | WHERE rpgr_state = 0 AND rpgr_end_time IS NOT NULL AND rpgr_end_time <![CDATA[<]]> NOW() |
| | | LIMIT #{count} |
| | | </select> |
| | | |
| | | </mapper> |
| | |
| | | WHERE d.`rwr_uid` = #{uid} AND d.`rwr_type` = #{type} |
| | | </select> |
| | | |
| | | <select id="countByUidAndTeamUidAndType" resultType="Long"> |
| | | SELECT IFNULL(COUNT(d.`rwr_id`),0) FROM yeshi_red_pack_win_invite d |
| | | WHERE d.`rwr_uid` = #{uid} AND d.`rwr_team_uid` = #{teamUid} AND d.`rwr_type` = #{type} |
| | | </select> |
| | | |
| | | <select id="getRewardList" resultMap="BaseResultMap"> |
| | | SELECT * FROM yeshi_red_pack_win_invite d |
| | | WHERE d.`rwr_uid` = #{uid} |
| | | ORDER BY d.`rwr_id` DESC |
| | | LIMIT #{start},#{count} |
| | | </select> |
| | | |
| | | <select id="countRewardRecord" resultType="Long"> |
| | | SELECT IFNULL(COUNT(d.`rwr_id`),0) FROM yeshi_red_pack_win_invite d |
| | | WHERE d.`rwr_uid` = #{uid} |
| | | </select> |
| | | |
| | | </mapper> |
| | |
| | | import com.yeshi.fanli.entity.bus.msg.MsgMoneyDetail;
|
| | | import com.yeshi.fanli.entity.bus.msg.MsgMoneyDetail.MsgTypeMoneyTypeEnum;
|
| | | import com.yeshi.fanli.exception.msg.MsgMoneyDetailException;
|
| | | import com.yeshi.fanli.log.LogHelper;
|
| | | import com.yeshi.fanli.service.inter.money.msg.MsgMoneyDetailService;
|
| | | import com.yeshi.fanli.service.inter.msg.UserMsgReadStateService;
|
| | | import com.yeshi.fanli.util.Constant;
|
| | |
| | | msgMoneyDetailMapper.updateByPrimaryKeySelective(update);
|
| | | }
|
| | | } else if (detail.getMsgType() == MsgTypeMoneyTypeEnum.redPackGiveOff
|
| | | || detail.getMsgType() == MsgTypeMoneyTypeEnum.redPackReceiveOff
|
| | | || detail.getMsgType() == MsgTypeMoneyTypeEnum.redPackGiveBack
|
| | | || detail.getMsgType() == MsgTypeMoneyTypeEnum.redPackExchangePass
|
| | | || detail.getMsgType() == MsgTypeMoneyTypeEnum.redPackExchangeReject
|
| | | || detail.getMsgType() == MsgTypeMoneyTypeEnum.redPackNewUserReward
|
| | |
| | | detail.setUpdateTime(new Date());
|
| | | detail.setRead(false);
|
| | | msgMoneyDetailMapper.insertSelective(detail);
|
| | | |
| | | System.out.println("1-insertSelective执行数据。。。。。。。。。。" + detail.getId());
|
| | | LogHelper.test("1-insertSelective执行数据。。。。。。。。。。" + detail.getId());
|
| | | } else if (detail.getMsgType() == MsgTypeMoneyTypeEnum.subSidy) {
|
| | | if (detail.getMoney() == null || detail.getUser() == null)
|
| | | throw new MsgMoneyDetailException(2, "消息信息不全");
|
| | |
| | | }
|
| | |
|
| | | userMsgReadStateService.addMoneyMsgUnReadCount(detail.getUser().getId(), 1);
|
| | | System.out.println("1-insertSelective执行数据完成。。。。。。。。。。");
|
| | | LogHelper.test("2-insertSelective执行数据。。。。。。。。。。" + detail.getId());
|
| | | }
|
| | |
|
| | | @Override
|
| | |
| | | }
|
| | | }
|
| | |
|
| | | @Async
|
| | | @Override
|
| | | public void redPackMsg(Long uid, MsgTypeMoneyTypeEnum type, String content, String beiZhu) {
|
| | | MsgMoneyDetail detail = MsgMoneyDetailFactory.createRedPackMsg(uid, type, content, beiZhu);
|
| | |
| | | }
|
| | |
|
| | | boolean rewardOrder = false;
|
| | |
|
| | | int type = 1; // 1 常规跳转页面 2弹出选项(奖励券)
|
| | | if (rewardSuccess) {
|
| | | // 奖励成功
|
| | | rewardOrder = true;
|
| | | if (!VersionUtil.greaterThan_2_0_2(acceptData.getPlatform(), acceptData.getVersion())) {
|
| | | rewardOrder = true; //奖励成功 2.0.2 消失
|
| | | }
|
| | | } else if (hasRewardCoupon && !freeOrder && HongBaoV2.TYPE_ZIGOU == hongBaoType
|
| | | && HongBaoV2.STATE_YILINGQU == hongBaoState) {
|
| | | // 有可用的奖励券 、非免单订单 、且已到账的 、返利订单
|
| | |
| | | throw new RedPackBalanceException(1, "参数传递不完整");
|
| | | // 加入明细
|
| | | redPackDetailService.insertSelective(detail);
|
| | | // 减少红包
|
| | | redPackBalanceMapper.addRedPack(uid, money);
|
| | | // 添加红包
|
| | | RedPackBalance redPackBalance = redPackBalanceMapper.selectForUpdate(uid);
|
| | | if (redPackBalance == null) {
|
| | | redPackBalance = new RedPackBalance();
|
| | | redPackBalance.setId(uid);
|
| | | redPackBalance.setMoney(money);
|
| | | redPackBalance.setCreateTime(new Date());
|
| | | redPackBalance.setUpdateTime(new Date());
|
| | | redPackBalanceMapper.insertSelective(redPackBalance);
|
| | | } else {
|
| | | redPackBalanceMapper.addRedPack(uid, money);
|
| | | }
|
| | | }
|
| | |
|
| | |
|
| | |
| | | package com.yeshi.fanli.service.impl.redpack;
|
| | |
|
| | | import java.math.BigDecimal;
|
| | | import java.text.SimpleDateFormat;
|
| | | import java.util.Date;
|
| | | import java.util.List;
|
| | |
|
| | | import javax.annotation.Resource;
|
| | |
|
| | |
| | | import org.springframework.transaction.annotation.Transactional;
|
| | | import org.yeshi.utils.DateUtil;
|
| | |
|
| | | import com.google.gson.Gson;
|
| | | import com.yeshi.fanli.dao.mybatis.redpack.RedPackGiveRecordMapper;
|
| | | import com.yeshi.fanli.dto.msg.MsgRedPackGiveContentDTO;
|
| | | import com.yeshi.fanli.entity.bus.msg.MsgMoneyDetail.MsgTypeMoneyTypeEnum;
|
| | | import com.yeshi.fanli.entity.bus.user.TokenRecord;
|
| | | import com.yeshi.fanli.entity.bus.user.TokenRecord.TokenTypeEnum;
|
| | | import com.yeshi.fanli.entity.redpack.RedPackDetail;
|
| | | import com.yeshi.fanli.entity.redpack.RedPackDetail.RedPackDetailTypeEnum;
|
| | | import com.yeshi.fanli.entity.redpack.RedPackGiveRecord;
|
| | | import com.yeshi.fanli.exception.redpack.RedPackGiveRecordException;
|
| | | import com.yeshi.fanli.service.inter.money.msg.UserMoneyMsgNotificationService;
|
| | | import com.yeshi.fanli.service.inter.redpack.RedPackBalanceService;
|
| | | import com.yeshi.fanli.service.inter.redpack.RedPackConfigService;
|
| | | import com.yeshi.fanli.service.inter.redpack.RedPackDetailService;
|
| | |
| | | @Resource
|
| | | private RedPackDetailService redPackDetailService;
|
| | |
|
| | | @Resource
|
| | | private UserMoneyMsgNotificationService userMoneyMsgNotificationService;
|
| | | |
| | |
|
| | | @Override
|
| | | public RedPackGiveRecord selectByPrimaryKey(Long id) {
|
| | |
| | | redPackGiveRecordMapper.updateByPrimaryKeySelective(record);
|
| | | }
|
| | |
|
| | | |
| | | @Override
|
| | | public List<RedPackGiveRecord> overdueList(int count) {
|
| | | return redPackGiveRecordMapper.overdueList(count);
|
| | | }
|
| | | |
| | | @Override
|
| | | @Transactional(rollbackFor = Exception.class)
|
| | | public void overdue(List<RedPackGiveRecord> list) throws Exception {
|
| | | if (list == null || list.size() == 0)
|
| | | return;
|
| | | |
| | | SimpleDateFormat sd = new SimpleDateFormat("yyyy.MM.dd HH:mm");
|
| | | RedPackGiveRecord updateRecord = null;
|
| | | for (RedPackGiveRecord giveRecord: list) {
|
| | | updateRecord = new RedPackGiveRecord();
|
| | | updateRecord.setId(giveRecord.getId());
|
| | | updateRecord.setState(1);
|
| | | redPackGiveRecordMapper.updateByPrimaryKeySelective(updateRecord);
|
| | | |
| | | // 退回红包
|
| | | redPackBalanceService.addRedPack(giveRecord.getGiveUid(), giveRecord.getAmount(), RedPackDetailFactory.createGiveOthersFail(giveRecord));
|
| | | |
| | | // 退回消息
|
| | | MsgRedPackGiveContentDTO givedto = new MsgRedPackGiveContentDTO();
|
| | | givedto.setTitle("你赠送的红包未被成功领取");
|
| | | givedto.setMoney("¥" + giveRecord.getAmount().setScale(2));
|
| | | givedto.setTime(sd.format(new Date()));
|
| | | givedto.setGiveTime(sd.format(giveRecord.getGiveTime()));
|
| | | userMoneyMsgNotificationService.redPackMsg(giveRecord.getGiveUid(), MsgTypeMoneyTypeEnum.redPackGiveBack, new Gson().toJson(givedto), "请到我的-红包查看");
|
| | | }
|
| | | }
|
| | |
|
| | |
|
| | | @Override
|
| | |
| | | if (endTime != null && endTime.getTime() < now.getTime())
|
| | | throw new RedPackGiveRecordException(1, "红包已失效了");
|
| | |
|
| | | giveRecord.setGiveUid(uid);
|
| | | giveRecord.setReceiveUid(uid);
|
| | | giveRecord.setReceiveTime(now);
|
| | | giveRecord.setState(RedPackGiveRecord.STATE_RECEIVE);
|
| | | // 领取人增加红包
|
| | |
| | | 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.UserExtraTaoBaoInfo;
|
| | | import com.yeshi.fanli.entity.bus.user.UserInfo;
|
| | | import com.yeshi.fanli.entity.order.CommonOrder;
|
| | | import com.yeshi.fanli.entity.redpack.RedPackWinInvite;
|
| | | import com.yeshi.fanli.entity.redpack.RedPackWinInvite.RedPackWinInviteTypeEnum;
|
| | | import com.yeshi.fanli.service.inter.money.msg.UserMoneyMsgNotificationService;
|
| | |
| | | import com.yeshi.fanli.service.inter.redpack.RedPackBalanceService;
|
| | | import com.yeshi.fanli.service.inter.redpack.RedPackConfigService;
|
| | | import com.yeshi.fanli.service.inter.redpack.RedPackWinInviteService;
|
| | | import com.yeshi.fanli.service.inter.user.UserInfoService;
|
| | | import com.yeshi.fanli.service.inter.user.integral.IntegralTaskRecordService;
|
| | | import com.yeshi.fanli.service.inter.user.invite.ThreeSaleSerivce;
|
| | | import com.yeshi.fanli.service.inter.user.tb.UserExtraTaoBaoInfoService;
|
| | | import com.yeshi.fanli.util.Constant;
|
| | | import com.yeshi.fanli.util.MoneyBigDecimalUtil;
|
| | | import com.yeshi.fanli.util.StringUtil;
|
| | | import com.yeshi.fanli.util.factory.RedPackDetailFactory;
|
| | | import com.yeshi.fanli.vo.order.CommonOrderVO;
|
| | |
|
| | |
| | | @Resource
|
| | | private UserMoneyMsgNotificationService userMoneyMsgNotificationService;
|
| | |
|
| | | @Resource |
| | | private UserInfoService userInfoService;
|
| | | |
| | | @Resource |
| | | private UserExtraTaoBaoInfoService userExtraTaoBaoInfoService;
|
| | | |
| | | @Resource |
| | | private IntegralTaskRecordService integralTaskRecordService;
|
| | | |
| | | |
| | | @Override
|
| | | public List<RedPackWinInvite> getRewardList(int start, int count, Long uid) {
|
| | | return redPackWinInviteMapper.getRewardList(start, count, uid);
|
| | | }
|
| | | |
| | | |
| | | @Override
|
| | | public Long countRewardRecord(Long uid) {
|
| | | return redPackWinInviteMapper.countRewardRecord(uid);
|
| | | }
|
| | |
|
| | | @Override
|
| | | @Transactional(rollbackFor = Exception.class)
|
| | |
| | | if (uid == null || source == null || orderNo == null)
|
| | | return;
|
| | |
|
| | | // 自己的奖励
|
| | | firstReward(uid, source, orderNo);
|
| | | |
| | | // 上一级的奖励
|
| | | UserInfo boss = threeSaleSerivce.getBoss(uid);
|
| | | if(boss != null) {
|
| | | firstReward(uid, source, orderNo);
|
| | | firstSharedOrderRewardToBoss(boss.getId(), uid, source, orderNo);
|
| | | firstSharedOrderRewardTheMonthToBoss(boss.getId(), uid, source, orderNo);
|
| | | }
|
| | | }
|
| | |
|
| | | /**
|
| | | * 新人奖励:完成首笔订单 (已到账) 首单=不限制金额、不限制商品、不限制数量、不限制订单类型)
|
| | | * 被邀请人下首单返利(下单就给):
|
| | | * 完成首笔订单 (已到账) 首单=不限制金额、不限制商品、不限制数量、不限制订单类型)
|
| | | * @param uid
|
| | | * @param source
|
| | | * @param orderNo
|
| | |
| | | */
|
| | | @Transactional
|
| | | private void firstReward(Long uid, Integer source, String orderNo) throws Exception{
|
| | | // 奖励一次
|
| | | long total = redPackWinInviteMapper.countByUidAndType(uid, RedPackWinInviteTypeEnum.newUserReward.name());
|
| | | if (total > 1)
|
| | | return;
|
| | | |
| | | // 1、判断是否用户首个订单
|
| | | CommonOrderVO order = commonOrderService.firstValidOrderByUid(uid);
|
| | | if (order == null || source == order.getSourceType() || orderNo.equals(order.getOrderNo()))
|
| | |
| | | */
|
| | | @Transactional
|
| | | private void firstSharedOrderRewardToBoss(Long uid, Long inviteeUid, Integer source, String orderNo) throws Exception{
|
| | | // 同一队员奖励一次
|
| | | long totalReward = redPackWinInviteMapper.countByUidAndTeamUidAndType(uid, inviteeUid, RedPackWinInviteTypeEnum.firstSharedOrder.name());
|
| | | if (totalReward > 1)
|
| | | return;
|
| | | |
| | | // 1、判断是否是改用户首个分享订单
|
| | | CommonOrderVO order = commonOrderService.firstValidOrderByUidAndType(inviteeUid, 2);
|
| | | if (order == null || source == order.getSourceType() || orderNo.equals(order.getOrderNo()))
|
| | |
| | | winInvite.setSource(source);
|
| | | winInvite.setOrderNo(orderNo);
|
| | | redPackWinInviteMapper.insertSelective(winInvite);
|
| | | |
| | | // 4、增加红包
|
| | | redPackBalanceService.addRedPack(uid, money, RedPackDetailFactory.createSeriesReward(winInvite));
|
| | |
|
| | |
| | | }
|
| | |
|
| | |
|
| | | public List<RedPackWinInvite> getRewardList() {
|
| | |
|
| | | @Transactional
|
| | | private void inviteSucceedReward(Long uid) throws Exception{
|
| | | // 验证是否存在上级
|
| | | UserInfo boss = threeSaleSerivce.getBoss(uid);
|
| | | if(boss == null) |
| | | return;
|
| | | |
| | | // 同一队员奖励一次
|
| | | long totalReward = redPackWinInviteMapper.countByUidAndTeamUidAndType(boss.getId(), uid, RedPackWinInviteTypeEnum.inviteSucceed.name());
|
| | | if (totalReward > 1)
|
| | | return;
|
| | | |
| | | // 1、绑定电话号码
|
| | | UserInfo userInfo = userInfoService.selectByPKey(uid);
|
| | | if (userInfo == null || StringUtil.isNullOrEmpty(userInfo.getPhone())) |
| | | return;
|
| | | |
| | | // 2、授权淘宝
|
| | | UserExtraTaoBaoInfo taoBaoInfo = userExtraTaoBaoInfoService.getByUid(uid);
|
| | | if (taoBaoInfo == null || StringUtil.isNullOrEmpty(taoBaoInfo.getTaoBaoUid()))
|
| | | return;
|
| | |
|
| | |
|
| | | boolean finishTask = false;
|
| | | // 3.1、产生任意有效订单(无需到账)
|
| | | CommonOrder commonOrder = commonOrderService.selectLatestValidByUid(uid);
|
| | | if (commonOrder != null) |
| | | finishTask = true;
|
| | |
|
| | | // 3.2、单位时间类累计产生≥200金币
|
| | | if (!finishTask) {
|
| | | long totalGoldCoin = integralTaskRecordService.getTotalGoldCoinByUid(uid);
|
| | | if (totalGoldCoin >= Constant.RED_PACK_GOLD_COIN)
|
| | | finishTask = true;
|
| | | }
|
| | |
|
| | | // 3.3、成功邀请一个好友
|
| | | if (!finishTask) {
|
| | | long countTeam = threeSaleSerivce.countSuccessFirstTeam(uid);
|
| | | if (countTeam >= 1)
|
| | | finishTask = true;
|
| | | }
|
| | |
|
| | | |
| | | |
| | | return null;
|
| | | if (finishTask) {
|
| | | // 奖励金额
|
| | | BigDecimal money = new BigDecimal(redPackConfigService.getValueByKey("invite_succeed"));
|
| | | |
| | | // 获得红包记录
|
| | | RedPackWinInvite winInvite = new RedPackWinInvite();
|
| | | winInvite.setCreateTime(new Date());
|
| | | winInvite.setUpdateTime(new Date());
|
| | | winInvite.setType(RedPackWinInviteTypeEnum.inviteSucceed);
|
| | | winInvite.setUid(boss.getId());
|
| | | winInvite.setTeamUid(uid);
|
| | | winInvite.setMoney(money);
|
| | | redPackWinInviteMapper.insertSelective(winInvite);
|
| | | |
| | | // 增加红包
|
| | | redPackBalanceService.addRedPack(boss.getId(), 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, new Gson().toJson(dto), "红包可用于购买会员");
|
| | | }
|
| | | }
|
| | | |
| | | |
| | | |
| | |
|
| | |
|
| | | }
|
| | |
| | | state = true;
|
| | | UserInfoExtra userInfoExtra = userInfoExtraService.getUserInfoExtra(uid);
|
| | | if (userInfoExtra == null || StringUtil.isNullOrEmpty(userInfoExtra.getInviteCode())) {
|
| | | tips.add("确认领取后,你将成为赠送者的一级队员;");
|
| | | tips.add("确认领取后,你将成为赠送人的一级队员;");
|
| | | tips.add("获赠的免单券,需要激活后才能使用,详情参见免单券激活规则;");
|
| | | tips.add("成功领取后,请到“我的-福利中心”查看。");
|
| | | } else {
|
| | |
| | | state = true;
|
| | | UserInfoExtra userInfoExtra = userInfoExtraService.getUserInfoExtra(uid);
|
| | | if (userInfoExtra == null || StringUtil.isNullOrEmpty(userInfoExtra.getInviteCode())) {
|
| | | tips.add("确认领取后,你将成为赠送者的一级队员;");
|
| | | tips.add("确认领取后,你将成为赠送人的一级队员;");
|
| | | tips.add("板栗快省奖励券,可用于“已到账”的返利订单,在返利的基础上再获得一定比例的返利;");
|
| | | tips.add("成功领取后,请到“我的-福利中心”中查看。");
|
| | | } else {
|
| | |
| | | state = true;
|
| | | UserInfoExtra userInfoExtra = userInfoExtraService.getUserInfoExtra(uid);
|
| | | if (userInfoExtra == null || StringUtil.isNullOrEmpty(userInfoExtra.getInviteCode())) {
|
| | | tips.add("确认领取后,你将成为增值的一级队员;");
|
| | | tips.add("确认领取后,你将成为赠送人的一级队员;");
|
| | | tips.add("红包可提现,可购买折扣商品;");
|
| | | tips.add("成功领取后,请到“我的-红包”中查看。");
|
| | | } else {
|
| | |
| | | try {
|
| | | msg = "领取红包成功,请到[我的-红包]中查看";
|
| | | // 领取红包、更新记录
|
| | | RedPackGiveRecord giveRecord = redPackGiveRecordService.receiveFriendsGive(uidToken, Long.parseLong(identify));
|
| | | RedPackGiveRecord giveRecord = redPackGiveRecordService.receiveFriendsGive(uid, Long.parseLong(identify));
|
| | | // 消息 + 队员
|
| | | executor.execute(new Runnable() {
|
| | | @Override
|
| | |
| | | dto.setUserInfo("昵称:" + giveUserName + " ID:" + giveUid);
|
| | | dto.setTime(sd.format(giveRecord.getGiveTime()));
|
| | | dto.setMoney("¥" + giveRecord.getAmount().setScale(2));
|
| | | userMoneyMsgNotificationService.redPackMsg(giveUid, MsgTypeMoneyTypeEnum.redPackReceiveOff, new Gson().toJson(dto), beiZhu);
|
| | | userMoneyMsgNotificationService.redPackMsg(uid, MsgTypeMoneyTypeEnum.redPackReceiveOff, new Gson().toJson(dto), beiZhu);
|
| | |
|
| | | // 赠送人消息
|
| | | String userName = "无";
|
| | |
| | | public UserInfoExtra getUserInfoExtra(Long uid) {
|
| | | return userInfoExtraMapper.getInfoExtraByUid(uid);
|
| | | }
|
| | | |
| | | @Override
|
| | | public UserInfoExtra getUserALLInfo(Long uid) {
|
| | | return userInfoExtraMapper.gerUserRank(uid);
|
| | | }
|
| | |
|
| | | |
| | | @Override
|
| | | public UserInfoExtra getByUidForUpdate(Long uid) {
|
| | | return userInfoExtraMapper.getByUidForUpdate(uid);
|
| | |
| | | package com.yeshi.fanli.service.impl.user;
|
| | |
|
| | | import java.util.Date;
|
| | |
|
| | | import javax.annotation.Resource;
|
| | |
|
| | | import org.springframework.stereotype.Service;
|
| | |
| | | }
|
| | |
|
| | | @Override
|
| | | public void addActivateRecord(Long id) {
|
| | | UserSystemCouponActivate record = new UserSystemCouponActivate();
|
| | | record.setId(id);
|
| | | record.setCount(0);
|
| | | record.setState(UserSystemCouponActivate.STATE_INIT);
|
| | | record.setCreateTime(new Date());
|
| | | record.setUpdateTime(new Date());
|
| | | userSystemCouponActivateMapper.insertSelective(record);
|
| | | }
|
| | | |
| | | @Override
|
| | | public void updateByPrimaryKeySelective(UserSystemCouponActivate record) {
|
| | | userSystemCouponActivateMapper.updateByPrimaryKeySelective(record);
|
| | | }
|
| | |
| | | userCoupon.setEndTime(endTime);
|
| | | userCoupon.setCreateTime(new Date());
|
| | | userCoupon.setUpdateTime(new Date());
|
| | | // 插入数据库
|
| | | insertSelective(userCoupon);
|
| | | userSystemCouponMapper.insertSelective(userCoupon);
|
| | | |
| | | if(coupon.getType() == CouponTypeEnum.freeCoupon) {
|
| | | userSystemCouponActivateService.addActivateRecord(userCoupon.getId());
|
| | | }
|
| | |
|
| | | executor.execute(new Runnable() {
|
| | | @Override
|
| | |
| | |
|
| | | Order order = orderService.findOrderByOrderIdAndType(orderNo, sourceType);
|
| | | if (order == null)
|
| | | return;
|
| | | throw new UserSystemCouponException(1, "该订单不存在");
|
| | |
|
| | | /* 奖金计算 以及相关红包信息处理 */
|
| | |
|
| | |
| | | return integralTaskRecordMapper.listByUidAndTaskId(uid, taskId, (page - 1) * count, count);
|
| | | }
|
| | |
|
| | | |
| | | @Override
|
| | | public long getTotalGoldCoinByUid(Long uid) {
|
| | | return integralTaskRecordMapper.getTotalGoldCoinByUid(uid);
|
| | | }
|
| | | |
| | | |
| | | |
| | | @Async()
|
| | | @Override
|
| | | public void firstRebateOrderRewardBoss(Long uid, Long originUid, String beizu) {
|
| | |
| | | package com.yeshi.fanli.service.inter.redpack;
|
| | |
|
| | | import java.math.BigDecimal;
|
| | | import java.util.List;
|
| | |
|
| | | import com.yeshi.fanli.entity.redpack.RedPackGiveRecord;
|
| | | import com.yeshi.fanli.exception.redpack.RedPackGiveRecordException;
|
| | |
| | | */
|
| | | public RedPackGiveRecord receiveFriendsGive(Long uid, Long id) throws RedPackGiveRecordException;
|
| | |
|
| | | /**
|
| | | * 查询需要退回的
|
| | | * @param count
|
| | | * @return
|
| | | */
|
| | | public List<RedPackGiveRecord> overdueList(int count);
|
| | |
|
| | | // 退回红包
|
| | | public void overdue(List<RedPackGiveRecord> list) throws Exception;
|
| | |
|
| | |
|
| | | }
|
| | |
| | | package com.yeshi.fanli.service.inter.redpack;
|
| | |
|
| | | import java.util.List;
|
| | |
|
| | | import com.yeshi.fanli.entity.redpack.RedPackWinInvite;
|
| | |
|
| | | public interface RedPackWinInviteService {
|
| | |
|
| | | /**
|
| | |
| | | * @param orderNo
|
| | | */
|
| | | public void orderArriveReward(Long uid, Integer source, String orderNo) throws Exception;
|
| | |
|
| | | /**
|
| | | * 查询获得记录
|
| | | * @param start
|
| | | * @param count
|
| | | * @param uid
|
| | | * @return
|
| | | */
|
| | | public List<RedPackWinInvite> getRewardList(int start, int count, Long uid);
|
| | |
|
| | | /**
|
| | | * 统计条数
|
| | | * @param uid
|
| | | * @return
|
| | | */
|
| | | public Long countRewardRecord(Long uid);
|
| | |
|
| | | }
|
| | |
| | | *开启自动提现: 更新超过期限的
|
| | | * @param days
|
| | | */
|
| | | void updateAutoExtract(@Param("days")Integer days);
|
| | | public void updateAutoExtract(@Param("days")Integer days);
|
| | |
|
| | | /**
|
| | | * 返回用户所有相关额外信息
|
| | | * @param uid
|
| | | * @return
|
| | | */
|
| | | public UserInfoExtra getUserALLInfo(Long uid);
|
| | |
|
| | | }
|
| | |
| | | */
|
| | | public void updateByPrimaryKeySelective(UserSystemCouponActivate record);
|
| | |
|
| | | /**
|
| | | * 创建记录
|
| | | * @param id
|
| | | */
|
| | | public void addActivateRecord(Long id);
|
| | |
|
| | | }
|
| | |
| | | */
|
| | | public List<IntegralTaskRecord> getSign7DaysRecord(long uid, Long cid);
|
| | |
|
| | | /**
|
| | | * 统计总金币
|
| | | * @param uid
|
| | | * @return
|
| | | */
|
| | | public long getTotalGoldCoinByUid(Long uid);
|
| | |
|
| | | }
|
| | |
| | | public static final BigDecimal RED_PACK_PAY_MIN = new BigDecimal("10");
|
| | | // 红包奖励分享订单连续奖励月数
|
| | | public static final int RED_PACK_REWARd_MONTH = 15;
|
| | | // 红包奖励-单位时间类累计产生≥200金币
|
| | | public static final long RED_PACK_GOLD_COIN = 200;
|
| | | |
| | | |
| | |
|
| | | public static WXGZConfig wxGZConfig;
|
| | |
|
| | |
| | | import com.yeshi.fanli.dto.msg.MsgOtherRewardIntegralDTO;
|
| | | import com.yeshi.fanli.dto.msg.MsgOtherSystemGiveDTO;
|
| | | import com.yeshi.fanli.dto.msg.MsgOtherTaoLiJinContentDTO;
|
| | | import com.yeshi.fanli.dto.msg.MsgRedPackAddContentDTO;
|
| | | import com.yeshi.fanli.dto.msg.MsgRedPackExchangeContentDTO;
|
| | | import com.yeshi.fanli.dto.msg.MsgRedPackGiveContentDTO;
|
| | | import com.yeshi.fanli.entity.bus.msg.MsgAccountDetail;
|
| | |
| | | COLOR_CONTENT));
|
| | | items.add(new CommonMsgItemVO(new ClientTextStyleVO("备注", COLOR_TITLE), contentList));
|
| | |
|
| | | return new UserMsgVO("http://img.flqapp.com/resource/money_detail/icon_system.png",
|
| | | return new UserMsgVO("http://img.flqapp.com/resource/msg/icon_hongbao_give.png",
|
| | | dto.getTitle(), msg.getUpdateTime() == null ? msg.getCreateTime() : msg.getUpdateTime(),
|
| | | items);
|
| | | } else if (msg.getMsgType() == MsgTypeMoneyTypeEnum.redPackGiveOff) { // 红包被成功领取
|
| | |
| | | COLOR_CONTENT));
|
| | | items.add(new CommonMsgItemVO(new ClientTextStyleVO("备注", COLOR_TITLE), contentList));
|
| | |
|
| | | return new UserMsgVO("http://img.flqapp.com/resource/money_detail/icon_system.png",
|
| | | return new UserMsgVO("http://img.flqapp.com/resource/msg/icon_hongbao_give.png",
|
| | | dto.getTitle(), msg.getUpdateTime() == null ? msg.getCreateTime() : msg.getUpdateTime(),
|
| | | items);
|
| | | } else if (msg.getMsgType() == MsgTypeMoneyTypeEnum.redPackGiveBack) { // 红包未被领取退回
|
| | | if (StringUtil.isNullOrEmpty(msg.getContent()))
|
| | | return null;
|
| | |
|
| | | MsgRedPackGiveContentDTO dto = new Gson().fromJson(msg.getContent(), MsgRedPackGiveContentDTO.class);
|
| | | if (dto == null)
|
| | | return null;
|
| | | |
| | | contentList = new ArrayList<>();
|
| | | contentList.add(new ClientTextStyleVO(dto.getTitle() + "", COLOR_CONTENT));
|
| | | items.add(new CommonMsgItemVO(new ClientTextStyleVO("赠送类别", COLOR_TITLE), contentList));
|
| | |
|
| | | contentList = new ArrayList<>();
|
| | | contentList.add(new ClientTextStyleVO(dto.getMoney() + "", COLOR_HIGHLIGHT_CONTENT));
|
| | | items.add(new CommonMsgItemVO(new ClientTextStyleVO("赠送金额", COLOR_TITLE), contentList));
|
| | | |
| | | contentList = new ArrayList<>();
|
| | | contentList.add(new ClientTextStyleVO(dto.getGiveTime() + "", COLOR_CONTENT));
|
| | | items.add(new CommonMsgItemVO(new ClientTextStyleVO("赠送时间", COLOR_TITLE), contentList));
|
| | | |
| | | contentList = new ArrayList<>();
|
| | | contentList.add(new ClientTextStyleVO(dto.getTime() + "", 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_hongbao_give.png",
|
| | | MsgTypeMoneyTypeEnum.redPackGiveBack.getDesc(), msg.getUpdateTime() == null ? msg.getCreateTime() : msg.getUpdateTime(),
|
| | | items);
|
| | | } else if (msg.getMsgType() == MsgTypeMoneyTypeEnum.redPackExchangePass) { // 红包提现成功
|
| | | if (StringUtil.isNullOrEmpty(msg.getContent()))
|
| | |
| | | COLOR_CONTENT));
|
| | | items.add(new CommonMsgItemVO(new ClientTextStyleVO("备注", COLOR_TITLE), contentList));
|
| | |
|
| | | return new UserMsgVO("http://img.flqapp.com/resource/money_detail/icon_system.png",
|
| | | return new UserMsgVO("http://img.flqapp.com/resource/msg/icon_hongbao_tixian.png",
|
| | | dto.getTitle(), msg.getUpdateTime() == null ? msg.getCreateTime() : msg.getUpdateTime(),
|
| | | items);
|
| | | } else if (msg.getMsgType() == MsgTypeMoneyTypeEnum.redPackExchangeReject) { // 红包提现拒绝
|
| | |
| | | COLOR_CONTENT));
|
| | | items.add(new CommonMsgItemVO(new ClientTextStyleVO("备注", COLOR_TITLE), contentList));
|
| | |
|
| | | return new UserMsgVO("http://img.flqapp.com/resource/money_detail/icon_system.png",
|
| | | return new UserMsgVO("http://img.flqapp.com/resource/msg/icon_hongbao_tixian.png",
|
| | | dto.getTitle(), msg.getUpdateTime() == null ? msg.getCreateTime() : msg.getUpdateTime(),
|
| | | items);
|
| | | } else if (msg.getMsgType() == MsgTypeMoneyTypeEnum.redPackNewUserReward
|
| | | || msg.getMsgType() == MsgTypeMoneyTypeEnum.redPackInviteSucceed
|
| | | || msg.getMsgType() == MsgTypeMoneyTypeEnum.redPackFirstSharedOrder
|
| | | || msg.getMsgType() == MsgTypeMoneyTypeEnum.redPackMonthSharedOrder) { // 红包邀请获得
|
| | | if (StringUtil.isNullOrEmpty(msg.getContent()))
|
| | | return null;
|
| | |
|
| | | MsgRedPackAddContentDTO dto = new Gson().fromJson(msg.getContent(), MsgRedPackAddContentDTO.class);
|
| | | if (dto == null)
|
| | | return null;
|
| | | |
| | | contentList = new ArrayList<>();
|
| | | contentList.add(new ClientTextStyleVO(msg.getMsgType().getDesc() + "", COLOR_CONTENT));
|
| | | items.add(new CommonMsgItemVO(new ClientTextStyleVO("增加原因", COLOR_TITLE), contentList));
|
| | |
|
| | | contentList = new ArrayList<>();
|
| | | contentList.add(new ClientTextStyleVO(dto.getMoney() + "", COLOR_HIGHLIGHT_CONTENT));
|
| | | items.add(new CommonMsgItemVO(new ClientTextStyleVO("金额", COLOR_TITLE), contentList));
|
| | |
|
| | | contentList = new ArrayList<>();
|
| | | contentList.add(new ClientTextStyleVO(dto.getBalance() + "", COLOR_HIGHLIGHT_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/img/tlj/icon_tlj.png",
|
| | | dto.getTitle(), msg.getUpdateTime() == null ? msg.getCreateTime() : msg.getUpdateTime(),
|
| | | items);
|
| | | }
|
New file |
| | |
| | | package com.yeshi.fanli.vo.redpack;
|
| | |
|
| | | import java.io.Serializable;
|
| | |
|
| | | import com.google.gson.annotations.Expose;
|
| | |
|
| | | public class RedPackWinInviteVO implements Serializable{
|
| | | |
| | | /**
|
| | | * |
| | | */
|
| | | private static final long serialVersionUID = 1L;
|
| | | |
| | | @Expose
|
| | | private String nickName;
|
| | | @Expose
|
| | | private String portrait;
|
| | | @Expose
|
| | | private String money;
|
| | | @Expose
|
| | | private String desc;
|
| | | |
| | | |
| | | public String getNickName() {
|
| | | return nickName;
|
| | | }
|
| | | public void setNickName(String nickName) {
|
| | | this.nickName = nickName;
|
| | | }
|
| | | public String getPortrait() {
|
| | | return portrait;
|
| | | }
|
| | | public void setPortrait(String portrait) {
|
| | | this.portrait = portrait;
|
| | | }
|
| | | public String getMoney() {
|
| | | return money;
|
| | | }
|
| | | public void setMoney(String money) {
|
| | | this.money = money;
|
| | | }
|
| | | public String getDesc() {
|
| | | return desc;
|
| | | }
|
| | | public void setDesc(String desc) {
|
| | | this.desc = desc;
|
| | | }
|
| | | }
|