From e1c5519ee7589063bca7c7d021cfa3bd8dba192a Mon Sep 17 00:00:00 2001 From: jiangyunjie Date: Wed, 29 Apr 2020 21:26:37 +0800 Subject: [PATCH] bug --- .../kiisoo/ic/customer/CustomerService.java | 23 +++++++++++-- .../kiisoo/ic/customer/bean/FriendDTO.java | 2 +- .../OpSellerCustomerRelationDOMapper.java | 7 ++++ .../mapper/StorePromotionDataDOMapper.java | 20 +++++++---- .../service/StorePromotionDataService.java | 12 +++---- .../OpSellerCustomerRelationDOMapper.xml | 19 ++++++----- .../mapper/StorePromotionDataDOMapper.xml | 33 ++++++++++--------- 7 files changed, 75 insertions(+), 41 deletions(-) diff --git a/src/main/java/com/kiisoo/ic/customer/CustomerService.java b/src/main/java/com/kiisoo/ic/customer/CustomerService.java index d3619e3..836c892 100644 --- a/src/main/java/com/kiisoo/ic/customer/CustomerService.java +++ b/src/main/java/com/kiisoo/ic/customer/CustomerService.java @@ -33,6 +33,7 @@ import com.kiisoo.ic.synchronous.entity.VipDataDTO; import com.kiisoo.ic.system.enums.RoleEnum; import com.kiisoo.ic.webappmy.vo.StafferInfoVO; import lombok.extern.slf4j.Slf4j; +import org.apache.commons.lang3.StringUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; @@ -439,10 +440,28 @@ public class CustomerService { Long shopId = stafferInfoVOS.get(0).getStoreId(); if (roleCode.equals(RoleEnum.ROLE_CODE_DZ.getRoleCode())) { List thisList = opSellerCustomerRelationDOMapper.selectFriendListByShopId(shopId, sellerId, search, thisDate, thisDate, type); - results.put("this", thisList); + thisList.forEach(friendDTO -> { + String inviteSellerName = opSellerCustomerRelationDOMapper.selectStaffName(friendDTO.getInviteSellerId()); + if (StringUtils.isNotBlank(inviteSellerName)) { + friendDTO.setInviteSellerName(inviteSellerName); + } + }); List lastList = opSellerCustomerRelationDOMapper.selectFriendListByShopId(shopId, sellerId, search, lastDate, lastDate, type); - results.put("last", lastList); + lastList.forEach(friendDTO -> { + String inviteSellerName = opSellerCustomerRelationDOMapper.selectStaffName(friendDTO.getInviteSellerId()); + if (StringUtils.isNotBlank(inviteSellerName)) { + friendDTO.setInviteSellerName(inviteSellerName); + } + }); List earlyList = opSellerCustomerRelationDOMapper.selectFriendListByShopId(shopId, sellerId, search, null, earlyDate, type); + earlyList.forEach(friendDTO -> { + String inviteSellerName = opSellerCustomerRelationDOMapper.selectStaffName(friendDTO.getInviteSellerId()); + if (StringUtils.isNotBlank(inviteSellerName)) { + friendDTO.setInviteSellerName(inviteSellerName); + } + }); + results.put("this", thisList); + results.put("last", lastList); results.put("early", earlyList); } else { List thisList = opSellerCustomerRelationDOMapper.selectFriendListBySeller(userId, search, thisDate, thisDate, type); diff --git a/src/main/java/com/kiisoo/ic/customer/bean/FriendDTO.java b/src/main/java/com/kiisoo/ic/customer/bean/FriendDTO.java index 43b4165..6055391 100644 --- a/src/main/java/com/kiisoo/ic/customer/bean/FriendDTO.java +++ b/src/main/java/com/kiisoo/ic/customer/bean/FriendDTO.java @@ -37,7 +37,7 @@ public class FriendDTO { /** * 邀请的导购id */ - private String inviteSellerId; + private Long inviteSellerId; /** * 添加时间 diff --git a/src/main/java/com/kiisoo/ic/customer/mapper/OpSellerCustomerRelationDOMapper.java b/src/main/java/com/kiisoo/ic/customer/mapper/OpSellerCustomerRelationDOMapper.java index 07bf0cd..13382e8 100644 --- a/src/main/java/com/kiisoo/ic/customer/mapper/OpSellerCustomerRelationDOMapper.java +++ b/src/main/java/com/kiisoo/ic/customer/mapper/OpSellerCustomerRelationDOMapper.java @@ -48,6 +48,13 @@ public interface OpSellerCustomerRelationDOMapper extends BaseMapper> selectAllCustomer(@Param("ids") List ids); List> selectAllCustomer1(@Param("ids") List ids); diff --git a/src/main/java/com/kiisoo/ic/store/mapper/StorePromotionDataDOMapper.java b/src/main/java/com/kiisoo/ic/store/mapper/StorePromotionDataDOMapper.java index 8270555..54b54b4 100644 --- a/src/main/java/com/kiisoo/ic/store/mapper/StorePromotionDataDOMapper.java +++ b/src/main/java/com/kiisoo/ic/store/mapper/StorePromotionDataDOMapper.java @@ -135,19 +135,25 @@ public interface StorePromotionDataDOMapper { @Param("endDate") Date endDate); /** - * 条件查询新增好友数 或总客户数 - * @param userId + * 条件查询新增好友数 或总客户数 (店长) * @param storeId * @param startDate * @param endDate - * @param type 门店导购客户关系表Type 1.有效(去重)、2.无效 * @return */ - Integer selectWxSumCusNumByCondition(@Param("userId") Long userId, - @Param("storeId") Long storeId, + Integer selectWxSumCusNumByConditionShopManager(@Param("storeId") Long storeId, + @Param("startDate") Date startDate, + @Param("endDate") Date endDate); + /** + * 条件查询新增好友数 或总客户数 (导购) + * @param userId + * @param startDate + * @param endDate + * @return + */ + Integer selectWxSumCusNumByConditionStaff(@Param("userId") Long userId, @Param("startDate") Date startDate, - @Param("endDate") Date endDate, - @Param("type") Integer type); + @Param("endDate") Date endDate); /** * 查询店长的店铺id diff --git a/src/main/java/com/kiisoo/ic/store/service/StorePromotionDataService.java b/src/main/java/com/kiisoo/ic/store/service/StorePromotionDataService.java index 984b1d2..bcb22b3 100644 --- a/src/main/java/com/kiisoo/ic/store/service/StorePromotionDataService.java +++ b/src/main/java/com/kiisoo/ic/store/service/StorePromotionDataService.java @@ -327,9 +327,9 @@ public class StorePromotionDataService { switch (roleCode) { // 店长 case Constants.WX_USER_ROLE_SHOP_MANAGER: - cusNum = storePromotionDataDOMapper.selectWxSumCusNumByCondition(null, storeId, null, null, null); - newCusNum = storePromotionDataDOMapper.selectWxSumCusNumByCondition(null, storeId, startDate, endDate, null); - newCusNumLast = storePromotionDataDOMapper.selectWxSumCusNumByCondition(null, storeId, lastStartDate, lastEndDate, null); + cusNum = storePromotionDataDOMapper.selectWxSumCusNumByConditionShopManager(storeId, null, null); + newCusNum = storePromotionDataDOMapper.selectWxSumCusNumByConditionShopManager(storeId, startDate, endDate); + newCusNumLast = storePromotionDataDOMapper.selectWxSumCusNumByConditionShopManager(storeId, lastStartDate, lastEndDate); // 店铺排名 List storeRankNoList = storePromotionDataDOMapper.selectStoreRankNo(startDate, endDate); if (CollectionUtils.isNotEmpty(storeRankNoList)) { @@ -372,9 +372,9 @@ public class StorePromotionDataService { break; // 导购 case Constants.WX_USER_ROLE_STAFF: - cusNum = storePromotionDataDOMapper.selectWxSumCusNumByCondition(userId, null, null, null, null); - newCusNum = storePromotionDataDOMapper.selectWxSumCusNumByCondition(userId, null, startDate, endDate, null); - newCusNumLast = storePromotionDataDOMapper.selectWxSumCusNumByCondition(userId, null, lastStartDate, lastEndDate, null); + cusNum = storePromotionDataDOMapper.selectWxSumCusNumByConditionStaff(userId, null, null); + newCusNum = storePromotionDataDOMapper.selectWxSumCusNumByConditionStaff(userId, startDate, endDate); + newCusNumLast = storePromotionDataDOMapper.selectWxSumCusNumByConditionStaff(userId, lastStartDate, lastEndDate); // 店铺排名 List staffRankNoList = storePromotionDataDOMapper.selectStaffRankNo(startDate, endDate, storeId); if (CollectionUtils.isNotEmpty(staffRankNoList)) { diff --git a/src/main/resources/mapper/OpSellerCustomerRelationDOMapper.xml b/src/main/resources/mapper/OpSellerCustomerRelationDOMapper.xml index 406888a..4933415 100644 --- a/src/main/resources/mapper/OpSellerCustomerRelationDOMapper.xml +++ b/src/main/resources/mapper/OpSellerCustomerRelationDOMapper.xml @@ -8,7 +8,7 @@ t2.id AS customerId, t2.phone AS mobile, t5.NAME AS inviteSellerName, - t4.user_id AS inviteSellerId, + t4.id AS inviteSellerId, t1.create_time AS addTime, t2.avatar_url as avatar, t3.level as vipFlag @@ -19,8 +19,8 @@ privilage_user t5 WHERE t1.customer_id = t2.id - AND t1.user_id = t5.id - AND t1.user_id = t4.user_id + AND t1.user_id = t4.id + AND t4.user_id = t5.id AND t1.store_id = t4.store_id and t3.id is not null @@ -50,18 +50,15 @@ t2.NAME AS customerName, t2.id AS customerId, t2.phone AS mobile, - t4.user_id AS inviteSellerId, + t1.user_id AS inviteSellerId, t1.create_time AS addTime, t2.avatar_url as avatar, t3.level as vipFlag 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 + op_customer t2 left join op_vip t3 on t2.member_id = t3.id and t3.status = 1 WHERE t1.customer_id = t2.id - AND t1.user_id = t4.user_id - AND t1.store_id = t4.store_id and t3.id is not null @@ -72,7 +69,7 @@ and t1.store_id = #{shopId} - and t4.user_id = #{sellerId} + and t1.user_id = #{sellerId} and @@ -87,6 +84,10 @@ order by t1.create_time desc + + - SELECT count(customer_id) from op_seller_customer_relation - where 1 = 1 - - AND user_id = #{userId} - - - AND store_id = #{storeId} - + WHERE store_id = #{storeId} and DATE_FORMAT(create_time,'%Y-%m-%d') >= DATE_FORMAT(#{startDate},'%Y-%m-%d') and DATE_FORMAT(create_time,'%Y-%m-%d') <= DATE_FORMAT(#{endDate},'%Y-%m-%d') - - AND `type` = #{type} - + group by store_id + + + SELECT DISTINCT - t1.user_id as id, + t1.id as id, t2.NAME AS staffName FROM poi_store_staff t1, @@ -388,7 +389,7 @@ FROM ( SELECT count( t2.customer_id ) AS newCusNum, t1.user_id AS userId FROM poi_store_staff t1 - LEFT JOIN `op_seller_customer_relation` t2 ON t1.user_id = t2.user_id + LEFT JOIN `op_seller_customer_relation` t2 ON t1.id = t2.user_id and DATE_FORMAT(t2.create_time,'%Y-%m-%d') >= DATE_FORMAT(#{startDate},'%Y-%m-%d')