|
|
|
@ -32,6 +32,7 @@ import com.kiisoo.ic.synchronous.entity.TurnBackDTO;
|
|
|
|
|
import com.kiisoo.ic.synchronous.entity.VipDataDTO;
|
|
|
|
|
import com.kiisoo.ic.system.enums.RoleEnum;
|
|
|
|
|
import com.kiisoo.ic.webappmy.vo.StafferInfoVO;
|
|
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
@ -51,6 +52,7 @@ import java.util.stream.Collectors;
|
|
|
|
|
* @Version: v1
|
|
|
|
|
*/
|
|
|
|
|
@Service
|
|
|
|
|
@Slf4j
|
|
|
|
|
public class CustomerService {
|
|
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
@ -159,6 +161,7 @@ public class CustomerService {
|
|
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
|
|
public void turnBack(TurnBackDTO turnBackDTOS){
|
|
|
|
|
if(turnBackDTOS.getWxData().getUnionId() == null || turnBackDTOS.getUserId() == null){
|
|
|
|
|
log.info("unionId 是空不操作");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
//客户信息
|
|
|
|
@ -170,10 +173,12 @@ public class CustomerService {
|
|
|
|
|
poiWrapper.eq("cp_user_id",turnBackDTOS.getUserId()).last("limit 1");
|
|
|
|
|
PrivilageCpUserStoreDO poiStore = privilageCpUserStoreDOMapper.selectOne(poiWrapper);
|
|
|
|
|
if(poiStore == null){
|
|
|
|
|
log.info("店铺信息是空的不操作");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
PoiStoreStaff poiStoreStaff = null;
|
|
|
|
|
if(!turnBackDTOS.getEaCode().equals("0")){
|
|
|
|
|
if(turnBackDTOS.getEaCode() == null || !turnBackDTOS.getEaCode().equals("0")){
|
|
|
|
|
log.info("导购code如果是0或者是空,不处理导购信息");
|
|
|
|
|
//导购信息
|
|
|
|
|
QueryWrapper<PoiStoreStaff> wrapper = new QueryWrapper<>();
|
|
|
|
|
wrapper.eq("staff_code",turnBackDTOS.getEaCode()).eq("store_id",poiStore.getStoreId()).last("limit 1");
|
|
|
|
@ -187,6 +192,7 @@ public class CustomerService {
|
|
|
|
|
insertCustomer.setAvatarUrl(turnBackDTOS.getWxData().getAvatarUrl());
|
|
|
|
|
insertCustomer.setPhone(turnBackDTOS.getPhone());
|
|
|
|
|
if(null != opCustomer){
|
|
|
|
|
log.info("客户信息存在就修改");
|
|
|
|
|
//更新一下
|
|
|
|
|
insertCustomer.setId(opCustomer.getId());
|
|
|
|
|
opCustomerDOMapper.updateById(insertCustomer);
|
|
|
|
@ -195,10 +201,12 @@ public class CustomerService {
|
|
|
|
|
sellerCustomerRelation(opCustomer,turnBackDTOS.getEaCode(),poiStore.getId(),poiStoreStaff.getUserId());
|
|
|
|
|
}
|
|
|
|
|
}else {
|
|
|
|
|
log.info("客户信息不存在在就新增");
|
|
|
|
|
insertCustomer.setCreateBy(Constants.SYS_OPERATION);
|
|
|
|
|
//不存在
|
|
|
|
|
opCustomerDOMapper.insert(insertCustomer);
|
|
|
|
|
if(poiStoreStaff != null) {
|
|
|
|
|
log.info("导购的信息没有就不添加导购客户的关系");
|
|
|
|
|
//添加关系
|
|
|
|
|
sellerCustomerRelation(insertCustomer, turnBackDTOS.getEaCode(), poiStore.getId(), poiStoreStaff.getUserId());
|
|
|
|
|
}
|
|
|
|
@ -206,6 +214,7 @@ public class CustomerService {
|
|
|
|
|
|
|
|
|
|
//处理客户vip的关系
|
|
|
|
|
if(turnBackDTOS.getVipData() != null){
|
|
|
|
|
log.info("如果有vip数据就认为是vip客户然后绑定客户vip关系");
|
|
|
|
|
//有vip数据就不需要重新请求bsd的vip接口
|
|
|
|
|
vipCheck(turnBackDTOS);
|
|
|
|
|
}
|
|
|
|
|