Blame view

parking-module-pay/src/main/java/com/zteits/pay/dao/impl/TdCCustPersionDaoImpl.java 5.04 KB
55f68655   王彪总   新项目
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
132
  package com.zteits.pay.dao.impl;
  
  import java.util.List;
  
  import org.apache.commons.lang3.StringUtils;
  import com.xiaoleilu.hutool.util.CollectionUtil;
  import com.zteits.clouds.api.dto.park.param.SwitchETCstateRequest;
  import com.zteits.clouds.api.dto.pay.custperson.CustPersonStatisticDTO;
  import com.zteits.clouds.api.dto.pay.custperson.CustPersonStatisticForHourDTO;
  import com.zteits.clouds.api.dto.pay.custperson.CustPersonStatisticForWeekDTO;
  import com.zteits.clouds.api.dto.pay.param.QueryPersonForPageByUserPhoneQReq;
  import com.zteits.clouds.api.dto.pay.param.TdCCustPersonQueryStatisticRequest;
  import org.springframework.beans.factory.annotation.Autowired;
  import org.springframework.stereotype.Component;
  
  import com.github.pagehelper.PageHelper;
  import com.github.pagehelper.PageInfo;
  import com.zteits.clouds.api.apibase.constants.DataStatusEnum;
  import com.zteits.clouds.api.dto.pay.TdCCustPersonDTO;
  import com.zteits.clouds.api.dto.pay.param.TdCCustPersonRequest;
  import com.zteits.pay.dao.TdCCustPersonDao;
  import com.zteits.pay.domain.TdCCustPerson;
  import com.zteits.pay.domain.TdCCustPersonExample;
  import com.zteits.pay.mapper.TdCCustPersonMapper;
  import com.zteits.pay.mapper.smapper.TdCCustPersonSMapper;
  
  @Component
  public class TdCCustPersionDaoImpl implements TdCCustPersonDao {
  	
  	@Autowired
  	private TdCCustPersonSMapper tdCCustPersonSMapper;
  	
  	@Autowired
  	private TdCCustPersonMapper tdCCustPersonMapper;
  
  	@Override
  	public PageInfo<TdCCustPersonDTO> queryPersonForPage(TdCCustPersonRequest request) {
  		PageHelper.startPage(request.getBaseRequest().getPageNum(), request.getBaseRequest().getPageSize());
  		List<TdCCustPersonDTO> list = tdCCustPersonSMapper.queryPersonForPage(request);
  		return new PageInfo<>(list);
  	}
  
  	@Override
  	public TdCCustPerson selectByUserPhone(String userPhone) {
  		return tdCCustPersonSMapper.selectByUserPhone(userPhone);
  	}
  	@Override
  	public int insertSelective(TdCCustPerson record) {
  		return tdCCustPersonMapper.insertSelective(record);
  	}
  	@Override
  	public int updateByUserPhone(TdCCustPerson person) {
  		return tdCCustPersonSMapper.updateByUserPhone(person);
  	}
  	@Override
  	public int updateByCustId(TdCCustPerson person) {
  		return tdCCustPersonSMapper.updateByCustId(person);
  	}
  	@Override
  	public TdCCustPerson queryPersonByCustId(String custId) {
  		return tdCCustPersonSMapper.queryPersonByCustId(custId);
  	}
  	@Override
  	public int updateCustPersonBaseInfoByCustId(TdCCustPerson person) {
  		return tdCCustPersonSMapper.updateCustPersonBaseInfoByCustId(person);
  	}
  
  	@Override
  	public List<TdCCustPerson> queryPersonByCustIds(List<String> custIds) {
  		TdCCustPersonExample example = new TdCCustPersonExample();
  		example.createCriteria().andDataStateEqualTo(DataStatusEnum.DATA_STATUS_VALID.value()).andCustIdIn(custIds);
  		return tdCCustPersonMapper.selectByExample(example);
  	}
  
  	@Override
  	public CustPersonStatisticDTO queryUserPersonStatistic(TdCCustPersonQueryStatisticRequest request) {
  		return tdCCustPersonSMapper.queryUserPersonStatistic(request);
  	}
  
  	@Override
  	public List<CustPersonStatisticForHourDTO> queryUserPersonStatisticForHour(TdCCustPersonQueryStatisticRequest request) {
  		return tdCCustPersonSMapper.queryUserPersonStatisticForHour(request);
  	}
  
  	@Override
  	public List<CustPersonStatisticForWeekDTO> queryUserPersonStatisticForWeek(TdCCustPersonQueryStatisticRequest request) {
  		return tdCCustPersonSMapper.queryUserPersonStatisticForWeek(request);
  	}
  
  	@Override
  	public PageInfo<TdCCustPerson> queryPersonForPageByUserPhone(QueryPersonForPageByUserPhoneQReq request) {
  		//1.设置分页
  		PageHelper.startPage(request.getBaseRequest().getPageNum(), request.getBaseRequest().getPageSize());
  		//2.查询数据
  		TdCCustPersonExample example = new TdCCustPersonExample();
  
  		TdCCustPersonExample.Criteria criteria = example.createCriteria();
  		if(StringUtils.isNotEmpty(request.getUserPhone())){
  			criteria.andUserPhoneEqualTo(request.getUserPhone());
  		}
  		criteria.andDataStateEqualTo(1);
  		//criteria.andOrgIdEqualTo(request.getOrgId());
  		List<TdCCustPerson> list = tdCCustPersonMapper.selectByExample(example);
  		return new PageInfo<TdCCustPerson>(list);
  	}
  
  	@Override
  	public TdCCustPerson selectByCustId(TdCCustPersonRequest personRequest) {
  		TdCCustPersonExample example = new TdCCustPersonExample();
  		example.createCriteria().andCustIdEqualTo(personRequest.getCustId())
  				.andDataStateEqualTo(DataStatusEnum.DATA_STATUS_VALID.value());
  		List<TdCCustPerson> tdCCustPeople = tdCCustPersonMapper.selectByExample(example);
  		if(CollectionUtil.isNotEmpty(tdCCustPeople)){
  			return tdCCustPeople.get(0);
  		}
  		return null;
  	}
  
  	@Override
  	public int switchETCstate(SwitchETCstateRequest request) {
  		TdCCustPersonExample example = new TdCCustPersonExample();
  		example.createCriteria().andCustIdEqualTo(request.getCustId())
  				.andDataStateEqualTo(DataStatusEnum.DATA_STATUS_VALID.value());
  		TdCCustPerson person = new TdCCustPerson();
  		person.setEtcOpenState(request.getEtcOpenState());
  		if(request.getEtcProtocolState() == 0) {
  			person.setEtcProtocolState(1);
  		}
  		return tdCCustPersonMapper.updateByExampleSelective(person,example);
  	}
  
  }