好友列表接口

master
jiangyunjie 6 years ago
parent ff28655f30
commit 00579203ad

@ -32,6 +32,8 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.time.LocalDate;
import java.util.*;
import java.util.concurrent.atomic.AtomicInteger;
@ -399,25 +401,30 @@ public class CustomerService {
* @param search
* @param roleCode
*/
public Map<String,Object> listCustomer(Long userId,Long sellerId,String search,String roleCode){
public Map<String,Object> listCustomer(Long userId,Long sellerId,String search,String roleCode, Integer type) throws Exception{
Map<String,Object> results = new HashMap<>();
Date thisDate = new Date();
Date lastDate = new Date();
DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
Calendar calendar = Calendar.getInstance();
calendar.set(Calendar.HOUR_OF_DAY, -24);
Date lastDate = dateFormat.parse(dateFormat.format(calendar.getTime()));
calendar.set(Calendar.HOUR_OF_DAY, -24);
Date earlyDate = dateFormat.parse(dateFormat.format(calendar.getTime()));
if (roleCode.equals(RoleEnum.ROLE_CODE_DZ.getRoleCode())){
List<StafferInfoVO> stafferInfoVOS = poiStoreStaffDOMapper.selectInfoById(userId);
Long shopId = stafferInfoVOS.get(0).getStoreId();
List<FriendDTO> thisList = opSellerCustomerRelationDOMapper.selectShopListByDate(shopId,null,sellerId,search,thisDate,thisDate);
List<FriendDTO> thisList = opSellerCustomerRelationDOMapper.selectShopListByDate(shopId,null,sellerId,search,thisDate,thisDate, type);
results.put("this",thisList);
List<FriendDTO> lastList = opSellerCustomerRelationDOMapper.selectShopListByDate(shopId,null,sellerId,search,lastDate,lastDate);
List<FriendDTO> lastList = opSellerCustomerRelationDOMapper.selectShopListByDate(shopId,null,sellerId,search,lastDate,lastDate, type);
results.put("last",lastList);
List<FriendDTO> earlyList = opSellerCustomerRelationDOMapper.selectShopListByDate(shopId,null,sellerId,search,null,lastDate);
List<FriendDTO> earlyList = opSellerCustomerRelationDOMapper.selectShopListByDate(shopId,null,sellerId,search,null,earlyDate, type);
results.put("early",earlyList);
}else{
List<FriendDTO> thisList = opSellerCustomerRelationDOMapper.selectShopListByDate(null,userId,null,search,thisDate,thisDate);
List<FriendDTO> thisList = opSellerCustomerRelationDOMapper.selectShopListByDate(null,userId,null,search,thisDate,thisDate, type);
results.put("this",thisList);
List<FriendDTO> lastList = opSellerCustomerRelationDOMapper.selectShopListByDate(null,userId,null,search,lastDate,lastDate);
List<FriendDTO> lastList = opSellerCustomerRelationDOMapper.selectShopListByDate(null,userId,null,search,lastDate,lastDate, type);
results.put("last",lastList);
List<FriendDTO> earlyList = opSellerCustomerRelationDOMapper.selectShopListByDate(null,userId,null,search,null,lastDate);
List<FriendDTO> earlyList = opSellerCustomerRelationDOMapper.selectShopListByDate(null,userId,null,search,null,earlyDate, type);
results.put("early",earlyList);
}
return results;

@ -48,4 +48,9 @@ public class FriendDTO {
*
*/
private String vipType;
/**
*
*/
private String avatar;
}

@ -70,18 +70,24 @@ public class CustomerController extends BaseController {
}
/**
*
* @param customerId id
* @param name
*
* @param userId
* @param sellerId
* @param search
* @param roleCode
* @param type 1. 2. ()
* @return
*/
@ResponseBody
@PostMapping("/list/friends")
public Map<String, Object> listCustomer(@RequestParam("userId") Long userId,@RequestParam(value = "sellerId",required = false)Long sellerId,
@RequestParam(value = "search",required = false)String search,@RequestParam("roleCode")String roleCode){
public Map<String, Object> listCustomer(@RequestParam("userId") Long userId,
@RequestParam(value = "sellerId",required = false)Long sellerId,
@RequestParam(value = "search",required = false)String search,
@RequestParam("roleCode")String roleCode,
@RequestParam("type") Integer type){
try {
Map<String, Object> stringObjectMap = customerService.listCustomer(userId, sellerId, search, roleCode);
return success();
Map<String, Object> stringObjectMap = customerService.listCustomer(userId, sellerId, search, roleCode, type);
return data(stringObjectMap);
} catch (Exception e) {
log.error("修改客户信息异常:",e);
return fail();

@ -18,12 +18,19 @@ public interface OpSellerCustomerRelationDOMapper extends BaseMapper<OpSellerCus
/**
*
* @param shopId
* @param userId
* @param sellerId
* @param search
* @param startDate
* @param endDate
* @param type
* @return
*/
List<FriendDTO> selectShopListByDate(@Param("shopId") Long shopId, @Param("userId")Long userId, @Param("sellerId")Long sellerId,
@Param("search")String search, @Param("startDate")Date startDate, @Param("endDate")Date endDate);
List<FriendDTO> selectShopListByDate(@Param("shopId") Long shopId,
@Param("userId") Long userId,
@Param("sellerId") Long sellerId,
@Param("search") String search,
@Param("startDate") Date startDate,
@Param("endDate") Date endDate,
@Param("type") Integer type);
}

@ -2,20 +2,40 @@
<!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.OpSellerCustomerRelationDOMapper">
<select id="selectShopListByDate" resultType="com.kiisoo.ic.customer.bean.FriendDTO">
select t2.name as customerName,t2.id as customerId,t2.phone as mobile,t5.name as inviteSellerName,t4.id as inviteSellerId,t1.create_time as addTime
from op_seller_customer_relation t1,op_customer t2,poi_store_staff t4,privilage_user t5
where t1.customer_id = t2.id
and t1.user_id = t5.userId
and t1.user_id = t4.user_id
and t1.store_id = t4.store_id
SELECT
t2.NAME AS customerName,
t2.id AS customerId,
t2.phone AS mobile,
t5.NAME AS inviteSellerName,
t4.id AS inviteSellerId,
t1.create_time AS addTime,
t6.avatar
FROM
op_seller_customer_relation t1,
op_customer t2 left join op_vip t3 on t2.member_id = t3.id and t3.status = 1,
poi_store_staff t4,
privilage_user t5,
op_customer_enterprise_wechat t6
WHERE
t1.customer_id = t2.id
AND t1.user_id = t5.id
AND t1.user_id = t4.user_id
AND t1.store_id = t4.store_id
and t2.id = t6.customer_id
<if test="type == 1">
and t3.id is not null
</if>
<if test="type == 2">
and t3.id is null
</if>
<if test="userId != null">
t1.user_id = #{userId}
and t1.user_id = #{userId}
</if>
<if test="shopId != null">
t1.store_id = #{shopId}
and t1.store_id = #{shopId}
</if>
<if test="sellerId != null">
t4.id = #{sellerId}
<if test="sellerId != null and sellerId != 0">
and t4.id = #{sellerId}
</if>
<if test="search != null and search !=''">
and
@ -23,10 +43,10 @@
LIKE CONCAT('%',#{search},'%')
</if>
<if test="startDate != null">
DATE_FORMAT(t1.create_time,'%Y-%m-%d') &gt;= DATE_FORMAT(#{startDate},'%Y-%m-%d')
and DATE_FORMAT(t1.create_time,'%Y-%m-%d') &gt;= DATE_FORMAT(#{startDate},'%Y-%m-%d')
</if>
<if test="endDate != null">
DATE_FORMAT(t1.create_time,'%Y-%m-%d') &lt;= DATE_FORMAT(#{endDate},'%Y-%m-%d')
and DATE_FORMAT(t1.create_time,'%Y-%m-%d') &lt;= DATE_FORMAT(#{endDate},'%Y-%m-%d')
</if>
</select>
</mapper>

Loading…
Cancel
Save