add
This commit is contained in:
@@ -211,6 +211,26 @@ public class AdminController {
|
||||
return ApiResponse.success(billService.createBill(bill));
|
||||
}
|
||||
|
||||
@PutMapping("/bills")
|
||||
public ApiResponse<Void> updateBill(@RequestBody BillRequest request) {
|
||||
Bill existing = billMapper.findById(request.getId());
|
||||
if (existing == null) {
|
||||
throw new ApiException("账单不存在");
|
||||
}
|
||||
Bill bill = new Bill();
|
||||
bill.setId(request.getId());
|
||||
bill.setElderId(request.getElderId());
|
||||
bill.setMonth(request.getMonth());
|
||||
bill.setBedFee(request.getBedFee());
|
||||
bill.setCareFee(request.getCareFee());
|
||||
bill.setMealFee(request.getMealFee());
|
||||
bill.setOtherFee(request.getOtherFee());
|
||||
bill.setTotal(billService.calcTotal(bill));
|
||||
bill.setStatus(existing.getStatus());
|
||||
billMapper.update(bill);
|
||||
return ApiResponse.success();
|
||||
}
|
||||
|
||||
@GetMapping("/bills")
|
||||
public ApiResponse<List<Bill>> listBills(@RequestParam(required = false) Long elderId) {
|
||||
if (elderId == null) {
|
||||
@@ -219,6 +239,16 @@ public class AdminController {
|
||||
return ApiResponse.success(billService.listByElderId(elderId));
|
||||
}
|
||||
|
||||
@DeleteMapping("/bills/{id}")
|
||||
public ApiResponse<Void> deleteBill(@PathVariable Long id) {
|
||||
Bill existing = billMapper.findById(id);
|
||||
if (existing == null) {
|
||||
throw new ApiException("账单不存在");
|
||||
}
|
||||
billMapper.delete(id);
|
||||
return ApiResponse.success();
|
||||
}
|
||||
|
||||
@GetMapping("/feedback")
|
||||
public ApiResponse<List<Feedback>> listFeedback() {
|
||||
return ApiResponse.success(feedbackMapper.listAll());
|
||||
|
||||
@@ -149,6 +149,12 @@ public class FamilyController {
|
||||
return ApiResponse.success(feedback);
|
||||
}
|
||||
|
||||
@GetMapping("/feedback")
|
||||
public ApiResponse<List<Feedback>> listFeedback() {
|
||||
Long familyId = Long.valueOf(StpUtil.getLoginId().toString());
|
||||
return ApiResponse.success(feedbackMapper.listByFamilyId(familyId));
|
||||
}
|
||||
|
||||
@GetMapping("/notices")
|
||||
public ApiResponse<List<Notice>> listNotices() {
|
||||
Long familyId = Long.valueOf(StpUtil.getLoginId().toString());
|
||||
|
||||
@@ -3,6 +3,7 @@ package com.nursinghome.dto;
|
||||
import java.math.BigDecimal;
|
||||
|
||||
public class BillRequest {
|
||||
private Long id;
|
||||
private Long elderId;
|
||||
private String month;
|
||||
private BigDecimal bedFee;
|
||||
@@ -10,6 +11,14 @@ public class BillRequest {
|
||||
private BigDecimal mealFee;
|
||||
private BigDecimal otherFee;
|
||||
|
||||
public Long getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(Long id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public Long getElderId() {
|
||||
return elderId;
|
||||
}
|
||||
|
||||
@@ -25,4 +25,10 @@ public interface BillMapper {
|
||||
|
||||
@Update("UPDATE bill SET status=#{status}, paid_at=#{paidAt} WHERE id=#{id}")
|
||||
int updateStatus(Bill bill);
|
||||
|
||||
@Update("UPDATE bill SET elder_id=#{elderId}, month=#{month}, bed_fee=#{bedFee}, care_fee=#{careFee}, meal_fee=#{mealFee}, other_fee=#{otherFee}, total=#{total}, status=#{status} WHERE id=#{id}")
|
||||
int update(Bill bill);
|
||||
|
||||
@Delete("DELETE FROM bill WHERE id=#{id}")
|
||||
int delete(Long id);
|
||||
}
|
||||
|
||||
@@ -14,6 +14,9 @@ public interface FeedbackMapper {
|
||||
@Select("SELECT * FROM feedback ORDER BY created_at DESC")
|
||||
List<Feedback> listAll();
|
||||
|
||||
@Select("SELECT * FROM feedback WHERE family_id = #{familyId} ORDER BY created_at DESC")
|
||||
List<Feedback> listByFamilyId(Long familyId);
|
||||
|
||||
@Update("UPDATE feedback SET status=#{status}, reply=#{reply}, updated_at=NOW() WHERE id=#{id}")
|
||||
int updateStatus(Feedback feedback);
|
||||
}
|
||||
|
||||
@@ -22,12 +22,7 @@ public class BillService {
|
||||
|
||||
public Bill createBill(Bill bill) {
|
||||
if (bill.getTotal() == null) {
|
||||
BigDecimal total = BigDecimal.ZERO;
|
||||
if (bill.getBedFee() != null) total = total.add(bill.getBedFee());
|
||||
if (bill.getCareFee() != null) total = total.add(bill.getCareFee());
|
||||
if (bill.getMealFee() != null) total = total.add(bill.getMealFee());
|
||||
if (bill.getOtherFee() != null) total = total.add(bill.getOtherFee());
|
||||
bill.setTotal(total);
|
||||
bill.setTotal(calcTotal(bill));
|
||||
}
|
||||
if (bill.getStatus() == null) {
|
||||
bill.setStatus("UNPAID");
|
||||
@@ -36,6 +31,15 @@ public class BillService {
|
||||
return bill;
|
||||
}
|
||||
|
||||
public BigDecimal calcTotal(Bill bill) {
|
||||
BigDecimal total = BigDecimal.ZERO;
|
||||
if (bill.getBedFee() != null) total = total.add(bill.getBedFee());
|
||||
if (bill.getCareFee() != null) total = total.add(bill.getCareFee());
|
||||
if (bill.getMealFee() != null) total = total.add(bill.getMealFee());
|
||||
if (bill.getOtherFee() != null) total = total.add(bill.getOtherFee());
|
||||
return total;
|
||||
}
|
||||
|
||||
public List<Bill> listByElderId(Long elderId) {
|
||||
return billMapper.listByElderId(elderId);
|
||||
}
|
||||
|
||||
@@ -19,7 +19,6 @@ mybatis:
|
||||
sa-token:
|
||||
token-name: satoken
|
||||
timeout: 86400
|
||||
activity-timeout: -1
|
||||
is-concurrent: true
|
||||
is-share: true
|
||||
token-style: uuid
|
||||
|
||||
Reference in New Issue
Block a user