xiaoyong931011
2021-07-14 32169b0b5af53ae87ccde57c31c1d6ad6e44a055
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
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;
    }
}