测试账户权限调整

master
yangkai 6 years ago
parent 839033b7f7
commit bd5b1541af

@ -76,4 +76,6 @@ public interface ClientAccountMapper {
List<JSONObject> listNullUnionIdAccounts();
List<JSONObject> query(JSONObject params);
List<JSONObject> partnerAndSubPartnerAccounts(@Param("client_id") int clientId);
}

@ -8,6 +8,7 @@ import com.alibaba.fastjson.JSONObject;
import com.github.miemiedev.mybatis.paginator.domain.PageBounds;
import com.github.miemiedev.mybatis.paginator.domain.PageList;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import java.util.List;
@ -63,4 +64,7 @@ public interface ManagerMapper {
List<JSONObject> listOpenIdByRole(@Param("mask") int mask);
List<JSONObject> listServants(@Param("mask") int mask);
@Select("select email from sys_managers where is_valid=1 AND role & 256 > 0 AND email IS NOT NULL")
List<String> listDevManager();
}

@ -328,4 +328,6 @@ public interface ClientManager {
void switchHfLink(JSONObject manager, String clientMoniker,boolean allow);
void sendHfEmailNotice(JSONObject order);
void updateAllPartnerPassword(String clientMoniker, List<String> emails);
}

@ -886,7 +886,7 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid
if (StringUtils.isEmpty(client.getString("sub_merchant_id"))) {
throw new BadRequestException("Sub Merchant ID Can't be null ");
}
String username = clientMoniker + client.getString("sub_merchant_id");
String username = clientMoniker;
boolean duplicated = true;
String pwd = RandomStringUtils.random(8, true, true);
while (duplicated) {
@ -899,7 +899,7 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid
newAccount(clientMoniker, account, manager, 1);
duplicated = false;
} catch (Exception e) {
username += "1";
username += "0";
}
}
sendInitEmail(client, username, pwd);
@ -959,9 +959,12 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid
ctx.setVariable("client_moniker", client.getString("client_moniker"));
ctx.setVariable("contact_person", client.getString("contact_person"));
ctx.setVariable("credential_code", client.getString("credential_code"));
final String content = thymeleaf.process("mail/new_client_notice", ctx);
// final String content = VelocityEngineUtils.mergeTemplateIntoString(null, "mail/new_client_notice.vm",
// "utf-8", model);
ctx.setVariable("password", "*****");
final String contentBd = thymeleaf.process("mail/new_client_notice", ctx);
final String mailTo = client.getString("contact_email");
if (StringUtils.isEmpty(mailTo)) {
throw new EmailException("Client Contact Email is invalid");
@ -977,8 +980,9 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid
@Override
public void run() {
try {
String emailId = mailService.sendEmail("Your RoyalPay Cross-border Payment has been set up", mailTo,
emails.isEmpty() ? "" : StringUtils.join(emails, ","), content);
String emailId = mailService.sendEmail("Your RoyalPay Cross-border Payment has been set up", mailTo, "", content);
mailService.sendEmail("Your RoyalPay Cross-border Payment has been set up", emails.isEmpty() ? "" : StringUtils.join(emails, ","),
"", contentBd);
JSONObject clientUpdate = new JSONObject();
clientUpdate.put("client_id", client.getIntValue("client_id"));
clientUpdate.put("approve_email_send", 3);
@ -3775,16 +3779,41 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid
ctx.setVariable("amount", order.getString("total_amount"));
ctx.setVariable("time", order.getString("create_time"));
final String content = thymeleaf.process( "mail/hf_email_notice", ctx);
final String mailTo = client.getString("contact_email");
if (StringUtils.isEmpty(mailTo)) {
throw new EmailException("Client Contact Email is invalid");
}
new Thread(() -> {
try {
mailService.sendEmail("你刚刚有一笔到账信息", client.getString("contact_email"), "", content);
mailService.sendEmail("你刚刚有一笔到账信息", mailTo, "", content);
} catch (Exception ignored) {
logger.error("邮件发送失败", ignored);
}
}).start();
}
@Override
public void updateAllPartnerPassword(String clientMoniker, List<String> emails) {
JSONObject client = getClientInfoByMoniker(clientMoniker);
if (client == null) {
throw new InvalidShortIdException();
}
List<JSONObject> partners = clientAccountMapper.partnerAndSubPartnerAccounts(client.getIntValue("client_id"));
partners.stream().forEach(partner -> {
String pwd = RandomStringUtils.random(8, true, true);
String salt = PasswordUtils.newSalt();
String pwdHash = PasswordUtils.hashPwd(pwd, salt);
partner.put("salt", salt);
partner.put("password_hash", pwdHash);
partner.put("password_aes", PasswordUtils.encryptAESPwd(pwd));
deviceManager.deviceOffline(partner.getString("account_id"));
clientAccountMapper.update(partner);
signInAccountService.clearAccountCache(partner.getString("account_id"));
partner.put("password", pwd);
});
sendTestMerchantPassword(partners, emails);
}
@Override
public String getShortLink(String clientMoniker) {
String longUrl = PlatformEnvironment.getEnv().concatUrl("/api/v1.0/hf_gateway/partners/" + clientMoniker + "/jump/pc");
@ -3813,4 +3842,17 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid
}
private void sendTestMerchantPassword(List<JSONObject> accounts, List<String> emails) {
Context ctx = new Context();
ctx.setVariable("accounts", accounts);
final String content = thymeleaf.process( "mail/test_merchant_password", ctx);
new Thread(() -> {
try {
mailService.sendEmail("测试商户账户已更新", emails.isEmpty() ? "" : StringUtils.join(emails, ","), "", content);
} catch (Exception ignored) {
logger.error("邮件发送失败", ignored);
}
}).start();
}
}

@ -284,12 +284,12 @@ public class PartnerManageController {
return tradeLogService.listOrderRefunds(orderId, null);
}
@ManagerMapping(value = "/{clientMoniker}/accounts", method = RequestMethod.GET, role = {ManagerRole.ADMIN, ManagerRole.BD_USER, ManagerRole.OPERATOR, ManagerRole.SERVANT, ManagerRole.DIRECTOR})
@ManagerMapping(value = "/{clientMoniker}/accounts", method = RequestMethod.GET, role = {ManagerRole.ADMIN, ManagerRole.BD_USER, ManagerRole.OPERATOR, ManagerRole.SERVANT, ManagerRole.DIRECTOR,ManagerRole.DEVELOPER})
public List<JSONObject> partnerAccounts(@PathVariable String clientMoniker, @ModelAttribute(CommonConsts.MANAGER_STATUS) JSONObject manager) {
return clientManager.listAccounts(manager, clientMoniker);
}
@ManagerMapping(value = "/{clientMoniker}/accounts", method = RequestMethod.POST, role = {ManagerRole.ADMIN, ManagerRole.OPERATOR, ManagerRole.BD_USER, ManagerRole.SERVANT})
@ManagerMapping(value = "/{clientMoniker}/accounts", method = RequestMethod.POST, role = {ManagerRole.ADMIN, ManagerRole.OPERATOR, ManagerRole.DEVELOPER})
public JSONObject addPartnerAccount(@RequestBody @Valid NewAccountBean account, Errors errors, @PathVariable String clientMoniker,
@ModelAttribute(CommonConsts.MANAGER_STATUS) JSONObject manager) {
HttpUtils.handleValidErrors(errors);

@ -0,0 +1,43 @@
package au.com.royalpay.payment.manage.task;
import au.com.royalpay.payment.manage.mappers.system.ManagerMapper;
import au.com.royalpay.payment.manage.merchants.core.ClientManager;
import au.com.royalpay.payment.tools.scheduler.SynchronizedScheduler;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
import javax.annotation.Resource;
import java.util.Arrays;
import java.util.List;
@Component
@ConditionalOnProperty(value = "app.run-tasks", havingValue = "false")
public class UpdatePartnerPasswordTask {
private Logger logger = LoggerFactory.getLogger(getClass());
@Resource
private ClientManager clientManager;
@Resource
private SynchronizedScheduler synchronizedScheduler;
@Resource
private ManagerMapper managerMapper;
private final static String EMAIL = "lily.tao@royalpay.com.au,bella.sun@royalpay.com.au," +
"astro.dai@royalpay.com.au,taylor.dang@royalpay.com.au";
@Scheduled(cron = "0 0 9 28 * ?")
public void resetPartnerPassword() {
synchronizedScheduler.executeProcess("manage_task:resetPartnerPassword", 120_000, () -> {
final List<String> emails = managerMapper.listDevManager();
List<String> emailList = Arrays.asList(EMAIL.split(","));
emailList.stream().forEach(email -> {
if (!emails.contains(email)) {
emails.add(email);
}
});
clientManager.updateAllPartnerPassword("PINE", emails);
});
}
}

@ -17,4 +17,10 @@
</if>
</where>
</select>
<select id="partnerAndSubPartnerAccounts" resultType="com.alibaba.fastjson.JSONObject">
SELECT sc.client_moniker, sa.*
FROM sys_clients sc
INNER JOIN sys_accounts sa ON sc.client_id = sa.client_id AND sa.is_valid = 1
WHERE sc.client_id = #{client_id} OR sc.parent_client_id = #{client_id} AND sc.is_valid = 1
</select>
</mapper>

@ -0,0 +1,49 @@
<html xmlns:th="http://www.thymeleaf.org" lang="zh">
<style type="text/css">
table.gridtable {
font-family: verdana,arial,sans-serif;
font-size:11px;
color:#333333;
border-width: 1px;
border-color: #666666;
border-collapse: collapse;
}
table.gridtable th {
border-width: 1px;
padding: 8px;
border-style: solid;
border-color: #666666;
background-color: #dedede;
}
table.gridtable td {
border-width: 1px;
padding: 8px;
border-style: solid;
border-color: #666666;
background-color: #ffffff;
}
</style>
<table class="gridtable">
<thead>
<tr>
<th>序号</th>
<th>商户</th>
<th>角色</th>
<th>用户名</th>
<th>密码</th>
</tr>
</thead>
<tbody>
<tr th:each="account : ${accounts}">
<td th:text="${accountStat.index} + 1"></td>
<td th:text="${account.client_moniker}"></td>
<td th:if="${account.role} == 1">admin</td>
<td th:if="${account.role} == 2">Manager</td>
<td th:if="${account.role} == 3">Cashier</td>
<td th:text="${account.username}"></td>
<td th:text="${account.password}"></td>
</tr>
</tbody>
</table>
</html>

@ -994,7 +994,7 @@ margin-bottom: 10%;"/>
<!--<i class="fa fa-file-image-o"></i> -->Marketing Materials
</a>
</li>
<li ng-if="[1]|withRole">
<li ng-if="(currentUser.client.client_id!=9 && currentUser.client.parent_client_id!=9)&&([1]|withRole)">
<a ui-sref="accounts">
<!--<i class="fa fa-users"></i> -->Accounts
</a>

@ -1,7 +1,7 @@
<div class="row margin-bottom">
<div class="col-sm-12">
<div class="btn-group">
<button class="btn btn-success" type="button" ng-click="addAccount()" ng-if="'111'|withRole">
<button class="btn btn-success" type="button" ng-click="addAccount()" ng-if="'100000011'|withRole">
<i class="fa fa-plus"></i> Add Account
</button>
</div>
@ -9,7 +9,7 @@
</div>
<div class="row">
<div class="col-sm-12">
<p ng-if="!accounts.length">There is no accounts for this partner, <a role="button" ng-click="addAccount()" ng-if="'111'|withRole">Create One</a></p>
<p ng-if="!accounts.length">There is no accounts for this partner, <a role="button" ng-click="addAccount()" ng-if="'100000011'|withRole">Create One</a></p>
<div class="col-sm-12 table-responsive">
<table class="table table-striped table-bordered table-hover" ng-if="accounts.length">
<thead>

Loading…
Cancel
Save