diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/fantang/controller/FtSettleDaoController.java b/ruoyi-system/src/main/java/com/ruoyi/system/fantang/controller/FtSettleDaoController.java index 4bb55750e..076ef0ffa 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/system/fantang/controller/FtSettleDaoController.java +++ b/ruoyi-system/src/main/java/com/ruoyi/system/fantang/controller/FtSettleDaoController.java @@ -2,6 +2,7 @@ package com.ruoyi.system.fantang.controller; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; +import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper; import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.ruoyi.common.annotation.Log; import com.ruoyi.common.core.controller.BaseController; @@ -10,11 +11,13 @@ import com.ruoyi.common.core.page.TableDataInfo; import com.ruoyi.common.enums.BusinessType; import com.ruoyi.common.utils.StringUtils; import com.ruoyi.common.utils.poi.ExcelUtil; +import com.ruoyi.system.fantang.domain.FtPrepaymentDao; import com.ruoyi.system.fantang.domain.FtReportMealsDao; import com.ruoyi.system.fantang.domain.FtSettleDao; import com.ruoyi.system.fantang.entity.ReportMealsPriceEntity; import com.ruoyi.system.fantang.entity.SettleEntity; -import com.ruoyi.system.fantang.service.IFtFoodDemandDaoService; +import com.ruoyi.system.fantang.service.IFtInvoiceDaoService; +import com.ruoyi.system.fantang.service.IFtPrepaymentDaoService; import com.ruoyi.system.fantang.service.IFtReportMealsDaoService; import com.ruoyi.system.fantang.service.IFtSettleDaoService; import lombok.RequiredArgsConstructor; @@ -41,7 +44,9 @@ public class FtSettleDaoController extends BaseController { private final IFtReportMealsDaoService iFtReportMealsDaoService; - private final IFtFoodDemandDaoService iFtFoodDemandDaoService; + private final IFtPrepaymentDaoService iFtPrepaymentDaoService; + + private final IFtInvoiceDaoService iFtInvoiceDaoService; /** @@ -50,8 +55,13 @@ public class FtSettleDaoController extends BaseController { @PostMapping("/showMealsWithSelect") public AjaxResult showMealsWithSelect(@RequestBody SettleEntity settlement) { + // 病人 id Long patientId = settlement.getPatientId(); + + // 上次结算 / 用餐日期 Date lastBillingDate = settlement.getLastBillingDate(); + + // 用户选择结算日期 Date selectBillingDate = settlement.getSelectBillingDate(); SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); @@ -66,8 +76,8 @@ public class FtSettleDaoController extends BaseController { ReportMealsPriceEntity reportMealsPrice = iFtReportMealsDaoService.sumTotalPrice(patientId, lastBillingDate, selectBillingDate); Map data = new HashMap<>(); - data.put("reportMealsList",reportMealsList); - data.put("reportMealsPrice",reportMealsPrice); + data.put("reportMealsList", reportMealsList); + data.put("reportMealsPrice", reportMealsPrice); return AjaxResult.success(data); } @@ -77,33 +87,61 @@ public class FtSettleDaoController extends BaseController { */ @PostMapping("/addSettle") public AjaxResult addSettle(@RequestBody SettleEntity settlement) { - System.out.println(settlement); + // 病人 id Long patientId = settlement.getPatientId(); + + // 上次结算 / 用餐日期 Date lastBillingDate = settlement.getLastBillingDate(); + + // 用户选择结算日期 Date selectBillingDate = settlement.getSelectBillingDate(); -// List reportMealsDaoList = iFtReportMealsDaoService.listByPatientIdAndDate(patientId,); + // 应收 + BigDecimal sumTotalPrice = settlement.getSumTotalPrice(); - // 根据病人 id ,上次结算日期,选择日期查询病人非营养餐记录 - QueryWrapper reportMealsWrapper = new QueryWrapper<>(); + // 实收 + BigDecimal netPeceipt = settlement.getNetPeceipt(); + + // 操作用户 + String userName = settlement.getUserName(); + + SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); + + // 根据病人 id 查询预付费记录 + QueryWrapper prepaymentWrapper = new QueryWrapper<>(); + prepaymentWrapper.eq("patient_id", patientId); + FtPrepaymentDao prepaymentDao = iFtPrepaymentDaoService.getOne(prepaymentWrapper); + + // 预付费扣费 + BigDecimal prepaid = prepaymentDao.getPrepaid(); + BigDecimal balance = prepaid.subtract(netPeceipt); + prepaymentDao.setPrepaid(balance); + iFtPrepaymentDaoService.updateById(prepaymentDao); + + // 添加结算记录 + FtSettleDao ftSettleDao = new FtSettleDao(); + ftSettleDao.setReceipts(netPeceipt); + ftSettleDao.setPatientId(patientId); + Date nowDate = new Date(); + ftSettleDao.setSettleAt(nowDate); + ftSettleDao.setOpera(userName); + ftSettleDao.setPayable(sumTotalPrice); + ftSettleDao.setReceipts(netPeceipt); + iFtSettleDaoService.save(ftSettleDao); + + // 修改报餐信息 + UpdateWrapper reportMealsWrapper = new UpdateWrapper<>(); reportMealsWrapper.eq("patient_id", patientId); - reportMealsWrapper.eq("nutrition_food_flag", 0); - reportMealsWrapper.between("create_at", lastBillingDate, selectBillingDate); - List reportMealsList = iFtReportMealsDaoService.list(reportMealsWrapper); + reportMealsWrapper.between("create_at", sdf.format(lastBillingDate), sdf.format(selectBillingDate)); + FtReportMealsDao reportMealsDao = new FtReportMealsDao(); + reportMealsDao.setSettlementFlag(1); + reportMealsDao.setSettlementAt(nowDate); + reportMealsDao.setSettlementBy(userName); + reportMealsDao.setSettlementId(ftSettleDao.getSettleId()); + iFtReportMealsDaoService.update(reportMealsDao, reportMealsWrapper); - // 统计非营养餐总价 -// BigDecimal totalPrice = iFtReportMealsDaoService.sumTotalPrice(patientId, lastBillingDate, selectBillingDate); - - - // 根据病人 id ,上次结算日期,选择日期查询病人养餐记录 - QueryWrapper withNutritionWrapper = new QueryWrapper<>(); - withNutritionWrapper.eq("patient_id", patientId); - withNutritionWrapper.eq("nutrition_food_flag", 1); - withNutritionWrapper.between("create_at", lastBillingDate, selectBillingDate); - List withNutritionList = iFtReportMealsDaoService.list(reportMealsWrapper); - - return null; + return AjaxResult.success("已收费"); } /** diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/fantang/domain/FtReportMealsDao.java b/ruoyi-system/src/main/java/com/ruoyi/system/fantang/domain/FtReportMealsDao.java index 741770c42..5a88cc230 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/system/fantang/domain/FtReportMealsDao.java +++ b/ruoyi-system/src/main/java/com/ruoyi/system/fantang/domain/FtReportMealsDao.java @@ -77,7 +77,9 @@ public class FtReportMealsDao implements Serializable { /** * 结算标志 */ - private Long settlementFlag; + private Integer settlementFlag; + + private Long settlementId; @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss") private Date settlementAt; diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/fantang/entity/SettleEntity.java b/ruoyi-system/src/main/java/com/ruoyi/system/fantang/entity/SettleEntity.java index 83f970fc9..8a4d8bfae 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/system/fantang/entity/SettleEntity.java +++ b/ruoyi-system/src/main/java/com/ruoyi/system/fantang/entity/SettleEntity.java @@ -54,4 +54,13 @@ public class SettleEntity { // 操作员 private String userName; + // 正餐总价 + private BigDecimal dinnerTotalPrice; + + // 营养餐总价 + private BigDecimal nutritionTotalPrice; + + // 正餐和营养餐总价 + private BigDecimal sumTotalPrice; + } diff --git a/ruoyi-system/src/main/java/com/ruoyi/system/fantang/service/IFtReportMealsDaoService.java b/ruoyi-system/src/main/java/com/ruoyi/system/fantang/service/IFtReportMealsDaoService.java index 86ad20d79..994975b87 100644 --- a/ruoyi-system/src/main/java/com/ruoyi/system/fantang/service/IFtReportMealsDaoService.java +++ b/ruoyi-system/src/main/java/com/ruoyi/system/fantang/service/IFtReportMealsDaoService.java @@ -32,3 +32,4 @@ public interface IFtReportMealsDaoService extends IService { ReportMealsPriceEntity sumTotalPrice(Long patientId, Date lastBillingDate, Date selectBillingDate); } + diff --git a/ruoyi-system/src/main/resources/mapper/fantang/FtReportMealsDaoMapper.xml b/ruoyi-system/src/main/resources/mapper/fantang/FtReportMealsDaoMapper.xml index eebd7e972..93ec67e35 100644 --- a/ruoyi-system/src/main/resources/mapper/fantang/FtReportMealsDaoMapper.xml +++ b/ruoyi-system/src/main/resources/mapper/fantang/FtReportMealsDaoMapper.xml @@ -13,6 +13,7 @@ + diff --git a/ruoyi-ui/src/views/fantang/settle/index.vue b/ruoyi-ui/src/views/fantang/settle/index.vue index 3a04b5be4..f340c28ef 100644 --- a/ruoyi-ui/src/views/fantang/settle/index.vue +++ b/ruoyi-ui/src/views/fantang/settle/index.vue @@ -346,6 +346,9 @@ export default { // 费用结算弹出层数据 formAddNewSettlement: { + dinnerTotalPrice: 0, + nutritionTotalPrice: 0, + sumTotalPrice: 0, hospitalId: null, patientId: null, name: null, @@ -465,14 +468,14 @@ export default { this.formAddNewSettlement.settlementDays = iDays; } - if (this.formAddNewSettlement.selectBillingDate!=null){ + if (this.formAddNewSettlement.selectBillingDate != null) { showMealsWithSelect(this.formAddNewSettlement).then(response => { this.mealsList = response.data.reportMealsList; this.dinnerTotalPrice = response.data.reportMealsPrice.dinnerTotalPrice; this.nutritionTotalPrice = response.data.reportMealsPrice.nutritionTotalPrice; this.sumTotalPrice = response.data.reportMealsPrice.sumTotalPrice; }) - }else { + } else { this.mealsList = null; this.dinnerTotalPrice = 0; this.nutritionTotalPrice = 0; @@ -632,11 +635,19 @@ export default { // } else { console.log(this.formAddNewSettlement); this.formAddNewSettlement.opera = this.userName; - addSettle(this.formAddNewSettlement).then(response => { - this.msgSuccess("结算成功"); - this.flagAddNewSettlementOpen = false; - this.getList(); - }); + this.formAddNewSettlement.dinnerTotalPrice = this.dinnerTotalPrice; + this.formAddNewSettlement.nutritionTotalPrice = this.nutritionTotalPrice; + this.formAddNewSettlement.sumTotalPrice = this.sumTotalPrice + console.log(this.formAddNewSettlement); + if (this.formAddNewSettlement.prepayment >= this.formAddNewSettlement.netPeceipt) { + addSettle(this.formAddNewSettlement).then(response => { + this.msgSuccess("已收费"); + this.flagAddNewSettlementOpen = false; + this.getList(); + }); + }else { + this.msgError("预付费余额不足"); + } // } // } // });