Browse Source

修复 收费bug

weiximei 6 years ago
parent
commit
a71e290a81

+ 11
- 10
CODE/smart-community/property-api/src/main/java/com/community/huiju/controller/BillController.java View File

87
     @PostMapping(value = "/bill/uploadExcel/add", consumes = "multipart/*", headers = "content-type=multipart/form-data")
87
     @PostMapping(value = "/bill/uploadExcel/add", consumes = "multipart/*", headers = "content-type=multipart/form-data")
88
     public ResponseBean addUploadExcel(HttpSession session,
88
     public ResponseBean addUploadExcel(HttpSession session,
89
                                        @RequestParam(value = "billId", required = false) Integer billId,
89
                                        @RequestParam(value = "billId", required = false) Integer billId,
90
-                                       @RequestParam("file") MultipartFile file,
90
+                                       @RequestParam(value = "file", required = false) MultipartFile file,
91
                                        @RequestParam("billExplain") String billExplain,
91
                                        @RequestParam("billExplain") String billExplain,
92
                                        @RequestParam("billName") String billName,
92
                                        @RequestParam("billName") String billName,
93
-                                       @RequestParam("endDate") Date endDate,
93
+                                       @RequestParam("endDate") String endDate,
94
                                        @RequestParam("billStatus") String billStatus) {
94
                                        @RequestParam("billStatus") String billStatus) {
95
         ResponseBean responseBean = new ResponseBean();
95
         ResponseBean responseBean = new ResponseBean();
96
         UserElement userElement = getUserElement(session);
96
         UserElement userElement = getUserElement(session);
97
-//        SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd");
98
-//        Date date = null;
99
-//        try {
100
-//            date = simpleDateFormat.parse(endDate);
101
-//        } catch (ParseException e) {
102
-//            e.printStackTrace();
103
-//        }
104
-        responseBean = iBillService.getExcelData(billId, file, billExplain, billName, endDate, billStatus, userElement);
97
+        SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
98
+        Date date = null;
99
+        try {
100
+            String d = simpleDateFormat.format(new Long(endDate));
101
+            date = simpleDateFormat.parse(d);
102
+        } catch (ParseException e) {
103
+            e.printStackTrace();
104
+        }
105
+        responseBean = iBillService.getExcelData(billId, file, billExplain, billName, date, billStatus, userElement);
105
         return responseBean;
106
         return responseBean;
106
     }
107
     }
107
 
108
 

+ 12
- 0
CODE/smart-community/property-api/src/main/java/com/community/huiju/service/impl/BillInvoiceServiceImpl.java View File

179
                 Bill bill = billMapper.selectById(billInvoice.getBillId());
179
                 Bill bill = billMapper.selectById(billInvoice.getBillId());
180
                 bill.setPayedNum(bill.getPayedNum() + 1);
180
                 bill.setPayedNum(bill.getPayedNum() + 1);
181
                 bill.setUnpayedNum(bill.getUnpayedNum() - 1);
181
                 bill.setUnpayedNum(bill.getUnpayedNum() - 1);
182
+                // 未交户数为0时, 收费组状态变更为 1 , 收费完成
183
+                if (bill.getUnpayedNum() == 0) {
184
+                    bill.setBillStatus("1");
185
+                }
182
                 billMapper.updateById(bill);
186
                 billMapper.updateById(bill);
183
 
187
 
184
             }
188
             }
211
         // 收费金额
215
         // 收费金额
212
         Double payPrice = jsonObject.getDouble("payPrice");
216
         Double payPrice = jsonObject.getDouble("payPrice");
213
 
217
 
218
+        // 判断是不是已经 收费完成
219
+        Bill bill = billMapper.selectById(billId);
220
+        if ("1".equals(bill.getBillStatus())) {
221
+            // 状态 收费完成, 不允许添加收费单
222
+            responseBean.addError("不能给收费已完成的收费组添加收费单!");
223
+            return responseBean;
224
+        }
225
+
214
         // 楼栋资料库
226
         // 楼栋资料库
215
         QueryWrapper<TpBuildingOwnerInfo> queryWrapper = new QueryWrapper<>();
227
         QueryWrapper<TpBuildingOwnerInfo> queryWrapper = new QueryWrapper<>();
216
         queryWrapper.eq("phase", phase);
228
         queryWrapper.eq("phase", phase);

+ 50
- 19
CODE/smart-community/property-api/src/main/java/com/community/huiju/service/impl/BillServiceImpl.java View File

2
 
2
 
3
 import com.alibaba.fastjson.JSONObject;
3
 import com.alibaba.fastjson.JSONObject;
4
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
4
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
5
+import com.baomidou.mybatisplus.core.metadata.IPage;
5
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
6
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
6
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
7
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
7
 import com.community.commom.constant.Constant;
8
 import com.community.commom.constant.Constant;
163
     public ResponseBean getExcelData(Integer billId, MultipartFile file, String billExplain, String billName, Date endDate, String billStatus, UserElement userElement) {
164
     public ResponseBean getExcelData(Integer billId, MultipartFile file, String billExplain, String billName, Date endDate, String billStatus, UserElement userElement) {
164
         ResponseBean responseBean = new ResponseBean();
165
         ResponseBean responseBean = new ResponseBean();
165
 
166
 
167
+        List<BillInvoice> records = null;
168
+        if (billId != null) {
169
+            // 查询出这个收费单, 存在的缴费单数据
170
+            QueryWrapper<BillInvoice> billInvoiceQueryWrapper = new QueryWrapper<>();
171
+            billInvoiceQueryWrapper.eq("bill_id", billId);
172
+            billInvoiceQueryWrapper.eq("community_id", userElement.getCommunityId());
173
+            records = billInvoiceMapper.selectList(billInvoiceQueryWrapper);
174
+        }
175
+
176
+        // 如果没有携带 excel 文件, 并且这个收费组里面也没有收费单, 那么就提示 发送账单失败,需要先上传账单excel
177
+        if (null == file && "0".equals(billStatus) && (null == records ||records.size() == 0)) {
178
+            responseBean.addError("发送账单失败,需要先上传账单excel");
179
+            return responseBean;
180
+        }
181
+
166
         responseBean = getExcelData(file, responseBean);
182
         responseBean = getExcelData(file, responseBean);
167
         List<TempBill> tempBills = (List<TempBill>) responseBean.getData();
183
         List<TempBill> tempBills = (List<TempBill>) responseBean.getData();
168
 
184
 
169
-        Double sumDouble = tempBills.stream().mapToDouble(TempBill::getMoney).sum() * 100;
185
+        Double sumDouble = 0.0;
170
         String strSumDouble = sumDouble + "";
186
         String strSumDouble = sumDouble + "";
187
+        // 如果 List 有数据, 表示携带了文件上传, 那么就从excel文件里面读取金额
188
+        if (tempBills.size() > 0) {
189
+            sumDouble = tempBills.stream().mapToDouble(TempBill::getMoney).sum() * 100;
190
+            strSumDouble = sumDouble + "";
191
+        }
192
+        // 如果 List 没有数据, records 有数据, 就表示用户做的修改操作 并且没有上传文件, 那么这里的金额应该从数据库读取
193
+        if (tempBills.size() == 0 && records != null) {
194
+            sumDouble = records.stream().mapToDouble(BillInvoice::getPayPrice).sum();
195
+            strSumDouble = sumDouble + "";
196
+        }
171
 
197
 
172
         // 存入缴费项表
198
         // 存入缴费项表
173
         Bill bill = new Bill();
199
         Bill bill = new Bill();
178
             strSumDouble = strSumDouble.substring(0, strSumDouble.lastIndexOf("."));
204
             strSumDouble = strSumDouble.substring(0, strSumDouble.lastIndexOf("."));
179
             bill.setPayPrice(strSumDouble);
205
             bill.setPayPrice(strSumDouble);
180
         }
206
         }
181
-        bill.setPayTotalNum(tempBills.size());
207
+
182
         bill.setPayedNum(0);
208
         bill.setPayedNum(0);
183
-        bill.setUnpayedNum(tempBills.size());
184
         bill.setBillStatus(billStatus);
209
         bill.setBillStatus(billStatus);
185
         bill.setCreateUser(userElement.getId());
210
         bill.setCreateUser(userElement.getId());
186
         bill.setCreateDate(new Date());
211
         bill.setCreateDate(new Date());
187
         bill.setCommunityId(userElement.getCommunityId());
212
         bill.setCommunityId(userElement.getCommunityId());
188
-        bill.setPayTotalNum(tempBills.size());
189
-        bill.setUnpayedNum(tempBills.size());
213
+        Integer payTotalNum = tempBills.size() != 0 ? tempBills.size() : records != null ? records.size() : 0;
214
+        Integer unpayedNum = tempBills.size() != 0 ? tempBills.size() : records != null ? records.size() : 0;
215
+        bill.setPayTotalNum(payTotalNum);
216
+        bill.setUnpayedNum(unpayedNum);
190
 
217
 
191
-        if (billId != null) {
218
+        if (file != null) {
192
             // 删除掉旧数据
219
             // 删除掉旧数据
193
-            QueryWrapper<BillInvoice> billInvoiceQueryWrapper = new QueryWrapper<>();
194
-            billInvoiceQueryWrapper.eq("bill_id", billId);
195
-            billInvoiceMapper.delete(billInvoiceQueryWrapper);
220
+            QueryWrapper<BillInvoice> billInvoiceQuery = new QueryWrapper<>();
221
+            billInvoiceQuery.eq("bill_id", billId);
222
+            billInvoiceMapper.delete(billInvoiceQuery);
223
+        }
196
 
224
 
225
+        if (billId != null) {
226
+            bill.setCreateUser(null);
227
+            bill.setCreateDate(null);
197
             // 设置主键, 表示修改
228
             // 设置主键, 表示修改
198
             bill.setId(billId);
229
             bill.setId(billId);
199
         }
230
         }
238
             }).collect(Collectors.toList());
269
             }).collect(Collectors.toList());
239
 
270
 
240
             iBillInvoiceService.saveBatch(billInvoices);
271
             iBillInvoiceService.saveBatch(billInvoices);
241
-            responseBean.addSuccess("操作成功!");
242
-        } else {
243
-            responseBean.addError("操作失败!");
244
         }
272
         }
245
-
246
-
273
+        responseBean.addSuccess("操作成功!");
247
         return responseBean;
274
         return responseBean;
248
     }
275
     }
249
 
276
 
250
     private ResponseBean getExcelData(MultipartFile file, ResponseBean responseBean) {
277
     private ResponseBean getExcelData(MultipartFile file, ResponseBean responseBean) {
251
-        ResponseBean responseBean1 = new ResponseBean();
278
+
279
+        // 数据
280
+        List<TempBill> tempBills = Lists.newArrayList();
281
+        if (null == file) {
282
+            responseBean.addSuccess(tempBills);
283
+            return responseBean;
284
+        }
285
+
252
         //获取文件的名字
286
         //获取文件的名字
253
         String originalFilename = file.getOriginalFilename();
287
         String originalFilename = file.getOriginalFilename();
254
         Workbook workbook = null;
288
         Workbook workbook = null;
269
         Sheet sheetAt = workbook.getSheetAt(0);
303
         Sheet sheetAt = workbook.getSheetAt(0);
270
         int lastRowNum = sheetAt.getLastRowNum();
304
         int lastRowNum = sheetAt.getLastRowNum();
271
 
305
 
272
-        // 数据
273
-        List<TempBill> tempBills = Lists.newArrayList();
274
-
275
         // 从第7行开始读取
306
         // 从第7行开始读取
276
         for (int i= 6; i<= lastRowNum; i++) {
307
         for (int i= 6; i<= lastRowNum; i++) {
277
             Row row = sheetAt.getRow(i);
308
             Row row = sheetAt.getRow(i);
322
 
353
 
323
 
354
 
324
             if (StringUtils.isNotBlank(money)) {
355
             if (StringUtils.isNotBlank(money)) {
325
-                Double moneyDouble = Double.valueOf(money) * 100;
356
+                Double moneyDouble = Double.valueOf(money); // * 100
326
                 money = moneyDouble + "";
357
                 money = moneyDouble + "";
327
                 money = money.substring(0, money.lastIndexOf("."));
358
                 money = money.substring(0, money.lastIndexOf("."));
328
                 temp.setMoney(Integer.valueOf(money));
359
                 temp.setMoney(Integer.valueOf(money));

+ 1
- 0
VUECODE/smart-property-manage/src/views/bill/add/index.vue View File

11
         <el-date-picker
11
         <el-date-picker
12
           v-model="ruleForm.endDate"
12
           v-model="ruleForm.endDate"
13
           type="date"
13
           type="date"
14
+          value-format="timestamp"
14
           placeholder="选择日期"/>
15
           placeholder="选择日期"/>
15
       </el-form-item>
16
       </el-form-item>
16
       <div>
17
       <div>

+ 7
- 6
VUECODE/smart-property-manage/src/views/bill/edi/index.vue View File

11
         <el-date-picker
11
         <el-date-picker
12
           v-model="ruleForm.endDate"
12
           v-model="ruleForm.endDate"
13
           type="date"
13
           type="date"
14
+          value-format="timestamp"
14
           placeholder="选择日期"/>
15
           placeholder="选择日期"/>
15
       </el-form-item>
16
       </el-form-item>
16
       <div>
17
       <div>
68
         layout="total, sizes, prev, pager, next, jumper"
69
         layout="total, sizes, prev, pager, next, jumper"
69
         @size-change="handleSizeChange"
70
         @size-change="handleSizeChange"
70
         @current-change="handleCurrentChange"/>
71
         @current-change="handleCurrentChange"/>
71
-      <el-form-item v-if="isUpload" style="margin-top: 20px;">
72
+      <el-form-item style="margin-top: 20px;"> <!-- v-if="isUpload" -->
72
         <el-button @click="submitFormAdd('ruleForm', 2)">保存草稿</el-button>
73
         <el-button @click="submitFormAdd('ruleForm', 2)">保存草稿</el-button>
73
         <el-button type="primary" @click="submitFormAdd('ruleForm', 0)">发送账单</el-button>
74
         <el-button type="primary" @click="submitFormAdd('ruleForm', 0)">发送账单</el-button>
74
       </el-form-item>
75
       </el-form-item>
75
-      <el-form-item v-else style="margin-top: 20px;">
76
-        <el-button @click="submitForm('ruleForm', 2)">保存草稿</el-button>
77
-        <el-button type="primary" @click="submitForm('ruleForm', 0)">发送账单</el-button>
78
-      </el-form-item>
76
+      <!--<el-form-item v-else style="margin-top: 20px;">-->
77
+      <!--<el-button @click="submitForm('ruleForm', 2)">保存草稿</el-button>-->
78
+      <!--<el-button type="primary" @click="submitForm('ruleForm', 0)">发送账单</el-button>-->
79
+      <!--</el-form-item>-->
79
     </el-form>
80
     </el-form>
80
   </div>
81
   </div>
81
 </template>
82
 </template>
211
           // const data = this.ruleForm
212
           // const data = this.ruleForm
212
           // data.files = this.files
213
           // data.files = this.files
213
           const formData = new FormData()
214
           const formData = new FormData()
214
-          formData.append('billId', this.ruleForm.billId)
215
+          formData.append('billId', this.listQuery.billId)
215
           formData.append('billExplain', this.ruleForm.billExplain)
216
           formData.append('billExplain', this.ruleForm.billExplain)
216
           formData.append('billName', this.ruleForm.billName)
217
           formData.append('billName', this.ruleForm.billName)
217
           formData.append('endDate', this.ruleForm.endDate)
218
           formData.append('endDate', this.ruleForm.endDate)

+ 4
- 10
VUECODE/smart-property-manage/src/views/bill/info/add/index.vue View File

31
             :value="item.roomNo"/>
31
             :value="item.roomNo"/>
32
         </el-select>
32
         </el-select>
33
       </el-form-item>
33
       </el-form-item>
34
-      <el-form-item label="截止时间">
35
-        <el-date-picker
36
-          v-model="formInline.worthOf"
37
-          type="date"
38
-          placeholder="选择日期"/>
39
-      </el-form-item>
40
       <br>
34
       <br>
41
       <el-form-item label="收费单说明">
35
       <el-form-item label="收费单说明">
42
         <el-input
36
         <el-input
148
         this.$message.error('户号')
142
         this.$message.error('户号')
149
         return
143
         return
150
       }
144
       }
151
-      if (this.formInline.worthOf === '') {
152
-        this.$message.error('催缴日期')
153
-        return
154
-      }
145
+      // if (this.formInline.worthOf === '') {
146
+      //   this.$message.error('催缴日期')
147
+      //   return
148
+      // }
155
       if (this.formInline.billInvoiceExplain === '') {
149
       if (this.formInline.billInvoiceExplain === '') {
156
         this.$message.error('收费单说明')
150
         this.$message.error('收费单说明')
157
         return
151
         return

+ 14
- 1
VUECODE/smart-property-manage/src/views/bill/info/index.vue View File

433
       })
433
       })
434
     },
434
     },
435
     addBillInvoice() {
435
     addBillInvoice() {
436
-      this.$router.push({ name: 'bill-info-add', params: { id: this.formInline.billId }})
436
+      // 如果是 收费已完成 的收费项, 则不允许跳进添加页面
437
+      this.$store.dispatch('GetBillByIdInfo', this.formInline.billId).then(res => {
438
+        const resCode = res.code
439
+        if (resCode === '0') {
440
+          const billStatus = res.data.billStatus
441
+          if (billStatus === '1') {
442
+            this.$message.error('不能给收费已完成的收费组添加收费单!')
443
+            return
444
+          }
445
+          this.$router.push({ name: 'bill-info-add', params: { id: this.formInline.billId }})
446
+        }
447
+      }).catch(() => {
448
+        console.log('GetBillByIdInfo error')
449
+      })
437
     },
450
     },
438
     showPayPrice(payPrice) { //  转换金额
451
     showPayPrice(payPrice) { //  转换金额
439
       const price = payPrice / 100
452
       const price = payPrice / 100