This commit is contained in:
2025-12-01 10:49:36 +08:00
parent f8a23a3342
commit 601656e97b
4 changed files with 24 additions and 15 deletions

View File

@@ -4,6 +4,7 @@ import com.mybatisflex.annotation.Column;
import com.mybatisflex.annotation.Id;
import com.mybatisflex.annotation.KeyType;
import com.mybatisflex.annotation.Table;
import java.io.Serializable;
import java.time.LocalDateTime;
@@ -45,6 +46,10 @@ public class BkContactList implements Serializable {
* 电话号码
*/
private String phone;
/**
* 昵称
*/
private String nickName;
/**
* 历史订单数

View File

@@ -18,5 +18,5 @@ public interface BkContactListMapper extends BaseMapper<BkContactList> {
* @param shopId 店铺ID
* @return 通讯录联系人列表
*/
List<BkContactList> getUserList(Long shopId);
List<BkContactList> getUserList(Long shopId, Long mainShopId);
}

View File

@@ -1,12 +1,13 @@
package com.czg.service.account.service.impl;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.util.StrUtil;
import com.mybatisflex.core.query.QueryWrapper;
import com.mybatisflex.spring.service.impl.ServiceImpl;
import com.czg.account.entity.BkContactList;
import com.czg.account.service.BkContactListService;
import com.czg.account.service.ShopInfoService;
import com.czg.service.account.mapper.BkContactListMapper;
import com.mybatisflex.core.query.QueryWrapper;
import com.mybatisflex.spring.service.impl.ServiceImpl;
import jakarta.annotation.Resource;
import org.springframework.stereotype.Service;
import java.util.List;
@@ -21,6 +22,8 @@ import java.util.stream.Collectors;
*/
@Service
public class BkContactListServiceImpl extends ServiceImpl<BkContactListMapper, BkContactList> implements BkContactListService {
@Resource
private ShopInfoService shopInfoService;
@Override
public List<BkContactList> getUserList(Long shopId, Set<String> phones) {
@@ -35,6 +38,7 @@ public class BkContactListServiceImpl extends ServiceImpl<BkContactListMapper, B
})
.collect(Collectors.toList());
mapper.insertBatch(collect, 50);
return mapper.getUserList(shopId);
Long mainShopId = shopInfoService.getMainIdByShopId(shopId);
return mapper.getUserList(shopId, mainShopId);
}
}

View File

@@ -5,16 +5,16 @@
<mapper namespace="com.czg.service.account.mapper.BkContactListMapper">
<select id="getUserList" resultType="com.czg.account.entity.BkContactList">
SELECT
`order`.call_phone AS phone,
count( 1 ) AS orderNum,
sum( CASE `order`.`status` WHEN '已取消' THEN 1 ELSE 0 END ) AS cancelNum,
MAX(`order`.create_time) AS lastBookingTime
FROM
`bk_order` `order`
INNER JOIN bk_contact_list contact ON `order`.call_phone = contact.phone AND contact.shop_id = #{shopId}
WHERE
`order`.shop_id = #{shopId}
SELECT user.nick_name AS nickName,
`order`.call_phone AS phone,
count(1) AS orderNum,
sum(CASE `order`.`status` WHEN '已取消' THEN 1 ELSE 0 END) AS cancelNum,
MAX(`order`.create_time) AS lastBookingTime
FROM `bk_order` `order`
INNER JOIN bk_contact_list contact
ON `order`.call_phone = contact.phone AND contact.shop_id = #{shopId}
LEFT JOIN tb_shop_user user ON `contact`.phone = user.phone and user.main_shop_id = #{mainShopId}
WHERE `order`.shop_id = #{shopId}
GROUP BY `order`.call_phone
</select>
</mapper>