| | |
| | |
|
| | | /**
|
| | | * 福利中心
|
| | | * |
| | | * @author Administrator
|
| | | *
|
| | | */
|
| | |
| | |
|
| | | /**
|
| | | * 用户券列表查询
|
| | | * |
| | | * @param acceptData
|
| | | * @param page
|
| | | * @param uid
|
| | |
| | | }
|
| | |
|
| | | long count = 0;
|
| | | List<UserSystemCouponVO> resultList = UserSystemCouponService.getUserCouponVOList((page - 1) * Constant.PAGE_SIZE, |
| | | Constant.PAGE_SIZE, uid );
|
| | | List<UserSystemCouponVO> resultList = UserSystemCouponService
|
| | | .getUserCouponVOList((page - 1) * Constant.PAGE_SIZE, Constant.PAGE_SIZE, uid);
|
| | |
|
| | | if (resultList != null && resultList.size() > 0) {
|
| | | count = UserSystemCouponService.countUserCouponList(uid);
|
| | |
| | |
|
| | | /**
|
| | | * 用户奖励券
|
| | | * |
| | | * @param acceptData
|
| | | * @param page
|
| | | * @param uid
|
| | |
| | | if (resultList == null ) {
|
| | | resultList =new ArrayList<UserSystemCouponVO>();
|
| | | }
|
| | | |
| | |
|
| | | JSONObject dataTip = new JSONObject();
|
| | | dataTip.put("content", configService.get("free_coupon_tip"));
|
| | |
| | | }
|
| | | }
|
| | |
|
| | | |
| | | /**
|
| | | * 免单券使用记录 以及状态修改
|
| | | * |
| | | * @param acceptData
|
| | | * @param page
|
| | | * @param uid
|
| | |
| | | }
|
| | | }
|
| | |
|
| | | |
| | | /**
|
| | | * 用户奖励券
|
| | | * |
| | | * @param acceptData
|
| | | * @param page
|
| | | * @param uid
|
| | |
| | | }
|
| | | }
|
| | |
|
| | | |
| | | /**
|
| | | * 免单券使用记录 以及状态修改
|
| | | * |
| | | * @param acceptData
|
| | | * @param page
|
| | | * @param uid
|
| | |
| | |
|
| | | /**
|
| | | * 订单-奖励进度详情
|
| | | * |
| | | * @param acceptData
|
| | | * @param orderNo 订单号
|
| | | * @param out
|
| | |
| | |
|
| | | /**
|
| | | * 订单-奖励进度详情
|
| | | * |
| | | * @param acceptData
|
| | | * @param orderNo 订单号
|
| | | * @param out
|
| | |
| | | }
|
| | | }
|
| | |
|
| | |
|
| | | /**
|
| | | * 获取抽奖次数
|
| | | *
|
| | |
| | | */
|
| | | @RequestMapping(value = "getLotteryCount")
|
| | | public void getLotteryCount(String callback, AcceptData acceptData, Long uid, PrintWriter out) {
|
| | | int count = 0;
|
| | | try {
|
| | | count = getSurplusCount(acceptData, uid);
|
| | | } catch (Exception e) {
|
| | | JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult(e.getMessage()));
|
| | | e.printStackTrace();
|
| | | // 默认最大抽奖次数
|
| | | int count = 5;
|
| | |
|
| | | if (uid == null || uid == 0) { // 未登录
|
| | | int platformType = 0;
|
| | | String platform = acceptData.getPlatform();
|
| | | if ("android".equals(platform)) {
|
| | | platformType = 1;
|
| | | } else if ("ios".equals(platform)) {
|
| | | platformType = 2;
|
| | | } else {
|
| | | JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("平台有误"));
|
| | | return;
|
| | | }
|
| | |
|
| | | try {
|
| | | String device = acceptData.getDevice();
|
| | | if (device == null || device.trim().length() == 0) {
|
| | | JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("设备不存在"));
|
| | | return;
|
| | | }
|
| | |
|
| | | List<DeviceLotteryRecord> list = deviceLotteryRecordService.listByPlatformAndDevice(platformType,
|
| | | device);
|
| | | if (list != null && list.size() > 0) {
|
| | | count = count - list.size();
|
| | | }
|
| | |
|
| | | } else { // 已登录
|
| | | UserInfoExtra userInfoExtra = userInfoExtraService.getUserInfoExtra(uid);
|
| | | if (userInfoExtra == null) {
|
| | | JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("用户信息不存在"));
|
| | | return;
|
| | | }
|
| | |
|
| | | Integer lotteryNewbies = userInfoExtra.getLotteryNewbies();
|
| | | if (lotteryNewbies == null) { // 未抽过
|
| | | // 是否有过订单:返利、分享订单
|
| | | boolean hasOrder = commonOrderCountService.hasRebateAndShareOrder(uid);
|
| | | if (hasOrder) {
|
| | | count = 0; // 不算新用户
|
| | | }
|
| | | userInfoExtra.setLotteryNewbies(count);
|
| | | userInfoExtraService.saveUserInfoExtra(userInfoExtra);
|
| | | } else {
|
| | | count = lotteryNewbies; // 剩余次数
|
| | | }
|
| | | }
|
| | |
|
| | | // 抽奖规则
|
| | | String lotteryRule = configService.get("lottery_rule_newbies");
|
| | |
|
| | |
| | | e.printStackTrace();
|
| | | }
|
| | | }
|
| | | |
| | |
|
| | | /**
|
| | | * 获取抽奖结果
|
| | |
| | | String hasPrize = "";
|
| | | Long couponId = null;
|
| | |
|
| | | if (uid == null) { // 未登录
|
| | | if (uid == null || uid == 0) { // 未登录
|
| | | int platformType = 0;
|
| | | String platform = acceptData.getPlatform();
|
| | | if ("android".equals(platform)) {
|
| | |
| | | }
|
| | | }
|
| | |
|
| | | |
| | | count = MAX_COUNT - 1 - list.size();
|
| | | |
| | |
|
| | | } else {
|
| | | count = MAX_COUNT - 1;
|
| | |
| | | count = lotteryNewbies - 1; // 剩余次数
|
| | | }
|
| | |
|
| | | List<UserSystemCoupon> list = userSystemCouponService.getUserCouponBySource(uid, UserSystemCoupon.SOURCE_CHOUJIANG);
|
| | | List<UserSystemCoupon> list = userSystemCouponService.getUserCouponBySource(uid,
|
| | | UserSystemCoupon.SOURCE_CHOUJIANG);
|
| | | if (list != null && list.size() == 1) {
|
| | | couponId = list.get(0).getSystemCoupon().getId();
|
| | | SystemCoupon coupon = systemCouponService.selectByPrimaryKey(couponId);
|
| | |
| | |
|
| | | /**
|
| | | * 奖品抽取
|
| | | * |
| | | * @param maxCount 最大次数
|
| | | * @param hasPrize 拥有奖品数量
|
| | | * @param record 已抽次数
|
| | |
| | | }
|
| | |
|
| | | return prize;
|
| | | }
|
| | | |
| | |
|
| | | /**
|
| | | * 获取抽奖结果
|
| | | * |
| | | * @param callback
|
| | | * @param acceptData
|
| | | * @param uid
|
| | | * @param out
|
| | | */
|
| | | public int getSurplusCount(AcceptData acceptData, Long uid) throws Exception {
|
| | |
|
| | | // 默认最大抽奖次数
|
| | | int count = 5;
|
| | |
|
| | | if (uid == null) { // 未登录
|
| | | int platformType = 0;
|
| | | String platform = acceptData.getPlatform();
|
| | | if ("android".equals(platform)) {
|
| | | platformType = 1;
|
| | | } else if ("ios".equals(platform)) {
|
| | | platformType = 2;
|
| | | } else {
|
| | | throw new Exception("平台有误");
|
| | | }
|
| | |
|
| | | String device = acceptData.getDevice();
|
| | | if (device == null || device.trim().length() == 0) {
|
| | | throw new Exception("设备不存在");
|
| | | }
|
| | |
|
| | | List<DeviceLotteryRecord> list = deviceLotteryRecordService.listByPlatformAndDevice(platformType, device);
|
| | | if (list != null && list.size() > 0) {
|
| | | count = count - list.size();
|
| | | }
|
| | |
|
| | | } else { // 已登录
|
| | | UserInfoExtra userInfoExtra = userInfoExtraService.getUserInfoExtra(uid);
|
| | | if (userInfoExtra == null) {
|
| | | throw new Exception("信息不正确");
|
| | | }
|
| | |
|
| | | Integer lotteryNewbies = userInfoExtra.getLotteryNewbies();
|
| | | if (lotteryNewbies == null) { // 未抽过
|
| | | // 是否有过订单:返利、分享订单
|
| | | boolean hasOrder = commonOrderCountService.hasRebateAndShareOrder(uid);
|
| | | if (hasOrder) {
|
| | | count = 0; // 不算新用户
|
| | | }
|
| | | userInfoExtra.setLotteryNewbies(count);
|
| | | userInfoExtraService.saveUserInfoExtra(userInfoExtra);
|
| | | } else {
|
| | | count = lotteryNewbies; // 剩余次数
|
| | | } |
| | | }
|
| | |
|
| | | return count;
|
| | | }
|
| | |
|
| | | }
|