package com.xzx.gc.user.service;
|
|
import cn.hutool.core.collection.CollUtil;
|
import cn.hutool.core.convert.Convert;
|
import com.xzx.gc.common.utils.BusinessUtil;
|
import com.xzx.gc.entity.WeightItemPrice;
|
import com.xzx.gc.user.dto.RayaltyDto;
|
import com.xzx.gc.user.mapper.RebateWeightPriceMapper;
|
import com.xzx.gc.user.mapper.WeightItemPriceMapper;
|
import lombok.extern.slf4j.Slf4j;
|
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.stereotype.Service;
|
import org.springframework.transaction.annotation.Transactional;
|
import tk.mybatis.mapper.entity.Example;
|
|
import java.util.List;
|
|
@Service
|
@Transactional
|
@Slf4j
|
public class WeightItemPriceService {
|
|
@Autowired
|
private BusinessUtil businessUtil;
|
|
@Autowired
|
private WeightItemPriceMapper weightItemPriceMapper;
|
|
/**
|
* 查看回收员的提成
|
* @param receiver
|
* @return
|
*/
|
public RayaltyDto findByReceiver(String receiver){
|
RayaltyDto rayaltyDto=new RayaltyDto();
|
|
Example example=new Example(WeightItemPrice.class);
|
Example.Criteria criteria = example.createCriteria();
|
criteria.andEqualTo("receiver",receiver);
|
criteria.andIn("status",CollUtil.newArrayList("1","3"));
|
List<WeightItemPrice> select = weightItemPriceMapper.selectByExample(example);
|
double sum = select.stream().mapToDouble(x -> Convert.toDouble(x.getSettleMoney(), 0.0)).sum();
|
rayaltyDto.setNotPay(businessUtil.changeMoney(String.valueOf(sum)));
|
|
// if(CollUtil.isNotEmpty(select)){
|
// Map<String, List<WeightItemPrice>> collect = select.stream().collect(Collectors.groupingBy(WeightItemPrice::getPackageId));
|
//
|
// BigDecimal money=Constants.MONEY_INIT;
|
// for (String s : collect.keySet()) {
|
// List<WeightItemPrice> weightItemPrices = collect.get(s);
|
// RebateWeightPrice weightPrice=new RebateWeightPrice();
|
// weightPrice.setPackageId(s);
|
// weightPrice.setDelFlag(Convert.toShort(Constants.DEL_NOT_FLAG));
|
// List<RebateWeightPrice> weightPrice1 = rebateWeightPriceMapper.select(weightPrice);
|
// if(CollUtil.isNotEmpty(weightPrice1)){
|
//
|
// //得到不同类型的物品的每公斤的提成
|
// Dict dict=Dict.create();
|
// for (RebateWeightPrice rebateWeightPrice : weightPrice1) {
|
// String productType = rebateWeightPrice.getProductType();
|
// String money1 = rebateWeightPrice.getMoney();
|
// dict.put(productType,money1);
|
// }
|
//
|
//
|
// //计算总额
|
// for (WeightItemPrice weightItemPrice : weightItemPrices) {
|
// String weight = weightItemPrice.getWeight();
|
// String productType = weightItemPrice.getProductType();
|
// Object o = dict.get(productType);
|
// if(o!=null){
|
// String moneyPer= (String) o;
|
// BigDecimal mul = NumberUtil.mul(Convert.toBigDecimal(weight), Convert.toBigDecimal(moneyPer));
|
// money=NumberUtil.add(money,mul);
|
// }
|
// }
|
// }
|
//
|
// }
|
//
|
// if(money.compareTo(BigDecimal.ZERO)>0){
|
// rayaltyDto.setNotPay(businessUtil.changeMoney(money.toString()));
|
// }
|
//
|
// }
|
|
return rayaltyDto;
|
}
|
}
|