|
|
|
@ -6,6 +6,7 @@ import cn.chjyj.szwh.mapper.*; |
|
|
|
import cn.chjyj.szwh.service.AccountCloseService; |
|
|
|
import cn.chjyj.szwh.vo.SettleVo; |
|
|
|
import com.alibaba.fastjson.JSONArray; |
|
|
|
import com.alibaba.fastjson.JSONObject; |
|
|
|
import org.apache.commons.lang3.StringUtils; |
|
|
|
import org.apache.commons.logging.Log; |
|
|
|
import org.apache.commons.logging.LogFactory; |
|
|
|
@ -14,10 +15,7 @@ import org.springframework.stereotype.Service; |
|
|
|
|
|
|
|
import java.math.BigDecimal; |
|
|
|
import java.text.SimpleDateFormat; |
|
|
|
import java.util.ArrayList; |
|
|
|
import java.util.HashMap; |
|
|
|
import java.util.List; |
|
|
|
import java.util.Map; |
|
|
|
import java.util.*; |
|
|
|
|
|
|
|
@Service |
|
|
|
public class AccountCloseServiceImpl implements AccountCloseService { |
|
|
|
@ -282,4 +280,70 @@ public class AccountCloseServiceImpl implements AccountCloseService { |
|
|
|
retmap.put("data",retlist); |
|
|
|
return retmap; |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
public Map<String, Object> setRatio(String ruleName, JSONArray jsonArray, 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); |
|
|
|
|
|
|
|
// accountRatioDetail
|
|
|
|
int sumRation=0;// 统计平台放和委托方的结算比例
|
|
|
|
|
|
|
|
for(int i=0;i<jsonArray.size();i++){ |
|
|
|
|
|
|
|
AccountRatioDetail acrd = new AccountRatioDetail(); |
|
|
|
// setting id由上面的返回
|
|
|
|
acrd.setSettingId(act.getId()); |
|
|
|
|
|
|
|
JSONObject tmpjson = (JSONObject) jsonArray.get(i); |
|
|
|
Integer roleType=tmpjson.getInteger("role_type"); |
|
|
|
acrd.setRoleType(roleType); |
|
|
|
|
|
|
|
Integer costType=tmpjson.getInteger("cost_type"); |
|
|
|
acrd.setCostType(costType); |
|
|
|
|
|
|
|
String sratio=tmpjson.getString("ratio"); |
|
|
|
if(StringUtils.isNotBlank(sratio)){ |
|
|
|
BigDecimal ratio = new BigDecimal(sratio); |
|
|
|
acrd.setRatio(ratio); |
|
|
|
// 判断处理
|
|
|
|
if((roleType==1 || costType==3) && sumRation!=100){ |
|
|
|
// 仅作整数部分计算
|
|
|
|
sumRation+=ratio.intValue(); |
|
|
|
}else{ |
|
|
|
code=400; |
|
|
|
msg="委托方与平台方比例之和未等于100,创建失败"; |
|
|
|
break; //跳出循环
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Integer calculate =tmpjson.getInteger("calculate"); |
|
|
|
acrd.setCalculate(calculate); |
|
|
|
//金额
|
|
|
|
String samount=tmpjson.getString("amount"); |
|
|
|
if(StringUtils.isNotBlank(samount)){ |
|
|
|
BigDecimal amount=new BigDecimal(samount); |
|
|
|
acrd.setAmount(amount); |
|
|
|
} |
|
|
|
// 入库
|
|
|
|
accountRatioDetailMapper.addAcDetail(acrd); |
|
|
|
} |
|
|
|
|
|
|
|
Map retmap = new HashMap(); |
|
|
|
retmap.put("code",code); |
|
|
|
retmap.put("msg",msg); |
|
|
|
return retmap; |
|
|
|
} |
|
|
|
} |
|
|
|
|