mirror of
https://gitee.com/huangge1199_admin/vue-pro.git
synced 2024-11-22 15:21:53 +08:00
【新增】MALL:拼团结果通知订阅消息
This commit is contained in:
parent
2bc96fe521
commit
b678da810e
@ -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 = "订单发货通知";
|
||||
|
||||
}
|
||||
|
@ -10,7 +10,5 @@ public interface MessageTemplateConstants {
|
||||
//======================= 小程序订阅消息 =======================
|
||||
|
||||
String WALLET_RECHARGER_PAID = "充值成功通知";
|
||||
// TODO @puhui999:这个放在售后那。aftersale
|
||||
String WALLET_RECHARGE_REFUNDED = "退款申请通知";
|
||||
|
||||
}
|
||||
|
@ -40,7 +40,6 @@ import static cn.iocoder.yudao.framework.common.util.number.MoneyUtils.fenToYuan
|
||||
import static cn.iocoder.yudao.module.pay.convert.wallet.PayWalletRechargeConvert.INSTANCE;
|
||||
import static cn.iocoder.yudao.module.pay.enums.ErrorCodeConstants.*;
|
||||
import static cn.iocoder.yudao.module.pay.enums.MessageTemplateConstants.WALLET_RECHARGER_PAID;
|
||||
import static cn.iocoder.yudao.module.pay.enums.MessageTemplateConstants.WALLET_RECHARGE_REFUNDED;
|
||||
import static cn.iocoder.yudao.module.pay.enums.refund.PayRefundStatusEnum.*;
|
||||
|
||||
/**
|
||||
@ -218,26 +217,6 @@ public class PayWalletRechargeServiceImpl implements PayWalletRechargeService {
|
||||
}
|
||||
// 3. 更新钱包充值的退款字段
|
||||
walletRechargeMapper.updateByIdAndRefunded(id, WAITING.getStatus(), updateObj);
|
||||
|
||||
// 4. 发送订阅消息
|
||||
getSelf().sendWalletRechargeRefundedMessage(walletRecharge.getWalletId(), payRefund);
|
||||
}
|
||||
|
||||
@Async
|
||||
public void sendWalletRechargeRefundedMessage(Long walletId, PayRefundDO payRefund) {
|
||||
// 1. 获得会员钱包信息
|
||||
PayWalletDO wallet = payWalletService.getWallet(walletId);
|
||||
// 2. 构建并发送模版消息
|
||||
String thing8 = PayRefundStatusEnum.isSuccess(payRefund.getStatus()) ? SUCCESS.getName() : FAILURE.getName();
|
||||
socialClientApi.sendWxaSubscribeMessage(new SocialWxaSubscribeMessageSendReqDTO()
|
||||
.setUserId(wallet.getUserId()).setUserType(wallet.getUserType())
|
||||
.setTemplateTitle(WALLET_RECHARGE_REFUNDED)
|
||||
.setPage("pages/user/wallet/money") // 钱包详情界面
|
||||
.addMessage("character_string1", String.valueOf(payRefund.getId())) // 退款订单编号
|
||||
.addMessage("time7", LocalDateTimeUtil.formatNormal(payRefund.getCreateTime())) // 申请时间
|
||||
.addMessage("amount3", fenToYuanStr(payRefund.getRefundPrice())) // 退款金额
|
||||
.addMessage("thing4", payRefund.getReason()) // 退款原因
|
||||
.addMessage("thing8", thing8 + ",点击卡片查看详情")); // 温馨提示
|
||||
}
|
||||
|
||||
private PayRefundDO validateWalletRechargeCanRefunded(PayWalletRechargeDO walletRecharge, Long payRefundId) {
|
||||
|
Loading…
Reference in New Issue
Block a user