diff --git a/agileboot-admin/src/main/java/com/agileboot/admin/controller/shop/ShopGoodsController.java b/agileboot-admin/src/main/java/com/agileboot/admin/controller/shop/ShopGoodsController.java
index b302885..6904b44 100644
--- a/agileboot-admin/src/main/java/com/agileboot/admin/controller/shop/ShopGoodsController.java
+++ b/agileboot-admin/src/main/java/com/agileboot/admin/controller/shop/ShopGoodsController.java
@@ -14,20 +14,13 @@ import io.swagger.v3.oas.annotations.Operation;
import java.util.List;
import lombok.RequiredArgsConstructor;
import org.springframework.validation.annotation.Validated;
-import org.springframework.web.bind.annotation.GetMapping;
-import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.*;
-import org.springframework.web.bind.annotation.RestController;
import com.agileboot.common.core.base.BaseController;
import com.agileboot.domain.shop.goods.command.AddGoodsCommand;
import com.agileboot.domain.shop.goods.command.UpdateGoodsCommand;
import javax.validation.constraints.NotNull;
import org.springframework.security.access.prepost.PreAuthorize;
-import org.springframework.web.bind.annotation.DeleteMapping;
-import org.springframework.web.bind.annotation.PathVariable;
-import org.springframework.web.bind.annotation.PostMapping;
-import org.springframework.web.bind.annotation.PutMapping;
-import org.springframework.web.bind.annotation.RequestBody;
/**
*
@@ -83,5 +76,16 @@ public class ShopGoodsController extends BaseController {
goodsApplicationService.updateGoods(command);
return ResponseDTO.ok();
}
+
+ /**
+ * 获取单个商品信息
+ */
+ @Operation(summary = "商品列表")
+// @PreAuthorize("@permission.has('shop:goods:list')")
+ @GetMapping("/getGoodsInfo")
+ public ResponseDTO getGoodsInfo(@RequestParam Long goodsId) {
+ ShopGoodsDTO goodsInfo = goodsApplicationService.getGoodsInfo(goodsId);
+ return ResponseDTO.ok(goodsInfo);
+ }
}
diff --git a/agileboot-api/src/main/java/com/agileboot/api/controller/OrderController.java b/agileboot-api/src/main/java/com/agileboot/api/controller/OrderController.java
index 0ddb279..0634e1f 100644
--- a/agileboot-api/src/main/java/com/agileboot/api/controller/OrderController.java
+++ b/agileboot-api/src/main/java/com/agileboot/api/controller/OrderController.java
@@ -3,6 +3,8 @@ package com.agileboot.api.controller;
import cn.hutool.json.JSONUtil;
import com.agileboot.common.constant.PayApiConstants;
import com.agileboot.common.core.base.BaseController;
+import com.agileboot.common.exception.ApiException;
+import com.agileboot.common.exception.error.ErrorCode;
import com.agileboot.domain.cabinet.operation.command.AddCabinetCellOperationCommand;
import com.agileboot.domain.shop.order.dto.CreateOrderResult;
import com.agileboot.domain.shop.order.dto.GetOrdersByOpenIdDTO;
@@ -10,7 +12,11 @@ import com.agileboot.domain.shop.order.model.OrderGoodsModelFactory;
import com.agileboot.domain.shop.order.model.OrderModel;
import com.agileboot.domain.shop.payment.PaymentApplicationService;
import com.agileboot.domain.shop.payment.dto.RefundVO;
+import com.agileboot.domain.shop.paymentOperationLog.PaymentOperationLogApplicationService;
+import com.agileboot.domain.shop.paymentOperationLog.command.AddPaymentOperationLogCommand;
import lombok.extern.slf4j.Slf4j;
+
+import org.apache.commons.lang3.exception.ExceptionUtils;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import com.agileboot.common.core.dto.ResponseDTO;
@@ -33,6 +39,7 @@ public class OrderController extends BaseController {
private final OrderApplicationService orderApplicationService;
private final PaymentApplicationService paymentApplicationService;
+ private final PaymentOperationLogApplicationService paymentOperationLogApplicationService;
/**
* 提交订单接口
@@ -41,8 +48,20 @@ public class OrderController extends BaseController {
*/
@PostMapping("/submit")
public ResponseDTO submitOrder(@Validated @RequestBody SubmitOrderCommand command) {
- CreateOrderResult result = orderApplicationService.createOrder(command);
- return ResponseDTO.ok(result);
+ try {
+ CreateOrderResult result = orderApplicationService.createOrder(command);
+ return ResponseDTO.ok(result);
+ } catch (Exception e) {
+ log.error("submitOrder error: ", e);
+ AddPaymentOperationLogCommand paymentOperationLogCommand = new AddPaymentOperationLogCommand();
+ paymentOperationLogCommand.setParams(JSONUtil.toJsonStr(command));
+ paymentOperationLogCommand.setOperationType("submitOrder");
+ paymentOperationLogCommand.setStatus(2);
+ paymentOperationLogCommand.setRemark(ExceptionUtils.getStackTrace(e));
+ paymentOperationLogCommand.initBaseEntity();
+ paymentOperationLogApplicationService.addPaymentOperationLog(paymentOperationLogCommand);
+ return ResponseDTO.fail(new ApiException(ErrorCode.Internal.INTERNAL_ERROR, e));
+ }
}
/**
diff --git a/agileboot-api/src/main/java/com/agileboot/api/controller/PaymentController.java b/agileboot-api/src/main/java/com/agileboot/api/controller/PaymentController.java
index 6f9bc4b..aa51f1f 100644
--- a/agileboot-api/src/main/java/com/agileboot/api/controller/PaymentController.java
+++ b/agileboot-api/src/main/java/com/agileboot/api/controller/PaymentController.java
@@ -28,6 +28,8 @@ import java.nio.charset.StandardCharsets;
import java.util.*;
import javax.servlet.http.HttpServletRequest;
+import com.agileboot.domain.shop.paymentOperationLog.PaymentOperationLogApplicationService;
+import com.agileboot.domain.shop.paymentOperationLog.command.AddPaymentOperationLogCommand;
import com.agileboot.domain.system.menu.MenuApplicationService;
import com.agileboot.domain.system.menu.dto.RouterDTO;
import com.agileboot.domain.system.user.db.SysUserEntity;
@@ -63,6 +65,7 @@ public class PaymentController {
private final SysUserQyUserApplicationService sysUserQyUserApplicationService;
private final MenuApplicationService menuApplicationService;
private final PaymentApplicationService paymentApplicationService;
+ private final PaymentOperationLogApplicationService paymentOperationLogApplicationService;
// 新增回调接口
/**
@@ -78,6 +81,13 @@ public class PaymentController {
@PostMapping("/callback")
public String paymentCallback(HttpServletRequest request, @RequestBody String requestBody) {
log.info("支付回调requestBody:{}", requestBody);
+ // 记录支付操作日志
+ AddPaymentOperationLogCommand paymentOperationLogCommand = new AddPaymentOperationLogCommand();
+ paymentOperationLogCommand.setOperationType("payCallback");
+ paymentOperationLogCommand.setStatus(1);
+ paymentOperationLogCommand.setRemark(requestBody);
+ paymentOperationLogCommand.initBaseEntity();
+ paymentOperationLogApplicationService.addPaymentOperationLog(paymentOperationLogCommand);
try {
paymentApplicationService.paymentCallback(requestBody);
return "success";
@@ -108,6 +118,13 @@ public class PaymentController {
@PostMapping("/refund/callback")
public String refundCallback(HttpServletRequest request, @RequestBody String requestBody) {
log.info("退款回调requestBody:{}", requestBody);
+ // 记录支付操作日志
+ AddPaymentOperationLogCommand paymentOperationLogCommand = new AddPaymentOperationLogCommand();
+ paymentOperationLogCommand.setOperationType("refundCallback");
+ paymentOperationLogCommand.setStatus(1);
+ paymentOperationLogCommand.setRemark(requestBody);
+ paymentOperationLogCommand.initBaseEntity();
+ paymentOperationLogApplicationService.addPaymentOperationLog(paymentOperationLogCommand);
try {
return paymentApplicationService.refundCallback(requestBody);
} catch (Exception e) {
diff --git a/agileboot-domain/src/main/java/com/agileboot/domain/shop/approval/ReturnApprovalApplicationService.java b/agileboot-domain/src/main/java/com/agileboot/domain/shop/approval/ReturnApprovalApplicationService.java
index dec2d59..248eafb 100644
--- a/agileboot-domain/src/main/java/com/agileboot/domain/shop/approval/ReturnApprovalApplicationService.java
+++ b/agileboot-domain/src/main/java/com/agileboot/domain/shop/approval/ReturnApprovalApplicationService.java
@@ -1,5 +1,6 @@
package com.agileboot.domain.shop.approval;
+import cn.hutool.json.JSONUtil;
import com.agileboot.common.constant.PayApiConstants;
import com.agileboot.common.constant.WeixinConstants;
import com.agileboot.common.core.page.PageDTO;
@@ -32,6 +33,8 @@ import com.agileboot.domain.shop.order.model.OrderModel;
import com.agileboot.domain.shop.order.model.OrderModelFactory;
import com.agileboot.domain.shop.payment.PaymentApplicationService;
import com.agileboot.domain.shop.payment.dto.RefundVO;
+import com.agileboot.domain.shop.paymentOperationLog.PaymentOperationLogApplicationService;
+import com.agileboot.domain.shop.paymentOperationLog.command.AddPaymentOperationLogCommand;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import java.math.BigDecimal;
@@ -45,6 +48,7 @@ import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.ObjectUtils;
import org.apache.commons.lang3.StringUtils;
+import org.apache.commons.lang3.exception.ExceptionUtils;
import org.springframework.stereotype.Service;
/**
@@ -66,6 +70,7 @@ public class ReturnApprovalApplicationService {
private final QyUserService qyUserService;
private final CabinetCellModelFactory cabinetCellModelFactory;
private final QyUserService userService;
+ private final PaymentOperationLogApplicationService paymentOperationLogApplicationService;
/**
* 获取退货审批列表
@@ -150,7 +155,22 @@ public class ReturnApprovalApplicationService {
PayApiConstants.biz_id, PayApiConstants.appkey,
orderModel.getBizOrderId(), orderModel.getUcid(),
"退还", returnAmount.intValue());
+
+ AddPaymentOperationLogCommand paymentOperationLogCommand = new AddPaymentOperationLogCommand();
+ paymentOperationLogCommand.setParams(JSONUtil.toJsonStr(command));
+ paymentOperationLogCommand.setOperationType("refund");
+ paymentOperationLogCommand.setStatus(1);
+ paymentOperationLogCommand.setRemark(JSONUtil.toJsonStr(refundVO));
+ paymentOperationLogCommand.initBaseEntity();
+ paymentOperationLogApplicationService.addPaymentOperationLog(paymentOperationLogCommand);
} catch (Exception e) {
+ AddPaymentOperationLogCommand paymentOperationLogCommand = new AddPaymentOperationLogCommand();
+ paymentOperationLogCommand.setParams(JSONUtil.toJsonStr(command));
+ paymentOperationLogCommand.setOperationType("refund");
+ paymentOperationLogCommand.setStatus(2);
+ paymentOperationLogCommand.setRemark(ExceptionUtils.getStackTrace(e));
+ paymentOperationLogCommand.initBaseEntity();
+ paymentOperationLogApplicationService.addPaymentOperationLog(paymentOperationLogCommand);
throw new RuntimeException("退款失败", e);
}
log.info("退款结果:{}", refundVO);
diff --git a/agileboot-domain/src/main/java/com/agileboot/domain/shop/goods/GoodsApplicationService.java b/agileboot-domain/src/main/java/com/agileboot/domain/shop/goods/GoodsApplicationService.java
index 021fa04..63bd019 100644
--- a/agileboot-domain/src/main/java/com/agileboot/domain/shop/goods/GoodsApplicationService.java
+++ b/agileboot-domain/src/main/java/com/agileboot/domain/shop/goods/GoodsApplicationService.java
@@ -65,4 +65,8 @@ public class GoodsApplicationService {
public List getGoodsWithCabinetList() {
return shopGoodsService.getGoodsWithCabinetList();
}
+
+ public ShopGoodsDTO getGoodsInfo(Long goodsId) {
+ return new ShopGoodsDTO(shopGoodsService.getGoodsInfo(goodsId));
+ }
}
diff --git a/agileboot-domain/src/main/java/com/agileboot/domain/shop/goods/db/ShopGoodsMapper.java b/agileboot-domain/src/main/java/com/agileboot/domain/shop/goods/db/ShopGoodsMapper.java
index eac2f94..a5fb338 100644
--- a/agileboot-domain/src/main/java/com/agileboot/domain/shop/goods/db/ShopGoodsMapper.java
+++ b/agileboot-domain/src/main/java/com/agileboot/domain/shop/goods/db/ShopGoodsMapper.java
@@ -71,4 +71,14 @@ public interface ShopGoodsMapper extends BaseMapper {
"LEFT JOIN smart_cabinet sc ON cc.cabinet_id = sc.cabinet_id " +
"WHERE g.deleted = 0 AND sc.deleted = 0 AND cc.deleted = 0 AND cc.goods_id IS NOT NULL ")
List getGoodsWithCabinetList();
+
+ @Select("SELECT g.goods_id, g.goods_name, g.category_id, g.price, " +
+ "g.stock, g.status, g.auto_approval, g.cover_img, SUM(cc.stock) AS total_stock, " +
+ "GROUP_CONCAT(DISTINCT cc.cell_no) AS cell_no_str, " +
+ "GROUP_CONCAT(DISTINCT sc.cabinet_name) AS cabinet_name " +
+ "FROM shop_goods g " +
+ "LEFT JOIN cabinet_cell cc ON g.goods_id = cc.goods_id AND cc.deleted = 0 " +
+ "LEFT JOIN smart_cabinet sc ON cc.cabinet_id = sc.cabinet_id AND sc.deleted = 0 " +
+ "WHERE g.goods_id = #{goodsId} ")
+ SearchGoodsDO getGoodsInfo(@Param("goodsId") Long goodsId);
}
diff --git a/agileboot-domain/src/main/java/com/agileboot/domain/shop/goods/db/ShopGoodsService.java b/agileboot-domain/src/main/java/com/agileboot/domain/shop/goods/db/ShopGoodsService.java
index 9260f3a..9385bc3 100644
--- a/agileboot-domain/src/main/java/com/agileboot/domain/shop/goods/db/ShopGoodsService.java
+++ b/agileboot-domain/src/main/java/com/agileboot/domain/shop/goods/db/ShopGoodsService.java
@@ -3,6 +3,7 @@ package com.agileboot.domain.shop.goods.db;
import com.agileboot.common.core.page.AbstractPageQuery;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.IService;
+
import java.util.List;
/**
@@ -19,4 +20,6 @@ public interface ShopGoodsService extends IService {
List selectAll();
List getGoodsWithCabinetList();
+
+ SearchGoodsDO getGoodsInfo(Long goodsId);
}
diff --git a/agileboot-domain/src/main/java/com/agileboot/domain/shop/goods/db/ShopGoodsServiceImpl.java b/agileboot-domain/src/main/java/com/agileboot/domain/shop/goods/db/ShopGoodsServiceImpl.java
index 40c2c3b..0e47da8 100644
--- a/agileboot-domain/src/main/java/com/agileboot/domain/shop/goods/db/ShopGoodsServiceImpl.java
+++ b/agileboot-domain/src/main/java/com/agileboot/domain/shop/goods/db/ShopGoodsServiceImpl.java
@@ -34,4 +34,9 @@ public class ShopGoodsServiceImpl extends ServiceImpl getGoodsWithCabinetList() {
return baseMapper.getGoodsWithCabinetList();
}
+
+ @Override
+ public SearchGoodsDO getGoodsInfo(Long goodsId) {
+ return baseMapper.getGoodsInfo(goodsId);
+ }
}
diff --git a/agileboot-domain/src/main/java/com/agileboot/domain/shop/order/OrderApplicationService.java b/agileboot-domain/src/main/java/com/agileboot/domain/shop/order/OrderApplicationService.java
index 196bfb5..0e93e0f 100644
--- a/agileboot-domain/src/main/java/com/agileboot/domain/shop/order/OrderApplicationService.java
+++ b/agileboot-domain/src/main/java/com/agileboot/domain/shop/order/OrderApplicationService.java
@@ -36,6 +36,8 @@ import com.agileboot.domain.shop.order.query.SearchShopOrderQuery;
import com.agileboot.domain.shop.payment.PaymentApplicationService;
import com.agileboot.domain.shop.payment.dto.WxJsApiPreCreateRequest;
import com.agileboot.domain.shop.payment.dto.WxJsApiPreCreateResponse;
+import com.agileboot.domain.shop.paymentOperationLog.PaymentOperationLogApplicationService;
+import com.agileboot.domain.shop.paymentOperationLog.command.AddPaymentOperationLogCommand;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import java.math.BigDecimal;
import java.math.RoundingMode;
@@ -48,6 +50,7 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
+import org.apache.commons.lang3.exception.ExceptionUtils;
import org.checkerframework.checker.units.qual.s;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
@@ -69,6 +72,7 @@ public class OrderApplicationService {
private final QyUserService userService;
private final QyUserModelFactory qyUserModelFactory;
private final CabinetCellOperationModelFactory cabinetCellOperationModelFactory;
+ private final PaymentOperationLogApplicationService paymentOperationLogApplicationService;
public PageDTO getOrderList(SearchShopOrderQuery query) {
Page page = orderService.page(query.toPage(), query.toQueryWrapper());
@@ -164,6 +168,14 @@ public class OrderApplicationService {
// 新增支付接口调用
WxJsApiPreCreateRequest paymentRequest = buildPaymentRequest(orderModel);
WxJsApiPreCreateResponse paymentResponse = paymentApplicationService.callJsApiPreCreate(paymentRequest);
+ // 记录支付操作日志
+ AddPaymentOperationLogCommand paymentOperationLogCommand = new AddPaymentOperationLogCommand();
+ paymentOperationLogCommand.setParams(JSONUtil.toJsonStr(command));
+ paymentOperationLogCommand.setOperationType("callJsApiPreCreate");
+ paymentOperationLogCommand.setStatus(1);
+ paymentOperationLogCommand.setRemark(JSONUtil.toJsonStr(paymentResponse));
+ paymentOperationLogCommand.initBaseEntity();
+ paymentOperationLogApplicationService.addPaymentOperationLog(paymentOperationLogCommand);
return new CreateOrderResult(orderModel.getOrderId(), orderModel.getTotalAmount(), paymentResponse, BigDecimal.valueOf(0));
} else if (Objects.equals(command.getPaymentType(), "balance")) {
diff --git a/agileboot-domain/src/main/java/com/agileboot/domain/shop/paymentOperationLog/db/PaymentOperationLogEntity.java b/agileboot-domain/src/main/java/com/agileboot/domain/shop/paymentOperationLog/db/PaymentOperationLogEntity.java
index f698e25..1f1b7cd 100644
--- a/agileboot-domain/src/main/java/com/agileboot/domain/shop/paymentOperationLog/db/PaymentOperationLogEntity.java
+++ b/agileboot-domain/src/main/java/com/agileboot/domain/shop/paymentOperationLog/db/PaymentOperationLogEntity.java
@@ -39,10 +39,17 @@ public class PaymentOperationLogEntity extends BaseEntity