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.xiaoleilu.hutool.date.DateUtil; import com.zteits.bill.dao.TVipAreaCardCustInfoDao; import com.zteits.bill.domain.TVipAreaCardCustInfo; import com.zteits.bill.domain.TVipAreaCardCustInfoExample; import com.zteits.bill.domain.TVipNoPushCardCustInfoDO; import com.zteits.bill.mapper.TVipAreaCardCustInfoMapper; import com.zteits.bill.mapper.smapper.TVipAreaCardCustInfoSMapper; import com.zteits.clouds.api.apibase.constants.DataStatusEnum; import com.zteits.clouds.api.dto.bill.dto.TVipAreaCardCustInfoDTO; import com.zteits.clouds.api.dto.bill.param.DeleteAreaCardByCustCardNoReq; import com.zteits.clouds.api.dto.bill.param.TVipAreaCardCustInfoQueryRequest; import com.zteits.clouds.api.dto.bill.param.TVipAreaCardCustInfoRequest; import com.zteits.clouds.api.dto.bill.param.ValidVipAreaCardCustInfoRequest; import com.zteits.clouds.api.dto.bill.vipcard.param.QueryIsBuyVipCardCustReq; import com.zteits.clouds.api.dto.bill.vipcard.param.QueryVipCardOrderDetailTotalReq; import com.zteits.clouds.api.dto.bill.vipcard.param.VipAreaCardExpireRequest; import com.zteits.clouds.api.dto.bill.vipcard.param.VipCardInfoReq; import com.zteits.clouds.api.dto.order.vipcardorder.dto.OrderVipAreacardDetailTotalDTO; import com.zteits.clouds.api.dto.order.vipcardorder.dto.ParkVipAreaCardNumDTO; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; import java.util.ArrayList; import java.util.Date; import java.util.List; @Component public class TVipAreaCardCustInfoDaoImpl implements TVipAreaCardCustInfoDao { @Autowired private TVipAreaCardCustInfoMapper tVipAreaCardCustInfoMapper; @Autowired private TVipAreaCardCustInfoSMapper tVipAreaCardCustInfoSMapper; @Override public int saveTVipAreaCardCustInfo(TVipAreaCardCustInfo tVipAreaCardCustInfo) { if(tVipAreaCardCustInfo.getCreateDate()==null){ tVipAreaCardCustInfo.setCreateDate(new Date()); } return tVipAreaCardCustInfoMapper.insertSelective(tVipAreaCardCustInfo); } @Override public int updateByExampleSelective(TVipAreaCardCustInfo record, TVipAreaCardCustInfoExample example) { return tVipAreaCardCustInfoMapper.updateByExampleSelective(record,example); } @Override public int updateByPrimaryKeySelective(TVipAreaCardCustInfo record) { return tVipAreaCardCustInfoMapper.updateByPrimaryKeySelective(record); } @Override public List selectByExample(TVipAreaCardCustInfoExample example) { return tVipAreaCardCustInfoMapper.selectByExample(example); } @Override public TVipAreaCardCustInfo queryByPrimaryKey(Long id) { return tVipAreaCardCustInfoMapper.selectByPrimaryKey(id); } /** * 根据个人卡编码 * @Auther: wangfs * @param * @return */ @Override public TVipAreaCardCustInfo queryByPersonCardNO(String personCardNo) { TVipAreaCardCustInfo tVipAreaCardCustInfo = new TVipAreaCardCustInfo(); TVipAreaCardCustInfoExample example = new TVipAreaCardCustInfoExample(); example.createCriteria().andCustCardNoEqualTo(personCardNo); List list = tVipAreaCardCustInfoMapper.selectByExample(example); if(!CollectionUtils.isEmpty(list)){ tVipAreaCardCustInfo = list.get(0); } return tVipAreaCardCustInfo; } @Override public List queryTVipAreaCardCustInfo(TVipAreaCardCustInfoRequest request) { TVipAreaCardCustInfo tVipAreaCardCustInfo = new TVipAreaCardCustInfo(); TVipAreaCardCustInfoExample example = new TVipAreaCardCustInfoExample(); TVipAreaCardCustInfoExample.Criteria sql = example.createCriteria(); sql.andDataStateEqualTo(DataStatusEnum.DATA_STATUS_VALID.value()); if(CollectionUtils.isNotEmpty(request.getCustCardNos())){ sql.andCustCardNoIn(request.getCustCardNos()); } if(StringUtils.isNotEmpty(request.getCustCardNo())){ sql.andCustCardNoEqualTo(request.getCustCardNo()); } if(StringUtils.isNotEmpty(request.getCardNo())){ sql.andCardNoEqualTo(request.getCardNo()); } if(StringUtils.isNotEmpty(request.getCarNumber())){ sql.andCardNoEqualTo(request.getCarNumber()); } example.setOrderByClause("exp_date desc"); List list = tVipAreaCardCustInfoMapper.selectByExample(example); return list; } @Override public int batchDeleteTVipAreaCardCustInfoByPrimaryKey(List ids, String opId, String opName) { TVipAreaCardCustInfo record = new TVipAreaCardCustInfo(); record.setModifyEmpid(opId); record.setModifyName(opName); record.setModifyDate(new Date()); record.setDataState(DataStatusEnum.DATA_STATUS_NO_VALID.value()); TVipAreaCardCustInfoExample example = new TVipAreaCardCustInfoExample(); example.createCriteria().andIdIn(ids); return tVipAreaCardCustInfoMapper.updateByExampleSelective(record,example); } @Override public PageInfo queryTVipAreaCardCustInfoForPage(TVipAreaCardCustInfoQueryRequest request) { PageHelper.startPage(request.getBaseRequest().getPageNum(), request.getBaseRequest().getPageSize()); List list = tVipAreaCardCustInfoSMapper.queryTVipAreaCardCustInfoForPage(request); if (CollectionUtils.isNotEmpty(list)) { return new PageInfo(list); } return new PageInfo(new ArrayList()); } @Override public List queryVipAreaCardInfoByCarNumbers(TVipAreaCardCustInfoQueryRequest request) { return tVipAreaCardCustInfoSMapper.queryVipAreaCardInfoByCarNumbers(request); } @Override public List queryVipAreaCardInfoByCarNumbersForApp(TVipAreaCardCustInfoQueryRequest request) { return tVipAreaCardCustInfoSMapper.queryVipAreaCardInfoByCarNumbersForApp(request); } /** * 根据个人卡编码更新个人卡状态 * * @param personCardNo * @return */ @Override public Boolean updateByPersonCardNo(String personCardNo) { TVipAreaCardCustInfo record = new TVipAreaCardCustInfo(); record.setDataState(DataStatusEnum.DATA_STATUS_VALID.value()); record.setRemark("购买订单已经下单成功,返回回调通知"); record.setModifyDate(new Date()); TVipAreaCardCustInfoExample example = new TVipAreaCardCustInfoExample(); example.createCriteria().andCustCardNoEqualTo(personCardNo); int i = tVipAreaCardCustInfoMapper.updateByExampleSelective(record, example); return i >0; } /** * 查询未推送给第三发的会员卡 * @param currentDate yyyy-MM-dd HH:mm:ss * @return */ @Override public List queryNoPustVipCardCustInfo(String currentDate, Long id) { return tVipAreaCardCustInfoSMapper.queryNoPustVipCardCustInfo(currentDate,id); } /** * 查询推送和未推送给第三发的会员卡 * @param currentDate yyyy-MM-dd HH:mm:ss * @return */ @Override public List queryPustVipCardCustInfo(String currentDate,Long id) { return tVipAreaCardCustInfoSMapper.queryPustVipCardCustInfo(currentDate,id); } /** * 查询用户是否购买区域卡 * @param request * @return */ @Override public Boolean queryIsBuyVipCardCust(QueryIsBuyVipCardCustReq request) { Integer integer = tVipAreaCardCustInfoSMapper.queryIsBuyVipCardCust(request); return integer>0; } @Override public List queryVipAreaCardStatisticTotal(QueryVipCardOrderDetailTotalReq request) { return tVipAreaCardCustInfoSMapper.queryVipAreaCardStatisticTotal(request); } @Override public ParkVipAreaCardNumDTO queryParkVipAreaCardNumByPlNo(String plNo,Long orgId) { return tVipAreaCardCustInfoSMapper.queryParkVipAreaCardNumByPlNo(plNo,orgId); } @Override public List queryExpireVipCardCustInfo(VipAreaCardExpireRequest vipPushRequest) { return tVipAreaCardCustInfoSMapper.queryExpireVipCardCustInfo(vipPushRequest); } /***********************************************时域卡************************************/ @Override public PageInfo queryTVipTimeCardCustInfoForPage(TVipAreaCardCustInfoQueryRequest request) { PageHelper.startPage(request.getBaseRequest().getPageNum(), request.getBaseRequest().getPageSize()); List list = tVipAreaCardCustInfoSMapper.queryTVipTimeCardCustInfoForPage(request); if (CollectionUtils.isNotEmpty(list)) { return new PageInfo(list); } return new PageInfo(new ArrayList()); } @Override public List queryVipTimeCardInfoByCarNumbers(TVipAreaCardCustInfoQueryRequest request) { return tVipAreaCardCustInfoSMapper.queryVipTimeCardInfoByCarNumbers(request); } @Override public List queryVipTimeCardInfoByCarNumbersForApp(TVipAreaCardCustInfoQueryRequest request) { return tVipAreaCardCustInfoSMapper.queryVipTimeCardInfoByCarNumbersForApp(request); } /** * 查询用户是否购买时域卡 * @param request * @return */ @Override public Boolean queryIsBuyTimeVipCardCust(QueryIsBuyVipCardCustReq request) { Integer integer = tVipAreaCardCustInfoSMapper.queryIsBuyTimeVipCardCust(request); return integer>0; } @Override public List queryVipTimeCardStatisticTotal(QueryVipCardOrderDetailTotalReq request) { return tVipAreaCardCustInfoSMapper.queryVipTimeCardStatisticTotal(request); } @Override public List queryExpireTimeVipCardCustInfo(VipAreaCardExpireRequest vipPushRequest) { return tVipAreaCardCustInfoSMapper.queryExpireTimeVipCardCustInfo(vipPushRequest); } @Override public TVipAreaCardCustInfo queryTimeCardBuyTimesByCarNumber(ValidVipAreaCardCustInfoRequest request) { return tVipAreaCardCustInfoSMapper.queryTimeCardBuyTimesByCarNumber(request); } @Override public int updateAreaCardInvalid(DeleteAreaCardByCustCardNoReq request) { TVipAreaCardCustInfo record = new TVipAreaCardCustInfo(); //将失效日期置为昨天 Date yesterday = DateUtil.yesterday(); yesterday = DateUtil.endOfDay(yesterday); record.setExpDate(yesterday); record.setModifyDate(null != request.getModifyDate() ? request.getModifyDate() : new Date()); record.setModifyEmpid(request.getModifyEmpid()); record.setModifyName(request.getModifyName()); TVipAreaCardCustInfoExample example = new TVipAreaCardCustInfoExample(); example.createCriteria().andCustCardNoEqualTo(request.getCustCardNo()); return tVipAreaCardCustInfoMapper.updateByExampleSelective(record, example); } /** * 根据到期时间查询区域卡 * @param * @return * @Author: wangfs * @Date: 2020/4/8 18:24 * */ @Override public List queryVipCardCustInfoByExpDate(VipAreaCardExpireRequest vipPushRequest) { Date beginTime = DateUtil.beginOfDay(vipPushRequest.getNowDate()); Date endTime = DateUtil.endOfDay(vipPushRequest.getNowDate()); List tVipAreaCardCustInfos = tVipAreaCardCustInfoMapper.queryVipCardCustInfoByExpDate(beginTime,endTime); return tVipAreaCardCustInfos; } @Override public List queryTVipAreaCardCustInfoListByAreaCardType(TVipAreaCardCustInfoRequest request) { List tVipAreaCardCustInfos = tVipAreaCardCustInfoSMapper.queryTVipAreaCardCustInfoListByAreaCardType(request); return tVipAreaCardCustInfos; } /** * 根据停车场编号与车牌号码查询当前有效的会员车信息 * @param request * @author: zegnqc * @return */ @Override public TVipAreaCardCustInfo queryCardCustInfoByParkcodeAndCarnumber(VipCardInfoReq request) { return tVipAreaCardCustInfoMapper.queryCardCustInfoByParkcodeAndCarnumber(request); } /** * 据停车场编号与车牌号码查询该车所有有效的会员卡记录,包括已过期数据 * * @Author: zegnqc */ @Override public List queryAllAreaVipCardByParkcodeAndCarnumber(VipCardInfoReq request) { return tVipAreaCardCustInfoMapper.queryAllAreaVipCardByParkcodeAndCarnumber(request); } @Override public List queryAllActiveInfo(TVipAreaCardCustInfoRequest request) { List tVipAreaCardCustInfos = tVipAreaCardCustInfoSMapper.queryAllActiveInfo(request); return tVipAreaCardCustInfos; } }