Merge remote-tracking branch 'origin/develop' into develop

# Conflicts:
#	src/main/java/au/com/royalpay/payment/manage/merchants/core/impls/ClientManagerImpl.java
#	src/main/java/au/com/royalpay/payment/manage/merchants/web/PartnerManageController.java
#	src/main/resources/application-rpay.properties
#	src/main/ui/static/payment/partner/partner-manage.js
#	src/main/ui/static/payment/partner/templates/sub_merchant_id_apply.html
master
kira 6 years ago
commit 98332d95a5

@ -36,10 +36,6 @@
<groupId>au.com.royalpay.payment</groupId>
<artifactId>jd-core</artifactId>
</dependency>
<dependency>
<groupId>au.com.royalpay.payment</groupId>
<artifactId>rpay-core</artifactId>
</dependency>
<dependency>
<groupId>com.github.stuxuhai</groupId>
<artifactId>jpinyin</artifactId>

@ -13,15 +13,18 @@ public class AddressInfo {
public AddressInfo(String address, String suburb, String state, String postCode, String country) {
this.address = address;
this.suburb = suburb;
this.state = state;
if (!postCode.matches("^\\d{4}$")) {
postCode = "9999";
country = "OTH";
state = "OTH";
}
this.postCode = postCode;
if (country != null && country.length() != 3) {
country = "OTH";
state = "OTH";
postCode = "9999";
}
this.postCode = postCode;
this.state = state;
this.country = country;
}

@ -8,6 +8,8 @@ public interface MerchantLocationService {
List<JSONObject> listMerchantsLocations(PartnerQuery query);
void initClientLocations() throws InterruptedException;
JSONObject getMerchantLocationByMoniker(String clientMoniker);
void updateMerchantLocation(JSONObject manager, String clientMoniker, JSONObject geoData);

@ -5,19 +5,43 @@ import au.com.royalpay.payment.manage.dev.core.MerchantLocationService;
import au.com.royalpay.payment.manage.mappers.system.ClientLocationsMapper;
import au.com.royalpay.payment.manage.merchants.beans.PartnerQuery;
import au.com.royalpay.payment.manage.merchants.core.ClientManager;
import cn.yixblog.platform.http.HttpRequestGenerator;
import cn.yixblog.platform.http.HttpRequestResult;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import io.netty.util.internal.ConcurrentSet;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Service;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.util.UriComponentsBuilder;
import javax.annotation.Resource;
import java.net.URISyntaxException;
import java.util.Date;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.concurrent.LinkedBlockingQueue;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;
@Service
public class MerchantLocationServiceImpl implements MerchantLocationService {
private Logger logger = LoggerFactory.getLogger(getClass());
private static final String GOOGLE_MAPS_API = "https://maps.googleapis.com/maps/api/geocode/json";
private static final String GOOGLE_API_KEY = "AIzaSyDUu6qXRV-j24rSdbPOMfVdTN1-2OfC2o8";
private ThreadPoolExecutor pool = new ThreadPoolExecutor(5, 100, 5, TimeUnit.SECONDS, new LinkedBlockingQueue<Runnable>());
private Set<Integer> failureSet = new ConcurrentSet<>();
@Resource
private ClientLocationsMapper clientLocationsMapper;
@Resource
private ClientManager clientManager;
@ -28,6 +52,66 @@ public class MerchantLocationServiceImpl implements MerchantLocationService {
return clientLocationsMapper.getAllMerchantsLocations(params);
}
@Resource
private JdbcTemplate jdbcTemplate;
@Override
public void initClientLocations() throws InterruptedException {
List<Map<String, Object>> clients = jdbcTemplate.queryForList("select client_id, CONCAT(IFNULL(address,''),' ',IFNULL(suburb,''),' ',IFNULL(state,''),' ',IFNULL(country,'')) as 'address' from royalpay_production.sys_clients where client_id not in (select client_id from royalpay_production.sys_clients_locations) ");
final int totalLen = clients.size();
logger.info("total length:" + totalLen);
for (int i = 0; i < totalLen; i++) {
Map<String, Object> client = clients.get(i);
final JSONObject clientObj = new JSONObject(client);
final int idx = i;
pool.execute(new Runnable() {
@Override
public void run() {
try {
processClient(clientObj, idx, totalLen);
} catch (URISyntaxException e) {
failureSet.add(clientObj.getIntValue("client_id"));
}
}
});
Thread.sleep(120);
}
pool.shutdown();
pool.awaitTermination(5, TimeUnit.HOURS);
System.err.println("Failed clients:" + StringUtils.join(failureSet, ","));
}
private void processClient(JSONObject client, int idx, int totalLen) throws URISyntaxException {
String url = UriComponentsBuilder.fromHttpUrl(GOOGLE_MAPS_API)
.queryParam("key", GOOGLE_API_KEY)
.queryParam("address", client.get("address")).toUriString();
HttpRequestGenerator gen = new HttpRequestGenerator(url, RequestMethod.GET);
int clientId = client.getIntValue("client_id");
logger.info("start processing index " + idx + "/" + totalLen + ",client_id=" + clientId);
HttpRequestResult result = gen.execute();
if (result.isSuccess()) {
try {
JSONObject address = result.getResponseContentJSONObj();
System.err.println(address);
JSONArray array1 = address.getJSONArray("results");
JSONObject aarray2 = (JSONObject) array1.get(0);
JSONObject location = aarray2.getJSONObject("geometry").getJSONObject("location");
String longitude = location.getString("lng");
String latitude = location.getString("lat");
String sql = "INSERT royalpay_production.sys_clients_locations values(replace(uuid(),'-','')," + clientId + ",'" + client.getString("address") + "','" + latitude + "','" + longitude + "','System Init',now())";
jdbcTemplate.update(sql);
} catch (Exception e) {
logger.error(e.getMessage(), e);
failureSet.add(clientId);
}
} else {
System.err.print(result.getStatusCode());
failureSet.add(clientId);
}
logger.info("finished index " + idx + "/" + totalLen + ",client_id=" + clientId);
}
@Override
public JSONObject getMerchantLocationByMoniker(String clientMoniker) {
return clientLocationsMapper.findTheLocationByMerchantCode(clientMoniker);

@ -22,4 +22,9 @@ public class ClientLocationsController {
public List<JSONObject> getClientsLocations(PartnerQuery query) {
return merchantLocationService.listMerchantsLocations(query);
}
@RequestMapping(value = "/init")
public void initClientLocations() throws InterruptedException {
merchantLocationService.initClientLocations();
}
}

@ -225,6 +225,8 @@ public interface ClientManager {
void disableClient(String clientMoniker, JSONObject manager);
void revertClient(String clientMoniker, JSONObject manager);
JSONObject getAuthFiles(JSONObject manager, String clientMoniker);
void uploadAuthFiles(JSONObject manager, String clientMoniker, ClientAuthFilesInfo filesInfo);
@ -335,7 +337,4 @@ public interface ClientManager {
void sendHfEmailNotice(JSONObject order);
void updateAllPartnerPassword(String clientMoniker, List<String> emails);
String subRpayMerchantApplication(String clientMoniker, JSONObject manager);
}

@ -7,7 +7,9 @@ import au.com.royalpay.payment.channels.wechat.config.WechatPayEnvironment;
import au.com.royalpay.payment.channels.wechat.runtime.MpPaymentApi;
import au.com.royalpay.payment.channels.wechat.runtime.WxPayClient;
import au.com.royalpay.payment.channels.wechat.runtime.beans.SubMerchantInfo;
import au.com.royalpay.payment.core.PaymentChannelApi;
import au.com.royalpay.payment.core.beans.PayChannel;
import au.com.royalpay.payment.core.exceptions.EmailException;
import au.com.royalpay.payment.core.exceptions.InvalidShortIdException;
import au.com.royalpay.payment.core.utils.OrderExpiryRuleResolver;
@ -25,7 +27,24 @@ import au.com.royalpay.payment.manage.mappers.log.LogSettleMailMapper;
import au.com.royalpay.payment.manage.mappers.payment.TransactionMapper;
import au.com.royalpay.payment.manage.mappers.redpack.ActClientInvitationCodeMapper;
import au.com.royalpay.payment.manage.mappers.risk.RiskAttentionMerchantsMapper;
import au.com.royalpay.payment.manage.mappers.system.*;
import au.com.royalpay.payment.manage.mappers.system.ClientAccountMapper;
import au.com.royalpay.payment.manage.mappers.system.ClientApplyMapper;
import au.com.royalpay.payment.manage.mappers.system.ClientAuditProcessMapper;
import au.com.royalpay.payment.manage.mappers.system.ClientBDMapper;
import au.com.royalpay.payment.manage.mappers.system.ClientBankAccountMapper;
import au.com.royalpay.payment.manage.mappers.system.ClientConfigMapper;
import au.com.royalpay.payment.manage.mappers.system.ClientDeviceMapper;
import au.com.royalpay.payment.manage.mappers.system.ClientFilesMapper;
import au.com.royalpay.payment.manage.mappers.system.ClientMapper;
import au.com.royalpay.payment.manage.mappers.system.ClientRateMapper;
import au.com.royalpay.payment.manage.mappers.system.ClientsContractMapper;
import au.com.royalpay.payment.manage.mappers.system.CommoditiesMapper;
import au.com.royalpay.payment.manage.mappers.system.MailSendMapper;
import au.com.royalpay.payment.manage.mappers.system.MailUnsubMapper;
import au.com.royalpay.payment.manage.mappers.system.ManagerMapper;
import au.com.royalpay.payment.manage.mappers.system.OrgMapper;
import au.com.royalpay.payment.manage.mappers.system.PermissionPartnerModuleMapper;
import au.com.royalpay.payment.manage.mappers.system.SysWxMerchantApplyMapper;
import au.com.royalpay.payment.manage.merchants.beans.ActivityPosterBuilder;
import au.com.royalpay.payment.manage.merchants.beans.BankAccountInfo;
import au.com.royalpay.payment.manage.merchants.beans.ClientAuthFilesInfo;
@ -222,9 +241,6 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid
@Resource
private WxPayClient wxPayClient;
@Resource
private RpayApi rpayApi;
@Resource
private ManagerMapper managerMapper;
@Resource
@ -2668,6 +2684,13 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid
clientModifySupport.processClientModify(new DisableModify(manager, clientMoniker, false));
}
@Override
public void revertClient(String clientMoniker, JSONObject manager) {
JSONObject client = clientDetail(manager, clientMoniker);
Assert.notEmpty(client);
clientModifySupport.processClientModify(new DisableModify(manager, clientMoniker, true));
}
@Override
public void checkTodo(JSONObject manager, List<TodoNotice> notices) {
if (ManagerRole.OPERATOR.hasRole(manager.getIntValue("role"))) {

@ -66,6 +66,11 @@ public class PartnerManageController {
clientManager.disableClient(clientMoniker, manager);
}
@ManagerMapping(value = "/{clientMoniker}/revert", method = RequestMethod.PUT, role = {ManagerRole.ADMIN, ManagerRole.OPERATOR})
public void revertClient(@PathVariable String clientMoniker, @ModelAttribute(CommonConsts.MANAGER_STATUS) JSONObject manager) {
clientManager.revertClient(clientMoniker, manager);
}
@ManagerMapping(value = "/{clientMoniker}/qrcode", method = RequestMethod.GET)
public JSONObject getQrCodeImg(@PathVariable String clientMoniker, @ModelAttribute(CommonConsts.MANAGER_STATUS) JSONObject manager, QRCodeConfig config) {
return clientManager.getQRCode(manager, clientMoniker, config);
@ -77,7 +82,7 @@ public class PartnerManageController {
response.setContentType("application/octet-stream;");
response.addHeader("Content-Disposition", "attachment; filename=qr_board.jpg");
OutputStream ous = response.getOutputStream();
clientManager.writeQrCodeBoard(manager, clientMoniker, config, ous, "PC");
clientManager.writeQrCodeBoard(manager, clientMoniker, config, ous,"PC");
}
@ManagerMapping(value = "/{clientMoniker}/qrcode_board/aggregate", method = RequestMethod.GET)
@ -86,7 +91,7 @@ public class PartnerManageController {
response.setContentType("application/octet-stream;");
response.addHeader("Content-Disposition", "attachment; filename=qr_board.jpg");
OutputStream ous = response.getOutputStream();
clientManager.writeAggregateQrCodeBoard(manager, clientMoniker, config, ous, "PC");
clientManager.writeAggregateQrCodeBoard(manager, clientMoniker, config, ous,"PC");
}
@ManagerMapping(value = "/{clientMoniker}/poster", method = RequestMethod.GET)
@ -115,18 +120,18 @@ public class PartnerManageController {
}
@ManagerMapping(value = "/{clientMoniker}/max_order_amount", method = RequestMethod.PUT, role = {ManagerRole.OPERATOR})
public void setMaxOrderAmount(@ModelAttribute(CommonConsts.MANAGER_STATUS) JSONObject manager, @PathVariable String clientMoniker, @RequestBody JSONObject limit) {
clientManager.setMaxOrderAmount(manager, clientMoniker, limit.getBigDecimal("limit"));
public void setMaxOrderAmount(@ModelAttribute(CommonConsts.MANAGER_STATUS) JSONObject manager,@PathVariable String clientMoniker, @RequestBody JSONObject limit) {
clientManager.setMaxOrderAmount(manager,clientMoniker, limit.getBigDecimal("limit"));
}
@ManagerMapping(value = "/{clientMoniker}/customer_surcharge_rate", method = RequestMethod.PUT, role = {ManagerRole.ADMIN})
public void setCustomerSurchargeRate(@ModelAttribute(CommonConsts.MANAGER_STATUS) JSONObject manager, @PathVariable String clientMoniker, @RequestBody JSONObject config) {
clientManager.setCustomerSurchargeRate(manager, clientMoniker, config.getBigDecimal("customer_surcharge_rate"));
public void setCustomerSurchargeRate(@ModelAttribute(CommonConsts.MANAGER_STATUS) JSONObject manager,@PathVariable String clientMoniker, @RequestBody JSONObject config) {
clientManager.setCustomerSurchargeRate(manager,clientMoniker, config.getBigDecimal("customer_surcharge_rate"));
}
@ManagerMapping(value = "/{clientMoniker}/order_expiry_config", method = RequestMethod.PUT, role = {ManagerRole.ADMIN})
public void setOrderExpiryConfig(@ModelAttribute(CommonConsts.MANAGER_STATUS) JSONObject manager, @PathVariable String clientMoniker, @RequestBody JSONObject config) {
clientManager.setOrderExpiryConfig(manager, clientMoniker, config.getString("order_expiry_config"));
public void setOrderExpiryConfig(@ModelAttribute(CommonConsts.MANAGER_STATUS) JSONObject manager,@PathVariable String clientMoniker, @RequestBody JSONObject config) {
clientManager.setOrderExpiryConfig(manager,clientMoniker, config.getString("order_expiry_config"));
}
@ManagerMapping(value = "/{clientMoniker}", method = RequestMethod.PUT, role = {ManagerRole.ADMIN, ManagerRole.BD_USER, ManagerRole.OPERATOR})
@ -171,38 +176,38 @@ public class PartnerManageController {
}
@ManagerMapping(value = "/{clientMoniker}/qrcode_surcharge", method = RequestMethod.PUT, role = {ManagerRole.OPERATOR, ManagerRole.ADMIN, ManagerRole.BD_USER, ManagerRole.SERVANT})
public void setClientPaySurCharge(@ModelAttribute(CommonConsts.MANAGER_STATUS) JSONObject manager, @PathVariable String clientMoniker, @RequestBody JSONObject config) {
clientManager.setClientQRCodePaySurCharge(manager, clientMoniker, config.getBooleanValue("qrcode_surcharge"));
public void setClientPaySurCharge(@ModelAttribute(CommonConsts.MANAGER_STATUS) JSONObject manager,@PathVariable String clientMoniker, @RequestBody JSONObject config) {
clientManager.setClientQRCodePaySurCharge(manager,clientMoniker, config.getBooleanValue("qrcode_surcharge"));
}
@ManagerMapping(value = "/{clientMoniker}/gateway_upgrade", method = RequestMethod.PUT, role = {ManagerRole.DEVELOPER})
public void enableGatewayUpgrade(@ModelAttribute(CommonConsts.MANAGER_STATUS) JSONObject manager, @PathVariable String clientMoniker, @RequestBody JSONObject config) {
clientManager.enableGatewayUpgrade(manager, clientMoniker, config.getBooleanValue("gateway_upgrade"));
public void enableGatewayUpgrade(@ModelAttribute(CommonConsts.MANAGER_STATUS) JSONObject manager,@PathVariable String clientMoniker, @RequestBody JSONObject config) {
clientManager.enableGatewayUpgrade(manager,clientMoniker, config.getBooleanValue("gateway_upgrade"));
}
@ManagerMapping(value = "/{clientMoniker}/gateway_alipay_online", method = RequestMethod.PUT, role = {ManagerRole.DEVELOPER})
public void enableGatewayAlipayOnline(@ModelAttribute(CommonConsts.MANAGER_STATUS) JSONObject manager, @PathVariable String clientMoniker, @RequestBody JSONObject config) {
clientManager.enableGatewayAlipayOnline(manager, clientMoniker, config.getBooleanValue("gateway_alipay_online"));
public void enableGatewayAlipayOnline(@ModelAttribute(CommonConsts.MANAGER_STATUS) JSONObject manager,@PathVariable String clientMoniker, @RequestBody JSONObject config) {
clientManager.enableGatewayAlipayOnline(manager,clientMoniker, config.getBooleanValue("gateway_alipay_online"));
}
@ManagerMapping(value = "/{clientMoniker}/api_surcharge", method = RequestMethod.PUT, role = {ManagerRole.OPERATOR, ManagerRole.ADMIN, ManagerRole.BD_USER, ManagerRole.SERVANT})
public void setClientApiPaySurCharge(@ModelAttribute(CommonConsts.MANAGER_STATUS) JSONObject manager, @PathVariable String clientMoniker, @RequestBody JSONObject config) {
clientManager.setClientApiPaySurCharge(manager, clientMoniker, config.getBooleanValue("api_surcharge"));
public void setClientApiPaySurCharge(@ModelAttribute(CommonConsts.MANAGER_STATUS) JSONObject manager,@PathVariable String clientMoniker, @RequestBody JSONObject config) {
clientManager.setClientApiPaySurCharge(manager,clientMoniker, config.getBooleanValue("api_surcharge"));
}
@ManagerMapping(value = "/{clientMoniker}/retail_surcharge", method = RequestMethod.PUT, role = {ManagerRole.OPERATOR, ManagerRole.ADMIN, ManagerRole.BD_USER, ManagerRole.SERVANT})
public void setClientRetailPaySurCharge(@ModelAttribute(CommonConsts.MANAGER_STATUS) JSONObject manager, @PathVariable String clientMoniker, @RequestBody JSONObject config) {
clientManager.setClientRetailPaySurCharge(manager, clientMoniker, config.getBooleanValue("retail_surcharge"));
public void setClientRetailPaySurCharge(@ModelAttribute(CommonConsts.MANAGER_STATUS) JSONObject manager,@PathVariable String clientMoniker, @RequestBody JSONObject config) {
clientManager.setClientRetailPaySurCharge(manager,clientMoniker, config.getBooleanValue("retail_surcharge"));
}
@ManagerMapping(value = "/{clientMoniker}/tax_in_surcharge", method = RequestMethod.PUT, role = {ManagerRole.OPERATOR, ManagerRole.ADMIN})
public void setClientTaxPayer(@ModelAttribute(CommonConsts.MANAGER_STATUS) JSONObject manager, @PathVariable String clientMoniker, @RequestBody JSONObject config) {
clientManager.setClientTaxInSurcharge(manager, clientMoniker, config.getBooleanValue("tax_in_surcharge"));
public void setClientTaxPayer(@ModelAttribute(CommonConsts.MANAGER_STATUS) JSONObject manager,@PathVariable String clientMoniker, @RequestBody JSONObject config) {
clientManager.setClientTaxInSurcharge(manager,clientMoniker, config.getBooleanValue("tax_in_surcharge"));
}
@ManagerMapping(value = "/{clientMoniker}/customer_tax_free", method = RequestMethod.PUT, role = {ManagerRole.OPERATOR})
public void setClientCustomerTaxFree(@ModelAttribute(CommonConsts.MANAGER_STATUS) JSONObject manager, @PathVariable String clientMoniker, @RequestBody JSONObject config) {
clientManager.setClientCustomerTaxFree(manager, clientMoniker, config.getBooleanValue("customer_tax_free"));
public void setClientCustomerTaxFree(@ModelAttribute(CommonConsts.MANAGER_STATUS) JSONObject manager,@PathVariable String clientMoniker, @RequestBody JSONObject config) {
clientManager.setClientCustomerTaxFree(manager,clientMoniker, config.getBooleanValue("customer_tax_free"));
}
@ManagerMapping(value = "/{clientMoniker}/credential_code", method = RequestMethod.PUT, role = {ManagerRole.OPERATOR, ManagerRole.BD_USER})
@ -290,7 +295,7 @@ 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, ManagerRole.DEVELOPER})
@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);
}
@ -338,8 +343,8 @@ public class PartnerManageController {
}
@ManagerMapping(value = "/{clientMoniker}/skip_clearing", method = RequestMethod.PUT, role = {ManagerRole.ADMIN, ManagerRole.OPERATOR, ManagerRole.FINANCIAL_STAFF})
public void skipClearing(@ModelAttribute(CommonConsts.MANAGER_STATUS) JSONObject manager, @PathVariable String clientMoniker, @RequestBody JSONObject skip_clearing) {
clientManager.setSkipClearing(manager, clientMoniker, skip_clearing.getBooleanValue("skip_clearing"));
public void skipClearing(@ModelAttribute(CommonConsts.MANAGER_STATUS) JSONObject manager,@PathVariable String clientMoniker, @RequestBody JSONObject skip_clearing) {
clientManager.setSkipClearing(manager,clientMoniker, skip_clearing.getBooleanValue("skip_clearing"));
}
@ManagerMapping(value = "/{clientMoniker}/settle_hour", method = RequestMethod.PUT, role = {ManagerRole.ADMIN, ManagerRole.OPERATOR, ManagerRole.SERVANT, ManagerRole.FINANCIAL_STAFF})
@ -389,7 +394,7 @@ public class PartnerManageController {
@RequestParam(required = false) String[] client_ids,
@RequestParam(defaultValue = "1") int page, @RequestParam(defaultValue = "10") int limit,
@ModelAttribute(CommonConsts.MANAGER_STATUS) JSONObject manager) {
return clientManager.listClientDevices(manager, clientMoniker, remark, page, limit, client_type, client_ids);
return clientManager.listClientDevices(manager, clientMoniker, remark, page, limit,client_type,client_ids);
}
@ManagerMapping(value = "/{clientMoniker}/devices/{devId}", method = RequestMethod.PUT, role = {ManagerRole.ADMIN, ManagerRole.OPERATOR, ManagerRole.BD_USER})
@ -448,7 +453,7 @@ public class PartnerManageController {
@ManagerMapping(value = "/{clientMoniker}/export/aggregate/agreepdf", method = RequestMethod.GET, role = {ManagerRole.ADMIN, ManagerRole.DIRECTOR, ManagerRole.OPERATOR})
public void exportAggregateAgreeFile(@PathVariable String clientMoniker, @ModelAttribute(CommonConsts.MANAGER_STATUS) JSONObject manager) throws Exception {
clientManager.getAggregateAgreeFile(clientMoniker, manager, false);
clientManager.getAggregateAgreeFile(clientMoniker, manager,false);
}
@ManagerMapping(value = "/{clientMoniker}/temp/export/pdf", method = RequestMethod.GET, role = {ManagerRole.ADMIN, ManagerRole.BD_USER, ManagerRole.DIRECTOR, ManagerRole.OPERATOR})
@ -458,7 +463,7 @@ public class PartnerManageController {
@ManagerMapping(value = "/{clientMoniker}/import/agreepdf", method = RequestMethod.PUT, role = {ManagerRole.ADMIN, ManagerRole.DIRECTOR, ManagerRole.OPERATOR})
public void importAgreeFile(@PathVariable String clientMoniker, @ModelAttribute(CommonConsts.MANAGER_STATUS) JSONObject manager, @RequestBody JSONObject source) throws Exception {
clientManager.importAgreeFile(clientMoniker, manager, source.getString("source_agree_file"), false);
clientManager.importAgreeFile(clientMoniker, manager, source.getString("source_agree_file"),false);
}
@ManagerMapping(value = "/{clientMoniker}/notify/completeAgree", method = RequestMethod.GET, role = {ManagerRole.ADMIN, ManagerRole.OPERATOR})
@ -508,19 +513,19 @@ public class PartnerManageController {
merchantLocationService.updateMerchantLocation(manager, clientMoniker, geoData);
}
@ManagerMapping(value = "/{clientMoniker}/wechat_compliance_permission", method = RequestMethod.PUT, role = {ManagerRole.OPERATOR, ManagerRole.ADMIN})
@ManagerMapping(value = "/{clientMoniker}/wechat_compliance_permission",method = RequestMethod.PUT,role = {ManagerRole.OPERATOR,ManagerRole.ADMIN})
public void wechatCcompliancePermission(@PathVariable String clientMoniker, @RequestBody JSONObject pass, @ModelAttribute(CommonConsts.MANAGER_STATUS) JSONObject manager) {
clientManager.switchPermission(manager, clientMoniker, "wechat_compliance", pass.getBooleanValue("allow"));
}
@ManagerMapping(value = "/{clientMoniker}/local_merchant_permission", method = RequestMethod.PUT, role = {ManagerRole.OPERATOR, ManagerRole.ADMIN})
@ManagerMapping(value = "/{clientMoniker}/local_merchant_permission",method = RequestMethod.PUT,role = {ManagerRole.OPERATOR,ManagerRole.ADMIN})
public void localMerchantPermission(@PathVariable String clientMoniker, @RequestBody JSONObject pass, @ModelAttribute(CommonConsts.MANAGER_STATUS) JSONObject manager) {
clientManager.switchPermission(manager, clientMoniker, "local_merchant", pass.getBooleanValue("allow"));
}
@ManagerMapping(value = "/{clientMoniker}/list_sub_applices", method = RequestMethod.GET, role = {ManagerRole.OPERATOR, ManagerRole.ADMIN})
@ManagerMapping(value = "/{clientMoniker}/list_sub_applices",method = RequestMethod.GET,role = {ManagerRole.OPERATOR,ManagerRole.ADMIN})
public List<JSONObject> listSubMerchantIdApplys(@PathVariable String clientMoniker, @ModelAttribute(CommonConsts.MANAGER_STATUS) JSONObject manager) {
return clientManager.listSubMerchantIdApplys(manager, clientMoniker);
return clientManager.listSubMerchantIdApplys(manager,clientMoniker);
}
@ManagerMapping(value = "/{clientMoniker}/list_rpay_sub_applices", method = RequestMethod.GET, role = {ManagerRole.OPERATOR, ManagerRole.ADMIN})
@ -530,27 +535,26 @@ public class PartnerManageController {
@ManagerMapping(value = "/{clientMoniker}/sub_apply", method = RequestMethod.POST, role = {ManagerRole.OPERATOR, ManagerRole.ADMIN})
public String subMerchantApplication(@PathVariable String clientMoniker, @RequestBody SubMerchantIdApply subMerchantIdApply, @ModelAttribute(CommonConsts.MANAGER_STATUS) JSONObject manager) {
return clientManager.subMerchantApplication(clientMoniker, subMerchantIdApply, manager);
return clientManager.subMerchantApplication(clientMoniker,subMerchantIdApply,manager);
}
@ManagerMapping(value = "/{clientMoniker}/get_merchant_ids", method = RequestMethod.GET, role = {ManagerRole.OPERATOR, ManagerRole.ADMIN})
@ManagerMapping(value = "/{clientMoniker}/get_merchant_ids",method = RequestMethod.GET,role = {ManagerRole.OPERATOR,ManagerRole.ADMIN})
public List<JSONObject> getMerchantIds(@PathVariable String clientMoniker, @ModelAttribute(CommonConsts.MANAGER_STATUS) JSONObject manager) {
return clientManager.listMerchantIds(clientMoniker, manager);
return clientManager.listMerchantIds(clientMoniker,manager);
}
@ManagerMapping(value = "/{clientMoniker}/get_sub_merchant_id_logs", method = RequestMethod.GET, role = {ManagerRole.OPERATOR})
@ManagerMapping(value = "/{clientMoniker}/get_sub_merchant_id_logs",method = RequestMethod.GET,role = {ManagerRole.OPERATOR})
public List<JSONObject> getClientSubMerchantIdLogs(@PathVariable String clientMoniker, @ModelAttribute(CommonConsts.MANAGER_STATUS) JSONObject manager) {
return clientManager.getClientSubMerchantIdLogs(clientMoniker, manager);
return clientManager.getClientSubMerchantIdLogs(clientMoniker,manager);
}
@ManagerMapping(value = "/unsub/{clientMoniker}", method = RequestMethod.PUT, role = {ManagerRole.OPERATOR})
@ManagerMapping(value = "/unsub/{clientMoniker}",method = RequestMethod.PUT,role = {ManagerRole.OPERATOR})
public void addSub(@PathVariable String clientMoniker, @ModelAttribute(CommonConsts.MANAGER_STATUS) JSONObject manager) {
clientManager.addSub(clientMoniker, manager);
clientManager.addSub(clientMoniker,manager);
}
@ManagerMapping(value = "/unsub/{clientMoniker}", method = RequestMethod.DELETE, role = {ManagerRole.OPERATOR})
@ManagerMapping(value = "/unsub/{clientMoniker}",method = RequestMethod.DELETE,role = {ManagerRole.OPERATOR})
public void removeSub(@PathVariable String clientMoniker, @ModelAttribute(CommonConsts.MANAGER_STATUS) JSONObject manager) {
clientManager.removeSub(clientMoniker, manager);
clientManager.removeSub(clientMoniker,manager);
}
@ManagerMapping(value = "/{clientMoniker}/hf", method = RequestMethod.PUT, role = {ManagerRole.ADMIN, ManagerRole.OPERATOR})
@ -563,10 +567,4 @@ public class PartnerManageController {
clientManager.switchPermission(manager, clientMoniker, "enable_hf_email_notice", pass.getBooleanValue("allow"));
}
@ManagerMapping(value = "/{clientMoniker}/registRpaySubMerchantId", method = RequestMethod.POST, role = {ManagerRole.OPERATOR, ManagerRole.ADMIN})
public String subRpayMerchantApplication(@PathVariable String clientMoniker, @ModelAttribute(CommonConsts.MANAGER_STATUS) JSONObject manager) {
return clientManager.subRpayMerchantApplication(clientMoniker, manager);
}
}

@ -4,6 +4,8 @@ import au.com.royalpay.payment.manage.mappers.system.MailUnsubMapper;
import au.com.royalpay.payment.manage.merchants.core.ClientManager;
import au.com.royalpay.payment.manage.notice.beans.NoticeBean;
import au.com.royalpay.payment.manage.notice.core.MailService;
import au.com.royalpay.payment.tools.codec.AESCrypt;
import au.com.royalpay.payment.tools.env.SysConfigManager;
import au.com.royalpay.payment.tools.exceptions.BadRequestException;
import au.com.royalpay.payment.tools.exceptions.NotFoundException;
import au.com.royalpay.payment.tools.exceptions.ServerErrorException;
@ -18,6 +20,8 @@ import com.github.miemiedev.mybatis.paginator.domain.PageBounds;
import org.apache.commons.codec.digest.DigestUtils;
import org.apache.commons.lang3.RandomStringUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.commons.net.util.Base64;
import org.jsoup.Jsoup;
import org.jsoup.nodes.Document;
import org.jsoup.nodes.Element;
@ -26,10 +30,13 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import org.springframework.util.Assert;
import org.springframework.web.bind.annotation.RequestMethod;
import java.io.IOException;
import java.net.URISyntaxException;
import java.nio.charset.StandardCharsets;
import java.security.Key;
import java.util.ArrayList;
import java.util.List;
@ -53,7 +60,11 @@ public class MailServiceImp implements MailService {
@Resource
private MailUnsubMapper mailUnsubMapper;
@Resource
private SysConfigManager sysConfigManager;
@Resource
private ClientManager clientManager;
@Value("${app.settle.aes-key}")
private String settleAESKey;
/* @Override
public void sendEmail(NoticeBean noticeBean) {
@ -79,8 +90,8 @@ public class MailServiceImp implements MailService {
public String sendEmailNotice(String notice_id, String title, List<JSONObject> mailTo, String content) throws URISyntaxException, IOException {
List<String> unsubAddress = mailUnsubMapper.getAllAddress();
List<JSONObject> mailToWithoutUnsub = new ArrayList<>();
mailTo.parallelStream().forEach(p->{
if(!unsubAddress.contains(p.getString("mailto"))){
mailTo.parallelStream().forEach(p -> {
if (!unsubAddress.contains(p.getString("mailto"))) {
mailToWithoutUnsub.add(p);
}
});
@ -91,7 +102,7 @@ public class MailServiceImp implements MailService {
String linkHref = link.attr("href");
String linkText = link.text();
Element e = link.previousElementSibling();
if (e!=null && "img".equalsIgnoreCase(e.tagName())) {
if (e != null && "img".equalsIgnoreCase(e.tagName())) {
e.remove();
}
@ -120,17 +131,13 @@ public class MailServiceImp implements MailService {
String postUrl = mailHost + "/mail?" + generateMailSignParam();
HttpRequestResult result = new HttpRequestGenerator(postUrl, RequestMethod.POST).setJSONEntity(noticeBean).execute();
if (result.isSuccess()) {
String mail_id = result.getResponseContentJSONObj().getString("mail_id");
return mail_id;
//System.out.println("send Mail=============="+mail_id);
} else {
throw new ServerErrorException("Error Connection "+result.getStatusCode());
throw new ServerErrorException("Error Connection " + result.getStatusCode());
}
}
@ -201,25 +208,25 @@ public class MailServiceImp implements MailService {
@Override
public JSONObject queryUnsubPageable(JSONObject params, int limit, int page) {
return PageListUtils.buildPageListResult(mailUnsubMapper.queryPageable(params,new PageBounds(page, limit, Order.formString("create_time.desc"))));
return PageListUtils.buildPageListResult(mailUnsubMapper.queryPageable(params, new PageBounds(page, limit, Order.formString("create_time.desc"))));
}
@Override
public void addUnsub(String ClientMoniker) {
JSONObject client = clientManager.getClientInfoByMoniker(ClientMoniker);
if(client==null){
if (client == null) {
throw new NotFoundException("Merchant not Found");
}
JSONObject existRecord = mailUnsubMapper.getOne(null,client.getString("contact_email"));
if(existRecord!=null){
JSONObject existRecord = mailUnsubMapper.getOne(null, client.getString("contact_email"));
if (existRecord != null) {
throw new BadRequestException("Client has already existed");
}
JSONObject record= new JSONObject();
JSONObject record = new JSONObject();
record.put("id", IdUtil.getId());
record.put("address",client.getString("contact_email"));
record.put("client_id",client.getIntValue("client_id"));
record.put("client_moniker",client.getString("client_moniker"));
record.put("address", client.getString("contact_email"));
record.put("client_id", client.getIntValue("client_id"));
record.put("client_moniker", client.getString("client_moniker"));
mailUnsubMapper.save(record);
}
@ -234,8 +241,13 @@ public class MailServiceImp implements MailService {
mailClients.add(mailClient);
noticeBean.setMailClients(mailClients);
noticeBean.setContent(content);
noticeBean.setSenderAddress("settlement@royalpay.com.au");
noticeBean.setPassword("MMKdMn7dJj49jp");
JSONObject sysConfig = sysConfigManager.getSysConfig();
noticeBean.setSenderAddress(sysConfig.getString("settle.email.address"));
String mailPwdEncrypted = sysConfig.getString("settle.email.password");
Assert.isTrue(StringUtils.isNotEmpty(mailPwdEncrypted), "Settlement mail pwd not configured");
Key aesKey = AESCrypt.fromKeyString(Base64.decodeBase64(settleAESKey));
String mailPwd = new String(AESCrypt.decrypt(Base64.decodeBase64(mailPwdEncrypted), aesKey), StandardCharsets.UTF_8);
noticeBean.setPassword(mailPwd);
noticeBean.setAttachFiles(attachFiles);
String postUrl = mailHost + "/mail/single?" + generateMailSignParam();
HttpRequestResult result = null;

@ -0,0 +1,35 @@
package au.com.royalpay.payment.manage.task;
import au.com.royalpay.payment.manage.dev.core.MerchantLocationService;
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;
/**
* Created by wangning on 2018/1/2.
*/
@Component
@ConditionalOnProperty(value = "app.run-tasks", havingValue = "true")
public class initClientLocationTask {
@Resource
private MerchantLocationService merchantLocationService;
@Resource
private SynchronizedScheduler synchronizedScheduler;
@Scheduled(cron = "0 0 5 * * *")
public void checkBillOrderCheck() {
synchronizedScheduler.executeProcess("manage_task:initClientLocation", 120_000, () -> {
try {
merchantLocationService.initClientLocations();
} catch (InterruptedException e) {
e.printStackTrace();
}
});
}
}

@ -1,6 +1,6 @@
server.port=5000
spring.profiles.active=dev,alipay,bestpay,jd,wechat,rpay
spring.profiles.active=dev,alipay,bestpay,jd,wechat
env.company=RoyalPay
@ -115,7 +115,7 @@ royalpay.sms.appkey=43390d81e20c5191c278fbf4cd275be2
im.openim.appkey=24986533
im.openim.secret=96e28e7be21a874177211c31834b5174
app.settle.aes-key=EPrfsM2JE69ZPR7BhXn34g==
#清算银行配置
settle.abafile.default-bank=CBA
settle.abafile.remains-to=ANZ

@ -52,12 +52,18 @@
</select>
<select id="analysisLuckyMoney" resultType="com.alibaba.fastjson.JSONObject">
SELECT COUNT(red_packet_order_id) total_counts,sum(red_packet_amount) total_amount,
ifnull(SUM(if(status=0 AND lock_key is null,1,0)),0) unsend_counts,SUM(if(status=0 AND lock_key is null,red_packet_amount,0)) unsend_amount,
sum(if(status!=0,1,0)) send_counts,SUM(if(status !=0 ,red_packet_amount,0)) send_amount,
sum(if(status=2,1,0)) fail_counts,SUM(if(status=2,red_packet_amount,0)) fail_amount,
sum(if(status=1 or status=3,1,0)) receive_counts,SUM(if(status=1 or status=3,red_packet_amount,0)) receive_amount,
sum(if(status=4,1,0)) return_counts,SUM(if(status=4,red_packet_amount,0)) return_amount
SELECT COUNT(red_packet_order_id) total_counts,
sum(red_packet_amount) total_amount,
ifnull(SUM(if(status=0 AND lock_key is null,1,0)),0) unsend_counts,
SUM(if(status=0 AND lock_key is null,red_packet_amount,0)) unsend_amount,
sum(if(status!=0,1,0)) send_counts,
SUM(if(status !=0 ,red_packet_amount,0)) send_amount,
sum(if(status=2,1,0)) fail_counts,
SUM(if(status=2,red_packet_amount,0)) fail_amount,
sum(if(status=1 or status=3,1,0)) receive_counts,
SUM(if(status=1 or status=3,red_packet_amount,0)) receive_amount,
sum(if(status=4,1,0)) return_counts,
SUM(if(status=4,red_packet_amount,0)) return_amount
FROM act_red_packets_orders
<where>
act_id = #{act_id}
@ -164,7 +170,11 @@
<select id="getRedPacketsByOpenid" resultType="int">
SELECT count(1) FROM act_red_packets_orders WHERE open_id=#{open_id} and date(event_time) = date(#{event_date}) and status !=0 and act_id = '2'
SELECT count(1)
FROM act_red_packets_orders
WHERE open_id=#{open_id}
and date(event_time) = date(#{event_date})
and status !=0 and act_id = '2'
</select>

@ -24,15 +24,19 @@
AND status != 0 AND act_id = #{act_id}
</select>
<!-- 由于在sys_customer_relation中新增了关联字段globalpay_openid
所以重新关联此字段再次left join, 选取其中不为null的
-->
<select id="listOrders" resultType="com.alibaba.fastjson.JSONObject">
SELECT
a.*,
b.client_moniker,
c.headimg,
c.nickname
ifnull(c.headimg, c2.headimg) headimg,
ifnull(c.nickname, c2.nickname) nickname
FROM act_red_packets_customer_orders a
INNER JOIN sys_clients b ON a.client_id = b.client_id
LEFT JOIN sys_customer_relation c ON c.wechat_openid = a.open_id
LEFT JOIN sys_customer_relation c2 ON c2.globalpay_openid = a.open_id
WHERE act_id = #{actId}
<if test="client_moniker != null">
AND b.client_moniker = #{client_moniker}

@ -3,6 +3,7 @@
<configuration>
<settings>
<setting name="safeResultHandlerEnabled" value="false"/>
<setting name="lazyLoadingEnabled" value="true"/>
</settings>
<plugins>

@ -763,6 +763,19 @@ define(['angular', 'decimal', 'static/commons/commons', 'uiBootstrap', 'uiRouter
})
})
};
$scope.revertClient = function () {
commonDialog.confirm({
title: 'Revert Partner',
content: 'Are you sure to Revert ' + $scope.partner.company_name + '?'
}).then(function () {
$http.put('/sys/partners/' + $scope.partner.client_moniker + '/revert').then(function () {
$state.go('^');
commonDialog.alert({title: 'Revert', content: 'Partner Already Revert', type: 'success'});
}, function (resp) {
commonDialog.alert({title: 'Error', content: resp.data.message, type: 'error'});
})
})
};
$scope.commitToCompliance = function () {
commonDialog.confirm({

@ -171,7 +171,6 @@
<li role="presentation" ng-class="{active:bankCtrl.rate_name=='Bestpay'}"><a role="button" ng-click="bankCtrl.rate_name='Bestpay'">Bestpay</a></li>
<li role="presentation" ng-class="{active:bankCtrl.rate_name=='jd'}"><a role="button" ng-click="bankCtrl.rate_name='jd'">JDpay</a></li>
<li role="presentation" ng-class="{active:bankCtrl.rate_name=='hf'}"><a role="button" ng-click="bankCtrl.rate_name='hf'">HFpay</a></li>
<li role="presentation" ng-class="{active:bankCtrl.rate_name=='Rpay'}"><a role="button" ng-click="bankCtrl.rate_name='Rpay'">Rpay+</a></li>
</ul>
<div class="table-responsive">
<table class="table table-bordered">

@ -78,6 +78,7 @@
</b>
<span ng-if="partner.is_valid==0" ng-class="{pass_timeout:partner.is_valid==0}">(已禁用)</span>
</h3>
<button ng-if="!partner.is_valid" type="button" class="btn btn-success" style="float:right;" ng-click="revertClient()">Revert</button>
</div>
<div class="box-body" ng-if="partner.is_valid==1">
<div ng-if="partner.open_status != 5 && partner.open_status!=10">
@ -255,7 +256,7 @@
<a ui-sref=".product">Product</a>
</li>
<li ui-sref-active="active" ng-if="('10'|withRole) && partner.is_valid==1">
<a ui-sref=".sub_merchant_applicaitons">Merchant Id Applicaitons</a>
<a ui-sref=".sub_merchant_applicaitons">Wechat Merchant Id Applicaitons</a>
</li>
<li ui-sref-active="active" ng-if="partner.is_valid==1">
<a ui-sref=".permission_client">Permissions</a>

@ -160,30 +160,6 @@
</div>
</div>
<div class="form-group"
ng-class="{'has-error':rate_form.hf_rate_value.$invalid && rate_form.hf_rate_value.$dirty}">
<label class="control-label col-sm-4" for="Rpay_rate_value_input">Rpay+ Rate Value</label>
<div class="col-sm-6">
<div class="input-group">
<input type="number" name="jd_rate_value" stringToNumber2 class="form-control" ng-model="rate.Rpay_rate_value"
min="0.6" max="2.2" step="0.1" id="Rpay_rate_value_input" required>
<div class="input-group-addon">%</div>
</div>
<div ng-messages="rate_form.hf_rate_value.$error" ng-if="rate_form.hf_rate_value.$dirty">
<div class="small text-danger" ng-message="max">
<i class="glyphicon glyphicon-alert"></i> No more than 2.2%
</div>
<div class="small text-danger" ng-message="min">
<i class="glyphicon glyphicon-alert"></i> No less than 0.6%
</div>
<div class="small text-danger" ng-message="required">
<i class="glyphicon glyphicon-alert"></i> Required Field
</div>
</div>
</div>
</div>
<div class="form-group">
<label class="control-label col-sm-4" for="active_time_input">Active Date</label>
<div class="col-sm-6">

@ -617,6 +617,7 @@ public class CustomerImpressionImplTest {
}
return result;
}
@Test

@ -0,0 +1,29 @@
package au.com.royalpay.payment.manage.process.aes;
import au.com.royalpay.payment.tools.codec.AESCrypt;
import org.apache.commons.net.util.Base64;
import org.junit.Test;
import java.nio.charset.StandardCharsets;
import java.security.Key;
/**
* Create by yixian at 2018-09-17 12:55
*/
public class AESTest {
@Test
public void initAESKey() {
System.out.println(Base64.encodeBase64String(AESCrypt.randomKey().getEncoded()));
}
@Test
public void testEncrypt() {
String keyStr = "EPrfsM2JE69ZPR7BhXn34g==";
String source = "123456";
Key key = AESCrypt.fromKeyString(Base64.decodeBase64(keyStr));
byte[] encrypted = AESCrypt.encrypt(source.getBytes(StandardCharsets.UTF_8), key);
System.out.println("encrypted: " + Base64.encodeBase64String(encrypted));
System.out.println("validate: " + new String(AESCrypt.decrypt(encrypted, key), StandardCharsets.UTF_8));
}
}

@ -28,7 +28,7 @@ public class ExportATOReport {
@Test
public void export() throws IOException {
String content = atoReportService.exportBTTPSFile(DateTime.parse("2017-07-01").toDate(), DateTime.parse("2017-07-31").toDate());
FileUtils.write(new File("C:\\Users\\yixian\\Documents\\royalpay2017070120170731.bttps"), content, StandardCharsets.US_ASCII);
String content = atoReportService.exportBTTPSFile(DateTime.parse("2017-07-01").toDate(), DateTime.parse("2018-06-30").toDate());
FileUtils.write(new File("C:\\Users\\yixian\\Documents\\royalpay2017070120180630.bttps"), content, StandardCharsets.US_ASCII);
}
}

Loading…
Cancel
Save