diff --git a/src/main/java/au/com/royalpay/payment/manage/appclient/core/RetailAppService.java b/src/main/java/au/com/royalpay/payment/manage/appclient/core/RetailAppService.java index a47819a0d..efbe605d6 100644 --- a/src/main/java/au/com/royalpay/payment/manage/appclient/core/RetailAppService.java +++ b/src/main/java/au/com/royalpay/payment/manage/appclient/core/RetailAppService.java @@ -2,19 +2,20 @@ package au.com.royalpay.payment.manage.appclient.core; import au.com.royalpay.payment.manage.appclient.beans.AppClientBean; import au.com.royalpay.payment.manage.appclient.beans.AppQueryBean; +import au.com.royalpay.payment.manage.merchants.beans.ClientAuthFilesInfo; import au.com.royalpay.payment.manage.notice.beans.NoticeInfo; import au.com.royalpay.payment.manage.signin.beans.ChangePwdBean; -import au.com.royalpay.payment.manage.tradelog.beans.TradeLogQuery; import au.com.royalpay.payment.tools.merchants.beans.QRCodeConfig; import au.com.royalpay.payment.tools.merchants.beans.UpdateSurchargeDTO; import com.alibaba.fastjson.JSONObject; -import javax.servlet.http.HttpServletResponse; import java.math.BigDecimal; import java.util.List; import java.util.Map; +import javax.servlet.http.HttpServletResponse; + /** * Created by yishuqian on 28/03/2017. @@ -86,6 +87,10 @@ public interface RetailAppService { JSONObject getClientInfo(JSONObject device); + JSONObject getClientInfoRealtime(JSONObject device); + + JSONObject getClientInfoMe(JSONObject device); + JSONObject updateRetailConfig(JSONObject device, boolean paySurcharge); JSONObject setRequireRemarkConfig(JSONObject device, boolean enabled); @@ -133,4 +138,8 @@ public interface RetailAppService { void getInvoiceFile(JSONObject device, AppQueryBean appQueryBean, HttpServletResponse httpResponse) throws Exception; Map channelAndDayOfAnalysis(int client_id, String clearingDetailId, String channel, JSONObject device); + + JSONObject getAuthFiles(JSONObject device); + + void uploadAuthFiles(JSONObject device,ClientAuthFilesInfo clientAuthFilesInfo); } diff --git a/src/main/java/au/com/royalpay/payment/manage/appclient/core/impls/RetailAppServiceImp.java b/src/main/java/au/com/royalpay/payment/manage/appclient/core/impls/RetailAppServiceImp.java index 046be4ee5..f322e6232 100644 --- a/src/main/java/au/com/royalpay/payment/manage/appclient/core/impls/RetailAppServiceImp.java +++ b/src/main/java/au/com/royalpay/payment/manage/appclient/core/impls/RetailAppServiceImp.java @@ -20,9 +20,11 @@ import au.com.royalpay.payment.manage.mappers.payment.OrderMapper; import au.com.royalpay.payment.manage.mappers.payment.TransactionMapper; import au.com.royalpay.payment.manage.mappers.system.ClientAccountMapper; import au.com.royalpay.payment.manage.mappers.system.ClientDeviceTokenMapper; +import au.com.royalpay.payment.manage.mappers.system.ClientMapper; import au.com.royalpay.payment.manage.mappers.system.ClientSettleDelayConfMapper; import au.com.royalpay.payment.manage.mappers.system.CustomerMapper; import au.com.royalpay.payment.manage.mappers.system.ManagerCustomerRelationAlipayMapper; +import au.com.royalpay.payment.manage.merchants.beans.ClientAuthFilesInfo; import au.com.royalpay.payment.manage.merchants.core.ClientConfigService; import au.com.royalpay.payment.manage.merchants.core.ClientManager; import au.com.royalpay.payment.manage.notice.beans.NoticeInfo; @@ -156,8 +158,13 @@ public class RetailAppServiceImp implements RetailAppService { private CleanService cleanService; @Resource private ClientConfigService clientConfigService; + @Resource + private ClientMapper clientMapper; private Map senderMap = new HashMap<>(); + private final String fileName[] = { "source_agree_file", "client_bank_file", "client_id_file", "client_agree_file", "client_company_file", + "client_apply_file" }; + @Resource public void setAppMsgSenders(AppMsgSender[] senders) { Arrays.stream(senders).forEach(appMsgSender -> senderMap.put(appMsgSender.devType(), appMsgSender)); @@ -245,7 +252,7 @@ public class RetailAppServiceImp implements RetailAppService { } @Override - public JSONObject getQrcode(JSONObject device, QRCodeConfig config,int client_id) { + public JSONObject getQrcode(JSONObject device, QRCodeConfig config, int client_id) { JSONObject client = merchantInfoProvider.getClientInfo(client_id); String url = PlatformEnvironment.getEnv().concatUrl("/api/payment/v1.0/partners/" + client.getString("client_moniker")); if (config.isCNY()) { @@ -255,7 +262,8 @@ public class RetailAppServiceImp implements RetailAppService { JSONObject res = new JSONObject(); res.put("url", url); res.put("qrcode", QRCodeUtils.qrcodeImageCode(url, 250, false)); -// res.put("qrcode_board", merchantInfoProvider.getQrCodeBoard(client, config,clientAccountMapper.findById(device.getString("account_id")),"APP")); + // res.put("qrcode_board", merchantInfoProvider.getQrCodeBoard(client, + // config,clientAccountMapper.findById(device.getString("account_id")),"APP")); res.put("qrcode_board", merchantInfoProvider.getQrCodeBoard(client, config)); return res; } @@ -263,14 +271,14 @@ public class RetailAppServiceImp implements RetailAppService { @Override public void changeSurchargeEnable(JSONObject device, UpdateSurchargeDTO updateSurchargeDTO) { - merchantInfoProvider.changeSurchargeEnable(device,updateSurchargeDTO); + merchantInfoProvider.changeSurchargeEnable(device, updateSurchargeDTO); } @Override public JSONObject getInvoiceData(JSONObject device, AppQueryBean appQueryBean) throws Exception { String clientType = device.getString("client_type"); deviceSupport.findRegister(clientType); - int client_id = device.getIntValue("client_id") ; + int client_id = device.getIntValue("client_id"); JSONObject client = clientManager.getClientInfo(client_id); String timezone = client.getString("timezone"); appQueryBean.setTimezone(timezone); @@ -280,7 +288,7 @@ public class RetailAppServiceImp implements RetailAppService { params.put("client_id", client_id); JSONObject analysis = transactionMapper.analysisTransFlow(params); BigDecimal total_surcharge = analysis.getBigDecimal("total_surcharge").add(analysis.getBigDecimal("tax_amount")); - analysis.put("total_surcharge",total_surcharge); + analysis.put("total_surcharge", total_surcharge); return analysis; } @@ -288,24 +296,38 @@ public class RetailAppServiceImp implements RetailAppService { public void getInvoiceFile(JSONObject device, AppQueryBean appQueryBean, HttpServletResponse httpResponse) throws Exception { String clientType = device.getString("client_type"); deviceSupport.findRegister(clientType); - int client_id = device.getIntValue("client_id") ; + int client_id = device.getIntValue("client_id"); JSONObject client = clientManager.getClientInfo(client_id); - device.put("client_moniker",client.getString("client_moniker")); + device.put("client_moniker", client.getString("client_moniker")); TradeLogQuery tradeLogQuery = new TradeLogQuery(); tradeLogQuery.setDatefrom(appQueryBean.getBegin()); tradeLogQuery.setDateto(appQueryBean.getEnd()); - if (appQueryBean.getApp_client_ids()==null){ + if (appQueryBean.getApp_client_ids() == null) { appQueryBean.setApp_client_ids(String.valueOf(client_id)); } tradeLogQuery.setClient_ids(appQueryBean.getApp_client_ids().split(",")); - tradeLogService.exportTransFlow(tradeLogQuery,device,httpResponse); + tradeLogService.exportTransFlow(tradeLogQuery, device, httpResponse); } @Override public Map channelAndDayOfAnalysis(int client_id, String clearingDetailId, String channel, JSONObject device) { String clientType = device.getString("client_type"); deviceSupport.findRegister(clientType); - return cleanService.channelAndDayOfAnalysis(client_id, clearingDetailId,channel,device.getJSONObject("client")); + return cleanService.channelAndDayOfAnalysis(client_id, clearingDetailId, channel, device.getJSONObject("client")); + } + + @Override + public JSONObject getAuthFiles(JSONObject device) { + JSONObject client = clientManager.getClientInfo(device.getIntValue("client_id")); + JSONObject account = clientAccountMapper.findById(device.getString("account_id")); + return clientManager.getAuthFiles(account,client.getString("client_moniker")); + } + + @Override + public void uploadAuthFiles(JSONObject device, ClientAuthFilesInfo clientAuthFilesInfo) { + JSONObject client = clientManager.getClientInfo(device.getIntValue("client_id")); + JSONObject account = clientAccountMapper.findById(device.getString("account_id")); + clientManager.uploadAuthFiles(account,client.getString("client_moniker"),clientAuthFilesInfo); } @Override @@ -316,7 +338,7 @@ public class RetailAppServiceImp implements RetailAppService { if (device.getIntValue("client_id") != account.getIntValue("client_id") || PartnerRole.getRole(account.getIntValue("role")) == PartnerRole.CASHIER) { throw new ForbiddenException("You have no permission"); } - clientManager.updateAppClient(account,device.getIntValue("client_id"), appClientBean); + clientManager.updateAppClient(account, device.getIntValue("client_id"), appClientBean); } @@ -334,6 +356,27 @@ public class RetailAppServiceImp implements RetailAppService { return res; } + @Override + public JSONObject getClientInfoRealtime(JSONObject device) { + return clientMapper.findClient(device.getIntValue("client_id")); + } + + @Override + public JSONObject getClientInfoMe(JSONObject device) { + JSONObject result = new JSONObject(); + JSONObject client = clientMapper.findClient(device.getIntValue("client_id")); + if (client.getString("store_photo") == null || client.getString("logo_url") == null || client.getString("company_photo") == null) { + result.put("base_info_lack", true); + } + JSONObject file = clientManager.getAuthFiles(null, client.getString("client_moniker")); + for (String s : fileName) { + if (file.getString(s) == null) { + result.put("compliance_info_lack", true); + } + } + return result; + } + @Override public JSONObject updateRetailConfig(JSONObject device, boolean clientPaySurcharge) { JSONObject user = userInfo(device); @@ -369,7 +412,7 @@ public class RetailAppServiceImp implements RetailAppService { user = JSON.parseObject(user.toJSONString()); return user; } else { - JSONObject clientWithConfig =clientManager.getClientInfo(device.getIntValue("client_id")); + JSONObject clientWithConfig = clientManager.getClientInfo(device.getIntValue("client_id")); clientWithConfig.putAll(clientConfigService.find(device.getIntValue("client_id"))); clientWithConfig = SignInAccountServiceImpl.clientInfoWithNoSecretInfo(clientWithConfig); clientWithConfig.put("terminal_id", device.getString("client_dev_id")); @@ -394,16 +437,16 @@ public class RetailAppServiceImp implements RetailAppService { params.put("client_id", client_id); PageList logs = clearingDetailMapper.listClientSettlementLog(params, new PageBounds(appQueryBean.getPage(), appQueryBean.getLimit(), Order.formString("report_date.desc"))); - logs.forEach(log -> log.put("total_charge",log.getBigDecimal("total_charge").add(log.getBigDecimal("tax_amount")))); + logs.forEach(log -> log.put("total_charge", log.getBigDecimal("total_charge").add(log.getBigDecimal("tax_amount")))); JSONObject result = PageListUtils.buildPageListResult(logs); - if (appQueryBean.getPage()==1){ - if (!logs.isEmpty() && logs.size()>0){ + if (appQueryBean.getPage() == 1) { + if (!logs.isEmpty() && logs.size() > 0) { JSONObject sendMailLog = logSettleMailMapper.findByDate(logs.get(0).getDate("report_date")); if (sendMailLog == null) { - result.put("padding",true); + result.put("padding", true); } - if (sendMailLog!=null && sendMailLog.getIntValue("mail_status") != 1) { - result.put("padding",true); + if (sendMailLog != null && sendMailLog.getIntValue("mail_status") != 1) { + result.put("padding", true); } } } @@ -427,7 +470,7 @@ public class RetailAppServiceImp implements RetailAppService { List channels = clearingDetailAnalysisMapper.listReportChannels(String.valueOf(clearing_detail_id)); JSONObject channelsObj = new JSONObject(); for (JSONObject channel : channels) { - channel.put("total_charge",channel.getBigDecimal("total_charge").add(channel.getBigDecimal("tax_amount"))); + channel.put("total_charge", channel.getBigDecimal("total_charge").add(channel.getBigDecimal("tax_amount"))); channelsObj.put(channel.getString("channel"), channel); } List credit = new ArrayList<>(); @@ -1131,7 +1174,7 @@ public class RetailAppServiceImp implements RetailAppService { } @Override - public JSONObject listDailyTransactions(String dateStr, String timezone, boolean thisDevOnly, JSONObject device,String app_client_ids) { + public JSONObject listDailyTransactions(String dateStr, String timezone, boolean thisDevOnly, JSONObject device, String app_client_ids) { try { JSONObject client = clientManager.getClientInfo(device.getIntValue("client_id")); SimpleDateFormat dateFormat = new SimpleDateFormat("yyyyMMdd"); @@ -1144,30 +1187,30 @@ public class RetailAppServiceImp implements RetailAppService { devId = device.getString("dev_id"); } Date to = DateUtils.addDays(date, 1); - String [] param_client_ids = null; - if(StringUtils.isEmpty(app_client_ids)) { + String[] param_client_ids = null; + if (StringUtils.isEmpty(app_client_ids)) { JSONArray client_ids = clientManager.getAllClientIds(device.getIntValue("client_id")); if (client_ids.size() > 1) { param_client_ids = new String[client_ids.size()]; client_ids.toArray(param_client_ids); } - }else { + } else { param_client_ids = app_client_ids.split(","); } - List transactions = transactionMapper.listDailyTransactions(date, to, devId, device.getIntValue("client_id"),param_client_ids); + List transactions = transactionMapper.listDailyTransactions(date, to, devId, device.getIntValue("client_id"), param_client_ids); if (transactions.isEmpty()) { throw new BadRequestException("No Transactions in date " + dateStr + " at " + timezone); } TimeZoneUtils.switchTimeZoneToString(transactions, timezone, "HH:mm:ss", Collections.singletonList("transaction_time")); BigDecimal display_amount = BigDecimal.ZERO; BigDecimal cny_display_amount = BigDecimal.ZERO; - for (JSONObject transaction:transactions){ - if (PlatformEnvironment.getEnv().getForeignCurrency().equals(transaction.getString("currency"))){ - if ("Credit".equals(transaction.getString("transaction_type"))){ + for (JSONObject transaction : transactions) { + if (PlatformEnvironment.getEnv().getForeignCurrency().equals(transaction.getString("currency"))) { + if ("Credit".equals(transaction.getString("transaction_type"))) { display_amount = display_amount.add(transaction.getBigDecimal("display_amount")); } - }else { - if ("Credit".equals(transaction.getString("transaction_type"))){ + } else { + if ("Credit".equals(transaction.getString("transaction_type"))) { cny_display_amount = cny_display_amount.add(transaction.getBigDecimal("display_amount")); } } @@ -1175,12 +1218,10 @@ public class RetailAppServiceImp implements RetailAppService { JSONObject res = new JSONObject(); res.put("transactions", transactions); - - - JSONObject analysis = transactionMapper.analysisRetailDailyReport(date, to, devId, device.getIntValue("client_id"),param_client_ids); + JSONObject analysis = transactionMapper.analysisRetailDailyReport(date, to, devId, device.getIntValue("client_id"), param_client_ids); analysis.put("date", TimeZoneUtils.formatTime(date, "dd/MMM/yyyy", timezone)); - analysis.put("display_amount",display_amount); - analysis.put("cny_display_amount",cny_display_amount); + analysis.put("display_amount", display_amount); + analysis.put("cny_display_amount", cny_display_amount); res.put("analysis", analysis); return res; } catch (ParseException e) { @@ -1238,19 +1279,19 @@ public class RetailAppServiceImp implements RetailAppService { Boolean isUpdate = PlatformEnvironment.getEnv().isAppUpdate(clientType); String updateContent = PlatformEnvironment.getEnv().getAppUpdateContent(clientType); int update_type = 0;// 0:不更新 1:更新 2:强制更新 - String [] oldVersion = version.split("\\."); - String [] newVersion = newAppVersion.split("\\."); + String[] oldVersion = version.split("\\."); + String[] newVersion = newAppVersion.split("\\."); JSONObject res = new JSONObject(); res.put("update_content", updateContent); for (int i = 0; i < newVersion.length; i++) { - if(Integer.valueOf(newVersion[i])>Integer.valueOf(oldVersion[i])){ + if (Integer.valueOf(newVersion[i]) > Integer.valueOf(oldVersion[i])) { update_type = 1; if (isUpdate) { update_type = 2; } res.put("update_type", update_type); return res; - }else if(Integer.valueOf(newVersion[i])