扫码王业务代码
This commit is contained in:
@@ -46,6 +46,7 @@ import org.springframework.context.annotation.Lazy;
|
||||
import org.springframework.transaction.interceptor.TransactionAspectSupport;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.validation.Valid;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.*;
|
||||
@@ -388,7 +389,7 @@ public class MerchantOrderController {
|
||||
@ApiOperation(value = "会员充值", notes = "APP扫码-会员充值", httpMethod = "GET")
|
||||
@ApiImplicitParams({
|
||||
@ApiImplicitParam(name = "MemberRechargeDTO", value = "MemberRechargeDTO", paramType = "MemberRechargeDTO", dataType = "MemberRechargeDTO", required = true)})
|
||||
public Result<Map<String, Object>> memberRecharge(@RequestBody MemberRechargeDTO memberRechargeDTO) {
|
||||
public Result<Map<String, Object>> memberRecharge(@RequestBody MemberRechargeDTO memberRechargeDTO, HttpServletRequest request) {
|
||||
|
||||
try {
|
||||
UserApp userApp = userAppService.queryUserAppByToken();
|
||||
@@ -398,7 +399,7 @@ public class MerchantOrderController {
|
||||
memberRechargeDTO.setMerchantCode(userApp.getMerchantCode());
|
||||
memberRechargeDTO.setUserId(String.valueOf(userApp.getUserId()));
|
||||
memberRechargeDTO.setUserName(userApp.getUserName());
|
||||
return merchantOrderService.toMemberRecharge(memberRechargeDTO);
|
||||
return merchantOrderService.toMemberRecharge(memberRechargeDTO, request);
|
||||
}catch (Exception e){
|
||||
e.printStackTrace();
|
||||
MsgException.throwException(e.getMessage());
|
||||
@@ -417,7 +418,7 @@ public class MerchantOrderController {
|
||||
@ApiOperation(tags = {"页面-收款"}, value = "扫码支付", notes = "扫码支付", httpMethod = "POST")
|
||||
@ApiImplicitParams({
|
||||
@ApiImplicitParam(name = "MerchantOrderVo", value = "扫码支付需要传递的参数实例", paramType = "body", dataType = "MerchantOrderVo", required = true)})
|
||||
public Result<Object> scanPay(@RequestBody MerChantOrderDTO merchantOrderDTO) {
|
||||
public Result<Object> scanPay(@RequestBody MerChantOrderDTO merchantOrderDTO, HttpServletRequest req) {
|
||||
UserApp tokenUa = userAppService.queryUserAppByToken();
|
||||
merchantOrderDTO.setMerchantCode(tokenUa.getMerchantCode());
|
||||
//校验金额
|
||||
@@ -425,7 +426,7 @@ public class MerchantOrderController {
|
||||
MsgException.throwException("金额异常");
|
||||
}
|
||||
try {
|
||||
return merchantOrderService.toActivePay(merchantOrderDTO);
|
||||
return merchantOrderService.toActivePay(merchantOrderDTO, req);
|
||||
} catch (Exception e){
|
||||
e.printStackTrace();
|
||||
return ResultGenerator.genFailResult(e.getMessage());
|
||||
@@ -437,7 +438,7 @@ public class MerchantOrderController {
|
||||
* @return
|
||||
*/
|
||||
@PostMapping("/posScanPay")
|
||||
public Result<Object> posScanPay(@RequestBody MerChantOrderDTO merchantOrderDTO) {
|
||||
public Result<Object> posScanPay(@RequestBody MerChantOrderDTO merchantOrderDTO, HttpServletRequest request) {
|
||||
//首先验签
|
||||
verify(merchantOrderDTO.getTimestamp(), merchantOrderDTO.getRequestId(), merchantOrderDTO.getAppId(), merchantOrderDTO.getToken());
|
||||
//通过后查询商户信息
|
||||
@@ -451,7 +452,7 @@ public class MerchantOrderController {
|
||||
}
|
||||
//进行支付操作
|
||||
try {
|
||||
Result<Object> activePay = merchantOrderService.toActivePay(merchantOrderDTO);
|
||||
Result<Object> activePay = merchantOrderService.toActivePay(merchantOrderDTO, request);
|
||||
String result = activePay.toString();
|
||||
JSONObject jsonData = JSONObject.parseObject(result);
|
||||
Object orderNumber = jsonData.getJSONObject("data").get("orderNumber");
|
||||
|
||||
@@ -0,0 +1,208 @@
|
||||
package cn.pluss.platform.controller.access;
|
||||
|
||||
import cn.pluss.platform.access.AccessService;
|
||||
import cn.pluss.platform.access.domain.CodeEnum;
|
||||
import cn.pluss.platform.access.domain.ReqEntity;
|
||||
import cn.pluss.platform.access.domain.RespEntity;
|
||||
import cn.pluss.platform.access.exception.AccessException;
|
||||
import cn.pluss.platform.access.service.AccessBizService;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
@RequestMapping("/access")
|
||||
@RestController
|
||||
public class AccessController {
|
||||
|
||||
@Autowired
|
||||
private AccessService accessService;
|
||||
|
||||
@Autowired
|
||||
private AccessBizService accessBizService;
|
||||
|
||||
@PostMapping("/storeInfoByDeviceNo")
|
||||
public RespEntity machineStoreInfo(@RequestBody ReqEntity reqEntity) {
|
||||
String requestId = reqEntity.getRequestId();
|
||||
JSONObject reqData = reqEntity.initJSONData();
|
||||
RespEntity result;
|
||||
|
||||
String deviceNo = reqData.getString("deviceNo");
|
||||
if (deviceNo == null) {
|
||||
result = new RespEntity(reqEntity.getOrgId(), CodeEnum.PARAM_ERROR, null, requestId);
|
||||
accessService.addSign(result);
|
||||
return result;
|
||||
}
|
||||
|
||||
Object bizResult = accessBizService.machineStoreInfo(deviceNo);
|
||||
result = new RespEntity(reqEntity.getOrgId(), CodeEnum.SUCCESS, bizResult, requestId);
|
||||
|
||||
accessService.addSign(result);
|
||||
return result;
|
||||
}
|
||||
|
||||
@PostMapping("/scanPay")
|
||||
public RespEntity scanPay(@RequestBody ReqEntity reqEntity) {
|
||||
String requestId = reqEntity.getRequestId();
|
||||
JSONObject reqData = reqEntity.initJSONData();
|
||||
RespEntity result;
|
||||
|
||||
String deviceNo = reqData.getString("deviceNo");
|
||||
if (deviceNo == null) {
|
||||
result = new RespEntity(reqEntity.getOrgId(), CodeEnum.PARAM_ERROR, null, requestId);
|
||||
accessService.addSign(result);
|
||||
return result;
|
||||
}
|
||||
|
||||
try {
|
||||
Object bizResult = accessBizService.scanPay(reqData);
|
||||
result = new RespEntity(reqEntity.getOrgId(), CodeEnum.SUCCESS, bizResult, requestId);
|
||||
|
||||
accessService.addSign(result);
|
||||
return result;
|
||||
} catch (AccessException e) {
|
||||
result = new RespEntity(reqEntity.getOrgId(), e.getCode(), null, requestId, e.getMessage());
|
||||
accessService.addSign(result);
|
||||
return result;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@PostMapping("/orderStatus")
|
||||
public RespEntity orderStatus(@RequestBody ReqEntity reqEntity) {
|
||||
String requestId = reqEntity.getRequestId();
|
||||
JSONObject reqData = reqEntity.initJSONData();
|
||||
RespEntity result;
|
||||
|
||||
String deviceNo = reqData.getString("deviceNo");
|
||||
if (deviceNo == null) {
|
||||
result = new RespEntity(reqEntity.getOrgId(), CodeEnum.PARAM_ERROR, null, requestId);
|
||||
accessService.addSign(result);
|
||||
return result;
|
||||
}
|
||||
|
||||
String orderNumber = reqData.getString("orderNumber");
|
||||
String mercOrderNo = reqData.getString("mercOrderNo");
|
||||
|
||||
try {
|
||||
Object bizResult = accessBizService.orderStatus(orderNumber, mercOrderNo);
|
||||
result = new RespEntity(reqEntity.getOrgId(), CodeEnum.SUCCESS, bizResult, requestId);
|
||||
|
||||
accessService.addSign(result);
|
||||
return result;
|
||||
} catch (AccessException e) {
|
||||
result = new RespEntity(reqEntity.getOrgId(), e.getCode(), null, requestId, e.getMessage());
|
||||
accessService.addSign(result);
|
||||
return result;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@PostMapping("/orderRefund")
|
||||
public RespEntity orderRefund(@RequestBody ReqEntity reqEntity) {
|
||||
String requestId = reqEntity.getRequestId();
|
||||
JSONObject reqData = reqEntity.initJSONData();
|
||||
RespEntity result;
|
||||
|
||||
String deviceNo = reqData.getString("deviceNo");
|
||||
if (deviceNo == null) {
|
||||
result = new RespEntity(reqEntity.getOrgId(), CodeEnum.PARAM_ERROR, null, requestId);
|
||||
accessService.addSign(result);
|
||||
return result;
|
||||
}
|
||||
|
||||
try {
|
||||
Object bizResult = accessBizService.refund(reqData);
|
||||
result = new RespEntity(reqEntity.getOrgId(), CodeEnum.SUCCESS, bizResult, requestId);
|
||||
|
||||
accessService.addSign(result);
|
||||
return result;
|
||||
} catch (AccessException e) {
|
||||
result = new RespEntity(reqEntity.getOrgId(), e.getCode(), null, requestId, e.getMessage());
|
||||
accessService.addSign(result);
|
||||
return result;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@PostMapping("/orderRefundList")
|
||||
public RespEntity orderRefundList(@RequestBody ReqEntity reqEntity) {
|
||||
String requestId = reqEntity.getRequestId();
|
||||
JSONObject reqData = reqEntity.initJSONData();
|
||||
RespEntity result;
|
||||
|
||||
String deviceNo = reqData.getString("deviceNo");
|
||||
if (deviceNo == null) {
|
||||
result = new RespEntity(reqEntity.getOrgId(), CodeEnum.PARAM_ERROR, null, requestId);
|
||||
accessService.addSign(result);
|
||||
return result;
|
||||
}
|
||||
|
||||
try {
|
||||
Object bizResult = accessBizService.refundList(reqData);
|
||||
result = new RespEntity(reqEntity.getOrgId(), CodeEnum.SUCCESS, bizResult, requestId);
|
||||
|
||||
accessService.addSign(result);
|
||||
return result;
|
||||
} catch (AccessException e) {
|
||||
result = new RespEntity(reqEntity.getOrgId(), e.getCode(), null, requestId, e.getMessage());
|
||||
accessService.addSign(result);
|
||||
return result;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@PostMapping("/orderList")
|
||||
public RespEntity orderList(@RequestBody ReqEntity reqEntity) {
|
||||
String requestId = reqEntity.getRequestId();
|
||||
JSONObject reqData = reqEntity.initJSONData();
|
||||
RespEntity result;
|
||||
|
||||
String deviceNo = reqData.getString("deviceNo");
|
||||
if (deviceNo == null) {
|
||||
result = new RespEntity(reqEntity.getOrgId(), CodeEnum.PARAM_ERROR, null, requestId);
|
||||
accessService.addSign(result);
|
||||
return result;
|
||||
}
|
||||
|
||||
try {
|
||||
Object bizResult = accessBizService.orderList(reqData);
|
||||
result = new RespEntity(reqEntity.getOrgId(), CodeEnum.SUCCESS, bizResult, requestId);
|
||||
|
||||
accessService.addSign(result);
|
||||
return result;
|
||||
} catch (AccessException e) {
|
||||
result = new RespEntity(reqEntity.getOrgId(), e.getCode(), null, requestId, e.getMessage());
|
||||
accessService.addSign(result);
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
@PostMapping("/dataAnalysis")
|
||||
public RespEntity dataAnalysis(@RequestBody ReqEntity reqEntity) {
|
||||
String requestId = reqEntity.getRequestId();
|
||||
JSONObject reqData = reqEntity.initJSONData();
|
||||
RespEntity result;
|
||||
|
||||
String deviceNo = reqData.getString("deviceNo");
|
||||
if (deviceNo == null) {
|
||||
result = new RespEntity(reqEntity.getOrgId(), CodeEnum.PARAM_ERROR, null, requestId);
|
||||
accessService.addSign(result);
|
||||
return result;
|
||||
}
|
||||
|
||||
try {
|
||||
Object bizResult = accessBizService.dataAnalysis(reqData);
|
||||
result = new RespEntity(reqEntity.getOrgId(), CodeEnum.SUCCESS, bizResult, requestId);
|
||||
|
||||
accessService.addSign(result);
|
||||
return result;
|
||||
} catch (AccessException e) {
|
||||
result = new RespEntity(reqEntity.getOrgId(), e.getCode(), null, requestId, e.getMessage());
|
||||
accessService.addSign(result);
|
||||
return result;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,9 @@
|
||||
package cn.pluss.platform.interceptor;
|
||||
|
||||
import cn.pluss.platform.access.AccessService;
|
||||
import cn.pluss.platform.access.domain.CodeEnum;
|
||||
import cn.pluss.platform.access.domain.ReqEntity;
|
||||
import cn.pluss.platform.access.domain.RespEntity;
|
||||
import cn.pluss.platform.api.Result;
|
||||
import cn.pluss.platform.api.ResultCode;
|
||||
import cn.pluss.platform.constants.CommonError;
|
||||
@@ -10,14 +14,20 @@ import cn.pluss.platform.merchant.MerchantStaffConnService;
|
||||
import cn.pluss.platform.userApp.UserAppService;
|
||||
import cn.pluss.platform.userInfo.UserInfoService;
|
||||
import cn.pluss.platform.util.ComUtil;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.servlet.handler.HandlerInterceptorAdapter;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.BufferedReader;
|
||||
import java.io.InputStream;
|
||||
import java.io.InputStreamReader;
|
||||
import java.net.URLDecoder;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@@ -35,6 +45,9 @@ public class TokenRegistryInterceptor extends HandlerInterceptorAdapter {
|
||||
@Resource
|
||||
private MerchantStaffConnService staffConnService;
|
||||
|
||||
@Autowired
|
||||
private AccessService accessService;
|
||||
|
||||
@Override
|
||||
public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
|
||||
String requestUri = request.getRequestURI();
|
||||
@@ -75,6 +88,46 @@ public class TokenRegistryInterceptor extends HandlerInterceptorAdapter {
|
||||
String contentType = request.getContentType();
|
||||
|
||||
|
||||
if (contentType != null
|
||||
&& contentType.contains("application/json")
|
||||
&& requestUri.startsWith("/api/access")) {
|
||||
StringBuilder responseStrBuilder = new StringBuilder();
|
||||
InputStream is = request.getInputStream();
|
||||
BufferedReader streamReader = new BufferedReader(new InputStreamReader(is, StandardCharsets.UTF_8));
|
||||
String inputStr;
|
||||
while ((inputStr = streamReader.readLine()) != null) {
|
||||
responseStrBuilder.append(inputStr);
|
||||
}
|
||||
|
||||
ReqEntity reqEntity;
|
||||
try {
|
||||
reqEntity = JSON.toJavaObject(JSON.parseObject(responseStrBuilder.toString()), ReqEntity.class);
|
||||
} catch (Exception e) {
|
||||
RespEntity entity = new RespEntity(null, CodeEnum.PARAM_ERROR, null, null);
|
||||
ComUtil.responseResult(response, entity);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (reqEntity == null || reqEntity.getOrgId() == null) {
|
||||
RespEntity entity = new RespEntity(null, CodeEnum.ORG_ID_NOT_FOUND, null, null);
|
||||
ComUtil.responseResult(response, entity);
|
||||
return false;
|
||||
}
|
||||
|
||||
boolean signCheck = accessService.checkSign(reqEntity);
|
||||
|
||||
// 操作
|
||||
if (signCheck) {
|
||||
return true;
|
||||
} else {
|
||||
RespEntity entity = new RespEntity(reqEntity.getOrgId(), CodeEnum.SIGN_ERROR, null, reqEntity.getRequestId());
|
||||
accessService.addSign(entity);
|
||||
ComUtil.responseResult(response, entity);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
synchronized (this) {
|
||||
String requestToken = request.getHeader("token");
|
||||
// 登录账号
|
||||
|
||||
Reference in New Issue
Block a user