feat: 对账管理

This commit is contained in:
2026-07-27 11:33:43 +08:00
parent d4e7e4282b
commit 2d8a31a3cc
9 changed files with 995 additions and 0 deletions
@@ -0,0 +1,67 @@
package com.budwk.app.zhgh.pointsmall.reconciliation.controller;
import cn.dev33.satoken.annotation.SaCheckPermission;
import com.budwk.app.base.annotation.SLog;
import com.budwk.app.base.result.Result;
import com.budwk.app.zhgh.pointsmall.reconciliation.param.PointsMallReconciliationOrderPageParam;
import com.budwk.app.zhgh.pointsmall.reconciliation.param.PointsMallReconciliationParam;
import com.budwk.app.zhgh.pointsmall.reconciliation.param.PointsMallReconciliationRecordPageParam;
import com.budwk.app.zhgh.pointsmall.reconciliation.service.PointsMallReconciliationService;
import org.nutz.ioc.loader.annotation.Inject;
import org.nutz.ioc.loader.annotation.IocBean;
import org.nutz.mvc.annotation.At;
import org.nutz.mvc.annotation.Ok;
@IocBean
@Ok("json:full")
@At("/platform/zhgh/points-mall/reconciliation")
public class PointsMallReconciliationController {
@Inject
private PointsMallReconciliationService pointsMallReconciliationService;
@At("")
@Ok("beetl:/platform/zhgh/points-mall/reconciliation/index.html")
@SaCheckPermission("points.mall.reconciliation")
public void index() {
}
@At
@SaCheckPermission("points.mall.reconciliation")
public Result pageData(PointsMallReconciliationOrderPageParam param) {
return Result.success(pointsMallReconciliationService.orderPage(param));
}
@At
@SaCheckPermission("points.mall.reconciliation")
public Result supplierList() {
return Result.success(pointsMallReconciliationService.listSuppliers());
}
@At
@SaCheckPermission("points.mall.reconciliation")
public Result pointsTotal(PointsMallReconciliationParam param) {
try {
return Result.success(pointsMallReconciliationService.pointsTotal(param));
} catch (IllegalArgumentException e) {
return Result.error(e.getMessage());
}
}
@At
@SLog(tag = "积分商城对账管理", msg = "执行订单对账")
@SaCheckPermission("points.mall.reconciliation")
public Result execute(PointsMallReconciliationParam param) {
try {
return Result.success(pointsMallReconciliationService.execute(param));
} catch (IllegalArgumentException e) {
return Result.error(e.getMessage());
}
}
@At
@SaCheckPermission("points.mall.reconciliation")
public Result recordPage(PointsMallReconciliationRecordPageParam param) {
return Result.success(pointsMallReconciliationService.recordPage(param));
}
}
@@ -0,0 +1,59 @@
package com.budwk.app.zhgh.pointsmall.reconciliation.models;
import com.budwk.app.base.model.BaseModel;
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.nutz.dao.entity.annotation.*;
import org.nutz.dao.interceptor.annotation.PrevInsert;
import java.io.Serializable;
import java.math.BigDecimal;
@Data
@EqualsAndHashCode(callSuper = true)
@Table("points_mall_reconciliation_order")
@Comment("积分商城供应商对账订单")
public class PointsMallReconciliationOrder extends BaseModel implements Serializable {
@Name
@Column
@Comment("ID")
@ColDefine(type = ColType.VARCHAR, width = 32)
@PrevInsert(uu32 = true)
private String id;
@Column
@Comment("供应商编码")
@ColDefine(type = ColType.VARCHAR, width = 64)
private String supplierId;
@Column
@Comment("订单ID")
@ColDefine(type = ColType.VARCHAR, width = 64)
private String orderId;
@Column
@Comment("用户ID")
@ColDefine(type = ColType.VARCHAR, width = 64)
private String userId;
@Column
@Comment("总价含税")
@ColDefine(type = ColType.FLOAT, width = 18, precision = 2)
private BigDecimal totalPrice;
@Column
@Comment("总价不含税")
@ColDefine(type = ColType.FLOAT, width = 18, precision = 2)
private BigDecimal invoiceNakedPrice;
@Column
@Comment("商品信息")
@ColDefine(type = ColType.TEXT)
private String productInfo;
@Column
@Comment("查询范围")
@ColDefine(type = ColType.VARCHAR, width = 200)
private String queryScope;
}
@@ -0,0 +1,101 @@
package com.budwk.app.zhgh.pointsmall.reconciliation.models;
import com.budwk.app.base.model.BaseModel;
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.nutz.dao.entity.annotation.*;
import org.nutz.dao.interceptor.annotation.PrevInsert;
import java.io.Serializable;
import java.math.BigDecimal;
@Data
@EqualsAndHashCode(callSuper = true)
@Table("points_mall_reconciliation_record")
@Comment("积分商城对账记录")
public class PointsMallReconciliationRecord extends BaseModel implements Serializable {
@Name
@Column
@Comment("ID")
@ColDefine(type = ColType.VARCHAR, width = 32)
@PrevInsert(uu32 = true)
private String id;
@Column
@Comment("供应商编码")
@ColDefine(type = ColType.VARCHAR, width = 64)
private String supplierId;
@Column
@Comment("订单ID")
@ColDefine(type = ColType.VARCHAR, width = 64)
private String orderId;
@Column
@Comment("用户ID")
@ColDefine(type = ColType.VARCHAR, width = 64)
private String userId;
@Column
@Comment("平台退款")
@ColDefine(type = ColType.FLOAT, width = 18, precision = 2)
private BigDecimal pRefund;
@Column
@Comment("平台订单总金额")
@ColDefine(type = ColType.FLOAT, width = 18, precision = 2)
private BigDecimal pTotalPrice;
@Column
@Comment("平台现金金额")
@ColDefine(type = ColType.FLOAT, width = 18, precision = 2)
private BigDecimal pCashAmount;
@Column
@Comment("平台消费积分")
@ColDefine(type = ColType.FLOAT, width = 18, precision = 2)
private BigDecimal pPointsPrice;
@Column
@Comment("供应商退款")
@ColDefine(type = ColType.FLOAT, width = 18, precision = 2)
private BigDecimal sRefund;
@Column
@Comment("供应商订单总金额")
@ColDefine(type = ColType.FLOAT, width = 18, precision = 2)
private BigDecimal sTotalPrice;
@Column
@Comment("供应商现金金额")
@ColDefine(type = ColType.FLOAT, width = 18, precision = 2)
private BigDecimal sCashAmount;
@Column
@Comment("供应商消费积分")
@ColDefine(type = ColType.FLOAT, width = 18, precision = 2)
private BigDecimal sPointsPrice;
@Column
@Comment("差异原因")
@ColDefine(type = ColType.VARCHAR, width = 1000)
private String diffReason;
@Column
@Comment("差异类型")
private Integer diffType;
@Column
@Comment("对账批次号")
@ColDefine(type = ColType.VARCHAR, width = 100)
private String batchNo;
@Column
@Comment("通知状态")
private Integer noticeStatus;
@Column
@Comment("推送次数")
private Integer pushTime;
}
@@ -0,0 +1,19 @@
package com.budwk.app.zhgh.pointsmall.reconciliation.param;
import com.budwk.app.base.param.PageForm;
import lombok.Data;
import lombok.EqualsAndHashCode;
@Data
@EqualsAndHashCode(callSuper = true)
public class PointsMallReconciliationOrderPageParam extends PageForm {
private String supplierId;
private String orderId;
private String userId;
private String startDate;
private String endDate;
private Integer reconciliationType;
private Integer reconciliationStatus;
private Integer invoiceStatus;
}
@@ -0,0 +1,13 @@
package com.budwk.app.zhgh.pointsmall.reconciliation.param;
import lombok.Data;
@Data
public class PointsMallReconciliationParam {
private String supplierId;
private Integer reconciliationType;
private String orderId;
private String startDate;
private String endDate;
}
@@ -0,0 +1,17 @@
package com.budwk.app.zhgh.pointsmall.reconciliation.param;
import com.budwk.app.base.param.PageForm;
import lombok.Data;
import lombok.EqualsAndHashCode;
@Data
@EqualsAndHashCode(callSuper = true)
public class PointsMallReconciliationRecordPageParam extends PageForm {
private String supplierId;
private String orderId;
private String userId;
private Integer diffType;
private String batchNo;
private Integer noticeStatus;
}
@@ -0,0 +1,26 @@
package com.budwk.app.zhgh.pointsmall.reconciliation.service;
import com.budwk.app.base.page.Pagination;
import com.budwk.app.base.service.BaseService;
import com.budwk.app.zhgh.pointsmall.reconciliation.models.PointsMallReconciliationRecord;
import com.budwk.app.zhgh.pointsmall.reconciliation.param.PointsMallReconciliationOrderPageParam;
import com.budwk.app.zhgh.pointsmall.reconciliation.param.PointsMallReconciliationParam;
import com.budwk.app.zhgh.pointsmall.reconciliation.param.PointsMallReconciliationRecordPageParam;
import com.budwk.app.zhgh.pointsmall.supplier.models.PointsMallSupplier;
import org.nutz.dao.entity.Record;
import java.math.BigDecimal;
import java.util.List;
public interface PointsMallReconciliationService extends BaseService<PointsMallReconciliationRecord> {
Pagination<Record> orderPage(PointsMallReconciliationOrderPageParam param);
BigDecimal pointsTotal(PointsMallReconciliationParam param);
String execute(PointsMallReconciliationParam param);
Pagination<Record> recordPage(PointsMallReconciliationRecordPageParam param);
List<PointsMallSupplier> listSuppliers();
}
@@ -0,0 +1,245 @@
package com.budwk.app.zhgh.pointsmall.reconciliation.service.impl;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.IdUtil;
import cn.hutool.core.util.StrUtil;
import com.budwk.app.base.page.Pagination;
import com.budwk.app.base.service.impl.BaseServiceImpl;
import com.budwk.app.zhgh.pointsmall.order.models.PointsMallOrderSub;
import com.budwk.app.zhgh.pointsmall.reconciliation.models.PointsMallReconciliationOrder;
import com.budwk.app.zhgh.pointsmall.reconciliation.models.PointsMallReconciliationRecord;
import com.budwk.app.zhgh.pointsmall.reconciliation.param.PointsMallReconciliationOrderPageParam;
import com.budwk.app.zhgh.pointsmall.reconciliation.param.PointsMallReconciliationParam;
import com.budwk.app.zhgh.pointsmall.reconciliation.param.PointsMallReconciliationRecordPageParam;
import com.budwk.app.zhgh.pointsmall.reconciliation.service.PointsMallReconciliationService;
import com.budwk.app.zhgh.pointsmall.supplier.models.PointsMallSupplier;
import org.nutz.dao.Chain;
import org.nutz.dao.Cnd;
import org.nutz.dao.Dao;
import org.nutz.dao.Sqls;
import org.nutz.dao.entity.Record;
import org.nutz.dao.sql.Sql;
import org.nutz.ioc.loader.annotation.IocBean;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Objects;
@IocBean(args = {"refer:dao"})
public class PointsMallReconciliationServiceImpl extends BaseServiceImpl<PointsMallReconciliationRecord> implements PointsMallReconciliationService {
public PointsMallReconciliationServiceImpl(Dao dao) {
super(dao);
}
@Override
public Pagination<Record> orderPage(PointsMallReconciliationOrderPageParam param) {
Cnd cnd = orderCnd(param, "o");
cnd.desc("o.orderCompleteTime").desc("o.orderCreateTime");
Sql sql = Sqls.create("select o.*, s.supplierName from points_mall_order_sub o left join points_mall_supplier s on o.supplierId = s.supplierId and s.delFlag = 0 $condition");
sql.setCondition(cnd);
return listPageMap(param.getPageNumber(), param.getPageSize(), sql);
}
@Override
public BigDecimal pointsTotal(PointsMallReconciliationParam param) {
checkReconciliationParam(param);
Sql sql = Sqls.create("select ifnull(sum(pointsPrice), 0) as totalPoints from points_mall_order_sub $condition");
sql.setCondition(reconciliationCnd(param, ""));
Record record = (Record) dao().execute(sql.setCallback(Sqls.callback.record())).getResult();
return record == null || record.get("totalPoints") == null ? BigDecimal.ZERO : new BigDecimal(record.get("totalPoints").toString());
}
@Override
public String execute(PointsMallReconciliationParam param) {
checkReconciliationParam(param);
List<PointsMallOrderSub> orders = dao().query(PointsMallOrderSub.class, reconciliationCnd(param, ""));
if (CollUtil.isEmpty(orders)) {
return "未查询到待对账订单";
}
String batchNo = DateUtil.format(new Date(), "yyyyMMddHHmmss") + IdUtil.fastSimpleUUID().substring(0, 6);
int success = 0;
int exception = 0;
List<PointsMallReconciliationRecord> records = new ArrayList<>();
for (PointsMallOrderSub order : orders) {
PointsMallReconciliationOrder supplierOrder = dao().fetch(PointsMallReconciliationOrder.class,
Cnd.where("orderId", "=", order.getOrderId())
.and("supplierId", "=", order.getSupplierId())
.and("delFlag", "=", false));
PointsMallReconciliationRecord record = buildRecord(order, supplierOrder, batchNo);
if (record.getDiffType() == null || record.getDiffType() == 0) {
success++;
dao().update(PointsMallOrderSub.class, Chain.make("reconciliationStatus", 1), Cnd.where("id", "=", order.getId()));
} else {
exception++;
dao().update(PointsMallOrderSub.class, Chain.make("reconciliationStatus", 2), Cnd.where("id", "=", order.getId()));
}
records.add(record);
}
dao().insert(records);
return "对账完成,批次号:" + batchNo + ",成功:" + success + ",异常:" + exception;
}
@Override
public Pagination<Record> recordPage(PointsMallReconciliationRecordPageParam param) {
Cnd cnd = Cnd.where("r.delFlag", "=", false);
if (StrUtil.isNotBlank(param.getSupplierId())) {
cnd.and("r.supplierId", "=", param.getSupplierId());
}
if (StrUtil.isNotBlank(param.getOrderId())) {
cnd.and("r.orderId", "like", "%" + param.getOrderId() + "%");
}
if (StrUtil.isNotBlank(param.getUserId())) {
cnd.and("r.userId", "like", "%" + param.getUserId() + "%");
}
if (param.getDiffType() != null) {
cnd.and("r.diffType", "=", param.getDiffType());
}
if (StrUtil.isNotBlank(param.getBatchNo())) {
cnd.and("r.batchNo", "like", "%" + param.getBatchNo() + "%");
}
if (param.getNoticeStatus() != null) {
cnd.and("r.noticeStatus", "=", param.getNoticeStatus());
}
cnd.desc("r.createdAt");
Sql sql = Sqls.create("select r.*, s.supplierName from points_mall_reconciliation_record r left join points_mall_supplier s on r.supplierId = s.supplierId and s.delFlag = 0 $condition");
sql.setCondition(cnd);
return listPageMap(param.getPageNumber(), param.getPageSize(), sql);
}
@Override
public List<PointsMallSupplier> listSuppliers() {
return dao().query(PointsMallSupplier.class, Cnd.where("delFlag", "=", false).asc("sortCode"));
}
private Cnd orderCnd(PointsMallReconciliationOrderPageParam param, String alias) {
Cnd cnd = Cnd.where(field(alias, "delFlag"), "=", false);
if (StrUtil.isNotBlank(param.getSupplierId())) {
cnd.and(field(alias, "supplierId"), "=", param.getSupplierId());
}
if (StrUtil.isNotBlank(param.getOrderId())) {
List<String> orderIds = StrUtil.splitTrim(param.getOrderId(), ",");
if (orderIds.size() > 1) {
cnd.and(field(alias, "orderId"), "in", orderIds);
} else {
cnd.and(field(alias, "orderId"), "like", "%" + param.getOrderId() + "%");
}
}
if (StrUtil.isNotBlank(param.getUserId())) {
cnd.and(field(alias, "userId"), "like", "%" + param.getUserId() + "%");
}
if (param.getReconciliationStatus() != null) {
cnd.and(field(alias, "reconciliationStatus"), "=", param.getReconciliationStatus());
}
if (param.getInvoiceStatus() != null) {
cnd.and(field(alias, "invoiceStatus"), "=", param.getInvoiceStatus());
}
addDateRange(cnd, alias, param.getStartDate(), param.getEndDate());
return cnd;
}
private Cnd reconciliationCnd(PointsMallReconciliationParam param, String alias) {
Cnd cnd = Cnd.where(field(alias, "delFlag"), "=", false);
cnd.and(field(alias, "supplierId"), "=", param.getSupplierId());
if (param.getReconciliationType() != null && param.getReconciliationType() == 2) {
cnd.and(field(alias, "reconciliationStatus"), "=", 2);
} else {
cnd.and(field(alias, "reconciliationStatus"), "=", 0);
}
if (StrUtil.isNotBlank(param.getOrderId())) {
List<String> orderIds = StrUtil.splitTrim(param.getOrderId(), ",");
if (orderIds.size() > 1) {
cnd.and(field(alias, "orderId"), "in", orderIds);
} else {
cnd.and(field(alias, "orderId"), "like", "%" + param.getOrderId() + "%");
}
}
addDateRange(cnd, alias, param.getStartDate(), param.getEndDate());
return cnd;
}
private void addDateRange(Cnd cnd, String alias, String startDate, String endDate) {
if (StrUtil.isNotBlank(startDate)) {
cnd.and(field(alias, "orderCompleteTime"), ">=", DateUtil.beginOfDay(DateUtil.parse(startDate)));
}
if (StrUtil.isNotBlank(endDate)) {
cnd.and(field(alias, "orderCompleteTime"), "<=", DateUtil.endOfDay(DateUtil.parse(endDate)));
}
}
private String field(String alias, String field) {
return StrUtil.isBlank(alias) ? field : alias + "." + field;
}
private void checkReconciliationParam(PointsMallReconciliationParam param) {
if (param == null) {
throw new IllegalArgumentException("对账参数不能为空");
}
if (StrUtil.isBlank(param.getSupplierId())) {
throw new IllegalArgumentException("供应商不能为空");
}
if (param.getReconciliationType() == null) {
throw new IllegalArgumentException("对账类型不能为空");
}
if (StrUtil.isBlank(param.getStartDate()) || StrUtil.isBlank(param.getEndDate())) {
throw new IllegalArgumentException("对账日期不能为空");
}
}
private PointsMallReconciliationRecord buildRecord(PointsMallOrderSub order, PointsMallReconciliationOrder supplierOrder, String batchNo) {
PointsMallReconciliationRecord record = new PointsMallReconciliationRecord();
record.setSupplierId(order.getSupplierId());
record.setOrderId(order.getOrderId());
record.setUserId(order.getUserId());
record.setPRefund(nullToZero(order.getRefund()));
record.setPTotalPrice(nullToZero(order.getTotalPrice()));
record.setPCashAmount(nullToZero(order.getWPayOrAPay()));
record.setPPointsPrice(nullToZero(order.getPointsPrice()));
record.setBatchNo(batchNo);
record.setNoticeStatus(0);
record.setPushTime(0);
if (supplierOrder == null) {
record.setSRefund(BigDecimal.ZERO);
record.setSTotalPrice(record.getPTotalPrice());
record.setSCashAmount(record.getPCashAmount());
record.setSPointsPrice(record.getPPointsPrice());
record.setDiffType(0);
record.setDiffReason("未获取到供应商侧对账订单,按平台订单确认");
return record;
}
record.setSRefund(BigDecimal.ZERO);
record.setSTotalPrice(nullToZero(supplierOrder.getTotalPrice()));
record.setSCashAmount(BigDecimal.ZERO);
record.setSPointsPrice(nullToZero(supplierOrder.getTotalPrice()));
List<String> reasons = new ArrayList<>();
if (!amountEquals(record.getPTotalPrice(), record.getSTotalPrice())) {
reasons.add("订单总金额不一致");
}
if (!amountEquals(record.getPPointsPrice(), record.getSPointsPrice())) {
reasons.add("积分金额不一致");
}
if (!Objects.equals(order.getUserId(), supplierOrder.getUserId())) {
reasons.add("用户ID不一致");
}
record.setDiffType(reasons.isEmpty() ? 0 : 1);
record.setDiffReason(reasons.isEmpty() ? "对账一致" : String.join("", reasons));
return record;
}
private BigDecimal nullToZero(BigDecimal value) {
return value == null ? BigDecimal.ZERO : value;
}
private boolean amountEquals(BigDecimal left, BigDecimal right) {
return nullToZero(left).compareTo(nullToZero(right)) == 0;
}
}
@@ -0,0 +1,448 @@
<!--#
layout("/layouts/platform.html"){
#-->
<div id="app" v-cloak>
<el-card shadow="never">
<search @search="doSearch">
<search-item label="供应商">
<el-select clearable filterable placeholder="请选择供应商" style="width: 100%" v-model="pageForm.supplierId">
<el-option :key="item.supplierId" :label="item.supplierName" :value="item.supplierId" v-for="item in supplierList"></el-option>
</el-select>
</search-item>
<search-item label="订单ID">
<el-input clearable placeholder="多个订单ID用英文逗号分隔" v-model="pageForm.orderId"></el-input>
</search-item>
<search-item label="用户ID">
<el-input clearable placeholder="请输入用户ID" v-model="pageForm.userId"></el-input>
</search-item>
<search-item label="起始日期">
<el-date-picker clearable placeholder="开始日期" style="width: 100%" type="date" value-format="yyyy-MM-dd" v-model="pageForm.startDate"></el-date-picker>
</search-item>
<search-item label="结束日期">
<el-date-picker clearable placeholder="结束日期" style="width: 100%" type="date" value-format="yyyy-MM-dd" v-model="pageForm.endDate"></el-date-picker>
</search-item>
<search-item label="对账状态">
<el-select clearable placeholder="请选择对账状态" style="width: 100%" v-model="pageForm.reconciliationStatus">
<el-option :key="item.value" :label="item.label" :value="item.value" v-for="item in reconciliationStatusOptions"></el-option>
</el-select>
</search-item>
<search-item label="发票状态">
<el-select clearable placeholder="请选择发票状态" style="width: 100%" v-model="pageForm.invoiceStatus">
<el-option :key="item.value" :label="item.label" :value="item.value" v-for="item in invoiceStatusOptions"></el-option>
</el-select>
</search-item>
</search>
</el-card>
<el-card class="mt10" shadow="never">
<table-tool label="对账订单列表">
<el-button @click="openReconcileDialog" size="mini" type="success">对账</el-button>
<el-button @click="openRecordDialog" size="mini" type="primary">对账记录</el-button>
</table-tool>
<el-table :data="tableData" border class="vi-table" size="small" style="width: 100%" v-loading="tableLoading">
<el-table-column :index="indexMethod" align="center" label="序号" type="index" width="70"></el-table-column>
<el-table-column align="center" label="订单ID" min-width="170" prop="orderId" show-overflow-tooltip></el-table-column>
<el-table-column align="center" label="供应商" min-width="150" prop="supplierName" show-overflow-tooltip></el-table-column>
<el-table-column align="center" label="供应商编码" min-width="120" prop="supplierId" show-overflow-tooltip></el-table-column>
<el-table-column align="center" label="用户ID" min-width="120" prop="userId" show-overflow-tooltip></el-table-column>
<el-table-column align="center" label="下单时间" min-width="160" prop="orderCreateTime" show-overflow-tooltip></el-table-column>
<el-table-column align="center" label="完成时间" min-width="160" prop="orderCompleteTime" show-overflow-tooltip></el-table-column>
<el-table-column align="center" label="订单状态" min-width="110">
<template slot-scope="{row}">
<el-tag :type="orderStatusType(row.orderState)" size="mini">{{ orderStateName(row.orderState) }}</el-tag>
</template>
</el-table-column>
<el-table-column align="center" label="对账状态" min-width="110">
<template slot-scope="{row}">
<el-tag :type="reconciliationStatusType(row.reconciliationStatus)" size="mini">{{ reconciliationStatusName(row.reconciliationStatus) }}</el-tag>
</template>
</el-table-column>
<el-table-column align="center" label="发票状态" min-width="110">
<template slot-scope="{row}">
<el-tag :type="invoiceStatusType(row.invoiceStatus)" size="mini">{{ invoiceStatusName(row.invoiceStatus) }}</el-tag>
</template>
</el-table-column>
<el-table-column align="center" label="订单总金额" min-width="110" prop="totalPrice"></el-table-column>
<el-table-column align="center" label="现金金额" min-width="110" prop="wPayOrAPay"></el-table-column>
<el-table-column align="center" label="积分金额" min-width="110" prop="pointsPrice"></el-table-column>
<el-table-column align="center" label="退款积分" min-width="110" prop="refund"></el-table-column>
<el-table-column align="center" label="发票代码" min-width="130" prop="invoiceCode" show-overflow-tooltip></el-table-column>
<el-table-column align="center" fixed="right" label="操作" width="90">
<template slot-scope="{row}">
<el-button @click="showOrderDetail(row)" size="mini">详情</el-button>
</template>
</el-table-column>
</el-table>
<el-pagination
:current-page="pageForm.pageNumber"
:page-size="pageForm.pageSize"
:page-sizes="[10, 20, 30, 50]"
:total="pageForm.totalCount"
@current-change="pageChange"
@size-change="sizeChange"
layout="total, sizes, prev, pager, next"
style="margin-top: 16px; text-align: right"
></el-pagination>
</el-card>
<el-dialog :close-on-click-modal="false" title="确认对账" :visible.sync="reconcileDialogVisible" width="480px">
<el-form label-width="100px" size="small">
<el-form-item label="供应商">
<el-select clearable filterable placeholder="请选择供应商" style="width: 100%" v-model="reconcileForm.supplierId">
<el-option :key="item.supplierId" :label="item.supplierName" :value="item.supplierId" v-for="item in supplierList"></el-option>
</el-select>
</el-form-item>
<el-form-item label="对账类型">
<el-select placeholder="请选择对账类型" style="width: 100%" v-model="reconcileForm.reconciliationType">
<el-option label="正常订单对账" :value="1"></el-option>
<el-option label="历史异常订单对账" :value="2"></el-option>
</el-select>
</el-form-item>
<el-form-item label="起始日期">
<el-date-picker placeholder="开始日期" style="width: 100%" type="date" value-format="yyyy-MM-dd" v-model="reconcileForm.startDate"></el-date-picker>
</el-form-item>
<el-form-item label="结束日期">
<el-date-picker placeholder="结束日期" style="width: 100%" type="date" value-format="yyyy-MM-dd" v-model="reconcileForm.endDate"></el-date-picker>
</el-form-item>
<el-form-item label="订单ID">
<el-input clearable placeholder="多个订单ID用英文逗号分隔" v-model="reconcileForm.orderId"></el-input>
</el-form-item>
<el-form-item label="积分合计">
<span>{{ reconcilePointsTotal }}</span>
</el-form-item>
</el-form>
<el-alert :closable="false" show-icon title="确认后订单将更新为已对账或对账异常,并生成对账记录。" type="warning"></el-alert>
<span slot="footer">
<el-button @click="reconcileDialogVisible = false">取消</el-button>
<el-button @click="loadPointsTotal" :loading="pointsTotalLoading">计算金额</el-button>
<el-button @click="executeReconciliation" :loading="executeLoading" type="primary">确认对账</el-button>
</span>
</el-dialog>
<el-dialog :close-on-click-modal="false" title="对账记录" :visible.sync="recordDialogVisible" top="5vh" width="90%">
<el-form :inline="true" size="small" @submit.native.prevent>
<el-form-item label="供应商">
<el-select clearable filterable placeholder="供应商" style="width: 180px" v-model="recordForm.supplierId">
<el-option :key="item.supplierId" :label="item.supplierName" :value="item.supplierId" v-for="item in supplierList"></el-option>
</el-select>
</el-form-item>
<el-form-item label="订单ID">
<el-input clearable placeholder="订单ID" v-model="recordForm.orderId"></el-input>
</el-form-item>
<el-form-item label="用户ID">
<el-input clearable placeholder="用户ID" v-model="recordForm.userId"></el-input>
</el-form-item>
<el-form-item label="批次号">
<el-input clearable placeholder="批次号" v-model="recordForm.batchNo"></el-input>
</el-form-item>
<el-form-item label="差异类型">
<el-select clearable placeholder="差异类型" style="width: 130px" v-model="recordForm.diffType">
<el-option label="一致" :value="0"></el-option>
<el-option label="金额异常" :value="1"></el-option>
</el-select>
</el-form-item>
<el-form-item>
<el-button @click="recordSearch" type="primary">查询</el-button>
<el-button @click="recordReset">重置</el-button>
</el-form-item>
</el-form>
<el-table :data="recordList" border size="small" style="width: 100%" v-loading="recordLoading">
<el-table-column :index="recordIndexMethod" align="center" label="序号" type="index" width="70"></el-table-column>
<el-table-column align="center" label="批次号" min-width="160" prop="batchNo" show-overflow-tooltip></el-table-column>
<el-table-column align="center" label="订单ID" min-width="160" prop="orderId" show-overflow-tooltip></el-table-column>
<el-table-column align="center" label="供应商" min-width="140" prop="supplierName" show-overflow-tooltip></el-table-column>
<el-table-column align="center" label="用户ID" min-width="110" prop="userId" show-overflow-tooltip></el-table-column>
<el-table-column align="center" label="平台总金额" min-width="110" prop="pTotalPrice"></el-table-column>
<el-table-column align="center" label="供应商总金额" min-width="120" prop="sTotalPrice"></el-table-column>
<el-table-column align="center" label="平台积分" min-width="100" prop="pPointsPrice"></el-table-column>
<el-table-column align="center" label="供应商积分" min-width="110" prop="sPointsPrice"></el-table-column>
<el-table-column align="center" label="差异类型" min-width="100">
<template slot-scope="{row}">
<el-tag :type="row.diffType === 0 ? 'success' : 'danger'" size="mini">{{ diffTypeName(row.diffType) }}</el-tag>
</template>
</el-table-column>
<el-table-column align="center" label="差异原因" min-width="220" prop="diffReason" show-overflow-tooltip></el-table-column>
</el-table>
<el-pagination
:current-page="recordForm.pageNumber"
:page-size="recordForm.pageSize"
:page-sizes="[10, 20, 30, 50]"
:total="recordForm.totalCount"
@current-change="recordPageChange"
@size-change="recordSizeChange"
layout="total, sizes, prev, pager, next"
style="margin-top: 16px; text-align: right"
></el-pagination>
<span slot="footer">
<el-button @click="recordDialogVisible = false">关闭</el-button>
</span>
</el-dialog>
<el-dialog :close-on-click-modal="false" title="订单详情" :visible.sync="detailDialogVisible" width="760px">
<el-descriptions :column="2" border size="small" v-if="currentOrder">
<el-descriptions-item label="订单ID">{{ currentOrder.orderId || "-" }}</el-descriptions-item>
<el-descriptions-item label="订单编码">{{ currentOrder.orderNumberId || "-" }}</el-descriptions-item>
<el-descriptions-item label="供应商">{{ currentOrder.supplierName || currentOrder.supplierId || "-" }}</el-descriptions-item>
<el-descriptions-item label="用户ID">{{ currentOrder.userId || "-" }}</el-descriptions-item>
<el-descriptions-item label="下单时间">{{ currentOrder.orderCreateTime || "-" }}</el-descriptions-item>
<el-descriptions-item label="完成时间">{{ currentOrder.orderCompleteTime || "-" }}</el-descriptions-item>
<el-descriptions-item label="订单总金额">{{ currentOrder.totalPrice || "0" }}</el-descriptions-item>
<el-descriptions-item label="现金金额">{{ currentOrder.wPayOrAPay || "0" }}</el-descriptions-item>
<el-descriptions-item label="积分金额">{{ currentOrder.pointsPrice || "0" }}</el-descriptions-item>
<el-descriptions-item label="退款积分">{{ currentOrder.refund || "0" }}</el-descriptions-item>
<el-descriptions-item label="物流单号">{{ currentOrder.logisticsOrderId || "-" }}</el-descriptions-item>
<el-descriptions-item label="承运商">{{ currentOrder.crrgBsnNm || "-" }}</el-descriptions-item>
</el-descriptions>
<span slot="footer">
<el-button @click="detailDialogVisible = false">关闭</el-button>
</span>
</el-dialog>
</div>
<script nonce="${cspNonce!}">
new Vue({
el: "#app",
mixins: [initTableMixins],
data() {
return {
supplierList: [],
tableData: [],
tableLoading: false,
pageForm: {
pageNumber: 1,
pageSize: 10,
totalCount: 0,
supplierId: null,
orderId: null,
userId: null,
startDate: null,
endDate: null,
reconciliationStatus: null,
invoiceStatus: null
},
reconcileDialogVisible: false,
reconcilePointsTotal: 0,
pointsTotalLoading: false,
executeLoading: false,
reconcileForm: {
supplierId: null,
reconciliationType: 1,
orderId: null,
startDate: null,
endDate: null
},
recordDialogVisible: false,
recordLoading: false,
recordList: [],
recordForm: {
pageNumber: 1,
pageSize: 10,
totalCount: 0,
supplierId: null,
orderId: null,
userId: null,
batchNo: null,
diffType: null,
noticeStatus: null
},
detailDialogVisible: false,
currentOrder: null,
reconciliationStatusOptions: [
{ value: 0, label: "未对账" },
{ value: 1, label: "已对账" },
{ value: 2, label: "对账异常" }
],
invoiceStatusOptions: [
{ value: 0, label: "未开票" },
{ value: 1, label: "已开票" },
{ value: 2, label: "开票中" }
],
orderStateOptions: [
{ value: 0, label: "待付款" },
{ value: 1, label: "已支付" },
{ value: 2, label: "进行中" },
{ value: 3, label: "已取消" },
{ value: 4, label: "已签收" },
{ value: 5, label: "已完成" },
{ value: 6, label: "换货" },
{ value: 7, label: "退货" },
{ value: 8, label: "已废除" }
]
}
},
methods: {
indexMethod(index) {
return index + 1 + (this.pageForm.pageNumber - 1) * this.pageForm.pageSize
},
recordIndexMethod(index) {
return index + 1 + (this.recordForm.pageNumber - 1) * this.recordForm.pageSize
},
doSearch() {
this.pageForm.pageNumber = 1
this.pageData()
},
async pageData() {
this.tableLoading = true
const resp = await this.$axios.post(loc() + "/pageData", this.pageForm)
this.tableLoading = false
if (resp.code === 0) {
this.tableData = resp.data.list || []
this.pageForm.totalCount = resp.data.totalCount || 0
} else {
this.notifyWarning(resp.msg)
}
},
pageChange(val) {
this.pageForm.pageNumber = val
this.pageData()
},
sizeChange(val) {
this.pageForm.pageSize = val
this.pageForm.pageNumber = 1
this.pageData()
},
async loadSuppliers() {
const resp = await this.$axios.post(loc() + "/supplierList")
if (resp.code === 0) {
this.supplierList = resp.data || []
}
},
openReconcileDialog() {
this.reconcileForm = {
supplierId: this.pageForm.supplierId,
reconciliationType: this.pageForm.reconciliationStatus === 2 ? 2 : 1,
orderId: this.pageForm.orderId,
startDate: this.pageForm.startDate,
endDate: this.pageForm.endDate
}
this.reconcilePointsTotal = 0
this.reconcileDialogVisible = true
this.loadPointsTotal()
},
async loadPointsTotal() {
if (!this.reconcileForm.supplierId || !this.reconcileForm.startDate || !this.reconcileForm.endDate || !this.reconcileForm.reconciliationType) {
this.notifyWarning("请先选择供应商、对账类型和对账日期")
return
}
this.pointsTotalLoading = true
const resp = await this.$axios.post(loc() + "/pointsTotal", this.reconcileForm)
this.pointsTotalLoading = false
if (resp.code === 0) {
this.reconcilePointsTotal = resp.data || 0
} else {
this.notifyWarning(resp.msg)
}
},
async executeReconciliation() {
if (!this.reconcileForm.supplierId || !this.reconcileForm.startDate || !this.reconcileForm.endDate || !this.reconcileForm.reconciliationType) {
this.notifyWarning("请先选择供应商、对账类型和对账日期")
return
}
this.executeLoading = true
const resp = await this.$axios.post(loc() + "/execute", this.reconcileForm)
this.executeLoading = false
if (resp.code === 0) {
this.notifySuccess(resp.data || "对账完成")
this.reconcileDialogVisible = false
this.pageData()
} else {
this.notifyWarning(resp.msg)
}
},
openRecordDialog() {
this.recordDialogVisible = true
this.recordForm.supplierId = this.pageForm.supplierId
this.recordForm.orderId = this.pageForm.orderId
this.recordPageData()
},
recordSearch() {
this.recordForm.pageNumber = 1
this.recordPageData()
},
recordReset() {
this.recordForm = {
pageNumber: 1,
pageSize: 10,
totalCount: 0,
supplierId: null,
orderId: null,
userId: null,
batchNo: null,
diffType: null,
noticeStatus: null
}
this.recordPageData()
},
async recordPageData() {
this.recordLoading = true
const resp = await this.$axios.post(loc() + "/recordPage", this.recordForm)
this.recordLoading = false
if (resp.code === 0) {
this.recordList = resp.data.list || []
this.recordForm.totalCount = resp.data.totalCount || 0
} else {
this.notifyWarning(resp.msg)
}
},
recordPageChange(val) {
this.recordForm.pageNumber = val
this.recordPageData()
},
recordSizeChange(val) {
this.recordForm.pageSize = val
this.recordForm.pageNumber = 1
this.recordPageData()
},
showOrderDetail(row) {
this.currentOrder = row
this.detailDialogVisible = true
},
reconciliationStatusName(value) {
const item = this.reconciliationStatusOptions.find((v) => String(v.value) === String(value))
return item ? item.label : "-"
},
reconciliationStatusType(value) {
const map = { 0: "info", 1: "success", 2: "danger" }
return map[value] || "info"
},
invoiceStatusName(value) {
const item = this.invoiceStatusOptions.find((v) => String(v.value) === String(value))
return item ? item.label : "-"
},
invoiceStatusType(value) {
const map = { 0: "info", 1: "success", 2: "warning" }
return map[value] || "info"
},
orderStateName(value) {
const item = this.orderStateOptions.find((v) => String(v.value) === String(value))
return item ? item.label : "-"
},
orderStatusType(value) {
const map = {
0: "info",
1: "primary",
2: "warning",
3: "danger",
4: "primary",
5: "success",
6: "warning",
7: "danger",
8: "info"
}
return map[value] || "info"
},
diffTypeName(value) {
return Number(value) === 0 ? "一致" : "异常"
}
},
created() {
this.loadSuppliers()
this.pageData()
}
})
</script>
<!--#
}
#-->