huwhois vor 3 Jahren
Ursprung
Commit
ca0d290fd0

+ 25 - 25
src/main/java/io/renren/modules/sales/controller/SaleCommissionController.java

@ -23,7 +23,7 @@ import io.renren.common.utils.PageUtils;
23 23
import io.renren.common.utils.R;
24 24
import io.renren.modules.sales.entity.SaleCommissionEntity;
25 25
import io.renren.modules.sales.entity.SaleOrderEntity;
26
import io.renren.modules.sales.entity.SaleOrderItemCommissionEntity;
26
import io.renren.modules.sales.entity.SaleOrderUnionItemEntity;
27 27
import io.renren.modules.sales.entity.SaleOrderItemEntity;
28 28
import io.renren.modules.sales.entity.SaleSellerFeeEntity;
29 29
import io.renren.modules.sales.service.SaleCommissionService;
@ -184,7 +184,7 @@ public class SaleCommissionController extends AbstractController {
184 184
            return R.error("年月不可为空");
185 185
        }
186 186
187
        List<SaleOrderItemCommissionEntity> commissionlist = saleCommissionService.queryMonthCommissionItemList(params);
187
        List<SaleOrderUnionItemEntity> commissionlist = saleCommissionService.queryMonthCommissionItemList(params);
188 188
189 189
        // 一般总利润
190 190
        BigDecimal hqTotalProfit = new BigDecimal("0.00");
@ -231,28 +231,28 @@ public class SaleCommissionController extends AbstractController {
231 231
            commissionSummaryList.add(commissionSummary);
232 232
        }
233 233
234
        // 业余员提成
235
        for (int k = 0; k < commissionlist.size(); k++) {
236
            SaleOrderItemCommissionEntity commission = commissionlist.get(k);
237
            for (CommissionSummaryUtils commissionSummary : commissionSummaryList) {
238
                if (commission.getSellerId() == commissionSummary.getSellerId()) {
239
                    if (commission.getCommissionType() == 1 && commission.getProfit() != null) {
240
                        commissionSummary
241
                                .setTotalProfit(commissionSummary.getTotalProfit().add(commission.getProfit()));
242
                                hqTotalProfit = hqTotalProfit.add(commission.getProfit());
243
                    }
244
                    if (commission.getCommissionType() == 2 && commission.getMoney() != null) {
245
                        commissionSummary
246
                                .setSpecialMoney(commissionSummary.getSpecialMoney().add(commission.getMoney()));
247
248
                        commissionSummary
249
                                .setSpecialValue(commissionSummary.getSpecialValue().add(commission.getSalesMoney()));
250
251
                        hqTotalSpecialValue = hqTotalSpecialValue.add(commission.getSalesMoney());
252
                    }
253
                }
254
            }
255
        }
234
        // // 业余员提成
235
        // for (int k = 0; k < commissionlist.size(); k++) {
236
        //     SaleOrderUnionItemEntity commission = commissionlist.get(k);
237
        //     for (CommissionSummaryUtils commissionSummary : commissionSummaryList) {
238
        //         if (commission.getSellerId() == commissionSummary.getSellerId()) {
239
        //             if (commission.getCommissionType() == 1 && commission.getProfit() != null) {
240
        //                 commissionSummary
241
        //                         .setTotalProfit(commissionSummary.getTotalProfit().add(commission.getProfit()));
242
        //                         hqTotalProfit = hqTotalProfit.add(commission.getProfit());
243
        //             }
244
        //             if (commission.getCommissionType() == 2 && commission.getMoney() != null) {
245
        //                 commissionSummary
246
        //                         .setSpecialMoney(commissionSummary.getSpecialMoney().add(commission.getMoney()));
247
248
        //                 commissionSummary
249
        //                         .setSpecialValue(commissionSummary.getSpecialValue().add(commission.getSalesMoney()));
250
251
        //                 hqTotalSpecialValue = hqTotalSpecialValue.add(commission.getSalesMoney());
252
        //             }
253
        //         }
254
        //     }
255
        // }
256 256
        for (CommissionSummaryUtils commissionSummary : commissionSummaryList) {
257 257
            commissionSummary.setGeneralMoney(commissionSummary.getTotalProfit()
258 258
                    .subtract(commissionSummary.getOtherFee()).multiply(commissionSummary.getGeneralRatio())
@ -338,7 +338,7 @@ public class SaleCommissionController extends AbstractController {
338 338
            return R.error("年月不可为空");
339 339
        }
340 340
341
        List<SaleOrderItemCommissionEntity> list =  saleCommissionService.queryMonthCommissionItemList(params);
341
        List<SaleOrderUnionItemEntity> list =  saleCommissionService.queryMonthCommissionItemList(params);
342 342
343 343
        return R.ok().put("list", list);
344 344
    }

+ 3 - 3
src/main/java/io/renren/modules/sales/dao/SaleCommissionDao.java

@ -1,6 +1,6 @@
1 1
package io.renren.modules.sales.dao;
2 2
3
import io.renren.modules.sales.entity.SaleOrderItemCommissionEntity;
3
import io.renren.modules.sales.entity.SaleOrderUnionItemEntity;
4 4
import io.renren.modules.sales.utils.CommissionSummaryUtils;
5 5
import io.renren.modules.sales.entity.SaleCommissionEntity;
6 6
@ -34,10 +34,10 @@ public interface SaleCommissionDao extends BaseMapper<SaleCommissionEntity> {
34 34
    + "truncate(ifnull(((select sum(`p`.`pay_money`) from `sy_sale_order_payment` `p` where (`soi`.`id` = `p`.`order_item_id`)) / 100),0),2) AS `pay_money`,"
35 35
    + "truncate(ifnull(((select sum(`t`.`fare`) from `sy_sale_order_transport` `t` where (`soi`.`id` = `t`.`order_item_id`)) / 100),0),2) AS `fare`"
36 36
    + " from (`sy_sale_commission` `sc` join `sy_sale_order_item` `soi` on((`sc`.`order_id` = `soi`.`order_id`))) ${ew.customSqlSegment}")
37
    List<SaleOrderItemCommissionEntity> queryMonthCommissionItemList(@Param(Constants.WRAPPER) QueryWrapper<SaleOrderItemCommissionEntity> ew);
37
    List<SaleOrderUnionItemEntity> queryMonthCommissionItemList(@Param(Constants.WRAPPER) QueryWrapper<SaleOrderUnionItemEntity> ew);
38 38
39 39
    List<CommissionSummaryUtils> querySellerGroupCommission(Integer year, Integer month, int i);
40 40
41 41
    @Delete("delete from sy_sale_commission where order_id=#{orderId}")
42
	void removeByOrderId(Long orderId);
42
    void removeByOrderId(Long orderId);
43 43
}

+ 1 - 1
src/main/java/io/renren/modules/sales/entity/SaleOrderEntity.java

@ -36,7 +36,7 @@ public class SaleOrderEntity implements Serializable {
36 36
    @TableId
37 37
    private Long id;
38 38
    /**
39
     * 序号, 格式 MHTNO
39
     * 序号, 格式 yyyymmno
40 40
     */
41 41
    private String no;
42 42
    /**

+ 0 - 156
src/main/java/io/renren/modules/sales/entity/SaleOrderItemCommissionEntity.java

@ -1,156 +0,0 @@
1
package io.renren.modules.sales.entity;
2
3
import com.baomidou.mybatisplus.annotation.TableField;
4
import com.baomidou.mybatisplus.annotation.TableId;
5
import com.baomidou.mybatisplus.annotation.TableName;
6
7
import java.math.BigDecimal;
8
import java.io.Serializable;
9
import java.util.Date;
10
11
import io.renren.convert.YuanToFenTypeHandler;
12
13
import lombok.Data;
14
15
/**
16
 * 销售订单产品明细  提成实体类
17
 * 
18
 * @author huwhois
19
 * @email huwhois@163.com
20
 * @date 2021-04-14 11:03:56
21
 */
22
@Data
23
@TableName(value = "sy_sale_order_item", autoResultMap = true)
24
public class SaleOrderItemCommissionEntity implements Serializable {
25
    private static final long serialVersionUID = 1L;
26
27
    /**
28
     * id
29
     */
30
    @TableId
31
    private Long id;
32
    /**
33
     * 订单id
34
     */
35
    private Long orderId;
36
    /**
37
     * 种类名称
38
     */
39
    private String productsCategoryName;
40
    /**
41
     * 产品名称
42
     */
43
    private String productsName;
44
    /**
45
     * 产品价格 单位元(数据库存整数分, 下同)
46
     */
47
    @TableField(typeHandler = YuanToFenTypeHandler.class)
48
    private BigDecimal productsPrice;
49
    /**
50
     * 销售数量(单位KG/台)
51
     */
52
    private BigDecimal salesAmount;
53
    /**
54
     * 销售价格 单位元
55
     */
56
    @TableField(typeHandler = YuanToFenTypeHandler.class)
57
    private BigDecimal salesPrice;
58
    /**
59
     * 销售金额
60
     */
61
    @TableField(typeHandler = YuanToFenTypeHandler.class)
62
    private BigDecimal salesMoney;
63
    /**
64
     * 实际发货量(单位KG/台)
65
     */
66
    // private BigDecimal actualAmount;
67
    /**
68
     * 实际成交价格, 单位元
69
     */
70
    // @TableField(typeHandler = YuanToFenTypeHandler.class)
71
    // private BigDecimal actualPrice;
72
    /**
73
     * 实际金额, 单位元
74
     */
75
    // @TableField(typeHandler = YuanToFenTypeHandler.class)
76
    // private BigDecimal actualMoney;
77
    /**
78
     * 代理费
79
     */
80
    @TableField(typeHandler = YuanToFenTypeHandler.class)
81
    private BigDecimal agency;
82
    /**
83
     * 其他费用
84
     */
85
    @TableField(typeHandler = YuanToFenTypeHandler.class)
86
    private BigDecimal otherFee;
87
    /**
88
     * 提成类别: 1,一般, 2, 特批1, 3, 特批2
89
     */
90
    private Integer commissionType;
91
    /**
92
     * 合同号
93
     */
94
    @TableField(exist = false)
95
    private String contractNo;
96
    /**
97
     * 销售时间
98
     */
99
    @TableField(exist = false)
100
    private String contractTime;
101
    /**
102
     * 客户名称
103
     */
104
    @TableField(exist = false) 
105
    private String clientName;
106
    /**
107
     * 销售员id
108
     */
109
    @TableField(exist = false)
110
    private Long sellerId;
111
    /**
112
     * 销售员
113
     */
114
    @TableField(exist = false)
115
    private String sellerName;
116
    /**
117
     * 销售部门
118
     */
119
    @TableField(exist = false)
120
    private String sellerDepartmentName;
121
    /**
122
     * 运费
123
     */
124
    @TableField(exist=false)
125
    private BigDecimal fare;
126
    /**
127
     * 总到款金额
128
     */
129
    @TableField(exist=false)
130
    private BigDecimal payMoney;
131
    /**
132
     * 合同基准额
133
     */
134
    @TableField(exist=false)
135
    private BigDecimal baseMoney;
136
    /**
137
     * 总利润
138
     */
139
    @TableField(exist=false)
140
    private BigDecimal profit;
141
    /**
142
     * 价格比例
143
     */
144
    @TableField(exist=false)
145
    private BigDecimal priceRate;
146
    /**
147
     * 提成比例(百分比)
148
     */
149
    @TableField(exist=false)
150
    private BigDecimal commissionRate;
151
    /**
152
     * 提成金额
153
     */
154
    @TableField(exist=false)
155
    private BigDecimal money;
156
}

+ 0 - 51
src/main/java/io/renren/modules/sales/entity/SaleOrderItemEntity.java

@ -149,55 +149,4 @@ public class SaleOrderItemEntity implements Serializable {
149 149
     */
150 150
    @TableField(exist=false)
151 151
    private List<SaleOrderTransportEntity> saleOrderTransports;
152
    /**
153
     * 合同号
154
     */
155
    @TableField(exist = false)
156
    private String contractNo;
157
    /**
158
     * 销售时间
159
     */
160
    @TableField(exist = false)
161
    @JsonFormat(pattern = "yyyy-MM-dd")
162
    @DateTimeFormat(pattern = "yyyy-MM-dd")
163
    private Date contractTime;
164
    /**
165
     * 客户id
166
     */
167
    @TableField(exist = false) 
168
    private Long clientId;
169
    /**
170
     * 客户名称
171
     */
172
    @TableField(exist = false) 
173
    private String clientName;
174
    /**
175
     * 销售员
176
     */
177
    @TableField(exist = false)
178
    private String sellerName;
179
    /**
180
     * 是否完成提成
181
     */
182
    @TableField(exist = false)
183
    private Long isCommission;
184
    /**
185
     * 销售部门
186
     */
187
    private String sellerDepartmentName;
188
    /**
189
     * 总收款
190
     */
191
    @TableField(exist = false)
192
    private BigDecimal PayMoney;
193
    /**
194
     * 运费
195
     */
196
    @TableField(exist=false)
197
    private BigDecimal fare;
198
    /**
199
     * u8 订单编号
200
     */
201
    @TableField(exist = false)
202
    private String u8id;
203 152
}

+ 2 - 2
src/main/java/io/renren/modules/sales/service/SaleCommissionService.java

@ -3,7 +3,7 @@ package io.renren.modules.sales.service;
3 3
import com.baomidou.mybatisplus.extension.service.IService;
4 4
import io.renren.common.utils.PageUtils;
5 5
import io.renren.modules.sales.entity.SaleCommissionEntity;
6
import io.renren.modules.sales.entity.SaleOrderItemCommissionEntity;
6
import io.renren.modules.sales.entity.SaleOrderUnionItemEntity;
7 7
8 8
import java.util.List;
9 9
import java.util.Map;
@ -24,7 +24,7 @@ public interface SaleCommissionService extends IService<SaleCommissionEntity> {
24 24
	 * @param params
25 25
	 * @return
26 26
	 */
27
	List<SaleOrderItemCommissionEntity> queryMonthCommissionItemList(Map<String, Object> params);
27
	List<SaleOrderUnionItemEntity> queryMonthCommissionItemList(Map<String, Object> params);
28 28
29 29
	/** 通过订单id删除提成 */
30 30
	void removeByOrderId(Long orderId);

+ 5 - 5
src/main/java/io/renren/modules/sales/service/impl/SaleCommissionServiceImpl.java

@ -14,7 +14,7 @@ import io.renren.common.utils.PageUtils;
14 14
import io.renren.common.utils.Query;
15 15
import io.renren.modules.sales.dao.SaleCommissionDao;
16 16
import io.renren.modules.sales.entity.SaleCommissionEntity;
17
import io.renren.modules.sales.entity.SaleOrderItemCommissionEntity;
17
import io.renren.modules.sales.entity.SaleOrderUnionItemEntity;
18 18
import io.renren.modules.sales.service.SaleCommissionService;
19 19
import io.renren.modules.sales.utils.CommissionUtils;
20 20
@ -43,7 +43,7 @@ public class SaleCommissionServiceImpl extends ServiceImpl<SaleCommissionDao, Sa
43 43
    }
44 44
45 45
    @Override
46
    public List<SaleOrderItemCommissionEntity> queryMonthCommissionItemList(Map<String, Object> params) {
46
    public List<SaleOrderUnionItemEntity> queryMonthCommissionItemList(Map<String, Object> params) {
47 47
        String key = params.containsKey("key") ? (String) params.get("key") : null;
48 48
49 49
        Integer year = 0;
@ -62,14 +62,14 @@ public class SaleCommissionServiceImpl extends ServiceImpl<SaleCommissionDao, Sa
62 62
63 63
        Long sellerId = params.containsKey("sellerId") ? Long.valueOf((String) params.get("sellerId")) : 0L;
64 64
65
        List<SaleOrderItemCommissionEntity> list = baseMapper
66
                .queryMonthCommissionItemList(new QueryWrapper<SaleOrderItemCommissionEntity>()
65
        List<SaleOrderUnionItemEntity> list = baseMapper
66
                .queryMonthCommissionItemList(new QueryWrapper<SaleOrderUnionItemEntity>()
67 67
                        .eq(commissionType != 0, "`soi`.`commission_type`", commissionType)
68 68
                        .eq(year != 0, "`year`", year).eq(month != 0, "`month`", month)
69 69
                        .eq(sellerId != 0L, "`seller_id`", sellerId).and(StringUtils.isNotBlank(key),
70 70
                                Wrapper -> Wrapper.like("`client_name`", key).or().like("`contract_no`", key)));
71 71
72
        for (SaleOrderItemCommissionEntity orderItemCommisson : list) {
72
        for (SaleOrderUnionItemEntity orderItemCommisson : list) {
73 73
            orderItemCommisson = CommissionUtils.handOrderItemCommission(orderItemCommisson);
74 74
        }
75 75

+ 3 - 40
src/main/java/io/renren/modules/sales/utils/CommissionUtils.java

@ -2,8 +2,7 @@ package io.renren.modules.sales.utils;
2 2
3 3
import java.math.BigDecimal;
4 4
5
import io.renren.modules.sales.entity.SaleOrderItemEntity;
6
import io.renren.modules.sales.entity.SaleOrderItemCommissionEntity;
5
import io.renren.modules.sales.entity.SaleOrderUnionItemEntity;
7 6
8 7
public class CommissionUtils {
9 8
	// 提成比例(百分比)
@ -58,42 +57,6 @@ public class CommissionUtils {
58 57
		this.generalMoney = generalMoney;
59 58
	}
60 59
61
	public CommissionUtils(SaleOrderItemEntity saleOrderItem) {
62
		switch (saleOrderItem.getCommissionType()) {
63
			case 2:
64
				this.priceRate = saleOrderItem.getActualPrice().divide(saleOrderItem.getProductsPrice(), 4,
65
						BigDecimal.ROUND_HALF_UP);
66
				if (this.priceRate.compareTo(LevelA) < 0) {
67
					this.speciallRatio = new BigDecimal("0.01");
68
				} else if (this.priceRate.compareTo(LevelB) < 0) {
69
					this.speciallRatio = new BigDecimal("0.015");
70
				} else {
71
					this.speciallRatio = new BigDecimal("0.02");
72
				}
73
				this.generalMoney = new BigDecimal("0.00");
74
				this.specialMoney = saleOrderItem.getActualMoney().subtract(saleOrderItem.getFare())
75
						.subtract(saleOrderItem.getAgency()).multiply(this.speciallRatio)
76
						.setScale(2, BigDecimal.ROUND_HALF_UP);
77
				break;
78
			case 3:
79
				this.priceRate = saleOrderItem.getActualPrice().divide(saleOrderItem.getProductsPrice(), 4,
80
						BigDecimal.ROUND_HALF_UP);
81
				this.speciallRatio = this.specialSS
82
						.add(this.priceRate.subtract(new BigDecimal("1")).divide(new BigDecimal("0.1"))
83
								.divide(new BigDecimal("100")).setScale(2, BigDecimal.ROUND_DOWN));
84
				this.generalMoney = new BigDecimal("0.00");
85
				this.specialMoney = saleOrderItem.getActualMoney().subtract(saleOrderItem.getFare())
86
						.subtract(saleOrderItem.getAgency()).multiply(this.speciallRatio)
87
						.setScale(2, BigDecimal.ROUND_HALF_UP);
88
				break;
89
			default:
90
				this.generalMoney = (saleOrderItem.getActualPrice().subtract(saleOrderItem.getProductsPrice()))
91
						.multiply(saleOrderItem.getActualAmount()).subtract(saleOrderItem.getFare())
92
						.subtract(saleOrderItem.getAgency()).setScale(2, BigDecimal.ROUND_HALF_UP);
93
				this.specialMoney = new BigDecimal("0.00");
94
				break;
95
		}
96
	}
97 60
98 61
	public BigDecimal getGeneralMoney() {
99 62
		return this.generalMoney;
@ -111,8 +74,8 @@ public class CommissionUtils {
111 74
		this.generalMoney = money;
112 75
	}
113 76
114
	public static SaleOrderItemCommissionEntity handOrderItemCommission(
115
			SaleOrderItemCommissionEntity orderItemCommisson) {
77
	public static SaleOrderUnionItemEntity handOrderItemCommission(
78
			SaleOrderUnionItemEntity orderItemCommisson) {
116 79
		if (orderItemCommisson.getCommissionType() == 1) {
117 80
			orderItemCommisson
118 81
					.setBaseMoney(orderItemCommisson.getProductsPrice().multiply(orderItemCommisson.getSalesAmount()));