Browse Source

证照管理

zjy 4 weeks ago
parent
commit
7313a75b5b

+ 35 - 2
alien-gateway/src/main/java/shop/alien/gateway/service/LifeUserService.java

@@ -145,6 +145,7 @@ public class LifeUserService extends ServiceImpl<LifeUserGatewayMapper, LifeUser
 
     /**
      * 用户登录log存放(加入mac地址)
+     * 记录用户登录信息并进行风控检查
      */
     @Transactional
     public void addLifeUserLogInfo(LifeUser user, String macIp) {
@@ -154,11 +155,12 @@ public class LifeUserService extends ServiceImpl<LifeUserGatewayMapper, LifeUser
             lifeUserLog.setUserName(user.getUserName());
             lifeUserLog.setMacIp(macIp);
             lifeUserLog.setCreatedTime(new Date());
-            int count = lifeUserLogMapper.insert(lifeUserLog);
+            // 将插入操作放到新事务中,确保立即提交
+            int count = insertLifeUserLogInNewTransaction(lifeUserLog);
             if (count > 0) {
                 String startDate = LocalDateTime.now().minusHours(24L).format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"));
                 String endDate = LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"));
-                // 使用一个新的事务来查询,确保能看到刚才插入的数据
+                // 使用一个新的事务来查询,此时能看到刚才插入的数据
                 List<LifeUserLog> lsit = getLifeUserLogByDateInNewTransaction(startDate, endDate, macIp);
 
                 if (lsit.size() > riskControlProperties.getAccountAbnormal().getRegCount24h() && !isViolation(startDate, endDate, macIp, user.getId())) {
@@ -176,11 +178,42 @@ public class LifeUserService extends ServiceImpl<LifeUserGatewayMapper, LifeUser
 
     }
 
+    /**
+     * 在新事务中插入用户登录日志
+     * 使用 REQUIRES_NEW 确保插入操作立即提交,便于后续查询
+     *
+     * @param lifeUserLog 用户登录日志对象
+     * @return int 插入成功的记录数
+     */
+    @Transactional(propagation = Propagation.REQUIRES_NEW)
+    public int insertLifeUserLogInNewTransaction(LifeUserLog lifeUserLog) {
+        return lifeUserLogMapper.insert(lifeUserLog);
+    }
+
+    /**
+     * 在新事务中查询指定时间段内的用户登录日志
+     * 使用 REQUIRES_NEW 确保能读取到已提交的最新数据
+     *
+     * @param startDate 开始时间
+     * @param endDate 结束时间
+     * @param macIp MAC地址/IP
+     * @return List<LifeUserLog> 用户登录日志列表
+     */
     @Transactional(propagation = Propagation.REQUIRES_NEW)
     public List<LifeUserLog> getLifeUserLogByDateInNewTransaction(String startDate, String endDate, String macIp) {
         return lifeUserLogMapper.getLifeUserLogByDate(startDate, endDate, macIp);
     }
 
+    /**
+     * 判断是否已存在违规记录
+     * 检查指定时间段内是否已经记录过该用户的风控信息
+     *
+     * @param startDate 开始时间
+     * @param endDate 结束时间
+     * @param macIp MAC地址/IP
+     * @param userId 用户ID
+     * @return boolean true-已存在违规记录,false-不存在
+     */
     public boolean isViolation(String startDate, String endDate, String macIp, Integer userId) {
         List<SecondRiskControlRecord> list = secondRiskControlRecordMapper.selectByBusinessId(startDate, endDate, macIp);
         for (SecondRiskControlRecord record : list) {

+ 63 - 0
alien-store-platform/src/main/java/shop/alien/storeplatform/controller/LicenseController.java

@@ -0,0 +1,63 @@
+package shop.alien.storeplatform.controller;
+
+import io.swagger.annotations.*;
+import lombok.RequiredArgsConstructor;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.web.bind.annotation.*;
+import shop.alien.entity.result.R;
+import shop.alien.entity.store.StoreImg;
+import shop.alien.storeplatform.service.LicenseService;
+
+import java.util.List;
+
+
+@Slf4j
+@Api(tags = {"商家端-证照管理"})
+@ApiSort(3)
+@CrossOrigin
+@RestController
+@RequestMapping("/license")
+@RequiredArgsConstructor
+public class LicenseController {
+
+    private final LicenseService licenseService;
+    @ApiOperation("获取营业执照图片信息")
+    @ApiOperationSupport(order = 1)
+    @ApiImplicitParams({
+            @ApiImplicitParam(name = "Integer", value = "城市", dataType = "String", paramType = "query", required = false)
+    })
+    @GetMapping("/querybusinessLicenseList")
+    public R<List<StoreImg>> querybusinessLicenseList(Integer id) {
+        log.info("LicenseController.getbusinessLicenseList?id={}", id);
+        List<StoreImg> result = licenseService.getbusinessLicenseList(id);
+        return R.data(result);
+    }
+
+    @ApiOperation("获取合同图片信息")
+    @ApiOperationSupport(order = 1)
+    @ApiImplicitParams({
+            @ApiImplicitParam(name = "id", value = "城市", dataType = "Integer", paramType = "query", required = false)
+    })
+    @GetMapping("/queryContractList")
+    public R<List<StoreImg>> queryContractList(Integer id) {
+        log.info("LicenseController.queryContractList?id={}", id);
+        List<StoreImg> result = licenseService.getContractList(id);
+        return R.data(result);
+    }
+
+    @ApiOperation("获取经营许可证图片信息")
+    @ApiOperationSupport(order = 1)
+    @ApiImplicitParams({
+            @ApiImplicitParam(name = "id", value = "城市", dataType = "Integer", paramType = "query", required = false)
+    })
+    @GetMapping("/queryFoodLicenceList")
+    public R<List<StoreImg>> queryFoodLicenceList(Integer id) {
+        log.info("LicenseController.queryFoodLicenceList?id={}", id);
+        List<StoreImg> result = licenseService.getFoodLicenceList(id);
+        return R.data(result);
+    }
+
+}
+
+
+

+ 18 - 0
alien-store-platform/src/main/java/shop/alien/storeplatform/service/LicenseService.java

@@ -0,0 +1,18 @@
+package shop.alien.storeplatform.service;
+
+
+import shop.alien.entity.store.StoreImg;
+
+import java.util.List;
+
+public interface LicenseService {
+
+    List<StoreImg> getbusinessLicenseList (Integer id);
+
+    List<StoreImg> getContractList (Integer id);
+
+    List<StoreImg> getFoodLicenceList (Integer id);
+}
+
+
+

+ 34 - 0
alien-store-platform/src/main/java/shop/alien/storeplatform/service/impl/LicenseServiceImpl.java

@@ -0,0 +1,34 @@
+package shop.alien.storeplatform.service.impl;
+
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import lombok.RequiredArgsConstructor;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.stereotype.Service;
+import shop.alien.entity.store.StoreImg;
+import shop.alien.mapper.StoreImgMapper;
+import shop.alien.storeplatform.service.LicenseService;
+
+import java.util.List;
+
+
+@Slf4j
+@Service
+@RequiredArgsConstructor
+public class LicenseServiceImpl implements LicenseService {
+
+    private final StoreImgMapper storeImgMapper;
+
+    public List<StoreImg> getbusinessLicenseList (Integer id) {
+        return storeImgMapper.selectList(new LambdaQueryWrapper<StoreImg>().eq(StoreImg::getImgType, 14).eq(StoreImg::getStoreId, id));
+    }
+
+    public List<StoreImg> getContractList (Integer id) {
+        return storeImgMapper.selectList(new LambdaQueryWrapper<StoreImg>().eq(StoreImg::getImgType, 15).eq(StoreImg::getStoreId, id));
+    }
+
+    public List<StoreImg> getFoodLicenceList (Integer id) {
+        return storeImgMapper.selectList(new LambdaQueryWrapper<StoreImg>().eq(StoreImg::getImgType, 25).eq(StoreImg::getStoreId, id));
+    }
+
+}
+