Commit ba187885172e42054231103760560dd8c8ddde0d
1 parent
1f65dd2e
【代码优化】SYSTEM:微信小程序的订阅
Showing
10 changed files
with
26 additions
and
22 deletions
yudao-module-mall/yudao-module-promotion-api/src/main/java/cn/iocoder/yudao/module/promotion/enums/MessageTemplateConstants.java
yudao-module-mall/yudao-module-promotion-biz/src/main/java/cn/iocoder/yudao/module/promotion/service/combination/CombinationRecordServiceImpl.java
| ... | ... | @@ -44,7 +44,7 @@ import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils. |
| 44 | 44 | import static cn.iocoder.yudao.framework.common.util.date.LocalDateTimeUtils.afterNow; |
| 45 | 45 | import static cn.iocoder.yudao.framework.common.util.date.LocalDateTimeUtils.beforeNow; |
| 46 | 46 | import static cn.iocoder.yudao.module.promotion.enums.ErrorCodeConstants.*; |
| 47 | -import static cn.iocoder.yudao.module.promotion.enums.MessageTemplateConstants.COMBINATION_RESULT; | |
| 47 | +import static cn.iocoder.yudao.module.promotion.enums.MessageTemplateConstants.COMBINATION_SUCCESS; | |
| 48 | 48 | |
| 49 | 49 | // TODO 芋艿:等拼团记录做完,完整 review 下 |
| 50 | 50 | |
| ... | ... | @@ -212,10 +212,10 @@ public class CombinationRecordServiceImpl implements CombinationRecordService { |
| 212 | 212 | } |
| 213 | 213 | updateRecords.add(updateRecord); |
| 214 | 214 | }); |
| 215 | - Boolean result = combinationRecordMapper.updateBatch(updateRecords); | |
| 215 | + Boolean updateSuccess = combinationRecordMapper.updateBatch(updateRecords); | |
| 216 | 216 | |
| 217 | 217 | // 3. 拼团成功发送订阅消息 |
| 218 | - if (result && isFull) { | |
| 218 | + if (updateSuccess && isFull) { | |
| 219 | 219 | records.forEach(item -> { |
| 220 | 220 | getSelf().sendCombinationResultMessage(item); |
| 221 | 221 | }); |
| ... | ... | @@ -227,7 +227,7 @@ public class CombinationRecordServiceImpl implements CombinationRecordService { |
| 227 | 227 | // 构建并发送模版消息 |
| 228 | 228 | socialClientApi.sendWxaSubscribeMessage(new SocialWxaSubscribeMessageSendReqDTO() |
| 229 | 229 | .setUserId(record.getUserId()).setUserType(UserTypeEnum.MEMBER.getValue()) |
| 230 | - .setTemplateTitle(COMBINATION_RESULT) | |
| 230 | + .setTemplateTitle(COMBINATION_SUCCESS) | |
| 231 | 231 | .setPage("pages/order/detail?id=" + record.getOrderId()) // 订单详情页 |
| 232 | 232 | .addMessage("thing1", "商品拼团活动") // 活动标题 |
| 233 | 233 | .addMessage("thing2", "恭喜您拼团成功!我们将尽快为您发货。")); // 温馨提示 | ... | ... |
yudao-module-mall/yudao-module-trade-api/src/main/java/cn/iocoder/yudao/module/trade/enums/MessageTemplateConstants.java
| ... | ... | @@ -7,15 +7,15 @@ package cn.iocoder.yudao.module.trade.enums; |
| 7 | 7 | */ |
| 8 | 8 | public interface MessageTemplateConstants { |
| 9 | 9 | |
| 10 | - //======================= 短信消息模版 ======================= | |
| 10 | + // ======================= 短信消息模版 ======================= | |
| 11 | 11 | |
| 12 | - String ORDER_DELIVERY = "order_delivery"; // 短信模版编号 | |
| 12 | + String SMS_ORDER_DELIVERY = "order_delivery"; // 短信模版编号 | |
| 13 | 13 | |
| 14 | - String BROKERAGE_WITHDRAW_AUDIT_APPROVE = "brokerage_withdraw_audit_approve"; // 佣金提现(审核通过) | |
| 15 | - String BROKERAGE_WITHDRAW_AUDIT_REJECT = "brokerage_withdraw_audit_reject"; // 佣金提现(审核不通过) | |
| 14 | + String SMS_BROKERAGE_WITHDRAW_AUDIT_APPROVE = "brokerage_withdraw_audit_approve"; // 佣金提现(审核通过) | |
| 15 | + String SMS_BROKERAGE_WITHDRAW_AUDIT_REJECT = "brokerage_withdraw_audit_reject"; // 佣金提现(审核不通过) | |
| 16 | 16 | |
| 17 | - //======================= 小程序订阅消息模版 ======================= | |
| 17 | + // ======================= 小程序订阅消息模版 ======================= | |
| 18 | 18 | |
| 19 | - String DELIVERY_ORDER = "订单发货通知"; | |
| 19 | + String WXA_ORDER_DELIVERY = "订单发货通知"; | |
| 20 | 20 | |
| 21 | 21 | } | ... | ... |
yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/brokerage/BrokerageWithdrawServiceImpl.java
| ... | ... | @@ -77,14 +77,14 @@ public class BrokerageWithdrawServiceImpl implements BrokerageWithdrawService { |
| 77 | 77 | |
| 78 | 78 | String templateCode; |
| 79 | 79 | if (BrokerageWithdrawStatusEnum.AUDIT_SUCCESS.equals(status)) { |
| 80 | - templateCode = MessageTemplateConstants.BROKERAGE_WITHDRAW_AUDIT_APPROVE; | |
| 80 | + templateCode = MessageTemplateConstants.SMS_BROKERAGE_WITHDRAW_AUDIT_APPROVE; | |
| 81 | 81 | // 3.1 通过时佣金转余额 |
| 82 | 82 | if (BrokerageWithdrawTypeEnum.WALLET.getType().equals(withdraw.getType())) { |
| 83 | 83 | // todo 疯狂: |
| 84 | 84 | } |
| 85 | 85 | // TODO 疯狂:调用转账接口 |
| 86 | 86 | } else if (BrokerageWithdrawStatusEnum.AUDIT_FAIL.equals(status)) { |
| 87 | - templateCode = MessageTemplateConstants.BROKERAGE_WITHDRAW_AUDIT_REJECT; | |
| 87 | + templateCode = MessageTemplateConstants.SMS_BROKERAGE_WITHDRAW_AUDIT_REJECT; | |
| 88 | 88 | // 3.2 驳回时需要退还用户佣金 |
| 89 | 89 | brokerageRecordService.addBrokerage(withdraw.getUserId(), BrokerageRecordBizTypeEnum.WITHDRAW_REJECT, |
| 90 | 90 | String.valueOf(withdraw.getId()), withdraw.getPrice(), BrokerageRecordBizTypeEnum.WITHDRAW_REJECT.getTitle()); | ... | ... |
yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/message/TradeMessageServiceImpl.java
| ... | ... | @@ -37,7 +37,7 @@ public class TradeMessageServiceImpl implements TradeMessageService { |
| 37 | 37 | notifyMessageSendApi.sendSingleMessageToMember( |
| 38 | 38 | new NotifySendSingleToUserReqDTO() |
| 39 | 39 | .setUserId(reqBO.getUserId()) |
| 40 | - .setTemplateCode(MessageTemplateConstants.ORDER_DELIVERY) | |
| 40 | + .setTemplateCode(MessageTemplateConstants.SMS_ORDER_DELIVERY) | |
| 41 | 41 | .setTemplateParams(msgMap)); |
| 42 | 42 | } |
| 43 | 43 | ... | ... |
yudao-module-mall/yudao-module-trade-biz/src/main/java/cn/iocoder/yudao/module/trade/service/order/TradeOrderUpdateServiceImpl.java
| ... | ... | @@ -71,7 +71,7 @@ import static cn.iocoder.yudao.framework.common.util.date.LocalDateTimeUtils.min |
| 71 | 71 | import static cn.iocoder.yudao.framework.common.util.servlet.ServletUtils.getClientIP; |
| 72 | 72 | import static cn.iocoder.yudao.framework.web.core.util.WebFrameworkUtils.getTerminal; |
| 73 | 73 | import static cn.iocoder.yudao.module.trade.enums.ErrorCodeConstants.*; |
| 74 | -import static cn.iocoder.yudao.module.trade.enums.MessageTemplateConstants.DELIVERY_ORDER; | |
| 74 | +import static cn.iocoder.yudao.module.trade.enums.MessageTemplateConstants.WXA_ORDER_DELIVERY; | |
| 75 | 75 | |
| 76 | 76 | /** |
| 77 | 77 | * 交易订单【写】Service 实现类 |
| ... | ... | @@ -384,7 +384,7 @@ public class TradeOrderUpdateServiceImpl implements TradeOrderUpdateService { |
| 384 | 384 | Long orderId = order.getId(); |
| 385 | 385 | socialClientApi.sendWxaSubscribeMessage(new SocialWxaSubscribeMessageSendReqDTO() |
| 386 | 386 | .setUserId(order.getUserId()).setUserType(UserTypeEnum.MEMBER.getValue()) |
| 387 | - .setTemplateTitle(DELIVERY_ORDER) | |
| 387 | + .setTemplateTitle(WXA_ORDER_DELIVERY) | |
| 388 | 388 | .setPage("pages/order/detail?id=" + orderId) // 订单详情页 |
| 389 | 389 | .addMessage("character_string3", String.valueOf(orderId)) // 订单编号 |
| 390 | 390 | .addMessage("phrase6", TradeOrderStatusEnum.DELIVERED.getName()) // 订单状态 | ... | ... |
yudao-module-pay/yudao-module-pay-api/src/main/java/cn/iocoder/yudao/module/pay/enums/MessageTemplateConstants.java
| ... | ... | @@ -7,8 +7,8 @@ package cn.iocoder.yudao.module.pay.enums; |
| 7 | 7 | */ |
| 8 | 8 | public interface MessageTemplateConstants { |
| 9 | 9 | |
| 10 | - //======================= 小程序订阅消息 ======================= | |
| 10 | + // ======================= 小程序订阅消息 ======================= | |
| 11 | 11 | |
| 12 | - String WALLET_RECHARGER_PAID = "充值成功通知"; | |
| 12 | + String WXA_WALLET_RECHARGER_PAID = "充值成功通知"; | |
| 13 | 13 | |
| 14 | 14 | } | ... | ... |
yudao-module-pay/yudao-module-pay-biz/src/main/java/cn/iocoder/yudao/module/pay/service/wallet/PayWalletRechargeServiceImpl.java
| ... | ... | @@ -39,7 +39,7 @@ import static cn.iocoder.yudao.framework.common.util.json.JsonUtils.toJsonString |
| 39 | 39 | import static cn.iocoder.yudao.framework.common.util.number.MoneyUtils.fenToYuanStr; |
| 40 | 40 | import static cn.iocoder.yudao.module.pay.convert.wallet.PayWalletRechargeConvert.INSTANCE; |
| 41 | 41 | import static cn.iocoder.yudao.module.pay.enums.ErrorCodeConstants.*; |
| 42 | -import static cn.iocoder.yudao.module.pay.enums.MessageTemplateConstants.WALLET_RECHARGER_PAID; | |
| 42 | +import static cn.iocoder.yudao.module.pay.enums.MessageTemplateConstants.WXA_WALLET_RECHARGER_PAID; | |
| 43 | 43 | import static cn.iocoder.yudao.module.pay.enums.refund.PayRefundStatusEnum.*; |
| 44 | 44 | |
| 45 | 45 | /** |
| ... | ... | @@ -147,7 +147,7 @@ public class PayWalletRechargeServiceImpl implements PayWalletRechargeService { |
| 147 | 147 | // 2. 构建并发送模版消息 |
| 148 | 148 | socialClientApi.sendWxaSubscribeMessage(new SocialWxaSubscribeMessageSendReqDTO() |
| 149 | 149 | .setUserId(wallet.getUserId()).setUserType(wallet.getUserType()) |
| 150 | - .setTemplateTitle(WALLET_RECHARGER_PAID) | |
| 150 | + .setTemplateTitle(WXA_WALLET_RECHARGER_PAID) | |
| 151 | 151 | .setPage("pages/user/wallet/money") // 钱包详情界面 |
| 152 | 152 | .addMessage("character_string1", String.valueOf(payOrderId)) // 支付单编号 |
| 153 | 153 | .addMessage("amount2", fenToYuanStr(walletRecharge.getTotalPrice())) // 充值金额 | ... | ... |
yudao-module-system/yudao-module-system-biz/src/main/java/cn/iocoder/yudao/module/system/service/social/SocialClientServiceImpl.java
| ... | ... | @@ -82,7 +82,11 @@ public class SocialClientServiceImpl implements SocialClientService { |
| 82 | 82 | @Value("${yudao.wxa-code.env-version:release}") |
| 83 | 83 | public String envVersion; |
| 84 | 84 | /** |
| 85 | - * 订阅消息跳转小程序类型:developer为开发版;trial为体验版;formal为正式版; | |
| 85 | + * 订阅消息跳转小程序类型 | |
| 86 | + * | |
| 87 | + * 1. developer:开发版 | |
| 88 | + * 2. trial:体验版 | |
| 89 | + * 3. formal:正式版 | |
| 86 | 90 | */ |
| 87 | 91 | @Value("${yudao.wxa-subscribe-message.miniprogram-state:formal}") |
| 88 | 92 | public String miniprogramState; | ... | ... |
yudao-server/src/main/resources/application-local.yaml
| ... | ... | @@ -224,7 +224,7 @@ yudao: |
| 224 | 224 | wxa-code: |
| 225 | 225 | env-version: develop # 小程序版本: 正式版为 "release";体验版为 "trial";开发版为 "develop" |
| 226 | 226 | wxa-subscribe-message: |
| 227 | - miniprogram-state: developer # 跳转小程序类型:developer为开发版;trial为体验版;formal为正式版; | |
| 227 | + miniprogram-state: developer # 跳转小程序类型:开发版为 “developer”;体验版为 “trial”为;正式版为 “formal” | |
| 228 | 228 | tencent-lbs-key: TVDBZ-TDILD-4ON4B-PFDZA-RNLKH-VVF6E # QQ 地图的密钥 https://lbs.qq.com/service/staticV2/staticGuide/staticDoc |
| 229 | 229 | |
| 230 | 230 | justauth: | ... | ... |