Bläddra i källkod

添加推广商品数据

liu 2 år sedan
förälder
incheckning
1db4b28813

+ 86 - 12
mhotel/src/com/happy/action/articleTweetAction.java

@@ -9,6 +9,7 @@ import com.happy.Model.*;
 import com.happy.Model.weixin.Users;
 import com.happy.Until.*;
 import com.happy.common.controller.BaseController;
+import com.happy.common.http.HttpsClient;
 import com.happy.constant.ConstDefault;
 import com.happy.constant.ResultStatusCode;
 import com.happy.dto.ArticleCommentDto;
@@ -19,7 +20,15 @@ import com.happy.vo.*;
 import com.opensymphony.xwork2.ModelDriven;
 import lombok.SneakyThrows;
 import org.apache.commons.lang.StringUtils;
+import org.apache.http.HttpResponse;
+import org.apache.http.client.HttpClient;
+import org.apache.http.client.methods.HttpGet;
+import org.apache.http.client.methods.HttpPost;
+import org.apache.http.entity.StringEntity;
+import org.apache.http.impl.client.HttpClientBuilder;
+import org.apache.http.util.EntityUtils;
 import org.apache.struts2.ServletActionContext;
+import org.aspectj.weaver.ast.Var;
 import org.springframework.transaction.annotation.Transactional;
 
 import javax.annotation.Resource;
@@ -28,6 +37,8 @@ import java.text.ParseException;
 import java.util.*;
 import java.util.stream.Collectors;
 
+import static com.happy.common.http.HttpsClient.httpsRequestReturnString;
+
 public class articleTweetAction extends BaseController implements ModelDriven<ArticleTweetDto> {
 
     private final ArticleTweetDto articleTweetDto = new ArticleTweetDto();
@@ -61,12 +72,12 @@ public class articleTweetAction extends BaseController implements ModelDriven<Ar
 
     public String endTime;
 
-    public String getKey(){
+    public String getKey() {
         return key;
     }
 
-    public void setKey(String key){
-        this.key=key;
+    public void setKey(String key) {
+        this.key = key;
     }
 
     public String getStartTime() {
@@ -366,9 +377,9 @@ public class articleTweetAction extends BaseController implements ModelDriven<Ar
             Optional<HotelPriceOneDataVo> one = newOneDatas.stream().filter(e -> e.getManagerId().equals(hotel.getManagerId())).findFirst();
             Optional<PriceHotelDataVo> min = mins.stream().filter(e -> e.getManagerId().equals(hotel.getManagerId())).findFirst();
             if (one != null && one.isPresent() && min != null && min.isPresent()) {
-                if(one.get().getPrice() > min.get().getPrice()){
+                if (one.get().getPrice() > min.get().getPrice()) {
                     hotelData.setPrice(decimalFormat.format(min.get().getPrice()));
-                }else{
+                } else {
                     hotelData.setPrice(decimalFormat.format(one.get().getPrice()));
                 }
             } else {
@@ -539,9 +550,9 @@ public class articleTweetAction extends BaseController implements ModelDriven<Ar
             Optional<HotelPriceOneDataVo> one = newOneDatas.stream().filter(e -> e.getManagerId().equals(hotel.getManagerId())).findFirst();
             Optional<PriceHotelDataVo> min = mins.stream().filter(e -> e.getManagerId().equals(hotel.getManagerId())).findFirst();
             if (one != null && one.isPresent() && min != null && min.isPresent()) {
-                if(one.get().getPrice() > min.get().getPrice()){
+                if (one.get().getPrice() > min.get().getPrice()) {
                     hotelData.setPrice(decimalFormat.format(min.get().getPrice()));
-                }else{
+                } else {
                     hotelData.setPrice(decimalFormat.format(one.get().getPrice()));
                 }
             } else {
@@ -757,7 +768,7 @@ public class articleTweetAction extends BaseController implements ModelDriven<Ar
             List<FileInfo> fileInfos = articleTweetService.queryList("and link_id in (" + articleIds + ")");
 
             for (ArticleListVo data : result.getPageList()) {
-                if(fileInfos != null){
+                if (fileInfos != null) {
                     List<FileInfo> fileInfoList = fileInfos.stream().filter(e -> e.getLinkId().equals(data.getId().toString())).collect(Collectors.toList());
                     if (fileInfoList != null) {
                         if (fileInfoList.size() > 1) {
@@ -1176,21 +1187,22 @@ public class articleTweetAction extends BaseController implements ModelDriven<Ar
 
     /**
      * 攻略分页
+     *
      * @return
      */
-    public String walkthroughPage(){
+    public String walkthroughPage() {
         JSONObject jsonObject = new JSONObject();
 
         StringBuilder strSql = new StringBuilder(" and at.status=1 "); // 推文没删除才显示
-        if (!Func.checkNull(key)){
+        if (!Func.checkNull(key)) {
             strSql.append(" and (at.user_name like '%").append(key).append("%' or at.title like '%").append(key).append("%') ");
         }
-        if (!Func.checkNull(startTime) && !Func.checkNull(endTime)){
+        if (!Func.checkNull(startTime) && !Func.checkNull(endTime)) {
             strSql.append(" and at.create_date >= '").append(startTime).append("' ");
             strSql.append(" and at.create_date <= '").append(endTime).append("' ");
         }
 
-        IPage<WalkthroughVo> walkthroughPage=articleTweetService.walkthroughPage(strSql.toString(),page, rows);
+        IPage<WalkthroughVo> walkthroughPage = articleTweetService.walkthroughPage(strSql.toString(), page, rows);
 
         jsonObject.put("message", "查询分页成功");
         jsonObject.put("code", 200);
@@ -1199,4 +1211,66 @@ public class articleTweetAction extends BaseController implements ModelDriven<Ar
         return null;
     }
 
+    /**
+     * 商品页面
+     */
+    public String productPage() throws Exception {
+
+        JSONObject jsonObject = new JSONObject();
+//        JSONObject jsonBody = new JSONObject();
+//        jsonBody.put("username", "admin");
+//        jsonBody.put("password", "123456");
+//
+//        String url = "https://www.jinganrenjiams.com/cloud-mall/admin/open/login";
+//
+        // 构建http请求客户端
+//        HttpClient httpclient = HttpClientBuilder.create().useSystemProperties().build();
+//        // 构建post请求
+//        HttpPost postMethod = new HttpPost(url);
+//        // 设置请求头
+//        postMethod.addHeader("Content-Type", "application/json");
+//        // 设置请求体
+//        postMethod.setEntity(new StringEntity(jsonBody.toString()));
+//
+//        // 发送请求
+//        HttpResponse response = httpclient.execute(postMethod);
+//
+//        String s = EntityUtils.toString(response.getEntity());
+//
+//        JSONObject postJson = JSONObject.parseObject(s);
+//
+//        JSONObject data = postJson.getJSONObject("data");
+//
+//        String token = data.getString("token");
+
+        // 构建http请求客户端
+        HttpClient httpclient = HttpClientBuilder.create().useSystemProperties().build();
+        String getUrl = "";
+
+        if (!Func.checkNull(key)) {
+                getUrl = "https://www.jinganrenjiams.com/cloud-mall/goods/open/page?state=1&curPage="+page+"&pageSize="+rows+"&goodsName=" + key;
+        } else {
+            getUrl = "https://www.jinganrenjiams.com/cloud-mall/goods/open/page?state=1&curPage="+page+"&pageSize="+rows;
+        }
+
+        HttpGet httpGet = new HttpGet(getUrl);
+        // 设置请求头
+        httpGet.addHeader("Content-Type", "application/json");
+//        httpGet.addHeader("Mall-Token", token);
+        // 发送请求
+        HttpResponse execute = httpclient.execute(httpGet);
+        String s1 = EntityUtils.toString(execute.getEntity());
+        JSONObject getJson = JSONObject.parseObject(s1);
+        JSONObject data1 = getJson.getJSONObject("data");
+
+
+        jsonObject.put("message", "查询分页成功");
+        jsonObject.put("code", 200);
+        jsonObject.put("data", data1);
+        ResUtil.writeJson(ServletActionContext.getResponse(), jsonObject.toString());
+
+        return null;
+    }
+
+
 }

+ 1 - 1
mhotel/src/com/happy/vo/WalkthroughVo.java

@@ -31,7 +31,7 @@ public class WalkthroughVo {
     /**
      * 创建时间
      */
-    private Date createDate;
+    private String createDate;
 
 
     /**