guozhaoshun 6 år sedan
förälder
incheckning
557cf56fd7

+ 0 - 3
rankin-api-web/src/main/java/cn/rankin/apiweb/controller/QRcodeController.java

@@ -26,11 +26,8 @@ public class QRcodeController {
     @RequestMapping(method = RequestMethod.GET)
     public APIResult<QRCodeVo> qrcode(@NeedUser DeviceUserVo user)
     {
-
         String eid = user.getEid();
-
         log.info("qrcode request header : eid={},", eid);
-
         return userService.qrcode(eid);
     }
 

+ 8 - 0
rankin-api-web/src/main/java/cn/rankin/apiweb/service/user/UserClient.java

@@ -82,6 +82,9 @@ public interface UserClient
     @RequestMapping(value = "/qrcode/callback", method = RequestMethod.POST)
     APIResult qrcodeCallback(@RequestParam("data")String data);
 
+    @RequestMapping(value = "/qrcode/status/fail", method = RequestMethod.PUT)
+    void updateQrcodesStatus(@RequestParam("eid") String eid);
+
 
     @Component
     class UserServiceHystrix implements UserClient
@@ -189,6 +192,11 @@ public interface UserClient
             return null;
         }
 
+        @Override
+        public void updateQrcodesStatus(String eid) {
+
+        }
+
 
     }
 }

+ 6 - 0
rankin-api-web/src/main/java/cn/rankin/apiweb/service/user/UserService.java

@@ -506,6 +506,12 @@ public class UserService
 
         String simple = vo.getMerchantSimple();
 
+
+        //生成新二维码入库前,将所有的待验证的二维码状态置为失败
+        userClient.updateQrcodesStatus(eid);
+
+
+
         QRCodeDTO dto = new QRCodeDTO();
         dto.setEid(eid);
         dto.setSimple(simple);

+ 5 - 0
rankin-user-service/src/main/java/cn/rankin/userservice/controller/QRCodeController.java

@@ -35,6 +35,11 @@ public class QRCodeController {
         return qrcodeService.findLastOne(eid);
     }
 
+    @RequestMapping(value = "/status/fail", method = RequestMethod.PUT)
+    public void updateStatusFail(@RequestParam("eid") String eid ){
+        qrcodeService.updateStatusFail(eid);
+    }
+
     @RequestMapping(value = "/callback", method = RequestMethod.POST)
     public APIResult callback(@RequestParam("data") String data)
     {

+ 3 - 0
rankin-user-service/src/main/java/cn/rankin/userservice/repository/QRCodeRepository.java

@@ -8,4 +8,7 @@ public interface QRCodeRepository extends BasicJpaRepository<QRCode, String> {
 
     @Query(value = "select qr.* from u_qrcode qr where qr.eid = ?1 ORDER BY qr.gmt_created DESC limit 1",nativeQuery = true)
     QRCode findLastOne(String eid);
+
+    @Query(value = "update QRCode qr set qr.status = 1 where qr.eid = ?1 and qr.status = 0 ")
+    void updateStatusFail(String eid);
 }

+ 6 - 0
rankin-user-service/src/main/java/cn/rankin/userservice/service/QRCodeService.java

@@ -7,6 +7,7 @@ import cn.rankin.userservice.repository.QRCodeRepository;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
+import javax.transaction.Transactional;
 import java.util.Date;
 
 import static cn.rankin.userservice.utils.DTOConverter.convert;
@@ -43,4 +44,9 @@ public class QRCodeService {
     public void update(QRCode qrcode) {
         qrcodeRepository.update(qrcode);
     }
+
+    @Transactional
+    public void updateStatusFail(String eid) {
+        qrcodeRepository.updateStatusFail(eid);
+    }
 }