wangqifan 5 роки тому
батько
коміт
90c952eab6

+ 45 - 32
src/main/java/com/izouma/zhumj/service/EntryRecordService.java

@@ -26,6 +26,9 @@ import org.springframework.stereotype.Service;
 
 import javax.persistence.criteria.Predicate;
 import java.math.BigDecimal;
+import java.time.LocalDate;
+import java.time.LocalDateTime;
+import java.time.LocalTime;
 import java.util.ArrayList;
 import java.util.List;
 import java.util.Optional;
@@ -80,37 +83,46 @@ public class EntryRecordService {
         return entryRecordRepo.save(entryRecord);
     }
 
-    public List<EntryRecordDTO> showRecords(Long customerId, Long contractId, EntryType type, Long billId) {
-        List<EntryRecord> entryRecords = entryRecordRepo.findAll((Specification<EntryRecord>) (root, criteriaQuery, criteriaBuilder) -> {
-            List<Predicate> and = new ArrayList<>();
-            if (customerId != null) {
-                and.add(criteriaBuilder.equal(root.get("customerId"), customerId));
-            }
-            if (contractId != null) {
-                List<Long> billIds = contractBillRepo.findByContractId(contractId)
-                        .stream()
-                        .map(ContractBill::getId)
-                        .collect(Collectors.toList());
-                and.add(root.get("billId").in(billIds));
-            }
-            if (type != null) {
-                and.add(criteriaBuilder.equal(root.get("type"), type));
-            } else {
-                and.add(criteriaBuilder.or(
-                        criteriaBuilder.equal(root.get("type"), EntryType.DEPOSIT),
-                        criteriaBuilder.equal(root.get("type"), EntryType.RECHARGE)
-                ));
-            }
-            if (billId != null) {
-                and.add(criteriaBuilder.equal(root.get("billId"), billId));
-            }
-            if (SecurityUtils.getAuthenticatedUser()
-                    .getAuthorities()
-                    .contains(Authority.getInstance(Authority.NAME.ROLE_SALE))) {
-                and.add(criteriaBuilder.equal(root.get("userId"), SecurityUtils.getAuthenticatedUser().getId()));
-            }
-            return criteriaBuilder.and(and.toArray(new Predicate[0]));
-        });
+    public List<EntryRecordDTO> showRecords(Long customerId, Long contractId, EntryType type, Long billId, LocalDate start, LocalDate end, Long saleId) {
+        List<EntryRecord> entryRecords = entryRecordRepo
+                .findAll((Specification<EntryRecord>) (root, criteriaQuery, criteriaBuilder) -> {
+                    List<Predicate> and = new ArrayList<>();
+                    if (customerId != null) {
+                        and.add(criteriaBuilder.equal(root.get("customerId"), customerId));
+                    }
+                    if (contractId != null) {
+                        List<Long> billIds = contractBillRepo.findByContractId(contractId)
+                                .stream()
+                                .map(ContractBill::getId)
+                                .collect(Collectors.toList());
+                        and.add(root.get("billId").in(billIds));
+                    }
+                    if (start != null & end != null) {
+                        and.add(criteriaBuilder
+                                .between(root.get("createdAt"), start.atStartOfDay(), end.atTime(LocalTime.MAX)));
+                    }
+                    if (saleId != null) {
+                        and.add(criteriaBuilder.equal(root.get("userId"), saleId));
+                    }
+                    if (type != null) {
+                        and.add(criteriaBuilder.equal(root.get("type"), type));
+                    } else {
+                        and.add(criteriaBuilder.or(
+                                criteriaBuilder.equal(root.get("type"), EntryType.DEPOSIT),
+                                criteriaBuilder.equal(root.get("type"), EntryType.RECHARGE)
+                        ));
+                    }
+                    if (billId != null) {
+                        and.add(criteriaBuilder.equal(root.get("billId"), billId));
+                    }
+                    if (SecurityUtils.getAuthenticatedUser()
+                            .getAuthorities()
+                            .contains(Authority.getInstance(Authority.NAME.ROLE_SALE))) {
+                        and.add(criteriaBuilder
+                                .equal(root.get("userId"), SecurityUtils.getAuthenticatedUser().getId()));
+                    }
+                    return criteriaBuilder.and(and.toArray(new Predicate[0]));
+                });
         List<EntryRecordDTO> dtos = new ArrayList<>();
         entryRecords.removeIf(entryRecord -> entryRecord.getBillId() == null);
         entryRecords.forEach(entryRecord -> {
@@ -127,7 +139,8 @@ public class EntryRecordService {
                     List<ReceiptStatus> receiptStatuses = new ArrayList<>();
                     receiptStatuses.add(ReceiptStatus.APPLY);
                     receiptStatuses.add(ReceiptStatus.COMPLETED);
-                    BillReceipt billReceipt = billReceiptRepo.findByBillIdAndStatusInAndBillTypeNot(billId, receiptStatuses, ReceiptType.DEPOSIT);
+                    BillReceipt billReceipt = billReceiptRepo
+                            .findByBillIdAndStatusInAndBillTypeNot(billId, receiptStatuses, ReceiptType.DEPOSIT);
                     EntryRecordDTO dto = EntryRecordDTO.builder()
                             .date(entryRecord.getCreatedAt().toLocalDate())
                             .source(contract.getContractSource().getDescription())

+ 21 - 6
src/main/java/com/izouma/zhumj/service/sale/ContractService.java

@@ -246,7 +246,8 @@ public class ContractService {
                 predicates.add(root.get("saleId").in(sales));
             }
 
-            if (!(SecurityUtils.hasRole(Authority.NAME.ROLE_SALE_ASSISTANT) || SecurityUtils.hasRole(Authority.NAME.ROLE_ADMIN))) {
+            if (!(SecurityUtils.hasRole(Authority.NAME.ROLE_SALE_ASSISTANT) || SecurityUtils
+                    .hasRole(Authority.NAME.ROLE_ADMIN))) {
                 Long saleId = SecurityUtils.getAuthenticatedUser().getId();
                 Set<Long> userIds = departmentService.allUsersWithOutThisDepartmentByUserId(saleId);
                 if (!userIds.isEmpty()) {
@@ -650,12 +651,23 @@ public class ContractService {
                         criteriaQuery.where(
                                 criteriaBuilder.equal(root.get("storeId"), storeId)
                         ).getRestriction());
-        return contractStoreList.stream()
+        List<ContractRoomType> contractRoomTypes = contractStoreList.stream()
                 .filter(contractStore -> contractStore.getContractNumber()
                         .equals(contract.getContractNumber()))
                 .flatMap(contractStore -> contractStore.getRoomTypes().stream())
                 .peek(contractRoom -> contractRoom.setStoreInfo(null))
                 .collect(Collectors.toList());
+        Set<Long> roomTypeIds = new HashSet<>();
+        Iterator<ContractRoomType> iterator = contractRoomTypes.iterator();
+        while (iterator.hasNext()) {
+            ContractRoomType contractRoomType = iterator.next();
+            if (roomTypeIds.contains(contractRoomType.getRoomTypeId())) {
+                iterator.remove();
+            } else {
+                roomTypeIds.add(contractRoomType.getRoomTypeId());
+            }
+        }
+        return contractRoomTypes;
     }
 
     public List<ContractCheckinInfo> storeContractCheckinInfos(Long storeId, Long contractId) {
@@ -691,7 +703,8 @@ public class ContractService {
     @Scheduled(cron = "0 0 0 * * ?")
     public void updateContractPhase() {
         LocalDate now = LocalDate.now();
-        List<ContractPhase> contractPhases = contractPhaseRepo.findByStartTimeBetween(now.atStartOfDay(), now.atTime(Constants.TIME_MAX));
+        List<ContractPhase> contractPhases = contractPhaseRepo
+                .findByStartTimeBetween(now.atStartOfDay(), now.atTime(Constants.TIME_MAX));
         for (ContractPhase contractPhase : contractPhases) {
             Contract contract = contractRepo.findById(contractPhase.getContractId()).orElse(null);
             if (contract == null) {
@@ -773,7 +786,8 @@ public class ContractService {
                     String roomNum = "";
                     if (roomTypeInfo != null) {
                         roomTypeName = roomTypeInfo.getTypeName();
-                        if (contract.getCheckInType() == CheckInType.TEAM || contract.getCheckInType() == CheckInType.SCATTERED_BEDS) {
+                        if (contract.getCheckInType() == CheckInType.TEAM || contract
+                                .getCheckInType() == CheckInType.SCATTERED_BEDS) {
                             roomNum = BigDecimal.valueOf(contractRoomType.getBeds())
                                     .divide(BigDecimal.valueOf(roomTypeInfo.getBedCount()), 1, RoundingMode.HALF_UP)
                                     .stripTrailingZeros().toPlainString() + "间";
@@ -863,8 +877,9 @@ public class ContractService {
             phaseStore.setId(null);
             phaseStore.setRoomTypes(new ArrayList<>());
 
-            for (ContractRoomType contractRoomType : contractRoomTypeRepo.findByContractIdAndStoreId(contract.getId(), contractStore
-                    .getStoreId())) {
+            for (ContractRoomType contractRoomType : contractRoomTypeRepo
+                    .findByContractIdAndStoreId(contract.getId(), contractStore
+                            .getStoreId())) {
                 PhaseRoomType phaseRoomType = new PhaseRoomType();
                 BeanUtils.copyProperties(contractRoomType, phaseRoomType);
                 phaseRoomType.setId(null);

+ 6 - 2
src/main/java/com/izouma/zhumj/web/EntryRecordController.java

@@ -15,6 +15,7 @@ import org.springframework.web.bind.annotation.*;
 
 import javax.servlet.http.HttpServletResponse;
 import java.io.IOException;
+import java.time.LocalDate;
 import java.util.List;
 
 @RestController
@@ -68,8 +69,11 @@ public class EntryRecordController extends BaseController {
     public List<EntryRecordDTO> recordReport(@RequestParam(required = false) Long customerId,
                                              @RequestParam(required = false) Long contractId,
                                              @RequestParam(required = false) EntryType type,
-                                             @RequestParam(required = false) Long billId) {
-        return entryRecordService.showRecords(customerId, contractId, type, billId);
+                                             @RequestParam(required = false) Long billId,
+                                             @RequestParam(required = false) LocalDate start,
+                                             @RequestParam(required = false) LocalDate end,
+                                             @RequestParam(required = false) Long saleId) {
+        return entryRecordService.showRecords(customerId, contractId, type, billId, start, end, saleId);
     }
 }
 

+ 9 - 0
src/main/vue/src/views/BillReceiptList.vue

@@ -93,6 +93,15 @@
                 <el-form-item prop="cycleRange" label="周期范围">
                     <el-input v-model="form.cycleRange" disabled></el-input>
                 </el-form-item>
+                <el-form-item prop="title" label="发票抬头">
+                    <el-input v-model="form.title" disabled></el-input>
+                </el-form-item>
+                <el-form-item prop="mark" label="发票识别号">
+                    <el-input v-model="form.mark" disabled></el-input>
+                </el-form-item>
+                <el-form-item prop="phone" label="注册电话">
+                    <el-input v-model="form.phone" disabled></el-input>
+                </el-form-item>
                 <el-form-item prop="receiptNumber" label="回复票号">
                     <el-input v-model="form.receiptNumber"></el-input>
                 </el-form-item>

+ 49 - 0
src/main/vue/src/views/EntryRecordReport.vue

@@ -21,6 +21,15 @@
                 >
                 </el-option>
             </el-select>
+            <el-select filterable v-model="saleId" placeholder="请选择销售员" class="filter-item">
+                <el-option
+                    v-for="(item, index) in canSaleUser"
+                    :key="index"
+                    :label="item.nickname + '(' + item.departmentName + ')'"
+                    :value="item.id"
+                >
+                </el-option>
+            </el-select>
             <el-select
                 v-model="contractId"
                 filterable
@@ -54,6 +63,18 @@
                 <el-option v-for="item in typeOption" :key="item.value" :label="item.label" :value="item.value">
                 </el-option>
             </el-select>
+            <el-date-picker
+                @change="onCurrentChange(1)"
+                v-model="dateRange"
+                type="daterange"
+                align="right"
+                unlink-panels
+                range-separator="至"
+                start-placeholder="开始日期"
+                end-placeholder="结束日期"
+                value-format="yyyy-MM-dd"
+                class="filter-item"
+            ></el-date-picker>
             <el-button @click="getData()" type="primary" icon="el-icon-search" class="filter-item">
                 搜索
             </el-button>
@@ -112,6 +133,9 @@ export default {
             contractId: null,
             searchingContract: false,
             searchingBills: false,
+            dateRange: [],
+            canSaleUser: [],
+            saleId: '',
             contractOptions: [],
             billOptions: [],
             customerId: null,
@@ -176,6 +200,23 @@ export default {
         }
     },
     methods: {
+        getCanUser() {
+            this.$http
+                .get(`/department/allUserInfosWithOutThisDepartment`)
+                .then(res => {
+                    res.forEach(item => {
+                        if (item.departments.length > 0) {
+                            item.departmentName = item.departments[0].name;
+                        } else {
+                            item.departmentName = '';
+                        }
+                    });
+                    this.canSaleUser = res;
+                })
+                .catch(e => {
+                    this.$message.error(e.error);
+                });
+        },
         getData() {
             let data = {
                 contractId: this.contractId,
@@ -183,6 +224,13 @@ export default {
                 billId: this.billId,
                 type: this.type
             };
+            if (this.dateRange) {
+                data.start = this.dateRange[0];
+                data.end = this.dateRange[1];
+            }
+            if (this.saleId) {
+                data.saleId = this.saleId;
+            }
             this.$http
                 .get('/entryRecord/recordReport', data)
                 .then(res => {
@@ -209,6 +257,7 @@ export default {
             } else {
                 this.searchContract();
             }
+            this.getCanUser();
         },
         searchBill(query) {
             if (this.searchingBills) return;

+ 3 - 3
src/main/vue/src/views/customer/CheckinInfoListForCustomer.vue

@@ -5,8 +5,8 @@
                 v-model="dateRange"
                 type="datetimerange"
                 range-separator="至"
-                start-placeholder="开始日期"
-                end-placeholder="结束日期"
+                start-placeholder="入住开始时间"
+                end-placeholder="入住结束时间"
                 :picker-options="pickerOptions"
                 value-format="yyyy-MM-dd HH:mm:ss"
                 class="filter-item"
@@ -15,7 +15,7 @@
             <el-date-picker
                 v-model="date"
                 type="date"
-                placeholder="选择日期"
+                placeholder="当日在住"
                 value-format="yyyy-MM-dd"
                 class="filter-item"
             >

+ 15 - 6
src/main/vue/src/views/sale/ContractBillList.vue

@@ -87,6 +87,7 @@
             <el-table-column prop="bedCount" label="床位数"> </el-table-column>
             <el-table-column prop="billName" label="费用名称"> </el-table-column>
             <el-table-column prop="receiptAmount" label="开票金额"> </el-table-column>
+            <el-table-column prop="receiptAmount" label="收据金额"> </el-table-column>
             <el-table-column label="操作" align="center" fixed="right" width="250">
                 <template v-slot="{ row }">
                     <el-button
@@ -494,17 +495,24 @@ export default {
                 this.formData.amount = row.money;
                 this.formData.deposit = false;
                 this.formData.rStatus = row.receiptStatus;
+                this.formData.cycleRange = row.startTime + '-' + row.endTime;
             }
             if (type === 0) {
-                this.formData.billType = 'DEPOSIT';
-                this.formData.amount = row.depositAmount;
-                this.formData.deposit = true;
-                this.formData.rStatus = row.depositStatus;
+                this.$http
+                    .get('/contract/get/' + row.contractId)
+                    .then(res => {
+                        this.formData.cycleRange = res.contractBeginTime + '-' + res.contractEndTime;
+                        this.formData.billType = 'DEPOSIT';
+                        this.formData.amount = row.depositAmount;
+                        this.formData.deposit = true;
+                        this.formData.rStatus = row.depositStatus;
+                    })
+                    .catch(e => {
+                        this.$message.error(e.error);
+                    });
             }
             this.formData.contractNumber = row.contractNumber;
             this.formData.customerName = row.coSimpleName;
-
-            this.formData.cycleRange = row.startTime + '-' + row.endTime;
             this.formData.billId = row.id;
             this.formData.idx = row.idx;
             this.getBillInfo(row.customerId);
@@ -525,6 +533,7 @@ export default {
                     if (res.billNumber) {
                         this.formData.mark = res.billNumber;
                     }
+                    this.formData.saleName = res.saleName;
                     this.showReceipt = true;
                 })
                 .catch(e => {