MrShi
5 小时以前 e50954f0708ecbbc672352102ae3b24279d40cc1
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
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
package com.doumee.service.business.impl;
 
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.doumee.core.constants.Constants;
import com.doumee.core.exception.BusinessException;
import com.doumee.core.model.PageData;
import com.doumee.core.model.PageWrap;
import com.doumee.core.utils.Utils;
import com.doumee.dao.business.OtherOrdersMapper;
import com.doumee.dao.business.model.OtherOrders;
import com.doumee.service.business.OtherOrdersService;
import com.github.yulichang.wrapper.MPJLambdaWrapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
 
import java.util.List;
import java.util.Objects;
 
/**
 * 其他订单记录Service实现
 * @author rk
 * @date 2026/04/16
 */
@Service
public class OtherOrdersServiceImpl implements OtherOrdersService {
 
    @Autowired
    private OtherOrdersMapper otherOrdersMapper;
 
    @Override
    public Integer create(OtherOrders otherOrders) {
        otherOrdersMapper.insert(otherOrders);
        return otherOrders.getId();
    }
 
    @Override
    public void deleteById(Integer id) {
        otherOrdersMapper.update(new UpdateWrapper<OtherOrders>().lambda()
                .set(OtherOrders::getDeleted, Constants.ONE)
                .eq(OtherOrders::getId, id));
    }
 
    @Override
    public void delete(OtherOrders otherOrders) {
        UpdateWrapper<OtherOrders> deleteWrapper = new UpdateWrapper<>(otherOrders);
        otherOrdersMapper.delete(deleteWrapper);
    }
 
    @Override
    public void deleteByIdInBatch(List<Integer> ids) {
        if (ids == null || ids.isEmpty()) {
            return;
        }
        otherOrdersMapper.deleteBatchIds(ids);
    }
 
    @Override
    public void updateById(OtherOrders otherOrders) {
        otherOrdersMapper.updateById(otherOrders);
    }
 
    @Override
    public void updateByIdInBatch(List<OtherOrders> otherOrdersList) {
        if (otherOrdersList == null || otherOrdersList.isEmpty()) {
            return;
        }
        for (OtherOrders otherOrders : otherOrdersList) {
            this.updateById(otherOrders);
        }
    }
 
    @Override
    public OtherOrders findById(Integer id) {
        OtherOrders otherOrders = otherOrdersMapper.selectById(id);
        if (Objects.isNull(otherOrders)) {
            throw new BusinessException(com.doumee.core.constants.ResponseStatus.DATA_EMPTY);
        }
        return otherOrders;
    }
 
    @Override
    public OtherOrders findOne(OtherOrders otherOrders) {
        QueryWrapper<OtherOrders> wrapper = new QueryWrapper<>(otherOrders);
        return otherOrdersMapper.selectOne(wrapper);
    }
 
    @Override
    public List<OtherOrders> findList(OtherOrders otherOrders) {
        QueryWrapper<OtherOrders> wrapper = new QueryWrapper<>(otherOrders);
        return otherOrdersMapper.selectList(wrapper);
    }
 
    @Override
    public PageData<OtherOrders> findPage(PageWrap<OtherOrders> pageWrap) {
        IPage<OtherOrders> page = new Page<>(pageWrap.getPage(), pageWrap.getCapacity());
        MPJLambdaWrapper<OtherOrders> queryWrapper = new MPJLambdaWrapper<OtherOrders>()
                .selectAll(OtherOrders.class);
        Utils.MP.blankToNull(pageWrap.getModel());
        pageWrap.getModel().setDeleted(Constants.ZERO);
        OtherOrders model = pageWrap.getModel();
        if (model.getType() != null) {
            queryWrapper.eq(OtherOrders::getType, model.getType());
        }
        if (model.getMemberId() != null) {
            queryWrapper.eq(OtherOrders::getMemberId, model.getMemberId());
        }
        if (model.getPayStatus() != null) {
            queryWrapper.eq(OtherOrders::getPayStatus, model.getPayStatus());
        }
        if (model.getOrderId() != null) {
            queryWrapper.eq(OtherOrders::getOrderId, model.getOrderId());
        }
        for (PageWrap.SortData sortData : pageWrap.getSorts()) {
            if (sortData.getDirection().equalsIgnoreCase(PageWrap.DESC)) {
                queryWrapper.orderByDesc(sortData.getProperty());
            } else {
                queryWrapper.orderByAsc(sortData.getProperty());
            }
        }
        return PageData.from(otherOrdersMapper.selectJoinPage(page, OtherOrders.class, queryWrapper));
    }
 
    @Override
    public long count(OtherOrders otherOrders) {
        QueryWrapper<OtherOrders> wrapper = new QueryWrapper<>(otherOrders);
        return otherOrdersMapper.selectCount(wrapper);
    }
}