master
yixian 7 years ago
parent de40d0d0ea
commit 4c6fbed61c

@ -38,10 +38,6 @@ public class ManualSettleSupportImpl implements ManualSettleSupport {
public JSONObject requestManualSettle(Date settleTo, String accountId) {
JSONObject account = clientAccountMapper.findById(accountId);
int clientId = account.getIntValue("client_id");
JSONObject client = merchantInfoProvider.getClientInfo(clientId);
if (!client.getBooleanValue("manual_settle")) {
throw new ForbiddenException("Manual Settlement Not Enabled");
}
if (DateUtils.isSameDay(new Date(), settleTo)) {
throw new BadRequestException("Cannot settle today's transactions");
}
@ -62,6 +58,10 @@ public class ManualSettleSupportImpl implements ManualSettleSupport {
@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"));

@ -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");
}
}
}
Loading…
Cancel
Save