diff --git a/src/main/java/com/budwk/app/zhgh/pointsmall/invoice/param/PointsMallInvoiceApplyParam.java b/src/main/java/com/budwk/app/zhgh/pointsmall/invoice/param/PointsMallInvoiceApplyParam.java index 62c63f96..5240d5b1 100644 --- a/src/main/java/com/budwk/app/zhgh/pointsmall/invoice/param/PointsMallInvoiceApplyParam.java +++ b/src/main/java/com/budwk/app/zhgh/pointsmall/invoice/param/PointsMallInvoiceApplyParam.java @@ -11,7 +11,7 @@ public class PointsMallInvoiceApplyParam { private String endDate; private String invoiceDate; private String invoiceTitle; - private String invoiceCode; + private String taxIdNumber; private String invoiceAddress; private String invoiceContact; private Integer invoiceType; diff --git a/src/main/java/com/budwk/app/zhgh/pointsmall/invoice/service/impl/PointsMallInvoiceServiceImpl.java b/src/main/java/com/budwk/app/zhgh/pointsmall/invoice/service/impl/PointsMallInvoiceServiceImpl.java index 2ea00da8..808122d9 100644 --- a/src/main/java/com/budwk/app/zhgh/pointsmall/invoice/service/impl/PointsMallInvoiceServiceImpl.java +++ b/src/main/java/com/budwk/app/zhgh/pointsmall/invoice/service/impl/PointsMallInvoiceServiceImpl.java @@ -6,13 +6,15 @@ import cn.hutool.core.util.RandomUtil; 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.invoice.models.PointsMallInvoiceInfo; import com.budwk.app.zhgh.pointsmall.invoice.models.PointsMallInvoiceMain; import com.budwk.app.zhgh.pointsmall.invoice.param.PointsMallInvoiceApplyParam; import com.budwk.app.zhgh.pointsmall.invoice.param.PointsMallInvoiceInfoPageParam; import com.budwk.app.zhgh.pointsmall.invoice.param.PointsMallInvoiceMainPageParam; import com.budwk.app.zhgh.pointsmall.invoice.param.PointsMallInvoiceOrderPageParam; import com.budwk.app.zhgh.pointsmall.invoice.service.PointsMallInvoiceService; +import com.budwk.app.zhgh.pointsmall.mallbridge.dto.MallInvoiceApplyDTO; +import com.budwk.app.zhgh.pointsmall.mallbridge.model.MallOutboundResult; +import com.budwk.app.zhgh.pointsmall.mallbridge.service.MallInvoiceApplyOutboundService; import com.budwk.app.zhgh.pointsmall.order.models.PointsMallOrderSub; import com.budwk.app.zhgh.pointsmall.supplier.models.PointsMallSupplier; import org.nutz.dao.Chain; @@ -21,6 +23,7 @@ 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.Inject; import org.nutz.ioc.loader.annotation.IocBean; import java.math.BigDecimal; @@ -30,6 +33,9 @@ import java.util.stream.Collectors; @IocBean(args = {"refer:dao"}) public class PointsMallInvoiceServiceImpl extends BaseServiceImpl implements PointsMallInvoiceService { + @Inject + private MallInvoiceApplyOutboundService mallInvoiceApplyOutboundService; + public PointsMallInvoiceServiceImpl(Dao dao) { super(dao); } @@ -38,7 +44,7 @@ public class PointsMallInvoiceServiceImpl extends BaseServiceImpl mainPage(PointsMallInvoiceMainPageParam param) { Cnd cnd = Cnd.where("delFlag", "=", false); if (StrUtil.isNotBlank(param.getSettlementId())) { - cnd.and("settlementId", "like", "%" + param.getSettlementId() + "%"); + cnd.and("settlementId", "=", param.getSettlementId()); } if (param.getBSuccess() != null) { cnd.and("bSuccess", "=", param.getBSuccess()); @@ -63,10 +69,10 @@ public class PointsMallInvoiceServiceImpl extends BaseServiceImpl orderIds = splitIds(dto.getOrderIds()); - log.info("积分商城开票申请开始,supplierId={},settlementId={},orderCount={}", dto.getSupplierId(), dto.getSettlementId(), orderIds.size()); - List orders = dao.query(PointsMallOrderSub.class, Cnd.where("supplierId", "=", dto.getSupplierId()) - .and("orderId", "in", orderIds).and("delFlag", "=", false)); - if (orders.isEmpty()) { - return MallOutboundResult.fail(404, "未找到可开票订单"); + String clientBAB7ServerUrl = conf.get("spdb.bab7.url", ""); + if (StrUtil.isBlank(clientBAB7ServerUrl)) { + return MallOutboundResult.fail(500, "未配置 BAB7 服务地址"); } - if (dto.getOrderNum() != null && dto.getOrderNum() != orders.size()) { - return MallOutboundResult.fail(400, "订单数量与开票申请不一致"); + PointsMallSupplier supplier = dao.fetch(PointsMallSupplier.class, + Cnd.where("supplierId", "=", dto.getSupplierId()).and("delFlag", "=", false)); + if (supplier == null) { + return MallOutboundResult.fail(404, "未找到对应供应商信息"); } - BigDecimal total = orders.stream().map(PointsMallOrderSub::getTotalPrice).filter(Objects::nonNull).reduce(BigDecimal.ZERO, BigDecimal::add); - if (dto.getOrderTotalPrice() != null && total.compareTo(dto.getOrderTotalPrice()) != 0) { - return MallOutboundResult.fail(400, "订单金额与开票申请不一致"); + if (StrUtil.isBlank(supplier.getSupplierApiUrl())) { + return MallOutboundResult.fail(404, "供应商地址未配置"); } - Trans.exec((Atom) () -> saveInvoiceApply(dto, orderIds, total)); - log.info("积分商城开票申请完成,supplierId={},settlementId={}", dto.getSupplierId(), dto.getSettlementId()); - return MallOutboundResult.success(); - } + long timestamp = System.currentTimeMillis(); + dto.setToken(MallBridgeCryptoUtil.generateSign(supplier.getSupplierId(), supplier.getClientId(), timestamp)); + dto.setTimestamp(timestamp); - private void saveInvoiceApply(MallInvoiceApplyDTO dto, List orderIds, BigDecimal total) { - PointsMallInvoiceMain main = dao.fetch(PointsMallInvoiceMain.class, Cnd.where("settlementId", "=", dto.getSettlementId()).and("delFlag", "=", false)); - if (main == null) { - main = new PointsMallInvoiceMain(); - main.setSettlementId(dto.getSettlementId()); - main.setBSuccess(0); - main.setSucOrderIds(String.join(",", orderIds)); - main.setFailOrderIds(""); - main.setFailMsg(""); - dao.insert(main); - } else { - main.setBSuccess(0); - main.setSucOrderIds(String.join(",", orderIds)); - main.setFailOrderIds(""); - main.setFailMsg(""); - dao.updateIgnoreNull(main); + String keyHex = conf.get("sm4cbc.keyHex", ""); + String ivHex = conf.get("sm4cbc.ivHex", ""); + String encrypt; + try { + encrypt = MallBridgeCryptoUtil.sm4CbcEncrypt(JSONUtil.toJsonStr(dto), keyHex, ivHex); + } catch (Exception e) { + log.error("9.2.5 发票开具申请接口请求参数 SM4CBC 加密出错", e); + return MallOutboundResult.fail(500, "发票开具申请参数加密失败"); } - PointsMallInvoiceInfo info = new PointsMallInvoiceInfo(); - info.setMainId(main.getId()); - info.setInvoiceId(dto.getSettlementId()); - info.setInvoiceCode(dto.getInvoiceCode()); - info.setInvoiceDate(parseDate(dto.getInvoiceDate())); - info.setInvoiceNakeAmount(nvl(dto.getInvoiceNakedPrice(), total)); - info.setInvoiceTaxAmount(nvl(dto.getInvoiceTaxPrice(), BigDecimal.ZERO)); - info.setInvoiceAmount(total); - info.setInvoiceType(Convert.toInt(dto.getInvoiceType(), null)); - info.setInvoiceAddress(dto.getInvoiceAddress()); - info.setInvoiceContact(dto.getInvoiceContact()); - info.setInvoiceContent(dto.getInvoiceContent()); - info.setInvoiceBank(dto.getBankName()); - info.setInvoiceAccount(dto.getBankAccount()); - info.setTaxIdNumber(dto.getInvoiceCode()); - info.setRemark(dto.getRemark()); - dao.insert(info); + HashMap bodyMap = new HashMap<>(); + bodyMap.put("Address4", supplier.getSupplierApiUrl() + "/supplierOpenApi/pointOrder/applyForInvoices"); + bodyMap.put("BussDealMd", "P"); + bodyMap.put("SroNo", supplier.getSroNo()); + bodyMap.put("RsrvFld1", supplier.getClientId()); + bodyMap.put("AplParmObjct", encrypt); - dao.update(PointsMallOrderSub.class, Chain.make("invoiceStatus", 2).add("invoiceCode", dto.getSettlementId()), - Cnd.where("supplierId", "=", dto.getSupplierId()).and("orderId", "in", orderIds)); + String response = HttpUtil.createPost(clientBAB7ServerUrl) + .contentType("application/json;charset=UTF-8") + .body(JSONUtil.toJsonStr(bodyMap)) + .execute() + .body(); + if (StrUtil.isBlank(response)) { + return MallOutboundResult.fail(502, "供应商开票申请无响应"); + } + return JSONUtil.toBean(response, MallOutboundResult.class); } } diff --git a/src/main/java/com/budwk/app/zhgh/pointsmall/mallbridge/service/MallInvoiceInfoQueryService.java b/src/main/java/com/budwk/app/zhgh/pointsmall/mallbridge/service/MallInvoiceInfoQueryService.java index 656571f0..50aabaad 100644 --- a/src/main/java/com/budwk/app/zhgh/pointsmall/mallbridge/service/MallInvoiceInfoQueryService.java +++ b/src/main/java/com/budwk/app/zhgh/pointsmall/mallbridge/service/MallInvoiceInfoQueryService.java @@ -1,19 +1,22 @@ package com.budwk.app.zhgh.pointsmall.mallbridge.service; import cn.hutool.core.util.StrUtil; -import com.budwk.app.zhgh.pointsmall.invoice.models.PointsMallInvoiceInfo; -import com.budwk.app.zhgh.pointsmall.invoice.models.PointsMallInvoiceMain; +import cn.hutool.http.HttpUtil; +import cn.hutool.json.JSONObject; +import cn.hutool.json.JSONUtil; import com.budwk.app.zhgh.pointsmall.mallbridge.dto.GetInvoiceInfoDTO; -import com.budwk.app.zhgh.pointsmall.mallbridge.dto.InvoiceInfoDTO; import com.budwk.app.zhgh.pointsmall.mallbridge.dto.QueryInvoiceInfoDTO; import com.budwk.app.zhgh.pointsmall.mallbridge.service.support.AbstractMallBridgeSupport; +import com.budwk.app.zhgh.pointsmall.mallbridge.util.MallBridgeCryptoUtil; +import com.budwk.app.zhgh.pointsmall.supplier.models.PointsMallSupplier; import lombok.extern.slf4j.Slf4j; import org.nutz.dao.Cnd; import org.nutz.dao.Dao; +import org.nutz.ioc.impl.PropertiesProxy; +import org.nutz.ioc.loader.annotation.Inject; import org.nutz.ioc.loader.annotation.IocBean; -import java.util.List; -import java.util.stream.Collectors; +import java.util.HashMap; /** * 商城桥接发票信息查询服务。 @@ -22,6 +25,9 @@ import java.util.stream.Collectors; @IocBean(args = {"refer:dao"}) public class MallInvoiceInfoQueryService extends AbstractMallBridgeSupport { + @Inject + private PropertiesProxy conf; + public MallInvoiceInfoQueryService(Dao dao) { super(dao); } @@ -33,21 +39,57 @@ public class MallInvoiceInfoQueryService extends AbstractMallBridgeSupport { if (dto == null || StrUtil.hasBlank(dto.getSupplierId(), dto.getSettlementId())) { throw new IllegalArgumentException("发票查询参数不能为空"); } - log.info("积分商城查询发票信息,supplierId={},settlementId={}", dto.getSupplierId(), dto.getSettlementId()); - PointsMallInvoiceMain main = dao.fetch(PointsMallInvoiceMain.class, Cnd.where("settlementId", "=", dto.getSettlementId()) - .and("delFlag", "=", false)); - if (main == null) { - throw new IllegalArgumentException("发票信息不存在"); + String clientBAB7ServerUrl = conf.get("spdb.bab7.url", ""); + if (StrUtil.isBlank(clientBAB7ServerUrl)) { + throw new IllegalArgumentException("未配置 BAB7 服务地址"); } - List invoiceInfos = dao.query(PointsMallInvoiceInfo.class, Cnd.where("mainId", "=", main.getId()).and("delFlag", "=", false)) - .stream().map(this::toInvoiceInfoDTO).collect(Collectors.toList()); - GetInvoiceInfoDTO result = new GetInvoiceInfoDTO(); - result.setBSuccess(main.getBSuccess()); - result.setSettlementId(main.getSettlementId()); - result.setSucOrderIds(main.getSucOrderIds()); - result.setFailOrderIds(main.getFailOrderIds()); - result.setFailMsg(main.getFailMsg()); - result.setInvoiceInfos(invoiceInfos); - return result; + PointsMallSupplier supplier = dao.fetch(PointsMallSupplier.class, + Cnd.where("supplierId", "=", dto.getSupplierId()).and("delFlag", "=", false)); + if (supplier == null) { + throw new IllegalArgumentException("未找到对应供应商信息"); + } + if (StrUtil.isBlank(supplier.getSupplierApiUrl())) { + throw new IllegalArgumentException("供应商地址未配置"); + } + + long timestamp = System.currentTimeMillis(); + dto.setToken(MallBridgeCryptoUtil.generateSign(supplier.getSupplierId(), supplier.getClientId(), timestamp)); + dto.setTimestamp(timestamp); + String encrypt; + try { + encrypt = MallBridgeCryptoUtil.sm4CbcEncrypt( + JSONUtil.toJsonStr(dto), + conf.get("sm4cbc.keyHex", ""), + conf.get("sm4cbc.ivHex", "") + ); + } catch (Exception e) { + log.error("9.2.10 发票获取接口请求参数 SM4CBC 加密出错", e); + throw new IllegalArgumentException("发票获取请求参数加密失败"); + } + + HashMap bodyMap = new HashMap<>(); + bodyMap.put("Address4", supplier.getSupplierApiUrl() + "/supplierOpenApi/pointOrder/queryInvoicesInfo"); + bodyMap.put("BussDealMd", "P"); + bodyMap.put("SroNo", supplier.getSroNo()); + bodyMap.put("RsrvFld1", supplier.getClientId()); + bodyMap.put("AplParmObjct", encrypt); + + String response = HttpUtil.createPost(clientBAB7ServerUrl) + .contentType("application/json;charset=UTF-8") + .body(JSONUtil.toJsonStr(bodyMap)) + .execute() + .body(); + if (StrUtil.isBlank(response)) { + throw new IllegalArgumentException("没有查询到发票信息"); + } + JSONObject responseJson = JSONUtil.parseObj(response); + if (responseJson.getInt("resultCode", -1) != 0) { + throw new IllegalArgumentException(StrUtil.blankToDefault(responseJson.getStr("message"), "获取发票信息失败")); + } + JSONObject invoiceInfo = responseJson.getJSONObject("getInvoiceInfo"); + if (invoiceInfo == null) { + throw new IllegalArgumentException("没有查询到发票信息"); + } + return JSONUtil.toBean(invoiceInfo, GetInvoiceInfoDTO.class); } } diff --git a/src/main/java/com/budwk/app/zhgh/pointsmall/reconciliation/service/impl/PointsMallReconciliationServiceImpl.java b/src/main/java/com/budwk/app/zhgh/pointsmall/reconciliation/service/impl/PointsMallReconciliationServiceImpl.java index 5cfd8541..ca3edacc 100644 --- a/src/main/java/com/budwk/app/zhgh/pointsmall/reconciliation/service/impl/PointsMallReconciliationServiceImpl.java +++ b/src/main/java/com/budwk/app/zhgh/pointsmall/reconciliation/service/impl/PointsMallReconciliationServiceImpl.java @@ -238,21 +238,21 @@ public class PointsMallReconciliationServiceImpl extends BaseServiceImpl reconciliationList, Integer reconciliationStatus) { diff --git a/src/main/java/com/budwk/app/zhgh/pointsmall/reconciliationrecord/service/impl/PointsMallReconciliationRecordServiceImpl.java b/src/main/java/com/budwk/app/zhgh/pointsmall/reconciliationrecord/service/impl/PointsMallReconciliationRecordServiceImpl.java index 405b3a43..f8aabb03 100644 --- a/src/main/java/com/budwk/app/zhgh/pointsmall/reconciliationrecord/service/impl/PointsMallReconciliationRecordServiceImpl.java +++ b/src/main/java/com/budwk/app/zhgh/pointsmall/reconciliationrecord/service/impl/PointsMallReconciliationRecordServiceImpl.java @@ -30,21 +30,21 @@ public class PointsMallReconciliationRecordServiceImpl extends BaseServiceImpl

implements PointsMallSupplierService { + @Inject + private RedisService redisService; + public PointsMallSupplierServiceImpl(Dao dao) { super(dao); } @@ -52,7 +65,32 @@ public class PointsMallSupplierServiceImpl extends BaseServiceImpl list = dao().query(PointsMallSupplier.class, cnd); + if (Objects.equals(1, mallType)) { + Sys_user user = dao().fetch(Sys_user.class, SecurityUtil.getUserId()); + if (user == null || StrUtil.isBlank(user.getVirtualId())) { + throw new BaseException("用户不存在"); + } + for (PointsMallSupplier supplier : list) { + supplier.setSupplierUrl(getSupplierIndexUrl(user, supplier)); + } + } + return list; + } + + private String getSupplierIndexUrl(Sys_user user, PointsMallSupplier supplier) { + String supplierUrl = supplier.getSupplierUrl(); + if (StrUtil.isBlank(supplierUrl) || !Objects.equals(1, supplier.getMallType())) { + return supplierUrl; + } + Map params = new HashMap<>(); + params.put("userId", user.getVirtualId()); + if ("10101013".equals(supplier.getSupplierId())) { + params.put("orgId", user.getVirtualOrgId()); + } + String keyword = IdUtil.fastSimpleUUID(); + redisService.setex("supplier-session:" + keyword, 300, JSONUtil.toJsonStr(params)); + return supplierUrl.concat(keyword); } @Override diff --git a/src/main/resources/views/platform/zhgh/points-mall/invoice/index.html b/src/main/resources/views/platform/zhgh/points-mall/invoice/index.html index 63be5be5..8288e294 100644 --- a/src/main/resources/views/platform/zhgh/points-mall/invoice/index.html +++ b/src/main/resources/views/platform/zhgh/points-mall/invoice/index.html @@ -86,7 +86,7 @@ layout("/layouts/platform.html"){ - + @@ -275,7 +275,7 @@ layout("/layouts/platform.html"){ endDate: null, invoiceDate: null, invoiceTitle: null, - invoiceCode: null, + taxIdNumber: null, invoiceAddress: null, invoiceContact: null, invoiceType: 10, diff --git a/src/main/resources/views/platform/zhgh/points-mall/reconciliation/index.html b/src/main/resources/views/platform/zhgh/points-mall/reconciliation/index.html index e0ee1f7d..e425c305 100644 --- a/src/main/resources/views/platform/zhgh/points-mall/reconciliation/index.html +++ b/src/main/resources/views/platform/zhgh/points-mall/reconciliation/index.html @@ -3,44 +3,74 @@ layout("/layouts/platform.html"){ #-->

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + 查询 + 重置 + 对账 + 开票申请 + + + + - - 对账 - 对账记录 - - + + + @@ -87,39 +117,43 @@ layout("/layouts/platform.html"){ - - - - - - - - - - - - - - - - - - - - - - - {{ reconcilePointsTotal }} - - - + + {{ reconcilePointsTotal }} + + 取消 - 计算金额 确认对账 + + + + + + + + + + + + + + + + + + + + + + + 取消 + 确认开票 + + + @@ -209,6 +243,8 @@ layout("/layouts/platform.html"){ supplierList: [], tableData: [], tableLoading: false, + selections: [], + hasSearched: false, pageForm: { pageNumber: 1, pageSize: 10, @@ -218,6 +254,7 @@ layout("/layouts/platform.html"){ userId: null, startDate: null, endDate: null, + reconciliationType: null, reconciliationStatus: null, invoiceStatus: null }, @@ -232,6 +269,36 @@ layout("/layouts/platform.html"){ startDate: null, endDate: null }, + applyDialogVisible: false, + applyLoading: false, + applyForm: { + invoiceDate: null, + invoiceTitle: null, + taxIdNumber: null, + invoiceAddress: null, + invoiceContact: null, + invoiceType: null + }, + applyRules: { + invoiceDate: [{ required: true, message: "请选择开票日期", trigger: "change" }], + invoiceTitle: [{ required: true, message: "请输入发票抬头", trigger: "blur" }], + taxIdNumber: [{ required: true, message: "请输入纳税人识别号", trigger: "blur" }], + invoiceAddress: [{ required: true, message: "请输入开户地址", trigger: "blur" }], + invoiceContact: [ + { required: true, message: "请输入联系电话", trigger: "blur" }, + { + validator(rule, value, callback) { + if (value && !/^1[3-9]\d{9}$/.test(value)) { + callback(new Error("请输入正确的手机号码")) + } else { + callback() + } + }, + trigger: "blur" + } + ], + invoiceType: [{ required: true, message: "请选择发票类型", trigger: "change" }] + }, recordDialogVisible: false, recordLoading: false, recordList: [], @@ -279,9 +346,32 @@ layout("/layouts/platform.html"){ return index + 1 + (this.recordForm.pageNumber - 1) * this.recordForm.pageSize }, doSearch() { + this.hasSearched = true + this.selections = [] this.pageForm.pageNumber = 1 this.pageData() }, + resetSearch() { + this.pageForm = { + pageNumber: 1, + pageSize: 10, + totalCount: 0, + supplierId: null, + orderId: null, + userId: null, + startDate: null, + endDate: null, + reconciliationType: null, + reconciliationStatus: null, + invoiceStatus: null + } + this.hasSearched = false + this.selections = [] + this.pageData() + }, + selectionChange(rows) { + this.selections = rows || [] + }, async pageData() { this.tableLoading = true const resp = await this.$axios.post(loc() + "/pageData", this.pageForm) @@ -308,48 +398,114 @@ layout("/layouts/platform.html"){ this.supplierList = resp.data || [] } }, - openReconcileDialog() { + async openReconcileDialog() { this.reconcileForm = { supplierId: this.pageForm.supplierId, - reconciliationType: this.pageForm.reconciliationStatus === 2 ? 2 : 1, + reconciliationType: this.pageForm.reconciliationType, 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("请先选择供应商、对账类型和对账日期") + if (!this.reconciliationParamsComplete()) { + this.notifyWarning(this.reconcileForm.reconciliationType === 2 ? "请选择供应商、对账类型、对账日期并填写订单ID" : "请选择供应商、对账类型和对账日期") return } + if (await this.loadPointsTotal()) { + this.reconcileDialogVisible = true + } + }, + reconciliationParamsComplete() { + if (!this.reconcileForm.supplierId || !this.reconcileForm.reconciliationType) { + return false + } + if (!this.reconcileForm.startDate || !this.reconcileForm.endDate) { + return false + } + return this.reconcileForm.reconciliationType !== 2 || !!this.reconcileForm.orderId + }, + async loadPointsTotal() { + if (!this.reconciliationParamsComplete()) { + return false + } 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 { + try { + const resp = await this.$axios.post(loc() + "/pointsTotal", this.reconcileForm) + if (resp.code === 0) { + this.reconcilePointsTotal = resp.data || 0 + return true + } this.notifyWarning(resp.msg) + return false + } finally { + this.pointsTotalLoading = false } }, async executeReconciliation() { - if (!this.reconcileForm.supplierId || !this.reconcileForm.startDate || !this.reconcileForm.endDate || !this.reconcileForm.reconciliationType) { - this.notifyWarning("请先选择供应商、对账类型和对账日期") + if (!this.reconciliationParamsComplete()) { + this.notifyWarning(this.reconcileForm.reconciliationType === 2 ? "请先选择供应商并填写订单ID" : "请先选择供应商、对账类型和对账日期") 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) + try { + const resp = await this.$axios.post(loc() + "/execute", this.reconcileForm) + if (resp.code === 0) { + this.notifySuccess(resp.data || "对账完成") + this.reconcileDialogVisible = false + this.pageData() + } else { + this.notifyWarning(resp.msg) + } + } finally { + this.executeLoading = false } }, + openApplyDialog() { + if (!this.pageForm.supplierId || !this.pageForm.startDate || !this.pageForm.endDate) { + return + } + if (!this.selections.length) { + this.notifyWarning("请先勾选需要开票的订单") + return + } + this.applyForm = { + invoiceDate: null, + invoiceTitle: null, + taxIdNumber: null, + invoiceAddress: null, + invoiceContact: null, + invoiceType: null + } + this.applyDialogVisible = true + }, + submitApply() { + this.$refs.applyFormRef.validate(async (valid) => { + if (!valid) { + return + } + this.applyLoading = true + try { + const params = Object.assign({}, this.applyForm, { + supplierId: this.pageForm.supplierId, + startDate: this.pageForm.startDate, + endDate: this.pageForm.endDate, + orderIds: this.selections.map((item) => item.orderId).join(",") + }) + const resp = await this.$axios.post("/platform/zhgh/points-mall/invoice/applyInvoice", params) + if (resp.code === 0) { + this.notifySuccess(resp.data || "开票申请成功") + this.applyDialogVisible = false + this.selections = [] + this.$refs.tableRef.clearSelection() + this.pageData() + } else { + this.notifyWarning(resp.msg) + } + } finally { + this.applyLoading = false + } + }) + }, openRecordDialog() { this.recordDialogVisible = true this.recordForm.supplierId = this.pageForm.supplierId diff --git a/src/main/resources/views/platform/zhghh5/points-mall/index.html b/src/main/resources/views/platform/zhghh5/points-mall/index.html index 939e8814..77bcb11f 100644 --- a/src/main/resources/views/platform/zhghh5/points-mall/index.html +++ b/src/main/resources/views/platform/zhghh5/points-mall/index.html @@ -146,36 +146,12 @@ layout("/layouts/platform_h5.html"){ this.userPoints = resp.data || 0 } }, - async openSupplier(item) { + openSupplier(item) { if (!item.supplierUrl) { this.$toast("暂无跳转地址") return } - const virtualId = this.$store && this.$store.state.user ? this.$store.state.user.virtualId : "" - if (!virtualId) { - this.$toast("获取用户信息失败,请重新登录后再试") - return - } - window.location.href = this.withSupplierQuery(item.supplierUrl, { - userId: virtualId - }) - }, - withSupplierQuery(url, params) { - const query = Object.keys(params) - .filter((key) => params[key] !== undefined && params[key] !== null && params[key] !== "") - .map((key) => encodeURIComponent(key) + "=" + encodeURIComponent(params[key])) - .join("&") - if (!query) { - return url - } - const hashIndex = url.indexOf("#") - if (hashIndex > -1) { - const base = url.slice(0, hashIndex) - const hash = url.slice(hashIndex) - const joiner = hash.indexOf("?") > -1 ? "&" : "?" - return base + hash + joiner + query - } - return url + (url.indexOf("?") > -1 ? "&" : "?") + query + window.location.href = item.supplierUrl }, onImgError(e) { e.target.src = this.defaultLogo