admin
2019-11-19 b02d3f5053530fc6d8050769a2598399e1a4e03b
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
package com.yeshi.fanli.service.impl.user.invite;
 
import java.util.Date;
 
import javax.annotation.Resource;
 
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
 
import com.yeshi.fanli.dao.mybatis.integral.UserGetIntegralFromOrderRecordMapper;
import com.yeshi.fanli.entity.integral.UserGetIntegralFromOrderRecord;
import com.yeshi.fanli.exception.integral.UserGetIntegralFromOrderRecordException;
import com.yeshi.fanli.service.inter.user.integral.UserGetIntegralFromOrderRecordService;
import com.yeshi.fanli.util.StringUtil;
 
@Service
public class UserGetIntegralFromOrderRecordServiceImpl implements UserGetIntegralFromOrderRecordService {
 
    @Resource
    private UserGetIntegralFromOrderRecordMapper userGetIntegralFromOrderRecordMapper;
 
    @Override
    public long countByEventTypeAndUidAndOrderInfo(int eventType, Long uid, String orderNo, int orderSourceType) {
        UserGetIntegralFromOrderRecord record = new UserGetIntegralFromOrderRecord();
        record.setEventType(eventType);
        record.setOrderNo(orderNo);
        record.setOrderSourceType(orderSourceType);
        record.setUid(uid);
        return userGetIntegralFromOrderRecordMapper.countByRecordInfo(record);
    }
 
    @Transactional
    @Override
    public void addRecord(UserGetIntegralFromOrderRecord record) throws UserGetIntegralFromOrderRecordException {
        if (record == null || record.getUid() == null || record.getEventType() == null
                || StringUtil.isNullOrEmpty(record.getOrderNo()) || record.getOrderSourceType() == null)
            throw new UserGetIntegralFromOrderRecordException(1, "信息不完整");
 
        long count = countByEventTypeAndUidAndOrderInfo(record.getEventType(), record.getUid(), record.getOrderNo(),
                record.getOrderSourceType());
        if (count > 0)
            throw new UserGetIntegralFromOrderRecordException(2, "记录已存在");
 
        if (record.getCreateTime() == null)
            record.setCreateTime(new Date());
        userGetIntegralFromOrderRecordMapper.insertSelective(record);
    }
 
}