Browse Source

二维码扫描签到

huwhois 5 years ago
parent
commit
336c5f1350

+ 1 - 1
src/main/java/io/renren/modules/admin/entity/SignEntity.java

@ -32,7 +32,7 @@ public class SignEntity implements Serializable {
32 32
	/**
33 33
	 * 签到人id
34 34
	 */
35
	private Long attenderId;
35
	private Long attendersId;
36 36
	/**
37 37
	 * 签到状态
38 38
	 */

+ 1 - 2
src/main/java/io/renren/modules/app/controller/OrderController.java

@ -44,8 +44,7 @@ public class OrderController {
44 44
    private UserService userService;
45 45
    @Autowired
46 46
    private PaymentService paymentService;
47
    @Autowired
48
    private MeetingService meetingService;
47
    
49 48
    /**
50 49
     * 订单列表
51 50
     */

+ 45 - 12
src/main/java/io/renren/modules/app/controller/Sign.java

@ -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
}

+ 1 - 1
src/main/java/io/renren/modules/app/dao/UserDao.java

@ -26,6 +26,6 @@ public interface UserDao extends BaseMapper<UserEntity> {
26 26
    @Select("select p.order_id, p.attenders_id as attendersId, (select a.name from attenders as a where a.id=p.attenders_id) as attendersName,  (select a.organization from attenders as a where a.id=p.attenders_id) as organization, (select tf.name from types_of_fee as tf where tf.id=p.pay_type) as typeName, p.pay_time, (select m.name_cn from meeting as m where m.id=p.meeting_id) as meetingName from payment as p where p.attenders_id in  (select a.id from attenders as a where a.member_id=#{member_id});")
27 27
    List<Map<String, Object>> queryOrderList(Long memberId);
28 28
29
    @Select("select a.name as attendersName,a.meeting_id as meetingId,a.position_id as position,(select m.name_cn from meeting as m where m.id=a.meeting_id) as meetingName ,(select m.start_time from meeting as m where m.id=a.meeting_id) as startTime,(select p.is_check from payment as p where p.attenders_id = a.id) as isCheck from attenders as a where a.id = #{attendersId};")
29
    @Select("select a.name as attendersName,a.meeting_id as meetingId,a.position_id as position,(select m.name_cn from meeting as m where m.id=a.meeting_id) as meetingName ,(select m.start_time from meeting as m where m.id=a.meeting_id) as startTime,(select m.end_time from meeting as m where m.id=a.meeting_id) as endTime,(select p.is_check from payment as p where p.attenders_id = a.id) as isCheck from attenders as a where a.id = #{attendersId};")
30 30
    Map<String, Object> queryOrderInfoByAttendersId(Long attendersId);
31 31
}