2 Commits e423d45cee ... 236e11f6e3

Auteur SHA1 Bericht Datum
  luofeiyun 236e11f6e3 Merge remote-tracking branch 'ship-ota-server/main' into main1 1 week geleden
  luofeiyun c7f1db4fc8 fix: 营销政策接口修改 1 week geleden

+ 27 - 2
ship-module-marketing/ship-module-marketing-biz/src/main/java/com/yc/ship/module/marketing/controller/admin/policy/PolicyController.java

@@ -114,9 +114,9 @@ public class PolicyController {
     }
 
     // 获取可以使用的营销政策
-    @GetMapping("/get-usable-policy")
+    @PostMapping("/get-usable-policy")
     @Operation(summary = "获取可以使用的营销政策")
-    public CommonResult<List<PolicyRespVO>> getUsablePolicy(@Validated PolicyUsableReqVO reqVO) {
+    public CommonResult<List<PolicyRespVO>> getUsablePolicy(@Validated @RequestBody PolicyUsableReqVO reqVO) {
         List<PolicyDO> list = policyService.getUsablePolicy(reqVO);
         List<PolicyRespVO> result = BeanUtils.toBean(list, PolicyRespVO.class);
         result.stream().forEach(policyRespVO -> {
@@ -138,6 +138,31 @@ public class PolicyController {
         return success(result);
     }
 
+    // 获取可以使用的营销政策
+    @GetMapping("/get-usable-policy-new")
+    @Operation(summary = "获取可以使用的营销政策")
+    public CommonResult<List<PolicyRespVO>> getUsablePolicyNew(Long voyageId) {
+        List<PolicyDO> list = policyService.getUsablePolicyByVoyageId(voyageId);
+        List<PolicyRespVO> result = BeanUtils.toBean(list, PolicyRespVO.class);
+        result.stream().forEach(policyRespVO -> {
+            List<Long> areaIds = policyRespVO.getAreaIds();
+            List<AreaCountryDTO> areaCountryDTOS = areaApi.getAreaCountryListByAreaIds(areaIds);
+            List<Integer> countryIds = CollectionUtils.convertList(areaCountryDTOS, AreaCountryDTO::getCountryId);
+            policyRespVO.setCountryIds(countryIds);
+        });
+        List<Long> policyIds = CollectionUtils.convertList(list, PolicyDO::getId);
+        List<PolicyDetailDO> policyDetails = policyDetailService.getByPolicyIds(policyIds);
+        Map<Long, List<PolicyDetailDO>> longListMap = CollectionUtils.convertMultiMap(policyDetails, PolicyDetailDO::getPolicyId);
+        result.stream().forEach(policyRespVO -> {
+            List<PolicyDetailDO> policyDetailDOList = longListMap.get(policyRespVO.getId());
+            List<Long> voyageIds = CollectionUtils.convertList(policyDetailDOList, PolicyDetailDO::getVoyageId);
+            policyRespVO.setVoyageIds(voyageIds);
+            List<Long> roomModelIds = CollectionUtils.convertList(policyDetailDOList, PolicyDetailDO::getRoomModelId);
+            policyRespVO.setRoomModelIds(roomModelIds);
+        });
+        return success(result);
+    }
+
     @GetMapping("/export-excel")
     @Operation(summary = "导出营销政策 Excel")
     @PreAuthorize("@ss.hasPermission('marketing:policy:export')")

+ 1 - 1
ship-module-marketing/ship-module-marketing-biz/src/main/java/com/yc/ship/module/marketing/controller/admin/policy/vo/PolicyUsableReqVO.java

@@ -22,5 +22,5 @@ public class PolicyUsableReqVO {
 
     @Schema(description = "国家ID", example = "7920")
     @NotEmpty(message = "国籍ID不能为空")
-    private List<Long> CountryIds;
+    private List<Long> countryIds;
 }

+ 3 - 1
ship-module-marketing/ship-module-marketing-biz/src/main/java/com/yc/ship/module/marketing/dal/mysql/policy/PolicyMapper.java

@@ -1,5 +1,6 @@
 package com.yc.ship.module.marketing.dal.mysql.policy;
 
+import com.yc.ship.framework.common.enums.CommonStatusEnum;
 import com.yc.ship.framework.common.pojo.PageResult;
 import com.yc.ship.framework.mybatis.core.query.LambdaQueryWrapperX;
 import com.yc.ship.framework.mybatis.core.mapper.BaseMapperX;
@@ -31,6 +32,7 @@ public interface PolicyMapper extends BaseMapperX<PolicyDO> {
         return selectList(new LambdaQueryWrapperX<PolicyDO>()
                 .inIfPresent(PolicyDO::getId, policyIds)
                 .ge(PolicyDO::getEffectiveTime, LocalDateTime.now())
-                .gt(PolicyDO::getSurplusNum, BigDecimal.ZERO));
+                .gt(PolicyDO::getSurplusNum, BigDecimal.ZERO)
+                .eq(PolicyDO::getStatus, CommonStatusEnum.ENABLE.getStatus()));
     }
 }

+ 5 - 0
ship-module-marketing/ship-module-marketing-biz/src/main/java/com/yc/ship/module/marketing/dal/mysql/policydetail/PolicyDetailMapper.java

@@ -8,6 +8,7 @@ import com.yc.ship.framework.mybatis.core.query.LambdaQueryWrapperX;
 import com.yc.ship.framework.mybatis.core.mapper.BaseMapperX;
 import com.yc.ship.module.marketing.controller.admin.policy.vo.PolicyUsableReqVO;
 import com.yc.ship.module.marketing.dal.dataobject.policydetail.PolicyDetailDO;
+import com.yc.ship.module.product.dal.dataobject.voyage.VoyageDO;
 import org.apache.ibatis.annotations.Mapper;
 import com.yc.ship.module.marketing.controller.admin.policydetail.vo.*;
 
@@ -48,4 +49,8 @@ public interface PolicyDetailMapper extends BaseMapperX<PolicyDetailDO> {
     default List<PolicyDetailDO> selectByPolicyIds(List<Long> policyIds) {
         return selectList(new LambdaQueryWrapperX<PolicyDetailDO>().in(PolicyDetailDO::getPolicyId, policyIds));
     }
+
+    default List<PolicyDetailDO> selectListByVoyageId(Long voyageId) {
+        return selectList(new LambdaQueryWrapperX<PolicyDetailDO>().eq(PolicyDetailDO::getVoyageId, voyageId));
+    }
 }

+ 7 - 0
ship-module-marketing/ship-module-marketing-biz/src/main/java/com/yc/ship/module/marketing/service/policy/PolicyService.java

@@ -58,4 +58,11 @@ public interface PolicyService {
      * @return
      */
     List<PolicyDO> getUsablePolicy(PolicyUsableReqVO reqVO);
+
+    /**
+     * 根据航次ID获取可以使用的营销政策
+     * @param voyageId
+     * @return
+     */
+    List<PolicyDO> getUsablePolicyByVoyageId(Long voyageId);
 }

+ 17 - 1
ship-module-marketing/ship-module-marketing-biz/src/main/java/com/yc/ship/module/marketing/service/policy/PolicyServiceImpl.java

@@ -128,7 +128,23 @@ public class PolicyServiceImpl implements PolicyService {
         List<PolicyDO> policyList = policyMapper.selectList(policyIds);
         List<PolicyDO> result = policyList.stream().filter(policyDO -> {
             LocalDateTime boardingTime = voyage.getBoardingTime();
-            return boardingTime.plusDays(policyDO.getEarlyDays() * -1L).compareTo(LocalDateTime.now()) < 0;
+            return boardingTime.plusDays(policyDO.getEarlyDays() * -1L).compareTo(LocalDateTime.now()) > 0;
+        }).collect(Collectors.toList());
+        return result;
+    }
+
+    @Override
+    public List<PolicyDO> getUsablePolicyByVoyageId(Long voyageId) {
+        VoyageDO voyage = voyageService.getVoyage(voyageId);
+        List<PolicyDetailDO> policyDetails = policyDetailMapper.selectListByVoyageId(voyageId);
+        List<Long> policyIds = CollectionUtils.convertList(policyDetails, PolicyDetailDO::getPolicyId);
+        if(CollectionUtils.isAnyEmpty(policyIds)) {
+            return Collections.emptyList();
+        }
+        List<PolicyDO> policyList = policyMapper.selectList(policyIds);
+        List<PolicyDO> result = policyList.stream().filter(policyDO -> {
+            LocalDateTime boardingTime = voyage.getBoardingTime();
+            return boardingTime.plusDays(policyDO.getEarlyDays() * -1L).compareTo(LocalDateTime.now()) > 0;
         }).collect(Collectors.toList());
         return result;
     }

+ 0 - 1
ship-module-trade/ship-module-trade-biz/src/main/java/com/yc/ship/module/trade/service/insurance/InsuranceServiceImpl.java

@@ -183,7 +183,6 @@ public class InsuranceServiceImpl implements InsuranceService {
         // 开始投保
         CommonResult commonResult = insuranceUtil.sendInsuranceApply(insuranceApplyReqDTO);
         if(!commonResult.isSuccess()) {
-            Object checkedData = commonResult.getCheckedData();
             throw exception0(commonResult.getCode(),commonResult.getMsg());
         }
         //保存投保信息