增加二级组织费率限制

master
yuan 7 years ago
parent ce38db718d
commit d4a251a395

@ -12,6 +12,7 @@ import com.alibaba.fastjson.JSONObject;
import com.github.miemiedev.mybatis.paginator.domain.Order; import com.github.miemiedev.mybatis.paginator.domain.Order;
import com.github.miemiedev.mybatis.paginator.domain.PageBounds; import com.github.miemiedev.mybatis.paginator.domain.PageBounds;
import com.github.miemiedev.mybatis.paginator.domain.PageList; import com.github.miemiedev.mybatis.paginator.domain.PageList;
import org.apache.commons.lang3.StringUtils;
import org.apache.ibatis.annotations.Param; import org.apache.ibatis.annotations.Param;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
@ -81,6 +82,7 @@ public class OrgManagerImpl implements OrgManager {
@Override @Override
public JSONObject saveNewOrg(OrgInfo org) { public JSONObject saveNewOrg(OrgInfo org) {
JSONObject json = org.toJSON(); JSONObject json = org.toJSON();
checkOrgRate(json);
json.put("is_valid", 1); json.put("is_valid", 1);
json.put("sort_no", orgMapper.listAllOrgs().size()); json.put("sort_no", orgMapper.listAllOrgs().size());
json.put("create_time",new Date()); json.put("create_time",new Date());
@ -91,6 +93,7 @@ public class OrgManagerImpl implements OrgManager {
@Override @Override
public void updateOrg(int orgId, OrgInfo org) { public void updateOrg(int orgId, OrgInfo org) {
JSONObject json = org.toJSON(); JSONObject json = org.toJSON();
checkOrgRate(json);
json.put("org_id", orgId); json.put("org_id", orgId);
orgMapper.updateOrg(json); orgMapper.updateOrg(json);
} }
@ -200,4 +203,37 @@ public class OrgManagerImpl implements OrgManager {
params.put("org_id",params.getString("org_id")); params.put("org_id",params.getString("org_id"));
} }
} }
private void checkOrgRate(JSONObject json){
if(StringUtils.isNotEmpty(json.getString("parent_org_id"))&&json.getIntValue("commission_type")==1){
JSONObject orgObject = orgMapper.findOne(json.getIntValue("parent_org_id"));
String rateNames = "";
JSONArray rate1 = new JSONArray();
JSONArray rate2 = new JSONArray();
if(orgObject.getString("commission_type").equals(json.getString("commission_type"))){
String[] rates = new String[]{"alipay_rate_value","wechat_rate_value","bestpay_rate_value","alipayonline_rate_value","jd_rate_value"};
for (String rateName: rates ){
if(StringUtils.isEmpty(orgObject.getString(rateName))){
rate1.add(rateName);
}
if(StringUtils.isEmpty(json.getString(rateName))){
rate2.add(rateName);
}
if(StringUtils.isNotEmpty(orgObject.getString(rateName))&&StringUtils.isNotEmpty(json.getString(rateName))){
if(orgObject.getDouble(rateName).compareTo(json.getDouble(rateName)) > 0){
rateNames += rateName +",";
}
}
}
}
if(rate1.size()>0){
throw new ForbiddenException("费率异常,请联系管理员");
}
if(rate2.size()>0){
throw new ForbiddenException("费率输入不完整,请重新输入");
}
if(!rateNames.equals("")){
throw new ForbiddenException("二级组织"+rateNames+"费率参数应大于一级组织费率,请重新输入");
}
}
}
} }

Loading…
Cancel
Save