1.update
Showing
4 changed files
with
67 additions
and
48 deletions
| ... | @@ -319,12 +319,13 @@ public class UserOperationServiceImpl implements UserOperationService { | ... | @@ -319,12 +319,13 @@ public class UserOperationServiceImpl implements UserOperationService { |
| 319 | String appid = userWeixinDTO.getAppid(); | 319 | String appid = userWeixinDTO.getAppid(); |
| 320 | MemberDTO memberDTO = memberAndWeixinUserDTO.getMemberDTO(); | 320 | MemberDTO memberDTO = memberAndWeixinUserDTO.getMemberDTO(); |
| 321 | 321 | ||
| 322 | UserWeixinDTO _userWeixinDTO = this.userWeixinService.findFirstByAppIdAndOpenId(appid, openid); | 322 | UserWeixinDTO _userWeixinDTO = this.userWeixinService.findFirstByUnionIdAndAppIdAndOpenId(unionid, appid, openid); |
| 323 | // 有账号 | 323 | // 有账号 |
| 324 | if (Objects.nonNull(_userWeixinDTO.getId())) { | 324 | if (Objects.nonNull(_userWeixinDTO.getId())) { |
| 325 | 325 | ||
| 326 | UserWeixinDTO _userWeixinDTO0 = this.userWeixinService.findFirstByAppIdAndOpenId(appid, openid); | ||
| 326 | // 会员存在 | 327 | // 会员存在 |
| 327 | if(Objects.nonNull(_userWeixinDTO.getMemberId())) { | 328 | if(Objects.nonNull(_userWeixinDTO0.getMemberId())) { |
| 328 | // 账号存在,修改账号和会员 | 329 | // 账号存在,修改账号和会员 |
| 329 | this.updateWeixin(_userWeixinDTO, userWeixinDTO); | 330 | this.updateWeixin(_userWeixinDTO, userWeixinDTO); |
| 330 | MemberDTO _memberDTO = this.memberService.findById(_userWeixinDTO.getMemberId()); | 331 | MemberDTO _memberDTO = this.memberService.findById(_userWeixinDTO.getMemberId()); | ... | ... |
| ... | @@ -34,6 +34,7 @@ import org.springframework.stereotype.Component; | ... | @@ -34,6 +34,7 @@ import org.springframework.stereotype.Component; |
| 34 | import java.io.IOException; | 34 | import java.io.IOException; |
| 35 | import java.text.ParseException; | 35 | import java.text.ParseException; |
| 36 | import java.time.LocalDate; | 36 | import java.time.LocalDate; |
| 37 | import java.time.LocalDateTime; | ||
| 37 | import java.util.*; | 38 | import java.util.*; |
| 38 | 39 | ||
| 39 | @Component | 40 | @Component |
| ... | @@ -108,7 +109,7 @@ public class UcEventBusIptv2ManagementUcEngine { | ... | @@ -108,7 +109,7 @@ public class UcEventBusIptv2ManagementUcEngine { |
| 108 | */ | 109 | */ |
| 109 | private void parseContent(String content) throws ParseException { | 110 | private void parseContent(String content) throws ParseException { |
| 110 | 111 | ||
| 111 | CommonMsg commonMsg = JSONUtil.parseMsg2Object(content, CommonMsg.class); | 112 | PlayContent commonMsg = JSONUtil.parseMsg2Object(content, PlayContent.class); |
| 112 | 113 | ||
| 113 | String evt = commonMsg.getEvt(); | 114 | String evt = commonMsg.getEvt(); |
| 114 | switch (evt.toUpperCase()) { | 115 | switch (evt.toUpperCase()) { |
| ... | @@ -116,7 +117,7 @@ public class UcEventBusIptv2ManagementUcEngine { | ... | @@ -116,7 +117,7 @@ public class UcEventBusIptv2ManagementUcEngine { |
| 116 | case "PLAY": | 117 | case "PLAY": |
| 117 | PlayContent playContent = JSONUtil.parseMsg2Object(content, PlayContent.class); | 118 | PlayContent playContent = JSONUtil.parseMsg2Object(content, PlayContent.class); |
| 118 | 119 | ||
| 119 | PlayContent.MsgData msgData = playContent.getMsgData(); | 120 | PlayContent.MsgData msgData = playContent.getMsg(); |
| 120 | if (Objects.nonNull(msgData)) { | 121 | if (Objects.nonNull(msgData)) { |
| 121 | String time = playContent.getTime(); | 122 | String time = playContent.getTime(); |
| 122 | String formatDate = DateUtil.formatDate(time); | 123 | String formatDate = DateUtil.formatDate(time); |
| ... | @@ -127,10 +128,13 @@ public class UcEventBusIptv2ManagementUcEngine { | ... | @@ -127,10 +128,13 @@ public class UcEventBusIptv2ManagementUcEngine { |
| 127 | Long mediaId = msgData.getMediaId(); | 128 | Long mediaId = msgData.getMediaId(); |
| 128 | String mediaName = msgData.getMediaName(); | 129 | String mediaName = msgData.getMediaName(); |
| 129 | Integer playDuration = msgData.getPlayDuration(); | 130 | Integer playDuration = msgData.getPlayDuration(); |
| 131 | if (Objects.isNull(playDuration) || playDuration == 0) { | ||
| 132 | return; | ||
| 133 | } | ||
| 130 | log.info("playDuration ==>> {}", playDuration); | 134 | log.info("playDuration ==>> {}", playDuration); |
| 131 | 135 | ||
| 132 | DataSyncMsg dataSyncMsg = new DataSyncMsg(); | 136 | DataSyncMsg dataSyncMsg = new DataSyncMsg(); |
| 133 | dataSyncMsg.setEventType(evt); | 137 | dataSyncMsg.setEvt(evt); |
| 134 | DataSyncMsg.MsgData msg = new DataSyncMsg.MsgData(); | 138 | DataSyncMsg.MsgData msg = new DataSyncMsg.MsgData(); |
| 135 | 139 | ||
| 136 | Integer playDurationValueTotal = 0; | 140 | Integer playDurationValueTotal = 0; |
| ... | @@ -164,18 +168,13 @@ public class UcEventBusIptv2ManagementUcEngine { | ... | @@ -164,18 +168,13 @@ public class UcEventBusIptv2ManagementUcEngine { |
| 164 | Integer totalKey = this.getRedisTotalKey(hmget); | 168 | Integer totalKey = this.getRedisTotalKey(hmget); |
| 165 | Integer maxSize = totalKey + 1; | 169 | Integer maxSize = totalKey + 1; |
| 166 | 170 | ||
| 167 | // DataSyncMsg dataSyncMsg1 = | 171 | this.checkTask(playDurationValueTotal, time, deviceType, |
| 168 | this.checkTask(playDurationValueTotal, time, deviceType, | 172 | mediaCode, mediaId, mediaName, dataSyncMsg, msg, userTvDTO); |
| 169 | mediaCode, mediaId, mediaName, dataSyncMsg, msg, userTvDTO); | ||
| 170 | |||
| 171 | // if (Objects.nonNull(dataSyncMsg1)) { | ||
| 172 | |||
| 173 | Map<String, Object> map = new HashMap<>(); | ||
| 174 | map.put(String.valueOf(maxSize), playDuration); | ||
| 175 | map.put("total", playDurationValueTotal); | ||
| 176 | this.redisUtils.hmset(key, map); | ||
| 177 | 173 | ||
| 178 | // } | 174 | Map<String, Object> map = new HashMap<>(); |
| 175 | map.put(String.valueOf(maxSize), playDuration); | ||
| 176 | map.put("total", playDurationValueTotal); | ||
| 177 | this.redisUtils.hmset(key, map); | ||
| 179 | } | 178 | } |
| 180 | 179 | ||
| 181 | } | 180 | } |
| ... | @@ -235,7 +234,10 @@ public class UcEventBusIptv2ManagementUcEngine { | ... | @@ -235,7 +234,10 @@ public class UcEventBusIptv2ManagementUcEngine { |
| 235 | if (playDurationValueTotal >= integer) { | 234 | if (playDurationValueTotal >= integer) { |
| 236 | dataSyncMsg1 = getDataSyncMsg(time, deviceType, mediaCode, mediaId, mediaName, integer, dataSyncMsg, | 235 | dataSyncMsg1 = getDataSyncMsg(time, deviceType, mediaCode, mediaId, mediaName, integer, dataSyncMsg, |
| 237 | msgData, userTvDTO); | 236 | msgData, userTvDTO); |
| 238 | 237 | dataSyncMsg1.setEvt("PLAY"); | |
| 238 | dataSyncMsg1.setEvent(8); | ||
| 239 | dataSyncMsg1.setTime(LocalDateTime.now()); | ||
| 240 | dataSyncMsg1.setDeviceType(1); | ||
| 239 | this.taskDeal(dataSyncMsg1); | 241 | this.taskDeal(dataSyncMsg1); |
| 240 | } | 242 | } |
| 241 | 243 | ||
| ... | @@ -291,8 +293,8 @@ public class UcEventBusIptv2ManagementUcEngine { | ... | @@ -291,8 +293,8 @@ public class UcEventBusIptv2ManagementUcEngine { |
| 291 | 293 | ||
| 292 | msgData1.setMemberCode(memberCode); | 294 | msgData1.setMemberCode(memberCode); |
| 293 | 295 | ||
| 294 | msgData1.setEvent(8); | 296 | // msgData1.setEvent(8); |
| 295 | msgData1.setDeviceType(deviceType); | 297 | // msgData1.setDeviceType(deviceType); |
| 296 | msgData1.setMediaId(mediaId); | 298 | msgData1.setMediaId(mediaId); |
| 297 | 299 | ||
| 298 | JSONObject param = new JSONObject(); | 300 | JSONObject param = new JSONObject(); |
| ... | @@ -322,9 +324,10 @@ public class UcEventBusIptv2ManagementUcEngine { | ... | @@ -322,9 +324,10 @@ public class UcEventBusIptv2ManagementUcEngine { |
| 322 | @Data | 324 | @Data |
| 323 | static class PlayContent { | 325 | static class PlayContent { |
| 324 | private String evt; | 326 | private String evt; |
| 327 | private Integer event; | ||
| 325 | private Integer deviceType; | 328 | private Integer deviceType; |
| 326 | private String time; | 329 | private String time; |
| 327 | private MsgData msgData; | 330 | private MsgData msg; |
| 328 | 331 | ||
| 329 | @Data | 332 | @Data |
| 330 | static class MsgData { | 333 | static class MsgData { |
| ... | @@ -335,11 +338,4 @@ public class UcEventBusIptv2ManagementUcEngine { | ... | @@ -335,11 +338,4 @@ public class UcEventBusIptv2ManagementUcEngine { |
| 335 | private String mediaName; | 338 | private String mediaName; |
| 336 | } | 339 | } |
| 337 | } | 340 | } |
| 338 | |||
| 339 | @Data | ||
| 340 | static class CommonMsg { | ||
| 341 | private String evt; | ||
| 342 | private Integer deviceType; | ||
| 343 | private String time; | ||
| 344 | } | ||
| 345 | } | 341 | } | ... | ... |
| ... | @@ -3,6 +3,10 @@ package com.topdraw.mq.consumer; | ... | @@ -3,6 +3,10 @@ package com.topdraw.mq.consumer; |
| 3 | import com.alibaba.fastjson.JSON; | 3 | import com.alibaba.fastjson.JSON; |
| 4 | import com.alibaba.fastjson.JSONObject; | 4 | import com.alibaba.fastjson.JSONObject; |
| 5 | import com.rabbitmq.client.Channel; | 5 | import com.rabbitmq.client.Channel; |
| 6 | import com.topdraw.business.module.member.service.MemberService; | ||
| 7 | import com.topdraw.business.module.member.service.dto.MemberDTO; | ||
| 8 | import com.topdraw.business.module.user.iptv.service.UserTvService; | ||
| 9 | import com.topdraw.business.module.user.iptv.service.dto.UserTvDTO; | ||
| 6 | import com.topdraw.mq.domain.DataSyncMsg; | 10 | import com.topdraw.mq.domain.DataSyncMsg; |
| 7 | import com.topdraw.resttemplate.RestTemplateClient; | 11 | import com.topdraw.resttemplate.RestTemplateClient; |
| 8 | import com.topdraw.util.FileUtil; | 12 | import com.topdraw.util.FileUtil; |
| ... | @@ -17,6 +21,7 @@ import org.springframework.beans.factory.annotation.Value; | ... | @@ -17,6 +21,7 @@ import org.springframework.beans.factory.annotation.Value; |
| 17 | import org.springframework.stereotype.Component; | 21 | import org.springframework.stereotype.Component; |
| 18 | import org.springframework.util.Assert; | 22 | import org.springframework.util.Assert; |
| 19 | 23 | ||
| 24 | import javax.validation.constraints.NotNull; | ||
| 20 | import java.io.IOException; | 25 | import java.io.IOException; |
| 21 | import java.time.LocalDate; | 26 | import java.time.LocalDate; |
| 22 | import java.util.Map; | 27 | import java.util.Map; |
| ... | @@ -32,6 +37,11 @@ public class UcGatewayIptv2IptvConsumer { | ... | @@ -32,6 +37,11 @@ public class UcGatewayIptv2IptvConsumer { |
| 32 | @Autowired | 37 | @Autowired |
| 33 | AutoRoute autoUser; | 38 | AutoRoute autoUser; |
| 34 | 39 | ||
| 40 | @Autowired | ||
| 41 | private MemberService memberService; | ||
| 42 | @Autowired | ||
| 43 | private UserTvService userTvService; | ||
| 44 | |||
| 35 | @Value("#{rabbitMqErrorLogConfig.getUcgError()}") | 45 | @Value("#{rabbitMqErrorLogConfig.getUcgError()}") |
| 36 | private Map<String, String> error; | 46 | private Map<String, String> error; |
| 37 | 47 | ||
| ... | @@ -86,6 +96,27 @@ public class UcGatewayIptv2IptvConsumer { | ... | @@ -86,6 +96,27 @@ public class UcGatewayIptv2IptvConsumer { |
| 86 | DataSyncMsg dataSyncMsg = JSONUtil.parseMsg2Object(content,DataSyncMsg.class); | 96 | DataSyncMsg dataSyncMsg = JSONUtil.parseMsg2Object(content,DataSyncMsg.class); |
| 87 | Assert.notNull(dataSyncMsg,"ERROR -->> operationConsumer -->> parseContent -->> 【dataSyncMsg】 not be null !!"); | 97 | Assert.notNull(dataSyncMsg,"ERROR -->> operationConsumer -->> parseContent -->> 【dataSyncMsg】 not be null !!"); |
| 88 | DataSyncMsg.MsgData msgData = dataSyncMsg.getMsg(); | 98 | DataSyncMsg.MsgData msgData = dataSyncMsg.getMsg(); |
| 99 | Long memberId = msgData.getMemberId(); | ||
| 100 | String memberCode = msgData.getMemberCode(); | ||
| 101 | if (Objects.nonNull(memberId) && StringUtils.isBlank(memberCode)) { | ||
| 102 | MemberDTO memberDTO = this.memberService.findById(memberId); | ||
| 103 | String code = memberDTO.getCode(); | ||
| 104 | msgData.setMemberCode(code); | ||
| 105 | } | ||
| 106 | |||
| 107 | String platformAccount = msgData.getPlatformAccount(); | ||
| 108 | if (StringUtils.isNotBlank(platformAccount)) { | ||
| 109 | UserTvDTO userTvDTO = userTvService.findByPlatformAccount(platformAccount); | ||
| 110 | if (Objects.nonNull(userTvDTO)) { | ||
| 111 | String priorityMemberCode = userTvDTO.getPriorityMemberCode(); | ||
| 112 | if (StringUtils.isNotBlank(priorityMemberCode)) { | ||
| 113 | msgData.setMemberCode(priorityMemberCode); | ||
| 114 | } else { | ||
| 115 | MemberDTO memberDTO = this.memberService.findById(userTvDTO.getMemberId()); | ||
| 116 | msgData.setMemberCode(memberDTO.getCode()); | ||
| 117 | } | ||
| 118 | } | ||
| 119 | } | ||
| 89 | Assert.notNull(msgData,"ERROR -->> operationConsumer -->> parseContent -->> 【msgData】 not be null !!"); | 120 | Assert.notNull(msgData,"ERROR -->> operationConsumer -->> parseContent -->> 【msgData】 not be null !!"); |
| 90 | return dataSyncMsg; | 121 | return dataSyncMsg; |
| 91 | } | 122 | } | ... | ... |
| ... | @@ -6,6 +6,7 @@ import lombok.NoArgsConstructor; | ... | @@ -6,6 +6,7 @@ import lombok.NoArgsConstructor; |
| 6 | 6 | ||
| 7 | import javax.validation.constraints.NotNull; | 7 | import javax.validation.constraints.NotNull; |
| 8 | import java.io.Serializable; | 8 | import java.io.Serializable; |
| 9 | import java.time.LocalDateTime; | ||
| 9 | 10 | ||
| 10 | /** | 11 | /** |
| 11 | * | 12 | * |
| ... | @@ -15,21 +16,18 @@ import java.io.Serializable; | ... | @@ -15,21 +16,18 @@ import java.io.Serializable; |
| 15 | @NoArgsConstructor | 16 | @NoArgsConstructor |
| 16 | public class DataSyncMsg implements Serializable { | 17 | public class DataSyncMsg implements Serializable { |
| 17 | 18 | ||
| 18 | // 实体类型(表示需要修改的数据模型) | ||
| 19 | // @NotNull | ||
| 20 | // private EntityType entityType; | ||
| 21 | |||
| 22 | // 事件类型(用户的实际操作) | ||
| 23 | @NotNull | 19 | @NotNull |
| 24 | private String eventType; | 20 | private String evt; |
| 25 | 21 | // 具体事件 行为事件类型 1:登录;2:观影;3:参与活动;4:订购;10:跨屏绑定;11:积分转移;30:积分兑换商品;98:系统操作;99:其他 | |
| 22 | private Integer event; | ||
| 23 | //设备类型 1:大屏;2:小屏(微信)3.小屏(xx) | ||
| 24 | @NotNull | ||
| 25 | private Integer deviceType; | ||
| 26 | // 发送时间 | ||
| 27 | private LocalDateTime time; | ||
| 26 | // 消息体 | 28 | // 消息体 |
| 27 | private MsgData msg; | 29 | private MsgData msg; |
| 28 | 30 | ||
| 29 | // 其他属性 | ||
| 30 | private String extraData; | ||
| 31 | |||
| 32 | |||
| 33 | /** | 31 | /** |
| 34 | * 消息体 | 32 | * 消息体 |
| 35 | */ | 33 | */ |
| ... | @@ -37,23 +35,16 @@ public class DataSyncMsg implements Serializable { | ... | @@ -37,23 +35,16 @@ public class DataSyncMsg implements Serializable { |
| 37 | @AllArgsConstructor | 35 | @AllArgsConstructor |
| 38 | @NoArgsConstructor | 36 | @NoArgsConstructor |
| 39 | public static class MsgData { | 37 | public static class MsgData { |
| 40 | private String remarks; //备注 | ||
| 41 | @NotNull | ||
| 42 | private Integer event; // 具体事件 行为事件类型 1:登录;2:观影;3:参与活动;4:订购;10:跨屏绑定;11:积分转移;30:积分兑换商品;98:系统操作;99:其他 | ||
| 43 | @NotNull | ||
| 44 | private Long memberId; // 会员id | 38 | private Long memberId; // 会员id |
| 45 | @NotNull | ||
| 46 | private Integer deviceType; //设备类型 1:大屏;2:小屏(微信)3.小屏(xx) | ||
| 47 | @NotNull | ||
| 48 | private String appCode; //用户对应的应用code | ||
| 49 | private String memberCode; | 39 | private String memberCode; |
| 50 | private Long accountId; // 账号id | ||
| 51 | private Long orderId; | 40 | private Long orderId; |
| 52 | private Long activityId; | 41 | private Long activityId; |
| 53 | private Long mediaId; | 42 | private Long mediaId; |
| 54 | private Long itemId; | 43 | private Long itemId; |
| 55 | private String param; | ||
| 56 | private String description; | 44 | private String description; |
| 45 | |||
| 46 | private String param; | ||
| 47 | private String platformAccount; | ||
| 57 | } | 48 | } |
| 58 | 49 | ||
| 59 | } | 50 | } | ... | ... |
-
Please register or sign in to post a comment