客户回调接口

master
Caps 6 years ago
parent 0634f6fa6e
commit 53f256828d

@ -22,8 +22,10 @@ import com.kiisoo.ic.domain.service.PrivilageDomainService;
import com.kiisoo.ic.generalize.service.RetailCompanyService;
import com.kiisoo.ic.store.entity.PoiStore;
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.PoiStoreStaffDOMapper;
import com.kiisoo.ic.store.mapper.PrivilageCpUserStoreDOMapper;
import com.kiisoo.ic.store.service.PoiStoreService;
import com.kiisoo.ic.synchronous.entity.TurnBackDTO;
import com.kiisoo.ic.synchronous.entity.VipDataDTO;
@ -65,6 +67,9 @@ public class CustomerService {
@Autowired
private PoiStoreStaffDOMapper poiStoreStaffDOMapper;
@Autowired
private PrivilageCpUserStoreDOMapper privilageCpUserStoreDOMapper;
@Autowired
private PoiStoreService poiStoreService;
@ -153,94 +158,54 @@ public class CustomerService {
public void turnBack(TurnBackDTO turnBackDTOS){
//客户信息
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);
//店铺信息
QueryWrapper<PoiStore> poiWrapper = new QueryWrapper<>();
poiWrapper.eq("code",turnBackDTOS.getShop_code()).last("limit 1");
PoiStore poiStore = poiStoreDOMapper.selectOne(poiWrapper);
//导购信息
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){
QueryWrapper<PrivilageCpUserStoreDO> poiWrapper = new QueryWrapper<>();
poiWrapper.eq("cp_user_id",turnBackDTOS.getUserId()).last("limit 1");
PrivilageCpUserStoreDO poiStore = privilageCpUserStoreDOMapper.selectOne(poiWrapper);
if(poiStore == null){
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();
insertCustomer.setWechatUniId(turnBackDTOS.getWx_data().getUnit_id());
insertCustomer.setWechatUniId(turnBackDTOS.getWxData().getUnionId());
insertCustomer.setName(turnBackDTOS.getName());
insertCustomer.setAvatarUrl(turnBackDTOS.getWx_data().getAvatar_url());
insertCustomer.setAvatarUrl(turnBackDTOS.getWxData().getAvatarUrl());
insertCustomer.setPhone(turnBackDTOS.getPhone());
if(null != opCustomer){
//更新一下
insertCustomer.setId(opCustomer.getId());
opCustomerDOMapper.updateById(insertCustomer);
//存在--1.处理客户导购关系。
sellerCustomerRelation(opCustomer,turnBackDTOS.getEa_code(),poiStore.getId(),poiStoreStaff.getUserId());
if(poiStoreStaff != null){
//存在--1.处理客户导购关系。
sellerCustomerRelation(opCustomer,turnBackDTOS.getEaCode(),poiStore.getId(),poiStoreStaff.getUserId());
}
}else {
insertCustomer.setCreateBy(Constants.SYS_OPERATION);
//不存在
opCustomerDOMapper.insert(insertCustomer);
//添加关系
sellerCustomerRelation(insertCustomer,turnBackDTOS.getEa_code(),poiStore.getId(),poiStoreStaff.getUserId());
if(poiStoreStaff != null) {
//添加关系
sellerCustomerRelation(insertCustomer, turnBackDTOS.getEaCode(), poiStore.getId(), poiStoreStaff.getUserId());
}
}
//处理客户vip的关系
if(turnBackDTOS.getVip_data() != null){
if(turnBackDTOS.getVipData() != null){
//有vip数据就不需要重新请求bsd的vip接口
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
* @param turnBackDTO vip
@ -250,14 +215,14 @@ public class CustomerService {
opCustomer.setUpdateBy(Constants.SYS_OPERATION);
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 opVip1 = new OpVip();
opVip1.setStatus(1L);
opVip1.setPhone(turnBackDTO.getVip_data().getPhone());
opVip1.setName(turnBackDTO.getVip_data().getName());
opVip1.setBirthday(turnBackDTO.getVip_data().getBirthday());
opVip1.setRegisterTime(new Date(turnBackDTO.getVip_data().getRegister_time()));
opVip1.setPhone(turnBackDTO.getVipData().getPhone());
opVip1.setName(turnBackDTO.getVipData().getName());
opVip1.setBirthday(turnBackDTO.getVipData().getBirthday());
opVip1.setRegisterTime(new Date(turnBackDTO.getVipData().getRegisterTime()));
if(opVip == null){
//数据库没有这个数据--新建数据
opVip1.setCreateBy(Constants.SYS_OPERATION);
@ -274,7 +239,7 @@ public class CustomerService {
opCustomer.setMemberId(opVip.getId());
}
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);
}

@ -66,7 +66,7 @@ public class SynchronousController {
*
* @return
*/
@RequestMapping(value = "/ics/customer",method = RequestMethod.POST,consumes = "Application/json")
@RequestMapping(value = "/ics/customer",method = RequestMethod.POST,consumes = "application/json")
@ResponseBody
public String turnBack(@RequestBody List<TurnBackDTO> turnBackDTOS){
String str = JSON.toJSONString(turnBackDTOS);

@ -1,8 +1,7 @@
package com.kiisoo.ic.synchronous.entity;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.util.Date;
import com.alibaba.fastjson.annotation.JSONField;
import com.fasterxml.jackson.annotation.JsonProperty;
/**
* @ClassName: TurnBackDTO
@ -16,12 +15,14 @@ public class TurnBackDTO {
/**
* code
*/
private String shop_code;
@JsonProperty(value = "user_id")
private String userId;
/**
* 广
*/
private String ea_code;
@JsonProperty(value = "ea_code")
private String eaCode;
/**
* 广 1广 2广
@ -41,32 +42,35 @@ public class TurnBackDTO {
/**
*
*/
private String join_time;
@JsonProperty(value = "join_time")
private String joinTime;
/**
* id
*/
private WxDataDTO wx_data;
@JsonProperty(value = "wx_data")
private WxDataDTO wxData;
/**
*
*/
private VipDataDTO vip_data;
@JsonProperty(value = "vip_data")
private VipDataDTO vipData;
public String getShop_code() {
return shop_code;
public String getUserId() {
return userId;
}
public void setShop_code(String shop_code) {
this.shop_code = shop_code;
public void setUserId(String userId) {
this.userId = userId;
}
public String getEa_code() {
return ea_code;
public String getEaCode() {
return eaCode;
}
public void setEa_code(String ea_code) {
this.ea_code = ea_code;
public void setEaCode(String eaCode) {
this.eaCode = eaCode;
}
public int getType() {
@ -93,31 +97,27 @@ public class TurnBackDTO {
this.phone = phone;
}
public String getJoin_time() {
return join_time;
public String getJoinTime() {
return joinTime;
}
public void setJoin_time(String join_time) {
this.join_time = join_time;
public void setJoinTime(String joinTime) {
this.joinTime = joinTime;
}
public WxDataDTO getWx_data() {
return wx_data;
public WxDataDTO getWxData() {
return wxData;
}
public void setWx_data(WxDataDTO wx_data) {
this.wx_data = wx_data;
public void setWxData(WxDataDTO wxData) {
this.wxData = wxData;
}
public VipDataDTO getVip_data() {
return vip_data;
public VipDataDTO getVipData() {
return vipData;
}
public void setVip_data(VipDataDTO vip_data) {
this.vip_data = vip_data;
public void setVipData(VipDataDTO vipData) {
this.vipData = vipData;
}
//
// public Date getJoinTime() {
// return LocalDate.parse(this.join_time);
// }
}

@ -1,7 +1,9 @@
package com.kiisoo.ic.synchronous.entity;
import java.util.Date;
import com.alibaba.fastjson.annotation.JSONField;
import java.util.Date;
import com.fasterxml.jackson.annotation.JsonProperty;
/**
* @ClassName: VipDataDTO
* @Description:
@ -39,7 +41,8 @@ public class VipDataDTO {
/**
*
*/
private String register_time;
@JsonProperty(value = "register_time")
private String registerTime;
public String getName() {
return name;
@ -81,11 +84,11 @@ public class VipDataDTO {
this.level = level;
}
public String getRegister_time() {
return register_time;
public String getRegisterTime() {
return registerTime;
}
public void setRegister_time(String register_time) {
this.register_time = register_time;
public void setRegisterTime(String registerTime) {
this.registerTime = registerTime;
}
}

@ -1,5 +1,7 @@
package com.kiisoo.ic.synchronous.entity;
import com.alibaba.fastjson.annotation.JSONField;
import com.fasterxml.jackson.annotation.JsonProperty;
/**
* @ClassName: WxDataDTO
* @Description:
@ -12,52 +14,56 @@ public class WxDataDTO {
/**
* unit_id
*/
private String unit_id;
@JsonProperty(value = "union_id")
private String unionId;
/**
* open_id
*/
private String open_id;
@JsonProperty(value = "open_id")
private String openId;
/**
* user_id
*/
private String user_id;
@JsonProperty(value = "user_id")
private String userId;
/**
*
*/
private String avatar_url;
@JsonProperty(value = "avatar_url")
private String avatarUrl;
public String getAvatar_url() {
return avatar_url;
public String getUnionId() {
return unionId;
}
public void setAvatar_url(String avatar_url) {
this.avatar_url = avatar_url;
public void setUnionId(String unionId) {
this.unionId = unionId;
}
public String getUnit_id() {
return unit_id;
public String getOpenId() {
return openId;
}
public void setUnit_id(String unit_id) {
this.unit_id = unit_id;
public void setOpenId(String openId) {
this.openId = openId;
}
public String getOpen_id() {
return open_id;
public String getUserId() {
return userId;
}
public void setOpen_id(String open_id) {
this.open_id = open_id;
public void setUserId(String userId) {
this.userId = userId;
}
public String getUser_id() {
return user_id;
public String getAvatarUrl() {
return avatarUrl;
}
public void setUser_id(String user_id) {
this.user_id = user_id;
public void setAvatarUrl(String avatarUrl) {
this.avatarUrl = avatarUrl;
}
}

Loading…
Cancel
Save