|
|
|
@ -5,6 +5,7 @@ import cn.chjyj.szwh.bean.*; |
|
|
|
import cn.chjyj.szwh.mapper.*; |
|
|
|
import cn.chjyj.szwh.service.AccountCloseService; |
|
|
|
import cn.chjyj.szwh.vo.SettleVo; |
|
|
|
import com.alibaba.fastjson.JSON; |
|
|
|
import com.alibaba.fastjson.JSONArray; |
|
|
|
import com.alibaba.fastjson.JSONObject; |
|
|
|
import org.apache.commons.lang3.StringUtils; |
|
|
|
@ -282,30 +283,31 @@ public class AccountCloseServiceImpl implements AccountCloseService { |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
public Map<String, Object> setRatio(String ruleName, JSONArray jsonArray, int adminId) { |
|
|
|
public Map<String, Object> doSettRatio(String ruleName, List<String>jslist, int adminId) { |
|
|
|
String msg="成功"; |
|
|
|
int code=200; |
|
|
|
//组装ratioSetting
|
|
|
|
AccountRatioSetting act = new AccountRatioSetting(); |
|
|
|
// Calendar calendar = Calendar.getInstance();
|
|
|
|
// Date now = calendar.getTime();
|
|
|
|
// ? 保存格式是否需要调整
|
|
|
|
// act.setCreatetime(now);
|
|
|
|
act.setUserId(adminId); |
|
|
|
act.setRuleName(ruleName); |
|
|
|
// 保存成功,并返回自编号
|
|
|
|
int actId=accountRatioSettingMapper.addAcrSetting(act); |
|
|
|
accountRatioSettingMapper.addAcrSetting(act); |
|
|
|
|
|
|
|
// accountRatioDetail
|
|
|
|
int sumRation=0;// 统计平台放和委托方的结算比例
|
|
|
|
|
|
|
|
for(int i=0;i<jsonArray.size();i++){ |
|
|
|
if(sumRation!=100){ |
|
|
|
code=400; |
|
|
|
msg="委托方与平台方比例之和未等于100,创建失败"; |
|
|
|
} |
|
|
|
|
|
|
|
for(int i=0;i<jslist.size();i++){ |
|
|
|
|
|
|
|
AccountRatioDetail acrd = new AccountRatioDetail(); |
|
|
|
// setting id由上面的返回
|
|
|
|
acrd.setSettingId(act.getId()); |
|
|
|
|
|
|
|
JSONObject tmpjson = (JSONObject) jsonArray.get(i); |
|
|
|
JSONObject tmpjson = JSON.parseObject(jslist.get(i)); |
|
|
|
Integer roleType=tmpjson.getInteger("role_type"); |
|
|
|
acrd.setRoleType(roleType); |
|
|
|
|
|
|
|
@ -317,18 +319,13 @@ public class AccountCloseServiceImpl implements AccountCloseService { |
|
|
|
BigDecimal ratio = new BigDecimal(sratio); |
|
|
|
acrd.setRatio(ratio); |
|
|
|
// 判断处理
|
|
|
|
if((roleType==1 || costType==3) && sumRation!=100){ |
|
|
|
if(roleType==1 || costType==3){ |
|
|
|
// 仅作整数部分计算
|
|
|
|
sumRation+=ratio.intValue(); |
|
|
|
}else{ |
|
|
|
code=400; |
|
|
|
msg="委托方与平台方比例之和未等于100,创建失败"; |
|
|
|
break; //跳出循环
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Integer calculate =tmpjson.getInteger("calculate"); |
|
|
|
acrd.setCalculate(calculate); |
|
|
|
//金额
|
|
|
|
|