puzhibing
2023-05-30 6d05cda0141cbd42a9b8810e539f5dcd8df506f0
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
package com.stylefeng.guns.modular.system.service.impl;
 
import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.stylefeng.guns.core.shiro.ShiroKit;
import com.stylefeng.guns.core.util.DateUtil;
import com.stylefeng.guns.modular.system.controller.resp.TRechargeRecordUserResp;
import com.stylefeng.guns.modular.system.model.TBill;
import com.stylefeng.guns.modular.system.dao.TBillMapper;
import com.stylefeng.guns.modular.system.service.ITBillService;
import com.baomidou.mybatisplus.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.StringUtils;
 
import java.util.Date;
import java.util.List;
import java.util.Objects;
import java.util.stream.Collectors;
 
/**
 * <p>
 * 发票管理 服务实现类
 * </p>
 *
 * @author stylefeng
 * @since 2023-03-14
 */
@Service
public class TBillServiceImpl extends ServiceImpl<TBillMapper, TBill> implements ITBillService {
 
    @Autowired
    private TBillMapper tBillMapper;
 
    @Override
    public EntityWrapper<TBill> getPageListWrapper(String createTime, String addresseePhone, Integer state, Integer billType, Integer billHeaderType) {
        EntityWrapper<TBill> wrapper = new EntityWrapper<>();
 
        if(StringUtils.hasLength(createTime)){
            String[] split = createTime.split(" - ");
            Date startTime = DateUtil.getDate_str4(split[0]);
            Date endTime = DateUtil.getDate_str4(split[1]);
            wrapper.between("createTime",startTime,endTime);
        }
        if(StringUtils.hasLength(addresseePhone)){
            wrapper.like("addresseePhone",addresseePhone);
        }
        if(Objects.nonNull(state)){
            wrapper.eq("state",state);
        }
        if(Objects.nonNull(billType)){
            wrapper.eq("billType",billType);
        }
        if(Objects.nonNull(billHeaderType)){
            wrapper.eq("billHeaderType",billHeaderType);
        }
        return wrapper;
    }
 
    @Override
    public List<TBill> getPageList(String createTime, String addresseePhone, Integer state, Integer billType, Integer billHeaderType) {
        String startTime = null;
        String endTime = null;
        // 开始,结束时间
        if(StringUtils.hasLength(createTime)){
            String[] split = createTime.split(" - ");
            startTime = split[0]+" 00:00:00";
            endTime = split[1] + " 23:59:59";
        }
        Integer roleType = Objects.requireNonNull(ShiroKit.getUser()).getRoleType();
        Integer objectId = Objects.requireNonNull(ShiroKit.getUser()).getObjectId();
        return tBillMapper.getPageList(startTime, endTime, addresseePhone,state,billType,billHeaderType,roleType,objectId);
    }
}