| | |
| | | import cc.mrbird.febs.common.annotation.Limit; |
| | | import cc.mrbird.febs.common.entity.FebsResponse; |
| | | import cc.mrbird.febs.common.entity.LimitType; |
| | | import cc.mrbird.febs.common.enumerates.OrderStatusEnum; |
| | | import cc.mrbird.febs.common.utils.MallUtils; |
| | | import cc.mrbird.febs.common.utils.ValidateEntityUtils; |
| | | import cc.mrbird.febs.mall.controller.dependentStation.constant.OrderConstants; |
| | | import cc.mrbird.febs.mall.dto.*; |
| | | import cc.mrbird.febs.mall.entity.MallOrderInfo; |
| | | import cc.mrbird.febs.mall.service.IApiMallOrderInfoService; |
| | |
| | | import cc.mrbird.febs.mall.vo.OrderListVo; |
| | | import cc.mrbird.febs.pay.service.IXcxPayService; |
| | | import cc.mrbird.febs.pay.service.LwPayService; |
| | | import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
| | | import io.swagger.annotations.Api; |
| | | import io.swagger.annotations.ApiOperation; |
| | | import io.swagger.annotations.ApiResponse; |
| | |
| | | |
| | | // 2. 获取订单详情 |
| | | MallOrderInfo order = mallOrderInfoService.getById(orderId); |
| | | if (order == null) { |
| | | return new FebsResponse().fail().message("订单创建失败"); |
| | | } |
| | | if (order != null |
| | | && OrderStatusEnum.WAIT_PAY.getValue() == order.getStatus() |
| | | ){ |
| | | |
| | | // 3. 调用 LWPAY 代收接口 |
| | | try { |
| | | String payUrl = lwPayService.createPayment( |
| | | order, |
| | | lwPayDto.getBankCode(), |
| | | lwPayDto.getNetwork() |
| | | // 3. 调用 LWPAY 代收接口 |
| | | try { |
| | | String payUrl = lwPayService.createPayment( |
| | | order, |
| | | lwPayDto.getBankCode(), |
| | | lwPayDto.getNetwork() |
| | | ); |
| | | |
| | | Map<String, Object> result = new HashMap<>(); |
| | | result.put("orderNo", order.getOrderNo()); |
| | | result.put("amount", order.getAmount()); |
| | | result.put("payUrl", payUrl); |
| | | return new FebsResponse().success().data(result); |
| | | } catch (Exception e) { |
| | | log.error("LWPAY 代收下单失败: orderId={}", orderId, e); |
| | | return new FebsResponse().fail().message("Payment channel exception: " + e.getMessage()); |
| | | } |
| | | } |
| | | return new FebsResponse().fail().message("Payment channel exception"); |
| | | } |
| | | |
| | | |
| | | |
| | | |
| | | @ApiOperation(value = "LWPAY支付", notes = "LWPAY支付") |
| | | @ApiResponses({ |
| | | @ApiResponse(code = 200, message = "success", response = ApiOrderPayVo.class) |
| | | }) |
| | | @PostMapping(value = "/payOrderByLwPay", produces = "application/json") |
| | | public FebsResponse payOrderByLwPay(@RequestBody @Validated ApiOrderPayDto payDto) { |
| | | |
| | | Long orderId = payDto.getOrderId(); |
| | | Integer payType = payDto.getPayType(); |
| | | // 2. 获取订单详情 |
| | | MallOrderInfo order = mallOrderInfoService.getById(orderId); |
| | | if (order != null |
| | | && OrderConstants.PAY_TYPE_SYSTEM == payType |
| | | && OrderStatusEnum.WAIT_PAY.getValue() == order.getStatus() |
| | | ){ |
| | | String orderNo = MallUtils.getOrderNum(); |
| | | order.setOrderNo(orderNo); |
| | | mallOrderInfoService.getBaseMapper().update( |
| | | null, |
| | | Wrappers.lambdaUpdate(MallOrderInfo.class) |
| | | .set(MallOrderInfo::getOrderNo, orderNo) |
| | | .eq(MallOrderInfo::getId, orderId) |
| | | ); |
| | | // 3. 调用 LWPAY 代收接口 |
| | | try { |
| | | String payUrl = lwPayService.createPayment( |
| | | order, |
| | | "967", |
| | | null |
| | | ); |
| | | |
| | | Map<String, Object> result = new HashMap<>(); |
| | | result.put("orderNo", order.getOrderNo()); |
| | | result.put("amount", order.getAmount()); |
| | | result.put("payUrl", payUrl); |
| | | return new FebsResponse().success().data(result).message("下单成功"); |
| | | } catch (Exception e) { |
| | | log.error("LWPAY 代收下单失败: orderId={}", orderId, e); |
| | | return new FebsResponse().fail().message("支付通道异常: " + e.getMessage()); |
| | | Map<String, Object> result = new HashMap<>(); |
| | | result.put("orderNo", order.getOrderNo()); |
| | | result.put("amount", order.getAmount()); |
| | | result.put("payUrl", payUrl); |
| | | return new FebsResponse().success().data(result).message("下单成功"); |
| | | } catch (Exception e) { |
| | | log.error("LWPAY 代收下单失败: orderId={}", orderId, e); |
| | | return new FebsResponse().fail().message("Payment channel exception: " + e.getMessage()); |
| | | } |
| | | } |
| | | return new FebsResponse().fail().message("Payment channel exception"); |
| | | } |
| | | |
| | | /** |