Browse Source

关注接口对接

ytf 3 years ago
parent
commit
c6a3030b44

+ 19 - 16
krock-pm/krock-web-pm/src/main/java/com/ydw/yunbuyer/web/pm/controller/api/TokenPersonController.java

@@ -1,5 +1,6 @@
1
 package com.ydw.yunbuyer.web.pm.controller.api;
1
 package com.ydw.yunbuyer.web.pm.controller.api;
2
 
2
 
3
+import com.ydw.yunbuyer.common.utils.date.CreatedTools;
3
 import com.ydw.yunbuyer.web.pm.base.ProjBaseAction;
4
 import com.ydw.yunbuyer.web.pm.base.ProjBaseAction;
4
 import com.ydw.yunbuyer.web.pm.web.WebMsgTools;
5
 import com.ydw.yunbuyer.web.pm.web.WebMsgTools;
5
 import io.swagger.annotations.Api;
6
 import io.swagger.annotations.Api;
@@ -8,6 +9,7 @@ import org.springframework.web.bind.annotation.RequestMapping;
8
 import org.springframework.web.bind.annotation.RestController;
9
 import org.springframework.web.bind.annotation.RestController;
9
 
10
 
10
 import java.io.IOException;
11
 import java.io.IOException;
12
+import java.util.Random;
11
 
13
 
12
 @Api(tags = "Token获取")
14
 @Api(tags = "Token获取")
13
 @RestController
15
 @RestController
@@ -15,20 +17,21 @@ import java.io.IOException;
15
 @RequestMapping("/api/token")
17
 @RequestMapping("/api/token")
16
 public class TokenPersonController extends ProjBaseAction {
18
 public class TokenPersonController extends ProjBaseAction {
17
 
19
 
18
-	/**
19
-	 *
20
-	 * 获取token
21
-	 * @return
22
-	 */
23
-	@RequestMapping("/get_token")
24
-	public String get_token() {
25
-		String token = null;
26
-		try {
27
-			token = WebMsgTools.get_access_Token();
28
-		} catch (IOException e) {
29
-			e.printStackTrace();
30
-		}
31
-		result.put("token", token);
32
-		return result.toJSONString();
33
-	}
20
+    /**
21
+     * 获取token
22
+     *
23
+     * @return
24
+     */
25
+    @RequestMapping("/get_token")
26
+    public String get_token() {
27
+        String token = null;
28
+        try {
29
+            token = WebMsgTools.get_access_Token() + "@" + CreatedTools.getCreated();
30
+        } catch (IOException e) {
31
+            e.printStackTrace();
32
+        }
33
+        result.put("token", token);
34
+        return result.toJSONString();
35
+    }
36
+
34
 }
37
 }

+ 10 - 5
krock-pm/krock-web-pm/src/main/java/com/ydw/yunbuyer/web/pm/controller_wxapp/ScheduledController.java

@@ -6,6 +6,8 @@ import java.util.*;
6
 import com.ydw.yunbuyer.web.pm.entity.t_pm_item_follow;
6
 import com.ydw.yunbuyer.web.pm.entity.t_pm_item_follow;
7
 import com.ydw.yunbuyer.web.pm.service.WxFollowService;
7
 import com.ydw.yunbuyer.web.pm.service.WxFollowService;
8
 import com.ydw.yunbuyer.web.pm.web.WebMsgTools;
8
 import com.ydw.yunbuyer.web.pm.web.WebMsgTools;
9
+import org.slf4j.Logger;
10
+import org.slf4j.LoggerFactory;
9
 import org.springframework.beans.factory.annotation.Autowired;
11
 import org.springframework.beans.factory.annotation.Autowired;
10
 import org.springframework.scheduling.annotation.Scheduled;
12
 import org.springframework.scheduling.annotation.Scheduled;
11
 import org.springframework.stereotype.Component;
13
 import org.springframework.stereotype.Component;
@@ -33,6 +35,7 @@ public class ScheduledController {
33
 	private static long SAME_DAY_END = 0L;//当天结束日期
35
 	private static long SAME_DAY_END = 0L;//当天结束日期
34
 	private static SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm"); //格式化
36
 	private static SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm"); //格式化
35
 	private static Map<String,List<Map<String, Object>>> SAME_DAY_MAP = new HashMap<>();//缓存数据
37
 	private static Map<String,List<Map<String, Object>>> SAME_DAY_MAP = new HashMap<>();//缓存数据
38
+	protected Logger logger = LoggerFactory.getLogger(ScheduledController.class);
36
 
39
 
37
 	@Autowired
40
 	@Autowired
38
 	private PmItemService pmItemService;
41
 	private PmItemService pmItemService;
@@ -104,7 +107,9 @@ public class ScheduledController {
104
 			SAME_DAY_MAP = new HashMap<>();//更新数据
107
 			SAME_DAY_MAP = new HashMap<>();//更新数据
105
 			addSameDayMap(nowTime);
108
 			addSameDayMap(nowTime);
106
 		}
109
 		}
110
+
107
 		if (CollectionUtils.isEmpty(SAME_DAY_MAP)){
111
 		if (CollectionUtils.isEmpty(SAME_DAY_MAP)){
112
+			logger.info("缓存列表数量:为空");
108
 			return;
113
 			return;
109
 		}
114
 		}
110
 		//3.查询数据 1.当前时间加30分钟查询数据 2.当前时间加10分钟查询数据
115
 		//3.查询数据 1.当前时间加30分钟查询数据 2.当前时间加10分钟查询数据
@@ -143,15 +148,20 @@ public class ScheduledController {
143
 	}
148
 	}
144
 
149
 
145
 	private void sendMsg(List<Map<String, Object>> list) {
150
 	private void sendMsg(List<Map<String, Object>> list) {
151
+
146
 		if (CollectionUtils.isEmpty(list)){
152
 		if (CollectionUtils.isEmpty(list)){
153
+			logger.info("当前时间为空");
147
 			return;
154
 			return;
148
 		}
155
 		}
156
+		logger.info("开始发送");
149
 		for (Map<String, Object> map:list) {
157
 		for (Map<String, Object> map:list) {
150
 			String open_id = String.valueOf(map.get("open_id"));
158
 			String open_id = String.valueOf(map.get("open_id"));
151
 			String pm_item_name = String.valueOf(map.get("pm_item_name"));
159
 			String pm_item_name = String.valueOf(map.get("pm_item_name"));
152
 			String time_opening = String.valueOf(map.get("time_opening"));
160
 			String time_opening = String.valueOf(map.get("time_opening"));
161
+			time_opening = formatter.format(Long.valueOf(time_opening));
153
 			WebMsgTools.sendAuctionStartReminderMessage(open_id,pm_item_name,time_opening);
162
 			WebMsgTools.sendAuctionStartReminderMessage(open_id,pm_item_name,time_opening);
154
 		}
163
 		}
164
+		logger.info("发送结束");
155
 	}
165
 	}
156
 
166
 
157
 	private static long getEndTime() {
167
 	private static long getEndTime() {
@@ -163,9 +173,4 @@ public class ScheduledController {
163
 		return todayEnd.getTimeInMillis();
173
 		return todayEnd.getTimeInMillis();
164
 	}
174
 	}
165
 
175
 
166
-	public static void main(String[] args) {
167
-		System.out.println(System.currentTimeMillis());
168
-		System.out.println(getEndTime());
169
-
170
-	}
171
 }
176
 }

+ 28 - 9
krock-pm/krock-web-pm/src/main/java/com/ydw/yunbuyer/web/pm/controller_wxapp/WxFollowController.java

@@ -10,12 +10,15 @@ import com.ydw.yunbuyer.web.pm.service.WxFollowService;
10
 import com.ydw.yunbuyer.web.pm.web.SessionWxService;
10
 import com.ydw.yunbuyer.web.pm.web.SessionWxService;
11
 import io.swagger.annotations.Api;
11
 import io.swagger.annotations.Api;
12
 import io.swagger.annotations.ApiOperation;
12
 import io.swagger.annotations.ApiOperation;
13
+import io.swagger.annotations.ApiParam;
13
 import org.apache.commons.lang3.StringUtils;
14
 import org.apache.commons.lang3.StringUtils;
14
 import org.springframework.beans.factory.annotation.Autowired;
15
 import org.springframework.beans.factory.annotation.Autowired;
15
 import org.springframework.context.annotation.Scope;
16
 import org.springframework.context.annotation.Scope;
17
+import org.springframework.web.bind.annotation.GetMapping;
16
 import org.springframework.web.bind.annotation.RequestMapping;
18
 import org.springframework.web.bind.annotation.RequestMapping;
17
 import org.springframework.web.bind.annotation.RestController;
19
 import org.springframework.web.bind.annotation.RestController;
18
 
20
 
21
+import java.text.SimpleDateFormat;
19
 import java.util.List;
22
 import java.util.List;
20
 import java.util.Map;
23
 import java.util.Map;
21
 
24
 
@@ -32,28 +35,29 @@ public class WxFollowController extends ProjBaseAction {
32
     private PmItemService pmItemService;
35
     private PmItemService pmItemService;
33
 
36
 
34
     @ApiOperation("关注和取消")
37
     @ApiOperation("关注和取消")
35
-    @RequestMapping("/edit_pm_follow")
36
-    public String edit_pm_follow(String pm_item_id){
38
+    @GetMapping("/edit_pm_follow")
39
+    public String edit_pm_follow(@ApiParam(name = "pm_item_id",value = "商品id",required = true) String pm_item_id){
37
         if (StringUtils.isBlank(pm_item_id)){
40
         if (StringUtils.isBlank(pm_item_id)){
38
             result.put("statuz",false);
41
             result.put("statuz",false);
39
-            result.put("message", "输入标的物id为空");
42
+            result.put("message", "输入商品id为空");
40
             return result.toJSONString();
43
             return result.toJSONString();
41
         }
44
         }
42
         t_pm_item t_pm_item = pmItemService.get(pm_item_id);
45
         t_pm_item t_pm_item = pmItemService.get(pm_item_id);
43
         if (t_pm_item == null ){
46
         if (t_pm_item == null ){
44
-            result.put("statuz",false);
45
-            result.put("message", "标的物不存在");
47
+            result.put("statu",false);
48
+            result.put("message", "商品不存在");
46
             return result.toJSONString();
49
             return result.toJSONString();
47
         }
50
         }
48
         if (t_pm_item.getTime_opening() <0 ){
51
         if (t_pm_item.getTime_opening() <0 ){
49
             result.put("statuz",false);
52
             result.put("statuz",false);
50
-            result.put("message", "标的物开拍时间没设置");
53
+            result.put("message", "商品开拍时间没设置");
51
             return result.toJSONString();
54
             return result.toJSONString();
52
         }
55
         }
53
         JSONObject person = sessionWxService.getCurrentLoginPersion();
56
         JSONObject person = sessionWxService.getCurrentLoginPersion();
54
         String person_id = person.getString("kid");//用户id
57
         String person_id = person.getString("kid");//用户id
55
         String open_id = person.getString("openid");//用户openid
58
         String open_id = person.getString("openid");//用户openid
56
         t_pm_item_follow pm_item_follow = wxFollowService.getPersonidAndPmid(person_id,pm_item_id);
59
         t_pm_item_follow pm_item_follow = wxFollowService.getPersonidAndPmid(person_id,pm_item_id);
60
+        int status = 0;
57
         if (pm_item_follow == null){
61
         if (pm_item_follow == null){
58
             t_pm_item_follow addParam = new t_pm_item_follow();
62
             t_pm_item_follow addParam = new t_pm_item_follow();
59
             addParam.setPerson_id(person_id);
63
             addParam.setPerson_id(person_id);
@@ -63,20 +67,22 @@ public class WxFollowController extends ProjBaseAction {
63
             addParam.setStatus(0);
67
             addParam.setStatus(0);
64
             addParam.setTime_opening(t_pm_item.getTime_opening());
68
             addParam.setTime_opening(t_pm_item.getTime_opening());
65
             wxFollowService.add(addParam);
69
             wxFollowService.add(addParam);
70
+            ScheduledController.initSameDayEnd(t_pm_item.getTime_opening());
66
         }else{
71
         }else{
67
-            int status = pm_item_follow.getStatus() == 0? -100 : 0; //转换关注状态
72
+            status = pm_item_follow.getStatus() == 0? -100 : 0; //转换关注状态
68
             pm_item_follow.setStatus(status);
73
             pm_item_follow.setStatus(status);
69
             pm_item_follow.setEditd(CreatedTools.getCreated());
74
             pm_item_follow.setEditd(CreatedTools.getCreated());
70
             pm_item_follow.setEdit_count(pm_item_follow.getEdit_count()+1);
75
             pm_item_follow.setEdit_count(pm_item_follow.getEdit_count()+1);
71
             wxFollowService.update(pm_item_follow);
76
             wxFollowService.update(pm_item_follow);
72
         }
77
         }
73
         result.put("statuz",true);
78
         result.put("statuz",true);
79
+        result.put("attentionState",status);
74
         result.put("message", "操作成功");
80
         result.put("message", "操作成功");
75
         return result.toJSONString();
81
         return result.toJSONString();
76
     }
82
     }
77
 
83
 
78
-    @ApiOperation("查询用户关注的标的物")
79
-    @RequestMapping("/list_person_pm_follow")
84
+    @ApiOperation("查询用户关注的商品")
85
+    @GetMapping("/list_person_pm_follow")
80
     public String list_person_pm_follow() {
86
     public String list_person_pm_follow() {
81
         JSONObject person = sessionWxService.getCurrentLoginPersion();
87
         JSONObject person = sessionWxService.getCurrentLoginPersion();
82
         String person_id = person.getString("kid");//用户id
88
         String person_id = person.getString("kid");//用户id
@@ -85,4 +91,17 @@ public class WxFollowController extends ProjBaseAction {
85
         return result.toJSONString();
91
         return result.toJSONString();
86
     }
92
     }
87
 
93
 
94
+    @ApiOperation("刷新定时中的缓存关注数据")
95
+    @GetMapping("/init_follow")
96
+    public String init_follow(){
97
+        ScheduledController.initSameDayEnd(System.currentTimeMillis());
98
+        logger.info("操作成功");
99
+        result.put("message", "操作成功");
100
+        return result.toJSONString();
101
+    }
102
+
103
+    public static void main(String[] args) {
104
+
105
+    }
106
+
88
 }
107
 }

+ 3 - 3
krock-pm/krock-web-pm/src/main/java/com/ydw/yunbuyer/web/pm/controller_wxapp/WxPmApiController.java

@@ -116,17 +116,17 @@ public class WxPmApiController extends ProjBaseAction {
116
 		List<Map<String, Object>> list1 = wxPmService.bidding_record(kid);
116
 		List<Map<String, Object>> list1 = wxPmService.bidding_record(kid);
117
 
117
 
118
 		// 是否关注查询
118
 		// 是否关注查询
119
-		JSONObject person = sessionWxService.getCurrentLoginPersion();
119
+/*		JSONObject person = sessionWxService.getCurrentLoginPersion();
120
 		String person_id = person.getString("kid");//用户id
120
 		String person_id = person.getString("kid");//用户id
121
 		t_pm_item_follow pm_follow = wxFollowService.getPersonidAndPmid(person_id, kid);
121
 		t_pm_item_follow pm_follow = wxFollowService.getPersonidAndPmid(person_id, kid);
122
-		Boolean follow = pm_follow == null?false:pm_follow.getStatus()==0; //true 关注 false 没关注
122
+		int attentionState = pm_follow == null?-100:pm_follow.getStatus();*/
123
 
123
 
124
 		result.put("nowtime", System.currentTimeMillis());
124
 		result.put("nowtime", System.currentTimeMillis());
125
 		result.put("imgarray", imgsrclist);
125
 		result.put("imgarray", imgsrclist);
126
 		result.put("data", list);
126
 		result.put("data", list);
127
 		result.put("record", list1);
127
 		result.put("record", list1);
128
 		result.put("statuz", true);
128
 		result.put("statuz", true);
129
-		result.put("follow", follow); //true 关注 false 没关注
129
+//		result.put("attentionState", attentionState);
130
 		return result.toJSONString();
130
 		return result.toJSONString();
131
 	}
131
 	}
132
 
132
 

+ 10 - 1
krock-pm/krock-web-pm/src/main/java/com/ydw/yunbuyer/web/pm/controller_wxapp/WxPmController.java

@@ -86,6 +86,9 @@ public class WxPmController extends ProjBaseAction {
86
 	@Autowired
86
 	@Autowired
87
 	private WxSubmitService wxSubmitService;
87
 	private WxSubmitService wxSubmitService;
88
 
88
 
89
+	@Autowired
90
+	private WxFollowService wxFollowService;
91
+
89
 	public static final Map<String, List<Map<String, Object>>> count = new HashMap<String, List<Map<String, Object>>>();
92
 	public static final Map<String, List<Map<String, Object>>> count = new HashMap<String, List<Map<String, Object>>>();
90
 
93
 
91
 	/**
94
 	/**
@@ -339,7 +342,7 @@ public class WxPmController extends ProjBaseAction {
339
 	 * @return
342
 	 * @return
340
 	 */
343
 	 */
341
 	@ApiOperation("详情页")
344
 	@ApiOperation("详情页")
342
-	@RequestMapping("/select_list")
345
+	@GetMapping("/select_list")
343
 	public String select_list(String kid) {
346
 	public String select_list(String kid) {
344
 		if (ChkUtil.isNull(kid)) {
347
 		if (ChkUtil.isNull(kid)) {
345
 			super.setTipMsg(false, "商品不存在", Tip.Type.error);
348
 			super.setTipMsg(false, "商品不存在", Tip.Type.error);
@@ -393,6 +396,11 @@ public class WxPmController extends ProjBaseAction {
393
 			if (ChkUtil.isNotNull(pm_offline_apply)) {
396
 			if (ChkUtil.isNotNull(pm_offline_apply)) {
394
 				result.put("pm_offline_apply", pm_offline_apply);
397
 				result.put("pm_offline_apply", pm_offline_apply);
395
 			}
398
 			}
399
+			// 是否关注查询
400
+			JSONObject person = sessionWxService.getCurrentLoginPersion();
401
+			String person_id = person.getString("kid");//用户id
402
+			t_pm_item_follow pm_follow = wxFollowService.getPersonidAndPmid(person_id, kid);
403
+			int attentionState = pm_follow == null?-100:pm_follow.getStatus();
396
 			// 竞价记录
404
 			// 竞价记录
397
 			List<Map<String, Object>> list1 = wxPmService.bidding_record(kid);
405
 			List<Map<String, Object>> list1 = wxPmService.bidding_record(kid);
398
 			result.put("nowtime", System.currentTimeMillis());
406
 			result.put("nowtime", System.currentTimeMillis());
@@ -400,6 +408,7 @@ public class WxPmController extends ProjBaseAction {
400
 			result.put("data", list);
408
 			result.put("data", list);
401
 			result.put("record", list1);
409
 			result.put("record", list1);
402
 			result.put("statuz", true);
410
 			result.put("statuz", true);
411
+			result.put("attentionState", attentionState);
403
 			return result.toJSONString();
412
 			return result.toJSONString();
404
 		}
413
 		}
405
 
414
 

+ 7 - 17
krock-pm/krock-web-pm/src/main/java/com/ydw/yunbuyer/web/pm/web/WebMsgTools.java

@@ -1,9 +1,12 @@
1
 package com.ydw.yunbuyer.web.pm.web;
1
 package com.ydw.yunbuyer.web.pm.web;
2
 
2
 
3
 import com.alibaba.fastjson.JSONObject;
3
 import com.alibaba.fastjson.JSONObject;
4
+import com.ydw.yunbuyer.web.pm.controller_wxapp.ScheduledController;
4
 import com.ydw.yunbuyer.web.pm.entity.TemplateData;
5
 import com.ydw.yunbuyer.web.pm.entity.TemplateData;
5
 import com.ydw.yunbuyer.web.pm.entity.WxMssVo;
6
 import com.ydw.yunbuyer.web.pm.entity.WxMssVo;
6
 import org.apache.http.client.ClientProtocolException;
7
 import org.apache.http.client.ClientProtocolException;
8
+import org.slf4j.Logger;
9
+import org.slf4j.LoggerFactory;
7
 import org.tmsps.ne4spring.utils.JsonUtil;
10
 import org.tmsps.ne4spring.utils.JsonUtil;
8
 
11
 
9
 import java.io.BufferedReader;
12
 import java.io.BufferedReader;
@@ -13,6 +16,7 @@ import java.io.InputStreamReader;
13
 import java.net.HttpURLConnection;
16
 import java.net.HttpURLConnection;
14
 import java.net.URL;
17
 import java.net.URL;
15
 import java.net.URLConnection;
18
 import java.net.URLConnection;
19
+import java.text.SimpleDateFormat;
16
 import java.util.HashMap;
20
 import java.util.HashMap;
17
 import java.util.List;
21
 import java.util.List;
18
 import java.util.Map;
22
 import java.util.Map;
@@ -20,12 +24,13 @@ import java.util.Random;
20
 
24
 
21
 public class WebMsgTools {
25
 public class WebMsgTools {
22
 	private static String subscribeMessageUrl = "https://api.weixin.qq.com/cgi-bin/message/subscribe/send?access_token=ACCESS_TOKEN";
26
 	private static String subscribeMessageUrl = "https://api.weixin.qq.com/cgi-bin/message/subscribe/send?access_token=ACCESS_TOKEN";
23
-
27
+	protected static Logger logger = LoggerFactory.getLogger(WebMsgTools.class);
24
 	/**
28
 	/**
25
 	 *  拍卖开始提醒
29
 	 *  拍卖开始提醒
26
 	 * @return
30
 	 * @return
27
 	 */
31
 	 */
28
 	public static String sendAuctionStartReminderMessage(String openId,String thing,String date){
32
 	public static String sendAuctionStartReminderMessage(String openId,String thing,String date){
33
+		logger.info("拍卖开始提醒发送参数:openId="+openId+" thing="+thing+" date="+date);
29
 		String url = null;
34
 		String url = null;
30
 		try {
35
 		try {
31
 			url = subscribeMessageUrl.replace("ACCESS_TOKEN",get_access_Token());
36
 			url = subscribeMessageUrl.replace("ACCESS_TOKEN",get_access_Token());
@@ -55,6 +60,7 @@ public class WebMsgTools {
55
 	 * @return
60
 	 * @return
56
 	 */
61
 	 */
57
 	public static String sendAuctionSuccessNoticeMessage(String openId,String thing,String amount,String date,String number) throws IOException {
62
 	public static String sendAuctionSuccessNoticeMessage(String openId,String thing,String amount,String date,String number) throws IOException {
63
+		logger.info("拍卖成功通知发送参数:openId="+openId+" thing="+thing+" amount="+amount+" date="+date+" number="+number);
58
 		String url = subscribeMessageUrl.replace("ACCESS_TOKEN",get_access_Token());
64
 		String url = subscribeMessageUrl.replace("ACCESS_TOKEN",get_access_Token());
59
 		WxMssVo wxMssVo = new WxMssVo();
65
 		WxMssVo wxMssVo = new WxMssVo();
60
 		wxMssVo.setTouser(openId);
66
 		wxMssVo.setTouser(openId);
@@ -147,20 +153,4 @@ public class WebMsgTools {
147
 		return result;
153
 		return result;
148
 	}
154
 	}
149
 
155
 
150
-	public static void main(String[] args) throws IOException {
151
-//		sendAuctionStartReminderMessage("oIQgR5QOJmf3gMCA2z8HyU9TaI5Q","cs","2022年01月05日");
152
-//		sendAuctionSuccessNoticeMessage("oIQgR5QOJmf3gMCA2z8HyU9TaI5Q","拍品名称","100","2022年01月05日","1");
153
-		int i = -1;
154
-		i >>>= 10;
155
-		System.out.println(i);
156
-		long l = -1;
157
-		l >>>= 10;
158
-		System.out.println(l);
159
-		short s = 1;
160
-		s >>= 10;
161
-		System.out.println(s);
162
-		byte b = 1;
163
-		b >>= 10;
164
-		System.out.println(b);
165
-	}
166
 }
156
 }