Browse Source

base64 转码

weiximei 6 years ago
parent
commit
ee2631190f

+ 2
- 1
CODE/smart-community/community-common/src/main/java/com/community/commom/utils/PayPriceUtils.java View File

@@ -21,7 +21,8 @@ public class PayPriceUtils {
21 21
      */
22 22
     public static Integer yuanConversionPoints(Double price) {
23 23
         Double d = price * 100;
24
-        return  Integer.parseInt(d + "");
24
+        String strD = d+"";
25
+        return  Integer.parseInt(strD.substring(0, strD.lastIndexOf(".")));
25 26
     }
26 27
 
27 28
 }

+ 8
- 2
CODE/smart-community/property-api/pom.xml View File

@@ -152,8 +152,14 @@
152 152
 			<artifactId>okhttp</artifactId>
153 153
 			<version>3.11.0</version>
154 154
 		</dependency>
155
-
156
-	</dependencies>
155
+        <dependency>
156
+            <groupId>org.springframework</groupId>
157
+            <artifactId>spring-test</artifactId>
158
+            <version>5.1.3.RELEASE</version>
159
+            <scope>compile</scope>
160
+        </dependency>
161
+
162
+    </dependencies>
157 163
 
158 164
 	<dependencyManagement>
159 165
 		<dependencies>

+ 3
- 2
CODE/smart-community/property-api/src/main/java/com/community/huiju/controller/BillInvoiceController.java View File

@@ -4,6 +4,7 @@ package com.community.huiju.controller;
4 4
 import com.alibaba.fastjson.JSONObject;
5 5
 import com.community.commom.mode.ResponseBean;
6 6
 import com.community.commom.session.UserElement;
7
+import com.community.commom.utils.PayPriceUtils;
7 8
 import com.community.huiju.common.base.BaseController;
8 9
 import com.community.huiju.service.IBillInvoiceService;
9 10
 import com.community.huiju.service.IBillService;
@@ -162,8 +163,8 @@ public class BillInvoiceController extends BaseController {
162 163
     public ResponseBean updateBillInvoiceIdPayPrice(HttpSession session,@PathVariable Integer billId, @RequestBody String parameter) {
163 164
         ResponseBean responseBean = new ResponseBean();
164 165
         UserElement userElement = getUserElement(session);
165
-        Integer payPrice = JSONObject.parseObject(parameter).getInteger("payPrice");
166
-        responseBean = iBillInvoiceService.updateBillInvoiceIdPayPrice(billId, payPrice , userElement);
166
+        Double payPrice = JSONObject.parseObject(parameter).getDouble("payPrice");
167
+        responseBean = iBillInvoiceService.updateBillInvoiceIdPayPrice(billId, PayPriceUtils.yuanConversionPoints(payPrice) , userElement);
167 168
         return responseBean;
168 169
     }
169 170
 

+ 27
- 0
CODE/smart-community/property-api/src/main/java/com/community/huiju/controller/ImageController.java View File

@@ -6,13 +6,19 @@ import com.community.huiju.service.ImageServiceI;
6 6
 import io.swagger.annotations.Api;
7 7
 import io.swagger.annotations.ApiOperation;
8 8
 import io.swagger.annotations.ApiParam;
9
+import org.apache.tomcat.util.http.fileupload.FileItem;
10
+import org.apache.tomcat.util.http.fileupload.disk.DiskFileItem;
9 11
 import org.springframework.beans.factory.annotation.Autowired;
10 12
 import org.springframework.cloud.context.config.annotation.RefreshScope;
13
+import org.springframework.mock.web.MockMultipartFile;
11 14
 import org.springframework.web.bind.annotation.PostMapping;
12 15
 import org.springframework.web.bind.annotation.RequestMapping;
13 16
 import org.springframework.web.bind.annotation.RestController;
14 17
 import org.springframework.web.multipart.MultipartFile;
18
+import org.springframework.web.multipart.commons.CommonsMultipartFile;
19
+import sun.misc.BASE64Decoder;
15 20
 
21
+import java.io.ByteArrayInputStream;
16 22
 import java.util.ArrayList;
17 23
 import java.util.List;
18 24
 
@@ -43,4 +49,25 @@ public class ImageController extends BaseController {
43 49
         responseBean.addSuccess(urls);
44 50
         return responseBean;
45 51
     }
52
+
53
+    @ApiOperation(value = "图片上传以及获取url", notes = "图片上传以及获取url")
54
+    @PostMapping(value = "/uploadimageBase64", consumes = "multipart/*", headers = "content-type=multipart/form-data")
55
+    public ResponseBean uploadImgBase64AndGetUrl(@ApiParam(value = "uploadFiles" ,required = true) String[] uploadFiles) throws Exception {
56
+        ResponseBean responseBean = new ResponseBean();
57
+        List<String> urls = new ArrayList<String>();
58
+//        for (MultipartFile uploadFile : uploadFiles){
59
+//            String url = imageService.getImageUrl(uploadFile);
60
+//            urls.add(url);
61
+//        }
62
+        for (String base64Url : uploadFiles) {
63
+            BASE64Decoder base64Decoder = new BASE64Decoder();
64
+            byte[] bytes = base64Decoder.decodeBuffer(base64Url);
65
+            ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(bytes);
66
+            MultipartFile multipartFil = new MockMultipartFile(String.valueOf(System.currentTimeMillis()), byteArrayInputStream);
67
+            String url = imageService.getImageUrl(multipartFil);
68
+            urls.add(url);
69
+        }
70
+        responseBean.addSuccess(urls);
71
+        return responseBean;
72
+    }
46 73
 }

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

@@ -10,10 +10,7 @@ import com.community.commom.session.UserElement;
10 10
 import com.community.commom.utils.PayPriceUtils;
11 11
 import com.community.huiju.dao.*;
12 12
 import com.community.huiju.exception.WisdomException;
13
-import com.community.huiju.model.Bill;
14
-import com.community.huiju.model.BillInvoice;
15
-import com.community.huiju.model.TaUser;
16
-import com.community.huiju.model.TpBuildingOwnerInfo;
13
+import com.community.huiju.model.*;
17 14
 import com.community.huiju.service.IBillInvoiceService;
18 15
 import com.google.common.collect.Maps;
19 16
 import org.apache.poi.hssf.usermodel.*;
@@ -153,7 +150,36 @@ public class BillInvoiceServiceImpl extends ServiceImpl<BillInvoiceMapper, BillI
153 150
             }
154 151
 
155 152
             billInvoice.setBillStatus("2");
156
-            billInvoiceMapper.updateById(billInvoice);
153
+            int rows = billInvoiceMapper.updateById(billInvoice);
154
+            if (rows > 0) {
155
+                TpBuildingOwnerInfo buildingOwnerInfo = tpBuildingOwnerInfoMapper.selectById(billInvoice.getBuildingOwnerInfoId());
156
+
157
+                // 插入流水
158
+                BillStatement billStatement = new BillStatement();
159
+                billStatement.setCommunityId(userElement.getCommunityId());
160
+                billStatement.setBillInvoiceId(billInvoice.getId());
161
+                billStatement.setTaUserId(billInvoice.getTaUserId());
162
+                billStatement.setPayPrice(billInvoice.getPayPrice());
163
+                billStatement.setPayName(buildingOwnerInfo.getOwnerName());
164
+                billStatement.setPayRemark(billInvoice.getBillInvoiceExplain());
165
+                billStatement.setPayType("1");
166
+                billStatement.setCreateTime(new Date());
167
+                billStatementMapper.insert(billStatement);
168
+
169
+                // 更新缴费单信息
170
+                billInvoice.setBillStatementId(billStatement.getId());
171
+                billInvoice.setPayName(billStatement.getPayName());
172
+                billInvoice.setPayDate(new Date());
173
+                billInvoice.setOutTradeNo(String.valueOf(System.currentTimeMillis()) + billInvoice.getId());
174
+                billInvoiceMapper.updateById(billInvoice);
175
+
176
+                // 修改缴费户数
177
+                Bill bill = billMapper.selectById(billInvoice.getBillId());
178
+                bill.setPayedNum(bill.getPayedNum() + 1);
179
+                bill.setUnpayedNum(bill.getUnpayedNum() - 1);
180
+                billMapper.updateById(bill);
181
+
182
+            }
157 183
         });
158 184
 
159 185
         responseBean.addSuccess("操作成功");
@@ -181,7 +207,7 @@ public class BillInvoiceServiceImpl extends ServiceImpl<BillInvoiceMapper, BillI
181 207
         // 收费单说明
182 208
         String billInvoiceExplain = jsonObject.getString("billInvoiceExplain");
183 209
         // 收费金额
184
-        Integer payPrice = jsonObject.getInteger("payPrice");
210
+        Double payPrice = jsonObject.getDouble("payPrice");
185 211
 
186 212
         // 楼栋资料库
187 213
         QueryWrapper<TpBuildingOwnerInfo> queryWrapper = new QueryWrapper<>();
@@ -198,6 +224,11 @@ public class BillInvoiceServiceImpl extends ServiceImpl<BillInvoiceMapper, BillI
198 224
         userQueryWrapper.eq("login_name", buildingOwnerInfo.getOwnerTel());
199 225
         TaUser taUser = taUserMapper.selectOne(userQueryWrapper);
200 226
 
227
+        if (null == taUser) {
228
+            responseBean.addError("该业主未绑定app, 无法操作!");
229
+            return responseBean;
230
+        }
231
+
201 232
 
202 233
         BillInvoice billInvoice = new BillInvoice();
203 234
         billInvoice.setBillId(billId);
@@ -210,6 +241,7 @@ public class BillInvoiceServiceImpl extends ServiceImpl<BillInvoiceMapper, BillI
210 241
         billInvoice.setCreateUser(userElement.getId());
211 242
         billInvoice.setCreateDate(new Date());
212 243
         billInvoice.setStatus(0);
244
+        billInvoice.setOutTradeNo("");
213 245
 
214 246
         int result = billInvoiceMapper.insert(billInvoice);
215 247
         billInvoice.setOutTradeNo(String.valueOf(System.currentTimeMillis()) + billInvoice.getId());
@@ -236,6 +268,12 @@ public class BillInvoiceServiceImpl extends ServiceImpl<BillInvoiceMapper, BillI
236 268
         }).collect(Collectors.toList());
237 269
 
238 270
         boolean b = this.updateBatchById(billInvoices);
271
+        // 修改为有效时, 修改应缴费户数
272
+        Bill bill = billMapper.selectById(billInvoices.get(0).getBillId());
273
+        bill.setPayTotalNum(bill.getPayTotalNum() + billInvoices.size());
274
+        bill.setUnpayedNum(bill.getUnpayedNum() + billInvoices.size());
275
+        billMapper.updateById(bill);
276
+
239 277
         if (b == false) {
240 278
             throw new WisdomException("操作失败");
241 279
         }
@@ -287,7 +325,8 @@ public class BillInvoiceServiceImpl extends ServiceImpl<BillInvoiceMapper, BillI
287 325
             responseBean.addError("不能修改已缴费");
288 326
             return responseBean;
289 327
         }
290
-        billInvoice.setPayPrice(PayPriceUtils.yuanConversionPoints(payPrice));
328
+        // 此处存储的是已经转换过的金额
329
+        billInvoice.setPayPrice(payPrice);
291 330
         billInvoice.setUpdateUser(userElement.getId());
292 331
         billInvoice.setUpdateDate(new Date());
293 332
 

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

@@ -182,6 +182,8 @@ public class BillServiceImpl extends ServiceImpl<BillMapper, Bill> implements IB
182 182
         bill.setCreateUser(userElement.getId());
183 183
         bill.setCreateDate(new Date());
184 184
         bill.setCommunityId(userElement.getCommunityId());
185
+        bill.setPayTotalNum(tempBills.size());
186
+        bill.setUnpayedNum(tempBills.size());
185 187
 
186 188
         int rows = billMapper.insert(bill);
187 189
         if (rows > 0) {
@@ -200,6 +202,7 @@ public class BillServiceImpl extends ServiceImpl<BillMapper, Bill> implements IB
200 202
                 queryWrapper.eq("community_id", userElement.getCommunityId());
201 203
                 TpBuildingOwnerInfo buildingOwnerInfo = tpBuildingOwnerInfoMapper.selectOne(queryWrapper);
202 204
 
205
+                // TODO 如果用户不在 app 里面,没有关联, 怎么处理?
203 206
                 // 查询app用户id
204 207
                 QueryWrapper<TaUser> userQueryWrapper = new QueryWrapper<>();
205 208
                 userQueryWrapper.eq("community_id", userElement.getCommunityId());

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

@@ -23,7 +23,7 @@
23 23
             :data="ruleForm"
24 24
             name="file"
25 25
             class="upload-demo"
26
-            action="http://localhost:8086/property-api/bill/uploadExcel/get"
26
+            action="http://106.14.20.193:8086/property-api/bill/uploadExcel/get"
27 27
             multiple>
28 28
             <el-button slot="trigger" size="large" type="primary">选取文件并预览</el-button>
29 29
           </el-upload>

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

@@ -23,7 +23,7 @@
23 23
             :data="ruleForm"
24 24
             name="file"
25 25
             class="upload-demo"
26
-            action="http://localhost:8086/property-api/bill/uploadExcel/get"
26
+            action="http://106.14.20.193:8086/property-api/bill/uploadExcel/get"
27 27
             multiple>
28 28
             <el-button slot="trigger" size="large" type="primary">选取文件并预览</el-button>
29 29
           </el-upload>
@@ -68,7 +68,11 @@
68 68
         layout="total, sizes, prev, pager, next, jumper"
69 69
         @size-change="handleSizeChange"
70 70
         @current-change="handleCurrentChange"/>
71
-      <el-form-item style="margin-top: 20px;">
71
+      <el-form-item v-if="isUpload" style="margin-top: 20px;">
72
+        <el-button @click="submitFormAdd('ruleForm', 2)">保存草稿</el-button>
73
+        <el-button type="primary" @click="submitFormAdd('ruleForm', 0)">发送账单</el-button>
74
+      </el-form-item>
75
+      <el-form-item v-else style="margin-top: 20px;">
72 76
         <el-button @click="submitForm('ruleForm', 2)">保存草稿</el-button>
73 77
         <el-button type="primary" @click="submitForm('ruleForm', 0)">发送账单</el-button>
74 78
       </el-form-item>
@@ -119,7 +123,8 @@ export default {
119 123
       total: 0,
120 124
       list: [], // 数据
121 125
       tempList: [], // 临时数据
122
-      files: '' // 文件
126
+      files: '', // 文件
127
+      isUpload: false // 是否上传
123 128
     }
124 129
   },
125 130
   created() {
@@ -170,6 +175,7 @@ export default {
170 175
       this.tempList = response.data.list
171 176
       this.total = response.data.total
172 177
       this.list = this.getList()
178
+      this.isUpload = true
173 179
       console.log(response)
174 180
     },
175 181
     handleExceed(files, fileList) {
@@ -198,6 +204,35 @@ export default {
198 204
         }
199 205
       })
200 206
     },
207
+    submitFormAdd(formName, status) { // 提交添加
208
+      this.$refs[formName].validate((valid) => {
209
+        if (valid) {
210
+          this.ruleForm.billStatus = status
211
+          // const data = this.ruleForm
212
+          // data.files = this.files
213
+          const formData = new FormData()
214
+          formData.append('billExplain', this.ruleForm.billExplain)
215
+          formData.append('billName', this.ruleForm.billName)
216
+          formData.append('endDate', this.ruleForm.endDate)
217
+          formData.append('billStatus', this.ruleForm.billStatus)
218
+          formData.append('file', this.files)
219
+          this.$store.dispatch('bill/BillUploadExcelAdd', formData).then(res => {
220
+            const resCode = res.code
221
+            if (resCode === '0') {
222
+              this.$message.success(res.message)
223
+              this.$router.push({ name: 'bill-index' })
224
+              return
225
+            }
226
+            this.$message.error(res.message)
227
+          }).catch(() => {
228
+            console.log('BillUploadExcelAdd error')
229
+          })
230
+        } else {
231
+          console.log('error submit!!')
232
+          return false
233
+        }
234
+      })
235
+    },
201 236
     billInvoiceGetInvoiceInvalid() { // 保存
202 237
       this.$store.dispatch('BillInvoiceGetInvoiceInvalid', this.listQuery).then(res => {
203 238
         const resData = res.data

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

@@ -128,6 +128,38 @@ export default {
128 128
   },
129 129
   methods: {
130 130
     onSubmit() {
131
+      if (this.formInline.phase === '') {
132
+        this.$message.error('期/区')
133
+        return
134
+      }
135
+      if (this.formInline.building === '') {
136
+        this.$message.error('栋')
137
+        return
138
+      }
139
+      // if (this.formInline.building === '') {
140
+      //   this.$message.error('单元')
141
+      //   return
142
+      // }
143
+      if (this.formInline.unit === '') {
144
+        this.$message.error('楼层')
145
+        return
146
+      }
147
+      if (this.formInline.roomNo === '') {
148
+        this.$message.error('户号')
149
+        return
150
+      }
151
+      if (this.formInline.worthOf === '') {
152
+        this.$message.error('催缴日期')
153
+        return
154
+      }
155
+      if (this.formInline.billInvoiceExplain === '') {
156
+        this.$message.error('收费单说明')
157
+        return
158
+      }
159
+      if (this.formInline.payPrice === '') {
160
+        this.$message.error('收费金额')
161
+        return
162
+      }
131 163
       this.$store.dispatch('AddTempBillInvoice', this.formInline).then(res => {
132 164
         const resCode = res.code
133 165
         if (resCode === '0') {

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

@@ -112,7 +112,7 @@
112 112
         </template>
113 113
       </el-table-column>
114 114
       <el-table-column
115
-        prop="billStatement"
115
+        prop="billStatementId"
116 116
         label="流水"
117 117
         align="center"/>
118 118
       <el-table-column
@@ -314,6 +314,9 @@ export default {
314 314
       }
315 315
     },
316 316
     formatDate(val) {
317
+      if (val === null) {
318
+        return ''
319
+      }
317 320
       var value = new Date(val)
318 321
       var year = value.getFullYear()
319 322
       var month = value.getMonth() + 1
@@ -366,6 +369,9 @@ export default {
366 369
         case '2':
367 370
           str = '已线下缴费'
368 371
           break
372
+        case '3':
373
+          str = '正在支付中'
374
+          break
369 375
       }
370 376
       return str
371 377
     },
@@ -384,11 +390,11 @@ export default {
384 390
     },
385 391
     ediPayPrice(obj) { // 修改金额
386 392
       const payPrice = obj.payPrice
387
-      this.$prompt('请输入金额(不含角、分)', '提示', {
393
+      this.$prompt('请输入金额', '提示', {
388 394
         confirmButtonText: '确定',
389 395
         cancelButtonText: '取消',
390 396
         inputPlaceholder: payPrice / 100,
391
-        inputPattern: /^\d+$/, // /^\d+\.?\d{0,2}$/
397
+        inputPattern: /^\d+\.?\d{0,2}$/, // /^\d+\.?\d{0,2}$/ 保留两位小数, /^\d+$/ 不保留小数
392 398
         inputErrorMessage: '请输入有效的金额'
393 399
       }).then(({ value }) => {
394 400
         // this.$message({