Ver código fonte

修复 收费bug

weiximei 6 anos atrás
pai
commit
a71e290a81

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

@@ -87,21 +87,22 @@ public class BillController extends BaseController {
87 87
     @PostMapping(value = "/bill/uploadExcel/add", consumes = "multipart/*", headers = "content-type=multipart/form-data")
88 88
     public ResponseBean addUploadExcel(HttpSession session,
89 89
                                        @RequestParam(value = "billId", required = false) Integer billId,
90
-                                       @RequestParam("file") MultipartFile file,
90
+                                       @RequestParam(value = "file", required = false) MultipartFile file,
91 91
                                        @RequestParam("billExplain") String billExplain,
92 92
                                        @RequestParam("billName") String billName,
93
-                                       @RequestParam("endDate") Date endDate,
93
+                                       @RequestParam("endDate") String endDate,
94 94
                                        @RequestParam("billStatus") String billStatus) {
95 95
         ResponseBean responseBean = new ResponseBean();
96 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 106
         return responseBean;
106 107
     }
107 108
 

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

@@ -179,6 +179,10 @@ public class BillInvoiceServiceImpl extends ServiceImpl<BillInvoiceMapper, BillI
179 179
                 Bill bill = billMapper.selectById(billInvoice.getBillId());
180 180
                 bill.setPayedNum(bill.getPayedNum() + 1);
181 181
                 bill.setUnpayedNum(bill.getUnpayedNum() - 1);
182
+                // 未交户数为0时, 收费组状态变更为 1 , 收费完成
183
+                if (bill.getUnpayedNum() == 0) {
184
+                    bill.setBillStatus("1");
185
+                }
182 186
                 billMapper.updateById(bill);
183 187
 
184 188
             }
@@ -211,6 +215,14 @@ public class BillInvoiceServiceImpl extends ServiceImpl<BillInvoiceMapper, BillI
211 215
         // 收费金额
212 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 227
         QueryWrapper<TpBuildingOwnerInfo> queryWrapper = new QueryWrapper<>();
216 228
         queryWrapper.eq("phase", phase);

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

@@ -2,6 +2,7 @@ package com.community.huiju.service.impl;
2 2
 
3 3
 import com.alibaba.fastjson.JSONObject;
4 4
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
5
+import com.baomidou.mybatisplus.core.metadata.IPage;
5 6
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
6 7
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
7 8
 import com.community.commom.constant.Constant;
@@ -163,11 +164,36 @@ public class BillServiceImpl extends ServiceImpl<BillMapper, Bill> implements IB
163 164
     public ResponseBean getExcelData(Integer billId, MultipartFile file, String billExplain, String billName, Date endDate, String billStatus, UserElement userElement) {
164 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 182
         responseBean = getExcelData(file, responseBean);
167 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 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 199
         Bill bill = new Bill();
@@ -178,22 +204,27 @@ public class BillServiceImpl extends ServiceImpl<BillMapper, Bill> implements IB
178 204
             strSumDouble = strSumDouble.substring(0, strSumDouble.lastIndexOf("."));
179 205
             bill.setPayPrice(strSumDouble);
180 206
         }
181
-        bill.setPayTotalNum(tempBills.size());
207
+
182 208
         bill.setPayedNum(0);
183
-        bill.setUnpayedNum(tempBills.size());
184 209
         bill.setBillStatus(billStatus);
185 210
         bill.setCreateUser(userElement.getId());
186 211
         bill.setCreateDate(new Date());
187 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 229
             bill.setId(billId);
199 230
         }
@@ -238,17 +269,20 @@ public class BillServiceImpl extends ServiceImpl<BillMapper, Bill> implements IB
238 269
             }).collect(Collectors.toList());
239 270
 
240 271
             iBillInvoiceService.saveBatch(billInvoices);
241
-            responseBean.addSuccess("操作成功!");
242
-        } else {
243
-            responseBean.addError("操作失败!");
244 272
         }
245
-
246
-
273
+        responseBean.addSuccess("操作成功!");
247 274
         return responseBean;
248 275
     }
249 276
 
250 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 287
         String originalFilename = file.getOriginalFilename();
254 288
         Workbook workbook = null;
@@ -269,9 +303,6 @@ public class BillServiceImpl extends ServiceImpl<BillMapper, Bill> implements IB
269 303
         Sheet sheetAt = workbook.getSheetAt(0);
270 304
         int lastRowNum = sheetAt.getLastRowNum();
271 305
 
272
-        // 数据
273
-        List<TempBill> tempBills = Lists.newArrayList();
274
-
275 306
         // 从第7行开始读取
276 307
         for (int i= 6; i<= lastRowNum; i++) {
277 308
             Row row = sheetAt.getRow(i);
@@ -322,7 +353,7 @@ public class BillServiceImpl extends ServiceImpl<BillMapper, Bill> implements IB
322 353
 
323 354
 
324 355
             if (StringUtils.isNotBlank(money)) {
325
-                Double moneyDouble = Double.valueOf(money) * 100;
356
+                Double moneyDouble = Double.valueOf(money); // * 100
326 357
                 money = moneyDouble + "";
327 358
                 money = money.substring(0, money.lastIndexOf("."));
328 359
                 temp.setMoney(Integer.valueOf(money));

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

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

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

@@ -11,6 +11,7 @@
11 11
         <el-date-picker
12 12
           v-model="ruleForm.endDate"
13 13
           type="date"
14
+          value-format="timestamp"
14 15
           placeholder="选择日期"/>
15 16
       </el-form-item>
16 17
       <div>
@@ -68,14 +69,14 @@
68 69
         layout="total, sizes, prev, pager, next, jumper"
69 70
         @size-change="handleSizeChange"
70 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 73
         <el-button @click="submitFormAdd('ruleForm', 2)">保存草稿</el-button>
73 74
         <el-button type="primary" @click="submitFormAdd('ruleForm', 0)">发送账单</el-button>
74 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 80
     </el-form>
80 81
   </div>
81 82
 </template>
@@ -211,7 +212,7 @@ export default {
211 212
           // const data = this.ruleForm
212 213
           // data.files = this.files
213 214
           const formData = new FormData()
214
-          formData.append('billId', this.ruleForm.billId)
215
+          formData.append('billId', this.listQuery.billId)
215 216
           formData.append('billExplain', this.ruleForm.billExplain)
216 217
           formData.append('billName', this.ruleForm.billName)
217 218
           formData.append('endDate', this.ruleForm.endDate)

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

@@ -31,12 +31,6 @@
31 31
             :value="item.roomNo"/>
32 32
         </el-select>
33 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 34
       <br>
41 35
       <el-form-item label="收费单说明">
42 36
         <el-input
@@ -148,10 +142,10 @@ export default {
148 142
         this.$message.error('户号')
149 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 149
       if (this.formInline.billInvoiceExplain === '') {
156 150
         this.$message.error('收费单说明')
157 151
         return

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

@@ -433,7 +433,20 @@ export default {
433 433
       })
434 434
     },
435 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 451
     showPayPrice(payPrice) { //  转换金额
439 452
       const price = payPrice / 100