TVipAreaCardDaoImpl.java
6.31 KB
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
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
package com.zteits.bill.dao.impl;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.zteits.bill.dao.TVipAreaCardDao;
import com.zteits.bill.domain.TVipAreaCard;
import com.zteits.bill.domain.TVipAreaCardExample;
import com.zteits.bill.mapper.TVipAreaCardMapper;
import com.zteits.clouds.api.apibase.constants.AuditorStatusEnum;
import com.zteits.clouds.api.apibase.constants.DataStatusEnum;
import com.zteits.clouds.api.dto.bill.param.TVipAreaCardRequest;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import java.util.Date;
import java.util.List;
@Component
public class TVipAreaCardDaoImpl implements TVipAreaCardDao {
@Autowired
private TVipAreaCardMapper tVipAreaCardMapper;
@Override
public int saveTVipAreaCard(TVipAreaCard tVipAreaCard) {
if(tVipAreaCard.getCreateDate()==null){
tVipAreaCard.setCreateDate(new Date());
}
return tVipAreaCardMapper.insertSelective(tVipAreaCard);
}
@Override
public int updateByExampleSelective(TVipAreaCard record, TVipAreaCardExample example) {
return tVipAreaCardMapper.updateByExampleSelective(record,example);
}
@Override
public int updateByPrimaryKeySelective(TVipAreaCard record) {
return tVipAreaCardMapper.updateByPrimaryKeySelective(record);
}
@Override
public List<TVipAreaCard> selectByExample(TVipAreaCardExample example) {
return tVipAreaCardMapper.selectByExample(example);
}
@Override
public TVipAreaCard queryByPrimaryKey(Long id) {
return tVipAreaCardMapper.selectByPrimaryKey(id);
}
@Override
public List<TVipAreaCard> queryTVipAreaCard(TVipAreaCardRequest request) {
TVipAreaCardExample example = new TVipAreaCardExample();
TVipAreaCardExample.Criteria sql = example.createCriteria();
sql.andAuditorStatusEqualTo(AuditorStatusEnum.AUDITOR_STATUS_AUDIT_PASS.value())
.andDataStateEqualTo(DataStatusEnum.DATA_STATUS_VALID.value());
if(request.getOrgId() != null){
sql.andOrgIdEqualTo(request.getOrgId());
}
if(request.getCardType() != null){
sql.andCardTypeEqualTo(request.getCardType());
}
if(request.getCarType() != null ){
sql.andCarTypeEqualTo(request.getCarType());
}
if(request.getAreaCardType() != null ){
sql.andAreaCardTypeEqualTo(request.getAreaCardType());
}
if(request.getSaleChannel() != null ){
sql.andSaleChannelEqualTo(request.getSaleChannel());
}
if(request.getType() != null ){
sql.andTypeEqualTo(request.getType());
}
if(DataStatusEnum.DATA_STATUS_VALID.value().equals(request.getCardStatus())){//若只查询上架的
sql.andCardStatusEqualTo(1)
.andEffDateLessThanOrEqualTo(new Date()) //EffDate<=new Date()
.andExpDateGreaterThanOrEqualTo(new Date()); //ExpDate>= new Date()
}
if(StringUtils.isNotEmpty(request.getCardNo())){
sql.andCardNoEqualTo(request.getCardNo());
}
return tVipAreaCardMapper.selectByExample(example);
}
@Override
public int batchDeleteTVipAreaCardByPrimaryKey(List<Long> ids, String opId, String opName) {
TVipAreaCard record = new TVipAreaCard();
record.setModifyEmpid(opId);
record.setModifyName(opName);
record.setModifyDate(new Date());
record.setCardStatus(2);
record.setDataState(DataStatusEnum.DATA_STATUS_NO_VALID.value());
TVipAreaCardExample example = new TVipAreaCardExample();
example.createCriteria().andIdIn(ids);
return tVipAreaCardMapper.updateByExampleSelective(record,example);
}
@Override
public PageInfo<TVipAreaCard> queryTVipAreaCardForPage(TVipAreaCardRequest request) {
//1.设置分页
PageHelper.startPage(request.getBaseRequest().getPageNum(), request.getBaseRequest().getPageSize());
TVipAreaCardExample example = new TVipAreaCardExample();
TVipAreaCardExample.Criteria sql = example.createCriteria();
sql.andDataStateEqualTo(DataStatusEnum.DATA_STATUS_VALID.value());
if(null != request.getCardType()){
sql.andCardTypeEqualTo(request.getCardType());
}
if(null != request.getCarType()){
sql.andCarTypeEqualTo(request.getCarType());
}
if(null != request.getType()){
sql.andTypeEqualTo(request.getType());
}
if(null != request.getAreaCardType()){
sql.andAreaCardTypeEqualTo(request.getAreaCardType());
}
if(null != request.getCardStatus()){
sql.andCardStatusEqualTo(request.getCardStatus());
}
sql.andOrgIdEqualTo(request.getOrgId());
example.setOrderByClause(" id desc");
List<TVipAreaCard> tVipAreaCards = tVipAreaCardMapper.selectByExample(example);
return new PageInfo<TVipAreaCard>(tVipAreaCards);
}
/**
* 通过卡编码查询卡规则信息
* @Auther: wangfs
* @param
* @return
*/
@Override
public TVipAreaCard queryTVipAreaCardByCardNo(String cardNo) {
TVipAreaCard tVipAreaCard = new TVipAreaCard();
TVipAreaCardExample example = new TVipAreaCardExample();
example.createCriteria().andCardNoEqualTo(cardNo)
.andDataStateEqualTo(DataStatusEnum.DATA_STATUS_VALID.value());
List<TVipAreaCard> tVipAreaCardList = tVipAreaCardMapper.selectByExample(example);
if(!CollectionUtils.isEmpty(tVipAreaCardList)){
tVipAreaCard = tVipAreaCardList.get(0);
}
return tVipAreaCard;
}
/*@Override
public PageInfo<TVipAreaCard> queryTVipAreaCardForPage(TVipAreaCardRequest request) {
PageHelper.startPage(request.getBaseRequest().getPageNum(), request.getBaseRequest().getPageSize());
//TODO 编写smapper实现
*//*List<TVipAreaCard> list = tVipAreaCardSMapper.queryTVipAreaCard(request);
if (CollectionUtils.isNotEmpty(list)) {
return new PageInfo<TVipAreaCard>(list);
}*//*
return new PageInfo<TVipAreaCard>(new ArrayList<TVipAreaCard>());
}*/
}