更新10.9
This commit is contained in:
parent
127d1b7a8a
commit
4686e8b5f1
@ -96,4 +96,18 @@ public interface CommissionRecordService {
|
||||
* @param storeId 店铺id
|
||||
*/
|
||||
void addRefundRecord(String orderNo,String type,Integer staffId,Integer storeId);
|
||||
|
||||
/**
|
||||
* 添加提成记录信息
|
||||
* @param storeId 店铺id
|
||||
* @param type 类型:1.油品订单出售;2.商品订单出售;3.储值卡充值;4.油品退款;5.商品退款;6.囤油卡充值
|
||||
* @param staffId 员工id
|
||||
* @param amount 订单金额
|
||||
* @param payAmount 实际支付金额
|
||||
* @param classify 分类:0油品提成方案;1商品提成方案;3会员充值方案
|
||||
* @param commissionSource 提成卡来源:油卡充值、囤油卡充值、油品出售、非油品
|
||||
* @param orderNo 订单号
|
||||
* @return
|
||||
*/
|
||||
int addRecord(Integer storeId, String type,Integer staffId,Double amount,Double payAmount, String classify, String commissionSource,String orderNo);
|
||||
}
|
||||
|
@ -1,16 +1,24 @@
|
||||
package com.fuint.business.commission.service.impl;
|
||||
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
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;
|
||||
import com.fuint.business.commission.entity.StaffCommission;
|
||||
import com.fuint.business.commission.mapper.CommissionRecordMapper;
|
||||
import com.fuint.business.commission.mapper.StaffCommissionMapper;
|
||||
import com.fuint.business.commission.service.CommissionRecordService;
|
||||
import com.fuint.business.commission.vo.CommissionRecordVo;
|
||||
import com.fuint.business.commission.vo.StaffPercentageVo;
|
||||
import com.fuint.business.member.entity.LJStaff;
|
||||
import com.fuint.business.member.service.ILJStaffService;
|
||||
import com.fuint.business.order.entity.AllOrderInfo;
|
||||
import com.fuint.business.order.mapper.AllOrderInfoMapper;
|
||||
import com.fuint.repository.mapper.NewMtStaffMapper;
|
||||
import com.fuint.repository.model.NewMtStaff;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import com.fuint.common.util.TokenUtil;
|
||||
@ -18,12 +26,8 @@ import io.lettuce.core.dynamic.annotation.Param;
|
||||
import com.fuint.common.dto.AccountInfo;
|
||||
|
||||
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* 提成记录表(CommissionRecord)表服务实现类
|
||||
@ -37,6 +41,12 @@ public class CommissionRecordServiceImpl implements CommissionRecordService {
|
||||
private CommissionRecordMapper commissionRecordMapper;
|
||||
@Autowired
|
||||
private ILJStaffService staffService;
|
||||
@Autowired
|
||||
private AllOrderInfoMapper allOrderInfoMapper;
|
||||
@Autowired
|
||||
private NewMtStaffMapper newMtStaffMapper;
|
||||
@Autowired
|
||||
private StaffCommissionMapper staffCommissionMapper;
|
||||
|
||||
/**
|
||||
* 通过ID查询单条数据
|
||||
@ -53,7 +63,7 @@ public class CommissionRecordServiceImpl implements CommissionRecordService {
|
||||
* 分页查询
|
||||
*
|
||||
* @param commissionRecord 筛选条件
|
||||
* @param page 分页对象
|
||||
* @param page 分页对象
|
||||
* @return 查询结果
|
||||
*/
|
||||
@Override
|
||||
@ -64,15 +74,15 @@ public class CommissionRecordServiceImpl implements CommissionRecordService {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String,Object> selectStaffCommissionList(Page page, CommissionRecord commissionRecord) {
|
||||
Map<String,Object> resMap = new HashMap<>();
|
||||
public Map<String, Object> selectStaffCommissionList(Page page, CommissionRecord commissionRecord) {
|
||||
Map<String, Object> resMap = new HashMap<>();
|
||||
AccountInfo nowAccountInfo = TokenUtil.getNowAccountInfo();
|
||||
LJStaff staff = new LJStaff();
|
||||
staff.setStoreId(nowAccountInfo.getStoreId());
|
||||
staff.setId(commissionRecord.getStaffId());
|
||||
staff.setRoleId(commissionRecord.getRoleId());
|
||||
IPage<LJStaff> ljStaffIPage = staffService.selectStaffList(page, staff);
|
||||
if (ObjectUtil.isNotEmpty(ljStaffIPage)){
|
||||
if (ObjectUtil.isNotEmpty(ljStaffIPage)) {
|
||||
List<StaffPercentageVo> list = new ArrayList<>();
|
||||
for (LJStaff record : ljStaffIPage.getRecords()) {
|
||||
StaffPercentageVo staffPercentageVo = new StaffPercentageVo();
|
||||
@ -95,8 +105,8 @@ public class CommissionRecordServiceImpl implements CommissionRecordService {
|
||||
staffPercentageVo.setOilStorageRecharge(commissionRecordMapper.selectAllCommissIon(commissionRecord));
|
||||
list.add(staffPercentageVo);
|
||||
}
|
||||
resMap.put("records",list);
|
||||
resMap.put("total",ljStaffIPage.getTotal());
|
||||
resMap.put("records", list);
|
||||
resMap.put("total", ljStaffIPage.getTotal());
|
||||
}
|
||||
|
||||
return resMap;
|
||||
@ -151,12 +161,12 @@ public class CommissionRecordServiceImpl implements CommissionRecordService {
|
||||
@Override
|
||||
public int insertRecord(CommissionRecord commissionRecord) {
|
||||
QueryWrapper queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.eq("staff_id",commissionRecord.getStaffId());
|
||||
queryWrapper.eq("store_id",commissionRecord.getStoreId());
|
||||
queryWrapper.eq("type",commissionRecord.getType());
|
||||
queryWrapper.eq("order_no",commissionRecord.getOrderNo());
|
||||
queryWrapper.eq("staff_id", commissionRecord.getStaffId());
|
||||
queryWrapper.eq("store_id", commissionRecord.getStoreId());
|
||||
queryWrapper.eq("type", commissionRecord.getType());
|
||||
queryWrapper.eq("order_no", commissionRecord.getOrderNo());
|
||||
CommissionRecord commissionRecord1 = commissionRecordMapper.selectOne(queryWrapper);
|
||||
if (ObjectUtil.isNotEmpty(commissionRecord1)){
|
||||
if (ObjectUtil.isNotEmpty(commissionRecord1)) {
|
||||
return 0;
|
||||
}
|
||||
return commissionRecordMapper.insert(commissionRecord);
|
||||
@ -179,14 +189,14 @@ public class CommissionRecordServiceImpl implements CommissionRecordService {
|
||||
@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);
|
||||
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) && ObjectUtil.isNotEmpty(commissionRecord.getAmount())){
|
||||
if (ObjectUtil.isNotEmpty(commissionRecord) && ObjectUtil.isNotEmpty(commissionRecord.getAmount())) {
|
||||
CommissionRecord record = new CommissionRecord();
|
||||
if (type.equals("1")){
|
||||
if (type.equals("1")) {
|
||||
record.setType("4");
|
||||
record.setStaffId(staffId);
|
||||
record.setStoreId(storeId);
|
||||
@ -195,7 +205,7 @@ public class CommissionRecordServiceImpl implements CommissionRecordService {
|
||||
record.setAmount(-commissionRecord.getAmount());
|
||||
commissionRecordMapper.insert(record);
|
||||
}
|
||||
if (type.equals("2")){
|
||||
if (type.equals("2")) {
|
||||
record.setType("5");
|
||||
record.setStaffId(staffId);
|
||||
record.setStoreId(storeId);
|
||||
@ -206,4 +216,76 @@ public class CommissionRecordServiceImpl implements CommissionRecordService {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 添加提成记录信息
|
||||
* @param storeId 店铺id
|
||||
* @param type 类型:1.油品订单出售;2.商品订单出售;3.储值卡充值;4.油品退款;5.商品退款;6.囤油卡充值
|
||||
* @param staffId 员工id
|
||||
* @param amount 订单金额
|
||||
* @param payAmount 实际支付金额
|
||||
* @param classify 分类:0油品提成方案;1商品提成方案;3会员充值方案
|
||||
* @param commissionSource 提成卡来源:油卡充值、囤油卡充值、油品出售、非油品
|
||||
* @param orderNo 订单号
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public int addRecord(Integer storeId, String type,Integer staffId,Double amount,Double payAmount, String classify, String commissionSource,String orderNo) {
|
||||
//根据员工id查询用户角色
|
||||
NewMtStaff newMtStaff = newMtStaffMapper.selectById(staffId);
|
||||
if (ObjectUtil.isNull(newMtStaff)) {
|
||||
throw new RuntimeException("员工不存在");
|
||||
}
|
||||
String roleId = newMtStaff.getRoleId();
|
||||
//查询对应的提成策略
|
||||
List<StaffCommission> staffCommissions = staffCommissionMapper.selectList(new LambdaQueryWrapper<StaffCommission>()
|
||||
.eq(StaffCommission::getStoreId, storeId)
|
||||
.eq(StaffCommission::getClassify, classify)
|
||||
.eq(StaffCommission::getStatus, "qy"));
|
||||
StaffCommission staffCommission = new StaffCommission();
|
||||
for (StaffCommission staffCommission1 : staffCommissions) {
|
||||
String[] split = staffCommission1.getStaffRoleGroup().split(",");
|
||||
String[] source = staffCommission1.getCommissionSource().split(",");
|
||||
if (Arrays.asList(split).contains(roleId) && Arrays.asList(source).contains(commissionSource)){
|
||||
staffCommission = staffCommission1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (ObjectUtil.isEmpty(staffCommission)) {
|
||||
return 0;
|
||||
}
|
||||
//添加提成记录表
|
||||
CommissionRecord record = new CommissionRecord();
|
||||
record.setStoreId(storeId);
|
||||
record.setStaffId(staffId);
|
||||
record.setOrderNo(orderNo);
|
||||
record.setDescription(commissionSource + "订单出售提成");
|
||||
record.setCreateTime(DateUtil.date());
|
||||
record.setCreateBy(TokenUtil.getNowAccountInfo().getId().toString());
|
||||
record.setType(type);
|
||||
//计算员工提成金额
|
||||
//判断提成类型
|
||||
Double royaltyRate = Double.valueOf(staffCommission.getRoyaltyRate().substring(0, staffCommission.getRoyaltyRate().length() - 1));
|
||||
String unit = staffCommission.getRoyaltyRate().substring(staffCommission.getRoyaltyRate().length() - 1);
|
||||
//按照订单金额计算提成
|
||||
if (staffCommission.getType().equals("orderAmount")) {
|
||||
compute(amount, staffCommission, unit, record, royaltyRate);
|
||||
}
|
||||
//按照实付金额计算提成
|
||||
else if (staffCommission.getType().equals("payAmount")){
|
||||
compute(payAmount, staffCommission, unit, record, royaltyRate);
|
||||
}
|
||||
return commissionRecordMapper.insert(record);
|
||||
}
|
||||
|
||||
private void compute(Double allOrderInfo, StaffCommission staffCommission, String unit, CommissionRecord record, Double royaltyRate) {
|
||||
if (allOrderInfo >= Double.valueOf(staffCommission.getMeetCondition())) {
|
||||
if (unit.equals("元")) {
|
||||
record.setAmount(royaltyRate);
|
||||
}
|
||||
if (unit.equals("%")) {
|
||||
record.setAmount(allOrderInfo * (royaltyRate / 100));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -109,7 +109,7 @@
|
||||
if (res.code == 200) {
|
||||
console.log(res, 108);
|
||||
this.show = true
|
||||
this.getList()
|
||||
// this.getList()
|
||||
}
|
||||
})
|
||||
this.getList()
|
||||
|
Loading…
Reference in New Issue
Block a user