Browse Source

修正新建比例保存失败的bug

master
xyiege 4 years ago
parent
commit
985db31013
  1. 2
      src/main/java/cn/chjyj/szwh/service/AccountCloseService.java
  2. 34
      src/main/java/cn/chjyj/szwh/service/impl/AccountCloseServiceImpl.java

2
src/main/java/cn/chjyj/szwh/service/AccountCloseService.java

@ -69,7 +69,7 @@ public interface AccountCloseService {
/** /**
* 设置分配比例 * 设置分配比例
* @param ruleName * @param ruleName
* @param jsonArray * @param jslist
* @param adminId * @param adminId
* @return * @return
*/ */

34
src/main/java/cn/chjyj/szwh/service/impl/AccountCloseServiceImpl.java

@ -2,6 +2,7 @@ package cn.chjyj.szwh.service.impl;
import cn.chjyj.szwh.bean.*; import cn.chjyj.szwh.bean.*;
import cn.chjyj.szwh.exception.ChException;
import cn.chjyj.szwh.mapper.*; import cn.chjyj.szwh.mapper.*;
import cn.chjyj.szwh.service.AccountCloseService; import cn.chjyj.szwh.service.AccountCloseService;
import cn.chjyj.szwh.vo.SettleVo; import cn.chjyj.szwh.vo.SettleVo;
@ -286,21 +287,19 @@ public class AccountCloseServiceImpl implements AccountCloseService {
public Map<String, Object> doSettRatio(String ruleName, List<String>jslist, int adminId) { public Map<String, Object> doSettRatio(String ruleName, List<String>jslist, int adminId) {
String msg="成功"; String msg="成功";
int code=200; int code=200;
Date now =new Date();
//组装ratioSetting //组装ratioSetting
AccountRatioSetting act = new AccountRatioSetting(); AccountRatioSetting act = new AccountRatioSetting();
act.setUserId(adminId); act.setUserId(adminId);
act.setRuleName(ruleName); act.setRuleName(ruleName);
act.setCreatetime(now);
// 保存成功,并返回自编号 // 保存成功,并返回自编号
accountRatioSettingMapper.addAcrSetting(act); accountRatioSettingMapper.addAcrSetting(act);
// accountRatioDetail // accountRatioDetail
int sumRation=0;// 统计平台放和委托方的结算比例 int sumRation=0;// 统计平台放和委托方的结算比例
if(sumRation!=100){
code=400;
msg="委托方与平台方比例之和未等于100,创建失败";
}
for(int i=0;i<jslist.size();i++){ for(int i=0;i<jslist.size();i++){
AccountRatioDetail acrd = new AccountRatioDetail(); AccountRatioDetail acrd = new AccountRatioDetail();
@ -314,30 +313,37 @@ public class AccountCloseServiceImpl implements AccountCloseService {
Integer costType=tmpjson.getInteger("cost_type"); Integer costType=tmpjson.getInteger("cost_type");
acrd.setCostType(costType); acrd.setCostType(costType);
// 分配比例值
BigDecimal ratio = new BigDecimal(0);
String sratio=tmpjson.getString("ratio"); String sratio=tmpjson.getString("ratio");
if(StringUtils.isNotBlank(sratio)){ if(StringUtils.isNotBlank(sratio)){
BigDecimal ratio = new BigDecimal(sratio); ratio = new BigDecimal(sratio);
acrd.setRatio(ratio);
// 判断处理
if(roleType==1 || costType==3){
// 仅作整数部分计算
sumRation+=ratio.intValue();
}
} }
acrd.setRatio(ratio);
Integer calculate =tmpjson.getInteger("calculate"); Integer calculate =tmpjson.getInteger("calculate");
acrd.setCalculate(calculate); acrd.setCalculate(calculate);
//金额 //金额
BigDecimal amount=new BigDecimal(0.00);
String samount=tmpjson.getString("amount"); String samount=tmpjson.getString("amount");
if(StringUtils.isNotBlank(samount)){ if(StringUtils.isNotBlank(samount)){
BigDecimal amount=new BigDecimal(samount); amount=new BigDecimal(samount);
}
acrd.setAmount(amount); acrd.setAmount(amount);
//委托方与平台方比例和
if(roleType==1 || roleType == 3){
sumRation += ratio.intValue();
} }
// 入库 // 入库
accountRatioDetailMapper.addAcDetail(acrd); accountRatioDetailMapper.addAcDetail(acrd);
} }
// 检查比例分配和 是否为100%
if(sumRation!=100){
code=400;
msg="委托方与平台方比例之和未等于100,创建失败";
}
Map retmap = new HashMap(); Map retmap = new HashMap();
retmap.put("code",code); retmap.put("code",code);
retmap.put("msg",msg); retmap.put("msg",msg);

Loading…
Cancel
Save