feature:客户信息开发

release
gaorl 2 years ago
parent a521635cce
commit 6d77a6d77a
  1. 24
      order-management-base-service/src/main/java/com/dxhy/order/baseservice/module/buyer/controller/BuyerController.java
  2. 5
      order-management-base-service/src/main/java/com/dxhy/order/baseservice/module/buyer/dao/BuyerMapper.java
  3. 2
      order-management-base-service/src/main/java/com/dxhy/order/baseservice/module/buyer/model/BuyerEntity.java
  4. 55
      order-management-base-service/src/main/java/com/dxhy/order/baseservice/module/buyer/model/BuyerEntityDetail.java
  5. 79
      order-management-base-service/src/main/java/com/dxhy/order/baseservice/module/buyer/service/impl/BuyerServiceImpl.java
  6. 138
      order-management-base-service/src/main/resources/mybatis/mapper/BuyerMapper.xml

@ -44,7 +44,7 @@ import java.util.*;
@Slf4j @Slf4j
@RestController @RestController
@Api(value = "购方信息", tags = {"管理模块"}) @Api(value = "购方信息", tags = {"管理模块"})
@RequestMapping("/buyer") @RequestMapping("/buyer")
public class BuyerController { public class BuyerController {
private static final String LOGGER_MSG = "(购方信息控制层)"; private static final String LOGGER_MSG = "(购方信息控制层)";
@ -123,28 +123,6 @@ public class BuyerController {
Long userId = userInfoService.getUser().getUserId(); Long userId = userInfoService.getUser().getUserId();
String id = buyerEntity.getId(); String id = buyerEntity.getId();
// 处理MDM默认银行账户等信息
List<MdmBankListBO> bankListBOS = new ArrayList<>();
if (CollectionUtil.isNotEmpty(buyerEntity.getBanks())) {
buyerEntity.getBanks().forEach(i -> {
MdmBankListBO temp = new MdmBankListBO();
temp.setAddress(i.getAddress());
temp.setPhone(i.getPhone());
temp.setBankNumber(i.getBankNumber());
temp.setBankOfDeposit(i.getBankOfDeposit());
bankListBOS.add(temp);
});
if (buyerEntity.getBankDefaultIndex() != null) {
buyerEntity.getBanks().get(buyerEntity.getBankDefaultIndex());
Integer index = buyerEntity.getBankDefaultIndex();
buyerEntity.setAddress(buyerEntity.getBanks().get(index).getAddress());
buyerEntity.setPhone(buyerEntity.getBanks().get(index).getPhone());
buyerEntity.setBankNumber(buyerEntity.getBanks().get(index).getBankNumber());
buyerEntity.setBankOfDeposit(buyerEntity.getBanks().get(index).getBankOfDeposit());
}
}
if (StringUtils.isNotBlank(id)) { if (StringUtils.isNotBlank(id)) {
// 修改 // 修改
buyerEntity.setModifyUserId(userId.toString()); buyerEntity.setModifyUserId(userId.toString());

@ -1,6 +1,7 @@
package com.dxhy.order.baseservice.module.buyer.dao; package com.dxhy.order.baseservice.module.buyer.dao;
import com.dxhy.order.baseservice.module.buyer.model.BuyerEntity; import com.dxhy.order.baseservice.module.buyer.model.BuyerEntity;
import com.dxhy.order.baseservice.module.buyer.model.BuyerEntityDetail;
import org.apache.ibatis.annotations.Param; import org.apache.ibatis.annotations.Param;
import java.util.List; import java.util.List;
@ -39,6 +40,10 @@ public interface BuyerMapper {
*/ */
int insertBuyer(BuyerEntity buyerEntity); int insertBuyer(BuyerEntity buyerEntity);
int batchInsertBuyerDetail(List<BuyerEntityDetail> buyerEntityDetails);
int deleteBuyerDetail(String buyerManageId);
int insertBuyerOnDuplicateKey(BuyerEntity buyerEntity); int insertBuyerOnDuplicateKey(BuyerEntity buyerEntity);
/** /**

@ -129,6 +129,8 @@ public class BuyerEntity implements Serializable {
// 银行账户 // 银行账户
private List<BuyerEntityBankBO> banks; private List<BuyerEntityBankBO> banks;
private List<BuyerEntityDetail> buyerEntityDetail;
// 默认银行账户的索引7 // 默认银行账户的索引7
private Integer bankDefaultIndex; private Integer bankDefaultIndex;
} }

@ -0,0 +1,55 @@
package com.dxhy.order.baseservice.module.buyer.model;
import lombok.Data;
import java.util.Date;
@Data
public class BuyerEntityDetail {
/**
* id
*/
private Integer consumerId;
/**
* buyer_manage_info 的主表
*/
private String buyerManageId;
/**
* 客户银行名称
*/
private String bankName;
/**
* 客户银行账户
*/
private String bankAccount;
/**
* 购方地址
*/
private String address;
/**
* 购方电话
*/
private String phone;
/**
* 默认银行标记
*/
private String defaultMark;
/**
* 创建人
*/
private String createUser;
/**
* 更新人
*/
private String updateUser;
/**
* 创建时间
*/
private Date createTime;
/**
* 更新时间
*/
private Date updateTime;
}

@ -1,5 +1,6 @@
package com.dxhy.order.baseservice.module.buyer.service.impl; package com.dxhy.order.baseservice.module.buyer.service.impl;
import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.core.util.ObjectUtil; import cn.hutool.core.util.ObjectUtil;
import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
@ -320,6 +321,7 @@ public class BuyerServiceImpl implements BuyerService {
@Override @Override
@Transactional
public R saveOrUpdateBuyerInfo(BuyerEntity buyerEntity) { public R saveOrUpdateBuyerInfo(BuyerEntity buyerEntity) {
/** /**
@ -329,16 +331,38 @@ public class BuyerServiceImpl implements BuyerService {
shList.add(buyerEntity.getXhfNsrsbh()); shList.add(buyerEntity.getXhfNsrsbh());
R r = new R(); R r = new R();
if (ConfigureConstant.STRING_1.equals(buyerEntity.getIsEdit()) && StringUtils.isBlank(buyerEntity.getId())) { // if (ConfigureConstant.STRING_1.equals(buyerEntity.getIsEdit()) && StringUtils.isBlank(buyerEntity.getId())) {
BuyerEntity existBuyer = isExistBuyer(buyerEntity); BuyerEntity existBuyer = isExistBuyer(buyerEntity);
if (ObjectUtil.isNotNull(existBuyer)) { if (ObjectUtil.isNotNull(existBuyer)) {
buyerEntity.setId(existBuyer.getId()); buyerEntity.setId(existBuyer.getId());
} }
// 处理MDM默认银行账户等信息
String buyerId = baseService.getGenerateShotKey();
if (CollectionUtil.isNotEmpty(buyerEntity.getBuyerEntityDetail())) {
buyerEntity.getBuyerEntityDetail().forEach(t -> {
if(ConfigureConstant.STRING_1.equals(buyerEntity.getIsEdit())){
t.setUpdateUser("");
t.setUpdateTime(new Date());
}else{
t.setBuyerManageId(buyerId);
t.setCreateUser("");
t.setCreateTime(new Date());
}
if("0".equals(t.getDefaultMark())){
buyerEntity.setAddress(t.getAddress());
buyerEntity.setPhone(t.getPhone());
buyerEntity.setBankNumber(t.getBankAccount());
buyerEntity.setBankOfDeposit(t.getBankName());
}
});
} }
if (StringUtils.isNotBlank(buyerEntity.getId())) { if (existBuyer != null) {//StringUtils.isNotBlank(buyerEntity.getId())
buyerEntity.setModifyTime(new Date()); buyerEntity.setModifyTime(new Date());
//更新明细表,最好的办法是先删除后新增
buyerMapper.deleteBuyerDetail(buyerEntity.getId());
buyerMapper.batchInsertBuyerDetail(buyerEntity.getBuyerEntityDetail());
int i = buyerMapper.updateBuyer(buyerEntity, shList); int i = buyerMapper.updateBuyer(buyerEntity, shList);
if (i <= 0) { if (i <= 0) {
@ -346,40 +370,17 @@ public class BuyerServiceImpl implements BuyerService {
} }
} else { } else {
BuyerEntity buyerEntity1 = new BuyerEntity(); //新增购方信息
buyerEntity1.setBuyerCode(buyerEntity.getBuyerCode()); if (StringUtils.isBlank(buyerEntity.getBuyerCode())) {
buyerEntity1.setTaxpayerCode(buyerEntity.getTaxpayerCode()); buyerEntity.setBuyerCode(baseService.getGenerateShotKey());
buyerEntity1.setPurchaseName(buyerEntity.getPurchaseName()); }
List<BuyerEntity> queryBuyerEntity = buyerMapper.selectBuyerByBuyerEntity(buyerEntity1, shList); log.info("{}添加开始执行开始执行 uuid = {}", LOGGER_MSG, buyerId);
if (queryBuyerEntity != null && queryBuyerEntity.size() > 0) { buyerEntity.setId(buyerId);
buyerMapper.batchInsertBuyerDetail(buyerEntity.getBuyerEntityDetail());
buyerEntity.setModifyTime(new Date()); int i = buyerMapper.insertBuyer(buyerEntity);
buyerEntity.setBuyerCode(queryBuyerEntity.get(0).getBuyerCode()); if (i <= 0) {
buyerEntity.setId(queryBuyerEntity.get(0).getId()); r.put("message", "添加失败").put(OrderManagementConstant.CODE, ConfigureConstant.STRING_9999);
//更新客户信息
int i = buyerMapper.updateBuyer(buyerEntity, shList);
if (i <= 0) {
r.put("message", "修改失败").put(OrderManagementConstant.CODE, ConfigureConstant.STRING_9999);
}
} else {
//新增购方信息
if (StringUtils.isBlank(buyerEntity.getBuyerCode())) {
buyerEntity.setBuyerCode(baseService.getGenerateShotKey());
}
String uuid = baseService.getGenerateShotKey();
log.info("{}添加开始执行开始执行 uuid = {}", LOGGER_MSG, uuid);
buyerEntity.setId(uuid);
int i = buyerMapper.insertBuyer(buyerEntity);
if (i <= 0) {
r.put("message", "添加失败").put(OrderManagementConstant.CODE, ConfigureConstant.STRING_9999);
}
} }
} }
return R.ok().put(OrderManagementConstant.MESSAGE, "保存成功!"); return R.ok().put(OrderManagementConstant.MESSAGE, "保存成功!");

@ -25,6 +25,19 @@
<result column="invoice_taxno" jdbcType="VARCHAR" property="invoiceTaxno"/> <result column="invoice_taxno" jdbcType="VARCHAR" property="invoiceTaxno"/>
<result column="mdm_multicode_json" jdbcType="VARCHAR" property="mdmMulticodeJson"/> <result column="mdm_multicode_json" jdbcType="VARCHAR" property="mdmMulticodeJson"/>
<result column="status" jdbcType="VARCHAR" property="status"/> <result column="status" jdbcType="VARCHAR" property="status"/>
<collection property="buyerEntityDetail" ofType="com.dxhy.order.baseservice.module.buyer.model.BuyerEntityDetail">
<id column="consumer_id" jdbcType="Integer" property="consumerId"/>
<result column="buyer_manage_id" jdbcType="VARCHAR" property="buyerManageId"/>
<result column="bank_name" jdbcType="VARCHAR" property="bankName"/>
<result column="bank_account" jdbcType="VARCHAR" property="bankAccount"/>
<result column="address" jdbcType="VARCHAR" property="address"/>
<result column="phone" jdbcType="VARCHAR" property="phone"/>
<result column="default_mark" jdbcType="VARCHAR" property="defaultMark"/>
<result column="create_user" jdbcType="VARCHAR" property="createUser"/>
<result column="update_user" jdbcType="VARCHAR" property="updateUser"/>
<result column="create_time" jdbcType="TIMESTAMP" property="createTime"/>
<result column="update_time" jdbcType="TIMESTAMP" property="updateTime"/>
</collection>
</resultMap> </resultMap>
<sql id="Buyer_Base_Column_List"> <sql id="Buyer_Base_Column_List">
@ -35,28 +48,29 @@
<bind name="dataType" value="${dataType}"/> <bind name="dataType" value="${dataType}"/>
<if test="dataType ==0 "> <if test="dataType ==0 ">
SELECT SELECT
id, bmi.id,
taxpayer_code, bmi.taxpayer_code,
purchase_name, bmi.purchase_name,
address, bmi.address,
phone, bmi.phone,
bank_of_deposit, bmi.bank_of_deposit,
bank_number, bmi.bank_number,
email, bmi.email,
sjh, bmi.sjh,
remarks, bmi.remarks,
create_user_id, bmi.create_user_id,
DATE_FORMAT(create_time, '%Y-%m-%d') createTime, bmi.DATE_FORMAT(create_time, '%Y-%m-%d') createTime,
DATE_FORMAT(modify_time, '%Y-%m-%d') modifyTime, bmi.DATE_FORMAT(modify_time, '%Y-%m-%d') modifyTime,
modify_user_id, bmi.modify_user_id,
ghf_qylx, bmi.ghf_qylx,
xhf_nsrsbh, bmi.xhf_nsrsbh,
xhf_mc, bmi.xhf_mc,
buyer_code, bmi.buyer_code,
create_time, bmi.create_time,
status bmi.status,
bmid.*
FROM FROM
buyer_manage_info buyer_manage_info bmi left join buyer_manage_info_detail bmid on bmi.id = bmid.buyer_manage_id
<where> <where>
<if test="shList != null and shList.size() == 0"> <if test="shList != null and shList.size() == 0">
and xhf_nsrsbh = '' and xhf_nsrsbh = ''
@ -274,6 +288,88 @@
</if> </if>
</where> </where>
</update> </update>
<insert id="batchInsertBuyerDetail" parameterType="com.dxhy.order.baseservice.module.buyer.model.BuyerEntityDetail" useGeneratedKeys="true" keyProperty="consumerId">
<bind name="dataType" value="${dataType}"/>
INSERT INTO buyer_manage_info_detail
<trim prefix="(" suffix=")" suffixOverrides=",">
<!--<if test="consumerId != null">-->
<!--consumer_id,-->
<!--</if>-->
<if test="buyerManageId != null">
buyer_manage_id,
</if>
<if test="bankName != null">
bank_name,
</if>
<if test="bankAccount != null">
bank_account,
</if>
<if test="address != null">
address,
</if>
<if test="phone != null">
phone,
</if>
<if test="defaultMark != null">
default_mark,
</if>
<if test="createUser != null">
create_user,
</if>
<if test="updateUser != null">
update_user,
</if>
<if test="createTime != null">
create_time,
</if>
<if test="updateTime != null">
update_time,
</if>
</trim>
<trim prefix="values">
<foreach collection="buyerEntityDetails" item="buyerDetail" index="index" open="(" separator="," close=")">
<!--<if test="consumerId != null">-->
<!--#{consumerId,jdbcType=VARCHAR},-->
<!--</if>-->
<if test="buyerManageId != null">
#{buyerManageId,jdbcType=VARCHAR},
</if>
<if test="bankName != null">
#{bankName,jdbcType=VARCHAR},
</if>
<if test="bankAccount != null">
#{bankAccount,jdbcType=VARCHAR},
</if>
<if test="address != null">
#{address,jdbcType=VARCHAR},
</if>
<if test="phone != null">
#{phone,jdbcType=VARCHAR},
</if>
<if test="defaultMark != null">
#{defaultMark,jdbcType=VARCHAR},
</if>
<if test="createUser != null">
#{createUser,jdbcType=VARCHAR},
</if>
<if test="updateUser != null">
#{updateUser,jdbcType=VARCHAR},
</if>
<if test="createTime != null">
now(),
</if>
<if test="updateTime != null">
now(),
</if>
</foreach>
</trim>
</insert>
<delete id="deleteBuyerDetail">
DELETE FROM buyer_manage_info_detail where buyer_manage_info = #{buyerManageId,jdbcType=VARCHAR}
</delete>
<!-- 插入数据--> <!-- 插入数据-->
<insert id="insertBuyer" parameterType="com.dxhy.order.baseservice.module.buyer.model.BuyerEntity"> <insert id="insertBuyer" parameterType="com.dxhy.order.baseservice.module.buyer.model.BuyerEntity">
<bind name="dataType" value="${dataType}"/> <bind name="dataType" value="${dataType}"/>

Loading…
Cancel
Save