|
|
@@ -109,7 +109,10 @@ public class GroupsRelationNetflixServiceImpl implements GroupsRelationNetflixSe
|
|
|
if (!redisService.setNx(RedisService.key.NF_SET_TIME_LIMIT.getName() + relationId, relationId, RedisService.key.NF_SET_TIME_LIMIT.getTimeout())) {
|
|
|
throw BusinessRuntimeException.getInstance("一分钟内可执行一次");
|
|
|
}
|
|
|
- return setNetflixSeatNum(relation.getNum(), user.getNickname(), account.getAccount(), account.getPassword(), relation.getExpiryTime(), code);
|
|
|
+ JSONObject jsonObject = setNetflixSeatNum(relation.getNum(), user.getNickname(), account.getAccount(), account.getPassword(), relation.getExpiryTime(), code);
|
|
|
+ relation.setPinCode(code);
|
|
|
+ relationMapper.updateById(relation);
|
|
|
+ return jsonObject;
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
@@ -176,4 +179,66 @@ public class GroupsRelationNetflixServiceImpl implements GroupsRelationNetflixSe
|
|
|
} catch (Exception e) {
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public JSONObject nfKickOut(long userId, Long relationId) {
|
|
|
+ List<Long> userIdList = userBindRelationService.getRelationUserIdList(userId, null);
|
|
|
+ GroupsRelation relation = relationMapper.selectById(relationId);
|
|
|
+ if (!userIdList.contains(relation.getUserId())) {
|
|
|
+ throw BusinessRuntimeException.getInstance("您车票已失效");
|
|
|
+ }
|
|
|
+ GroupsTrips groupsTrips = groupsMapper.selectById(relation.getGroupsId());
|
|
|
+ Account account = accountMapper.selectById(groupsTrips.getAccountId());
|
|
|
+ if (account.getGoodsId() != 1) {
|
|
|
+ throw BusinessRuntimeException.getInstance("系统错误");
|
|
|
+ }
|
|
|
+ User user = userMapper.selectById(relation.getUserId());
|
|
|
+ if (!redisService.setNx(RedisService.key.NF_KICKOUT_TIME_LIMIT.getName() + relationId, relationId, RedisService.key.NF_KICKOUT_TIME_LIMIT.getTimeout())) {
|
|
|
+ throw BusinessRuntimeException.getInstance("一分钟内可执行一次");
|
|
|
+ }
|
|
|
+ return doNfKickOut(relation.getNum(), user.getNickname(), account.getAccount(), account.getPassword(),account.getCookie(), relation.getExpiryTime(), relation.getPinCode());
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 踢出奈飞设备
|
|
|
+ */
|
|
|
+ private JSONObject doNfKickOut(Integer seatNum, String seatName, String account, String password, String cookie, Date expiryTime, String code) {
|
|
|
+ JSONObject params = new JSONObject();
|
|
|
+ params.putOpt("username", account);
|
|
|
+ params.putOpt("password", password);
|
|
|
+ params.putOpt("seat_name", seatName);
|
|
|
+ params.putOpt("seat_num", seatNum);
|
|
|
+ params.putOpt("seat_time", expiryTime);
|
|
|
+ if (StrUtil.isNotBlank(code)) {
|
|
|
+ params.putOpt("pin_code", code);
|
|
|
+ }
|
|
|
+ if (StrUtil.isNotEmpty(cookie)) {
|
|
|
+ params.putOpt("cookie", cookie);
|
|
|
+ }
|
|
|
+ //设置座位
|
|
|
+ String url = Constant.ZHAOJU_MOVIES + "/netflix_seat";
|
|
|
+ log.info("设置账号:{} 奈飞用户:{}座位信息", account, seatName);
|
|
|
+ try {
|
|
|
+ HttpResponse<String> res =
|
|
|
+ J11HttpC.custom()
|
|
|
+ .ofPost()
|
|
|
+ .url(url)
|
|
|
+ .headers(J11HttpC.ReqType.raw_json)
|
|
|
+ .body(HttpRequest.BodyPublishers.ofString(Jsons.toJson(params), IoKit.Charsets.UTF_8.getCharset()))
|
|
|
+ .send(HttpResponse.BodyHandlers.ofString());
|
|
|
+ String body = res.body();
|
|
|
+ JSONObject jsonObject = Jsons.parseObject(body, JSONObject.class);
|
|
|
+ JSONObject data = Jsons.parseObject(jsonObject.get("data"), JSONObject.class);
|
|
|
+ Integer status = data.getInt("status");
|
|
|
+ if (status == 2) {
|
|
|
+ log.error("设置用户:{}奈飞座位号失败", seatName);
|
|
|
+ }
|
|
|
+ return data;
|
|
|
+ } catch (Exception e) {
|
|
|
+ log.error("设置用户:{}奈飞座位号错误,msg:{}", seatName, StringUtil.getErrorText(e));
|
|
|
+ }
|
|
|
+ JSONObject jsonObject = new JSONObject();
|
|
|
+ jsonObject.putOpt("status", 2);
|
|
|
+ return jsonObject;
|
|
|
+ }
|
|
|
}
|