add default issued

This commit is contained in:
东皇 2018-01-15 20:52:42 +08:00
parent fee5d97833
commit af5cc9777f

View File

@ -46,6 +46,8 @@ public class CustomerServiceSupport
private CustomerYearToDateSaleMapper customerYearToDateSaleMapper;
@Autowired
private ImportRecordMapper importRecordMapper;
@Autowired
private CustomerIssueMapper customerIssueMapper;
/**
* override find by id with find by search
@ -239,8 +241,10 @@ public class CustomerServiceSupport
private void createOrUpdateCustomer(final String operator, final Customer customer, final Date date) {
log.info("User [{}] create or update customer [{}].", operator, customer);
final String customerId = customer.getId();
final String ms = customer.getMs();
final Customer customerExisted = mapper.find(customer.getId());
final Customer customerExisted = mapper.find(customerId);
if (customerExisted != null) {
log.info("Customer existed [{}] found, update.", customerExisted);
// basic props
@ -248,7 +252,7 @@ public class CustomerServiceSupport
customerExisted.setCountryCode(customer.getCountryCode());
customerExisted.setState(customer.getState());
customerExisted.setCity(customer.getCity());
customerExisted.setMs(customer.getMs());
customerExisted.setMs(ms);
customerExisted.setRegion(customer.getRegion());
customerExisted.setSalesperson(customer.getSalesperson());
@ -267,6 +271,21 @@ public class CustomerServiceSupport
log.info("Create customer [{}].", customer);
mapper.insert(customer);
}
// no issues
if (customerIssueMapper.count(
new Search(CustomerIssue.CUSTOMER_ID, customerId)) < 1) {
CustomerIssue ci = new CustomerIssue();
ci.setId(idSeq.get());
ci.setCustomerId(customerId);
ci.setEnabled(true);
ci.setCreatedBy(operator);
ci.setDateCreated(now);
ci.setIssue("CA".equals(ms) ?
"General info:\\n\\nGlobal Project (for CA only):\\nCust. Core Business:\\nLEMO app:\\nLEMO rivals(%):\\nCust. staff qty:\\nCust. competitors:\\n" :
"General info:\\n\\nCust. Core Business:\\nLEMO app:\\nLEMO rivals(%):\\nCust. staff qty:\\nCust. competitors:\\n");
customerIssueMapper.insert(ci);
}
}
private void createOrUpdateCustomerPermissions(final String operator, final String customerId, final String strAccounts, Date date) {