feat:第三方支付日志
This commit is contained in:
1 parent
4f3a8c1883
commit
3c20ebf10a
16 files changed
+547
No files matched your search
@@ -58,6 +58,33 @@ CREATE TABLE `third_door_log`
|
||||
COLLATE = utf8mb4_general_ci
|
||||
ROW_FORMAT = DYNAMIC COMMENT ='智能柜日志';
|
||||
|
||||
-- ----------------------------
|
||||
-- Table structure for third_pay_log
|
||||
-- ----------------------------
|
||||
DROP TABLE IF EXISTS `third_pay_log`;
|
||||
CREATE TABLE `third_pay_log`
|
||||
(
|
||||
`id` bigint NOT NULL COMMENT '主键',
|
||||
`pay_source_type` varchar(32) NOT NULL COMMENT '支付发起方类型id',
|
||||
`biz_type` varchar(32) NOT NULL COMMENT '支付类型',
|
||||
`biz_id` varchar(2048) DEFAULT NULL COMMENT '支付类型id',
|
||||
`api_url` text DEFAULT NULL COMMENT 'api-url',
|
||||
`res` text DEFAULT NULL COMMENT 'res',
|
||||
`req` text DEFAULT NULL COMMENT 'req',
|
||||
`error` text DEFAULT NULL COMMENT '调用错误',
|
||||
`time_consuming` char(64) DEFAULT NULL COMMENT '耗时(毫秒)',
|
||||
`create_time` datetime DEFAULT NULL COMMENT '创建时间',
|
||||
`update_time` datetime DEFAULT NULL COMMENT '更新时间',
|
||||
`create_by` varchar(32) COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '创建人',
|
||||
`update_by` varchar(32) COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '更新人',
|
||||
`del_flag` char(1) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '删除时间',
|
||||
`tenant_id` bigint(20) DEFAULT NULL,
|
||||
PRIMARY KEY (`id`) USING BTREE
|
||||
) ENGINE = InnoDB
|
||||
DEFAULT CHARSET = utf8mb4
|
||||
COLLATE = utf8mb4_general_ci
|
||||
ROW_FORMAT = DYNAMIC COMMENT ='第三方支付日志';
|
||||
|
||||
|
||||
-- ----------------------------
|
||||
-- Table structure for third_zy_id_dict
|
||||
|
||||
+28
@@ -0,0 +1,28 @@
|
||||
package com.bsd.pjcloud.thirdparty.constant.pay;
|
||||
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.Getter;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
/**
|
||||
* 第三方统一支付类型
|
||||
*/
|
||||
@AllArgsConstructor
|
||||
@Getter
|
||||
public enum ThirdPayBizTypeEnum {
|
||||
|
||||
LB_PAY("10", "宁波银行支付"),
|
||||
;
|
||||
|
||||
private final String type;
|
||||
private final String description;
|
||||
|
||||
public static ThirdPayBizTypeEnum valueOfByType(String type) {
|
||||
if (ObjectUtil.isEmpty(type)) return null;
|
||||
return Arrays.stream(values()).filter(v -> ObjectUtil.equals(type, v.getType())).findFirst().get();
|
||||
}
|
||||
|
||||
}
|
||||
+31
@@ -0,0 +1,31 @@
|
||||
package com.bsd.pjcloud.thirdparty.constant.pay;
|
||||
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
/**
|
||||
* 支付状态返回枚举
|
||||
*/
|
||||
@AllArgsConstructor
|
||||
@Getter
|
||||
public enum ThirdPayVoStatusEnum {
|
||||
|
||||
SUCCESS(200, "成功"),
|
||||
SIGN_ERROR(400, "签名验证失败"),
|
||||
USER_EXIST(501, "用户不存在"),
|
||||
ORDER_EXIST(502, "订单不存在"),
|
||||
BALANCE_NOT_ENOUGH(505, "用户余额不足"),
|
||||
;
|
||||
|
||||
private final int type;
|
||||
private final String description;
|
||||
|
||||
public static ThirdPayVoStatusEnum valueOfByType(String type) {
|
||||
if (ObjectUtil.isEmpty(type)) return null;
|
||||
return Arrays.stream(values()).filter(v -> ObjectUtil.equals(type, v.getType())).findFirst().get();
|
||||
}
|
||||
|
||||
}
|
||||
+29
@@ -0,0 +1,29 @@
|
||||
package com.bsd.pjcloud.thirdparty.dto.pay;
|
||||
|
||||
import com.bsd.pjcloud.thirdparty.constant.pay.ThirdPayBizTypeEnum;
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class PayDto {
|
||||
|
||||
/**
|
||||
* 用户id
|
||||
*/
|
||||
private Long userId;
|
||||
|
||||
/**
|
||||
* 第三方唯一id
|
||||
*/
|
||||
private String thirdOrderId;
|
||||
|
||||
/**
|
||||
* 第三方统一支付类型
|
||||
*/
|
||||
private ThirdPayBizTypeEnum bizType;
|
||||
|
||||
/**
|
||||
* 扣款金额(分)
|
||||
*/
|
||||
private Integer money;
|
||||
|
||||
}
|
||||
+18
@@ -0,0 +1,18 @@
|
||||
package com.bsd.pjcloud.thirdparty.dto.pay;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
@Data
|
||||
public class RefundDto {
|
||||
|
||||
/**
|
||||
* 用户id
|
||||
*/
|
||||
private Long userId;
|
||||
|
||||
/**
|
||||
* 平台唯一订单号
|
||||
*/
|
||||
private String platformOrderId;
|
||||
|
||||
}
|
||||
+13
@@ -0,0 +1,13 @@
|
||||
package com.bsd.pjcloud.thirdparty.dto.pay;
|
||||
|
||||
import com.bsd.pjcloud.thirdparty.entity.api.ThirdPayLogEntity;
|
||||
import lombok.Data;
|
||||
|
||||
import java.time.LocalDate;
|
||||
|
||||
@Data
|
||||
public class ThirdPayLogDto extends ThirdPayLogEntity {
|
||||
|
||||
private LocalDate[] createTimeList;
|
||||
|
||||
}
|
||||
+118
@@ -0,0 +1,118 @@
|
||||
package com.bsd.pjcloud.thirdparty.entity.api;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.*;
|
||||
import com.baomidou.mybatisplus.extension.activerecord.Model;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import com.bsd.pjcloud.common.core.util.TenantTable;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
/**
|
||||
* 第三方支付日志
|
||||
*/
|
||||
@Data
|
||||
@TenantTable
|
||||
@TableName("third_pay_log")
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@Schema(description = "第三方支付日志")
|
||||
public class ThirdPayLogEntity extends Model<ThirdPayLogEntity> {
|
||||
|
||||
|
||||
/**
|
||||
* 主键
|
||||
*/
|
||||
@TableId(type = IdType.ASSIGN_ID)
|
||||
@Schema(description="主键")
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 支付发起方类型id
|
||||
*/
|
||||
@Schema(description="支付发起方类型id")
|
||||
private String paySourceType;
|
||||
|
||||
/**
|
||||
* 支付类型
|
||||
*/
|
||||
@Schema(description="支付类型")
|
||||
private String bizType;
|
||||
|
||||
/**
|
||||
* 支付类型id
|
||||
*/
|
||||
@Schema(description="支付类型id")
|
||||
private String bizId;
|
||||
|
||||
/**
|
||||
* api-url
|
||||
*/
|
||||
@Schema(description="api-url")
|
||||
private String apiUrl;
|
||||
|
||||
/**
|
||||
* res
|
||||
*/
|
||||
@Schema(description="res")
|
||||
private String res;
|
||||
|
||||
/**
|
||||
* req
|
||||
*/
|
||||
@Schema(description="req")
|
||||
private String req;
|
||||
|
||||
/**
|
||||
* 调用错误
|
||||
*/
|
||||
@Schema(description="调用错误")
|
||||
private String error;
|
||||
|
||||
/**
|
||||
* 耗时(毫秒)
|
||||
*/
|
||||
@Schema(description="耗时(毫秒)")
|
||||
private String timeConsuming;
|
||||
|
||||
/**
|
||||
* 创建人
|
||||
*/
|
||||
@TableField(fill = FieldFill.INSERT)
|
||||
@Schema(description="创建人")
|
||||
private String createBy;
|
||||
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
@TableField(fill = FieldFill.INSERT)
|
||||
@Schema(description="创建时间")
|
||||
private LocalDateTime createTime;
|
||||
|
||||
/**
|
||||
* 更新人
|
||||
*/
|
||||
@TableField(fill = FieldFill.INSERT_UPDATE)
|
||||
@Schema(description="更新人")
|
||||
private String updateBy;
|
||||
|
||||
/**
|
||||
* 更新时间
|
||||
*/
|
||||
@TableField(fill = FieldFill.INSERT_UPDATE)
|
||||
@Schema(description="更新时间")
|
||||
private LocalDateTime updateTime;
|
||||
|
||||
/**
|
||||
* 删除时间
|
||||
*/
|
||||
@TableLogic
|
||||
@TableField(fill = FieldFill.INSERT)
|
||||
@Schema(description="删除时间")
|
||||
private String delFlag;
|
||||
|
||||
/**
|
||||
* tenantId
|
||||
*/
|
||||
@Schema(description="tenantId")
|
||||
private Long tenantId;
|
||||
}
|
||||
pjcloud-thirdparty/pjcloud-thirdparty-api/src/main/java/com/bsd/pjcloud/thirdparty/vo/pay/PayVo.java
Vendored
+25
@@ -0,0 +1,25 @@
|
||||
package com.bsd.pjcloud.thirdparty.vo.pay;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
@Data
|
||||
public class PayVo {
|
||||
|
||||
/**
|
||||
* 平台唯一订单号
|
||||
*/
|
||||
private String platformOrderId;
|
||||
|
||||
/**
|
||||
* 第三方唯一订单号
|
||||
*/
|
||||
private String thirdOrderId;
|
||||
|
||||
/**
|
||||
* 平台支付时间
|
||||
*/
|
||||
private LocalDateTime payTime;
|
||||
|
||||
}
|
||||
+30
@@ -0,0 +1,30 @@
|
||||
package com.bsd.pjcloud.thirdparty.vo.pay;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
@Data
|
||||
public class RefundVo {
|
||||
|
||||
/**
|
||||
* 平台唯一订单号
|
||||
*/
|
||||
private String platformOrderId;
|
||||
|
||||
/**
|
||||
* 平台唯一退款单号
|
||||
*/
|
||||
private String platformRefundId;
|
||||
|
||||
/**
|
||||
* 第三方唯一订单号
|
||||
*/
|
||||
private String thirdOrderId;
|
||||
|
||||
/**
|
||||
* 退款时间
|
||||
*/
|
||||
private LocalDateTime refundTime;
|
||||
|
||||
}
|
||||
+89
@@ -0,0 +1,89 @@
|
||||
package com.bsd.pjcloud.thirdparty.controller.pay;
|
||||
|
||||
import cn.hutool.core.util.ArrayUtil;
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.bsd.pjcloud.common.core.util.R;
|
||||
import com.bsd.pjcloud.common.log.annotation.SysLog;
|
||||
import com.bsd.pjcloud.thirdparty.dto.pay.ThirdPayLogDto;
|
||||
import com.bsd.pjcloud.thirdparty.entity.api.ThirdPayLogEntity;
|
||||
import com.bsd.pjcloud.thirdparty.service.ThirdPayLogService;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import com.bsd.pjcloud.common.excel.annotation.ResponseExcel;
|
||||
import io.swagger.v3.oas.annotations.security.SecurityRequirement;
|
||||
import org.springdoc.core.annotations.ParameterObject;
|
||||
import org.springframework.http.HttpHeaders;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* 第三方支付日志
|
||||
*/
|
||||
@RestController
|
||||
@RequiredArgsConstructor
|
||||
@RequestMapping("/thirdPayLog")
|
||||
@Tag(description = "thirdPayLog", name = "第三方支付日志管理")
|
||||
@SecurityRequirement(name = HttpHeaders.AUTHORIZATION)
|
||||
public class ThirdPayLogController {
|
||||
|
||||
private final ThirdPayLogService thirdPayLogService;
|
||||
|
||||
@Operation(summary = "分页查询", description = "分页查询")
|
||||
@GetMapping("/page")
|
||||
@PreAuthorize("@pms.hasPermission('third_thirdPayLog_view')")
|
||||
public R getThirdPayLogPage(@ParameterObject Page page, @ParameterObject ThirdPayLogDto dto) {
|
||||
LambdaQueryWrapper<ThirdPayLogEntity> wrapper = new LambdaQueryWrapper<ThirdPayLogEntity>()
|
||||
.eq(ObjectUtil.isNotEmpty(dto.getPaySourceType()), ThirdPayLogEntity::getPaySourceType, dto.getPaySourceType())
|
||||
.eq(ObjectUtil.isNotEmpty(dto.getBizType()), ThirdPayLogEntity::getBizType, dto.getBizType())
|
||||
.between(ObjectUtil.isNotEmpty(dto.getCreateTimeList()), ThirdPayLogEntity::getCreateTime, dto.getCreateTimeList()[0], dto.getCreateTimeList()[1])
|
||||
.orderByDesc(ThirdPayLogEntity::getCreateTime)
|
||||
.orderByDesc(ThirdPayLogEntity::getId);
|
||||
return R.ok(thirdPayLogService.page(page, wrapper));
|
||||
}
|
||||
|
||||
@Operation(summary = "通过id查询", description = "通过id查询")
|
||||
@GetMapping("/{id}")
|
||||
@PreAuthorize("@pms.hasPermission('third_thirdPayLog_view')")
|
||||
public R getById(@PathVariable("id") Long id) {
|
||||
return R.ok(thirdPayLogService.getById(id));
|
||||
}
|
||||
|
||||
@Operation(summary = "新增第三方支付日志", description = "新增第三方支付日志")
|
||||
@SysLog("新增第三方支付日志")
|
||||
@PostMapping
|
||||
@PreAuthorize("@pms.hasPermission('third_thirdPayLog_add')")
|
||||
public R save(@RequestBody ThirdPayLogEntity thirdPayLog) {
|
||||
return R.ok(thirdPayLogService.save(thirdPayLog));
|
||||
}
|
||||
|
||||
@Operation(summary = "修改第三方支付日志", description = "修改第三方支付日志")
|
||||
@SysLog("修改第三方支付日志")
|
||||
@PutMapping
|
||||
@PreAuthorize("@pms.hasPermission('third_thirdPayLog_edit')")
|
||||
public R updateById(@RequestBody ThirdPayLogEntity thirdPayLog) {
|
||||
return R.ok(thirdPayLogService.updateById(thirdPayLog));
|
||||
}
|
||||
|
||||
@Operation(summary = "通过id删除第三方支付日志", description = "通过id删除第三方支付日志")
|
||||
@SysLog("通过id删除第三方支付日志")
|
||||
@DeleteMapping
|
||||
@PreAuthorize("@pms.hasPermission('third_thirdPayLog_del')")
|
||||
public R removeById(@RequestBody Long[] ids) {
|
||||
return R.ok(thirdPayLogService.removeBatchByIds(CollUtil.toList(ids)));
|
||||
}
|
||||
|
||||
@ResponseExcel
|
||||
@GetMapping("/export")
|
||||
@PreAuthorize("@pms.hasPermission('third_thirdPayLog_export')")
|
||||
public List<ThirdPayLogEntity> export(ThirdPayLogEntity thirdPayLog, Long[] ids) {
|
||||
return thirdPayLogService.list(Wrappers.lambdaQuery(thirdPayLog).in(ArrayUtil.isNotEmpty(ids), ThirdPayLogEntity::getId, ids));
|
||||
}
|
||||
}
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
package com.bsd.pjcloud.thirdparty.mapper.pay;
|
||||
|
||||
import com.bsd.pjcloud.common.data.datascope.PjcloudBaseMapper;
|
||||
import com.bsd.pjcloud.thirdparty.entity.api.ThirdPayLogEntity;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
@Mapper
|
||||
public interface ThirdPayLogMapper extends PjcloudBaseMapper<ThirdPayLogEntity> {
|
||||
|
||||
|
||||
}
|
||||
+21
@@ -0,0 +1,21 @@
|
||||
package com.bsd.pjcloud.thirdparty.service;
|
||||
|
||||
|
||||
import com.bsd.pjcloud.thirdparty.dto.pay.PayDto;
|
||||
import com.bsd.pjcloud.thirdparty.dto.pay.RefundDto;
|
||||
import com.bsd.pjcloud.thirdparty.vo.pay.PayVo;
|
||||
import com.bsd.pjcloud.thirdparty.vo.pay.RefundVo;
|
||||
|
||||
public interface ThirdPayApiService {
|
||||
|
||||
/**
|
||||
* 扣款
|
||||
*/
|
||||
PayVo pay(PayDto dto);
|
||||
|
||||
/**
|
||||
* 退款
|
||||
*/
|
||||
RefundVo refund(RefundDto dto);
|
||||
|
||||
}
|
||||
+8
@@ -0,0 +1,8 @@
|
||||
package com.bsd.pjcloud.thirdparty.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.bsd.pjcloud.thirdparty.entity.api.ThirdPayLogEntity;
|
||||
|
||||
public interface ThirdPayLogService extends IService<ThirdPayLogEntity> {
|
||||
|
||||
}
|
||||
+55
@@ -0,0 +1,55 @@
|
||||
package com.bsd.pjcloud.thirdparty.service.impl.pay;
|
||||
|
||||
import com.bsd.pjcloud.thirdparty.dto.pay.PayDto;
|
||||
import com.bsd.pjcloud.thirdparty.dto.pay.RefundDto;
|
||||
import com.bsd.pjcloud.thirdparty.service.ThirdPayApiService;
|
||||
import com.bsd.pjcloud.thirdparty.vo.pay.PayVo;
|
||||
import com.bsd.pjcloud.thirdparty.vo.pay.RefundVo;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
|
||||
/**
|
||||
* 第三方支付
|
||||
*/
|
||||
@Service
|
||||
@Validated
|
||||
@Slf4j
|
||||
@RequiredArgsConstructor
|
||||
public class ThirdPayApiServiceImpl implements ThirdPayApiService {
|
||||
|
||||
private final String TAG = "第三方支付";
|
||||
|
||||
/**
|
||||
* 扣款
|
||||
*/
|
||||
@Override
|
||||
public PayVo pay(PayDto dto) {
|
||||
PayVo vo = new PayVo();
|
||||
try {
|
||||
|
||||
} catch (Exception e) {
|
||||
|
||||
} finally {
|
||||
|
||||
}
|
||||
return vo;
|
||||
}
|
||||
|
||||
/**
|
||||
* 退款
|
||||
*/
|
||||
@Override
|
||||
public RefundVo refund(RefundDto dto) {
|
||||
RefundVo vo = new RefundVo();
|
||||
try {
|
||||
|
||||
} catch (Exception e) {
|
||||
|
||||
} finally {
|
||||
|
||||
}
|
||||
return vo;
|
||||
}
|
||||
}
|
||||
+21
@@ -0,0 +1,21 @@
|
||||
package com.bsd.pjcloud.thirdparty.service.impl.pay;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.bsd.pjcloud.thirdparty.entity.api.ThirdPayLogEntity;
|
||||
import com.bsd.pjcloud.thirdparty.mapper.pay.ThirdPayLogMapper;
|
||||
import com.bsd.pjcloud.thirdparty.service.ThirdPayLogService;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
|
||||
/**
|
||||
* 第三方支付日志
|
||||
*/
|
||||
@Service
|
||||
@Validated
|
||||
@Slf4j
|
||||
@RequiredArgsConstructor
|
||||
public class ThirdPayLogServiceImpl extends ServiceImpl<ThirdPayLogMapper, ThirdPayLogEntity> implements ThirdPayLogService {
|
||||
|
||||
}
|
||||
+23
@@ -0,0 +1,23 @@
|
||||
<?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.bsd.pjcloud.thirdparty.mapper.pay.ThirdPayLogMapper">
|
||||
|
||||
<resultMap id="thirdPayLogMap" type="com.bsd.pjcloud.thirdparty.entity.api.ThirdPayLogEntity">
|
||||
<id property="id" column="id"/>
|
||||
<result property="paySourceType" column="pay_source_type"/>
|
||||
<result property="bizType" column="biz_type"/>
|
||||
<result property="bizId" column="biz_id"/>
|
||||
<result property="apiUrl" column="api_url"/>
|
||||
<result property="res" column="res"/>
|
||||
<result property="req" column="req"/>
|
||||
<result property="error" column="error"/>
|
||||
<result property="timeConsuming" column="time_consuming"/>
|
||||
<result property="createBy" column="create_by"/>
|
||||
<result property="createTime" column="create_time"/>
|
||||
<result property="updateBy" column="update_by"/>
|
||||
<result property="updateTime" column="update_time"/>
|
||||
<result property="delFlag" column="del_flag"/>
|
||||
<result property="tenantId" column="tenant_id"/>
|
||||
</resultMap>
|
||||
</mapper>
|
||||
Reference in new issue
Block a user