♻️ Refactoring code. pigx-pay-biz 适配最新V5 UI
This commit is contained in:
1 parent
4103227078
commit
106627660e
26 files changed
+744
-229
No files matched your search
+24
-26
@@ -41,33 +41,31 @@ import java.util.Map;
|
||||
@SecurityRequirement(name = HttpHeaders.AUTHORIZATION)
|
||||
public class SysTokenController {
|
||||
|
||||
private final RemoteTokenService remoteTokenService;
|
||||
private final RemoteTokenService remoteTokenService;
|
||||
|
||||
/**
|
||||
* 分页token 信息
|
||||
*
|
||||
* @param params 参数集
|
||||
* @return token集合
|
||||
*/
|
||||
@RequestMapping("/page")
|
||||
public R getTokenPage(@RequestBody Map<String, Object> params) {
|
||||
return remoteTokenService.getTokenPage(params, SecurityConstants.FROM_IN);
|
||||
}
|
||||
/**
|
||||
* 分页token 信息
|
||||
* @param params 参数集
|
||||
* @return token集合
|
||||
*/
|
||||
@RequestMapping("/page")
|
||||
public R getTokenPage(@RequestBody Map<String, Object> params) {
|
||||
return remoteTokenService.getTokenPage(params, SecurityConstants.FROM_IN);
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除
|
||||
*
|
||||
* @param token getTokenPage
|
||||
* @return success/false
|
||||
*/
|
||||
@SysLog("删除用户token")
|
||||
@DeleteMapping("/delete")
|
||||
@PreAuthorize("@pms.hasPermission('sys_token_del')")
|
||||
public R removeById(@RequestBody String[] tokens) {
|
||||
for (String token : tokens) {
|
||||
remoteTokenService.removeTokenById(token, SecurityConstants.FROM_IN);
|
||||
}
|
||||
return R.ok();
|
||||
}
|
||||
/**
|
||||
* 删除
|
||||
* @param token getTokenPage
|
||||
* @return success/false
|
||||
*/
|
||||
@SysLog("删除用户token")
|
||||
@DeleteMapping("/delete")
|
||||
@PreAuthorize("@pms.hasPermission('sys_token_del')")
|
||||
public R removeById(@RequestBody String[] tokens) {
|
||||
for (String token : tokens) {
|
||||
remoteTokenService.removeTokenById(token, SecurityConstants.FROM_IN);
|
||||
}
|
||||
return R.ok();
|
||||
}
|
||||
|
||||
}
|
||||
Executable → Regular
+63
-36
@@ -17,29 +17,36 @@
|
||||
|
||||
package com.pig4cloud.pigx.pay.controller;
|
||||
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
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.pig4cloud.pigx.common.core.util.R;
|
||||
import com.pig4cloud.pigx.common.log.annotation.SysLog;
|
||||
import com.pig4cloud.pigx.pay.entity.PayChannel;
|
||||
import com.pig4cloud.pigx.pay.service.PayChannelService;
|
||||
import io.swagger.v3.oas.annotations.security.SecurityRequirement;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import lombok.AllArgsConstructor;
|
||||
import org.springframework.http.HttpHeaders;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import com.pig4cloud.pigx.common.excel.annotation.ResponseExcel;
|
||||
import io.swagger.v3.oas.annotations.security.SecurityRequirement;
|
||||
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;
|
||||
|
||||
/**
|
||||
* 渠道
|
||||
* 支付渠道表
|
||||
*
|
||||
* @author lengleng
|
||||
* @date 2019-05-28 23:57:58
|
||||
* @author PIG
|
||||
* @date 2023-02-27 17:49:03
|
||||
*/
|
||||
@RestController
|
||||
@AllArgsConstructor
|
||||
@RequestMapping("/paychannel")
|
||||
@Tag(description = "paychannel", name = "paychannel管理")
|
||||
@RequiredArgsConstructor
|
||||
@RequestMapping("/channel")
|
||||
@Tag(description = "channel", name = "支付渠道表管理")
|
||||
@SecurityRequirement(name = HttpHeaders.AUTHORIZATION)
|
||||
public class PayChannelController {
|
||||
|
||||
@@ -48,61 +55,81 @@ public class PayChannelController {
|
||||
/**
|
||||
* 分页查询
|
||||
* @param page 分页对象
|
||||
* @param payChannel 渠道
|
||||
* @param payChannel 支付渠道表
|
||||
* @return
|
||||
*/
|
||||
@Operation(summary = "分页查询", description = "分页查询")
|
||||
@GetMapping("/page")
|
||||
public R getPayChannelPage(Page page, PayChannel payChannel) {
|
||||
return R.ok(payChannelService.page(page, Wrappers.query(payChannel)));
|
||||
@PreAuthorize("@pms.hasPermission('pay_channel_view')")
|
||||
public R getpayChannelPage(Page page, PayChannel payChannel) {
|
||||
LambdaQueryWrapper<PayChannel> wrapper = Wrappers.lambdaQuery();
|
||||
wrapper.like(StrUtil.isNotBlank(payChannel.getChannelName()), PayChannel::getChannelName,
|
||||
payChannel.getChannelName());
|
||||
wrapper.eq(StrUtil.isNotBlank(payChannel.getState()), PayChannel::getState, payChannel.getState());
|
||||
return R.ok(payChannelService.page(page, wrapper));
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过id查询渠道
|
||||
* 通过id查询支付渠道表
|
||||
* @param id id
|
||||
* @return R
|
||||
*/
|
||||
@Operation(summary = "通过id查询", description = "通过id查询")
|
||||
@GetMapping("/{id}")
|
||||
public R getById(@PathVariable("id") Integer id) {
|
||||
@PreAuthorize("@pms.hasPermission('pay_channel_view')")
|
||||
public R getById(@PathVariable("id") Long id) {
|
||||
return R.ok(payChannelService.getById(id));
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增渠道
|
||||
* @param payChannel 渠道
|
||||
* 新增支付渠道表
|
||||
* @param payChannel 支付渠道表
|
||||
* @return R
|
||||
*/
|
||||
@SysLog("新增渠道")
|
||||
@Operation(summary = "新增支付渠道表", description = "新增支付渠道表")
|
||||
@SysLog("新增支付渠道表")
|
||||
@PostMapping
|
||||
@PreAuthorize("@pms.hasPermission('pay_paychannel_add')")
|
||||
@PreAuthorize("@pms.hasPermission('pay_channel_add')")
|
||||
public R save(@RequestBody PayChannel payChannel) {
|
||||
payChannelService.saveChannel(payChannel);
|
||||
return R.ok();
|
||||
return R.ok(payChannelService.save(payChannel));
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改渠道
|
||||
* @param payChannel 渠道
|
||||
* 修改支付渠道表
|
||||
* @param payChannel 支付渠道表
|
||||
* @return R
|
||||
*/
|
||||
@SysLog("修改渠道")
|
||||
@Operation(summary = "修改支付渠道表", description = "修改支付渠道表")
|
||||
@SysLog("修改支付渠道表")
|
||||
@PutMapping
|
||||
@PreAuthorize("@pms.hasPermission('pay_paychannel_edit')")
|
||||
@PreAuthorize("@pms.hasPermission('pay_channel_edit')")
|
||||
public R updateById(@RequestBody PayChannel payChannel) {
|
||||
payChannelService.updateById(payChannel);
|
||||
return R.ok();
|
||||
return R.ok(payChannelService.updateById(payChannel));
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过id删除渠道
|
||||
* @param id id
|
||||
* 通过id删除支付渠道表
|
||||
* @param ids id列表
|
||||
* @return R
|
||||
*/
|
||||
@SysLog("删除渠道")
|
||||
@DeleteMapping("/{id}")
|
||||
@PreAuthorize("@pms.hasPermission('pay_paychannel_del')")
|
||||
public R removeById(@PathVariable Integer id) {
|
||||
payChannelService.removeById(id);
|
||||
return R.ok();
|
||||
@Operation(summary = "通过id删除支付渠道表", description = "通过id删除支付渠道表")
|
||||
@SysLog("通过id删除支付渠道表")
|
||||
@DeleteMapping
|
||||
@PreAuthorize("@pms.hasPermission('pay_channel_del')")
|
||||
public R removeById(@RequestBody Long[] ids) {
|
||||
return R.ok(payChannelService.removeBatchByIds(CollUtil.toList(ids)));
|
||||
}
|
||||
|
||||
}
|
||||
/**
|
||||
* 导出excel 表格
|
||||
* @param payChannel 查询条件
|
||||
* @return excel 文件流
|
||||
*/
|
||||
@ResponseExcel
|
||||
@GetMapping("/export")
|
||||
@PreAuthorize("@pms.hasPermission('pay_channel_export')")
|
||||
public List<PayChannel> export(PayChannel payChannel) {
|
||||
return payChannelService.list(Wrappers.query(payChannel));
|
||||
}
|
||||
|
||||
}
|
||||
+44
-26
@@ -17,15 +17,19 @@
|
||||
|
||||
package com.pig4cloud.pigx.pay.controller;
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import cn.hutool.core.util.URLUtil;
|
||||
import cn.hutool.http.ContentType;
|
||||
import cn.hutool.json.JSONObject;
|
||||
import cn.hutool.json.JSONUtil;
|
||||
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.fasterxml.jackson.databind.ObjectMapper;
|
||||
import com.pig4cloud.pigx.common.core.util.R;
|
||||
import com.pig4cloud.pigx.common.data.tenant.TenantContextHolder;
|
||||
import com.pig4cloud.pigx.common.excel.annotation.ResponseExcel;
|
||||
import com.pig4cloud.pigx.common.log.annotation.SysLog;
|
||||
import com.pig4cloud.pigx.common.security.annotation.Inner;
|
||||
import com.pig4cloud.pigx.pay.entity.PayChannel;
|
||||
@@ -34,9 +38,10 @@ import com.pig4cloud.pigx.pay.service.PayChannelService;
|
||||
import com.pig4cloud.pigx.pay.service.PayGoodsOrderService;
|
||||
import com.pig4cloud.pigx.pay.utils.PayChannelNameEnum;
|
||||
import com.pig4cloud.pigx.pay.utils.PayConstants;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.security.SecurityRequirement;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.SneakyThrows;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import me.chanjar.weixin.common.bean.oauth2.WxOAuth2AccessToken;
|
||||
@@ -45,14 +50,14 @@ import me.chanjar.weixin.mp.api.WxMpService;
|
||||
import me.chanjar.weixin.mp.api.impl.WxMpServiceImpl;
|
||||
import me.chanjar.weixin.mp.config.impl.WxMpDefaultConfigImpl;
|
||||
import org.springframework.http.HttpHeaders;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.web.servlet.ModelAndView;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* 商品
|
||||
@@ -61,10 +66,10 @@ import java.util.Map;
|
||||
* @date 2019-05-28 23:58:27
|
||||
*/
|
||||
@Slf4j
|
||||
@Controller
|
||||
@AllArgsConstructor
|
||||
@RestController
|
||||
@RequiredArgsConstructor
|
||||
@RequestMapping("/goods")
|
||||
@Tag(description = "goods", name = "商品订单管理")
|
||||
@Tag(description = "goods", name = "商品订单表管理")
|
||||
@SecurityRequirement(name = HttpHeaders.AUTHORIZATION)
|
||||
public class PayGoodsOrderController {
|
||||
|
||||
@@ -85,7 +90,7 @@ public class PayGoodsOrderController {
|
||||
@SneakyThrows
|
||||
@Inner(false)
|
||||
@GetMapping("/buy")
|
||||
@SysLog("购买商品")
|
||||
@Operation(summary = "购买商品", description = "购买商品")
|
||||
public void buy(PayGoodsOrder goods, HttpServletRequest request, HttpServletResponse response) {
|
||||
String ua = request.getHeader(HttpHeaders.USER_AGENT);
|
||||
log.info("当前扫码方式 UA:{}", ua);
|
||||
@@ -102,7 +107,7 @@ public class PayGoodsOrderController {
|
||||
String wxUrl = "https://open.weixin.qq.com/connect/oauth2/authorize?appid=%s"
|
||||
+ "&redirect_uri=%s&response_type=code&scope=snsapi_base&state=%s";
|
||||
|
||||
String redirectUri = String.format("%s/pay/goods/wx?amount=%s&TENANT-ID=%s", channel.getNotifyUrl(),
|
||||
String redirectUri = String.format("%s/admin/goods/wx?amount=%s&TENANT-ID=%s", channel.getNotifyUrl(),
|
||||
goods.getAmount(), TenantContextHolder.getTenantId());
|
||||
|
||||
response.sendRedirect(
|
||||
@@ -118,7 +123,7 @@ public class PayGoodsOrderController {
|
||||
@SneakyThrows
|
||||
@Inner(false)
|
||||
@GetMapping("/merge/buy")
|
||||
@SysLog("聚合支付购买商品")
|
||||
@Operation(summary = "聚合支付购买商品", description = "聚合支付购买商品")
|
||||
public void mergeBuy(PayGoodsOrder goods, HttpServletResponse response) {
|
||||
Map<String, Object> result = payGoodsOrderService.buy(goods, true);
|
||||
response.setContentType(ContentType.JSON.getValue());
|
||||
@@ -136,6 +141,7 @@ public class PayGoodsOrderController {
|
||||
@Inner(false)
|
||||
@SneakyThrows
|
||||
@GetMapping("/wx")
|
||||
@Operation(summary = "商品信息", description = "回调code")
|
||||
public ModelAndView wx(PayGoodsOrder goods, String code, ModelAndView modelAndView) {
|
||||
PayChannel channel = channelService.getOne(
|
||||
Wrappers.<PayChannel>lambdaQuery().eq(PayChannel::getChannelId, PayChannelNameEnum.WEIXIN_MP), false);
|
||||
@@ -165,10 +171,14 @@ public class PayGoodsOrderController {
|
||||
* @param payGoodsOrder 商品订单表
|
||||
* @return
|
||||
*/
|
||||
@ResponseBody
|
||||
@Operation(summary = "分页查询", description = "分页查询")
|
||||
@GetMapping("/page")
|
||||
public R getPayGoodsOrderPage(Page page, PayGoodsOrder payGoodsOrder) {
|
||||
return R.ok(payGoodsOrderService.page(page, Wrappers.query(payGoodsOrder)));
|
||||
public R getpayGoodsOrderPage(Page page, PayGoodsOrder payGoodsOrder) {
|
||||
LambdaQueryWrapper<PayGoodsOrder> wrapper = Wrappers.lambdaQuery();
|
||||
wrapper.eq(StrUtil.isNotBlank(payGoodsOrder.getStatus()), PayGoodsOrder::getStatus, payGoodsOrder.getStatus());
|
||||
wrapper.like(Objects.nonNull(payGoodsOrder.getPayOrderId()), PayGoodsOrder::getPayOrderId,
|
||||
payGoodsOrder.getPayOrderId());
|
||||
return R.ok(payGoodsOrderService.page(page, wrapper));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -176,9 +186,9 @@ public class PayGoodsOrderController {
|
||||
* @param goodsOrderId id
|
||||
* @return R
|
||||
*/
|
||||
@ResponseBody
|
||||
@GetMapping(value = "/{goodsOrderId}")
|
||||
public R getById(@PathVariable("goodsOrderId") Integer goodsOrderId) {
|
||||
@Operation(summary = "通过id查询", description = "通过id查询")
|
||||
@GetMapping("/{goodsOrderId}")
|
||||
public R getById(@PathVariable("goodsOrderId") Long goodsOrderId) {
|
||||
return R.ok(payGoodsOrderService.getById(goodsOrderId));
|
||||
}
|
||||
|
||||
@@ -187,10 +197,9 @@ public class PayGoodsOrderController {
|
||||
* @param payGoodsOrder 商品订单表
|
||||
* @return R
|
||||
*/
|
||||
@Operation(summary = "新增商品订单表", description = "新增商品订单表")
|
||||
@SysLog("新增商品订单表")
|
||||
@PostMapping
|
||||
@ResponseBody
|
||||
@PreAuthorize("@pms.hasPermission('generator_paygoodsorder_add')")
|
||||
public R save(@RequestBody PayGoodsOrder payGoodsOrder) {
|
||||
return R.ok(payGoodsOrderService.save(payGoodsOrder));
|
||||
}
|
||||
@@ -200,25 +209,34 @@ public class PayGoodsOrderController {
|
||||
* @param payGoodsOrder 商品订单表
|
||||
* @return R
|
||||
*/
|
||||
@Operation(summary = "修改商品订单表", description = "修改商品订单表")
|
||||
@SysLog("修改商品订单表")
|
||||
@PutMapping
|
||||
@ResponseBody
|
||||
@PreAuthorize("@pms.hasPermission('generator_paygoodsorder_edit')")
|
||||
public R updateById(@RequestBody PayGoodsOrder payGoodsOrder) {
|
||||
return R.ok(payGoodsOrderService.updateById(payGoodsOrder));
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过id删除商品订单表
|
||||
* @param goodsOrderId id
|
||||
* @param ids goodsOrderId列表
|
||||
* @return R
|
||||
*/
|
||||
@SysLog("删除商品订单表")
|
||||
@ResponseBody
|
||||
@DeleteMapping("/{goodsOrderId}")
|
||||
@PreAuthorize("@pms.hasPermission('generator_paygoodsorder_del')")
|
||||
public R removeById(@PathVariable Integer goodsOrderId) {
|
||||
return R.ok(payGoodsOrderService.removeById(goodsOrderId));
|
||||
@Operation(summary = "通过id删除商品订单表", description = "通过id删除商品订单表")
|
||||
@SysLog("通过id删除商品订单表")
|
||||
@DeleteMapping
|
||||
public R removeById(@RequestBody Long[] ids) {
|
||||
return R.ok(payGoodsOrderService.removeBatchByIds(CollUtil.toList(ids)));
|
||||
}
|
||||
|
||||
/**
|
||||
* 导出excel 表格
|
||||
* @param payGoodsOrder 查询条件
|
||||
* @return excel 文件流
|
||||
*/
|
||||
@ResponseExcel
|
||||
@GetMapping("/export")
|
||||
public List<PayGoodsOrder> export(PayGoodsOrder payGoodsOrder) {
|
||||
return payGoodsOrderService.list(Wrappers.query(payGoodsOrder));
|
||||
}
|
||||
|
||||
}
|
||||
+57
-23
@@ -17,21 +17,26 @@
|
||||
|
||||
package com.pig4cloud.pigx.pay.controller;
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
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.ijpay.alipay.AliPayApi;
|
||||
import com.ijpay.core.kit.HttpKit;
|
||||
import com.ijpay.core.kit.WxPayKit;
|
||||
import com.pig4cloud.pigx.common.core.util.R;
|
||||
import com.pig4cloud.pigx.common.excel.annotation.ResponseExcel;
|
||||
import com.pig4cloud.pigx.common.log.annotation.SysLog;
|
||||
import com.pig4cloud.pigx.common.security.annotation.Inner;
|
||||
import com.pig4cloud.pigx.common.xss.core.XssCleanIgnore;
|
||||
import com.pig4cloud.pigx.pay.entity.PayNotifyRecord;
|
||||
import com.pig4cloud.pigx.pay.handler.PayNotifyCallbakHandler;
|
||||
import com.pig4cloud.pigx.pay.service.PayNotifyRecordService;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.security.SecurityRequirement;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.SneakyThrows;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.http.HttpHeaders;
|
||||
@@ -40,6 +45,7 @@ import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
@@ -50,9 +56,9 @@ import java.util.Map;
|
||||
*/
|
||||
@Slf4j
|
||||
@RestController
|
||||
@AllArgsConstructor
|
||||
@RequiredArgsConstructor
|
||||
@RequestMapping("/notify")
|
||||
@Tag(description = "notify", name = "notify管理")
|
||||
@Tag(description = "notify", name = "通知记录日志表管理")
|
||||
@SecurityRequirement(name = HttpHeaders.AUTHORIZATION)
|
||||
public class PayNotifyRecordController {
|
||||
|
||||
@@ -67,58 +73,69 @@ public class PayNotifyRecordController {
|
||||
/**
|
||||
* 分页查询
|
||||
* @param page 分页对象
|
||||
* @param payNotifyRecord 异步通知记录
|
||||
* @param payNotifyRecord 通知记录日志表
|
||||
* @return
|
||||
*/
|
||||
@Operation(summary = "分页查询", description = "分页查询")
|
||||
@GetMapping("/page")
|
||||
public R getPayNotifyRecordPage(Page page, PayNotifyRecord payNotifyRecord) {
|
||||
return R.ok(payNotifyRecordService.page(page, Wrappers.query(payNotifyRecord)));
|
||||
@PreAuthorize("@pms.hasPermission('pay_record_view')")
|
||||
public R getpayNotifyRecordPage(Page page, PayNotifyRecord payNotifyRecord) {
|
||||
LambdaQueryWrapper<PayNotifyRecord> wrapper = Wrappers.lambdaQuery();
|
||||
wrapper.eq(StrUtil.isNotBlank(payNotifyRecord.getNotifyId()), PayNotifyRecord::getNotifyId,
|
||||
payNotifyRecord.getNotifyId());
|
||||
wrapper.eq(StrUtil.isNotBlank(payNotifyRecord.getOrderNo()), PayNotifyRecord::getOrderNo,
|
||||
payNotifyRecord.getOrderNo());
|
||||
return R.ok(payNotifyRecordService.page(page, wrapper));
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过id查询异步通知记录
|
||||
* 通过id查询通知记录日志表
|
||||
* @param id id
|
||||
* @return R
|
||||
*/
|
||||
@Operation(summary = "通过id查询", description = "通过id查询")
|
||||
@GetMapping("/{id}")
|
||||
@PreAuthorize("@pms.hasPermission('pay_record_view')")
|
||||
public R getById(@PathVariable("id") Long id) {
|
||||
return R.ok(payNotifyRecordService.getById(id));
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增异步通知记录
|
||||
* @param payNotifyRecord 异步通知记录
|
||||
* 新增通知记录日志表
|
||||
* @param payNotifyRecord 通知记录日志表
|
||||
* @return R
|
||||
*/
|
||||
@SysLog("新增异步通知记录")
|
||||
@Operation(summary = "新增通知记录日志表", description = "新增通知记录日志表")
|
||||
@SysLog("新增通知记录日志表")
|
||||
@PostMapping
|
||||
@PreAuthorize("@pms.hasPermission('pay_paynotifyrecord_add')")
|
||||
public R save(@RequestBody PayNotifyRecord payNotifyRecord) {
|
||||
return R.ok(payNotifyRecordService.save(payNotifyRecord));
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改异步通知记录
|
||||
* @param payNotifyRecord 异步通知记录
|
||||
* 修改通知记录日志表
|
||||
* @param payNotifyRecord 通知记录日志表
|
||||
* @return R
|
||||
*/
|
||||
@SysLog("修改异步通知记录")
|
||||
@Operation(summary = "修改通知记录日志表", description = "修改通知记录日志表")
|
||||
@SysLog("修改通知记录日志表")
|
||||
@PutMapping
|
||||
@PreAuthorize("@pms.hasPermission('pay_paynotifyrecord_edit')")
|
||||
@PreAuthorize("@pms.hasPermission('pay_record_edit')")
|
||||
public R updateById(@RequestBody PayNotifyRecord payNotifyRecord) {
|
||||
return R.ok(payNotifyRecordService.updateById(payNotifyRecord));
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过id删除异步通知记录
|
||||
* @param id id
|
||||
* 通过id删除通知记录日志表
|
||||
* @param ids id列表
|
||||
* @return R
|
||||
*/
|
||||
@SysLog("删除异步通知记录")
|
||||
@DeleteMapping("/{id}")
|
||||
@PreAuthorize("@pms.hasPermission('pay_paynotifyrecord_del')")
|
||||
public R removeById(@PathVariable Long id) {
|
||||
return R.ok(payNotifyRecordService.removeById(id));
|
||||
@Operation(summary = "通过id删除通知记录日志表", description = "通过id删除通知记录日志表")
|
||||
@SysLog("通过id删除通知记录日志表")
|
||||
@DeleteMapping
|
||||
@PreAuthorize("@pms.hasPermission('pay_record_del')")
|
||||
public R removeById(@RequestBody Long[] ids) {
|
||||
return R.ok(payNotifyRecordService.removeBatchByIds(CollUtil.toList(ids)));
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -129,7 +146,9 @@ public class PayNotifyRecordController {
|
||||
@Inner(false)
|
||||
@SneakyThrows
|
||||
@XssCleanIgnore
|
||||
@SysLog("支付宝渠道异步回调")
|
||||
@PostMapping("/ali/callbak")
|
||||
@Operation(summary = "支付宝渠道异步回调", description = "支付宝渠道异步回调")
|
||||
public void aliCallbak(HttpServletRequest request, HttpServletResponse response) {
|
||||
// 解析回调信息
|
||||
Map<String, String> params = AliPayApi.toMap(request);
|
||||
@@ -143,9 +162,10 @@ public class PayNotifyRecordController {
|
||||
*/
|
||||
@Inner(false)
|
||||
@SneakyThrows
|
||||
@ResponseBody
|
||||
@XssCleanIgnore
|
||||
@PostMapping("/wx/callbak")
|
||||
@Operation(summary = "微信渠道支付回调", description = "微信渠道支付回调")
|
||||
@SysLog("微信渠道支付回调")
|
||||
public String wxCallbak(HttpServletRequest request) {
|
||||
String xmlMsg = HttpKit.readData(request);
|
||||
log.info("微信订单回调信息:{}", xmlMsg);
|
||||
@@ -162,10 +182,24 @@ public class PayNotifyRecordController {
|
||||
@SneakyThrows
|
||||
@XssCleanIgnore
|
||||
@PostMapping("/merge/callbak")
|
||||
@Operation(summary = "聚合渠道异步回调", description = "聚合渠道异步回调")
|
||||
@SysLog("聚合渠道异步回调")
|
||||
public void mergeCallbak(HttpServletRequest request, HttpServletResponse response) {
|
||||
// 解析回调信息
|
||||
Map<String, String> params = AliPayApi.toMap(request);
|
||||
response.getWriter().print(mergePayCallback.handle(params));
|
||||
}
|
||||
|
||||
/**
|
||||
* 导出excel 表格
|
||||
* @param payNotifyRecord 查询条件
|
||||
* @return excel 文件流
|
||||
*/
|
||||
@ResponseExcel
|
||||
@GetMapping("/export")
|
||||
@PreAuthorize("@pms.hasPermission('pay_record_export')")
|
||||
public List<PayNotifyRecord> export(PayNotifyRecord payNotifyRecord) {
|
||||
return payNotifyRecordService.list(Wrappers.query(payNotifyRecord));
|
||||
}
|
||||
|
||||
}
|
||||
+58
-26
@@ -17,12 +17,17 @@
|
||||
|
||||
package com.pig4cloud.pigx.pay.controller;
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
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.pig4cloud.pigx.common.core.util.R;
|
||||
import com.pig4cloud.pigx.common.excel.annotation.ResponseExcel;
|
||||
import com.pig4cloud.pigx.common.log.annotation.SysLog;
|
||||
import com.pig4cloud.pigx.pay.entity.PayRefundOrder;
|
||||
import com.pig4cloud.pigx.pay.service.PayRefundOrderService;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.security.SecurityRequirement;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import lombok.AllArgsConstructor;
|
||||
@@ -30,6 +35,8 @@ import org.springframework.http.HttpHeaders;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 退款
|
||||
*
|
||||
@@ -38,8 +45,8 @@ import org.springframework.web.bind.annotation.*;
|
||||
*/
|
||||
@RestController
|
||||
@AllArgsConstructor
|
||||
@RequestMapping("/payrefundorder")
|
||||
@Tag(description = "payrefundorder", name = "payrefundorder管理")
|
||||
@RequestMapping("/refund")
|
||||
@Tag(description = "refund", name = "退款订单表管理")
|
||||
@SecurityRequirement(name = HttpHeaders.AUTHORIZATION)
|
||||
public class PayRefundOrderController {
|
||||
|
||||
@@ -48,58 +55,83 @@ public class PayRefundOrderController {
|
||||
/**
|
||||
* 分页查询
|
||||
* @param page 分页对象
|
||||
* @param payRefundOrder 退款
|
||||
* @param payRefundOrder 退款订单表
|
||||
* @return
|
||||
*/
|
||||
@Operation(summary = "分页查询", description = "分页查询")
|
||||
@GetMapping("/page")
|
||||
public R getPayRefundOrderPage(Page page, PayRefundOrder payRefundOrder) {
|
||||
return R.ok(payRefundOrderService.page(page, Wrappers.query(payRefundOrder)));
|
||||
@PreAuthorize("@pms.hasPermission('pay_refund_view')")
|
||||
public R getpayRefundOrderPage(Page page, PayRefundOrder payRefundOrder) {
|
||||
LambdaQueryWrapper<PayRefundOrder> wrapper = Wrappers.lambdaQuery();
|
||||
wrapper.eq(payRefundOrder.getRefundOrderId() != null, PayRefundOrder::getRefundOrderId,
|
||||
payRefundOrder.getRefundOrderId());
|
||||
wrapper.eq(payRefundOrder.getPayOrderId() != null, PayRefundOrder::getPayOrderId,
|
||||
payRefundOrder.getPayOrderId());
|
||||
wrapper.eq(StrUtil.isNotBlank(payRefundOrder.getMchId()), PayRefundOrder::getMchId, payRefundOrder.getMchId());
|
||||
return R.ok(payRefundOrderService.page(page, wrapper));
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过id查询退款
|
||||
* @param orderId id
|
||||
* 通过id查询退款订单表
|
||||
* @param refundOrderId id
|
||||
* @return R
|
||||
*/
|
||||
@GetMapping("/{orderId}")
|
||||
public R getById(@PathVariable String orderId) {
|
||||
return R.ok(payRefundOrderService.getById(orderId));
|
||||
@Operation(summary = "通过id查询", description = "通过id查询")
|
||||
@GetMapping("/{refundOrderId}")
|
||||
@PreAuthorize("@pms.hasPermission('pay_refund_view')")
|
||||
public R getById(@PathVariable("refundOrderId") Long refundOrderId) {
|
||||
return R.ok(payRefundOrderService.getById(refundOrderId));
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增退款
|
||||
* @param payRefundOrder 退款
|
||||
* 新增退款订单表
|
||||
* @param payRefundOrder 退款订单表
|
||||
* @return R
|
||||
*/
|
||||
@SysLog("新增退款")
|
||||
@Operation(summary = "新增退款订单表", description = "新增退款订单表")
|
||||
@SysLog("新增退款订单表")
|
||||
@PostMapping
|
||||
@PreAuthorize("@pms.hasPermission('pay_payrefundorder_add')")
|
||||
@PreAuthorize("@pms.hasPermission('pay_refund_add')")
|
||||
public R save(@RequestBody PayRefundOrder payRefundOrder) {
|
||||
return R.ok(payRefundOrderService.save(payRefundOrder));
|
||||
return R.ok(payRefundOrderService.refund(payRefundOrder));
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改退款
|
||||
* @param payRefundOrder 退款
|
||||
* 修改退款订单表
|
||||
* @param payRefundOrder 退款订单表
|
||||
* @return R
|
||||
*/
|
||||
@SysLog("修改退款")
|
||||
@Operation(summary = "修改退款订单表", description = "修改退款订单表")
|
||||
@SysLog("修改退款订单表")
|
||||
@PutMapping
|
||||
@PreAuthorize("@pms.hasPermission('pay_payrefundorder_edit')")
|
||||
@PreAuthorize("@pms.hasPermission('pay_refund_edit')")
|
||||
public R updateById(@RequestBody PayRefundOrder payRefundOrder) {
|
||||
return R.ok(payRefundOrderService.updateById(payRefundOrder));
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过id删除退款
|
||||
* @param refundOrderId refundOrderId
|
||||
* 通过id删除退款订单表
|
||||
* @param ids refundOrderId列表
|
||||
* @return R
|
||||
*/
|
||||
@SysLog("删除退款")
|
||||
@DeleteMapping("/{refundOrderId}")
|
||||
@PreAuthorize("@pms.hasPermission('pay_payrefundorder_del')")
|
||||
public R removeById(@PathVariable String refundOrderId) {
|
||||
return R.ok(payRefundOrderService.removeById(refundOrderId));
|
||||
@Operation(summary = "通过id删除退款订单表", description = "通过id删除退款订单表")
|
||||
@SysLog("通过id删除退款订单表")
|
||||
@DeleteMapping
|
||||
@PreAuthorize("@pms.hasPermission('pay_refund_del')")
|
||||
public R removeById(@RequestBody Long[] ids) {
|
||||
return R.ok(payRefundOrderService.removeBatchByIds(CollUtil.toList(ids)));
|
||||
}
|
||||
|
||||
/**
|
||||
* 导出excel 表格
|
||||
* @param payRefundOrder 查询条件
|
||||
* @return excel 文件流
|
||||
*/
|
||||
@ResponseExcel
|
||||
@GetMapping("/export")
|
||||
@PreAuthorize("@pms.hasPermission('pay_refund_export')")
|
||||
public List<PayRefundOrder> export(PayRefundOrder payRefundOrder) {
|
||||
return payRefundOrderService.list(Wrappers.query(payRefundOrder));
|
||||
}
|
||||
|
||||
}
|
||||
+56
-26
@@ -17,29 +17,37 @@
|
||||
|
||||
package com.pig4cloud.pigx.pay.controller;
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
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.pig4cloud.pigx.common.core.util.R;
|
||||
import com.pig4cloud.pigx.common.excel.annotation.ResponseExcel;
|
||||
import com.pig4cloud.pigx.common.log.annotation.SysLog;
|
||||
import com.pig4cloud.pigx.pay.entity.PayTradeOrder;
|
||||
import com.pig4cloud.pigx.pay.service.PayTradeOrderService;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.security.SecurityRequirement;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.http.HttpHeaders;
|
||||
import org.springframework.security.access.prepost.PreAuthorize;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 支付
|
||||
* 支付订单表
|
||||
*
|
||||
* @author lengleng
|
||||
* @date 2019-05-28 23:58:18
|
||||
* @author PIG
|
||||
* @date 2023-02-28 14:18:17
|
||||
*/
|
||||
@RestController
|
||||
@AllArgsConstructor
|
||||
@RequestMapping("/order")
|
||||
@Tag(description = "order", name = "订单")
|
||||
@RequiredArgsConstructor
|
||||
@RequestMapping("/trade")
|
||||
@Tag(description = "trade", name = "支付订单表管理")
|
||||
@SecurityRequirement(name = HttpHeaders.AUTHORIZATION)
|
||||
public class PayTradeOrderController {
|
||||
|
||||
@@ -48,58 +56,80 @@ public class PayTradeOrderController {
|
||||
/**
|
||||
* 分页查询
|
||||
* @param page 分页对象
|
||||
* @param payTradeOrder 支付
|
||||
* @param payTradeOrder 支付订单表
|
||||
* @return
|
||||
*/
|
||||
@Operation(summary = "分页查询", description = "分页查询")
|
||||
@GetMapping("/page")
|
||||
public R getPayTradeOrderPage(Page page, PayTradeOrder payTradeOrder) {
|
||||
return R.ok(payTradeOrderService.page(page, Wrappers.query(payTradeOrder)));
|
||||
@PreAuthorize("@pms.hasPermission('pay_trade_view')")
|
||||
public R getpayTradeOrderPage(Page page, PayTradeOrder payTradeOrder) {
|
||||
LambdaQueryWrapper<PayTradeOrder> wrapper = Wrappers.lambdaQuery();
|
||||
wrapper.like(payTradeOrder.getOrderId() != null, PayTradeOrder::getOrderId, payTradeOrder.getOrderId());
|
||||
wrapper.eq(StrUtil.isNotBlank(payTradeOrder.getStatus()), PayTradeOrder::getStatus, payTradeOrder.getStatus());
|
||||
return R.ok(payTradeOrderService.page(page, wrapper));
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过id查询支付
|
||||
* 通过id查询支付订单表
|
||||
* @param orderId id
|
||||
* @return R
|
||||
*/
|
||||
@Operation(summary = "通过id查询", description = "通过id查询")
|
||||
@GetMapping("/{orderId}")
|
||||
public R getById(@PathVariable("orderId") String orderId) {
|
||||
@PreAuthorize("@pms.hasPermission('pay_trade_view')")
|
||||
public R getById(@PathVariable("orderId") Long orderId) {
|
||||
return R.ok(payTradeOrderService.getById(orderId));
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增支付
|
||||
* @param payTradeOrder 支付
|
||||
* 新增支付订单表
|
||||
* @param payTradeOrder 支付订单表
|
||||
* @return R
|
||||
*/
|
||||
@SysLog("新增支付")
|
||||
@Operation(summary = "新增支付订单表", description = "新增支付订单表")
|
||||
@SysLog("新增支付订单表")
|
||||
@PostMapping
|
||||
@PreAuthorize("@pms.hasPermission('pay_paytradeorder_add')")
|
||||
@PreAuthorize("@pms.hasPermission('pay_trade_add')")
|
||||
public R save(@RequestBody PayTradeOrder payTradeOrder) {
|
||||
return R.ok(payTradeOrderService.save(payTradeOrder));
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改支付
|
||||
* @param payTradeOrder 支付
|
||||
* 修改支付订单表
|
||||
* @param payTradeOrder 支付订单表
|
||||
* @return R
|
||||
*/
|
||||
@SysLog("修改支付")
|
||||
@Operation(summary = "修改支付订单表", description = "修改支付订单表")
|
||||
@SysLog("修改支付订单表")
|
||||
@PutMapping
|
||||
@PreAuthorize("@pms.hasPermission('pay_paytradeorder_edit')")
|
||||
@PreAuthorize("@pms.hasPermission('pay_trade_edit')")
|
||||
public R updateById(@RequestBody PayTradeOrder payTradeOrder) {
|
||||
return R.ok(payTradeOrderService.updateById(payTradeOrder));
|
||||
}
|
||||
|
||||
/**
|
||||
* 通过id删除支付
|
||||
* @param orderId id
|
||||
* 通过id删除支付订单表
|
||||
* @param ids orderId列表
|
||||
* @return R
|
||||
*/
|
||||
@SysLog("删除支付")
|
||||
@DeleteMapping("/{orderId}")
|
||||
@PreAuthorize("@pms.hasPermission('pay_paytradeorder_del')")
|
||||
public R removeById(@PathVariable String orderId) {
|
||||
return R.ok(payTradeOrderService.removeById(orderId));
|
||||
@Operation(summary = "通过id删除支付订单表", description = "通过id删除支付订单表")
|
||||
@SysLog("通过id删除支付订单表")
|
||||
@DeleteMapping
|
||||
@PreAuthorize("@pms.hasPermission('pay_trade_del')")
|
||||
public R removeById(@RequestBody Long[] ids) {
|
||||
return R.ok(payTradeOrderService.removeBatchByIds(CollUtil.toList(ids)));
|
||||
}
|
||||
|
||||
/**
|
||||
* 导出excel 表格
|
||||
* @param payTradeOrder 查询条件
|
||||
* @return excel 文件流
|
||||
*/
|
||||
@ResponseExcel
|
||||
@GetMapping("/export")
|
||||
@PreAuthorize("@pms.hasPermission('pay_trade_export')")
|
||||
public List<PayTradeOrder> export(PayTradeOrder payTradeOrder) {
|
||||
return payTradeOrderService.list(Wrappers.query(payTradeOrder));
|
||||
}
|
||||
|
||||
}
|
||||
+28
-11
@@ -44,58 +44,74 @@ public class PayChannel extends Model<PayChannel> {
|
||||
* 渠道主键ID
|
||||
*/
|
||||
@TableId(type = IdType.ASSIGN_ID)
|
||||
@Schema(description = "渠道主键ID")
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 应用ID
|
||||
* mchId
|
||||
*/
|
||||
@Sensitive(prefixNoMaskLen = 4, suffixNoMaskLen = 4)
|
||||
private String appId;
|
||||
@Schema(description = "mchId")
|
||||
private String mchId;
|
||||
|
||||
/**
|
||||
* 渠道ID
|
||||
*/
|
||||
@Schema(description = "渠道ID")
|
||||
private String channelId;
|
||||
|
||||
/**
|
||||
* 渠道名称,如:alipay,wechat
|
||||
*/
|
||||
@Schema(description = "渠道名称,如:alipay,wechat")
|
||||
private String channelName;
|
||||
|
||||
/**
|
||||
* 渠道商户ID | 12****123
|
||||
*/
|
||||
@Sensitive(prefixNoMaskLen = 2, suffixNoMaskLen = 3)
|
||||
@Schema(description = "渠道商户ID | 12****123")
|
||||
private String channelMchId;
|
||||
|
||||
/**
|
||||
* 前端回调地址
|
||||
*/
|
||||
@Schema(description = "前端回调地址")
|
||||
private String returnUrl;
|
||||
|
||||
/**
|
||||
* 后端回调地址
|
||||
*/
|
||||
@Schema(description = "后端回调地址")
|
||||
private String notifyUrl;
|
||||
|
||||
/**
|
||||
* 渠道状态
|
||||
*/
|
||||
@Schema(description = "渠道状态")
|
||||
private String state;
|
||||
|
||||
/**
|
||||
* 配置参数,json字符串
|
||||
*/
|
||||
@Schema(description = "配置参数,json字符串")
|
||||
private String param;
|
||||
|
||||
/**
|
||||
* 备注
|
||||
*/
|
||||
@Schema(description = "备注")
|
||||
private String remark;
|
||||
|
||||
/**
|
||||
* delFlag
|
||||
*/
|
||||
@TableLogic
|
||||
@Schema(description = "delFlag")
|
||||
private String delFlag;
|
||||
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
@Schema(description = "创建时间")
|
||||
@TableField(fill = FieldFill.INSERT)
|
||||
private LocalDateTime createTime;
|
||||
|
||||
@@ -103,18 +119,19 @@ public class PayChannel extends Model<PayChannel> {
|
||||
* 更新时间
|
||||
*/
|
||||
@TableField(fill = FieldFill.INSERT_UPDATE)
|
||||
@Schema(description = "更新时间")
|
||||
private LocalDateTime updateTime;
|
||||
|
||||
/**
|
||||
* 是否删除 -1:已删除 0:正常
|
||||
*/
|
||||
@TableLogic
|
||||
@TableField(fill = FieldFill.INSERT)
|
||||
private String delFlag;
|
||||
|
||||
/**
|
||||
* 租户ID
|
||||
*/
|
||||
@Schema(description = "租户ID")
|
||||
private Long tenantId;
|
||||
|
||||
/**
|
||||
* 应用ID
|
||||
*/
|
||||
@Schema(description = "应用ID")
|
||||
private String appId;
|
||||
|
||||
}
|
||||
+19
-9
@@ -34,7 +34,7 @@ import java.time.LocalDateTime;
|
||||
@Data
|
||||
@TableName("pay_goods_order")
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@Schema(description = "商品")
|
||||
@Schema(description = "商品订单表")
|
||||
public class PayGoodsOrder extends Model<PayGoodsOrder> {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
@@ -43,60 +43,70 @@ public class PayGoodsOrder extends Model<PayGoodsOrder> {
|
||||
* 商品订单ID
|
||||
*/
|
||||
@TableId(type = IdType.ASSIGN_ID)
|
||||
@Schema(description = "商品订单ID")
|
||||
private Long goodsOrderId;
|
||||
|
||||
/**
|
||||
* 商品ID
|
||||
*/
|
||||
@Schema(description = "商品ID")
|
||||
private String goodsId;
|
||||
|
||||
/**
|
||||
* 商品名称
|
||||
*/
|
||||
@Schema(description = "商品名称")
|
||||
private String goodsName;
|
||||
|
||||
/**
|
||||
* 金额,单位分
|
||||
*/
|
||||
@Schema(description = "金额,单位分")
|
||||
private String amount;
|
||||
|
||||
/**
|
||||
* 用户ID
|
||||
*/
|
||||
@Schema(description = "用户ID")
|
||||
private String userId;
|
||||
|
||||
/**
|
||||
* 订单状态,订单生成(0),支付成功(1),处理完成(2),处理失败(-1)
|
||||
*/
|
||||
@Schema(description = "订单状态,订单生成(0),支付成功(1),处理完成(2),处理失败(-1)")
|
||||
private String status;
|
||||
|
||||
/**
|
||||
* 支付订单号
|
||||
*/
|
||||
private String payOrderId;
|
||||
@Schema(description = "支付订单号")
|
||||
private Long payOrderId;
|
||||
|
||||
/**
|
||||
* delFlag
|
||||
*/
|
||||
@TableLogic
|
||||
@Schema(description = "delFlag")
|
||||
private String delFlag;
|
||||
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
@Schema(description = "创建时间")
|
||||
@TableField(fill = FieldFill.INSERT)
|
||||
private LocalDateTime createTime;
|
||||
|
||||
/**
|
||||
* 更新时间
|
||||
*/
|
||||
@Schema(description = "更新时间")
|
||||
@TableField(fill = FieldFill.INSERT_UPDATE)
|
||||
private LocalDateTime updateTime;
|
||||
|
||||
/**
|
||||
* 是否删除 -1:已删除 0:正常
|
||||
*/
|
||||
@TableLogic
|
||||
@TableField(fill = FieldFill.INSERT)
|
||||
private String delFlag;
|
||||
|
||||
/**
|
||||
* 租户ID
|
||||
*/
|
||||
@Schema(description = "租户ID")
|
||||
private Long tenantId;
|
||||
|
||||
}
|
||||
+16
-7
@@ -43,55 +43,64 @@ public class PayNotifyRecord extends Model<PayNotifyRecord> {
|
||||
* ID
|
||||
*/
|
||||
@TableId(type = IdType.ASSIGN_ID)
|
||||
@Schema(description = "ID")
|
||||
private Long id;
|
||||
|
||||
/**
|
||||
* 响应ID
|
||||
*/
|
||||
@Schema(description = "响应ID")
|
||||
private String notifyId;
|
||||
|
||||
/**
|
||||
* 请求报文
|
||||
*/
|
||||
@Schema(description = "请求报文")
|
||||
private String request;
|
||||
|
||||
/**
|
||||
* 响应报文
|
||||
*/
|
||||
@Schema(description = "响应报文")
|
||||
private String response;
|
||||
|
||||
/**
|
||||
* 系统订单号
|
||||
*/
|
||||
@Schema(description = "系统订单号")
|
||||
private String orderNo;
|
||||
|
||||
/**
|
||||
* http状态
|
||||
*/
|
||||
@Schema(description = "http状态")
|
||||
private String httpStatus;
|
||||
|
||||
/**
|
||||
* delFlag
|
||||
*/
|
||||
@TableLogic
|
||||
@Schema(description = "delFlag")
|
||||
private String delFlag;
|
||||
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
@Schema(description = "创建时间")
|
||||
@TableField(fill = FieldFill.INSERT)
|
||||
private LocalDateTime createTime;
|
||||
|
||||
/**
|
||||
* 更新时间
|
||||
*/
|
||||
@Schema(description = "更新时间")
|
||||
@TableField(fill = FieldFill.INSERT_UPDATE)
|
||||
private LocalDateTime updateTime;
|
||||
|
||||
/**
|
||||
* 是否删除 -1:已删除 0:正常
|
||||
*/
|
||||
@TableLogic
|
||||
@TableField(fill = FieldFill.INSERT)
|
||||
private String delFlag;
|
||||
|
||||
/**
|
||||
* 租户ID
|
||||
*/
|
||||
@Schema(description = "租户ID")
|
||||
private Long tenantId;
|
||||
|
||||
}
|
||||
+43
-14
@@ -34,7 +34,7 @@ import java.time.LocalDateTime;
|
||||
@Data
|
||||
@TableName("pay_refund_order")
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@Schema(description = "退款")
|
||||
@Schema(description = "退款订单表")
|
||||
public class PayRefundOrder extends Model<PayRefundOrder> {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
@@ -43,155 +43,184 @@ public class PayRefundOrder extends Model<PayRefundOrder> {
|
||||
* 退款订单号
|
||||
*/
|
||||
@TableId(type = IdType.ASSIGN_ID)
|
||||
@Schema(description = "退款订单号")
|
||||
private Long refundOrderId;
|
||||
|
||||
/**
|
||||
* 支付订单号
|
||||
*/
|
||||
@Schema(description = "支付订单号")
|
||||
private Long payOrderId;
|
||||
|
||||
/**
|
||||
* 渠道支付单号
|
||||
*/
|
||||
@Schema(description = "渠道支付单号")
|
||||
private String channelPayOrderNo;
|
||||
|
||||
/**
|
||||
* 商户ID
|
||||
*/
|
||||
@Schema(description = "商户ID")
|
||||
private String mchId;
|
||||
|
||||
/**
|
||||
* 商户退款单号
|
||||
*/
|
||||
@Schema(description = "商户退款单号")
|
||||
private String mchRefundNo;
|
||||
|
||||
/**
|
||||
* 渠道ID
|
||||
*/
|
||||
@Schema(description = "渠道ID")
|
||||
private String channelId;
|
||||
|
||||
/**
|
||||
* 支付金额,单位元
|
||||
* 支付金额
|
||||
*/
|
||||
@Schema(description = "支付金额")
|
||||
private String payAmount;
|
||||
|
||||
/**
|
||||
* 退款金额,单位分
|
||||
*/
|
||||
@Schema(description = "退款金额,单位分")
|
||||
private Long refundAmount;
|
||||
|
||||
/**
|
||||
* 三位货币代码,人民币:cny
|
||||
* 三位货币代码
|
||||
*/
|
||||
@Schema(description = "三位货币代码")
|
||||
private String currency;
|
||||
|
||||
/**
|
||||
* 退款状态:0-订单生成,1-退款中,2-退款成功,3-退款失败,4-业务处理完成
|
||||
*/
|
||||
private String status;
|
||||
@Schema(description = "退款状态:0-订单生成,1-退款中,2-退款成功,3-退款失败,4-业务处理完成")
|
||||
private Integer status;
|
||||
|
||||
/**
|
||||
* 退款结果:0-不确认结果,1-等待手动处理,2-确认成功,3-确认失败
|
||||
*/
|
||||
private String result;
|
||||
@Schema(description = "退款结果:0-不确认结果,1-等待手动处理,2-确认成功,3-确认失败")
|
||||
private Integer result;
|
||||
|
||||
/**
|
||||
* 客户端IP
|
||||
*/
|
||||
@Schema(description = "客户端IP")
|
||||
private String clientIp;
|
||||
|
||||
/**
|
||||
* 设备
|
||||
*/
|
||||
@Schema(description = "设备")
|
||||
private String device;
|
||||
|
||||
/**
|
||||
* 备注
|
||||
*/
|
||||
@Schema(description = "备注")
|
||||
private String remark;
|
||||
|
||||
/**
|
||||
* 渠道用户标识,如微信openId,支付宝账号
|
||||
* 渠道用户标识
|
||||
*/
|
||||
@Schema(description = "渠道用户标识")
|
||||
private String channelUser;
|
||||
|
||||
/**
|
||||
* 用户姓名
|
||||
*/
|
||||
@Schema(description = "用户姓名")
|
||||
private String username;
|
||||
|
||||
/**
|
||||
* 渠道商户ID
|
||||
*/
|
||||
@Schema(description = "渠道商户ID")
|
||||
private String channelMchId;
|
||||
|
||||
/**
|
||||
* 渠道订单号
|
||||
*/
|
||||
@Schema(description = "渠道订单号")
|
||||
private String channelOrderNo;
|
||||
|
||||
/**
|
||||
* 渠道错误码
|
||||
*/
|
||||
@Schema(description = "渠道错误码")
|
||||
private String channelErrCode;
|
||||
|
||||
/**
|
||||
* 渠道错误描述
|
||||
*/
|
||||
@Schema(description = "渠道错误描述")
|
||||
private String channelErrMsg;
|
||||
|
||||
/**
|
||||
* 特定渠道发起时额外参数
|
||||
*/
|
||||
@Schema(description = "特定渠道发起时额外参数")
|
||||
private String extra;
|
||||
|
||||
/**
|
||||
* 通知地址
|
||||
*/
|
||||
private String notifyurl;
|
||||
@Schema(description = "通知地址")
|
||||
private String notifyUrl;
|
||||
|
||||
/**
|
||||
* 扩展参数1
|
||||
*/
|
||||
@Schema(description = "扩展参数1")
|
||||
private String param1;
|
||||
|
||||
/**
|
||||
* 扩展参数2
|
||||
*/
|
||||
@Schema(description = "扩展参数2")
|
||||
private String param2;
|
||||
|
||||
/**
|
||||
* 订单失效时间
|
||||
*/
|
||||
@Schema(description = "订单失效时间")
|
||||
private LocalDateTime expireTime;
|
||||
|
||||
/**
|
||||
* 订单退款成功时间
|
||||
*/
|
||||
@Schema(description = "订单退款成功时间")
|
||||
private LocalDateTime refundSuccTime;
|
||||
|
||||
/**
|
||||
* delFlag
|
||||
*/
|
||||
@TableLogic
|
||||
@Schema(description = "delFlag")
|
||||
private String delFlag;
|
||||
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
@Schema(description = "创建时间")
|
||||
@TableField(fill = FieldFill.INSERT)
|
||||
private LocalDateTime createTime;
|
||||
|
||||
/**
|
||||
* 更新时间
|
||||
*/
|
||||
@Schema(description = "更新时间")
|
||||
@TableField(fill = FieldFill.INSERT_UPDATE)
|
||||
private LocalDateTime updateTime;
|
||||
|
||||
/**
|
||||
* 是否删除 -1:已删除 0:正常
|
||||
*/
|
||||
@TableLogic
|
||||
@TableField(fill = FieldFill.INSERT)
|
||||
private String delFlag;
|
||||
|
||||
/**
|
||||
* 租户ID
|
||||
*/
|
||||
@Schema(description = "租户ID")
|
||||
private Long tenantId;
|
||||
|
||||
}
|
||||
+31
-7
@@ -34,7 +34,7 @@ import java.time.LocalDateTime;
|
||||
@Data
|
||||
@TableName("pay_trade_order")
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@Schema(description = "支付")
|
||||
@Schema(description = "支付订单表")
|
||||
public class PayTradeOrder extends Model<PayTradeOrder> {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
@@ -43,130 +43,154 @@ public class PayTradeOrder extends Model<PayTradeOrder> {
|
||||
* 支付订单号
|
||||
*/
|
||||
@TableId(type = IdType.ASSIGN_ID)
|
||||
private String orderId;
|
||||
@Schema(description = "支付订单号")
|
||||
private Long orderId;
|
||||
|
||||
/**
|
||||
* 渠道ID
|
||||
*/
|
||||
@Schema(description = "渠道ID")
|
||||
private String channelId;
|
||||
|
||||
/**
|
||||
* 支付金额,单位元
|
||||
* 支付金额
|
||||
*/
|
||||
@Schema(description = "支付金额")
|
||||
private String amount;
|
||||
|
||||
/**
|
||||
* 三位货币代码,人民币:cny
|
||||
* 三位货币代码
|
||||
*/
|
||||
@Schema(description = "三位货币代码")
|
||||
private String currency;
|
||||
|
||||
/**
|
||||
* 支付状态,0-订单生成,1-支付中(目前未使用),2-支付成功,3-业务处理完成
|
||||
*/
|
||||
@Schema(description = "支付状态,0-订单生成,1-支付中(目前未使用),2-支付成功,3-业务处理完成")
|
||||
private String status;
|
||||
|
||||
/**
|
||||
* 客户端IP
|
||||
*/
|
||||
@Schema(description = "客户端IP")
|
||||
private String clientIp;
|
||||
|
||||
/**
|
||||
* 设备
|
||||
*/
|
||||
@Schema(description = "设备")
|
||||
private String device;
|
||||
|
||||
/**
|
||||
* 商品标题
|
||||
*/
|
||||
@Schema(description = "商品标题")
|
||||
private String subject;
|
||||
|
||||
/**
|
||||
* 商品描述信息
|
||||
*/
|
||||
@Schema(description = "商品描述信息")
|
||||
private String body;
|
||||
|
||||
/**
|
||||
* 特定渠道发起时额外参数
|
||||
*/
|
||||
@Schema(description = "特定渠道发起时额外参数")
|
||||
private String extra;
|
||||
|
||||
/**
|
||||
* 渠道商户ID
|
||||
*/
|
||||
@Schema(description = "渠道商户ID")
|
||||
private String channelMchId;
|
||||
|
||||
/**
|
||||
* 渠道订单号
|
||||
*/
|
||||
@Schema(description = "渠道订单号")
|
||||
private String channelOrderNo;
|
||||
|
||||
/**
|
||||
* 渠道支付错误码
|
||||
*/
|
||||
@Schema(description = "渠道支付错误码")
|
||||
private String errCode;
|
||||
|
||||
/**
|
||||
* 渠道支付错误描述
|
||||
*/
|
||||
@Schema(description = "渠道支付错误描述")
|
||||
private String errMsg;
|
||||
|
||||
/**
|
||||
* 扩展参数1
|
||||
*/
|
||||
@Schema(description = "扩展参数1")
|
||||
private String param1;
|
||||
|
||||
/**
|
||||
* 扩展参数2
|
||||
*/
|
||||
@Schema(description = "扩展参数2")
|
||||
private String param2;
|
||||
|
||||
/**
|
||||
* 通知地址
|
||||
*/
|
||||
@Schema(description = "通知地址")
|
||||
private String notifyUrl;
|
||||
|
||||
/**
|
||||
* 通知次数
|
||||
*/
|
||||
@Schema(description = "通知次数")
|
||||
private Integer notifyCount;
|
||||
|
||||
/**
|
||||
* 最后一次通知时间
|
||||
*/
|
||||
@Schema(description = "最后一次通知时间")
|
||||
private Long lastNotifyTime;
|
||||
|
||||
/**
|
||||
* 订单失效时间
|
||||
*/
|
||||
@Schema(description = "订单失效时间")
|
||||
private Long expireTime;
|
||||
|
||||
/**
|
||||
* 订单支付成功时间
|
||||
*/
|
||||
private Long paySuccTime;
|
||||
@Schema(description = "订单支付成功时间")
|
||||
private LocalDateTime paySuccTime;
|
||||
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
@Schema(description = "创建时间")
|
||||
@TableField(fill = FieldFill.INSERT)
|
||||
private LocalDateTime createTime;
|
||||
|
||||
/**
|
||||
* 更新时间
|
||||
*/
|
||||
@Schema(description = "更新时间")
|
||||
@TableField(fill = FieldFill.INSERT_UPDATE)
|
||||
private LocalDateTime updateTime;
|
||||
|
||||
/**
|
||||
* 是否删除 -1:已删除 0:正常
|
||||
* delFlag
|
||||
*/
|
||||
@TableLogic
|
||||
@TableField(fill = FieldFill.INSERT)
|
||||
@Schema(description = "delFlag")
|
||||
private String delFlag;
|
||||
|
||||
/**
|
||||
* 租户ID
|
||||
*/
|
||||
@Schema(description = "租户ID")
|
||||
private Long tenantId;
|
||||
|
||||
}
|
||||
+51
@@ -0,0 +1,51 @@
|
||||
package com.pig4cloud.pigx.pay.handler;
|
||||
|
||||
import com.pig4cloud.pigx.pay.entity.PayChannel;
|
||||
import com.pig4cloud.pigx.pay.entity.PayRefundOrder;
|
||||
import com.pig4cloud.pigx.pay.entity.PayTradeOrder;
|
||||
|
||||
/**
|
||||
* @author lengleng
|
||||
* @date 2023-03-01
|
||||
* <p>
|
||||
* 退款业务
|
||||
*/
|
||||
public interface PayOrderRefundHandler {
|
||||
|
||||
/**
|
||||
* 准备支付参数
|
||||
*/
|
||||
default PayChannel preparePayParams() {
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建商品退款订单
|
||||
* @param tradeOrder 交易订单
|
||||
* @return
|
||||
*/
|
||||
PayRefundOrder createPayRefundOrder(PayRefundOrder refundOrder, PayTradeOrder tradeOrder);
|
||||
|
||||
/**
|
||||
* 调起渠道退款
|
||||
* @param refundOrder 商品退款订单
|
||||
* @param tradeOrder 交易订单
|
||||
* @return obj
|
||||
*/
|
||||
Object refund(PayRefundOrder refundOrder, PayTradeOrder tradeOrder);
|
||||
|
||||
/**
|
||||
* 更新订单信息
|
||||
* @param goodsOrder 商品订单
|
||||
* @param tradeOrder 交易订单
|
||||
*/
|
||||
void updateOrder(Object obj, PayRefundOrder refundOrder, PayTradeOrder tradeOrder);
|
||||
|
||||
/**
|
||||
* 调用入口
|
||||
* @param goodsOrde 商品订单
|
||||
* @return
|
||||
*/
|
||||
Object handle(PayRefundOrder refundOrder);
|
||||
|
||||
}
|
||||
+1
-1
@@ -46,7 +46,7 @@ public abstract class AbstractPayOrderHandler implements PayOrderHandler {
|
||||
*/
|
||||
@Override
|
||||
public void createGoodsOrder(PayGoodsOrder goodsOrder) {
|
||||
goodsOrder.setPayOrderId(paySequence.nextNo());
|
||||
goodsOrder.setPayOrderId(Long.parseLong(paySequence.nextNo()));
|
||||
goodsOrder.setStatus(OrderStatusEnum.INIT.getStatus());
|
||||
goodsOrderMapper.insert(goodsOrder);
|
||||
}
|
||||
|
||||
+2
-3
@@ -35,6 +35,7 @@ import lombok.AllArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
@@ -116,11 +117,9 @@ public class AlipayPayNotifyCallbackHandler extends AbstractPayNotifyCallbakHand
|
||||
|
||||
PayTradeOrder tradeOrder = tradeOrderService
|
||||
.getOne(Wrappers.<PayTradeOrder>lambdaQuery().eq(PayTradeOrder::getOrderId, orderNo));
|
||||
Long succTime = MapUtil.getLong(params, "time_end");
|
||||
tradeOrder.setPaySuccTime(succTime);
|
||||
tradeOrder.setPaySuccTime(LocalDateTime.now());
|
||||
tradeOrder.setChannelOrderNo(params.get("trade_no"));
|
||||
tradeOrder.setStatus(TradeStatusEnum.TRADE_SUCCESS.getStatus());
|
||||
tradeOrder.setChannelOrderNo(params.get("transaction_id"));
|
||||
tradeOrderService.updateById(tradeOrder);
|
||||
|
||||
return "success";
|
||||
|
||||
+142
@@ -0,0 +1,142 @@
|
||||
package com.pig4cloud.pigx.pay.handler.impl;
|
||||
|
||||
import cn.hutool.core.util.CharsetUtil;
|
||||
import cn.hutool.core.util.NumberUtil;
|
||||
import cn.hutool.extra.servlet.ServletUtil;
|
||||
import cn.hutool.json.JSONObject;
|
||||
import cn.hutool.json.JSONUtil;
|
||||
import com.alipay.api.domain.AlipayTradeRefundModel;
|
||||
import com.alipay.api.response.AlipayTradeRefundResponse;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import com.ijpay.alipay.AliPayApi;
|
||||
import com.ijpay.alipay.AliPayApiConfig;
|
||||
import com.ijpay.alipay.AliPayApiConfigKit;
|
||||
import com.pig4cloud.pigx.pay.entity.PayChannel;
|
||||
import com.pig4cloud.pigx.pay.entity.PayRefundOrder;
|
||||
import com.pig4cloud.pigx.pay.entity.PayTradeOrder;
|
||||
import com.pig4cloud.pigx.pay.handler.PayOrderRefundHandler;
|
||||
import com.pig4cloud.pigx.pay.mapper.PayChannelMapper;
|
||||
import com.pig4cloud.pigx.pay.mapper.PayRefundOrderMapper;
|
||||
import com.pig4cloud.pigx.pay.mapper.PayTradeOrderMapper;
|
||||
import com.pig4cloud.pigx.pay.utils.OrderStatusEnum;
|
||||
import com.pig4cloud.pigx.pay.utils.PayChannelNameEnum;
|
||||
import com.pig4cloud.pigx.pay.utils.TradeStatusEnum;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.SneakyThrows;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
/**
|
||||
* yungous 退款时限
|
||||
*
|
||||
* @author lengleng
|
||||
* @date 2023/3/1
|
||||
*/
|
||||
@Service("ALIPAY_REFUND")
|
||||
@RequiredArgsConstructor
|
||||
public class AlipayPayOrderRefundHandler implements PayOrderRefundHandler {
|
||||
|
||||
private final PayRefundOrderMapper refundOrderMapper;
|
||||
|
||||
private final PayChannelMapper channelMapper;
|
||||
|
||||
private final PayTradeOrderMapper tradeOrderMapper;
|
||||
|
||||
private final HttpServletRequest request;
|
||||
|
||||
@Override
|
||||
public PayChannel preparePayParams() {
|
||||
PayChannel channel = channelMapper.selectOne(
|
||||
Wrappers.<PayChannel>lambdaQuery().eq(PayChannel::getChannelId, PayChannelNameEnum.ALIPAY_WAP.name()));
|
||||
|
||||
if (channel == null) {
|
||||
throw new IllegalArgumentException("支付宝网页支付渠道配置为空");
|
||||
}
|
||||
|
||||
JSONObject params = JSONUtil.parseObj(channel.getParam());
|
||||
AliPayApiConfig aliPayApiConfig = AliPayApiConfig.builder().setAppId(channel.getAppId())
|
||||
.setPrivateKey(params.getStr("privateKey")).setCharset(CharsetUtil.UTF_8)
|
||||
.setAliPayPublicKey(params.getStr("publicKey")).setServiceUrl(params.getStr("serviceUrl"))
|
||||
.setSignType("RSA2").build();
|
||||
AliPayApiConfigKit.setThreadLocalAliPayApiConfig(aliPayApiConfig);
|
||||
return channel;
|
||||
}
|
||||
|
||||
/**
|
||||
* 创建商品退款订单
|
||||
* @param refundOrder 退款订单
|
||||
* @param tradeOrder 交易订单
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public PayRefundOrder createPayRefundOrder(PayRefundOrder refundOrder, PayTradeOrder tradeOrder) {
|
||||
refundOrder.setPayOrderId(tradeOrder.getOrderId());
|
||||
refundOrder.setChannelOrderNo(tradeOrder.getChannelOrderNo());
|
||||
refundOrder.setChannelId(PayChannelNameEnum.ALIPAY_WAP.getName());
|
||||
refundOrder.setChannelMchId(AliPayApiConfigKit.getAliPayApiConfig().getAppId());
|
||||
refundOrder.setClientIp(ServletUtil.getClientIP(request));
|
||||
refundOrder.setPayAmount(tradeOrder.getAmount());
|
||||
refundOrderMapper.insert(refundOrder);
|
||||
return refundOrder;
|
||||
}
|
||||
|
||||
/**
|
||||
* 调起渠道退款
|
||||
* @param refundOrder 商品退款订单
|
||||
* @param tradeOrder 交易订单
|
||||
* @return obj
|
||||
*/
|
||||
@Override
|
||||
@SneakyThrows
|
||||
public Object refund(PayRefundOrder refundOrder, PayTradeOrder tradeOrder) {
|
||||
AlipayTradeRefundModel refundModel = new AlipayTradeRefundModel();
|
||||
refundModel.setOutTradeNo(tradeOrder.getOrderId().toString());
|
||||
refundModel.setTradeNo(tradeOrder.getChannelOrderNo());
|
||||
refundModel.setRefundAmount(NumberUtil.div(refundOrder.getRefundAmount().toString(), "100", 2).toString());
|
||||
refundModel.setRefundReason(refundOrder.getRemark());
|
||||
return AliPayApi.tradeRefundToResponse(refundModel);
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新订单信息
|
||||
* @param refundOrder 退款订单
|
||||
* @param tradeOrder 交易订单
|
||||
*/
|
||||
@Override
|
||||
public void updateOrder(Object obj, PayRefundOrder refundOrder, PayTradeOrder tradeOrder) {
|
||||
AlipayTradeRefundResponse refundResponse = (AlipayTradeRefundResponse) obj;
|
||||
refundOrder.setMchRefundNo(refundResponse.getTradeNo());
|
||||
// 更新退款单状态成功
|
||||
refundOrder.setStatus(Integer.parseInt(TradeStatusEnum.TRADE_SUCCESS.getStatus()));
|
||||
refundOrder.setRefundSuccTime(LocalDateTime.now());
|
||||
refundOrderMapper.updateById(refundOrder);
|
||||
// 更新原订单为退款成功状态
|
||||
tradeOrder.setPaySuccTime(LocalDateTime.now());
|
||||
tradeOrder.setStatus(OrderStatusEnum.REFUND_SUCCESS.getStatus());
|
||||
tradeOrderMapper.updateById(tradeOrder);
|
||||
}
|
||||
|
||||
/**
|
||||
* 调用入口
|
||||
* @param refundOrder 退款订单
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public Object handle(PayRefundOrder refundOrder) {
|
||||
// 准备支付宝相关参数
|
||||
preparePayParams();
|
||||
// 根据订单ID查询交易订单
|
||||
PayTradeOrder payTradeOrder = tradeOrderMapper.selectOne(
|
||||
Wrappers.<PayTradeOrder>lambdaQuery().eq(PayTradeOrder::getOrderId, refundOrder.getPayOrderId()));
|
||||
// 创建退款单
|
||||
createPayRefundOrder(refundOrder, payTradeOrder);
|
||||
// 拉起支付宝退款
|
||||
Object refund = refund(refundOrder, payTradeOrder);
|
||||
// 更新库表状态
|
||||
updateOrder(refund, refundOrder, payTradeOrder);
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
+2
-2
@@ -119,7 +119,7 @@ public class AlipayWapPayOrderHandler extends AbstractPayOrderHandler {
|
||||
AlipayTradeWapPayModel model = new AlipayTradeWapPayModel();
|
||||
model.setBody(tradeOrder.getBody());
|
||||
model.setSubject(tradeOrder.getBody());
|
||||
model.setOutTradeNo(tradeOrder.getOrderId());
|
||||
model.setOutTradeNo(String.valueOf(tradeOrder.getOrderId()));
|
||||
model.setTimeoutExpress("30m");
|
||||
|
||||
// 分转成元 并且保留两位
|
||||
@@ -129,7 +129,7 @@ public class AlipayWapPayOrderHandler extends AbstractPayOrderHandler {
|
||||
try {
|
||||
log.info("拉起支付宝wap 支付参数 {}", model);
|
||||
AliPayApi.wapPay(response, model, ChannelPayApiConfigKit.get().getReturnUrl(),
|
||||
ChannelPayApiConfigKit.get().getNotifyUrl() + "/pay/notify/ali/callbak");
|
||||
ChannelPayApiConfigKit.get().getNotifyUrl() + "/admin/notify/ali/callbak");
|
||||
}
|
||||
catch (AlipayApiException e) {
|
||||
log.error("支付宝手机支付失败", e);
|
||||
|
||||
+4
-3
@@ -118,9 +118,10 @@ public class WeChatMpPayOrderHandler extends AbstractPayOrderHandler {
|
||||
// 预订单参数
|
||||
Map<String, String> params = UnifiedOrderModel.builder().appid(wxPayApiConfig.getAppId())
|
||||
.mch_id(wxPayApiConfig.getMchId()).nonce_str(WxPayKit.generateStr()).body(goodsOrder.getGoodsName())
|
||||
.attach(TenantContextHolder.getTenantId().toString()).out_trade_no(tradeOrder.getOrderId())
|
||||
.total_fee(goodsOrder.getAmount()).spbill_create_ip(ip)
|
||||
.notify_url(ChannelPayApiConfigKit.get().getNotifyUrl() + "/pay/notify/wx/callbak")
|
||||
.attach(TenantContextHolder.getTenantId().toString())
|
||||
.out_trade_no(String.valueOf(tradeOrder.getOrderId())).total_fee(goodsOrder.getAmount())
|
||||
.spbill_create_ip(ip)
|
||||
.notify_url(ChannelPayApiConfigKit.get().getNotifyUrl() + "/admin/notify/wx/callbak")
|
||||
.trade_type(TradeType.JSAPI.getTradeType()).openid(goodsOrder.getUserId()).build()
|
||||
.createSign(wxPayApiConfig.getPartnerKey(), SignType.HMACSHA256);
|
||||
|
||||
|
||||
+2
-2
@@ -35,6 +35,7 @@ import lombok.AllArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
@@ -111,8 +112,7 @@ public class WeChatPayNotifyCallbackHandler extends AbstractPayNotifyCallbakHand
|
||||
|
||||
PayTradeOrder tradeOrder = tradeOrderService
|
||||
.getOne(Wrappers.<PayTradeOrder>lambdaQuery().eq(PayTradeOrder::getOrderId, orderNo));
|
||||
Long succTime = MapUtil.getLong(params, "time_end");
|
||||
tradeOrder.setPaySuccTime(succTime);
|
||||
tradeOrder.setPaySuccTime(LocalDateTime.now());
|
||||
tradeOrder.setStatus(tradeStatus);
|
||||
tradeOrder.setChannelOrderNo(params.get("transaction_id"));
|
||||
tradeOrder.setErrMsg(params.get("err_code_des"));
|
||||
|
||||
+5
-4
@@ -1,7 +1,5 @@
|
||||
package com.pig4cloud.pigx.pay.handler.impl;
|
||||
|
||||
import cn.hutool.core.date.DatePattern;
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import cn.hutool.core.map.MapUtil;
|
||||
import cn.hutool.core.util.RandomUtil;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
@@ -19,6 +17,7 @@ import lombok.AllArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
@@ -102,9 +101,11 @@ public class YungouosMergePayNotifyCallbakHandler extends AbstractPayNotifyCallb
|
||||
|
||||
goodsOrderService.updateById(goodsOrder);
|
||||
|
||||
String succTime = MapUtil.getStr(params, "time");
|
||||
tradeOrder.setPaySuccTime(DateUtil.parse(succTime, DatePattern.NORM_DATETIME_FORMAT).getTime());
|
||||
tradeOrder.setPaySuccTime(LocalDateTime.now());
|
||||
tradeOrder.setChannelOrderNo(params.get("orderNo"));
|
||||
// 修改实际的支付渠道
|
||||
String payChannel = params.get(PayConstants.MERGE_OUT_TRADE_NO);
|
||||
tradeOrder.setChannelId(payChannel);
|
||||
tradeOrderService.updateById(tradeOrder);
|
||||
return "SUCCESS";
|
||||
}
|
||||
|
||||
+3
-3
@@ -87,9 +87,9 @@ public class YungouosMergePayOrderHandler extends AbstractPayOrderHandler {
|
||||
|
||||
String money = NumberUtil.div(tradeOrder.getAmount(), "100", 2).toString();
|
||||
|
||||
return MergePay.nativePay(tradeOrder.getOrderId(), money, channel.getChannelMchId(), tradeOrder.getBody(), "1",
|
||||
TenantContextHolder.getTenantId().toString(),
|
||||
ChannelPayApiConfigKit.get().getNotifyUrl() + "/pay/notify/merge/callbak",
|
||||
return MergePay.nativePay(String.valueOf(tradeOrder.getOrderId()), money, channel.getChannelMchId(),
|
||||
tradeOrder.getBody(), "1", TenantContextHolder.getTenantId().toString(),
|
||||
ChannelPayApiConfigKit.get().getNotifyUrl() + "/admin/notify/merge/callbak",
|
||||
ChannelPayApiConfigKit.get().getReturnUrl(), "", "", "", channel.getParam());
|
||||
}
|
||||
|
||||
|
||||
+7
@@ -28,4 +28,11 @@ import com.pig4cloud.pigx.pay.entity.PayRefundOrder;
|
||||
*/
|
||||
public interface PayRefundOrderService extends IService<PayRefundOrder> {
|
||||
|
||||
/**
|
||||
* 退款操作
|
||||
* @param refundOrder refundOrder
|
||||
* @return true/false
|
||||
*/
|
||||
Boolean refund(PayRefundOrder refundOrder);
|
||||
|
||||
}
|
||||
+27
@@ -16,12 +16,18 @@
|
||||
*/
|
||||
package com.pig4cloud.pigx.pay.service.impl;
|
||||
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.pig4cloud.pigx.pay.entity.PayRefundOrder;
|
||||
import com.pig4cloud.pigx.pay.handler.PayOrderRefundHandler;
|
||||
import com.pig4cloud.pigx.pay.mapper.PayRefundOrderMapper;
|
||||
import com.pig4cloud.pigx.pay.service.PayRefundOrderService;
|
||||
import com.pig4cloud.pigx.pay.utils.RefundNameEnum;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 退款
|
||||
*
|
||||
@@ -29,7 +35,28 @@ import org.springframework.stereotype.Service;
|
||||
* @date 2019-05-28 23:58:11
|
||||
*/
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
public class PayRefundOrderServiceImpl extends ServiceImpl<PayRefundOrderMapper, PayRefundOrder>
|
||||
implements PayRefundOrderService {
|
||||
|
||||
private final Map<String, PayOrderRefundHandler> refundHandlerMap;
|
||||
|
||||
/**
|
||||
* 退款操作
|
||||
* @param refundOrder refundOrder
|
||||
* @return true/false
|
||||
*/
|
||||
@Override
|
||||
public Boolean refund(PayRefundOrder refundOrder) {
|
||||
String channelId = refundOrder.getChannelId();
|
||||
// 判断用哪个通道
|
||||
if (StrUtil.containsAnyIgnoreCase(channelId, "ali")) {
|
||||
refundHandlerMap.get(RefundNameEnum.ALIPAY.getName()).handle(refundOrder);
|
||||
}
|
||||
else {
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
+5
@@ -28,6 +28,11 @@ public enum OrderStatusEnum {
|
||||
*/
|
||||
COMPLETE("2", "完成"),
|
||||
|
||||
/**
|
||||
* 退款成功
|
||||
*/
|
||||
REFUND_SUCCESS("5", "退款成功"),
|
||||
|
||||
/**
|
||||
* 订单支付失败
|
||||
*/
|
||||
|
||||
+5
@@ -43,4 +43,9 @@ public interface PayConstants {
|
||||
*/
|
||||
String MERGE_OUT_TRADE_NO = "outTradeNo";
|
||||
|
||||
/**
|
||||
* 支付渠道
|
||||
*/
|
||||
String PAY_CHANNEL = "payChannel";
|
||||
|
||||
}
|
||||
+13
@@ -0,0 +1,13 @@
|
||||
package com.pig4cloud.pigx.pay.utils;
|
||||
|
||||
/**
|
||||
* @author lengleng
|
||||
* @date 2023/3/1
|
||||
*
|
||||
* 支付异常错误
|
||||
*/
|
||||
public interface PayErrorCodes {
|
||||
|
||||
String UNSUPPORTED_OPERATION = "unsupported_operation";
|
||||
|
||||
}
|
||||
+36
@@ -0,0 +1,36 @@
|
||||
package com.pig4cloud.pigx.pay.utils;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
|
||||
/**
|
||||
* @author lengleng
|
||||
* @date 2019-05-30
|
||||
* <p>
|
||||
* 支付渠道名称
|
||||
*/
|
||||
@AllArgsConstructor
|
||||
public enum RefundNameEnum {
|
||||
|
||||
/**
|
||||
* 支付宝wap支付
|
||||
*/
|
||||
ALIPAY("ALIPAY_REFUND", "支付宝退款"),
|
||||
|
||||
/**
|
||||
* 微信H5支付
|
||||
*/
|
||||
WEIXIN("WEIXIN_REFUND", "微信退款");
|
||||
|
||||
/**
|
||||
* 名称
|
||||
*/
|
||||
@Getter
|
||||
private String name;
|
||||
|
||||
/**
|
||||
* 描述
|
||||
*/
|
||||
private String description;
|
||||
|
||||
}
|
||||
Reference in new issue
Block a user