店铺对应的推广用户

master
wangweijia 6 years ago
parent 3a80623e09
commit c7ea9d04f7

@ -5,7 +5,7 @@ import com.kiisoo.ic.constants.Constants;
import com.kiisoo.ic.customer.bean.CustomerDTO;
import com.kiisoo.ic.customer.bean.CustomerModifyDTO;
import com.kiisoo.ic.customer.entity.OpCustomer;
import com.kiisoo.ic.customer.entity.OpCustomerDTO;
import com.kiisoo.ic.customer.bean.OpCustomerDTO;
import com.kiisoo.ic.customer.entity.OpSellerCustomerRelation;
import com.kiisoo.ic.customer.entity.OpVip;
import com.kiisoo.ic.customer.mapper.OpCustomerDOMapper;
@ -14,7 +14,6 @@ import com.kiisoo.ic.customer.mapper.OpVipDOMapper;
import com.kiisoo.ic.domain.service.PrivilageDomainService;
import com.kiisoo.ic.store.entity.PoiStore;
import com.kiisoo.ic.store.service.PoiStoreService;
import com.kiisoo.ic.store.entity.PoiStore;
import com.kiisoo.ic.store.entity.PoiStoreStaff;
import com.kiisoo.ic.store.mapper.PoiStoreDOMapper;
import com.kiisoo.ic.store.mapper.PoiStoreStaffDOMapper;
@ -150,6 +149,15 @@ public class CustomerService {
return customers;
}
/**
* id
* @param sellerId
*/
public List<OpCustomerDTO> getCustomerInfoByShopIds(long sellerId, Date startDate, Date endDate){
List<OpCustomerDTO> customers = opCustomerDOMapper.selectCustomerInfoBySellerId(sellerId, startDate, endDate);
return customers;
}
/**
* 广
* @param userId id
@ -158,10 +166,16 @@ public class CustomerService {
* @param startDate
* @param endDate
*/
public List<OpCustomerDTO> getCustomerByUserAndDate(long userId,Long shopId, Long regionId , Date startDate, Date endDate){
public List<OpCustomerDTO> getCustomerByUserAndDate(long userId,Long shopId, Long regionId , Long sellerId, Date startDate, Date endDate){
Set<Long> shopIds = new HashSet<>();
//根据店铺查询所有扫码客户信息
List<OpCustomerDTO> opCustomerDTOS;
//如果有店铺则查店铺
if(shopId != null){
if(sellerId != null){
opCustomerDTOS = getCustomerInfoByShopIds(sellerId, startDate, endDate);
return opCustomerDTOS;
}else if(shopId != null){
shopIds.add(shopId);
}else if(regionId != null){
//如果有区域则查区域店铺
@ -173,7 +187,7 @@ public class CustomerService {
}
//根据店铺查询所有扫码客户信息
List<OpCustomerDTO> opCustomerDTOS = getCustomerInfoByShopIds(shopIds, startDate, endDate);
opCustomerDTOS = getCustomerInfoByShopIds(shopIds, startDate, endDate);
return opCustomerDTOS;
}

@ -1,4 +1,4 @@
package com.kiisoo.ic.customer.entity;
package com.kiisoo.ic.customer.bean;
import lombok.Data;

@ -2,7 +2,7 @@ package com.kiisoo.ic.customer.controller;
import com.kiisoo.ic.common.BaseController;
import com.kiisoo.ic.customer.CustomerService;
import com.kiisoo.ic.customer.entity.OpCustomerDTO;
import com.kiisoo.ic.customer.bean.OpCustomerDTO;
import lombok.extern.slf4j.Slf4j;
import org.apache.ibatis.annotations.Param;
import org.springframework.beans.factory.annotation.Autowired;
@ -28,10 +28,10 @@ public class CustomerController extends BaseController {
@ResponseBody
@PostMapping("/info")
public Map<String, Object> getCustomerInfo(@Param("userId") long userId, Long shopId, Long regionId ,
public Map<String, Object> getCustomerInfo(@Param("userId") long userId, Long shopId, Long regionId , Long sellerId,
@Param("startDate") Date startDate, @Param("endDate") Date endDate){
List<OpCustomerDTO> opCustomerDTOS = customerService.getCustomerByUserAndDate(userId, shopId, regionId, startDate, endDate);
List<OpCustomerDTO> opCustomerDTOS = customerService.getCustomerByUserAndDate(userId, shopId, regionId, sellerId, startDate, endDate);
return data(opCustomerDTOS);
}
}

@ -2,11 +2,10 @@ package com.kiisoo.ic.customer.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.kiisoo.ic.customer.entity.OpCustomer;
import com.kiisoo.ic.customer.entity.OpCustomerDTO;
import com.kiisoo.ic.customer.bean.OpCustomerDTO;
import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Repository;
import javax.xml.crypto.Data;
import java.util.Date;
import java.util.List;
import java.util.Set;
@ -27,4 +26,12 @@ public interface OpCustomerDOMapper extends BaseMapper<OpCustomer> {
List<OpCustomerDTO> selectCustomerInfoByShopIds(@Param("shopId") Set<Long> shopIds,
@Param("startDate")Date startDate, @Param("endDate") Date endDate);
/**
* id广
* @param sellerId id
* @param startDate 广
* @param endDate 广
* @return
*/
List<OpCustomerDTO> selectCustomerInfoBySellerId(@Param("sellerId") long sellerId, @Param("startDate") Date startDate,@Param("endDate") Date endDate);
}

@ -45,15 +45,19 @@ public class RegionService {
* @return map keyshop,region value: regiondos, shopIds
*/
public Map<String, Object> getRegionAndShop(long userId){
//找到区域集合
List<RegionDO> regionDOS = getUserRegion(userId);
//找到店铺集合
List<Long> shopsIds = privilageDomainService.listUserDatePermission(userId);
List<PoiStore> shops = poiStoreDOMapper.selectBatchIds(shopsIds);
//找到店铺对应的导购
List<PoiStoreStaff> sellers = poiStoreStaffDOMapper.selectSellersByShopIds(shopsIds);
Map<String, Object> regionAndShop = new HashMap<>();
regionAndShop.put("region", regionDOS);
regionAndShop.put("shop", shops);
regionAndShop.put("seller", sellers);
return regionAndShop;
}

@ -0,0 +1,26 @@
package com.kiisoo.ic.store.bean;
import com.kiisoo.ic.store.entity.PoiStoreStaff;
import lombok.Data;
/**
*
*/
@Data
public class PoiStoreStaffDTO extends PoiStoreStaff {
/**名称*/
private String name;
/**电话*/
private String mobil;
/**邮箱*/
private String email;
/**地址*/
private String address;
/**备注*/
private String remark;
}

@ -23,4 +23,10 @@ public interface PoiStoreStaffDOMapper extends BaseMapper<PoiStoreStaff> {
List<Long> selectByUserId(@Param("userId") Long userId);
/**
*
* @param shopId
* @return
*/
List<PoiStoreStaff> selectSellersByShopIds(@Param("shopId") List<Long> shopId);
}

@ -1,7 +1,10 @@
package com.kiisoo.ic.store.service;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.kiisoo.ic.store.entity.PoiStore;
import com.kiisoo.ic.store.entity.PoiStoreStaff;
import com.kiisoo.ic.store.mapper.PoiStoreDOMapper;
import com.kiisoo.ic.store.mapper.PoiStoreStaffDOMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
@ -16,6 +19,9 @@ public class PoiStoreService {
@Autowired
private PoiStoreDOMapper poiStoreDOMapper;
@Autowired
private PoiStoreStaffDOMapper poiStoreStaffDOMapper;
/**
* id
* @param regionId
@ -24,4 +30,14 @@ public class PoiStoreService {
List<PoiStore> poiStores = poiStoreDOMapper.selectRegionShop(regionId);
return poiStores;
}
/**
* id
* @param shopId id
*/
public List<PoiStoreStaff> getShopSeller(List<Long> shopId){
List<PoiStoreStaff> sellers = poiStoreStaffDOMapper.selectSellersByShopIds(shopId);
return sellers;
}
}

@ -2,7 +2,7 @@
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.kiisoo.ic.customer.mapper.OpCustomerDOMapper">
<select id="selectCustomerInfoByShopIds" resultType="com.kiisoo.ic.customer.entity.OpCustomerDTO">
<select id="selectCustomerInfoByShopIds" resultType="com.kiisoo.ic.customer.bean.OpCustomerDTO">
select
t2.id,t2.`name`,t2.member_id as idCard,GROUP_CONCAT(DISTINCT t0.`name`) as shopName, GROUP_CONCAT(DISTINCT t4.`name`) as sellerName, t3.birthday, t2.phone
from
@ -25,4 +25,17 @@
GROUP BY t2.id
order by t2.id asc
</select>
<select id="selectCustomerInfoBySellerId" resultType="com.kiisoo.ic.customer.bean.OpCustomerDTO">
select
t2.id,t2.`name`,t2.member_id as idCard,GROUP_CONCAT(DISTINCT t0.`name`) as shopName, GROUP_CONCAT(DISTINCT t4.`name`) as sellerName, t3.birthday, t2.phone
from
poi_store t0,
op_seller_customer_relation t1 LEFT JOIN privilage_user t4 on t1.user_id = t4.id,
op_customer t2 LEFT JOIN op_vip t3 on t2.member_id = t3.id
where t0.id = t1.store_id and t1.customer_id = t2.id
and t1.user_id = #{sellerId}
and t1.create_time BETWEEN #{startDate} and #{endDate}
GROUP BY t2.id
order by t2.id asc
</select>
</mapper>

@ -9,5 +9,23 @@
<select id="selectByUserId" resultType="java.lang.Long">
select store_id from poi_store_staff where user_id = #{userId}
</select>
<select id="selectSellersByShopIds" resultType="com.kiisoo.ic.store.bean.PoiStoreStaffDTO">
select
t2.id, t2.name, t2.mobil, t2.email, t2.address, t2.remark, t2.status
from poi_store_staff t1, privilage_user t2
where t1.user_id = t2.id and
<choose>
<when test="shopId != null and shopId.size > 0">
t1.store_id in
<foreach collection="shopId" index="index" item="item" open="(" separator="," close=")">
#{item}
</foreach>
</when>
<otherwise>
1 = 0
</otherwise>
</choose>
group by t1.staff_code
</select>
</mapper>

Loading…
Cancel
Save