|
|
@@ -22,7 +22,6 @@ import org.springframework.beans.BeanUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
-import org.springframework.util.CollectionUtils;
|
|
|
|
|
|
import java.util.List;
|
|
|
|
|
|
@@ -113,35 +112,34 @@ public class MastCustomerServiceImpl extends MastCustomerBaseServiceImpl impleme
|
|
|
|
|
|
MastCustomerSearchBo mastCustomer = new MastCustomerSearchBo();
|
|
|
mastCustomer.setDiscontinuedFlg(DelFlgEnum.OFF.getCode());
|
|
|
- mastCustomer.setPhoneNumber( DecryptUtils.encryptAES(mastCustomerBo.getPhoneNumber()));
|
|
|
+ mastCustomer.setFarmerId(mastCustomerBo.getFarmerId());
|
|
|
+ mastCustomer.setPhoneNumber(DecryptUtils.encryptAES(mastCustomerBo.getPhoneNumber()));
|
|
|
|
|
|
// データを取得
|
|
|
- List<MastCustomerVo> list = mastCustomerMapper.selectList(mastCustomer);
|
|
|
+ MastCustomerVo mastCustomerVo = mastCustomerMapper.selectDetails(mastCustomer);
|
|
|
// 顧客マスタの追加時
|
|
|
- if (CollectionUtils.isEmpty(list)) {
|
|
|
+ if (ValueUtils.isEmpty(mastCustomerVo)) {
|
|
|
// お問い合わせ者顧客を増やすフラグ
|
|
|
- String autoCustomerId = rangedSeqService.generateSerialNo(IRangedSeqService.SERIAL_TYPE_CUSTOMER);
|
|
|
- mastCustomerBo.setCustomerId(autoCustomerId);
|
|
|
this.insertInfo(mastCustomerBo);
|
|
|
- return autoCustomerId;
|
|
|
- }
|
|
|
+ return mastCustomerBo.getCustomerId();
|
|
|
+ } else {
|
|
|
+ // 顧客マスタの更新時
|
|
|
+ String customerId = mastCustomerVo.getCustomerId();
|
|
|
+ if (ValueUtils.isEqual(mastCustomerBo.getCustomerName(), mastCustomerVo.getCustomerName())) {
|
|
|
|
|
|
- // 顧客マスタの更新時
|
|
|
- String customerId = "";
|
|
|
- for (MastCustomerVo item : list) {
|
|
|
- if (ValueUtils.isEqual(mastCustomerBo.getCustomerName(), item.getCustomerName())) {
|
|
|
- customerId = item.getCustomerId();
|
|
|
- continue;
|
|
|
+ return customerId;
|
|
|
}
|
|
|
// 関連付けを設定
|
|
|
- mastCustomerBo.setId(item.getId());
|
|
|
- mastCustomerBo.setCustomerId(item.getCustomerId());
|
|
|
- mastCustomerBo.setVersion(item.getVersion());
|
|
|
+ mastCustomerBo.setId(mastCustomerVo.getId());
|
|
|
+ mastCustomerBo.setCustomerId(mastCustomerVo.getCustomerId());
|
|
|
+ mastCustomerBo.setVersion(mastCustomerVo.getVersion());
|
|
|
+ mastCustomerBo.setFarmerId(mastCustomerVo.getFarmerId());
|
|
|
mastCustomerBo.setPhoneNoCheckFlg(true);
|
|
|
mastCustomerBo.setCustomerName(mastCustomerBo.getCustomerName());
|
|
|
this.updateInfo(mastCustomerBo);
|
|
|
+ return customerId;
|
|
|
+
|
|
|
}
|
|
|
- return customerId;
|
|
|
|
|
|
}
|
|
|
|
|
|
@@ -223,11 +221,12 @@ public class MastCustomerServiceImpl extends MastCustomerBaseServiceImpl impleme
|
|
|
/**
|
|
|
* 電話番号で顧客がいるかどうかを確認します
|
|
|
*
|
|
|
+ * @param farmerId 農家ID
|
|
|
* @param phoneNumber 電話番号
|
|
|
* @return 結果
|
|
|
*/
|
|
|
- public boolean checkExistCustomerByPhoneNumber(String phoneNumber) {
|
|
|
- int mastCustomerCount = mastCustomerMapper.getCustomerCntByPhoneNumber(phoneNumber);
|
|
|
+ public boolean checkExistCustomerByPhoneNumber(String farmerId, String phoneNumber) {
|
|
|
+ int mastCustomerCount = mastCustomerMapper.getCustomerCntByPhoneNumber(farmerId, phoneNumber);
|
|
|
return mastCustomerCount > 0;
|
|
|
}
|
|
|
|