Showing
6 changed files
with
123 additions
and
9 deletions
| ... | @@ -5,6 +5,9 @@ import lombok.Data; | ... | @@ -5,6 +5,9 @@ import lombok.Data; |
| 5 | 5 | ||
| 6 | @Data | 6 | @Data |
| 7 | public class ConsignmentAddDto { | 7 | public class ConsignmentAddDto { |
| 8 | + /** | ||
| 9 | + * 是否为该用户的运单 1:是 0:否 | ||
| 10 | + */ | ||
| 8 | Integer isCreatorFlag; | 11 | Integer isCreatorFlag; |
| 9 | Consignment consignment; | 12 | Consignment consignment; |
| 10 | } | 13 | } | ... | ... |
| ... | @@ -28,6 +28,8 @@ public enum ResponseCode { | ... | @@ -28,6 +28,8 @@ public enum ResponseCode { |
| 28 | MESSAGE_CODE_30008(30008,"business_exception_30008"), | 28 | MESSAGE_CODE_30008(30008,"business_exception_30008"), |
| 29 | MESSAGE_CODE_30009(30009,"business_exception_30009"), | 29 | MESSAGE_CODE_30009(30009,"business_exception_30009"), |
| 30 | MESSAGE_CODE_30010(30010,"business_exception_30010"), | 30 | MESSAGE_CODE_30010(30010,"business_exception_30010"), |
| 31 | + MESSAGE_CODE_30011(30011,"business_exception_30010"), | ||
| 32 | + MESSAGE_CODE_30012(30012,"business_exception_30012"), | ||
| 31 | 33 | ||
| 32 | /******打个样,编写样例*****/ | 34 | /******打个样,编写样例*****/ |
| 33 | // MESSAGE_CODE_30001(30001,"business_exception_30001"), | 35 | // MESSAGE_CODE_30001(30001,"business_exception_30001"), | ... | ... |
| ... | @@ -8,10 +8,13 @@ import com.fedex.connect.customer.data.bo.ConsignmentBo; | ... | @@ -8,10 +8,13 @@ import com.fedex.connect.customer.data.bo.ConsignmentBo; |
| 8 | import com.fedex.connect.customer.service.base.BaseService; | 8 | import com.fedex.connect.customer.service.base.BaseService; |
| 9 | import com.fedex.connect.customer.service.biz.IConsignmentService; | 9 | import com.fedex.connect.customer.service.biz.IConsignmentService; |
| 10 | import com.fedex.connect.customer.util.service.biz.ConsignmentUtil; | 10 | import com.fedex.connect.customer.util.service.biz.ConsignmentUtil; |
| 11 | +import org.apache.commons.lang3.StringUtils; | ||
| 11 | import org.springframework.beans.factory.annotation.Autowired; | 12 | import org.springframework.beans.factory.annotation.Autowired; |
| 12 | import org.springframework.stereotype.Service; | 13 | import org.springframework.stereotype.Service; |
| 13 | import org.springframework.web.multipart.MultipartFile; | 14 | import org.springframework.web.multipart.MultipartFile; |
| 14 | 15 | ||
| 16 | +import java.util.Objects; | ||
| 17 | + | ||
| 15 | /** | 18 | /** |
| 16 | * @Author Szl | 19 | * @Author Szl |
| 17 | * @Description 类说明 运单操作相关service | 20 | * @Description 类说明 运单操作相关service |
| ... | @@ -37,15 +40,35 @@ public class ConsignmentServiceImpl extends BaseService implements IConsignmentS | ... | @@ -37,15 +40,35 @@ public class ConsignmentServiceImpl extends BaseService implements IConsignmentS |
| 37 | public ResponseVo add(ConsignmentBo bo, User user){ | 40 | public ResponseVo add(ConsignmentBo bo, User user){ |
| 38 | //查询运单表是否存在已提交的运单 | 41 | //查询运单表是否存在已提交的运单 |
| 39 | Consignment consignment = consignmentRepository.findByConsignmentCode(bo.getConsignmentCode()); | 42 | Consignment consignment = consignmentRepository.findByConsignmentCode(bo.getConsignmentCode()); |
| 40 | - if (consignment != null && consignment.getId() != null){ | 43 | + /** |
| 41 | - //如果存在则进行bo基础校验 | 44 | + * 不存在则直接返回 |
| 42 | - consignmentUtil.consignmentCreatorCheck(consignment,bo); | 45 | + */ |
| 43 | - //校验是否是本账号的运单 | 46 | + if (consignment == null){ |
| 44 | - ResponseVo responseVo = consignmentUtil.consignmentUuidCheck(consignment, user); | 47 | + if (!StringUtils.isEmpty(bo.getShipperAccount())){ |
| 45 | - return responseVo; | 48 | + if (Objects.equals(user.getAccountNo(),bo.getShipperAccount())){ |
| 49 | + return new ResponseUtils().success(); | ||
| 50 | + } | ||
| 51 | + }else { | ||
| 52 | + /** | ||
| 53 | + * 不存在运单,并且没有填写shipperAccount,则直接返回 | ||
| 54 | + */ | ||
| 55 | + return new ResponseUtils().success(); | ||
| 56 | + } | ||
| 57 | + } | ||
| 58 | + /** | ||
| 59 | + * 根据是否是DM501返回不同的提示 | ||
| 60 | + */ | ||
| 61 | + if (StringUtils.isEmpty(consignment.getUserUuid())){ | ||
| 62 | + /** | ||
| 63 | + * 非501数据 | ||
| 64 | + */ | ||
| 65 | + return consignmentUtil.consignmentCheckWithNotCe(consignment,bo,user); | ||
| 66 | + }else { | ||
| 67 | + /** | ||
| 68 | + * 501数据 | ||
| 69 | + */ | ||
| 70 | + return consignmentUtil.consignmentCheckWithCe(consignment,bo,user); | ||
| 46 | } | 71 | } |
| 47 | - //如果不存在直接返回 | ||
| 48 | - return responseUtils.success(); | ||
| 49 | } | 72 | } |
| 50 | 73 | ||
| 51 | /** | 74 | /** | ... | ... |
| ... | @@ -2,7 +2,6 @@ package com.fedex.connect.customer.util.service.biz; | ... | @@ -2,7 +2,6 @@ package com.fedex.connect.customer.util.service.biz; |
| 2 | 2 | ||
| 3 | import com.fedex.connect.common.dependencies.contants.DigitConstants; | 3 | import com.fedex.connect.common.dependencies.contants.DigitConstants; |
| 4 | import com.fedex.connect.common.dependencies.date.vo.ResponseVo; | 4 | import com.fedex.connect.common.dependencies.date.vo.ResponseVo; |
| 5 | -import com.fedex.connect.common.dependencies.enums.BaseResponseCode; | ||
| 6 | import com.fedex.connect.common.dependencies.i18n.LocaleMessageUtil; | 5 | import com.fedex.connect.common.dependencies.i18n.LocaleMessageUtil; |
| 7 | import com.fedex.connect.common.dependencies.util.ResponseUtils; | 6 | import com.fedex.connect.common.dependencies.util.ResponseUtils; |
| 8 | import com.fedex.connect.common.model.biz.Consignment; | 7 | import com.fedex.connect.common.model.biz.Consignment; |
| ... | @@ -12,6 +11,7 @@ import com.fedex.connect.customer.data.dto.ConsignmentAddDto; | ... | @@ -12,6 +11,7 @@ import com.fedex.connect.customer.data.dto.ConsignmentAddDto; |
| 12 | import com.fedex.connect.customer.enums.ResponseCode; | 11 | import com.fedex.connect.customer.enums.ResponseCode; |
| 13 | import org.springframework.beans.factory.annotation.Autowired; | 12 | import org.springframework.beans.factory.annotation.Autowired; |
| 14 | import org.springframework.stereotype.Component; | 13 | import org.springframework.stereotype.Component; |
| 14 | +import org.springframework.util.StringUtils; | ||
| 15 | 15 | ||
| 16 | import java.util.ArrayList; | 16 | import java.util.ArrayList; |
| 17 | import java.util.List; | 17 | import java.util.List; |
| ... | @@ -32,6 +32,88 @@ public class ConsignmentUtil { | ... | @@ -32,6 +32,88 @@ public class ConsignmentUtil { |
| 32 | 32 | ||
| 33 | /** | 33 | /** |
| 34 | * @Author Szl | 34 | * @Author Szl |
| 35 | + * @Description 功能说明 不存在501的运单add时判断该运单是否为自己的运单 | ||
| 36 | + * @Date 2024/11/12 | ||
| 37 | + * @param consignment | ||
| 38 | + * @param bo | ||
| 39 | + * @param user | ||
| 40 | + * @return void | ||
| 41 | + */ | ||
| 42 | + public ResponseVo consignmentCheckWithNotCe(Consignment consignment, ConsignmentBo bo, User user){ | ||
| 43 | + ConsignmentAddDto consignmentAddDto = new ConsignmentAddDto(); | ||
| 44 | + consignmentAddDto.setConsignment(consignment); | ||
| 45 | + if (isShipperAccountMatch(bo.getShipperAccount(), consignment.getShipperAccount())){ | ||
| 46 | + consignmentAddDto.setIsCreatorFlag(DigitConstants.DIGIT_ONE); | ||
| 47 | + return responseUtils.success(consignmentAddDto); | ||
| 48 | + }else { | ||
| 49 | + return responseUtils.success(ResponseCode.MESSAGE_CODE_30011); | ||
| 50 | + } | ||
| 51 | + } | ||
| 52 | + | ||
| 53 | + /** | ||
| 54 | + * @Author Szl | ||
| 55 | + * @Description 功能说明 存在501的运单add时判断该运单是否为自己的运单 | ||
| 56 | + * @Date 2024/11/12 | ||
| 57 | + * @param consignment | ||
| 58 | + * @param bo | ||
| 59 | + * @param user | ||
| 60 | + * @return void | ||
| 61 | + */ | ||
| 62 | + public ResponseVo consignmentCheckWithCe(Consignment consignment, ConsignmentBo bo, User user) { | ||
| 63 | + ConsignmentAddDto consignmentAddDto = new ConsignmentAddDto(); | ||
| 64 | + consignmentAddDto.setConsignment(consignment); | ||
| 65 | + | ||
| 66 | + /** | ||
| 67 | + * uuid相同,直接返回所有运单信息 | ||
| 68 | + */ | ||
| 69 | + if (Objects.equals(consignment.getUserUuid(), user.getUserUuid())) { | ||
| 70 | + consignmentAddDto.setIsCreatorFlag(DigitConstants.DIGIT_ONE); | ||
| 71 | + return responseUtils.success(consignmentAddDto); | ||
| 72 | + } | ||
| 73 | + | ||
| 74 | + /** | ||
| 75 | + * uuid不一致且未填写shipperAccount | ||
| 76 | + */ | ||
| 77 | + if (StringUtils.hasText(bo.getShipperAccount())){ | ||
| 78 | + consignmentAddDto.setIsCreatorFlag(DigitConstants.DIGIT_TWO); | ||
| 79 | + return responseUtils.success(ResponseCode.MESSAGE_CODE_30012); | ||
| 80 | + } | ||
| 81 | + | ||
| 82 | + /** | ||
| 83 | + * 运单的shipperAccount和用户的shipperAccount一致,则返回提示语+运单信息 | ||
| 84 | + */ | ||
| 85 | + if (isShipperAccountMatch(user.getAccountNo(), consignment.getShipperAccount())) { | ||
| 86 | + consignmentAddDto.setIsCreatorFlag(DigitConstants.DIGIT_ONE); | ||
| 87 | + return responseUtils.success(ResponseCode.MESSAGE_CODE_30004, consignmentAddDto); | ||
| 88 | + } | ||
| 89 | + | ||
| 90 | + /** | ||
| 91 | + * 录入的shipperAccount和运单的shipperAccount一致,则返回提示语+运单信息 | ||
| 92 | + */ | ||
| 93 | + if (isShipperAccountMatch(bo.getShipperAccount(), consignment.getShipperAccount())) { | ||
| 94 | + consignmentAddDto.setIsCreatorFlag(DigitConstants.DIGIT_ONE); | ||
| 95 | + return responseUtils.success(ResponseCode.MESSAGE_CODE_30005, consignmentAddDto); | ||
| 96 | + } | ||
| 97 | + | ||
| 98 | + /** | ||
| 99 | + * 都不一致,但是输入了shipperAccount,则给出提示 | ||
| 100 | + */ | ||
| 101 | + if (StringUtils.hasText(bo.getShipperAccount())) { | ||
| 102 | + consignmentAddDto.setIsCreatorFlag(DigitConstants.DIGIT_TWO); | ||
| 103 | + return responseUtils.success(ResponseCode.MESSAGE_CODE_30005); | ||
| 104 | + } | ||
| 105 | + | ||
| 106 | + return responseUtils.success(); | ||
| 107 | + } | ||
| 108 | + | ||
| 109 | + // 抽取 ShipperAccount 比较逻辑 | ||
| 110 | + private boolean isShipperAccountMatch(String account1, String account2) { | ||
| 111 | + return StringUtils.hasText(account1) && StringUtils.hasText(account2) && account1.equals(account2); | ||
| 112 | + } | ||
| 113 | + | ||
| 114 | + | ||
| 115 | + /** | ||
| 116 | + * @Author Szl | ||
| 35 | * @Description 功能说明 校验运单创建人 | 117 | * @Description 功能说明 校验运单创建人 |
| 36 | * @Date 2024/11/5 | 118 | * @Date 2024/11/5 |
| 37 | * @param consignment | 119 | * @param consignment | ... | ... |
| ... | @@ -38,3 +38,5 @@ business_exception_30007=所有上传文件数量不超过50个文件 | ... | @@ -38,3 +38,5 @@ business_exception_30007=所有上传文件数量不超过50个文件 |
| 38 | business_exception_30008=所有上传文件总大小不超过50M | 38 | business_exception_30008=所有上传文件总大小不超过50M |
| 39 | business_exception_30009=运单或发票未上传 | 39 | business_exception_30009=运单或发票未上传 |
| 40 | business_exception_30010=文件类型不在:运单、发票、箱单、其他 | 40 | business_exception_30010=文件类型不在:运单、发票、箱单、其他 |
| 41 | +business_exception_30011=该运单已被其他人创建,不可以重复创建 | ||
| 42 | +business_exception_30012=UUID不一致 | ||
| ... | \ No newline at end of file | ... | \ No newline at end of file | ... | ... |
| ... | @@ -38,3 +38,5 @@ business_exception_30007=所有上传文件数量不超过50个文件 | ... | @@ -38,3 +38,5 @@ business_exception_30007=所有上传文件数量不超过50个文件 |
| 38 | business_exception_30008=所有上传文件总大小不超过50M | 38 | business_exception_30008=所有上传文件总大小不超过50M |
| 39 | business_exception_30009=运单或发票未上传 | 39 | business_exception_30009=运单或发票未上传 |
| 40 | business_exception_30010=文件类型不在:运单、发票、箱单、其他 | 40 | business_exception_30010=文件类型不在:运单、发票、箱单、其他 |
| 41 | +business_exception_30011=该运单已被其他人创建,不可以重复创建 | ||
| 42 | +business_exception_30012=UUID不一致 | ||
| ... | \ No newline at end of file | ... | \ No newline at end of file | ... | ... |
-
Please register or login to post a comment