删除客户导购关系

dev_0531
yechenhao 5 years ago
parent 44bdf44284
commit 9ecb636e5a

@ -352,17 +352,42 @@ public class CustomerService {
* @date 2020/05/24 13:46 * @date 2020/05/24 13:46
*/ */
private void handleDelCustomer (TurnBackDTO turnBackDTOS) { private void handleDelCustomer (TurnBackDTO turnBackDTOS) {
String customerUserId = turnBackDTOS.getWxData().getUserId();
if (StringUtils.isBlank(customerUserId)){
return;
}
privilageCpUserDOMapper.deleteCount(customerUserId,turnBackDTOS.getUserId());
QueryWrapper<OpCustomer> customerQw = new QueryWrapper<>();
customerQw.eq("external_userid",customerUserId).last("limit 1");
OpCustomer customer = opCustomerDOMapper.selectOne(customerQw);
if (customer == null){
return;
}
//店铺信息 //店铺信息
PrivilageCpUserStoreDO poiStore = privilageCpUserStoreDOMapper.selectOneCpUser(turnBackDTOS.getUserId()); PrivilageCpUserStoreDO poiStore = privilageCpUserStoreDOMapper.selectOneCpUser(turnBackDTOS.getUserId());
if (null == poiStore) { if (null == poiStore) {
//无店铺数据处理 QueryWrapper<PrivilageCpUserDO> cpUserQw = new QueryWrapper<>();
log.error("无店铺数据处理 no store data : " + turnBackDTOS.toString()); cpUserQw.eq("cp_user_id",turnBackDTOS.getUserId()).last("limit 1");
return; PrivilageCpUserDO privilageCpUserDO = privilageCpUserDOMapper.selectOne(cpUserQw);
}
QueryWrapper<PrivilageCpUserStoreDO> relationQw = new QueryWrapper<>();
relationQw.eq("customer_id",customer.getId()).eq("user_id",privilageCpUserDO.getId()).eq("type",3);
privilageCpUserStoreDOMapper.delete(relationQw);
}else{
String eaCode = turnBackDTOS.getEaCode();
PoiStoreStaff staff;
QueryWrapper<PoiStoreStaff> staffQw = new QueryWrapper<>();
if (StringUtils.isNotBlank(eaCode) && !"0".equals(eaCode)){
staffQw.eq("staff_code",eaCode).eq("type",4).eq("store_id",poiStore.getStoreId()).last("limit 1");
staff = poiStoreStaffDOMapper.selectOne(staffQw);
}else{
staffQw.eq("staff_code",turnBackDTOS.getUserId()).eq("type",1).eq("store_id",poiStore.getStoreId()).last("limit 1");
staff = poiStoreStaffDOMapper.selectOne(staffQw);
}
QueryWrapper<PrivilageCpUserStoreDO> relationQw = new QueryWrapper<>();
relationQw.eq("customer_id",customer.getId()).eq("user_id",staff.getId());
privilageCpUserStoreDOMapper.delete(relationQw);
}
} }
/** /**

@ -31,4 +31,6 @@ public interface PrivilageCpUserDOMapper extends BaseMapper<PrivilageCpUserDO> {
Long selectDistinctStoresCount(@Param("cpUserIds")List<String> cpUserIds); Long selectDistinctStoresCount(@Param("cpUserIds")List<String> cpUserIds);
int deleteCount(@Param("customerUserId")String customerUserId, @Param("cpUserId")String cpUserId);
} }

@ -53,4 +53,8 @@
select distinct customer_user_id from op_cp_user_customer_relation where cp_user_id = #{cpUserId} select distinct customer_user_id from op_cp_user_customer_relation where cp_user_id = #{cpUserId}
</select> </select>
<delete id="deleteCount">
delete from op_cp_user_customer_relation where customer_user_id = #{customerUserId} and cp_user_id = #{cpUserId}
</delete>
</mapper> </mapper>

Loading…
Cancel
Save