客户概览后台

master
wyj2080 6 years ago
parent cc6b38ebce
commit 77e0766b20

@ -34,18 +34,18 @@ public class CustomerViewController extends BaseController {
/**
* main
* @param userId id
* @param organizationId id
* @param shopId id
* @param sevenDayStartTime
* @param sevenDayEndTime
* @param selectStartTime
* @param selectEndTime
* @param startTime
* @param endTime
* @return VO
*/
@ResponseBody
@RequestMapping(value = "/main", method = RequestMethod.GET)
public Map<String,Object> getMainData(@RequestParam("userId")Long userId, Long organizationId, Long shopId,
@RequestParam("sevenDayStartTime")String sevenDayStartTime, @RequestParam("sevenDayEndTime")String sevenDayEndTime){
public Map<String,Object> getMainData(@RequestParam("userId")Long userId, @RequestParam("selectStartTime")String selectStartTime, @RequestParam("selectEndTime")String selectEndTime,
@RequestParam("startTime")String startTime, @RequestParam("endTime")String endTime){
try{
CustomerViewVO result = customerViewService.selectCustomerViewMain(userId, organizationId, shopId, sevenDayStartTime, sevenDayEndTime);
CustomerViewVO result = customerViewService.selectCustomerViewMain(userId, selectStartTime, selectEndTime, startTime, endTime);
return data(result);
}catch (Exception e){
log.error("查询客户数据概览出错", e);

@ -0,0 +1,24 @@
package com.kiisoo.ic.customer.entity;
import lombok.Data;
/**
* @Description: VO
* @Author: wangyinjia
* @Date: 2020/4/17
* @Company: kiisoo
* @Version: 1.0
*/
@Data
public class CustomerViewCompanyVO {
/**排名*/
private Integer position;
/**零售公司id*/
private Long orgId;
/**零售公司名称*/
private String orgName;
/**新增好友数*/
private Integer newCustomerCount;
}

@ -0,0 +1,27 @@
package com.kiisoo.ic.customer.entity;
import lombok.Data;
/**
* @Description: VO
* @Author: wangyinjia
* @Date: 2020/4/17
* @Company: kiisoo
* @Version: 1.0
*/
@Data
public class CustomerViewShopVO {
/**排名*/
private Integer position;
/**店铺id*/
private Long shopId;
/**店铺名称*/
private String shopName;
/**零售公司id*/
private Long orgId;
/**零售公司名称*/
private String orgName;
/**新增好友数*/
private Integer newCustomerCount;
}

@ -14,42 +14,47 @@ import java.util.List;
*/
@Data
public class CustomerViewVO {
/**全部客户*/
private Long allCustomer;
/**有效客户*/
private Long validCustomer;
/**新增客户*/
/**新增好友*/
private Long newCustomer;
/**新增有效客户*/
/**新增好友(去重)*/
private Long newValidCustomer;
/**删除拉黑数*/
private Long deleteCustomer;
/**全部好友*/
private Long allCustomer;
/**全部好友(去重)*/
private Long allValidCustomer;
/**删除拉黑数(累计去重)*/
private Long validDeleteCustomer;
/**会员总数*/
private Long allVipCount;
/**好友list*/
List<OpCustomer> customerList;
/**好友(去重)list*/
List<OpCustomer> validCustomerList;
/**零售公司新增top10*/
List<CustomerViewCompanyVO> orgNewCustomerList;
/**店铺新增top10*/
List<CustomerViewShopVO> shopNewCustomerList;
/**零推广list*/
List<CustomerViewZeroExtendVO> zeroExtendList;
/**近七天新增客户list*/
List<OpCustomer> sevenDayCustomerList;
/**近七天新增会员list*/
List<OpVip> sevenDayVipList;
/**未关联的客户*/
private Long customer;
/**已关联人数*/
private Long common;
/**未关联的会员*/
private Long vip;
/**
*
*/
public CustomerViewVO(){
allCustomer = 0L;
validCustomer = 0L;
newCustomer = 0L;
newValidCustomer = 0L;
deleteCustomer = 0L;
customer = 0L;
common = 0L;
vip = 0L;
sevenDayCustomerList = new ArrayList<>();
sevenDayVipList = new ArrayList<>();
allCustomer = 0L;
allValidCustomer = 0L;
validDeleteCustomer = 0L;
allVipCount = 0L;
customerList = new ArrayList<>();
validCustomerList = new ArrayList<>();
orgNewCustomerList = new ArrayList<>();
shopNewCustomerList = new ArrayList<>();
zeroExtendList = new ArrayList<>();
}
}

@ -0,0 +1,23 @@
package com.kiisoo.ic.customer.entity;
import lombok.Data;
/**
* @Description: 广VO
* @Author: wangyinjia
* @Date: 2020/4/17
* @Company: kiisoo
* @Version: 1.0
*/
@Data
public class CustomerViewZeroExtendVO {
/**零售公司id*/
private Long orgId;
/**零售公司名称*/
private String orgName;
/**店铺总数*/
private Integer allShopCount;
/**零推广店铺数*/
private Integer zeroShopCount;
}

@ -104,4 +104,16 @@ public class OpCustomer {
@TableField(exist = false)
private Date registerTime;
/**
* id
*/
@TableField(exist = false)
private Long shopId;
/**
* 12
*/
@TableField(exist = false)
private Integer validType;
}

@ -1,6 +1,7 @@
package com.kiisoo.ic.customer.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.kiisoo.ic.customer.entity.CustomerViewShopVO;
import com.kiisoo.ic.customer.entity.OpCustomer;
import com.kiisoo.ic.customer.bean.OpCustomerDTO;
import org.apache.ibatis.annotations.Param;
@ -38,7 +39,16 @@ public interface OpCustomerDOMapper extends BaseMapper<OpCustomer> {
/**
* list
*/
List<OpCustomer> selectCustomerList(@Param("shopIds") List<Long> shopIds, @Param("sellerId") Long sellerId, @Param("memberId") Long memberId, @Param("startDate") Date startDate, @Param("endDate") Date endDate);
List<OpCustomer> selectCustomerList(@Param("shopIds") List<Long> shopIds, @Param("sellerId") Long sellerId, @Param("memberId") Long memberId, @Param("startDate") String startDate, @Param("endDate") String endDate);
/**
*
*/
Long selectCustomerCount(@Param("shopIds") List<Long> shopIds, @Param("type")Integer type, @Param("startDate") String startDate, @Param("endDate") String endDate);
/**
* ids
*/
List<CustomerViewShopVO> selectOrgByShopIds(@Param("shopIds") List<Long> shopIds);
}

@ -17,4 +17,9 @@ public interface OpVipDOMapper extends BaseMapper<OpVip> {
* list
*/
List<OpVip> selectVipList(@Param("shopIds") List<Long> shopIds, @Param("startDate") Date startDate, @Param("endDate") Date endDate);
/**
*
*/
Long selectVipCount(@Param("shopIds") List<Long> shopIds, @Param("startDate") Date startDate, @Param("endDate") Date endDate);
}

@ -1,21 +1,22 @@
package com.kiisoo.ic.customer.service;
import com.kiisoo.ic.customer.entity.CustomerViewVO;
import com.kiisoo.ic.customer.entity.OpCustomer;
import com.kiisoo.ic.customer.entity.OpVip;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.kiisoo.ic.customer.entity.*;
import com.kiisoo.ic.customer.mapper.OpCustomerDOMapper;
import com.kiisoo.ic.customer.mapper.OpVipDOMapper;
import com.kiisoo.ic.domain.service.PrivilageDomainService;
import com.kiisoo.ic.generalize.entity.PoiCustomerContactDataStat;
import com.kiisoo.ic.generalize.mapper.PoiCustomerContactDataStatMapper;
import com.kiisoo.ic.store.entity.PoiStore;
import com.kiisoo.ic.store.service.PoiStoreService;
import com.kiisoo.ic.store.mapper.PoiStoreDOMapper;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections.CollectionUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.atomic.AtomicLong;
import java.util.*;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.stream.Collectors;
/**
@ -29,8 +30,10 @@ import java.util.stream.Collectors;
@Service
public class CustomerViewService {
/**零*/
static final Long ZERO_L= 0L;
/**有效*/
static final Integer VALID = 1;
static final Integer TEN = 10;
/**
* mapper
@ -42,7 +45,7 @@ public class CustomerViewService {
* mapper
*/
@Autowired
private PoiStoreService poiStoreService;
private PoiStoreDOMapper poiStoreDOMapper;
/**
* mapper
@ -50,6 +53,12 @@ public class CustomerViewService {
@Autowired
private OpCustomerDOMapper opCustomerDOMapper;
/**
* mapper
*/
@Autowired
private PoiCustomerContactDataStatMapper poiCustomerContactDataStatMapper;
/**
* vip mapper
*/
@ -59,137 +68,204 @@ public class CustomerViewService {
/**
* main
* @param userId id
* @param organizationId id
* @param shopId id
* @param sevenDayStartTime
* @param sevenDayEndTime
* @param selectStartTime
* @param selectEndTime
* @param startTime
* @param endTime
* @return VO
*/
public CustomerViewVO selectCustomerViewMain(Long userId, Long organizationId, Long shopId, String sevenDayStartTime, String sevenDayEndTime){
public CustomerViewVO selectCustomerViewMain(Long userId, String selectStartTime, String selectEndTime, String startTime, String endTime){
CustomerViewVO customerViewVO = new CustomerViewVO();
//shopIds
// List<Long> shopIds = getShopIds(userId, regionId, shopId);
List<Long> shopIds = new ArrayList<>();
//客户list
List<OpCustomer> customerList = opCustomerDOMapper.selectCustomerList(shopIds, null, null, null, null);
//会员list
List<OpVip> vipList = opVipDOMapper.selectVipList(shopIds, null, null);
//5大块客户数
//设置客户关联vip人数
setCustomerAndVipSize(customerList, vipList, customerViewVO);
//近七天新增list
List<OpCustomer> sevenDayCustomerList = customerList.stream().filter(customerDO -> filterSevenDayCustomer(customerDO, sevenDayStartTime, sevenDayEndTime)).collect(Collectors.toList());
List<OpVip> sevenDayVipList = vipList.stream().filter(vipDO -> filterSevenDayVip(vipDO, sevenDayStartTime, sevenDayEndTime)).collect(Collectors.toList());
customerViewVO.setSevenDayCustomerList(sevenDayCustomerList);
customerViewVO.setSevenDayVipList(sevenDayVipList);
List<Long> shopIds = getShopIds(userId);
if(CollectionUtils.isEmpty(shopIds)){
return customerViewVO;
}
//柱状图好友list
List<OpCustomer> customerList = opCustomerDOMapper.selectCustomerList(shopIds, null, null, startTime, endTime);
//好友总数
Long customerCount = opCustomerDOMapper.selectCustomerCount(shopIds, null, null, null);
//好友总数(去重)
Long validCustomerCount = opCustomerDOMapper.selectCustomerCount(shopIds, VALID, null, null);
//删除拉黑数
QueryWrapper<PoiCustomerContactDataStat> wrapper = new QueryWrapper<>();
wrapper.in("store_id", shopIds).le("stat_time", selectEndTime).ge("stat_time", selectStartTime);
Long validDeleteCustomerCount = poiCustomerContactDataStatMapper.selectList(wrapper).stream()
.filter(contactDO -> contactDO.getNegativeFeedbackCnt() != null)
.map(PoiCustomerContactDataStat::getNegativeFeedbackCnt).mapToLong(a -> a).sum();
//会员总数
Long vipCount = opVipDOMapper.selectVipCount(shopIds, null, null);
//柱状图list
List<OpCustomer> validCustomerList = customerList.stream().filter(customerDO -> VALID.equals(customerDO.getValidType())).collect(Collectors.toList());
customerViewVO.setCustomerList(customerList);
customerViewVO.setValidCustomerList(validCustomerList);
//设置新增好友好友总数拉黑数vip人数柱状图list等数据
setCustomerViewData(customerViewVO, customerCount, validCustomerCount, validDeleteCustomerCount, vipCount, customerList, validCustomerList, selectStartTime, selectEndTime);
//前十名排行list等
List<OpCustomer> newCustimerList = customerList.stream().filter(customerDO -> filterCustomerByRegisterTime(customerDO, selectStartTime, selectEndTime)).collect(Collectors.toList());
List<CustomerViewCompanyVO> orgNewCustomerList = getOrgNewCustomerList(newCustimerList);
List<CustomerViewShopVO> shopNewCustomerList = getShopNewCustomerList(newCustimerList);
List<CustomerViewZeroExtendVO> zeroExtendList = getZeroExtendList(newCustimerList, shopIds);
customerViewVO.setOrgNewCustomerList(orgNewCustomerList);
customerViewVO.setShopNewCustomerList(shopNewCustomerList);
customerViewVO.setZeroExtendList(zeroExtendList);
return customerViewVO;
}
/**
* shopIds
* @param userId id
* @param regionId id
* @param shopId id
* @return shopIds
*/
List<Long> getShopIds(Long userId, Long regionId, Long shopId){
List<Long> shopIds = new ArrayList<>();
//单店
if(shopId != null){
shopIds.add(shopId);
return shopIds;
}
//单区域
if(regionId != null){
List<PoiStore> shopList = poiStoreService.getRegionShop(regionId);
shopIds = shopList.stream().map(PoiStore::getId).collect(Collectors.toList());
return shopIds;
}
//所有shopIds
shopIds = privilageDomainService.listUserDatePermission(userId);
List<Long> getShopIds(Long userId){
List<Long> shopIds = privilageDomainService.listUserDatePermission(userId);
return shopIds;
}
/**
* vip
* @param customerList List
* @param vipList vipList
* viplist
* @param customerViewVO VO
* @param customerCount
* @param validCustomerCount ()
* @param validDeleteCustomerCount
* @param vipCount
* @param customerList list
* @param validCustomerList list
* @param selectStartTime
* @param selectEndTime
*/
public void setCustomerAndVipSize(List<OpCustomer> customerList, List<OpVip> vipList, CustomerViewVO customerViewVO){
//关联人数(手机号确定)
List<String> customerPhoneList = customerList.stream().map(OpCustomer::getPhone).distinct().collect(Collectors.toList());
List<String> vipPhoneList = vipList.stream().map(OpVip::getPhone).distinct().collect(Collectors.toList());
AtomicLong commonInt = new AtomicLong(0);
customerPhoneList.forEach(customerPhone -> {
if(vipPhoneList.contains(customerPhone)){
commonInt.incrementAndGet();
}
});
Long common = commonInt.get();
customerViewVO.setCommon(common);
//未关联的客户数
Long customer = customerList.stream().filter(customerDO -> ZERO_L.equals(customerDO.getMemberId())).map(OpCustomer::getPhone).distinct().count();
customerViewVO.setCustomer(customer);
//未关联会员数
Long vip = vipList.stream().map(OpVip::getPhone).distinct().count();
customerViewVO.setVip(vip - common);
public void setCustomerViewData(CustomerViewVO customerViewVO, Long customerCount, Long validCustomerCount, Long validDeleteCustomerCount, Long vipCount,
List<OpCustomer> customerList, List<OpCustomer> validCustomerList, String selectStartTime, String selectEndTime){
//新增好友
Long newCustomerCount = customerList.stream().filter(customerDO -> filterCustomerByRegisterTime(customerDO, selectStartTime, selectEndTime)).count();
customerViewVO.setNewCustomer(newCustomerCount);
//新增好友(去重)
Long newValidCustomerCount = validCustomerList.stream().filter(customerDO -> filterCustomerByRegisterTime(customerDO, selectStartTime, selectEndTime)).count();
customerViewVO.setNewValidCustomer(newValidCustomerCount);
//好友总数
customerViewVO.setAllCustomer(customerCount);
//好友总数(去重)
customerViewVO.setAllValidCustomer(validCustomerCount);
//删除拉黑数(累计去重)
customerViewVO.setValidDeleteCustomer(validDeleteCustomerCount);
//会员总数
customerViewVO.setAllVipCount(vipCount);
}
/**
* list
* @param customerDO DO
* @param sevenDayStartTime
* @param sevenDayEndTime
* @return list
*
* @param customerDO DO
* @param selectStartTime
* @param selectEndTime
* @return true/false
*/
Boolean filterSevenDayCustomer(OpCustomer customerDO, String sevenDayStartTime, String sevenDayEndTime){
boolean filterCustomerByRegisterTime(OpCustomer customerDO, String selectStartTime, String selectEndTime){
Date registerDate = customerDO.getRegisterTime();
if(registerDate == null){
return false;
}
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
try {
if(customerDO.getRegisterTime() != null){
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
Long start = sdf.parse(sevenDayStartTime).getTime();
Long end = sdf.parse(sevenDayEndTime).getTime();
if(customerDO.getRegisterTime().getTime() >= start && customerDO.getRegisterTime().getTime() <= end){
return true;
}else{
return false;
}
}else{
return false;
}
long startTime = sdf.parse(selectStartTime).getTime();
long endTime = sdf.parse(selectEndTime).getTime();
long registerTime = registerDate.getTime();
return startTime <= registerTime && endTime >= registerTime;
}catch (Exception e){
log.error("过滤近7天客户出错", e);
log.error("格式化时间出错", e);
return false;
}
}
/**
* list
* @param vipDO DO
* @param sevenDayStartTime
* @param sevenDayEndTime
* @return list
* list
* @param newCustimerList list
* @return list
*/
Boolean filterSevenDayVip(OpVip vipDO, String sevenDayStartTime, String sevenDayEndTime){
try {
if(vipDO.getRegisterTime() != null){
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
Long start = sdf.parse(sevenDayStartTime).getTime();
Long end = sdf.parse(sevenDayEndTime).getTime();
if(vipDO.getRegisterTime().getTime() >= start && vipDO.getRegisterTime().getTime() <= end){
return true;
}else{
return false;
}
}else{
return false;
}
}catch (Exception e){
log.error("过滤近7天会员出错", e);
return false;
List<CustomerViewCompanyVO> getOrgNewCustomerList(List<OpCustomer> newCustimerList){
List<CustomerViewCompanyVO> orgNewCustomerList = new ArrayList<>();
//店铺id-新增好友数map
Map<Long, Long> shopIdCountMap = newCustimerList.stream().collect(Collectors.groupingBy(OpCustomer::getShopId, Collectors.counting()));
//店铺id→零售公司名称
List<Long> shopIds = newCustimerList.stream().map(OpCustomer::getShopId).collect(Collectors.toList());
if(CollectionUtils.isEmpty(shopIds)){
return orgNewCustomerList;
}
//公司id-公司店铺list map
Map<Long, List<CustomerViewShopVO>> orgShopListMap = opCustomerDOMapper.selectOrgByShopIds(shopIds).stream().distinct().collect(Collectors.groupingBy(CustomerViewShopVO::getOrgId));
//每个公司新增数
List<CustomerViewCompanyVO> tmpList = new ArrayList<>();
orgShopListMap.forEach((orgId,customerViewShopList) -> {
CustomerViewCompanyVO orgViewDO = new CustomerViewCompanyVO();
orgViewDO.setOrgId(orgId);
orgViewDO.setOrgName(customerViewShopList.get(0).getOrgName());
AtomicInteger newCustomerCount = new AtomicInteger(0);
customerViewShopList.forEach(customerViewShopVO -> {
Long shopId = customerViewShopVO.getShopId();
int tmpCount = shopIdCountMap.get(shopId) == null ? 0 : Math.toIntExact(shopIdCountMap.get(shopId));
newCustomerCount.updateAndGet(v -> v + tmpCount);
});
orgViewDO.setNewCustomerCount(newCustomerCount.get());
tmpList.add(orgViewDO);
});
//排序
orgNewCustomerList = tmpList.stream().sorted(Comparator.comparing(CustomerViewCompanyVO::getNewCustomerCount).reversed()).limit(TEN).collect(Collectors.toList());
return orgNewCustomerList;
}
/**
* list
* @param newCustimerList list
* @return list
*/
List<CustomerViewShopVO> getShopNewCustomerList(List<OpCustomer> newCustimerList){
//店铺分组
Map<Long, List<OpCustomer>> shopIdMap = newCustimerList.stream().collect(Collectors.groupingBy(OpCustomer::getShopId));
List<CustomerViewShopVO> shopViewList = new ArrayList<>();
shopIdMap.forEach((k,v) -> {
CustomerViewShopVO shopVO = new CustomerViewShopVO();
shopVO.setShopId(k);
shopVO.setNewCustomerCount(v.size());
PoiStore shopDO = poiStoreDOMapper.selectById(k);
if(shopDO != null){
shopVO.setShopName(shopDO.getName());
}
shopViewList.add(shopVO);
});
//排序
List<CustomerViewShopVO> shopNewCustomerList = shopViewList.stream().sorted(Comparator.comparing(CustomerViewShopVO::getNewCustomerCount).reversed()).limit(TEN).collect(Collectors.toList());
return shopNewCustomerList;
}
/**
* 广list
* @param newCustimerList list
* @param shopIds ids
* @return 广list
*/
List<CustomerViewZeroExtendVO> getZeroExtendList(List<OpCustomer> newCustimerList, List<Long> shopIds){
List<CustomerViewZeroExtendVO> zeroExtendList = new ArrayList<>();
//有推广的店铺ids
List<Long> notZeroShopIds = newCustimerList.stream().map(OpCustomer::getShopId).distinct().collect(Collectors.toList());
//公司id-公司店铺list map
Map<Long, List<CustomerViewShopVO>> orgShopListMap = opCustomerDOMapper.selectOrgByShopIds(shopIds).stream().distinct().collect(Collectors.groupingBy(CustomerViewShopVO::getOrgId));
List<CustomerViewZeroExtendVO> tmpZeroExtendList = new ArrayList<>();
orgShopListMap.forEach((orgId, orgShopRelationList) -> {
List<Long> tmpShopIds = orgShopRelationList.stream().map(CustomerViewShopVO::getShopId).distinct().collect(Collectors.toList());
int tmpShopCount = tmpShopIds.size();
CustomerViewZeroExtendVO zeroExtendVO = new CustomerViewZeroExtendVO();
zeroExtendVO.setOrgId(orgId);
zeroExtendVO.setOrgName(orgShopRelationList.get(0).getOrgName());
zeroExtendVO.setAllShopCount(tmpShopCount);
//推广的店铺
tmpShopIds.retainAll(notZeroShopIds);
zeroExtendVO.setZeroShopCount(tmpShopCount - tmpShopIds.size());
tmpZeroExtendList.add(zeroExtendVO);
});
zeroExtendList = tmpZeroExtendList.stream().filter(zeroExtendDO -> zeroExtendDO.getZeroShopCount() > 0).collect(Collectors.toList());
return zeroExtendList;
}
}

@ -54,7 +54,8 @@
<!--客户list-->
<select id="selectCustomerList" resultType="com.kiisoo.ic.customer.entity.OpCustomer">
select t1.id as id, t1.`name` as name, t1.member_id as memberId, t1.phone as phone, t2.create_time as registerTime
select t1.id as id, t1.`name` as name, t1.member_id as memberId, t1.phone as phone,
t2.create_time as registerTime, t2.type as validType, t2.store_id as shopId
from op_customer t1, op_seller_customer_relation t2
where t1.id=t2.customer_id
<if test="memberId != null">
@ -69,6 +70,28 @@
<if test="sellerId != null">
and t2.user_id=#{sellerId}
</if>
<if test="startDate != null and startDate != ''">
and t2.create_time <![CDATA[ >= ]]> #{startDate}
</if>
<if test="endDate != null and endDate != ''">
and t2.create_time <![CDATA[ <= ]]> #{endDate}
</if>
</select>
<!--客户总数-->
<select id="selectCustomerCount" resultType="Long">
select count(t1.id)
from op_customer t1, op_seller_customer_relation t2
where t1.id=t2.customer_id
<if test="shopIds != null and shopIds.size > 0">
and t2.store_id in
<foreach collection="shopIds" separator="," item="item" index="index" close=")" open="(">
#{item}
</foreach>
</if>
<if test="type != null">
and t2.type = #{type}
</if>
<if test="startDate != null">
and t2.create_time <![CDATA[ >= ]]> #{startDate}
</if>
@ -77,4 +100,17 @@
</if>
</select>
<!--店铺ids→零售公司-->
<select id="selectOrgByShopIds" resultType="com.kiisoo.ic.customer.entity.CustomerViewShopVO">
select t1.id as orgId,t1.`name` as orgName, t3.entity_id as shopId
from privilage_organizational t1, privilage_organizational_domain t2, privilage_domain_entity t3
where t1.id = t2.org_id
and t2.domain_id = t3.domain_id
and t3.type = 3
and t3.entity_id in
<foreach collection="shopIds" separator="," item="item" index="index" close=")" open="(">
#{item}
</foreach>
</select>
</mapper>

@ -21,4 +21,23 @@
</if>
</select>
<!--会员总数-->
<select id="selectVipCount" resultType="Long">
select count(t1.id)
from op_vip t1,op_vip_attr t2
where t1.id = t2.vip_id
<if test="shopIds != null and shopIds.size > 0">
and t2.register_store_id in
<foreach collection="shopIds" separator="," item="item" index="index" close=")" open="(">
#{item}
</foreach>
</if>
<if test="startDate != null">
and t1.register_time <![CDATA[ >= ]]> #{startDate}
</if>
<if test="endDate != null">
and t1.register_time <![CDATA[ <= ]]> #{endDate}
</if>
</select>
</mapper>

Loading…
Cancel
Save