|
|
@ -7,6 +7,8 @@ import com.kiisoo.ic.customer.entity.OpVip;
|
|
|
|
import com.kiisoo.ic.customer.mapper.OpCustomerDOMapper;
|
|
|
|
import com.kiisoo.ic.customer.mapper.OpCustomerDOMapper;
|
|
|
|
import com.kiisoo.ic.customer.mapper.OpSellerCustomerRelationDOMapper;
|
|
|
|
import com.kiisoo.ic.customer.mapper.OpSellerCustomerRelationDOMapper;
|
|
|
|
import com.kiisoo.ic.customer.mapper.OpVipDOMapper;
|
|
|
|
import com.kiisoo.ic.customer.mapper.OpVipDOMapper;
|
|
|
|
|
|
|
|
import com.kiisoo.ic.store.entity.PoiStoreStaff;
|
|
|
|
|
|
|
|
import com.kiisoo.ic.store.mapper.PoiStoreStaffDOMapper;
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
@ -29,33 +31,38 @@ public class CustomerService {
|
|
|
|
|
|
|
|
|
|
|
|
private final OpVipDOMapper opVipDOMapper;
|
|
|
|
private final OpVipDOMapper opVipDOMapper;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private final PoiStoreStaffDOMapper poiStoreStaffDOMapper;
|
|
|
|
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
@Autowired
|
|
|
|
public CustomerService(OpCustomerDOMapper opCustomerDOMapper, OpSellerCustomerRelationDOMapper opSellerCustomerRelationDOMapper, OpVipDOMapper opVipDOMapper) {
|
|
|
|
public CustomerService(OpCustomerDOMapper opCustomerDOMapper, OpSellerCustomerRelationDOMapper opSellerCustomerRelationDOMapper, OpVipDOMapper opVipDOMapper, PoiStoreStaffDOMapper poiStoreStaffDOMapper) {
|
|
|
|
this.opCustomerDOMapper = opCustomerDOMapper;
|
|
|
|
this.opCustomerDOMapper = opCustomerDOMapper;
|
|
|
|
this.opSellerCustomerRelationDOMapper = opSellerCustomerRelationDOMapper;
|
|
|
|
this.opSellerCustomerRelationDOMapper = opSellerCustomerRelationDOMapper;
|
|
|
|
this.opVipDOMapper = opVipDOMapper;
|
|
|
|
this.opVipDOMapper = opVipDOMapper;
|
|
|
|
|
|
|
|
this.poiStoreStaffDOMapper = poiStoreStaffDOMapper;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* 绑定客户的关系
|
|
|
|
* 绑定客户的关系
|
|
|
|
* @param openId 微信openId
|
|
|
|
* @param uniId 微信uniId
|
|
|
|
* @param sellerId 分享码的导购id
|
|
|
|
* @param staffCode 分享码的导购Code
|
|
|
|
* @param shopId 导购所在的店铺id
|
|
|
|
|
|
|
|
* @Description: 根据客户联系方式查询客户id 1.判断客户是否存在,不存在就添加,存在就进行下一步 2.判断客户id和导购是否绑定了关系如果绑定了就直接下一步,如果没有就绑定 3.判断客户id和vip是否绑定了关系如果绑定了就直接下一步,如果没有就绑定
|
|
|
|
* @Description: 根据客户联系方式查询客户id 1.判断客户是否存在,不存在就添加,存在就进行下一步 2.判断客户id和导购是否绑定了关系如果绑定了就直接下一步,如果没有就绑定 3.判断客户id和vip是否绑定了关系如果绑定了就直接下一步,如果没有就绑定
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
|
@Deprecated
|
|
|
|
@Deprecated
|
|
|
|
public void customerRelation(String openId,long sellerId,long shopId){
|
|
|
|
public void customerRelation(String uniId,String staffCode){
|
|
|
|
QueryWrapper<OpCustomer> wrapper = new QueryWrapper<>();
|
|
|
|
QueryWrapper<OpCustomer> customerWrapper = new QueryWrapper<>();
|
|
|
|
wrapper.eq("wechat_open_id",openId).last("limit 1");
|
|
|
|
customerWrapper.eq("wechat_uni_id",uniId).last("limit 1");
|
|
|
|
OpCustomer opCustomer = opCustomerDOMapper.selectOne(wrapper);
|
|
|
|
OpCustomer opCustomer = opCustomerDOMapper.selectOne(customerWrapper);
|
|
|
|
|
|
|
|
QueryWrapper<PoiStoreStaff> poiWrapper = new QueryWrapper<>();
|
|
|
|
|
|
|
|
poiWrapper.eq("staff_code",staffCode).last("limit 1");
|
|
|
|
|
|
|
|
PoiStoreStaff poiStoreStaff = poiStoreStaffDOMapper.selectOne(poiWrapper);
|
|
|
|
if(null != opCustomer){
|
|
|
|
if(null != opCustomer){
|
|
|
|
//存在--1.处理客户导购关系。2.处理客户和vip关系(待定)
|
|
|
|
//存在--1.处理客户导购关系。2.处理客户和vip关系(待定)
|
|
|
|
sellerCustomerRelation(opCustomer,sellerId,shopId);
|
|
|
|
sellerCustomerRelation(opCustomer,staffCode,poiStoreStaff.getStoreId(),poiStoreStaff.getUserId());
|
|
|
|
}else {
|
|
|
|
}else {
|
|
|
|
//不存在
|
|
|
|
//不存在
|
|
|
|
OpCustomer insertCustomer = new OpCustomer();
|
|
|
|
OpCustomer insertCustomer = new OpCustomer();
|
|
|
|
insertCustomer.setWechatOpenId(openId);
|
|
|
|
insertCustomer.setWechatUniId(uniId);
|
|
|
|
opCustomerDOMapper.insert(insertCustomer);
|
|
|
|
opCustomerDOMapper.insert(insertCustomer);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -88,11 +95,11 @@ public class CustomerService {
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* 处理客户和导购的关系
|
|
|
|
* 处理客户和导购的关系
|
|
|
|
* @param opCustomer 客户的数据信息
|
|
|
|
* @param opCustomer 客户的数据信息
|
|
|
|
* @param sellerId 导购id
|
|
|
|
* @param staffCode 导购Code
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
private void sellerCustomerRelation(OpCustomer opCustomer,long sellerId,long shopId){
|
|
|
|
private void sellerCustomerRelation(OpCustomer opCustomer,String staffCode,long shopId,long sellerId){
|
|
|
|
QueryWrapper<OpSellerCustomerRelation> wrapper1 = new QueryWrapper<>();
|
|
|
|
QueryWrapper<OpSellerCustomerRelation> wrapper1 = new QueryWrapper<>();
|
|
|
|
wrapper1.eq("customer_id",opCustomer.getId()).eq("user_id",sellerId).eq("store_id",shopId).last("limit 1");
|
|
|
|
wrapper1.eq("customer_id",opCustomer.getId()).eq("staff_code",staffCode).eq("store_id",shopId).last("limit 1");
|
|
|
|
OpSellerCustomerRelation opSellerCustomerRelation = opSellerCustomerRelationDOMapper.selectOne(wrapper1);
|
|
|
|
OpSellerCustomerRelation opSellerCustomerRelation = opSellerCustomerRelationDOMapper.selectOne(wrapper1);
|
|
|
|
if(null == opSellerCustomerRelation){
|
|
|
|
if(null == opSellerCustomerRelation){
|
|
|
|
//不存在就添加
|
|
|
|
//不存在就添加
|
|
|
|