xin
2025-07-17 8c551068472e529a98b3eb27c9e347a924e48bf8
oying-system/src/main/java/com/oying/modules/sh/service/impl/OrderOperationLogServiceImpl.java
@@ -1,7 +1,11 @@
package com.oying.modules.sh.service.impl;
import com.alibaba.fastjson2.JSON;
import com.oying.modules.sh.domain.OrderOperationLog;
import com.oying.utils.FileUtil;
import com.oying.modules.sh.domain.vo.OrderResponse;
import com.oying.modules.sh.mapper.OrderMapper;
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;
@@ -10,40 +14,86 @@
import com.oying.modules.sh.mapper.OrderOperationLogMapper;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import com.oying.utils.PageUtil;
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;
import com.oying.utils.PageResult;
/**
* @description 服务实现
* @author lixin
* @date 2025-06-11
**/
 * @author lixin
 * @description 服务实现
 * @date 2025-06-11
 **/
@Service
@RequiredArgsConstructor
public class OrderOperationLogServiceImpl extends ServiceImpl<OrderOperationLogMapper, OrderOperationLog> implements OrderOperationLogService {
    private final OrderOperationLogMapper orderOperationLogMapper;
    private final OrderMapper orderMapper;
    @Override
    public PageResult<OrderOperationLog> queryAll(OrderOperationLogQueryCriteria criteria, Page<Object> page){
    public PageResult<OrderOperationLog> queryAll(OrderOperationLogQueryCriteria criteria, Page<Object> page) {
        return PageUtil.toPage(orderOperationLogMapper.findAll(criteria, page));
    }
    @Override
    public List<OrderOperationLog> queryAll(OrderOperationLogQueryCriteria criteria){
    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) {
    public void create(OrderResponse response, OrderStatusEnum statusEnum, String cardName) {
        String userType = ConstantsKey.BUYER;
        String username = null;
        switch (statusEnum) {
            case ZERO:
            case ONE:
            case EIGHT:
            case NINE:
                userType = ConstantsKey.BUYER;
                break;
            case TWO:
                username = response.getOrder().getUsername();
            case FOUR:
                userType = ConstantsKey.MERCHANT;
                break;
            case THREE:
                orderMapper.updateRider(response.getOrder().getOrderNum(), SecurityUtils.getCurrentUserId(), SecurityUtils.getCurrentUsername(), cardName);
            case FIVE:
            case SIX:
            case SEVEN:
                userType = ConstantsKey.RIDER;
                break;
            default:
        }
        if (username == null) {
            username = SecurityUtils.getCurrentUsername();
        }
        Timestamp time = new Timestamp(System.currentTimeMillis());
        OrderOperationLog resources = new OrderOperationLog();
        resources.setOrderNum(response.getOrder().getOrderNum());
        resources.setUsername(username);
        resources.setUserType(userType);
        resources.setOperation(statusEnum.getKey());
        resources.setOperationDescribe(statusEnum.getValue());
        resources.setRemark(username + ":" + time + ">" + statusEnum.getValue() + ":" + response.getOrder().getOrderNum());
        Map<String, Object> map = new LinkedHashMap<>();
        map.put("order", response.getOrder());
        map.put("address", response.getAddress());
        resources.setSnapshotData(JSON.toJSONString(map));
        resources.setOperationTime(time);
        orderOperationLogMapper.insert(resources);
        orderMapper.updateOrderStatus(response.getOrder().getOrderNum(), statusEnum.getKey(), statusEnum.getValue());
    }
    @Override
@@ -65,7 +115,7 @@
        List<Map<String, Object>> list = new ArrayList<>();
        for (OrderOperationLog orderOperationLog : all) {
            Map<String, Object> map = new LinkedHashMap<>();
            map.put("用户id", orderOperationLog.getUserId());
            map.put("用户账号", orderOperationLog.getUsername());
            map.put("用户类型", orderOperationLog.getUserType());
            map.put("用户操作", orderOperationLog.getOperation());
            map.put("备注", orderOperationLog.getRemark());