|
|
@@ -1,8 +1,10 @@
|
|
|
package modules.user;
|
|
|
|
|
|
+import com.alibaba.fastjson.JSONObject;
|
|
|
import com.jfinal.kit.StrKit;
|
|
|
import com.jfinal.plugin.activerecord.Db;
|
|
|
import common.model.User;
|
|
|
+import common.utils.bsn.BsnSDK;
|
|
|
import common.utils.http.MyRet;
|
|
|
|
|
|
import java.util.List;
|
|
|
@@ -22,7 +24,32 @@ public class UserService {
|
|
|
return MyRet.fail("注册失败,请联系客服。");
|
|
|
}
|
|
|
|
|
|
- return MyRet.ok("注册成功。");
|
|
|
+ // 生成Bsn地址
|
|
|
+ try {
|
|
|
+ JSONObject response = BsnSDK.createChainAccount("DLTBH_" + user.getId() + "_" + user.getCreateTime());
|
|
|
+
|
|
|
+ if (response.getInteger("code") == -1) {
|
|
|
+ throw new RuntimeException("地址创建失败:" + response);
|
|
|
+ }
|
|
|
+
|
|
|
+ JSONObject data = response.getJSONObject("data");
|
|
|
+ String address = data.getString("opbChainClientAddress");
|
|
|
+
|
|
|
+ if (StrKit.isBlank(address)) {
|
|
|
+ throw new RuntimeException("地址创建成功,但获取失败:" + data);
|
|
|
+ }
|
|
|
+
|
|
|
+ user.setBsnAccountAddress(address);
|
|
|
+
|
|
|
+ if (user.update()) {
|
|
|
+ return MyRet.ok("注册成功。");
|
|
|
+ } else {
|
|
|
+ throw new RuntimeException("地址生成获取成功,但更新给用户失败");
|
|
|
+ }
|
|
|
+ } catch (Exception e) {
|
|
|
+ String msg = "注册成功,但是BSN地址生成失败:" + e.getMessage() + ", 请联系客服处理。";
|
|
|
+ return MyRet.fail(msg);
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
public MyRet login(String mobileNumber, String pwdMd5Md5) {
|