Quellcode durchsuchen

缴费记录接口

cgy vor 4 Monaten
Ursprung
Commit
daf568e5fd

+ 9 - 0
zhsw-common/src/main/java/com/rongwei/zhsw/system/wechat/PaymentRecordService.java

@@ -0,0 +1,9 @@
+package com.rongwei.zhsw.system.wechat;
+
+import com.rongwe.zhsw.system.vo.PaymentRocordVo;
+import com.rongwei.rwcommon.base.R;
+
+public interface PaymentRecordService {
+
+    R getPaymentRecordList(PaymentRocordVo paymentRocordVo);
+}

+ 108 - 0
zhsw-common/src/main/java/com/rongwei/zhsw/system/wechat/impl/PaymentRecordServiceImpl.java

@@ -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);
+    }
+}

+ 17 - 0
zhsw-entity/src/main/java/com/rongwe/zhsw/system/vo/PaymentRocordVo.java

@@ -0,0 +1,17 @@
+package com.rongwe.zhsw.system.vo;
+
+import lombok.Data;
+
+import java.util.Date;
+
+/**
+ * sw_billing_record
+ *
+ */
+@Data
+public class PaymentRocordVo {
+    //用户 id
+    private String accountNum;
+    // 缴费记录年份
+    private int year= new Date().getYear();
+}

+ 26 - 0
zhsw-server/src/main/java/com/rongwei/zhsw/system/controller/weChat/PayMentController.java

@@ -0,0 +1,26 @@
+package com.rongwei.zhsw.system.controller.weChat;
+
+import com.rongwe.zhsw.system.vo.PaymentRocordVo;
+import com.rongwei.rwcommon.base.R;
+import com.rongwei.zhsw.system.wechat.PaymentRecordService;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.PostMapping;
+import org.springframework.web.bind.annotation.RequestBody;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RestController;
+
+@RestController
+@RequestMapping("/wechat/payment")
+public class PayMentController {
+    private static final Logger log = LoggerFactory.getLogger(PayMentController.class);
+
+    @Autowired
+    private PaymentRecordService paymentRecordService;
+
+    @PostMapping("/record")
+    private R info(@RequestBody PaymentRocordVo payMentRocordVo) {
+        return paymentRecordService.getPaymentRecordList(payMentRocordVo);
+    }
+}