|
@@ -2,13 +2,13 @@ package com.huiju.estateagents.property.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.huiju.estateagents.base.ResponseBean;
|
8
|
9
|
import com.huiju.estateagents.center.taUser.entity.TaUser;
|
9
|
10
|
import com.huiju.estateagents.center.taUser.mapper.TaUserMapper;
|
10
|
11
|
import com.huiju.estateagents.property.common.Constant;
|
11
|
|
-import com.huiju.estateagents.property.common.UserElement;
|
12
|
12
|
import com.huiju.estateagents.property.dao.*;
|
13
|
13
|
import com.huiju.estateagents.property.exception.WisdomException;
|
14
|
14
|
import com.huiju.estateagents.property.model.*;
|
|
@@ -20,6 +20,7 @@ import com.google.common.collect.Lists;
|
20
|
20
|
import com.google.common.collect.Maps;
|
21
|
21
|
import lombok.Data;
|
22
|
22
|
import lombok.extern.slf4j.Slf4j;
|
|
23
|
+import org.apache.commons.collections.CollectionUtils;
|
23
|
24
|
import org.apache.commons.lang3.StringUtils;
|
24
|
25
|
import org.apache.poi.hssf.usermodel.HSSFCell;
|
25
|
26
|
import org.apache.poi.hssf.usermodel.HSSFRow;
|
|
@@ -97,6 +98,12 @@ public class BillServiceImpl extends ServiceImpl<BillMapper, Bill> implements IB
|
97
|
98
|
@Autowired
|
98
|
99
|
private TpRoomNoMapper tpRoomNoMapper;
|
99
|
100
|
|
|
101
|
+ @Autowired
|
|
102
|
+ private TpBillOrderMapper tpBillOrderMapper;
|
|
103
|
+
|
|
104
|
+ @Autowired
|
|
105
|
+ private BillStatementMapper tpBillStatementMapper;
|
|
106
|
+
|
100
|
107
|
@Override
|
101
|
108
|
@Transactional(rollbackFor = Exception.class)
|
102
|
109
|
public ResponseBean updateBillNameAndBillExplainAndEndDate(TaUser userElement, String parameter) {
|
|
@@ -677,4 +684,124 @@ public class BillServiceImpl extends ServiceImpl<BillMapper, Bill> implements IB
|
677
|
684
|
}
|
678
|
685
|
}
|
679
|
686
|
|
|
687
|
+ /**
|
|
688
|
+ * 根据payType分页获取缴费或未缴费的数据
|
|
689
|
+ * @param userElement
|
|
690
|
+ * @param payType
|
|
691
|
+ * @param pageNum
|
|
692
|
+ * @param pageSize
|
|
693
|
+ * @return
|
|
694
|
+ */
|
|
695
|
+ @Override
|
|
696
|
+ public Map<String, Object> getBillsList(TaUser userElement, Integer payType, Integer pageNum, Integer pageSize) {
|
|
697
|
+
|
|
698
|
+
|
|
699
|
+ /**
|
|
700
|
+ * 账单 关联的是房产,
|
|
701
|
+ */
|
|
702
|
+
|
|
703
|
+ //使用分页插件
|
|
704
|
+ IPage<Map<String,Object>> page = new Page<>(pageNum, pageSize);
|
|
705
|
+ IPage<Map<String,Object>> billsPage = billInvoiceMapper.getBillsList(page,userElement.getOrgId(), userElement.getRoomNoId(), payType);
|
|
706
|
+ List<Map<String, Object>> billsList = billsPage.getRecords();
|
|
707
|
+ billsList.forEach(e-> {
|
|
708
|
+ String payPrice = String.valueOf(e.get("payPrice"));
|
|
709
|
+ Double payPriceDouble = Double.valueOf(payPrice) / 100;
|
|
710
|
+ e.put("payPrice", payPriceDouble);
|
|
711
|
+ });
|
|
712
|
+ Map<String,Object> result = Maps.newHashMap();
|
|
713
|
+ result.put("list",billsList);
|
|
714
|
+ result.put("total",page.getTotal());
|
|
715
|
+ return result;
|
|
716
|
+ }
|
|
717
|
+
|
|
718
|
+ /**
|
|
719
|
+ * 获取账单的详细信息
|
|
720
|
+ * @param billInvoiceId
|
|
721
|
+ * @return
|
|
722
|
+ */
|
|
723
|
+ @Override
|
|
724
|
+ public Map<String, Object> getBillInvoiceDetail(Integer orgId,Integer billInvoiceId) {
|
|
725
|
+ Map<String, Object> billInvoiceDetail = billInvoiceMapper.getBillInvoiceDetail(orgId, billInvoiceId);
|
|
726
|
+ String payPrice = String.valueOf(billInvoiceDetail.get("payPrice"));
|
|
727
|
+ Double payPriceDouble = Double.valueOf(payPrice) / 100;
|
|
728
|
+ billInvoiceDetail.put("payPrice", payPriceDouble);
|
|
729
|
+ return billInvoiceDetail;
|
|
730
|
+ }
|
|
731
|
+
|
|
732
|
+ @Override
|
|
733
|
+ public ResponseBean payHistory(TaUser userElement) {
|
|
734
|
+ ResponseBean responseBean = new ResponseBean();
|
|
735
|
+
|
|
736
|
+ //1. 查询所有订单
|
|
737
|
+ //2. 根据订单
|
|
738
|
+
|
|
739
|
+
|
|
740
|
+ // 所有订单
|
|
741
|
+ List<TpBillOrder> billOrderList = tpBillOrderMapper.selectByRoomNoId(userElement.getRoomNoId());
|
|
742
|
+ billOrderList.forEach(e->{
|
|
743
|
+ // 这个订单的所有缴费信息
|
|
744
|
+ List<TpBillOrder> orderList = tpBillOrderMapper.selectByOrderBumber(e.getOrderBumber());
|
|
745
|
+
|
|
746
|
+ // 缴费组
|
|
747
|
+ List<BillInvoice> tpBillInvoices = orderList.stream().map(billOrder -> billInvoiceMapper.selectByIdBillInvoiceInfo(billOrder.getTpBillInvoiceId())).collect(Collectors.toList());
|
|
748
|
+ tpBillInvoices.forEach( billInvoice -> billInvoice.setSumPayPrice(Double.valueOf(billInvoice.getPayPrice() + "") / 100));
|
|
749
|
+
|
|
750
|
+ // 所有缴费组的总额
|
|
751
|
+ Long billCountPrice = Long.valueOf(tpBillInvoices.stream().map(billCount -> billCount.getPayPrice()).count() + "") / 100;
|
|
752
|
+
|
|
753
|
+
|
|
754
|
+ e.setBillList(tpBillInvoices);
|
|
755
|
+ e.setSumPrice(billCountPrice);
|
|
756
|
+ });
|
|
757
|
+
|
|
758
|
+ responseBean.addSuccess(billOrderList);
|
|
759
|
+ return responseBean;
|
|
760
|
+ }
|
|
761
|
+
|
|
762
|
+ @Override
|
|
763
|
+ public ResponseBean getOrderInfo(String orderNumber) {
|
|
764
|
+ ResponseBean responseBean = new ResponseBean();
|
|
765
|
+
|
|
766
|
+ /**
|
|
767
|
+ * 1.根据订单号获取所有缴费组
|
|
768
|
+ * 2.获取其中的一条缴费订单数据, 因为订单号再库里面是多条,取第一条就可以
|
|
769
|
+ * 3.计算出所有缴费组的总额
|
|
770
|
+ * 4.获取一个缴费的流水记录, 因为 订单号对应多个缴费单,每一个缴费单对应一个缴费流水, 然后通过缴费流水可以知道缴费人,缴费类型,缴费备注等等
|
|
771
|
+ */
|
|
772
|
+
|
|
773
|
+ // 这个订单所有的缴费组记录, 拿到每一个缴费组的id
|
|
774
|
+ List<TpBillOrder> billOrderList = tpBillOrderMapper.selectByOrderNumberBill(orderNumber);
|
|
775
|
+ if (CollectionUtils.isEmpty(billOrderList)) {
|
|
776
|
+ responseBean.addError("订单号不存在!");
|
|
777
|
+ return responseBean;
|
|
778
|
+ }
|
|
779
|
+ // 每个缴费单数据
|
|
780
|
+ List<BillInvoice> tpBillInvoices = billOrderList.stream().map(e -> billInvoiceMapper.selectByIdBillInvoiceInfo(e.getTpBillInvoiceId())).collect(Collectors.toList());
|
|
781
|
+ tpBillInvoices.forEach(e -> e.setSumPayPrice(Double.valueOf(e.getPayPrice() + "") / 100));
|
|
782
|
+
|
|
783
|
+ // 这个订单总额
|
|
784
|
+ Double billCountPrice = Double.valueOf(tpBillInvoices.stream().map(e -> e.getPayPrice()).count() + "") / 100;
|
|
785
|
+
|
|
786
|
+ // 因为订单号是多条,取第一条即可
|
|
787
|
+ TpBillOrder tpBillOrder = billOrderList.get(0);
|
|
788
|
+
|
|
789
|
+ // 获取一条流水
|
|
790
|
+ BillStatement tpBillStatement = tpBillStatementMapper.selectByCommunityIdAndBillInvoiceId(tpBillOrder.getOrgId(), tpBillOrder.getTpBillInvoiceId());
|
|
791
|
+
|
|
792
|
+
|
|
793
|
+ Map<String, Object> map = Maps.newHashMap();
|
|
794
|
+ map.put("orderNumber", orderNumber);
|
|
795
|
+ map.put("createDate", tpBillOrder.getCreateDate());
|
|
796
|
+ map.put("sumPrice", billCountPrice);
|
|
797
|
+ map.put("payName", tpBillStatement.getPayName());
|
|
798
|
+ map.put("updateDate", tpBillOrder.getUpdateDate());
|
|
799
|
+ map.put("payType", tpBillStatement.getPayType());
|
|
800
|
+ map.put("payRemark", tpBillStatement.getPayRemark());
|
|
801
|
+ map.put("list", tpBillInvoices);
|
|
802
|
+
|
|
803
|
+ responseBean.addSuccess(map);
|
|
804
|
+ return responseBean;
|
|
805
|
+ }
|
|
806
|
+
|
680
|
807
|
}
|