parent
de40d0d0ea
commit
4c6fbed61c
@ -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…
Reference in new issue