| | |
| | | import com.yeshi.makemoney.app.service.inter.goldcorn.GoldCornGetRecordService; |
| | | import com.yeshi.makemoney.app.service.inter.goldcorn.GoldCornMakeService; |
| | | import com.yeshi.makemoney.app.service.inter.team.TeamInviteRelationService; |
| | | import com.yeshi.makemoney.app.service.inter.user.UserExtraInfoService; |
| | | import com.yeshi.makemoney.app.service.query.goldcorn.GoldCornConsumeRecordQuery; |
| | | import com.yeshi.makemoney.app.service.query.goldcorn.GoldCornGetRecordQuery; |
| | | import com.yeshi.makemoney.app.utils.Constant; |
| | |
| | | import com.yeshi.makemoney.app.vo.goldcorn.*; |
| | | import net.sf.json.JSONArray; |
| | | import net.sf.json.JSONObject; |
| | | import org.springframework.data.redis.core.RedisTemplate; |
| | | import org.springframework.stereotype.Controller; |
| | | import org.springframework.web.bind.annotation.RequestMapping; |
| | | import org.springframework.web.bind.annotation.ResponseBody; |
| | |
| | | import javax.annotation.Resource; |
| | | import java.lang.reflect.Type; |
| | | import java.util.*; |
| | | import java.util.concurrent.TimeUnit; |
| | | import java.util.stream.Collectors; |
| | | |
| | | /** |
| | |
| | | |
| | | @Resource |
| | | private TeamInviteRelationService teamInviteRelationService; |
| | | |
| | | @Resource |
| | | private UserExtraInfoService userExtraInfoService; |
| | | |
| | | @Resource |
| | | private RedisTemplate<String, Object> redisTemplate; |
| | | |
| | | private Gson gson = JsonUtil.getConvertBigDecimalToStringBuilder(new GsonBuilder()).create(); |
| | | |
| | |
| | | @UserLogin(uid = "#uid") |
| | | @RequestMapping("doTask") |
| | | @ResponseBody |
| | | public String doTask(AcceptData acceptData, Long uid, String taskData) { |
| | | Type type = new TypeToken<List<GoldCornDoTaskVO>>() { |
| | | }.getType(); |
| | | List<GoldCornDoTaskVO> list = null; |
| | | public String doTask(AcceptData acceptData, Long uid, GoldCornDoTaskVO vo) { |
| | | |
| | | if (vo.getType() == null) { |
| | | return JsonUtil.loadFalseResult("参数不完整"); |
| | | } |
| | | |
| | | try { |
| | | list = gson.fromJson(taskData, type); |
| | | } catch (Exception e) { |
| | | |
| | | } |
| | | if (list == null) { |
| | | return JsonUtil.loadFalseResult("数据为空"); |
| | | } |
| | | |
| | | for (GoldCornDoTaskVO vo : list) { |
| | | try { |
| | | goldCornMakeService.addGoldCorn(uid, vo.getType(), vo.getDouble() == null ? false : vo.getDouble(), new Date(vo.getFinishTime() == null ? System.currentTimeMillis() : vo.getFinishTime()), null); |
| | | } catch (UserInfoException e) { |
| | | e.printStackTrace(); |
| | | } catch (GoldCornGetPriceException e) { |
| | | e.printStackTrace(); |
| | | } catch (GoldCornGetFrequencyConfigException e) { |
| | | e.printStackTrace(); |
| | | } catch (GoldCornMakeException e) { |
| | | e.printStackTrace(); |
| | | JSONObject data = new JSONObject(); |
| | | Integer result = null; |
| | | if (vo.getType() == GoldCornGetType.watchVideo) { |
| | | result = goldCornMakeService.watchVideo(uid, vo.getDouble(), vo.getFinishTime() == null ? new Date() : new Date(vo.getFinishTime()), vo.getTimeSeconds()); |
| | | } else if (vo.getType() == GoldCornGetType.readNovel) { |
| | | result = goldCornMakeService.readNovel(uid, vo.getDouble(), vo.getFinishTime() == null ? new Date() : new Date(vo.getFinishTime()), vo.getTimeSeconds()); |
| | | } else if (vo.getType() == GoldCornGetType.scanNews) { |
| | | result = goldCornMakeService.scanNews(uid, vo.getDouble(), vo.getFinishTime() == null ? new Date() : new Date(vo.getFinishTime()), vo.getNum()); |
| | | } else { |
| | | return JsonUtil.loadFalseResult("任务类型出错"); |
| | | } |
| | | data.put("goldCorn", result); |
| | | |
| | | return JsonUtil.loadTrueResult(data); |
| | | |
| | | } catch (GoldCornGetPriceException e) { |
| | | e.printStackTrace(); |
| | | return JsonUtil.loadFalseResult("业务错误"); |
| | | } catch (UserInfoException e) { |
| | | e.printStackTrace(); |
| | | return JsonUtil.loadFalseResult(e.getMessage()); |
| | | } catch (GoldCornMakeException e) { |
| | | e.printStackTrace(); |
| | | return JsonUtil.loadFalseResult(e.getMessage()); |
| | | } catch (GoldCornGetFrequencyConfigException e) { |
| | | e.printStackTrace(); |
| | | return JsonUtil.loadFalseResult(e.getMessage()); |
| | | } |
| | | return JsonUtil.loadTrueResult(""); |
| | | } |
| | | |
| | | |
| | |
| | | if (uid != null) { |
| | | vo.setSignIned(goldCornMakeService.isSignIn(uid, now)); |
| | | vo.setContinueSignInDay(goldCornMakeService.getContinueSignDay(uid)); |
| | | vo.setNotify(userExtraInfoService.getSignInNotify(uid)); |
| | | } |
| | | /*************签到日期列表开始**************/ |
| | | |
| | |
| | | } else { |
| | | dayDiff++; |
| | | //未来的时间 |
| | | dayInfo.setGoldCorn(goldCornGetPriceService.getSingInPrice(acceptData.getSystem(), vo.getContinueSignInDay() + 1 + dayDiff)); |
| | | dayInfo.setGoldCorn(goldCornGetPriceService.getSingInPrice(acceptData.getSystem(), vo.getContinueSignInDay() + (vo.isSignIned() ? 0 : 1) + dayDiff)); |
| | | dayInfo.setState(SignInInfoVO.SignInDayInfo.STATE_NOT_GOT); |
| | | } |
| | | //清除临时变量 |
| | |
| | | |
| | | } |
| | | |
| | | |
| | | /** |
| | | * @return java.lang.String |
| | | * @author hxh |
| | | * @description 设置签到提醒 |
| | | * @date 10:39 2022/4/22 |
| | | * @param: acceptData |
| | | * @param: uid |
| | | * @param: notify 是否提醒 |
| | | **/ |
| | | @UserLogin(uid = "#uid") |
| | | @RequestMapping("setSignInNotify") |
| | | @ResponseBody |
| | | public String setSignInNotify(AcceptData acceptData, Long uid, boolean notify) { |
| | | userExtraInfoService.setSignInNotify(uid, notify); |
| | | return JsonUtil.loadTrueResult(""); |
| | | } |
| | | |
| | | |
| | | } |