管理员系统优化
This commit is contained in:
@@ -122,14 +122,15 @@ public class ConvenientInquiryController {
|
||||
|
||||
@ApiOperation("试用用户到正式用户的转化率")
|
||||
@GetMapping("/conversionRate")
|
||||
public Response<Map<String, Float>> conversionRate() {
|
||||
public Response<Map<String, Object>> conversionRate() {
|
||||
return Response.success(convenientInquiryService.conversionRate());
|
||||
}
|
||||
|
||||
@ApiOperation("试用用户国家/城市分布")
|
||||
@GetMapping("/trialUserCountry")
|
||||
public Response<Map<String, List<Object>>> trialUserCountry() {
|
||||
return Response.success(convenientInquiryService.trialUserCountry());
|
||||
public Response<Map<String, List<Object>>> trialUserCountry(@ApiParam(value = "startTime") @RequestParam(required = false) @Nullable String startTime,
|
||||
@ApiParam(value = "endTime") @RequestParam(required = false) @Nullable String endTime) {
|
||||
return Response.success(convenientInquiryService.trialUserCountry(startTime, endTime));
|
||||
}
|
||||
|
||||
@ApiOperation("添加用户")
|
||||
|
||||
@@ -3,6 +3,7 @@ package com.ai.da.mapper.primary;
|
||||
import com.ai.da.common.config.mybatis.plus.CommonMapper;
|
||||
import com.ai.da.mapper.primary.entity.TrialOrder;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
@@ -15,6 +16,7 @@ public interface TrialOrderMapper extends CommonMapper<TrialOrder> {
|
||||
|
||||
Map<String, Long> countOfficialUser();
|
||||
|
||||
List<TrialOrder> selectIdsByEmails(List<String> emails);
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -181,4 +181,6 @@ public interface AccountService extends IService<Account> {
|
||||
String updateNoLoginRequiredNew(NoLoginRequiredDTO noLoginRequiredDTO, HttpServletRequest request);
|
||||
|
||||
void halfPricePromotion();
|
||||
|
||||
List<String> getPaidCustomerEmail();
|
||||
}
|
||||
|
||||
@@ -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();
|
||||
|
||||
Map<String, List<Object>> trialUserCountry();
|
||||
Map<String, List<Object>> trialUserCountry(String startTime, String endTime);
|
||||
|
||||
Boolean addUser(AccountAddDTO accountAddDTO);
|
||||
|
||||
|
||||
@@ -571,6 +571,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 {
|
||||
@@ -583,6 +584,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()));
|
||||
@@ -1464,6 +1466,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)
|
||||
|
||||
@@ -392,7 +392,7 @@ public class ConvenientInquiryServiceImpl extends ServiceImpl<QuestionnaireMappe
|
||||
private TrialOrderMapper trialOrderMapper;
|
||||
|
||||
// 试用用户到正式用户的转化率
|
||||
public Map<String, Float> conversionRate() {
|
||||
public Map<String, Object> conversionRate() {
|
||||
|
||||
QueryWrapper<TrialOrder> queryWrapper = new QueryWrapper<>();
|
||||
// 获取试用用户总数
|
||||
@@ -402,22 +402,32 @@ 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();
|
||||
List<TrialOrder> paidTrialUsers = trialOrderMapper.selectIdsByEmails(paidCustomerEmail);
|
||||
|
||||
// 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);
|
||||
|
||||
Reference in New Issue
Block a user