|
@ -1,21 +1,21 @@
|
1
|
1
|
package io.renren.modules.app.controller;
|
2
|
2
|
|
3
|
|
import java.util.Arrays;
|
|
3
|
import java.text.SimpleDateFormat;
|
|
4
|
import java.util.Date;
|
4
|
5
|
import java.util.Map;
|
5
|
6
|
|
6
|
|
import org.apache.shiro.authz.annotation.RequiresPermissions;
|
|
7
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
8
|
|
7
|
9
|
import org.springframework.beans.factory.annotation.Autowired;
|
8
|
|
import org.springframework.web.bind.annotation.PathVariable;
|
9
|
10
|
import org.springframework.web.bind.annotation.PostMapping;
|
10
|
|
import org.springframework.web.bind.annotation.RequestBody;
|
11
|
11
|
import org.springframework.web.bind.annotation.RequestMapping;
|
12
|
12
|
import org.springframework.web.bind.annotation.RequestParam;
|
13
|
13
|
import org.springframework.web.bind.annotation.RestController;
|
14
|
14
|
|
|
15
|
import io.renren.common.utils.R;
|
15
|
16
|
import io.renren.modules.admin.entity.SignEntity;
|
16
|
17
|
import io.renren.modules.admin.service.SignService;
|
17
|
|
import io.renren.common.utils.PageUtils;
|
18
|
|
import io.renren.common.utils.R;
|
|
18
|
import io.renren.modules.app.service.UserService;
|
19
|
19
|
|
20
|
20
|
|
21
|
21
|
|
|
@ -31,17 +31,50 @@ import io.renren.common.utils.R;
|
31
|
31
|
public class Sign {
|
32
|
32
|
@Autowired
|
33
|
33
|
private SignService signService;
|
34
|
|
|
|
34
|
@Autowired
|
|
35
|
private UserService userService;
|
35
|
36
|
/**
|
36
|
37
|
* 保存
|
37
|
38
|
*/
|
38
|
39
|
@PostMapping("/signin")
|
39
|
40
|
public R save(@RequestParam Map<String, Object> params){
|
40
|
41
|
Long attendersId = Long.valueOf(params.get("attendersId").toString());
|
41
|
|
SignEntity SignEntity = new SignEntity();
|
42
|
|
SignEntity.setAttenderId(attendersId);
|
43
|
|
|
44
|
|
|
45
|
|
return R.ok();
|
|
42
|
SignEntity sEntity = signService.getOne(
|
|
43
|
new QueryWrapper<SignEntity>().eq("attenders_id", attendersId)
|
|
44
|
);
|
|
45
|
if (sEntity == null) {
|
|
46
|
Map<String, Object> orderInfo = userService.queryOrderInfoByAttendersId(attendersId);
|
|
47
|
if (Integer.valueOf(orderInfo.get("isCheck").toString()) == 0) {
|
|
48
|
return R.error(1, "签到未成功");
|
|
49
|
}
|
|
50
|
SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
|
|
51
|
try {
|
|
52
|
Date dateStart = simpleDateFormat.parse(orderInfo.get("startTime").toString());
|
|
53
|
long startTime = dateStart.getTime();
|
|
54
|
Date dateEnd = simpleDateFormat.parse(orderInfo.get("endTime").toString());
|
|
55
|
long endTime = dateEnd.getTime();
|
|
56
|
long nowtime = System.currentTimeMillis();
|
|
57
|
if (nowtime < startTime || nowtime > endTime) {
|
|
58
|
return R.error(2, "签到未成功");
|
|
59
|
}
|
|
60
|
} catch (Exception e) {
|
|
61
|
return R.error();
|
|
62
|
}
|
|
63
|
SignEntity signEntity = new SignEntity();
|
|
64
|
signEntity.setAttendersId(attendersId);
|
|
65
|
signEntity.setMeetingId(Long.valueOf(orderInfo.get("meetingId").toString()));
|
|
66
|
signEntity.setStatus(1);
|
|
67
|
signEntity.setBadge(0);
|
|
68
|
signEntity.setCreateTime(new Date());
|
|
69
|
signEntity.setFlag(1L);
|
|
70
|
signEntity.setIsDel(0);
|
|
71
|
signService.save(signEntity);
|
|
72
|
return R.ok().put("signInfo", signEntity);
|
|
73
|
} else {
|
|
74
|
sEntity.setLastTime(new Date());
|
|
75
|
sEntity.setFlag(sEntity.getFlag() + 1L);
|
|
76
|
signService.updateById(sEntity);
|
|
77
|
return R.ok().put("signInfo", sEntity);
|
|
78
|
}
|
46
|
79
|
}
|
47
|
80
|
}
|