|
|
|
@ -1,11 +1,22 @@
|
|
|
|
|
package au.com.royalpay.payment.manage.appclient.core.impls;
|
|
|
|
|
|
|
|
|
|
import au.com.royalpay.payment.manage.appclient.core.ManageAppService;
|
|
|
|
|
import au.com.royalpay.payment.manage.mappers.system.ManageDeviceTokenMapper;
|
|
|
|
|
import au.com.royalpay.payment.manage.mappers.system.ManagerMapper;
|
|
|
|
|
import au.com.royalpay.payment.manage.mappers.system.OrgMapper;
|
|
|
|
|
import au.com.royalpay.payment.manage.merchants.beans.ClientRegisterInfo;
|
|
|
|
|
import au.com.royalpay.payment.manage.merchants.beans.PartnerQuery;
|
|
|
|
|
import au.com.royalpay.payment.manage.merchants.core.ClientManager;
|
|
|
|
|
import au.com.royalpay.payment.manage.signin.beans.ChangePwdBean;
|
|
|
|
|
import au.com.royalpay.payment.manage.signin.core.ManagerAccountsService;
|
|
|
|
|
import au.com.royalpay.payment.manage.signin.core.SignInAccountService;
|
|
|
|
|
import au.com.royalpay.payment.tools.device.DeviceSupport;
|
|
|
|
|
import au.com.royalpay.payment.tools.device.ManageDeviceSupport;
|
|
|
|
|
import au.com.royalpay.payment.tools.device.support.DeviceRegister;
|
|
|
|
|
import au.com.royalpay.payment.tools.exceptions.ForbiddenException;
|
|
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
|
|
import com.github.miemiedev.mybatis.paginator.domain.PageBounds;
|
|
|
|
|
import org.springframework.cache.annotation.Cacheable;
|
|
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
|
@ -18,16 +29,85 @@ public class ManageAppServiceImp implements ManageAppService {
|
|
|
|
|
private ManageDeviceSupport manageDeviceSupport;
|
|
|
|
|
@Resource
|
|
|
|
|
private OrgMapper orgMapper;
|
|
|
|
|
@Resource
|
|
|
|
|
private ManagerMapper managerMapper;
|
|
|
|
|
@Resource
|
|
|
|
|
private ClientManager clientManager;
|
|
|
|
|
@Resource
|
|
|
|
|
private SignInAccountService signInAccountService;
|
|
|
|
|
@Resource
|
|
|
|
|
private ManageDeviceTokenMapper manageDeviceTokenMapper;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void updateDevToken(JSONObject device, String devToken) {
|
|
|
|
|
manageDeviceSupport.updateDeviceMessageToken(device, devToken);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void sign_out(JSONObject device) {
|
|
|
|
|
String clientType = device.getString("client_type");
|
|
|
|
|
DeviceRegister register = manageDeviceSupport.findRegister(clientType);
|
|
|
|
|
register.manageSignout(device);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void changeAccountPassword(JSONObject device, ChangePwdBean change, String manager_id) {
|
|
|
|
|
String clientType = device.getString("client_type");
|
|
|
|
|
manageDeviceSupport.findRegister(clientType);
|
|
|
|
|
// JSONObject client = signInAccountService.getClient(account_id);
|
|
|
|
|
if (!manager_id.equals(device.getString("manager_id"))) {
|
|
|
|
|
throw new ForbiddenException("You have no permission");
|
|
|
|
|
}
|
|
|
|
|
signInAccountService.changeManagerPassword(device, change);
|
|
|
|
|
updateDevTokenStatus(device.getString("dev_id"), 0);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public List<JSONObject> getReferrerList(JSONObject device) {
|
|
|
|
|
String clientType = device.getString("client_type");
|
|
|
|
|
manageDeviceSupport.findRegister(clientType);
|
|
|
|
|
return orgMapper.listOrgs(1,new PageBounds());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public JSONObject registerClient(JSONObject device, ClientRegisterInfo registery) {
|
|
|
|
|
String clientType = device.getString("client_type");
|
|
|
|
|
manageDeviceSupport.findRegister(clientType);
|
|
|
|
|
JSONObject manager = managerMapper.findById(device.getString("manager_id"));
|
|
|
|
|
return clientManager.registerClient(null, registery, manager);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public List<JSONObject> listPartners(JSONObject device, PartnerQuery query) {
|
|
|
|
|
String clientType = device.getString("client_type");
|
|
|
|
|
manageDeviceSupport.findRegister(clientType);
|
|
|
|
|
JSONObject manager = managerMapper.findById(device.getString("manager_id"));
|
|
|
|
|
return clientManager.listPartners( manager, query);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public JSONObject clientDetail(JSONObject device, String clientMoniker) {
|
|
|
|
|
String clientType = device.getString("client_type");
|
|
|
|
|
manageDeviceSupport.findRegister(clientType);
|
|
|
|
|
JSONObject manager = managerMapper.findById(device.getString("manager_id"));
|
|
|
|
|
return clientManager.clientDetail(manager, clientMoniker);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public void updateDevTokenStatus(String devId, int status) {
|
|
|
|
|
JSONObject devTokenObj = getDevTokenByDevId(devId);
|
|
|
|
|
if (devTokenObj != null) {
|
|
|
|
|
devTokenObj.put("is_valid", status);
|
|
|
|
|
manageDeviceTokenMapper.update(devTokenObj);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
@Cacheable(value = ":dev_message_token:", key = "#dev_id")
|
|
|
|
|
public JSONObject getDevTokenByDevId(String dev_id) {
|
|
|
|
|
return manageDeviceTokenMapper.findByDevId(dev_id);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|