提交 | 用户 | age
|
689637
|
1 |
package com.hx.phip.service.userMoney.impl; |
A |
2 |
|
|
3 |
import javax.annotation.Resource; |
|
4 |
|
fe8b6c
|
5 |
import com.alibaba.fastjson.JSON; |
34f071
|
6 |
import com.alibaba.fastjson.JSONArray; |
fe8b6c
|
7 |
import com.alibaba.fastjson.JSONObject; |
689637
|
8 |
import com.hx.common.service.CommonService; |
fe8b6c
|
9 |
import com.hx.phiappt.common.OperationReasonConstants; |
dfa10a
|
10 |
import com.hx.phiappt.common.OrderItemConstants; |
fe8b6c
|
11 |
import com.hx.phiappt.common.OriginChannelConstants; |
007982
|
12 |
import com.hx.phiappt.common.PlatformConstants; |
16a35e
|
13 |
import com.hx.phiappt.constants.tool.TimerHandleTool; |
34f071
|
14 |
import com.hx.phiappt.constants.tool.UserInfoTool; |
0798f6
|
15 |
import com.hx.phiappt.constants.tool.money.UserMoneyTool; |
689637
|
16 |
import com.hx.phiappt.model.*; |
dfa10a
|
17 |
import com.hx.phiappt.model.giving.TurnAdd; |
bf83fa
|
18 |
import com.hx.phip.config.CustomParameter; |
689637
|
19 |
import com.hx.phip.dao.mapper.*; |
dfa10a
|
20 |
import com.hx.phip.entity.enums.UserMoneyEnum; |
fe8b6c
|
21 |
import com.hx.phip.model.ApplyParameter; |
A |
22 |
import com.hx.phip.model.SysParameter; |
ce1308
|
23 |
import com.hx.phip.service.SystemParameterService; |
07e691
|
24 |
import com.hx.phip.service.UserIntegralRecordService; |
689637
|
25 |
import com.hx.phip.service.UserMoneyService; |
07e691
|
26 |
import com.hx.phip.service.UserValueAddedFundRecordService; |
fe8b6c
|
27 |
import com.hx.phip.tool.ApplyParameterTool; |
A |
28 |
import com.hx.phip.tool.SendSMSTool; |
3a4e9f
|
29 |
import com.hx.util.DateUtil; |
689637
|
30 |
import com.hx.util.StringUtils; |
dfa10a
|
31 |
import com.hz.his.dto.user.money.UserTurnDto; |
bf83fa
|
32 |
import com.platform.constants.PlatformPattern; |
689637
|
33 |
import com.platform.exception.PlatTipsException; |
A |
34 |
import com.platform.resultTool.PlatformCode; |
fe8b6c
|
35 |
import com.platform.resultTool.SystemCode; |
ac698b
|
36 |
import org.slf4j.Logger; |
A |
37 |
import org.slf4j.LoggerFactory; |
dfa10a
|
38 |
import org.springframework.beans.BeanUtils; |
689637
|
39 |
import org.springframework.stereotype.Service; |
A |
40 |
import org.springframework.transaction.annotation.Transactional; |
|
41 |
|
|
42 |
import com.hx.exception.TipsException; |
|
43 |
import com.hx.phiappt.model.userMoney.UserMoneyUnclaimed; |
|
44 |
import com.hx.phip.service.userMoney.UserMoneyUnclaimedService; |
|
45 |
import com.hx.mybatisTool.SqlSentence; |
|
46 |
|
fe8b6c
|
47 |
import java.lang.reflect.Field; |
A |
48 |
import java.lang.reflect.Modifier; |
689637
|
49 |
import java.math.BigDecimal; |
ffbf05
|
50 |
import java.util.*; |
689637
|
51 |
|
A |
52 |
@Transactional |
|
53 |
@Service |
|
54 |
public class UserMoneyUnclaimedServiceImpl implements UserMoneyUnclaimedService { |
ac698b
|
55 |
|
A |
56 |
private static final Logger logger = LoggerFactory.getLogger(UserMoneyUnclaimedServiceImpl.class); |
689637
|
57 |
|
34f071
|
58 |
@Resource |
A |
59 |
private UserMapper userMapper; |
689637
|
60 |
@Resource |
A |
61 |
private CommonService commonService; |
bf83fa
|
62 |
@Resource |
A |
63 |
private CustomParameter customParameter; |
ffbf05
|
64 |
@Resource |
A |
65 |
private UserInfoMapper userInfoMapper; |
689637
|
66 |
@Resource |
A |
67 |
private UserMoneyService userMoneyService; |
ce1308
|
68 |
@Resource |
A |
69 |
private SystemParameterService systemParameterService; |
07e691
|
70 |
@Resource |
689637
|
71 |
private UserMoneyUnclaimedMapper userMoneyUnclaimedMapper; |
A |
72 |
@Resource |
07e691
|
73 |
private UserIntegralRecordService userIntegralRecordService; |
A |
74 |
@Resource |
|
75 |
private UserValueAddedFundRecordService userValueAddedFundRecordService; |
dfa10a
|
76 |
@Resource |
F |
77 |
private TurnAddMapper turnAddMapper; |
689637
|
78 |
|
A |
79 |
/** |
|
80 |
* 查询列表 |
|
81 |
*/ |
|
82 |
@Override |
|
83 |
public List<UserMoneyUnclaimed> selectList(SqlSentence sqlSentence) { |
|
84 |
return userMoneyUnclaimedMapper.selectList(sqlSentence); |
|
85 |
} |
|
86 |
|
|
87 |
/** |
|
88 |
* 查询列表 |
|
89 |
*/ |
|
90 |
@Override |
|
91 |
public List<Map<String, Object>> selectListMap(SqlSentence sqlSentence) { |
|
92 |
return userMoneyUnclaimedMapper.selectListMap(sqlSentence); |
|
93 |
} |
|
94 |
|
|
95 |
/** |
|
96 |
* 查询单个 |
|
97 |
*/ |
|
98 |
@Override |
|
99 |
public UserMoneyUnclaimed selectOne(SqlSentence sqlSentence) { |
|
100 |
return userMoneyUnclaimedMapper.selectOne(sqlSentence); |
|
101 |
} |
|
102 |
|
|
103 |
/** |
|
104 |
* 查询单个 |
|
105 |
*/ |
|
106 |
@Override |
|
107 |
public Map<String, Object> selectOneMap(SqlSentence sqlSentence) { |
|
108 |
return userMoneyUnclaimedMapper.selectOneMap(sqlSentence); |
|
109 |
} |
|
110 |
|
|
111 |
/** |
|
112 |
* 查询单个,大数据不拿取 |
|
113 |
*/ |
|
114 |
@Override |
|
115 |
public UserMoneyUnclaimed selectOneByKey(Object object) { |
|
116 |
return userMoneyUnclaimedMapper.selectOneByKey(object); |
|
117 |
} |
|
118 |
|
|
119 |
/** |
|
120 |
* 查询单个,大数据拿取 |
|
121 |
*/ |
|
122 |
@Override |
|
123 |
public UserMoneyUnclaimed selectOneByKeyBlob(Object object) { |
|
124 |
return userMoneyUnclaimedMapper.selectOneByKeyBlob(object); |
|
125 |
} |
|
126 |
|
|
127 |
/** |
34f071
|
128 |
* 获取操作用户资金信息消息 |
A |
129 |
* @param userMoneyUnclaimed 参数 |
|
130 |
* @param type 是否领取资金 |
|
131 |
* @return 返回 |
|
132 |
*/ |
|
133 |
private JSONObject getOpInfo(UserMoneyUnclaimed userMoneyUnclaimed, Integer type) { |
|
134 |
BigDecimal before = BigDecimal.ZERO; |
|
135 |
BigDecimal after = BigDecimal.ZERO; |
|
136 |
JSONObject jsonObject = new JSONObject(); |
|
137 |
// 获取处理信息 |
|
138 |
StringBuilder info = new StringBuilder(); |
|
139 |
info.append(userMoneyUnclaimed.getOriginSubject()); |
|
140 |
// 查询用户资金信息 |
|
141 |
UserMoney userMoney = userMoneyService.selectUserIdDecrypt(userMoneyUnclaimed.getUserId()); |
|
142 |
switch (userMoneyUnclaimed.getFundType()) { |
|
143 |
case UserMoneyUnclaimed.FUND_TYPE_STORED_VALUE_FUND: |
eb4b67
|
144 |
info.append(", 储值金"); |
34f071
|
145 |
before = new BigDecimal(userMoney.getStoredValueFund()); |
A |
146 |
after = before.add(userMoneyUnclaimed.getOpNumber()); |
|
147 |
break; |
|
148 |
case UserMoneyUnclaimed.FUND_TYPE_VALUE_ADDED_FUND: |
eb4b67
|
149 |
info.append(", 增值金"); |
34f071
|
150 |
before = new BigDecimal(userMoney.getValueAddedFund()); |
A |
151 |
after = before.add(userMoneyUnclaimed.getOpNumber()); |
|
152 |
break; |
|
153 |
case UserMoneyUnclaimed.FUND_TYPE_INTEGRAL: |
eb4b67
|
154 |
info.append(", 积分"); |
34f071
|
155 |
before = new BigDecimal(userMoney.getIntegral()); |
A |
156 |
after = before.add(userMoneyUnclaimed.getOpNumber()); |
|
157 |
break; |
|
158 |
case UserMoneyUnclaimed.FUND_TYPE_DEPOSIT: |
eb4b67
|
159 |
info.append(", 预定金"); |
34f071
|
160 |
before = new BigDecimal(userMoney.getDeposit()); |
A |
161 |
after = before.add(userMoneyUnclaimed.getOpNumber()); |
|
162 |
break; |
|
163 |
} |
eb4b67
|
164 |
info.append(", 操作数量:").append(userMoneyUnclaimed.getOpNumber()); |
34f071
|
165 |
if (UserMoneyUnclaimed.FUND_TYPE_VALUE_ADDED_FUND == userMoneyUnclaimed.getFundType()) { |
A |
166 |
// 增值金添加是否需要领取 |
|
167 |
int opType = userMoneyUnclaimed.getOpType() == null ? BaseEntity.YES : userMoneyUnclaimed.getOpType(); |
eb4b67
|
168 |
info.append(", 是否需要领取:").append(BaseEntity.YES.equals(opType) ? "是" : "否"); |
2b66d8
|
169 |
if (BaseEntity.NO.equals(type)){ |
eb4b67
|
170 |
before = null; |
A |
171 |
after = null; |
|
172 |
} |
34f071
|
173 |
} |
A |
174 |
if (BaseEntity.YES.equals(type)){ |
eb4b67
|
175 |
info.append(", 领取资金: ").append(userMoneyUnclaimed.getOpNumber()); |
A |
176 |
} |
|
177 |
if (3 == type){ |
|
178 |
info.append(", 作废待领取资金: ").append(userMoneyUnclaimed.getOpNumber()); |
|
179 |
before = null; |
|
180 |
after = null; |
34f071
|
181 |
} |
A |
182 |
jsonObject.put("key", info.toString()); |
dbfd62
|
183 |
if (before != null) { |
A |
184 |
jsonObject.put("before", before); |
|
185 |
jsonObject.put("after", after); |
|
186 |
} |
34f071
|
187 |
return jsonObject; |
A |
188 |
} |
|
189 |
|
|
190 |
/** |
|
191 |
* 添加用户日志 |
|
192 |
* @param userMoneyUnclaimed 用户资金对象 |
|
193 |
* @param type 是否领取资金 |
|
194 |
*/ |
|
195 |
private void addUserLog(UserMoneyUnclaimed userMoneyUnclaimed, Integer type){ |
|
196 |
// 处理用户日志 |
|
197 |
User user = userMapper.selectOneByKey(userMoneyUnclaimed.getUserId()); |
|
198 |
if (user != null) { |
|
199 |
// 用户日志 |
|
200 |
JSONArray logArray = new JSONArray(); |
|
201 |
JSONObject jsonObject = getOpInfo(userMoneyUnclaimed, type); |
|
202 |
logArray.add(jsonObject); |
|
203 |
// 操作人转换 |
|
204 |
UserUpdateLog userUpdateLog = new UserUpdateLog(); |
007982
|
205 |
// 来源渠道 |
A |
206 |
userUpdateLog.setSourceAppCode(userMoneyUnclaimed.getOriginChannel()); |
|
207 |
if (!StringUtils.isEmpty(userMoneyUnclaimed.getOriginChannel())){ |
|
208 |
String name = PlatformConstants.getName(userMoneyUnclaimed.getOriginChannel()); |
|
209 |
userUpdateLog.setSourceAppName(name); |
|
210 |
} |
34f071
|
211 |
switch (userMoneyUnclaimed.getOperatorType()) { |
A |
212 |
case UserMoneyUnclaimed.OPERATOR_TYPE_USER: |
|
213 |
userUpdateLog.setOperatorType(UserUpdateLog.OPERATOR_TYPE_USER); |
|
214 |
userUpdateLog.setOperatorId(userMoneyUnclaimed.getOperatorId()); |
|
215 |
userUpdateLog.setOperatorName(userMoneyUnclaimed.getOperatorName()); |
|
216 |
break; |
|
217 |
case UserMoneyUnclaimed.OPERATOR_TYPE_EMPLOYEE: |
|
218 |
userUpdateLog.setOperatorType(UserUpdateLog.OPERATOR_TYPE_EMPLOYEE); |
|
219 |
userUpdateLog.setOperatorId(userMoneyUnclaimed.getOperatorId()); |
|
220 |
userUpdateLog.setOperatorName(userMoneyUnclaimed.getOperatorName()); |
|
221 |
break; |
|
222 |
case UserMoneyUnclaimed.OPERATOR_TYPE_ADMIN: |
|
223 |
userUpdateLog.setOperatorType(UserUpdateLog.OPERATOR_TYPE_ADMIN); |
|
224 |
userUpdateLog.setOperatorId(userMoneyUnclaimed.getOperatorId()); |
|
225 |
userUpdateLog.setOperatorName(userMoneyUnclaimed.getOperatorName()); |
|
226 |
break; |
|
227 |
case UserMoneyUnclaimed.OPERATOR_TYPE_SYSTEM: |
|
228 |
userUpdateLog.setOperatorType(UserUpdateLog.OPERATOR_TYPE_SYSTEM); |
|
229 |
break; |
|
230 |
} |
ce1308
|
231 |
// 记录编号 |
A |
232 |
String recordNo = systemParameterService.createUSLGNo(user.getId(), user.getCIQ()); |
34f071
|
233 |
// 添加用户日志 |
ce1308
|
234 |
UserInfoTool.addUserUpdateLogOp(commonService, user, user.getShopId(), userUpdateLog, "用户资金调整", logArray, userMoneyUnclaimed.getRemarks(), recordNo); |
34f071
|
235 |
} |
A |
236 |
} |
|
237 |
|
|
238 |
/** |
16a35e
|
239 |
* 发送企业微信资金到账消息 |
A |
240 |
* @param userMoneyUnclaimed 参数 |
|
241 |
*/ |
|
242 |
private void sentCorpNotice(UserMoneyUnclaimed userMoneyUnclaimed) { |
339884
|
243 |
// 开始处理添加发送通知任务 到账提醒 |
A |
244 |
if (userMoneyUnclaimed.getOpNumber().compareTo(BigDecimal.ZERO) > 0) { |
16a35e
|
245 |
// 添加发送通知任务 |
A |
246 |
TimerHandleTool.addTask(commonService, TimerHandleItem.TYPE_USER_MONEY_CORP_NOTICE, userMoneyUnclaimed.getId(), null); |
|
247 |
} |
|
248 |
} |
|
249 |
|
|
250 |
/** |
689637
|
251 |
* 新增 |
A |
252 |
*/ |
|
253 |
@Override |
|
254 |
public void insert(UserMoneyUnclaimed userMoneyUnclaimed) { |
|
255 |
int count = userMoneyUnclaimedMapper.insert(userMoneyUnclaimed); |
|
256 |
if (count != 1) { |
|
257 |
throw new TipsException("新增失败!"); |
45739e
|
258 |
} else { |
A |
259 |
// 重新获取下数据 |
|
260 |
UserMoneyUnclaimed checkUserMoneyUnclaimed = userMoneyUnclaimedMapper.selectOneByKey(userMoneyUnclaimed.getId()); |
|
261 |
if(checkUserMoneyUnclaimed != null) { |
34f071
|
262 |
// 添加用户日志 |
A |
263 |
addUserLog(userMoneyUnclaimed, BaseEntity.NO); |
dbfd62
|
264 |
// 过滤待领取的数据 |
A |
265 |
this.handlerReceiveData(checkUserMoneyUnclaimed, BaseEntity.YES); |
16a35e
|
266 |
// 处理发送顾问通知消息 |
181647
|
267 |
this.sentCorpNotice(checkUserMoneyUnclaimed); |
45739e
|
268 |
} |
689637
|
269 |
} |
A |
270 |
} |
|
271 |
|
|
272 |
/** |
|
273 |
* 修改 |
|
274 |
*/ |
|
275 |
@Override |
|
276 |
public void updateAll(UserMoneyUnclaimed userMoneyUnclaimed) { |
dbfd62
|
277 |
// 作废了记录处理 |
eb4b67
|
278 |
if(BaseEntity.YES.equals(userMoneyUnclaimed.getIsDel())){ |
A |
279 |
// 添加用户日志 |
|
280 |
addUserLog(userMoneyUnclaimed, 3); |
|
281 |
} |
689637
|
282 |
int count = userMoneyUnclaimedMapper.updateAll(userMoneyUnclaimed); |
A |
283 |
if (count != 1) { |
|
284 |
throw new TipsException("保存失败!"); |
|
285 |
} |
|
286 |
} |
|
287 |
|
|
288 |
/** |
|
289 |
* 修改 |
|
290 |
*/ |
|
291 |
@Override |
|
292 |
public void updateWhere(SqlSentence sqlSentence) { |
|
293 |
int count = userMoneyUnclaimedMapper.updateWhere(sqlSentence); |
|
294 |
if (count != 1) { |
|
295 |
throw new TipsException("保存失败!"); |
|
296 |
} |
|
297 |
} |
|
298 |
|
|
299 |
/** |
|
300 |
* 删除一个 |
|
301 |
*/ |
|
302 |
@Override |
|
303 |
public void deleteOne(String delId) { |
|
304 |
int count = userMoneyUnclaimedMapper.deleteById(delId); |
|
305 |
if (count != 1) { |
|
306 |
throw new TipsException("删除失败!"); |
|
307 |
} |
|
308 |
} |
|
309 |
|
|
310 |
/** |
|
311 |
* 查询条数 |
|
312 |
*/ |
|
313 |
@Override |
|
314 |
public int selectCount(SqlSentence sqlSentence) { |
|
315 |
int count = userMoneyUnclaimedMapper.selectCount(sqlSentence); |
|
316 |
return count; |
|
317 |
} |
|
318 |
|
|
319 |
/** |
|
320 |
* 校验参数 |
|
321 |
* |
|
322 |
* @param userMoneyUnclaimed 用户待领取列表 |
|
323 |
*/ |
07e691
|
324 |
@Override |
A |
325 |
public void checkParam(UserMoneyUnclaimed userMoneyUnclaimed) { |
689637
|
326 |
// 用户校验 |
A |
327 |
if (StringUtils.isEmpty(userMoneyUnclaimed.getUserId())) { |
|
328 |
throw new PlatTipsException(PlatformCode.ERROR_PARAMETER_NULL, "用户id不能为空"); |
|
329 |
} |
|
330 |
|
|
331 |
// 资金类型判断 |
|
332 |
if (userMoneyUnclaimed.getFundType() == null) { |
|
333 |
throw new PlatTipsException(PlatformCode.ERROR_PARAMETER_NULL, "资金类型不能为空"); |
|
334 |
} else { |
|
335 |
// 资金类型判断是否匹配 |
|
336 |
switch (userMoneyUnclaimed.getFundType()) { |
|
337 |
case UserMoneyUnclaimed.FUND_TYPE_STORED_VALUE_FUND: |
|
338 |
case UserMoneyUnclaimed.FUND_TYPE_VALUE_ADDED_FUND: |
|
339 |
case UserMoneyUnclaimed.FUND_TYPE_INTEGRAL: |
|
340 |
case UserMoneyUnclaimed.FUND_TYPE_DEPOSIT: |
|
341 |
break; |
|
342 |
default: |
fe8b6c
|
343 |
throw new PlatTipsException(PlatformCode.ERROR_PARAMETER_NULL, "资金类型错误,类型不存在"); |
689637
|
344 |
} |
A |
345 |
} |
|
346 |
|
|
347 |
// 来源渠道 |
|
348 |
if (StringUtils.isEmpty(userMoneyUnclaimed.getOriginChannel())) { |
be736e
|
349 |
// 默认来源渠道为 预约后台 |
A |
350 |
userMoneyUnclaimed.setOriginChannel(OriginChannelConstants.ORIGIN_CHANNEL_PHIS); |
|
351 |
// throw new PlatTipsException(PlatformCode.ERROR_PARAMETER_NULL, "来源渠道不能为空"); |
|
352 |
} |
|
353 |
/* else { |
fe8b6c
|
354 |
if (checkConstantNotHaveValue(OriginChannelConstants.class, userMoneyUnclaimed.getOriginChannel())) { |
A |
355 |
throw new PlatTipsException(PlatformCode.ERROR_PARAMETER_NULL, "来源渠道错误,渠道不存在"); |
|
356 |
} |
be736e
|
357 |
}*/ |
fe8b6c
|
358 |
|
A |
359 |
// 操作原因 |
ffbf05
|
360 |
if (StringUtils.isEmpty(userMoneyUnclaimed.getOperationReason())) { |
fe8b6c
|
361 |
throw new PlatTipsException(PlatformCode.ERROR_PARAMETER_NULL, "操作原因不能为空"); |
A |
362 |
} else { |
|
363 |
if (checkConstantNotHaveValue(OperationReasonConstants.class, userMoneyUnclaimed.getOperationReason())) { |
63c3fa
|
364 |
throw new PlatTipsException(PlatformCode.ERROR_PARAMETER_NULL, "操作原因错误,原因不存在"); |
fe8b6c
|
365 |
} |
689637
|
366 |
} |
A |
367 |
|
0c0f9a
|
368 |
// 操作类型 |
A |
369 |
if (userMoneyUnclaimed.getOpType() == null) { |
07e691
|
370 |
// 默认为系统处理 |
0c0f9a
|
371 |
userMoneyUnclaimed.setOpType(UserMoneyUnclaimed.OP_TYPE_SYSTEM); |
07e691
|
372 |
// 增值金默认需要领取 |
A |
373 |
if (UserMoneyUnclaimed.FUND_TYPE_VALUE_ADDED_FUND == userMoneyUnclaimed.getFundType()) { |
|
374 |
// 增值金默认需要领取 负数不用用户领取和判断是否需要发送短信提醒领取 |
ffbf05
|
375 |
if (BigDecimal.ZERO.compareTo(userMoneyUnclaimed.getOpNumber()) < 0) { |
07e691
|
376 |
userMoneyUnclaimed.setOpType(UserMoneyUnclaimed.OP_TYPE_RECEIVE); |
A |
377 |
} |
|
378 |
} |
0c0f9a
|
379 |
} else { |
A |
380 |
// 判断是否是支持的类型 |
|
381 |
if (UserMoneyUnclaimed.OP_TYPE_SYSTEM != userMoneyUnclaimed.getOpType() && UserMoneyUnclaimed.OP_TYPE_RECEIVE != userMoneyUnclaimed.getOpType()) { |
|
382 |
throw new PlatTipsException(PlatformCode.ERROR_PARAMETER_NULL, "操作类型错误"); |
|
383 |
} |
04477c
|
384 |
} |
A |
385 |
|
|
386 |
// 是否发送短信 |
ffbf05
|
387 |
if (UserMoneyUnclaimed.OP_TYPE_RECEIVE == userMoneyUnclaimed.getOpType()) { |
A |
388 |
boolean flag = true; |
|
389 |
// 查询用户设置是否领取状态 |
|
390 |
UserInfo userInfo = userInfoMapper.selectOneByUserId(userMoneyUnclaimed.getUserId()); |
|
391 |
if (userInfo != null) { |
|
392 |
// 不需要领取处理数据 |
|
393 |
if (userInfo.getIsReceiveValueAddedFund() != null && BaseEntity.NO.equals(userInfo.getIsReceiveValueAddedFund())) { |
|
394 |
flag = false; |
|
395 |
userMoneyUnclaimed.setOpType(UserMoneyUnclaimed.OP_TYPE_SYSTEM); |
|
396 |
// 用户设置了不用再领取增值金 |
|
397 |
logger.info("操作用户资金(待领取记录)-用户设置是否需要领取状态:{}", userInfo.getIsReceiveValueAddedFund()); |
|
398 |
} |
|
399 |
} |
04477c
|
400 |
// 校验是否要发送短信 |
ffbf05
|
401 |
if (flag) { |
A |
402 |
checkIsNeedSentSMS(userMoneyUnclaimed); |
|
403 |
} |
0c0f9a
|
404 |
} |
A |
405 |
|
689637
|
406 |
// 判断操作数量或金额 |
A |
407 |
if (userMoneyUnclaimed.getOpNumber() == null) { |
|
408 |
throw new PlatTipsException(PlatformCode.ERROR_PARAMETER_NULL, "操作数量或金额不能为空"); |
|
409 |
} else { |
|
410 |
// 判断操作数量或金额 是否为 0 |
|
411 |
if (BigDecimal.ZERO.compareTo(userMoneyUnclaimed.getOpNumber()) == 0) { |
|
412 |
throw new PlatTipsException(PlatformCode.ERROR_PARAMETER_NULL, "操作数量或金额不能为0"); |
|
413 |
} else if (BigDecimal.ZERO.compareTo(userMoneyUnclaimed.getOpNumber()) < 0) { |
|
414 |
// 资金操作类型-增加 |
|
415 |
userMoneyUnclaimed.setFundOpType(UserMoneyUnclaimed.FUND_OP_TYPE_INCREASE); |
|
416 |
} else if (BigDecimal.ZERO.compareTo(userMoneyUnclaimed.getOpNumber()) > 0) { |
|
417 |
// 资金操作类型-减少 |
|
418 |
userMoneyUnclaimed.setFundOpType(UserMoneyUnclaimed.FUND_OP_TYPE_REDUCE); |
|
419 |
} |
|
420 |
|
|
421 |
// 用户资金数据校验 |
|
422 |
UserMoney userMoney = userMoneyService.selectUserIdDecrypt(userMoneyUnclaimed.getUserId()); |
c54805
|
423 |
logger.info("用户{},用户资产{},用户金额记录{}",userMoneyUnclaimed.getUserId(),JSON.toJSONString(userMoney),JSON.toJSONString(userMoneyUnclaimed)); |
689637
|
424 |
if (userMoney == null) { |
A |
425 |
throw new PlatTipsException(PlatformCode.ERROR_PARAMETER_NULL, "用户的资产数据不存在"); |
|
426 |
} else { |
|
427 |
// 判断数量减扣数量是否充足 |
|
428 |
if (UserMoneyUnclaimed.FUND_OP_TYPE_REDUCE == userMoneyUnclaimed.getFundOpType()) { |
|
429 |
// 资金类型判断是否匹配 |
|
430 |
switch (userMoneyUnclaimed.getFundType()) { |
|
431 |
case UserMoneyUnclaimed.FUND_TYPE_STORED_VALUE_FUND: |
|
432 |
// 金额操作 |
|
433 |
BigDecimal storedValueFund = new BigDecimal(userMoney.getStoredValueFund()); |
8360f2
|
434 |
// 判断是否足够扣减 |
A |
435 |
this.checkCanOperation(userMoneyUnclaimed.getFundType(), storedValueFund, userMoneyUnclaimed.getOpNumber()); |
689637
|
436 |
break; |
A |
437 |
case UserMoneyUnclaimed.FUND_TYPE_VALUE_ADDED_FUND: |
07e691
|
438 |
// 金额操作 不做校验可以减成负数 |
34f071
|
439 |
BigDecimal valueAddedFund = new BigDecimal(userMoney.getValueAddedFund()); |
8360f2
|
440 |
// 判断是否足够扣减 |
A |
441 |
this.checkCanOperation(userMoneyUnclaimed.getFundType(), valueAddedFund, userMoneyUnclaimed.getOpNumber()); |
689637
|
442 |
break; |
A |
443 |
case UserMoneyUnclaimed.FUND_TYPE_INTEGRAL: |
fecaea
|
444 |
// 积分操作 |
689637
|
445 |
BigDecimal integral = new BigDecimal(userMoney.getIntegral()); |
8360f2
|
446 |
// 判断是否足够扣减 |
A |
447 |
this.checkCanOperation(userMoneyUnclaimed.getFundType(), integral, userMoneyUnclaimed.getOpNumber()); |
689637
|
448 |
break; |
A |
449 |
case UserMoneyUnclaimed.FUND_TYPE_DEPOSIT: |
|
450 |
// 金额操作 |
|
451 |
BigDecimal deposit = new BigDecimal(userMoney.getDeposit()); |
8360f2
|
452 |
// 判断是否足够扣减 |
A |
453 |
this.checkCanOperation(userMoneyUnclaimed.getFundType(), deposit, userMoneyUnclaimed.getOpNumber()); |
689637
|
454 |
break; |
A |
455 |
} |
|
456 |
} |
|
457 |
} |
|
458 |
} |
|
459 |
|
|
460 |
// 操作人信息判断 |
|
461 |
if (userMoneyUnclaimed.getOperatorType() == null) { |
|
462 |
// 操作人类型默认为员工 |
|
463 |
userMoneyUnclaimed.setOperatorType(UserMoneyUnclaimed.OPERATOR_TYPE_EMPLOYEE); |
|
464 |
} else { |
|
465 |
// 操作人类型判断是否匹配 |
|
466 |
switch (userMoneyUnclaimed.getOperatorType()) { |
|
467 |
case UserMoneyUnclaimed.OPERATOR_TYPE_ADMIN: |
|
468 |
case UserMoneyUnclaimed.OPERATOR_TYPE_USER: |
|
469 |
case UserMoneyUnclaimed.OPERATOR_TYPE_EMPLOYEE: |
|
470 |
break; |
|
471 |
default: |
|
472 |
throw new PlatTipsException(PlatformCode.ERROR_PARAMETER_NULL, "操作人类型错误"); |
|
473 |
} |
|
474 |
} |
|
475 |
|
|
476 |
// 判断是否传了操作人id |
|
477 |
if (StringUtils.isEmpty(userMoneyUnclaimed.getOperatorId())) { |
|
478 |
throw new PlatTipsException(PlatformCode.ERROR_PARAMETER_NULL, "操作人id不能为空"); |
|
479 |
} |
|
480 |
|
|
481 |
// 操作人为员工 |
|
482 |
if (UserMoneyUnclaimed.OPERATOR_TYPE_EMPLOYEE == userMoneyUnclaimed.getOperatorType()) { |
|
483 |
Employee employee = commonService.selectOneByKey(EmployeeMapper.class, userMoneyUnclaimed.getOperatorId()); |
|
484 |
if (employee == null) { |
|
485 |
throw new PlatTipsException(PlatformCode.ERROR_TIPS, "操作人的信息不存在"); |
|
486 |
} else { |
|
487 |
// 填充名称 |
|
488 |
userMoneyUnclaimed.setOperatorName(employee.getCnName()); |
|
489 |
} |
|
490 |
} |
|
491 |
|
|
492 |
// 操作人为后台用户 |
|
493 |
if (UserMoneyUnclaimed.OPERATOR_TYPE_ADMIN == userMoneyUnclaimed.getOperatorType()) { |
|
494 |
SysAdmin sysAdmin = commonService.selectOneByKey(SysAdminMapper.class, userMoneyUnclaimed.getOperatorId()); |
|
495 |
if (sysAdmin == null) { |
|
496 |
throw new PlatTipsException(PlatformCode.ERROR_TIPS, "操作人的信息不存在"); |
|
497 |
} else { |
|
498 |
// 填充名称 |
|
499 |
userMoneyUnclaimed.setOperatorName(sysAdmin.getName()); |
|
500 |
} |
|
501 |
} |
|
502 |
|
|
503 |
// 操作人为用户 |
fc1e34
|
504 |
if (UserMoneyUnclaimed.OPERATOR_TYPE_USER == userMoneyUnclaimed.getOperatorType()) { |
689637
|
505 |
User user = commonService.selectOneByKey(UserMapper.class, userMoneyUnclaimed.getOperatorId()); |
A |
506 |
if (user == null) { |
|
507 |
throw new PlatTipsException(PlatformCode.ERROR_TIPS, "操作人的信息不存在"); |
|
508 |
} else { |
|
509 |
// 填充名称 |
|
510 |
userMoneyUnclaimed.setOperatorName(user.getName()); |
0c0f9a
|
511 |
} |
A |
512 |
} |
|
513 |
|
839339
|
514 |
/*// 判断订单 先不判断订单 |
45739e
|
515 |
if(!StringUtils.isEmpty(userMoneyUnclaimed.getOrderId())){ |
0c0f9a
|
516 |
OrdersTotal ordersTotal = commonService.selectOneByKey(OrdersTotalMapper.class, userMoneyUnclaimed.getOrderId()); |
A |
517 |
if(ordersTotal == null){ |
|
518 |
throw new PlatTipsException(PlatformCode.ERROR_TIPS, "主订单的信息不存在"); |
|
519 |
} |
|
520 |
} |
|
521 |
|
|
522 |
// 判断子订单 |
|
523 |
if(!StringUtils.isEmpty(userMoneyUnclaimed.getOrderItemId())){ |
|
524 |
if(StringUtils.isEmpty(userMoneyUnclaimed.getOrderId())){ |
|
525 |
throw new PlatTipsException(PlatformCode.ERROR_TIPS, "主订单id不能为空!"); |
|
526 |
} |
|
527 |
OrderItem orderItem = commonService.selectOneByKey(OrderItemMapper.class, userMoneyUnclaimed.getOrderItemId()); |
|
528 |
if(orderItem == null){ |
|
529 |
throw new PlatTipsException(PlatformCode.ERROR_TIPS, "子订单的信息不存在"); |
|
530 |
} else { |
|
531 |
if(!orderItem.getOrderId().equals(userMoneyUnclaimed.getOrderId())){ |
|
532 |
throw new PlatTipsException(PlatformCode.ERROR_TIPS, "子订单的信息与主订单的信息不匹配"); |
|
533 |
} |
689637
|
534 |
} |
839339
|
535 |
}*/ |
689637
|
536 |
|
A |
537 |
// 获取有效期时间配置 待领取默认30天领取 |
3a4e9f
|
538 |
int validityPeriod = UserMoneyTool.getUnclaimedValidityTime(commonService); |
A |
539 |
// 获取时间 |
|
540 |
Date limitEndTime = DateUtil.addDay(userMoneyUnclaimed.getLimitStartTime(), validityPeriod); |
689637
|
541 |
// 设置有效期时间 |
3a4e9f
|
542 |
userMoneyUnclaimed.setLimitEndTime(limitEndTime); |
689637
|
543 |
} |
A |
544 |
|
|
545 |
/** |
fe8b6c
|
546 |
* 校验常量值是否存在 |
A |
547 |
* @param classObj 类对象 |
|
548 |
* @param value 校验值 |
|
549 |
* @return 返回 |
|
550 |
*/ |
565a37
|
551 |
@Override |
A |
552 |
public boolean checkConstantNotHaveValue(Class classObj, String value) { |
fe8b6c
|
553 |
boolean flag = true; |
A |
554 |
// 判断是否存在这个来源渠道 |
|
555 |
Field[] fields = classObj.getDeclaredFields(); |
|
556 |
for (Field field : fields) { |
|
557 |
field.setAccessible(true); |
|
558 |
// 获取常量名称 |
|
559 |
String fieldName = field.getName(); |
|
560 |
// 判断常量值是否存在 |
|
561 |
if (field.getType().toString().endsWith("java.lang.String") && Modifier.isStatic(field.getModifiers())) { |
|
562 |
try { |
|
563 |
// 获取常量值 |
|
564 |
String fieldValue = field.get(classObj).toString(); |
|
565 |
if (fieldValue.equals(value)) { |
|
566 |
flag = false; |
|
567 |
break; |
|
568 |
} |
|
569 |
}catch (Exception ex){ |
|
570 |
throw new PlatTipsException(PlatformCode.ERROR_TIPS, "常量获取配置出现错误"); |
|
571 |
|
|
572 |
} |
|
573 |
} |
|
574 |
} |
|
575 |
return flag; |
|
576 |
} |
|
577 |
|
|
578 |
/** |
689637
|
579 |
* 判断数据是否支持减扣 |
A |
580 |
*/ |
8360f2
|
581 |
private void checkCanOperation(Integer fundType, BigDecimal value, BigDecimal opNumber) { |
689637
|
582 |
// 负数取反计算 |
8360f2
|
583 |
if (BigDecimal.ZERO.compareTo(opNumber) > 0) { |
689637
|
584 |
opNumber = opNumber.negate(); |
A |
585 |
} |
|
586 |
// 计算账户余额是否支持减扣 |
|
587 |
BigDecimal subtractValue = value.subtract(opNumber); |
|
588 |
if (subtractValue.compareTo(BigDecimal.ZERO) < 0) { |
8360f2
|
589 |
// 获取资金名称 |
A |
590 |
String fundTypeName = UserMoneyUnclaimed.getFundTypeName(fundType); |
|
591 |
// 提示错误 |
|
592 |
throw new PlatTipsException(PlatformCode.ERROR_TIPS, String.format("用户资金账户%s不足扣减!", fundTypeName)); |
fe8b6c
|
593 |
} |
A |
594 |
} |
|
595 |
|
|
596 |
/** |
|
597 |
* 根据平台判断是否需要发送短信 |
|
598 |
* @param userMoneyUnclaimed 用户待领取信息 |
|
599 |
*/ |
04477c
|
600 |
private void checkIsNeedSentSMS(UserMoneyUnclaimed userMoneyUnclaimed) { |
A |
601 |
// CRM不用发送短信领取其他平台需要发送短信领取 |
|
602 |
// if(!OriginChannelConstants.ORIGIN_CHANNEL_CRM.equals(userMoneyUnclaimed.getOriginChannel())) { |
|
603 |
userMoneyUnclaimed.setIsSentSMS(BaseEntity.YES); |
|
604 |
String url = getSMSUrl(); |
|
605 |
if (StringUtils.isEmpty(url)) { |
|
606 |
throw new PlatTipsException(PlatformCode.ERROR_TIPS, "获取发送短信链接地址出现异常!"); |
689637
|
607 |
} |
04477c
|
608 |
userMoneyUnclaimed.setSMSUrl(url); |
A |
609 |
//} |
689637
|
610 |
} |
A |
611 |
|
|
612 |
/** |
fe8b6c
|
613 |
* 生成需要发送短信的地址 |
A |
614 |
* @return 返回 |
|
615 |
*/ |
bf83fa
|
616 |
private String getSMSUrl() { |
A |
617 |
// 生成小程序链接 |
fe8b6c
|
618 |
String urlLink = null; |
bf83fa
|
619 |
// 正式区在拿取链接 |
47e70d
|
620 |
if (PlatformPattern.PROD.equals(customParameter.getPlatformPatternMoney())) { |
7cf66a
|
621 |
// 获取用户CRM小程序token |
bf83fa
|
622 |
ApplyParameter applyParameter = ApplyParameterTool.getMpParameter("wx71e6babac80abcee", commonService); |
A |
623 |
if (applyParameter == null) { |
|
624 |
throw new PlatTipsException(PlatformCode.ERROR_TIPS, "mpId is error"); |
fe8b6c
|
625 |
} |
7cf66a
|
626 |
// 获取范围密钥 |
A |
627 |
SysParameter sysParameter = systemParameterService.getAccessToken(applyParameter.getMpAppId(), applyParameter.getMpSecretKey()); |
bf83fa
|
628 |
if (sysParameter == null) { |
A |
629 |
throw new PlatTipsException(PlatformCode.ERROR_SYSTEM, "服务错误" + SystemCode.ERROR_GET_CORP_TOKEN); |
|
630 |
} |
|
631 |
|
deb885
|
632 |
// 更换链接 原CRM 1.0 /pages/recharge/incrementInfo |
A |
633 |
String result = SendSMSTool.getAooLetUrl(sysParameter.getParamValue(), "/pages/portClient_me/incrementValue/incrementValue", "", "release"); |
bf83fa
|
634 |
if (!StringUtils.isEmpty(result)) { |
A |
635 |
JSONObject jsonObject = JSON.parseObject(result); |
|
636 |
if (jsonObject.getInteger("errcode") != 0) { |
|
637 |
throw new PlatTipsException(PlatformCode.ERROR_SYSTEM, "生成短信小程序路径错误:" + jsonObject.getString("msg") + SystemCode.ERROR_GET_CORP_TOKEN); |
|
638 |
} |
|
639 |
urlLink = jsonObject.getString("url_link"); |
|
640 |
} |
|
641 |
} else { |
|
642 |
// 测试区跳转百度 |
2d878f
|
643 |
urlLink = "https://wxaurl.cn/6666"; |
fe8b6c
|
644 |
} |
A |
645 |
return urlLink; |
|
646 |
} |
0c0f9a
|
647 |
|
A |
648 |
/** |
07e691
|
649 |
* 待领取资产处理 |
fecaea
|
650 |
* @param userMoneyUnclaimed 待领取数据 |
fc1e34
|
651 |
* @param isReceive 是否过滤领取数据 0 否 1 是 |
0c0f9a
|
652 |
*/ |
A |
653 |
@Override |
fc1e34
|
654 |
public void handlerReceiveData(UserMoneyUnclaimed userMoneyUnclaimed, Integer isReceive) { |
07e691
|
655 |
if (userMoneyUnclaimed != null) { |
A |
656 |
// 多线程添加锁 |
|
657 |
synchronized (this) { |
31051b
|
658 |
// 判断是不是要领取的数据 |
3a4e9f
|
659 |
if (BaseEntity.YES.equals(isReceive)) { |
fc1e34
|
660 |
if (UserMoneyUnclaimed.OP_TYPE_RECEIVE == userMoneyUnclaimed.getOpType()) { |
ac698b
|
661 |
logger.info("待领取资产处理跳过,数据id:{},原因:需要领取数据", userMoneyUnclaimed.getId()); |
fc1e34
|
662 |
return; |
A |
663 |
} |
31051b
|
664 |
} |
A |
665 |
// 判断是否处理了 |
3a4e9f
|
666 |
if (UserMoneyUnclaimed.STATUS_SUCCEED == userMoneyUnclaimed.getStatus()) { |
ac698b
|
667 |
logger.info("待领取资产处理跳过,数据id:{},原因:数据已领取不需要再处理", userMoneyUnclaimed.getId()); |
31051b
|
668 |
return; |
A |
669 |
} |
|
670 |
// 判断数据是否有效 |
3a4e9f
|
671 |
if (UserMoneyUnclaimed.NO.equals(userMoneyUnclaimed.getIsValid())) { |
ac698b
|
672 |
logger.info("待领取资产处理跳过,数据id:{},原因:数据已失效无法领取", userMoneyUnclaimed.getId()); |
31051b
|
673 |
return; |
A |
674 |
} |
dbfd62
|
675 |
// 添加用户日志 |
3a4e9f
|
676 |
if (BaseEntity.NO.equals(isReceive)) { |
dbfd62
|
677 |
addUserLog(userMoneyUnclaimed, BaseEntity.YES); |
A |
678 |
} |
07e691
|
679 |
// 操作资金处理 |
A |
680 |
switch (userMoneyUnclaimed.getFundType()) { |
|
681 |
case UserMoneyUnclaimed.FUND_TYPE_STORED_VALUE_FUND: |
|
682 |
case UserMoneyUnclaimed.FUND_TYPE_DEPOSIT: |
|
683 |
// 储值金和预定金只处理总资金信息 |
|
684 |
userMoneyService.handleMoneyData(userMoneyUnclaimed); |
|
685 |
break; |
|
686 |
case UserMoneyUnclaimed.FUND_TYPE_VALUE_ADDED_FUND: |
|
687 |
// 处理增值金 |
|
688 |
userValueAddedFundRecordService.handleData(userMoneyUnclaimed); |
|
689 |
break; |
|
690 |
case UserMoneyUnclaimed.FUND_TYPE_INTEGRAL: |
|
691 |
// 处理积分 |
|
692 |
userIntegralRecordService.handleData(userMoneyUnclaimed); |
|
693 |
break; |
|
694 |
} |
|
695 |
// 更新状态成已处理 |
|
696 |
SqlSentence sqlSentence = new SqlSentence(); |
|
697 |
Map<String, Object> sqlValue = new HashMap<>(); |
89e4d1
|
698 |
String sql = " status=#{m.status},receiveTime=#{m.nowTime},limitEndTime=#{m.limitEndTime},editTime=#{m.nowTime} WHERE id=#{m.id}"; |
3a4e9f
|
699 |
sqlValue.put("nowTime", new Date()); |
07e691
|
700 |
sqlValue.put("id", userMoneyUnclaimed.getId()); |
A |
701 |
sqlValue.put("status", UserMoneyUnclaimed.STATUS_SUCCEED); |
89e4d1
|
702 |
// 已领取调整领取时间 |
3a4e9f
|
703 |
int validityPeriod = UserMoneyTool.getReceivedValidityTime(commonService); |
A |
704 |
// 获取时间 |
|
705 |
Date limitEndTime = DateUtil.addDay(userMoneyUnclaimed.getLimitStartTime(), validityPeriod); |
|
706 |
sqlValue.put("limitEndTime", limitEndTime); |
07e691
|
707 |
sqlSentence.sqlSentence(sql, sqlValue); |
A |
708 |
commonService.updateWhere(UserMoneyUnclaimedMapper.class, sqlSentence); |
|
709 |
} |
|
710 |
} |
0c0f9a
|
711 |
} |
dfa10a
|
712 |
|
F |
713 |
/**转赠*/ |
|
714 |
@Override |
|
715 |
public void turn(UserTurnDto userTurnDto) { |
|
716 |
logger.info("转赠参数"+ JSONObject.toJSONString(userTurnDto)); |
|
717 |
//1.参数校验 |
|
718 |
turnParameterCheck(userTurnDto); |
|
719 |
|
|
720 |
//2.判断用户是否有资金信息 |
|
721 |
//查询转出用户 |
|
722 |
User turnUser = userMapper.selectOneByKey(userTurnDto.getTurnPeopleId()); |
|
723 |
if (turnUser == null){ |
|
724 |
throw new PlatTipsException(PlatformCode.ERROR_TIPS,"找不到转出客户信息"); |
|
725 |
} |
|
726 |
//查询转入用户 |
|
727 |
User doneeUser = userMapper.selectOneByKey(userTurnDto.getDoneeId()); |
|
728 |
if (doneeUser == null){ |
|
729 |
throw new PlatTipsException(PlatformCode.ERROR_TIPS,"找不到转入客户信息"); |
|
730 |
} |
|
731 |
//3.转赠操作 |
|
732 |
//增值金 |
|
733 |
if (userTurnDto.getIncrementMoney() != null) { |
|
734 |
//操作资金 |
|
735 |
moneyTurn(0,userTurnDto); |
|
736 |
//生成转赠记录 |
|
737 |
newTurnAdd(UserMoneyEnum.INCREMENT.getCode(), userTurnDto,turnUser,doneeUser); |
|
738 |
} |
|
739 |
//储值金 |
|
740 |
if (userTurnDto.getStoredMoney() != null){ |
|
741 |
//操作资金 |
|
742 |
moneyTurn(1,userTurnDto); |
|
743 |
//生成转赠记录 |
|
744 |
newTurnAdd(UserMoneyEnum.STORED.getCode(), userTurnDto,turnUser,doneeUser); |
|
745 |
} |
|
746 |
//积分 |
|
747 |
if (userTurnDto.getIntegral() != null){ |
|
748 |
//操作资金 |
|
749 |
moneyTurn(2,userTurnDto); |
|
750 |
//生成转赠记录 |
|
751 |
newTurnAdd(UserMoneyEnum.INTEGRAL.getCode(), userTurnDto,turnUser,doneeUser); |
|
752 |
} |
|
753 |
} |
|
754 |
|
|
755 |
/** |
|
756 |
* @param moneyType 操作金额类型:0增值金,1储值金,2积分 |
|
757 |
* @param userTurnDto 参数 |
|
758 |
* */ |
|
759 |
private void moneyTurn(Integer moneyType,UserTurnDto userTurnDto) { |
|
760 |
//增值金转出人金额校验 |
|
761 |
UserMoneyUnclaimed userMoneyUnclaimed = new UserMoneyUnclaimed(); |
|
762 |
//金额类型 |
|
763 |
if (moneyType == 0){ |
|
764 |
userMoneyUnclaimed.setFundType(UserMoneyUnclaimed.FUND_TYPE_VALUE_ADDED_FUND); |
390e1c
|
765 |
userMoneyUnclaimed.setOpNumber(new BigDecimal(userTurnDto.getIncrementMoney()).negate()); |
dfa10a
|
766 |
}else if (moneyType == 1){ |
F |
767 |
userMoneyUnclaimed.setFundType(UserMoneyUnclaimed.FUND_TYPE_STORED_VALUE_FUND); |
390e1c
|
768 |
userMoneyUnclaimed.setOpNumber(new BigDecimal(userTurnDto.getStoredMoney()).negate()); |
dfa10a
|
769 |
}else if (moneyType == 2){ |
F |
770 |
userMoneyUnclaimed.setFundType(UserMoneyUnclaimed.FUND_TYPE_INTEGRAL); |
390e1c
|
771 |
userMoneyUnclaimed.setOpNumber(new BigDecimal(userTurnDto.getIntegral()).negate()); |
dfa10a
|
772 |
} |
ffeeb0
|
773 |
userMoneyUnclaimed.setOpType(0); |
dfa10a
|
774 |
userMoneyUnclaimed.setOriginChannel(userTurnDto.getAppIdCode()); |
F |
775 |
userMoneyUnclaimed.setOperatorId(userTurnDto.getCreateId()); |
|
776 |
userMoneyUnclaimed.setOperatorName(userTurnDto.getCreateName()); |
|
777 |
userMoneyUnclaimed.setOperationReason(OperationReasonConstants.OP_TURN_MONTY); |
|
778 |
userMoneyUnclaimed.setOriginSubject(userTurnDto.getOriginSubject()); |
|
779 |
userMoneyUnclaimed.setCommonId(userTurnDto.getCommonId()); |
|
780 |
userMoneyUnclaimed.setRemarks(userTurnDto.getRemarks()); |
|
781 |
//转出用户 |
|
782 |
userMoneyUnclaimed.setUserId(userTurnDto.getTurnPeopleId()); |
|
783 |
|
|
784 |
//转入用户 |
|
785 |
UserMoneyUnclaimed intoUserMoneyUnclaimed = new UserMoneyUnclaimed(); |
|
786 |
BeanUtils.copyProperties(userMoneyUnclaimed,intoUserMoneyUnclaimed); |
|
787 |
intoUserMoneyUnclaimed.setUserId(userTurnDto.getDoneeId()); |
7c05b8
|
788 |
intoUserMoneyUnclaimed.setOpNumber(userMoneyUnclaimed.getOpNumber().negate()); |
2c350d
|
789 |
intoUserMoneyUnclaimed.setOpType(0); |
dfa10a
|
790 |
|
F |
791 |
//转出 |
|
792 |
checkParam(userMoneyUnclaimed); |
|
793 |
insert(userMoneyUnclaimed); |
|
794 |
//转入 |
|
795 |
checkParam(intoUserMoneyUnclaimed); |
|
796 |
insert(intoUserMoneyUnclaimed); |
|
797 |
} |
|
798 |
|
|
799 |
/**转赠记录新增*/ |
|
800 |
private void newTurnAdd(Integer type, UserTurnDto userTurnDto, User turnOutUser, User turnIntoUser) { |
|
801 |
//转赠记录 |
|
802 |
TurnAdd turnAdd = new TurnAdd(); |
|
803 |
turnAdd.setCreateId(userTurnDto.getCreateId()); |
|
804 |
turnAdd.setCreateName(userTurnDto.getCreateName()); |
|
805 |
turnAdd.setRemarks(userTurnDto.getRemarks()); |
|
806 |
turnAdd.setTurnPeopleId(userTurnDto.getTurnPeopleId()); |
|
807 |
turnAdd.setTurnPeopleName(userTurnDto.getTurnPeopleName()); |
|
808 |
turnAdd.setTurnShopId(userTurnDto.getTurnShopId()); |
|
809 |
turnAdd.setTurnShopName(userTurnDto.getTurnShopName()); |
|
810 |
// 转增人其他信息 |
|
811 |
if (turnOutUser != null){ |
|
812 |
turnAdd.setTurnPeopleCIQ(turnOutUser.getCIQ()); |
|
813 |
turnAdd.setTurnPeopleLevel(turnOutUser.getUserLevel()); |
|
814 |
turnAdd.setTurnPeopleUserStatus(turnOutUser.getUserStatus()); |
|
815 |
} |
|
816 |
turnAdd.setDoneeId(userTurnDto.getDoneeId()); |
|
817 |
turnAdd.setDoneeName(userTurnDto.getDoneeName()); |
|
818 |
turnAdd.setDoneeShopId(userTurnDto.getDoneeShopId()); |
|
819 |
turnAdd.setDoneeShopName(userTurnDto.getDoneeShopName()); |
|
820 |
// 受赠人其他信息 |
|
821 |
if (turnIntoUser != null){ |
|
822 |
turnAdd.setDoneeCIQ(turnIntoUser.getCIQ()); |
|
823 |
turnAdd.setDoneeLevel(turnIntoUser.getUserLevel()); |
|
824 |
turnAdd.setDoneeUserStatus(turnIntoUser.getUserStatus()); |
|
825 |
} |
|
826 |
//消费/实际金额给默认0值 |
|
827 |
turnAdd.setConsumptionMoney(BigDecimal.ZERO); |
|
828 |
turnAdd.setActualMoney(BigDecimal.ZERO); |
|
829 |
if (UserMoneyEnum.INCREMENT.getCode().equals(type)){ |
|
830 |
turnAdd.setTurnMoney(new BigDecimal(userTurnDto.getIncrementMoney())); |
|
831 |
turnAdd.setRechargeMoney(new BigDecimal(userTurnDto.getIncrementMoney())); |
|
832 |
turnAdd.setType(OrderItemConstants.TYPE_TURN_INCREMENT); |
|
833 |
}else if (UserMoneyEnum.STORED.getCode().equals(type)){ |
|
834 |
turnAdd.setTurnMoney(new BigDecimal(userTurnDto.getStoredMoney())); |
|
835 |
turnAdd.setRechargeMoney(new BigDecimal(userTurnDto.getStoredMoney())); |
|
836 |
turnAdd.setType(OrderItemConstants.TYPE_TURN_STORED); |
|
837 |
}else if (UserMoneyEnum.INTEGRAL.getCode().equals(type)){ |
|
838 |
turnAdd.setTurnMoney(new BigDecimal(userTurnDto.getIntegral())); |
|
839 |
turnAdd.setRechargeMoney(new BigDecimal(userTurnDto.getIntegral())); |
|
840 |
turnAdd.setType(OrderItemConstants.TYPE_TURN_INTEGRAL); |
|
841 |
} |
|
842 |
if (turnAddMapper.insert(turnAdd) != 1){ |
|
843 |
throw new PlatTipsException(PlatformCode.ERROR_TIPS,"新增转赠记录失败!"); |
|
844 |
} |
|
845 |
} |
|
846 |
|
|
847 |
/**转赠参数判断*/ |
|
848 |
private void turnParameterCheck(UserTurnDto userTurnDto) { |
|
849 |
if (StringUtils.isEmpty(userTurnDto.getTurnPeopleId())){ |
|
850 |
throw new PlatTipsException(PlatformCode.ERROR_PARAMETER_NULL, "转赠人标识不能为空!"); |
|
851 |
} |
|
852 |
if (StringUtils.isEmpty(userTurnDto.getTurnPeopleName())){ |
|
853 |
throw new PlatTipsException(PlatformCode.ERROR_PARAMETER_NULL, "转赠人名称不能为空!"); |
|
854 |
} |
|
855 |
if (StringUtils.isEmpty(userTurnDto.getTurnShopId())){ |
|
856 |
throw new PlatTipsException(PlatformCode.ERROR_PARAMETER_NULL, "转赠人门店标识不能为空!"); |
|
857 |
} |
|
858 |
if (StringUtils.isEmpty(userTurnDto.getTurnShopName())){ |
|
859 |
throw new PlatTipsException(PlatformCode.ERROR_PARAMETER_NULL, "转赠人门店名称不能为空!"); |
|
860 |
} |
|
861 |
if (StringUtils.isEmpty(userTurnDto.getDoneeId())){ |
|
862 |
throw new PlatTipsException(PlatformCode.ERROR_PARAMETER_NULL, "受赠人标识不能为空!"); |
|
863 |
} |
|
864 |
if (StringUtils.isEmpty(userTurnDto.getDoneeName())){ |
|
865 |
throw new PlatTipsException(PlatformCode.ERROR_PARAMETER_NULL, "受赠人名称不能为空!"); |
|
866 |
} |
|
867 |
if (StringUtils.isEmpty(userTurnDto.getDoneeShopId())){ |
|
868 |
throw new PlatTipsException(PlatformCode.ERROR_PARAMETER_NULL, "受赠人门店标识不能为空!"); |
|
869 |
} |
|
870 |
if (StringUtils.isEmpty(userTurnDto.getDoneeShopName())){ |
|
871 |
throw new PlatTipsException(PlatformCode.ERROR_PARAMETER_NULL, "受赠人门店名称不能为空!"); |
|
872 |
} |
|
873 |
if (userTurnDto.getIncrementMoney() == null && userTurnDto.getStoredMoney() == null && userTurnDto.getIntegral() == null){ |
|
874 |
throw new PlatTipsException(PlatformCode.ERROR_PARAMETER_NULL, "转赠资金不能为空!"); |
|
875 |
} |
|
876 |
if(userTurnDto.getIncrementMoney() != null && new BigDecimal(userTurnDto.getIncrementMoney()).compareTo(BigDecimal.ZERO) < 0){ |
|
877 |
throw new PlatTipsException(PlatformCode.ERROR_PARAMETER_NULL, "转赠增值金数值错误!"); |
|
878 |
} |
|
879 |
if(userTurnDto.getStoredMoney() != null && new BigDecimal(userTurnDto.getStoredMoney()).compareTo(BigDecimal.ZERO) < 0){ |
|
880 |
throw new PlatTipsException(PlatformCode.ERROR_PARAMETER_NULL, "转赠储值金金额错误!"); |
|
881 |
} |
|
882 |
if(userTurnDto.getIntegral() != null && new BigDecimal(userTurnDto.getIntegral()).compareTo(BigDecimal.ZERO) < 0){ |
|
883 |
throw new PlatTipsException(PlatformCode.ERROR_PARAMETER_NULL, "转赠积分数值错误!"); |
|
884 |
} |
|
885 |
if (StringUtils.isEmpty(userTurnDto.getCreateId())){ |
|
886 |
throw new PlatTipsException(PlatformCode.ERROR_PARAMETER_NULL, "操作人标识不能为空!"); |
|
887 |
} |
|
888 |
if (StringUtils.isEmpty(userTurnDto.getCreateName())){ |
|
889 |
throw new PlatTipsException(PlatformCode.ERROR_PARAMETER_NULL, "操作人名称不能为空!"); |
|
890 |
} |
|
891 |
if (userTurnDto.getTurnPeopleId().equals(userTurnDto.getDoneeId())){ |
|
892 |
throw new PlatTipsException(PlatformCode.ERROR_PARAMETER_NULL, "转赠人与受赠人不能为同一人!"); |
|
893 |
} |
|
894 |
|
|
895 |
} |
|
896 |
|
689637
|
897 |
} |