Commit ad3bb6bd by 林永健

refactor(push): 优化每日BI动态推送逻辑及相关数据查询

- 重构策略数据分组逻辑,按 merchantId + biz 组合键处理
- 改进门店配置缓存获取,支持批量查询多业务类型
- 新增按门店与业务类型批量查询关注明细方法,减少查询次数
- 统一使用 StrategyInfo 替代 MerchantBiFollow 作为推送中数据载体
- 优化推送流程,确保无动态数据或无配置时跳过推送
- 服务层调整,wechatPushService 接口改用 StrategyInfo 参数
- Mapper及XML新增按门店及业务类型查询关注明细接口及映射
- 实体类 MerchantBiFollowDetail 新增 transient 字段存储关联商户和业务类型ID
- 移除冗余导入,提升代码整洁性和可维护性
1 parent cf416a12
......@@ -78,5 +78,10 @@ public class MerchantBiFollowDetail implements Serializable {
@Column(name = "deleted_flag")
private String deletedFlag;
@Transient
private Integer merchantId;
@Transient
private Integer businessType;
private static final long serialVersionUID = 1L;
}
\ No newline at end of file
......@@ -49,4 +49,6 @@ public interface MerchantBiFollowDetailMapper extends OreMapper<MerchantBiFollow
* @return 所有关注明细列表
*/
List<MerchantBiFollowDetail> batchFindByFollowId(@Param("followIds") List<Integer> followIds);
List<MerchantBiFollowDetail> findByMerchantIdsAndBizs(@Param("merchantIds") List<Integer> merchantIds, @Param("bizs") List<Byte> bizs);
}
\ No newline at end of file
......@@ -8,6 +8,7 @@ import cn.com.glsx.dj.peanalysis.dto.analysis.MerchantBiCommentReq;
import cn.com.glsx.dj.peanalysis.dto.analysis.MerchantBiFollowReq;
import cn.com.glsx.dj.peanalysis.model.MerchantBiFollow;
import cn.com.glsx.dj.peanalysis.utils.MetricsValueUtils;
import cn.com.glsx.dj.strategy.model.StrategyInfo;
import cn.com.glsx.framework.core.beans.rpc.RpcResponse;
import cn.com.glsx.framework.core.exception.RpcServiceException;
import cn.com.glsx.scrm.wechat.enums.WorkWechatAppMessageTypeEnum;
......@@ -77,17 +78,18 @@ public class WechatPushService {
/**
* 每日动态汇总推送
*/
public void pushDailySummaryMsg(MerchantBiFollow req, int count, List<String> targetUuids, boolean isFollower) {
public void pushDailySummaryMsg(StrategyInfo req, int count, List<String> targetUuids, boolean isFollower) {
byte businessType = req.getBiz().byteValue();
String prefix = isFollower ? "你关注的" : "你负责的";
String content = String.format("%s「%s」门店:「%s」昨日共有「%d」条动态,请及时查看。",
prefix, MetricsValueUtils.getBusinessTypeName(req.getBusinessType()), req.getMerchantName(), count);
prefix, MetricsValueUtils.getBusinessTypeName(businessType), req.getMerchantName(), count);
WechatPushParam param = WechatPushParam.builder()
.title("日常跟进提醒")
.content(content)
.storeId(req.getMerchantId())
.storeName(req.getMerchantName())
.businessTypeCode(req.getBusinessType())
.businessTypeCode(businessType)
.targetUuids(targetUuids)
.build();
......
......@@ -13,6 +13,10 @@
<result column="updated_date" jdbcType="TIMESTAMP" property="updatedDate" />
<result column="deleted_flag" jdbcType="CHAR" property="deletedFlag" />
</resultMap>
<resultMap id="WithMerchant" extends="BaseResultMap" type="cn.com.glsx.dj.peanalysis.model.MerchantBiFollowDetail">
<result column="merchant_id" jdbcType="INTEGER" property="merchantId" />
<result column="business_type" jdbcType="VARCHAR" property="businessType" />
</resultMap>
<sql id="Base_Column_List">
id, follow_id, staff_uuid, staff_phone, staff_name, created_by, created_date, updated_by,
......@@ -88,4 +92,25 @@
</foreach>
AND deleted_flag = 'N'
</select>
<select id="findByMerchantIdsAndBizs" resultMap="WithMerchant">
SELECT
d.*, f.merchant_id, f.business_type
FROM dj_merchant_bi_follow_detail d
left join dj_merchant_bi_follow f on d.follow_id = f.id
<where>
AND d.deleted_flag = 'N'
AND f.deleted_flag = 'N'
and f.merchant_id IN
<foreach collection="merchantIds" item="id" open="(" separator="," close=")">
#{id}
</foreach>
<if test="bizs != null and bizs.size() > 0">
and f.business_type IN
<foreach collection="bizs" item="id" open="(" separator="," close=")">
#{id}
</foreach>
</if>
</where>
</select>
</mapper>
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!