管理员系统优化

This commit is contained in:
2024-11-06 17:27:16 +08:00
parent 59b02b3f28
commit 903bafb245
8 changed files with 65 additions and 14 deletions

View File

@@ -122,14 +122,15 @@ public class ConvenientInquiryController {
@ApiOperation("试用用户到正式用户的转化率") @ApiOperation("试用用户到正式用户的转化率")
@GetMapping("/conversionRate") @GetMapping("/conversionRate")
public Response<Map<String, Float>> conversionRate() { public Response<Map<String, Object>> conversionRate() {
return Response.success(convenientInquiryService.conversionRate()); return Response.success(convenientInquiryService.conversionRate());
} }
@ApiOperation("试用用户国家/城市分布") @ApiOperation("试用用户国家/城市分布")
@GetMapping("/trialUserCountry") @GetMapping("/trialUserCountry")
public Response<Map<String, List<Object>>> trialUserCountry() { public Response<Map<String, List<Object>>> trialUserCountry(@ApiParam(value = "startTime") @RequestParam(required = false) @Nullable String startTime,
return Response.success(convenientInquiryService.trialUserCountry()); @ApiParam(value = "endTime") @RequestParam(required = false) @Nullable String endTime) {
return Response.success(convenientInquiryService.trialUserCountry(startTime, endTime));
} }
@ApiOperation("添加用户") @ApiOperation("添加用户")

View File

@@ -3,6 +3,7 @@ package com.ai.da.mapper.primary;
import com.ai.da.common.config.mybatis.plus.CommonMapper; import com.ai.da.common.config.mybatis.plus.CommonMapper;
import com.ai.da.mapper.primary.entity.TrialOrder; import com.ai.da.mapper.primary.entity.TrialOrder;
import java.util.List;
import java.util.Map; import java.util.Map;
/** /**
@@ -15,6 +16,7 @@ public interface TrialOrderMapper extends CommonMapper<TrialOrder> {
Map<String, Long> countOfficialUser(); Map<String, Long> countOfficialUser();
List<TrialOrder> selectIdsByEmails(List<String> emails);
} }

View File

@@ -181,4 +181,6 @@ public interface AccountService extends IService<Account> {
String updateNoLoginRequiredNew(NoLoginRequiredDTO noLoginRequiredDTO, HttpServletRequest request); String updateNoLoginRequiredNew(NoLoginRequiredDTO noLoginRequiredDTO, HttpServletRequest request);
void halfPricePromotion(); void halfPricePromotion();
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, 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); Boolean addUser(AccountAddDTO accountAddDTO);

View File

@@ -571,6 +571,7 @@ public class AccountServiceImpl extends ServiceImpl<AccountMapper, Account> impl
account.setIsBeginner(1); account.setIsBeginner(1);
account.setSystemUser(3); account.setSystemUser(3);
account.setValidStartTime(System.currentTimeMillis()); account.setValidStartTime(System.currentTimeMillis());
account.setCountry(accountTrialDTO.getCountry());
if (link) { if (link) {
account.setValidEndTime(toDayEnd(Instant.now().plus(5, ChronoUnit.DAYS).toEpochMilli())); account.setValidEndTime(toDayEnd(Instant.now().plus(5, ChronoUnit.DAYS).toEpochMilli()));
} else { } else {
@@ -583,6 +584,7 @@ public class AccountServiceImpl extends ServiceImpl<AccountMapper, Account> impl
account.setUserPassword("Third-000000"); account.setUserPassword("Third-000000");
account.setUserEmail(trialOrder.getEmail()); account.setUserEmail(trialOrder.getEmail());
account.setLanguage(Language.ENGLISH.name()); account.setLanguage(Language.ENGLISH.name());
account.setCountry(accountTrialDTO.getCountry());
account.setValidStartTime(System.currentTimeMillis()); account.setValidStartTime(System.currentTimeMillis());
if (link) { if (link) {
account.setValidEndTime(toDayEnd(Instant.now().plus(5, ChronoUnit.DAYS).toEpochMilli())); 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 @Override
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)

View File

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

View File

@@ -29,7 +29,7 @@
<select id="getDesignStatistic" resultType="com.ai.da.model.dto.UserDesignStatisticDTO" parameterType="String"> <select id="getDesignStatistic" resultType="com.ai.da.model.dto.UserDesignStatisticDTO" parameterType="String">
select d.*,c.id trialOrderId, c.title,c.surname,c.given_name,c.country,c.occupation,c.create_time select d.*,c.id trialOrderId, c.title,c.surname,c.given_name,c.country,c.occupation,c.create_time
from ( from (
select b.account_id,count(b.account_id) design_times,a.user_name,a.user_email,a.is_trial select b.account_id,count(b.account_id) design_times,a.user_name,a.user_email,a.is_trial,a.credits
from t_account a from t_account a
left join t_design b on a.id = b.account_id left join t_design b on a.id = b.account_id
<where> <where>

View File

@@ -24,4 +24,13 @@
ON a.user_email = b.email ON a.user_email = b.email
</select> </select>
<select id="selectIdsByEmails" parameterType="java.util.List" resultType="com.ai.da.mapper.primary.entity.TrialOrder">
SELECT *
FROM trial_order
WHERE email IN
<foreach item="email" collection="list" open="(" separator="," close=")">
#{email}
</foreach>
</select>
</mapper> </mapper>