添加业务
This commit is contained in:
parent
c62fdd4218
commit
33d6b303b9
15
.vscode/settings.json
vendored
15
.vscode/settings.json
vendored
@ -9,5 +9,20 @@
|
||||
"maven.pomfile.autoUpdateEffectivePOM": true,
|
||||
"java.debug.settings.hotCodeReplace": "auto",
|
||||
"spring-boot.ls.java.home": "",
|
||||
"java.jdt.ls.vmargs": "-XX:+UseParallelGC -XX:GCTimeRatio=9 -XX:AdaptiveSizePolicyWeight=90 -Dsun.zip.disableMemoryMapping=true -Xmx4G -Xms4G -Xlog:disable",
|
||||
// "java.compile.nullAnalysis.mode": "automatic"
|
||||
"maven.excludedFolders": [
|
||||
"**/.vscode",
|
||||
"**/.idea",
|
||||
"**/target",
|
||||
"**/.*",
|
||||
"**/node_modules",
|
||||
"**/target",
|
||||
"**/bin",
|
||||
"**/archetype-resources"
|
||||
],
|
||||
"boot-java.rewrite.refactorings.on": true,
|
||||
"maven.executable.preferMavenWrapper": true,
|
||||
"java.import.maven.enabled": true,
|
||||
"java.dependency.packagePresentation": "hierarchical",
|
||||
}
|
8
pom.xml
8
pom.xml
@ -28,6 +28,7 @@
|
||||
<commons.io.version>2.11.0</commons.io.version>
|
||||
<commons.collections.version>3.2.2</commons.collections.version>
|
||||
<poi.version>4.1.2</poi.version>
|
||||
<httpclient.version>4.5.2</httpclient.version>
|
||||
<velocity.version>2.3</velocity.version>
|
||||
<jwt.version>0.9.1</jwt.version>
|
||||
<knife4j.version>4.5.0</knife4j.version>
|
||||
@ -136,6 +137,13 @@
|
||||
<version>${velocity.version}</version>
|
||||
</dependency>
|
||||
|
||||
<!--httpclient-->
|
||||
<dependency>
|
||||
<groupId>org.apache.httpcomponents</groupId>
|
||||
<artifactId>httpclient</artifactId>
|
||||
<version>${httpclient.version}</version>
|
||||
</dependency>
|
||||
|
||||
<!-- collections工具类 -->
|
||||
<dependency>
|
||||
<groupId>commons-collections</groupId>
|
||||
|
@ -19,9 +19,9 @@ import com.ruoyi.common.core.domain.AjaxResult;
|
||||
import com.ruoyi.common.core.page.TableDataInfo;
|
||||
import com.ruoyi.common.enums.BusinessType;
|
||||
import com.ruoyi.common.utils.poi.ExcelUtil;
|
||||
import com.ruoyi.common.utils.uuid.Seq;
|
||||
import com.ruoyi.pay.domain.PayOrder;
|
||||
import com.ruoyi.pay.service.IPayOrderService;
|
||||
import com.ruoyi.pay.utils.SnowflakeIdWorker;
|
||||
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
@ -41,9 +41,6 @@ public class PayOrderController extends BaseController
|
||||
@Autowired
|
||||
private IPayOrderService payOrderService;
|
||||
|
||||
@Autowired
|
||||
private SnowflakeIdWorker snowflakeidworker;
|
||||
|
||||
/**
|
||||
* 查询订单列表
|
||||
*/
|
||||
@ -92,7 +89,7 @@ public class PayOrderController extends BaseController
|
||||
public AjaxResult add(@RequestBody PayOrder payOrder)
|
||||
{
|
||||
payOrder.setUserId(getUserId());
|
||||
payOrder.setOrderNumber(snowflakeidworker.nextId().toString());
|
||||
payOrder.setOrderNumber(Seq.getId().toString());
|
||||
AjaxResult result = toAjax(payOrderService.insertPayOrder(payOrder));
|
||||
result.put(AjaxResult.DATA_TAG, payOrder);
|
||||
return result;
|
||||
|
@ -1,79 +0,0 @@
|
||||
package com.ruoyi.pay.utils;
|
||||
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@Component
|
||||
public class SnowflakeIdWorker {
|
||||
// 开始时间戳(2015-01-01)
|
||||
private final long twepoch = 1420041600000L;
|
||||
// 机器id所占的位数
|
||||
private final long workerIdBits = 5L;
|
||||
// 数据标识id所占的位数
|
||||
private final long datacenterIdBits = 5L;
|
||||
// 支持的最大机器id,结果是31(二进制:11111)
|
||||
private final long maxWorkerId = -1L ^ (-1L << workerIdBits);
|
||||
// 支持的最大数据标识id,结果是31(二进制:11111)
|
||||
private final long maxDatacenterId = -1L ^ (-1L << datacenterIdBits);
|
||||
// 序列在id中占的位数
|
||||
private final long sequenceBits = 12L;
|
||||
// 机器ID向左移12位
|
||||
private final long workerIdShift = sequenceBits;
|
||||
// 数据标识id向左移17位(12+5)
|
||||
private final long datacenterIdShift = sequenceBits + workerIdBits;
|
||||
// 时间戳向左移22位(5+5+12)
|
||||
private final long timestampLeftShift = sequenceBits + workerIdBits + datacenterIdBits;
|
||||
// 生成序列的掩码,这里为4095(二进制:111111111111)
|
||||
private final long sequenceMask = -1L ^ (-1L << sequenceBits);
|
||||
// 工作机器ID(0~31)
|
||||
private long workerId;
|
||||
// 数据中心ID(0~31)
|
||||
private long datacenterId;
|
||||
// 毫秒内序列(0~4095)
|
||||
private long sequence = 0L;
|
||||
// 上次生成ID的时间戳
|
||||
private long lastTimestamp = -1L;
|
||||
|
||||
public SnowflakeIdWorker() {
|
||||
this(0,0);
|
||||
}
|
||||
|
||||
public SnowflakeIdWorker(long workerId, long datacenterId) {
|
||||
if (workerId > maxWorkerId || workerId < 0) {
|
||||
throw new IllegalArgumentException(String.format("worker Id can't be greater than %d or less than 0", maxWorkerId));
|
||||
}
|
||||
if (datacenterId > maxDatacenterId || datacenterId < 0) {
|
||||
throw new IllegalArgumentException(String.format("datacenter Id can't be greater than %d or less than 0", maxDatacenterId));
|
||||
}
|
||||
this.workerId = workerId;
|
||||
this.datacenterId = datacenterId;
|
||||
}
|
||||
|
||||
public synchronized Long nextId() {
|
||||
long timestamp = timeGen();
|
||||
if (timestamp < lastTimestamp) {
|
||||
throw new RuntimeException(String.format("Clock moved backwards. Refusing to generate id for %d milliseconds", lastTimestamp - timestamp));
|
||||
}
|
||||
if (lastTimestamp == timestamp) {
|
||||
sequence = (sequence + 1) & sequenceMask;
|
||||
if (sequence == 0) {
|
||||
timestamp = tilNextMillis(lastTimestamp);
|
||||
}
|
||||
} else {
|
||||
sequence = 0L;
|
||||
}
|
||||
lastTimestamp = timestamp;
|
||||
return ((timestamp - twepoch) << timestampLeftShift) | (datacenterId << datacenterIdShift) | (workerId << workerIdShift) | sequence;
|
||||
}
|
||||
|
||||
protected Long tilNextMillis(long lastTimestamp) {
|
||||
long timestamp = timeGen();
|
||||
while (timestamp <= lastTimestamp) {
|
||||
timestamp = timeGen();
|
||||
}
|
||||
return timestamp;
|
||||
}
|
||||
|
||||
protected long timeGen() {
|
||||
return System.currentTimeMillis();
|
||||
}
|
||||
}
|
@ -2,10 +2,12 @@ package com.ruoyi.pay.sqb.controller;
|
||||
|
||||
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.RequestParam;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import com.alibaba.fastjson2.JSON;
|
||||
import com.ruoyi.common.annotation.Anonymous;
|
||||
import com.ruoyi.common.core.controller.BaseController;
|
||||
import com.ruoyi.common.core.domain.AjaxResult;
|
||||
@ -51,4 +53,14 @@ public class SQBController extends BaseController {
|
||||
return success(sqbServiceImpl.query(payOrder));
|
||||
}
|
||||
|
||||
@PostMapping("/refund")
|
||||
@Anonymous
|
||||
public AjaxResult refund(@RequestBody PayOrder payOrder) {
|
||||
String refund = sqbServiceImpl.refund(payOrder);
|
||||
if (refund == null) {
|
||||
return error("退款失败");
|
||||
}
|
||||
Object parse = JSON.parse(refund);
|
||||
return success(parse);
|
||||
}
|
||||
}
|
||||
|
@ -8,6 +8,7 @@ import org.springframework.stereotype.Service;
|
||||
|
||||
import com.alibaba.fastjson2.JSON;
|
||||
import com.alibaba.fastjson2.JSONObject;
|
||||
import com.ruoyi.common.utils.SecurityUtils;
|
||||
import com.ruoyi.common.utils.sign.Md5Utils;
|
||||
import com.ruoyi.pay.domain.PayOrder;
|
||||
import com.ruoyi.pay.sqb.constant.SqbConstant;
|
||||
@ -179,9 +180,9 @@ public class SQBServiceImpl {
|
||||
params.put("terminal_sn", sqbConstant.getTerminalSn()); // 收钱吧终端ID
|
||||
params.put("client_sn", payOrder.getOrderNumber()); // 商户系统订单号,必须在商户系统内唯一;且长度不超过32字节
|
||||
params.put("total_amount", payOrder.getTotalAmount()); // 交易总金额
|
||||
params.put("payway", payway); // 支付方式
|
||||
// params.put("payway", payway); // 支付方式
|
||||
params.put("subject", "无简介"); // 交易简介
|
||||
params.put("operator", "admin"); // 门店操作员
|
||||
params.put("operator", SecurityUtils.getUsername()); // 门店操作员
|
||||
|
||||
String sign = getSign(params.toString() + sqbConstant.getTerminalKey());
|
||||
String result = HttpUtil.httpPost(url, params.toString(), sign, sqbConstant.getTerminalSn());
|
||||
|
Loading…
Reference in New Issue
Block a user