|
@@ -31,6 +31,7 @@ import org.springframework.data.redis.core.RedisTemplate;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.web.multipart.MultipartFile;
|
|
|
import org.springframework.web.util.UriComponentsBuilder;
|
|
|
+import reactor.util.function.Tuple2;
|
|
|
|
|
|
import java.io.IOException;
|
|
|
import java.math.BigDecimal;
|
|
@@ -103,6 +104,9 @@ public class KfAppletMsgServiceImpl implements IKfAppletMsgService {
|
|
|
@Autowired
|
|
|
private RedisUtil<String> redisUtil;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private KfWxApiService wxApiService;
|
|
|
+
|
|
|
@Autowired
|
|
|
private IDistributedLockComponent distributedLockComponent;
|
|
|
|
|
@@ -211,8 +215,14 @@ public class KfAppletMsgServiceImpl implements IKfAppletMsgService {
|
|
|
|
|
|
if (CollectionUtils.isNotEmpty(orderList) && orderList.stream().map(Order::getAmount)
|
|
|
.reduce(BigDecimal.ZERO, BigDecimal::add).intValue() >= kfSystemReply.getRechargeReplyAmount()) {
|
|
|
-
|
|
|
- this.sysMsgSend(gameId, openId, kfSystemReply.getRechargeReplyContent(), kfRoom);
|
|
|
+
|
|
|
+ if (Strings.isNotBlank(kfSystemReply.getRechargeReplyContent())) {
|
|
|
+ this.sysMsgSend(gameId, openId, kfSystemReply.getRechargeReplyContent(), kfRoom);
|
|
|
+ }
|
|
|
+
|
|
|
+ if (Strings.isNotBlank(kfSystemReply.getRechargeReplyPicture())) {
|
|
|
+ this.sysImgMsgSend(gameId, openId, kfSystemReply.getRechargeReplyPicture(), kfRoom);
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -238,13 +248,45 @@ public class KfAppletMsgServiceImpl implements IKfAppletMsgService {
|
|
|
msgParamMap.put("touser", openId);
|
|
|
msgParamMap.put("msgtype", KfRoomMsgTypeEnum.KF_MSG_TYPE_TEXT.getValue());
|
|
|
msgParamMap.put("text", textMap);
|
|
|
- kfWxApiService.sendCustomMessageApi(gameId, msgParamMap);
|
|
|
+
|
|
|
+ Tuple2<Long, String> tuple2 = kfWxApiService.sendCustomMessageApi(gameId, msgParamMap);
|
|
|
+
|
|
|
+ if (!Objects.equals(tuple2.getT1(), 0L)) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
|
|
|
Map<String, Object> kfRoomMsgMap = new HashMap<>(1);
|
|
|
kfRoomMsgMap.put("text", msgContent);
|
|
|
kfRoomMsgService.save(this.transform(openId, gameId, kfRoom, KfRoomMsgTypeEnum.KF_MSG_TYPE_TEXT, JsonUtil.toString(kfRoomMsgMap)));
|
|
|
}
|
|
|
|
|
|
+ private void sysImgMsgSend(Long gameId, String openId, String imageUrl, KfRoom kfRoom) {
|
|
|
+
|
|
|
+ Map<String, Object> imageMap = new HashMap<>(1);
|
|
|
+
|
|
|
+ Tuple2<Long, String> uploadTuple2 = wxApiService.mediaUpload(gameId, FileUtil.urlToMultipartFile(imageUrl));
|
|
|
+
|
|
|
+ if (uploadTuple2.getT1() != 0) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ imageMap.put("media_id", uploadTuple2.getT2());
|
|
|
+
|
|
|
+ Map<String, Object> msgParamMap = new HashMap<>(3);
|
|
|
+ msgParamMap.put("touser", openId);
|
|
|
+ msgParamMap.put("msgtype", KfRoomMsgTypeEnum.KF_MSG_TYPE_IMAGE.getValue());
|
|
|
+ msgParamMap.put(KfRoomMsgTypeEnum.KF_MSG_TYPE_IMAGE.getValue(), imageMap);
|
|
|
+
|
|
|
+ Tuple2<Long, String> tuple2 = wxApiService.sendCustomMessageApi(gameId, msgParamMap);
|
|
|
+
|
|
|
+ if (!Objects.equals(tuple2.getT1(), 0L)) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ Map<String, Object> kfRoomMsgMap = new HashMap<>(1);
|
|
|
+ kfRoomMsgMap.put("image", imageUrl);
|
|
|
+ kfRoomMsgService.save(this.transform(openId, gameId, kfRoom, KfRoomMsgTypeEnum.KF_MSG_TYPE_IMAGE, JsonUtil.toString(kfRoomMsgMap)));
|
|
|
+ }
|
|
|
+
|
|
|
private boolean orderHandle(String orderId, Long gameId, KfAppletMsgDTO kfAppletMsgDTO, KfRoom kfRoom, KfRoomMsg kfRoomMsg) {
|
|
|
|
|
|
if (!KfAppletMsgDTO.MSG_CONTENT_PAY.contains(kfAppletMsgDTO.getContent())
|
|
@@ -475,7 +517,11 @@ public class KfAppletMsgServiceImpl implements IKfAppletMsgService {
|
|
|
msgParamMap.put("touser", openId);
|
|
|
msgParamMap.put("msgtype", KfRoomMsgTypeEnum.KF_MSG_TYPE_LINK.getValue());
|
|
|
msgParamMap.put(KfRoomMsgTypeEnum.KF_MSG_TYPE_LINK.getValue(), linkMap);
|
|
|
- kfWxApiService.sendCustomMessageApi(gameId, msgParamMap);
|
|
|
+ Tuple2<Long, String> tuple2 = kfWxApiService.sendCustomMessageApi(gameId, msgParamMap);
|
|
|
+
|
|
|
+ if (!Objects.equals(tuple2.getT1(), 0L)) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
|
|
|
kfRoomMsgService.save(this.transform(openId, gameId, kfRoom, KfRoomMsgTypeEnum.KF_MSG_TYPE_LINK, JsonUtil.toString(msgParamMap)));
|
|
|
|