好友列表接口

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.stereotype.Service;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.time.LocalDate; import java.time.LocalDate;
import java.util.*; import java.util.*;
import java.util.concurrent.atomic.AtomicInteger; import java.util.concurrent.atomic.AtomicInteger;
@ -399,25 +401,30 @@ public class CustomerService {
* @param search * @param search
* @param roleCode * @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<>(); Map<String,Object> results = new HashMap<>();
Date thisDate = new Date(); 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())){ if (roleCode.equals(RoleEnum.ROLE_CODE_DZ.getRoleCode())){
List<StafferInfoVO> stafferInfoVOS = poiStoreStaffDOMapper.selectInfoById(userId); List<StafferInfoVO> stafferInfoVOS = poiStoreStaffDOMapper.selectInfoById(userId);
Long shopId = stafferInfoVOS.get(0).getStoreId(); 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); 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); 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); results.put("early",earlyList);
}else{ }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); 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); 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); results.put("early",earlyList);
} }
return results; return results;

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

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

@ -18,12 +18,19 @@ public interface OpSellerCustomerRelationDOMapper extends BaseMapper<OpSellerCus
/** /**
* *
* @param shopId * @param shopId
* @param userId
* @param sellerId * @param sellerId
* @param search * @param search
* @param startDate * @param startDate
* @param endDate * @param endDate
* @param type
* @return * @return
*/ */
List<FriendDTO> selectShopListByDate(@Param("shopId") Long shopId, @Param("userId")Long userId, @Param("sellerId")Long sellerId, List<FriendDTO> selectShopListByDate(@Param("shopId") Long shopId,
@Param("search")String search, @Param("startDate")Date startDate, @Param("endDate")Date endDate); @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"> <!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"> <mapper namespace="com.kiisoo.ic.customer.mapper.OpSellerCustomerRelationDOMapper">
<select id="selectShopListByDate" resultType="com.kiisoo.ic.customer.bean.FriendDTO"> <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 SELECT
from op_seller_customer_relation t1,op_customer t2,poi_store_staff t4,privilage_user t5 t2.NAME AS customerName,
where t1.customer_id = t2.id t2.id AS customerId,
and t1.user_id = t5.userId t2.phone AS mobile,
and t1.user_id = t4.user_id t5.NAME AS inviteSellerName,
and t1.store_id = t4.store_id 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"> <if test="userId != null">
t1.user_id = #{userId} and t1.user_id = #{userId}
</if> </if>
<if test="shopId != null"> <if test="shopId != null">
t1.store_id = #{shopId} and t1.store_id = #{shopId}
</if> </if>
<if test="sellerId != null"> <if test="sellerId != null and sellerId != 0">
t4.id = #{sellerId} and t4.id = #{sellerId}
</if> </if>
<if test="search != null and search !=''"> <if test="search != null and search !=''">
and and
@ -23,10 +43,10 @@
LIKE CONCAT('%',#{search},'%') LIKE CONCAT('%',#{search},'%')
</if> </if>
<if test="startDate != null"> <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>
<if test="endDate != null"> <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> </if>
</select> </select>
</mapper> </mapper>

Loading…
Cancel
Save