ytf пре 3 година
родитељ
комит
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 1
 package com.ydw.yunbuyer.web.pm.controller.api;
2 2
 
3
+import com.ydw.yunbuyer.common.utils.date.CreatedTools;
3 4
 import com.ydw.yunbuyer.web.pm.base.ProjBaseAction;
4 5
 import com.ydw.yunbuyer.web.pm.web.WebMsgTools;
5 6
 import io.swagger.annotations.Api;
@@ -8,6 +9,7 @@ import org.springframework.web.bind.annotation.RequestMapping;
8 9
 import org.springframework.web.bind.annotation.RestController;
9 10
 
10 11
 import java.io.IOException;
12
+import java.util.Random;
11 13
 
12 14
 @Api(tags = "Token获取")
13 15
 @RestController
@@ -15,20 +17,21 @@ import java.io.IOException;
15 17
 @RequestMapping("/api/token")
16 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 6
 import com.ydw.yunbuyer.web.pm.entity.t_pm_item_follow;
7 7
 import com.ydw.yunbuyer.web.pm.service.WxFollowService;
8 8
 import com.ydw.yunbuyer.web.pm.web.WebMsgTools;
9
+import org.slf4j.Logger;
10
+import org.slf4j.LoggerFactory;
9 11
 import org.springframework.beans.factory.annotation.Autowired;
10 12
 import org.springframework.scheduling.annotation.Scheduled;
11 13
 import org.springframework.stereotype.Component;
@@ -33,6 +35,7 @@ public class ScheduledController {
33 35
 	private static long SAME_DAY_END = 0L;//当天结束日期
34 36
 	private static SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm"); //格式化
35 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 40
 	@Autowired
38 41
 	private PmItemService pmItemService;
@@ -104,7 +107,9 @@ public class ScheduledController {
104 107
 			SAME_DAY_MAP = new HashMap<>();//更新数据
105 108
 			addSameDayMap(nowTime);
106 109
 		}
110
+
107 111
 		if (CollectionUtils.isEmpty(SAME_DAY_MAP)){
112
+			logger.info("缓存列表数量:为空");
108 113
 			return;
109 114
 		}
110 115
 		//3.查询数据 1.当前时间加30分钟查询数据 2.当前时间加10分钟查询数据
@@ -143,15 +148,20 @@ public class ScheduledController {
143 148
 	}
144 149
 
145 150
 	private void sendMsg(List<Map<String, Object>> list) {
151
+
146 152
 		if (CollectionUtils.isEmpty(list)){
153
+			logger.info("当前时间为空");
147 154
 			return;
148 155
 		}
156
+		logger.info("开始发送");
149 157
 		for (Map<String, Object> map:list) {
150 158
 			String open_id = String.valueOf(map.get("open_id"));
151 159
 			String pm_item_name = String.valueOf(map.get("pm_item_name"));
152 160
 			String time_opening = String.valueOf(map.get("time_opening"));
161
+			time_opening = formatter.format(Long.valueOf(time_opening));
153 162
 			WebMsgTools.sendAuctionStartReminderMessage(open_id,pm_item_name,time_opening);
154 163
 		}
164
+		logger.info("发送结束");
155 165
 	}
156 166
 
157 167
 	private static long getEndTime() {
@@ -163,9 +173,4 @@ public class ScheduledController {
163 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 10
 import com.ydw.yunbuyer.web.pm.web.SessionWxService;
11 11
 import io.swagger.annotations.Api;
12 12
 import io.swagger.annotations.ApiOperation;
13
+import io.swagger.annotations.ApiParam;
13 14
 import org.apache.commons.lang3.StringUtils;
14 15
 import org.springframework.beans.factory.annotation.Autowired;
15 16
 import org.springframework.context.annotation.Scope;
17
+import org.springframework.web.bind.annotation.GetMapping;
16 18
 import org.springframework.web.bind.annotation.RequestMapping;
17 19
 import org.springframework.web.bind.annotation.RestController;
18 20
 
21
+import java.text.SimpleDateFormat;
19 22
 import java.util.List;
20 23
 import java.util.Map;
21 24
 
@@ -32,28 +35,29 @@ public class WxFollowController extends ProjBaseAction {
32 35
     private PmItemService pmItemService;
33 36
 
34 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 40
         if (StringUtils.isBlank(pm_item_id)){
38 41
             result.put("statuz",false);
39
-            result.put("message", "输入标的物id为空");
42
+            result.put("message", "输入商品id为空");
40 43
             return result.toJSONString();
41 44
         }
42 45
         t_pm_item t_pm_item = pmItemService.get(pm_item_id);
43 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 49
             return result.toJSONString();
47 50
         }
48 51
         if (t_pm_item.getTime_opening() <0 ){
49 52
             result.put("statuz",false);
50
-            result.put("message", "标的物开拍时间没设置");
53
+            result.put("message", "商品开拍时间没设置");
51 54
             return result.toJSONString();
52 55
         }
53 56
         JSONObject person = sessionWxService.getCurrentLoginPersion();
54 57
         String person_id = person.getString("kid");//用户id
55 58
         String open_id = person.getString("openid");//用户openid
56 59
         t_pm_item_follow pm_item_follow = wxFollowService.getPersonidAndPmid(person_id,pm_item_id);
60
+        int status = 0;
57 61
         if (pm_item_follow == null){
58 62
             t_pm_item_follow addParam = new t_pm_item_follow();
59 63
             addParam.setPerson_id(person_id);
@@ -63,20 +67,22 @@ public class WxFollowController extends ProjBaseAction {
63 67
             addParam.setStatus(0);
64 68
             addParam.setTime_opening(t_pm_item.getTime_opening());
65 69
             wxFollowService.add(addParam);
70
+            ScheduledController.initSameDayEnd(t_pm_item.getTime_opening());
66 71
         }else{
67
-            int status = pm_item_follow.getStatus() == 0? -100 : 0; //转换关注状态
72
+            status = pm_item_follow.getStatus() == 0? -100 : 0; //转换关注状态
68 73
             pm_item_follow.setStatus(status);
69 74
             pm_item_follow.setEditd(CreatedTools.getCreated());
70 75
             pm_item_follow.setEdit_count(pm_item_follow.getEdit_count()+1);
71 76
             wxFollowService.update(pm_item_follow);
72 77
         }
73 78
         result.put("statuz",true);
79
+        result.put("attentionState",status);
74 80
         result.put("message", "操作成功");
75 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 86
     public String list_person_pm_follow() {
81 87
         JSONObject person = sessionWxService.getCurrentLoginPersion();
82 88
         String person_id = person.getString("kid");//用户id
@@ -85,4 +91,17 @@ public class WxFollowController extends ProjBaseAction {
85 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 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 120
 		String person_id = person.getString("kid");//用户id
121 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 124
 		result.put("nowtime", System.currentTimeMillis());
125 125
 		result.put("imgarray", imgsrclist);
126 126
 		result.put("data", list);
127 127
 		result.put("record", list1);
128 128
 		result.put("statuz", true);
129
-		result.put("follow", follow); //true 关注 false 没关注
129
+//		result.put("attentionState", attentionState);
130 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 86
 	@Autowired
87 87
 	private WxSubmitService wxSubmitService;
88 88
 
89
+	@Autowired
90
+	private WxFollowService wxFollowService;
91
+
89 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 342
 	 * @return
340 343
 	 */
341 344
 	@ApiOperation("详情页")
342
-	@RequestMapping("/select_list")
345
+	@GetMapping("/select_list")
343 346
 	public String select_list(String kid) {
344 347
 		if (ChkUtil.isNull(kid)) {
345 348
 			super.setTipMsg(false, "商品不存在", Tip.Type.error);
@@ -393,6 +396,11 @@ public class WxPmController extends ProjBaseAction {
393 396
 			if (ChkUtil.isNotNull(pm_offline_apply)) {
394 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 405
 			List<Map<String, Object>> list1 = wxPmService.bidding_record(kid);
398 406
 			result.put("nowtime", System.currentTimeMillis());
@@ -400,6 +408,7 @@ public class WxPmController extends ProjBaseAction {
400 408
 			result.put("data", list);
401 409
 			result.put("record", list1);
402 410
 			result.put("statuz", true);
411
+			result.put("attentionState", attentionState);
403 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 1
 package com.ydw.yunbuyer.web.pm.web;
2 2
 
3 3
 import com.alibaba.fastjson.JSONObject;
4
+import com.ydw.yunbuyer.web.pm.controller_wxapp.ScheduledController;
4 5
 import com.ydw.yunbuyer.web.pm.entity.TemplateData;
5 6
 import com.ydw.yunbuyer.web.pm.entity.WxMssVo;
6 7
 import org.apache.http.client.ClientProtocolException;
8
+import org.slf4j.Logger;
9
+import org.slf4j.LoggerFactory;
7 10
 import org.tmsps.ne4spring.utils.JsonUtil;
8 11
 
9 12
 import java.io.BufferedReader;
@@ -13,6 +16,7 @@ import java.io.InputStreamReader;
13 16
 import java.net.HttpURLConnection;
14 17
 import java.net.URL;
15 18
 import java.net.URLConnection;
19
+import java.text.SimpleDateFormat;
16 20
 import java.util.HashMap;
17 21
 import java.util.List;
18 22
 import java.util.Map;
@@ -20,12 +24,13 @@ import java.util.Random;
20 24
 
21 25
 public class WebMsgTools {
22 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 30
 	 * @return
27 31
 	 */
28 32
 	public static String sendAuctionStartReminderMessage(String openId,String thing,String date){
33
+		logger.info("拍卖开始提醒发送参数:openId="+openId+" thing="+thing+" date="+date);
29 34
 		String url = null;
30 35
 		try {
31 36
 			url = subscribeMessageUrl.replace("ACCESS_TOKEN",get_access_Token());
@@ -55,6 +60,7 @@ public class WebMsgTools {
55 60
 	 * @return
56 61
 	 */
57 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 64
 		String url = subscribeMessageUrl.replace("ACCESS_TOKEN",get_access_Token());
59 65
 		WxMssVo wxMssVo = new WxMssVo();
60 66
 		wxMssVo.setTouser(openId);
@@ -147,20 +153,4 @@ public class WebMsgTools {
147 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
 }