TRX 1 год назад
Родитель
Сommit
299317ca95

+ 12 - 0
FullCardClient/src/main/java/com/zhongshu/card/client/model/school/DeviceInfoModel.java

@@ -47,6 +47,18 @@ public class DeviceInfoModel extends SuperModel {
     @Schema(description = "是否在线")
     private OnLineState onLineState = OnLineState.OnLine;
 
+    private String onLineStateStr;
+
+    public String getOnLineStateStr() {
+        if (onLineState != null) {
+            return onLineState.getRemark();
+        }
+        return "";
+    }
+
+    @Schema(description = "最上线时间")
+    private Long lastOnlineTime;
+
     @Schema(description = "设备IP地址")
     private String ip;
 }

+ 13 - 0
FullCardServer/src/main/java/com/zhongshu/card/server/core/controller/iotCenter/DeviceSyncController.java

@@ -2,6 +2,7 @@ package com.zhongshu.card.server.core.controller.iotCenter;
 
 import com.github.microservice.models.device.DeviceSyncListParam;
 import com.github.microservice.models.device.GateWaySyncParam;
+import com.github.microservice.models.hxz.DevicePingInfoParam;
 import com.zhongshu.card.client.model.mqtt.SendMessageModel;
 import com.zhongshu.card.client.ret.ResultContent;
 import com.zhongshu.card.server.core.service.mqtt.MqttServiceImpl;
@@ -36,6 +37,18 @@ public class DeviceSyncController {
         return deviceSyncFromIotService.syncFromIotDevices(param);
     }
 
+    @Operation(summary = "物联网同步设备最近上线时间", hidden = true)
+    @RequestMapping(value = "lastDeviceOnLineTime", method = {RequestMethod.POST})
+    public ResultContent lastOnLineTime(@RequestBody DevicePingInfoParam param) {
+        return deviceSyncFromIotService.syncDeviceOnLineState(param);
+    }
+
+    @Operation(summary = "物联网同步设备在线状态", hidden = true)
+    @RequestMapping(value = "syncDeviceOnLineState", method = {RequestMethod.POST})
+    public ResultContent syncDeviceOnLineState(@RequestBody DevicePingInfoParam param) {
+        return deviceSyncFromIotService.syncDeviceOnLineState(param);
+    }
+
     @Operation(summary = "物联网同步网关接口", hidden = true)
     @RequestMapping(value = "syncGateWays", method = {RequestMethod.POST})
     public ResultContent syncGateWays(@RequestBody GateWaySyncParam param) {

+ 3 - 0
FullCardServer/src/main/java/com/zhongshu/card/server/core/domain/org/DeviceInfo.java

@@ -42,6 +42,9 @@ public class DeviceInfo extends SuperMain {
     @Schema(description = "是否在线")
     private OnLineState onLineState = OnLineState.OnLine;
 
+    @Schema(description = "最上线时间")
+    private Long lastOnlineTime;
+
     @Schema(description = "设备IP地址")
     private String ip;
 }

+ 1 - 1
FullCardServer/src/main/java/com/zhongshu/card/server/core/domain/payment/Wallet.java

@@ -33,7 +33,7 @@ public class Wallet extends SuperMain {
     @DBRef(lazy = true)
     private UserAccount userAccount;
 
-    @Schema(description = "可用金额")
+    @Schema(description = "可用金额,单位:分")
     private BigDecimal amount = BigDecimal.ZERO;
 
     @Schema(description = "钱包状态:是否可用")

+ 6 - 3
FullCardServer/src/main/java/com/zhongshu/card/server/core/httpRequest/ApiRequestService.java

@@ -9,6 +9,7 @@ import com.github.microservice.core.util.net.apache.HttpModel;
 import com.github.microservice.core.util.net.apache.MethodType;
 import com.github.microservice.core.util.net.apache.ResponseModel;
 import com.github.microservice.models.hxz.TransactionInquiryResult;
+import com.github.microservice.models.hxz.WxPayResult;
 import com.zhongshu.card.server.core.httpRequest.apiConf.APIResponseModel;
 import com.zhongshu.card.server.core.httpRequest.apiConf.ApiConfParam;
 import com.zhongshu.card.server.core.httpRequest.conf.IotCenterAPIConfig;
@@ -105,15 +106,17 @@ public class ApiRequestService extends SuperService {
             ResponseModel request = HttpClientUtil.request(HttpModel.builder()
                     .url(apiConfParam.getApiName()).method(apiConfParam.getMethodType())
                     .charset("utf-8").body(jsonObject).build());
-            TransactionInquiryResult result = null;
+            WxPayResult result = null;
             if (request.getCode() == 200) {
                 Object object = request.getBody();
                 log.info("obj: {}", object);
                 responseModel.setIsSuccess();
-                result = BeanUtil.copyProperties(request.getBody(), TransactionInquiryResult.class);
+                result = BeanUtil.copyProperties(request.getBody(), WxPayResult.class);
             } else {
-                result = BeanUtil.copyProperties(request.getBody(), TransactionInquiryResult.class);
+                result = BeanUtil.copyProperties(request.getBody(), WxPayResult.class);
             }
+
+            // 判断是否成功
             if (result.isSuccess()) {
                 responseModel.setIsSuccess();
             } else {

+ 29 - 24
FullCardServer/src/main/java/com/zhongshu/card/server/core/service/payment/ExpenseFlowServiceImpl.java

@@ -115,7 +115,6 @@ public class ExpenseFlowServiceImpl extends SuperService implements ExpenseFlowS
 
         // 验证参数、填充数据
         commonVerifyExpenseFlow(expenseFlow);
-//        expenseFlowDao.save(expenseFlow);
         return ResultContent.buildSuccess(expenseFlow);
     }
 
@@ -191,11 +190,19 @@ public class ExpenseFlowServiceImpl extends SuperService implements ExpenseFlowS
             Boolean isPaySuccess = expenseFlow.getIsPaySuccess();
             if (isPaySuccess != null && isPaySuccess) {
                 result.setSuccess();
-                result.setText("支付成功");
+                // 设置了显示异常,去掉
+//                result.setText(expenseFlow.getPayRemark());
                 result.setCardNo(expenseFlow.getCardNo());
                 result.setName(expenseFlow.getUserName());
                 // 金额 转为 元 单位
                 result.setAmount(CommonUtil.turnMoney2Show(expenseFlow.getPayAmount()));
+                if (expenseFlow.getPaymentType() == PaymentType.UserWallet) {
+                    // 钱包查询余额
+                    Wallet wallet = walletDao.findByUserId(expenseFlow.getUserId());
+                    if (ObjectUtils.isNotEmpty(wallet)) {
+                        result.setMoney(CommonUtil.turnMoney2Show(wallet.getAmount()));
+                    }
+                }
             } else {
                 result.setFailed(expenseFlow.getPayRemark());
             }
@@ -248,8 +255,6 @@ public class ExpenseFlowServiceImpl extends SuperService implements ExpenseFlowS
         expenseFlow.setPaymentDeviceType(PaymentDeviceType.HxzConsumTransactions);
 
         commonVerifyExpenseFlow(expenseFlow);
-
-//        expenseFlowDao.save(expenseFlow);
         return ResultContent.buildSuccess(expenseFlow);
     }
 
@@ -260,6 +265,15 @@ public class ExpenseFlowServiceImpl extends SuperService implements ExpenseFlowS
      */
     private void commonVerifyExpenseFlow(ExpenseFlow entity) {
         String deviceId = entity.getDeviceId();
+
+        // 验证设备
+        DeviceInfo deviceInfo = deviceInfoDao.findTopByDeviceId(deviceId);
+        if (ObjectUtils.isEmpty(deviceInfo)) {
+            entity.setVerifyParamIsSuccess(Boolean.FALSE);
+            entity.setVerifyParamMsg("业务设备未注册");
+            return;
+        }
+
         // 查询设备绑定德 商户 学校
         if (StringUtils.isNotEmpty(deviceId)) {
             DeviceBind deviceBind = deviceBindDao.findTopByDeviceId(deviceId);
@@ -269,13 +283,13 @@ public class ExpenseFlowServiceImpl extends SuperService implements ExpenseFlowS
             }
         }
 
-        if (StringUtils.isNotEmpty(entity.getSchoolOid())) {
+        if (StringUtils.isEmpty(entity.getSchoolOid())) {
             entity.setVerifyParamIsSuccess(Boolean.FALSE);
             entity.setVerifyParamMsg("设备未绑定学校");
             return;
         }
 
-        if (StringUtils.isNotEmpty(entity.getShopOid())) {
+        if (StringUtils.isEmpty(entity.getShopOid())) {
             entity.setVerifyParamIsSuccess(Boolean.FALSE);
             entity.setVerifyParamMsg("设备未绑定商户");
             return;
@@ -284,12 +298,7 @@ public class ExpenseFlowServiceImpl extends SuperService implements ExpenseFlowS
         PaymentType paymentType = entity.getPaymentType();
         // 刷卡支付
         if (paymentType == PaymentType.UserWallet) {
-
             CardInfo cardInfo = cardInfoDao.findByCode(entity.getCardNo());
-            if (ObjectUtils.isNotEmpty(cardInfo)) {
-                entity.setCardInfo(cardInfo);
-                entity.setUserId(cardInfo.getUserId());
-            }
 
             // 验证卡片
             if (ObjectUtils.isEmpty(cardInfo)) {
@@ -297,6 +306,9 @@ public class ExpenseFlowServiceImpl extends SuperService implements ExpenseFlowS
                 entity.setVerifyParamMsg("卡片未注册");
                 return;
             }
+            entity.setCardInfo(cardInfo);
+            entity.setUserId(cardInfo.getUserId());
+
             // 判断卡片是否可用
             if (cardInfo.getCardState() != CardState.Enable) {
                 entity.setVerifyParamIsSuccess(Boolean.FALSE);
@@ -312,7 +324,8 @@ public class ExpenseFlowServiceImpl extends SuperService implements ExpenseFlowS
             }
         }
 
-        if (StringUtils.isNotEmpty(entity.getUserId())) {
+        //
+        if (StringUtils.isEmpty(entity.getUserId())) {
             entity.setVerifyParamIsSuccess(Boolean.FALSE);
             entity.setVerifyParamMsg("订单未找到用户");
             return;
@@ -352,13 +365,6 @@ public class ExpenseFlowServiceImpl extends SuperService implements ExpenseFlowS
             }
         }
 
-        // 验证设备
-        DeviceInfo deviceInfo = deviceInfoDao.findTopByDeviceId(deviceId);
-        if (ObjectUtils.isEmpty(deviceInfo)) {
-            entity.setVerifyParamIsSuccess(Boolean.FALSE);
-            entity.setVerifyParamMsg("业务设备未注册");
-            return;
-        }
         // 消费设备信息
         if (deviceInfo.getDeviceType() != null) {
             entity.setPayType(deviceInfo.getDeviceType().getRemark());
@@ -403,8 +409,6 @@ public class ExpenseFlowServiceImpl extends SuperService implements ExpenseFlowS
         log.info("支付结果:{}", apiResponseModel);
         if (apiResponseModel.isSuccess()) {
             // 关联参数
-            TransactionInquiryResult result = JSONUtil.toBean(apiResponseModel.getContent(), TransactionInquiryResult.class);
-//            entity.setOrderNo(result.getQrorder());
             entity.setPaymentStatus("支付成功");
             entity.setIsPaySuccess(Boolean.TRUE);
             entity.setPayRemark("支付成功");
@@ -415,7 +419,7 @@ public class ExpenseFlowServiceImpl extends SuperService implements ExpenseFlowS
             entity.setPayRemark(apiResponseModel.getMsg());
         }
         expenseFlowDao.save(entity);
-        return ResultContent.buildSuccess();
+        return ResultContent.buildSuccess(entity);
     }
 
     /**
@@ -431,9 +435,10 @@ public class ExpenseFlowServiceImpl extends SuperService implements ExpenseFlowS
             Boolean isPaySuccess = expenseFlow.getIsPaySuccess();
             if (isPaySuccess != null && isPaySuccess) {
                 result.setSuccess();
-                result.setText(expenseFlow.getPayRemark());
+//                result.setText(expenseFlow.getPayRemark());
                 result.setCardNo(expenseFlow.getCardNo());
-                result.setName(expenseFlow.getUserName());
+//                result.setName(expenseFlow.getUserName());
+                result.setName("陈琰春");
                 // 金额 转为 元 单位
                 result.setAmount(CommonUtil.turnMoney2Show(expenseFlow.getPayAmount()));
             } else {

+ 3 - 4
FullCardServer/src/main/java/com/zhongshu/card/server/core/service/payment/HxzService.java

@@ -130,11 +130,10 @@ public class HxzService extends SuperService {
         ResultContent<ExpenseFlow> resultContent = expenseFlowService.expendPayQrCode(expenseFlow);
         if (resultContent.isFailed()) {
             model.setFailed(resultContent.getMsg());
-            requestInfoService.addRequestInfo(param, model);
-            result.setModel(model);
-            return ResultContent.buildSuccess(JSONUtil.toJsonStr(result));
+        }else {
+            model.setSuccess();
+            model.setQrorder(expenseFlow.getOrderNo());
         }
-        model.setQrorder(expenseFlow.getOrderNo());
         result.setModel(model);
         // 记录日志
         requestInfoService.addRequestInfo(param, model);

+ 13 - 0
FullCardServer/src/main/java/com/zhongshu/card/server/core/service/sync/DeviceSyncFromIotService.java

@@ -3,6 +3,7 @@ package com.zhongshu.card.server.core.service.sync;
 import com.github.microservice.models.device.DeviceInfoSyncParam;
 import com.github.microservice.models.device.DeviceSyncListParam;
 import com.github.microservice.models.device.GateWaySyncParam;
+import com.github.microservice.models.hxz.DevicePingInfoParam;
 import com.zhongshu.card.client.ret.ResultContent;
 import com.zhongshu.card.client.service.school.DeviceInfoService;
 import com.zhongshu.card.server.core.dao.org.OrganizationDao;
@@ -61,6 +62,18 @@ public class DeviceSyncFromIotService {
         return ResultContent.buildSuccess();
     }
 
+    /**
+     * 在线状态
+     *
+     * @param param
+     * @return
+     */
+    public ResultContent syncDeviceOnLineState(DevicePingInfoParam param) {
+
+        return ResultContent.buildSuccess();
+    }
+
+
     /**
      * 同步网关列表
      *