|  | @@ -1,16 +1,22 @@
 | 
	
		
			
				|  |  |  package com.ruoyi.basicData.service.impl;
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | +import com.alibaba.fastjson.JSONArray;
 | 
	
		
			
				|  |  | +import com.alibaba.fastjson.JSONObject;
 | 
	
		
			
				|  |  | +import com.baomidou.mybatisplus.mapper.EntityWrapper;
 | 
	
		
			
				|  |  |  import com.ruoyi.basicData.domain.TCorps;
 | 
	
		
			
				|  |  | +import com.ruoyi.basicData.domain.TCustomerContact;
 | 
	
		
			
				|  |  |  import com.ruoyi.basicData.mapper.TCorpsMapper;
 | 
	
		
			
				|  |  | +import com.ruoyi.basicData.mapper.TCustomerContactMapper;
 | 
	
		
			
				|  |  |  import com.ruoyi.basicData.service.ITCorpsService;
 | 
	
		
			
				|  |  | +import com.ruoyi.common.core.domain.AjaxResult;
 | 
	
		
			
				|  |  | +import com.ruoyi.common.core.domain.model.LoginUser;
 | 
	
		
			
				|  |  |  import com.ruoyi.common.utils.DateUtils;
 | 
	
		
			
				|  |  | +import com.ruoyi.common.utils.StringUtils;
 | 
	
		
			
				|  |  |  import org.springframework.beans.factory.annotation.Autowired;
 | 
	
		
			
				|  |  |  import org.springframework.stereotype.Service;
 | 
	
		
			
				|  |  |  import org.springframework.transaction.annotation.Transactional;
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -import java.util.HashMap;
 | 
	
		
			
				|  |  | -import java.util.List;
 | 
	
		
			
				|  |  | -import java.util.Map;
 | 
	
		
			
				|  |  | +import java.util.*;
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  /**
 | 
	
		
			
				|  |  |   * 客户详情Service业务层处理
 | 
	
	
		
			
				|  | @@ -23,8 +29,8 @@ public class TCorpsServiceImpl implements ITCorpsService {
 | 
	
		
			
				|  |  |      @Autowired
 | 
	
		
			
				|  |  |      private TCorpsMapper tCorpsMapper;
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -//    @Autowired
 | 
	
		
			
				|  |  | -//    private TCustomerContactMapper tCustomerContactMapper;
 | 
	
		
			
				|  |  | +    @Autowired
 | 
	
		
			
				|  |  | +    private TCustomerContactMapper tCustomerContactMapper;
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |      /**
 | 
	
		
			
				|  |  |       * 查询客户详情
 | 
	
	
		
			
				|  | @@ -37,8 +43,13 @@ public class TCorpsServiceImpl implements ITCorpsService {
 | 
	
		
			
				|  |  |      public Map<String, Object> selectTCorpsById(Long fId) {
 | 
	
		
			
				|  |  |          Map<String, Object> map = new HashMap<>();
 | 
	
		
			
				|  |  |          TCorps tCorps = tCorpsMapper.selectTCorpsById(fId);
 | 
	
		
			
				|  |  | -//        tCustomerContactMapper.se
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  | +        if (StringUtils.isNull(tCorps)) {
 | 
	
		
			
				|  |  | +            map.put("corp", tCorps);
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +        List<TCustomerContact> customerContactList = tCustomerContactMapper.selectList(new EntityWrapper<TCustomerContact>().eq("f_pid", fId));
 | 
	
		
			
				|  |  | +        if (StringUtils.isEmpty(customerContactList)) {
 | 
	
		
			
				|  |  | +            map.put("customerContact", customerContactList);
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  |          return map;
 | 
	
		
			
				|  |  |      }
 | 
	
		
			
				|  |  |  
 | 
	
	
		
			
				|  | @@ -56,13 +67,41 @@ public class TCorpsServiceImpl implements ITCorpsService {
 | 
	
		
			
				|  |  |      /**
 | 
	
		
			
				|  |  |       * 新增客户详情
 | 
	
		
			
				|  |  |       *
 | 
	
		
			
				|  |  | -     * @param tCorps 客户详情
 | 
	
		
			
				|  |  | +     * @param tCorps            客户详情
 | 
	
		
			
				|  |  | +     * @param tCustomerContacts 客户联系人
 | 
	
		
			
				|  |  | +     * @param loginUser         当前登陆人
 | 
	
		
			
				|  |  |       * @return 结果
 | 
	
		
			
				|  |  |       */
 | 
	
		
			
				|  |  |      @Override
 | 
	
		
			
				|  |  | -    public int insertTCorps(TCorps tCorps) {
 | 
	
		
			
				|  |  | -        tCorps.setCreateTime(DateUtils.getNowDate());
 | 
	
		
			
				|  |  | -        return tCorpsMapper.insertTCorps(tCorps);
 | 
	
		
			
				|  |  | +    @Transactional
 | 
	
		
			
				|  |  | +    public AjaxResult insertTCorps(String tCorps, String tCustomerContacts, LoginUser loginUser) {
 | 
	
		
			
				|  |  | +        if (StringUtils.isEmpty(tCorps)) {
 | 
	
		
			
				|  |  | +            return AjaxResult.error("提交失败:客户信息为空");
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +        if (StringUtils.isEmpty(tCustomerContacts)) {
 | 
	
		
			
				|  |  | +            return AjaxResult.error("提交失败:客户联系人为空");
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +        TCorps corps = JSONArray.parseObject(tCorps, TCorps.class);
 | 
	
		
			
				|  |  | +        JSONArray jsonArray = JSONArray.parseArray(tCustomerContacts);
 | 
	
		
			
				|  |  | +        List<TCustomerContact> customerContactList = JSONObject.parseArray(jsonArray.toJSONString(), TCustomerContact.class);
 | 
	
		
			
				|  |  | +        corps.setfStatus("0");
 | 
	
		
			
				|  |  | +        if (StringUtils.isNull(corps.getfId())) {
 | 
	
		
			
				|  |  | +            corps.setCreateBy(loginUser.getUser().getUserName());
 | 
	
		
			
				|  |  | +            corps.setCreateTime(new Date());
 | 
	
		
			
				|  |  | +            tCorpsMapper.insertTCorps(corps);
 | 
	
		
			
				|  |  | +        } else {
 | 
	
		
			
				|  |  | +            corps.setUpdateBy(loginUser.getUser().getUserName());
 | 
	
		
			
				|  |  | +            corps.setUpdateTime(new Date());
 | 
	
		
			
				|  |  | +            tCorpsMapper.updateById(corps);
 | 
	
		
			
				|  |  | +            tCustomerContactMapper.delete(new EntityWrapper<TCustomerContact>().eq("f_pid", corps.getfId()));
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +        for (TCustomerContact cc : customerContactList) {
 | 
	
		
			
				|  |  | +            cc.setfStatus("0");
 | 
	
		
			
				|  |  | +            cc.setCreateBy(loginUser.getUser().getUserName());
 | 
	
		
			
				|  |  | +            cc.setCreateTime(new Date());
 | 
	
		
			
				|  |  | +            tCustomerContactMapper.insertTCustomerContact(cc);
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +        return AjaxResult.success();
 | 
	
		
			
				|  |  |      }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |      /**
 |