lrf402788946 4 năm trước cách đây
mục cha
commit
e919f4d6b7
1 tập tin đã thay đổi với 6 bổ sung2 xóa
  1. 6 2
      app/service/attendance.js

+ 6 - 2
app/service/attendance.js

@@ -23,6 +23,7 @@ class AttendanceService extends CrudService {
   }
 
   async attendancecreate(data) {
+    // 修改ibeacon=>[],存有 limit 范围内的所有蓝牙设备号
     const { openid, type, ibeacon } = data;
     assert(openid && type && ibeacon, '缺少信息项');
     // 通过openid取得学生信息
@@ -50,7 +51,9 @@ class AttendanceService extends CrudService {
       if (!location) {
         throw new BusinessError(ErrorCode.DATA_NOT_EXIST, '位置信息不存在');
       }
-      if (location.ibeacon !== ibeacon) {
+      // 判断,location的蓝牙号在不在ibeacon中
+      const r = ibeacon.find(f => `${f}` === `${location.ibeacon}`);
+      if (!r) {
         throw new BusinessError(ErrorCode.BUSINESS, '考勤位置不正确');
       }
       const attendance = await this.model.findOne({
@@ -115,7 +118,8 @@ class AttendanceService extends CrudService {
       if (!beedroom) {
         throw new BusinessError(ErrorCode.DATA_NOT_EXIST, '寝室信息不存在');
       }
-      if (beedroom.ibeacon !== ibeacon) {
+      const r = ibeacon.find(f => `${f}` === `${beedroom.ibeacon}`);
+      if (!r) {
         throw new BusinessError(ErrorCode.BUSINESS, '考勤位置不正确');
       }
       const attendance = await this.model.findOne({