ソースを参照

お問い合わせ做成

zdsong 2 ヶ月 前
コミット
07a5dee034

+ 110 - 0
farm-crm-biz/src/main/java/jp/yamoto/farm/crm/biz/bss/domain/bo/BssAskBo.java

@@ -0,0 +1,110 @@
+package jp.yamoto.farm.crm.biz.bss.domain.bo;
+
+import jp.yamoto.farm.common.validator.annotation.*;
+import jp.yamoto.farm.common.validator.enums.CheckTypeEnum;
+import jp.yamoto.farm.common.validator.utils.ValidatorGroup;
+import lombok.Data;
+
+import java.io.Serial;
+import java.io.Serializable;
+import java.math.BigDecimal;
+import java.util.Date;
+
+/**
+ * 問合せ情報 サービスパラメータ対象
+ *
+ * @author nextosd
+ */
+@Data
+public class BssAskBo implements Serializable {
+
+    @Serial
+    private static final long serialVersionUID = 1L;
+
+    /**
+     * ID
+     */
+    private String id;
+
+    /**
+     * お問い合わせ番号
+     */
+    @LmLength(min = 1, max = 20, params = {"{askNo}", "20"}, groups = {ValidatorGroup.AddGroup.class, ValidatorGroup.UpdateGroup.class})
+    private String askNo;
+
+    /**
+     * カテゴリ(大)
+     */
+    @LmNotBlank(params = {"{category1}"}, groups = {ValidatorGroup.AddGroup.class, ValidatorGroup.UpdateGroup.class})
+    @LmLength(min = 1, max = 20, params = {"{category1}", "20"}, groups = {ValidatorGroup.AddGroup.class, ValidatorGroup.UpdateGroup.class})
+    private String category1;
+
+    /**
+     * カテゴリ(中)
+     */
+    @LmNotBlank(params = {"{category2}"}, groups = {ValidatorGroup.AddGroup.class, ValidatorGroup.UpdateGroup.class})
+    @LmLength(min = 1, max = 20, params = {"{category2}", "20"}, groups = {ValidatorGroup.AddGroup.class, ValidatorGroup.UpdateGroup.class})
+    private String category2;
+
+    /**
+     * ステータス
+     */
+    @LmNotBlank(params = {"{status}"}, groups = {ValidatorGroup.AddGroup.class, ValidatorGroup.UpdateGroup.class})
+    private Integer status;
+
+    /**
+     * お問い合わせ・対応内容
+     */
+    @LmNotBlank(params = {"{askAnswerRemark}"}, groups = {ValidatorGroup.AddGroup.class, ValidatorGroup.UpdateGroup.class})
+    private String askAnswerRemark;
+
+    /**
+     * お問い合わせ者区分
+     */
+    private Integer askUserType;
+
+    /**
+     * システム顧客番号
+     */
+    @LmLength(min = 1, max = 20, params = {"{sysCustomerId}", "20"}, groups = {ValidatorGroup.AddGroup.class, ValidatorGroup.UpdateGroup.class})
+    private String sysCustomerId;
+
+    /**
+     * 顧客情報を登録フラグ
+     */
+    private Boolean customerAddFlg;
+
+    /**
+     * 顧客ID
+     */
+    @LmLength(min = 1, max = 20, params = {"{customerId}", "20"}, groups = {ValidatorGroup.AddGroup.class, ValidatorGroup.UpdateGroup.class})
+    private String customerId;
+
+    /**
+     * 顧客名
+     */
+    @LmLength(min = 1, max = 128, params = {"{customerName}", "128"}, groups = {ValidatorGroup.AddGroup.class, ValidatorGroup.UpdateGroup.class})
+    private String askUser;
+
+    /**
+     * 電話番号
+     */
+    private String phoneNumber;
+
+    /**
+     * 農家ID
+     */
+    @LmLength(min = 1, max = 20, params = {"{farmerId}", "20"}, groups = {ValidatorGroup.AddGroup.class, ValidatorGroup.UpdateGroup.class})
+    private String farmerId;
+
+    /**
+     * 注文ID
+     */
+    @LmLength(min = 1, max = 40, params = {"{orderId}", "40"}, groups = {ValidatorGroup.AddGroup.class, ValidatorGroup.UpdateGroup.class})
+    private String orderId;
+
+    /**
+     * リビジョン
+     */
+    private Integer version;
+}

+ 122 - 0
farm-crm-biz/src/main/java/jp/yamoto/farm/crm/biz/bss/domain/entity/BssAsk.java

@@ -0,0 +1,122 @@
+package jp.yamoto.farm.crm.biz.bss.domain.entity;
+
+import jp.yamoto.farm.common.core.domain.BaseEntity;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+
+import java.io.Serial;
+import java.math.BigDecimal;
+import java.util.Date;
+
+/**
+ * 問合せ情報 (bss_ask)
+ *
+ * @author nextosd
+ */
+@EqualsAndHashCode(callSuper = true)
+@Data
+public class BssAsk extends BaseEntity {
+
+    @Serial
+    private static final long serialVersionUID = 1L;
+
+    /**
+     * ID
+     */
+    private String id;
+
+    /**
+     * お問い合わせ番号
+     */
+    private String askNo;
+
+    /**
+     * 問合せ受付日
+     */
+    private String askDate;
+
+    /**
+     * 問合せ経路
+     */
+    private Integer askWay;
+
+    /**
+     * 問合せ種別
+     */
+    private Integer askType;
+
+    /**
+     * カテゴリ(大)
+     */
+    private String category1;
+
+    /**
+     * カテゴリ(中)
+     */
+    private String category2;
+
+    /**
+     * ステータス
+     */
+    private Integer status;
+
+    /**
+     * お問い合わせ・対応内容
+     */
+    private String askAnswerRemark;
+
+    /**
+     * 回答内容
+     */
+    private String answer;
+
+    /**
+     * お問い合わせ者
+     */
+    private String askUser;
+
+    /**
+     * お問い合わせ者区分
+     */
+    private Integer askUserType;
+
+    /**
+     * 最終対応者
+     */
+    private String finalAnswerUser;
+
+    /**
+     * 最終更新日時
+     */
+    private Date finalUpdateTime;
+
+    /**
+     * システム顧客番号
+     */
+    private String sysCustomerId;
+
+    /**
+     * 顧客ID
+     */
+    private String customerId;
+
+    /**
+     * 農家ID
+     */
+    private String farmerId;
+
+    /**
+     * 注文ID
+     */
+    private String orderId;
+
+    /**
+     * ユーザーID
+     */
+    private String userCd;
+
+    /**
+     * リビジョン
+     */
+    private Integer version;
+}

+ 66 - 0
farm-crm-biz/src/main/java/jp/yamoto/farm/crm/biz/bss/domain/entity/BssAskHistory.java

@@ -0,0 +1,66 @@
+package jp.yamoto.farm.crm.biz.bss.domain.entity;
+
+import jp.yamoto.farm.common.core.domain.BaseEntity;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+
+import java.io.Serial;
+import java.math.BigDecimal;
+
+/**
+ * 問合せ対応履歴情報  (bss_ask_history)
+ *
+ * @author nextosd
+ */
+@EqualsAndHashCode(callSuper = true)
+@Data
+public class BssAskHistory extends BaseEntity {
+
+    @Serial
+    private static final long serialVersionUID = 1L;
+
+    /**
+     * ID
+     */
+    private String id;
+
+    /**
+     * 問合せ番号
+     */
+    private String askNo;
+
+    /**
+     * カテゴリ(大)
+     */
+    private String category1;
+
+    /**
+     * カテゴリ(中)
+     */
+    private String category2;
+
+    /**
+     * シリアルナンバー
+     */
+    private Integer seqNo;
+
+    /**
+     * お問い合わせ・対応内容
+     */
+    private String askAnswerRemark;
+
+    /**
+     * 対応者
+     */
+    private String answerUser;
+
+    /**
+     * 対応時間
+     */
+    private String answerTime;
+
+    /**
+     * リビジョン
+     */
+    private Integer version;
+}

+ 47 - 0
farm-crm-biz/src/main/java/jp/yamoto/farm/crm/biz/bss/mapper/BssAskHistoryMapper.java

@@ -0,0 +1,47 @@
+package jp.yamoto.farm.crm.biz.bss.mapper;
+
+import jp.yamoto.farm.crm.biz.bss.domain.entity.BssAskHistory;
+import jp.yamoto.farm.crm.biz.bss.domain.vo.BssAskHistoryVo;
+
+import java.util.List;
+
+/**
+ * 問合せ対応履歴情報  Mapperインタフェース
+ *
+ * @author nextosd
+ */
+public interface BssAskHistoryMapper {
+
+    /**
+     * 問合せ対応履歴情報 を検索
+     *
+     * @param id 問合せ対応履歴情報 プライマリ・キー
+     * @return 問合せ対応履歴情報
+     */
+    public BssAskHistoryVo selectById(String id);
+
+    /**
+     * 問合せ対応履歴情報 を検索リスト
+     *
+     * @param bssAskHistory 問合せ対応履歴情報
+     * @return 問合せ対応履歴情報 リスト
+     */
+    public List<BssAskHistoryVo> selectList(BssAskHistory bssAskHistory);
+
+    /**
+     * 問合せ対応履歴情報 を登録
+     *
+     * @param bssAskHistory 問合せ対応履歴情報
+     * @return 結果
+     */
+    public int insert(BssAskHistory bssAskHistory);
+
+    /**
+     * 問合せ対応履歴情報 を修正
+     *
+     * @param bssAskHistory 問合せ対応履歴情報
+     * @return 結果
+     */
+    public int update(BssAskHistory bssAskHistory);
+
+}

+ 49 - 0
farm-crm-biz/src/main/java/jp/yamoto/farm/crm/biz/bss/mapper/BssAskMapper.java

@@ -0,0 +1,49 @@
+package jp.yamoto.farm.crm.biz.bss.mapper;
+
+import jp.yamoto.farm.crm.biz.bss.domain.entity.BssAsk;
+import jp.yamoto.farm.crm.biz.bss.domain.vo.BssAskVo;
+import jp.yamoto.farm.crm.biz.master.domain.entity.MastOkyakusama;
+
+import java.util.List;
+
+
+/**
+ * 問合せ情報 Mapperインタフェース
+ *
+ * @author nextosd
+ */
+public interface BssAskMapper {
+
+    /**
+     * 問合せ情報を検索
+     *
+     * @param id 問合せ情報プライマリ・キー
+     * @return 問合せ情報
+     */
+    public BssAskVo selectById(String id);
+
+    /**
+     * 問合せ情報を検索リスト
+     *
+     * @param bssAsk 問合せ情報
+     * @return 問合せ情報リスト
+     */
+    public List<BssAskVo> selectList(BssAsk bssAsk);
+
+    /**
+     * 問合せ情報を登録
+     *
+     * @param bssAsk 問合せ情報
+     * @return 結果
+     */
+    public int insert(BssAsk bssAsk);
+
+    /**
+     * 問合せ情報を修正
+     *
+     * @param bssAsk 問合せ情報
+     * @return 結果
+     */
+    public int update(BssAsk bssAsk);
+
+}

+ 48 - 0
farm-crm-biz/src/main/java/jp/yamoto/farm/crm/biz/bss/service/IBssAskService.java

@@ -0,0 +1,48 @@
+package jp.yamoto.farm.crm.biz.bss.service;
+
+import jp.yamoto.farm.crm.biz.bss.domain.bo.BssAskBo;
+import jp.yamoto.farm.crm.biz.bss.domain.entity.BssAsk;
+import jp.yamoto.farm.crm.biz.bss.domain.vo.BssAskVo;
+
+import java.util.List;
+
+/**
+ * お問い合わせ Serviceインタフェース
+ *
+ * @author nextosd
+ */
+public interface IBssAskService {
+
+    /**
+     * お問い合わせの検索
+     *
+     * @param id お問い合わせプライマリ・キー
+     * @return お問い合わせ
+     */
+    public BssAskVo selectById(String id);
+
+    /**
+     * お問い合わせのリストを検索
+     *
+     * @param bssAskBo お問い合わせパラメータ対象
+     * @return お問い合わせリスト
+     */
+    public List<BssAskVo> selectList(BssAskBo bssAskBo);
+
+    /**
+     * お問い合わせの追加
+     *
+     * @param bssAskBo お問い合わせパラメータ対象
+     * @return 結果
+     */
+    public int insert(BssAskBo bssAskBo);
+
+    /**
+     * お問い合わせの修正
+     *
+     * @param bssAskBo お問い合わせパラメータ対象
+     * @return 結果
+     */
+    public int update(BssAskBo bssAskBo);
+
+}

+ 269 - 0
farm-crm-biz/src/main/java/jp/yamoto/farm/crm/biz/bss/service/impl/BssAskServiceImpl.java

@@ -0,0 +1,269 @@
+package jp.yamoto.farm.crm.biz.bss.service.impl;
+
+import jp.yamoto.farm.common.core.domain.model.LoginUser;
+import jp.yamoto.farm.common.core.enums.DelFlgEnum;
+import jp.yamoto.farm.common.exception.ServiceException;
+import jp.yamoto.farm.common.utils.*;
+import jp.yamoto.farm.common.utils.uuid.IdUtils;
+import jp.yamoto.farm.crm.biz.bss.domain.bo.BssAskBo;
+import jp.yamoto.farm.crm.biz.bss.domain.entity.BssAsk;
+import jp.yamoto.farm.crm.biz.bss.domain.entity.BssAskHistory;
+import jp.yamoto.farm.crm.biz.bss.domain.vo.BssAskVo;
+import jp.yamoto.farm.crm.biz.bss.mapper.BssAskHistoryMapper;
+import jp.yamoto.farm.crm.biz.bss.mapper.BssAskMapper;
+import jp.yamoto.farm.crm.biz.bss.service.IBssAskService;
+import jp.yamoto.farm.crm.biz.master.domain.bo.MastCustomerBo;
+import jp.yamoto.farm.crm.biz.master.domain.bo.MastFarmerBo;
+import jp.yamoto.farm.crm.biz.master.domain.entity.MastFarmer;
+import jp.yamoto.farm.crm.biz.master.domain.vo.MastFarmerVo;
+import jp.yamoto.farm.crm.biz.master.service.IMastCustomerService;
+import jp.yamoto.farm.crm.biz.master.service.IMastFarmerService;
+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;
+
+/**
+ * お問い合わせ Service業務処理
+ *
+ * @author nextosd
+ */
+@Service
+public class BssAskServiceImpl implements IBssAskService {
+
+    @Autowired
+    private BssAskMapper bssAskMapper;
+
+    @Autowired
+    private BssAskHistoryMapper bssAskHistoryMapper;
+
+    @Autowired
+    private IMastCustomerService mastCustomerService;
+
+    @Autowired
+    private IMastFarmerService mastFarmerService;
+
+    /**
+     * お問い合わせの検索
+     *
+     * @param id お問い合わせプライマリ・キー
+     * @return お問い合わせ
+     */
+    @Override
+    public BssAskVo selectById(String id) {
+        BssAskVo bssAskVo = bssAskMapper.selectById(id);
+
+        if (bssAskVo == null) {
+            throw new ServiceException(MessageUtils.message("E0007"));
+        }
+
+        // 情報
+        if (ValueUtils.isNotEmpty(bssAskVo.getFarmerId())) {
+            MastFarmerBo mastFarmerBo = new MastFarmerBo();
+            mastFarmerBo.setFarmerId(bssAskVo.getFarmerId());
+            List<MastFarmerVo> farmerVoList = mastFarmerService.selectList(mastFarmerBo);
+            bssAskVo.setMastFarmerVo(CollectionUtils.isEmpty(farmerVoList) ? null : farmerVoList.getFirst());
+        }
+
+        // 注文情報
+        if (ValueUtils.isNotEmpty(bssAskVo.getOrderId())) {
+
+        }
+
+        // 対応履歴
+        BssAskHistory bssAskHistory =new BssAskHistory();
+        bssAskHistory.setAskNo(bssAskVo.getAskNo());
+        bssAskVo.setVssAskHistoryVoLst(bssAskHistoryMapper.selectList(bssAskHistory));
+
+        return bssAskVo;
+    }
+
+    /**
+     * お問い合わせのリストを検索
+     *
+     * @param bssAskBo お問い合わせパラメータ対象
+     * @return お問い合わせリスト
+     */
+    @Override
+    public List<BssAskVo> selectList(BssAskBo bssAskBo) {
+
+        BssAsk bssAsk = new BssAsk();
+        BeanUtils.copyProperties(bssAskBo, bssAsk);
+        return bssAskMapper.selectList(bssAsk);
+    }
+
+    /**
+     * お問い合わせの追加
+     *
+     * @param bssAskBo お問い合わせパラメータ対象
+     * @return 結果
+     */
+    @Override
+    @Transactional(rollbackFor = Exception.class)
+    public int insert(BssAskBo bssAskBo) {
+
+        // お問い合わせ情報 保存する前にチェックしてください
+        this.checkBeforeInsert(bssAskBo);
+
+        // 顧客マスタの お問い合わせから保存
+        this.insertCustomer(bssAskBo);
+
+        // 問合せ情報
+        BssAsk bssAsk = new BssAsk();
+        BeanUtils.copyProperties(bssAskBo, bssAsk);
+        // 保存前にデータを構築
+        this.buildAskInfo4Save(bssAsk);
+        // 問合せ情報を登録
+        int result = bssAskMapper.insert(bssAsk);
+        if (result > 0) {
+            // お問い合わせ情報対応履歴登録
+            result = this.insertAskHistory(bssAsk);
+        }
+
+        return result;
+    }
+
+    /**
+     * お問い合わせの編集
+     *
+     * @param bssAskBo お問い合わせパラメータ対象
+     * @return 結果
+     */
+    @Override
+    @Transactional(rollbackFor = Exception.class)
+    public int update(BssAskBo bssAskBo) {
+        BssAsk bssAsk = new BssAsk();
+        BeanUtils.copyProperties(bssAskBo, bssAsk);
+
+        // 保存前にデータを構築
+        BssAsk bssAskOld = this.buildAskInfo4Save(bssAsk);
+
+        int result = bssAskMapper.update(bssAsk);
+        if (result < 1) {
+            throw new ServiceException(MessageUtils.message("E0007"));
+        }
+
+        // お問い合わせ情報対応履歴登録
+        if (ValueUtils.isNotEmpty(bssAskOld)) {
+            result = this.insertAskHistory(bssAskOld);
+        }
+
+        return result;
+    }
+
+    /**
+     * 顧客情報を登録
+     *
+     * @param bssAskBo お問い合わせパラメータ対象
+     */
+    private void insertCustomer(BssAskBo bssAskBo) {
+
+        // [顧客情報を登録]が選択され、顧客IDが空の場合。
+        if (ValueUtils.isNotEmpty(bssAskBo.getCustomerAddFlg())
+                && bssAskBo.getCustomerAddFlg() && ValueUtils.isEmpty(bssAskBo.getCustomerId())) {
+            // 顧客マスタの お問い合わせから保存
+            MastCustomerBo mastCustomerBo = new MastCustomerBo();
+            mastCustomerBo.setAskAddCustomerFlg(true);
+            mastCustomerBo.setCustomerId(bssAskBo.getCustomerId());
+            mastCustomerBo.setPhoneNumber(bssAskBo.getPhoneNumber());
+            mastCustomerBo.setCustomerName(bssAskBo.getAskUser());
+            String customerId = mastCustomerService.saveCustomerWithBssAsk(mastCustomerBo);
+            bssAskBo.setCustomerId(customerId);
+
+        }
+
+    }
+
+    /**
+     * 保存前にデータを構築
+     *
+     * @param bssAsk お問い合わせ情報
+     * @return 更新前にデータ
+     */
+    private BssAsk buildAskInfo4Save(BssAsk bssAsk) {
+        // ログインユーザー情報を取得します
+        LoginUser loginUser = SecurityUtils.getLoginUser();
+
+        // ユーザーID
+        bssAsk.setUserCd(loginUser.getUserCode());
+
+        // ID が空の場合は、ID を設定します。
+        if (ValueUtils.isEmpty(bssAsk.getId())) {
+
+            // ID
+            bssAsk.setId(IdUtils.nextIdStr());
+            // 問い合わせ番号
+            bssAsk.setAskNo(bssAsk.getId());
+            // リビジョン
+            bssAsk.setVersion(0);
+            // 問合せ経路 (0:経路指定なし 1:電話 2:FAX 3:ハガキ 4:その他)
+            bssAsk.setAskWay(0);
+            // 問合せ種別 (0:注文 1:問合せ)
+            bssAsk.setAskType(ValueUtils.isNotEmpty(bssAsk.getOrderId()) ? 1 : 0);
+
+            // 問合せ受付日
+            bssAsk.setAskDate(DateUtils.getDate());
+
+            return null;
+        } else {
+            // 更新前にデータを取得
+            BssAskVo bssAskVo = this.bssAskMapper.selectById(bssAsk.getId());
+            bssAsk.setAskNo(bssAskVo.getAskNo());
+            bssAsk.setAskDate(bssAskVo.getAskDate());
+            BssAsk bssAskOld = new BssAsk();
+            BeanUtils.copyProperties(bssAskVo, bssAskOld);
+            return bssAskOld;
+        }
+
+    }
+
+    /**
+     * お問い合わせ情報対応履歴登録
+     *
+     * @param bssAsk お問い合わせ情報
+     * @return 結果
+     */
+    private int insertAskHistory(BssAsk bssAsk) {
+
+        BssAskHistory bssAskHistory = new BssAskHistory();
+        bssAskHistory.setId(IdUtils.nextIdStr());
+        // 問合せ番号
+        bssAskHistory.setAskNo(bssAsk.getAskNo());
+        //  シリアルナンバー
+        bssAskHistory.setSeqNo(bssAsk.getVersion() + 1);
+        //  お問い合わせ・対応内容
+        bssAskHistory.setAskAnswerRemark(bssAsk.getAskAnswerRemark());
+        //  対応者
+        bssAskHistory.setAnswerUser(bssAsk.getUserCd());
+        //  対応時間
+        bssAskHistory.setAnswerTime(DateUtils.getTime());
+
+        return bssAskHistoryMapper.insert(bssAskHistory);
+    }
+
+    /**
+     * お問い合わせ情報 保存する前にチェックしてください
+     * @param bssAskBo お問い合わせパラメータ対象
+     */
+    private void checkBeforeInsert(BssAskBo bssAskBo ) {
+
+        // 顧客名
+        if (ValueUtils.isEmpty(bssAskBo.getAskUser())) {
+            throw new ServiceException(MessageUtils.message("E0003", MessageUtils.message("label.customerName")));
+        }
+
+        // 電話番号
+        if (ValueUtils.isEmpty(bssAskBo.getPhoneNumber())) {
+            throw new ServiceException(MessageUtils.message("E0003", MessageUtils.message("label.phoneNumber")));
+        }
+        // 電話番号の形式チェック
+        if (!ValidatorUtils.isPhoneNo(bssAskBo.getPhoneNumber())) {
+            throw new ServiceException(MessageUtils.message("E0062", MessageUtils.message("label.phoneNumber")));
+        }
+
+    }
+
+}

+ 247 - 0
farm-crm-biz/src/main/resources/mapper/crm/BssAskHistoryMapper.xml

@@ -0,0 +1,247 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<!DOCTYPE mapper
+        PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
+        "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="jp.yamoto.farm.xxx.xxx.xxx.mapper.BssAskHistoryMapper">
+   <resultMap type="BssAskHistory" id="BssAskHistoryResult">
+        <result property="id" column="id"/>
+        <result property="askNo" column="ask_no"/>
+        <result property="category1" column="category1"/>
+        <result property="category2" column="category2"/>
+        <result property="seqNo" column="seq_no"/>
+        <result property="askAnswerRemark" column="ask_answer_remark"/>
+        <result property="answerUser" column="answer_user"/>
+        <result property="answerTime" column="answer_time"/>
+        <result property="createTime" column="create_time"/>
+        <result property="createBy" column="create_by"/>
+        <result property="createPgId" column="create_pg_id"/>
+        <result property="updateTime" column="update_time"/>
+        <result property="updateBy" column="update_by"/>
+        <result property="updatePgId" column="update_pg_id"/>
+        <result property="version" column="version"/>
+
+    </resultMap>
+    <sql id="selectBssAskHistoryVo">
+        select
+          id,
+          ask_no,
+          category1,
+          category2,
+          seq_no,
+          ask_answer_remark,
+          answer_user,
+          answer_time,
+          create_time,
+          create_by,
+          create_pg_id,
+          update_time,
+          update_by,
+          update_pg_id,
+          version
+        from bss_ask_history
+    </sql>
+    <select id="selectList" parameterType="BssAskHistory" resultMap="BssAskHistoryResult">
+        <include refid="selectBssAskHistoryVo"/>
+        <where>
+            <if test="id != null  and id != ''">
+                and id = #{id}
+            </if>
+            <if test="askNo != null  and askNo != ''">
+                and ask_no = #{askNo}
+            </if>
+            <if test="category1 != null  and category1 != ''">
+                and category1 = #{category1}
+            </if>
+            <if test="category2 != null  and category2 != ''">
+                and category2 = #{category2}
+            </if>
+            <if test="seqNo != null ">
+                and seq_no = #{seqNo}
+            </if>
+            <if test="askAnswerRemark != null ">
+                and ask_answer_remark = #{askAnswerRemark}
+            </if>
+            <if test="answerUser != null  and answerUser != ''">
+                and answer_user = #{answerUser}
+            </if>
+            <if test="answerTime != null  and answerTime != ''">
+                and answer_time = #{answerTime}
+            </if>
+
+        </where>
+
+        order by ask_no,seq_no
+    </select>
+
+    <select id="selectById" parameterType="String"  resultMap="BssAskHistoryResult">
+        <include refid="selectBssAskHistoryVo"/>
+        where id = #{id}
+
+    </select>
+
+    <insert id="insert" parameterType="BssAskHistory">
+        insert into bss_ask_history
+        <trim prefix="(" suffix=")" suffixOverrides=",">
+            <if test="id != null">
+                id,
+            </if>
+            <if test="askNo != null">
+                ask_no,
+            </if>
+            <if test="category1 != null">
+                category1,
+            </if>
+            <if test="category2 != null">
+                category2,
+            </if>
+            <if test="seqNo != null">
+                seq_no,
+            </if>
+            <if test="askAnswerRemark != null">
+                ask_answer_remark,
+            </if>
+            <if test="answerUser != null">
+                answer_user,
+            </if>
+            <if test="answerTime != null">
+                answer_time,
+            </if>
+            <if test="createTime != null">
+                create_time,
+            </if>
+            <if test="createBy != null">
+                create_by,
+            </if>
+            <if test="createPgId != null">
+                create_pg_id,
+            </if>
+            <if test="updateTime != null">
+                update_time,
+            </if>
+            <if test="updateBy != null">
+                update_by,
+            </if>
+            <if test="updatePgId != null">
+                update_pg_id,
+            </if>
+            <if test="version != null">
+                version,
+            </if>
+
+        </trim>
+        <trim prefix="values (" suffix=")" suffixOverrides=",">
+            <if test="id != null">
+                #{id},
+            </if>
+            <if test="askNo != null">
+                #{askNo},
+            </if>
+            <if test="category1 != null">
+                #{category1},
+            </if>
+            <if test="category2 != null">
+                #{category2},
+            </if>
+            <if test="seqNo != null">
+                #{seqNo},
+            </if>
+            <if test="askAnswerRemark != null">
+                #{askAnswerRemark},
+            </if>
+            <if test="answerUser != null">
+                #{answerUser},
+            </if>
+            <if test="answerTime != null">
+                #{answerTime},
+            </if>
+            <if test="createTime != null">
+                #{createTime},
+            </if>
+            <if test="createBy != null">
+                #{createBy},
+            </if>
+            <if test="createPgId != null">
+                #{createPgId},
+            </if>
+            <if test="updateTime != null">
+                #{updateTime},
+            </if>
+            <if test="updateBy != null">
+                #{updateBy},
+            </if>
+            <if test="updatePgId != null">
+                #{updatePgId},
+            </if>
+            <if test="version != null">
+                #{version},
+            </if>
+
+        </trim>
+    </insert>
+
+    <update id="update" parameterType="BssAskHistory">
+        update bss_ask_history
+        <trim prefix="SET" suffixOverrides=",">
+            <if test="id != null">
+                id = #{id},
+            </if>
+            <if test="askNo != null">
+                ask_no = #{askNo},
+            </if>
+            <if test="category1 != null">
+                category1 = #{category1},
+            </if>
+            <if test="category2 != null">
+                category2 = #{category2},
+            </if>
+            <if test="seqNo != null">
+                seq_no = #{seqNo},
+            </if>
+            <if test="askAnswerRemark != null">
+                ask_answer_remark = #{askAnswerRemark},
+            </if>
+            <if test="answerUser != null">
+                answer_user = #{answerUser},
+            </if>
+            <if test="answerTime != null">
+                answer_time = #{answerTime},
+            </if>
+            <if test="createTime != null">
+                create_time = #{createTime},
+            </if>
+            <if test="createBy != null">
+                create_by = #{createBy},
+            </if>
+            <if test="createPgId != null">
+                create_pg_id = #{createPgId},
+            </if>
+            <if test="updateTime != null">
+                update_time = #{updateTime},
+            </if>
+            <if test="updateBy != null">
+                update_by = #{updateBy},
+            </if>
+            <if test="updatePgId != null">
+                update_pg_id = #{updatePgId},
+            </if>
+            <if test="version != null">
+                version = #{version},
+            </if>
+
+        </trim>
+        where
+        id = #{id}
+
+        and version = #{version}
+    </update>
+
+    <delete id="deleteById" parameterType="String">
+        delete
+        from
+        bss_ask_history
+        where
+        id = #{id}
+
+    </delete>
+
+ </mapper>

+ 401 - 0
farm-crm-biz/src/main/resources/mapper/crm/BssAskMapper.xml

@@ -0,0 +1,401 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<!DOCTYPE mapper
+        PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
+        "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="jp.yamoto.farm.crm.biz.bss.mapper.BssAskMapper">
+   <resultMap type="BssAskVo" id="BssAskResult">
+        <result property="id" column="id"/>
+        <result property="askNo" column="ask_no"/>
+        <result property="askDate" column="ask_date"/>
+        <result property="askWay" column="ask_way"/>
+        <result property="askType" column="ask_type"/>
+        <result property="category1" column="category1"/>
+        <result property="category2" column="category2"/>
+        <result property="status" column="status"/>
+        <result property="askAnswerRemark" column="ask_answer_remark"/>
+        <result property="answer" column="answer"/>
+        <result property="askUser" column="ask_user"/>
+        <result property="askUserType" column="ask_user_type"/>
+        <result property="finalAnswerUser" column="final_answer_user"/>
+        <result property="finalUpdateTime" column="final_update_time"/>
+        <result property="sysCustomerId" column="sys_customer_id"/>
+        <result property="customerId" column="customer_id"/>
+        <result property="farmerId" column="farmer_id"/>
+        <result property="orderId" column="order_id"/>
+        <result property="userCd" column="user_cd"/>
+        <result property="createTime" column="create_time"/>
+        <result property="createBy" column="create_by"/>
+        <result property="createPgId" column="create_pg_id"/>
+        <result property="updateTime" column="update_time"/>
+        <result property="updateBy" column="update_by"/>
+        <result property="updatePgId" column="update_pg_id"/>
+        <result property="version" column="version"/>
+
+    </resultMap>
+    <sql id="selectBssAskVo">
+        select
+          id,
+          ask_no,
+          ask_date,
+          ask_way,
+          ask_type,
+          category1,
+          category2,
+          status,
+          ask_answer_remark,
+          answer,
+          ask_user,
+          ask_user_type,
+          final_answer_user,
+          final_update_time,
+          sys_customer_id,
+          customer_id,
+          farmer_id,
+          order_id,
+          user_cd,
+          create_time,
+          create_by,
+          create_pg_id,
+          update_time,
+          update_by,
+          update_pg_id,
+          version
+        from bss_ask
+    </sql>
+    <select id="selectList" parameterType="BssAsk" resultMap="BssAskResult">
+        <include refid="selectBssAskVo"/>
+        <where>
+            <if test="id != null  and id != ''">
+                and id = #{id}
+            </if>
+            <if test="askNo != null  and askNo != ''">
+                and ask_no = #{askNo}
+            </if>
+            <if test="askDate != null  and askDate != ''">
+                and ask_date = #{askDate}
+            </if>
+            <if test="askWay != null ">
+                and ask_way = #{askWay}
+            </if>
+            <if test="askType != null ">
+                and ask_type = #{askType}
+            </if>
+            <if test="category1 != null  and category1 != ''">
+                and category1 = #{category1}
+            </if>
+            <if test="category2 != null  and category2 != ''">
+                and category2 = #{category2}
+            </if>
+            <if test="status != null ">
+                and status = #{status}
+            </if>
+            <if test="askAnswerRemark != null ">
+                and ask_answer_remark = #{askAnswerRemark}
+            </if>
+            <if test="answer != null ">
+                and answer = #{answer}
+            </if>
+            <if test="askUser != null  and askUser != ''">
+                and ask_user = #{askUser}
+            </if>
+            <if test="askUserType != null ">
+                and ask_user_type = #{askUserType}
+            </if>
+            <if test="finalAnswerUser != null  and finalAnswerUser != ''">
+                and final_answer_user = #{finalAnswerUser}
+            </if>
+            <if test="finalUpdateTime != null ">
+                and final_update_time = #{finalUpdateTime}
+            </if>
+            <if test="sysCustomerId != null  and sysCustomerId != ''">
+                and sys_customer_id = #{sysCustomerId}
+            </if>
+            <if test="customerId != null  and customerId != ''">
+                and customer_id = #{customerId}
+            </if>
+            <if test="farmerId != null  and farmerId != ''">
+                and farmer_id = #{farmerId}
+            </if>
+            <if test="orderId != null  and orderId != ''">
+                and order_id = #{orderId}
+            </if>
+            <if test="userCd != null  and userCd != ''">
+                and user_cd = #{userCd}
+            </if>
+
+        </where>
+    </select>
+
+    <select id="selectById" parameterType="String"  resultMap="BssAskResult">
+        <include refid="selectBssAskVo"/>
+        where id = #{id}
+
+    </select>
+
+    <select id="selectAskListByCustomerId" parameterType="BssAsk" resultMap="BssAskResult">
+
+    </select>
+
+    <insert id="insert" parameterType="BssAsk">
+        insert into bss_ask
+        <trim prefix="(" suffix=")" suffixOverrides=",">
+            <if test="id != null">
+                id,
+            </if>
+            <if test="askNo != null">
+                ask_no,
+            </if>
+            <if test="askDate != null">
+                ask_date,
+            </if>
+            <if test="askWay != null">
+                ask_way,
+            </if>
+            <if test="askType != null">
+                ask_type,
+            </if>
+            <if test="category1 != null">
+                category1,
+            </if>
+            <if test="category2 != null">
+                category2,
+            </if>
+            <if test="status != null">
+                status,
+            </if>
+            <if test="askAnswerRemark != null">
+                ask_answer_remark,
+            </if>
+            <if test="answer != null">
+                answer,
+            </if>
+            <if test="askUser != null">
+                ask_user,
+            </if>
+            <if test="askUserType != null">
+                ask_user_type,
+            </if>
+            <if test="finalAnswerUser != null">
+                final_answer_user,
+            </if>
+            <if test="finalUpdateTime != null">
+                final_update_time,
+            </if>
+            <if test="sysCustomerId != null">
+                sys_customer_id,
+            </if>
+            <if test="customerId != null">
+                customer_id,
+            </if>
+            <if test="farmerId != null">
+                farmer_id,
+            </if>
+            <if test="orderId != null">
+                order_id,
+            </if>
+            <if test="userCd != null">
+                user_cd,
+            </if>
+            <if test="createTime != null">
+                create_time,
+            </if>
+            <if test="createBy != null">
+                create_by,
+            </if>
+            <if test="createPgId != null">
+                create_pg_id,
+            </if>
+            <if test="updateTime != null">
+                update_time,
+            </if>
+            <if test="updateBy != null">
+                update_by,
+            </if>
+            <if test="updatePgId != null">
+                update_pg_id,
+            </if>
+            <if test="version != null">
+                version,
+            </if>
+
+        </trim>
+        <trim prefix="values (" suffix=")" suffixOverrides=",">
+            <if test="id != null">
+                #{id},
+            </if>
+            <if test="askNo != null">
+                #{askNo},
+            </if>
+            <if test="askDate != null">
+                #{askDate},
+            </if>
+            <if test="askWay != null">
+                #{askWay},
+            </if>
+            <if test="askType != null">
+                #{askType},
+            </if>
+            <if test="category1 != null">
+                #{category1},
+            </if>
+            <if test="category2 != null">
+                #{category2},
+            </if>
+            <if test="status != null">
+                #{status},
+            </if>
+            <if test="askAnswerRemark != null">
+                #{askAnswerRemark},
+            </if>
+            <if test="answer != null">
+                #{answer},
+            </if>
+            <if test="askUser != null">
+                #{askUser},
+            </if>
+            <if test="askUserType != null">
+                #{askUserType},
+            </if>
+            <if test="finalAnswerUser != null">
+                #{finalAnswerUser},
+            </if>
+            <if test="finalUpdateTime != null">
+                #{finalUpdateTime},
+            </if>
+            <if test="sysCustomerId != null">
+                #{sysCustomerId},
+            </if>
+            <if test="customerId != null">
+                #{customerId},
+            </if>
+            <if test="farmerId != null">
+                #{farmerId},
+            </if>
+            <if test="orderId != null">
+                #{orderId},
+            </if>
+            <if test="userCd != null">
+                #{userCd},
+            </if>
+            <if test="createTime != null">
+                #{createTime},
+            </if>
+            <if test="createBy != null">
+                #{createBy},
+            </if>
+            <if test="createPgId != null">
+                #{createPgId},
+            </if>
+            <if test="updateTime != null">
+                #{updateTime},
+            </if>
+            <if test="updateBy != null">
+                #{updateBy},
+            </if>
+            <if test="updatePgId != null">
+                #{updatePgId},
+            </if>
+            <if test="version != null">
+                #{version},
+            </if>
+
+        </trim>
+    </insert>
+
+    <update id="update" parameterType="BssAsk">
+        update bss_ask
+        <trim prefix="SET" suffixOverrides=",">
+            <if test="id != null">
+                id = #{id},
+            </if>
+            <if test="askNo != null">
+                ask_no = #{askNo},
+            </if>
+            <if test="askDate != null">
+                ask_date = #{askDate},
+            </if>
+            <if test="askWay != null">
+                ask_way = #{askWay},
+            </if>
+            <if test="askType != null">
+                ask_type = #{askType},
+            </if>
+            <if test="category1 != null">
+                category1 = #{category1},
+            </if>
+            <if test="category2 != null">
+                category2 = #{category2},
+            </if>
+            <if test="status != null">
+                status = #{status},
+            </if>
+            <if test="askAnswerRemark != null">
+                ask_answer_remark = #{askAnswerRemark},
+            </if>
+            <if test="answer != null">
+                answer = #{answer},
+            </if>
+            <if test="askUser != null">
+                ask_user = #{askUser},
+            </if>
+            <if test="askUserType != null">
+                ask_user_type = #{askUserType},
+            </if>
+            <if test="finalAnswerUser != null">
+                final_answer_user = #{finalAnswerUser},
+            </if>
+            <if test="finalUpdateTime != null">
+                final_update_time = #{finalUpdateTime},
+            </if>
+            <if test="sysCustomerId != null">
+                sys_customer_id = #{sysCustomerId},
+            </if>
+            <if test="customerId != null">
+                customer_id = #{customerId},
+            </if>
+            <if test="farmerId != null">
+                farmer_id = #{farmerId},
+            </if>
+            <if test="orderId != null">
+                order_id = #{orderId},
+            </if>
+            <if test="userCd != null">
+                user_cd = #{userCd},
+            </if>
+            <if test="createTime != null">
+                create_time = #{createTime},
+            </if>
+            <if test="createBy != null">
+                create_by = #{createBy},
+            </if>
+            <if test="createPgId != null">
+                create_pg_id = #{createPgId},
+            </if>
+            <if test="updateTime != null">
+                update_time = #{updateTime},
+            </if>
+            <if test="updateBy != null">
+                update_by = #{updateBy},
+            </if>
+            <if test="updatePgId != null">
+                update_pg_id = #{updatePgId},
+            </if>
+            version = version + 1
+
+        </trim>
+        where
+        id = #{id}
+
+        and version = #{version}
+    </update>
+
+    <delete id="deleteById" parameterType="String">
+        delete
+        from
+        bss_ask
+        where
+        id = #{id}
+
+    </delete>
+
+ </mapper>

+ 70 - 0
farm-crm/src/main/java/jp/yamoto/farm/crm/web/controller/bss/BssAskController.java

@@ -0,0 +1,70 @@
+package jp.yamoto.farm.crm.web.controller.bss;
+
+import jp.yamoto.farm.common.annotation.Log;
+import jp.yamoto.farm.common.core.controller.BaseController;
+import jp.yamoto.farm.common.core.domain.AjaxResult;
+import jp.yamoto.farm.common.core.page.TableDataInfo;
+import jp.yamoto.farm.common.enums.BusinessType;
+import jp.yamoto.farm.common.validator.utils.ValidatorGroup;
+import jp.yamoto.farm.crm.biz.bss.domain.bo.BssAskBo;
+import jp.yamoto.farm.crm.biz.bss.domain.vo.BssAskVo;
+import jp.yamoto.farm.crm.biz.bss.service.IBssAskService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.security.access.prepost.PreAuthorize;
+import org.springframework.validation.annotation.Validated;
+import org.springframework.web.bind.annotation.*;
+
+import java.util.List;
+
+/**
+ * お問い合わせタController
+ *
+ * @author nextosd
+ */
+@RestController
+@RequestMapping("/api/ask")
+public class BssAskController extends BaseController {
+
+    @Autowired
+    private IBssAskService bssAskService;
+
+    /**
+     * お問い合わせタのリスト
+     */
+    @PreAuthorize("@ss.hasPermi('crm:bssAsk:list')")
+    @GetMapping("/list")
+    public TableDataInfo list(BssAskBo bssAskBo) {
+        startPage();
+        List<BssAskVo> list = bssAskService.selectList(bssAskBo);
+        return getDataTable(list);
+    }
+
+    /**
+     * お問い合わせタの詳細情報
+     */
+    @GetMapping(value = "/{id}/detail")
+    public AjaxResult detail(@PathVariable("id") String id) {
+        return success(bssAskService.selectById(id));
+    }
+
+    /**
+     * お問い合わせタの追加
+     */
+    @PreAuthorize("@ss.hasPermi('crm:bssAsk:add')")
+    @Log(title = "お問い合わせタ", businessType = BusinessType.INSERT)
+    @PostMapping("/add")
+    public AjaxResult add(@RequestBody @Validated({ValidatorGroup.AddGroup.class}) BssAskBo bssAskBo) {
+        return toAjax(bssAskService.insert(bssAskBo));
+    }
+
+    /**
+     * お問い合わせタの修正
+     */
+    @PreAuthorize("@ss.hasPermi('crm:bssAsk:edit')")
+    @Log(title = "お問い合わせタ", businessType = BusinessType.UPDATE)
+    @PostMapping("/update")
+    public AjaxResult edit(@RequestBody @Validated({ValidatorGroup.AddGroup.class}) BssAskBo bssAskBo) {
+        return toAjax(bssAskService.update(bssAskBo));
+    }
+
+}