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