|
|
@@ -32,13 +32,11 @@ import org.springblade.check.dto.AuditProecessDTO;
|
|
|
import org.springblade.check.entity.AuditPathsActs;
|
|
|
import org.springblade.check.entity.AuditPathsLevels;
|
|
|
import org.springblade.check.feign.ICheckClient;
|
|
|
+import org.springblade.client.entity.BasicCorpsProfitChange;
|
|
|
import org.springblade.client.entity.CorpsDesc;
|
|
|
import org.springblade.client.entity.FeesDesc;
|
|
|
import org.springblade.client.entity.GoodsDesc;
|
|
|
-import org.springblade.client.feign.ICorpsDescClient;
|
|
|
-import org.springblade.client.feign.IFeesDescClient;
|
|
|
-import org.springblade.client.feign.IGoodsDescClient;
|
|
|
-import org.springblade.client.feign.ISerialClient;
|
|
|
+import org.springblade.client.feign.*;
|
|
|
import org.springblade.core.secure.utils.AuthUtil;
|
|
|
import org.springblade.core.secure.utils.SecureUtil;
|
|
|
import org.springblade.core.tool.api.R;
|
|
|
@@ -83,6 +81,7 @@ public class OrderServiceImpl extends ServiceImpl<OrderMapper, Order> implements
|
|
|
private ICorpsDescClient corpsDescClient;//获取客户信息
|
|
|
private OrderMapper orderMapper;
|
|
|
private final ICheckClient iCheckClient;
|
|
|
+ private ICorpsProfitChangeClient corpsProfitChangeClient;
|
|
|
@Override
|
|
|
public IPage<OrderVO> selectOrderPage(IPage<OrderVO> page, OrderVO order) {
|
|
|
List<OrderVO> orderVOList = baseMapper.selectOrderPage(page, order);
|
|
|
@@ -210,7 +209,7 @@ public class OrderServiceImpl extends ServiceImpl<OrderMapper, Order> implements
|
|
|
return x.add(y.getPurchaseAmount().multiply(y.getOrderQuantity()));
|
|
|
},BigDecimal::add);//采购金额求和
|
|
|
BigDecimal amount = list.stream().map(OrderItems::getAmount).reduce(BigDecimal.ZERO, BigDecimal::add);//金额求和
|
|
|
- BigDecimal grossProfit = amount.subtract(reduce.add(order.getPredictOceanFreight()));//毛利润
|
|
|
+ BigDecimal grossProfit = amount.subtract(reduce.add(order.getPredictOceanFreight())).subtract(order.getThisUsedProfit());
|
|
|
BigDecimal grossProfitRate = new BigDecimal(BigInteger.ZERO);
|
|
|
if (amount.compareTo(BigDecimal.ZERO) > 0){
|
|
|
grossProfitRate = (grossProfit.divide(amount,2)).multiply(new BigDecimal(100));
|
|
|
@@ -600,6 +599,8 @@ public class OrderServiceImpl extends ServiceImpl<OrderMapper, Order> implements
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
+ @Transactional
|
|
|
+ @GlobalTransactional
|
|
|
public void passCheck(Long id)
|
|
|
{
|
|
|
LambdaQueryWrapper<Order> orderLambdaQueryWrapper=new LambdaQueryWrapper<>();
|
|
|
@@ -613,6 +614,80 @@ 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)
|
|
|
+ {
|
|
|
+ //增加客户的总返利
|
|
|
+ /*basicCorpsProfitChange.setChangeProfitReturn(order.getThisUsedProfit());*/
|
|
|
+ //增加客户的已用返利
|
|
|
+ basicCorpsProfitChange.setChangeUsedProfit(order.getThisUsedProfit());
|
|
|
+ //减少客户的可用返利
|
|
|
+ basicCorpsProfitChange.setChangeSurplusProfit(order.getThisUsedProfit().negate());
|
|
|
+ }
|
|
|
+ //检查是否含有产生返利,如果有, 需要增加客户的本月待到账返利
|
|
|
+ if(order.getCreateProfit()!=null && order.getCreateProfit().compareTo(BigDecimal.ZERO)==1)
|
|
|
+ {
|
|
|
+ //增加客户的月返利
|
|
|
+ basicCorpsProfitChange.setChangeMonthProfit(order.getCreateProfit());
|
|
|
+
|
|
|
+ }
|
|
|
+ //新增返利变动记录
|
|
|
+ R save = corpsProfitChangeClient.save(basicCorpsProfitChange);
|
|
|
+ if(!save.isSuccess())
|
|
|
+ {
|
|
|
+ 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?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())
|
|
|
+ {
|
|
|
+ throw new SecurityException("更新客户返利信息失败");
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
}
|
|
|
|
|
|
@Override
|