|
|
@@ -615,10 +615,19 @@ public class OrderServiceImpl extends ServiceImpl<OrderMapper, Order> implements
|
|
|
order.setStatus(3);
|
|
|
baseMapper.updateById(order);
|
|
|
|
|
|
+ //不需要计算返利
|
|
|
+ if((order.getThisUsedProfit()==null|| order.getThisUsedProfit().compareTo(new BigDecimal("0"))==0) && (order.getCreateProfit()==null|| order.getCreateProfit().compareTo(new BigDecimal("0"))==0))
|
|
|
+ {
|
|
|
+ return;
|
|
|
+ }
|
|
|
//检查是否使用返利,如果使用返利
|
|
|
BasicCorpsProfitChange basicCorpsProfitChange=new BasicCorpsProfitChange();
|
|
|
+ basicCorpsProfitChange.setCorpId(order.getCorpId());
|
|
|
basicCorpsProfitChange.setOrderId(order.getId());
|
|
|
basicCorpsProfitChange.setOrderNo(order.getOrderNo());
|
|
|
+ basicCorpsProfitChange.setCreateTime(new Date());
|
|
|
+ basicCorpsProfitChange.setCreateUser(AuthUtil.getUserId());
|
|
|
+ //有返利
|
|
|
if(order.getThisUsedProfit()!=null && order.getThisUsedProfit().compareTo(BigDecimal.ZERO)==1)
|
|
|
{
|
|
|
//增加客户的总返利
|
|
|
@@ -629,10 +638,11 @@ public class OrderServiceImpl extends ServiceImpl<OrderMapper, Order> implements
|
|
|
basicCorpsProfitChange.setChangeSurplusProfit(order.getThisUsedProfit().negate());
|
|
|
}
|
|
|
//检查是否含有产生返利,如果有, 需要增加客户的本月待到账返利
|
|
|
- if(order.getCreateProfit()!=null && order.getCreateProfit().compareTo(BigDecimal.ZERO)==1)
|
|
|
+ if(order.getCreateProfit()!=null && order.getCreateProfit().compareTo(BigDecimal.ZERO)==1)
|
|
|
{
|
|
|
- //增加客户的月返利
|
|
|
- basicCorpsProfitChange.setChangeMonthProfit(order.getCreateProfit());
|
|
|
+ //增加客户的月返利
|
|
|
+ basicCorpsProfitChange.setChangeMonthProfit(order.getCreateProfit());
|
|
|
+
|
|
|
}
|
|
|
//新增返利变动记录
|
|
|
R save = corpsProfitChangeClient.save(basicCorpsProfitChange);
|
|
|
@@ -640,18 +650,34 @@ public class OrderServiceImpl extends ServiceImpl<OrderMapper, Order> implements
|
|
|
{
|
|
|
throw new SecurityException("保存返利变动记录失败");
|
|
|
}
|
|
|
-
|
|
|
-
|
|
|
+ //修改客户返利
|
|
|
R<CorpsDesc> corpMessage = corpsDescClient.getCorpMessage(order.getCorpId());
|
|
|
if(!corpMessage.isSuccess()||corpMessage.getData()==null)
|
|
|
{
|
|
|
throw new SecurityException("未查到客户记录");
|
|
|
}
|
|
|
CorpsDesc corpsDesc = corpMessage.getData();
|
|
|
- corpsDesc.setProfitReturn(basicCorpsProfitChange.getChangeProfitReturn()==null?BigDecimal.ZERO.add(corpsDesc.getProfitReturn()):basicCorpsProfitChange.getChangeProfitReturn().add(corpsDesc.getProfitReturn()));
|
|
|
- corpsDesc.setUsedProfit(basicCorpsProfitChange.getChangeUsedProfit()==null?BigDecimal.ZERO.add(corpsDesc.getUsedProfit()):basicCorpsProfitChange.getChangeUsedProfit().add(corpsDesc.getUsedProfit()));
|
|
|
- corpsDesc.setSurplusProfit(basicCorpsProfitChange.getChangeSurplusProfit()==null?BigDecimal.ZERO.add(corpsDesc.getSurplusProfit()):basicCorpsProfitChange.getChangeSurplusProfit().add(corpsDesc.getSurplusProfit()));
|
|
|
- corpsDesc.setMonthProfit(basicCorpsProfitChange.getChangeMonthProfit()==null?BigDecimal.ZERO.add(corpsDesc.getMonthProfit()):basicCorpsProfitChange.getChangeMonthProfit().add(corpsDesc.getMonthProfit()));
|
|
|
+ corpsDesc.setProfitReturn(basicCorpsProfitChange.getChangeProfitReturn()==null?new BigDecimal("0").add(corpsDesc.getProfitReturn()):basicCorpsProfitChange.getChangeProfitReturn().add(corpsDesc.getProfitReturn()));
|
|
|
+ corpsDesc.setUsedProfit(basicCorpsProfitChange.getChangeUsedProfit()==null?new BigDecimal("0").add(corpsDesc.getUsedProfit()):basicCorpsProfitChange.getChangeUsedProfit().add(corpsDesc.getUsedProfit()));
|
|
|
+ corpsDesc.setSurplusProfit(basicCorpsProfitChange.getChangeSurplusProfit()==null?new BigDecimal("0").add(corpsDesc.getSurplusProfit()):basicCorpsProfitChange.getChangeSurplusProfit().add(corpsDesc.getSurplusProfit()));
|
|
|
+ corpsDesc.setMonthProfit(basicCorpsProfitChange.getChangeMonthProfit()==null?new BigDecimal("0").add(corpsDesc.getMonthProfit()):basicCorpsProfitChange.getChangeMonthProfit().add(corpsDesc.getMonthProfit()));
|
|
|
+
|
|
|
+ if(corpsDesc.getProfitReturn().compareTo(new BigDecimal("0"))==-1)
|
|
|
+ {
|
|
|
+ throw new SecurityException("修改客户返利失败:总返利不能为负数");
|
|
|
+ }
|
|
|
+ if(corpsDesc.getUsedProfit().compareTo(new BigDecimal("0"))==-1)
|
|
|
+ {
|
|
|
+ throw new SecurityException("修改客户返利失败:已用返利不能为负数");
|
|
|
+ }
|
|
|
+ if(corpsDesc.getSurplusProfit().compareTo(new BigDecimal("0"))==-1)
|
|
|
+ {
|
|
|
+ throw new SecurityException("修改客户返利失败:可用返利不能为负数");
|
|
|
+ }
|
|
|
+ if(corpsDesc.getMonthProfit().compareTo(new BigDecimal("0"))==-1)
|
|
|
+ {
|
|
|
+ throw new SecurityException("修改客户返利失败:本月待到账返利不能为负数");
|
|
|
+ }
|
|
|
//更新客户返利情况
|
|
|
R corpsUpdate = corpsDescClient.corpsUpdate(corpsDesc);
|
|
|
if(!corpsUpdate.isSuccess())
|
|
|
@@ -659,6 +685,9 @@ public class OrderServiceImpl extends ServiceImpl<OrderMapper, Order> implements
|
|
|
throw new SecurityException("更新客户返利信息失败");
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
}
|
|
|
|
|
|
@Override
|