|
|
@@ -11,6 +11,7 @@ import com.kym.mapper.MpMsgTemplateMapper;
|
|
|
import com.kym.service.MpMsgTemplateService;
|
|
|
import com.kym.service.MpRelationService;
|
|
|
import com.kym.service.wechat.TemplateParamBuilder;
|
|
|
+import org.springframework.context.annotation.Lazy;
|
|
|
import org.springframework.scheduling.annotation.Async;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
@@ -30,9 +31,18 @@ public class MpMsgTemplateServiceImpl extends ServiceImpl<MpMsgTemplateMapper, M
|
|
|
|
|
|
private final MpRelationService mpRelationService;
|
|
|
|
|
|
- public MpMsgTemplateServiceImpl(Map<MsgTemplateType, TemplateParamBuilder> paramBuilders, MpRelationService mpRelationService) {
|
|
|
+ /**
|
|
|
+ * 自身代理:sendTemplateMessage 标有 @Async,同类自调用会使代理失效
|
|
|
+ * (微信 HTTP 调用将同步执行在调用方事务内),必须通过代理调用
|
|
|
+ */
|
|
|
+ private final MpMsgTemplateService self;
|
|
|
+
|
|
|
+ public MpMsgTemplateServiceImpl(Map<MsgTemplateType, TemplateParamBuilder> paramBuilders,
|
|
|
+ MpRelationService mpRelationService,
|
|
|
+ @Lazy MpMsgTemplateService self) {
|
|
|
this.paramBuilders = paramBuilders;
|
|
|
this.mpRelationService = mpRelationService;
|
|
|
+ this.self = self;
|
|
|
}
|
|
|
|
|
|
|
|
|
@@ -44,7 +54,7 @@ public class MpMsgTemplateServiceImpl extends ServiceImpl<MpMsgTemplateMapper, M
|
|
|
*/
|
|
|
@Override
|
|
|
public void sendPaymentSuccessMsg(PayLog payLog, Integer balance) {
|
|
|
- sendTemplateMessage(MsgTemplateType.PAYMENT_SUCCESS, payLog.getUserId(), payLog, balance);
|
|
|
+ self.sendTemplateMessage(MsgTemplateType.PAYMENT_SUCCESS, payLog.getUserId(), payLog, balance);
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
@@ -55,7 +65,7 @@ public class MpMsgTemplateServiceImpl extends ServiceImpl<MpMsgTemplateMapper, M
|
|
|
*/
|
|
|
@Override
|
|
|
public void sendOrderCompletedMsg(WashOrder washOrder, Integer balance) {
|
|
|
- sendTemplateMessage(MsgTemplateType.ORDER_COMPLETED, washOrder.getUserId(), washOrder, balance);
|
|
|
+ self.sendTemplateMessage(MsgTemplateType.ORDER_COMPLETED, washOrder.getUserId(), washOrder, balance);
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
@@ -65,7 +75,7 @@ public class MpMsgTemplateServiceImpl extends ServiceImpl<MpMsgTemplateMapper, M
|
|
|
*/
|
|
|
@Override
|
|
|
public void sendParkingCouponMsg(WashOrder washOrder, String parkingCouponUrl) {
|
|
|
- sendTemplateMessage(MsgTemplateType.PARKING_COUPON, washOrder.getUserId(), washOrder, parkingCouponUrl);
|
|
|
+ self.sendTemplateMessage(MsgTemplateType.PARKING_COUPON, washOrder.getUserId(), washOrder, parkingCouponUrl);
|
|
|
}
|
|
|
|
|
|
|