mirror of
https://gitee.com/dromara/RuoYi-Vue-Plus.git
synced 2026-09-19 09:55:16 +08:00
员工报餐:修改查看补贴余额,添加补贴订单收款,补贴订单退款
This commit is contained in:
parent
9c5fc1ba2c
commit
d1b4bfc77c
@ -62,7 +62,7 @@ spring:
|
|||||||
# 端口,默认为6379
|
# 端口,默认为6379
|
||||||
port: 6379
|
port: 6379
|
||||||
# 数据库索引
|
# 数据库索引
|
||||||
database: 0
|
database: 2
|
||||||
# 密码
|
# 密码
|
||||||
password:
|
password:
|
||||||
# 连接超时时间
|
# 连接超时时间
|
||||||
|
|||||||
@ -4,15 +4,14 @@ import com.alibaba.fastjson.JSONObject;
|
|||||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||||
import com.ruoyi.common.core.controller.BaseController;
|
import com.ruoyi.common.core.controller.BaseController;
|
||||||
import com.ruoyi.common.core.domain.AjaxResult;
|
import com.ruoyi.common.core.domain.AjaxResult;
|
||||||
import com.ruoyi.system.fantang.domain.FtConfigDao;
|
import com.ruoyi.system.fantang.domain.*;
|
||||||
import com.ruoyi.system.fantang.domain.FtFoodDao;
|
|
||||||
import com.ruoyi.system.fantang.domain.FtOrderDao;
|
|
||||||
import com.ruoyi.system.fantang.domain.FtStaffSubsidyDao;
|
|
||||||
import com.ruoyi.system.fantang.service.*;
|
import com.ruoyi.system.fantang.service.*;
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
import org.springframework.web.bind.annotation.*;
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
|
||||||
|
import java.math.BigDecimal;
|
||||||
import java.util.Calendar;
|
import java.util.Calendar;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@ -330,13 +329,9 @@ public class ClientController extends BaseController {
|
|||||||
*/
|
*/
|
||||||
@GetMapping("/getStaffSubsidyBalance/{staffId}")
|
@GetMapping("/getStaffSubsidyBalance/{staffId}")
|
||||||
public AjaxResult getStaffSubsidyBalance(@PathVariable Long staffId) {
|
public AjaxResult getStaffSubsidyBalance(@PathVariable Long staffId) {
|
||||||
QueryWrapper<FtStaffSubsidyDao> wrapper = new QueryWrapper<>();
|
FtStaffInfoDao staffInfoDao = staffInfoDaoService.getById(staffId);
|
||||||
wrapper.eq("staff_id", staffId);
|
|
||||||
wrapper.orderByDesc("price");
|
|
||||||
wrapper.last("limit 1");
|
|
||||||
FtStaffSubsidyDao staffSubsidyDao = staffSubsidyDaoService.getOne(wrapper);
|
|
||||||
|
|
||||||
return AjaxResult.success(staffSubsidyDao.getPrice());
|
return AjaxResult.success(staffInfoDao.getBalance());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -395,4 +390,97 @@ public class ClientController extends BaseController {
|
|||||||
|
|
||||||
return AjaxResult.success(ftOrderDao.getDiscount());
|
return AjaxResult.success(ftOrderDao.getDiscount());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 补贴订单收款
|
||||||
|
*/
|
||||||
|
@Transactional
|
||||||
|
@PostMapping("/orderCollection")
|
||||||
|
public AjaxResult orderCollection(@RequestBody JSONObject params) {
|
||||||
|
|
||||||
|
// 订单 id
|
||||||
|
Integer orderId = params.getInteger("orderId");
|
||||||
|
|
||||||
|
// 实收
|
||||||
|
BigDecimal receipts = params.getBigDecimal("receipts");
|
||||||
|
|
||||||
|
// 当前订单信息
|
||||||
|
FtOrderDao orderDao = orderDaoService.getById(orderId);
|
||||||
|
|
||||||
|
// 当前订单员工信息
|
||||||
|
FtStaffInfoDao staffInfoDao = staffInfoDaoService.getById(orderDao.getStaffId());
|
||||||
|
|
||||||
|
// 员工账户补贴余额
|
||||||
|
BigDecimal balance = staffInfoDao.getBalance();
|
||||||
|
|
||||||
|
// 余额是否大于实收
|
||||||
|
if (balance.compareTo(receipts) < 0) {
|
||||||
|
|
||||||
|
return AjaxResult.error("补贴余额不足");
|
||||||
|
|
||||||
|
} else {
|
||||||
|
|
||||||
|
// 更新员工账户补贴余额
|
||||||
|
BigDecimal nowBalance = balance.subtract(receipts);
|
||||||
|
staffInfoDao.setBalance(nowBalance);
|
||||||
|
|
||||||
|
// 更新订单信息
|
||||||
|
orderDao.setReceipts(receipts);
|
||||||
|
orderDao.setPayFlag(1);
|
||||||
|
orderDao.setPayType(3);
|
||||||
|
orderDaoService.save(orderDao);
|
||||||
|
|
||||||
|
// 添加补贴流水记录
|
||||||
|
FtStaffSubsidyDao staffSubsidyDao = new FtStaffSubsidyDao();
|
||||||
|
staffSubsidyDao.setStaffId(orderDao.getStaffId());
|
||||||
|
staffSubsidyDao.setIncomeType(2);
|
||||||
|
staffSubsidyDao.setPrice(receipts);
|
||||||
|
staffSubsidyDao.setConsumAt(new Date());
|
||||||
|
staffSubsidyDao.setOrderId(orderDao.getOrderId());
|
||||||
|
staffSubsidyDaoService.save(staffSubsidyDao);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
return AjaxResult.success("已收款");
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 补贴订单退款
|
||||||
|
*/
|
||||||
|
@Transactional
|
||||||
|
@PostMapping("/orderRefund")
|
||||||
|
public AjaxResult orderRefund(@RequestBody JSONObject params){
|
||||||
|
|
||||||
|
// 订单 id
|
||||||
|
Integer orderId = params.getInteger("orderId");
|
||||||
|
|
||||||
|
// 实收
|
||||||
|
BigDecimal receipts = params.getBigDecimal("receipts");
|
||||||
|
|
||||||
|
// 当前订单信息
|
||||||
|
FtOrderDao orderDao = orderDaoService.getById(orderId);
|
||||||
|
|
||||||
|
// 当前订单员工信息
|
||||||
|
FtStaffInfoDao staffInfoDao = staffInfoDaoService.getById(orderDao.getStaffId());
|
||||||
|
|
||||||
|
// 员工账户补贴余额
|
||||||
|
BigDecimal balance = staffInfoDao.getBalance();
|
||||||
|
|
||||||
|
// 更新员工账户补贴余额
|
||||||
|
staffInfoDao.setBalance(balance.add(receipts));
|
||||||
|
staffInfoDaoService.updateById(staffInfoDao);
|
||||||
|
|
||||||
|
// 添加补贴流水记录
|
||||||
|
FtStaffSubsidyDao staffSubsidyDao = new FtStaffSubsidyDao();
|
||||||
|
staffSubsidyDao.setStaffId(orderDao.getStaffId());
|
||||||
|
// 收支类型
|
||||||
|
staffSubsidyDao.setIncomeType(4);
|
||||||
|
staffSubsidyDao.setPrice(receipts);
|
||||||
|
staffSubsidyDao.setConsumAt(new Date());
|
||||||
|
staffSubsidyDao.setOrderId(orderDao.getOrderId());
|
||||||
|
staffSubsidyDaoService.save(staffSubsidyDao);
|
||||||
|
|
||||||
|
return AjaxResult.success("已退款");
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -61,7 +61,7 @@ public class FtOrderDaoController extends BaseController {
|
|||||||
if (ftOrderDao.getCurrentPrice() != null) {
|
if (ftOrderDao.getCurrentPrice() != null) {
|
||||||
lqw.eq(FtOrderDao::getCurrentPrice, ftOrderDao.getCurrentPrice());
|
lqw.eq(FtOrderDao::getCurrentPrice, ftOrderDao.getCurrentPrice());
|
||||||
}
|
}
|
||||||
if (StringUtils.isNotBlank(ftOrderDao.getPayType())) {
|
if (ftOrderDao.getPayType() != null) {
|
||||||
lqw.eq(FtOrderDao::getPayType, ftOrderDao.getPayType());
|
lqw.eq(FtOrderDao::getPayType, ftOrderDao.getPayType());
|
||||||
}
|
}
|
||||||
if (ftOrderDao.getWriteOffAt() != null) {
|
if (ftOrderDao.getWriteOffAt() != null) {
|
||||||
|
|||||||
@ -48,7 +48,7 @@ public class FtStaffSubsidyDaoController extends BaseController {
|
|||||||
if (StringUtils.isNotBlank(ftStaffSubsidyDao.getSubsidyType())) {
|
if (StringUtils.isNotBlank(ftStaffSubsidyDao.getSubsidyType())) {
|
||||||
lqw.eq(FtStaffSubsidyDao::getSubsidyType, ftStaffSubsidyDao.getSubsidyType());
|
lqw.eq(FtStaffSubsidyDao::getSubsidyType, ftStaffSubsidyDao.getSubsidyType());
|
||||||
}
|
}
|
||||||
if (StringUtils.isNotBlank(ftStaffSubsidyDao.getIncomeType())) {
|
if (ftStaffSubsidyDao.getIncomeType() != null) {
|
||||||
lqw.eq(FtStaffSubsidyDao::getIncomeType, ftStaffSubsidyDao.getIncomeType());
|
lqw.eq(FtStaffSubsidyDao::getIncomeType, ftStaffSubsidyDao.getIncomeType());
|
||||||
}
|
}
|
||||||
if (ftStaffSubsidyDao.getPrice() != null) {
|
if (ftStaffSubsidyDao.getPrice() != null) {
|
||||||
@ -130,7 +130,7 @@ public class FtStaffSubsidyDaoController extends BaseController {
|
|||||||
FtStaffSubsidyDao ftStaffSubsidyDao = new FtStaffSubsidyDao();
|
FtStaffSubsidyDao ftStaffSubsidyDao = new FtStaffSubsidyDao();
|
||||||
ftStaffSubsidyDao.setStaffId(staffDatum.getStaffId());
|
ftStaffSubsidyDao.setStaffId(staffDatum.getStaffId());
|
||||||
ftStaffSubsidyDao.setSubsidyType(subsidy.getType());
|
ftStaffSubsidyDao.setSubsidyType(subsidy.getType());
|
||||||
ftStaffSubsidyDao.setIncomeType("1");
|
ftStaffSubsidyDao.setIncomeType(1);
|
||||||
ftStaffSubsidyDao.setPrice(subsidy.getPrice());
|
ftStaffSubsidyDao.setPrice(subsidy.getPrice());
|
||||||
ftStaffSubsidyDao.setConsumAt(giveOutDate);
|
ftStaffSubsidyDao.setConsumAt(giveOutDate);
|
||||||
ftStaffSubsidyDaoList.add(ftStaffSubsidyDao);
|
ftStaffSubsidyDaoList.add(ftStaffSubsidyDao);
|
||||||
|
|||||||
@ -110,7 +110,7 @@ public class FtOrderDao implements Serializable {
|
|||||||
* 支付方式
|
* 支付方式
|
||||||
*/
|
*/
|
||||||
@Excel(name = "支付方式")
|
@Excel(name = "支付方式")
|
||||||
private String payType;
|
private Integer payType;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 支付标志
|
* 支付标志
|
||||||
|
|||||||
@ -52,7 +52,7 @@ public class FtStaffSubsidyDao implements Serializable {
|
|||||||
* 收支类型
|
* 收支类型
|
||||||
*/
|
*/
|
||||||
@Excel(name = "收支类型")
|
@Excel(name = "收支类型")
|
||||||
private String incomeType;
|
private Integer incomeType;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 金额
|
* 金额
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user