|
@@ -1,8 +1,10 @@
|
|
|
package com.zhongshu.card.server.core.service.payment;
|
|
package com.zhongshu.card.server.core.service.payment;
|
|
|
|
|
|
|
|
|
|
+import cn.hutool.json.JSONObject;
|
|
|
import cn.hutool.json.JSONUtil;
|
|
import cn.hutool.json.JSONUtil;
|
|
|
import com.github.microservice.components.data.base.util.PageEntityUtil;
|
|
import com.github.microservice.components.data.base.util.PageEntityUtil;
|
|
|
import com.github.microservice.models.hxz.*;
|
|
import com.github.microservice.models.hxz.*;
|
|
|
|
|
+import com.github.microservice.models.type.OrderFromType;
|
|
|
import com.github.microservice.models.type.PaymentDeviceType;
|
|
import com.github.microservice.models.type.PaymentDeviceType;
|
|
|
import com.github.microservice.models.type.PaymentType;
|
|
import com.github.microservice.models.type.PaymentType;
|
|
|
import com.zhongshu.card.client.model.payment.ExpenseFlowCount;
|
|
import com.zhongshu.card.client.model.payment.ExpenseFlowCount;
|
|
@@ -78,6 +80,17 @@ public class ExpenseFlowServiceImpl extends SuperService implements ExpenseFlowS
|
|
|
@Autowired
|
|
@Autowired
|
|
|
DeviceBindDao deviceBindDao;
|
|
DeviceBindDao deviceBindDao;
|
|
|
|
|
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 创建流水
|
|
|
|
|
+ *
|
|
|
|
|
+ * @param mqttDataId
|
|
|
|
|
+ * @return
|
|
|
|
|
+ */
|
|
|
|
|
+ public ExpenseFlow init(String mqttDataId) {
|
|
|
|
|
+ ExpenseFlow expenseFlow = expenseFlowDao.init(mqttDataId, TokenUtil.create());
|
|
|
|
|
+ return expenseFlow;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
/**
|
|
/**
|
|
|
* 创建订单
|
|
* 创建订单
|
|
|
*
|
|
*
|
|
@@ -107,6 +120,7 @@ public class ExpenseFlowServiceImpl extends SuperService implements ExpenseFlowS
|
|
|
String deviceId = iotParam.getDeviceId();
|
|
String deviceId = iotParam.getDeviceId();
|
|
|
expenseFlow.setDeviceId(deviceId);
|
|
expenseFlow.setDeviceId(deviceId);
|
|
|
|
|
|
|
|
|
|
+ expenseFlow.setOrderFromType(OrderFromType.Swipe);
|
|
|
// 支付方式
|
|
// 支付方式
|
|
|
expenseFlow.setPaymentWay(param.getPaymentType().getRemark());
|
|
expenseFlow.setPaymentWay(param.getPaymentType().getRemark());
|
|
|
expenseFlow.setPaymentType(param.getPaymentType());
|
|
expenseFlow.setPaymentType(param.getPaymentType());
|
|
@@ -119,13 +133,13 @@ public class ExpenseFlowServiceImpl extends SuperService implements ExpenseFlowS
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
- * 消费付款
|
|
|
|
|
|
|
+ * 钱包支付
|
|
|
*
|
|
*
|
|
|
* @param entity
|
|
* @param entity
|
|
|
* @return
|
|
* @return
|
|
|
*/
|
|
*/
|
|
|
@Transactional
|
|
@Transactional
|
|
|
- public ResultContent<ExpenseFlow> expendPay(ExpenseFlow entity) {
|
|
|
|
|
|
|
+ public ResultContent<ExpenseFlow> walletPay(ExpenseFlow entity) {
|
|
|
if (entity.getVerifyParamIsSuccess() == null || !entity.getVerifyParamIsSuccess()) {
|
|
if (entity.getVerifyParamIsSuccess() == null || !entity.getVerifyParamIsSuccess()) {
|
|
|
// 参数失败
|
|
// 参数失败
|
|
|
entity.setIsPaySuccess(Boolean.FALSE);
|
|
entity.setIsPaySuccess(Boolean.FALSE);
|
|
@@ -172,46 +186,9 @@ public class ExpenseFlowServiceImpl extends SuperService implements ExpenseFlowS
|
|
|
e.printStackTrace();
|
|
e.printStackTrace();
|
|
|
}
|
|
}
|
|
|
expenseFlowDao.save(entity);
|
|
expenseFlowDao.save(entity);
|
|
|
-
|
|
|
|
|
return ResultContent.buildSuccess();
|
|
return ResultContent.buildSuccess();
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- /**
|
|
|
|
|
- * 查询构建支付返回结果
|
|
|
|
|
- *
|
|
|
|
|
- * @param orderNo
|
|
|
|
|
- * @param cardNo
|
|
|
|
|
- * @return
|
|
|
|
|
- */
|
|
|
|
|
- public ConsumTransactionsResult buildConsumTransactionsResult(String orderNo, String cardNo) {
|
|
|
|
|
- ConsumTransactionsResult result = new ConsumTransactionsResult();
|
|
|
|
|
- ExpenseFlow expenseFlow = expenseFlowDao.findTopByOrderNoAndCardNoOrderByCreateTimeDesc(orderNo, cardNo);
|
|
|
|
|
- if (ObjectUtils.isNotEmpty(expenseFlow)) {
|
|
|
|
|
- Boolean isPaySuccess = expenseFlow.getIsPaySuccess();
|
|
|
|
|
- if (isPaySuccess != null && isPaySuccess) {
|
|
|
|
|
- result.setSuccess();
|
|
|
|
|
- // 设置了显示异常,去掉
|
|
|
|
|
-// 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());
|
|
|
|
|
- }
|
|
|
|
|
- } else {
|
|
|
|
|
- result.setFailed("未查询到订单");
|
|
|
|
|
- }
|
|
|
|
|
- return result;
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
/**
|
|
/**
|
|
|
* 通过 付款码(二维码)支付接口 创建订单
|
|
* 通过 付款码(二维码)支付接口 创建订单
|
|
|
*
|
|
*
|
|
@@ -220,8 +197,15 @@ public class ExpenseFlowServiceImpl extends SuperService implements ExpenseFlowS
|
|
|
*/
|
|
*/
|
|
|
public ResultContent<ExpenseFlow> createExpenseFlowByHxz(QRCodeTransactionModel iotParam, ExpenseFlow expenseFlow) {
|
|
public ResultContent<ExpenseFlow> createExpenseFlowByHxz(QRCodeTransactionModel iotParam, ExpenseFlow expenseFlow) {
|
|
|
expenseFlow.setMqttDataId(iotParam.getMqttDataId());
|
|
expenseFlow.setMqttDataId(iotParam.getMqttDataId());
|
|
|
-
|
|
|
|
|
|
|
+ // 支付方式 付款码
|
|
|
|
|
+ String QR = iotParam.getQR();
|
|
|
|
|
+ // 判断是否是平台的二维码
|
|
|
String userId = "665fc0389083d203896d3541";
|
|
String userId = "665fc0389083d203896d3541";
|
|
|
|
|
+ if (StringUtils.isNotEmpty(QR) && QR.indexOf("userId") > 0) {
|
|
|
|
|
+ JSONObject jsonObject = JSONUtil.parseObj(QR);
|
|
|
|
|
+ userId = jsonObject.getStr("userId");
|
|
|
|
|
+ }
|
|
|
|
|
+ expenseFlow.setOrderFromType(OrderFromType.QrCode);
|
|
|
expenseFlow.setUserId(userId);
|
|
expenseFlow.setUserId(userId);
|
|
|
|
|
|
|
|
expenseFlow.setYear(DateUtils.paresTime(System.currentTimeMillis(), DateUtils.patternyyyy));
|
|
expenseFlow.setYear(DateUtils.paresTime(System.currentTimeMillis(), DateUtils.patternyyyy));
|
|
@@ -242,8 +226,6 @@ public class ExpenseFlowServiceImpl extends SuperService implements ExpenseFlowS
|
|
|
String deviceId = iotParam.getDeviceId();
|
|
String deviceId = iotParam.getDeviceId();
|
|
|
expenseFlow.setDeviceId(deviceId);
|
|
expenseFlow.setDeviceId(deviceId);
|
|
|
|
|
|
|
|
- // 支付方式 付款码
|
|
|
|
|
- String QR = iotParam.getQR();
|
|
|
|
|
// 判断 是 微信、支付宝的付款码
|
|
// 判断 是 微信、支付宝的付款码
|
|
|
PaymentType paymentType = PaymentUtil.getPaymentTypeByQr(QR);
|
|
PaymentType paymentType = PaymentUtil.getPaymentTypeByQr(QR);
|
|
|
expenseFlow.setQr(QR);
|
|
expenseFlow.setQr(QR);
|
|
@@ -296,10 +278,9 @@ public class ExpenseFlowServiceImpl extends SuperService implements ExpenseFlowS
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
PaymentType paymentType = entity.getPaymentType();
|
|
PaymentType paymentType = entity.getPaymentType();
|
|
|
- // 刷卡支付
|
|
|
|
|
- if (paymentType == PaymentType.UserWallet) {
|
|
|
|
|
|
|
+ // 刷卡支付 并且钱包支付
|
|
|
|
|
+ if (paymentType == PaymentType.UserWallet && entity.getOrderFromType() == OrderFromType.Swipe) {
|
|
|
CardInfo cardInfo = cardInfoDao.findByCode(entity.getCardNo());
|
|
CardInfo cardInfo = cardInfoDao.findByCode(entity.getCardNo());
|
|
|
-
|
|
|
|
|
// 验证卡片
|
|
// 验证卡片
|
|
|
if (ObjectUtils.isEmpty(cardInfo)) {
|
|
if (ObjectUtils.isEmpty(cardInfo)) {
|
|
|
entity.setVerifyParamIsSuccess(Boolean.FALSE);
|
|
entity.setVerifyParamIsSuccess(Boolean.FALSE);
|
|
@@ -356,7 +337,6 @@ public class ExpenseFlowServiceImpl extends SuperService implements ExpenseFlowS
|
|
|
entity.setVerifyParamMsg(String.format("支付失败钱包%s", wallet.getDataState().getRemark()));
|
|
entity.setVerifyParamMsg(String.format("支付失败钱包%s", wallet.getDataState().getRemark()));
|
|
|
return;
|
|
return;
|
|
|
}
|
|
}
|
|
|
-
|
|
|
|
|
// 检查
|
|
// 检查
|
|
|
if (wallet.getAmount().compareTo(amount) < 0) {
|
|
if (wallet.getAmount().compareTo(amount) < 0) {
|
|
|
entity.setVerifyParamIsSuccess(Boolean.FALSE);
|
|
entity.setVerifyParamIsSuccess(Boolean.FALSE);
|
|
@@ -429,13 +409,49 @@ public class ExpenseFlowServiceImpl extends SuperService implements ExpenseFlowS
|
|
|
return ResultContent.buildSuccess(entity);
|
|
return ResultContent.buildSuccess(entity);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 查询构建支付返回结果
|
|
|
|
|
+ *
|
|
|
|
|
+ * @param orderNo
|
|
|
|
|
+ * @param cardNo
|
|
|
|
|
+ * @return
|
|
|
|
|
+ */
|
|
|
|
|
+ public ConsumTransactionsResult buildConsumTransactionsResult(String orderNo, String cardNo) {
|
|
|
|
|
+ ConsumTransactionsResult result = new ConsumTransactionsResult();
|
|
|
|
|
+ ExpenseFlow expenseFlow = expenseFlowDao.findTopByOrderNoAndCardNoOrderByCreateTimeDesc(orderNo, cardNo);
|
|
|
|
|
+ if (ObjectUtils.isNotEmpty(expenseFlow)) {
|
|
|
|
|
+ Boolean isPaySuccess = expenseFlow.getIsPaySuccess();
|
|
|
|
|
+ if (isPaySuccess != null && isPaySuccess) {
|
|
|
|
|
+ result.setSuccess();
|
|
|
|
|
+ // 设置了显示异常,去掉
|
|
|
|
|
+// 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());
|
|
|
|
|
+ }
|
|
|
|
|
+ } else {
|
|
|
|
|
+ result.setFailed("未查询到订单");
|
|
|
|
|
+ }
|
|
|
|
|
+ return result;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
/**
|
|
/**
|
|
|
* 查询构建支付返回结果
|
|
* 查询构建支付返回结果
|
|
|
*
|
|
*
|
|
|
* @param orderNo
|
|
* @param orderNo
|
|
|
* @return
|
|
* @return
|
|
|
*/
|
|
*/
|
|
|
- public ConsumTransactionsResult buildConsumTransactionsResult(String orderNo) {
|
|
|
|
|
|
|
+ public ConsumTransactionsResult buildPayResult(String orderNo) {
|
|
|
ConsumTransactionsResult result = new ConsumTransactionsResult();
|
|
ConsumTransactionsResult result = new ConsumTransactionsResult();
|
|
|
ExpenseFlow expenseFlow = expenseFlowDao.findTopByOrderNoOrderByCreateTimeDesc(orderNo);
|
|
ExpenseFlow expenseFlow = expenseFlowDao.findTopByOrderNoOrderByCreateTimeDesc(orderNo);
|
|
|
if (ObjectUtils.isNotEmpty(expenseFlow)) {
|
|
if (ObjectUtils.isNotEmpty(expenseFlow)) {
|
|
@@ -443,11 +459,23 @@ public class ExpenseFlowServiceImpl extends SuperService implements ExpenseFlowS
|
|
|
if (isPaySuccess != null && isPaySuccess) {
|
|
if (isPaySuccess != null && isPaySuccess) {
|
|
|
result.setSuccess();
|
|
result.setSuccess();
|
|
|
// result.setText(expenseFlow.getPayRemark());
|
|
// result.setText(expenseFlow.getPayRemark());
|
|
|
|
|
+ if (expenseFlow.getPaymentType() == PaymentType.WxQrCode
|
|
|
|
|
+ || expenseFlow.getPaymentType() == PaymentType.ZfbQrCode) {
|
|
|
|
|
+ result.setName("陈琰春");
|
|
|
|
|
+ } else {
|
|
|
|
|
+ result.setName(expenseFlow.getUserName());
|
|
|
|
|
+ }
|
|
|
result.setCardNo(expenseFlow.getCardNo());
|
|
result.setCardNo(expenseFlow.getCardNo());
|
|
|
-// result.setName(expenseFlow.getUserName());
|
|
|
|
|
- result.setName("陈琰春");
|
|
|
|
|
// 金额 转为 元 单位
|
|
// 金额 转为 元 单位
|
|
|
result.setAmount(CommonUtil.turnMoney2Show(expenseFlow.getPayAmount()));
|
|
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 {
|
|
} else {
|
|
|
result.setFailed(expenseFlow.getPayRemark());
|
|
result.setFailed(expenseFlow.getPayRemark());
|
|
|
}
|
|
}
|