|
|
|
@ -45,8 +45,7 @@ import java.util.Map;
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* account service for sign in
|
|
|
|
|
* Created by yixian on 2016-06-29.
|
|
|
|
|
* account service for sign in Created by yixian on 2016-06-29.
|
|
|
|
|
*/
|
|
|
|
|
@Service
|
|
|
|
|
public class SignInAccountServiceImpl implements SignInAccountService, ApplicationEventPublisherAware {
|
|
|
|
@ -121,7 +120,7 @@ public class SignInAccountServiceImpl implements SignInAccountService, Applicati
|
|
|
|
|
if (client == null) {
|
|
|
|
|
throw new ForbiddenException("用户不存在或已禁用");
|
|
|
|
|
}
|
|
|
|
|
client.putAll(clientConfigService.find(client.getIntValue("parent_client_id")));
|
|
|
|
|
client.putAll(clientConfigService.find(client_id));
|
|
|
|
|
client = clientInfoWithNoSecretInfo(client);
|
|
|
|
|
if (client.getInteger("parent_client_id") != null) {
|
|
|
|
|
JSONObject rootPartner = clientManager.getClientInfo(client.getIntValue("parent_client_id"));
|
|
|
|
@ -150,11 +149,9 @@ public class SignInAccountServiceImpl implements SignInAccountService, Applicati
|
|
|
|
|
JSONObject account = managerMapper.findAvailableByLoginId(loginInfo.getLoginId());
|
|
|
|
|
validLoginInfo(loginInfo, account);
|
|
|
|
|
JSONObject client = clientManager.getClientInfoIgnoreInvalid(account.getIntValue("client_id"));
|
|
|
|
|
client.putAll(clientConfigService.find(client.getIntValue("client_id")));
|
|
|
|
|
if (client != null && !client.getBooleanValue("is_valid")) {
|
|
|
|
|
throw new BadRequestException(LocaleSupport.localeMessage("error.login.password"));
|
|
|
|
|
}
|
|
|
|
|
validLoginInfo(loginInfo, account);
|
|
|
|
|
publisher.publishEvent(new ManagerLoginEvent(this, account.getString("manager_id"), RequestEnvironment.getClientIp(), "PASSWORD"));
|
|
|
|
|
return account;
|
|
|
|
|
}
|
|
|
|
@ -174,7 +171,8 @@ public class SignInAccountServiceImpl implements SignInAccountService, Applicati
|
|
|
|
|
public JSONObject clientLoginCheck(LoginInfo loginInfo) {
|
|
|
|
|
JSONObject account = clientAccountMapper.findByUsername(loginInfo.getLoginId());
|
|
|
|
|
validLoginInfo(loginInfo, account);
|
|
|
|
|
publisher.publishEvent(new ClientLoginEvent(this, account.getIntValue("client_id"), account.getString("account_id"), RequestEnvironment.getClientIp(), "PASSWORD"));
|
|
|
|
|
publisher.publishEvent(
|
|
|
|
|
new ClientLoginEvent(this, account.getIntValue("client_id"), account.getString("account_id"), RequestEnvironment.getClientIp(), "PASSWORD"));
|
|
|
|
|
return account;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -221,7 +219,7 @@ public class SignInAccountServiceImpl implements SignInAccountService, Applicati
|
|
|
|
|
}
|
|
|
|
|
JSONObject account = new JSONObject();
|
|
|
|
|
client = clientManager.getClientDetailById(client.getIntValue("client_id"));
|
|
|
|
|
client.putAll(clientConfigService.find(client.getIntValue("parent_client_id")));
|
|
|
|
|
client.putAll(clientConfigService.find(client.getIntValue("client_id")));
|
|
|
|
|
client = clientInfoWithNoSecretInfo(client);
|
|
|
|
|
if (client.getInteger("parent_client_id") != null) {
|
|
|
|
|
JSONObject rootPartner = clientManager.getClientInfo(client.getIntValue("parent_client_id"));
|
|
|
|
@ -254,7 +252,8 @@ public class SignInAccountServiceImpl implements SignInAccountService, Applicati
|
|
|
|
|
if (account == null) {
|
|
|
|
|
throw new ForbiddenException("Your WeChat Account haven't bind to a client user");
|
|
|
|
|
}
|
|
|
|
|
publisher.publishEvent(new ClientLoginEvent(this, account.getIntValue("client_id"), account.getString("account_id"), RequestEnvironment.getClientIp(), "wechat"));
|
|
|
|
|
publisher.publishEvent(
|
|
|
|
|
new ClientLoginEvent(this, account.getIntValue("client_id"), account.getString("account_id"), RequestEnvironment.getClientIp(), "wechat"));
|
|
|
|
|
return account;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -264,7 +263,8 @@ public class SignInAccountServiceImpl implements SignInAccountService, Applicati
|
|
|
|
|
if (account == null) {
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
publisher.publishEvent(new ClientLoginEvent(this, account.getIntValue("client_id"), account.getString("account_id"), RequestEnvironment.getClientIp(), "wechat"));
|
|
|
|
|
publisher.publishEvent(
|
|
|
|
|
new ClientLoginEvent(this, account.getIntValue("client_id"), account.getString("account_id"), RequestEnvironment.getClientIp(), "wechat"));
|
|
|
|
|
return account;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -293,17 +293,18 @@ public class SignInAccountServiceImpl implements SignInAccountService, Applicati
|
|
|
|
|
|
|
|
|
|
String codeKey = signInStatusManager.addChangepasswordVerifyCode(client_moniker);
|
|
|
|
|
String url = PlatformEnvironment.getEnv().concatUrl("/global/userstatus/partner_changepassword_page/" + codeKey);
|
|
|
|
|
// JSONObject map = new JSONObject();
|
|
|
|
|
// map.put("url", url);
|
|
|
|
|
// map.put("accounts", accounts);
|
|
|
|
|
// map.put("client_moniker", client_moniker);
|
|
|
|
|
//todo velocityEngine
|
|
|
|
|
// JSONObject map = new JSONObject();
|
|
|
|
|
// map.put("url", url);
|
|
|
|
|
// map.put("accounts", accounts);
|
|
|
|
|
// map.put("client_moniker", client_moniker);
|
|
|
|
|
// todo velocityEngine
|
|
|
|
|
Context ctx = new Context();
|
|
|
|
|
ctx.setVariable("url", url);
|
|
|
|
|
ctx.setVariable("accounts", accounts);
|
|
|
|
|
ctx.setVariable("client_moniker", client_moniker);
|
|
|
|
|
final String content = thymeleaf.process( "mail/reset_password", ctx);
|
|
|
|
|
//final String content = VelocityEngineUtils.mergeTemplateIntoString(null, "mail/reset_password.vm", "utf-8", map);
|
|
|
|
|
final String content = thymeleaf.process("mail/reset_password", ctx);
|
|
|
|
|
// final String content = VelocityEngineUtils.mergeTemplateIntoString(null, "mail/reset_password.vm",
|
|
|
|
|
// "utf-8", map);
|
|
|
|
|
|
|
|
|
|
new Thread(() -> {
|
|
|
|
|
try {
|
|
|
|
@ -324,18 +325,17 @@ public class SignInAccountServiceImpl implements SignInAccountService, Applicati
|
|
|
|
|
|
|
|
|
|
public static JSONObject clientInfoWithNoSecretInfo(JSONObject client) {
|
|
|
|
|
JSONObject simpleClient = new JSONObject();
|
|
|
|
|
String[] columns = {"client_id", "client_moniker", "parent_client_id",
|
|
|
|
|
"company_name", "address","business_name","business_structure", "abn","acn","company_phone","suburb","postcode","state","contact_person","contact_phone","contact_email",
|
|
|
|
|
"short_name", "logo_url", "enable_refund", "enable_refund_auth", "retail_surcharge", "require_custinfo", "require_remark",
|
|
|
|
|
"logo_thumbnail", "creator", "create_time", "approver", "approve_result", "approve_time", "timezone",
|
|
|
|
|
"has_children", "source", "customer_surcharge_rate", "enable_alipay", "enable_wechat", "enable_bestpay","manual_settle","skip_clearing"};
|
|
|
|
|
String[] columns = { "client_id", "client_moniker", "parent_client_id", "company_name", "address", "business_name", "business_structure", "abn", "acn",
|
|
|
|
|
"company_phone", "suburb", "postcode", "state", "contact_person", "contact_phone", "contact_email", "short_name", "logo_url", "enable_refund",
|
|
|
|
|
"enable_refund_auth", "retail_surcharge", "require_custinfo", "require_remark", "logo_thumbnail", "creator", "create_time", "approver",
|
|
|
|
|
"approve_result", "approve_time", "timezone", "has_children", "source", "customer_surcharge_rate", "enable_alipay", "enable_wechat",
|
|
|
|
|
"enable_bestpay", "manual_settle", "skip_clearing" };
|
|
|
|
|
for (String col : columns) {
|
|
|
|
|
simpleClient.put(col, client.get(col));
|
|
|
|
|
}
|
|
|
|
|
return simpleClient;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void setApplicationEventPublisher(ApplicationEventPublisher applicationEventPublisher) {
|
|
|
|
|
this.publisher = applicationEventPublisher;
|
|
|
|
|