|
@@ -1,11 +1,18 @@
|
|
|
package cn.rankin.userservice.controller;
|
|
|
|
|
|
+import cn.rankin.common.utils.api.model.APIResult;
|
|
|
+import cn.rankin.common.utils.util.FastJsonUtils;
|
|
|
import cn.rankin.data.api.user.dto.QRCodeDTO;
|
|
|
+import cn.rankin.data.api.user.entity.LocationInfo;
|
|
|
import cn.rankin.data.api.user.entity.QRCode;
|
|
|
+import cn.rankin.userservice.service.LocationInfoService;
|
|
|
import cn.rankin.userservice.service.QRCodeService;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
|
|
|
+import java.util.Date;
|
|
|
+import java.util.Map;
|
|
|
+
|
|
|
@RestController
|
|
|
@RequestMapping(value = "/qrcode")
|
|
|
public class QRCodeController {
|
|
@@ -13,6 +20,9 @@ public class QRCodeController {
|
|
|
@Autowired
|
|
|
private QRCodeService qrcodeService;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private LocationInfoService locationInfoService;
|
|
|
+
|
|
|
@RequestMapping(method = RequestMethod.POST)
|
|
|
public QRCode add(@RequestBody QRCodeDTO dto) {
|
|
|
return qrcodeService.add(dto);
|
|
@@ -23,4 +33,87 @@ public class QRCodeController {
|
|
|
return qrcodeService.findLastOne(eid);
|
|
|
}
|
|
|
|
|
|
+ @RequestMapping(value = "/callback", method = RequestMethod.POST)
|
|
|
+ public APIResult callback(@RequestParam("data") String data)
|
|
|
+ {
|
|
|
+
|
|
|
+ Map<String, Object> requestMap = FastJsonUtils.stringToCollect(data);
|
|
|
+
|
|
|
+ boolean status = (boolean) requestMap.get("status");
|
|
|
+ Map<String, Object> dataMap = (Map<String, Object>) requestMap.get("data");
|
|
|
+
|
|
|
+
|
|
|
+ Map<String, Object> qrcodeMap = (Map<String, Object>) dataMap.get("qrcode");
|
|
|
+ String eid = (String) qrcodeMap.get("user");
|
|
|
+ long time = (long) qrcodeMap.get("time");
|
|
|
+
|
|
|
+ QRCode qrcode = new QRCode();
|
|
|
+ qrcode.setEid(eid);
|
|
|
+ //qrcode.setTime(new Date(time));
|
|
|
+
|
|
|
+ QRCode entity = qrcodeService.findFirst(qrcode);
|
|
|
+
|
|
|
+ if(status){
|
|
|
+ qrcodeCallback(eid, qrcode.getSimple(), dataMap);
|
|
|
+ entity.setStatus(2);
|
|
|
+ qrcodeService.update(entity);
|
|
|
+ return APIResult.ok("扫码成功");
|
|
|
+ }else{
|
|
|
+ entity.setStatus(1);
|
|
|
+ qrcodeService.update(entity);
|
|
|
+ return APIResult.ok("扫码失败");
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 处理位置信息
|
|
|
+ * @param dataMap
|
|
|
+ */
|
|
|
+ private void qrcodeCallback(String eid,String simple ,Map<String,Object> dataMap) {
|
|
|
+
|
|
|
+ Map<String,Object> position = (Map<String, Object>) dataMap.get("position");
|
|
|
+ String lat = (String) position.get("lat");
|
|
|
+ String lng = (String) position.get("lng");
|
|
|
+ String precise = (String) position.get("precise");
|
|
|
+ String address = (String) position.get("address");
|
|
|
+
|
|
|
+ Map<String,Object> teacher_info = (Map<String, Object>) dataMap.get("teacher_info");
|
|
|
+ String tRealName = (String) teacher_info.get("real_name");
|
|
|
+ String tMobile = (String) teacher_info.get("mobile");
|
|
|
+ String tPosition = (String) teacher_info.get("position");
|
|
|
+ String tEnCode = (String) teacher_info.get("en_code");
|
|
|
+
|
|
|
+
|
|
|
+ Map<String,Object> campus_info = (Map<String, Object>) dataMap.get("campus_info");
|
|
|
+ String campusName = (String) campus_info.get("campus_name");
|
|
|
+ String cEnCode = (String) campus_info.get("en_code");
|
|
|
+ String cLat = (String) campus_info.get("lat");
|
|
|
+ String cLng = (String) campus_info.get("lng");
|
|
|
+ Map<String,Object> attach = (Map<String, Object>) dataMap.get("attach");
|
|
|
+
|
|
|
+
|
|
|
+ LocationInfo locationInfo = new LocationInfo();
|
|
|
+ locationInfo.setEid(eid);
|
|
|
+ locationInfo.setSimple(simple);
|
|
|
+ locationInfo.setAddress(address);
|
|
|
+ locationInfo.setLat(lat);
|
|
|
+ locationInfo.setLng(lng);
|
|
|
+ locationInfo.setPrecise(precise);
|
|
|
+
|
|
|
+
|
|
|
+ locationInfo.setTRealName(tRealName);
|
|
|
+ locationInfo.setTEnCode(tEnCode);
|
|
|
+ locationInfo.setTMobile(tMobile);
|
|
|
+ locationInfo.setTPosition(tPosition);
|
|
|
+
|
|
|
+ locationInfo.setCampusName(campusName);
|
|
|
+ locationInfo.setCEnCode(cEnCode);
|
|
|
+ locationInfo.setCLat(cLat);
|
|
|
+ locationInfo.setCLng(cLng);
|
|
|
+
|
|
|
+ locationInfoService.add(locationInfo);
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
}
|