瀏覽代碼

Merge remote-tracking branch 'origin/store-plantform' into store-plantform

wxd 3 周之前
父節點
當前提交
1ba6ce2f78

+ 5 - 0
alien-entity/src/main/java/shop/alien/entity/storePlatform/vo/StoreLicenseHistoryDto.java

@@ -8,6 +8,8 @@ import lombok.EqualsAndHashCode;
 import org.apache.ibatis.type.Alias;
 import shop.alien.entity.storePlatform.StoreLicenseHistory;
 
+import java.util.List;
+
 /**
  * 商户证照历史记录展示DTO
  * <p>
@@ -31,5 +33,8 @@ public class StoreLicenseHistoryDto extends StoreLicenseHistory {
     @ApiModelProperty(value = "审核状态名称")
     private String licenseExecuteName;
 
+    @ApiModelProperty(value = "相同时间的证照历史记录列表")
+    private List<StoreLicenseHistoryDto> licenseList;
+
 }
 

+ 36 - 3
alien-store-platform/src/main/java/shop/alien/storeplatform/controller/LicenseController.java

@@ -13,6 +13,8 @@ import shop.alien.mapper.WebAuditMapper;
 import shop.alien.storeplatform.service.LicenseService;
 
 import java.util.List;
+import java.util.Map;
+import java.util.Map;
 
 
 @Slf4j
@@ -65,7 +67,7 @@ public class LicenseController {
         return R.data(result);
     }
 
-    @ApiOperation(value = "门店装修-食品经营许可证")
+    @ApiOperation(value = "门店装修-修改食品经营许可证")
     @PostMapping("/uploadfoodLicence")
     public R<String> uploadfoodLicence(@RequestBody StoreImg storeImg) {
         log.info("StoreInfoController.uploadfoodLicence?storeImg={}", storeImg);
@@ -82,8 +84,6 @@ public class LicenseController {
         return R.fail("食品经营许可证图片添加失败");
     }
 
-
-
     @ApiOperation("根据商户ID获取经营许可证历史记录")
     @ApiOperationSupport(order = 3)
     @ApiImplicitParams({
@@ -101,6 +101,15 @@ public class LicenseController {
         }
     }
 
+    @ApiOperation(value = "门店装修-食品经营许可证状态")
+    @ApiImplicitParams({@ApiImplicitParam(name = "id", value = "门店id", dataType = "int", paramType = "query", required = true)})
+    @GetMapping("/getStoreFoodLicenceStatus")
+    public R<Map<String, Object>> getStoreFoodLicenceStatus(int id) {
+        log.info("StoreInfoController.getStoreFoodLicenceStatus?id={}", id);
+        return R.data(licenseService.getStoreFoodLicenceStatus(id));
+    }
+
+
     @ApiOperation(value = "门店装修-续签合同")
     @PostMapping("/uploadRenewalContract")
     public R<String> uploadRenewalContract(@RequestBody List<StoreImg> storeImgList) {
@@ -112,6 +121,30 @@ public class LicenseController {
         return R.success("续签合同图片添加成功");
     }
 
+    @ApiOperation(value = "门店装修-续签合同状态及合同图片")
+    @ApiImplicitParams({@ApiImplicitParam(name = "id", value = "门店id", dataType = "int", paramType = "query", required = true)})
+    @GetMapping("/getStoreContractStatus")
+    public R<Map<String, Object>> getStoreContractStatus(int id) {
+        log.info("StoreInfoController.getStoreContractStatus?id={}", id);
+        return R.data(licenseService.getStoreContractStatus(id));
+    }
+
+    @ApiOperation("根据商户ID获取合同历史记录(按时间分组)")
+    @ApiOperationSupport(order = 3)
+    @ApiImplicitParams({
+            @ApiImplicitParam(name = "storeId", value = "商户ID", dataType = "Integer", paramType = "query", required = true)
+    })
+    @GetMapping("/queryContractByStatusList")
+    public R<List<StoreLicenseHistoryDto>> queryContractByStatusList(@RequestParam("storeId") Integer storeId) {
+        log.info("LicenseController.queryContractByStatusList: storeId={}", storeId);
+        try {
+            List<StoreLicenseHistoryDto> result = licenseService.queryContractByStatusList(storeId);
+            return R.data(result);
+        } catch (Exception e) {
+            log.error("LicenseController.queryContractByStatusList ERROR: {}", e.getMessage(), e);
+            return R.fail(e.getMessage());
+        }
+    }
 }
 
 

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

@@ -6,6 +6,8 @@ import shop.alien.entity.storePlatform.vo.StoreLicenseHistoryDto;
 import shop.alien.entity.storePlatform.vo.StoreLicenseHistoryVO;
 
 import java.util.List;
+import java.util.Map;
+import java.util.Map;
 
 public interface LicenseService {
 
@@ -30,6 +32,35 @@ public interface LicenseService {
      *
      */
     int uploadRenewalContract(List<StoreImg> storeImgList);
+
+
+    /**
+     * 获取店铺食品经营许可证状态以及店铺状态为审核中合同图片list
+     * @param id
+     * @return
+     */
+    Map<String,Object> getStoreFoodLicenceStatus(int id);
+
+
+    /**
+     * 获取店铺续签合同状态以及店铺状态为审核中合同图片list
+     *
+     */
+    Map<String,Object> getStoreContractStatus(int id);
+
+
+    /**
+     * 根据商户ID查询合同历史记录列表(按时间分组)
+     * <p>
+     * 将数据按照创建时间进行分组,相同时间的数据存储到 licenseList 中
+     * 返回按时间去重后的列表,每个元素包含该时间下的所有记录
+     * 排序规则:时间倒序(最新的在前),同一时间内ID升序
+     * </p>
+     *
+     * @param storeId 商户ID
+     * @return 按时间分组且已排序的证照历史记录列表
+     */
+    List<StoreLicenseHistoryDto> queryContractByStatusList (Integer storeId);
 }
 
 

+ 176 - 15
alien-store-platform/src/main/java/shop/alien/storeplatform/service/impl/LicenseServiceImpl.java

@@ -5,6 +5,7 @@ import lombok.RequiredArgsConstructor;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.beans.BeanUtils;
 import org.springframework.stereotype.Service;
+import org.springframework.util.CollectionUtils;
 import shop.alien.entity.store.*;
 import shop.alien.entity.storePlatform.vo.StoreLicenseHistoryDto;
 import shop.alien.entity.storePlatform.vo.StoreLicenseHistoryVO;
@@ -16,9 +17,7 @@ import shop.alien.storeplatform.service.LicenseService;
 
 import java.text.ParseException;
 import java.text.SimpleDateFormat;
-import java.util.Date;
-import java.util.List;
-import java.util.Optional;
+import java.util.*;
 
 /**
  * 证照管理服务实现类
@@ -134,26 +133,26 @@ public class LicenseServiceImpl implements LicenseService {
     public List<StoreLicenseHistoryDto> queryLicenceByStatusList (Integer storeId) {
 
         List<StoreLicenseHistory> licenseList = licenseHistoryMapper.queryLicenceByStatusList(storeId, 2, 1);
-        
+
         // 创建日期格式化对象,格式为 yyyy-MM-dd
-        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
-        
+        SimpleDateFormat sdf = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss");
+
         // 创建返回的 VO 列表
         List<StoreLicenseHistoryDto> voList = new java.util.ArrayList<>();
-        
+
         for (StoreLicenseHistory license : licenseList) {
             // 创建 VO 对象
             StoreLicenseHistoryDto vo = new StoreLicenseHistoryDto();
 
             // 将实体对象属性复制到 VO 对象
             BeanUtils.copyProperties(license, vo);
-            
+
             // 将创建时间格式化为 yyyy-MM-dd 格式,去除时分秒
             if (license.getCreatedTime() != null) {
                 String dateStr = sdf.format(license.getCreatedTime());
                 vo.setCreatedDateFormat(dateStr);
             }
-            
+
             // 设置审核状态名称
             if (license.getLicenseExecuteStatus() != null) {
                 switch (license.getLicenseExecuteStatus()) {
@@ -171,10 +170,10 @@ public class LicenseServiceImpl implements LicenseService {
                         break;
                 }
             }
-            
+
             voList.add(vo);
         }
-        
+
         return voList;
     }
 
@@ -185,6 +184,8 @@ public class LicenseServiceImpl implements LicenseService {
         Optional<Integer> storeId = storeImgList.stream().map(StoreImg::getStoreId).findFirst();
         int value = storeId.orElse(0);
         int num = 0;
+
+        Date date = new Date();
         //先清除数据
         storeImgMapper.delete(new LambdaQueryWrapper<StoreImg>().eq(StoreImg::getImgType,22).eq(StoreImg::getStoreId,value));
         for (StoreImg renewContract : storeImgList) {
@@ -197,10 +198,7 @@ public class LicenseServiceImpl implements LicenseService {
             storeImg.setCreatedUserId(renewContract.getCreatedUserId());
             num = storeImgMapper.insert(storeImg);
 
-            // 经营许可证历史表删除
-            licenseHistoryMapper.delete(new LambdaQueryWrapper<StoreLicenseHistory>()
-                    .eq(StoreLicenseHistory::getLicenseStatus,1)
-                    .eq(StoreLicenseHistory::getStoreId,storeImg.getStoreId()));
+
             // 经营许可证历史表插入
             StoreLicenseHistory licenseHistory = new StoreLicenseHistory();
             licenseHistory.setStoreId(storeImg.getStoreId());
@@ -208,6 +206,7 @@ public class LicenseServiceImpl implements LicenseService {
             licenseHistory.setLicenseExecuteStatus(2);
             licenseHistory.setImgUrl(storeImg.getImgUrl());
             licenseHistory.setDeleteFlag(0);
+            licenseHistory.setCreatedTime(date);
             licenseHistoryMapper.insert(licenseHistory);
         }
         if (num > 0) {
@@ -221,6 +220,168 @@ public class LicenseServiceImpl implements LicenseService {
     }
 
 
+    @Override
+    public Map<String, Object> getStoreFoodLicenceStatus(int id) {
+        Map<String, Object> map = new HashMap<>();
+        StoreInfo storeInfo = storeInfoMapper.selectOne(new LambdaQueryWrapper<StoreInfo>().eq(StoreInfo::getId, id));
+        //审核通过给前台反显未提交
+        if (storeInfo.getFoodLicenceStatus() == 1) {
+            map.put("foodLicenceStatus", 0);
+        } else {
+            map.put("foodLicenceStatus", storeInfo.getFoodLicenceStatus());
+        }
+        //食品经营许可证照片列表
+        List<StoreImg> storeImgList = storeImgMapper.selectList(new LambdaQueryWrapper<StoreImg>().eq(StoreImg::getImgType, 24).eq(StoreImg::getStoreId, id));
+        if (!CollectionUtils.isEmpty(storeImgList)) {
+            map.put("foodLicenceImgList", storeImgList);
+        } else {
+            map.put("foodLicenceImgList", "");
+        }
+        if (storeInfo.getFoodLicenceReason() != null) {
+            map.put("foodLicenceReason", storeInfo.getFoodLicenceReason());
+        } else {
+            map.put("foodLicenceReason", "");
+        }
+        return map;
+    }
+
+
+    @Override
+    public Map<String, Object> getStoreContractStatus(int id) {
+        Map<String, Object> map = new HashMap<>();
+        StoreInfo storeInfo = storeInfoMapper.selectOne(new LambdaQueryWrapper<StoreInfo>().eq(StoreInfo::getId, id));
+        //审核通过给前台反显未提交
+        if (storeInfo.getRenewContractStatus() == 1) {
+            map.put("renewContractStatus", 0);
+        } else {
+            map.put("renewContractStatus", storeInfo.getRenewContractStatus());
+        }
+        //续签合同照片列表
+        List<StoreImg> storeImgList = storeImgMapper.selectList(new LambdaQueryWrapper<StoreImg>().eq(StoreImg::getImgType, 22).eq(StoreImg::getStoreId, id));
+        if (!CollectionUtils.isEmpty(storeImgList)) {
+            map.put("contractImgList", storeImgList);
+        } else {
+            map.put("contractImgList", "");
+        }
+        if (storeInfo.getContractReason() != null) {
+            map.put("contractReason", storeInfo.getContractReason());
+        } else {
+            map.put("contractReason", "");
+        }
+        return map;
+    }
+
+
+    /**
+     * 根据商户ID查询合同历史记录列表(按时间分组)
+     * <p>
+     * 查询指定商户的合同历史记录,将创建时间格式化为 yyyy-MM-dd HH:mm:ss 格式,
+     * 并按照时间进行分组,相同时间的数据存储到 licenseList 中
+     * 返回按时间去重后的列表,每个元素包含该时间下的所有记录
+     * 排序规则:时间倒序(最新的在前),同一时间内ID升序
+     * </p>
+     *
+     * @param storeId 商户ID
+     * @return 按时间分组的证照历史记录列表
+     */
+    @Override
+    public List<StoreLicenseHistoryDto> queryContractByStatusList (Integer storeId) {
+
+        // 查询证照类型为1(合同管理)的记录
+        List<StoreLicenseHistory> licenseList = licenseHistoryMapper.queryLicenceByStatusList(storeId, 1, 1);
+
+        // 第一步:对原始数据进行排序
+        // 时间倒序(最新的在前),同一时间内ID升序
+        licenseList.sort((o1, o2) -> {
+            // 先按时间倒序排序(最新的在前)
+            if (o1.getCreatedTime() != null && o2.getCreatedTime() != null) {
+                int timeCompare = o2.getCreatedTime().compareTo(o1.getCreatedTime());
+                if (timeCompare != 0) {
+                    return timeCompare;
+                }
+            }
+            // 时间相同时,按ID升序排序
+            if (o1.getId() != null && o2.getId() != null) {
+                return o1.getId().compareTo(o2.getId());
+            }
+            return 0;
+        });
+
+        // 创建日期格式化对象,格式为 yyyy-MM-dd HH:mm:ss
+        SimpleDateFormat sdf = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss");
 
+        // 使用 LinkedHashMap 按时间分组,保持插入顺序
+        Map<String, List<StoreLicenseHistoryDto>> timeGroupMap = new LinkedHashMap<>();
+
+        // 第二步:按时间分组,将所有数据按时间归类
+        for (StoreLicenseHistory license : licenseList) {
+            // 创建 VO 对象
+            StoreLicenseHistoryDto vo = new StoreLicenseHistoryDto();
+
+            // 将实体对象属性复制到 VO 对象
+            BeanUtils.copyProperties(license, vo);
+
+            // 格式化创建时间
+            String dateKey = "";
+            if (license.getCreatedTime() != null) {
+                String dateStr = sdf.format(license.getCreatedTime());
+                vo.setCreatedDateFormat(dateStr);
+                // 使用日期时间作为分组 key
+                dateKey = dateStr;
+            }
+
+            // 设置审核状态名称
+            if (license.getLicenseExecuteStatus() != null) {
+                switch (license.getLicenseExecuteStatus()) {
+                    case 1:
+                        vo.setLicenseExecuteName("审核通过");
+                        break;
+                    case 2:
+                        vo.setLicenseExecuteName("审核中");
+                        break;
+                    case 3:
+                        vo.setLicenseExecuteName("审核失败");
+                        break;
+                    default:
+                        vo.setLicenseExecuteName("未知");
+                        break;
+                }
+            }
+
+            // 将 VO 对象添加到对应时间的列表中
+            if (!dateKey.isEmpty()) {
+                timeGroupMap.computeIfAbsent(dateKey, k -> new ArrayList<>()).add(vo);
+            }
+        }
+
+        // 第三步:将分组后的数据转换为列表结构
+        // 每个时间节点创建一个父对象,将该时间的所有记录存储到 licenseList 中
+        List<StoreLicenseHistoryDto> resultList = new ArrayList<>();
+        
+        for (Map.Entry<String, List<StoreLicenseHistoryDto>> entry : timeGroupMap.entrySet()) {
+            String timeKey = entry.getKey();
+            List<StoreLicenseHistoryDto> sameTimeList = entry.getValue();
+            
+            // 创建一个父对象,代表这个时间节点
+            StoreLicenseHistoryDto parentVo = new StoreLicenseHistoryDto();
+            
+            // 使用第一条记录的基本信息作为父对象的信息(ID最小的那条)
+            if (!sameTimeList.isEmpty()) {
+                StoreLicenseHistoryDto firstItem = sameTimeList.get(0);
+                BeanUtils.copyProperties(firstItem, parentVo);
+                
+                // 将相同时间的所有记录存储到 licenseList 中(已按ID升序排列)
+                parentVo.setLicenseList(sameTimeList);
+                parentVo.setCreatedDateFormat(timeKey);
+                
+                resultList.add(parentVo);
+            }
+        }
+
+        log.info("queryContractByStatusList - 共查询到 {} 条记录,按时间分组后 {} 个时间节点", 
+                 licenseList.size(), resultList.size());
+
+        return resultList;
+    }
 }
 

+ 2 - 0
alien-store/src/main/java/shop/alien/store/controller/StoreInfoController.java

@@ -626,7 +626,9 @@ public class StoreInfoController {
                     LambdaUpdateWrapper<StoreLicenseHistory> wrapper = new LambdaUpdateWrapper<>();
                     wrapper.eq(StoreLicenseHistory::getStoreId, storeInfo.getId());
                     wrapper.eq(StoreLicenseHistory::getLicenseStatus, 2);
+                    wrapper.eq(StoreLicenseHistory::getLicenseExecuteStatus, 2);
                     wrapper.set(StoreLicenseHistory::getLicenseExecuteStatus, 3);
+                    wrapper.set(StoreLicenseHistory::getReasonRefusal, storeInfoDto.getFoodLicenceReason());
                     wrapper.set(StoreLicenseHistory::getDeleteFlag, 1);
                     licenseHistoryMapper.update(null, wrapper);
 

+ 42 - 8
alien-store/src/main/java/shop/alien/store/service/impl/StoreInfoServiceImpl.java

@@ -2202,9 +2202,6 @@ public class StoreInfoServiceImpl extends ServiceImpl<StoreInfoMapper, StoreInfo
             storeImg.setImgDescription("经营许可证审核通过前图片");
             storeImgMapper.insert(storeImg);
 
-            licenseHistoryMapper.delete(new LambdaQueryWrapper<StoreLicenseHistory>()
-                    .eq(StoreLicenseHistory::getLicenseStatus,2)
-                    .eq(StoreLicenseHistory::getStoreId,storeImg.getStoreId()));
             // 经营许可证历史表插入
             StoreLicenseHistory licenseHistory = new StoreLicenseHistory();
             licenseHistory.setStoreId(storeImg.getStoreId());
@@ -2303,12 +2300,15 @@ public class StoreInfoServiceImpl extends ServiceImpl<StoreInfoMapper, StoreInfo
         imgLambdaUpdateWrapper.in(StoreImg::getId, imgList).set(StoreImg::getImgType, 25).set(StoreImg::getImgDescription,"经营许可证审核通过图片");
         int num = storeImgMapper.update(null, imgLambdaUpdateWrapper);
 
+
         // 将原来的食品经营许可证历史表数据删除
-        licenseHistoryMapper.delete(new LambdaQueryWrapper<StoreLicenseHistory>()
-                .eq(StoreLicenseHistory::getStoreId,id)
-                .eq(StoreLicenseHistory::getLicenseStatus,2)
-                .eq(StoreLicenseHistory::getLicenseExecuteStatus,1)
-                .eq(StoreLicenseHistory::getDeleteFlag,0));
+        LambdaUpdateWrapper<StoreLicenseHistory> wrapper = new LambdaUpdateWrapper<>();
+        wrapper.eq(StoreLicenseHistory::getStoreId, id);
+        wrapper.eq(StoreLicenseHistory::getLicenseStatus, 2);
+        wrapper.eq(StoreLicenseHistory::getLicenseExecuteStatus, 1);
+        wrapper.eq(StoreLicenseHistory::getDeleteFlag, 0);
+        wrapper.set(StoreLicenseHistory::getDeleteFlag, 1);
+        licenseHistoryMapper.update(null, wrapper);
 
         // 将新的食品经营许可证历史表数据变为审核通过
         LambdaUpdateWrapper<StoreLicenseHistory> wrapper1 = new LambdaUpdateWrapper<>();
@@ -2356,4 +2356,38 @@ public class StoreInfoServiceImpl extends ServiceImpl<StoreInfoMapper, StoreInfo
         }
         return result;
     }
+
+    public void updateLicenseHistoryInfo(Integer storeId, Integer foodLicenceStatus) {
+        if (foodLicenceStatus == 3) {
+            // 审核拒绝时修改提交记录
+            LambdaUpdateWrapper<StoreLicenseHistory> wrapper = new LambdaUpdateWrapper<>();
+            wrapper.eq(StoreLicenseHistory::getStoreId, storeId);
+            wrapper.eq(StoreLicenseHistory::getLicenseStatus, 1);
+            wrapper.eq(StoreLicenseHistory::getLicenseExecuteStatus, 2);
+            wrapper.set(StoreLicenseHistory::getLicenseExecuteStatus, 3);
+            wrapper.set(StoreLicenseHistory::getReasonRefusal, storeId);
+            wrapper.set(StoreLicenseHistory::getDeleteFlag, 1);
+            licenseHistoryMapper.update(null, wrapper);
+        } else {
+            // 将原来的食品经营许可证历史表数据删除
+            LambdaUpdateWrapper<StoreLicenseHistory> wrapper = new LambdaUpdateWrapper<>();
+            wrapper.eq(StoreLicenseHistory::getStoreId, storeId);
+            wrapper.eq(StoreLicenseHistory::getLicenseStatus, 1);
+            wrapper.eq(StoreLicenseHistory::getLicenseExecuteStatus, 1);
+            wrapper.eq(StoreLicenseHistory::getDeleteFlag, 0);
+            wrapper.set(StoreLicenseHistory::getDeleteFlag, 1);
+            licenseHistoryMapper.update(null, wrapper);
+
+            // 将新的食品经营许可证历史表数据变为审核通过
+            LambdaUpdateWrapper<StoreLicenseHistory> wrapper1 = new LambdaUpdateWrapper<>();
+            wrapper1.eq(StoreLicenseHistory::getStoreId, storeId);
+            wrapper1.eq(StoreLicenseHistory::getLicenseStatus, 1);
+            wrapper1.eq(StoreLicenseHistory::getLicenseExecuteStatus, 2);
+            wrapper1.eq(StoreLicenseHistory::getDeleteFlag, 0);
+            wrapper1.set(StoreLicenseHistory::getLicenseExecuteStatus, 1);
+            licenseHistoryMapper.update(null, wrapper1);
+        }
+    }
+
+
 }