Blame view

parking-module-pay/src/main/java/com/zteits/pay/dao/impl/TdCCustInvoiceinfoDaoImpl.java 3.06 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
  /**
   * 
   */
  package com.zteits.pay.dao.impl;
  
  import java.util.List;
  
  import com.alipay.api.domain.DataEnumValue;
  import com.zteits.clouds.api.apibase.constants.DataStatusEnum;
  import com.zteits.clouds.api.dto.pay.param.TdCCustInvoiceinfoRequest;
  import org.springframework.beans.factory.annotation.Autowired;
  import org.springframework.stereotype.Component;
  import org.springframework.transaction.annotation.Transactional;
  
  import com.zteits.pay.dao.TdCCustInvoiceinfoDao;
  import com.zteits.pay.domain.TdCCustInvoiceinfo;
  import com.zteits.pay.domain.TdCCustInvoiceinfoExample;
  import com.zteits.pay.mapper.TdCCustInvoiceinfoMapper;
  
  /**
   * @author hxz
   *
   */
  @Component
  public class TdCCustInvoiceinfoDaoImpl implements TdCCustInvoiceinfoDao {
  	
  	@Autowired
  	private TdCCustInvoiceinfoMapper tdCCustInvoiceinfoMapper;
  
  	@Override
  	@Transactional
  	public Long insertCustomerInvoiceInfo(TdCCustInvoiceinfo record) {
  		if (record.getIsDefault().equals("1")) {
  			TdCCustInvoiceinfoExample example = new TdCCustInvoiceinfoExample ();
  			example.createCriteria().andCustIdEqualTo(record.getCustId());
  			TdCCustInvoiceinfo updateRecord = new TdCCustInvoiceinfo ();
  			updateRecord.setCustId(record.getCustId());
  			updateRecord.setIsDefault("0");
  			tdCCustInvoiceinfoMapper.updateByExampleSelective(updateRecord, example);
  		}
  		
  		return new Long((long)tdCCustInvoiceinfoMapper.insertSelective(record));
  	}
  
  	@Override
  	public Boolean deleteCustomerInvoiceInfoByID(Long id) {
  		TdCCustInvoiceinfoExample example = new TdCCustInvoiceinfoExample();
  		example.createCriteria().andIdEqualTo(id);
  		
  		return tdCCustInvoiceinfoMapper.deleteByExample(example) > 0;
  	}
  
  	@Override
  	@Transactional
  	public Boolean updateByPrimaryKeySelective(TdCCustInvoiceinfo record) {
  		if (record.getIsDefault().equals("1")) {
  			TdCCustInvoiceinfoExample example = new TdCCustInvoiceinfoExample ();
  			example.createCriteria().andCustIdEqualTo(record.getCustId());
  			TdCCustInvoiceinfo updateRecord = new TdCCustInvoiceinfo ();
  			updateRecord.setCustId(record.getCustId());
  			updateRecord.setIsDefault("0");
  			tdCCustInvoiceinfoMapper.updateByExampleSelective(updateRecord, example);
  		}
  
  		return tdCCustInvoiceinfoMapper.updateByPrimaryKeySelective(record) > 0;
  	}
  
  	@Override
  	public TdCCustInvoiceinfo queryCustomerInvoiceInfoById(Long id) {
  		
  		return tdCCustInvoiceinfoMapper.selectByPrimaryKey(id);
  	}
  
  	@Override
  	public List<TdCCustInvoiceinfo> queryCustInvoiceInfoList(TdCCustInvoiceinfoExample example) {
  		
  		return tdCCustInvoiceinfoMapper.selectByExample(example);
  	}
  
  	@Override
  	public Long checkBindInfoNum(TdCCustInvoiceinfoRequest requestObject) {
  		TdCCustInvoiceinfoExample example = new TdCCustInvoiceinfoExample();
  		example.createCriteria().andDataStateEqualTo(DataStatusEnum.DATA_STATUS_VALID.value())
  				.andCustIdEqualTo(requestObject.getCustId());
  		return tdCCustInvoiceinfoMapper.countByExample(example);
  	}
  
  	@Override
  	public Boolean updateByExampleSelective(TdCCustInvoiceinfo record, TdCCustInvoiceinfoExample example) {
  		
  		return tdCCustInvoiceinfoMapper.updateByExampleSelective(record, example) > 0;
  	}
  
  }