feature:客户信息开发

release
gaorl 2 years ago
parent a521635cce
commit 6d77a6d77a
  1. 22
      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. 55
      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

@ -123,28 +123,6 @@ public class BuyerController {
Long userId = userInfoService.getUser().getUserId();
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)) {
// 修改
buyerEntity.setModifyUserId(userId.toString());

@ -1,6 +1,7 @@
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.BuyerEntityDetail;
import org.apache.ibatis.annotations.Param;
import java.util.List;
@ -39,6 +40,10 @@ public interface BuyerMapper {
*/
int insertBuyer(BuyerEntity buyerEntity);
int batchInsertBuyerDetail(List<BuyerEntityDetail> buyerEntityDetails);
int deleteBuyerDetail(String buyerManageId);
int insertBuyerOnDuplicateKey(BuyerEntity buyerEntity);
/**

@ -129,6 +129,8 @@ public class BuyerEntity implements Serializable {
// 银行账户
private List<BuyerEntityBankBO> banks;
private List<BuyerEntityDetail> buyerEntityDetail;
// 默认银行账户的索引7
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;
import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.core.util.ObjectUtil;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
@ -320,6 +321,7 @@ public class BuyerServiceImpl implements BuyerService {
@Override
@Transactional
public R saveOrUpdateBuyerInfo(BuyerEntity buyerEntity) {
/**
@ -329,59 +331,58 @@ public class BuyerServiceImpl implements BuyerService {
shList.add(buyerEntity.getXhfNsrsbh());
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);
if (ObjectUtil.isNotNull(existBuyer)) {
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 (StringUtils.isNotBlank(buyerEntity.getId())) {
buyerEntity.setModifyTime(new Date());
int i = buyerMapper.updateBuyer(buyerEntity, shList);
if (i <= 0) {
r.put("message", "修改失败").put(OrderManagementConstant.CODE, ConfigureConstant.STRING_9999);
if("0".equals(t.getDefaultMark())){
buyerEntity.setAddress(t.getAddress());
buyerEntity.setPhone(t.getPhone());
buyerEntity.setBankNumber(t.getBankAccount());
buyerEntity.setBankOfDeposit(t.getBankName());
}
});
}
} else {
BuyerEntity buyerEntity1 = new BuyerEntity();
buyerEntity1.setBuyerCode(buyerEntity.getBuyerCode());
buyerEntity1.setTaxpayerCode(buyerEntity.getTaxpayerCode());
buyerEntity1.setPurchaseName(buyerEntity.getPurchaseName());
List<BuyerEntity> queryBuyerEntity = buyerMapper.selectBuyerByBuyerEntity(buyerEntity1, shList);
if (queryBuyerEntity != null && queryBuyerEntity.size() > 0) {
if (existBuyer != null) {//StringUtils.isNotBlank(buyerEntity.getId())
buyerEntity.setModifyTime(new Date());
buyerEntity.setBuyerCode(queryBuyerEntity.get(0).getBuyerCode());
buyerEntity.setId(queryBuyerEntity.get(0).getId());
//更新客户信息
//更新明细表,最好的办法是先删除后新增
buyerMapper.deleteBuyerDetail(buyerEntity.getId());
buyerMapper.batchInsertBuyerDetail(buyerEntity.getBuyerEntityDetail());
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);
log.info("{}添加开始执行开始执行 uuid = {}", LOGGER_MSG, buyerId);
buyerEntity.setId(buyerId);
buyerMapper.batchInsertBuyerDetail(buyerEntity.getBuyerEntityDetail());
int i = buyerMapper.insertBuyer(buyerEntity);
if (i <= 0) {
r.put("message", "添加失败").put(OrderManagementConstant.CODE, ConfigureConstant.STRING_9999);
}
}
}
return R.ok().put(OrderManagementConstant.MESSAGE, "保存成功!");
}

@ -25,6 +25,19 @@
<result column="invoice_taxno" jdbcType="VARCHAR" property="invoiceTaxno"/>
<result column="mdm_multicode_json" jdbcType="VARCHAR" property="mdmMulticodeJson"/>
<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>
<sql id="Buyer_Base_Column_List">
@ -35,28 +48,29 @@
<bind name="dataType" value="${dataType}"/>
<if test="dataType ==0 ">
SELECT
id,
taxpayer_code,
purchase_name,
address,
phone,
bank_of_deposit,
bank_number,
email,
sjh,
remarks,
create_user_id,
DATE_FORMAT(create_time, '%Y-%m-%d') createTime,
DATE_FORMAT(modify_time, '%Y-%m-%d') modifyTime,
modify_user_id,
ghf_qylx,
xhf_nsrsbh,
xhf_mc,
buyer_code,
create_time,
status
bmi.id,
bmi.taxpayer_code,
bmi.purchase_name,
bmi.address,
bmi.phone,
bmi.bank_of_deposit,
bmi.bank_number,
bmi.email,
bmi.sjh,
bmi.remarks,
bmi.create_user_id,
bmi.DATE_FORMAT(create_time, '%Y-%m-%d') createTime,
bmi.DATE_FORMAT(modify_time, '%Y-%m-%d') modifyTime,
bmi.modify_user_id,
bmi.ghf_qylx,
bmi.xhf_nsrsbh,
bmi.xhf_mc,
bmi.buyer_code,
bmi.create_time,
bmi.status,
bmid.*
FROM
buyer_manage_info
buyer_manage_info bmi left join buyer_manage_info_detail bmid on bmi.id = bmid.buyer_manage_id
<where>
<if test="shList != null and shList.size() == 0">
and xhf_nsrsbh = ''
@ -274,6 +288,88 @@
</if>
</where>
</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">
<bind name="dataType" value="${dataType}"/>

Loading…
Cancel
Save