Merge branch 'refs/heads/dev/dev' into dev/dev_xp
This commit is contained in:
@@ -51,7 +51,7 @@ public class AuthenticationFilter extends OncePerRequestFilter {
|
|||||||
"/api/python/flush","/api/account/healthy","/api/ali-pay/trade/notify","/api/paypal/ipn/back","/api/alipay-hk/trade/notify",
|
"/api/python/flush","/api/account/healthy","/api/ali-pay/trade/notify","/api/paypal/ipn/back","/api/alipay-hk/trade/notify",
|
||||||
"/api/portfolio/page", "/api/portfolio/detail", "/api/portfolio/commentPage", "/api/portfolio/viewsIncrease",
|
"/api/portfolio/page", "/api/portfolio/detail", "/api/portfolio/commentPage", "/api/portfolio/viewsIncrease",
|
||||||
"/api/account/designWorksRegister","/api/account/questionnaire","/api/stripe/trade/notify",
|
"/api/account/designWorksRegister","/api/account/questionnaire","/api/stripe/trade/notify",
|
||||||
"/notification","/api/account/activateNewEmail"
|
"/notification","/api/account/activateNewEmail","/api/third/party/auth/google_callback"
|
||||||
);
|
);
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ public class AccountTask {
|
|||||||
/**
|
/**
|
||||||
* 每周日晚上刷新 年付用户、月付用户的积分
|
* 每周日晚上刷新 年付用户、月付用户的积分
|
||||||
*/
|
*/
|
||||||
@Scheduled(cron = "59 59 23 ? * SUN")
|
// @Scheduled(cron = "59 59 23 ? * SUN")
|
||||||
// @Scheduled(cron = "59 59 23 * * ?")
|
// @Scheduled(cron = "59 59 23 * * ?")
|
||||||
public void refreshCreditsMonthly() {
|
public void refreshCreditsMonthly() {
|
||||||
log.info("每周日晚11:59:59刷新付费用户积分为 6000");
|
log.info("每周日晚11:59:59刷新付费用户积分为 6000");
|
||||||
@@ -33,7 +33,7 @@ public class AccountTask {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 每天凌晨0点执行一次
|
// 每天凌晨0点执行一次
|
||||||
@Scheduled(cron = "0 0 0 * * ?")
|
// @Scheduled(cron = "0 0 0 * * ?")
|
||||||
public void cancelActivityBenefits() {
|
public void cancelActivityBenefits() {
|
||||||
// 1、查询当前所有参与了活动且过期的用户
|
// 1、查询当前所有参与了活动且过期的用户
|
||||||
List<Account> accountList = accountService.getExpiredUserBySystemUser(4);
|
List<Account> accountList = accountService.getExpiredUserBySystemUser(4);
|
||||||
@@ -46,7 +46,7 @@ public class AccountTask {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 每天检测正式用户到期情况,每天凌晨0点执行
|
// 每天检测正式用户到期情况,每天凌晨0点执行
|
||||||
@Scheduled(cron = "0 0 0 * * ?")
|
// @Scheduled(cron = "0 0 0 * * ?")
|
||||||
public void paidUserToVisitor() {
|
public void paidUserToVisitor() {
|
||||||
// 1、查询当前已过期正式用户或试用用户
|
// 1、查询当前已过期正式用户或试用用户
|
||||||
List<Account> accountList = accountService.getExpiredUserBySystemUser(1);
|
List<Account> accountList = accountService.getExpiredUserBySystemUser(1);
|
||||||
|
|||||||
@@ -1,7 +1,10 @@
|
|||||||
package com.ai.da.common.websocket;
|
package com.ai.da.common.websocket;
|
||||||
|
|
||||||
|
import com.alibaba.fastjson.JSONObject;
|
||||||
|
import com.alibaba.fastjson2.JSON;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
import org.springframework.web.bind.annotation.RequestParam;
|
||||||
|
|
||||||
import javax.websocket.*;
|
import javax.websocket.*;
|
||||||
import javax.websocket.server.PathParam;
|
import javax.websocket.server.PathParam;
|
||||||
@@ -16,54 +19,55 @@ import java.util.concurrent.ConcurrentHashMap;
|
|||||||
@Slf4j
|
@Slf4j
|
||||||
public class NotificationConnection {
|
public class NotificationConnection {
|
||||||
|
|
||||||
static Map<String,Session> sessionMap = new ConcurrentHashMap<>();
|
//连接超时
|
||||||
|
public static final long MAX_TIME_OUT = 3 * 60 * 1000;
|
||||||
|
|
||||||
private Session session;
|
private Session session;
|
||||||
|
private Long userId;
|
||||||
// 这里用ConcurrentHashMap 因为他是一个线程安全的Map
|
// 这里用ConcurrentHashMap 因为他是一个线程安全的Map
|
||||||
private static ConcurrentHashMap<Long, NotificationConnection> websockets = new ConcurrentHashMap<>();
|
private static ConcurrentHashMap<Long, NotificationConnection> websockets = new ConcurrentHashMap<>();
|
||||||
//连接建立时执行的操作
|
|
||||||
/*@OnOpen
|
|
||||||
public void onOpen(Session session){
|
|
||||||
sessionMap.put(session.getId(),session);
|
|
||||||
log.info("websocket is open, sessionId: {}",session.getId());
|
|
||||||
}*/
|
|
||||||
|
|
||||||
@OnOpen
|
@OnOpen
|
||||||
public void onOpen(Session session, @PathParam("id") String id) { // 接收到前端传来的用户ID
|
public void onOpen(Session session, @PathParam("id") String id) { // 接收到前端传来的用户ID
|
||||||
this.session = session;
|
this.session = session;
|
||||||
|
this.userId = Long.valueOf(id);
|
||||||
|
this.session.setMaxIdleTimeout(MAX_TIME_OUT);
|
||||||
websockets.put(Long.parseLong(id), this); //将ID作为key,当前的对象作为Value
|
websockets.put(Long.parseLong(id), this); //将ID作为key,当前的对象作为Value
|
||||||
log.info("【建立连接】 用户为:{}", this.session);
|
log.info("【建立连接】 用户为:{}", this.session);
|
||||||
log.info("【建立连接】 用户Id为:{}", id);
|
log.info("【建立连接】 用户Id为:{}", id);
|
||||||
log.info("【建立连接】 总数为:{}", websockets.size());
|
log.info("【当前连接总数】 为:{}", websockets.size());
|
||||||
}
|
}
|
||||||
|
|
||||||
@OnClose
|
@OnClose
|
||||||
public void onClose() {
|
public void onClose(CloseReason reason) {
|
||||||
websockets.remove(this); // 将当前的对象从集合中删除
|
log.info("【连接断开】 用户为:{}, sessionId: {}, 原因为{}", this.userId, this.session.getId(), reason);
|
||||||
log.info("【连接断开】 用户为:{}", this.session);
|
log.info("【当前连接总数】 为:{}", websockets.size());
|
||||||
// log.info("【连接断开】 总数为:{}", websockets.size());
|
websockets.remove(this.userId); // 将当前的对象从集合中删除
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 错误时调用
|
||||||
|
* @param throwable 异常
|
||||||
|
*/
|
||||||
|
@OnError
|
||||||
|
public void onError(Throwable throwable) {
|
||||||
|
log.info("【连接异常】 用户为:{} , sessionId: {}", this.userId, this.session.getId(), throwable);
|
||||||
|
websockets.remove(this.userId); // 将当前的对象从集合中删除
|
||||||
|
log.info("【当前连接总数】 为:{}", websockets.size());
|
||||||
}
|
}
|
||||||
|
|
||||||
//收到了客户端消息执行的操作
|
//收到了客户端消息执行的操作
|
||||||
@OnMessage
|
@OnMessage
|
||||||
public void onMessage(String text){
|
public void onMessage(@RequestParam String text){
|
||||||
log.info("收到了一条消息:"+text);
|
Map<String, String> textMap = JSONObject.parseObject(text, Map.class);
|
||||||
|
log.info("收到了一条来自 {} 的消息:{}, sessionId:{}", this.userId, textMap.get("text"), this.session.getId());
|
||||||
// return "已收到你的消息";
|
// return "已收到你的消息";
|
||||||
}
|
if (textMap.get("text").equals("PING")){
|
||||||
/*//连接关闭的时候执行的操作
|
sendMsg(JSON.toJSONString("PONG"), this.userId);
|
||||||
@OnClose
|
|
||||||
public void onClose(Session session){
|
|
||||||
sessionMap.remove(session.getId());
|
|
||||||
log.info("websocket is close, sessionId: {}",session.getId());
|
|
||||||
}
|
|
||||||
|
|
||||||
public void sendMsg(String message) throws IOException {
|
|
||||||
for(String key:sessionMap.keySet()){
|
|
||||||
sessionMap.get(key).getBasicRemote().sendText(message);
|
|
||||||
}
|
}
|
||||||
}*/
|
}
|
||||||
|
|
||||||
public void sendMsg(String message, Long userId) throws IOException {
|
public void sendMsg(String message, Long userId) {
|
||||||
if (userId == null) { // 如果等于null则证明是群发
|
if (userId == null) { // 如果等于null则证明是群发
|
||||||
// 获取当前Map的一个迭代器,遍历Map的方式有很多种,看着来
|
// 获取当前Map的一个迭代器,遍历Map的方式有很多种,看着来
|
||||||
// 这个就是遍历这个集合的过程....
|
// 这个就是遍历这个集合的过程....
|
||||||
@@ -73,7 +77,11 @@ public class NotificationConnection {
|
|||||||
NotificationConnection webSocket = entry.getValue();
|
NotificationConnection webSocket = entry.getValue();
|
||||||
// 接下来就是遍历群发
|
// 接下来就是遍历群发
|
||||||
log.info("广播消息 【给用户】 :{}发送消息【{}】", webSocket, message);
|
log.info("广播消息 【给用户】 :{}发送消息【{}】", webSocket, message);
|
||||||
webSocket.session.getBasicRemote().sendText(message); // 发送!!!!!!!!!
|
try {
|
||||||
|
webSocket.session.getBasicRemote().sendText(message); // 发送!!!!!!!!!
|
||||||
|
} catch (IOException e) {
|
||||||
|
log.error("Failed to send message to session {}: {}", webSocket.session.getId(), e.getMessage());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} else { // 如果不是群发,则判断ID,其余步骤一致
|
} else { // 如果不是群发,则判断ID,其余步骤一致
|
||||||
// 获取当前Map的一个迭代器,遍历Map的方式有很多种,看着来
|
// 获取当前Map的一个迭代器,遍历Map的方式有很多种,看着来
|
||||||
|
|||||||
@@ -6,8 +6,6 @@ import org.springframework.web.socket.server.standard.ServerEndpointExporter;
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Configuration of WebSocket
|
* Configuration of WebSocket
|
||||||
*
|
|
||||||
* @author db1995
|
|
||||||
*/
|
*/
|
||||||
@Configuration
|
@Configuration
|
||||||
public class WebSocketConfig {
|
public class WebSocketConfig {
|
||||||
|
|||||||
@@ -122,14 +122,16 @@ public class ConvenientInquiryController {
|
|||||||
|
|
||||||
@ApiOperation("试用用户到正式用户的转化率")
|
@ApiOperation("试用用户到正式用户的转化率")
|
||||||
@GetMapping("/conversionRate")
|
@GetMapping("/conversionRate")
|
||||||
public Response<Map<String, Float>> conversionRate() {
|
public Response<Map<String, Object>> conversionRate(@ApiParam(value = "startTime") @RequestParam(required = false) @Nullable String startTime,
|
||||||
return Response.success(convenientInquiryService.conversionRate());
|
@ApiParam(value = "endTime") @RequestParam(required = false) @Nullable String endTime) {
|
||||||
|
return Response.success(convenientInquiryService.conversionRate(startTime, endTime));
|
||||||
}
|
}
|
||||||
|
|
||||||
@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("添加用户")
|
||||||
|
|||||||
@@ -14,6 +14,7 @@ import org.springframework.web.bind.annotation.*;
|
|||||||
|
|
||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
import javax.servlet.http.HttpServletRequest;
|
import javax.servlet.http.HttpServletRequest;
|
||||||
|
import javax.servlet.http.HttpSession;
|
||||||
import javax.validation.Valid;
|
import javax.validation.Valid;
|
||||||
import java.security.cert.X509Certificate;
|
import java.security.cert.X509Certificate;
|
||||||
|
|
||||||
@@ -114,4 +115,10 @@ public class ThirdPartyController {
|
|||||||
public Response<String> updateNoLoginRequiredNew(@RequestBody NoLoginRequiredDTO noLoginRequiredDTO, HttpServletRequest request) {
|
public Response<String> updateNoLoginRequiredNew(@RequestBody NoLoginRequiredDTO noLoginRequiredDTO, HttpServletRequest request) {
|
||||||
return Response.success(accountService.updateNoLoginRequiredNew(noLoginRequiredDTO, request));
|
return Response.success(accountService.updateNoLoginRequiredNew(noLoginRequiredDTO, request));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@CrossOrigin
|
||||||
|
@GetMapping("/auth/google_callback")
|
||||||
|
public Response<String> googleCallback(@RequestParam("code") String code, HttpSession session) {
|
||||||
|
return Response.success(accountService.googleCallback(code, session));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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,4 @@ public interface TrialOrderMapper extends CommonMapper<TrialOrder> {
|
|||||||
|
|
||||||
Map<String, Long> countOfficialUser();
|
Map<String, Long> countOfficialUser();
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,30 @@
|
|||||||
|
package com.ai.da.mapper.primary.entity;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.annotation.IdType;
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableId;
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableName;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.EqualsAndHashCode;
|
||||||
|
import lombok.experimental.Accessors;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
@EqualsAndHashCode(callSuper = false)
|
||||||
|
@Accessors(chain = true)
|
||||||
|
@TableName("account_extend")
|
||||||
|
public class AccountExtend implements Serializable {
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* ID
|
||||||
|
*/
|
||||||
|
@TableId(value = "id", type = IdType.AUTO)
|
||||||
|
private Long id;
|
||||||
|
|
||||||
|
private Long accountId;
|
||||||
|
|
||||||
|
private String authType;
|
||||||
|
|
||||||
|
private String auth;
|
||||||
|
}
|
||||||
@@ -0,0 +1,17 @@
|
|||||||
|
package com.ai.da.mapper.primary.entity;
|
||||||
|
|
||||||
|
import com.ai.da.common.config.mybatis.plus.CommonMapper;
|
||||||
|
|
||||||
|
import java.util.Date;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Mapper 接口
|
||||||
|
*
|
||||||
|
* @author easy-generator
|
||||||
|
* @since 2022-06-13
|
||||||
|
*/
|
||||||
|
public interface AccountExtendMapper extends CommonMapper<AccountExtend> {
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,10 @@
|
|||||||
|
package com.ai.da.mapper.primary.entity;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public class GoogleUser {
|
||||||
|
private String id;
|
||||||
|
private String email;
|
||||||
|
private String name;
|
||||||
|
}
|
||||||
@@ -15,6 +15,8 @@ public class UserDesignStatisticDTO {
|
|||||||
|
|
||||||
private String isTrial;
|
private String isTrial;
|
||||||
|
|
||||||
|
private String credits;
|
||||||
|
|
||||||
private String trialOrderId;
|
private String trialOrderId;
|
||||||
|
|
||||||
private String title;
|
private String title;
|
||||||
|
|||||||
10
src/main/java/com/ai/da/model/vo/GoogleTokenResponse.java
Normal file
10
src/main/java/com/ai/da/model/vo/GoogleTokenResponse.java
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
package com.ai.da.model.vo;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public class GoogleTokenResponse {
|
||||||
|
private String accessToken;
|
||||||
|
private String idToken;
|
||||||
|
|
||||||
|
}
|
||||||
@@ -11,6 +11,7 @@ import com.baomidou.mybatisplus.extension.service.IService;
|
|||||||
import org.springframework.web.multipart.MultipartFile;
|
import org.springframework.web.multipart.MultipartFile;
|
||||||
|
|
||||||
import javax.servlet.http.HttpServletRequest;
|
import javax.servlet.http.HttpServletRequest;
|
||||||
|
import javax.servlet.http.HttpSession;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
@@ -181,4 +182,8 @@ public interface AccountService extends IService<Account> {
|
|||||||
String updateNoLoginRequiredNew(NoLoginRequiredDTO noLoginRequiredDTO, HttpServletRequest request);
|
String updateNoLoginRequiredNew(NoLoginRequiredDTO noLoginRequiredDTO, HttpServletRequest request);
|
||||||
|
|
||||||
void halfPricePromotion();
|
void halfPricePromotion();
|
||||||
|
|
||||||
|
String googleCallback(String code, HttpSession session);
|
||||||
|
|
||||||
|
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, 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);
|
Boolean addUser(AccountAddDTO accountAddDTO);
|
||||||
|
|
||||||
|
|||||||
@@ -34,10 +34,12 @@ import org.springframework.beans.factory.annotation.Value;
|
|||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
import org.springframework.util.Assert;
|
import org.springframework.util.Assert;
|
||||||
|
import org.springframework.web.client.RestTemplate;
|
||||||
import org.springframework.web.multipart.MultipartFile;
|
import org.springframework.web.multipart.MultipartFile;
|
||||||
|
|
||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
import javax.servlet.http.HttpServletRequest;
|
import javax.servlet.http.HttpServletRequest;
|
||||||
|
import javax.servlet.http.HttpSession;
|
||||||
import javax.sql.DataSource;
|
import javax.sql.DataSource;
|
||||||
import java.math.BigDecimal;
|
import java.math.BigDecimal;
|
||||||
import java.sql.Connection;
|
import java.sql.Connection;
|
||||||
@@ -62,6 +64,9 @@ public class AccountServiceImpl extends ServiceImpl<AccountMapper, Account> impl
|
|||||||
@Resource
|
@Resource
|
||||||
private AccountMapper accountMapper;
|
private AccountMapper accountMapper;
|
||||||
|
|
||||||
|
@Resource
|
||||||
|
private AccountExtendMapper accountExtendMapper;
|
||||||
|
|
||||||
@Resource
|
@Resource
|
||||||
private JWTTokenHelper jwtTokenHelper;
|
private JWTTokenHelper jwtTokenHelper;
|
||||||
|
|
||||||
@@ -571,6 +576,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 +589,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 +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
|
@Override
|
||||||
@Transactional(rollbackFor = Exception.class)
|
@Transactional(rollbackFor = Exception.class)
|
||||||
@@ -1822,4 +1854,82 @@ public class AccountServiceImpl extends ServiceImpl<AccountMapper, Account> impl
|
|||||||
log.info("邮箱绑定更改完成,用户id:{},新邮箱:{}", accountId, newMailbox);
|
log.info("邮箱绑定更改完成,用户id:{},新邮箱:{}", accountId, newMailbox);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String googleCallback(String code, HttpSession session) {
|
||||||
|
try {
|
||||||
|
log.info("code:" + code);
|
||||||
|
// 使用 code 获取 Google 用户信息
|
||||||
|
GoogleUser googleUser = getGoogleUserFromCode(code);
|
||||||
|
log.info("googleUser:" + JSON.toJSONString(googleUser));
|
||||||
|
|
||||||
|
// 检查数据库中是否已有该用户
|
||||||
|
// QueryWrapper<AccountExtend> qw = new QueryWrapper<>();
|
||||||
|
// qw.lambda().eq(AccountExtend::getAuth, googleUser.getId());
|
||||||
|
// List<AccountExtend> accountExtends = accountExtendMapper.selectList(qw);
|
||||||
|
// Account existingUser = findUserByGoogleId(googleUser.getId());
|
||||||
|
return "Login successful";
|
||||||
|
// if (CollectionUtil.isNotEmpty(accountExtends)) {
|
||||||
|
// // 用户已存在,直接登录
|
||||||
|
//// session.setAttribute("user", existingUser);
|
||||||
|
// return "Login successful";
|
||||||
|
// } else {
|
||||||
|
// // 用户不存在,创建新用户(自动注册)
|
||||||
|
//// User newUser = googleAuthService.registerNewUser(googleUser);
|
||||||
|
//// session.setAttribute("user", newUser);
|
||||||
|
// return "Registration and login successful";
|
||||||
|
// }
|
||||||
|
} catch (Exception e) {
|
||||||
|
return "Error processing Google login: " + e.getMessage();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static final String TOKEN_URL = "https://oauth2.googleapis.com/token";
|
||||||
|
private static final String USER_INFO_URL = "https://www.googleapis.com/oauth2/v3/userinfo";
|
||||||
|
private static final String CLIENT_ID = "194770296147-njd68pm7tnapgonkj2h48mhf63n15n3f.apps.googleusercontent.com";
|
||||||
|
private static final String CLIENT_SECRET = "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";
|
||||||
|
private static final String REDIRECT_URI = "https://develop.api.aida.com.hk/api/third/party/auth/google_callback";
|
||||||
|
|
||||||
|
public GoogleUser getGoogleUserFromCode(String code) {
|
||||||
|
// Step 1: Exchange code for access_token
|
||||||
|
String accessToken = getAccessToken(code);
|
||||||
|
log.info("accessToken" + accessToken);
|
||||||
|
|
||||||
|
// Step 2: Use access_token to get Google User info
|
||||||
|
return getGoogleUserInfo(accessToken);
|
||||||
|
}
|
||||||
|
|
||||||
|
private String getAccessToken(String code) {
|
||||||
|
RestTemplate restTemplate = new RestTemplate();
|
||||||
|
Map<String, String> params = new HashMap<>();
|
||||||
|
params.put("client_id", CLIENT_ID);
|
||||||
|
params.put("client_secret", CLIENT_SECRET);
|
||||||
|
params.put("redirect_uri", REDIRECT_URI);
|
||||||
|
params.put("grant_type", "authorization_code");
|
||||||
|
params.put("code", code);
|
||||||
|
|
||||||
|
// 使用 RestTemplate 发起请求以获取 access_token
|
||||||
|
GoogleTokenResponse response = restTemplate.postForObject(TOKEN_URL, params, GoogleTokenResponse.class);
|
||||||
|
return response.getAccessToken();
|
||||||
|
}
|
||||||
|
|
||||||
|
private GoogleUser getGoogleUserInfo(String accessToken) {
|
||||||
|
RestTemplate restTemplate = new RestTemplate();
|
||||||
|
String url = USER_INFO_URL + "?access_token=" + accessToken;
|
||||||
|
return restTemplate.getForObject(url, GoogleUser.class);
|
||||||
|
}
|
||||||
|
|
||||||
|
// public User findUserByGoogleId(String googleId) {
|
||||||
|
// // 从数据库中根据 Google ID 查找用户
|
||||||
|
// return userRepository.findByGoogleId(googleId);
|
||||||
|
// }
|
||||||
|
|
||||||
|
// public User registerNewUser(GoogleUser googleUser) {
|
||||||
|
// // 创建并保存新用户
|
||||||
|
// User newUser = new User();
|
||||||
|
// newUser.setGoogleId(googleUser.getId());
|
||||||
|
// newUser.setEmail(googleUser.getEmail());
|
||||||
|
// newUser.setUsername(googleUser.getName());
|
||||||
|
// return userRepository.save(newUser);
|
||||||
|
// }
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -392,9 +392,15 @@ public class ConvenientInquiryServiceImpl extends ServiceImpl<QuestionnaireMappe
|
|||||||
private TrialOrderMapper trialOrderMapper;
|
private TrialOrderMapper trialOrderMapper;
|
||||||
|
|
||||||
// 试用用户到正式用户的转化率
|
// 试用用户到正式用户的转化率
|
||||||
public Map<String, Float> conversionRate() {
|
public Map<String, Object> conversionRate(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("count(distinct email) as count");
|
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");
|
Long totalTrials = (Long) trialMaps.get(0).get("count");
|
||||||
|
|
||||||
// 获取从试用用户转为正式用户的用户数量
|
// 获取从试用用户转为正式用户的用户数量
|
||||||
Map<String, Long> officialMaps = trialOrderMapper.countOfficialUser();
|
List<String> paidCustomerEmail = accountService.getPaidCustomerEmail();
|
||||||
Long trialToOfficial = officialMaps.get("count");
|
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("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);
|
||||||
|
|||||||
@@ -204,11 +204,7 @@ public class MessageCenterServiceImpl extends ServiceImpl<NotificationMapper, No
|
|||||||
String jsonString = JSON.toJSONString(resp);
|
String jsonString = JSON.toJSONString(resp);
|
||||||
// log.info("消息推送 : {}", jsonString);
|
// log.info("消息推送 : {}", jsonString);
|
||||||
|
|
||||||
try {
|
notificationConnection.sendMsg(jsonString, receiverId);
|
||||||
notificationConnection.sendMsg(jsonString, receiverId);
|
|
||||||
} catch (IOException e) {
|
|
||||||
throw new RuntimeException(e);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// 取消点赞、删除评论、取消关注
|
// 取消点赞、删除评论、取消关注
|
||||||
|
|||||||
@@ -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>
|
||||||
|
|||||||
Reference in New Issue
Block a user