From c1d20b425b10e8ba59f102dd1ab413055883eed0 Mon Sep 17 00:00:00 2001
From: 彭雪彬 <1724387007@qq.com>
Date: Mon, 14 Jul 2025 16:57:11 +0800
Subject: [PATCH] Merge remote-tracking branch 'origin/xin' into pxb

---
 oying-system/src/main/java/com/oying/modules/sh/service/impl/OrderOperationLogServiceImpl.java |  107 +++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 107 insertions(+), 0 deletions(-)

diff --git a/oying-system/src/main/java/com/oying/modules/sh/service/impl/OrderOperationLogServiceImpl.java b/oying-system/src/main/java/com/oying/modules/sh/service/impl/OrderOperationLogServiceImpl.java
new file mode 100644
index 0000000..d4b2546
--- /dev/null
+++ b/oying-system/src/main/java/com/oying/modules/sh/service/impl/OrderOperationLogServiceImpl.java
@@ -0,0 +1,107 @@
+package com.oying.modules.sh.service.impl;
+
+import com.alibaba.fastjson2.JSON;
+import com.oying.modules.sh.domain.Order;
+import com.oying.modules.sh.domain.OrderAddressSnapshot;
+import com.oying.modules.sh.domain.OrderOperationLog;
+import com.oying.utils.*;
+import com.oying.utils.enums.OrderStatusEnum;
+import lombok.RequiredArgsConstructor;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.oying.modules.sh.service.OrderOperationLogService;
+import com.oying.modules.sh.domain.dto.OrderOperationLogQueryCriteria;
+import com.oying.modules.sh.mapper.OrderOperationLogMapper;
+import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
+
+import java.sql.Timestamp;
+import java.util.List;
+import java.util.Map;
+import java.io.IOException;
+import javax.servlet.http.HttpServletResponse;
+import java.util.ArrayList;
+import java.util.LinkedHashMap;
+
+/**
+ * @author lixin
+ * @description 服务实现
+ * @date 2025-06-11
+ **/
+@Service
+@RequiredArgsConstructor
+public class OrderOperationLogServiceImpl extends ServiceImpl<OrderOperationLogMapper, OrderOperationLog> implements OrderOperationLogService {
+
+    private final OrderOperationLogMapper orderOperationLogMapper;
+
+    @Override
+    public PageResult<OrderOperationLog> queryAll(OrderOperationLogQueryCriteria criteria, Page<Object> page) {
+        return PageUtil.toPage(orderOperationLogMapper.findAll(criteria, page));
+    }
+
+    @Override
+    public List<OrderOperationLog> queryAll(OrderOperationLogQueryCriteria criteria) {
+        return orderOperationLogMapper.findAll(criteria);
+    }
+
+    @Override
+    public List<OrderOperationLog> getByOrderNum(String orderNum) {
+        return orderOperationLogMapper.getByOrderNum(orderNum);
+    }
+
+    @Override
+    @Transactional(rollbackFor = Exception.class)
+    public void create(OrderOperationLog resources) {
+        orderOperationLogMapper.insert(resources);
+    }
+
+    @Override
+    @Transactional(rollbackFor = Exception.class)
+    public void create(Order order, OrderAddressSnapshot addressSnapshot) {
+        Map<String, Object> map = new LinkedHashMap<>();
+        map.put("order", order);
+        map.put("address", addressSnapshot);
+        String username = SecurityUtils.getCurrentUsername();
+        Timestamp time = new Timestamp(System.currentTimeMillis());
+        OrderOperationLog resources = new OrderOperationLog();
+        resources.setOrderNum(order.getOrderNum());
+        resources.setUsername(username);
+        resources.setUserType(ConstantsKey.BUYER);
+        resources.setOperation(OrderStatusEnum.ZERO.getKey());
+        resources.setOperationDescribe(OrderStatusEnum.ZERO.getValue());
+        resources.setRemark(username + ":" + time + ">" + OrderStatusEnum.ZERO.getValue() + ":" + order.getOrderNum());
+        resources.setSnapshotData(JSON.toJSONString(map));
+        resources.setOperationTime(time);
+    }
+
+    @Override
+    @Transactional(rollbackFor = Exception.class)
+    public void update(OrderOperationLog resources) {
+        OrderOperationLog orderOperationLog = getById(resources.getLogId());
+        orderOperationLog.copy(resources);
+        orderOperationLogMapper.updateById(orderOperationLog);
+    }
+
+    @Override
+    @Transactional(rollbackFor = Exception.class)
+    public void deleteAll(List<Long> ids) {
+        orderOperationLogMapper.deleteBatchIds(ids);
+    }
+
+    @Override
+    public void download(List<OrderOperationLog> all, HttpServletResponse response) throws IOException {
+        List<Map<String, Object>> list = new ArrayList<>();
+        for (OrderOperationLog orderOperationLog : all) {
+            Map<String, Object> map = new LinkedHashMap<>();
+            map.put("用户账号", orderOperationLog.getUsername());
+            map.put("用户类型", orderOperationLog.getUserType());
+            map.put("用户操作", orderOperationLog.getOperation());
+            map.put("备注", orderOperationLog.getRemark());
+            map.put("操作时的订单快照", orderOperationLog.getSnapshotData());
+            map.put("操作时间", orderOperationLog.getOperationTime());
+            map.put("订单号", orderOperationLog.getOrderNum());
+            list.add(map);
+        }
+        FileUtil.downloadExcel(list, response);
+    }
+}

--
Gitblit v1.9.3