From 41e7e3b7a28c6d893fd5201f78c68f4873d47933 Mon Sep 17 00:00:00 2001
From: 苗权威 <1160292058@qq.com>
Date: Fri, 30 Aug 2019 21:09:12 +0800
Subject: [PATCH] 8.30
---
.idea/workspace.xml | 549 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
tts_service/src/main/java/ai/qiwu/com/tts_service/service/TTService.java | 2 +-
xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/common/Utils.java | 4 +++-
xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/common/temple/TempleUtils.java | 89 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++---
xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/common/temple/funny/FunnyDocument.java | 20 ++++++++++++++++++++
xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/common/temple/funny/FunnyMainTemplate.java | 24 ++++++++++++++++++++++++
xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/common/temple/funny/FunnyPageItemData.java | 13 +++++++++++++
xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/common/temple/funny/FunnyPojo.java | 48 ++++++++++++++++++++++++++++++++++++++++++++++++
xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/controller/XiaoDuHomeController.java | 1 +
xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/entity/primary/AppFlowerTB.java | 3 ++-
xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/repository/primary/AppFlowerTBRepository.java | 3 +++
xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/repository/secondary/XiaoDuOrderTbRepository.java | 4 +++-
xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/service/DplBotService.java | 188 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++----------------------------------------------------------------
xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/service/ScheduleService.java | 13 ++++++++++++-
xiaoduhome/src/main/resources/static/json/funny.json | 62 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
xiaoduhome/src/main/resources/static/json/funnyPageItem.json | 31 +++++++++++++++++++++++++++++++
16 files changed, 720 insertions(+), 334 deletions(-)
create mode 100644 xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/common/temple/funny/FunnyDocument.java
create mode 100644 xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/common/temple/funny/FunnyMainTemplate.java
create mode 100644 xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/common/temple/funny/FunnyPageItemData.java
create mode 100644 xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/common/temple/funny/FunnyPojo.java
create mode 100644 xiaoduhome/src/main/resources/static/json/funny.json
create mode 100644 xiaoduhome/src/main/resources/static/json/funnyPageItem.json
diff --git a/.idea/workspace.xml b/.idea/workspace.xml
index 2882036..f869ea4 100644
--- a/.idea/workspace.xml
+++ b/.idea/workspace.xml
@@ -3,13 +3,14 @@
-
-
+
-
+
+
+
+
-
@@ -56,30 +57,53 @@
-
-
+
+
-
-
+
+
+
+
+
+
+
-
+
-
-
+
+
-
+
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -88,50 +112,49 @@
-
+
-
-
+
+
-
+
-
-
+
+
+
+
+
-
+
-
-
-
-
-
-
+
+
-
+
-
-
+
+
-
+
-
-
+
+
@@ -150,11 +173,6 @@
- margin-bottom
- TTSResponse
- mp3File
- componentId
- CallP
AUDIO_DIR
log.info
log.error
@@ -166,7 +184,6 @@
version
ite
border-radius
- position
margin
padding
bottom
@@ -180,6 +197,12 @@
LAST_OUTTIME_RESULT
botAcc
POOL
+ status:{}
+ 555
+ new Thread
+ position
+ direction
+ POOL.submit
OPENID_CACHE
@@ -195,14 +218,6 @@
@@ -278,8 +301,8 @@
-
-
+
+
@@ -291,8 +314,8 @@
-
+
@@ -303,65 +326,37 @@
-
+
-
+
-
-
-
-
-
-
-
-
+
-
-
+
-
-
+
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
@@ -370,6 +365,8 @@
+
+
@@ -379,6 +376,8 @@
+
+
@@ -389,6 +388,8 @@
+
+
@@ -400,6 +401,7 @@
+
@@ -538,7 +540,7 @@
-
+
@@ -590,7 +592,7 @@
-
+
@@ -969,6 +971,7 @@
+
@@ -989,15 +992,14 @@
-
+
-
@@ -1077,7 +1079,8 @@
-
+
+
@@ -1087,7 +1090,7 @@
-
+
@@ -1099,7 +1102,7 @@
-
+
@@ -1110,10 +1113,10 @@
-
+
-
+
@@ -1143,375 +1146,397 @@
+
+
+
+
-
+
-
-
+
+
-
+
-
-
+
+
+
+
+
+
-
+
-
-
+
+
-
+
-
-
+
+
-
+
-
+
-
+
-
-
+
+
-
+
-
-
+
+
-
+
-
-
-
-
-
-
-
-
+
-
+
-
-
+
+
-
+
-
-
+
+
-
+
-
-
+
+
-
+
-
-
+
+
-
+
-
-
+
+
-
+
-
-
+
+
-
+
-
-
+
+
-
+
-
-
+
+
-
+
-
-
+
+
-
+
-
-
+
+
-
+
-
-
+
+
-
+
-
-
+
+
-
+
-
-
+
+
+
+
+
-
+
-
-
+
+
-
+
-
-
+
+
+
+
+
-
+
-
-
+
+
-
+
-
-
+
+
-
+
-
-
+
+
-
+
-
-
+
+
-
+
-
-
+
+
-
+
-
-
-
-
-
-
+
+
-
+
-
-
+
+
-
+
-
-
+
+
-
+
-
-
+
+
-
+
-
-
+
+
-
+
-
-
+
+
-
-
+
+
-
+
-
-
+
+
-
+
-
-
+
+
-
+
-
-
+
+
-
+
-
-
+
+
-
-
+
+
-
+
-
-
+
+
+
+
+
+
-
+
-
-
+
+
-
+
-
-
-
-
-
-
+
+
-
+
-
-
+
+
-
+
-
-
+
+
+
+
+
+
-
+
-
-
+
+
+
+
+
-
+
-
-
+
+
-
+
-
-
+
+
-
+
+
+
+
+
+
+
+
-
-
+
+
-
-
+
+
-
-
+
+
+
+
+
+
+
diff --git a/tts_service/src/main/java/ai/qiwu/com/tts_service/service/TTService.java b/tts_service/src/main/java/ai/qiwu/com/tts_service/service/TTService.java
index bdaa716..c1a1955 100644
--- a/tts_service/src/main/java/ai/qiwu/com/tts_service/service/TTService.java
+++ b/tts_service/src/main/java/ai/qiwu/com/tts_service/service/TTService.java
@@ -254,7 +254,7 @@ public class TTService {
// ResponseCodeWithData data = future.get(60, TimeUnit.SECONDS);
ResponseCodeWithData data = future.get();
if (data.getCode() != 200) {
- log.error("下载:{}音频失败, status:{}", data.getCode());
+ log.error("下载音频失败, status:{}", data.getCode());
TTServiceUtil.buildTTS_lsResponse(response, new TTSResponse(data.getCode()), null, data.getCode());
return;
}
diff --git a/xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/common/Utils.java b/xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/common/Utils.java
index 3207c98..72c2630 100644
--- a/xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/common/Utils.java
+++ b/xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/common/Utils.java
@@ -105,7 +105,9 @@ public class Utils {
String[] names = word.split("、");
List botNames = new ArrayList<>();
for (String name : names) {
- botNames.add(name.substring(1, name.length()-1));
+ int i = name.indexOf(":");
+ if (i == -1) i = name.length()-1;
+ botNames.add(name.substring(1, i));
}
return botNames;
}
diff --git a/xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/common/temple/TempleUtils.java b/xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/common/temple/TempleUtils.java
index 088db81..9c446ad 100644
--- a/xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/common/temple/TempleUtils.java
+++ b/xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/common/temple/TempleUtils.java
@@ -2,6 +2,9 @@ package ai.qiwu.com.xiaoduhome.common.temple;
import ai.qiwu.com.xiaoduhome.common.BaseHolder;
import ai.qiwu.com.xiaoduhome.common.Constants;
+import ai.qiwu.com.xiaoduhome.common.temple.funny.FunnyDocument;
+import ai.qiwu.com.xiaoduhome.common.temple.funny.FunnyPageItemData;
+import ai.qiwu.com.xiaoduhome.common.temple.funny.FunnyPojo;
import ai.qiwu.com.xiaoduhome.common.temple.playUpdate.PlayUpdateDocument;
import ai.qiwu.com.xiaoduhome.common.temple.playUpdate.PlayUpdatePojo;
import ai.qiwu.com.xiaoduhome.common.temple.rank.RankBotInfo;
@@ -63,6 +66,23 @@ public class TempleUtils {
return document;
}
+ public static FunnyDocument getFunnyDocument(List bots) {
+ FunnyDocument document = JSON.parseObject(getDPLTemple("static/json/funny.json"), FunnyDocument.class);
+ List datas = new ArrayList<>();
+ FunnyPojo page = document.getMainTemplate().getItems().get(1).getItems().get(0);
+ List dataList = new ArrayList<>();
+ page.setItems(dataList);
+ for (OnProductDetail bot : bots) {
+ FunnyPageItemData data = new FunnyPageItemData();
+ data.setImgSrc(new StringBuilder(Constants.IMG_PREFIX).append(bot.getBannerImgUrl()).toString());
+ data.setText(bot.getIntro());
+ datas.add(data);
+ dataList.add(getFunnyPageItemPojo());
+ }
+ page.setData(datas);
+ return document;
+ }
+
public static RankingDocument getRanking() {
if (RANKING_DOCUMENT != null) {
return RANKING_DOCUMENT;
@@ -228,8 +248,71 @@ public class TempleUtils {
return FRAME_CATEGORY;
}
- public static void main(String[] args) {
- SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm");
- System.out.println(sdf.format(new java.sql.Date(1566887509312L)));
+ private static FunnyPojo getFunnyPageItemPojo() {
+ FunnyPojo pojo = new FunnyPojo();
+ pojo.setType("Container");
+ pojo.setFlexDirection("row");
+ pojo.setWidth("100%");
+ pojo.setHeight("100%");
+
+ FunnyPojo image = new FunnyPojo();
+ image.setSrc("${data.imgSrc}");
+ image.setType("Image");
+ image.setMarginTop("30dp");
+ image.setHeight("400dp");
+ image.setWidth("400dp");
+ image.setMarginLeft("25dp");
+
+ FunnyPojo textContainer = new FunnyPojo();
+ textContainer.setType("Container");
+ textContainer.setWidth("500dp");
+ textContainer.setHeight("100%");
+
+ FunnyPojo text = new FunnyPojo();
+ text.setType("Text");
+ text.setText("${data.text}");
+ text.setFontSize("25dp");
+ text.setLineHeight("60dp");
+ text.setMarginTop("20dp");
+ text.setMarginLeft("10dp");
+
+ List textContainerItems = new ArrayList<>();
+ textContainerItems.add(text);
+ textContainer.setItems(textContainerItems);
+
+ List pojoItems = new ArrayList<>();
+ pojoItems.add(image);
+ pojoItems.add(textContainer);
+
+ pojo.setItems(pojoItems);
+ return pojo;
+ }
+
+ public static void main(String[] args) throws IOException, CloneNotSupportedException {
+// SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm");
+// System.out.println(sdf.format(new java.sql.Date(1566887509312L)));
+
+ new Thread(() -> {
+ int i = 3000;
+ long start = System.currentTimeMillis();
+ while (i-- > 0) {
+ try {
+ FunnyPojo pageItem = JSON.parseObject(getJsonFromName("static/json/funnyPageItem.json"),FunnyPojo.class);
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ }
+ long end = System.currentTimeMillis();
+ System.out.println("JSON:"+(end-start));
+ }).start();
+ new Thread(() -> {
+ int i = 3000;
+ long start = System.currentTimeMillis();
+ while (i-- > 0) {
+ getFunnyPageItemPojo();
+ }
+ long end = System.currentTimeMillis();
+ System.out.println("TEST:"+(end-start));
+ }).start();
}
}
diff --git a/xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/common/temple/funny/FunnyDocument.java b/xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/common/temple/funny/FunnyDocument.java
new file mode 100644
index 0000000..d1f9c46
--- /dev/null
+++ b/xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/common/temple/funny/FunnyDocument.java
@@ -0,0 +1,20 @@
+package ai.qiwu.com.xiaoduhome.common.temple.funny;
+
+import com.baidu.dueros.data.response.directive.dpl.Document;
+import com.fasterxml.jackson.databind.annotation.JsonSerialize;
+import lombok.Data;
+import lombok.Getter;
+import lombok.Setter;
+import lombok.ToString;
+
+/**
+ * @author 苗权威
+ * @dateTime 19-8-30 上午11:28
+ */
+@Getter
+@Setter
+@ToString
+@JsonSerialize(include = JsonSerialize.Inclusion.NON_NULL)
+public class FunnyDocument extends Document {
+ private FunnyMainTemplate mainTemplate;
+}
diff --git a/xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/common/temple/funny/FunnyMainTemplate.java b/xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/common/temple/funny/FunnyMainTemplate.java
new file mode 100644
index 0000000..c591f98
--- /dev/null
+++ b/xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/common/temple/funny/FunnyMainTemplate.java
@@ -0,0 +1,24 @@
+package ai.qiwu.com.xiaoduhome.common.temple.funny;
+
+import ai.qiwu.com.xiaoduhome.common.temple.rank.RankingPojo;
+import com.fasterxml.jackson.databind.annotation.JsonSerialize;
+import lombok.Data;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * @author 苗权威
+ * @dateTime 19-8-30 上午11:28
+ */
+@Data
+@JsonSerialize(include = JsonSerialize.Inclusion.NON_NULL)
+public class FunnyMainTemplate {
+ private List parameters = new ArrayList<>();
+ private List items;
+
+ public FunnyMainTemplate() {
+ this.parameters.add("payload");
+ this.items = new ArrayList<>();
+ }
+}
diff --git a/xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/common/temple/funny/FunnyPageItemData.java b/xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/common/temple/funny/FunnyPageItemData.java
new file mode 100644
index 0000000..26afa59
--- /dev/null
+++ b/xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/common/temple/funny/FunnyPageItemData.java
@@ -0,0 +1,13 @@
+package ai.qiwu.com.xiaoduhome.common.temple.funny;
+
+import lombok.Data;
+
+/**
+ * @author 苗权威
+ * @dateTime 19-8-30 下午1:09
+ */
+@Data
+public class FunnyPageItemData {
+ private String imgSrc;
+ private String text;
+}
diff --git a/xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/common/temple/funny/FunnyPojo.java b/xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/common/temple/funny/FunnyPojo.java
new file mode 100644
index 0000000..f849428
--- /dev/null
+++ b/xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/common/temple/funny/FunnyPojo.java
@@ -0,0 +1,48 @@
+package ai.qiwu.com.xiaoduhome.common.temple.funny;
+
+import ai.qiwu.com.xiaoduhome.pojo.dpl.Event;
+import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
+import com.fasterxml.jackson.annotation.JsonProperty;
+import com.fasterxml.jackson.databind.annotation.JsonSerialize;
+import lombok.Data;
+
+import java.util.List;
+
+/**
+ * @author 苗权威
+ * @dateTime 19-8-30 上午11:18
+ */
+@Data
+@JsonIgnoreProperties(ignoreUnknown = true)
+@JsonSerialize(include = JsonSerialize.Inclusion.NON_NULL)
+public class FunnyPojo {
+ private String type;
+ private String height;
+ private String width;
+ private String position;
+ private String left;
+ private String top;
+ private String src;
+ private List items;
+ private String headerTitle;
+ private Boolean hasBackIcon;
+ @JsonProperty("flex-direction")
+ private String flexDirection;
+ @JsonProperty("margin-top")
+ private String marginTop;
+ @JsonProperty("margin-left")
+ private String marginLeft;
+ @JsonProperty("font-size")
+ private String fontSize;
+ @JsonProperty("line-height")
+ private String lineHeight;
+ private List data;
+ private String text;
+ private String bottom;
+ private List hints;
+ private String direction;
+ private String componentId;
+ private String looping;
+ private String autoplay;
+ private List onLoaded;
+}
diff --git a/xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/controller/XiaoDuHomeController.java b/xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/controller/XiaoDuHomeController.java
index f6f99b3..515042a 100644
--- a/xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/controller/XiaoDuHomeController.java
+++ b/xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/controller/XiaoDuHomeController.java
@@ -5,6 +5,7 @@ import ai.qiwu.com.xiaoduhome.service.DplBotService;
import ai.qiwu.com.xiaoduhome.service.ResponseEncapsulation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.util.ResourceUtils;
+import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
diff --git a/xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/entity/primary/AppFlowerTB.java b/xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/entity/primary/AppFlowerTB.java
index 13bb95c..fbec539 100644
--- a/xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/entity/primary/AppFlowerTB.java
+++ b/xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/entity/primary/AppFlowerTB.java
@@ -45,7 +45,8 @@ public class AppFlowerTB {
@Column
private Integer status;
- @Column(name = "gmt_create")
+ @CreatedDate
+ @Column(name = "gmt_create",nullable = false,updatable = false)
private Date createTime;
@Column(name = "gmt_modified")
diff --git a/xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/repository/primary/AppFlowerTBRepository.java b/xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/repository/primary/AppFlowerTBRepository.java
index d9ac8d6..fc95b43 100644
--- a/xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/repository/primary/AppFlowerTBRepository.java
+++ b/xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/repository/primary/AppFlowerTBRepository.java
@@ -5,6 +5,7 @@ import org.springframework.data.domain.Example;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Repository;
+import org.springframework.transaction.annotation.Transactional;
/**
* @author 苗权威
@@ -13,9 +14,11 @@ import org.springframework.stereotype.Repository;
@Repository
public interface AppFlowerTBRepository extends JpaRepository {
+ @Transactional
@Query(value = "INSERT INTO app_flower_tb (module,bot_username,user_id,unit_price,number,order_id,status,gmt_create,gmt_modified) VALUES (0,?1,?2,1,1,?3,1,?4,?4)",nativeQuery = true)
void insertOrder(String botId, String userId, String orderId, String time);
+ @Transactional
@Override
S save(S s);
diff --git a/xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/repository/secondary/XiaoDuOrderTbRepository.java b/xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/repository/secondary/XiaoDuOrderTbRepository.java
index bc88ffa..77d242d 100644
--- a/xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/repository/secondary/XiaoDuOrderTbRepository.java
+++ b/xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/repository/secondary/XiaoDuOrderTbRepository.java
@@ -24,10 +24,12 @@ public interface XiaoDuOrderTbRepository extends JpaRepository S saveAndFlush(S s);
@Transactional
- @Query(value = "UPDATE xiaodu_order_id SET creation_timestamp=?2,order_id=?3,status=1,update_time=now() WHERE ch_order_id=?1",nativeQuery = true)
+ @Query(value = "UPDATE xiaodu_order_tb SET creation_timestamp=?2,order_id=?3,status=1,update_time=now() WHERE ch_order_id=?1",nativeQuery = true)
void updateAterSeccessPayed(String chOrderId, String creationTimestamp, String orderId);
@Transactional
@Override
void delete(XiaoDuOrderTB xiaoDuOrderTB);
+
+ void deleteByStatus(Boolean status);
}
diff --git a/xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/service/DplBotService.java b/xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/service/DplBotService.java
index 1b92116..c86171e 100644
--- a/xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/service/DplBotService.java
+++ b/xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/service/DplBotService.java
@@ -4,6 +4,8 @@ import ai.qiwu.com.xiaoduhome.common.*;
import ai.qiwu.com.xiaoduhome.common.temple.Agent;
import ai.qiwu.com.xiaoduhome.common.temple.CollectHistoryDocument;
import ai.qiwu.com.xiaoduhome.common.temple.TempleUtils;
+import ai.qiwu.com.xiaoduhome.common.temple.funny.FunnyDocument;
+import ai.qiwu.com.xiaoduhome.common.temple.funny.FunnyPojo;
import ai.qiwu.com.xiaoduhome.common.temple.rank.RankingDocument;
import ai.qiwu.com.xiaoduhome.common.temple.recommand.RecommandDocument;
import ai.qiwu.com.xiaoduhome.entity.primary.*;
@@ -513,14 +515,14 @@ public class DplBotService extends BaseBot {
return new Response();
} else if (PRE_COLLE.equals(componentPrefix)) {
boolean isUnCollect = "Un".equals(componentId.substring(5,7));
- String botId = componentId.substring(7);
+ final String botId = componentId.substring(7);
if (isUnCollect) {
//取消收藏
try {
- String userId = getUsUserId();
+ final String userId = getUsUserId();
if (userId == null) throw new IllegalStateException("通过accessToken获取用户id失败");
- new UnCollectThread(botId, userId).start();
+ POOL.submit(new UnCollectThread(botId, userId));
// QiWuResponse response = RequestTerminal.requestTerminate(CHAT_COLLECT, userId);
// log.info("chat 取消收藏 的返回{}", response);
} catch (Exception e) {
@@ -535,7 +537,7 @@ public class DplBotService extends BaseBot {
String userId = getUsUserId();
if (userId == null) throw new IllegalStateException("通过accessToken获取用户id失败");
- new CollectThread(botId, userId).start();
+ POOL.submit(new CollectThread(botId, userId));
// QiWuResponse response = RequestTerminal.requestTerminate(CHAT_COLLECT, userId);
// log.info("chat 我要收藏 的返回{}", response);
} catch (Exception e) {
@@ -553,6 +555,14 @@ public class DplBotService extends BaseBot {
this.addDirective(render);
this.addDirective(new PushStack());
}
+// else if ("funnyChange".equals(componentId)) {
+// ExecuteCommands executeCommands = new ExecuteCommands();
+// AutoPageCommand page = new AutoPageCommand();
+// page.setComponentId("funnyPage");
+// page.setDurationInMillisecond(2000);
+// executeCommands.addCommand(page);
+// this.addDirective(executeCommands);
+// }
return new Response();
}
@@ -569,59 +579,27 @@ public class DplBotService extends BaseBot {
log.info("此次支付结果:"+result+";msg: "+payload.getMessage());
if (result.equals("SUCCESS")) {
log.info("支付成功");
- new SendFlowerThread(buyEvent).start();
+ POOL.submit(new SendFlowerThread(buyEvent));
+ POOL.submit(new SendFlowerBuyToXiaoduTB(buyEvent));
return buildErrorResponse("感谢大人赏的花");
}
return buildErrorResponse("哎呀,没有支付成功");
}
- class SendFlowerThread extends Thread {
+ class SendFlowerBuyToXiaoduTB implements Runnable {
BuyEvent buyEvent;
- SendFlowerThread(BuyEvent buyEvent) {
- super("SendFlower");
+ SendFlowerBuyToXiaoduTB(BuyEvent buyEvent) {
this.buyEvent = buyEvent;
}
-
@Override
public void run() {
- String baiduOrderReferenceId = buyEvent.getPayload().getBaiduOrderReferenceId();
- String timeStamp = buyEvent.getTimestamp();
- String botId = new String(Base64.getDecoder().decode(buyEvent.getToken()), StandardCharsets.UTF_8);
- String userId = getSessionAttribute("userId");
- Integer unitePrice = Integer.parseInt(Config.getProperty("unitPrice", "1"));
- try {
- if (userId == null) userId = getUserIdByToken(getAccessToken());
- if (userId == null) throw new Exception("未获取到用户id");
- AppFlowerTBTintRepository tinyRepository = BaseHolder.getBean("appFlowerTBTintRepository");
- AppFlowerTBTiny tiny = tinyRepository.getByUserIdAndBotIdAndUnitPrice(Integer.parseInt(userId),
- botId,unitePrice/100.0);
- if (tiny == null) {
- AppFlowerTBRepository flowerRepository = BaseHolder.getBean("appFlowerTBRepository");
- AppFlowerTB flowerTB = new AppFlowerTB();
- flowerTB.setNumber(1);
- flowerTB.setModule(0);
- flowerTB.setBotName(botId);
- flowerTB.setUserId(Integer.parseInt(userId));
- flowerTB.setStatus(1);
- flowerTB.setUnitPrice(unitePrice/100.0);
- flowerTB.setCreateTime(new Date(Integer.parseInt(timeStamp)*1000));
- flowerTB.setOrderId(0);
- AppFlowerTB response = flowerRepository.save(flowerTB);
- if (response == null) throw new Exception("向app_flower_tb中插入数据失败");
- }else {
- AppFlowerTBRepository flowerRepository = BaseHolder.getBean("appFlowerTBRepository");
- AppFlowerTB flowerTB = new AppFlowerTB();
- flowerTB.setId(tiny.getId());
- int preNumber = tiny.getNumber();
- flowerTB.setNumber(preNumber+1);
- AppFlowerTB response = flowerRepository.save(flowerTB);
- if (response == null || response.getNumber() == preNumber) throw new Exception("向app_flower_tb中更新数据失败");
- }
- } catch (Exception e) {
- log.error("用户成功支付,game_flower_tb操作出现错误:{}",e.toString());
- }
try {
+ String baiduOrderReferenceId = buyEvent.getPayload().getBaiduOrderReferenceId();
+ String timeStamp = buyEvent.getTimestamp();
+ String botId = new String(Base64.getDecoder().decode(buyEvent.getToken()), StandardCharsets.UTF_8);
+ String userId = getSessionAttribute("userId");
+ Integer unitePrice = Integer.parseInt(Config.getProperty("unitPrice", Constants.UNIT_PRICE));
if (userId == null) userId = getUserIdByToken(getAccessToken());
if (userId == null) throw new Exception("未获取到用户id");
XiaoDuOrderTbRepository repository = BaseHolder.getBean("xiaoDuOrderTbRepository");
@@ -642,6 +620,54 @@ public class DplBotService extends BaseBot {
}
}
+ class SendFlowerThread implements Runnable {
+ BuyEvent buyEvent;
+
+ SendFlowerThread(BuyEvent buyEvent) {
+ this.buyEvent = buyEvent;
+ }
+
+ @Override
+ public void run() {
+ //String baiduOrderReferenceId = buyEvent.getPayload().getBaiduOrderReferenceId();
+ String timeStamp = buyEvent.getTimestamp();
+ String botId = new String(Base64.getDecoder().decode(buyEvent.getToken()), StandardCharsets.UTF_8);
+ String userId = getSessionAttribute("userId");
+ int unitePrice = Integer.parseInt(Config.getProperty("unitPrice", Constants.UNIT_PRICE));
+ try {
+ if (userId == null) userId = getUserIdByToken(getAccessToken());
+ if (userId == null) throw new Exception("未获取到用户id");
+ //AppFlowerTBTintRepository tinyRepository = BaseHolder.getBean("appFlowerTBTintRepository");
+ //AppFlowerTBTiny tiny = tinyRepository.getByUserIdAndBotIdAndUnitPrice(Integer.parseInt(userId), botId,unitePrice/100.0);
+ AppFlowerTBRepository flowerRepository = BaseHolder.getBean("appFlowerTBRepository");
+ AppFlowerTB flowerTB = new AppFlowerTB();
+ flowerTB.setNumber(1);
+ flowerTB.setModule(0);
+ flowerTB.setBotName(botId);
+ flowerTB.setUserId(Integer.parseInt(userId));
+ flowerTB.setStatus(1);
+ flowerTB.setUnitPrice(unitePrice/100.0);
+ flowerTB.setCreateTime(new Date(Integer.parseInt(timeStamp)*1000));
+ flowerTB.setOrderId(0);
+ AppFlowerTB response = flowerRepository.save(flowerTB);
+ if (response == null) throw new Exception("向app_flower_tb中插入数据失败");
+// if (tiny == null) {
+//
+// }else {
+// AppFlowerTBRepository flowerRepository = BaseHolder.getBean("appFlowerTBRepository");
+// AppFlowerTB flowerTB = new AppFlowerTB();
+// flowerTB.setId(tiny.getId());
+// int preNumber = tiny.getNumber();
+// flowerTB.setNumber(preNumber+1);
+// AppFlowerTB response = flowerRepository.save(flowerTB);
+// if (response == null || response.getNumber() == preNumber) throw new Exception("向app_flower_tb中更新数据失败");
+// }
+ } catch (Exception e) {
+ log.error("用户成功支付,game_flower_tb操作出现错误:{}",e.toString());
+ }
+ }
+ }
+
private ExecuteCommands changeIconIdTextAfterCollect(boolean collect, String botId) {
ExecuteCommands executeCommands = new ExecuteCommands();
UpdateComponentCommand update = new UpdateComponentCommand();
@@ -876,12 +902,11 @@ public class DplBotService extends BaseBot {
}
- class CollectThread extends Thread {
+ class CollectThread implements Runnable {
String botId;
String userId;
CollectThread(String botId, String userId) {
- super("CollectThread");
this.botId = botId;
this.userId = userId;
}
@@ -892,24 +917,24 @@ public class DplBotService extends BaseBot {
AppFavoriteTB entity = new AppFavoriteTB();
entity.setBotId(botId);
entity.setUserId(user_id);
-
- Example example = Example.of(entity);
+ entity.setModule(0);
+ //Example example = Example.of(entity);
AppFavoriteTBRepository repository = BaseHolder.getBean("appFavoriteTBRepository");
- boolean exist = repository.exists(example);
- log.info("2333:{}",exist);
- if (!exist) {
- entity.setModule(0);
- repository.save(entity);
- }
+ repository.save(entity);
+// boolean exist = repository.exists(example);
+// log.info("2333:{}",exist);
+// if (!exist) {
+// entity.setModule(0);
+// repository.save(entity);
+// }
}
}
- class UnCollectThread extends Thread {
+ class UnCollectThread implements Runnable {
String botId;
String userId;
UnCollectThread(String botId, String userId) {
- super("UnCollectThread");
this.botId = botId;
this.userId = userId;
}
@@ -921,6 +946,7 @@ public class DplBotService extends BaseBot {
// entity.setUserId(Integer.parseInt(userId));
AppFavoriteTBRepository repository = BaseHolder.getBean("appFavoriteTBRepository");
+ log.info("取消收藏被调用");
repository.deleteByBotIdAndUserId(botId, Integer.parseInt(userId));
//repository.deleteFavorite(userId, userid);
}
@@ -1306,7 +1332,8 @@ public class DplBotService extends BaseBot {
if (alreadyCollected) {
if (collect) detail.setResponse(buildErrorResponse("您之前就已经收藏过该作品啦,看来你真的很喜欢它"));
else {
- new UnCollectThread(botAccount, userId).start();
+ //final String lamBotAccount = botAccount;
+ POOL.submit(new UnCollectThread(botAccount, userId));
String botName = ScheduleService.PRODUCT_ID_DETAIL.get(botAccount).getName();
if (inProductInfo) {
ExecuteCommands commands = changeIconIdTextAfterCollect(false, botAccount);
@@ -1317,7 +1344,7 @@ public class DplBotService extends BaseBot {
}
}else {
if (collect) {
- new CollectThread(botAccount, userId).start();
+ POOL.submit(new CollectThread(botAccount, userId));
String word = ScheduleService.PRODUCT_ID_DETAIL.get(botAccount).getName();
if (inProductInfo) {
ExecuteCommands commands = changeIconIdTextAfterCollect(true, botAccount);
@@ -1354,11 +1381,13 @@ public class DplBotService extends BaseBot {
log.info("确认送花个数");
dplBotService.ask("sys.number");
outputSpeech = new OutputSpeech(OutputSpeech.SpeechType.PlainText, "请问您要送几朵花");
+ dplBotService.setExpectSpeech(true);
} else {
log.info("确认最终送花意图");
dplBotService.setConfirmIntent();
outputSpeech = new OutputSpeech(OutputSpeech.SpeechType.PlainText,
new StringBuilder("您要送").append(num).append("朵花是吗").toString());
+ dplBotService.setExpectSpeech(true);
}
detail.getResponse().setOutputSpeech(outputSpeech);
LAST_OUTTIME_RESULT.put(userId, detail);
@@ -1366,8 +1395,10 @@ public class DplBotService extends BaseBot {
log.info("确认");
String price = Config.getProperty("unitPrice");
if (price != null) {
+ //log.info("num:{}",num);
+ //log.info("slot:{}",dplBotService.getSlot("sys.number"));
int unitPrice = Integer.parseInt(price);
- String amount = String.valueOf(unitPrice*Integer.parseInt(num)/100);
+ String amount = String.valueOf(unitPrice*Integer.parseInt(num)/100.0);
String orderId = new StringBuilder(userId).append(System.currentTimeMillis()).toString();
String appUserId = dplBotService.getSessionAttribute("userId");
if (appUserId == null) {
@@ -1394,6 +1425,7 @@ public class DplBotService extends BaseBot {
if (repository.exists(example)) {
Charge charge = new Charge(amount, orderId, "flower", botId);
charge.setToken(new StringBuilder(botId).append(File.separator).append(num).toString());
+ dplBotService.addDirective(charge);
detail.getDirectives().add(charge);
detail.setResponse(buildErrorResponse("请扫描二维码完成支付"));
} else {
@@ -1412,8 +1444,6 @@ public class DplBotService extends BaseBot {
LAST_OUTTIME_RESULT.put(userId, detail);
}
return;
- } else if ("funny".equals(intentName)) {
-
}
Query query = intentRequest.getQuery();
@@ -1439,6 +1469,18 @@ public class DplBotService extends BaseBot {
return;
}
String text = data.getText();
+ if ("funny".equals(intentName)) {
+ FunnyDocument document = displayFunnyRecommandPage(text);
+ if (document != null) {
+ document.getMainTemplate().getItems().get(2).setSrc(data.getAudio());
+ RenderDocument render = new RenderDocument(document);
+ dplBotService.addDirective(render);
+ detail.getDirectives().add(render);
+ LAST_OUTTIME_RESULT.put(userId, detail);
+ return;
+ }
+ log.info("funny出现问题");
+ }
//log.info("小悟返回:{}", text);
text = text.substring(text.indexOf("】")+1);
final String botAccount = ScheduleService.getNx2BotToHz1().get(data.getAipioneerUsername());
@@ -1462,7 +1504,7 @@ public class DplBotService extends BaseBot {
RenderDocument render = new RenderDocument(PLAY_DOCUMENT);
dplBotService.addDirective(render);
detail.getDirectives().add(render);
- new Thread(() -> {
+ POOL.submit(() -> {
XiaoDuHistoryTBRepository repository = BaseHolder.getBean("xiaoDuHistoryTBRepository");
XiaoDuHistoryTB historyTB = repository.getByXiaoduUserIdAndBotId(userId, botAccount);
if (historyTB == null) {
@@ -1476,7 +1518,7 @@ public class DplBotService extends BaseBot {
log.info("更新历史数据:{}", botAccount);
}
repository.save(historyTB);
- }).start();
+ });
String trace = dplBotService.getSessionAttribute(BACK_TRACE);
if (trace == null || trace.length() != 2) trace = "00";
trace = new StringBuilder(trace).append(botAccount).append(File.separator).toString();
@@ -1518,6 +1560,23 @@ public class DplBotService extends BaseBot {
}
}
+ private FunnyDocument displayFunnyRecommandPage(String word) {
+ try {
+ List botNames = Utils.getRecommandBotNames(word);
+ log.info("botNames:{}",botNames);
+ List bots = new ArrayList<>();
+ for (String botName : botNames) {
+ OnProductDetail detail = ScheduleService.PRODUCT_NAME_DETAIL.get(botName);
+ if (detail == null) continue;
+ bots.add(detail);
+ }
+ if (bots.size() != 0) return TempleUtils.getFunnyDocument(bots);
+ } catch (Exception e) {
+ log.error("获取funny页出错:{}",e.toString());
+ }
+ return null;
+ }
+
private XiaoDuOrderTB buildBeforePayPojo(String botAccount, String appUserId, String userId, int unitPrice,
int number, String orderId) {
XiaoDuOrderTB xiaoDuOrderTB = new XiaoDuOrderTB();
@@ -1527,6 +1586,7 @@ public class DplBotService extends BaseBot {
xiaoDuOrderTB.setUnitPrice(unitPrice);
xiaoDuOrderTB.setNumber(number);
xiaoDuOrderTB.setIsBuy(false);
+ xiaoDuOrderTB.setStatus(false);
xiaoDuOrderTB.setOrderId(orderId);
return xiaoDuOrderTB;
}
diff --git a/xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/service/ScheduleService.java b/xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/service/ScheduleService.java
index f8c0e81..196b7bf 100644
--- a/xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/service/ScheduleService.java
+++ b/xiaoduhome/src/main/java/ai/qiwu/com/xiaoduhome/service/ScheduleService.java
@@ -6,6 +6,7 @@ import ai.qiwu.com.xiaoduhome.repository.primary.AllOnProductInfoRepository;
import ai.qiwu.com.xiaoduhome.repository.primary.GameProjectTbRepository;
import ai.qiwu.com.xiaoduhome.repository.primary.ProjectLabelRepository;
import ai.qiwu.com.xiaoduhome.repository.secondary.XiaoDuHistoryTBRepository;
+import ai.qiwu.com.xiaoduhome.repository.secondary.XiaoDuOrderTbRepository;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.beans.factory.annotation.Autowired;
@@ -44,13 +45,16 @@ public class ScheduleService implements InitializingBean {
private final XiaoDuHistoryTBRepository xiaoDuHistoryTBRepository;
+ private final XiaoDuOrderTbRepository xiaoDuOrderTbRepository;
+
@Autowired
public ScheduleService(GameProjectTbRepository gameProjectTbRepository,
- ProjectLabelRepository projectLabelRepository, AllOnProductInfoRepository allOnProductInfoRepository, XiaoDuHistoryTBRepository xiaoDuHistoryTBRepository) {
+ ProjectLabelRepository projectLabelRepository, AllOnProductInfoRepository allOnProductInfoRepository, XiaoDuHistoryTBRepository xiaoDuHistoryTBRepository, XiaoDuOrderTbRepository xiaoDuOrderTbRepository) {
this.gameProjectTbRepository = gameProjectTbRepository;
this.projectLabelRepository = projectLabelRepository;
this.allOnProductInfoRepository = allOnProductInfoRepository;
this.xiaoDuHistoryTBRepository = xiaoDuHistoryTBRepository;
+ this.xiaoDuOrderTbRepository = xiaoDuOrderTbRepository;
}
@Scheduled(cron = "0 0 19 * * ?")
@@ -113,6 +117,13 @@ public class ScheduleService implements InitializingBean {
//log.error("清理历史记录数据库出错:{}", e.toString());
}
+ @Scheduled(cron = "0 0 3 * * ?")
+ public void deleteUnPayedOrder() {
+ new Thread(() -> {
+ xiaoDuOrderTbRepository.deleteByStatus(false);
+ }).start();
+ }
+
@Override
public void afterPropertiesSet() throws Exception {
initAllOnTableProductInfo();
diff --git a/xiaoduhome/src/main/resources/static/json/funny.json b/xiaoduhome/src/main/resources/static/json/funny.json
new file mode 100644
index 0000000..8ec8b90
--- /dev/null
+++ b/xiaoduhome/src/main/resources/static/json/funny.json
@@ -0,0 +1,62 @@
+{
+ "type": "DPL",
+ "version": "1.0",
+ "mainTemplate": {
+ "parameters": [
+ "payload"
+ ],
+ "items": [
+ {
+ "type": "Image",
+ "height": "100%",
+ "width": "100%",
+ "position": "absolute",
+ "left": "0dp",
+ "top": "0dp",
+ "src": "https://aliyun-hz1.chewrobot.com/xiaoduhome/image/backend.jpg"
+ },
+ {
+ "type": "Container",
+ "width": "100%",
+ "height": "100%",
+ "items": [
+ {
+ "type": "Pager",
+ "direction": "horizontal",
+ "componentId": "funnyPage",
+ "width": "100%",
+ "height": "100%",
+ "onLoaded": [
+ {
+ "type": "AutoPage",
+ "componentId": "funnyPage",
+ "durationInMillisecond": 3000
+ }
+ ]
+ }
+ ]
+ },
+ {
+ "type": "Audio",
+ "componentId": "audioCom",
+ "looping": "false",
+ "autoplay": "true"
+ },
+ {
+ "type": "Container",
+ "position": "absolute",
+ "width": "100%",
+ "left": "0",
+ "bottom": "0",
+ "items": [
+ {
+ "type": "Footer",
+ "hints": [
+ "返回/回到首页","可左右滑动"
+ ]
+ }
+ ]
+ }
+ ]
+ }
+}
\ No newline at end of file
diff --git a/xiaoduhome/src/main/resources/static/json/funnyPageItem.json b/xiaoduhome/src/main/resources/static/json/funnyPageItem.json
new file mode 100644
index 0000000..f2cd73b
--- /dev/null
+++ b/xiaoduhome/src/main/resources/static/json/funnyPageItem.json
@@ -0,0 +1,31 @@
+{
+ "type": "Container",
+ "flex-direction": "row",
+ "width": "100%",
+ "height": "100%",
+ "items": [
+ {
+ "type": "Image",
+ "margin-top": "30dp",
+ "height": "400dp",
+ "width": "400dp",
+ "margin-left": "25dp",
+ "src": "${data.imgSrc}"
+ },
+ {
+ "type": "Container",
+ "width": "500dp",
+ "height": "100%",
+ "items": [
+ {
+ "type": "Text",
+ "text": "${data.text}",
+ "font-size": "25dp",
+ "line-height":"60dp",
+ "margin-top": "30dp",
+ "margin-left": "10dp"
+ }
+ ]
+ }
+ ]
+}
\ No newline at end of file
--
libgit2 0.27.1