|
|
|
|
|
package com.kiisoo.ic.customer;
|
|
|
|
|
|
|
|
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
|
|
|
import com.kiisoo.ic.customer.entity.OpCustomer;
|
|
|
|
|
|
import com.kiisoo.ic.customer.entity.OpSellerCustomerRelation;
|
|
|
|
|
|
import com.kiisoo.ic.customer.mapper.OpCustomerDOMapper;
|
|
|
|
|
|
import com.kiisoo.ic.customer.mapper.OpSellerCustomerRelationDOMapper;
|
|
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
|
|
|
|
|
|
import java.util.Date;
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* @ClassName: CustomerService
|
|
|
|
|
|
* @Description: 客户业务类
|
|
|
|
|
|
* @Auther: Caps
|
|
|
|
|
|
* @Date: 2020/4/2 0002 17:06
|
|
|
|
|
|
* @Version: v1
|
|
|
|
|
|
*/
|
|
|
|
|
|
@Service
|
|
|
|
|
|
public class CustomerService {
|
|
|
|
|
|
|
|
|
|
|
|
private final OpCustomerDOMapper opCustomerDOMapper;
|
|
|
|
|
|
|
|
|
|
|
|
private final OpSellerCustomerRelationDOMapper opSellerCustomerRelationDOMapper;
|
|
|
|
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
|
|
public CustomerService(OpCustomerDOMapper opCustomerDOMapper, OpSellerCustomerRelationDOMapper opSellerCustomerRelationDOMapper) {
|
|
|
|
|
|
this.opCustomerDOMapper = opCustomerDOMapper;
|
|
|
|
|
|
this.opSellerCustomerRelationDOMapper = opSellerCustomerRelationDOMapper;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* 绑定客户的关系
|
|
|
|
|
|
* @param phone 客户手机号
|
|
|
|
|
|
* @param sellerId 分享码的导购id
|
|
|
|
|
|
* @param shopId 导购所在的店铺id
|
|
|
|
|
|
* @Description: 根据客户联系方式查询客户id 1.判断客户是否存在,不存在就添加,存在就进行下一步 2.判断客户id和导购是否绑定了关系如果绑定了就直接下一步,如果没有就绑定 3.判断客户id和vip是否绑定了关系如果绑定了就直接下一步,如果没有就绑定
|
|
|
|
|
|
*/
|
|
|
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
|
|
|
@Deprecated
|
|
|
|
|
|
public void customerRelation(String phone,long sellerId,long shopId){
|
|
|
|
|
|
QueryWrapper<OpCustomer> wrapper = new QueryWrapper<>();
|
|
|
|
|
|
wrapper.eq("phone",phone).last("limit 1");
|
|
|
|
|
|
OpCustomer opCustomer = opCustomerDOMapper.selectOne(wrapper);
|
|
|
|
|
|
if(null != opCustomer){
|
|
|
|
|
|
//存在--1.处理客户导购关系。2.处理客户和vip关系(待定)
|
|
|
|
|
|
sellerCustomerRelation(opCustomer,sellerId,shopId);
|
|
|
|
|
|
}else {
|
|
|
|
|
|
//不存在
|
|
|
|
|
|
OpCustomer insertCustomer = new OpCustomer();
|
|
|
|
|
|
insertCustomer.setPhone(phone);
|
|
|
|
|
|
opCustomerDOMapper.insert(insertCustomer);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
* 处理客户和导购的关系
|
|
|
|
|
|
* @param opCustomer 客户的数据信息
|
|
|
|
|
|
* @param sellerId 导购id
|
|
|
|
|
|
*/
|
|
|
|
|
|
private void sellerCustomerRelation(OpCustomer opCustomer,long sellerId,long shopId){
|
|
|
|
|
|
QueryWrapper<OpSellerCustomerRelation> wrapper1 = new QueryWrapper<>();
|
|
|
|
|
|
wrapper1.eq("customer_id",opCustomer.getId()).eq("user_id",sellerId).eq("store_id",shopId).last("limit 1");
|
|
|
|
|
|
OpSellerCustomerRelation opSellerCustomerRelation = opSellerCustomerRelationDOMapper.selectOne(wrapper1);
|
|
|
|
|
|
if(null == opSellerCustomerRelation){
|
|
|
|
|
|
//不存在就添加
|
|
|
|
|
|
OpSellerCustomerRelation insertRelation = new OpSellerCustomerRelation();
|
|
|
|
|
|
insertRelation.setCreateTime(new Date());
|
|
|
|
|
|
insertRelation.setUpdateTime(new Date());
|
|
|
|
|
|
insertRelation.setCustomerId(opCustomer.getId());
|
|
|
|
|
|
insertRelation.setStoreId(shopId);
|
|
|
|
|
|
insertRelation.setUserId(sellerId);
|
|
|
|
|
|
opSellerCustomerRelationDOMapper.insert(insertRelation);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|