|
|
@@ -2,10 +2,7 @@ package com.crm.custom.service.impl;
|
|
|
|
|
|
import com.crm.custom.dao.mapper.GoldenQuestionCustomMapper;
|
|
|
import com.crm.custom.dao.mapper.GoldenRewardQuestionMapper;
|
|
|
-import com.crm.custom.dao.repository.CustomInfoRepository;
|
|
|
-import com.crm.custom.dao.repository.GoldenCustomRewardRecordRepository;
|
|
|
-import com.crm.custom.dao.repository.GoldenQuestionCustomRepository;
|
|
|
-import com.crm.custom.dao.repository.GoldenRewardQuestionRepository;
|
|
|
+import com.crm.custom.dao.repository.*;
|
|
|
import com.crm.custom.service.GoldenRewardQuestionService;
|
|
|
import com.crm.custom.service.SysConfigService;
|
|
|
import com.crm.rely.backend.core.constant.Constants;
|
|
|
@@ -50,6 +47,8 @@ public class GoldenRewardQuestionServiceImpl implements GoldenRewardQuestionServ
|
|
|
@Autowired
|
|
|
private GoldenCustomRewardRecordRepository goldenCustomRewardRecordRepository;
|
|
|
@Autowired
|
|
|
+ private GoldenCustomBalanceRecordRepository customBalanceRecordRepository;
|
|
|
+ @Autowired
|
|
|
private SysConfigService sysConfigService;
|
|
|
|
|
|
@Override
|
|
|
@@ -64,9 +63,11 @@ public class GoldenRewardQuestionServiceImpl implements GoldenRewardQuestionServ
|
|
|
Integer count = goldenQuestionCustomMapper.getCountQuestionByDate(customId,startDate,endDate);
|
|
|
if (count == null || count <= 0) {
|
|
|
GoldenRewardQuestionTable table = mapper.getRandQuestion();
|
|
|
- dto.setQuestionId(table.getId());
|
|
|
- dto.setQuestion(table.getQuestion());
|
|
|
- dto.setType(1);
|
|
|
+ if (table != null) {
|
|
|
+ dto.setQuestionId(table.getId());
|
|
|
+ dto.setQuestion(table.getQuestion());
|
|
|
+ dto.setType(1);
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@@ -91,6 +92,7 @@ public class GoldenRewardQuestionServiceImpl implements GoldenRewardQuestionServ
|
|
|
BeanUtils.copyProperties(entity, table);
|
|
|
table.setQuestion(questionTable.getQuestion());
|
|
|
table.setAnswer(questionTable.getAnswer());
|
|
|
+ table.setCustomRight(questionTable.getAnswer() == table.getCustomAnswer() ? 1 : 0 );
|
|
|
goldenQuestionCustomRepository.save(table);
|
|
|
}
|
|
|
|
|
|
@@ -184,6 +186,15 @@ public class GoldenRewardQuestionServiceImpl implements GoldenRewardQuestionServ
|
|
|
BigDecimal balance = custom.getBalance() == null ? BigDecimal.ZERO : custom.getBalance();
|
|
|
custom.setBalance(balance.add(giveAmount));
|
|
|
customInfoRepository.save(custom);
|
|
|
+
|
|
|
+ GoldenCustomBalanceRecordTable record = new GoldenCustomBalanceRecordTable();
|
|
|
+ record.setCustomId(custom.getId());
|
|
|
+ record.setCId(custom.getCId());
|
|
|
+ record.setAmount(giveAmount);
|
|
|
+ record.setType(2);
|
|
|
+ record.setAddTime(new Date());
|
|
|
+ customBalanceRecordRepository.save(record);
|
|
|
+
|
|
|
}else{
|
|
|
table.setStatus(3);
|
|
|
}
|
|
|
@@ -195,27 +206,27 @@ public class GoldenRewardQuestionServiceImpl implements GoldenRewardQuestionServ
|
|
|
|
|
|
}
|
|
|
|
|
|
- public static void main(String[] args) throws Exception {
|
|
|
- System.out.println(DateUtil.formatDate(DateUtil.addDate(new Date(),-180)));
|
|
|
- }
|
|
|
-
|
|
|
@JmsListener(destination = ConfigConstants.CUSTOM_REWARD_RECORD)
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
public void addCustomRewardRecord(String content) throws ServiceException {
|
|
|
- log.info(String.format("CUSTOM_REWARD_RECORD,content:%s", content));
|
|
|
+ log.info(String.format("CUSTOM_REWARD_RECORD,content-customId:%s", content));
|
|
|
|
|
|
if (Strings.isNullOrEmpty(content)) {
|
|
|
log.error("CUSTOM_REWARD_RECORD,content is null");
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
- GoldenCustomRewardRecordTable table = new GoldenCustomRewardRecordTable();
|
|
|
- table.setCustomId(Long.valueOf(content));
|
|
|
- table.setStartDate(new Date());
|
|
|
- table.setStatus(1);
|
|
|
- table.setGrantStatus(1);
|
|
|
- table.setAddTime(new Date());
|
|
|
- goldenCustomRewardRecordRepository.save(table);
|
|
|
+ GoldenCustomRewardRecordTable recodeTable = goldenCustomRewardRecordRepository.findFirstByCustomId(Long.valueOf(content));
|
|
|
+ if(recodeTable == null){
|
|
|
+ GoldenCustomRewardRecordTable table = new GoldenCustomRewardRecordTable();
|
|
|
+ table.setCustomId(Long.valueOf(content));
|
|
|
+ table.setStartDate(new Date());
|
|
|
+ table.setStatus(1);
|
|
|
+ table.setGrantStatus(1);
|
|
|
+ table.setAddTime(new Date());
|
|
|
+ goldenCustomRewardRecordRepository.save(table);
|
|
|
+ }
|
|
|
+
|
|
|
}
|
|
|
|
|
|
}
|