ソースを参照

Merge remote-tracking branch 'origin/main'

于俊龙 3 週間 前
コミット
06588a50df

+ 1 - 0
farm-common-biz/src/main/resources/mapper/MastFarmerBaseMapper.xml

@@ -148,6 +148,7 @@
             </if>
 
         </where>
+        order by farmer_id
     </select>
 
     <select id="selectById" parameterType="String"  resultMap="MastFarmerEntityResult">

+ 1 - 2
farm-common/src/main/java/jp/yamoto/farm/common/utils/ValidatorUtils.java

@@ -79,8 +79,7 @@ public class ValidatorUtils extends org.apache.commons.lang3.StringUtils {
     /**
      * 電話番号 TODO適切な電話番号形式?????
      */
-    private static final Pattern PATTERN_PHONE_NO = Pattern.compile( "^(\\+?81|0)[\\s\\-]?\\d{1,4}[\\s\\-]?\\d{1,4}[\\s\\-]?\\d{4}$"
-    );
+    private static final Pattern PATTERN_PHONE_NO = Pattern.compile("^[0-9-]+$");
     /**
      * 時分
      */

+ 11 - 8
farm-common/src/main/java/jp/yamoto/farm/common/validator/constraint/LmPostalCdValidator.java

@@ -28,14 +28,17 @@ public class LmPostalCdValidator implements ConstraintValidator<LmPostalCd, Stri
     @Override
     public boolean isValid(String value, ConstraintValidatorContext context) {
         boolean isValid = true;
-        // 半角の変換
-        String halfValue = ConvertUtils.toDBC(value);
-        isValid = ValidatorUtils.isPostalCd(halfValue);
-        if (!isValid) {
-            String messageString = SpringUtils.getBean(IValidatorService.class).getErrorMessage(lmPostalCd.message(),
-                    lmPostalCd.params());
-            context.disableDefaultConstraintViolation();
-            context.buildConstraintViolationWithTemplate(messageString).addConstraintViolation();
+
+        if(ValidatorUtils.isNotEmpty(value)){
+            // 半角の変換
+            String halfValue = ConvertUtils.toDBC(value);
+            isValid = ValidatorUtils.isPostalCd(halfValue);
+            if (!isValid) {
+                String messageString = SpringUtils.getBean(IValidatorService.class).getErrorMessage(lmPostalCd.message(),
+                        lmPostalCd.params());
+                context.disableDefaultConstraintViolation();
+                context.buildConstraintViolationWithTemplate(messageString).addConstraintViolation();
+            }
         }
 
         return isValid;

+ 7 - 1
farm-crm-biz/src/main/java/jp/yamoto/farm/crm/biz/master/domain/bo/MastCustomerBo.java

@@ -122,7 +122,6 @@ public class MastCustomerBo implements Serializable {
     /**
      * メールアドレス
      */
-    @LmNotBlank(params = {"{mailAddress}"}, groups = {ValidatorGroup.AddGroup.class, ValidatorGroup.UpdateGroup.class})
     @LmLength(min = 1, max = 128, params = {"{mailAddress}", "128"}, groups = {ValidatorGroup.AddGroup.class, ValidatorGroup.UpdateGroup.class})
     private String mailAddress;
 
@@ -156,7 +155,14 @@ public class MastCustomerBo implements Serializable {
      */
     private Integer version;
 
+    /**
+     * 顧客追加フラグ
+     */
     private Boolean askAddCustomerFlg;
 
+    /**
+     * 電話番号の重複をチェックしないフラグ
+     */
+    private Boolean phoneNoCheckFlg = false;
 
 }

+ 27 - 12
farm-crm-biz/src/main/java/jp/yamoto/farm/crm/biz/master/service/impl/MastCustomerServiceImpl.java

@@ -113,7 +113,7 @@ public class MastCustomerServiceImpl extends MastCustomerBaseServiceImpl impleme
 
         MastCustomerSearchBo mastCustomer = new MastCustomerSearchBo();
         mastCustomer.setDiscontinuedFlg(DelFlgEnum.OFF.getCode());
-        mastCustomer.setPhoneNumber(mastCustomerBo.getPhoneNumber());
+        mastCustomer.setPhoneNumber( DecryptUtils.encryptAES(mastCustomerBo.getPhoneNumber()));
 
         // データを取得
         List<MastCustomerVo> list = mastCustomerMapper.selectList(mastCustomer);
@@ -133,6 +133,12 @@ public class MastCustomerServiceImpl extends MastCustomerBaseServiceImpl impleme
                 customerId = item.getCustomerId();
                 continue;
             }
+            // 関連付けを設定
+            mastCustomerBo.setId(item.getId());
+            mastCustomerBo.setCustomerId(item.getCustomerId());
+            mastCustomerBo.setVersion(item.getVersion());
+            mastCustomerBo.setPhoneNoCheckFlg(true);
+            mastCustomerBo.setCustomerName(mastCustomerBo.getCustomerName());
             this.updateInfo(mastCustomerBo);
         }
         return customerId;
@@ -242,12 +248,16 @@ public class MastCustomerServiceImpl extends MastCustomerBaseServiceImpl impleme
         MastAddressEntity addressEntity = new MastAddressEntity();
         StringBuilder addressBuilder = new StringBuilder();
         // 都道府県
-        addressEntity = addressBaseService.selectMastAddress(new MastAddressEntity(mastCustomer.getKenId()));
-        addressBuilder.append(ValueUtils.isNotEmpty(addressEntity.getKenName()) ? addressEntity.getKenName() : "");
+        if(ValueUtils.isNotEmpty(mastCustomer.getKenId())) {
+            addressEntity = addressBaseService.selectMastAddress(new MastAddressEntity(mastCustomer.getKenId()));
+            addressBuilder.append(ValueUtils.isNotEmpty(addressEntity.getKenName()) ? addressEntity.getKenName() : "");
+        }
 
         // 市区町村
-        addressEntity = addressBaseService.selectMastAddress(new MastAddressEntity(null, mastCustomer.getCityId()));
-        addressBuilder.append(ValueUtils.isNotEmpty(addressEntity.getCityName()) ? addressEntity.getCityName() : "");
+        if(ValueUtils.isNotEmpty(mastCustomer.getCityId())) {
+            addressEntity = addressBaseService.selectMastAddress(new MastAddressEntity(null, mastCustomer.getCityId()));
+            addressBuilder.append(ValueUtils.isNotEmpty(addressEntity.getCityName()) ? addressEntity.getCityName() : "");
+        }
 
         // 町域・番地
         addressBuilder.append(ValueUtils.isNotEmpty(mastCustomer.getTownName()) ? mastCustomer.getTownName() : "");
@@ -255,7 +265,9 @@ public class MastCustomerServiceImpl extends MastCustomerBaseServiceImpl impleme
         // ビル等
         addressBuilder.append(ValueUtils.isNotEmpty(mastCustomer.getBuildingEtc()) ? mastCustomer.getBuildingEtc() : "");
         // 住所
-        mastCustomer.setAddress(addressBuilder.toString());
+        if(ValueUtils.isNotEmpty(mastCustomer.getKenId()) && !addressBuilder.isEmpty()) {
+            mastCustomer.setAddress(addressBuilder.toString());
+        }
 
         // データを暗号化
         // メールアドレス
@@ -263,7 +275,7 @@ public class MastCustomerServiceImpl extends MastCustomerBaseServiceImpl impleme
             mastCustomer.setMailAddress(DecryptUtils.encryptAES(mastCustomer.getMailAddress()));
         }
         // 電話番号
-        if (ValueUtils.isNotEmpty(mastCustomer.getMailAddress())) {
+        if (ValueUtils.isNotEmpty(mastCustomer.getPhoneNumber())) {
             mastCustomer.setPhoneNumber(DecryptUtils.encryptAES(mastCustomer.getPhoneNumber()));
         }
 
@@ -284,7 +296,7 @@ public class MastCustomerServiceImpl extends MastCustomerBaseServiceImpl impleme
         mastCustomerVo.setPhoneNumber(phoneNumber);
 
         // プレーンテキストメール
-        if (isDecryptMail) {
+        if (isDecryptMail && ValueUtils.isNotEmpty(mastCustomerVo.getMailAddress())) {
             String mailAddress = DecryptUtils.decryptAES(mastCustomerVo.getMailAddress());
             mastCustomerVo.setMailAddress(mailAddress);
         }
@@ -314,10 +326,13 @@ public class MastCustomerServiceImpl extends MastCustomerBaseServiceImpl impleme
         }
 
         // 電話番号の重複チェック
-        farmerSearchCheckBo.setPhoneNumber(DecryptUtils.encryptAES(mastCustomerBo.getPhoneNumber()));
-        int mastFarmerCount = mastCustomerMapper.getCustomerInfoCount(farmerSearchCheckBo);
-        if (mastFarmerCount > 0) {
-            throw new ServiceException(MessageUtils.message("E0001", MessageUtils.message("label.phoneNumber")));
+        if(!mastCustomerBo.getPhoneNoCheckFlg()) {
+            farmerSearchCheckBo.setPhoneNumber(DecryptUtils.encryptAES(mastCustomerBo.getPhoneNumber()));
+            int mastFarmerCount = mastCustomerMapper.getCustomerInfoCount(farmerSearchCheckBo);
+            if (mastFarmerCount > 0) {
+                throw new ServiceException(MessageUtils.message("E0001", MessageUtils.message("label.phoneNumber")));
+            }
         }
+
     }
 }