|
|
|
|
@ -41,7 +41,9 @@ import org.springblade.modules.jinchao.excel.CustomerExcel; |
|
|
|
|
import org.springblade.modules.jinchao.mapper.CustomerMapper; |
|
|
|
|
import org.springblade.modules.jinchao.service.IContactService; |
|
|
|
|
import org.springblade.modules.jinchao.service.ICustomerService; |
|
|
|
|
import org.springblade.modules.system.pojo.entity.User; |
|
|
|
|
import org.springblade.modules.system.service.IDictService; |
|
|
|
|
import org.springblade.modules.system.service.IUserService; |
|
|
|
|
import org.springframework.beans.BeanUtils; |
|
|
|
|
import org.springframework.stereotype.Service; |
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.Wrapper; |
|
|
|
|
@ -70,6 +72,8 @@ public class CustomerServiceImpl extends BaseServiceImpl<CustomerMapper, Custome |
|
|
|
|
private IContactService contactService; |
|
|
|
|
@Resource |
|
|
|
|
private IDictService dictService; |
|
|
|
|
@Resource |
|
|
|
|
private IUserService userService; |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public IPage<CustomerVO> selectCustomerPage(IPage<CustomerVO> page, CustomerVO customer) { |
|
|
|
|
@ -91,19 +95,19 @@ public class CustomerServiceImpl extends BaseServiceImpl<CustomerMapper, Custome |
|
|
|
|
if (submit.getContacts() == null || submit.getContacts().isEmpty()) { |
|
|
|
|
return R.fail("contacts为空"); |
|
|
|
|
} |
|
|
|
|
CustomerEntity cu = new CustomerEntity(); |
|
|
|
|
BeanUtils.copyProperties(submit, cu); |
|
|
|
|
boolean save = save(cu); |
|
|
|
|
CustomerEntity c = new CustomerEntity(); |
|
|
|
|
BeanUtils.copyProperties(submit, c); |
|
|
|
|
boolean save = save(c); |
|
|
|
|
for (int i = 0; i < submit.getContacts().size(); i++) { |
|
|
|
|
ContactEntity co = submit.getContacts().get(i); |
|
|
|
|
co.setId(null); |
|
|
|
|
if (i == 1) { |
|
|
|
|
if (i == 0) { |
|
|
|
|
co.setContactType(ContactConst.TYPE_MAIN); |
|
|
|
|
} else { |
|
|
|
|
co.setContactType(ContactConst.TYPE_SECONDARY); |
|
|
|
|
} |
|
|
|
|
co.setSort(i); |
|
|
|
|
co.setCustomerId(cu.getId()); |
|
|
|
|
co.setSort(i + 1); |
|
|
|
|
co.setCustomerId(c.getId()); |
|
|
|
|
} |
|
|
|
|
contactService.saveBatch(submit.getContacts()); |
|
|
|
|
return R.status(save); |
|
|
|
|
@ -116,25 +120,29 @@ public class CustomerServiceImpl extends BaseServiceImpl<CustomerMapper, Custome |
|
|
|
|
} |
|
|
|
|
CustomerEntity cu = new CustomerEntity(); |
|
|
|
|
BeanUtils.copyProperties(submit, cu); |
|
|
|
|
boolean save = updateById(cu); |
|
|
|
|
// 更新客户
|
|
|
|
|
boolean update = updateById(cu); |
|
|
|
|
// List<ContactEntity> existList = contactService.list(
|
|
|
|
|
// new QueryWrapper<ContactEntity>().eq("", "")
|
|
|
|
|
// );
|
|
|
|
|
for (int i = 0; i < submit.getContacts().size(); i++) { |
|
|
|
|
ContactEntity co = submit.getContacts().get(i); |
|
|
|
|
co.setCustomerId(cu.getId()); |
|
|
|
|
if (co.getSort() == null || co.getSort() == 0L) { |
|
|
|
|
co.setSort(i); |
|
|
|
|
co.setSort(i + 1); |
|
|
|
|
} |
|
|
|
|
if (co.getContactType() == null || co.getContactType() == 0L) { |
|
|
|
|
co.setContactType(ContactConst.TYPE_SECONDARY); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
contactService.saveOrUpdateBatch(submit.getContacts()); |
|
|
|
|
return R.status(save); |
|
|
|
|
return R.status(update); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public IPage<CustomerVO> search(IPage<CustomerVO> page, CustomerSearch search) { |
|
|
|
|
IPage<CustomerVO> pagesVo = page.setRecords(baseMapper.searchPage(page, search)); |
|
|
|
|
pagesVo.getRecords().stream().peek(this::setVoValue).collect(Collectors.toList()); |
|
|
|
|
pagesVo.getRecords().stream().peek(this::setVoValueMain).collect(Collectors.toList()); |
|
|
|
|
return pagesVo; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@ -147,7 +155,7 @@ public class CustomerServiceImpl extends BaseServiceImpl<CustomerMapper, Custome |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public void setVoValue(CustomerVO vo) { |
|
|
|
|
public void setVoValueMain(CustomerVO vo) { |
|
|
|
|
vo.setCountryValue(dictService.getValue(ContactConst.DICT_CUSTOMER_COUNTRY, vo.getCountry())); |
|
|
|
|
vo.setFromTypeValue(dictService.getValue(ContactConst.DICT_CUSTOMER_FROM_TYPE, vo.getFromType())); |
|
|
|
|
{ |
|
|
|
|
@ -160,5 +168,21 @@ public class CustomerServiceImpl extends BaseServiceImpl<CustomerMapper, Custome |
|
|
|
|
vo.setContactMain(contactF); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
{ |
|
|
|
|
User uC = userService.getById(vo.getCreateUser()); |
|
|
|
|
if (uC != null) { |
|
|
|
|
vo.setCreateUserRealName(uC.getRealName()); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public void setVoValueDetail(CustomerSubmit submit) { |
|
|
|
|
List<ContactEntity> list = contactService.list( |
|
|
|
|
new QueryWrapper<ContactEntity>() |
|
|
|
|
.eq("customer_id", submit.getId()) |
|
|
|
|
.orderByAsc("sort") |
|
|
|
|
); |
|
|
|
|
submit.setContacts(list); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|