客户回调接口

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.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);
} }

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

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

@ -1,7 +1,9 @@
package com.kiisoo.ic.synchronous.entity; 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 * @ClassName: VipDataDTO
* @Description: * @Description:
@ -39,7 +41,8 @@ public class VipDataDTO {
/** /**
* *
*/ */
private String register_time; @JsonProperty(value = "register_time")
private String registerTime;
public String getName() { public String getName() {
return name; return name;
@ -81,11 +84,11 @@ public class VipDataDTO {
this.level = level; this.level = level;
} }
public String getRegister_time() { public String getRegisterTime() {
return register_time; return registerTime;
} }
public void setRegister_time(String register_time) { public void setRegisterTime(String registerTime) {
this.register_time = register_time; this.registerTime = registerTime;
} }
} }

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

Loading…
Cancel
Save