eason.qian 7 years ago
parent 1dceaae57b
commit d55919af7d

@ -1,21 +1,23 @@
package au.com.royalpay.payment.manage.cashback.web; package au.com.royalpay.payment.manage.cashback.web;
import au.com.royalpay.payment.core.exceptions.InvalidShortIdException;
import au.com.royalpay.payment.manage.analysis.beans.AnalysisBean; import au.com.royalpay.payment.manage.analysis.beans.AnalysisBean;
import au.com.royalpay.payment.manage.cashback.core.CashbackService; import au.com.royalpay.payment.manage.cashback.core.CashbackService;
import au.com.royalpay.payment.manage.merchants.core.ClientManager; import au.com.royalpay.payment.manage.merchants.core.ClientManager;
import au.com.royalpay.payment.manage.permission.manager.PartnerMapping; import au.com.royalpay.payment.manage.permission.manager.PartnerMapping;
import au.com.royalpay.payment.tools.CommonConsts; import au.com.royalpay.payment.tools.CommonConsts;
import au.com.royalpay.payment.tools.exceptions.ForbiddenException;
import au.com.royalpay.payment.tools.permission.enums.PartnerRole;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.web.bind.annotation.ModelAttribute; import org.springframework.web.bind.annotation.*;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import javax.annotation.Resource; import javax.annotation.Resource;
import java.math.BigDecimal;
/** /**
* Created by yishuqian on 01/06/2017. * Created by yishuqian on 01/06/2017.
@ -70,4 +72,24 @@ public class CashbackController {
params.put("client_id", partner.getIntValue("client_id")); params.put("client_id", partner.getIntValue("client_id"));
return cashbackService.getDrawDeposits(params,analysisBean.getPage(),analysisBean.getLimit()); return cashbackService.getDrawDeposits(params,analysisBean.getPage(),analysisBean.getLimit());
} }
@PartnerMapping(value = "/withdraw_deposits",method = RequestMethod.PUT,roles = PartnerRole.ADMIN)
public void drawDeposits(@ModelAttribute(CommonConsts.PARTNER_STATUS) JSONObject partner, @RequestBody JSONObject cashObj){
if (!cashObj.containsKey("draw_amount")||cashObj.getBigDecimal("draw_amount").compareTo(BigDecimal.ZERO)<=0){
throw new InvalidShortIdException();
}
JSONObject obj = new JSONObject();
BigDecimal draw_amount = cashObj.getBigDecimal("draw_amount");
obj.put("client_id",partner.getIntValue("client_id"));
obj.put("account_id",partner.getIntValue("account_id"));
obj.put("display_name",partner.getString("display_name"));
if (cashObj.containsKey("client_id")){
JSONArray clientIds = clientManager.getAllClientIds(partner.getIntValue("client_id"));
if (!clientIds.contains(cashObj.getString("client_id"))){
throw new ForbiddenException("partner has no permission");
}
obj.put("client_id",cashObj.getIntValue("client_id"));
}
cashbackService.drawDeposits(draw_amount,obj.getIntValue("client_id"),obj);
}
} }

Loading…
Cancel
Save