UserServicefeeServiceImpl.java
4.3 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
/*
* Copyright (c) 2018, 2028, glsx and/or its affiliates. All rights reserved.
* GLSX PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*
*/
package com.glsx.usercenter.service.impl;
import java.math.BigDecimal;
import java.util.Date;
import java.util.List;
import com.google.common.collect.Lists;
import org.apache.commons.lang.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.glsx.common.utils.bean.BeanUtils;
import com.glsx.usercenter.exception.BusinessException;
import com.glsx.usercenter.mapper.SysUserServiceFeeMapper;
import com.glsx.usercenter.pojo.user.SysUserServiceFee;
import com.glsx.usercenter.service.IUserServicefeeService;
/**
* @ClassName: UserServicefeeServiceImpl
* @Description: TODO(这里用一句话描述这个类的作用)
* @author Zheng Xiajun
* @date 2019年12月25日
*
*/
@Service
public class UserServicefeeServiceImpl implements IUserServicefeeService {
public Logger logger = LoggerFactory.getLogger(UserServicefeeServiceImpl.class);
@Autowired
private SysUserServiceFeeMapper sysUserServiceFeeMapper;
/*
* (non-Javadoc)
*
* @see
* com.glsx.usercenter.service.IUserServicefeeService#insertSelective(com.
* glsx.usercenter.pojo.user.SysUserServiceFee)
*/
@Override
public void insertSelective(SysUserServiceFee sysUserServiceFee) {
sysUserServiceFeeMapper.insertSelective(sysUserServiceFee);
}
/*
* (non-Javadoc)
*
* @see com.glsx.usercenter.service.IUserServicefeeService#insert(java.lang.
* String)
*/
@Override
public void updateUserServiceFee(String str, int userId, int userType) {
// String str= 908,100,100,100|45874,200,200,200
if (StringUtils.isNotBlank(str)) {
List<SysUserServiceFee> list = sysUserServiceFeeMapper.getUserServiceFeeList(userId, null);
if (!list.isEmpty()) {
sysUserServiceFeeMapper.batchInsertHistory(list);
sysUserServiceFeeMapper.deleteByUserId(userId);
list.clear();
} else {
list = Lists.newArrayList();
}
String[] array = str.split("\\|");
Date now = new Date();
for (int i = 0; i < array.length; i++) {
String item = array[i];
SysUserServiceFee sysUserServiceFee = new SysUserServiceFee();
sysUserServiceFee.setUserId(userId);
sysUserServiceFee.setCreateTime(now);
sysUserServiceFee.setUserType(userType);
sysUserServiceFee.setServiceCode(item.split(",")[0]);
if (BigDecimal.ZERO.compareTo(new BigDecimal(item.split(",")[1])) < 0) {
sysUserServiceFee.setServiceFee(new BigDecimal(item.split(",")[1]));
sysUserServiceFee.setFeeType(com.glsx.usercenter.constants.Constants.FEE_TYPE_INSTALL);
list.add(sysUserServiceFee);
} else {
throw BusinessException.create("服务项目定价必须大于0!");
}
if (BigDecimal.ZERO.compareTo(new BigDecimal(item.split(",")[2])) < 0) {
SysUserServiceFee sysUserServiceFee2 = new SysUserServiceFee();
BeanUtils.copyBeanProp(sysUserServiceFee2, sysUserServiceFee);
sysUserServiceFee2.setServiceFee(new BigDecimal(item.split(",")[2]));
sysUserServiceFee2.setFeeType(com.glsx.usercenter.constants.Constants.FEE_ORDER_DISMANTLE);
list.add(sysUserServiceFee2);
} else {
throw BusinessException.create("服务项目定价必须大于0!");
}
if (BigDecimal.ZERO.compareTo(new BigDecimal(item.split(",")[3])) < 0) {
SysUserServiceFee sysUserServiceFee3 = new SysUserServiceFee();
BeanUtils.copyBeanProp(sysUserServiceFee3, sysUserServiceFee);
sysUserServiceFee3.setServiceFee(new BigDecimal(item.split(",")[3]));
sysUserServiceFee3.setFeeType(com.glsx.usercenter.constants.Constants.FEE_TYPE_REPAIR);
list.add(sysUserServiceFee3);
} else {
throw BusinessException.create("服务项目定价必须大于0!");
}
}
sysUserServiceFeeMapper.batchInsert(list);
}
}
@Override
public List<SysUserServiceFee> getUserServiceFeeList(Integer userId,
String serviceCode) {
// TODO Auto-generated method stub
return sysUserServiceFeeMapper.getUserServiceFeeList(userId, serviceCode);
}
}