Merge remote-tracking branch 'origin/dev/dev' into dev/dev

# Conflicts:
#	src/main/java/com/ai/da/service/AccountService.java
This commit is contained in:
shahaibo
2024-11-11 16:06:21 +08:00
13 changed files with 129 additions and 43 deletions

View File

@@ -184,4 +184,6 @@ public interface AccountService extends IService<Account> {
void halfPricePromotion();
String googleCallback(String code, HttpSession session);
List<String> getPaidCustomerEmail();
}

View File

@@ -32,9 +32,9 @@ public interface ConvenientInquiryService extends IService<Questionnaire> {
Map<String, List<Object>> getActiveUserFunc(String startTime, String endTime, List<Long> ids);
Map<String, Float> conversionRate();
Map<String, Object> conversionRate(String startTime, String endTime);
Map<String, List<Object>> trialUserCountry();
Map<String, List<Object>> trialUserCountry(String startTime, String endTime);
Boolean addUser(AccountAddDTO accountAddDTO);

View File

@@ -576,6 +576,7 @@ public class AccountServiceImpl extends ServiceImpl<AccountMapper, Account> impl
account.setIsBeginner(1);
account.setSystemUser(3);
account.setValidStartTime(System.currentTimeMillis());
account.setCountry(accountTrialDTO.getCountry());
if (link) {
account.setValidEndTime(toDayEnd(Instant.now().plus(5, ChronoUnit.DAYS).toEpochMilli()));
} else {
@@ -588,6 +589,7 @@ public class AccountServiceImpl extends ServiceImpl<AccountMapper, Account> impl
account.setUserPassword("Third-000000");
account.setUserEmail(trialOrder.getEmail());
account.setLanguage(Language.ENGLISH.name());
account.setCountry(accountTrialDTO.getCountry());
account.setValidStartTime(System.currentTimeMillis());
if (link) {
account.setValidEndTime(toDayEnd(Instant.now().plus(5, ChronoUnit.DAYS).toEpochMilli()));
@@ -1469,6 +1471,31 @@ public class AccountServiceImpl extends ServiceImpl<AccountMapper, Account> impl
}
}
private static final String QUERY_PAID_CUSTOMER_EMAIL = "SELECT distinct c.email " +
"FROM `pmr_wc_order_stats` o " +
"inner join `pmr_wc_customer_lookup` c " +
"on o.customer_id = c.customer_id " +
"and o.net_total in (5000, 500, 250) " +
"and o.`status` != 'wc-failed' " +
"and c.email not in ('1779019091@qq.com', 'xupei3360@163.com', '1627315083@qq.com', 'gigiwu33@hotmail.com')";
public List<String> getPaidCustomerEmail(){
List<String> paidCustomerEmail = new ArrayList<>();
try (Connection connection = dataSource.getConnection();
PreparedStatement preparedStatement = connection.prepareStatement(QUERY_PAID_CUSTOMER_EMAIL)) {
try (ResultSet queryOrderResultSet = preparedStatement.executeQuery()) {
while (queryOrderResultSet.next()) {
paidCustomerEmail.add(queryOrderResultSet.getString("email"));
}
}
} catch (Exception e) {
// 记录异常并处理
e.printStackTrace();
// return null;
}
return paidCustomerEmail;
}
// 收集调查问卷的信息
@Override
@Transactional(rollbackFor = Exception.class)

View File

@@ -392,9 +392,15 @@ public class ConvenientInquiryServiceImpl extends ServiceImpl<QuestionnaireMappe
private TrialOrderMapper trialOrderMapper;
// 试用用户到正式用户的转化率
public Map<String, Float> conversionRate() {
public Map<String, Object> conversionRate(String startTime, String endTime) {
QueryWrapper<TrialOrder> queryWrapper = new QueryWrapper<>();
if (!StringUtils.isNullOrEmpty(startTime)){
queryWrapper.gt("create_time", startTime);
}
if (!StringUtils.isNullOrEmpty(endTime)){
queryWrapper.lt("create_time", endTime);
}
// 获取试用用户总数
queryWrapper.select("count(distinct email) as count");
@@ -402,22 +408,40 @@ public class ConvenientInquiryServiceImpl extends ServiceImpl<QuestionnaireMappe
Long totalTrials = (Long) trialMaps.get(0).get("count");
// 获取从试用用户转为正式用户的用户数量
Map<String, Long> officialMaps = trialOrderMapper.countOfficialUser();
Long trialToOfficial = officialMaps.get("count");
List<String> paidCustomerEmail = accountService.getPaidCustomerEmail();
QueryWrapper<TrialOrder> qw = new QueryWrapper<>();
if (!StringUtils.isNullOrEmpty(startTime)){
qw.gt("create_time", startTime);
}
if (!StringUtils.isNullOrEmpty(endTime)){
qw.lt("create_time", endTime);
}
qw.in("email", paidCustomerEmail);
List<TrialOrder> paidTrialUsers = trialOrderMapper.selectList(qw);
// Map<String, Long> officialMaps = trialOrderMapper.countOfficialUser();
// Long trialToOfficial = officialMaps.get("count");
// 计算转化率
HashMap<String, Float> resp = new HashMap<>();
HashMap<String, Object> resp = new HashMap<>();
resp.put("trialUserCount", totalTrials.floatValue());
resp.put("trialToOfficialCount", trialToOfficial.floatValue());
resp.put("conversionRate", new BigDecimal(trialToOfficial).divide(new BigDecimal(totalTrials), 2, RoundingMode.HALF_UP).floatValue());
resp.put("trialToOfficialCount", (float) paidTrialUsers.size());
resp.put("conversionRate", new BigDecimal(paidTrialUsers.size()).divide(new BigDecimal(totalTrials), 6, RoundingMode.HALF_UP).floatValue());
resp.put("paidTrialUser", paidTrialUsers);
return resp;
}
// 试用用户地区统计
public Map<String, List<Object>> trialUserCountry() {
public Map<String, List<Object>> trialUserCountry(String startTime, String endTime) {
QueryWrapper<TrialOrder> queryWrapper = new QueryWrapper<>();
if (!StringUtils.isNullOrEmpty(startTime)){
queryWrapper.gt("create_time", startTime);
}
if (!StringUtils.isNullOrEmpty(endTime)){
queryWrapper.lt("create_time", endTime);
}
queryWrapper.select("country, count(id) as count")
.groupBy("country");
List<Map<String, Object>> countryCount = trialOrderMapper.selectMaps(queryWrapper);

View File

@@ -112,10 +112,15 @@ public class MessageCenterServiceImpl extends ServiceImpl<NotificationMapper, No
notificationVO.setPortfolioId(null);
}else {
Portfolio byId = portfolioService.getById(notificationVO.getPortfolioId());
if (Objects.isNull(byId.getPortfolioName())){
notificationVO.setPortfolioName(null);
if (!Objects.isNull(byId)){
if (Objects.isNull(byId.getPortfolioName())){
notificationVO.setPortfolioName(null);
}else {
notificationVO.setPortfolioName(byId.getPortfolioName());
}
}else {
notificationVO.setPortfolioName(byId.getPortfolioName());
String name = UserContext.getUserHolder().getLanguage().equals("ENGLISH") ? CommonConstant.PORTFOLIO_DELETED_EN : CommonConstant.PORTFOLIO_DELETED_CN;
notificationVO.setPortfolioName(name);
}
}
// 设置单个人 系统消息是否已读
@@ -199,11 +204,7 @@ public class MessageCenterServiceImpl extends ServiceImpl<NotificationMapper, No
String jsonString = JSON.toJSONString(resp);
// log.info("消息推送 {}", jsonString);
try {
notificationConnection.sendMsg(jsonString, receiverId);
} catch (IOException e) {
throw new RuntimeException(e);
}
notificationConnection.sendMsg(jsonString, receiverId);
}
// 取消点赞、删除评论、取消关注