魏熙美 il y a 6 ans
Parent
révision
aa24837c26

+ 49
- 0
CODE/smart-community/app-api/src/main/java/com/community/huiju/config/BillQuartz.java Voir le fichier

@@ -0,0 +1,49 @@
1
+package com.community.huiju.config;
2
+
3
+import com.community.huiju.dao.TpBillInvoiceMapper;
4
+import com.community.huiju.dao.TpBillOrderMapper;
5
+import com.community.huiju.model.TpBillInvoice;
6
+import com.community.huiju.model.TpBillOrder;
7
+import lombok.extern.slf4j.Slf4j;
8
+import org.springframework.beans.factory.annotation.Autowired;
9
+import org.springframework.scheduling.annotation.Scheduled;
10
+import org.springframework.stereotype.Component;
11
+
12
+import java.util.List;
13
+
14
+/**
15
+ * 定时器
16
+ * @author weiximei
17
+ */
18
+@Component
19
+@Slf4j
20
+public class BillQuartz {
21
+
22
+    @Autowired
23
+    private TpBillOrderMapper tpBillOrderMapper;
24
+
25
+    @Autowired
26
+    private TpBillInvoiceMapper tpBillInvoiceMapper;
27
+
28
+    @Scheduled(cron = "0 0/10 * * * ?")
29
+    public void billInvoice() {
30
+        log.info("定时任务,扫描订单,超过 10 分未付款则,关闭订单!");
31
+        List<TpBillOrder> billOrderList = tpBillOrderMapper.selectCloseOrder();
32
+        if (!billOrderList.isEmpty()) {
33
+            // 把缴费单变为未交费
34
+            billOrderList.forEach(e->{
35
+                TpBillInvoice tpBillInvoice = tpBillInvoiceMapper.selectByPrimaryKey(e.getTpBillInvoiceId());
36
+                tpBillInvoice.setBillStatus("0");
37
+                tpBillInvoiceMapper.updateByPrimaryKeySelective(tpBillInvoice);
38
+            });
39
+
40
+            // 关闭订单
41
+            billOrderList.forEach(e -> {
42
+                e.setOrderStatus("3");
43
+                tpBillOrderMapper.updateByPrimaryKeySelective(e);
44
+            });
45
+
46
+        }
47
+    }
48
+
49
+}

+ 17
- 0
CODE/smart-community/app-api/src/main/java/com/community/huiju/dao/TpBillInvoiceMapper.java Voir le fichier

@@ -3,6 +3,8 @@ package com.community.huiju.dao;
3 3
 import com.community.huiju.model.TpBillInvoice;
4 4
 import org.apache.ibatis.annotations.Mapper;
5 5
 import org.apache.ibatis.annotations.Param;
6
+import org.apache.ibatis.annotations.ResultMap;
7
+import org.apache.ibatis.annotations.Select;
6 8
 
7 9
 import java.util.List;
8 10
 import java.util.Map;
@@ -51,4 +53,19 @@ public interface TpBillInvoiceMapper {
51 53
     List<TpBillInvoice> selectByBuildingOwnerInfoId(@Param("buildingOwnerInfoId") Integer buildingOwnerInfoId);
52 54
 
53 55
     int updateBeach(Map<String, Object> map);
56
+
57
+    /**
58
+     * 根据 id 查询缴费单
59
+     * @param billId
60
+     * @return
61
+     */
62
+    @ResultMap("BaseResultMap")
63
+    @Select("select " +
64
+            "t.* ," +
65
+            "b.bill_name as billName " +
66
+            "from " +
67
+            "tp_bill_invoice t " +
68
+            "LEFT JOIN tp_bill b ON t.bill_id = b.id " +
69
+            "where t.id = #{billId}")
70
+    TpBillInvoice selectByIdBillInvoiceInfo(Integer billId);
54 71
 }

+ 18
- 1
CODE/smart-community/app-api/src/main/java/com/community/huiju/dao/TpBillOrderMapper.java Voir le fichier

@@ -43,7 +43,7 @@ public interface TpBillOrderMapper {
43 43
      */
44 44
     @ResultMap("BaseResultMap")
45 45
     @Select("SELECT tbo.* FROM tp_bill_order tbo LEFT JOIN tp_bill_invoice tbi on tbo.tp_bill_invoice_id = tbi.id " +
46
-            "WHERE tbi.room_no_id = #{roomNoId} GROUP BY tbo.order_bumber")
46
+            "WHERE tbi.room_no_id = #{roomNoId} and tbo.order_status = 1 GROUP BY tbo.order_bumber")
47 47
     List<TpBillOrder> selectByRoomNoId(@Param("roomNoId") Integer roomNoId);
48 48
 
49 49
     /**
@@ -55,4 +55,21 @@ public interface TpBillOrderMapper {
55 55
     @Select("SELECT * FROM tp_bill_order WHERE order_bumber = #{orderBumber} GROUP BY tp_bill_id")
56 56
     List<TpBillOrder> selectByOrderNumberBill(@Param("orderBumber") String orderBumber);
57 57
 
58
+    /**
59
+     * 可关闭的订单
60
+     * @return
61
+     */
62
+    @ResultMap("BaseResultMap")
63
+    @Select("SELECT t.* from tp_bill_order t where TIMESTAMPDIFF(MINUTE,create_date,now()) >= 10 and t.order_status in (0,2)")
64
+    List<TpBillOrder> selectCloseOrder();
65
+
66
+    /**
67
+     * 根据收费组id 和 订单号 查询出这个订单号内该收费组所有的数据
68
+     * @param tpBillId
69
+     * @param orderNumber
70
+     * @return
71
+     */
72
+    @ResultMap("BaseResultMap")
73
+    @Select("SELECT * FROM tp_bill_order WHERE order_bumber = #{orderNumber} and tp_bill_id = #{tpBillId}")
74
+    List<TpBillOrder> selectByBillIdAndOrderNumber(@Param("tpBillId") Integer tpBillId, @Param("orderNumber") String orderNumber);
58 75
 }

+ 15
- 0
CODE/smart-community/app-api/src/main/java/com/community/huiju/model/TpBillInvoice.java Voir le fichier

@@ -42,6 +42,13 @@ public class TpBillInvoice {
42 42
      */
43 43
     private String payType;
44 44
 
45
+    // =================================
46
+
47
+    /**
48
+     * 转换后金额,用于支付
49
+     */
50
+    private Double sumPayPrice;
51
+
45 52
     public Integer getId() {
46 53
         return id;
47 54
     }
@@ -185,4 +192,12 @@ public class TpBillInvoice {
185 192
     public void setPayType(String payType) {
186 193
         this.payType = payType;
187 194
     }
195
+
196
+    public Double getSumPayPrice() {
197
+        return sumPayPrice;
198
+    }
199
+
200
+    public void setSumPayPrice(Double sumPayPrice) {
201
+        this.sumPayPrice = sumPayPrice;
202
+    }
188 203
 }

+ 7
- 7
CODE/smart-community/app-api/src/main/java/com/community/huiju/model/TpBillOrder.java Voir le fichier

@@ -35,12 +35,12 @@ public class TpBillOrder {
35 35
     /**
36 36
      * 订单总额
37 37
      */
38
-    private Long sumPrice;
38
+    private Double sumPrice;
39 39
 
40 40
     /**
41
-     * 缴费集合
41
+     * 缴费集合
42 42
      */
43
-    private List<TpBill> billList;
43
+    private List<TpBillInvoice> billList;
44 44
 
45 45
     public Integer getId() {
46 46
         return id;
@@ -130,19 +130,19 @@ public class TpBillOrder {
130 130
         this.payPhone = payPhone;
131 131
     }
132 132
 
133
-    public Long getSumPrice() {
133
+    public Double getSumPrice() {
134 134
         return sumPrice;
135 135
     }
136 136
 
137
-    public void setSumPrice(Long sumPrice) {
137
+    public void setSumPrice(Double sumPrice) {
138 138
         this.sumPrice = sumPrice;
139 139
     }
140 140
 
141
-    public List<TpBill> getBillList() {
141
+    public List<TpBillInvoice> getBillList() {
142 142
         return billList;
143 143
     }
144 144
 
145
-    public void setBillList(List<TpBill> billList) {
145
+    public void setBillList(List<TpBillInvoice> billList) {
146 146
         this.billList = billList;
147 147
     }
148 148
 }

+ 17
- 8
CODE/smart-community/app-api/src/main/java/com/community/huiju/service/impl/BillServiceImpl.java Voir le fichier

@@ -7,6 +7,7 @@ import com.community.huiju.model.*;
7 7
 import com.community.huiju.service.BillServiceI;
8 8
 import com.github.pagehelper.Page;
9 9
 import com.github.pagehelper.PageHelper;
10
+import com.google.common.collect.Lists;
10 11
 import com.google.common.collect.Maps;
11 12
 import org.apache.commons.collections.CollectionUtils;
12 13
 import org.springframework.beans.factory.annotation.Autowired;
@@ -14,6 +15,7 @@ import org.springframework.stereotype.Service;
14 15
 
15 16
 import java.util.List;
16 17
 import java.util.Map;
18
+import java.util.concurrent.atomic.AtomicReference;
17 19
 import java.util.stream.Collectors;
18 20
 
19 21
 /**
@@ -102,12 +104,17 @@ public class BillServiceImpl implements BillServiceI {
102 104
 		// 所有订单
103 105
 		List<TpBillOrder> billOrderList = tpBillOrderMapper.selectByRoomNoId(userElement.getRoomNoId());
104 106
 		billOrderList.forEach(e->{
107
+			// 这个订单的所有缴费信息
108
+			List<TpBillOrder> orderList = tpBillOrderMapper.selectByOrderBumber(e.getOrderBumber());
109
+
105 110
 			// 缴费组
106
-			List<TpBill> billsCollect = billOrderList.stream().map(billOrder -> tpBillMapper.selectByPrimaryKey(billOrder.getTpBillId())).collect(Collectors.toList());
111
+			List<TpBillInvoice> tpBillInvoices = orderList.stream().map(billOrder -> tpBillInvoiceMapper.selectByIdBillInvoiceInfo(billOrder.getTpBillInvoiceId())).collect(Collectors.toList());
112
+			tpBillInvoices.forEach( billInvoice -> billInvoice.setSumPayPrice(Double.parseDouble(billInvoice.getPayPrice() + "") / 100));
113
+
107 114
 			// 所有缴费组的总额
108
-			Long billCountPrice = billsCollect.stream().map(billCount -> Integer.parseInt(billCount.getPayPrice())).count();
115
+			Double billCountPrice = Double.parseDouble(tpBillInvoices.stream().map(billCount -> billCount.getPayPrice()).count() + "") / 100;
109 116
 
110
-			e.setBillList(billsCollect);
117
+			e.setBillList(tpBillInvoices);
111 118
 			e.setSumPrice(billCountPrice);
112 119
 		});
113 120
 
@@ -132,10 +139,12 @@ public class BillServiceImpl implements BillServiceI {
132 139
 			responseBean.addError("订单号不存在!");
133 140
 			return responseBean;
134 141
 		}
135
-		// 每个缴费组数据
136
-		List<TpBill> tpBillList = billOrderList.stream().map(e -> tpBillMapper.selectByPrimaryKey(e.getTpBillId())).collect(Collectors.toList());
137
-		// 所有缴费组的总额
138
-		Long billCountPrice = tpBillList.stream().map(billCount -> Integer.parseInt(billCount.getPayPrice())).count();
142
+		// 每个缴费单数据
143
+		List<TpBillInvoice> tpBillInvoices = billOrderList.stream().map(e -> tpBillInvoiceMapper.selectByIdBillInvoiceInfo(e.getTpBillInvoiceId())).collect(Collectors.toList());
144
+		tpBillInvoices.forEach(e -> e.setSumPayPrice(Double.parseDouble(e.getPayPrice() + "") / 100));
145
+
146
+		// 这个订单总额
147
+		Double billCountPrice = Double.parseDouble(tpBillInvoices.stream().map(e -> e.getPayPrice()).count() + "") / 100;
139 148
 
140 149
 		// 因为订单号是多条,取第一条即可
141 150
 		TpBillOrder tpBillOrder = billOrderList.get(0);
@@ -152,7 +161,7 @@ public class BillServiceImpl implements BillServiceI {
152 161
 		map.put("updateDate", tpBillOrder.getUpdateDate());
153 162
 		map.put("payType", tpBillStatement.getPayType());
154 163
 		map.put("payRemark", tpBillStatement.getPayRemark());
155
-		map.put("list", tpBillList);
164
+		map.put("list", tpBillInvoices);
156 165
 
157 166
 		responseBean.addSuccess(map);
158 167
 		return responseBean;

+ 13
- 26
CODE/smart-community/app-api/src/main/java/com/community/huiju/service/impl/WxPayServiceImpl.java Voir le fichier

@@ -6,6 +6,7 @@ import com.community.huiju.common.wxpay.WXPay;
6 6
 import com.community.huiju.common.wxpay.WXPayConstants;
7 7
 import com.community.huiju.common.wxpay.WXPayUtil;
8 8
 import com.community.huiju.dao.*;
9
+import com.community.huiju.exception.WisdomException;
9 10
 import com.community.huiju.model.*;
10 11
 import com.community.huiju.service.WxPayServiceI;
11 12
 import com.google.common.collect.Lists;
@@ -76,6 +77,12 @@ public class WxPayServiceImpl implements WxPayServiceI {
76 77
 		if (CollectionUtils.isEmpty(billOrderList)){
77 78
 			throw new Exception("订单不存在");
78 79
 		}
80
+		// 检测订单是否 已关闭
81
+		billOrderList.forEach(e-> {
82
+			if ("3".equals(e.getOrderStatus())) {
83
+				throw new WisdomException("无法支付已关闭的订单!");
84
+			}
85
+		});
79 86
 
80 87
 		// 计算金额
81 88
 		Integer payPrice = billOrderList.stream().mapToInt(e -> tpBillInvoiceMapper.selectByPrimaryKey(e.getTpBillInvoiceId()).getPayPrice()).sum();
@@ -225,8 +232,6 @@ public class WxPayServiceImpl implements WxPayServiceI {
225 232
 		// 如果是家属/租客, 应该用业主的用户id
226 233
 		TaUser taUser = taUserMapper.selectByPrimaryKey(userElement.getId());
227 234
 
228
-		List<TpBillOrder> billOrderList = Lists.newArrayList();
229
-
230 235
 		Random random = new Random();
231 236
 		String orderNo = String.valueOf(System.currentTimeMillis()) + random.nextInt();
232 237
 
@@ -249,18 +254,14 @@ public class WxPayServiceImpl implements WxPayServiceI {
249 254
 			tpBillOrder.setUpdateUser(userElement.getId());
250 255
 			tpBillOrder.setOrderBumber(orderNo);
251 256
 			tpBillOrder.setPayPhone(taUser.getLoginName());
257
+			tpBillOrder.setOrderStatus("0");
252 258
 
253 259
 			tpBillOrderMapper.insertSelective(tpBillOrder);
254 260
 
255
-			// billOrderList.add(tpBillOrder);
256 261
 		}
257 262
 
258 263
 		// 修改缴费人
259
-		// updateBillInvoiceBillStatus(billInvoiceIdArray, user.getUserName(), "1");
260
-
261
-		// 生成缴费订单
262
-		// tpBillOrderMapper.batchInsertSelective(billOrderList);
263
-
264
+		 updateBillInvoiceBillStatus(billInvoiceIdArray, taUser.getUserName(), "3");
264 265
 		return orderNo;
265 266
 	}
266 267
 	
@@ -274,20 +275,6 @@ public class WxPayServiceImpl implements WxPayServiceI {
274 275
 	@Transactional(rollbackFor = Exception.class)
275 276
 	public void wxCancelPay(String outTradeNo, UserElement userElement) throws Exception {
276 277
 
277
-//		Integer userId = userElement.getId();
278
-//
279
-//		//获取支付金额
280
-//		TpBillInvoice tpBillInvoice = tpBillInvoiceMapper.selectByIdAndUserId(billInvoiceId,userId,userElement.getCommunityId());
281
-//		if (null == tpBillInvoice){
282
-//			throw new Exception("订单不存在");
283
-//		}else if (!tpBillInvoice.getBillStatus().equals("3")){
284
-//			throw new Exception("不是正在支付的订单");
285
-//		}
286
-//		//更新为正在支付状态
287
-//		updateBillInvoiceBillStatus(billInvoiceId,"0");
288
-
289
-
290
-
291 278
 		//获取支付金额
292 279
 		List<TpBillOrder> billOrderList = tpBillOrderMapper.selectByOrderBumber(outTradeNo);
293 280
 		if (CollectionUtils.isEmpty(billOrderList)){
@@ -306,14 +293,14 @@ public class WxPayServiceImpl implements WxPayServiceI {
306 293
 		// 缴费单id集合
307 294
 		List<Integer> billInvoiceIdList = billInvoiceList.stream().map(e -> e.getId()).collect(Collectors.toList());
308 295
 
309
-		//更新为正在支付状态
310
-		updateBillInvoiceBillStatus(billInvoiceIdList,"0");
296
+		//更新为支付状态
297
+		updateBillInvoiceBillStatus(billInvoiceIdList, "","0");
311 298
 		log.info("订单: {}, 状态变更为取消支付", outTradeNo);
312 299
 
313
-		// 更改订单状态 为支付成功
300
+		// 更改订单状态 为订单已关闭
314 301
 		List<TpBillOrder> billOrders = tpBillOrderMapper.selectByOrderBumber(outTradeNo);
315 302
 		billOrders.forEach(e-> {
316
-			e.setOrderStatus("0");
303
+			e.setOrderStatus("3");
317 304
 			tpBillOrderMapper.updateByPrimaryKeySelective(e);
318 305
 		});
319 306
 	}

+ 1
- 1
CODE/smart-community/property-api/src/main/java/com/community/huiju/controller/BillStatementController.java Voir le fichier

@@ -37,7 +37,7 @@ public class BillStatementController extends BaseController {
37 37
 
38 38
     @ApiOperation(value = "获取订单信息", notes = "获取订单信息")
39 39
     @ApiImplicitParams({
40
-            @ApiImplicitParam(dataTypeClass = String.class, paramType = "body", name = "parameter", value = "id流水编号," +
40
+            @ApiImplicitParam(dataTypeClass = String.class, paramType = "body", name = "parameter", value = "payPhone订单号," +
41 41
                     "billId缴费项编号,billName缴费项名称,billInvoiceId缴费单编号,payName缴费人"),
42 42
             @ApiImplicitParam(dataTypeClass = String.class, paramType = "header", name = "X-Auth-Token", value = "token")
43 43
     })

+ 1
- 0
CODE/smart-community/property-api/src/main/java/com/community/huiju/service/impl/BillOrderServiceImpl.java Voir le fichier

@@ -50,6 +50,7 @@ public class BillOrderServiceImpl extends ServiceImpl<TpBillOrderMapper, TpBillO
50 50
         billOrderList.forEach(e->{
51 51
             QueryWrapper<TpBillOrder> billInvoiceOrderQueryWrapper = new QueryWrapper<>();
52 52
             billInvoiceOrderQueryWrapper.eq("tp_bill_id", e.getTpBillId());
53
+            billInvoiceOrderQueryWrapper.eq("order_bumber", orderNumber);
53 54
             // 当前收费组下的所有的缴费单
54 55
             List<TpBillOrder> billInvoiceOrderList = tpBillOrderMapper.selectList(billInvoiceOrderQueryWrapper);
55 56
             List<BillInvoice> billInvoiceList = billInvoiceOrderList.stream().map(billInvoice -> {

+ 3
- 3
CODE/smart-community/property-api/src/main/java/com/community/huiju/service/impl/BillStatementServiceImpl.java Voir le fichier

@@ -51,8 +51,8 @@ public class BillStatementServiceImpl extends ServiceImpl<BillStatementMapper, B
51 51
 
52 52
         Integer pageNum = jsonObject.getInteger("pageNum");
53 53
         Integer pageSize = jsonObject.getInteger("pageSize");
54
-        // 流水 id
55
-        Integer id = jsonObject.getInteger("id");
54
+        // 订单号 orderBumber
55
+        String orderBumber = jsonObject.getString("orderBumber");
56 56
         // 缴费项 id
57 57
         Integer billId = jsonObject.getInteger("billId");
58 58
         // 缴费项 名称
@@ -64,7 +64,7 @@ public class BillStatementServiceImpl extends ServiceImpl<BillStatementMapper, B
64 64
 
65 65
         // 参数
66 66
         Map<String, Object> map = Maps.newHashMap();
67
-        map.put("id", id);
67
+        map.put("orderBumber", orderBumber);
68 68
         map.put("billId", billId);
69 69
         map.put("billName", billName);
70 70
         map.put("billInvoiceId", billInvoiceId);

+ 2
- 2
CODE/smart-community/property-api/src/main/resources/mapper/BillOrderMapper.xml Voir le fichier

@@ -12,8 +12,8 @@
12 12
         LEFT JOIN tp_bill tb on tbo.tp_bill_id = tb.id
13 13
         <where>
14 14
             <trim prefixOverrides="and | or">
15
-                <if test="map.id != null">
16
-                    and tbo.id like CONCAT('%',#{map.id},'%')
15
+                <if test="map.orderBumber != null">
16
+                    and tbo.order_bumber like CONCAT('%',#{map.orderBumber},'%')
17 17
                 </if>
18 18
                 <if test="map.billId != null">
19 19
                     and tbo.tp_bill_id like CONCAT('%',#{map.billId},'%')

+ 2
- 2
VUECODE/smart-property-manage/src/api/billStatement.js Voir le fichier

@@ -6,11 +6,11 @@ export function getBillStatementAll(data) {
6 6
     url: '/bill/statement/all',
7 7
     method: 'post',
8 8
     data: {
9
-      id: data.id, // 流水 id
9
+      orderBumber: data.orderBumber, // 订单号
10 10
       billId: data.billId, // 缴费项 id
11 11
       billName: data.billName, //  缴费项 名称
12 12
       billInvoiceId: data.billInvoiceId, // 缴费单 编号
13
-      payPhone: data.payName, //  缴费人手机号
13
+      payPhone: data.payPhone, //  缴费人手机号
14 14
       pageNum: data.pageNum,
15 15
       pageSize: data.pageSize
16 16
     }

+ 24
- 3
VUECODE/smart-property-manage/src/views/bill/statement/index.vue Voir le fichier

@@ -2,7 +2,7 @@
2 2
   <div id="root">
3 3
     <el-form :model="formInline" inline class="form-inline">
4 4
       <el-form-item label="订单号">
5
-        <el-input v-model="formInline.id" placeholder="订单号"/>
5
+        <el-input v-model="formInline.orderBumber" placeholder="订单号"/>
6 6
       </el-form-item>
7 7
       <el-form-item label="缴费项目编号">
8 8
         <el-input v-model="formInline.billId" placeholder="缴费项目编号"/>
@@ -72,7 +72,9 @@
72 72
       <el-table-column
73 73
         prop="orderStatus"
74 74
         align="center"
75
-        label="订单状态"/>
75
+        label="订单状态">
76
+        <template slot-scope="scope">{{ show(scope.row.orderStatus) }}</template>
77
+      </el-table-column>
76 78
       <el-table-column
77 79
         prop="payPhone"
78 80
         align="center"
@@ -119,7 +121,7 @@ export default {
119 121
   data() {
120 122
     return {
121 123
       formInline: {
122
-        id: '', // 流水 id
124
+        orderBumber: '', // 流水 id
123 125
         billId: '', // 缴费项 id
124 126
         billName: '', //  缴费项 名称
125 127
         billInvoiceId: '', // 缴费单 编号
@@ -239,6 +241,25 @@ export default {
239 241
     },
240 242
     getOrderInfo(id) { // 跳转订单详情
241 243
       this.$router.push({ name: 'bill-statement-info-index', query: { id: id }})
244
+    },
245
+    show(orderStatus) {
246
+      let str = ''
247
+      switch (orderStatus) {
248
+        case '0':
249
+          str = '未支付'
250
+          break
251
+        case '1':
252
+          str = '已支付'
253
+          break
254
+        case '2':
255
+          str = '正在支付'
256
+          break
257
+        case '3':
258
+          str = '已关闭'
259
+          break
260
+      }
261
+
262
+      return str
242 263
     }
243 264
   }
244 265
 }