| | |
| | | import org.springframework.stereotype.Service;
|
| | | import org.springframework.transaction.annotation.Transactional;
|
| | | import org.yeshi.utils.DateUtil;
|
| | | import org.yeshi.utils.JsonUtil;
|
| | |
|
| | | import com.yeshi.fanli.dao.mybatis.user.UserSystemCouponMapper;
|
| | | import com.yeshi.fanli.entity.bus.user.DeviceLotteryRecord;
|
| | | import com.yeshi.fanli.entity.bus.user.HongBaoV2;
|
| | | import com.yeshi.fanli.entity.bus.user.Order;
|
| | | import com.yeshi.fanli.entity.bus.user.UserInfo;
|
| | |
| | | import com.yeshi.fanli.service.inter.hongbao.ThreeSaleSerivce;
|
| | | import com.yeshi.fanli.service.inter.msg.UserMoneyMsgNotificationService;
|
| | | import com.yeshi.fanli.service.inter.msg.UserOtherMsgNotificationService;
|
| | | import com.yeshi.fanli.service.inter.order.CommonOrderCountService;
|
| | | import com.yeshi.fanli.service.inter.order.CommonOrderService;
|
| | | import com.yeshi.fanli.service.inter.order.HongBaoOrderService;
|
| | | import com.yeshi.fanli.service.inter.order.OrderHongBaoMapService;
|
| | | import com.yeshi.fanli.service.inter.order.OrderService;
|
| | | import com.yeshi.fanli.service.inter.user.DeviceLotteryRecordService;
|
| | | import com.yeshi.fanli.service.inter.user.UserInfoExtraService;
|
| | | import com.yeshi.fanli.service.inter.user.UserInfoService;
|
| | | import com.yeshi.fanli.service.inter.user.UserMoneyDetailService;
|
| | |
| | | @Resource
|
| | | private UserOtherMsgNotificationService userOtherMsgNotificationService;
|
| | |
|
| | | @Resource
|
| | | private DeviceLotteryRecordService deviceLotteryRecordService;
|
| | | |
| | | @Resource
|
| | | private CommonOrderCountService commonOrderCountService;
|
| | |
|
| | | @Override
|
| | | public int insertSelective(UserSystemCoupon record) {
|
| | |
| | | }
|
| | |
|
| | | @Override
|
| | | public void insertUserCoupon(Long uid, String couponType,String source)throws UserSystemCouponException,Exception{
|
| | | @Transactional
|
| | | public void insertUserCoupon(Long uid, String couponType, String source)throws UserSystemCouponException,Exception{
|
| | |
|
| | | if (couponType == null || uid == null) {
|
| | | throw new UserSystemCouponException(1, "参数不正确");
|
| | |
| | | UserInfoExtra userInfoExtra = userInfoExtraService.getUserInfoExtra(uid);
|
| | | // 添加一条消息
|
| | | if (userInfoExtra != null) {
|
| | | userInfoExtra.setCouponNews(userInfoExtra.getCouponNews() + 1);
|
| | | if (userInfoExtra.getCouponNews() == null) {
|
| | | userInfoExtra.setCouponNews(1);
|
| | | } else {
|
| | | userInfoExtra.setCouponNews(userInfoExtra.getCouponNews() + 1);
|
| | | }
|
| | | |
| | | |
| | | try {
|
| | | userInfoExtraService.saveUserInfoExtra(userInfoExtra);
|
| | | } catch (UserInfoExtraException e) {
|
| | |
| | | }
|
| | |
|
| | | jumpBtn = new HashMap<String, Object>();
|
| | | Map<String, Object> jumpLink = new HashMap<String, Object>();
|
| | |
|
| | | UserInfoExtra userInfoExtra = userInfoExtraService.getUserInfoExtra(uid);
|
| | |
|
| | | // 邀请队员界面
|
| | | if (userInfoExtra != null && userInfoExtra.getInviteCode() != null
|
| | | && userInfoExtra.getInviteCode().trim().length() > 0) {
|
| | | // 邀请激活成功界面
|
| | | jumpLink.put("url", configService.get("invite_activation_success_url") + "?alert=true");
|
| | | } else {
|
| | | // 激活邀请码界面
|
| | | jumpLink.put("url", configService.get("invite_activation_url"));
|
| | | }
|
| | | /*
|
| | | * Map<String, Object> jumpLink = new HashMap<String, Object>();
|
| | | *UserInfoExtra userInfoExtra = userInfoExtraService.getUserInfoExtra(uid);
|
| | | * if (userInfoExtra != null && userInfoExtra.getInviteCode() != null &&
|
| | | * userInfoExtra.getInviteCode().trim().length() > 0) { // 邀请激活成功界面
|
| | | * jumpLink.put("url", configService.get("invite_activation_success_url") +
|
| | | * "?alert=true"); } else { // 激活邀请码界面 jumpLink.put("url",
|
| | | * configService.get("invite_activation_url")); }
|
| | | * jumpBtn.put("params", jumpLink);
|
| | | */
|
| | |
|
| | | jumpBtn.put("params", jumpLink);
|
| | | jumpBtn.put("jumpDetail", jumpDetailV2Service.getByTypeCache("invite_web"));
|
| | | jumpBtn.put("jumpDetail", jumpDetailV2Service.getByTypeCache("invite"));
|
| | |
|
| | | } else if (stateActivated == 1) {
|
| | | // 显示规则
|
| | |
| | | return;
|
| | | }
|
| | |
|
| | | // 验证是否失效
|
| | | updateCounponInvalid(uid);
|
| | | |
| | | // 待活福利免单券
|
| | | List<UserSystemCoupon> list = userSystemCouponMapper.getCouponByTypeAndNotActivated(uid, systemCoupon.getId());
|
| | | if (list == null || list.size() == 0) {
|
| | |
| | |
|
| | | for (UserSystemCoupon userSystemCoupon: list) {
|
| | | // 激活
|
| | | userSystemCoupon.setStateActivated(1);
|
| | | userSystemCoupon.setUpdateTime(new Date());
|
| | | userSystemCouponMapper.updateByPrimaryKeySelective(userSystemCoupon);
|
| | | UserSystemCoupon update=new UserSystemCoupon();
|
| | | update.setId(userSystemCoupon.getId());
|
| | | update.setStateActivated(1);
|
| | | update.setUpdateTime(new Date());
|
| | | userSystemCouponMapper.updateByPrimaryKeySelective(update);
|
| | | |
| | | Integer state = userSystemCoupon.getState();
|
| | | if (UserSystemCoupon.STATE_OVERDUE == state) {
|
| | | continue; // 已失效不做消息推送
|
| | | }
|
| | |
|
| | | // 消息推送
|
| | | try {
|
| | | userOtherMsgNotificationService.welfareCouponGet(userSystemCoupon);
|
| | | UserInfo userInfo = userInfoService.selectByPKey(uid);
|
| | | |
| | | userOtherMsgNotificationService.welfareCouponActive(userSystemCoupon, userInfo);
|
| | | } catch(Exception e) {
|
| | | try {
|
| | | LogHelper.errorDetailInfo(e);
|
| | |
| | | }
|
| | |
|
| | |
|
| | | @Override
|
| | | @Transactional
|
| | | public void copyLotteryPrize(Long uid, int platform, String device) throws Exception {
|
| | | |
| | | if (uid == null || device == null) {
|
| | | return;
|
| | | }
|
| | | |
| | | // 未登陆之前抽奖记录
|
| | | List<DeviceLotteryRecord> list = deviceLotteryRecordService.listByPlatformAndDevice(platform, device);
|
| | | if (list == null || list.size() == 0) {
|
| | | return;
|
| | | }
|
| | | |
| | | // 获取额外信息
|
| | | UserInfoExtra userInfoExtra = userInfoExtraService.getUserInfoExtra(uid);
|
| | | if (userInfoExtra != null && userInfoExtra.getLotteryNewbies() != null) {
|
| | | return;
|
| | | }
|
| | | |
| | | // 是否有过订单:返利、分享订单
|
| | | boolean hasOrder = commonOrderCountService.hasRebateAndShareOrder(uid);
|
| | | if (hasOrder) {
|
| | | return;
|
| | | }
|
| | | |
| | | int coupon = 0;
|
| | | |
| | | for (DeviceLotteryRecord reviceLotteryRecord: list) {
|
| | | |
| | | // 删除记录
|
| | | deviceLotteryRecordService.deleteByPrimaryKey(reviceLotteryRecord.getId());
|
| | | |
| | | Long systemCouponId = reviceLotteryRecord.getSystemCouponId();
|
| | | if (systemCouponId == null) {
|
| | | continue;
|
| | | }
|
| | | SystemCoupon systemCoupon = systemCouponService.selectByPrimaryKey(systemCouponId);
|
| | | if (systemCoupon == null) {
|
| | | continue;
|
| | | }
|
| | | |
| | | int stateActivated = 1;
|
| | | if (systemCoupon.getType() == CouponTypeEnum.welfareFreeCoupon) {
|
| | | // 福利券状态
|
| | | long countSuccess = threeSaleSerivce.countSuccessFirstTeam(uid);
|
| | | // 没有下级队员 --待激活
|
| | | if (countSuccess == 0) {
|
| | | stateActivated = 0;
|
| | | }
|
| | | }
|
| | | |
| | | // 结束日期
|
| | | String endDay = DateUtil.plusDay(systemCoupon.getExpiryDay(), 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_CHOUJIANG);
|
| | | userCoupon.setSystemCoupon(systemCoupon);
|
| | | userCoupon.setState(UserSystemCoupon.STATE_CAN_USE);
|
| | | userCoupon.setStateActivated(stateActivated);
|
| | | userCoupon.setStartTime(new Date());
|
| | | userCoupon.setEndTime(endTime);
|
| | | userCoupon.setCreateTime(new Date());
|
| | | userCoupon.setUpdateTime(new Date());
|
| | | // 插入数据库
|
| | | insertSelective(userCoupon);
|
| | | |
| | | // 券数量
|
| | | coupon ++;
|
| | | |
| | | // 消息推送
|
| | | try {
|
| | | if (systemCoupon.getType() == CouponTypeEnum.welfareFreeCoupon) {
|
| | | userOtherMsgNotificationService.welfareCouponGet(userCoupon);
|
| | | } else if (systemCoupon.getType() == CouponTypeEnum.freeCoupon) {
|
| | | userOtherMsgNotificationService.freeSheetCouponGet(userCoupon);
|
| | | } else if (systemCoupon.getType() == CouponTypeEnum.rebatePercentCoupon) {
|
| | | userOtherMsgNotificationService.rewardCouponGet(userCoupon,systemCoupon.getPercent().intValue());
|
| | | }
|
| | | |
| | | } catch(Exception e) {
|
| | | try {
|
| | | LogHelper.errorDetailInfo(e);
|
| | | } catch (Exception e1) {
|
| | | e1.printStackTrace();
|
| | | }
|
| | | }
|
| | | }
|
| | | |
| | | if(userInfoExtra == null) {
|
| | | userInfoExtra = new UserInfoExtra();
|
| | | userInfoExtra.setUserInfo(new UserInfo(uid));
|
| | | }
|
| | | |
| | | userInfoExtra.setLotteryNewbies(Constant.MAX_COUNT_LOTTERY_NEWBIES-list.size());
|
| | | Integer couponNews = userInfoExtra.getCouponNews();
|
| | | if (couponNews == null) {
|
| | | userInfoExtra.setCouponNews(coupon);
|
| | | } else {
|
| | | userInfoExtra.setCouponNews(couponNews + coupon);
|
| | | }
|
| | | userInfoExtraService.saveUserInfoExtra(userInfoExtra);
|
| | |
|
| | | }
|
| | | }
|
| | | |