|
|
@ -22,8 +22,10 @@ import com.kiisoo.ic.domain.service.PrivilageDomainService;
|
|
|
|
import com.kiisoo.ic.generalize.service.RetailCompanyService;
|
|
|
|
import com.kiisoo.ic.generalize.service.RetailCompanyService;
|
|
|
|
import com.kiisoo.ic.store.entity.PoiStore;
|
|
|
|
import com.kiisoo.ic.store.entity.PoiStore;
|
|
|
|
import com.kiisoo.ic.store.entity.PoiStoreStaff;
|
|
|
|
import com.kiisoo.ic.store.entity.PoiStoreStaff;
|
|
|
|
|
|
|
|
import com.kiisoo.ic.store.entity.PrivilageCpUserStoreDO;
|
|
|
|
import com.kiisoo.ic.store.mapper.PoiStoreDOMapper;
|
|
|
|
import com.kiisoo.ic.store.mapper.PoiStoreDOMapper;
|
|
|
|
import com.kiisoo.ic.store.mapper.PoiStoreStaffDOMapper;
|
|
|
|
import com.kiisoo.ic.store.mapper.PoiStoreStaffDOMapper;
|
|
|
|
|
|
|
|
import com.kiisoo.ic.store.mapper.PrivilageCpUserStoreDOMapper;
|
|
|
|
import com.kiisoo.ic.store.service.PoiStoreService;
|
|
|
|
import com.kiisoo.ic.store.service.PoiStoreService;
|
|
|
|
import com.kiisoo.ic.synchronous.entity.TurnBackDTO;
|
|
|
|
import com.kiisoo.ic.synchronous.entity.TurnBackDTO;
|
|
|
|
import com.kiisoo.ic.synchronous.entity.VipDataDTO;
|
|
|
|
import com.kiisoo.ic.synchronous.entity.VipDataDTO;
|
|
|
@ -65,6 +67,9 @@ public class CustomerService {
|
|
|
|
@Autowired
|
|
|
|
@Autowired
|
|
|
|
private PoiStoreStaffDOMapper poiStoreStaffDOMapper;
|
|
|
|
private PoiStoreStaffDOMapper poiStoreStaffDOMapper;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
|
|
|
|
private PrivilageCpUserStoreDOMapper privilageCpUserStoreDOMapper;
|
|
|
|
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
@Autowired
|
|
|
|
private PoiStoreService poiStoreService;
|
|
|
|
private PoiStoreService poiStoreService;
|
|
|
|
|
|
|
|
|
|
|
@ -153,94 +158,54 @@ public class CustomerService {
|
|
|
|
public void turnBack(TurnBackDTO turnBackDTOS){
|
|
|
|
public void turnBack(TurnBackDTO turnBackDTOS){
|
|
|
|
//客户信息
|
|
|
|
//客户信息
|
|
|
|
QueryWrapper<OpCustomer> customerWrapper = new QueryWrapper<>();
|
|
|
|
QueryWrapper<OpCustomer> customerWrapper = new QueryWrapper<>();
|
|
|
|
customerWrapper.eq("wechat_uni_id",turnBackDTOS.getWx_data().getUnit_id()).last("limit 1");
|
|
|
|
customerWrapper.eq("wechat_uni_id",turnBackDTOS.getWxData().getUnionId()).last("limit 1");
|
|
|
|
OpCustomer opCustomer = opCustomerDOMapper.selectOne(customerWrapper);
|
|
|
|
OpCustomer opCustomer = opCustomerDOMapper.selectOne(customerWrapper);
|
|
|
|
//店铺信息
|
|
|
|
//店铺信息
|
|
|
|
QueryWrapper<PoiStore> poiWrapper = new QueryWrapper<>();
|
|
|
|
QueryWrapper<PrivilageCpUserStoreDO> poiWrapper = new QueryWrapper<>();
|
|
|
|
poiWrapper.eq("code",turnBackDTOS.getShop_code()).last("limit 1");
|
|
|
|
poiWrapper.eq("cp_user_id",turnBackDTOS.getUserId()).last("limit 1");
|
|
|
|
PoiStore poiStore = poiStoreDOMapper.selectOne(poiWrapper);
|
|
|
|
PrivilageCpUserStoreDO poiStore = privilageCpUserStoreDOMapper.selectOne(poiWrapper);
|
|
|
|
//导购信息
|
|
|
|
if(poiStore == null){
|
|
|
|
QueryWrapper<PoiStoreStaff> wrapper = new QueryWrapper<>();
|
|
|
|
|
|
|
|
wrapper.eq("staff_code",turnBackDTOS.getEa_code()).eq("store_code",turnBackDTOS.getShop_code()).last("limit 1");
|
|
|
|
|
|
|
|
PoiStoreStaff poiStoreStaff = poiStoreStaffDOMapper.selectOne(wrapper);
|
|
|
|
|
|
|
|
if(poiStoreStaff == null || poiStore == null){
|
|
|
|
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
PoiStoreStaff poiStoreStaff = null;
|
|
|
|
|
|
|
|
if(!turnBackDTOS.getEaCode().equals("0")){
|
|
|
|
|
|
|
|
//导购信息
|
|
|
|
|
|
|
|
QueryWrapper<PoiStoreStaff> wrapper = new QueryWrapper<>();
|
|
|
|
|
|
|
|
wrapper.eq("staff_code",turnBackDTOS.getEaCode()).eq("store_id",poiStore.getStoreId()).last("limit 1");
|
|
|
|
|
|
|
|
poiStoreStaff = poiStoreStaffDOMapper.selectOne(wrapper);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//做插入使用 --如果没有客户信息就先创建客户信息如果有就判断是否有客户导购得关系,如果没有就添加有就不管
|
|
|
|
//做插入使用 --如果没有客户信息就先创建客户信息如果有就判断是否有客户导购得关系,如果没有就添加有就不管
|
|
|
|
OpCustomer insertCustomer = new OpCustomer();
|
|
|
|
OpCustomer insertCustomer = new OpCustomer();
|
|
|
|
insertCustomer.setWechatUniId(turnBackDTOS.getWx_data().getUnit_id());
|
|
|
|
insertCustomer.setWechatUniId(turnBackDTOS.getWxData().getUnionId());
|
|
|
|
insertCustomer.setName(turnBackDTOS.getName());
|
|
|
|
insertCustomer.setName(turnBackDTOS.getName());
|
|
|
|
insertCustomer.setAvatarUrl(turnBackDTOS.getWx_data().getAvatar_url());
|
|
|
|
insertCustomer.setAvatarUrl(turnBackDTOS.getWxData().getAvatarUrl());
|
|
|
|
insertCustomer.setPhone(turnBackDTOS.getPhone());
|
|
|
|
insertCustomer.setPhone(turnBackDTOS.getPhone());
|
|
|
|
if(null != opCustomer){
|
|
|
|
if(null != opCustomer){
|
|
|
|
//更新一下
|
|
|
|
//更新一下
|
|
|
|
insertCustomer.setId(opCustomer.getId());
|
|
|
|
insertCustomer.setId(opCustomer.getId());
|
|
|
|
opCustomerDOMapper.updateById(insertCustomer);
|
|
|
|
opCustomerDOMapper.updateById(insertCustomer);
|
|
|
|
//存在--1.处理客户导购关系。
|
|
|
|
if(poiStoreStaff != null){
|
|
|
|
sellerCustomerRelation(opCustomer,turnBackDTOS.getEa_code(),poiStore.getId(),poiStoreStaff.getUserId());
|
|
|
|
//存在--1.处理客户导购关系。
|
|
|
|
|
|
|
|
sellerCustomerRelation(opCustomer,turnBackDTOS.getEaCode(),poiStore.getId(),poiStoreStaff.getUserId());
|
|
|
|
|
|
|
|
}
|
|
|
|
}else {
|
|
|
|
}else {
|
|
|
|
insertCustomer.setCreateBy(Constants.SYS_OPERATION);
|
|
|
|
insertCustomer.setCreateBy(Constants.SYS_OPERATION);
|
|
|
|
//不存在
|
|
|
|
//不存在
|
|
|
|
opCustomerDOMapper.insert(insertCustomer);
|
|
|
|
opCustomerDOMapper.insert(insertCustomer);
|
|
|
|
//添加关系
|
|
|
|
if(poiStoreStaff != null) {
|
|
|
|
sellerCustomerRelation(insertCustomer,turnBackDTOS.getEa_code(),poiStore.getId(),poiStoreStaff.getUserId());
|
|
|
|
//添加关系
|
|
|
|
|
|
|
|
sellerCustomerRelation(insertCustomer, turnBackDTOS.getEaCode(), poiStore.getId(), poiStoreStaff.getUserId());
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//处理客户vip的关系
|
|
|
|
//处理客户vip的关系
|
|
|
|
if(turnBackDTOS.getVip_data() != null){
|
|
|
|
if(turnBackDTOS.getVipData() != null){
|
|
|
|
//有vip数据就不需要重新请求bsd的vip接口
|
|
|
|
//有vip数据就不需要重新请求bsd的vip接口
|
|
|
|
vipCheck(turnBackDTOS);
|
|
|
|
vipCheck(turnBackDTOS);
|
|
|
|
//查询是否有这个vip如果有就绑定关系如果没有就先添加vip然后再绑定关系
|
|
|
|
|
|
|
|
}else {
|
|
|
|
|
|
|
|
//需要请求bsd的vip接口获取vip数据
|
|
|
|
|
|
|
|
JSONObject jsonObject2 = JSON.parseObject(HttpClientUtil.httpGet("http://vtest.bsd.cn/BSD_WXAPP/miniProgram/getMemberDtlByUnionId?token=" + TOKEN + "&unionId=" + turnBackDTOS.getWx_data().getUnit_id()).getMessage());
|
|
|
|
|
|
|
|
VipDataDTO vipDataDTO = new VipDataDTO();
|
|
|
|
|
|
|
|
vipDataDTO.setBirthday(jsonObject2.getDate("birthday"));
|
|
|
|
|
|
|
|
vipDataDTO.setName(jsonObject2.getString("memberName"));
|
|
|
|
|
|
|
|
vipDataDTO.setPhone(jsonObject2.getString("mobileNo"));
|
|
|
|
|
|
|
|
vipDataDTO.setRegister_time(String.valueOf(LocalDate.now()));
|
|
|
|
|
|
|
|
vipData(vipDataDTO,turnBackDTOS.getWx_data().getUnit_id());
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
|
|
* 添加会员数据
|
|
|
|
|
|
|
|
* @param vipDataDTO
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
private void vipData(VipDataDTO vipDataDTO, String unionId){
|
|
|
|
|
|
|
|
OpCustomer opCustomer = new OpCustomer(vipDataDTO.getName(),vipDataDTO.getPhone());
|
|
|
|
|
|
|
|
opCustomer.setUpdateBy(Constants.SYS_OPERATION);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
QueryWrapper<OpVip> wrapper = new QueryWrapper<>();
|
|
|
|
|
|
|
|
wrapper.eq("phone",vipDataDTO.getPhone()).eq("name",vipDataDTO.getName());
|
|
|
|
|
|
|
|
OpVip opVip = opVipDOMapper.selectOne(wrapper);
|
|
|
|
|
|
|
|
OpVip opVip1 = new OpVip();
|
|
|
|
|
|
|
|
opVip1.setStatus(1L);
|
|
|
|
|
|
|
|
opVip1.setPhone(vipDataDTO.getPhone());
|
|
|
|
|
|
|
|
opVip1.setName(vipDataDTO.getName());
|
|
|
|
|
|
|
|
opVip1.setBirthday(vipDataDTO.getBirthday());
|
|
|
|
|
|
|
|
opVip1.setRegisterTime(new Date(vipDataDTO.getRegister_time()));
|
|
|
|
|
|
|
|
if(opVip == null){
|
|
|
|
|
|
|
|
//数据库没有这个数据--新建数据
|
|
|
|
|
|
|
|
opVip1.setCreateTime(new Date());
|
|
|
|
|
|
|
|
opVip1.setCreateBy(Constants.SYS_OPERATION);
|
|
|
|
|
|
|
|
opVipDOMapper.insert(opVip1);
|
|
|
|
|
|
|
|
//有vip信息就绑定信息
|
|
|
|
|
|
|
|
opCustomer.setMemberId(opVip1.getId());
|
|
|
|
|
|
|
|
}else {
|
|
|
|
|
|
|
|
opVip1.setId(opVip.getId());
|
|
|
|
|
|
|
|
opVip1.setUpdateTime(new Date());
|
|
|
|
|
|
|
|
opVip1.setUpdateBy(Constants.SYS_OPERATION);
|
|
|
|
|
|
|
|
opVipDOMapper.updateById(opVip1);
|
|
|
|
|
|
|
|
//有vip信息就绑定信息
|
|
|
|
|
|
|
|
opCustomer.setMemberId(opVip.getId());
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
QueryWrapper<OpCustomer> wrapper1 = new QueryWrapper<>();
|
|
|
|
|
|
|
|
wrapper1.eq("wechat_uni_id",unionId);
|
|
|
|
|
|
|
|
opCustomerDOMapper.update(opCustomer,wrapper1);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* vip数据检验
|
|
|
|
* vip数据检验
|
|
|
|
* @param turnBackDTO vip数据
|
|
|
|
* @param turnBackDTO vip数据
|
|
|
@ -250,14 +215,14 @@ public class CustomerService {
|
|
|
|
opCustomer.setUpdateBy(Constants.SYS_OPERATION);
|
|
|
|
opCustomer.setUpdateBy(Constants.SYS_OPERATION);
|
|
|
|
|
|
|
|
|
|
|
|
QueryWrapper<OpVip> wrapper = new QueryWrapper<>();
|
|
|
|
QueryWrapper<OpVip> wrapper = new QueryWrapper<>();
|
|
|
|
wrapper.eq("phone",turnBackDTO.getVip_data().getPhone()).eq("name",turnBackDTO.getVip_data().getName());
|
|
|
|
wrapper.eq("phone",turnBackDTO.getVipData().getPhone()).eq("name",turnBackDTO.getVipData().getName());
|
|
|
|
OpVip opVip = opVipDOMapper.selectOne(wrapper);
|
|
|
|
OpVip opVip = opVipDOMapper.selectOne(wrapper);
|
|
|
|
OpVip opVip1 = new OpVip();
|
|
|
|
OpVip opVip1 = new OpVip();
|
|
|
|
opVip1.setStatus(1L);
|
|
|
|
opVip1.setStatus(1L);
|
|
|
|
opVip1.setPhone(turnBackDTO.getVip_data().getPhone());
|
|
|
|
opVip1.setPhone(turnBackDTO.getVipData().getPhone());
|
|
|
|
opVip1.setName(turnBackDTO.getVip_data().getName());
|
|
|
|
opVip1.setName(turnBackDTO.getVipData().getName());
|
|
|
|
opVip1.setBirthday(turnBackDTO.getVip_data().getBirthday());
|
|
|
|
opVip1.setBirthday(turnBackDTO.getVipData().getBirthday());
|
|
|
|
opVip1.setRegisterTime(new Date(turnBackDTO.getVip_data().getRegister_time()));
|
|
|
|
opVip1.setRegisterTime(new Date(turnBackDTO.getVipData().getRegisterTime()));
|
|
|
|
if(opVip == null){
|
|
|
|
if(opVip == null){
|
|
|
|
//数据库没有这个数据--新建数据
|
|
|
|
//数据库没有这个数据--新建数据
|
|
|
|
opVip1.setCreateBy(Constants.SYS_OPERATION);
|
|
|
|
opVip1.setCreateBy(Constants.SYS_OPERATION);
|
|
|
@ -274,7 +239,7 @@ public class CustomerService {
|
|
|
|
opCustomer.setMemberId(opVip.getId());
|
|
|
|
opCustomer.setMemberId(opVip.getId());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
QueryWrapper<OpCustomer> wrapper1 = new QueryWrapper<>();
|
|
|
|
QueryWrapper<OpCustomer> wrapper1 = new QueryWrapper<>();
|
|
|
|
wrapper1.eq("wechat_uni_id",turnBackDTO.getWx_data().getUnit_id());
|
|
|
|
wrapper1.eq("wechat_uni_id",turnBackDTO.getWxData().getUnionId());
|
|
|
|
opCustomerDOMapper.update(opCustomer,wrapper1);
|
|
|
|
opCustomerDOMapper.update(opCustomer,wrapper1);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|