mirror of
https://gitee.com/hhyykk/ipms-sjy.git
synced 2025-07-25 00:15:06 +08:00
【新增】MALL:拼团结果通知订阅消息
This commit is contained in:
@ -0,0 +1,14 @@
|
||||
package cn.iocoder.yudao.module.promotion.enums;
|
||||
|
||||
/**
|
||||
* 通知模板枚举类
|
||||
*
|
||||
* @author HUIHUI
|
||||
*/
|
||||
public interface MessageTemplateConstants {
|
||||
|
||||
//======================= 小程序订阅消息模版 =======================
|
||||
|
||||
String COMBINATION_RESULT = "拼团结果通知";
|
||||
|
||||
}
|
@ -5,6 +5,7 @@ import cn.hutool.core.util.ObjUtil;
|
||||
import cn.hutool.extra.spring.SpringUtil;
|
||||
import cn.iocoder.yudao.framework.common.core.KeyValue;
|
||||
import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum;
|
||||
import cn.iocoder.yudao.framework.common.enums.UserTypeEnum;
|
||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||
import cn.iocoder.yudao.framework.common.util.json.JsonUtils;
|
||||
import cn.iocoder.yudao.module.member.api.user.MemberUserApi;
|
||||
@ -23,11 +24,14 @@ import cn.iocoder.yudao.module.promotion.dal.dataobject.combination.CombinationP
|
||||
import cn.iocoder.yudao.module.promotion.dal.dataobject.combination.CombinationRecordDO;
|
||||
import cn.iocoder.yudao.module.promotion.dal.mysql.combination.CombinationRecordMapper;
|
||||
import cn.iocoder.yudao.module.promotion.enums.combination.CombinationRecordStatusEnum;
|
||||
import cn.iocoder.yudao.module.system.api.social.SocialClientApi;
|
||||
import cn.iocoder.yudao.module.system.api.social.dto.SocialWxaSubscribeMessageSendReqDTO;
|
||||
import cn.iocoder.yudao.module.trade.api.order.TradeOrderApi;
|
||||
import jakarta.annotation.Nullable;
|
||||
import jakarta.annotation.Resource;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.context.annotation.Lazy;
|
||||
import org.springframework.scheduling.annotation.Async;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
@ -40,6 +44,7 @@ import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.
|
||||
import static cn.iocoder.yudao.framework.common.util.date.LocalDateTimeUtils.afterNow;
|
||||
import static cn.iocoder.yudao.framework.common.util.date.LocalDateTimeUtils.beforeNow;
|
||||
import static cn.iocoder.yudao.module.promotion.enums.ErrorCodeConstants.*;
|
||||
import static cn.iocoder.yudao.module.promotion.enums.MessageTemplateConstants.COMBINATION_RESULT;
|
||||
|
||||
// TODO 芋艿:等拼团记录做完,完整 review 下
|
||||
|
||||
@ -68,6 +73,8 @@ public class CombinationRecordServiceImpl implements CombinationRecordService {
|
||||
@Resource
|
||||
@Lazy // 延迟加载,避免循环依赖
|
||||
private TradeOrderApi tradeOrderApi;
|
||||
@Resource
|
||||
public SocialClientApi socialClientApi;
|
||||
|
||||
// TODO @芋艿:在详细预览下;
|
||||
@Override
|
||||
@ -205,7 +212,25 @@ public class CombinationRecordServiceImpl implements CombinationRecordService {
|
||||
}
|
||||
updateRecords.add(updateRecord);
|
||||
});
|
||||
combinationRecordMapper.updateBatch(updateRecords);
|
||||
Boolean result = combinationRecordMapper.updateBatch(updateRecords);
|
||||
|
||||
// 3. 拼团成功发送订阅消息
|
||||
if (result && isFull) {
|
||||
records.forEach(item -> {
|
||||
getSelf().sendCombinationResultMessage(item);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@Async
|
||||
public void sendCombinationResultMessage(CombinationRecordDO record) {
|
||||
// 构建并发送模版消息
|
||||
socialClientApi.sendWxaSubscribeMessage(new SocialWxaSubscribeMessageSendReqDTO()
|
||||
.setUserId(record.getUserId()).setUserType(UserTypeEnum.MEMBER.getValue())
|
||||
.setTemplateTitle(COMBINATION_RESULT)
|
||||
.setPage("pages/order/detail?id=" + record.getOrderId()) // 订单详情页
|
||||
.addMessage("thing1", "商品拼团活动") // 活动标题
|
||||
.addMessage("thing2", "恭喜您拼团成功!我们将尽快为您发货。")); // 温馨提示
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -16,7 +16,6 @@ public interface MessageTemplateConstants {
|
||||
|
||||
//======================= 小程序订阅消息模版 =======================
|
||||
|
||||
String TRADE_AFTER_SALE_CHANGE = "售后进度通知";
|
||||
String DELIVERY_ORDER = "订单发货通知";
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user