| | |
| | | import com.yeshi.fanli.service.inter.user.UserInfoExtraService;
|
| | | import com.yeshi.fanli.service.inter.user.UserInfoService;
|
| | | import com.yeshi.fanli.util.Constant;
|
| | | import com.yeshi.fanli.util.StringUtil;
|
| | | import com.yeshi.fanli.vo.integral.DailySignVO;
|
| | | import com.yeshi.fanli.vo.integral.ExchangeTipVO;
|
| | | import com.yeshi.fanli.vo.integral.IntegralTaskClassVO;
|
| | |
| | |
|
| | | @Resource
|
| | | private ConfigService configService;
|
| | | |
| | |
|
| | | @Resource
|
| | | private UserInfoService userInfoService;
|
| | |
|
| | | @Resource
|
| | | private UserInfoExtraService userInfoExtraService;
|
| | | |
| | |
|
| | | @Resource
|
| | | private IntegralTaskClassService integralTaskClassService;
|
| | |
|
| | | @Resource
|
| | | private IntegralTaskRecordService integralTaskRecordService;
|
| | | |
| | |
|
| | | @Resource
|
| | | private IntegralExchangeService integralExchangeService;
|
| | | |
| | |
|
| | | @Resource
|
| | | private IntegralExchangeRecordService integralExchangeRecordService;
|
| | | |
| | |
|
| | | @Resource
|
| | | private CodePublishRecordService codePublishRecordService;
|
| | | |
| | |
|
| | | /**
|
| | | * 获取任务列表
|
| | | * |
| | | * @param acceptData
|
| | | * @param uid
|
| | | * @param page
|
| | |
| | | out.print(JsonUtil.loadFalseResult(1, "页码不正确"));
|
| | | return;
|
| | | }
|
| | | |
| | |
|
| | | GsonBuilder gsonBuilder = new GsonBuilder().excludeFieldsWithoutExposeAnnotation();
|
| | | Gson gson = gsonBuilder.create();
|
| | | try {
|
| | | JSONObject data = new JSONObject();
|
| | | List<IntegralTaskClassVO> list = integralTaskClassService.getIntegralTaskClassVO(uid, (page - 1) * Constant.PAGE_SIZE, Constant.PAGE_SIZE);
|
| | | List<IntegralTaskClassVO> list = integralTaskClassService.getIntegralTaskClassVO(uid,
|
| | | (page - 1) * Constant.PAGE_SIZE, Constant.PAGE_SIZE);
|
| | | if (list == null) {
|
| | | list = new ArrayList<IntegralTaskClassVO>();
|
| | | }
|
| | | long count = integralTaskClassService.countTaskClass();
|
| | | |
| | |
|
| | | if (page == 1) {
|
| | | UserInfoExtraVO extraVO = userInfoExtraService.getInfoExtraVOByUid(uid);
|
| | | if (extraVO == null) {
|
| | |
| | | out.print(JsonUtil.loadFalseResult(1, "查询用户信息不全"));
|
| | | return;
|
| | | }
|
| | | |
| | |
|
| | | UserRank userRank = extraVO.getUserRank();
|
| | | if (userRank == null) {
|
| | | out.print(JsonUtil.loadFalseResult(1, "用户等级不存在"));
|
| | | return;
|
| | | }
|
| | | |
| | |
|
| | | boolean signState = false;
|
| | | IntegralTaskClass taskClass = integralTaskClassService.getByUniqueKey(UniqueKeyEnum.dailySign.name());
|
| | | if (taskClass != null)
|
| | | signState = integralTaskRecordService.isToDaySign(uid, taskClass.getId());
|
| | | |
| | |
|
| | | // 签到日期
|
| | | DailySignVO dailySignVO = integralTaskClassService.getDailySignList(uid, userRank.getId());
|
| | | data.put("signState", signState);
|
| | |
| | | data.put("userRank", gson.toJson(userRank));
|
| | | data.put("dailySign", dailySignVO);
|
| | | }
|
| | | |
| | |
|
| | | data.put("count", count);
|
| | | data.put("list", gson.toJson(list));
|
| | | out.print(JsonUtil.loadTrueResult(data));
|
| | |
| | | LogHelper.errorDetailInfo(e);
|
| | | }
|
| | | }
|
| | | |
| | | |
| | |
|
| | | /**
|
| | | * 获取已完成任务 未领取金币
|
| | | * |
| | | * @param acceptData
|
| | | * @param uid
|
| | | * @param out
|
| | |
| | | if (list == null) {
|
| | | list = new ArrayList<IntegralTaskRecord>();
|
| | | }
|
| | | |
| | |
|
| | | GsonBuilder gsonBuilder = new GsonBuilder().excludeFieldsWithoutExposeAnnotation();
|
| | | Gson gson = gsonBuilder.create();
|
| | | |
| | |
|
| | | JSONObject data = new JSONObject();
|
| | | data.put("list", gson.toJson(list));
|
| | | out.print(JsonUtil.loadTrueResult(data));
|
| | | }
|
| | |
|
| | | |
| | | /**
|
| | | * 领取金币
|
| | | * |
| | | * @param acceptData
|
| | | * @param uid
|
| | | * @param ids
|
| | |
| | | out.print(JsonUtil.loadFalseResult(1, "用户未登录"));
|
| | | return;
|
| | | }
|
| | | |
| | |
|
| | | Gson gson = new Gson();
|
| | | Set<Long> idList = gson.fromJson(ids, new TypeToken<HashSet<Long>>() {}.getType());
|
| | | Set<Long> idList = gson.fromJson(ids, new TypeToken<HashSet<Long>>() {
|
| | | }.getType());
|
| | | if (idList == null || idList.size() == 0) {
|
| | | out.print(JsonUtil.loadFalseResult("领取id不能为空"));
|
| | | return;
|
| | |
| | | out.print(JsonUtil.loadFalseResult(e.getMsg()));
|
| | | }
|
| | | }
|
| | | |
| | | |
| | |
|
| | | /**
|
| | | * 金币兑换列表
|
| | | * 金币兑换列表
|
| | | * |
| | | * @param acceptData
|
| | | * @param uid
|
| | | * @param ids
|
| | |
| | | out.print(JsonUtil.loadFalseResult(1, "用户未登录"));
|
| | | return;
|
| | | }
|
| | | |
| | |
|
| | | if (page == null || page < 1) {
|
| | | out.print(JsonUtil.loadFalseResult(1, "页码不正确"));
|
| | | return;
|
| | | }
|
| | | |
| | |
|
| | | UserInfoExtraVO extraVO = userInfoExtraService.getInfoExtraVOByUid(uid);
|
| | | if (extraVO == null) {
|
| | | out.print(JsonUtil.loadFalseResult(1, "用户相关信息不存在"));
|
| | | return;
|
| | | }
|
| | | |
| | |
|
| | | List<IntegralExchange> list = integralExchangeRecordService.listExchange((page - 1) * Constant.PAGE_SIZE,
|
| | | Constant.PAGE_SIZE, uid);
|
| | | if (list == null) |
| | | if (list == null)
|
| | | list = new ArrayList<IntegralExchange>();
|
| | | |
| | |
|
| | | Long count = integralExchangeService.countValid();
|
| | | |
| | |
|
| | | GsonBuilder gsonBuilder = new GsonBuilder().excludeFieldsWithoutExposeAnnotation();
|
| | | Gson gson = gsonBuilder.create();
|
| | | |
| | |
|
| | | JSONObject data = new JSONObject();
|
| | | data.put("goldCoin", extraVO.getGoldCoin() + "枚");
|
| | | data.put("count", count);
|
| | | data.put("list", gson.toJson(list));
|
| | | out.print(JsonUtil.loadTrueResult(data));
|
| | | }
|
| | | |
| | |
|
| | | /**
|
| | | * 兑换金币检验
|
| | | * |
| | | * @param acceptData
|
| | | * @param uid
|
| | | * @param id
|
| | |
| | | public void verifyExchange(AcceptData acceptData, Long uid, Long id, PrintWriter out) {
|
| | | try {
|
| | | ExchangeTipVO exchange = integralExchangeService.verifyExchange(uid, id);
|
| | | |
| | |
|
| | | GsonBuilder gsonBuilder = new GsonBuilder().excludeFieldsWithoutExposeAnnotation();
|
| | | Gson gson = gsonBuilder.create();
|
| | | |
| | |
|
| | | JSONObject data = new JSONObject();
|
| | | data.put("result", gson.toJson(exchange));
|
| | | out.print(JsonUtil.loadTrueResult(data));
|
| | |
| | | out.print(JsonUtil.loadFalseResult(1, e.getMsg()));
|
| | | }
|
| | | }
|
| | | |
| | |
|
| | | /**
|
| | | * 兑换金币
|
| | | * |
| | | * @param acceptData
|
| | | * @param uid
|
| | | * @param id
|
| | |
| | | public void exchange(AcceptData acceptData, Long uid, Long id, PrintWriter out) {
|
| | | try {
|
| | | IntegralExchange exchange = integralExchangeService.exchange(uid, id);
|
| | | |
| | |
|
| | | GsonBuilder gsonBuilder = new GsonBuilder().excludeFieldsWithoutExposeAnnotation();
|
| | | Gson gson = gsonBuilder.create();
|
| | | |
| | |
|
| | | JSONObject data = new JSONObject();
|
| | | data.put("result", gson.toJson(exchange));
|
| | | out.print(JsonUtil.loadTrueResult(data));
|
| | |
| | | out.print(JsonUtil.loadFalseResult(1, e.getMsg()));
|
| | | }
|
| | | }
|
| | | |
| | | |
| | |
|
| | | /**
|
| | | * 兑换金币检验-邀请码
|
| | | * |
| | | * @param acceptData
|
| | | * @param uid
|
| | | * @param id
|
| | |
| | | public void verifyInviteCode(AcceptData acceptData, Long uid, Long id, PrintWriter out) {
|
| | | try {
|
| | | ExchangeTipVO exchange = integralExchangeService.verifyInviteCode(uid, id);
|
| | | |
| | |
|
| | | GsonBuilder gsonBuilder = new GsonBuilder().excludeFieldsWithoutExposeAnnotation();
|
| | | Gson gson = gsonBuilder.create();
|
| | | |
| | |
|
| | | JSONObject data = new JSONObject();
|
| | | data.put("result", gson.toJson(exchange));
|
| | | out.print(JsonUtil.loadTrueResult(data));
|
| | |
| | | out.print(JsonUtil.loadFalseResult(1, e.getMsg()));
|
| | | }
|
| | | }
|
| | | |
| | | |
| | |
|
| | | /**
|
| | | * 兑换金币-邀请码
|
| | | * |
| | | * @param acceptData
|
| | | * @param uid
|
| | | * @param id
|
| | |
| | | out.print(JsonUtil.loadFalseResult(1, e.getMsg()));
|
| | | }
|
| | | }
|
| | | |
| | | |
| | | |
| | |
|
| | | /**
|
| | | * 邀请码发布列表
|
| | | * |
| | | * @param acceptData
|
| | | * @param page
|
| | | * @param out
|
| | |
| | | out.print(JsonUtil.loadFalseResult(1, "页码不正确"));
|
| | | return;
|
| | | }
|
| | | |
| | | List<CodePublishRecord> list = codePublishRecordService.listValid((page - 1) * Constant.PAGE_SIZE, Constant.PAGE_SIZE);
|
| | |
|
| | | List<CodePublishRecord> list = codePublishRecordService.listValid((page - 1) * Constant.PAGE_SIZE,
|
| | | Constant.PAGE_SIZE);
|
| | | if (list == null) {
|
| | | list = new ArrayList<CodePublishRecord>();
|
| | | } |
| | | |
| | | }
|
| | |
|
| | | long count = codePublishRecordService.countValid();
|
| | | |
| | |
|
| | | JSONObject data = new JSONObject();
|
| | | data.put("count", count);
|
| | | data.put("list", getGson().toJson(list));
|
| | | data.put("helpLink", configService.get("publish_list_help_link"));
|
| | | out.print(JsonUtil.loadTrueResult(data));
|
| | | }
|
| | | |
| | | |
| | |
|
| | | /**
|
| | | * 事件推送
|
| | | * |
| | | * @param acceptData
|
| | | * @param event
|
| | | * @param uid
|
| | | * @param out
|
| | | */
|
| | | @RequestMapping(value = "pushEvent", method = RequestMethod.POST)
|
| | | public void pushEvent(AcceptData acceptData, String event, Long uid, PrintWriter out) {
|
| | | if (uid == null || uid == 0) {
|
| | | out.print(JsonUtil.loadFalseResult("用户尚未登录"));
|
| | | return;
|
| | | }
|
| | | |
| | | if (StringUtil.isNullOrEmpty(event)) {
|
| | | out.print(JsonUtil.loadFalseResult("事件为空"));
|
| | | return;
|
| | | }
|
| | |
|
| | | JSONObject data = new JSONObject();
|
| | | if ("recommendSearch".equalsIgnoreCase(event) || "scanGoods".equalsIgnoreCase(event)
|
| | | || "scanTBCart".equalsIgnoreCase(event)) {
|
| | | JSONObject notify = new JSONObject();
|
| | | switch (event) {
|
| | | |
| | | case "recommendSearch":
|
| | | notify.put("name", "完成一次智能搜索");
|
| | | notify.put("score", "+20");
|
| | | break;
|
| | | case "scanGoods":
|
| | | notify.put("name", "完成一次商品浏览");
|
| | | notify.put("score", "+10");
|
| | | break;
|
| | | case "scanTBCart":
|
| | | notify.put("name", "完成一次购物车浏览");
|
| | | notify.put("score", "+30");
|
| | | break;
|
| | | }
|
| | |
|
| | | data.put("notify", notify);
|
| | | }
|
| | | out.print(JsonUtil.loadTrueResult(data));
|
| | | }
|
| | |
|
| | | /**
|
| | | * 时间处理
|
| | | * |
| | | * @return
|
| | | */
|
| | | private Gson getGson() {
|
| | |
| | | String desc = "";
|
| | | if (value != null) {
|
| | | // 判断是否是同一天
|
| | | |
| | |
|
| | | Calendar calendar = Calendar.getInstance();
|
| | | calendar.setTime(value);
|
| | | int y1 = calendar.get(Calendar.YEAR);//获取年份
|
| | | int d1 = calendar.get(Calendar.DAY_OF_YEAR);//获取年中第几天
|
| | | int y1 = calendar.get(Calendar.YEAR);// 获取年份
|
| | | int d1 = calendar.get(Calendar.DAY_OF_YEAR);// 获取年中第几天
|
| | |
|
| | | Date nowDate = new Date();
|
| | | Calendar calendar2 = Calendar.getInstance();
|
| | | calendar2.setTime(nowDate);
|
| | | int y2 = calendar2.get(Calendar.YEAR);//获取年份
|
| | | int d2 = calendar2.get(Calendar.DAY_OF_YEAR);//获取年中第几天
|
| | | |
| | | int y2 = calendar2.get(Calendar.YEAR);// 获取年份
|
| | | int d2 = calendar2.get(Calendar.DAY_OF_YEAR);// 获取年中第几天
|
| | |
|
| | | long old = value.getTime();
|
| | | long now = nowDate.getTime();
|
| | | if (y1 == y2) {
|
| | |
| | | long cha = now - old;
|
| | | if (cha < 1000 * 60 * 2L) {
|
| | | desc = "刚刚";
|
| | | }else if (cha < 1000 * 60 * 60L) {
|
| | | } else if (cha < 1000 * 60 * 60L) {
|
| | | desc = (cha / (1000 * 60)) + "分钟前";
|
| | | }else {
|
| | | } else {
|
| | | desc = (cha / (1000 * 60 * 60)) + "小时前";
|
| | | }
|
| | | } else if (d2 - d1 == 1) {
|
| | |
| | | Gson gson = gb.create();
|
| | | return gson;
|
| | | }
|
| | | |
| | | |
| | | |
| | | |
| | |
|
| | | }
|