update sqb pay
This commit is contained in:
parent
da51c58c19
commit
3b4c920ab7
@ -1,27 +1,31 @@
|
|||||||
package com.ruoyi.pay.controller;
|
package com.ruoyi.pay.controller;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import jakarta.servlet.http.HttpServletResponse;
|
|
||||||
import org.springframework.security.access.prepost.PreAuthorize;
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.security.access.prepost.PreAuthorize;
|
||||||
|
import org.springframework.web.bind.annotation.DeleteMapping;
|
||||||
import org.springframework.web.bind.annotation.GetMapping;
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
|
import org.springframework.web.bind.annotation.PathVariable;
|
||||||
import org.springframework.web.bind.annotation.PostMapping;
|
import org.springframework.web.bind.annotation.PostMapping;
|
||||||
import org.springframework.web.bind.annotation.PutMapping;
|
import org.springframework.web.bind.annotation.PutMapping;
|
||||||
import org.springframework.web.bind.annotation.DeleteMapping;
|
|
||||||
import org.springframework.web.bind.annotation.PathVariable;
|
|
||||||
import org.springframework.web.bind.annotation.RequestBody;
|
import org.springframework.web.bind.annotation.RequestBody;
|
||||||
import org.springframework.web.bind.annotation.RequestMapping;
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
import com.ruoyi.common.annotation.Log;
|
import com.ruoyi.common.annotation.Log;
|
||||||
import com.ruoyi.common.core.controller.BaseController;
|
import com.ruoyi.common.core.controller.BaseController;
|
||||||
import com.ruoyi.common.core.domain.AjaxResult;
|
import com.ruoyi.common.core.domain.AjaxResult;
|
||||||
|
import com.ruoyi.common.core.page.TableDataInfo;
|
||||||
import com.ruoyi.common.enums.BusinessType;
|
import com.ruoyi.common.enums.BusinessType;
|
||||||
|
import com.ruoyi.common.utils.poi.ExcelUtil;
|
||||||
import com.ruoyi.pay.domain.PayOrder;
|
import com.ruoyi.pay.domain.PayOrder;
|
||||||
import com.ruoyi.pay.service.IPayOrderService;
|
import com.ruoyi.pay.service.IPayOrderService;
|
||||||
import com.ruoyi.common.utils.poi.ExcelUtil;
|
import com.ruoyi.pay.utils.SnowflakeIdWorker;
|
||||||
import com.ruoyi.common.core.page.TableDataInfo;
|
|
||||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
|
||||||
import io.swagger.v3.oas.annotations.Operation;
|
import io.swagger.v3.oas.annotations.Operation;
|
||||||
|
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||||
|
import jakarta.servlet.http.HttpServletResponse;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 订单Controller
|
* 订单Controller
|
||||||
@ -37,6 +41,9 @@ public class PayOrderController extends BaseController
|
|||||||
@Autowired
|
@Autowired
|
||||||
private IPayOrderService payOrderService;
|
private IPayOrderService payOrderService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private SnowflakeIdWorker snowflakeidworker;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 查询订单列表
|
* 查询订单列表
|
||||||
*/
|
*/
|
||||||
@ -84,6 +91,8 @@ public class PayOrderController extends BaseController
|
|||||||
@PostMapping
|
@PostMapping
|
||||||
public AjaxResult add(@RequestBody PayOrder payOrder)
|
public AjaxResult add(@RequestBody PayOrder payOrder)
|
||||||
{
|
{
|
||||||
|
payOrder.setUserId(getUserId());
|
||||||
|
payOrder.setOrderNumber(snowflakeidworker.nextId().toString());
|
||||||
return toAjax(payOrderService.insertPayOrder(payOrder));
|
return toAjax(payOrderService.insertPayOrder(payOrder));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
package com.ruoyi.pay.mapper;
|
package com.ruoyi.pay.mapper;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import com.ruoyi.pay.domain.PayOrder;
|
import com.ruoyi.pay.domain.PayOrder;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -19,6 +20,14 @@ public interface PayOrderMapper
|
|||||||
*/
|
*/
|
||||||
public PayOrder selectPayOrderByOrderId(Long orderId);
|
public PayOrder selectPayOrderByOrderId(Long orderId);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询订单
|
||||||
|
*
|
||||||
|
* @param orderNumber 订单号
|
||||||
|
* @return 订单集合
|
||||||
|
*/
|
||||||
|
public PayOrder selectPayOrderByOrderNumber(String orderNumber);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 查询订单列表
|
* 查询订单列表
|
||||||
*
|
*
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
package com.ruoyi.pay.service;
|
package com.ruoyi.pay.service;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import com.ruoyi.pay.domain.PayOrder;
|
import com.ruoyi.pay.domain.PayOrder;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -9,8 +10,7 @@ import com.ruoyi.pay.domain.PayOrder;
|
|||||||
* @author ruoyi
|
* @author ruoyi
|
||||||
* @date 2024-02-15
|
* @date 2024-02-15
|
||||||
*/
|
*/
|
||||||
public interface IPayOrderService
|
public interface IPayOrderService {
|
||||||
{
|
|
||||||
/**
|
/**
|
||||||
* 查询订单
|
* 查询订单
|
||||||
*
|
*
|
||||||
@ -19,6 +19,14 @@ public interface IPayOrderService
|
|||||||
*/
|
*/
|
||||||
public PayOrder selectPayOrderByOrderId(Long orderId);
|
public PayOrder selectPayOrderByOrderId(Long orderId);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询订单
|
||||||
|
*
|
||||||
|
* @param orderNumber 订单号
|
||||||
|
* @return 订单集合
|
||||||
|
*/
|
||||||
|
public PayOrder selectPayOrderByOrderNumber(String orderNumber);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 查询订单列表
|
* 查询订单列表
|
||||||
*
|
*
|
||||||
|
@ -1,10 +1,12 @@
|
|||||||
package com.ruoyi.pay.service.impl;
|
package com.ruoyi.pay.service.impl;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import com.ruoyi.pay.mapper.PayOrderMapper;
|
|
||||||
import com.ruoyi.pay.domain.PayOrder;
|
import com.ruoyi.pay.domain.PayOrder;
|
||||||
|
import com.ruoyi.pay.mapper.PayOrderMapper;
|
||||||
import com.ruoyi.pay.service.IPayOrderService;
|
import com.ruoyi.pay.service.IPayOrderService;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -14,8 +16,7 @@ import com.ruoyi.pay.service.IPayOrderService;
|
|||||||
* @date 2024-02-15
|
* @date 2024-02-15
|
||||||
*/
|
*/
|
||||||
@Service
|
@Service
|
||||||
public class PayOrderServiceImpl implements IPayOrderService
|
public class PayOrderServiceImpl implements IPayOrderService {
|
||||||
{
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private PayOrderMapper payOrderMapper;
|
private PayOrderMapper payOrderMapper;
|
||||||
|
|
||||||
@ -26,11 +27,21 @@ public class PayOrderServiceImpl implements IPayOrderService
|
|||||||
* @return 订单
|
* @return 订单
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public PayOrder selectPayOrderByOrderId(Long orderId)
|
public PayOrder selectPayOrderByOrderId(Long orderId) {
|
||||||
{
|
|
||||||
return payOrderMapper.selectPayOrderByOrderId(orderId);
|
return payOrderMapper.selectPayOrderByOrderId(orderId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 查询订单
|
||||||
|
*
|
||||||
|
* @param orderNumber 订单号
|
||||||
|
* @return 订单集合
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public PayOrder selectPayOrderByOrderNumber(String orderNumber) {
|
||||||
|
return payOrderMapper.selectPayOrderByOrderNumber(orderNumber);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 查询订单列表
|
* 查询订单列表
|
||||||
*
|
*
|
||||||
@ -38,8 +49,7 @@ public class PayOrderServiceImpl implements IPayOrderService
|
|||||||
* @return 订单
|
* @return 订单
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public List<PayOrder> selectPayOrderList(PayOrder payOrder)
|
public List<PayOrder> selectPayOrderList(PayOrder payOrder) {
|
||||||
{
|
|
||||||
return payOrderMapper.selectPayOrderList(payOrder);
|
return payOrderMapper.selectPayOrderList(payOrder);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -50,8 +60,7 @@ public class PayOrderServiceImpl implements IPayOrderService
|
|||||||
* @return 结果
|
* @return 结果
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public int insertPayOrder(PayOrder payOrder)
|
public int insertPayOrder(PayOrder payOrder) {
|
||||||
{
|
|
||||||
return payOrderMapper.insertPayOrder(payOrder);
|
return payOrderMapper.insertPayOrder(payOrder);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -62,8 +71,7 @@ public class PayOrderServiceImpl implements IPayOrderService
|
|||||||
* @return 结果
|
* @return 结果
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public int updatePayOrder(PayOrder payOrder)
|
public int updatePayOrder(PayOrder payOrder) {
|
||||||
{
|
|
||||||
return payOrderMapper.updatePayOrder(payOrder);
|
return payOrderMapper.updatePayOrder(payOrder);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -74,8 +82,7 @@ public class PayOrderServiceImpl implements IPayOrderService
|
|||||||
* @return 结果
|
* @return 结果
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public int deletePayOrderByOrderIds(Long[] orderIds)
|
public int deletePayOrderByOrderIds(Long[] orderIds) {
|
||||||
{
|
|
||||||
return payOrderMapper.deletePayOrderByOrderIds(orderIds);
|
return payOrderMapper.deletePayOrderByOrderIds(orderIds);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -86,8 +93,7 @@ public class PayOrderServiceImpl implements IPayOrderService
|
|||||||
* @return 结果
|
* @return 结果
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public int deletePayOrderByOrderId(Long orderId)
|
public int deletePayOrderByOrderId(Long orderId) {
|
||||||
{
|
|
||||||
return payOrderMapper.deletePayOrderByOrderId(orderId);
|
return payOrderMapper.deletePayOrderByOrderId(orderId);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,79 @@
|
|||||||
|
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();
|
||||||
|
}
|
||||||
|
}
|
@ -1,88 +1,101 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8" ?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<!DOCTYPE mapper
|
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||||
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
|
||||||
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
|
||||||
<mapper namespace="com.ruoyi.pay.mapper.PayOrderMapper">
|
<mapper namespace="com.ruoyi.pay.mapper.PayOrderMapper">
|
||||||
|
|
||||||
<resultMap type="PayOrder" id="PayOrderResult">
|
<resultMap type="PayOrder" id="PayOrderResult">
|
||||||
<result property="orderId" column="order_id" />
|
<result property="orderId" column="order_id" />
|
||||||
<result property="userId" column="user_id" />
|
<result property="userId" column="user_id" />
|
||||||
<result property="orderNumber" column="order_number" />
|
<result property="orderNumber" column="order_number" />
|
||||||
<result property="orderStatus" column="order_status" />
|
<result property="orderStatus" column="order_status" />
|
||||||
<result property="totalAmount" column="total_amount" />
|
<result property="totalAmount" column="total_amount" />
|
||||||
<result property="orderContent" column="order_content" />
|
<result property="orderContent" column="order_content" />
|
||||||
<result property="orderRemark" column="order_remark" />
|
<result property="orderRemark" column="order_remark" />
|
||||||
<result property="orderMessage" column="order_message" />
|
<result property="orderMessage" column="order_message" />
|
||||||
</resultMap>
|
</resultMap>
|
||||||
|
|
||||||
<sql id="selectPayOrderVo">
|
<sql id="selectPayOrderVo"> select order_id, user_id, order_number, order_status, total_amount,
|
||||||
select order_id, user_id, order_number, order_status, total_amount, order_content, order_remark, order_message from pay_order
|
order_content, order_remark, order_message from pay_order </sql>
|
||||||
</sql>
|
|
||||||
|
|
||||||
<select id="selectPayOrderList" parameterType="PayOrder" resultMap="PayOrderResult">
|
<select id="selectPayOrderList" parameterType="PayOrder" resultMap="PayOrderResult">
|
||||||
<include refid="selectPayOrderVo"/>
|
<include refid="selectPayOrderVo" />
|
||||||
<where>
|
<where>
|
||||||
<if test="userId != null "> and user_id = #{userId}</if>
|
<if test="userId != null "> and user_id = #{userId}</if>
|
||||||
<if test="orderNumber != null and orderNumber != ''"> and order_number = #{orderNumber}</if>
|
<if
|
||||||
<if test="orderStatus != null and orderStatus != ''"> and order_status = #{orderStatus}</if>
|
test="orderNumber != null and orderNumber != ''"> and order_number = #{orderNumber}</if>
|
||||||
<if test="totalAmount != null and totalAmount != ''"> and total_amount = #{totalAmount}</if>
|
<if
|
||||||
<if test="orderContent != null and orderContent != ''"> and order_content = #{orderContent}</if>
|
test="orderStatus != null and orderStatus != ''"> and order_status = #{orderStatus}</if>
|
||||||
<if test="orderRemark != null and orderRemark != ''"> and order_remark = #{orderRemark}</if>
|
<if
|
||||||
<if test="orderMessage != null and orderMessage != ''"> and order_message = #{orderMessage}</if>
|
test="totalAmount != null and totalAmount != ''"> and total_amount = #{totalAmount}</if>
|
||||||
|
<if
|
||||||
|
test="orderContent != null and orderContent != ''"> and order_content =
|
||||||
|
#{orderContent}</if>
|
||||||
|
<if test="orderRemark != null and orderRemark != ''"> and order_remark
|
||||||
|
= #{orderRemark}</if>
|
||||||
|
<if test="orderMessage != null and orderMessage != ''"> and
|
||||||
|
order_message = #{orderMessage}</if>
|
||||||
</where>
|
</where>
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
<select id="selectPayOrderByOrderId" parameterType="Long" resultMap="PayOrderResult">
|
<select id="selectPayOrderByOrderId" parameterType="Long" resultMap="PayOrderResult">
|
||||||
<include refid="selectPayOrderVo"/>
|
<include refid="selectPayOrderVo" /> where pay_order.order_id = #{orderId} </select>
|
||||||
where pay_order.order_id = #{orderId}
|
|
||||||
</select>
|
<select id="selectPayOrderByOrderNumber" parameterType="String" resultMap="PayOrderResult">
|
||||||
|
<include refid="selectPayOrderVo" /> where pay_order.order_number = #{orderNumber} </select>
|
||||||
<insert id="insertPayOrder" parameterType="PayOrder">
|
|
||||||
insert into pay_order
|
<insert id="insertPayOrder" parameterType="PayOrder"> insert into pay_order <trim prefix="("
|
||||||
<trim prefix="(" suffix=")" suffixOverrides=",">
|
suffix=")" suffixOverrides=",">
|
||||||
<if test="orderId != null">order_id,</if>
|
<if test="orderId != null">order_id,</if>
|
||||||
<if test="userId != null">user_id,</if>
|
<if test="userId != null">user_id,</if>
|
||||||
<if test="orderNumber != null">order_number,</if>
|
<if
|
||||||
<if test="orderStatus != null">order_status,</if>
|
test="orderNumber != null">order_number,</if>
|
||||||
|
<if test="orderStatus != null">
|
||||||
|
order_status,</if>
|
||||||
<if test="totalAmount != null">total_amount,</if>
|
<if test="totalAmount != null">total_amount,</if>
|
||||||
<if test="orderContent != null">order_content,</if>
|
<if
|
||||||
<if test="orderRemark != null">order_remark,</if>
|
test="orderContent != null">order_content,</if>
|
||||||
|
<if test="orderRemark != null">
|
||||||
|
order_remark,</if>
|
||||||
<if test="orderMessage != null">order_message,</if>
|
<if test="orderMessage != null">order_message,</if>
|
||||||
</trim>
|
</trim>
|
||||||
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
<trim
|
||||||
|
prefix="values (" suffix=")" suffixOverrides=",">
|
||||||
<if test="orderId != null">#{orderId},</if>
|
<if test="orderId != null">#{orderId},</if>
|
||||||
<if test="userId != null">#{userId},</if>
|
<if test="userId != null">#{userId},</if>
|
||||||
<if test="orderNumber != null">#{orderNumber},</if>
|
<if
|
||||||
<if test="orderStatus != null">#{orderStatus},</if>
|
test="orderNumber != null">#{orderNumber},</if>
|
||||||
|
<if test="orderStatus != null">
|
||||||
|
#{orderStatus},</if>
|
||||||
<if test="totalAmount != null">#{totalAmount},</if>
|
<if test="totalAmount != null">#{totalAmount},</if>
|
||||||
<if test="orderContent != null">#{orderContent},</if>
|
<if
|
||||||
<if test="orderRemark != null">#{orderRemark},</if>
|
test="orderContent != null">#{orderContent},</if>
|
||||||
|
<if test="orderRemark != null">
|
||||||
|
#{orderRemark},</if>
|
||||||
<if test="orderMessage != null">#{orderMessage},</if>
|
<if test="orderMessage != null">#{orderMessage},</if>
|
||||||
</trim>
|
</trim>
|
||||||
</insert>
|
</insert>
|
||||||
|
|
||||||
<update id="updatePayOrder" parameterType="PayOrder">
|
<update id="updatePayOrder" parameterType="PayOrder"> update pay_order <trim prefix="SET"
|
||||||
update pay_order
|
suffixOverrides=",">
|
||||||
<trim prefix="SET" suffixOverrides=",">
|
|
||||||
<if test="userId != null">user_id = #{userId},</if>
|
<if test="userId != null">user_id = #{userId},</if>
|
||||||
<if test="orderNumber != null">order_number = #{orderNumber},</if>
|
<if test="orderNumber != null">order_number
|
||||||
|
= #{orderNumber},</if>
|
||||||
<if test="orderStatus != null">order_status = #{orderStatus},</if>
|
<if test="orderStatus != null">order_status = #{orderStatus},</if>
|
||||||
<if test="totalAmount != null">total_amount = #{totalAmount},</if>
|
<if
|
||||||
<if test="orderContent != null">order_content = #{orderContent},</if>
|
test="totalAmount != null">total_amount = #{totalAmount},</if>
|
||||||
<if test="orderRemark != null">order_remark = #{orderRemark},</if>
|
<if
|
||||||
<if test="orderMessage != null">order_message = #{orderMessage},</if>
|
test="orderContent != null">order_content = #{orderContent},</if>
|
||||||
|
<if
|
||||||
|
test="orderRemark != null">order_remark = #{orderRemark},</if>
|
||||||
|
<if
|
||||||
|
test="orderMessage != null">order_message = #{orderMessage},</if>
|
||||||
</trim>
|
</trim>
|
||||||
where pay_order.order_id = #{orderId}
|
where pay_order.order_id = #{orderId} </update>
|
||||||
</update>
|
|
||||||
|
|
||||||
<delete id="deletePayOrderByOrderId" parameterType="Long">
|
<delete id="deletePayOrderByOrderId" parameterType="Long"> delete from pay_order where order_id
|
||||||
delete from pay_order where order_id = #{orderId}
|
= #{orderId} </delete>
|
||||||
</delete>
|
|
||||||
|
|
||||||
<delete id="deletePayOrderByOrderIds" parameterType="String">
|
<delete id="deletePayOrderByOrderIds" parameterType="String"> delete from pay_order where
|
||||||
delete from pay_order where order_id in
|
order_id in <foreach item="orderId" collection="array" open="(" separator="," close=")">
|
||||||
<foreach item="orderId" collection="array" open="(" separator="," close=")">
|
#{orderId} </foreach>
|
||||||
#{orderId}
|
|
||||||
</foreach>
|
|
||||||
</delete>
|
</delete>
|
||||||
</mapper>
|
</mapper>
|
@ -23,6 +23,12 @@
|
|||||||
<artifactId>ruoyi-common</artifactId>
|
<artifactId>ruoyi-common</artifactId>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
|
<!-- 支付基础模块-->
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.ruoyi</groupId>
|
||||||
|
<artifactId>ruoyi-pay-common</artifactId>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
<!--httpclient-->
|
<!--httpclient-->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.apache.httpcomponents</groupId>
|
<groupId>org.apache.httpcomponents</groupId>
|
||||||
|
@ -0,0 +1,33 @@
|
|||||||
|
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.RequestMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RequestParam;
|
||||||
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
|
|
||||||
|
import com.ruoyi.common.annotation.Anonymous;
|
||||||
|
import com.ruoyi.common.core.controller.BaseController;
|
||||||
|
import com.ruoyi.common.core.domain.AjaxResult;
|
||||||
|
import com.ruoyi.pay.domain.PayOrder;
|
||||||
|
import com.ruoyi.pay.service.IPayOrderService;
|
||||||
|
import com.ruoyi.pay.sqb.service.Impl.SQBServiceImpl;
|
||||||
|
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("/pay/sql")
|
||||||
|
public class SQBController extends BaseController {
|
||||||
|
@Autowired
|
||||||
|
private SQBServiceImpl sqbServiceImpl;
|
||||||
|
@Autowired
|
||||||
|
private IPayOrderService payOrderServicer;
|
||||||
|
|
||||||
|
@PostMapping("/payUrl")
|
||||||
|
@Anonymous
|
||||||
|
public AjaxResult postMethodName(@RequestParam("id") String orderNumber) throws Exception {
|
||||||
|
PayOrder payOrder = payOrderServicer.selectPayOrderByOrderNumber(orderNumber);
|
||||||
|
String url = sqbServiceImpl.payUrl(payOrder);
|
||||||
|
AjaxResult ajaxResult = new AjaxResult(200,url,"操作成功");
|
||||||
|
return ajaxResult;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -9,6 +9,7 @@ import org.springframework.stereotype.Service;
|
|||||||
import com.alibaba.fastjson2.JSON;
|
import com.alibaba.fastjson2.JSON;
|
||||||
import com.alibaba.fastjson2.JSONObject;
|
import com.alibaba.fastjson2.JSONObject;
|
||||||
import com.ruoyi.common.utils.sign.Md5Utils;
|
import com.ruoyi.common.utils.sign.Md5Utils;
|
||||||
|
import com.ruoyi.pay.domain.PayOrder;
|
||||||
import com.ruoyi.pay.sqb.constant.SqbConstant;
|
import com.ruoyi.pay.sqb.constant.SqbConstant;
|
||||||
import com.ruoyi.pay.sqb.utils.HttpUtil;
|
import com.ruoyi.pay.sqb.utils.HttpUtil;
|
||||||
|
|
||||||
@ -99,8 +100,7 @@ public class SQBServiceImpl {
|
|||||||
*
|
*
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public String refund(String clientSn, String total, String payway, String subject, String operator,
|
public String refund(String clientSn, String total, String payway, String subject, String operator) {
|
||||||
String terminalSn) {
|
|
||||||
String url = sqbConstant.getApiDomain() + "/upay/v2/refund";
|
String url = sqbConstant.getApiDomain() + "/upay/v2/refund";
|
||||||
JSONObject params = new JSONObject();
|
JSONObject params = new JSONObject();
|
||||||
try {
|
try {
|
||||||
@ -125,8 +125,7 @@ public class SQBServiceImpl {
|
|||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public String query(String clientSn, String total, String payway, String subject, String operator,
|
public String query(String clientSn, String total, String payway, String subject, String operator) {
|
||||||
String terminalSn) {
|
|
||||||
String url = sqbConstant.getApiDomain() + "/upay/v2/query";
|
String url = sqbConstant.getApiDomain() + "/upay/v2/query";
|
||||||
JSONObject params = new JSONObject();
|
JSONObject params = new JSONObject();
|
||||||
try {
|
try {
|
||||||
@ -146,22 +145,24 @@ public class SQBServiceImpl {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public String payUrl(String clientSn, String total, String payway, String subject, String operator,
|
public String payUrl(PayOrder payOrder) throws UnsupportedEncodingException {
|
||||||
String terminalSn) throws UnsupportedEncodingException {
|
if(payOrder.getRemark() == null){
|
||||||
|
payOrder.setRemark("支付");
|
||||||
|
}
|
||||||
String param = "" +
|
String param = "" +
|
||||||
"client_sn=" + clientSn +
|
"client_sn=" + payOrder.getOrderNumber() +
|
||||||
"&operator=" + operator +
|
"&operator=" + "admin" +
|
||||||
"&return_url=" + "https://www.shouqianba.com/" +
|
"&return_url=" + "https://www.shouqianba.com/" +
|
||||||
"&subject=" + subject +
|
"&subject=" + payOrder.getRemark() +
|
||||||
"&terminal_sn=" + terminalSn +
|
"&terminal_sn=" + sqbConstant.getTerminalSn() +
|
||||||
"&total_amount=" + total;
|
"&total_amount=" + payOrder.getTotalAmount();
|
||||||
String urlParam = "" +
|
String urlParam = "" +
|
||||||
"client_sn=" + clientSn +
|
"client_sn=" + payOrder.getOrderNumber() +
|
||||||
"&operator=" + URLEncoder.encode(operator, "UTF-8") +
|
"&operator=" + URLEncoder.encode("admin", "UTF-8") +
|
||||||
"&return_url=" + "https://www.shouqianba.com/" +
|
"&return_url=" + "https://www.shouqianba.com/" +
|
||||||
"&subject=" + URLEncoder.encode(subject, "UTF-8") +
|
"&subject=" + URLEncoder.encode(payOrder.getRemark(), "UTF-8") +
|
||||||
"&terminal_sn=" + terminalSn +
|
"&terminal_sn=" + sqbConstant.getTerminalSn() +
|
||||||
"&total_amount=" + total;
|
"&total_amount=" + payOrder.getTotalAmount();
|
||||||
String sign = getSign(param + "&key=" + sqbConstant.getTerminalKey());
|
String sign = getSign(param + "&key=" + sqbConstant.getTerminalKey());
|
||||||
return "https://qr.shouqianba.com/gateway?" + urlParam + "&sign=" + sign.toUpperCase();
|
return "https://qr.shouqianba.com/gateway?" + urlParam + "&sign=" + sign.toUpperCase();
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user