From d8023ecfba03bb36b0b01a1004a708f1d7dc00cc Mon Sep 17 00:00:00 2001 From: cun-nan <19819293608@163.com> Date: Thu, 18 Jan 2024 10:56:43 +0800 Subject: [PATCH] bug --- fuintAdmin/src/views/staff/list.vue | 15 +++++-- .../views/staffCommission/staffCommission.vue | 24 +++++++++-- .../fuyou/service/impl/FyPayServiceImpl.java | 10 +++-- .../commission/entity/CommissionRecord.java | 2 +- .../mapper/CommissionRecordMapper.java | 3 +- .../service/CommissionRecordService.java | 9 +++++ .../impl/CommissionRecordServiceImpl.java | 33 +++++++++++++++ .../impl/StaffCommissionServiceImpl.java | 40 +++++++++++++++++-- .../service/impl/AllOrderInfoServiceImpl.java | 5 +++ .../service/impl/OilOrderServiceImpl.java | 12 +++--- 10 files changed, 132 insertions(+), 21 deletions(-) diff --git a/fuintAdmin/src/views/staff/list.vue b/fuintAdmin/src/views/staff/list.vue index 42e14d9d1..2806a0d0c 100644 --- a/fuintAdmin/src/views/staff/list.vue +++ b/fuintAdmin/src/views/staff/list.vue @@ -60,6 +60,13 @@ + + + @@ -175,7 +182,7 @@ - + - + + + + + + + @@ -65,7 +75,15 @@ - + + + @@ -238,7 +256,7 @@ - + diff --git a/fuintBackend/fuint-application/src/main/java/com/fuint/api/fuyou/service/impl/FyPayServiceImpl.java b/fuintBackend/fuint-application/src/main/java/com/fuint/api/fuyou/service/impl/FyPayServiceImpl.java index 7b437c056..4f528a342 100644 --- a/fuintBackend/fuint-application/src/main/java/com/fuint/api/fuyou/service/impl/FyPayServiceImpl.java +++ b/fuintBackend/fuint-application/src/main/java/com/fuint/api/fuyou/service/impl/FyPayServiceImpl.java @@ -175,7 +175,7 @@ public class FyPayServiceImpl implements FyPayService { // 油品订单 oilOrder.setOrderStatus("paid"); oilOrder.setPayTime(date); - staffCommissionService.countStaffCommission(oilOrder.getStaffId(),oilOrder.getStoreId(),oilOrder.getOrderAmount(),oilOrder.getPayAmount(),oilOrder.getOilNum(),"油品",orderNo); + staffCommissionService.countStaffCommission(oilOrder.getStaffId(),oilOrder.getStoreId(),oilOrder.getOrderAmount(),oilOrder.getPayAmount(),oilOrder.getOilNum(),"1",orderNo); // 修改油罐容量 List jsonObjects = JSONArray.parseArray(map1.get("oilOrder"), JSONObject.class); if (jsonObjects.size()<=1) { @@ -197,7 +197,7 @@ public class FyPayServiceImpl implements FyPayService { // 商品订单 goodsOrder.setStatus("paid"); goodsOrder.setPayTime(date); - staffCommissionService.countStaffCommission(goodsOrder.getStaffId(),goodsOrder.getStoreId(),goodsOrder.getAmount(),goodsOrder.getPayAmount(),0.0,"商品",orderNo); + staffCommissionService.countStaffCommission(goodsOrder.getStaffId(),goodsOrder.getStoreId(),goodsOrder.getAmount(),goodsOrder.getPayAmount(),0.0,"2",orderNo); if (!map1.get("goodsOrder").equals("[]")){ List goods = JSONArray.parseArray(map1.get("goodsOrder"), JSONObject.class); OrderGoods orderGoods = new OrderGoods(); @@ -228,9 +228,13 @@ public class FyPayServiceImpl implements FyPayService { } if (!ArrayUtil.isEmpty(list)){ if (list.size()>1){ + Double oilLiters = 0.0; + for (OilOrder order : list){ + oilLiters += order.getOilNum(); + } for (OilOrder order : list) { if (order.getOrderType().equals("主订单")){ - staffCommissionService.countStaffCommission(order.getStaffId(),order.getStoreId(),order.getOrderAmount(),order.getPayAmount(),order.getOilNum(),"油品",orderNo); + staffCommissionService.countStaffCommission(order.getStaffId(),order.getStoreId(),order.getOrderAmount(),order.getPayAmount(),oilLiters,"1",orderNo); } // 添加多个油品订单 order.setOrderStatus("paid"); diff --git a/fuintBackend/fuint-application/src/main/java/com/fuint/business/commission/entity/CommissionRecord.java b/fuintBackend/fuint-application/src/main/java/com/fuint/business/commission/entity/CommissionRecord.java index bdf1e0b5a..8011f4bea 100644 --- a/fuintBackend/fuint-application/src/main/java/com/fuint/business/commission/entity/CommissionRecord.java +++ b/fuintBackend/fuint-application/src/main/java/com/fuint/business/commission/entity/CommissionRecord.java @@ -39,7 +39,7 @@ public class CommissionRecord extends BaseEntity { @ApiModelProperty("员工id") private Integer staffId; /** - * 类型 + * 类型 1.油品订单出售;2.商品订单出售;3.储值卡充值;4.油品退款;5.商品退款 */ @ApiModelProperty("类型") private String type; diff --git a/fuintBackend/fuint-application/src/main/java/com/fuint/business/commission/mapper/CommissionRecordMapper.java b/fuintBackend/fuint-application/src/main/java/com/fuint/business/commission/mapper/CommissionRecordMapper.java index 169447230..b80ffad3a 100644 --- a/fuintBackend/fuint-application/src/main/java/com/fuint/business/commission/mapper/CommissionRecordMapper.java +++ b/fuintBackend/fuint-application/src/main/java/com/fuint/business/commission/mapper/CommissionRecordMapper.java @@ -1,5 +1,6 @@ package com.fuint.business.commission.mapper; +import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.fuint.business.commission.entity.CommissionRecord; @@ -14,7 +15,7 @@ import java.util.List; * @author wangh * @since 2023-11-14 13:40:03 */ -public interface CommissionRecordMapper { +public interface CommissionRecordMapper extends BaseMapper { /** * 通过ID查询单条数据 diff --git a/fuintBackend/fuint-application/src/main/java/com/fuint/business/commission/service/CommissionRecordService.java b/fuintBackend/fuint-application/src/main/java/com/fuint/business/commission/service/CommissionRecordService.java index b8c2d4d19..947b7e564 100644 --- a/fuintBackend/fuint-application/src/main/java/com/fuint/business/commission/service/CommissionRecordService.java +++ b/fuintBackend/fuint-application/src/main/java/com/fuint/business/commission/service/CommissionRecordService.java @@ -77,4 +77,13 @@ public interface CommissionRecordService { * @return */ Double selectAllAmount(CommissionRecordVo commissionRecord); + + /** + * 添加退款提成记录信息 + * @param orderNo 订单号 + * @param type 订单类型(1、油品;2、商品) + * @param staffId 员工id + * @param storeId 店铺id + */ + void addRefundRecord(String orderNo,String type,Integer staffId,Integer storeId); } diff --git a/fuintBackend/fuint-application/src/main/java/com/fuint/business/commission/service/impl/CommissionRecordServiceImpl.java b/fuintBackend/fuint-application/src/main/java/com/fuint/business/commission/service/impl/CommissionRecordServiceImpl.java index 6e7be2f8b..42aad0afe 100644 --- a/fuintBackend/fuint-application/src/main/java/com/fuint/business/commission/service/impl/CommissionRecordServiceImpl.java +++ b/fuintBackend/fuint-application/src/main/java/com/fuint/business/commission/service/impl/CommissionRecordServiceImpl.java @@ -1,5 +1,7 @@ package com.fuint.business.commission.service.impl; +import cn.hutool.core.util.ObjectUtil; +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.fuint.business.commission.entity.CommissionRecord; @@ -112,4 +114,35 @@ public class CommissionRecordServiceImpl implements CommissionRecordService { commissionRecord.setStoreId(nowAccountInfo.getStoreId()); return commissionRecordMapper.selectAllAmount(commissionRecord); } + + @Override + public void addRefundRecord(String orderNo, String type, Integer staffId, Integer storeId) { + QueryWrapper queryWrapper = new QueryWrapper<>(); + queryWrapper.eq("staff_id",staffId); + queryWrapper.eq("store_id",storeId); + queryWrapper.eq("type",type); + queryWrapper.eq("order_no",orderNo); + CommissionRecord commissionRecord = commissionRecordMapper.selectOne(queryWrapper); + if (ObjectUtil.isNotEmpty(commissionRecord)){ + CommissionRecord record = new CommissionRecord(); + if (type.equals("1")){ + record.setType("4"); + record.setStaffId(staffId); + record.setStoreId(storeId); + record.setDescription("油品退款订单"); + record.setOrderNo(orderNo); + record.setAmount(-commissionRecord.getAmount()); + commissionRecordMapper.insert(record); + } + if (type.equals("2")){ + record.setType("5"); + record.setStaffId(staffId); + record.setStoreId(storeId); + record.setDescription("商品退款订单"); + record.setOrderNo(orderNo); + record.setAmount(-commissionRecord.getAmount()); + commissionRecordMapper.insert(record); + } + } + } } diff --git a/fuintBackend/fuint-application/src/main/java/com/fuint/business/commission/service/impl/StaffCommissionServiceImpl.java b/fuintBackend/fuint-application/src/main/java/com/fuint/business/commission/service/impl/StaffCommissionServiceImpl.java index dd34ba54f..fa1436587 100644 --- a/fuintBackend/fuint-application/src/main/java/com/fuint/business/commission/service/impl/StaffCommissionServiceImpl.java +++ b/fuintBackend/fuint-application/src/main/java/com/fuint/business/commission/service/impl/StaffCommissionServiceImpl.java @@ -110,11 +110,12 @@ public class StaffCommissionServiceImpl extends ServiceImpl0 && ObjectUtil.isNotEmpty(staff)){ for (StaffCommission staffCommission : list) { CommissionRecord commissionRecord = new CommissionRecord(); - if (type.equals(staffCommission.getCommissionSource()) && staff.getRoleId().equals(staffCommission.getStaffRoleGroup())){ + if (type.equals("1") && staffCommission.getCommissionSource().equals("油品") + && staff.getRoleId().equals(staffCommission.getStaffRoleGroup())){ commissionRecord.setStaffId(staffId); commissionRecord.setStoreId(storeId); - commissionRecord.setType(type+"订单出售"); - commissionRecord.setDescription(type+"订单出售提成"); + commissionRecord.setType(type); + commissionRecord.setDescription(staffCommission.getCommissionSource()+"订单出售提成"); commissionRecord.setOrderNo(orderNo); Double royaltyRate = Double.valueOf(staffCommission.getRoyaltyRate().substring(0,staffCommission.getRoyaltyRate().length()-1)); String unit = staffCommission.getRoyaltyRate().substring(staffCommission.getRoyaltyRate().length()-1); @@ -153,6 +154,39 @@ public class StaffCommissionServiceImpl extends ServiceImpl=Double.valueOf(staffCommission.getMeetCondition())){ + if (unit.equals("元")){ + commissionRecord.setAmount(royaltyRate); + } + if (unit.equals("%")){ + commissionRecord.setAmount(amount*(royaltyRate/100)); + } + } + } +// 按照实付金额计算提成 + if (staffCommission.getType().equals("payAmount")){ + if (payAmount>=Double.valueOf(staffCommission.getMeetCondition())){ + if (unit.equals("元")){ + commissionRecord.setAmount(royaltyRate); + } + if (unit.equals("%")){ + commissionRecord.setAmount(payAmount*(royaltyRate/100)); + } + } + } + commissionRecordService.insertRecord(commissionRecord); + } } } } diff --git a/fuintBackend/fuint-application/src/main/java/com/fuint/business/order/service/impl/AllOrderInfoServiceImpl.java b/fuintBackend/fuint-application/src/main/java/com/fuint/business/order/service/impl/AllOrderInfoServiceImpl.java index 8bcbe0391..af1dc7718 100644 --- a/fuintBackend/fuint-application/src/main/java/com/fuint/business/order/service/impl/AllOrderInfoServiceImpl.java +++ b/fuintBackend/fuint-application/src/main/java/com/fuint/business/order/service/impl/AllOrderInfoServiceImpl.java @@ -11,6 +11,7 @@ import com.fuint.api.fuyou.entity.Const; import com.fuint.api.fuyou.entity.MerchantConfig; import com.fuint.api.fuyou.service.FyPayService; import com.fuint.api.fuyou.service.MerchantConfigService; +import com.fuint.business.commission.service.CommissionRecordService; import com.fuint.business.convenienceSore.dto.LJGoodsDto; import com.fuint.business.convenienceSore.entity.StockStatistic; import com.fuint.business.convenienceSore.entity.StockTrack; @@ -142,6 +143,8 @@ public class AllOrderInfoServiceImpl extends ServiceImpl map) { @@ -209,9 +212,11 @@ public class AllOrderInfoServiceImpl extends ServiceImpl i ljOrder.setStaffId(staffId); ljOrder.setStatus(payStatus); if (payType.equals("CASH")){ - staffCommissionService.countStaffCommission(staffId,storeId,goodsAmount,goodsActualPay,0.0,"商品",orderNo); + staffCommissionService.countStaffCommission(staffId,storeId,goodsAmount,goodsActualPay,0.0,"2",orderNo); ljOrder.setPayTime(new Date()); } // 将商品订单的json数据转换为数组 @@ -329,7 +329,7 @@ public class OilOrderServiceImpl extends ServiceImpl i order.setPayAmount(oilActualPay); order.setOrderNo(orderNo); if (payType.equals("CASH")){ - staffCommissionService.countStaffCommission(staffId,storeId,oilAmount,oilActualPay,oilLiters,"油品",orderNo); + staffCommissionService.countStaffCommission(staffId,storeId,oilAmount,oilActualPay,oilLiters,"1",orderNo); } }else { order.setOrderType("子订单"); @@ -653,7 +653,7 @@ public class OilOrderServiceImpl extends ServiceImpl i cashierOrder.setPayType(map.get("payType")); cashierOrderService.insertCashierOrder(cashierOrder); this.insertAllOrderInfo(orderNo, storeId, oilAmount, map.get("payType"), userId, "PC", "1", status); - staffCommissionService.countStaffCommission(Integer.valueOf(map.get("staffId")),storeId,oilAmount,oilAmount,oilLiters,"油品",orderNo); + staffCommissionService.countStaffCommission(Integer.valueOf(map.get("staffId")),storeId,oilAmount,oilAmount,oilLiters,"1",orderNo); res.put("success","success"); } } @@ -718,7 +718,7 @@ public class OilOrderServiceImpl extends ServiceImpl i cashierOrderService.insertCashierOrder(cashierOrder); this.updateGrowthValue1(oilAmount,userId, Integer.valueOf(oilOrder.getOils()),0.0,storeId,orderNo); this.insertAllOrderInfo(orderNo,accountInfo.getStoreId(),oilAmount,map.get("payType"),userId,"PC","1","paid"); - staffCommissionService.countStaffCommission(Integer.valueOf(map.get("staffId")),storeId,oilAmount,oilAmount,oilLiters,"油品",orderNo); + staffCommissionService.countStaffCommission(Integer.valueOf(map.get("staffId")),storeId,oilAmount,oilAmount,oilLiters,"1",orderNo); // this.insertCardBalance(oilAmount,userId,storeId); res.put("success","success"); }else { @@ -1011,7 +1011,7 @@ public class OilOrderServiceImpl extends ServiceImpl i this.updateGrowthValue(payAmount,userId, Integer.valueOf(oilOrder.getOils()),oilCardAmount,oilOrder.getStoreId(),orderNo); this.addOilTracks(oilOrder,oilOrder.getStoreId()); this.insertCardOrder(oilOrder.getUserId(),oilOrder.getStoreId(),orderNo,oilOrder.getOrderAmount(),"paid", Double.valueOf(balanceAmount),payAmount); - staffCommissionService.countStaffCommission(oilOrder.getStaffId(),oilOrder.getStoreId(),oilOrder.getOrderAmount(),oilOrder.getOrderAmount(),oilOrder.getOilNum(),"油品",orderNo); + staffCommissionService.countStaffCommission(oilOrder.getStaffId(),oilOrder.getStoreId(),oilOrder.getOrderAmount(),oilOrder.getOrderAmount(),oilOrder.getOilNum(),"1",orderNo); oilOrder.setPayAmount(payAmount); oilOrder.setDiscountAmount(Double.valueOf(discountAmount)); oilOrder.setPayTime(new Date()); @@ -1082,7 +1082,7 @@ public class OilOrderServiceImpl extends ServiceImpl i } this.updateGrowthValue(oilOrder.getPayAmount(),userId, Integer.valueOf(oilOrder.getOils()),null,oilOrder.getStoreId(),orderNo); this.addOilTracks(oilOrder,oilOrder.getStoreId()); - staffCommissionService.countStaffCommission(oilOrder.getStaffId(),oilOrder.getStoreId(),oilOrder.getOrderAmount(),oilOrder.getPayAmount(),oilOrder.getOilNum(),"油品",orderNo); + staffCommissionService.countStaffCommission(oilOrder.getStaffId(),oilOrder.getStoreId(),oilOrder.getOrderAmount(),oilOrder.getPayAmount(),oilOrder.getOilNum(),"1",orderNo); CashierOrder cashierOrder = cashierOrderService.selectCashierOrder(orderNo); if (ObjectUtil.isNotEmpty(cashierOrder)){ cashierOrder.setOilOrderId(oilOrder.getId());