Browse Source

顾客修正

zdsong 2 weeks ago
parent
commit
61c1bf3200

+ 10 - 0
farm-crm-biz/src/main/java/jp/yamoto/farm/crm/biz/bss/domain/vo/BssAskHistoryVo.java

@@ -26,6 +26,16 @@ public class BssAskHistoryVo extends BaseEntity {
     private String askNo;
 
     /**
+     * カテゴリ(大)
+     */
+    private String category1;
+
+    /**
+     * カテゴリ(中)
+     */
+    private String category2;
+
+    /**
      * シリアルナンバー
      */
     private Integer seqNo;

+ 13 - 0
farm-crm-biz/src/main/java/jp/yamoto/farm/crm/biz/bss/domain/vo/BssAskVo.java

@@ -1,12 +1,15 @@
 package jp.yamoto.farm.crm.biz.bss.domain.vo;
 
 import jp.yamoto.farm.common.core.domain.BaseEntity;
+import jp.yamoto.farm.crm.biz.master.domain.entity.MastFarmer;
+import jp.yamoto.farm.crm.biz.master.domain.vo.MastFarmerVo;
 import lombok.Data;
 import lombok.EqualsAndHashCode;
 
 import java.io.Serial;
 import java.math.BigDecimal;
 import java.util.Date;
+import java.util.List;
 
 /**
  * 問合せ情報詳細情報Vo
@@ -115,4 +118,14 @@ public class BssAskVo extends BaseEntity {
      * リビジョン
      */
     private Integer version;
+
+    /**
+     * 農家マスタ詳細情報Vo
+     */
+    private MastFarmerVo mastFarmerVo;
+
+    /**
+     * 問合せ対応履歴情報 詳細情報Vo
+     */
+    private List<BssAskHistoryVo> vssAskHistoryVoLst;
 }

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

@@ -158,4 +158,7 @@ public class MastCustomerBo implements Serializable {
      */
     private Integer version;
 
+    private Boolean askAddCustomerFlg;
+
+
 }

+ 8 - 0
farm-crm-biz/src/main/java/jp/yamoto/farm/crm/biz/master/mapper/MastCustomerMapper.java

@@ -36,6 +36,14 @@ public interface MastCustomerMapper {
      */
     public int getCustomerIdCount(String customerId);
 
+    /**
+     * 電話番号で顧客がいるかどうかを確認します
+     *
+     * @param phoneNumber 顧客ID
+     * @return 結果
+     */
+    public int getCustomerCntByPhoneNumber(String phoneNumber);
+
      /**
      *顧客マスタを登録
      *

+ 9 - 1
farm-crm-biz/src/main/java/jp/yamoto/farm/crm/biz/master/service/IMastCustomerService.java

@@ -43,7 +43,7 @@ public interface IMastCustomerService {
      * @param mastCustomerBo 顧客マスタパラメータ対象
      * @return 結果
      */
-    public void saveCustomerWithBssAsk(MastCustomerBo mastCustomerBo);
+    public String saveCustomerWithBssAsk(MastCustomerBo mastCustomerBo);
 
     /**
      * 顧客マスタの一括削除
@@ -52,4 +52,12 @@ public interface IMastCustomerService {
      * @return 結果
      */
     public int deleteLogicByIdAndVersion(MastCustomer mastCustomer);
+
+    /**
+     * 電話番号で顧客がいるかどうかを確認します
+     *
+     * @param phoneNumber 電話番号
+     * @return 結果
+     */
+    public boolean checkExistCustomerByPhoneNumber(String phoneNumber);
 }

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

@@ -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);
+        }
     }
 
 }

+ 12 - 0
farm-crm-biz/src/main/resources/mapper/crm/MastCustomerMapper.xml

@@ -169,6 +169,18 @@
         </where>
     </select>
 
+    <select id="getCustomerCntByPhoneNumber" parameterType="String" resultType="java.lang.Integer">
+        SELECT
+        count(1)
+        FROM
+        mast_customer
+        <where>
+            <if test="phoneNumber != null  and phoneNumber != ''">
+                and phone_number = #{phoneNumber}
+            </if>
+        </where>
+    </select>
+
     <insert id="insert" parameterType="MastCustomer">
         insert into mast_customer
         <trim prefix="(" suffix=")" suffixOverrides=",">

+ 8 - 0
farm-crm/src/main/java/jp/yamoto/farm/crm/web/controller/master/MastCustomerController.java

@@ -71,4 +71,12 @@ public class MastCustomerController extends BaseController {
     public AjaxResult deleteLogic(@RequestBody MastCustomer mastCustomer) {
         return toAjax(mastCustomerService.deleteLogicByIdAndVersion(mastCustomer));
     }
+
+    /**
+     * 電話番号で顧客がいるかどうかを確認します(顧客情報を登録)
+     */
+    @GetMapping(value = "/check/exists/with/phone")
+    public AjaxResult checkExistCustomerByPhoneNumber(@RequestParam("phoneNumber") String phoneNumber) {
+        return success(mastCustomerService.checkExistCustomerByPhoneNumber(phoneNumber));
+    }
 }