|
@@ -23,6 +23,7 @@ import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
|
|
|
import javax.servlet.http.HttpServletRequest;
|
|
|
+import java.math.BigDecimal;
|
|
|
import java.text.SimpleDateFormat;
|
|
|
import java.util.*;
|
|
|
|
|
@@ -273,4 +274,89 @@ public class WithdrawalRecordController {
|
|
|
|
|
|
return msgResult;
|
|
|
}
|
|
|
+
|
|
|
+ @ApiOperation(value="审核")
|
|
|
+ @RequestMapping(value = "approval",method = RequestMethod.POST)
|
|
|
+ public MessageResult<String> approval(
|
|
|
+ String id,String status,
|
|
|
+ @RequestAttribute String subject) throws Exception{
|
|
|
+
|
|
|
+ //当前用户ID
|
|
|
+ System.out.println(subject);
|
|
|
+
|
|
|
+ MessageResult<String> msgResult = new MessageResult<>();
|
|
|
+
|
|
|
+ try{
|
|
|
+
|
|
|
+ WithdrawalRecord wr = withdrawalRecordService.get(id);
|
|
|
+ if(wr == null){
|
|
|
+ throw new Exception("查无此项申请!");
|
|
|
+ }
|
|
|
+
|
|
|
+ AccountInfo ai = accountInfoService.get(wr.getMerchantId());
|
|
|
+ if(ai == null){
|
|
|
+ throw new Exception("查无此营收用户!");
|
|
|
+ }
|
|
|
+
|
|
|
+ CapitalInfo ci = capitalInfoService.findByMerchantId(wr.getMerchantId());
|
|
|
+ if(ci == null){
|
|
|
+ ci = new CapitalInfo();
|
|
|
+ ci.setId(UUID.randomUUID().toString());
|
|
|
+ ci.setMerchantId(wr.getMerchantId());
|
|
|
+ ci.setAlreadyWithdrawalAmount(new BigDecimal(0));
|
|
|
+ ci.setOnlineTotalRevenue(new BigDecimal(0));
|
|
|
+ ci.setTotalRevenue(new BigDecimal(0));
|
|
|
+ ci.setWithdrawalAmount(new BigDecimal(0));
|
|
|
+
|
|
|
+ ci.setDelFlag(false);
|
|
|
+ ci.setCreateBy(subject);
|
|
|
+ ci.setCreateTime(new Date());
|
|
|
+ capitalInfoService.insert(ci);
|
|
|
+
|
|
|
+ throw new Exception("该用户账户有误!");
|
|
|
+ }else{
|
|
|
+ if("1".equals(status)){
|
|
|
+ //withdrawal_amount 可提现金额
|
|
|
+ //already_withdrawal_amount 已提现金额
|
|
|
+ BigDecimal withdrawalAmount = ci.getWithdrawalAmount();
|
|
|
+ BigDecimal alreadyWithdrawalAmount = ci.getAlreadyWithdrawalAmount();
|
|
|
+ //正在提现金额
|
|
|
+ BigDecimal applyWithdrawalAmount = wr.getApplyWithdrawalAmount();
|
|
|
+
|
|
|
+ if(withdrawalAmount.compareTo(applyWithdrawalAmount) < 0 ) {
|
|
|
+ //小于
|
|
|
+ throw new Exception("可提现金额不足");
|
|
|
+ }else{
|
|
|
+ BigDecimal newWithdrawalAmount = withdrawalAmount.subtract(applyWithdrawalAmount);
|
|
|
+ BigDecimal newAlreadyWithdrawalAmount = alreadyWithdrawalAmount.add(applyWithdrawalAmount);
|
|
|
+
|
|
|
+ ci.setWithdrawalAmount(newWithdrawalAmount);
|
|
|
+ ci.setAlreadyWithdrawalAmount(newAlreadyWithdrawalAmount);
|
|
|
+ ci.setUpdateBy(subject);
|
|
|
+ ci.setUpdateTime(new Date());
|
|
|
+
|
|
|
+ capitalInfoService.update(ci);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ wr.setStatus(status);
|
|
|
+ wr.setUpdateBy(subject);
|
|
|
+ wr.setUpdateTime(new Date());
|
|
|
+ wr.setExamineBy(subject);
|
|
|
+ wr.setExamineTime(new Date());
|
|
|
+ withdrawalRecordService.update(wr);
|
|
|
+ }
|
|
|
+
|
|
|
+ msgResult.setResult(true);
|
|
|
+ msgResult.setMessage("审核完成");
|
|
|
+ }
|
|
|
+ catch(Exception ex){
|
|
|
+ logger.error(ex.getMessage(),ex);
|
|
|
+
|
|
|
+ msgResult.setResult(false);
|
|
|
+ msgResult.setMessage(ex.getMessage());
|
|
|
+ }
|
|
|
+
|
|
|
+ return msgResult;
|
|
|
+ }
|
|
|
}
|