diff --git a/game-dao/src/main/java/awesome/group/game/dao/bean/MatrixUser.java b/game-dao/src/main/java/awesome/group/game/dao/bean/MatrixUser.java
index a0ed33d..4bddf9c 100644
--- a/game-dao/src/main/java/awesome/group/game/dao/bean/MatrixUser.java
+++ b/game-dao/src/main/java/awesome/group/game/dao/bean/MatrixUser.java
@@ -12,7 +12,11 @@ public class MatrixUser {
private Integer appId;
private String name;
private String aliPayAccount;
+ private String nickname;
+ private String avatar;
+ private Integer money;//分,已提现金额
private String pwd;
private String inviteCode;
private Integer upUid;
+ private Long income;
}
diff --git a/game-service/pom.xml b/game-service/pom.xml
index 601d700..b4787b0 100644
--- a/game-service/pom.xml
+++ b/game-service/pom.xml
@@ -95,6 +95,10 @@
redis.clients
jedis
+
+ com.alipay.sdk
+ alipay-sdk-java
+
diff --git a/game-service/src/main/java/awesome/group/game/service/SmsService.java b/game-service/src/main/java/awesome/group/game/service/SmsService.java
index f665302..d2bcf1a 100644
--- a/game-service/src/main/java/awesome/group/game/service/SmsService.java
+++ b/game-service/src/main/java/awesome/group/game/service/SmsService.java
@@ -52,7 +52,7 @@ public class SmsService {
}
public void sendCaptcha(String phone, String scene) {
- List sceneList = Arrays.asList("register");
+ List sceneList = Arrays.asList("register", "login", "reset_pwd");
if (!sceneList.contains(scene)) {
throw new PaganiException(PaganiExceptionCode.GENERAL_ERROR, "非法scene");
}
diff --git a/game-service/src/main/java/awesome/group/game/service/bo/citrus/LoginReq.java b/game-service/src/main/java/awesome/group/game/service/bo/citrus/LoginReq.java
new file mode 100644
index 0000000..f6c8754
--- /dev/null
+++ b/game-service/src/main/java/awesome/group/game/service/bo/citrus/LoginReq.java
@@ -0,0 +1,9 @@
+package awesome.group.game.service.bo.citrus;
+
+public class LoginReq {
+ public String mobile;
+ public String pwd;
+ public String appCode;
+ public String code;//验证码
+
+}
diff --git a/game-service/src/main/java/awesome/group/game/service/bo/citrus/UserBo.java b/game-service/src/main/java/awesome/group/game/service/bo/citrus/UserBo.java
new file mode 100644
index 0000000..217f059
--- /dev/null
+++ b/game-service/src/main/java/awesome/group/game/service/bo/citrus/UserBo.java
@@ -0,0 +1,32 @@
+package awesome.group.game.service.bo.citrus;
+
+import awesome.group.game.dao.bean.MatrixUser;
+
+public class UserBo {
+ public Integer id;
+ public String mobile;
+ public String name;
+ public String nickname;
+ public String avatar;
+ public Integer money;//分,已提现金额
+ public String aliPayAccount;
+ public Long income;//ecpm和,分
+ public String inviteCode;
+ public String inviteUrl;
+
+ public UserBo() {
+ }
+
+ public UserBo(MatrixUser u) {
+ this.id = u.getId();
+ this.mobile = u.getMobile();
+ this.name = u.getName();
+ this.aliPayAccount = u.getAliPayAccount();
+ this.income = u.getIncome();
+ this.inviteCode = u.getInviteCode();
+ this.inviteUrl = String.format("https://pomelo.bzgames.cn/register/%s", u.getInviteCode());
+ this.nickname = u.getNickname();
+ this.avatar = u.getAvatar();
+ this.money = u.getMoney();
+ }
+}
diff --git a/game-service/src/main/java/awesome/group/game/service/RegisterService.java b/game-service/src/main/java/awesome/group/game/service/citrus/RegisterService.java
similarity index 89%
rename from game-service/src/main/java/awesome/group/game/service/RegisterService.java
rename to game-service/src/main/java/awesome/group/game/service/citrus/RegisterService.java
index b9d4ad7..1bdab25 100644
--- a/game-service/src/main/java/awesome/group/game/service/RegisterService.java
+++ b/game-service/src/main/java/awesome/group/game/service/citrus/RegisterService.java
@@ -1,9 +1,10 @@
-package awesome.group.game.service;
+package awesome.group.game.service.citrus;
import awesome.group.game.dao.bean.MatrixApp;
import awesome.group.game.dao.bean.MatrixUser;
import awesome.group.game.dao.mapper.MatrixAppMapper;
import awesome.group.game.dao.mapper.MatrixUserMapper;
+import awesome.group.game.service.SmsService;
import awesome.group.game.service.bo.MatrixAppBo;
import awesome.group.game.service.bo.RegisterBo;
import awesome.group.game.service.common.exception.PaganiException;
@@ -38,6 +39,12 @@ public class RegisterService {
return new MatrixAppBo(app);
}
+ public MatrixAppBo getAppByAppCode(String appCode) {
+ MatrixApp app = appMapper.queryByCode(appCode);
+ Assert.isTrue(app != null, "参数非法");
+ return new MatrixAppBo(app);
+ }
+
public void register(RegisterBo bo) {
Assert.isTrue(StringUtils.hasText(bo.mobile), "手机号不能为空");
Assert.isTrue(StringUtils.hasText(bo.inviteCode), "邀请码不能为空");
diff --git a/game-service/src/main/java/awesome/group/game/service/citrus/UserService.java b/game-service/src/main/java/awesome/group/game/service/citrus/UserService.java
new file mode 100644
index 0000000..50d68b6
--- /dev/null
+++ b/game-service/src/main/java/awesome/group/game/service/citrus/UserService.java
@@ -0,0 +1,63 @@
+package awesome.group.game.service.citrus;
+
+import awesome.group.game.dao.bean.MatrixApp;
+import awesome.group.game.dao.bean.MatrixUser;
+import awesome.group.game.dao.mapper.MatrixAppMapper;
+import awesome.group.game.dao.mapper.MatrixUserMapper;
+import awesome.group.game.service.SmsService;
+import awesome.group.game.service.bo.citrus.LoginReq;
+import awesome.group.game.service.bo.citrus.UserBo;
+import awesome.group.game.service.common.exception.PaganiException;
+import awesome.group.game.service.common.exception.PaganiExceptionCode;
+import awesome.group.game.service.util.EncryptUtil;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+import org.springframework.util.Assert;
+import org.springframework.util.StringUtils;
+
+@Service
+public class UserService {
+ @Autowired
+ private MatrixUserMapper userMapper;
+
+ @Autowired
+ private MatrixAppMapper appMapper;
+
+ @Autowired
+ private SmsService smsService;
+
+ public MatrixUser login(LoginReq req) {
+ Assert.isTrue(req != null, "非法请求");
+ Assert.isTrue(StringUtils.hasText(req.mobile), "非法请求");
+ Assert.isTrue(StringUtils.hasText(req.pwd), "非法请求");
+ Assert.isTrue(StringUtils.hasText(req.appCode), "appCode不能为空");
+ MatrixApp app = appMapper.queryByCode(req.appCode);
+ Assert.isTrue(StringUtils.hasText(req.appCode), "appCode非法");
+ MatrixUser user = userMapper.selectByAppIdAndMobile(app.getId(), req.mobile);
+ Assert.isTrue(user != null, "用户不存在");
+ String str = EncryptUtil.sha1(req.pwd);
+ Assert.isTrue(user.getPwd().equals(str), "密码错误");
+ return user;
+ }
+
+ public MatrixUser loginByCode(LoginReq req) {
+ Assert.isTrue(req != null, "非法请求");
+ Assert.isTrue(StringUtils.hasText(req.mobile), "非法请求");
+ Assert.isTrue(StringUtils.hasText(req.code), "非法请求");
+ Assert.isTrue(StringUtils.hasText(req.appCode), "appCode不能为空");
+ MatrixApp app = appMapper.queryByCode(req.appCode);
+ Assert.isTrue(StringUtils.hasText(req.appCode), "appCode非法");
+ if (!smsService.verifyAndUseCaptcha(req.mobile, "login", req.code)) {
+ throw new PaganiException(PaganiExceptionCode.GENERAL_ERROR, "验证码错误");
+ }
+
+ MatrixUser user = userMapper.selectByAppIdAndMobile(app.getId(), req.mobile);
+ Assert.isTrue(user != null, "用户不存在");
+ return user;
+ }
+
+ public UserBo getUser(Integer uid) {
+ MatrixUser u = userMapper.selectById(uid);
+ return new UserBo(u);
+ }
+}
diff --git a/game-service/src/test/resources/application-default.yml b/game-service/src/test/resources/application-default.yml
index 897d1f5..9909d10 100644
--- a/game-service/src/test/resources/application-default.yml
+++ b/game-service/src/test/resources/application-default.yml
@@ -9,6 +9,14 @@ spring:
proxy-target-class: true
pid:
file: pid #pid文件名
+ redis:
+ host: 127.0.0.1
+ port: 6379
+ password:
+ maxTotal: 128
+ poolMaxWaitMs: 50
+ timeOutMs: 100
+
datasource:
game:
type: com.zaxxer.hikari.HikariDataSource
diff --git a/game-web/src/main/java/awesome/group/game/web/RequestContext.java b/game-web/src/main/java/awesome/group/game/web/RequestContext.java
index 7765410..e76c60f 100644
--- a/game-web/src/main/java/awesome/group/game/web/RequestContext.java
+++ b/game-web/src/main/java/awesome/group/game/web/RequestContext.java
@@ -17,6 +17,7 @@ public class RequestContext {
private static final String KEY_UID = "uid";
public static final String ADMIN_ID = "adminId";
+ public static final String CITRUS_UID = "citrusUid";
private static final ThreadLocal