重构监听事件对象

This commit is contained in:
jinqiming 2020-11-10 18:09:01 +08:00
parent 2e5a65b2c3
commit b81b074752
10 changed files with 213 additions and 261 deletions

View File

@ -377,6 +377,67 @@ var table = {
});
});
},
// 导入数据
importExcelAlipay:function(formId) {
table.set();
var currentId = $.common.isEmpty(formId) ? 'importTpl' : formId;
layer.open({
type: 1,
area: ['500px', '530px'],
fix: false,
//不固定
maxmin: true,
shade: 0.3,
title: '导入' + table.options.modalName + '数据',
content: $('#' + currentId).html(),
btn: ['<i class="fa fa-check"></i> 导入', '<i class="fa fa-remove"></i> 取消'],
// 弹层外区域关闭
shadeClose: true,
btn1: function(index, layero){
var file = layero.find('#file').val();
var tradeAccount = layero.find('#tradeAccount').val();
var tradeRealName = layero.find('#tradeRealName').val();
if (file == '' || (!$.common.endWith(file, '.xls') && !$.common.endWith(file, '.xlsx'))){
$.modal.msgWarning("请选择后缀为 “xls”或“xlsx”的文件。");
return false;
}
if(tradeAccount==''||tradeAccount==null){
$.modal.msgWarning("交易账户不能为空");
return false;
}
if(tradeRealName==''||tradeRealName==null){
$.modal.msgWarning("真实姓名不能为空");
return false;
}
var index = layer.load(2, {shade: false});
$.modal.disable();
var formData = new FormData(layero.find('form')[0]);
$.ajax({
url: table.options.importUrl,
data: formData,
cache: false,
contentType: false,
processData: false,
type: 'POST',
success: function (result) {
if (result.code == web_status.SUCCESS) {
$.modal.closeAll();
$.modal.alertSuccess(result.msg);
$.table.refresh();
} else if (result.code == web_status.WARNING) {
layer.close(index);
$.modal.enable();
$.modal.alertWarning(result.msg)
} else {
layer.close(index);
$.modal.enable();
$.modal.alertError(result.msg);
}
}
});
}
});
},
// 下载模板
importTemplate: function() {
table.set();

View File

@ -18,43 +18,6 @@
<label>商家订单号:</label>
<input type="text" name="orderNo"/>
</li>
<li class="select-time">
<label>交易创建时间:</label>
<input type="text" class="time-input" id="startTime" placeholder="开始时间" name="params[beginTradeCreateTime]"/>
<span>-</span>
<input type="text" class="time-input" id="endTime" placeholder="结束时间" name="params[endTradeCreateTime]"/>
</li>
<li class="select-time">
<label>交易支付时间:</label>
<input type="text" class="time-input" id="startTime" placeholder="开始时间" name="params[beginPayTime]"/>
<span>-</span>
<input type="text" class="time-input" id="endTime" placeholder="结束时间" name="params[endPayTime]"/>
</li>
<li class="select-time">
<label>最近修改时间:</label>
<input type="text" class="time-input" id="startTime" placeholder="开始时间" name="params[beginLastModifyTime]"/>
<span>-</span>
<input type="text" class="time-input" id="endTime" placeholder="结束时间" name="params[endLastModifyTime]"/>
</li>
<li>
<label>交易来源地:</label>
<input type="text" name="tradeSourcePlace"/>
</li>
<li>
<label>交易类型:</label>
<select name="tradeType" th:with="type=${@dict.getType('trade_type')}">
<option value="">所有</option>
<option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
</select>
</li>
<li>
<label>交易对方:</label>
<input type="text" name="counterparty"/>
</li>
<li>
<label>交易金额:</label>
<input type="text" name="tradePrice"/>
</li>
<li>
<label>交易状态:</label>
<select name="tradeStatus" th:with="type=${@dict.getType('trade_status_type')}">
@ -69,14 +32,6 @@
<option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
</select>
</li>
<li>
<label>服务费:</label>
<input type="text" name="serviceCharge"/>
</li>
<li>
<label>退款金额:</label>
<input type="text" name="refundPrice"/>
</li>
<li>
<label>资金状态:</label>
<select name="capitalStatus" th:with="type=${@dict.getType('capital_status')}">
@ -84,18 +39,6 @@
<option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
</select>
</li>
<li>
<label>所属人:</label>
<input type="text" name="belongUserId"/>
</li>
<li>
<label>交易主体账户:</label>
<input type="text" name="tradeAccount"/>
</li>
<li>
<label>交易真实姓名:</label>
<input type="text" name="tradeRealName"/>
</li>
<li>
<a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i class="fa fa-search"></i>&nbsp;搜索</a>
<a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i class="fa fa-refresh"></i>&nbsp;重置</a>
@ -115,7 +58,7 @@
<a class="btn btn-danger multiple disabled" onclick="$.operate.removeAll()" shiro:hasPermission="system:flow:remove">
<i class="fa fa-remove"></i> 删除
</a>
<a class="btn btn-info" onclick="$.table.importExcel()" shiro:hasPermission="system:flow:import">
<a class="btn btn-info" onclick="$.table.importExcelAlipay()" shiro:hasPermission="system:flow:import">
<i class="fa fa-upload"></i> 导入
</a>
<a class="btn btn-warning" onclick="$.table.exportExcel()" shiro:hasPermission="system:flow:export">
@ -145,6 +88,7 @@
removeUrl: prefix + "/remove",
exportUrl: prefix + "/export",
importUrl: prefix + "/importData",
importTemplateUrl: prefix + "/importTemplate",
modalName: "财务支付宝流水",
columns: [{
checkbox: true
@ -156,28 +100,48 @@
},
{
field: 'tradeNo',
title: '交易号'
title: '交易号',
formatter: function(value, row, index) {
if(value==null||value==''){
return '';
}else {
return value.substr(0,8);
}
}
},
{
field: 'orderNo',
title: '商家订单号'
title: '商家订单号',
formatter: function(value, row, index) {
if(value==null||value==''){
return '';
}else {
return value.substr(0,8);
}
}
},
{
field: 'tradeCreateTime',
title: '交易创建时间'
field: 'goodsName',
title: '商品'
},
{
field: 'tradePrice',
title: '交易金额'
},
{
field: 'serviceCharge',
title: '服务费'
},
{
field: 'refundPrice',
title: '退款金额'
},
{
field: 'payTime',
title: '交易支付时间'
},
{
field: 'lastModifyTime',
title: '最近修改时间'
},
{
field: 'tradeSourcePlace',
title: '交易来源地'
},
{
field: 'tradeType',
title: '交易类型',
@ -189,10 +153,7 @@
field: 'counterparty',
title: '交易对方'
},
{
field: 'tradePrice',
title: '交易金额'
},
{
field: 'tradeStatus',
title: '交易状态',
@ -207,14 +168,7 @@
return $.table.selectDictLabel(incomeExpenditureTypeDatas, value);
}
},
{
field: 'serviceCharge',
title: '服务费'
},
{
field: 'refundPrice',
title: '退款金额'
},
{
field: 'capitalStatus',
title: '资金状态',
@ -222,14 +176,6 @@
return $.table.selectDictLabel(capitalStatusDatas, value);
}
},
{
field: 'remark',
title: '备注'
},
{
field: 'belongUserId',
title: '所属人'
},
{
field: 'tradeAccount',
title: '交易主体账户'
@ -238,6 +184,7 @@
field: 'tradeRealName',
title: '交易真实姓名'
},
{
title: '操作',
align: 'center',
@ -255,12 +202,32 @@
</body>
<!-- 导入区域 -->
<script id="importTpl" type="text/template">
<form enctype="multipart/form-data" class="mt20 mb10">
<form enctype="multipart/form-data" class="form-horizontal m" >
<div class="col-xs-offset-1">
<div class="form-group">
<label class="col-sm-3 control-label">下载模板:</label>
<div class="col-sm-8">
<a onclick="$.table.importTemplate()" class="btn btn-default btn-xs"><i class="fa fa-file-excel-o"></i> 下载模板</a>
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label">导入数据:</label>
<div class="col-sm-8">
<input type="file" id="file" name="file"/>
<div class="mt10 pt5">
<input type="checkbox" id="updateSupport" name="updateSupport" title="如果登录账户已经存在,更新这条数据。"> 是否更新已经存在的用户数据
&nbsp; <a onclick="$.table.importTemplate()" class="btn btn-default btn-xs"><i class="fa fa-file-excel-o"></i> 下载模板</a>
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label">交易账户:</label>
<div class="col-sm-8">
<input name="tradeAccount" id="tradeAccount" class="form-control" type="text">
</div>
</div>
<div class="form-group">
<label class="col-sm-3 control-label">真实姓名:</label>
<div class="col-sm-8">
<input name="tradeRealName" name="tradeRealName" class="form-control" type="text">
</div>
</div>
<font color="red" class="pull-left mt10">
提示仅允许导入“xls”或“xlsx”格式文件

View File

@ -107,7 +107,11 @@
<artifactId>easyexcel</artifactId>
<version>2.1.6</version>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>1.18.10</version>
</dependency>
</dependencies>
</project>

View File

@ -2,6 +2,8 @@ package com.snow.framework.excel;
import com.alibaba.excel.context.AnalysisContext;
import com.alibaba.excel.event.AnalysisEventListener;
import com.snow.common.json.JSON;
import com.snow.common.utils.DateUtils;
import com.snow.common.utils.bean.BeanUtils;
import com.snow.system.domain.FinanceAlipayFlow;
import com.snow.system.domain.FinanceAlipayFlowImport;
@ -16,8 +18,10 @@ import java.io.BufferedWriter;
import java.io.FileWriter;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
/**
* @author qimingjin
@ -88,61 +92,74 @@ public class FinanceAlipayFlowListener extends AnalysisEventListener<FinanceAlip
}
public void saveData(){
list.forEach(t->{
FinanceAlipayFlow financeAlipayFlow=new FinanceAlipayFlow();
BeanUtils.copyProperties(t,financeAlipayFlow);
String capitalStatus = t.getCapitalStatus();
if(StringUtils.isEmpty(capitalStatus)){
financeAlipayFlow.setCapitalStatus(0);
List<FinanceAlipayFlow> financeAlipayFlowList = list.stream().map(t -> {
FinanceAlipayFlow financeAlipayFlow = new FinanceAlipayFlow();
BeanUtils.copyProperties(t, financeAlipayFlow);
String payTime = t.getPayTime();
String tradeCreateTime = t.getTradeCreateTime();
String lastModifyTime = t.getLastModifyTime();
if (!StringUtils.isEmpty(payTime)) {
Date date = DateUtils.parseDate(payTime);
financeAlipayFlow.setPayTime(date);
}
else if(capitalStatus.equals("已支出")){
if (!StringUtils.isEmpty(tradeCreateTime)) {
Date date = DateUtils.parseDate(tradeCreateTime);
financeAlipayFlow.setTradeCreateTime(date);
}
if (!StringUtils.isEmpty(lastModifyTime)) {
Date date = DateUtils.parseDate(lastModifyTime);
financeAlipayFlow.setLastModifyTime(date);
}
String capitalStatus = t.getCapitalStatus();
if (StringUtils.isEmpty(capitalStatus)) {
financeAlipayFlow.setCapitalStatus(0);
} else if (capitalStatus.equals("已支出")) {
financeAlipayFlow.setCapitalStatus(1);
}else if(capitalStatus.equals("已收入")){
} else if (capitalStatus.equals("已收入")) {
financeAlipayFlow.setCapitalStatus(2);
}else if(capitalStatus.equals("资金转移")){
} else if (capitalStatus.equals("资金转移")) {
financeAlipayFlow.setCapitalStatus(3);
}else {
} else {
financeAlipayFlow.setCapitalStatus(10);
}
String incomeExpenditureType = t.getIncomeExpenditureType();
if(StringUtils.isEmpty(incomeExpenditureType)){
if (StringUtils.isEmpty(incomeExpenditureType)) {
financeAlipayFlow.setIncomeExpenditureType(0);
}
else if(incomeExpenditureType.equals("收入")){
} else if (incomeExpenditureType.equals("收入")) {
financeAlipayFlow.setIncomeExpenditureType(2);
}else if(incomeExpenditureType.equals("支出")){
} else if (incomeExpenditureType.equals("支出")) {
financeAlipayFlow.setIncomeExpenditureType(1);
}
String tradeStatus = t.getTradeStatus();
if(StringUtils.isEmpty(tradeStatus)){
if (StringUtils.isEmpty(tradeStatus)) {
financeAlipayFlow.setTradeStatus(null);
}
else if(tradeStatus.equals("交易成功")){
} else if (tradeStatus.equals("交易成功")) {
financeAlipayFlow.setTradeStatus(1);
}else if(tradeStatus.equals("交易关闭")){
} else if (tradeStatus.equals("交易关闭")) {
financeAlipayFlow.setTradeStatus(2);
}else if(tradeStatus.equals("还款成功")){
} else if (tradeStatus.equals("还款成功")) {
financeAlipayFlow.setTradeStatus(3);
}else if(tradeStatus.equals("退款成功")){
} else if (tradeStatus.equals("退款成功")) {
financeAlipayFlow.setTradeStatus(4);
}
String tradeType = t.getTradeType();
if(StringUtils.isEmpty(tradeType)){
if (StringUtils.isEmpty(tradeType)) {
financeAlipayFlow.setTradeType(null);
}
else if(tradeType.equals("即时到账交易")){
} else if (tradeType.equals("即时到账交易")) {
financeAlipayFlow.setTradeType(1);
}else if(tradeType.equals("支付宝担保交易")){
} else if (tradeType.equals("支付宝担保交易")) {
financeAlipayFlow.setTradeType(2);
}
financeAlipayFlow.setCreateBy(operName);
financeAlipayFlow.setBelongUserId(belongUserId);
financeAlipayFlow.setTradeRealName(tradeRealName);
financeAlipayFlow.setTradeAccount(tradeAccount);
financeAlipayFlowService.insertFinanceAlipayFlow(financeAlipayFlow);
});
log.info("转化后的对象:financeAlipayFlow{}", com.alibaba.fastjson.JSON.toJSONString(financeAlipayFlow));
return financeAlipayFlow;
}).collect(Collectors.toList());
financeAlipayFlowService.insertBatchFinanceAlipayFlow(financeAlipayFlowList);
}

View File

@ -23,7 +23,11 @@
<artifactId>snow-common</artifactId>
<version>4.3.1</version>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>1.18.10</version>
</dependency>
</dependencies>
</project>

View File

@ -1,6 +1,7 @@
package com.snow.system.domain;
import com.alibaba.excel.annotation.ExcelProperty;
import lombok.Data;
import java.math.BigDecimal;
import java.util.Date;
@ -12,6 +13,7 @@ import java.util.Date;
* @author snow
* @String 2020-11-09
*/
@Data
public class FinanceAlipayFlowImport
{
private static final long serialVersionUID = 1L;
@ -28,15 +30,15 @@ public class FinanceAlipayFlowImport
/** 交易创建时间 */
@ExcelProperty(index = 2)
private Date tradeCreateTime;
private String tradeCreateTime;
/** 交易支付时间 */
@ExcelProperty(index = 3)
private Date payTime;
private String payTime;
/** 最近修改时间 */
@ExcelProperty(index = 4)
private Date lastModifyTime;
private String lastModifyTime;
/** 交易来源地 */
@ExcelProperty(index =5)
@ -82,135 +84,4 @@ public class FinanceAlipayFlowImport
@ExcelProperty(index = 15)
private String capitalStatus;
public String getTradeNo() {
return tradeNo;
}
public void setTradeNo(String tradeNo) {
this.tradeNo = tradeNo;
}
public String getOrderNo() {
return orderNo;
}
public void setOrderNo(String orderNo) {
this.orderNo = orderNo;
}
public Date getTradeCreateTime() {
return tradeCreateTime;
}
public void setTradeCreateTime(Date tradeCreateTime) {
this.tradeCreateTime = tradeCreateTime;
}
public Date getPayTime() {
return payTime;
}
public void setPayTime(Date payTime) {
this.payTime = payTime;
}
public Date getLastModifyTime() {
return lastModifyTime;
}
public void setLastModifyTime(Date lastModifyTime) {
this.lastModifyTime = lastModifyTime;
}
public String getTradeSourcePlace() {
return tradeSourcePlace;
}
public void setTradeSourcePlace(String tradeSourcePlace) {
this.tradeSourcePlace = tradeSourcePlace;
}
public String getTradeType() {
return tradeType;
}
public void setTradeType(String tradeType) {
this.tradeType = tradeType;
}
public String getCounterparty() {
return counterparty;
}
public void setCounterparty(String counterparty) {
this.counterparty = counterparty;
}
public String getGoodsName() {
return goodsName;
}
public void setGoodsName(String goodsName) {
this.goodsName = goodsName;
}
public BigDecimal getTradePrice() {
return tradePrice;
}
public void setTradePrice(BigDecimal tradePrice) {
this.tradePrice = tradePrice;
}
public String getIncomeExpenditureType() {
return incomeExpenditureType;
}
public void setIncomeExpenditureType(String incomeExpenditureType) {
this.incomeExpenditureType = incomeExpenditureType;
}
public String getTradeStatus() {
return tradeStatus;
}
public void setTradeStatus(String tradeStatus) {
this.tradeStatus = tradeStatus;
}
public BigDecimal getServiceCharge() {
return serviceCharge;
}
public void setServiceCharge(BigDecimal serviceCharge) {
this.serviceCharge = serviceCharge;
}
public BigDecimal getRefundPrice() {
return refundPrice;
}
public void setRefundPrice(BigDecimal refundPrice) {
this.refundPrice = refundPrice;
}
public String getRemark() {
return remark;
}
public void setRemark(String remark) {
this.remark = remark;
}
public String getCapitalStatus() {
return capitalStatus;
}
public void setCapitalStatus(String capitalStatus) {
this.capitalStatus = capitalStatus;
}
}

View File

@ -2,6 +2,7 @@ package com.snow.system.mapper;
import java.util.List;
import com.snow.system.domain.FinanceAlipayFlow;
import org.apache.ibatis.annotations.Param;
/**
* 财务支付宝流水Mapper接口
@ -35,6 +36,13 @@ public interface FinanceAlipayFlowMapper
*/
public int insertFinanceAlipayFlow(FinanceAlipayFlow financeAlipayFlow);
/**
* 批量新增财务支付宝流水
* @param financeAlipayFlowList
* @return
*/
public int insertBatchFinanceAlipayFlow(@Param("financeAlipayFlowList") List financeAlipayFlowList);
/**
* 修改财务支付宝流水
*

View File

@ -34,6 +34,13 @@ public interface IFinanceAlipayFlowService
* @return 结果
*/
public int insertFinanceAlipayFlow(FinanceAlipayFlow financeAlipayFlow);
/**
* 批量新增财务支付宝流水
* @param financeAlipayFlowList
* @return
*/
public int insertBatchFinanceAlipayFlow(List<FinanceAlipayFlow> financeAlipayFlowList);
/**
* 修改财务支付宝流水

View File

@ -58,6 +58,11 @@ public class FinanceAlipayFlowServiceImpl implements IFinanceAlipayFlowService
return financeAlipayFlowMapper.insertFinanceAlipayFlow(financeAlipayFlow);
}
@Override
public int insertBatchFinanceAlipayFlow(List<FinanceAlipayFlow> financeAlipayFlowList) {
return financeAlipayFlowMapper.insertBatchFinanceAlipayFlow(financeAlipayFlowList);
}
/**
* 修改财务支付宝流水
*

View File

@ -112,7 +112,15 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="goodsName != null">#{goodsName},</if>
</trim>
</insert>
<insert id="insertBatchFinanceAlipayFlow" parameterType="java.util.List">
insert into finance_alipay_flow (trade_no, order_no, trade_create_time, pay_time, last_modify_time, trade_source_place, trade_type, counterparty, trade_price, trade_status, income_expenditure_type, service_charge, refund_price, capital_status, remark, belong_user_id, trade_account, trade_real_name, create_time, create_by,goods_name) values
<foreach collection="financeAlipayFlowList" item="item" separator="," close=";">
(
#{item.tradeNo}, #{item.orderNo}, #{item.tradeCreateTime}, #{item.payTime}, #{item.lastModifyTime}, #{item.tradeSourcePlace}, #{item.tradeType}
,#{item.counterparty}, #{item.tradePrice}, #{item.tradeStatus}, #{item.incomeExpenditureType}, #{item.serviceCharge}, #{item.refundPrice}, #{item.capitalStatus},#{item.remark}, #{item.belongUserId}, #{item.tradeAccount}, #{item.tradeRealName}, now(), #{item.createBy}, #{item.goodsName}
)
</foreach>
</insert>
<update id="updateFinanceAlipayFlow" parameterType="FinanceAlipayFlow">
update finance_alipay_flow
<trim prefix="SET" suffixOverrides=",">