|
|
@@ -2,11 +2,9 @@ package jp.yamoto.farm.crm.biz.master.service.impl;
|
|
|
|
|
|
import jp.yamoto.farm.common.core.domain.model.LoginUser;
|
|
|
import jp.yamoto.farm.common.core.enums.DelFlgEnum;
|
|
|
+import jp.yamoto.farm.common.core.service.IRangedSeqService;
|
|
|
import jp.yamoto.farm.common.exception.ServiceException;
|
|
|
-import jp.yamoto.farm.common.utils.DateUtils;
|
|
|
-import jp.yamoto.farm.common.utils.MessageUtils;
|
|
|
-import jp.yamoto.farm.common.utils.SecurityUtils;
|
|
|
-import jp.yamoto.farm.common.utils.ValueUtils;
|
|
|
+import jp.yamoto.farm.common.utils.*;
|
|
|
import jp.yamoto.farm.common.utils.uuid.IdUtils;
|
|
|
import jp.yamoto.farm.crm.biz.master.domain.bo.MastCustomerBo;
|
|
|
import jp.yamoto.farm.crm.biz.master.domain.entity.MastCustomer;
|
|
|
@@ -35,6 +33,9 @@ public class MastCustomerServiceImpl implements IMastCustomerService {
|
|
|
@Autowired
|
|
|
private MastCustomerMapper mastCustomerMapper;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private IRangedSeqService rangedSeqService;
|
|
|
+
|
|
|
/**
|
|
|
* 顧客マスタの検索
|
|
|
*
|
|
|
@@ -49,6 +50,8 @@ public class MastCustomerServiceImpl implements IMastCustomerService {
|
|
|
throw new ServiceException(MessageUtils.message("E0007"));
|
|
|
}
|
|
|
|
|
|
+ // 検索結果をリセット
|
|
|
+ this.restSearchData4View(mastCustomerVo, true);
|
|
|
return mastCustomerVo;
|
|
|
}
|
|
|
|
|
|
@@ -65,8 +68,8 @@ public class MastCustomerServiceImpl implements IMastCustomerService {
|
|
|
MastCustomer mastCustomer = new MastCustomer();
|
|
|
// データを取得
|
|
|
List<MastCustomerVo> list = mastCustomerMapper.selectList(mastCustomer);
|
|
|
- for(MastCustomerVo item : list) {
|
|
|
- this.restSearchData4View(item);
|
|
|
+ for (MastCustomerVo item : list) {
|
|
|
+ this.restSearchData4View(item, false);
|
|
|
}
|
|
|
return list;
|
|
|
}
|
|
|
@@ -92,22 +95,35 @@ public class MastCustomerServiceImpl implements IMastCustomerService {
|
|
|
*
|
|
|
* @param mastCustomerBo 顧客マスタパラメータ対象
|
|
|
*/
|
|
|
- public void saveCustomerWithBssAsk(MastCustomerBo mastCustomerBo) {
|
|
|
+ @Override
|
|
|
+ @Transactional(rollbackFor = Exception.class)
|
|
|
+ public String saveCustomerWithBssAsk(MastCustomerBo mastCustomerBo) {
|
|
|
+
|
|
|
MastCustomer mastCustomer = new MastCustomer();
|
|
|
mastCustomer.setDiscontinuedFlg(DelFlgEnum.OFF.getCode());
|
|
|
mastCustomer.setPhoneNumber(mastCustomerBo.getPhoneNumber());
|
|
|
+
|
|
|
// データを取得
|
|
|
List<MastCustomerVo> list = mastCustomerMapper.selectList(mastCustomer);
|
|
|
- if(CollectionUtils.isEmpty(list)) {
|
|
|
+ // 顧客マスタの追加時
|
|
|
+ if (CollectionUtils.isEmpty(list)) {
|
|
|
+ // お問い合わせ者顧客を増やすフラグ
|
|
|
+ String autoCustomerId = rangedSeqService.generateSerialNo(IRangedSeqService.SERIAL_TYPE_CUSTOMER);
|
|
|
+ mastCustomerBo.setCustomerId(autoCustomerId);
|
|
|
this.insert(mastCustomerBo);
|
|
|
- return;
|
|
|
+ return autoCustomerId;
|
|
|
}
|
|
|
- for(MastCustomerVo item : list) {
|
|
|
- if(ValueUtils.isEqual(mastCustomerBo.getCustomerName(), item.getCustomerName())) {
|
|
|
+
|
|
|
+ // 顧客マスタの更新時
|
|
|
+ String customerId = "";
|
|
|
+ for (MastCustomerVo item : list) {
|
|
|
+ if (ValueUtils.isEqual(mastCustomerBo.getCustomerName(), item.getCustomerName())) {
|
|
|
+ customerId = item.getCustomerId();
|
|
|
continue;
|
|
|
}
|
|
|
this.update(mastCustomerBo);
|
|
|
}
|
|
|
+ return customerId;
|
|
|
|
|
|
}
|
|
|
|
|
|
@@ -172,10 +188,22 @@ public class MastCustomerServiceImpl implements IMastCustomerService {
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
+ * 電話番号で顧客がいるかどうかを確認します
|
|
|
+ *
|
|
|
+ * @param phoneNumber 電話番号
|
|
|
+ * @return 結果
|
|
|
+ */
|
|
|
+ public boolean checkExistCustomerByPhoneNumber(String phoneNumber) {
|
|
|
+ int mastCustomerCount = mastCustomerMapper.getCustomerCntByPhoneNumber(phoneNumber);
|
|
|
+ return mastCustomerCount > 0 ;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
* 保存前にデータを構築
|
|
|
*
|
|
|
* @param mastCustomer 農家マスタ情報
|
|
|
*/
|
|
|
+ @SneakyThrows
|
|
|
private void buildCustomerInfo4Save(MastCustomer mastCustomer) {
|
|
|
// ログインユーザー情報を取得します
|
|
|
LoginUser loginUser = SecurityUtils.getLoginUser();
|
|
|
@@ -183,18 +211,16 @@ public class MastCustomerServiceImpl implements IMastCustomerService {
|
|
|
if (ValueUtils.isEmpty(mastCustomer.getId())) {
|
|
|
// ID
|
|
|
mastCustomer.setId(IdUtils.nextIdStr());
|
|
|
-
|
|
|
}
|
|
|
|
|
|
// データを暗号化
|
|
|
-
|
|
|
// メールアドレス
|
|
|
if (ValueUtils.isNotEmpty(mastCustomer.getMailAddress())) {
|
|
|
-// mastFarmer.setMailAddress(DecryptUtils.encryptAES(mastFarmer.getMailAddress()));
|
|
|
+ mastCustomer.setMailAddress(DecryptUtils.encryptAES(mastCustomer.getMailAddress()));
|
|
|
}
|
|
|
// 電話番号
|
|
|
if (ValueUtils.isNotEmpty(mastCustomer.getMailAddress())) {
|
|
|
-// mastFarmer.setPhoneNumber(DecryptUtils.encryptAES(mastFarmer.getPhoneNumber()));
|
|
|
+ mastCustomer.setPhoneNumber(DecryptUtils.encryptAES(mastCustomer.getPhoneNumber()));
|
|
|
}
|
|
|
|
|
|
}
|
|
|
@@ -202,15 +228,22 @@ public class MastCustomerServiceImpl implements IMastCustomerService {
|
|
|
/**
|
|
|
* 検索結果をリセット
|
|
|
*
|
|
|
- * @param mastCustomeVo 農家マスタ詳細情報Vo
|
|
|
+ * @param mastCustomerVo 農家マスタ詳細情報Vo
|
|
|
+ * @param isDecryptMail 農家マスタ詳細情報Vo
|
|
|
*/
|
|
|
@SneakyThrows
|
|
|
- private void restSearchData4View(MastCustomerVo mastCustomeVo) {
|
|
|
+ private void restSearchData4View(MastCustomerVo mastCustomerVo,boolean isDecryptMail) {
|
|
|
// デコードページにはアイテムが表示されます
|
|
|
|
|
|
- // 電話番号
|
|
|
-// String phoneNumber = DecryptUtils.decryptAES(mastCustomer.getPhoneNumber());
|
|
|
-// mastCustomer.setPhoneNumber(phoneNumber);
|
|
|
+ //電話番号
|
|
|
+ String phoneNumber = DecryptUtils.decryptAES(mastCustomerVo.getPhoneNumber());
|
|
|
+ mastCustomerVo.setPhoneNumber(phoneNumber);
|
|
|
+
|
|
|
+ // プレーンテキストメール
|
|
|
+ if (isDecryptMail) {
|
|
|
+ String mailAddress = DecryptUtils.decryptAES(mastCustomerVo.getMailAddress());
|
|
|
+ mastCustomerVo.setMailAddress(mailAddress);
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
}
|