xin
2025-07-08 83396a38be3c69c81f8acc4681c18f5dd0e698be
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
package com.oying.modules.sh.service.impl;
 
import com.oying.modules.sh.domain.OrderReturn;
import com.oying.utils.FileUtil;
import com.oying.utils.enums.ReturnAuditEnum;
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.OrderReturnService;
import com.oying.modules.sh.domain.dto.OrderReturnQueryCriteria;
import com.oying.modules.sh.mapper.OrderReturnMapper;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import com.oying.utils.PageUtil;
 
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;
 
/**
 * @author lixin
 * @description 服务实现
 * @date 2025-06-11
 **/
@Service
@RequiredArgsConstructor
public class OrderReturnServiceImpl extends ServiceImpl<OrderReturnMapper, OrderReturn> implements OrderReturnService {
 
    private final OrderReturnMapper orderReturnMapper;
 
    @Override
    public PageResult<OrderReturn> queryAll(OrderReturnQueryCriteria criteria, Page<Object> page) {
        return PageUtil.toPage(orderReturnMapper.findAll(criteria, page));
    }
 
    @Override
    public List<OrderReturn> queryAll(OrderReturnQueryCriteria criteria) {
        return orderReturnMapper.findAll(criteria);
    }
 
    @Override
    public OrderReturn getByReturnNum(String returnNum) {
        return orderReturnMapper.getByReturnNum(returnNum);
    }
 
    @Override
    public void updatePayStatus(String returnNum, String status, String time) {
        orderReturnMapper.updatePayStatus(returnNum, status, time);
    }
 
    @Override
    @Transactional(rollbackFor = Exception.class)
    public void create(OrderReturn resources) {
        orderReturnMapper.insert(resources);
    }
 
    @Override
    @Transactional(rollbackFor = Exception.class)
    public void update(OrderReturn resources) {
        OrderReturn orderReturn = getById(resources.getReturnId());
        orderReturn.copy(resources);
        orderReturnMapper.updateById(orderReturn);
    }
 
    @Override
    @Transactional(rollbackFor = Exception.class)
    public void deleteAll(List<Long> ids) {
        orderReturnMapper.deleteBatchIds(ids);
    }
 
    @Override
    public void download(List<OrderReturn> all, HttpServletResponse response) throws IOException {
        List<Map<String, Object>> list = new ArrayList<>();
        for (OrderReturn orderReturn : all) {
            Map<String, Object> map = new LinkedHashMap<>();
            map.put("退单号", orderReturn.getReturnNum());
            map.put("订单号", orderReturn.getOrderNum());
            map.put("用户", orderReturn.getUserId());
            map.put("门店ID", orderReturn.getStoreId());
            map.put("原金额", orderReturn.getOriginalPrice());
            map.put("折扣价", orderReturn.getPaidPrice());
            map.put("实付金额", orderReturn.getActuallyPayPrice());
            map.put("退款价格", orderReturn.getRefundPrice());
            map.put("退款状态", orderReturn.getRefundStatus());
            map.put("退款成功时间", orderReturn.getSuccessTime());
            map.put("退款渠道", orderReturn.getChannel());
            map.put("退款原因", orderReturn.getReason());
            map.put("备注", orderReturn.getRemark());
            map.put("图片", orderReturn.getPhotos());
            map.put("审核状态", ReturnAuditEnum.getValue(orderReturn.getAuditStatus()));
            map.put("审核人", orderReturn.getAuditUser());
            map.put("审核时间", orderReturn.getAuditTime());
            map.put("审核信息", orderReturn.getAuditMessage());
            map.put("创建人", orderReturn.getCreateBy());
            map.put("创建时间", orderReturn.getCreateTime());
            map.put("修改者", orderReturn.getUpdateBy());
            map.put("修改时间", orderReturn.getUpdateTime());
            list.add(map);
        }
        FileUtil.downloadExcel(list, response);
    }
}