|
|
|
@ -117,16 +117,17 @@ public class CustomerService {
|
|
|
|
|
insertCustomer.setExternalUserid(customerDTO.getExternalUserid());
|
|
|
|
|
String customerName = EmployeeService.filterEmoji(customerDTO.getName());
|
|
|
|
|
insertCustomer.setName(customerName);
|
|
|
|
|
insertCustomer.setCreateTime(opCustomer.getCreateTime());
|
|
|
|
|
if (null != opCustomer) {
|
|
|
|
|
//存在--1.处理客户导购关系。
|
|
|
|
|
sellerCustomerRelation(opCustomer, customerDTO.getStaffCode(), poiStore.getId(), poiStoreStaff.getUserId());
|
|
|
|
|
sellerCustomerRelation(opCustomer, customerDTO.getStaffCode(),opCustomer.getCreateTime(), poiStore.getId(), poiStoreStaff.getUserId());
|
|
|
|
|
return opCustomer.getId();
|
|
|
|
|
} else {
|
|
|
|
|
insertCustomer.setCreateBy(Constants.SYS_OPERATION);
|
|
|
|
|
//不存在
|
|
|
|
|
opCustomerDOMapper.insert(insertCustomer);
|
|
|
|
|
//添加关系
|
|
|
|
|
sellerCustomerRelation(insertCustomer, customerDTO.getStaffCode(), poiStore.getId(), poiStoreStaff.getUserId());
|
|
|
|
|
sellerCustomerRelation(insertCustomer, customerDTO.getStaffCode(),insertCustomer.getCreateTime(), poiStore.getId(), poiStoreStaff.getUserId());
|
|
|
|
|
return insertCustomer.getId();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
@ -203,9 +204,9 @@ public class CustomerService {
|
|
|
|
|
}
|
|
|
|
|
if (poiStoreStaff != null) {
|
|
|
|
|
//存在--1.处理客户导购关系。
|
|
|
|
|
sellerCustomerRelation(opCustomer, turnBackDTOS.getEaCode(), poiStore.getStoreId(), poiStoreStaff.getId());
|
|
|
|
|
sellerCustomerRelation(opCustomer, turnBackDTOS.getEaCode(),sdf.parse(turnBackDTOS.getJoinTime()), poiStore.getStoreId(), poiStoreStaff.getId());
|
|
|
|
|
} else {
|
|
|
|
|
storeCustomerRelation(opCustomer, poiStore.getStoreId());
|
|
|
|
|
storeCustomerRelation(opCustomer,sdf.parse(turnBackDTOS.getJoinTime()), poiStore.getStoreId());
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
insertCustomer.setCreateBy(Constants.SYS_OPERATION);
|
|
|
|
@ -219,9 +220,9 @@ public class CustomerService {
|
|
|
|
|
|
|
|
|
|
if (poiStoreStaff != null) {
|
|
|
|
|
//添加关系
|
|
|
|
|
sellerCustomerRelation(insertCustomer, turnBackDTOS.getEaCode(), poiStore.getStoreId(), poiStoreStaff.getId());
|
|
|
|
|
sellerCustomerRelation(insertCustomer, turnBackDTOS.getEaCode(),sdf.parse(turnBackDTOS.getJoinTime()), poiStore.getStoreId(), poiStoreStaff.getId());
|
|
|
|
|
} else {
|
|
|
|
|
storeCustomerRelation(insertCustomer, poiStore.getStoreId());
|
|
|
|
|
storeCustomerRelation(insertCustomer, sdf.parse(turnBackDTOS.getJoinTime()),poiStore.getStoreId());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -278,7 +279,7 @@ public class CustomerService {
|
|
|
|
|
* @param opCustomer 客户的数据信息
|
|
|
|
|
* @param staffCode 导购Code
|
|
|
|
|
*/
|
|
|
|
|
private void sellerCustomerRelation(OpCustomer opCustomer, String staffCode, long shopId, long sellerId) {
|
|
|
|
|
private void sellerCustomerRelation(OpCustomer opCustomer, String staffCode,Date joinTime, long shopId, long sellerId) {
|
|
|
|
|
QueryWrapper<PoiStoreStaff> staf = new QueryWrapper<PoiStoreStaff>();
|
|
|
|
|
staf.eq("staff_code", staffCode).eq("status", 1).ne("user_id", 0).last("limit 1");
|
|
|
|
|
|
|
|
|
@ -289,7 +290,7 @@ public class CustomerService {
|
|
|
|
|
if (null == opSellerCustomerRelation) {
|
|
|
|
|
//不存在就添加
|
|
|
|
|
OpSellerCustomerRelation insertRelation = new OpSellerCustomerRelation();
|
|
|
|
|
insertRelation.setCreateTime(new Date());
|
|
|
|
|
insertRelation.setCreateTime(joinTime);
|
|
|
|
|
insertRelation.setUpdateTime(new Date());
|
|
|
|
|
insertRelation.setCustomerId(opCustomer.getId());
|
|
|
|
|
insertRelation.setStoreId(shopId);
|
|
|
|
@ -312,14 +313,14 @@ public class CustomerService {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void storeCustomerRelation(OpCustomer opCustomer, long shopId) {
|
|
|
|
|
private void storeCustomerRelation(OpCustomer opCustomer, Date joinTime,long shopId) {
|
|
|
|
|
QueryWrapper<OpSellerCustomerRelation> wrapper1 = new QueryWrapper<>();
|
|
|
|
|
wrapper1.eq("customer_id", opCustomer.getId()).eq("store_id", shopId).last("limit 1");
|
|
|
|
|
OpSellerCustomerRelation opSellerCustomerRelation = opSellerCustomerRelationDOMapper.selectOne(wrapper1);
|
|
|
|
|
if (null == opSellerCustomerRelation) {
|
|
|
|
|
//不存在就添加
|
|
|
|
|
OpSellerCustomerRelation insertRelation = new OpSellerCustomerRelation();
|
|
|
|
|
insertRelation.setCreateTime(new Date());
|
|
|
|
|
insertRelation.setCreateTime(joinTime);
|
|
|
|
|
insertRelation.setUpdateTime(new Date());
|
|
|
|
|
insertRelation.setCustomerId(opCustomer.getId());
|
|
|
|
|
insertRelation.setStoreId(shopId);
|
|
|
|
|