Browse Source

资金管理-充值退款列表计算已退款金额

ZhangWenQiang 6 years ago
parent
commit
c1759a4f81

+ 40 - 0
happy-boot-module-powerjob/src/main/java/org/jeecg/modules/hlgaccount/controller/HlgAccountDetailController.java

@@ -12,9 +12,11 @@ import javax.servlet.http.HttpServletResponse;
 
 import org.jeecg.common.api.vo.Result;
 import org.jeecg.common.system.query.QueryGenerator;
+import org.jeecg.common.util.businessAccountUtils;
 import org.jeecg.common.util.oConvertUtils;
 import org.jeecg.modules.hlgaccount.entity.HlgAccount;
 import org.jeecg.modules.hlgaccount.entity.HlgAccountDetail;
+import org.jeecg.modules.hlgaccount.entity.HlgRefundDetail;
 import org.jeecg.modules.hlgaccount.service.IHlgAccountDetailService;
 
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
@@ -22,6 +24,7 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import lombok.extern.slf4j.Slf4j;
 
+import org.jeecg.modules.hlgaccount.service.IHlgRefundDetailService;
 import org.jeecgframework.poi.excel.ExcelImportUtil;
 import org.jeecgframework.poi.excel.def.NormalExcelConstants;
 import org.jeecgframework.poi.excel.entity.ExportParams;
@@ -47,6 +50,8 @@ import com.alibaba.fastjson.JSON;
 public class HlgAccountDetailController {
     @Autowired
     private IHlgAccountDetailService hlgAccountDetailService;
+    @Autowired
+    private IHlgRefundDetailService hlgRefundDetailService;
 
     /**
      * 收支明细列表
@@ -72,6 +77,40 @@ public class HlgAccountDetailController {
     }
 
     /**
+     * 充值退款列表
+     *
+     * @param hlgAccountDetail
+     * @param pageNo
+     * @param pageSize
+     * @param req
+     * @return
+     */
+    @GetMapping(value = "/refundList")
+    public Result<IPage<HlgAccountDetail>> refundList(HlgAccountDetail hlgAccountDetail,
+                                                      @RequestParam(name = "pageNo", defaultValue = "1") Integer pageNo,
+                                                      @RequestParam(name = "pageSize", defaultValue = "10") Integer pageSize,
+                                                      HttpServletRequest req) {
+        Result<IPage<HlgAccountDetail>> result = new Result<IPage<HlgAccountDetail>>();
+        QueryWrapper<HlgAccountDetail> queryWrapper = QueryGenerator.initQueryWrapperForRule(hlgAccountDetail, req.getParameterMap());
+        Page<HlgAccountDetail> page = new Page<HlgAccountDetail>(pageNo, pageSize);
+        Page<HlgAccountDetail> pageList = hlgAccountDetailService.pageList(page, hlgAccountDetail, queryWrapper);
+        //遍历列表
+        for (HlgAccountDetail hlgAccountDetail1 : pageList.getRecords()) {
+            //查询该账户明细已退款记录
+            List<HlgRefundDetail> hlgRefundDetailList = hlgRefundDetailService.findListByAccountDetailId(hlgAccountDetail1.getId());
+            //已退款金额
+            Double refundAmount = 0.00;
+            for (HlgRefundDetail hlgRefundDetail : hlgRefundDetailList) {
+                refundAmount = businessAccountUtils.add(refundAmount, hlgRefundDetail.getRefundAmount());
+            }
+            hlgAccountDetail1.setRefundAmount(refundAmount);
+        }
+        result.setSuccess(true);
+        result.setResult(pageList);
+        return result;
+    }
+
+    /**
      * 添加
      *
      * @param hlgAccountDetail
@@ -133,6 +172,7 @@ public class HlgAccountDetailController {
 
     /**
      * 退款
+     *
      * @param hlgAccountDetail
      * @return
      */