|
|
@ -128,14 +128,14 @@ public class CustomerService {
|
|
|
|
insertCustomer.setCreateTime(opCustomer.getCreateTime());
|
|
|
|
insertCustomer.setCreateTime(opCustomer.getCreateTime());
|
|
|
|
if (null != opCustomer) {
|
|
|
|
if (null != opCustomer) {
|
|
|
|
//存在--1.处理客户导购关系。
|
|
|
|
//存在--1.处理客户导购关系。
|
|
|
|
sellerCustomerRelation(opCustomer, customerDTO.getStaffCode(),opCustomer.getCreateTime(), poiStore.getId(), poiStoreStaff.getUserId());
|
|
|
|
sellerCustomerRelation(opCustomer, opCustomer.getCreateTime(), poiStore.getId(), poiStoreStaff.getUserId());
|
|
|
|
return opCustomer.getId();
|
|
|
|
return opCustomer.getId();
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
insertCustomer.setCreateBy(Constants.SYS_OPERATION);
|
|
|
|
insertCustomer.setCreateBy(Constants.SYS_OPERATION);
|
|
|
|
//不存在
|
|
|
|
//不存在
|
|
|
|
opCustomerDOMapper.insert(insertCustomer);
|
|
|
|
opCustomerDOMapper.insert(insertCustomer);
|
|
|
|
//添加关系
|
|
|
|
//添加关系
|
|
|
|
sellerCustomerRelation(insertCustomer, customerDTO.getStaffCode(),insertCustomer.getCreateTime(), poiStore.getId(), poiStoreStaff.getUserId());
|
|
|
|
sellerCustomerRelation(insertCustomer, insertCustomer.getCreateTime(), poiStore.getId(), poiStoreStaff.getUserId());
|
|
|
|
return insertCustomer.getId();
|
|
|
|
return insertCustomer.getId();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -229,7 +229,7 @@ public class CustomerService {
|
|
|
|
if (poiStoreStaff != null) {
|
|
|
|
if (poiStoreStaff != null) {
|
|
|
|
//存在--1.处理客户导购关系。
|
|
|
|
//存在--1.处理客户导购关系。
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
sellerCustomerRelation(insertCustomer, turnBackDTOS.getEaCode(),sdf.parse(turnBackDTOS.getJoinTime()), poiStore.getStoreId(), poiStoreStaff.getId());
|
|
|
|
sellerCustomerRelation(insertCustomer, sdf.parse(turnBackDTOS.getJoinTime()), poiStore.getStoreId(), poiStoreStaff.getId());
|
|
|
|
}catch (Exception e) {
|
|
|
|
}catch (Exception e) {
|
|
|
|
log.error(insertCustomer.toString(),e);
|
|
|
|
log.error(insertCustomer.toString(),e);
|
|
|
|
return;
|
|
|
|
return;
|
|
|
@ -255,7 +255,7 @@ public class CustomerService {
|
|
|
|
if (poiStoreStaff != null) {
|
|
|
|
if (poiStoreStaff != null) {
|
|
|
|
//添加关系
|
|
|
|
//添加关系
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
sellerCustomerRelation(insertCustomer, turnBackDTOS.getEaCode(),sdf.parse(turnBackDTOS.getJoinTime()), poiStore.getStoreId(), poiStoreStaff.getId());
|
|
|
|
sellerCustomerRelation(insertCustomer, sdf.parse(turnBackDTOS.getJoinTime()), poiStore.getStoreId(), poiStoreStaff.getId());
|
|
|
|
}catch (Exception e) {
|
|
|
|
}catch (Exception e) {
|
|
|
|
log.error(insertCustomer.toString(),e);
|
|
|
|
log.error(insertCustomer.toString(),e);
|
|
|
|
return;
|
|
|
|
return;
|
|
|
@ -331,13 +331,10 @@ public class CustomerService {
|
|
|
|
* @param staffCode 导购Code
|
|
|
|
* @param staffCode 导购Code
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
|
public void sellerCustomerRelation(OpCustomer opCustomer, String staffCode,Date joinTime, long shopId, long sellerId) {
|
|
|
|
public void sellerCustomerRelation(OpCustomer opCustomer, 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");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
PoiStoreStaff poiStoreStaff = poiStoreStaffDOMapper.selectOne(staf);
|
|
|
|
|
|
|
|
QueryWrapper<OpSellerCustomerRelation> wrapper1 = new QueryWrapper<>();
|
|
|
|
QueryWrapper<OpSellerCustomerRelation> wrapper1 = new QueryWrapper<>();
|
|
|
|
wrapper1.eq("customer_id", opCustomer.getId()).eq("user_id", poiStoreStaff.getId()).eq("store_id", shopId).last("limit 1");
|
|
|
|
//一个客户只能添加一个店的店长微信,所以根据店铺判断即可
|
|
|
|
|
|
|
|
wrapper1.eq("customer_id", opCustomer.getId()).eq("store_id", shopId).last("limit 1");
|
|
|
|
OpSellerCustomerRelation opSellerCustomerRelation = opSellerCustomerRelationDOMapper.selectOne(wrapper1);
|
|
|
|
OpSellerCustomerRelation opSellerCustomerRelation = opSellerCustomerRelationDOMapper.selectOne(wrapper1);
|
|
|
|
if (null == opSellerCustomerRelation) {
|
|
|
|
if (null == opSellerCustomerRelation) {
|
|
|
|
//不存在就添加
|
|
|
|
//不存在就添加
|
|
|
@ -362,6 +359,16 @@ public class CustomerService {
|
|
|
|
insertRelation.setType(2);
|
|
|
|
insertRelation.setType(2);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
opSellerCustomerRelationDOMapper.insert(insertRelation);
|
|
|
|
opSellerCustomerRelationDOMapper.insert(insertRelation);
|
|
|
|
|
|
|
|
}else{
|
|
|
|
|
|
|
|
//可能是同步过来的数据,此时已经存在的话,用有导购的代替
|
|
|
|
|
|
|
|
opSellerCustomerRelation.setCreateTime(joinTime);
|
|
|
|
|
|
|
|
opSellerCustomerRelation.setUpdateTime(new Date());
|
|
|
|
|
|
|
|
opSellerCustomerRelation.setCustomerId(opCustomer.getId());
|
|
|
|
|
|
|
|
opSellerCustomerRelation.setStoreId(shopId);
|
|
|
|
|
|
|
|
opSellerCustomerRelation.setUserId(sellerId);
|
|
|
|
|
|
|
|
opSellerCustomerRelation.setCreateBy(Constants.SYS_OPERATION);
|
|
|
|
|
|
|
|
opSellerCustomerRelation.setUpdateBy(Constants.SYS_OPERATION);
|
|
|
|
|
|
|
|
opSellerCustomerRelationDOMapper.updateById(opSellerCustomerRelation);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|