|
@@ -0,0 +1,108 @@
|
|
|
+package com.rongwei.zhsw.system.wechat.impl;
|
|
|
+
|
|
|
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
+import com.rongwe.zhsw.system.domain.SwBillManagementPaidDo;
|
|
|
+import com.rongwe.zhsw.system.domain.SwBillingRecordDo;
|
|
|
+import com.rongwe.zhsw.system.vo.PaymentRocordVo;
|
|
|
+import com.rongwei.rwcommon.base.R;
|
|
|
+import com.rongwei.rwcommon.base.exception.CustomException;
|
|
|
+import com.rongwei.zhsw.system.service.impl.SwBillManagementPaidServiceImpl;
|
|
|
+import com.rongwei.zhsw.system.service.impl.SwBillingRecordServiceImpl;
|
|
|
+import com.rongwei.zhsw.system.wechat.PaymentRecordService;
|
|
|
+import org.apache.commons.lang.StringUtils;
|
|
|
+import org.slf4j.Logger;
|
|
|
+import org.slf4j.LoggerFactory;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.stereotype.Service;
|
|
|
+
|
|
|
+import java.util.ArrayList;
|
|
|
+import java.util.HashMap;
|
|
|
+import java.util.List;
|
|
|
+import java.util.Map;
|
|
|
+import java.util.stream.Collectors;
|
|
|
+
|
|
|
+@Service
|
|
|
+public class PaymentRecordServiceImpl implements PaymentRecordService {
|
|
|
+ private static final Logger log = LoggerFactory.getLogger(PaymentRecordServiceImpl.class);
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private SwBillingRecordServiceImpl swBillingRecordService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private SwBillManagementPaidServiceImpl swBillManagementPaidService;
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 获取缴费记录及其对应的所有账单
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public R getPaymentRecordList(PaymentRocordVo paymentRocordVo) {
|
|
|
+ // 户号
|
|
|
+ String accountNum = paymentRocordVo.getAccountNum();
|
|
|
+ if (StringUtils.isBlank(accountNum)) {
|
|
|
+ throw new CustomException("户号为空");
|
|
|
+ }
|
|
|
+ // 年份
|
|
|
+ int year = paymentRocordVo.getYear();
|
|
|
+
|
|
|
+ // 查询缴费记录
|
|
|
+ List<SwBillingRecordDo> billingRecords = swBillingRecordService.list(new LambdaQueryWrapper<SwBillingRecordDo>()
|
|
|
+ .eq(SwBillingRecordDo::getDeleted, 0)
|
|
|
+ .eq(SwBillingRecordDo::getUsernumber, accountNum)
|
|
|
+ .eq(SwBillingRecordDo::getYear, year)
|
|
|
+ .orderByDesc(SwBillingRecordDo::getChargedate));
|
|
|
+
|
|
|
+ // 获取所有缴费记录ID
|
|
|
+ List<String> recordIds = billingRecords.stream()
|
|
|
+ .map(SwBillingRecordDo::getId)
|
|
|
+ .collect(Collectors.toList());
|
|
|
+
|
|
|
+ // 查询关联的账单信息
|
|
|
+ Map<String, List<SwBillManagementPaidDo>> billMap = new HashMap<>();
|
|
|
+ if (!recordIds.isEmpty()) {
|
|
|
+ List<SwBillManagementPaidDo> allBills = swBillManagementPaidService.list(new LambdaQueryWrapper<SwBillManagementPaidDo>()
|
|
|
+ .in(SwBillManagementPaidDo::getPaymentrecordid, recordIds));
|
|
|
+
|
|
|
+ billMap = allBills.stream()
|
|
|
+ .collect(Collectors.groupingBy(SwBillManagementPaidDo::getPaymentrecordid));
|
|
|
+ }
|
|
|
+
|
|
|
+ // 组装返回数据
|
|
|
+ List<Map<String, Object>> returnList = new ArrayList<>();
|
|
|
+ for (SwBillingRecordDo record : billingRecords) {
|
|
|
+ Map<String, Object> paymentRecord = new HashMap<>();
|
|
|
+ // 缴费记录信息
|
|
|
+ paymentRecord.put("billingnumber", record.getBillingnumber());
|
|
|
+ paymentRecord.put("chargedate", record.getChargedate());
|
|
|
+ paymentRecord.put("topuppaymentamount", record.getTopuppaymentamount());
|
|
|
+ paymentRecord.put("balancededuction", record.getBalancededuction());
|
|
|
+ paymentRecord.put("allfeewaiver", record.getAllfeewaiver());
|
|
|
+ paymentRecord.put("latefees", record.getLatefees());
|
|
|
+ paymentRecord.put("oughttohavepaid", record.getOughttohavepaid());
|
|
|
+ paymentRecord.put("actualdue", record.getActualdue());
|
|
|
+ paymentRecord.put("usernumber", record.getUsernumber());
|
|
|
+
|
|
|
+ // 关联的账单列表
|
|
|
+ List<Map<String, Object>> billList = new ArrayList<>();
|
|
|
+ List<SwBillManagementPaidDo> bills = billMap.getOrDefault(record.getId(), new ArrayList<>());
|
|
|
+ for (SwBillManagementPaidDo bill : bills) {
|
|
|
+ Map<String, Object> billInfo = new HashMap<>();
|
|
|
+ billInfo.put("billnumber", bill.getBillnumber());
|
|
|
+ billInfo.put("thismeterreadingdate", bill.getThismeterreadingdate());
|
|
|
+ billInfo.put("currentwateruse", bill.getCurrentwateruse());
|
|
|
+ billInfo.put("meterReading", bill.getLastmeterreading().stripTrailingZeros().toPlainString()
|
|
|
+ + "-" + bill.getThismeterreading().stripTrailingZeros().toPlainString());
|
|
|
+ billInfo.put("feewaiver", bill.getFeewaiver());
|
|
|
+ billInfo.put("latefees", bill.getLatefees());
|
|
|
+ billInfo.put("actualdue", bill.getActualdue());
|
|
|
+ billInfo.put("status", bill.getStatus());
|
|
|
+ billList.add(billInfo);
|
|
|
+ }
|
|
|
+ paymentRecord.put("bills", billList);
|
|
|
+ returnList.add(paymentRecord);
|
|
|
+ }
|
|
|
+
|
|
|
+ return R.ok(returnList);
|
|
|
+ }
|
|
|
+}
|