|
@@ -14,14 +14,18 @@ import cn.hnthyy.thmz.service.his.mz.MzyReqrecService;
|
|
|
import cn.hnthyy.thmz.service.thmz.TransactionService;
|
|
|
import cn.hnthyy.thmz.service.thmz.WindowsService;
|
|
|
import cn.hnthyy.thmz.vo.MisPosVo;
|
|
|
+import cn.hutool.core.util.StrUtil;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
import org.json.JSONObject;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
-import org.springframework.web.bind.annotation.*;
|
|
|
+import org.springframework.web.bind.annotation.RequestBody;
|
|
|
+import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
+import org.springframework.web.bind.annotation.RequestMethod;
|
|
|
+import org.springframework.web.bind.annotation.RequestParam;
|
|
|
+import org.springframework.web.bind.annotation.RestController;
|
|
|
|
|
|
import javax.servlet.http.HttpServletRequest;
|
|
|
-import java.util.Arrays;
|
|
|
import java.util.HashMap;
|
|
|
import java.util.Map;
|
|
|
|
|
@@ -42,13 +46,14 @@ public class TransactionController {
|
|
|
*
|
|
|
* @return
|
|
|
*/
|
|
|
- @UserLoginToken
|
|
|
@RequestMapping(value = "/sign", method = {RequestMethod.GET})
|
|
|
- public Map<String, Object> sign(HttpServletRequest httpServletRequest) {
|
|
|
+ public Map<String, Object> sign(HttpServletRequest httpServletRequest,@RequestParam(required = false) String ip) {
|
|
|
Map<String, Object> resultMap = new HashMap<>();
|
|
|
try {
|
|
|
- String ipAddress = HttpUtil.getIPAddress(httpServletRequest);
|
|
|
- Windows windowsDb = windowsService.queryLastWindowsIpAddress(ipAddress);
|
|
|
+ if(StrUtil.isBlank(ip)){
|
|
|
+ ip = HttpUtil.getIPAddress(httpServletRequest);
|
|
|
+ }
|
|
|
+ Windows windowsDb = windowsService.queryLastWindowsIpAddress(ip);
|
|
|
if (windowsDb == null || StringUtils.isBlank(windowsDb.getMisPosRouterCode())) {
|
|
|
resultMap.put("code", -1);
|
|
|
resultMap.put("message", "您暂未配置只能POS机的【路由识别码】,请配置完后重试!");
|
|
@@ -85,13 +90,14 @@ public class TransactionController {
|
|
|
*
|
|
|
* @return
|
|
|
*/
|
|
|
- @UserLoginToken
|
|
|
@RequestMapping(value = "/balance", method = {RequestMethod.GET})
|
|
|
- public Map<String, Object> balance(HttpServletRequest httpServletRequest) {
|
|
|
+ public Map<String, Object> balance(HttpServletRequest httpServletRequest,@RequestParam(required = false) String ip) {
|
|
|
Map<String, Object> resultMap = new HashMap<>();
|
|
|
try {
|
|
|
- String ipAddress = HttpUtil.getIPAddress(httpServletRequest);
|
|
|
- Windows windowsDb = windowsService.queryLastWindowsIpAddress(ipAddress);
|
|
|
+ if(StrUtil.isBlank(ip)){
|
|
|
+ ip = HttpUtil.getIPAddress(httpServletRequest);
|
|
|
+ }
|
|
|
+ Windows windowsDb = windowsService.queryLastWindowsIpAddress(ip);
|
|
|
if (windowsDb == null || StringUtils.isBlank(windowsDb.getMisPosRouterCode())) {
|
|
|
resultMap.put("code", -1);
|
|
|
resultMap.put("message", "您暂未配置只能POS机的【路由识别码】,请配置完后重试!");
|
|
@@ -129,7 +135,6 @@ public class TransactionController {
|
|
|
*
|
|
|
* @return
|
|
|
*/
|
|
|
- @UserLoginToken
|
|
|
@RequestMapping(value = "/consume", method = {RequestMethod.POST})
|
|
|
public Map<String, Object> consume(@RequestBody MisPosVo misPosVo, HttpServletRequest httpServletRequest) {
|
|
|
Map<String, Object> resultMap = new HashMap<>();
|
|
@@ -159,7 +164,7 @@ public class TransactionController {
|
|
|
resultMap.put("message", "请求类型参数传值错误!");
|
|
|
return resultMap;
|
|
|
}
|
|
|
- String ipAddress = HttpUtil.getIPAddress(httpServletRequest);
|
|
|
+ String ipAddress = StrUtil.isBlank(misPosVo.getIp()) ? HttpUtil.getIPAddress(httpServletRequest) : misPosVo.getIp();
|
|
|
Windows windowsDb = windowsService.queryLastWindowsIpAddress(ipAddress);
|
|
|
if (windowsDb == null || StringUtils.isBlank(windowsDb.getMisPosRouterCode())) {
|
|
|
resultMap.put("code", -1);
|
|
@@ -220,7 +225,6 @@ public class TransactionController {
|
|
|
*
|
|
|
* @return
|
|
|
*/
|
|
|
- @UserLoginToken
|
|
|
@RequestMapping(value = "/consumeCommon", method = {RequestMethod.POST})
|
|
|
public Map<String, Object> consumeCommon(@RequestBody MisPosVo misPosVo, HttpServletRequest httpServletRequest) {
|
|
|
Map<String, Object> resultMap = new HashMap<>();
|
|
@@ -240,7 +244,7 @@ public class TransactionController {
|
|
|
resultMap.put("message", "支付方式不能为空");
|
|
|
return resultMap;
|
|
|
}
|
|
|
- String ipAddress = HttpUtil.getIPAddress(httpServletRequest);
|
|
|
+ String ipAddress = StrUtil.isBlank(misPosVo.getIp()) ? HttpUtil.getIPAddress(httpServletRequest) : misPosVo.getIp();
|
|
|
Windows windowsDb = windowsService.queryLastWindowsIpAddress(ipAddress);
|
|
|
if (windowsDb == null || StringUtils.isBlank(windowsDb.getMisPosRouterCode())) {
|
|
|
resultMap.put("code", -1);
|
|
@@ -288,7 +292,6 @@ public class TransactionController {
|
|
|
*
|
|
|
* @return
|
|
|
*/
|
|
|
- @UserLoginToken
|
|
|
@RequestMapping(value = "/refund", method = {RequestMethod.POST})
|
|
|
public Map<String, Object> refund(@RequestBody MisPosVo misPosVo, HttpServletRequest httpServletRequest) {
|
|
|
Map<String, Object> resultMap = new HashMap<>();
|
|
@@ -344,7 +347,7 @@ public class TransactionController {
|
|
|
resultMap.put("message", "交易类型错误");
|
|
|
return resultMap;
|
|
|
}
|
|
|
- String ipAddress = HttpUtil.getIPAddress(httpServletRequest);
|
|
|
+ String ipAddress = StrUtil.isBlank(misPosVo.getIp()) ? HttpUtil.getIPAddress(httpServletRequest) : misPosVo.getIp();
|
|
|
Windows windowsDb = windowsService.queryLastWindowsIpAddress(ipAddress);
|
|
|
if (windowsDb == null || StringUtils.isBlank(windowsDb.getMisPosRouterCode())) {
|
|
|
resultMap.put("code", -1);
|
|
@@ -391,9 +394,8 @@ public class TransactionController {
|
|
|
* @param httpServletRequest
|
|
|
* @return
|
|
|
*/
|
|
|
- @UserLoginToken
|
|
|
@RequestMapping(value = "/reprint", method = {RequestMethod.GET})
|
|
|
- public Map<String, Object> reprint(@RequestParam("traceNo") String traceNo,HttpServletRequest httpServletRequest) {
|
|
|
+ public Map<String, Object> reprint(@RequestParam("traceNo") String traceNo,@RequestParam(required = false) String ip,HttpServletRequest httpServletRequest) {
|
|
|
Map<String, Object> resultMap = new HashMap<>();
|
|
|
try {
|
|
|
if(StringUtils.isBlank(traceNo)){
|
|
@@ -401,8 +403,10 @@ public class TransactionController {
|
|
|
resultMap.put("message", "重印失败,交易凭证号为空!");
|
|
|
return resultMap;
|
|
|
}
|
|
|
- String ipAddress = HttpUtil.getIPAddress(httpServletRequest);
|
|
|
- Windows windowsDb = windowsService.queryLastWindowsIpAddress(ipAddress);
|
|
|
+ if(StrUtil.isBlank(ip)){
|
|
|
+ ip = HttpUtil.getIPAddress(httpServletRequest);
|
|
|
+ }
|
|
|
+ Windows windowsDb = windowsService.queryLastWindowsIpAddress(ip);
|
|
|
if (windowsDb == null || StringUtils.isBlank(windowsDb.getMisPosRouterCode())) {
|
|
|
resultMap.put("code", -1);
|
|
|
resultMap.put("message", "您暂未配置只能POS机的【路由识别码】,请配置完后重试!");
|
|
@@ -441,13 +445,14 @@ public class TransactionController {
|
|
|
*
|
|
|
* @return
|
|
|
*/
|
|
|
- @UserLoginToken
|
|
|
@RequestMapping(value = "/settle", method = {RequestMethod.GET})
|
|
|
- public Map<String, Object> settle(HttpServletRequest httpServletRequest) {
|
|
|
+ public Map<String, Object> settle(@RequestParam(required = false) String ip,HttpServletRequest httpServletRequest) {
|
|
|
Map<String, Object> resultMap = new HashMap<>();
|
|
|
try {
|
|
|
- String ipAddress = HttpUtil.getIPAddress(httpServletRequest);
|
|
|
- Windows windowsDb = windowsService.queryLastWindowsIpAddress(ipAddress);
|
|
|
+ if(StrUtil.isBlank(ip)){
|
|
|
+ ip = HttpUtil.getIPAddress(httpServletRequest);
|
|
|
+ }
|
|
|
+ Windows windowsDb = windowsService.queryLastWindowsIpAddress(ip);
|
|
|
if (windowsDb == null || StringUtils.isBlank(windowsDb.getMisPosRouterCode())) {
|
|
|
resultMap.put("code", -1);
|
|
|
resultMap.put("message", "您暂未配置只能POS机的【路由识别码】,请配置完后重试!");
|
|
@@ -486,9 +491,8 @@ public class TransactionController {
|
|
|
* @param httpServletRequest
|
|
|
* @return
|
|
|
*/
|
|
|
- @UserLoginToken
|
|
|
@RequestMapping(value = "/query", method = {RequestMethod.GET})
|
|
|
- public Map<String, Object> query(@RequestParam("plId") String plId,HttpServletRequest httpServletRequest) {
|
|
|
+ public Map<String, Object> query(@RequestParam("plId") String plId,@RequestParam(required = false) String ip,HttpServletRequest httpServletRequest) {
|
|
|
Map<String, Object> resultMap = new HashMap<>();
|
|
|
try {
|
|
|
if(StringUtils.isBlank(plId)){
|
|
@@ -496,8 +500,10 @@ public class TransactionController {
|
|
|
resultMap.put("message", "交易查询失败,订单号为空!");
|
|
|
return resultMap;
|
|
|
}
|
|
|
- String ipAddress = HttpUtil.getIPAddress(httpServletRequest);
|
|
|
- Windows windowsDb = windowsService.queryLastWindowsIpAddress(ipAddress);
|
|
|
+ if(StrUtil.isBlank(ip)){
|
|
|
+ ip = HttpUtil.getIPAddress(httpServletRequest);
|
|
|
+ }
|
|
|
+ Windows windowsDb = windowsService.queryLastWindowsIpAddress(ip);
|
|
|
if (windowsDb == null || StringUtils.isBlank(windowsDb.getMisPosRouterCode())) {
|
|
|
resultMap.put("code", -1);
|
|
|
resultMap.put("message", "您暂未配置只能POS机的【路由识别码】,请配置完后重试!");
|