diff --git a/src/db/modify.sql b/src/db/modify.sql index bbf38a50d..390efea1f 100644 --- a/src/db/modify.sql +++ b/src/db/modify.sql @@ -314,4 +314,26 @@ ALTER TABLE `sys_customer_relation` ADD COLUMN `globalpay_openid` varchar(100) NULL AFTER `kanga_openid`; -ALTER TABLE act_app_list ADD banner_img VARCHAR(200) NULL COMMENT 'App首页banner图片'; \ No newline at end of file +ALTER TABLE act_app_list ADD banner_img VARCHAR(200) NULL COMMENT 'App首页banner图片'; + + +alter table act_app_list add column `msg_start_date` date DEFAULT NULL; +alter table act_app_list add column `msg_end_date` date DEFAULT NULL; +alter table act_app_list add column `msg_interval` smallint(3) DEFAULT NULL; + +alter table sys_clients add column `manual_settle` tinyint(1) DEFAULT 0; + + +create table log_clients_operation( +id varchar(50) not null, +client_id int(11) not null, +operator_id varchar(50) not null comment '操作人者 账户ID', +operator_type SMALLINT (2) not null comment '操作人者类型', +create_time datetime not null, +operation varchar(50) DEFAULT NULL, +PRIMARY key(`id`) +); +alter table act_app_list MODIFY column is_show_window tinyint(1) DEFAULT 0 COMMENT 'app是否弹框' + + +alter table sys_clients_contract add column confirm_time datetime DEFAULT null comment '合同确认时间'; \ No newline at end of file diff --git a/src/main/java/au/com/royalpay/payment/manage/activities/app_index/beans/AppActBean.java b/src/main/java/au/com/royalpay/payment/manage/activities/app_index/beans/AppActBean.java index 1ede5f853..6ed065c33 100644 --- a/src/main/java/au/com/royalpay/payment/manage/activities/app_index/beans/AppActBean.java +++ b/src/main/java/au/com/royalpay/payment/manage/activities/app_index/beans/AppActBean.java @@ -1,12 +1,11 @@ package au.com.royalpay.payment.manage.activities.app_index.beans; import au.com.royalpay.payment.core.exceptions.ParamInvalidException; + import com.alibaba.fastjson.JSONObject; -import org.apache.commons.lang3.StringUtils; + import org.apache.commons.lang3.time.DateUtils; -import org.springframework.data.redis.serializer.Jackson2JsonRedisSerializer; -import javax.xml.crypto.Data; import java.text.ParseException; import java.util.Date; @@ -18,47 +17,37 @@ public class AppActBean { private String act_name; private String act_url; private String params_json; - private Boolean is_valid = true; + private boolean is_valid = true; private String desc; private String act_content; private String show_type; - private Boolean is_show_window; + private boolean is_show_window; private String act_img; private String window_img; private String active_date; private String expire_date; private String banner_img; + private String msg_start_date; + private String msg_end_date; + private String msg_interval; public JSONObject toJsonParam(){ JSONObject params = new JSONObject(); - if(StringUtils.isNotEmpty(act_name)){ - params.put("act_name",act_name); - } - if(StringUtils.isNotEmpty(act_url)){ - params.put("act_url",act_url); - } - if(StringUtils.isNotEmpty(params_json)){ - params.put("params_json",params_json); - } - if(StringUtils.isNotEmpty(desc)){ - params.put("desc",desc); - } - if(StringUtils.isNotEmpty(act_content)){ - params.put("act_content",act_content); - } - if(StringUtils.isNotEmpty(show_type)){ - params.put("show_type",show_type); - } - if(StringUtils.isNotEmpty(act_img)){ - params.put("act_img",act_img); - } - if(StringUtils.isNotEmpty(window_img)){ - params.put("window_img",window_img); - } - if(StringUtils.isNotEmpty(banner_img)){ - params.put("banner_img",banner_img); - } + params.put("act_name",act_name); + params.put("act_url",act_url); + params.put("params_json",params_json); + params.put("desc",desc); + params.put("act_content",act_content); + params.put("show_type",show_type); + params.put("act_img",act_img); + params.put("window_img",window_img); + params.put("banner_img",banner_img); + params.put("msg_interval",msg_interval); + params.put("is_show_window",is_show_window); + params.put("is_valid",is_valid); + params.put("msg_start_date", msg_start_date); + params.put("msg_end_date", msg_end_date); if (active_date != null) { try { Date fromDate = DateUtils.parseDate(active_date, DATE_PATTERNS); @@ -75,8 +64,22 @@ public class AppActBean { throw new ParamInvalidException("expire_date", "error.payment.valid.invalid_date_format"); } } - params.put("is_show_window",is_show_window); - params.put("is_valid",is_valid); + if (msg_start_date != null) { + try { + Date fromDate = DateUtils.parseDate(msg_start_date, DATE_PATTERNS); + params.put("msg_start_date", fromDate); + } catch (ParseException e) { + throw new ParamInvalidException("msg_start_date", "error.payment.valid.invalid_date_format"); + } + } + if (msg_end_date != null) { + try { + Date fromDate = DateUtils.parseDate(msg_end_date, DATE_PATTERNS); + params.put("msg_end_date", fromDate); + } catch (ParseException e) { + throw new ParamInvalidException("msg_end_date", "error.payment.valid.invalid_date_format"); + } + } return params; } @@ -183,4 +186,28 @@ public class AppActBean { public void setBanner_img(String banner_img) { this.banner_img = banner_img; } + + public String getMsg_start_date() { + return msg_start_date; + } + + public void setMsg_start_date(String msg_start_date) { + this.msg_start_date = msg_start_date; + } + + public String getMsg_end_date() { + return msg_end_date; + } + + public void setMsg_end_date(String msg_end_date) { + this.msg_end_date = msg_end_date; + } + + public String getMsg_interval() { + return msg_interval; + } + + public void setMsg_interval(String msg_interval) { + this.msg_interval = msg_interval; + } } diff --git a/src/main/java/au/com/royalpay/payment/manage/activities/app_index/core/AppActService.java b/src/main/java/au/com/royalpay/payment/manage/activities/app_index/core/AppActService.java index 39f1f771e..ba05e6552 100644 --- a/src/main/java/au/com/royalpay/payment/manage/activities/app_index/core/AppActService.java +++ b/src/main/java/au/com/royalpay/payment/manage/activities/app_index/core/AppActService.java @@ -20,4 +20,6 @@ public interface AppActService { void updateAct(JSONObject manager,String act_id,AppActBean appActBean); JSONObject getLatestWindowNotice(); + + void published(JSONObject manager,String act_id,boolean is_valid); } diff --git a/src/main/java/au/com/royalpay/payment/manage/activities/app_index/core/impls/AppActServiceImp.java b/src/main/java/au/com/royalpay/payment/manage/activities/app_index/core/impls/AppActServiceImp.java index f100e4d72..741f07747 100644 --- a/src/main/java/au/com/royalpay/payment/manage/activities/app_index/core/impls/AppActServiceImp.java +++ b/src/main/java/au/com/royalpay/payment/manage/activities/app_index/core/impls/AppActServiceImp.java @@ -67,4 +67,13 @@ public class AppActServiceImp implements AppActService { actAppMapper.newAppAct(params); return params; } + + @Override + public void published(JSONObject manager, String act_id, boolean is_valid) { + JSONObject params = new JSONObject(); + params.put("act_id",act_id); + params.put("is_valid",is_valid); + params.put("update_time",new Date()); + actAppMapper.updateAct(params); + } } diff --git a/src/main/java/au/com/royalpay/payment/manage/activities/app_index/web/AppActController.java b/src/main/java/au/com/royalpay/payment/manage/activities/app_index/web/AppActController.java index bd9d190b6..1bd08b431 100644 --- a/src/main/java/au/com/royalpay/payment/manage/activities/app_index/web/AppActController.java +++ b/src/main/java/au/com/royalpay/payment/manage/activities/app_index/web/AppActController.java @@ -3,15 +3,21 @@ package au.com.royalpay.payment.manage.activities.app_index.web; import au.com.royalpay.payment.manage.activities.app_index.beans.AppActBean; import au.com.royalpay.payment.manage.activities.app_index.beans.AppActQueryBean; import au.com.royalpay.payment.manage.activities.app_index.core.AppActService; -import au.com.royalpay.payment.manage.activities.monsettledelay.beans.MonDelayBean; import au.com.royalpay.payment.manage.permission.manager.ManagerMapping; import au.com.royalpay.payment.tools.CommonConsts; import au.com.royalpay.payment.tools.permission.enums.ManagerRole; import au.com.royalpay.payment.tools.utils.PageListUtils; + import com.alibaba.fastjson.JSONObject; import com.github.miemiedev.mybatis.paginator.domain.PageList; + import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.web.bind.annotation.*; +import org.springframework.web.bind.annotation.ModelAttribute; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestMethod; +import org.springframework.web.bind.annotation.RestController; @RestController @RequestMapping("/manager/app/act") @@ -31,7 +37,7 @@ public class AppActController { return appActService.getActDetail(manager,act_id); } - @ManagerMapping(value = "/new",method = RequestMethod.PUT,role = ManagerRole.SITE_MANAGER) + @ManagerMapping(method = RequestMethod.PUT,role = ManagerRole.SITE_MANAGER) public JSONObject newAppAct(@ModelAttribute(CommonConsts.MANAGER_STATUS) JSONObject manager, @RequestBody AppActBean appActBean){ return appActService.newAppAct(manager,appActBean); } @@ -39,4 +45,9 @@ public class AppActController { public void updateAppAct(@ModelAttribute(CommonConsts.MANAGER_STATUS) JSONObject manager, @PathVariable String act_id,@RequestBody AppActBean appActBean){ appActService.updateAct(manager,act_id,appActBean); } + + @ManagerMapping(value = "/published/{act_id}",method = RequestMethod.PUT,role = ManagerRole.SITE_MANAGER) + public void publishedAppAct(@ModelAttribute(CommonConsts.MANAGER_STATUS) JSONObject manager, @PathVariable String act_id,@RequestBody boolean is_valid){ + appActService.published(manager,act_id,is_valid); + } } diff --git a/src/main/java/au/com/royalpay/payment/manage/activities/monsettledelay/core/impls/ActMonDelaySettleServiceImp.java b/src/main/java/au/com/royalpay/payment/manage/activities/monsettledelay/core/impls/ActMonDelaySettleServiceImp.java index 0d7342475..cabb285fe 100644 --- a/src/main/java/au/com/royalpay/payment/manage/activities/monsettledelay/core/impls/ActMonDelaySettleServiceImp.java +++ b/src/main/java/au/com/royalpay/payment/manage/activities/monsettledelay/core/impls/ActMonDelaySettleServiceImp.java @@ -4,9 +4,12 @@ import au.com.royalpay.payment.manage.activities.monsettledelay.core.ActMonDelay import au.com.royalpay.payment.manage.mappers.act.ActAppMapper; import au.com.royalpay.payment.manage.mappers.act.ActMonDelaySettleMapper; import au.com.royalpay.payment.manage.mappers.act.ActMonDelaySettleRedPackMapper; +import au.com.royalpay.payment.manage.mappers.log.ClientsOperationLogMapper; import au.com.royalpay.payment.manage.mappers.system.ClientAccountMapper; +import au.com.royalpay.payment.manage.merchants.core.ClientManager; import au.com.royalpay.payment.tools.device.DeviceSupport; import au.com.royalpay.payment.tools.env.PlatformEnvironment; +import au.com.royalpay.payment.tools.env.RequestEnvironment; import au.com.royalpay.payment.tools.exceptions.BadRequestException; import au.com.royalpay.payment.tools.exceptions.ForbiddenException; import au.com.royalpay.payment.tools.permission.enums.PartnerRole; @@ -17,7 +20,9 @@ import com.github.miemiedev.mybatis.paginator.domain.Order; import com.github.miemiedev.mybatis.paginator.domain.PageBounds; import com.github.miemiedev.mybatis.paginator.domain.PageList; +import org.springframework.context.MessageSource; import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; import org.springframework.util.Assert; import java.math.BigDecimal; @@ -40,12 +45,15 @@ public class ActMonDelaySettleServiceImp implements ActMonDelaySettleService { private ClientAccountMapper clientAccountMapper; @Resource private ActAppMapper actAppMapper; - + @Resource + private ClientsOperationLogMapper clientsOperationLogMapper; + @Resource + private ClientManager clientManager; + @Resource + private MessageSource messageSource; @Override public JSONObject getActNotice(JSONObject device) { - String clientType = device.getString("client_type"); - deviceSupport.findRegister(clientType); int client_id = device.getIntValue("client_id"); BigDecimal total_redpack = actMonDelaySettleRedPackMapper.getTotalRedPack(client_id); JSONObject res = new JSONObject(); @@ -62,15 +70,14 @@ public class ActMonDelaySettleServiceImp implements ActMonDelaySettleService { if (!act.getBoolean("is_valid")) { throw new BadRequestException("Activity is not valid"); } - String clientType = device.getString("client_type"); - deviceSupport.findRegister(clientType); int client_id = device.getIntValue("client_id"); List clientLogs = actMonDelaySettleMapper.clientLog(client_id); JSONObject res = new JSONObject(); res.put("operation_pause",false); - Boolean apply = false; - if (!clientLogs.isEmpty()) { - apply = true; + Boolean apply = true; + if (clientLogs.isEmpty()) { + apply = false; + res.put("cancel_waring",messageSource.getMessage("sys.mondelay.cancel.waring", null, RequestEnvironment.getLocale())); } if (new Date().compareTo(act.getDate("active_date")) < 0) { res.put("active", false); @@ -92,10 +99,12 @@ public class ActMonDelaySettleServiceImp implements ActMonDelaySettleService { res.put("apply", apply); res.put("total_redpack", total_redpack); res.put("list", list); + return res; } @Override + @Transactional public void actApply(JSONObject device) { LocalDateTime dt = LocalDateTime.now(); if(dt.getDayOfWeek()== DayOfWeek.MONDAY && dt.getHour()<18){ @@ -112,8 +121,6 @@ public class ActMonDelaySettleServiceImp implements ActMonDelaySettleService { if (new Date().compareTo(act.getDate("expire_date")) > 0) { throw new BadRequestException("The activity has expired"); } - String clientType = device.getString("client_type"); - deviceSupport.findRegister(clientType); int client_id = device.getIntValue("client_id"); List clientLogs = actMonDelaySettleMapper.clientLog(client_id); if (!clientLogs.isEmpty()) { @@ -129,16 +136,19 @@ public class ActMonDelaySettleServiceImp implements ActMonDelaySettleService { device.put("rate", params.getBigDecimal("rate") == null ? new BigDecimal(0.15) : params.getBigDecimal("rate")); device.put("expire_time", act.getDate("expire_date")); actMonDelaySettleMapper.save(device); + clientManager.changeManualSettle(client_id,true,device.getString("account_id"),1,"参加活动打开手动清算"); + } + + @Override + @Transactional public void cancelAct(JSONObject device) { LocalDateTime dt = LocalDateTime.now(); if(dt.getDayOfWeek()== DayOfWeek.MONDAY && dt.getHour()<18){ throw new BadRequestException("每周一0点至18点为收益计算时间,暂停退出活动操作"); } - String clientType = device.getString("client_type"); - deviceSupport.findRegister(clientType); int client_id = device.getIntValue("client_id"); List clientLogs = actMonDelaySettleMapper.clientLog(client_id); if (clientLogs.isEmpty()) { @@ -148,6 +158,8 @@ public class ActMonDelaySettleServiceImp implements ActMonDelaySettleService { clientLog.put("is_valid", 0); clientLog.put("expire_time", new Date()); actMonDelaySettleMapper.update(clientLog); + clientManager.changeManualSettle(client_id,false,device.getString("account_id"),1,"退出活动关闭手动清算"); } + } diff --git a/src/main/java/au/com/royalpay/payment/manage/analysis/core/impls/DashboardServiceImpl.java b/src/main/java/au/com/royalpay/payment/manage/analysis/core/impls/DashboardServiceImpl.java index 67b3206ca..248197b91 100644 --- a/src/main/java/au/com/royalpay/payment/manage/analysis/core/impls/DashboardServiceImpl.java +++ b/src/main/java/au/com/royalpay/payment/manage/analysis/core/impls/DashboardServiceImpl.java @@ -1,5 +1,28 @@ package au.com.royalpay.payment.manage.analysis.core.impls; +import au.com.royalpay.payment.core.exceptions.ParamInvalidException; +import au.com.royalpay.payment.manage.analysis.beans.AnalysisBean; +import au.com.royalpay.payment.manage.analysis.core.DashboardAnalysisTask; +import au.com.royalpay.payment.manage.analysis.core.DashboardService; +import au.com.royalpay.payment.manage.analysis.mappers.ClientAnalysisMapper; +import au.com.royalpay.payment.manage.analysis.mappers.CustomerAndOrdersStatisticsMapper; +import au.com.royalpay.payment.manage.analysis.mappers.TransactionAnalysisMapper; +import au.com.royalpay.payment.manage.mappers.system.ClientMapper; +import au.com.royalpay.payment.manage.mappers.system.ExchangeRateMapper; +import au.com.royalpay.payment.manage.merchants.core.ClientManager; +import au.com.royalpay.payment.tools.defines.TradeType; + +import com.alibaba.fastjson.JSONObject; +import com.github.miemiedev.mybatis.paginator.domain.Order; +import com.github.miemiedev.mybatis.paginator.domain.PageBounds; + +import org.apache.commons.lang3.time.DateUtils; +import org.apache.commons.lang3.time.DurationFormatUtils; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.cache.annotation.Cacheable; +import org.springframework.stereotype.Service; + import java.text.DateFormat; import java.text.ParseException; import java.text.SimpleDateFormat; @@ -12,28 +35,6 @@ import java.util.TreeMap; import javax.annotation.Resource; -import org.apache.commons.lang3.time.DateUtils; -import org.apache.commons.lang3.time.DurationFormatUtils; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.cache.annotation.Cacheable; -import org.springframework.stereotype.Service; - -import com.alibaba.fastjson.JSONObject; -import com.github.miemiedev.mybatis.paginator.domain.Order; -import com.github.miemiedev.mybatis.paginator.domain.PageBounds; - -import au.com.royalpay.payment.core.exceptions.ParamInvalidException; -import au.com.royalpay.payment.manage.analysis.beans.AnalysisBean; -import au.com.royalpay.payment.manage.analysis.core.DashboardAnalysisTask; -import au.com.royalpay.payment.manage.analysis.core.DashboardService; -import au.com.royalpay.payment.manage.analysis.mappers.ClientAnalysisMapper; -import au.com.royalpay.payment.manage.analysis.mappers.CustomerAndOrdersStatisticsMapper; -import au.com.royalpay.payment.manage.analysis.mappers.TransactionAnalysisMapper; -import au.com.royalpay.payment.manage.mappers.system.ClientMapper; -import au.com.royalpay.payment.manage.merchants.core.ClientManager; -import au.com.royalpay.payment.tools.defines.TradeType; - /** * Created by davep on 2016-07-28. */ @@ -50,6 +51,8 @@ public class DashboardServiceImpl implements DashboardService,DashboardAnalysisT private ClientMapper clientMapper; @Resource private CustomerAndOrdersStatisticsMapper customerAndOrdersStatisticsMapper; + @Resource + private ExchangeRateMapper exchangeRateMapper; @Override public JSONObject getCommonAnalysis1(JSONObject params) { @@ -323,7 +326,8 @@ public class DashboardServiceImpl implements DashboardService,DashboardAnalysisT } public void channelsExchangeRate(Date beginDate,Date endDate,Map exchangeRateMap, String channel){ - List channelRates = transactionAnalysisMapper.listExchangeRates(beginDate, endDate,channel); + + List channelRates = exchangeRateMapper.listExchangeRates(beginDate, endDate,channel); for (JSONObject analysisItem:channelRates){ Date date = analysisItem.getDate("date"); JSONObject dataItem = exchangeRateMap.get(date); 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 0f1f5213b..309a2af8f 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 @@ -115,4 +115,6 @@ public interface RetailAppService { JSONObject getCheckClientInfo(JSONObject device); + void changeManualSettle(JSONObject device,boolean manual_settle); + } 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 857e5d35a..c8712b21d 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 @@ -438,8 +438,8 @@ public class RetailAppServiceImp implements RetailAppService { break; } Calendar calendar = (Calendar) order.get("transaction_time"); - String trade_date = DateFormatUtils.format(calendar, "yyyy-MM-dd"); - String trade_time = DateFormatUtils.format(calendar, "HH:mm:ss"); + String trade_date = DateFormatUtils.format(calendar, "yyyy-MM-dd",calendar.getTimeZone()); + String trade_time = DateFormatUtils.format(calendar, "HH:mm:ss",calendar.getTimeZone()); order.put("trade_date", trade_date); order.put("trade_time", trade_time); // todo @@ -1385,6 +1385,11 @@ public class RetailAppServiceImp implements RetailAppService { return clientManager.getCheckClientInfo(device.getIntValue("client_id"), device.getString("account_id")); } + @Override + public void changeManualSettle(JSONObject device,boolean manual_settle) { + clientManager.changeManualSettle(device.getIntValue("client_id"),manual_settle,device.getString("account_id"),1,"商户修改手动清算配置"); + } + private static boolean mathchLetterorNum(String str) { String regex = "[A-Za-z0-9]{8}"; return str.matches(regex); diff --git a/src/main/java/au/com/royalpay/payment/manage/appclient/web/RetailAppController.java b/src/main/java/au/com/royalpay/payment/manage/appclient/web/RetailAppController.java index e6dea762c..c9135b94e 100644 --- a/src/main/java/au/com/royalpay/payment/manage/appclient/web/RetailAppController.java +++ b/src/main/java/au/com/royalpay/payment/manage/appclient/web/RetailAppController.java @@ -11,6 +11,7 @@ import au.com.royalpay.payment.manage.bill.bean.QueryBillBean; import au.com.royalpay.payment.manage.bill.bean.QueryBillOrderBean; import au.com.royalpay.payment.manage.bill.core.BillOrderService; import au.com.royalpay.payment.manage.bill.core.BillService; +import au.com.royalpay.payment.manage.settlement.core.ManualSettleSupport; import au.com.royalpay.payment.manage.signin.beans.ChangePwdBean; import au.com.royalpay.payment.manage.signin.core.SignInStatusManager; import au.com.royalpay.payment.manage.system.core.ClientContractService; @@ -22,6 +23,7 @@ import au.com.royalpay.payment.tools.http.HttpUtils; import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSONObject; +import org.apache.commons.lang3.time.DateUtils; import org.springframework.validation.Errors; import org.springframework.web.bind.annotation.ModelAttribute; import org.springframework.web.bind.annotation.PathVariable; @@ -29,9 +31,12 @@ import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.RequestParam; +import org.springframework.web.bind.annotation.ResponseBody; import org.springframework.web.servlet.ModelAndView; import java.math.BigDecimal; +import java.text.ParseException; +import java.util.Date; import java.util.List; import java.util.Map; @@ -58,6 +63,8 @@ public class RetailAppController { private AppActService appActService; @Resource private ClientContractService clientContractService; + @Resource + private ManualSettleSupport manualSettleSupport; @RequestMapping(value = "/token", method = RequestMethod.PUT) public void updateDevToken(@ModelAttribute(CommonConsts.RETAIL_DEVICE) JSONObject device, @RequestBody JSONObject token) { @@ -114,7 +121,7 @@ public class RetailAppController { @RequestMapping("/transaction_log/{clearing_detail_id}") public JSONObject getTransactionLogByClearingDetailId(@ModelAttribute(CommonConsts.RETAIL_DEVICE) JSONObject device, @PathVariable int clearing_detail_id, - @RequestParam(required = false) String timezone) { + @RequestParam(required = false) String timezone) { return retailAppService.getTransactionLogsByClearingDetailId(device, clearing_detail_id, timezone); } @@ -126,7 +133,7 @@ public class RetailAppController { @RequestMapping(value = "/notice/{noticeId}", method = RequestMethod.PUT) public void updateNoticePartnerHasRead(@ModelAttribute(CommonConsts.RETAIL_DEVICE) JSONObject device, @PathVariable String noticeId, - @RequestBody JSONObject account_param) { + @RequestBody JSONObject account_param) { if (!device.getString("account_id").equals(account_param.getString("account_id"))) { throw new ForbiddenException("You have no permission"); } @@ -147,7 +154,7 @@ public class RetailAppController { /* 我的页面begin */ @RequestMapping(value = "/partner_password/{account_id}", method = RequestMethod.PUT) public void changePassword(@ModelAttribute(CommonConsts.RETAIL_DEVICE) JSONObject device, @PathVariable String account_id, - @RequestBody @Valid ChangePwdBean change, Errors errors) { + @RequestBody @Valid ChangePwdBean change, Errors errors) { HttpUtils.handleValidErrors(errors); retailAppService.changeAccountPassword(device, change, account_id); } @@ -176,7 +183,7 @@ public class RetailAppController { /* 活动页面 begin */ @RequestMapping(value = "/activities", method = RequestMethod.GET) public JSONObject getActivities(@ModelAttribute(CommonConsts.RETAIL_DEVICE) JSONObject device, @RequestParam(defaultValue = "activity_page") String type, - @RequestParam(defaultValue = "1") int page, @RequestParam(defaultValue = "10") int limit) { + @RequestParam(defaultValue = "1") int page, @RequestParam(defaultValue = "10") int limit) { return retailAppService.getActivities(device, type, page, limit); } @@ -220,7 +227,7 @@ public class RetailAppController { @RequestMapping(value = "/daily_transactions/date/{dateStr}", method = RequestMethod.GET) public JSONObject listDailyTransactions(@PathVariable String dateStr, @RequestParam(defaultValue = "Australia/Melbourne") String timezone, - @RequestParam(defaultValue = "false") boolean thisdevice, @ModelAttribute(CommonConsts.RETAIL_DEVICE) JSONObject device) { + @RequestParam(defaultValue = "false") boolean thisdevice, @ModelAttribute(CommonConsts.RETAIL_DEVICE) JSONObject device) { return retailAppService.listDailyTransactions(dateStr, timezone, thisdevice, device); } @@ -271,7 +278,7 @@ public class RetailAppController { @RequestMapping(value = "/cash_back/clean_info", method = RequestMethod.GET) public JSONObject getCashbackCleanInfo(@ModelAttribute(CommonConsts.RETAIL_DEVICE) JSONObject device, - @RequestParam(value = "client_id", required = false) String client_id) { + @RequestParam(value = "client_id", required = false) String client_id) { if (client_id == null) { client_id = device.getString("client_id"); } @@ -287,7 +294,7 @@ public class RetailAppController { @RequestMapping(value = "/coupon/used", method = RequestMethod.GET) public JSONObject getCoupons(@ModelAttribute(CommonConsts.RETAIL_DEVICE) JSONObject device, @RequestParam(value = "page", defaultValue = "1") int page, - @RequestParam(value = "limit", defaultValue = "10") int limit) { + @RequestParam(value = "limit", defaultValue = "10") int limit) { return retailAppService.getCoupons(device, page, limit); } @@ -339,15 +346,15 @@ public class RetailAppController { @RequestMapping(value = "/bills/orders/{bill_id}", method = RequestMethod.GET) public JSONObject getBillOrders(@PathVariable("bill_id") String bill_id, QueryBillOrderBean queryBillOrderBean, - @ModelAttribute(CommonConsts.RETAIL_DEVICE) JSONObject device) { + @ModelAttribute(CommonConsts.RETAIL_DEVICE) JSONObject device) { JSONObject result = billOrderService.query(bill_id, device.getIntValue("client_id"), queryBillOrderBean); result.put("analysis", billOrderService.analysis(bill_id, device.getIntValue("client_id"), queryBillOrderBean)); return result; } - @RequestMapping(value = "/acts",method = RequestMethod.GET) - public List getIndexAct(@ModelAttribute(CommonConsts.RETAIL_DEVICE) JSONObject device){ + @RequestMapping(value = "/acts", method = RequestMethod.GET) + public List getIndexAct(@ModelAttribute(CommonConsts.RETAIL_DEVICE) JSONObject device) { return appActService.listAppActs(); } @@ -373,12 +380,38 @@ public class RetailAppController { public JSONObject generateSourceAgreeFile(@ModelAttribute(CommonConsts.RETAIL_DEVICE) JSONObject device) { JSONObject file = clientContractService.getSourceAgreement(device.getIntValue("client_id")); JSONObject result = new JSONObject(); - result.put("file_url",file.getString("file_value")); + result.put("file_url", file.getString("file_value")); return result; } @RequestMapping(value = "/file/agree/confirm", method = RequestMethod.POST) public void confirmSourceAgreeFile(@ModelAttribute(CommonConsts.RETAIL_DEVICE) JSONObject device) { - clientContractService.confirmSourceAgreement(device.getIntValue("client_id"),device.getString("account_id"),"App"); + clientContractService.confirmSourceAgreement(device.getIntValue("client_id"), device.getString("account_id"), "App"); + } + + @RequestMapping(value = "/manual_settle", method = RequestMethod.GET) + public JSONObject getManualSettleStatus(@ModelAttribute(CommonConsts.RETAIL_DEVICE) JSONObject device) { + return manualSettleSupport.findCurrentSettle(device.getIntValue("client_id"), true); } + + @RequestMapping(value = "/manual_settle", method = RequestMethod.PUT) + public JSONObject requestManualSettle(@ModelAttribute(CommonConsts.RETAIL_DEVICE) JSONObject device, @RequestBody JSONObject data) { + String settleToStr = data.getString("settle_to"); + if (settleToStr == null) { + throw new ParamInvalidException("settle_to", "error.payment.valid.param_missing"); + } + try { + Date setteTo = DateUtils.parseDate(settleToStr, "yyyy-MM-dd"); + return manualSettleSupport.requestManualSettle(setteTo, device.getString("account_id")); + } catch (ParseException e) { + throw new ParamInvalidException("settle_to", "error.payment.valid.invalid_time"); + } + } + + @RequestMapping(value = "/client/manual_settle", method = RequestMethod.PUT) + @ResponseBody + public void confirmSourceAgreeFile(@ModelAttribute(CommonConsts.RETAIL_DEVICE) JSONObject device,@RequestBody JSONObject data) { + retailAppService.changeManualSettle(device,data.getBoolean("manual_settle")); + } + } diff --git a/src/main/java/au/com/royalpay/payment/manage/management/clearing/web/ClearingConfigController.java b/src/main/java/au/com/royalpay/payment/manage/management/clearing/web/ClearingConfigController.java index fda50ec79..89a9e4a61 100644 --- a/src/main/java/au/com/royalpay/payment/manage/management/clearing/web/ClearingConfigController.java +++ b/src/main/java/au/com/royalpay/payment/manage/management/clearing/web/ClearingConfigController.java @@ -4,7 +4,12 @@ import au.com.royalpay.payment.manage.management.clearing.core.CleanService; import au.com.royalpay.payment.manage.permission.manager.ManagerMapping; import au.com.royalpay.payment.tools.permission.enums.ManagerRole; import au.com.royalpay.payment.tools.CommonConsts; + +import com.alibaba.fastjson.JSON; +import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONObject; + +import org.springframework.util.CollectionUtils; import org.springframework.web.bind.annotation.*; import javax.annotation.Resource; @@ -18,13 +23,14 @@ public class ClearingConfigController { @Resource private CleanService cleanService; - @ManagerMapping(value = "/rate_warnings",method = RequestMethod.GET,role = {ManagerRole.ADMIN,ManagerRole.OPERATOR, ManagerRole.FINANCIAL_STAFF}) - public JSONObject getRateWarnings(){ + @ManagerMapping(value = "/rate_warnings", method = RequestMethod.GET, role = { ManagerRole.ADMIN, ManagerRole.OPERATOR, ManagerRole.FINANCIAL_STAFF }) + public JSONObject getRateWarnings() { return cleanService.rateWarnings(); } - @ManagerMapping(value = "/clients/{clientMoniker}/auto_rate",method = RequestMethod.PUT,role = {ManagerRole.ADMIN,ManagerRole.OPERATOR}) - public JSONObject generateRateAutomatically(@PathVariable String clientMoniker, @ModelAttribute(CommonConsts.MANAGER_STATUS) JSONObject manager){ - return cleanService.autoGenerateRate(clientMoniker,manager); + @ManagerMapping(value = "/clients/{clientMoniker}/auto_rate", method = RequestMethod.PUT, role = { ManagerRole.ADMIN, ManagerRole.OPERATOR }) + public JSONObject generateRateAutomatically(@PathVariable String clientMoniker, @ModelAttribute(CommonConsts.MANAGER_STATUS) JSONObject manager) { + return cleanService.autoGenerateRate(clientMoniker, manager); } + } diff --git a/src/main/java/au/com/royalpay/payment/manage/mappers/log/ClientsOperationLogMapper.java b/src/main/java/au/com/royalpay/payment/manage/mappers/log/ClientsOperationLogMapper.java new file mode 100644 index 000000000..c69f68e87 --- /dev/null +++ b/src/main/java/au/com/royalpay/payment/manage/mappers/log/ClientsOperationLogMapper.java @@ -0,0 +1,16 @@ +package au.com.royalpay.payment.manage.mappers.log; + +import com.alibaba.fastjson.JSONObject; + +import cn.yixblog.support.mybatis.autosql.annotations.AutoMapper; +import cn.yixblog.support.mybatis.autosql.annotations.AutoSql; +import cn.yixblog.support.mybatis.autosql.annotations.SqlType; + +/** + * Created by yixian on 2017-04-18. + */ +@AutoMapper(tablename = "log_clients_operation",pkName = "id") +public interface ClientsOperationLogMapper { + @AutoSql(type = SqlType.INSERT) + void save(JSONObject review); +} diff --git a/src/main/java/au/com/royalpay/payment/manage/mappers/payment/TaskManualSettleMapper.java b/src/main/java/au/com/royalpay/payment/manage/mappers/payment/TaskManualSettleMapper.java new file mode 100644 index 000000000..735c80aea --- /dev/null +++ b/src/main/java/au/com/royalpay/payment/manage/mappers/payment/TaskManualSettleMapper.java @@ -0,0 +1,31 @@ +package au.com.royalpay.payment.manage.mappers.payment; + +import cn.yixblog.support.mybatis.autosql.annotations.AdvanceSelect; +import cn.yixblog.support.mybatis.autosql.annotations.AutoMapper; +import cn.yixblog.support.mybatis.autosql.annotations.AutoSql; +import cn.yixblog.support.mybatis.autosql.annotations.SqlType; +import com.alibaba.fastjson.JSONObject; +import org.apache.ibatis.annotations.Param; + +import java.util.List; + +/** + * Create by yixian at 2018-03-20 18:05 + */ +@AutoMapper(tablename = "task_client_manual_settle", pkName = "task_id") +public interface TaskManualSettleMapper { + + @AutoSql(type = SqlType.SELECT) + @AdvanceSelect(addonWhereClause = "request_time>curdate()") + JSONObject findTodayTask(@Param("client_id") int clientId); + + @AutoSql(type = SqlType.SELECT) + @AdvanceSelect(addonWhereClause = "clearing_order is null") + List listActiveTasks(@Param("client_id") int clientId); + + @AutoSql(type = SqlType.INSERT) + void save(JSONObject task); + + @AutoSql(type = SqlType.UPDATE) + void update(JSONObject task); +} diff --git a/src/main/java/au/com/royalpay/payment/manage/mappers/payment/TransactionMapper.java b/src/main/java/au/com/royalpay/payment/manage/mappers/payment/TransactionMapper.java index 97622c602..f6b91f73c 100644 --- a/src/main/java/au/com/royalpay/payment/manage/mappers/payment/TransactionMapper.java +++ b/src/main/java/au/com/royalpay/payment/manage/mappers/payment/TransactionMapper.java @@ -128,4 +128,6 @@ public interface TransactionMapper { List getClientRank(@Param("begin") Date begin, @Param("end") Date end); + List listClientUnsettleDataByDate(@Param("client_id") int clientId); + } diff --git a/src/main/java/au/com/royalpay/payment/manage/mappers/system/ClientsContractMapper.java b/src/main/java/au/com/royalpay/payment/manage/mappers/system/ClientsContractMapper.java index 043079965..873ad7b61 100644 --- a/src/main/java/au/com/royalpay/payment/manage/mappers/system/ClientsContractMapper.java +++ b/src/main/java/au/com/royalpay/payment/manage/mappers/system/ClientsContractMapper.java @@ -1,5 +1,6 @@ package au.com.royalpay.payment.manage.mappers.system; +import java.sql.SQLType; import java.util.List; import org.apache.ibatis.annotations.Param; @@ -23,4 +24,9 @@ public interface ClientsContractMapper { JSONObject findByClientId(@Param("client_id") int clientId); + @AutoSql(type = SqlType.SELECT) + List list(); + + List listWithClientInfo(); + } diff --git a/src/main/java/au/com/royalpay/payment/manage/mappers/system/ExchangeRateMapper.java b/src/main/java/au/com/royalpay/payment/manage/mappers/system/ExchangeRateMapper.java new file mode 100644 index 000000000..dc086e7d7 --- /dev/null +++ b/src/main/java/au/com/royalpay/payment/manage/mappers/system/ExchangeRateMapper.java @@ -0,0 +1,29 @@ +package au.com.royalpay.payment.manage.mappers.system; + +import java.util.Date; +import java.util.List; + +import org.apache.ibatis.annotations.Param; + +import com.alibaba.fastjson.JSONObject; + +import cn.yixblog.support.mybatis.autosql.annotations.AdvanceSelect; +import cn.yixblog.support.mybatis.autosql.annotations.AutoMapper; +import cn.yixblog.support.mybatis.autosql.annotations.AutoSql; +import cn.yixblog.support.mybatis.autosql.annotations.SqlType; + +/** + * Create by yixian at 2017-12-19 19:09 + */ +@AutoMapper(tablename = "sys_exchange_rate", pkName = "id") +public interface ExchangeRateMapper { + @AutoSql(type = SqlType.SELECT) + @AdvanceSelect(addonWhereClause = "type = 1") + JSONObject findMaxRate(@Param("create_date") Date create_time); + + @AutoSql(type = SqlType.SELECT) + @AdvanceSelect(addonWhereClause = "type = 2") + JSONObject findMinRate(@Param("create_date") Date create_time); + + List listExchangeRates(@Param("begin") Date begin, @Param("end") Date end, @Param("channel") String channel); +} diff --git a/src/main/java/au/com/royalpay/payment/manage/merchants/core/ClientInfoCacheSupport.java b/src/main/java/au/com/royalpay/payment/manage/merchants/core/ClientInfoCacheSupport.java new file mode 100644 index 000000000..fcbe2b634 --- /dev/null +++ b/src/main/java/au/com/royalpay/payment/manage/merchants/core/ClientInfoCacheSupport.java @@ -0,0 +1,9 @@ +package au.com.royalpay.payment.manage.merchants.core; + +public interface ClientInfoCacheSupport { + + + void clearClientCache(int clientId); + + void clearClientMonikerCache(String clientMoniker); +} diff --git a/src/main/java/au/com/royalpay/payment/manage/merchants/core/ClientManager.java b/src/main/java/au/com/royalpay/payment/manage/merchants/core/ClientManager.java index 3e0825e09..11fefbe1b 100644 --- a/src/main/java/au/com/royalpay/payment/manage/merchants/core/ClientManager.java +++ b/src/main/java/au/com/royalpay/payment/manage/merchants/core/ClientManager.java @@ -36,10 +36,6 @@ public interface ClientManager { JSONObject getClientInfo(int clientId); - void clearClientCache(int clientId); - - void clearClientMonikerCache(String clientMoniker); - JSONObject getClientInfoIgnoreInvalid(int clientId); JSONObject getClientInfoByMoniker(String clientMoniker); @@ -231,6 +227,7 @@ public interface ClientManager { void changePaymentPage(JSONObject account, String paypad_version); + void changeManualSettle(int client_id, boolean manual_settle,String operator_id,int type,String operation); void changeQRCodePaySurcharge(JSONObject account, boolean paySurcharge); diff --git a/src/main/java/au/com/royalpay/payment/manage/merchants/core/impls/ClientInfoCacheSupportImpl.java b/src/main/java/au/com/royalpay/payment/manage/merchants/core/impls/ClientInfoCacheSupportImpl.java new file mode 100644 index 000000000..0e540548e --- /dev/null +++ b/src/main/java/au/com/royalpay/payment/manage/merchants/core/impls/ClientInfoCacheSupportImpl.java @@ -0,0 +1,40 @@ +package au.com.royalpay.payment.manage.merchants.core.impls; + +import au.com.royalpay.payment.manage.mappers.system.ClientAccountMapper; +import au.com.royalpay.payment.manage.merchants.core.ClientInfoCacheSupport; +import au.com.royalpay.payment.manage.merchants.core.ClientManager; +import au.com.royalpay.payment.manage.signin.core.SignInAccountService; +import com.alibaba.fastjson.JSONObject; +import org.springframework.cache.annotation.CacheEvict; +import org.springframework.stereotype.Service; + +import javax.annotation.Resource; +import java.util.List; + +@Service +public class ClientInfoCacheSupportImpl implements ClientInfoCacheSupport{ + @Resource + private ClientAccountMapper clientAccountMapper; + @Resource + private SignInAccountService signInAccountService; + @Resource + private ClientManager clientManager; + @Resource + private ClientInfoCacheSupport clientInfoCacheSupport; + + @Override + @CacheEvict(value = ":app_client_info:", key = "''+#clientId") + public void clearClientCache(int clientId) { + List accounts = clientAccountMapper.listPartnerAccounts(clientId); + for (JSONObject acc : accounts) { + signInAccountService.clearAccountCache(acc.getString("account_id")); + } + JSONObject client = clientManager.getClientInfo(clientId); + clientInfoCacheSupport.clearClientMonikerCache(client.getString("client_moniker")); + } + + @Override + @CacheEvict(value = ":app_client_info_moniker:", key = "#clientMoniker") + public void clearClientMonikerCache(String clientMoniker) { + } +} diff --git a/src/main/java/au/com/royalpay/payment/manage/merchants/core/impls/ClientManagerImpl.java b/src/main/java/au/com/royalpay/payment/manage/merchants/core/impls/ClientManagerImpl.java index 67dab6933..4d259a3b9 100644 --- a/src/main/java/au/com/royalpay/payment/manage/merchants/core/impls/ClientManagerImpl.java +++ b/src/main/java/au/com/royalpay/payment/manage/merchants/core/impls/ClientManagerImpl.java @@ -13,31 +13,13 @@ import au.com.royalpay.payment.manage.analysis.mappers.TransactionAnalysisMapper import au.com.royalpay.payment.manage.appclient.beans.AppClientBean; import au.com.royalpay.payment.manage.device.core.DeviceManager; import au.com.royalpay.payment.manage.mappers.financial.FinancialBDConfigMapper; +import au.com.royalpay.payment.manage.mappers.log.ClientsOperationLogMapper; 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.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.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.ManagerMapper; -import au.com.royalpay.payment.manage.mappers.system.OrgMapper; -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; -import au.com.royalpay.payment.manage.merchants.beans.ClientRateConfig; -import au.com.royalpay.payment.manage.merchants.beans.ClientRegisterInfo; -import au.com.royalpay.payment.manage.merchants.beans.NewAccountBean; -import au.com.royalpay.payment.manage.merchants.beans.PartnerQuery; -import au.com.royalpay.payment.manage.merchants.beans.SubMerchantIdApply; +import au.com.royalpay.payment.manage.mappers.system.*; +import au.com.royalpay.payment.manage.merchants.beans.*; import au.com.royalpay.payment.manage.merchants.core.ClientComplyValidator; +import au.com.royalpay.payment.manage.merchants.core.ClientInfoCacheSupport; import au.com.royalpay.payment.manage.merchants.core.ClientManager; import au.com.royalpay.payment.manage.notice.core.MailService; import au.com.royalpay.payment.manage.signin.beans.TodoNotice; @@ -66,21 +48,16 @@ import au.com.royalpay.payment.tools.merchants.qrboard.QRBoard; import au.com.royalpay.payment.tools.merchants.qrboard.QRBoardProvider; import au.com.royalpay.payment.tools.permission.enums.ManagerRole; import au.com.royalpay.payment.tools.permission.enums.PartnerRole; -import au.com.royalpay.payment.tools.utils.ImageUtils; -import au.com.royalpay.payment.tools.utils.PageListUtils; -import au.com.royalpay.payment.tools.utils.PasswordUtils; -import au.com.royalpay.payment.tools.utils.PdfUtils; -import au.com.royalpay.payment.tools.utils.QRCodeUtils; -import au.com.royalpay.payment.tools.utils.TimeZoneUtils; +import au.com.royalpay.payment.tools.utils.*; import au.com.royalpay.payment.tools.websocket.notify.PartnerPageEvent; - +import cn.yixblog.platform.http.HttpRequestGenerator; +import cn.yixblog.platform.http.HttpRequestResult; import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONObject; import com.github.miemiedev.mybatis.paginator.domain.Order; import com.github.miemiedev.mybatis.paginator.domain.PageBounds; import com.github.miemiedev.mybatis.paginator.domain.PageList; - import org.apache.commons.io.IOUtils; import org.apache.commons.lang3.ArrayUtils; import org.apache.commons.lang3.RandomStringUtils; @@ -106,35 +83,23 @@ import org.springframework.web.bind.annotation.RequestMethod; import org.thymeleaf.context.Context; import org.thymeleaf.spring4.SpringTemplateEngine; +import javax.annotation.Resource; +import javax.imageio.ImageIO; +import javax.servlet.ServletOutputStream; +import javax.servlet.http.HttpServletResponse; import java.awt.*; import java.awt.image.BufferedImage; -import java.io.ByteArrayInputStream; -import java.io.ByteArrayOutputStream; -import java.io.File; -import java.io.IOException; -import java.io.InputStream; -import java.io.OutputStream; +import java.io.*; import java.math.BigDecimal; import java.net.URISyntaxException; import java.net.URL; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Date; +import java.util.*; import java.util.List; -import java.util.Objects; import java.util.concurrent.TimeUnit; import java.util.stream.Collectors; import java.util.zip.ZipEntry; import java.util.zip.ZipOutputStream; -import javax.annotation.Resource; -import javax.imageio.ImageIO; -import javax.servlet.ServletOutputStream; -import javax.servlet.http.HttpServletResponse; - -import cn.yixblog.platform.http.HttpRequestGenerator; -import cn.yixblog.platform.http.HttpRequestResult; - import static au.com.royalpay.payment.manage.permission.utils.OrgCheckUtils.checkOrgPermission; /** @@ -219,6 +184,10 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid private ClientContractService clientContractService; @Resource private MessageSource messageSource; + @Resource + private ClientsOperationLogMapper clientsOperationLogMapper; + @Resource + private ClientInfoCacheSupport clientInfoCacheSupport; private static final String SOURCE_AGREE_FILE = "source_agree_file"; private static final String CLIENT_BANK_FILE = "client_bank_file"; @@ -247,22 +216,6 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid return clientMapper.findClient(clientId); } - @Override - @CacheEvict(value = ":app_client_info:", key = "''+#clientId") - public void clearClientCache(int clientId) { - List accounts = clientAccountMapper.listPartnerAccounts(clientId); - for (JSONObject acc : accounts) { - signInAccountService.clearAccountCache(acc.getString("account_id")); - } - JSONObject client = getClientInfo(clientId); - clearClientMonikerCache(client.getString("client_moniker")); - } - - @Override - @CacheEvict(value = ":app_client_info_moniker:", key = "#clientMoniker") - public void clearClientMonikerCache(String clientMoniker) { - } - @Override public JSONObject getClientInfoIgnoreInvalid(int clientId) { return clientMapper.findClientIgnoreInvalid(clientId); @@ -571,7 +524,7 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid } } clientMapper.update(updateInfo); - clearClientCache(clientId); + clientInfoCacheSupport.clearClientCache(clientId); } @Override @@ -597,7 +550,7 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid clientMapper.update(update); } } - clearClientCache(clientId); + clientInfoCacheSupport.clearClientCache(clientId); } @Override @@ -634,7 +587,7 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid saveClientAuditProcess(client.getIntValue("client_id"), open_status, 5, "合规通过", manager); } } - clearClientCache(client.getIntValue("client_id")); + clientInfoCacheSupport.clearClientCache(client.getIntValue("client_id")); } @Override @@ -655,7 +608,7 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid saveClientAuditProcess(client.getIntValue("client_id"), 10, 1, "绿色通道申请通过", manager); sendCommissionWechatMessage(client); initAdminUserAndSendEmail(manager, clientMoniker, client); - clearClientCache(client.getIntValue("client_id")); + clientInfoCacheSupport.clearClientCache(client.getIntValue("client_id")); } private void initAdminUserAndSendEmail(JSONObject manager, String clientMoniker, JSONObject client) { @@ -713,7 +666,7 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid sendInitEmail(client, account.getString("username"), pwd); } } - clearClientCache(clientId); + clientInfoCacheSupport.clearClientCache(clientId); } @Override @@ -833,7 +786,7 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid } int clientId = client.getIntValue("client_id"); updateClientApproveEmailStatus(clientId, 1); - clearClientCache(clientId); + clientInfoCacheSupport.clearClientCache(clientId); } private void updateClientApproveEmailStatus(int clientId, int status) { @@ -884,7 +837,7 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid checkOrgPermission(manager, client); client.put(permissionKey, allow); clientMapper.update(client); - clearClientCache(client.getIntValue("client_id")); + clientInfoCacheSupport.clearClientCache(client.getIntValue("client_id")); } @Override @@ -1071,7 +1024,7 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid Assert.notNull(partner); partner.put("enable_pay_notice", enable); clientMapper.update(partner); - clearClientCache(partner.getIntValue("client_id")); + clientInfoCacheSupport.clearClientCache(partner.getIntValue("client_id")); } @Override @@ -1099,7 +1052,7 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid Assert.notNull(partner, "Merchant is null"); partner.put("enable_refund_auth", enable); clientMapper.update(partner); - clearClientCache(partner.getIntValue("client_id")); + clientInfoCacheSupport.clearClientCache(partner.getIntValue("client_id")); } @Override @@ -1134,7 +1087,7 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid subClient.put("bd_user", managerId); clientMapper.update(subClient); } - clearClientCache(client.getIntValue("client_id")); + clientInfoCacheSupport.clearClientCache(client.getIntValue("client_id")); } @Override @@ -1146,7 +1099,7 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid checkOrgPermission(manager, client); client.put("credential_code", RandomStringUtils.random(32, true, true)); clientMapper.update(client); - clearClientCache(client.getIntValue("client_id")); + clientInfoCacheSupport.clearClientCache(client.getIntValue("client_id")); } @Override @@ -1217,7 +1170,7 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid update.put("client_id", client.getIntValue("client_id")); update.put("settle_hour", hour); clientMapper.update(update); - clearClientCache(client.getIntValue("client_id")); + clientInfoCacheSupport.clearClientCache(client.getIntValue("client_id")); } @Override @@ -1689,7 +1642,7 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid partner.put("client_id", clientId); partner.put("timezone", timezone); clientMapper.update(partner); - clearClientCache(clientId); + clientInfoCacheSupport.clearClientCache(clientId); } @Override @@ -2191,8 +2144,7 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid client.put("refund_pwd", pwdHash); client.put("refund_pwd_salt", salt); clientMapper.update(client); - clearClientCache(client.getIntValue("client_id")); - clearClientMonikerCache(client.getString("client_moniker")); + clientInfoCacheSupport.clearClientCache(client.getIntValue("client_id")); } @Override @@ -2224,7 +2176,7 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid update.put("client_id", clientId); update.put("qrcode_surcharge", paySurcharge); clientMapper.update(update); - clearClientCache(clientId); + clientInfoCacheSupport.clearClientCache(clientId); } @Override @@ -2238,7 +2190,7 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid update.put("client_id", clientId); update.put("api_surcharge", enableApiSurcharge); clientMapper.update(update); - clearClientCache(clientId); + clientInfoCacheSupport.clearClientCache(clientId); } @Override @@ -2252,7 +2204,7 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid update.put("client_id", clientId); update.put("retail_surcharge", paySurcharge); clientMapper.update(update); - clearClientCache(clientId); + clientInfoCacheSupport.clearClientCache(clientId); } @Override @@ -2266,7 +2218,7 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid update.put("client_id", clientId); update.put("tax_in_surcharge", taxInSurcharge); clientMapper.update(update); - clearClientCache(clientId); + clientInfoCacheSupport.clearClientCache(clientId); } @Override @@ -2282,13 +2234,13 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid @Override public void updateClientCleanDays(int clientId, int cleanDays) { clientMapper.updateCleanDays(clientId, cleanDays); - clearClientCache(clientId); + clientInfoCacheSupport.clearClientCache(clientId); } @Override public void updateClientEmail(int clientId, String contact_email) { clientMapper.updateClientEmail(clientId, contact_email); - clearClientCache(clientId); + clientInfoCacheSupport.clearClientCache(clientId); } @Override @@ -2296,7 +2248,7 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid JSONObject client = clientDetail(manager, clientMoniker); int clientId = client.getIntValue("client_id"); clientMapper.disableClient(clientId); - clearClientCache(clientId); + clientInfoCacheSupport.clearClientCache(clientId); } @Override @@ -2590,7 +2542,7 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid checkOrgPermission(manager, client); client.put("paypad_version", paypad_version); clientMapper.update(client); - clearClientCache(client.getIntValue("client_id")); + clientInfoCacheSupport.clearClientCache(client.getIntValue("client_id")); } @Override @@ -2604,7 +2556,31 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid updateObj.put("client_id", client.getIntValue("client_id")); updateObj.put("paypad_version", paypad_version); clientMapper.update(updateObj); - clearClientCache(clientId); + clientInfoCacheSupport.clearClientCache(clientId); + } + + @Override + @Transactional + public void changeManualSettle(int client_id, boolean manual_settle,String operator_id,int type,String operation) { + JSONObject client = getClientInfo(client_id); + if(client==null){ + throw new BadRequestException("merchant not found"); + } + JSONObject record = new JSONObject(); + record.put("client_id",client_id); + record.put("manual_settle",manual_settle); + clientMapper.update(record); + + JSONObject actClientLog = new JSONObject(); + actClientLog.put("client_id",client_id); + actClientLog.put("operator_id",operator_id); + actClientLog.put("operation",operation); + actClientLog.put("create_time",new Date()); + actClientLog.put("operator_type",type); + clientsOperationLogMapper.save(actClientLog); + + clientInfoCacheSupport.clearClientCache(client_id); + } @Override @@ -2618,7 +2594,7 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid updateObj.put("client_id", client.getIntValue("client_id")); updateObj.put("qrcode_surcharge", paySurcharge); clientMapper.update(updateObj); - clearClientCache(clientId); + clientInfoCacheSupport.clearClientCache(clientId); } @Override @@ -2632,7 +2608,7 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid updateObj.put("client_id", client.getIntValue("client_id")); updateObj.put("api_surcharge", enableApiSurcharge); clientMapper.update(updateObj); - clearClientCache(clientId); + clientInfoCacheSupport.clearClientCache(clientId); } @Override @@ -2650,7 +2626,7 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid updateObj.put("client_id", client.getIntValue("client_id")); updateObj.put("retail_surcharge", paySurcharge); clientMapper.update(updateObj); - clearClientCache(clientId); + clientInfoCacheSupport.clearClientCache(clientId); } @Override @@ -2678,7 +2654,7 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid updateObj.put("retail_surcharge", updateSurchargeDTO.getRetailSurcharge()); clientMapper.update(updateObj); } - clearClientCache(clientId); + clientInfoCacheSupport.clearClientCache(clientId); } @Override @@ -2709,7 +2685,7 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid } catch (Exception e) { logger.error("RefusePartnerError=======:" + clientMoniker + "," + e.getMessage()); } - clearClientCache(client.getIntValue("client_id")); + clientInfoCacheSupport.clearClientCache(client.getIntValue("client_id")); } @Override @@ -2742,7 +2718,7 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid BigDecimal customerSurchargeRate = new BigDecimal(appClientBean.getCustomerSurchargeRate()).setScale(2, BigDecimal.ROUND_HALF_DOWN); setCustomerSurchargeRate(client.getString("client_moniker"), customerSurchargeRate); } - clearClientCache(client_id); + clientInfoCacheSupport.clearClientCache(client_id); } @Override @@ -2756,7 +2732,7 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid update.put("client_id", clientId); update.put("skip_clearing", skip_clearing); clientMapper.update(update); - clearClientCache(clientId); + clientInfoCacheSupport.clearClientCache(clientId); } @Override @@ -2770,7 +2746,7 @@ public class ClientManagerImpl implements ClientManager, ManagerTodoNoticeProvid update.put("client_id", clientId); update.put("gateway_upgrade", gatewayUpgrade); clientMapper.update(update); - clearClientCache(clientId); + clientInfoCacheSupport.clearClientCache(clientId); } private void sendMessagetoCompliance(JSONObject client, String bd_user_name) { diff --git a/src/main/java/au/com/royalpay/payment/manage/merchants/web/PartnerViewController.java b/src/main/java/au/com/royalpay/payment/manage/merchants/web/PartnerViewController.java index 3782de3b1..a903936f6 100644 --- a/src/main/java/au/com/royalpay/payment/manage/merchants/web/PartnerViewController.java +++ b/src/main/java/au/com/royalpay/payment/manage/merchants/web/PartnerViewController.java @@ -2,14 +2,12 @@ package au.com.royalpay.payment.manage.merchants.web; import au.com.royalpay.payment.core.exceptions.ParamInvalidException; import au.com.royalpay.payment.manage.merchants.beans.NewAccountBean; -import au.com.royalpay.payment.tools.merchants.beans.QRCodeConfig; import au.com.royalpay.payment.manage.merchants.core.ClientManager; import au.com.royalpay.payment.manage.merchants.core.ClientSignEventSupport; import au.com.royalpay.payment.manage.permission.manager.PartnerMapping; +import au.com.royalpay.payment.manage.permission.manager.RequirePartner; import au.com.royalpay.payment.manage.support.wechatclients.KangaLandWechatApiImpl; import au.com.royalpay.payment.manage.support.wechatclients.RedpackWechatApiImpl; -import au.com.royalpay.payment.tools.permission.enums.PartnerRole; -import au.com.royalpay.payment.manage.permission.manager.RequirePartner; import au.com.royalpay.payment.manage.tradelog.beans.TradeLogQuery; import au.com.royalpay.payment.manage.tradelog.core.TradeLogService; import au.com.royalpay.payment.tools.CommonConsts; @@ -17,20 +15,31 @@ import au.com.royalpay.payment.tools.connections.mpsupport.beans.WxOauthType; import au.com.royalpay.payment.tools.exceptions.BadRequestException; import au.com.royalpay.payment.tools.exceptions.ForbiddenException; import au.com.royalpay.payment.tools.http.HttpUtils; +import au.com.royalpay.payment.tools.merchants.beans.QRCodeConfig; +import au.com.royalpay.payment.tools.permission.enums.PartnerRole; import au.com.royalpay.payment.tools.permission.wechat.WechatMapping; + import com.alibaba.fastjson.JSONObject; + import org.springframework.stereotype.Controller; import org.springframework.ui.Model; import org.springframework.validation.Errors; -import org.springframework.web.bind.annotation.*; +import org.springframework.web.bind.annotation.ModelAttribute; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestMethod; +import org.springframework.web.bind.annotation.RequestParam; +import org.springframework.web.bind.annotation.ResponseBody; -import javax.annotation.Resource; -import javax.servlet.http.HttpServletResponse; -import javax.validation.Valid; import java.io.IOException; import java.io.OutputStream; import java.util.List; +import javax.annotation.Resource; +import javax.servlet.http.HttpServletResponse; +import javax.validation.Valid; + /** * view for partner client * Created by yixian on 2016-07-03. @@ -348,4 +357,13 @@ public class PartnerViewController { public void fullReleasePreAuthorization(@ModelAttribute(CommonConsts.PARTNER_STATUS) JSONObject account, @RequestBody TradeLogQuery query) throws Exception { tradeLogService.fullReleasePreAuthorization(account, query); } + + + @PartnerMapping(value = "/manual_settle", method = RequestMethod.PUT, roles = PartnerRole.ADMIN) + @ResponseBody + public void manualSettle(@ModelAttribute(CommonConsts.PARTNER_STATUS) JSONObject account, @RequestParam boolean manual_settle) { + clientManager.changeManualSettle(account.getIntValue("client_id"),manual_settle,account.getString("account_id"),1,"商户"+(manual_settle?"打开":"关闭")+"手动清算"); + } + + } diff --git a/src/main/java/au/com/royalpay/payment/manage/settlement/core/ManualSettleSupport.java b/src/main/java/au/com/royalpay/payment/manage/settlement/core/ManualSettleSupport.java new file mode 100644 index 000000000..5033a4028 --- /dev/null +++ b/src/main/java/au/com/royalpay/payment/manage/settlement/core/ManualSettleSupport.java @@ -0,0 +1,16 @@ +package au.com.royalpay.payment.manage.settlement.core; + +import com.alibaba.fastjson.JSONObject; + +import java.util.Date; + +/** + * Create by yixian at 2018-03-20 17:42 + */ +public interface ManualSettleSupport { + + JSONObject requestManualSettle(Date settleTo, String accountId); + + JSONObject findCurrentSettle(int clientId, boolean includingUnsettleData); + +} diff --git a/src/main/java/au/com/royalpay/payment/manage/settlement/core/impls/ManualSettleSupportImpl.java b/src/main/java/au/com/royalpay/payment/manage/settlement/core/impls/ManualSettleSupportImpl.java new file mode 100644 index 000000000..0971f1a31 --- /dev/null +++ b/src/main/java/au/com/royalpay/payment/manage/settlement/core/impls/ManualSettleSupportImpl.java @@ -0,0 +1,98 @@ +package au.com.royalpay.payment.manage.settlement.core.impls; + +import au.com.royalpay.payment.manage.mappers.log.ClearingLogMapper; +import au.com.royalpay.payment.manage.mappers.payment.TaskManualSettleMapper; +import au.com.royalpay.payment.manage.mappers.payment.TransactionMapper; +import au.com.royalpay.payment.manage.mappers.system.ClientAccountMapper; +import au.com.royalpay.payment.manage.settlement.core.ManualSettleSupport; +import au.com.royalpay.payment.tools.exceptions.BadRequestException; +import au.com.royalpay.payment.tools.exceptions.ForbiddenException; +import au.com.royalpay.payment.tools.locale.LocaleSupport; +import au.com.royalpay.payment.tools.merchants.core.MerchantInfoProvider; +import au.com.royalpay.payment.tools.permission.enums.PartnerRole; +import au.com.royalpay.payment.tools.utils.CurrencyAmountUtils; +import com.alibaba.fastjson.JSONObject; +import org.apache.commons.lang3.time.DateFormatUtils; +import org.apache.commons.lang3.time.DateUtils; +import org.springframework.stereotype.Service; + +import javax.annotation.Resource; +import java.math.BigDecimal; +import java.util.Date; +import java.util.List; + +/** + * Create by yixian at 2018-03-20 17:44 + */ +@Service +public class ManualSettleSupportImpl implements ManualSettleSupport { + + @Resource + private MerchantInfoProvider merchantInfoProvider; + @Resource + private TransactionMapper transactionMapper; + @Resource + private TaskManualSettleMapper taskManualSettleMapper; + @Resource + private ClearingLogMapper clearingLogMapper; + @Resource + private ClientAccountMapper clientAccountMapper; + + @Override + public JSONObject requestManualSettle(Date settleTo, String accountId) { + JSONObject account = clientAccountMapper.findById(accountId); + if (PartnerRole.getRole(account.getIntValue("role")) != PartnerRole.ADMIN) { + throw new ForbiddenException(); + } + int clientId = account.getIntValue("client_id"); + if (DateUtils.isSameDay(new Date(), settleTo)) { + throw new BadRequestException("Cannot settle today's transactions"); + } + JSONObject currentTask = findCurrentSettle(clientId, false); + String taskId = currentTask.getString("task_id"); + currentTask.put("request_time", new Date()); + currentTask.put("client_id", clientId); + currentTask.put("applier_id", account.getString("account_id")); + currentTask.put("applier_name", account.getString("display_name")); + currentTask.put("settle_to", settleTo); + if (taskId != null) { + taskManualSettleMapper.update(currentTask); + } else { + taskManualSettleMapper.save(currentTask); + } + return currentTask; + } + + @Override + public JSONObject findCurrentSettle(int clientId, boolean includingUnsettleData) { + JSONObject client = merchantInfoProvider.getClientInfo(clientId); + if (!client.getBooleanValue("manual_settle")) { + throw new ForbiddenException("Manual Settlement Not Enabled"); + } + JSONObject todayTask = taskManualSettleMapper.findTodayTask(clientId); + if (todayTask != null) { + todayTask.put("settle_to", DateFormatUtils.format(todayTask.getDate("settle_to"), "yyyy-MM-dd")); + } else { + todayTask = new JSONObject(); + } + List settleLogs = clearingLogMapper.findByDate(new Date()); + //今天未清算则锁定 + todayTask.put("locked", settleLogs.isEmpty()); + if (includingUnsettleData) { + List unsettleReports = transactionMapper.listClientUnsettleDataByDate(clientId); + unsettleReports.parallelStream().forEach(report -> { + report.put("clearing_amount", CurrencyAmountUtils.scalePlatformCurrency(report.getBigDecimal("clearing_amount"))); + BigDecimal settleAmount = report.getBigDecimal("settle_amount"); + report.put("settle_amount", CurrencyAmountUtils.scalePlatformCurrency(settleAmount == null ? BigDecimal.ZERO : settleAmount)); + report.put("date_str", DateFormatUtils.format(report.getDate("trans_date"), "yyyy-MM-dd")); + }); + todayTask.put("unsettle", unsettleReports); + BigDecimal totalClearing = unsettleReports.stream().map(report -> report.getBigDecimal("clearing_amount")).reduce(BigDecimal::add).orElse(BigDecimal.ZERO); + todayTask.put("total_clearing_amount", CurrencyAmountUtils.scalePlatformCurrency(totalClearing)); + BigDecimal totalSettle = unsettleReports.stream().map(report -> report.getBigDecimal("settle_amount")).reduce(BigDecimal::add).orElse(BigDecimal.ZERO); + todayTask.put("total_settle_amount", CurrencyAmountUtils.scalePlatformCurrency(totalSettle)); + todayTask.put("desc", LocaleSupport.localeMessage("manual_settle.notice")); + } + return todayTask; + } +} diff --git a/src/main/java/au/com/royalpay/payment/manage/settlement/package-info.java b/src/main/java/au/com/royalpay/payment/manage/settlement/package-info.java new file mode 100644 index 000000000..51ea13c08 --- /dev/null +++ b/src/main/java/au/com/royalpay/payment/manage/settlement/package-info.java @@ -0,0 +1,5 @@ +/** + * 清算相关 + * Create by yixian at 2018-03-20 17:42 + */ +package au.com.royalpay.payment.manage.settlement; \ No newline at end of file diff --git a/src/main/java/au/com/royalpay/payment/manage/settlement/web/ClientManualSettleController.java b/src/main/java/au/com/royalpay/payment/manage/settlement/web/ClientManualSettleController.java new file mode 100644 index 000000000..c2e984976 --- /dev/null +++ b/src/main/java/au/com/royalpay/payment/manage/settlement/web/ClientManualSettleController.java @@ -0,0 +1,43 @@ +package au.com.royalpay.payment.manage.settlement.web; + +import au.com.royalpay.payment.core.exceptions.ParamInvalidException; +import au.com.royalpay.payment.manage.permission.manager.PartnerMapping; +import au.com.royalpay.payment.manage.settlement.core.ManualSettleSupport; +import au.com.royalpay.payment.tools.CommonConsts; +import au.com.royalpay.payment.tools.permission.enums.PartnerRole; +import com.alibaba.fastjson.JSONObject; +import org.apache.commons.lang3.time.DateUtils; +import org.springframework.web.bind.annotation.*; + +import javax.annotation.Resource; +import java.text.ParseException; +import java.util.Date; + +/** + * Create by yixian at 2018-03-20 20:30 + */ +@RequestMapping("/client/manual_settle") +@RestController +public class ClientManualSettleController { + @Resource + private ManualSettleSupport manualSettleSupport; + + @PartnerMapping(value = "/today", method = RequestMethod.GET, roles = {PartnerRole.ADMIN}) + public JSONObject checkRequestInToday(@ModelAttribute(CommonConsts.PARTNER_STATUS) JSONObject account) { + return manualSettleSupport.findCurrentSettle(account.getIntValue("client_id"), true); + } + + @PartnerMapping(value = "/today", method = RequestMethod.PUT, roles = {PartnerRole.ADMIN}) + public JSONObject requestManualSettle(@ModelAttribute(CommonConsts.PARTNER_STATUS) JSONObject account, @RequestBody JSONObject data) { + String settleToStr = data.getString("settle_to"); + if (settleToStr == null) { + throw new ParamInvalidException("settle_to", "error.payment.valid.param_missing"); + } + try { + Date setteTo = DateUtils.parseDate(settleToStr, "yyyy-MM-dd"); + return manualSettleSupport.requestManualSettle(setteTo, account.getString("account_id")); + } catch (ParseException e) { + throw new ParamInvalidException("settle_to", "error.payment.valid.invalid_time"); + } + } +} diff --git a/src/main/java/au/com/royalpay/payment/manage/signin/core/impls/SignInAccountServiceImpl.java b/src/main/java/au/com/royalpay/payment/manage/signin/core/impls/SignInAccountServiceImpl.java index c68879275..15e17db04 100644 --- a/src/main/java/au/com/royalpay/payment/manage/signin/core/impls/SignInAccountServiceImpl.java +++ b/src/main/java/au/com/royalpay/payment/manage/signin/core/impls/SignInAccountServiceImpl.java @@ -320,7 +320,7 @@ public class SignInAccountServiceImpl implements SignInAccountService, Applicati "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"}; + "has_children", "source", "customer_surcharge_rate", "enable_alipay", "enable_wechat", "enable_bestpay","manual_settle"}; for (String col : columns) { simpleClient.put(col, client.get(col)); } diff --git a/src/main/java/au/com/royalpay/payment/manage/system/core/ClientContractService.java b/src/main/java/au/com/royalpay/payment/manage/system/core/ClientContractService.java index 9f57b23ea..902ef5e0f 100644 --- a/src/main/java/au/com/royalpay/payment/manage/system/core/ClientContractService.java +++ b/src/main/java/au/com/royalpay/payment/manage/system/core/ClientContractService.java @@ -2,6 +2,8 @@ package au.com.royalpay.payment.manage.system.core; import com.alibaba.fastjson.JSONObject; +import java.util.List; + public interface ClientContractService { JSONObject getOrGenerateSourceAgreement(int client_id,String channel); @@ -12,4 +14,5 @@ public interface ClientContractService { JSONObject getClientContractExpire(int client_id); + List list(); } diff --git a/src/main/java/au/com/royalpay/payment/manage/system/core/impl/ClientContractServiceImpl.java b/src/main/java/au/com/royalpay/payment/manage/system/core/impl/ClientContractServiceImpl.java index 2827e912f..14e259675 100644 --- a/src/main/java/au/com/royalpay/payment/manage/system/core/impl/ClientContractServiceImpl.java +++ b/src/main/java/au/com/royalpay/payment/manage/system/core/impl/ClientContractServiceImpl.java @@ -107,14 +107,15 @@ public class ClientContractServiceImpl implements ClientContractService { if(contract.getBoolean("has_sign")){ return; } + Date now = new Date(); JSONObject account = clientAccountMapper.findById(account_id); contract.put("has_sign", 1); contract.put("sign_account_id",account_id); contract.put("sign_channel",channel); + contract.put("confirm_time",now); contract.put("signatory",account.getString("display_name")); clientsContractMapper.update(contract); - Date now = new Date(); List rateInfo = clientRateMapper.minExpiryTime(client_id, null); if(expire){ rateInfo.forEach((p)->{ @@ -214,4 +215,9 @@ public class ClientContractServiceImpl implements ClientContractService { return result; } + + @Override + public List list() { + return clientsContractMapper.listWithClientInfo(); + } } diff --git a/src/main/java/au/com/royalpay/payment/manage/system/web/contractController.java b/src/main/java/au/com/royalpay/payment/manage/system/web/contractController.java new file mode 100644 index 000000000..2d688dfe8 --- /dev/null +++ b/src/main/java/au/com/royalpay/payment/manage/system/web/contractController.java @@ -0,0 +1,26 @@ +package au.com.royalpay.payment.manage.system.web; + +import au.com.royalpay.payment.manage.permission.manager.ManagerMapping; +import au.com.royalpay.payment.manage.system.core.ClientContractService; + +import com.alibaba.fastjson.JSONObject; + +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestMethod; +import org.springframework.web.bind.annotation.RestController; + +import java.util.List; + +import javax.annotation.Resource; + +@RestController +@RequestMapping(value = "/manage/contract") +public class contractController { + @Resource + private ClientContractService clientContractService; + + @ManagerMapping(value = "/list",method = RequestMethod.GET) + public List list(){ + return clientContractService.list(); + } +} diff --git a/src/main/resources/au/com/royalpay/payment/manage/mappers/payment/OrderMapper.xml b/src/main/resources/au/com/royalpay/payment/manage/mappers/payment/OrderMapper.xml index 0066484ff..d538acf9d 100644 --- a/src/main/resources/au/com/royalpay/payment/manage/mappers/payment/OrderMapper.xml +++ b/src/main/resources/au/com/royalpay/payment/manage/mappers/payment/OrderMapper.xml @@ -650,6 +650,7 @@ o.pre_authorization, o.refund_amount refund_fee, o.customer_id, + o.order_detail, t.clearing_amount, t.refund_id, t.transaction_time, diff --git a/src/main/resources/au/com/royalpay/payment/manage/mappers/payment/TransactionMapper.xml b/src/main/resources/au/com/royalpay/payment/manage/mappers/payment/TransactionMapper.xml index 18cd984c7..0ee0981d6 100644 --- a/src/main/resources/au/com/royalpay/payment/manage/mappers/payment/TransactionMapper.xml +++ b/src/main/resources/au/com/royalpay/payment/manage/mappers/payment/TransactionMapper.xml @@ -31,20 +31,22 @@ and t.refund_id is NOT NULL and t.transaction_type='Debit' and t.refund_id is NULL - and o.channel=#{chan} + and + o.channel=#{chan} + @@ -172,12 +186,16 @@ and t.transaction_time < #{to} @@ -298,7 +317,8 @@ and c.client_moniker=#{client_moniker} and c.org_id = #{org_id} and c.org_id in - #{org_id} + #{org_id} + GROUP BY c.client_id order by total desc @@ -317,7 +337,8 @@ and c.client_moniker=#{client_moniker} and c.org_id = #{org_id} and c.org_id in - #{org_id} + #{org_id} + @@ -525,33 +546,33 @@ = t.transaction_time AND - r.rate_name = 'Wechat'), 1) wechat_rate_value, + r.rate_name = 'Wechat'), 1) wechat_rate_value, ifnull((SELECT min(r.rate_value) FROM sys_client_rates r WHERE r.client_id = t.client_id AND r.active_time <= t.transaction_time AND r.expiry_time >= t.transaction_time AND - r.rate_name = 'Alipay'), 1) alipay_rate_value, + r.rate_name = 'Alipay'), 1) alipay_rate_value, ifnull((SELECT min(r.rate_value) FROM sys_client_rates r WHERE r.client_id = t.client_id AND r.active_time <= t.transaction_time AND r.expiry_time >= t.transaction_time AND - r.rate_name = 'Bestpay'), 1) bestpay_rate_value, + r.rate_name = 'Bestpay'), 1) bestpay_rate_value, ifnull((SELECT min(r.rate_value) FROM sys_client_rates r WHERE r.client_id = t.client_id AND r.active_time <= t.transaction_time AND r.expiry_time >= t.transaction_time AND - r.rate_name = 'jd'), 1) jd_rate_value, + r.rate_name = 'jd'), 1) jd_rate_value, ifnull((SELECT min(r.rate_value) FROM sys_client_rates r WHERE r.client_id = t.client_id AND r.active_time <= t.transaction_time AND @@ -561,7 +582,7 @@ INNER JOIN sys_clients c ON c.client_id = t.client_id INNER JOIN sys_org so ON c.org_id = so.org_id AND so.is_valid = 1 AND so.type = 0 AND so.parent_org_id = #{parent_org_id} - WHERE year(t.transaction_time) = #{year} AND month(t.transaction_time) = #{month} AND t.channel != 'Settlement' + WHERE year(t.transaction_time) = #{year} AND month(t.transaction_time) = #{month} AND t.channel != 'Settlement' GROUP BY t.client_id, trade_date, channel ORDER BY c.org_id ASC, t.client_id ASC, trade_date ASC ]]> @@ -676,7 +697,8 @@ select sum(if(t.transaction_type='Credit',settle_amount,-settle_amount)) settle_amount , DATE_FORMAT(t.transaction_time,'%Y%m%d') weekend from pmt_transactions t - INNER JOIN log_clearing_detail d on d.clear_detail_id=t.clearing_order and DAYOFWEEK(d.report_date)>2 and clear_days = 1 + INNER JOIN log_clearing_detail d on d.clear_detail_id=t.clearing_order and DAYOFWEEK(d.report_date)>2 and + clear_days = 1 where (DAYOFWEEK(t.transaction_time)=1 or DAYOFWEEK(t.transaction_time) = 7) and t.transaction_time > #{begin} @@ -722,5 +744,15 @@ and t.clearing_order is not NULL group by client_id + \ No newline at end of file diff --git a/src/main/resources/au/com/royalpay/payment/manage/mappers/system/ClientsContractMapper.xml b/src/main/resources/au/com/royalpay/payment/manage/mappers/system/ClientsContractMapper.xml index f0b8b14c7..8530d41d2 100644 --- a/src/main/resources/au/com/royalpay/payment/manage/mappers/system/ClientsContractMapper.xml +++ b/src/main/resources/au/com/royalpay/payment/manage/mappers/system/ClientsContractMapper.xml @@ -7,4 +7,10 @@ order by create_time desc limit 1 + \ No newline at end of file diff --git a/src/main/resources/au/com/royalpay/payment/manage/mappers/system/ExchangeRateMapper.xml b/src/main/resources/au/com/royalpay/payment/manage/mappers/system/ExchangeRateMapper.xml new file mode 100644 index 000000000..1c552bbf8 --- /dev/null +++ b/src/main/resources/au/com/royalpay/payment/manage/mappers/system/ExchangeRateMapper.xml @@ -0,0 +1,19 @@ + + + + + \ No newline at end of file diff --git a/src/main/resources/i18n/addon_en.properties b/src/main/resources/i18n/addon_en.properties new file mode 100644 index 000000000..5fe45b118 --- /dev/null +++ b/src/main/resources/i18n/addon_en.properties @@ -0,0 +1 @@ +manual_settle.notice=Settlement will be made on second work day after submitted this application. Your balance will not update during this time. \ No newline at end of file diff --git a/src/main/resources/i18n/addon_zh.properties b/src/main/resources/i18n/addon_zh.properties new file mode 100644 index 000000000..9cf1789bf --- /dev/null +++ b/src/main/resources/i18n/addon_zh.properties @@ -0,0 +1 @@ +manual_settle.notice=提现申请提交后会在第二个工作日到账,在此期间您的余额不会更新 \ No newline at end of file diff --git a/src/main/resources/i18n/msg_en.properties b/src/main/resources/i18n/msg_en.properties index 1ea334469..88903aca8 100644 --- a/src/main/resources/i18n/msg_en.properties +++ b/src/main/resources/i18n/msg_en.properties @@ -104,4 +104,7 @@ app.label.coupons=Available Coupons sys.contract.ordinary.info=Dear merchant, your service contract with ROYALPAY has expired. In order not to affect your normal use, please contact your supervisor or use your administrator account as soon as possible for service renewal. sys.contract.ordinary.waring=Dear merchant, your service contract with ROYALPAY expires in {0} days. In order not to affect your normal use, please contact your supervisor or use your administrator account as soon as possible in order to renew your service contract. sys.contract.waring=Dear merchant, your service contract with ROYALPAY is due to expire in {0} days. In order not to affect your normal use, please see the latest service agreement for renewal. -sys.contract.info=Dear merchant, your service contract with ROYALPAY has expired. Please check the latest service agreement to renew your contract so as not to affect your normal use. \ No newline at end of file +sys.contract.info=Dear merchant, your service contract with ROYALPAY has expired. Please check the latest service agreement to renew your contract so as not to affect your normal use. + + +sys.mondelay.cancel.waring=this is mondelay cancel waring \ No newline at end of file diff --git a/src/main/resources/i18n/msg_zh.properties b/src/main/resources/i18n/msg_zh.properties index a2a041316..20964d285 100644 --- a/src/main/resources/i18n/msg_zh.properties +++ b/src/main/resources/i18n/msg_zh.properties @@ -98,4 +98,6 @@ app.label.coupons=可用优惠券 sys.contract.ordinary.info=尊敬的商户,您与ROYALPAY的服务合同已到期,为了不影响您的正常使用,请尽快联系您的主管或使用管理员账户登录以便进行服务续约 sys.contract.ordinary.waring=尊敬的商户,您与ROYALPAY的服务合同还有{0}天到期,为了不影响您的正常使用,请尽快联系您的主管或使用管理员账户登录以便进行服务续约 sys.contract.waring=尊敬的商户,您与ROYALPAY的服务合同还有{0}天到期,为了不影响您的正常使用,请查看最新服务协议进行续约。 -sys.contract.info=尊敬的商户,您与ROYALPAY的服务合同已到期,为了不影响您的正常使用,请查看最新服务协议进行续约。 \ No newline at end of file +sys.contract.info=尊敬的商户,您与ROYALPAY的服务合同已到期,为了不影响您的正常使用,请查看最新服务协议进行续约。 + +sys.mondelay.cancel.waring=商户取消活动警告 \ No newline at end of file diff --git a/src/main/resources/templates/activity/mondelay/mondelay.html b/src/main/resources/templates/activity/mondelay/mondelay.html index d2350f0ff..e21edce0b 100644 --- a/src/main/resources/templates/activity/mondelay/mondelay.html +++ b/src/main/resources/templates/activity/mondelay/mondelay.html @@ -111,6 +111,8 @@ \ No newline at end of file diff --git a/src/main/ui/manage.html b/src/main/ui/manage.html index e6057232c..74127442d 100644 --- a/src/main/ui/manage.html +++ b/src/main/ui/manage.html @@ -338,6 +338,12 @@ margin-bottom: 10%;"/> 余额增值活动 +
  • + + 合同签约情况 + +
  • +
  • @@ -417,7 +423,6 @@ margin-bottom: 10%;"/> 网站管理|Site Manage
  • -
  • 积分商城|Integral Mall diff --git a/src/main/ui/static/actapp/app_act_list.js b/src/main/ui/static/actapp/app_act_list.js index 35cc04915..95af59c10 100644 --- a/src/main/ui/static/actapp/app_act_list.js +++ b/src/main/ui/static/actapp/app_act_list.js @@ -36,7 +36,7 @@ define(['angular', 'static/commons/commons', 'uiBootstrap', 'uiRouter', 'ngBootS $scope.act = {}; $scope.act.act_id = act.act_id; $scope.act.is_valid = !act.is_valid; - $http.put('/manager/app/act/' + $scope.act.act_id, $scope.act).then(function (resp) { + $http.put('/manager/app/act/published/'+$scope.act.act_id, $scope.act.is_valid).then(function (resp) { commonDialog.alert({title: 'Success', content: '修改成功', type: 'success'}); $scope.loadActAppList(1); }, function (resp) { @@ -65,7 +65,13 @@ define(['angular', 'static/commons/commons', 'uiBootstrap', 'uiRouter', 'ngBootS if ($scope.actDetail.expire_date) { $scope.actDetail.expire_date = $filter('date')($scope.actDetail.expire_date, 'yyyy-MM-dd'); } - $http.put('/manager/app/act/new', $scope.actDetail).then(function (resp) { + if ($scope.actDetail.msg_start_date) { + $scope.actDetail.msg_start_date = $filter('date')($scope.actDetail.msg_start_date, 'yyyy-MM-dd'); + } + if ($scope.actDetail.msg_end_date) { + $scope.actDetail.msg_end_date = $filter('date')($scope.actDetail.msg_end_date, 'yyyy-MM-dd'); + } + $http.put('/manager/app/act', $scope.actDetail).then(function (resp) { commonDialog.alert({title: 'Success', content: '新增成功', type: 'success'}); $state.go('^.detail',{act_id:resp.data.act_id},{reload:true}); }, function (resp) { @@ -78,6 +84,12 @@ define(['angular', 'static/commons/commons', 'uiBootstrap', 'uiRouter', 'ngBootS $scope.ctrl = {dateInput: false}; $scope.actDetail.active_date = new Date($scope.actDetail.active_date); $scope.actDetail.expire_date = new Date($scope.actDetail.expire_date); + if($scope.actDetail.msg_start_date){ + $scope.actDetail.msg_start_date = new Date($scope.actDetail.msg_start_date); + } + if($scope.actDetail.msg_end_date){ + $scope.actDetail.msg_end_date = new Date($scope.actDetail.msg_end_date); + } $scope.submit = function () { if ($scope.actDetail.active_date) { $scope.actDetail.active_date = $filter('date')($scope.actDetail.active_date, 'yyyy-MM-dd'); @@ -85,6 +97,12 @@ define(['angular', 'static/commons/commons', 'uiBootstrap', 'uiRouter', 'ngBootS if ($scope.actDetail.expire_date) { $scope.actDetail.expire_date = $filter('date')($scope.actDetail.expire_date, 'yyyy-MM-dd'); } + if ($scope.actDetail.msg_start_date) { + $scope.actDetail.msg_start_date = $filter('date')($scope.actDetail.msg_start_date, 'yyyy-MM-dd'); + } + if ($scope.actDetail.msg_end_date) { + $scope.actDetail.msg_end_date = $filter('date')($scope.actDetail.msg_end_date, 'yyyy-MM-dd'); + } $http.put('/manager/app/act/' + $scope.actDetail.act_id, $scope.actDetail).then(function (resp) { commonDialog.alert({title: 'Success', content: '修改成功', type: 'success'}); $state.reload(); diff --git a/src/main/ui/static/actapp/templates/act_app_detail.html b/src/main/ui/static/actapp/templates/act_app_detail.html index 920accbcf..9e38d9e32 100644 --- a/src/main/ui/static/actapp/templates/act_app_detail.html +++ b/src/main/ui/static/actapp/templates/act_app_detail.html @@ -3,9 +3,9 @@

    APP_ACTIVITY

    @@ -44,8 +44,7 @@
    - +
    +
    + +
    +
    + +
    + ~ +
    + +
    +
    +
    + +
    + +
    +
    + + H +
    +
    +
    +
    + +
    + +
    +

    Bank Account

    diff --git a/src/main/ui/static/sys/contract.js b/src/main/ui/static/sys/contract.js new file mode 100644 index 000000000..76425cae3 --- /dev/null +++ b/src/main/ui/static/sys/contract.js @@ -0,0 +1,54 @@ +/** + * Created by yishuqian on 01/06/2017. + */ +define(['angular'], function (angular) { + 'use strict'; + var app = angular.module('contractApp', ['ui.router']); + app.config(['$stateProvider', function ($stateProvider) { + $stateProvider.state('contract', { + url: '/contract', + templateUrl: '/static/sys/templates/contract_sign.html', + controller: 'contractAnalysisCtrl' + }).state('rate_warnings', { + url: '/rate_warnings', + templateUrl: '/static/analysis/templates/settle_warnings.html', + controller: 'settleWarningsCtrl' + }) + }]); + app.controller('contractAnalysisCtrl', ['$scope', '$http', '$state', '$filter', 'commonDialog', function ($scope, $http, $state, $filter, commonDialog) { + $scope.getContractAnalysis = function () { + $http.get('/manage/contract/list').then(function (resp) { + $scope.contract_analysis = resp.data; + }); + }; + $scope.getContractAnalysis(); + }]); + + app.controller('settleWarningsCtrl', ['$scope', '$http', '$filter', 'commonDialog', function ($scope, $http, $filter, commonDialog) { + $scope.loadWarnings = function () { + $http.get('/manage/clearing/rate_warnings').then(function (resp) { + $scope.warning = resp.data; + }) + }; + $scope.loadWarnings(); + $scope.generateRate = function (client) { + commonDialog.confirm({title: 'Confirm Required', content: '根据上季度总交易额自动计算下周期费率,确定执行?'}).then(function () { + $http.put('/manage/clearing/clients/' + client.client_moniker + '/auto_rate').then(function (resp) { + var content = 'New Rate value=' + resp.data.rate_value + '; expiry_time=' + $filter('date')(resp.data.expiry_time, 'dd/MMM/yyyy'); + commonDialog.alert({ + type: 'success', + title: 'New Rate Generated', + content: content + }).then(function () { + $scope.loadWarnings(); + }); + + }, function (resp) { + commonDialog.alert({type: 'error', title: 'Error', content: resp.data.message}); + }) + }) + } + }]); + + return app; +}); \ No newline at end of file diff --git a/src/main/ui/static/sys/templates/contract_sign.html b/src/main/ui/static/sys/templates/contract_sign.html new file mode 100644 index 000000000..ea28a6db7 --- /dev/null +++ b/src/main/ui/static/sys/templates/contract_sign.html @@ -0,0 +1,35 @@ + + + + \ No newline at end of file diff --git a/src/test/java/au/com/royalpay/payment/manage/valid/TestI18N.java b/src/test/java/au/com/royalpay/payment/manage/valid/TestI18N.java new file mode 100644 index 000000000..23acc14a3 --- /dev/null +++ b/src/test/java/au/com/royalpay/payment/manage/valid/TestI18N.java @@ -0,0 +1,23 @@ +package au.com.royalpay.payment.manage.valid; + +/** + * Create by yixian at 2018-03-21 10:36 + */ + +import au.com.royalpay.payment.tools.locale.LocaleSupport; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.test.context.ActiveProfiles; +import org.springframework.test.context.junit4.SpringRunner; + +@SpringBootTest +@ActiveProfiles({ "local", "alipay", "wechat", "jd", "bestpay" }) +@RunWith(SpringRunner.class) +public class TestI18N { + + @Test + public void test(){ + System.out.println("------------------------"+ LocaleSupport.localeMessage("manual_settle.notice")); + } +}