123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125 |
- package com.api.games.service.impl;
- import com.api.common.JSONUtils;
- import com.api.common.UtilFun;
- import com.api.config.ConstUser;
- import com.api.core.response.Result;
- import com.api.core.response.ResultGenerator;
- import com.api.core.service.AbstractService;
- import com.api.games.dao.GamePlayTimeMapper;
- import com.api.games.dao.PushLogMapper;
- import com.api.games.dao.ScaleLogMapper;
- import com.api.games.dao.UserConfigMapper;
- import com.api.games.model.GamePlayTime;
- import com.api.games.model.PushLog;
- import com.api.games.model.ScaleLog;
- import com.api.games.model.UserConfig;
- import com.api.games.service.ScaleLogService;
- import com.github.pagehelper.PageHelper;
- import com.github.pagehelper.PageInfo;
- import org.springframework.stereotype.Service;
- import org.springframework.transaction.annotation.Transactional;
- import tk.mybatis.mapper.entity.Condition;
- import javax.annotation.Resource;
- import java.util.Calendar;
- import java.util.Date;
- import java.util.List;
- import java.util.Map;
- /**
- * Created by wanghuiwen on 2020/02/23.
- */
- @Service
- @Transactional
- public class ScaleLogServiceImpl extends AbstractService<ScaleLog> implements ScaleLogService {
- @Resource
- private ScaleLogMapper scaleLogMapper;
- @Resource
- private UserConfigMapper userConfigMapper;
- @Resource
- private PushLogMapper pushLogMapper;
- @Resource
- private GamePlayTimeMapper gamePlayTimeMapper;
- @Override
- public void deletePlayGameId(Long id){
- gamePlayTimeMapper.deleteByPrimaryKey(id);
- }
- @Override
- public Result listOverDate(Long uid){
- Calendar calendar = Calendar.getInstance();
- calendar.add(Calendar.HOUR_OF_DAY, -2);
- return ResultGenerator.genSuccessResult(gamePlayTimeMapper.getScalePlayTime(uid, "2000-01-01 00:00:00", UtilFun.DateToString(calendar.getTime(), UtilFun.YYYYMMDDHHMMSS)));
- }
- @Override
- public void deleteByUid(Long id) {
- List<ScaleLog> scaleLogs = scaleLogMapper.listByUid(id);
- for (ScaleLog item : scaleLogs){
- deleteById(item.getId());
- }
- }
- @Override
- public Result list(String search, String ordermap, Integer page, Integer size) {
- Map<String, Object> params = JSONUtils.json2map(search);
- Map<String, Object> order = JSONUtils.json2map(ordermap);
- for (String key : order.keySet()) {
- if (order.get(key) != null && order.get(key).equals("ascending")) order.put(key, "asc");
- if (order.get(key) != null && order.get(key).equals("descending")) order.put(key, "desc");
- }
- PageHelper.startPage(page, size);
- List<Map<String, Object>> res = scaleLogMapper.list(params, order);
- PageInfo<Map<String, Object>> pageInfo = new PageInfo<>(res);
- return ResultGenerator.genSuccessResult(pageInfo);
- }
- @Override
- public Result notPerformed() {
- List<ScaleLog> res = scaleLogMapper.notPerformed();
- if (res != null && res.size() > 0) save(res);
- return ResultGenerator.genSuccessResult();
- }
- @Override
- public List<Map<String, Object>> download(String search, String ordermap) {
- Map<String, Object> params = JSONUtils.json2map(search);
- Map<String, Object> order = JSONUtils.json2map(ordermap);
- for (String key : order.keySet()) {
- if (order.get(key) != null && order.get(key).equals("ascending")) order.put(key, "asc");
- if (order.get(key) != null && order.get(key).equals("descending")) order.put(key, "desc");
- }
- return scaleLogMapper.list(params, order);
- }
- @Override
- public Result date(Long id, Long msgId) {
- //修改推送记录状态
- if (msgId != null) {
- PushLog pushLog = pushLogMapper.selectByPrimaryKey(msgId);
- if (pushLog != null) {
- pushLog.setStatus(ConstUser.PUSH_ING);
- pushLogMapper.updateByPrimaryKeySelective(pushLog);
- }
- }
- Condition condition = new Condition(ScaleLog.class);
- condition.createCriteria().andEqualTo("schedule", 0).andEqualTo("userId", id);
- List<ScaleLog> scaleLogs = scaleLogMapper.selectByCondition(condition);
- return ResultGenerator.genSuccessResult(scaleLogs);
- }
- @Override
- public String sign(Long uid) {
- List<ScaleLog> logs = scaleLogMapper.listByUid(uid);
- return String.valueOf(logs == null ? 1 : logs.size() + 1);
- }
- }
|