Explorar el Código

账户管理--数据导出

ZhangWenQiang hace 5 años
padre
commit
1020262219

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

@@ -13,6 +13,7 @@ import org.jeecg.common.util.oConvertUtils;
 import org.jeecg.modules.hlgaccount.entity.HlgAccountDetail;
 import org.jeecg.modules.hlgaccount.entity.HlgAccountDetailExport;
 import org.jeecg.modules.hlgaccount.entity.HlgAccountDetailInMoney;
+import org.jeecg.modules.hlgaccount.entity.HlgAccountDetailManagerExport;
 import org.jeecg.modules.hlgaccount.service.IHlgAccountDetailService;
 import org.jeecg.modules.hlgcpmanager.entity.HlgCpAccountDetail;
 import org.jeecgframework.poi.excel.ExcelImportUtil;
@@ -480,4 +481,30 @@ public class HlgAccountDetailController {
         mv.addObject(NormalExcelConstants.PARAMS, new ExportParams("收支记录数据", "导出信息"));
         return mv;
     }
+
+    /**
+     * 账户明细导出
+     *
+     * @param request
+     * @param hlgAccountDetailManagerExport
+     * @return
+     */
+    @RequestMapping(value = "/exportXlsManager")
+    public ModelAndView exportXlsManager(HttpServletRequest request, HlgAccountDetailManagerExport hlgAccountDetailManagerExport) {
+        // Step.1 组装查询条件查询数据
+        QueryWrapper<HlgAccountDetailManagerExport> queryWrapper = QueryGenerator.initQueryWrapperForRule(hlgAccountDetailManagerExport, request.getParameterMap());
+        List<HlgAccountDetailManagerExport> pageList = hlgAccountDetailService.findManagerExportList(hlgAccountDetailManagerExport, queryWrapper);
+        // Step.2 AutoPoi 导出Excel
+        ModelAndView mv = new ModelAndView(new JeecgEntityExcelView());
+        // 过滤选中数据
+        String selections = request.getParameter("selections");
+        if (oConvertUtils.isEmpty(selections)) {
+            mv.addObject(NormalExcelConstants.DATA_LIST, pageList);
+        }
+        //导出文件名称
+        mv.addObject(NormalExcelConstants.FILE_NAME, "账户明细");
+        mv.addObject(NormalExcelConstants.CLASS, HlgAccountDetailManagerExport.class);
+        mv.addObject(NormalExcelConstants.PARAMS, new ExportParams("账户明细数据", "导出信息"));
+        return mv;
+    }
 }

+ 71 - 0
happy-boot-module-powerjob/src/main/java/org/jeecg/modules/hlgaccount/entity/HlgAccountDetailManagerExport.java

@@ -0,0 +1,71 @@
+package org.jeecg.modules.hlgaccount.entity;
+
+import com.fasterxml.jackson.annotation.JsonFormat;
+import lombok.Data;
+import org.jeecg.common.aspect.annotation.Dict;
+import org.jeecgframework.poi.excel.annotation.Excel;
+import org.springframework.format.annotation.DateTimeFormat;
+
+import java.io.Serializable;
+import java.util.Date;
+
+/**
+ * @Description: 账户明细表(用于账户明细页面导出)
+ * @Author: jeecg-boot
+ * @Date: 2020-02-21
+ * @Version: V1.0
+ */
+@Data
+public class HlgAccountDetailManagerExport implements Serializable {
+    private static final long serialVersionUID = 1L;
+
+    /**
+     * 生成时间
+     */
+    @Excel(name = "业务时间", width = 30, format = "yyyy-MM-dd HH:mm:ss")
+    @JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss")
+    @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+    private Date generateTime;
+
+    /**
+     * 类型(0:充值 1:支付)
+     */
+    @Excel(name = "收支方向", width = 15, dicCode = "account_type")
+    @Dict(dicCode = "account_type")
+    private Integer type;
+
+    /**
+     * 项目金额
+     */
+    @Excel(name = "金额", width = 25)
+    private String amount;
+
+    /**
+     * 服务费
+     */
+    @Excel(name = "服务费", width = 25)
+    private String serviceFee;
+
+    /**
+     * 备注
+     */
+    @Excel(name = "备注", width = 50)
+    private String remark;
+
+    /**
+     * 平台企业账户
+     */
+    private java.lang.Integer accountId;
+
+    private java.lang.Double totalAmount;
+
+    private java.lang.Integer paymentId;
+
+    private String paymentCode;
+
+    /**
+     * 是否退款(0:否 1:是)
+     */
+    private Integer isDrawback;
+
+}

+ 5 - 0
happy-boot-module-powerjob/src/main/java/org/jeecg/modules/hlgaccount/mapper/HlgAccountDetailMapper.java

@@ -10,6 +10,7 @@ import org.jeecg.modules.hlgaccount.entity.HlgAccountDetail;
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
 import org.jeecg.modules.hlgaccount.entity.HlgAccountDetailExport;
 import org.jeecg.modules.hlgaccount.entity.HlgAccountDetailInMoney;
+import org.jeecg.modules.hlgaccount.entity.HlgAccountDetailManagerExport;
 import org.jeecg.modules.hlgcompany.entity.HlgCompanySubcontractor;
 import org.jeecg.modules.hlgpayment.entity.HlgPaymentDetail;
 
@@ -46,4 +47,8 @@ public interface HlgAccountDetailMapper extends BaseMapper<HlgAccountDetail> {
     List<HlgAccountDetail> findPaymentExportList(@Param("hlgAccountDetail") HlgAccountDetailExport hlgAccountDetailExport, @Param(Constants.WRAPPER) QueryWrapper<HlgAccountDetailExport> queryWrapper);
 
     List<HlgAccountDetail> findManagerListA_B(Page<HlgAccountDetail> pageList, @Param("hlgAccountDetail") HlgAccountDetail hlgAccountDetail, @Param(Constants.WRAPPER) QueryWrapper<HlgAccountDetail> queryWrapper);
+
+    List<HlgAccountDetailManagerExport> findManagerExportList(@Param("hlgAccountDetail") HlgAccountDetailManagerExport hlgAccountDetailManagerExport, @Param(Constants.WRAPPER) QueryWrapper<HlgAccountDetailManagerExport> queryWrapper);
+
+    List<HlgAccountDetailManagerExport> findManagerExportListA_B(@Param("hlgAccountDetail") HlgAccountDetailManagerExport hlgAccountDetailManagerExport, @Param(Constants.WRAPPER) QueryWrapper<HlgAccountDetailManagerExport> queryWrapper);
 }

+ 62 - 0
happy-boot-module-powerjob/src/main/java/org/jeecg/modules/hlgaccount/mapper/xml/HlgAccountDetailMapper.xml

@@ -619,4 +619,66 @@
         </where>
         ORDER BY a.generate_time DESC,a.id ASC
     </select>
+
+    <select id="findManagerExportList" resultType="org.jeecg.modules.hlgaccount.entity.HlgAccountDetailManagerExport" >
+        SELECT
+        a.id AS "id",
+        a.account_id AS "accountId",
+        a.payment_id AS "paymentId",
+        a.type AS "type",
+        a.total_amount AS "totalAmount",
+        a.amount AS "amount",
+        a.service_rate AS "serviceRate",
+        a.service_fee AS "serviceFee",
+        a.is_through_platform AS "isThroughPlatform",
+        a.is_drawback AS "isDrawback",
+        a.sys_org_code AS "sysOrgCode",
+        a.is_display AS "isDisplay",
+        a.generate_time AS "generateTime",
+        a.generate_by AS "generateBy",
+        p.payment_code AS "paymentCode"
+        FROM hlg_account_detail a
+        <include refid="hlgAccountDetailJoins"/>
+        <where>
+            1=1
+            and a.is_display = '1'
+            and a.generate_time > DATE_SUB(CURDATE(), INTERVAL 6 MONTH)
+            <if test="hlgAccountDetail.accountId != null ">
+                and a.account_id = #{hlgAccountDetail.accountId}
+            </if>
+
+        </where>
+        ORDER BY a.generate_time DESC,a.id ASC
+    </select>
+
+    <select id="findManagerExportListA_B" resultType="org.jeecg.modules.hlgaccount.entity.HlgAccountDetailManagerExport" >
+        SELECT
+        a.id AS "id",
+        a.cp_account_id AS "accountId",
+        a.payment_id AS "paymentId",
+        a.type AS "type",
+        a.total_amount AS "totalAmount",
+        a.amount AS "amount",
+        a.service_rate AS "serviceRate",
+        a.service_fee AS "serviceFee",
+        1 AS "isThroughPlatform",
+        a.is_drawback AS "isDrawback",
+        a.sys_org_code AS "sysOrgCode",
+        a.is_display AS "isDisplay",
+        a.generate_time AS "generateTime",
+        a.generate_by AS "generateBy",
+        p.payment_code AS "paymentCode"
+        FROM hlg_cp_account_detail a
+        LEFT JOIN hlg_payment p ON p.id = a.payment_id
+        <where>
+            1=1
+            and a.is_display = '1'
+            and a.generate_time > DATE_SUB(CURDATE(), INTERVAL 6 MONTH)
+            <if test="hlgAccountDetail.accountId != null ">
+                and a.cp_account_id = #{hlgAccountDetail.accountId}
+            </if>
+
+        </where>
+        ORDER BY a.generate_time DESC,a.id ASC
+    </select>
 </mapper>

+ 3 - 0
happy-boot-module-powerjob/src/main/java/org/jeecg/modules/hlgaccount/service/IHlgAccountDetailService.java

@@ -8,6 +8,7 @@ import org.jeecg.modules.hlgaccount.entity.HlgAccountDetail;
 import com.baomidou.mybatisplus.extension.service.IService;
 import org.jeecg.modules.hlgaccount.entity.HlgAccountDetailExport;
 import org.jeecg.modules.hlgaccount.entity.HlgAccountDetailInMoney;
+import org.jeecg.modules.hlgaccount.entity.HlgAccountDetailManagerExport;
 import org.jeecg.modules.hlgcompany.entity.HlgCompanySubcontractor;
 import org.jeecg.modules.hlgcpmanager.entity.HlgCpAccountDetail;
 import org.jeecg.modules.hlgpayment.entity.HlgPaymentDetail;
@@ -47,4 +48,6 @@ public interface IHlgAccountDetailService extends IService<HlgAccountDetail> {
     Result<HlgAccountDetail> rechargeA_B(HlgCpAccountDetail hlgCpAccountDetail);
 
     Result<HlgAccountDetail> refundA_B(HlgCpAccountDetail hlgCpAccountDetail);
+
+    List<HlgAccountDetailManagerExport> findManagerExportList(HlgAccountDetailManagerExport hlgAccountDetailManagerExport, QueryWrapper<HlgAccountDetailManagerExport> queryWrapper);
 }

+ 57 - 4
happy-boot-module-powerjob/src/main/java/org/jeecg/modules/hlgaccount/service/impl/HlgAccountDetailServiceImpl.java

@@ -8,10 +8,7 @@ import org.apache.shiro.SecurityUtils;
 import org.jeecg.common.api.vo.Result;
 import org.jeecg.common.system.vo.LoginUser;
 import org.jeecg.common.util.businessAccountUtils;
-import org.jeecg.modules.hlgaccount.entity.HlgAccount;
-import org.jeecg.modules.hlgaccount.entity.HlgAccountDetail;
-import org.jeecg.modules.hlgaccount.entity.HlgAccountDetailExport;
-import org.jeecg.modules.hlgaccount.entity.HlgAccountDetailInMoney;
+import org.jeecg.modules.hlgaccount.entity.*;
 import org.jeecg.modules.hlgaccount.mapper.HlgAccountDetailMapper;
 import org.jeecg.modules.hlgaccount.service.IHlgAccountDetailService;
 import org.jeecg.modules.hlgaccount.service.IHlgAccountService;
@@ -635,6 +632,62 @@ public class HlgAccountDetailServiceImpl extends ServiceImpl<HlgAccountDetailMap
     }
 
     /**
+     * 导出账户明细
+     *
+     * @param hlgAccountDetailManagerExport
+     * @param queryWrapper
+     * @return
+     */
+    @Override
+    public List<HlgAccountDetailManagerExport> findManagerExportList(HlgAccountDetailManagerExport hlgAccountDetailManagerExport, QueryWrapper<HlgAccountDetailManagerExport> queryWrapper) {
+        List<HlgAccountDetailManagerExport> list = new ArrayList<>();
+        //判断是否是平台服务商(A-B)
+        if (hlgAccountDetailManagerExport.getAccountId() == 0) {
+            //获取当前登录用户
+            LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal();
+            QueryWrapper<HlgCompany> queryWrapper1 = new QueryWrapper<>();
+            queryWrapper1.eq("sys_org_code", sysUser.getOrgCode());
+            HlgCompany hlgCompany = hlgCompanyService.getOne(queryWrapper1);
+            //A-B账户
+            QueryWrapper<HlgCpAccount> queryWrapper2 = new QueryWrapper<>();
+            queryWrapper2.eq("company_id", hlgCompany.getId());
+            HlgCpAccount hlgCpAccount = hlgCpAccountService.getOne(queryWrapper2);
+            hlgAccountDetailManagerExport.setAccountId(hlgCpAccount.getId());
+            list = baseMapper.findManagerExportListA_B(hlgAccountDetailManagerExport, queryWrapper);
+        } else {
+            list = baseMapper.findManagerExportList(hlgAccountDetailManagerExport, queryWrapper);
+        }
+        for (HlgAccountDetailManagerExport hlgAccountDetailManagerExportN : list) {
+            String remark = "";
+            switch (hlgAccountDetailManagerExportN.getType()) {
+                case 0:
+                    remark = "充值" + hlgAccountDetailManagerExportN.getTotalAmount() + "元,扣除服务费" +
+                            hlgAccountDetailManagerExportN.getServiceFee() + "元,实际到账" + hlgAccountDetailManagerExportN.getAmount() + "元";
+                    break;
+                case 1:
+                    if (hlgAccountDetailManagerExportN.getPaymentId() != null) {
+                        remark = "付款:" + hlgAccountDetailManagerExportN.getPaymentCode();
+                    }
+                    break;
+                case 2:
+                    remark = "付款失败:" + hlgAccountDetailManagerExportN.getPaymentCode();
+                    break;
+                default:
+                    remark = "";
+                    break;
+            }
+            if (hlgAccountDetailManagerExportN.getIsDrawback() == 1) {
+                hlgAccountDetailManagerExportN.setAmount(hlgAccountDetailManagerExportN.getAmount() + "(已退款)");
+            }
+            if (hlgAccountDetailManagerExportN.getIsDrawback() == 1) {
+                hlgAccountDetailManagerExportN.setServiceFee(hlgAccountDetailManagerExportN.getServiceFee() + "(已退款)");
+            }
+            hlgAccountDetailManagerExportN.setRemark(remark);
+        }
+        return list;
+    }
+
+    /**
      * 收支备注统一处理
      *
      * @param hlgAccountDetailNew