| | |
| | | }
|
| | |
|
| | |
|
| | | |
| | | @Transactional
|
| | | public void randomRewardCouponForPush(Integer amount, Long uid) throws Exception {
|
| | | int coupon = 0;
|
| | | |
| | | for (int i = 0; i < amount; i++) {
|
| | | // 系统随机
|
| | | BigDecimal percent = new BigDecimal(randomNum());
|
| | | |
| | | // 查询奖励券
|
| | | SystemCoupon systemCoupon = systemCouponService.getCouponByTypeAndPercent(
|
| | | CouponTypeEnum.rebatePercentCoupon.name(),percent);
|
| | | |
| | | if (systemCoupon == null) {
|
| | | return;
|
| | | }
|
| | | |
| | | // 结束日期
|
| | | // 今天在内 减去一天
|
| | | String endDay = DateUtil.plusDay(systemCoupon.getExpiryDay() - 1, new Date());
|
| | | SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");
|
| | | Date endTime = format.parse(endDay);
|
| | | |
| | | UserSystemCoupon userCoupon = new UserSystemCoupon();
|
| | | userCoupon.setUid(uid);
|
| | | userCoupon.setSource(UserSystemCoupon.SOURCE_SYSTEM_PUSH);
|
| | | userCoupon.setSystemCoupon(systemCoupon);
|
| | | userCoupon.setState(UserSystemCoupon.STATE_CAN_USE);
|
| | | userCoupon.setStateActivated(1);
|
| | | userCoupon.setStartTime(new Date());
|
| | | userCoupon.setEndTime(endTime);
|
| | | userCoupon.setCreateTime(new Date());
|
| | | userCoupon.setUpdateTime(new Date());
|
| | | // 插入数据库
|
| | | insertSelective(userCoupon);
|
| | | |
| | | // 券数量
|
| | | coupon ++;
|
| | | |
| | | // 消息推送
|
| | | try {
|
| | | userOtherMsgNotificationService.rewardCouponGet(userCoupon,systemCoupon.getPercent().intValue());
|
| | | } catch(Exception e) {
|
| | | try {
|
| | | LogHelper.errorDetailInfo(e);
|
| | | } catch (Exception e1) {
|
| | | e1.printStackTrace();
|
| | | }
|
| | | }
|
| | | }
|
| | | |
| | | // 获取额外信息
|
| | | UserInfoExtra userInfoExtra = userInfoExtraService.getUserInfoExtra(uid);
|
| | | if (userInfoExtra == null) {
|
| | | return;
|
| | | }
|
| | | |
| | | Integer couponNews = userInfoExtra.getCouponNews();
|
| | | if (couponNews == null) {
|
| | | userInfoExtra.setCouponNews(coupon);
|
| | | } else {
|
| | | userInfoExtra.setCouponNews(couponNews + coupon);
|
| | | }
|
| | | userInfoExtraService.saveUserInfoExtra(userInfoExtra);
|
| | | }
|
| | | |
| | | |
| | | @Override
|
| | | @Transactional
|
| | | public void randomRewardCoupon(int num, Long uid, String source) throws Exception {
|