111
k94314517
2025-02-28 32a43e602e4a78478781532d31fbc38755188df7
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
package com.doumee.service.business.impl;
 
import com.doumee.core.constants.Constants;
import com.doumee.core.model.PageData;
import com.doumee.core.model.PageWrap;
import com.doumee.core.utils.Utils;
import com.doumee.dao.business.DiscountLogMapper;
import com.doumee.dao.business.model.DiscountLog;
import com.doumee.dao.business.model.DiscountMember;
import com.doumee.dao.system.model.SystemUser;
import com.doumee.service.business.DiscountLogService;
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.github.yulichang.wrapper.MPJLambdaWrapper;
import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;
 
import java.util.List;
import java.util.Objects;
 
/**
 * 用户套餐卡使用调整日志表Service实现
 * @author 江蹄蹄
 * @date 2025/02/17 09:43
 */
@Service
public class DiscountLogServiceImpl implements DiscountLogService {
 
    @Autowired
    private DiscountLogMapper discountLogMapper;
 
    @Override
    public String create(DiscountLog discountLog) {
        discountLogMapper.insert(discountLog);
        return discountLog.getId();
    }
 
    @Override
    public void deleteById(String id) {
        discountLogMapper.deleteById(id);
    }
 
    @Override
    public void delete(DiscountLog discountLog) {
        UpdateWrapper<DiscountLog> deleteWrapper = new UpdateWrapper<>(discountLog);
        discountLogMapper.delete(deleteWrapper);
    }
 
    @Override
    public void deleteByIdInBatch(List<String> ids) {
        if (CollectionUtils.isEmpty(ids)) {
            return;
        }
        discountLogMapper.deleteBatchIds(ids);
    }
 
    @Override
    public void updateById(DiscountLog discountLog) {
        discountLogMapper.updateById(discountLog);
    }
 
    @Override
    public void updateByIdInBatch(List<DiscountLog> discountLogs) {
        if (CollectionUtils.isEmpty(discountLogs)) {
            return;
        }
        for (DiscountLog discountLog: discountLogs) {
            this.updateById(discountLog);
        }
    }
 
    @Override
    public DiscountLog findById(String id) {
        return discountLogMapper.selectById(id);
    }
 
    @Override
    public DiscountLog findOne(DiscountLog discountLog) {
        QueryWrapper<DiscountLog> wrapper = new QueryWrapper<>(discountLog);
        return discountLogMapper.selectOne(wrapper);
    }
 
    @Override
    public List<DiscountLog> findList(DiscountLog discountLog) {
        QueryWrapper<DiscountLog> wrapper = new QueryWrapper<>(discountLog);
        return discountLogMapper.selectList(wrapper);
    }
  
    @Override
    public PageData<DiscountLog> findPage(PageWrap<DiscountLog> pageWrap) {
        IPage<DiscountLog> page = new Page<>(pageWrap.getPage(), pageWrap.getCapacity());
        MPJLambdaWrapper<DiscountLog> queryWrapper = new MPJLambdaWrapper<>();
        Utils.MP.blankToNull(pageWrap.getModel());
        DiscountLog model = pageWrap.getModel();
        queryWrapper.selectAll(DiscountLog.class)
                .selectAs(SystemUser::getRealname,DiscountLog::getCreatorName)
                .leftJoin(SystemUser.class,SystemUser::getId,DiscountLog::getCreator)
                .eq(DiscountLog::getIsdeleted, Constants.ZERO)
                .eq(Objects.nonNull(model.getType()),DiscountLog::getType,model.getType())
                .eq(StringUtils.isNotBlank(model.getDiscountMemberId()),DiscountLog::getDiscountMemberId,model.getDiscountMemberId());
        PageData<DiscountLog> pageData = PageData.from(discountLogMapper.selectJoinPage(page, DiscountLog.class,queryWrapper));
        if(com.github.xiaoymin.knife4j.core.util.CollectionUtils.isNotEmpty(pageData.getRecords())){
            for (DiscountLog discountLog:pageData.getRecords()) {
                if(Constants.equalsInteger(discountLog.getType(),Constants.ZERO)&&Objects.nonNull(discountLog.getRidePrice())){
                    discountLog.setRidePrice(
                            Constants.translateMoney(discountLog.getRidePrice())
                    );
                }
            }
        }
        return pageData;
    }
 
    @Override
    public long count(DiscountLog discountLog) {
        QueryWrapper<DiscountLog> wrapper = new QueryWrapper<>(discountLog);
        return discountLogMapper.selectCount(wrapper);
    }
}