pos付款相关
This commit is contained in:
parent
cbad5d16b7
commit
5f1fd5bdbe
|
|
@ -23,12 +23,14 @@ import cn.pluss.platform.merchantOrder.MerchantOrderService;
|
|||
import cn.pluss.platform.notice.NoticeService;
|
||||
import cn.pluss.platform.pay.PayService;
|
||||
import cn.pluss.platform.pos.BasePosReq;
|
||||
import cn.pluss.platform.pos.PosPay;
|
||||
import cn.pluss.platform.pos.PosTradeQueryReq;
|
||||
import cn.pluss.platform.pos.ReturnFundsReq;
|
||||
import cn.pluss.platform.ryx.pay.RyxPayService;
|
||||
import cn.pluss.platform.sxf.pay.SxfPayService;
|
||||
import cn.pluss.platform.user.impl.GeneralPushUtil;
|
||||
import cn.pluss.platform.userApp.UserAppService;
|
||||
import cn.pluss.platform.util.BeanUtils;
|
||||
import cn.pluss.platform.util.IpUtils;
|
||||
import cn.pluss.platform.util.StringUtil;
|
||||
import cn.pluss.platform.util.TokenUtil;
|
||||
|
|
@ -47,6 +49,7 @@ import lombok.Setter;
|
|||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Qualifier;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Lazy;
|
||||
import org.springframework.transaction.interceptor.TransactionAspectSupport;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
|
@ -441,24 +444,26 @@ public class MerchantOrderController {
|
|||
}
|
||||
/**
|
||||
* 博实结pos机反扫支付
|
||||
* @param merchantOrderDTO
|
||||
* @param
|
||||
* @return
|
||||
*/
|
||||
@PostMapping("/posScanPay")
|
||||
public Result<Object> posScanPay(HttpServletRequest request,@RequestBody MerChantOrderDTO merchantOrderDTO)throws Exception{
|
||||
public JSONObject posScanPay(HttpServletRequest request,@RequestBody BasePosReq req)throws Exception{
|
||||
//首先验签
|
||||
verify(merchantOrderDTO.getTimestamp(), merchantOrderDTO.getRequestId(), merchantOrderDTO.getAppId(), merchantOrderDTO.getToken(),
|
||||
merchantOrderDTO.getReqData());
|
||||
verify(req.getTimestamp(), req.getRequestId(), req.getAppId(), req.getToken(),
|
||||
req.getReqData());
|
||||
//拆分参数
|
||||
JSONObject jsonParam = JSONObject.parseObject(merchantOrderDTO.getReqData());
|
||||
Object sn = jsonParam.get("sn");
|
||||
Object authCode = jsonParam.get("authCode");
|
||||
Object consumeFee = jsonParam.get("consumeFee");
|
||||
Object type = jsonParam.get("type");
|
||||
Object mercOrderNo = jsonParam.get("mercOrderNo");
|
||||
Object remark = jsonParam.get("remark");
|
||||
PosPay posPay = JSONObject.parseObject(req.getReqData(), PosPay.class);
|
||||
MerChantOrderDTO merchantOrderDTO = new MerChantOrderDTO();
|
||||
merchantOrderDTO.setSn(posPay.getSn());
|
||||
merchantOrderDTO.setMercOrderNo(posPay.getMercOrderNo());
|
||||
merchantOrderDTO.setType(posPay.getType());
|
||||
merchantOrderDTO.setAuthCode(posPay.getAuthCode());
|
||||
merchantOrderDTO.setRemark(posPay.getRemark());
|
||||
merchantOrderDTO.setConsumeFee(Double.valueOf(posPay.getConsumeFee()));
|
||||
|
||||
//通过后查询商户信息
|
||||
DeviceStock deviceStock = deviceStockService.checkBind(sn.toString());
|
||||
DeviceStock deviceStock = deviceStockService.checkBind(posPay.getSn());
|
||||
MerchantBaseInfo merchantBaseInfoById = merchantBaseInfoService.getMerchantBaseInfoById(Integer.valueOf(deviceStock.getActMercId()));
|
||||
MsgException.checkNull(merchantBaseInfoById, "找不到商户");
|
||||
merchantOrderDTO.setMerchantCode(merchantBaseInfoById.getMerchantCode());
|
||||
|
|
@ -472,20 +477,27 @@ public class MerchantOrderController {
|
|||
String result = activePay.toString();
|
||||
JSONObject jsonData = JSONObject.parseObject(result);
|
||||
Object orderNumber = jsonData.getJSONObject("data").get("orderNumber");
|
||||
String data = jsonData.getJSONObject("data").get("data").toString();
|
||||
JSONObject jsonDataInfo = JSONObject.parseObject(data);
|
||||
|
||||
HashMap<String, Object> map = new HashMap<>();
|
||||
map.put("orderNumber", orderNumber);
|
||||
return ResultGenerator.genSuccessResult(map);
|
||||
map.put("consumeFee", jsonDataInfo.get("consumeFee"));
|
||||
map.put("mercOrderNo", posPay.getMercOrderNo());
|
||||
map.put("remark", posPay.getRemark());
|
||||
map.put("status", jsonDataInfo.get("status"));
|
||||
return ResultGenerator.genSuccessJsonPos(map, req.getAppId(), req.getRequestId());
|
||||
} catch (Exception e){
|
||||
e.printStackTrace();
|
||||
return ResultGenerator.genFailResult(e.getMessage());
|
||||
return ResultGenerator.genFailJsonPos(e.getMessage(), req.getAppId(), req.getRequestId());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@PostMapping(value = "orderList")
|
||||
public Result<Object> posTradeQuery(HttpServletRequest request, @RequestBody BasePosReq req){
|
||||
public Result<Object> posTradeQuery(HttpServletRequest request, @RequestBody BasePosReq req)throws Exception{
|
||||
|
||||
verify(req.getTimestamp(),req.getRequestId(),req.getAppId(),req.getToken());
|
||||
verify(req.getTimestamp(),req.getRequestId(),req.getAppId(),req.getToken(), req.getReqData());
|
||||
|
||||
PosTradeQueryReq tradeQueryReq=JSONObject.parseObject(req.getReqData(),PosTradeQueryReq.class);
|
||||
DeviceStock deviceStock = deviceStockService.checkBind(tradeQueryReq.getSn());
|
||||
|
|
@ -1380,7 +1392,6 @@ public class MerchantOrderController {
|
|||
//首先验证签
|
||||
Map<String, String> tokenMap = TokenUtil.getToken(timestamp, requestId, appId, reqData);
|
||||
boolean sign = tokenMap.get("TOKEN").equals(token);
|
||||
System.out.println(token);
|
||||
MsgException.check(!sign,"签名错误");
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -77,4 +77,22 @@ public class ResultGenerator {
|
|||
result.put("data",data);
|
||||
return result;
|
||||
}
|
||||
public static JSONObject genSuccessJsonPos(Object data, String appId, String requestId) {
|
||||
JSONObject result = new JSONObject();
|
||||
result.put("code","0000");
|
||||
result.put("msg","操作成功");
|
||||
result.put("appId", appId);
|
||||
result.put("requestId", requestId);
|
||||
result.put("respData", data);
|
||||
return result;
|
||||
}
|
||||
public static JSONObject genFailJsonPos(String msg, String appId, String requestId) {
|
||||
JSONObject result = new JSONObject();
|
||||
result.put("code","400");
|
||||
result.put("msg", msg);
|
||||
result.put("appId", appId);
|
||||
result.put("requestId", requestId);
|
||||
return result;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,4 +1,6 @@
|
|||
package cn.pluss.platform.util;
|
||||
import cn.hutool.json.JSONUtil;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import org.apache.commons.lang3.RandomStringUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.slf4j.Logger;
|
||||
|
|
@ -58,50 +60,61 @@ public class TokenUtil {
|
|||
finalMap.put("TOKEN", MD5Util.md5(token + APP_SECRET).toUpperCase());
|
||||
return finalMap;
|
||||
}
|
||||
//
|
||||
public static Map<String, String> getToken(String timestamp, String requestId, String appId, String reqData)throws Exception {
|
||||
String token = "";
|
||||
String encode = "";
|
||||
System.out.println(appId);
|
||||
System.out.println(reqData);
|
||||
SortedMap<String, Object> map = new TreeMap();
|
||||
map.put("appId", appId);
|
||||
map.put("timestamp", timestamp);
|
||||
map.put("requestId", requestId);
|
||||
map.put("reqData", reqData);
|
||||
Iterator<Map.Entry<String, Object>> iterator = map.entrySet().iterator();
|
||||
while (iterator.hasNext()) {
|
||||
Map.Entry<String, Object> next = iterator.next();
|
||||
String key = next.getKey();
|
||||
Object value = next.getValue();
|
||||
token += key + value;
|
||||
encode += key + "=" + value + "&";
|
||||
}
|
||||
System.out.println(token);
|
||||
map.put("reqData",convertObject(JSONObject.parseObject(reqData,Map.class)));
|
||||
String encode= convertMap(map);
|
||||
Map<String, String> finalMap = new HashMap<>();
|
||||
finalMap.put("ENCODE",encode);
|
||||
finalMap.put("TOKEN", MD5Util.md5(token + APP_SECRET).toUpperCase());
|
||||
|
||||
String t=encode.concat(APP_SECRET);
|
||||
finalMap.put("TOKEN", MD5Util.md5(t).toUpperCase());
|
||||
return finalMap;
|
||||
}
|
||||
|
||||
|
||||
public static String convertObject(Map<String,Object> map){
|
||||
String[] sortedKeys = map.keySet().toArray(new String[]{});
|
||||
Arrays.sort(sortedKeys);// 排序请求参数
|
||||
StringBuilder s2 = new StringBuilder();
|
||||
s2.append("{");
|
||||
for (String key : sortedKeys) {
|
||||
s2.append("\"").append(key).append("\"").append(":").append("\"").append(map.get(key)).append("\"").append(",");
|
||||
}
|
||||
s2.deleteCharAt(s2.length() - 1);
|
||||
s2.append("}");
|
||||
return s2.toString();
|
||||
}
|
||||
|
||||
|
||||
public static String convertMap(Map<String,Object> map){
|
||||
String[] sortedKeys = map.keySet().toArray(new String[]{});
|
||||
Arrays.sort(sortedKeys);// 排序请求参数
|
||||
StringBuilder s2 = new StringBuilder();
|
||||
for (String key : sortedKeys) {
|
||||
s2.append(key).append(map.get(key));
|
||||
}
|
||||
return s2.toString();
|
||||
}
|
||||
|
||||
|
||||
|
||||
public static void main(String[] args) throws Exception{
|
||||
String s = String.valueOf(System.currentTimeMillis());
|
||||
System.out.println(s);
|
||||
String s1 = UUID.randomUUID().toString();
|
||||
System.out.println(s1);
|
||||
String param = "{\n" +
|
||||
" \"type\": \"4\",\n" +
|
||||
" \"consumeFee\": \"0.01\",\n" +
|
||||
" \"authCode\": \"283907976309543222\",\n" +
|
||||
" \"sn\": \"BSJQG01YJ0001\",\n" +
|
||||
" \"mercOrderNo\": \" \",\n" +
|
||||
" \"remark\": \"测试\"\n" +
|
||||
" }";
|
||||
Map<String, String> token = getToken(s, s1, APP_ID,param);
|
||||
String param = "{\"type\":\"4\",\"consumeFee\":\"0.01\",\"authCode\":\"286272579674870782\",\"sn\":\"BSJQG01YJ0001\",\"mercOrderNo\":\"\",\"remark\":\"\"}";
|
||||
Map<String, String> token = getToken(s,s1 , APP_ID,param);
|
||||
System.out.println(token);
|
||||
|
||||
System.out.println("");
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -56,30 +56,10 @@ public class MerChantOrderDTO {
|
|||
* @date: 2021/12/22 16:01
|
||||
*/
|
||||
private String deviceNo;
|
||||
/**
|
||||
* timestamp时间戳(pos机)
|
||||
*/
|
||||
private String timestamp;
|
||||
/**
|
||||
* 唯一识别码(pos机)
|
||||
*/
|
||||
private String appId;
|
||||
/**
|
||||
* 签名(pos)
|
||||
*/
|
||||
private String token;
|
||||
/**
|
||||
* 请求标识,用于唯一标识当前请求(pos,uuid)
|
||||
*/
|
||||
private String requestId;
|
||||
/**
|
||||
* 设备号
|
||||
*/
|
||||
private String sn;
|
||||
/**
|
||||
* 业务参数
|
||||
*/
|
||||
private String reqData;
|
||||
|
||||
/**
|
||||
* @description:
|
||||
|
|
|
|||
Loading…
Reference in New Issue