|
@@ -0,0 +1,119 @@
|
|
|
|
|
+package com.cyksj.service.relation.impl;
|
|
|
|
|
+
|
|
|
|
|
+import cn.hutool.json.JSONObject;
|
|
|
|
|
+import com.cyksj.common.constant.Constant;
|
|
|
|
|
+import com.cyksj.common.exception.BusinessRuntimeException;
|
|
|
|
|
+import com.cyksj.common.util.IoKit;
|
|
|
|
|
+import com.cyksj.common.util.J11HttpC;
|
|
|
|
|
+import com.cyksj.common.util.Jsons;
|
|
|
|
|
+import com.cyksj.common.util.StringUtil;
|
|
|
|
|
+import com.cyksj.mapper.AccountMapper;
|
|
|
|
|
+import com.cyksj.mapper.GroupsMapper;
|
|
|
|
|
+import com.cyksj.mapper.GroupsRelationMapper;
|
|
|
|
|
+import com.cyksj.mapper.UserMapper;
|
|
|
|
|
+import com.cyksj.model.entity.Account;
|
|
|
|
|
+import com.cyksj.model.entity.GroupsRelation;
|
|
|
|
|
+import com.cyksj.model.entity.GroupsTrips;
|
|
|
|
|
+import com.cyksj.model.entity.User;
|
|
|
|
|
+import com.cyksj.service.relation.GroupsRelationNetflixService;
|
|
|
|
|
+import com.cyksj.service.user.UserBindRelationService;
|
|
|
|
|
+import lombok.RequiredArgsConstructor;
|
|
|
|
|
+import lombok.extern.slf4j.Slf4j;
|
|
|
|
|
+import org.springframework.stereotype.Service;
|
|
|
|
|
+
|
|
|
|
|
+import java.net.http.HttpRequest;
|
|
|
|
|
+import java.net.http.HttpResponse;
|
|
|
|
|
+import java.util.Date;
|
|
|
|
|
+import java.util.List;
|
|
|
|
|
+
|
|
|
|
|
+/**
|
|
|
|
|
+ * 项目名: yhlxj2
|
|
|
|
|
+ * 文件名: GroupsRelationNetflixServiceImpl
|
|
|
|
|
+ * 创建者: JavaZou
|
|
|
|
|
+ * 创建时间:2024/6/17 15:45
|
|
|
|
|
+ */
|
|
|
|
|
+@Service
|
|
|
|
|
+@RequiredArgsConstructor
|
|
|
|
|
+@Slf4j
|
|
|
|
|
+public class GroupsRelationNetflixServiceImpl implements GroupsRelationNetflixService {
|
|
|
|
|
+ private final UserMapper userMapper;
|
|
|
|
|
+
|
|
|
|
|
+ private final GroupsRelationMapper relationMapper;
|
|
|
|
|
+
|
|
|
|
|
+ private final GroupsMapper groupsMapper;
|
|
|
|
|
+
|
|
|
|
|
+ private final AccountMapper accountMapper;
|
|
|
|
|
+
|
|
|
|
|
+ private final UserBindRelationService userBindRelationService;
|
|
|
|
|
+
|
|
|
|
|
+ @Override
|
|
|
|
|
+ public JSONObject setNetflixSeatNum(Integer seatNum, String seatName, String account, String password, Date expiryTime) {
|
|
|
|
|
+ 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);
|
|
|
|
|
+ //设置座位
|
|
|
|
|
+ String url = Constant.ZHAOJU_MOVIES + "/netflix_set/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;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ @Override
|
|
|
|
|
+ public JSONObject setNetflixPin(Long relationId, long userId) {
|
|
|
|
|
+ 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());
|
|
|
|
|
+ return setNetflixSeatNum(relation.getNum(), user.getNickname(), account.getAccount(), account.getPassword(), relation.getExpiryTime());
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ @Override
|
|
|
|
|
+ public Integer getPinStatus(String taskId) throws Exception {
|
|
|
|
|
+ JSONObject params = new JSONObject();
|
|
|
|
|
+ params.putOpt("transId", taskId);
|
|
|
|
|
+ //查询任务状态
|
|
|
|
|
+ String url = Constant.ZHAOJU_MOVIES + "/netflix_set/netflix_task_status";
|
|
|
|
|
+ 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");
|
|
|
|
|
+ return status;
|
|
|
|
|
+ }
|
|
|
|
|
+}
|