Merge branch 'master' of gitee.com:super-shopkeeper/chaozhanggui

This commit is contained in:
zhujunshuai
2023-04-12 14:05:07 +08:00
31 changed files with 2954 additions and 64 deletions

View File

@@ -28,6 +28,7 @@ import cn.pluss.platform.userApp.UserAppService;
import cn.pluss.platform.util.StringUtil;
import cn.pluss.platform.util.TokenUtil;
import cn.pluss.platform.vo.MemberScanVO;
import cn.pluss.platform.vo.MerchantOrderPosVO;
import cn.pluss.platform.vo.MerchantOrderVO;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
@@ -49,6 +50,8 @@ import javax.validation.Valid;
import java.text.SimpleDateFormat;
import java.util.*;
import static cn.hutool.poi.excel.sax.AttributeName.s;
@Slf4j
@RestController
@RequiredArgsConstructor
@@ -436,10 +439,7 @@ public class MerchantOrderController {
@PostMapping("/posScanPay")
public Result<Object> posScanPay(@RequestBody MerChantOrderDTO merchantOrderDTO) {
//首先验签
Map<String, String> token = TokenUtil.getToken(merchantOrderDTO.getTimestamp(), merchantOrderDTO.getRequestId());
boolean sign = token.get("TOKEN").equals(merchantOrderDTO.getToken());
System.out.println(token);
MsgException.check(!sign,"签名错误");
verify(merchantOrderDTO.getTimestamp(), merchantOrderDTO.getRequestId(), merchantOrderDTO.getAppId(), merchantOrderDTO.getToken());
//通过后查询商户信息
DeviceStock deviceStock = deviceStockService.checkBind(merchantOrderDTO.getSn());
MerchantBaseInfo merchantBaseInfoById = merchantBaseInfoService.getMerchantBaseInfoById(Integer.valueOf(deviceStock.getActMercId()));
@@ -451,14 +451,19 @@ public class MerchantOrderController {
}
//进行支付操作
try {
return merchantOrderService.toActivePay(merchantOrderDTO);
Result<Object> activePay = merchantOrderService.toActivePay(merchantOrderDTO);
String result = activePay.toString();
JSONObject jsonData = JSONObject.parseObject(result);
Object orderNumber = jsonData.getJSONObject("data").get("orderNumber");
HashMap<String, Object> map = new HashMap<>();
map.put("orderNumber", orderNumber);
return ResultGenerator.genSuccessResult(map);
} catch (Exception e){
e.printStackTrace();
return ResultGenerator.genFailResult(e.getMessage());
}
}
/**
* 主扫会员支付
* @param memberScanPayDTO
@@ -775,6 +780,69 @@ public class MerchantOrderController {
}
return ResultGenerator.genSuccessResult("获取成功",order);
}
@GetMapping("/pos/tradeQuery/{orderNumber}")
@ApiOperation(value = "pos交易订单支付结果查询", notes = "交易订单支付结果查询", httpMethod = "GET")
@ApiImplicitParams({
@ApiImplicitParam(name = "orderNumber", value = "查询的orderNumber", paramType = "orderNumber", required = true, dataType = "String")})
public Result<Object> posTradeQuery(@PathVariable String orderNumber, String timestamp,
String requestId, String token, String appId) throws Exception {
//首先验签
verify(timestamp, requestId, appId, token);
// 校验参数是否完整
if (StringUtil.isEmpty(orderNumber)) {
return ResultGenerator.genFailResult("无订单号");
}
QueryWrapper<MerchantOrder> queryWrapper = new QueryWrapper<MerchantOrder>()
.eq("orderNumber",orderNumber);
MerchantOrder order = merchantOrderService.getOne(queryWrapper);
if(order == null){
return ResultGenerator.genFailResult("订单数据异常");
}
MerchantOrderPosVO orderPosVO = new MerchantOrderPosVO();
//支付成功
if("1".equals(order.getStatus())){
orderPosVO.setConsumeFee(order.getConsumeFee());
orderPosVO.setStatus(order.getStatus());
orderPosVO.setPayTypeCode(order.getPayTypeCode());
return ResultGenerator.genSuccessResult("获取成功",orderPosVO);
}
String aisleSwitch = order.getAisleSwitch();
MerchantChannelStatus channel = null;
switch (aisleSwitch){
case "2":
channel = merchantChannelStatusMapper.getByMerchantCode(order.getMerchantCode(),1);
break;
default:
channel = merchantChannelStatusMapper.getByMerchantCode(order.getMerchantCode(),Integer.valueOf(aisleSwitch));
break;
}
if(channel != null){
JSONObject result = null;
switch (channel.getChannel()){
case 1:
result = sxfPayService.tradeQuery(order,channel.getMerchantId());
break;
case 3:
result = ryxPayService.tradeQuery(order,channel.getMerchantId());
break;
case 4:
result = ysPayOldService.tradeQuery(order,channel.getMerchantId());
break;
}
if(result != null){
merchantOrderService.updateOrderStatus(result,order);
String status = result.getString("payStatus");
if("1".equals(status)){
order.setStatus("1");
}
}
orderPosVO.setConsumeFee(order.getConsumeFee());
orderPosVO.setStatus(order.getStatus());
orderPosVO.setPayTypeCode(order.getPayTypeCode());
}
return ResultGenerator.genSuccessResult("获取成功", orderPosVO);
}
@GetMapping("/closeOrder")
@ApiOperation(value = "订单关闭", notes = "订单关闭", httpMethod = "POST")
@@ -1233,4 +1301,13 @@ public class MerchantOrderController {
List<Map<String, Object>> couponList = merchantOrderService.getCouponList(orderNumber);
return ResultGenerator.genSuccessResult(couponList);
}
public void verify(String timestamp, String requestId, String appId,
String token){
//首先验证签
Map<String, String> tokenMap = TokenUtil.getToken(timestamp, requestId, appId);
boolean sign = tokenMap.get("TOKEN").equals(token);
System.out.println(token);
MsgException.check(!sign,"签名错误");
}
}

View File

@@ -2,6 +2,7 @@ package cn.pluss.platform.controller.merchant.callback;
import cn.hutool.crypto.symmetric.DES;
import cn.pluss.platform.channel.MerchantAuditService;
import cn.pluss.platform.channel.ys.YSAuditServiceV3;
import cn.pluss.platform.entity.RyxAccessModel;
import cn.pluss.platform.ryx.RyxService;
import cn.pluss.platform.ys.impl.v20210929.YsConfigV2;
@@ -15,6 +16,7 @@ import org.springframework.web.bind.annotation.*;
import java.nio.charset.StandardCharsets;
import java.util.Map;
import java.util.concurrent.ExecutorService;
/**
* @author DJH
@@ -45,6 +47,10 @@ public class AuditCallbackController {
@Autowired
private YsConfigV2 ysConfig;
@Autowired
private YSAuditServiceV3 ysAuditServiceV3;
@Autowired
private ExecutorService executorService;
@PostMapping("sxf")
// TODO 后续需要接sxf的回调
@@ -75,6 +81,30 @@ public class AuditCallbackController {
ysAuditServiceV2.merchantAuditCallback(respJson);
return "success";
}
@PostMapping("/ysV3")
public String ysAuditCallbackV3(@RequestBody JSONObject result) throws Exception {
log.info("云商服V3进件接口回调参数{}",result.toJSONString());
executorService.execute(() -> {
try {
ysAuditServiceV3.callback(result);
} catch (Exception e) {
e.printStackTrace();
}
});
return "success";
}
@PostMapping("/ysSignV3")
public String ysSignV3(@RequestBody JSONObject result) throws Exception {
log.info("云商服V3签约接口回调参数{}",result.toJSONString());
executorService.execute(() -> {
try {
ysAuditServiceV3.callback(result);
} catch (Exception e) {
e.printStackTrace();
}
});
return "success";
}
/**
* 审核不通过的解密data数据

View File

@@ -56,6 +56,7 @@ public class TokenRegistryInterceptor extends HandlerInterceptorAdapter {
limitUri.add("/api/open/login");
limitUri.add("/api/index.html");
limitUri.add("/api/merchantOrder/posScanPay");
limitUri.add("/api/merchantOrder/pos/tradeQuery");
boolean passFlag = limitUri.stream().anyMatch(s -> s.equals(requestUri) || requestUri.startsWith(s));
if (passFlag) {
return true;