店铺对应的推广用户

master
wangweijia 6 years ago
parent c6866b9b30
commit 0d59e84b22

@ -1,6 +1,8 @@
package com.kiisoo.ic.customer;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.kiisoo.ic.constants.Constants;
import com.kiisoo.ic.customer.bean.CustomerDTO;
import com.kiisoo.ic.customer.bean.CustomerModifyDTO;
@ -149,8 +151,16 @@ public class CustomerService {
* id
* @param shopIds
*/
public List<OpCustomerDTO> getCustomerInfoByShopIds(Set<Long> shopIds, Date startDate, Date endDate){
public List<OpCustomerDTO> getCustomerInfoByShopIds(Set<Long> shopIds, Date startDate, Date endDate, int pageNum, int pageSize){
PageHelper.startPage(pageNum,pageSize);
List<OpCustomerDTO> customers = opCustomerDOMapper.selectCustomerInfoByShopIds(shopIds, startDate, endDate);
//求分页总数
Page<OpCustomerDTO> pageList = (Page<OpCustomerDTO>)customers;
Long totalSize = pageList.getTotal();
for (OpCustomerDTO m : customers ) {
m.setTotalSize(totalSize);
}
return customers;
}
@ -171,7 +181,7 @@ public class CustomerService {
* @param startDate
* @param endDate
*/
public List<OpCustomerDTO> getCustomerByUserAndDate(long userId,Long shopId, Long regionId , Long sellerId, Date startDate, Date endDate){
public List<OpCustomerDTO> getCustomerByUserAndDate(long userId,Long shopId, Long regionId , Long sellerId, Date startDate, Date endDate, int pageNum, int pageSize){
Set<Long> shopIds = new HashSet<>();
//根据店铺查询所有扫码客户信息
@ -192,8 +202,16 @@ public class CustomerService {
}
//根据店铺查询所有扫码客户信息
opCustomerDTOS = getCustomerInfoByShopIds(shopIds, startDate, endDate);
opCustomerDTOS = getCustomerInfoByShopIds(shopIds, startDate, endDate,pageNum,pageSize);
return opCustomerDTOS;
}
/**
*
* @param opCustomer
*/
public void editCustomerInfo(OpCustomer opCustomer){
opCustomerDOMapper.updateById(opCustomer);
}
}

@ -27,4 +27,8 @@ public class OpCustomerDTO {
private String phone;
/**vip手机*/
private String vipPhone;
/*
*
*/
private long totalSize;
}

@ -3,14 +3,12 @@ package com.kiisoo.ic.customer.controller;
import com.kiisoo.ic.common.BaseController;
import com.kiisoo.ic.customer.CustomerService;
import com.kiisoo.ic.customer.bean.OpCustomerDTO;
import com.kiisoo.ic.customer.entity.OpCustomer;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.apache.ibatis.annotations.Param;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.*;
import java.text.ParseException;
import java.text.SimpleDateFormat;
@ -32,15 +30,41 @@ public class CustomerController extends BaseController {
@ResponseBody
@PostMapping("/info")
public Map<String, Object> getCustomerInfo(@Param("userId") long userId, Long shopId, Long regionId , Long sellerId,
String startDate, String endDate){
String startDate, String endDate,@RequestParam("pageNum") int pageNum, @RequestParam("pageSize")int pageSize){
SimpleDateFormat sdf = new SimpleDateFormat();
List<OpCustomerDTO> opCustomerDTOS = null;
try {
opCustomerDTOS = customerService.getCustomerByUserAndDate(userId, shopId, regionId, sellerId,
StringUtils.isBlank(startDate) ? null : sdf.parse(startDate), StringUtils.isBlank(endDate) ? null : sdf.parse(endDate));
StringUtils.isBlank(startDate) ? null : sdf.parse(startDate), StringUtils.isBlank(endDate) ? null : sdf.parse(endDate) ,pageNum,pageSize);
return data(opCustomerDTOS);
} catch (ParseException e) {
log.error("日期转换异常:",e);
return fail();
}
}
/**
*
* @param customerId id
* @param name
* @return
*/
@ResponseBody
@PostMapping("/edit/info")
public Map<String, Object> editCustomerInfo(@RequestParam("customerId") long customerId, String name){
try {
if(null!=name){
OpCustomer opCustomer = new OpCustomer();
opCustomer.setId(customerId);
opCustomer.setName(name);
customerService.editCustomerInfo(opCustomer);
}
return success();
} catch (Exception e) {
log.error("修改客户信息异常:",e);
return fail();
}
return data(opCustomerDTOS);
}
}

@ -19,11 +19,25 @@ public class RegionController extends BaseController{
@Autowired
private RegionService regionService;
/**
*
*
*/
@ResponseBody
@PostMapping("/user/region")
public Map<String, Object> saveAccountInput(@RequestParam("userId")long userId) {
return data(regionService.getRegionAndShop(userId));
}
/**
*
*/
@ResponseBody
@PostMapping("/user/only/region")
public Map<String, Object> getUserRegion(@RequestParam("userId")long userId) {
try {
return data(regionService.getUserRegion(userId));
}catch (Exception e){
log.error("查找用户区域",e);
return fail();
}
}
}

@ -0,0 +1,40 @@
package com.kiisoo.ic.store.controller;
import com.kiisoo.ic.common.BaseController;
import com.kiisoo.ic.store.service.PoiStoreService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import java.util.Map;
/**
*
*/
@Controller
@RequestMapping("/poi/store")
@Slf4j
public class PoiStoreController extends BaseController {
@Autowired
private PoiStoreService poiStoreService;
/**
* idid
* @return
*/
@RequestMapping(value = "/user/shop",method = RequestMethod.POST)
@ResponseBody
public Map<String,Object> getUserShop(@RequestParam("userId")long userId, Long regionId){
try {
return data(poiStoreService.getRegionShop(userId,regionId));
}catch (Exception e){
log.error("获取用户店铺失败",e);
return fail();
}
}
}

@ -0,0 +1,41 @@
package com.kiisoo.ic.store.controller;
import com.kiisoo.ic.common.BaseController;
import com.kiisoo.ic.store.service.PoiSellerService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import java.util.Map;
/**
*
*/
@Controller
@RequestMapping("/poi/seller")
@Slf4j
public class PoiStoreStaffController extends BaseController {
@Autowired
private PoiSellerService poiSellerService;
/**
*
* @return
*/
@ResponseBody
@PostMapping("/user/seller")
public Map<String,Object> getSellerData(@RequestParam("userId")long userId, Long shopId, Long regionId){
try {
return data(poiSellerService.getAllSeller(regionId, shopId, userId));
}catch (Exception e){
log.error("查找用户管辖的导购",e);
return fail();
}
}
}

@ -1,8 +1,10 @@
package com.kiisoo.ic.store.controller;
import com.kiisoo.ic.common.BaseController;
import com.kiisoo.ic.store.service.PoiStoreService;
import com.kiisoo.ic.store.service.StoreEmployeeService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
@ -40,4 +42,5 @@ public class StoreEmployeeController extends BaseController {
return fail();
}
}
}

@ -0,0 +1,59 @@
package com.kiisoo.ic.store.service;
import com.kiisoo.ic.domain.service.PrivilageDomainService;
import com.kiisoo.ic.store.bean.PoiStoreStaffDTO;
import com.kiisoo.ic.store.entity.PoiStore;
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;
import java.util.ArrayList;
import java.util.List;
import java.util.stream.Collectors;
/**
*
*/
@Service
public class PoiSellerService {
@Autowired
private PoiStoreStaffDOMapper poiStoreStaffDOMapper;
@Autowired
private PoiStoreService poiStoreService;
@Autowired
private PrivilageDomainService privilageDomainService;
/**
* id
* @param shopId id
*/
public List<PoiStoreStaffDTO> getShopSeller(List<Long> shopId){
List<PoiStoreStaffDTO> sellers = poiStoreStaffDOMapper.selectSellersByShopIds(shopId);
return sellers;
}
/**
*
*/
public List<PoiStoreStaffDTO> getAllSeller(Long regionId, Long shopId, long userId){
List<Long> shopIds = new ArrayList<>();
//先找到店铺
if(null != shopId){
//有店铺就用店铺
shopIds.add(shopId);
}else if(regionId != null){
//有区域就查区域店铺
List<PoiStore> stores = poiStoreService.getRegionShop(regionId);
shopIds = stores.stream().map(i -> i.getId()).collect(Collectors.toList());
}else{
//什么都没有就全查
shopIds = privilageDomainService.listUserDatePermission(userId);
}
List<PoiStoreStaffDTO> sellers = poiStoreStaffDOMapper.selectSellersByShopIds(shopIds);
return sellers;
}
}

@ -1,6 +1,7 @@
package com.kiisoo.ic.store.service;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.kiisoo.ic.domain.service.PrivilageDomainService;
import com.kiisoo.ic.store.bean.PoiStoreStaffDTO;
import com.kiisoo.ic.store.entity.PoiStore;
import com.kiisoo.ic.store.entity.PoiStoreStaff;
@ -23,6 +24,8 @@ public class PoiStoreService {
@Autowired
private PoiStoreStaffDOMapper poiStoreStaffDOMapper;
@Autowired
private PrivilageDomainService privilageDomainService;
/**
* id
* @param regionId
@ -33,12 +36,18 @@ public class PoiStoreService {
}
/**
* id
* @param shopId id
* id
* @param regionId
*/
public List<PoiStoreStaffDTO> getShopSeller(List<Long> shopId){
List<PoiStoreStaffDTO> sellers = poiStoreStaffDOMapper.selectSellersByShopIds(shopId);
return sellers;
public List<PoiStore> getRegionShop(long userId,Long regionId){
List<PoiStore> poiStores;
if(null == regionId){
//找到店铺集合
List<Long> shopsIds = privilageDomainService.listUserDatePermission(userId);
poiStores = poiStoreDOMapper.selectBatchIds(shopsIds);
}else{
poiStores = poiStoreDOMapper.selectRegionShop(regionId);
}
return poiStores;
}
}

Loading…
Cancel
Save