API订单建表
This commit is contained in:
parent
ce6f30a195
commit
999f164830
|
@ -0,0 +1,79 @@
|
|||
package com.ruoyi.ss.apiBill.domain;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.Date;
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import org.apache.commons.lang3.builder.ToStringBuilder;
|
||||
import org.apache.commons.lang3.builder.ToStringStyle;
|
||||
import com.ruoyi.common.annotation.Excel;
|
||||
import com.ruoyi.common.core.domain.BaseEntity;
|
||||
|
||||
/**
|
||||
* API收费订单对象 ss_api_bill
|
||||
*
|
||||
* @author ruoyi
|
||||
* @date 2024-08-09
|
||||
*/
|
||||
@Data
|
||||
public class ApiBill extends BaseEntity
|
||||
{
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private Long billId;
|
||||
|
||||
@Excel(name = "订单编号")
|
||||
@ApiModelProperty("订单编号")
|
||||
private String billNo;
|
||||
|
||||
@Excel(name = "用户ID")
|
||||
@ApiModelProperty("用户ID")
|
||||
private Long userId;
|
||||
|
||||
@Excel(name = "秘钥ID")
|
||||
@ApiModelProperty("秘钥ID")
|
||||
private Long accessId;
|
||||
|
||||
@Excel(name = "API收费标准ID")
|
||||
@ApiModelProperty("API收费标准ID")
|
||||
private Long apiId;
|
||||
|
||||
@Excel(name = "订单金额", readConverterExp = "元=")
|
||||
@ApiModelProperty("订单金额")
|
||||
private BigDecimal amount;
|
||||
|
||||
@Excel(name = "状态")
|
||||
@ApiModelProperty("状态")
|
||||
private String status;
|
||||
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
@Excel(name = "订单超时时间", width = 30, dateFormat = "yyyy-MM-dd HH:mm:ss")
|
||||
@ApiModelProperty("订单超时时间")
|
||||
private Date expireTime;
|
||||
|
||||
@Excel(name = "支付成功的支付订单ID")
|
||||
@ApiModelProperty("支付成功的支付订单ID")
|
||||
private Long payId;
|
||||
|
||||
@Excel(name = "API收费标准类型")
|
||||
@ApiModelProperty("API收费标准类型")
|
||||
private String apiType;
|
||||
|
||||
@Excel(name = "API收费标准")
|
||||
@ApiModelProperty("API收费标准")
|
||||
private Long apiNum;
|
||||
|
||||
@Excel(name = "API收费标准名称")
|
||||
@ApiModelProperty("API收费标准名称")
|
||||
private String apiName;
|
||||
|
||||
@Excel(name = "API收费标准描述")
|
||||
@ApiModelProperty("API收费标准描述")
|
||||
private String apiDescription;
|
||||
|
||||
@Excel(name = "API收费标准单价")
|
||||
@ApiModelProperty("API收费标准单价")
|
||||
private BigDecimal apiPrice;
|
||||
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
package com.ruoyi.ss.apiBill.domain;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* @author wjh
|
||||
* 2024/8/9
|
||||
*/
|
||||
@Data
|
||||
public class ApiBillQuery extends ApiBillVO{
|
||||
}
|
|
@ -0,0 +1,11 @@
|
|||
package com.ruoyi.ss.apiBill.domain;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* @author wjh
|
||||
* 2024/8/9
|
||||
*/
|
||||
@Data
|
||||
public class ApiBillVO extends ApiBill{
|
||||
}
|
|
@ -0,0 +1,64 @@
|
|||
package com.ruoyi.ss.apiBill.mapper;
|
||||
|
||||
import java.util.List;
|
||||
import com.ruoyi.ss.apiBill.domain.ApiBill;
|
||||
import com.ruoyi.ss.apiBill.domain.ApiBillVO;
|
||||
import com.ruoyi.ss.apiBill.domain.ApiBillQuery;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
/**
|
||||
* API收费订单Mapper接口
|
||||
*
|
||||
* @author ruoyi
|
||||
* @date 2024-08-09
|
||||
*/
|
||||
public interface ApiBillMapper
|
||||
{
|
||||
/**
|
||||
* 查询API收费订单
|
||||
*
|
||||
* @param billId API收费订单主键
|
||||
* @return API收费订单
|
||||
*/
|
||||
public ApiBillVO selectApiBillByBillId(Long billId);
|
||||
|
||||
/**
|
||||
* 查询API收费订单列表
|
||||
*
|
||||
* @param query API收费订单
|
||||
* @return API收费订单集合
|
||||
*/
|
||||
public List<ApiBillVO> selectApiBillList(@Param("query")ApiBillQuery query);
|
||||
|
||||
/**
|
||||
* 新增API收费订单
|
||||
*
|
||||
* @param apiBill API收费订单
|
||||
* @return 结果
|
||||
*/
|
||||
public int insertApiBill(ApiBill apiBill);
|
||||
|
||||
/**
|
||||
* 修改API收费订单
|
||||
*
|
||||
* @param apiBill API收费订单
|
||||
* @return 结果
|
||||
*/
|
||||
public int updateApiBill(@Param("data") ApiBill apiBill);
|
||||
|
||||
/**
|
||||
* 删除API收费订单
|
||||
*
|
||||
* @param billId API收费订单主键
|
||||
* @return 结果
|
||||
*/
|
||||
public int deleteApiBillByBillId(Long billId);
|
||||
|
||||
/**
|
||||
* 批量删除API收费订单
|
||||
*
|
||||
* @param billIds 需要删除的数据主键集合
|
||||
* @return 结果
|
||||
*/
|
||||
public int deleteApiBillByBillIds(Long[] billIds);
|
||||
}
|
|
@ -0,0 +1,121 @@
|
|||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<!DOCTYPE mapper
|
||||
PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.ruoyi.ss.apiBill.mapper.ApiBillMapper">
|
||||
|
||||
<resultMap type="ApiBillVO" id="ApiBillResult" autoMapping="true"/>
|
||||
|
||||
<sql id="selectApiBillVo">
|
||||
select
|
||||
sab.bill_id,
|
||||
sab.bill_no,
|
||||
sab.user_id,
|
||||
sab.access_id,
|
||||
sab.api_id,
|
||||
sab.amount,
|
||||
sab.status,
|
||||
sab.expire_time,
|
||||
sab.pay_id,
|
||||
sab.api_type,
|
||||
sab.api_num,
|
||||
sab.api_name,
|
||||
sab.api_description,
|
||||
sab.api_price,
|
||||
sab.create_time
|
||||
from ss_api_bill sab
|
||||
</sql>
|
||||
|
||||
<sql id="searchCondition">
|
||||
<if test="query.billId != null "> and sab.bill_id = #{query.billId}</if>
|
||||
<if test="query.billNo != null and query.billNo != ''"> and sab.bill_no like concat('%', #{query.billNo}, '%')</if>
|
||||
<if test="query.userId != null "> and sab.user_id = #{query.userId}</if>
|
||||
<if test="query.accessId != null "> and sab.access_id = #{query.accessId}</if>
|
||||
<if test="query.apiId != null "> and sab.api_id = #{query.apiId}</if>
|
||||
<if test="query.status != null and query.status != ''"> and sab.status = #{query.status}</if>
|
||||
<if test="query.payId != null "> and sab.pay_id = #{query.payId}</if>
|
||||
<if test="query.apiType != null and query.apiType != ''"> and sab.api_type = #{query.apiType}</if>
|
||||
<if test="query.apiName != null and query.apiName != ''"> and sab.api_name like concat('%', #{query.apiName}, '%')</if>
|
||||
<if test="query.apiDescription != null and query.apiDescription != ''"> and sab.api_description like concat('%', #{query.apiDescription}, '%')</if>
|
||||
</sql>
|
||||
|
||||
<select id="selectApiBillList" parameterType="ApiBillQuery" resultMap="ApiBillResult">
|
||||
<include refid="selectApiBillVo"/>
|
||||
<where>
|
||||
<include refid="searchCondition"/>
|
||||
</where>
|
||||
</select>
|
||||
|
||||
<select id="selectApiBillByBillId" parameterType="Long" resultMap="ApiBillResult">
|
||||
<include refid="selectApiBillVo"/>
|
||||
where sab.bill_id = #{billId}
|
||||
</select>
|
||||
|
||||
<insert id="insertApiBill" parameterType="ApiBill" useGeneratedKeys="true" keyProperty="billId">
|
||||
insert into ss_api_bill
|
||||
<trim prefix="(" suffix=")" suffixOverrides=",">
|
||||
<if test="billNo != null and billNo != ''">bill_no,</if>
|
||||
<if test="userId != null">user_id,</if>
|
||||
<if test="accessId != null">access_id,</if>
|
||||
<if test="apiId != null">api_id,</if>
|
||||
<if test="amount != null">amount,</if>
|
||||
<if test="status != null and status != ''">status,</if>
|
||||
<if test="expireTime != null">expire_time,</if>
|
||||
<if test="payId != null">pay_id,</if>
|
||||
<if test="apiType != null and apiType != ''">api_type,</if>
|
||||
<if test="apiNum != null">api_num,</if>
|
||||
<if test="apiName != null and apiName != ''">api_name,</if>
|
||||
<if test="apiDescription != null and apiDescription != ''">api_description,</if>
|
||||
<if test="apiPrice != null">api_price,</if>
|
||||
<if test="createTime != null">create_time,</if>
|
||||
</trim>
|
||||
<trim prefix="values (" suffix=")" suffixOverrides=",">
|
||||
<if test="billNo != null and billNo != ''">#{billNo},</if>
|
||||
<if test="userId != null">#{userId},</if>
|
||||
<if test="accessId != null">#{accessId},</if>
|
||||
<if test="apiId != null">#{apiId},</if>
|
||||
<if test="amount != null">#{amount},</if>
|
||||
<if test="status != null and status != ''">#{status},</if>
|
||||
<if test="expireTime != null">#{expireTime},</if>
|
||||
<if test="payId != null">#{payId},</if>
|
||||
<if test="apiType != null and apiType != ''">#{apiType},</if>
|
||||
<if test="apiNum != null">#{apiNum},</if>
|
||||
<if test="apiName != null and apiName != ''">#{apiName},</if>
|
||||
<if test="apiDescription != null and apiDescription != ''">#{apiDescription},</if>
|
||||
<if test="apiPrice != null">#{apiPrice},</if>
|
||||
<if test="createTime != null">#{createTime},</if>
|
||||
</trim>
|
||||
</insert>
|
||||
|
||||
<update id="updateApiBill" parameterType="ApiBill">
|
||||
update ss_api_bill
|
||||
<trim prefix="SET" suffixOverrides=",">
|
||||
<if test="data.billNo != null and data.billNo != ''">bill_no = #{data.billNo},</if>
|
||||
<if test="data.userId != null">user_id = #{data.userId},</if>
|
||||
<if test="data.accessId != null">access_id = #{data.accessId},</if>
|
||||
<if test="data.apiId != null">api_id = #{data.apiId},</if>
|
||||
<if test="data.amount != null">amount = #{data.amount},</if>
|
||||
<if test="data.status != null and data.status != ''">status = #{data.status},</if>
|
||||
<if test="data.expireTime != null">expire_time = #{data.expireTime},</if>
|
||||
<if test="data.payId != null">pay_id = #{data.payId},</if>
|
||||
<if test="data.apiType != null and data.apiType != ''">api_type = #{data.apiType},</if>
|
||||
<if test="data.apiNum != null">api_num = #{data.apiNum},</if>
|
||||
<if test="data.apiName != null and data.apiName != ''">api_name = #{data.apiName},</if>
|
||||
<if test="data.apiDescription != null and data.apiDescription != ''">api_description = #{data.apiDescription},</if>
|
||||
<if test="data.apiPrice != null">api_price = #{data.apiPrice},</if>
|
||||
<if test="data.createTime != null">create_time = #{data.createTime},</if>
|
||||
</trim>
|
||||
where bill_id = #{data.billId}
|
||||
</update>
|
||||
|
||||
<delete id="deleteApiBillByBillId" parameterType="Long">
|
||||
delete from ss_api_bill where bill_id = #{billId}
|
||||
</delete>
|
||||
|
||||
<delete id="deleteApiBillByBillIds" parameterType="String">
|
||||
delete from ss_api_bill where bill_id in
|
||||
<foreach item="billId" collection="array" open="(" separator="," close=")">
|
||||
#{billId}
|
||||
</foreach>
|
||||
</delete>
|
||||
</mapper>
|
|
@ -0,0 +1,63 @@
|
|||
package com.ruoyi.ss.apiBill.service;
|
||||
|
||||
import java.util.List;
|
||||
import com.ruoyi.ss.apiBill.domain.ApiBill;
|
||||
import com.ruoyi.ss.apiBill.domain.ApiBillVO;
|
||||
import com.ruoyi.ss.apiBill.domain.ApiBillQuery;
|
||||
|
||||
/**
|
||||
* API收费订单Service接口
|
||||
*
|
||||
* @author ruoyi
|
||||
* @date 2024-08-09
|
||||
*/
|
||||
public interface ApiBillService
|
||||
{
|
||||
/**
|
||||
* 查询API收费订单
|
||||
*
|
||||
* @param billId API收费订单主键
|
||||
* @return API收费订单
|
||||
*/
|
||||
public ApiBillVO selectApiBillByBillId(Long billId);
|
||||
|
||||
/**
|
||||
* 查询API收费订单列表
|
||||
*
|
||||
* @param apiBill API收费订单
|
||||
* @return API收费订单集合
|
||||
*/
|
||||
public List<ApiBillVO> selectApiBillList(ApiBillQuery apiBill);
|
||||
|
||||
/**
|
||||
* 新增API收费订单
|
||||
*
|
||||
* @param apiBill API收费订单
|
||||
* @return 结果
|
||||
*/
|
||||
public int insertApiBill(ApiBill apiBill);
|
||||
|
||||
/**
|
||||
* 修改API收费订单
|
||||
*
|
||||
* @param apiBill API收费订单
|
||||
* @return 结果
|
||||
*/
|
||||
public int updateApiBill(ApiBill apiBill);
|
||||
|
||||
/**
|
||||
* 批量删除API收费订单
|
||||
*
|
||||
* @param billIds 需要删除的API收费订单主键集合
|
||||
* @return 结果
|
||||
*/
|
||||
public int deleteApiBillByBillIds(Long[] billIds);
|
||||
|
||||
/**
|
||||
* 删除API收费订单信息
|
||||
*
|
||||
* @param billId API收费订单主键
|
||||
* @return 结果
|
||||
*/
|
||||
public int deleteApiBillByBillId(Long billId);
|
||||
}
|
|
@ -0,0 +1,97 @@
|
|||
package com.ruoyi.ss.apiBill.service.impl;
|
||||
|
||||
import java.util.List;
|
||||
import com.ruoyi.common.utils.DateUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import com.ruoyi.ss.apiBill.mapper.ApiBillMapper;
|
||||
import com.ruoyi.ss.apiBill.domain.ApiBill;
|
||||
import com.ruoyi.ss.apiBill.domain.ApiBillVO;
|
||||
import com.ruoyi.ss.apiBill.domain.ApiBillQuery;
|
||||
import com.ruoyi.ss.apiBill.service.ApiBillService;
|
||||
|
||||
/**
|
||||
* API收费订单Service业务层处理
|
||||
*
|
||||
* @author ruoyi
|
||||
* @date 2024-08-09
|
||||
*/
|
||||
@Service
|
||||
public class ApiBillServiceImpl implements ApiBillService
|
||||
{
|
||||
@Autowired
|
||||
private ApiBillMapper apiBillMapper;
|
||||
|
||||
/**
|
||||
* 查询API收费订单
|
||||
*
|
||||
* @param billId API收费订单主键
|
||||
* @return API收费订单
|
||||
*/
|
||||
@Override
|
||||
public ApiBillVO selectApiBillByBillId(Long billId)
|
||||
{
|
||||
return apiBillMapper.selectApiBillByBillId(billId);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询API收费订单列表
|
||||
*
|
||||
* @param apiBill API收费订单
|
||||
* @return API收费订单
|
||||
*/
|
||||
@Override
|
||||
public List<ApiBillVO> selectApiBillList(ApiBillQuery apiBill)
|
||||
{
|
||||
return apiBillMapper.selectApiBillList(apiBill);
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增API收费订单
|
||||
*
|
||||
* @param apiBill API收费订单
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int insertApiBill(ApiBill apiBill)
|
||||
{
|
||||
apiBill.setCreateTime(DateUtils.getNowDate());
|
||||
return apiBillMapper.insertApiBill(apiBill);
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改API收费订单
|
||||
*
|
||||
* @param apiBill API收费订单
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int updateApiBill(ApiBill apiBill)
|
||||
{
|
||||
return apiBillMapper.updateApiBill(apiBill);
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量删除API收费订单
|
||||
*
|
||||
* @param billIds 需要删除的API收费订单主键
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int deleteApiBillByBillIds(Long[] billIds)
|
||||
{
|
||||
return apiBillMapper.deleteApiBillByBillIds(billIds);
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除API收费订单信息
|
||||
*
|
||||
* @param billId API收费订单主键
|
||||
* @return 结果
|
||||
*/
|
||||
@Override
|
||||
public int deleteApiBillByBillId(Long billId)
|
||||
{
|
||||
return apiBillMapper.deleteApiBillByBillId(billId);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,15 @@
|
|||
package com.ruoyi.ss.payBill.service;
|
||||
|
||||
import com.ruoyi.ss.payBill.domain.PayBill;
|
||||
import com.ruoyi.ss.timeBill.domain.TimeBill;
|
||||
|
||||
/**
|
||||
* @author wjh
|
||||
* 2024/8/9
|
||||
*/
|
||||
public interface PayBillConverter {
|
||||
|
||||
|
||||
PayBill toPo(TimeBill timeBill, Long channelId);
|
||||
|
||||
}
|
|
@ -5,8 +5,6 @@ import java.util.List;
|
|||
import com.ruoyi.ss.payBill.domain.PayBill;
|
||||
import com.ruoyi.ss.payBill.domain.PayBillVO;
|
||||
import com.ruoyi.ss.payBill.domain.PayBillQuery;
|
||||
import com.ruoyi.ss.payBill.domain.enums.PayBillBstType;
|
||||
import com.ruoyi.ss.timeBill.domain.TimeBillVO;
|
||||
|
||||
/**
|
||||
* 支付订单Service接口
|
||||
|
@ -67,7 +65,7 @@ public interface PayBillService
|
|||
/**
|
||||
* 创建支付订单
|
||||
*/
|
||||
PayBillVO createBill(TimeBillVO bill, Long channelId);
|
||||
PayBillVO createBill(PayBill bill);
|
||||
|
||||
/**
|
||||
* 根据业务ID关闭订单
|
||||
|
@ -75,7 +73,7 @@ public interface PayBillService
|
|||
* @param bstId 业务ID
|
||||
* @param bstType 业务类型
|
||||
*/
|
||||
boolean closeByBstId(Long bstId, PayBillBstType bstType);
|
||||
boolean closeByBstId(Long bstId, String bstType);
|
||||
|
||||
/**
|
||||
* 根据业务ID查询
|
||||
|
|
|
@ -0,0 +1,56 @@
|
|||
package com.ruoyi.ss.payBill.service.impl;
|
||||
|
||||
import com.ruoyi.ss.payBill.domain.PayBill;
|
||||
import com.ruoyi.ss.payBill.domain.PayBillVO;
|
||||
import com.ruoyi.ss.payBill.domain.enums.PayBillBstType;
|
||||
import com.ruoyi.ss.payBill.domain.enums.PayBillStatus;
|
||||
import com.ruoyi.ss.payBill.service.PayBillConverter;
|
||||
import com.ruoyi.ss.timeBill.domain.TimeBill;
|
||||
import com.ruoyi.ss.transactionBill.domain.enums.TransactionBillPayType;
|
||||
import com.ruoyi.ss.user.domain.SmUserVo;
|
||||
import com.ruoyi.ss.user.service.ISmUserService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
/**
|
||||
* @author wjh
|
||||
* 2024/8/9
|
||||
*/
|
||||
@Service
|
||||
public class PayBillConverterImpl implements PayBillConverter {
|
||||
|
||||
@Autowired
|
||||
private ISmUserService userService;
|
||||
|
||||
@Override
|
||||
public PayBill toPo(TimeBill bill, Long channelId) {
|
||||
if (bill == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
PayBill po = new PayBill();
|
||||
|
||||
// 查询用户
|
||||
SmUserVo user = userService.selectSmUserByUserId(bill.getUserId());
|
||||
if (user == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
// 若关闭成功,创建支付订单
|
||||
PayBillVO data = new PayBillVO();
|
||||
data.setBstType(PayBillBstType.TIME_BILL.getType());
|
||||
data.setBstId(bill.getBillId());
|
||||
data.setAmount(bill.getAmount());
|
||||
data.setChannelId(channelId);
|
||||
data.setStatus(PayBillStatus.WAIT_PAY.getStatus());
|
||||
data.setDescription("计时订单" + bill.getBillNo());
|
||||
|
||||
// TODO 渠道成本及服务费
|
||||
|
||||
// 支付人
|
||||
if (TransactionBillPayType.WECHAT.getType().equals(data.getChannelId())) {
|
||||
data.setAccount(user.getWxOpenId());
|
||||
}
|
||||
return po;
|
||||
}
|
||||
}
|
|
@ -10,10 +10,8 @@ import com.ruoyi.common.utils.ServiceUtil;
|
|||
import com.ruoyi.common.utils.SnowFlakeUtil;
|
||||
import com.ruoyi.ss.payBill.domain.enums.PayBillBstType;
|
||||
import com.ruoyi.ss.payBill.domain.enums.PayBillStatus;
|
||||
import com.ruoyi.ss.timeBill.domain.TimeBillVO;
|
||||
import com.ruoyi.ss.timeBill.service.TimeBillService;
|
||||
import com.ruoyi.ss.transactionBill.domain.enums.TransactionBillPayType;
|
||||
import com.ruoyi.ss.user.domain.SmUserVo;
|
||||
import com.ruoyi.ss.user.service.ISmUserService;
|
||||
import com.ruoyi.common.pay.wx.service.WxPayService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
@ -130,49 +128,26 @@ public class PayBillServiceImpl implements PayBillService
|
|||
}
|
||||
|
||||
@Override
|
||||
public PayBillVO createBill(TimeBillVO bill, Long channelId) {
|
||||
public PayBillVO createBill(PayBill bill) {
|
||||
// 锁
|
||||
String lockKey = bill.getBillNo();
|
||||
String lockKey = bill.getBstType() + bill.getBstId();
|
||||
if (!redisLock.lock(RedisLockKey.PAY_BILL, lockKey)) {
|
||||
return null;
|
||||
};
|
||||
try {
|
||||
// 关闭旧的支付订单
|
||||
PayBillBstType bstType = PayBillBstType.TIME_BILL;
|
||||
boolean close = this.closeByBstId(bill.getBillId(), bstType);
|
||||
if (!close) {
|
||||
return null;
|
||||
}
|
||||
transactionTemplate.execute(status -> {
|
||||
// 插入订单
|
||||
int insert = this.insertPayBill(bill);
|
||||
ServiceUtil.assertion(insert != 1, "插入支付订单失败");
|
||||
|
||||
// 查询用户
|
||||
SmUserVo user = userService.selectSmUserByUserId(bill.getUserId());
|
||||
if (user == null) {
|
||||
return null;
|
||||
}
|
||||
// 关闭旧的支付订单
|
||||
boolean close = this.closeByBstId(bill.getBstId(), bill.getBstType());
|
||||
ServiceUtil.assertion(!close, "关闭旧支付订单失败");
|
||||
|
||||
// 若关闭成功,创建支付订单
|
||||
PayBillVO data = new PayBillVO();
|
||||
data.setBstType(bstType.getType());
|
||||
data.setBstId(bill.getBillId());
|
||||
data.setAmount(bill.getAmount());
|
||||
data.setChannelId(channelId);
|
||||
data.setStatus(PayBillStatus.WAIT_PAY.getStatus());
|
||||
data.setDescription("计时订单" + bill.getBillNo());
|
||||
return insert;
|
||||
});
|
||||
|
||||
|
||||
// TODO 渠道成本及服务费
|
||||
|
||||
// 支付人
|
||||
if (TransactionBillPayType.WECHAT.getType().equals(data.getChannelId())) {
|
||||
data.setAccount(user.getWxOpenId());
|
||||
}
|
||||
|
||||
int insert = this.insertPayBill(data);
|
||||
if (insert != 1) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return this.selectByPayNo(data.getPayNo());
|
||||
return this.selectByPayNo(bill.getPayNo());
|
||||
} finally {
|
||||
redisLock.unlock(RedisLockKey.PAY_BILL, lockKey);
|
||||
}
|
||||
|
@ -180,13 +155,14 @@ public class PayBillServiceImpl implements PayBillService
|
|||
}
|
||||
|
||||
@Override
|
||||
public boolean closeByBstId(Long bstId, PayBillBstType bstType) {
|
||||
public boolean closeByBstId(Long bstId, String bstType) {
|
||||
if (bstId == null || bstType == null ) {
|
||||
return false;
|
||||
}
|
||||
// 查询支付中的订单
|
||||
PayBillQuery query = new PayBillQuery();
|
||||
query.setBstId(bstId);
|
||||
query.setBstType(bstType.getType());
|
||||
query.setBstType(bstType);
|
||||
query.setStatusList(PayBillStatus.getCanCancelList());
|
||||
List<PayBillVO> payingList = this.selectPayBillList(query);
|
||||
if (CollectionUtils.isEmpty(payingList)) {
|
||||
|
@ -195,12 +171,7 @@ public class PayBillServiceImpl implements PayBillService
|
|||
|
||||
// 关闭正在支付中的订单
|
||||
transactionTemplate.execute(status -> {
|
||||
// 修改状态
|
||||
PayBill closeData = new PayBillVO();
|
||||
closeData.setStatus(PayBillStatus.CANCEL.getStatus());
|
||||
int update = this.updateByQuery(closeData, query);
|
||||
ServiceUtil.assertion(update != payingList.size(), "修改订单状态失败");
|
||||
|
||||
// 关闭订单
|
||||
for (PayBillVO bill : payingList) {
|
||||
// 关闭支付中的订单
|
||||
if (PayBillStatus.PAYING.getStatus().equals(bill.getStatus())
|
||||
|
@ -209,10 +180,15 @@ public class PayBillServiceImpl implements PayBillService
|
|||
}
|
||||
}
|
||||
|
||||
// 修改状态
|
||||
PayBill closeData = new PayBillVO();
|
||||
closeData.setStatus(PayBillStatus.CANCEL.getStatus());
|
||||
int update = this.updateByQuery(closeData, query);
|
||||
ServiceUtil.assertion(update != payingList.size(), "修改订单状态失败");
|
||||
|
||||
return update;
|
||||
});
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
@ -16,6 +16,7 @@ import com.ruoyi.iot.service.IotService;
|
|||
import com.ruoyi.ss.device.domain.vo.DeviceVO;
|
||||
import com.ruoyi.ss.device.service.DeviceService;
|
||||
import com.ruoyi.ss.payBill.domain.PayBillVO;
|
||||
import com.ruoyi.ss.payBill.service.PayBillConverter;
|
||||
import com.ruoyi.ss.payBill.service.PayBillService;
|
||||
import com.ruoyi.ss.suit.domain.enums.SuitTimeUnit;
|
||||
import com.ruoyi.ss.timeBill.domain.dto.TimeBillAddOrderDTO;
|
||||
|
@ -67,6 +68,9 @@ public class TimeBillServiceImpl implements TimeBillService
|
|||
@Autowired
|
||||
private WxPayServiceImpl wxPayService;
|
||||
|
||||
@Autowired
|
||||
private PayBillConverter payBillConverter;
|
||||
|
||||
/**
|
||||
* 查询时长订单
|
||||
*
|
||||
|
@ -286,7 +290,7 @@ public class TimeBillServiceImpl implements TimeBillService
|
|||
ServiceUtil.assertion(update != 1, "订单状态已发生变化,请稍后重试");
|
||||
|
||||
// 创建支付订单
|
||||
PayBillVO payBill = payBillService.createBill(bill, dto.getChannelId());
|
||||
PayBillVO payBill = payBillService.createBill(payBillConverter.toPo(bill, dto.getChannelId()));
|
||||
ServiceUtil.assertion(payBill == null, "创建支付订单失败");
|
||||
|
||||
// 调起支付
|
||||
|
|
|
@ -0,0 +1,107 @@
|
|||
package com.ruoyi.web.controller.ss;
|
||||
|
||||
import java.util.List;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
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.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
import com.ruoyi.common.annotation.Log;
|
||||
import com.ruoyi.common.core.controller.BaseController;
|
||||
import com.ruoyi.common.core.domain.AjaxResult;
|
||||
import com.ruoyi.common.enums.BusinessType;
|
||||
import com.ruoyi.ss.apiBill.domain.ApiBill;
|
||||
import com.ruoyi.ss.apiBill.domain.ApiBillVO;
|
||||
import com.ruoyi.ss.apiBill.domain.ApiBillQuery;
|
||||
import com.ruoyi.ss.apiBill.service.ApiBillService;
|
||||
import com.ruoyi.common.utils.poi.ExcelUtil;
|
||||
import com.ruoyi.common.core.page.TableDataInfo;
|
||||
|
||||
/**
|
||||
* API收费订单Controller
|
||||
*
|
||||
* @author ruoyi
|
||||
* @date 2024-08-09
|
||||
*/
|
||||
@RestController
|
||||
@RequestMapping("/ss/apiBill")
|
||||
public class ApiBillController extends BaseController
|
||||
{
|
||||
@Autowired
|
||||
private ApiBillService apiBillService;
|
||||
|
||||
/**
|
||||
* 查询API收费订单列表
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('ss:apiBill:list')")
|
||||
@GetMapping("/list")
|
||||
public TableDataInfo list(ApiBillQuery query)
|
||||
{
|
||||
startPage();
|
||||
startOrderBy();
|
||||
List<ApiBillVO> list = apiBillService.selectApiBillList(query);
|
||||
return getDataTable(list);
|
||||
}
|
||||
|
||||
/**
|
||||
* 导出API收费订单列表
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('ss:apiBill:export')")
|
||||
@Log(title = "API收费订单", businessType = BusinessType.EXPORT)
|
||||
@PostMapping("/export")
|
||||
public void export(HttpServletResponse response, ApiBillQuery query)
|
||||
{
|
||||
List<ApiBillVO> list = apiBillService.selectApiBillList(query);
|
||||
ExcelUtil<ApiBillVO> util = new ExcelUtil<ApiBillVO>(ApiBillVO.class);
|
||||
util.exportExcel(response, list, "API收费订单数据");
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取API收费订单详细信息
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('ss:apiBill:query')")
|
||||
@GetMapping(value = "/{billId}")
|
||||
public AjaxResult getInfo(@PathVariable("billId") Long billId)
|
||||
{
|
||||
return success(apiBillService.selectApiBillByBillId(billId));
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增API收费订单
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('ss:apiBill:add')")
|
||||
@Log(title = "API收费订单", businessType = BusinessType.INSERT)
|
||||
@PostMapping
|
||||
public AjaxResult add(@RequestBody ApiBill apiBill)
|
||||
{
|
||||
return toAjax(apiBillService.insertApiBill(apiBill));
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改API收费订单
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('ss:apiBill:edit')")
|
||||
@Log(title = "API收费订单", businessType = BusinessType.UPDATE)
|
||||
@PutMapping
|
||||
public AjaxResult edit(@RequestBody ApiBill apiBill)
|
||||
{
|
||||
return toAjax(apiBillService.updateApiBill(apiBill));
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除API收费订单
|
||||
*/
|
||||
@PreAuthorize("@ss.hasPermi('ss:apiBill:remove')")
|
||||
@Log(title = "API收费订单", businessType = BusinessType.DELETE)
|
||||
@DeleteMapping("/{billIds}")
|
||||
public AjaxResult remove(@PathVariable Long[] billIds)
|
||||
{
|
||||
return toAjax(apiBillService.deleteApiBillByBillIds(billIds));
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user