|
|
@@ -1,29 +1,14 @@
|
|
|
package com.zhongshu.iot.server.core.service.payment;
|
|
|
|
|
|
-import cn.hutool.json.JSONUtil;
|
|
|
-import com.github.microservice.models.hxz.*;
|
|
|
-import com.github.microservice.types.payment.PaymentType;
|
|
|
import com.zhongshu.iot.server.core.dao.mqtt.DeviceInfoDao;
|
|
|
import com.zhongshu.iot.server.core.domain.ExecuteAnnotationService;
|
|
|
-import com.zhongshu.iot.server.core.domain.ExecuteAnnotationServiceMethod;
|
|
|
-import com.zhongshu.iot.server.core.domain.iot.device.DeviceInfo;
|
|
|
import com.zhongshu.iot.server.core.httpRequest.ApiRequestService;
|
|
|
-import com.github.microservice.http.APIResponseModel;
|
|
|
-import com.zhongshu.iot.server.core.httpRequest.conf.FullCardAPIConfig;
|
|
|
import com.zhongshu.iot.server.core.service.base.SuperService;
|
|
|
import com.zhongshu.iot.server.core.service.other.RequestInfoService;
|
|
|
-import com.github.microservice.net.ResultContent;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
-import org.apache.commons.lang3.ObjectUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
-import java.text.SimpleDateFormat;
|
|
|
-import java.time.DayOfWeek;
|
|
|
-import java.time.LocalDate;
|
|
|
-import java.util.Date;
|
|
|
-import java.util.Map;
|
|
|
-
|
|
|
/**
|
|
|
* @author TRX
|
|
|
* @date 2024/6/25
|
|
|
@@ -42,128 +27,128 @@ public class HxzService extends SuperService {
|
|
|
@Autowired
|
|
|
ApiRequestService apiRequestService;
|
|
|
|
|
|
- public ServerTimeResult serverTime(ServerTimeModel param) {
|
|
|
- String deviceId = param.getDeviceID().toString();
|
|
|
- ServerTimeResult result = new ServerTimeResult();
|
|
|
- DeviceInfo deviceInfo = deviceInfoDao.findTopByDeviceId(deviceId);
|
|
|
- if (ObjectUtils.isEmpty(deviceInfo)) {
|
|
|
- result.setFailed("设备未注册");
|
|
|
- requestInfoService.addHXZRequestInfo(param, result);
|
|
|
- return result;
|
|
|
- }
|
|
|
- // 业务验证
|
|
|
- APIResponseModel resultContent = apiRequestService.sendFullCardAPI(
|
|
|
- FullCardAPIConfig.ServerTime, param);
|
|
|
- if (resultContent.isSuccess()) {
|
|
|
- ServerTimeResult timeResult = resultContent.toBean(ServerTimeResult.class);
|
|
|
-
|
|
|
- if (timeResult.isSuccess()) {
|
|
|
- var nowTime = new Date(System.currentTimeMillis());
|
|
|
- LocalDate date = LocalDate.now();
|
|
|
- int week = Map.of(DayOfWeek.MONDAY, 1, DayOfWeek.TUESDAY, 2, DayOfWeek.WEDNESDAY, 3, DayOfWeek.THURSDAY, 4, DayOfWeek.FRIDAY, 5, DayOfWeek.SATURDAY, 6, DayOfWeek.SUNDAY, 0).get(date.getDayOfWeek());
|
|
|
- result.setSuccess();
|
|
|
- result.setTime(new SimpleDateFormat("yyyyMMddHHmmss").format(nowTime) + "" + week);
|
|
|
- result.setWLPage(0);
|
|
|
- result.setWLUptate(0);
|
|
|
- log.info("ServerTime : {} - {}", result);
|
|
|
- } else {
|
|
|
- result.setFailed(timeResult.getMsg());
|
|
|
- }
|
|
|
- } else {
|
|
|
- result.setFailed(resultContent.getMsg());
|
|
|
- }
|
|
|
- return result;
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * 刷卡扣费
|
|
|
- *
|
|
|
- * @param dataStr
|
|
|
- * @return
|
|
|
- */
|
|
|
- @ExecuteAnnotationServiceMethod(value = "ConsumTransactions", remark = "云版消费机 2.2 用户刷卡综合接口")
|
|
|
- public ResultContent<Object> consumTransactions(String dataStr) {
|
|
|
- ConsumTransactionsModel params = JSONUtil.toBean(dataStr, ConsumTransactionsModel.class);
|
|
|
- ConsumTransactionsResult ret = new ConsumTransactionsResult();
|
|
|
-
|
|
|
- ConsumTransactionsFullParam param = new ConsumTransactionsFullParam();
|
|
|
- param.setParam(params);
|
|
|
- APIResponseModel resultContent = apiRequestService.sendFullCardAPI(
|
|
|
- FullCardAPIConfig.ConsumTransactions, param);
|
|
|
- if (resultContent.isSuccess()) {
|
|
|
- // 请求成功
|
|
|
- ConsumTransactionsFullResult fullResult = resultContent.toBean(ConsumTransactionsFullResult.class);
|
|
|
- ret = fullResult.getModel();
|
|
|
- } else {
|
|
|
- // 失败
|
|
|
- ret.setStatus(0);
|
|
|
- ret.setMsg(resultContent.getMsg());
|
|
|
- }
|
|
|
- return ResultContent.buildSuccess(ret);
|
|
|
- }
|
|
|
-
|
|
|
- @ExecuteAnnotationServiceMethod(value = "orderQuery", remark = "云版消费机 2.3 用户刷卡消费结果查询接口")
|
|
|
- public ResultContent<Object> orderQuery(String dataStr) {
|
|
|
- OrderQueryModel param = JSONUtil.toBean(dataStr, OrderQueryModel.class);
|
|
|
-
|
|
|
- ConsumTransactionsResult ret = new ConsumTransactionsResult();
|
|
|
- APIResponseModel resultContent = apiRequestService.sendFullCardAPI(
|
|
|
- FullCardAPIConfig.orderQuery, param);
|
|
|
- if (resultContent.isSuccess()) {
|
|
|
- // 请求成功
|
|
|
- ConsumTransactionsFullResult fullResult = resultContent.toBean(ConsumTransactionsFullResult.class);
|
|
|
- ret = fullResult.getModel();
|
|
|
- } else {
|
|
|
- // 失败
|
|
|
- ret.setStatus(0);
|
|
|
- ret.setMsg(resultContent.getMsg());
|
|
|
- }
|
|
|
- return ResultContent.buildSuccess(ret);
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * 付款码(二维码)
|
|
|
- *
|
|
|
- * @param dataStr
|
|
|
- * @return
|
|
|
- */
|
|
|
- @ExecuteAnnotationServiceMethod(value = "QRCodeTransaction", remark = "云版消费机 2.7 付款码(二维码)支付接口")
|
|
|
- public ResultContent<Object> QRCodeTransaction(String dataStr) {
|
|
|
- QRCodeTransactionModel params = JSONUtil.toBean(dataStr, QRCodeTransactionModel.class);
|
|
|
- // 根据QR判断支付模式
|
|
|
- params.setPaymentType(PaymentType.WxQrCode);
|
|
|
-
|
|
|
- QRCodeTransactionResult ret = new QRCodeTransactionResult();
|
|
|
- APIResponseModel resultContent = apiRequestService.sendFullCardAPI(
|
|
|
- FullCardAPIConfig.QRCodeTransaction, params);
|
|
|
- if (resultContent.isSuccess()) {
|
|
|
- // 请求成功
|
|
|
- QRCodeTransactionFullResult fullResult = resultContent.toBean(QRCodeTransactionFullResult.class);
|
|
|
- ret = fullResult.getModel();
|
|
|
- } else {
|
|
|
- // 失败
|
|
|
- ret.setStatus(0);
|
|
|
- ret.setMsg(resultContent.getMsg());
|
|
|
- }
|
|
|
- return ResultContent.buildSuccess(ret);
|
|
|
- }
|
|
|
-
|
|
|
- @ExecuteAnnotationServiceMethod(value = "TransactionInquiry", remark = "云版消费机 2.8.二维码支付结果查询接口")
|
|
|
- public ResultContent<Object> TransactionInquiry(String dataStr) {
|
|
|
- TransactionInquiryModel params = JSONUtil.toBean(dataStr, TransactionInquiryModel.class);
|
|
|
- ConsumTransactionsResult ret = new ConsumTransactionsResult();
|
|
|
- APIResponseModel resultContent = apiRequestService.sendFullCardAPI(
|
|
|
- FullCardAPIConfig.TransactionInquiry, params);
|
|
|
- if (resultContent.isSuccess()) {
|
|
|
- // 请求成功
|
|
|
- ConsumTransactionsFullResult fullResult = resultContent.toBean(ConsumTransactionsFullResult.class);
|
|
|
- ret = fullResult.getModel();
|
|
|
- } else {
|
|
|
- // 失败
|
|
|
- ret.setStatus(0);
|
|
|
- ret.setMsg(resultContent.getMsg());
|
|
|
- }
|
|
|
- return ResultContent.buildSuccess(ret);
|
|
|
- }
|
|
|
+// public ServerTimeResult serverTime(ServerTimeModel param) {
|
|
|
+// String deviceId = param.getDeviceID().toString();
|
|
|
+// ServerTimeResult result = new ServerTimeResult();
|
|
|
+// DeviceInfo deviceInfo = deviceInfoDao.findTopByDeviceId(deviceId);
|
|
|
+// if (ObjectUtils.isEmpty(deviceInfo)) {
|
|
|
+// result.setFailed("设备未注册");
|
|
|
+// requestInfoService.addHXZRequestInfo(param, result);
|
|
|
+// return result;
|
|
|
+// }
|
|
|
+// // 业务验证
|
|
|
+// APIResponseModel resultContent = apiRequestService.sendFullCardAPI(
|
|
|
+// FullCardAPIConfig.ServerTime, param);
|
|
|
+// if (resultContent.isSuccess()) {
|
|
|
+// ServerTimeResult timeResult = resultContent.toBean(ServerTimeResult.class);
|
|
|
+//
|
|
|
+// if (timeResult.isSuccess()) {
|
|
|
+// var nowTime = new Date(System.currentTimeMillis());
|
|
|
+// LocalDate date = LocalDate.now();
|
|
|
+// int week = Map.of(DayOfWeek.MONDAY, 1, DayOfWeek.TUESDAY, 2, DayOfWeek.WEDNESDAY, 3, DayOfWeek.THURSDAY, 4, DayOfWeek.FRIDAY, 5, DayOfWeek.SATURDAY, 6, DayOfWeek.SUNDAY, 0).get(date.getDayOfWeek());
|
|
|
+// result.setSuccess();
|
|
|
+// result.setTime(new SimpleDateFormat("yyyyMMddHHmmss").format(nowTime) + "" + week);
|
|
|
+// result.setWLPage(0);
|
|
|
+// result.setWLUptate(0);
|
|
|
+// log.info("ServerTime : {} - {}", result);
|
|
|
+// } else {
|
|
|
+// result.setFailed(timeResult.getMsg());
|
|
|
+// }
|
|
|
+// } else {
|
|
|
+// result.setFailed(resultContent.getMsg());
|
|
|
+// }
|
|
|
+// return result;
|
|
|
+// }
|
|
|
+//
|
|
|
+// /**
|
|
|
+// * 刷卡扣费
|
|
|
+// *
|
|
|
+// * @param dataStr
|
|
|
+// * @return
|
|
|
+// */
|
|
|
+// @ExecuteAnnotationServiceMethod(value = "ConsumTransactions", remark = "云版消费机 2.2 用户刷卡综合接口")
|
|
|
+// public ResultContent<Object> consumTransactions(String dataStr) {
|
|
|
+// ConsumTransactionsModel params = JSONUtil.toBean(dataStr, ConsumTransactionsModel.class);
|
|
|
+// ConsumTransactionsResult ret = new ConsumTransactionsResult();
|
|
|
+//
|
|
|
+// ConsumTransactionsFullParam param = new ConsumTransactionsFullParam();
|
|
|
+// param.setParam(params);
|
|
|
+// APIResponseModel resultContent = apiRequestService.sendFullCardAPI(
|
|
|
+// FullCardAPIConfig.ConsumTransactions, param);
|
|
|
+// if (resultContent.isSuccess()) {
|
|
|
+// // 请求成功
|
|
|
+// ConsumTransactionsFullResult fullResult = resultContent.toBean(ConsumTransactionsFullResult.class);
|
|
|
+// ret = fullResult.getModel();
|
|
|
+// } else {
|
|
|
+// // 失败
|
|
|
+// ret.setStatus(0);
|
|
|
+// ret.setMsg(resultContent.getMsg());
|
|
|
+// }
|
|
|
+// return ResultContent.buildSuccess(ret);
|
|
|
+// }
|
|
|
+//
|
|
|
+// @ExecuteAnnotationServiceMethod(value = "orderQuery", remark = "云版消费机 2.3 用户刷卡消费结果查询接口")
|
|
|
+// public ResultContent<Object> orderQuery(String dataStr) {
|
|
|
+// OrderQueryModel param = JSONUtil.toBean(dataStr, OrderQueryModel.class);
|
|
|
+//
|
|
|
+// ConsumTransactionsResult ret = new ConsumTransactionsResult();
|
|
|
+// APIResponseModel resultContent = apiRequestService.sendFullCardAPI(
|
|
|
+// FullCardAPIConfig.orderQuery, param);
|
|
|
+// if (resultContent.isSuccess()) {
|
|
|
+// // 请求成功
|
|
|
+// ConsumTransactionsFullResult fullResult = resultContent.toBean(ConsumTransactionsFullResult.class);
|
|
|
+// ret = fullResult.getModel();
|
|
|
+// } else {
|
|
|
+// // 失败
|
|
|
+// ret.setStatus(0);
|
|
|
+// ret.setMsg(resultContent.getMsg());
|
|
|
+// }
|
|
|
+// return ResultContent.buildSuccess(ret);
|
|
|
+// }
|
|
|
+//
|
|
|
+// /**
|
|
|
+// * 付款码(二维码)
|
|
|
+// *
|
|
|
+// * @param dataStr
|
|
|
+// * @return
|
|
|
+// */
|
|
|
+// @ExecuteAnnotationServiceMethod(value = "QRCodeTransaction", remark = "云版消费机 2.7 付款码(二维码)支付接口")
|
|
|
+// public ResultContent<Object> QRCodeTransaction(String dataStr) {
|
|
|
+// QRCodeTransactionModel params = JSONUtil.toBean(dataStr, QRCodeTransactionModel.class);
|
|
|
+// // 根据QR判断支付模式
|
|
|
+// params.setPaymentType(PaymentType.WxQrCode);
|
|
|
+//
|
|
|
+// QRCodeTransactionResult ret = new QRCodeTransactionResult();
|
|
|
+// APIResponseModel resultContent = apiRequestService.sendFullCardAPI(
|
|
|
+// FullCardAPIConfig.QRCodeTransaction, params);
|
|
|
+// if (resultContent.isSuccess()) {
|
|
|
+// // 请求成功
|
|
|
+// QRCodeTransactionFullResult fullResult = resultContent.toBean(QRCodeTransactionFullResult.class);
|
|
|
+// ret = fullResult.getModel();
|
|
|
+// } else {
|
|
|
+// // 失败
|
|
|
+// ret.setStatus(0);
|
|
|
+// ret.setMsg(resultContent.getMsg());
|
|
|
+// }
|
|
|
+// return ResultContent.buildSuccess(ret);
|
|
|
+// }
|
|
|
+//
|
|
|
+// @ExecuteAnnotationServiceMethod(value = "TransactionInquiry", remark = "云版消费机 2.8.二维码支付结果查询接口")
|
|
|
+// public ResultContent<Object> TransactionInquiry(String dataStr) {
|
|
|
+// TransactionInquiryModel params = JSONUtil.toBean(dataStr, TransactionInquiryModel.class);
|
|
|
+// ConsumTransactionsResult ret = new ConsumTransactionsResult();
|
|
|
+// APIResponseModel resultContent = apiRequestService.sendFullCardAPI(
|
|
|
+// FullCardAPIConfig.TransactionInquiry, params);
|
|
|
+// if (resultContent.isSuccess()) {
|
|
|
+// // 请求成功
|
|
|
+// ConsumTransactionsFullResult fullResult = resultContent.toBean(ConsumTransactionsFullResult.class);
|
|
|
+// ret = fullResult.getModel();
|
|
|
+// } else {
|
|
|
+// // 失败
|
|
|
+// ret.setStatus(0);
|
|
|
+// ret.setMsg(resultContent.getMsg());
|
|
|
+// }
|
|
|
+// return ResultContent.buildSuccess(ret);
|
|
|
+// }
|
|
|
|
|
|
}
|