客户扫码关联关系

master
Caps 6 years ago
parent a992b75005
commit 09951f4bd3

@ -1,8 +1,16 @@
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:
@ -13,20 +21,58 @@ import org.springframework.transaction.annotation.Transactional;
@Service
public class CustomerService {
private final OpCustomerDOMapper opCustomerDOMapper;
private final OpSellerCustomerRelationDOMapper opSellerCustomerRelationDOMapper;
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.idvip
*/
@Transactional(rollbackFor = Exception.class)
@Deprecated
public void customerRelation(String phone,long sellerId,long shopId){
//根据客户联系方式查询客户id
//1.判断客户是否存在,不存在就添加
//2.判断客户id和导购是否绑定了关系如果绑定了就直接下一步如果没有就绑定
//3.判断客户id和门店是否绑定了关系如果绑定了就直接下一步如果没有就绑定
//4.判断客户id和vip是否绑定了关系如果绑定了就直接下一步如果没有就绑定
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);
}
}
}

@ -0,0 +1,91 @@
package com.kiisoo.ic.customer.entity;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Data;
import java.util.Date;
/**
* @Description
* @Author Caps
* @Date 2020-04-07
*/
@Data
@TableName ("op_customer")
public class OpCustomer {
/**
* ID
*/
@TableId(type = IdType.AUTO)
private Long id;
/**
* openId
*/
private String wechatOpenId;
/**
* uniId
*/
private String wechatUniId;
private String wechatXxxId;
/**
* ID
*/
private Long memberId;
/**
* 1 2
*/
private Long type;
/**
*
*/
private String name;
/**
*
*/
private String phone;
/**
*
*/
private String desc;
/**
*
*/
private String mail;
/**
* ID()
*/
private Long brandId;
/**
*
*/
private Date createTime;
/**
*
*/
private Date updateTime;
/**
*
*/
private String createBy;
/**
*
*/
private String updateBy;
}

@ -0,0 +1,59 @@
package com.kiisoo.ic.customer.entity;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.Data;
import java.util.Date;
/**
* @Description
* @Author Caps
* @Date 2020-04-07
*/
@Data
@TableName ("op_seller_customer_relation")
public class OpSellerCustomerRelation {
/**
* ID
*/
@TableId(type = IdType.AUTO)
private Long id;
/**
* ID
*/
private Long userId;
/**
* ID
*/
private Long customerId;
/**
* ID
*/
private Long storeId;
/**
*
*/
private Date createTime;
/**
*
*/
private Date updateTime;
/**
*
*/
private String createBy;
/**
*
*/
private String updateBy;
}

@ -0,0 +1,13 @@
package com.kiisoo.ic.customer.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.kiisoo.ic.customer.entity.OpCustomer;
import org.springframework.stereotype.Repository;
/**
*
*/
@Repository
public interface OpCustomerDOMapper extends BaseMapper<OpCustomer> {
}

@ -0,0 +1,13 @@
package com.kiisoo.ic.customer.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.kiisoo.ic.customer.entity.OpSellerCustomerRelation;
import org.springframework.stereotype.Repository;
/**
*
*/
@Repository
public interface OpSellerCustomerRelationDOMapper extends BaseMapper<OpSellerCustomerRelation> {
}
Loading…
Cancel
Save