Total processing time: 141 ms; Peak memory: 6.280 MB. Show Profiling Timeline
| Time | Duration | Category | Info |
|---|---|---|---|
| 17:43:29.284 | 40.5 ms | yii\db\Command::query | SELECT COUNT(*) FROM ((SELECT 107 AS "object_type", "i"."id" AS "object_id", 0 AS "event_type", 0 AS "event_id", ''::text AS "business_node", "i"."invoice_num" AS "bill_no", "i"."from_date" AS "bill_date", NULL::timestamp without time zone AS "completed_at", "i"."amount" AS "amount", "c"."client_id" AS "client_id", NULL::integer AS "supplier_id", NULL::integer AS "contact_id", NULL::integer AS "department_id", NULL::integer AS "handler_id", "i"."created_by" AS "created_by", NULL::integer AS "erp_bank_id", true AS "have_invoice", true AS "is_verified" FROM "a57be577deb434"."tbl_sales_contract_invoices" "i" LEFT JOIN "a57be577deb434"."tbl_sales_contracts" "c" ON c.id = i.contract_id WHERE (("i"."is_cancel"=FALSE) AND ("i"."is_draft"=FALSE)) AND (("i"."invoice_type" <> -1) OR ("i"."invoice_type" IS NULL)) AND ("i"."from_date" >= '2026-05-01') AND ("i"."from_date" <= '2026-05-31')) UNION ALL ( SELECT 107 AS "object_type", "i"."id" AS "object_id", 0 AS "event_type", 0 AS "event_id", ''::text AS "business_node", "i"."invoice_num" AS "bill_no", "i"."from_date" AS "bill_date", NULL::timestamp without time zone AS "completed_at", "i"."amount" AS "amount", "c"."client_id" AS "client_id", NULL::integer AS "supplier_id", NULL::integer AS "contact_id", NULL::integer AS "department_id", NULL::integer AS "handler_id", "i"."created_by" AS "created_by", NULL::integer AS "erp_bank_id", true AS "have_invoice", true AS "is_verified" FROM "a57be577deb434"."tbl_sales_contract_invoices" "i" LEFT JOIN "a57be577deb434"."tbl_sales_contracts" "c" ON c.id = i.contract_id WHERE (("i"."is_cancel"=FALSE) AND ("i"."is_draft"=FALSE)) AND ("i"."invoice_type"=-1) AND ("i"."from_date" >= '2026-05-01') AND ("i"."from_date" <= '2026-05-31') ) UNION ALL ( SELECT 109 AS "object_type", "i"."id" AS "object_id", 0 AS "event_type", 0 AS "event_id", ''::text AS "business_node", "i"."invoice_num" AS "bill_no", COALESCE(CAST(i.verify_at AS date), i.from_date) AS "bill_date", NULL::timestamp without time zone AS "completed_at", "i"."amount" AS "amount", NULL::integer AS "client_id", "i"."supplier_id" AS "supplier_id", NULL::integer AS "contact_id", NULL::integer AS "department_id", "i"."handler" AS "handler_id", "i"."created_by" AS "created_by", NULL::integer AS "erp_bank_id", true AS "have_invoice", "i"."is_verify" AS "is_verified" FROM "a57be577deb434"."tbl_purchase_contract_invoices" "i" WHERE ("i"."is_cancel"=FALSE) AND (("i"."invoice_type" <> -1) OR ("i"."invoice_type" IS NULL)) AND (COALESCE(CAST(i.verify_at AS date), i.from_date) >= '2026-05-01') AND (COALESCE(CAST(i.verify_at AS date), i.from_date) <= '2026-05-31') ) UNION ALL ( SELECT 109 AS "object_type", "i"."id" AS "object_id", 0 AS "event_type", 0 AS "event_id", ''::text AS "business_node", "i"."invoice_num" AS "bill_no", COALESCE(CAST(i.verify_at AS date), i.from_date) AS "bill_date", NULL::timestamp without time zone AS "completed_at", "i"."amount" AS "amount", NULL::integer AS "client_id", "i"."supplier_id" AS "supplier_id", NULL::integer AS "contact_id", NULL::integer AS "department_id", "i"."handler" AS "handler_id", "i"."created_by" AS "created_by", NULL::integer AS "erp_bank_id", true AS "have_invoice", "i"."is_verify" AS "is_verified" FROM "a57be577deb434"."tbl_purchase_contract_invoices" "i" WHERE ("i"."is_cancel"=FALSE) AND ("i"."invoice_type"=-1) AND (COALESCE(CAST(i.verify_at AS date), i.from_date) >= '2026-05-01') AND (COALESCE(CAST(i.verify_at AS date), i.from_date) <= '2026-05-31') ) UNION ALL ( SELECT 7 AS "object_type", "c"."id" AS "object_id", 0 AS "event_type", 0 AS "event_id", ''::text AS "business_node", "c"."serial_no" AS "bill_no", "c"."signed_at" AS "bill_date", NULL::timestamp without time zone AS "completed_at", ROUND((COALESCE(NULLIF(SUM(p.total_amount), 0), c.amount, 0) * 1.13)::numeric, 2) AS "amount", "c"."client_id" AS "client_id", NULL::integer AS "supplier_id", NULL::integer AS "contact_id", NULL::integer AS "department_id", "c"."handler" AS "handler_id", "c"."created_by" AS "created_by", NULL::integer AS "erp_bank_id", true AS "have_invoice", true AS "is_verified" FROM "a57be577deb434"."tbl_sales_contracts" "c" LEFT JOIN "a57be577deb434"."tbl_project_product_rels" "p" ON p.project_id = c.from_project WHERE (COALESCE(c.including_tax, false) = false) AND (NOT ("c"."from_project" IS NULL)) AND (COALESCE(c.is_draft, false) = false) AND (COALESCE(c.is_verify, false) = false) AND (COALESCE(c.is_edit_verify, false) = false) AND (COALESCE(c.is_chargeback_verify, false) = false) AND ("c"."signed_at" >= '2026-05-01') AND ("c"."signed_at" <= '2026-05-31') GROUP BY "c"."id", "c"."serial_no", "c"."signed_at", "c"."amount", "c"."client_id", "c"."handler", "c"."created_by" ) UNION ALL ( SELECT 13 AS "object_type", "c"."id" AS "object_id", 0 AS "event_type", 0 AS "event_id", ''::text AS "business_node", "c"."serial_no" AS "bill_no", "c"."signed_at" AS "bill_date", NULL::timestamp without time zone AS "completed_at", ROUND((COALESCE(NULLIF(SUM(p.total_amount), 0), c.amount, 0) * 1.13)::numeric, 2) AS "amount", NULL::integer AS "client_id", "c"."supplier_id" AS "supplier_id", NULL::integer AS "contact_id", NULL::integer AS "department_id", "c"."handler" AS "handler_id", "c"."created_by" AS "created_by", NULL::integer AS "erp_bank_id", true AS "have_invoice", true AS "is_verified" FROM "a57be577deb434"."tbl_purchase_contracts" "c" LEFT JOIN "a57be577deb434"."tbl_purchase_contract_product_rels" "p" ON p.purchase_contract_id = c.id WHERE (COALESCE(c.including_tax, false) = false) AND (COALESCE(c.cost_type, 1) = 1) AND (COALESCE(c.is_draft, false) = false) AND (COALESCE(c.is_chargeback, false) = false) AND (COALESCE(c.is_verify, false) = false) AND (COALESCE(c.is_edit_verify, false) = false) AND (COALESCE(c.is_chargeback_verify, false) = false) AND ("c"."signed_at" >= '2026-05-01') AND ("c"."signed_at" <= '2026-05-31') GROUP BY "c"."id", "c"."serial_no", "c"."signed_at", "c"."amount", "c"."supplier_id", "c"."handler", "c"."created_by" ) UNION ALL ( SELECT 20008 AS "object_type", "e"."id" AS "object_id", 0 AS "event_type", 0 AS "event_id", ''::text AS "business_node", "e"."serial_no" AS "bill_no", "e"."wrote_date" AS "bill_date", NULL::timestamp without time zone AS "completed_at", CASE WHEN COALESCE(e.amount, 0) > 0 THEN COALESCE(e.amount, 0) ELSE COALESCE(SUM(s.actual_total_amount), 0) END AS "amount", "e"."client_id" AS "client_id", NULL::integer AS "supplier_id", NULL::integer AS "contact_id", NULL::integer AS "department_id", "e"."handler" AS "handler_id", "e"."created_by" AS "created_by", NULL::integer AS "erp_bank_id", true AS "have_invoice", true AS "is_verified" FROM "a57be577deb434"."tbl_erp_sales_outbounds" "e" LEFT JOIN "a57be577deb434"."tbl_erp_inventory_product_spents" "s" ON s.erp_sales_outbound_id = e.id WHERE ("e"."status"=2) AND ("e"."wrote_date" >= '2026-05-01') AND ("e"."wrote_date" <= '2026-05-31') GROUP BY "e"."id", "e"."serial_no", "e"."wrote_date", "e"."amount", "e"."client_id", "e"."handler", "e"."created_by" ) UNION ALL ( SELECT 20009 AS "object_type", "e"."id" AS "object_id", 0 AS "event_type", 0 AS "event_id", ''::text AS "business_node", "e"."serial_no" AS "bill_no", "e"."wrote_date" AS "bill_date", NULL::timestamp without time zone AS "completed_at", "e"."amount" AS "amount", "e"."client_id" AS "client_id", NULL::integer AS "supplier_id", NULL::integer AS "contact_id", NULL::integer AS "department_id", "e"."handler" AS "handler_id", "e"."created_by" AS "created_by", NULL::integer AS "erp_bank_id", true AS "have_invoice", true AS "is_verified" FROM "a57be577deb434"."tbl_erp_sales_returns" "e" WHERE ("e"."status"=2) AND ("e"."wrote_date" >= '2026-05-01') AND ("e"."wrote_date" <= '2026-05-31') ) UNION ALL ( SELECT 20003 AS "object_type", "e"."id" AS "object_id", 0 AS "event_type", 0 AS "event_id", ''::text AS "business_node", "e"."serial_no" AS "bill_no", "e"."wrote_date" AS "bill_date", NULL::timestamp without time zone AS "completed_at", COALESCE(NULLIF(SUM(p.total_amount), 0), e.amount, 0) AS "amount", NULL::integer AS "client_id", "e"."supplier_id" AS "supplier_id", NULL::integer AS "contact_id", NULL::integer AS "department_id", "e"."handler" AS "handler_id", "e"."created_by" AS "created_by", NULL::integer AS "erp_bank_id", true AS "have_invoice", true AS "is_verified" FROM "a57be577deb434"."tbl_erp_purchase_returns" "e" LEFT JOIN "a57be577deb434"."tbl_erp_purchase_return_products" "p" ON p.erp_purchase_return_id = e.id WHERE ("e"."status"=2) AND ("e"."wrote_date" >= '2026-05-01') AND ("e"."wrote_date" <= '2026-05-31') GROUP BY "e"."id", "e"."serial_no", "e"."wrote_date", "e"."amount", "e"."supplier_id", "e"."handler", "e"."created_by" ) UNION ALL ( SELECT 20013 AS "object_type", "e"."id" AS "object_id", 0 AS "event_type", 0 AS "event_id", ''::text AS "business_node", "e"."serial_no" AS "bill_no", "e"."wrote_date" AS "bill_date", NULL::timestamp without time zone AS "completed_at", "e"."amount" AS "amount", "e"."client_id" AS "client_id", "e"."supplier_id" AS "supplier_id", NULL::integer AS "contact_id", NULL::integer AS "department_id", "e"."handler" AS "handler_id", "e"."created_by" AS "created_by", NULL::integer AS "erp_bank_id", true AS "have_invoice", true AS "is_verified" FROM "a57be577deb434"."tbl_erp_collect_tickets" "e" WHERE ("e"."status"=2) AND ("e"."wrote_date" >= '2026-05-01') AND ("e"."wrote_date" <= '2026-05-31') ) UNION ALL ( SELECT 20012 AS "object_type", "e"."id" AS "object_id", 0 AS "event_type", 0 AS "event_id", ''::text AS "business_node", "e"."serial_no" AS "bill_no", "e"."wrote_date" AS "bill_date", NULL::timestamp without time zone AS "completed_at", "e"."amount" AS "amount", "e"."client_id" AS "client_id", "e"."supplier_id" AS "supplier_id", NULL::integer AS "contact_id", NULL::integer AS "department_id", "e"."handler" AS "handler_id", "e"."created_by" AS "created_by", NULL::integer AS "erp_bank_id", true AS "have_invoice", true AS "is_verified" FROM "a57be577deb434"."tbl_erp_payment_tickets" "e" WHERE ("e"."status"=2) AND ("e"."wrote_date" >= '2026-05-01') AND ("e"."wrote_date" <= '2026-05-31') ) UNION ALL ( SELECT 20019 AS "object_type", "e"."id" AS "object_id", 0 AS "event_type", 0 AS "event_id", ''::text AS "business_node", "e"."serial_no" AS "bill_no", "e"."wrote_date" AS "bill_date", NULL::timestamp without time zone AS "completed_at", "e"."amount" AS "amount", "e"."client_id" AS "client_id", "e"."supplier_id" AS "supplier_id", NULL::integer AS "contact_id", NULL::integer AS "department_id", "e"."handler" AS "handler_id", "e"."created_by" AS "created_by", NULL::integer AS "erp_bank_id", true AS "have_invoice", true AS "is_verified" FROM "a57be577deb434"."tbl_erp_advance_payment_tickets" "e" WHERE ("e"."status"=2) AND ("e"."wrote_date" >= '2026-05-01') AND ("e"."wrote_date" <= '2026-05-31') ) UNION ALL ( (SELECT 20021 AS "object_type", "t"."id" AS "object_id", 1 AS "event_type", "e"."id" AS "event_id", '付款'::text AS "business_node", "t"."serial_no" AS "bill_no", CAST(e.settle_at AS date) AS "bill_date", "e"."settle_at" AS "completed_at", "e"."amount" AS "amount", "t"."client_id" AS "client_id", "t"."supplier_id" AS "supplier_id", "t"."contact_id" AS "contact_id", NULL::integer AS "department_id", "t"."handler" AS "handler_id", "t"."created_by" AS "created_by", "e"."erp_bank_id" AS "erp_bank_id", true AS "have_invoice", true AS "is_verified" FROM "a57be577deb434"."tbl_erp_other_collect_tickets" "t" INNER JOIN "a57be577deb434"."tbl_erp_other_collect_ticket_bank_outs" "e" ON e.erp_other_collect_ticket_id = t.id WHERE ("t"."status" IN (2, 5)) AND (NOT ("e"."settle_at" IS NULL)) AND ("e"."amount" > 0) AND ("e"."settle_at" >= '2026-05-01') AND ("e"."settle_at" <= '2026-05-31 23:59:59')) UNION ALL ( SELECT 20021 AS "object_type", "t"."id" AS "object_id", 2 AS "event_type", "p"."id" AS "event_id", '收款'::text AS "business_node", "t"."serial_no" AS "bill_no", CAST(t.bank_settle_at AS date) AS "bill_date", "t"."bank_settle_at" AS "completed_at", "p"."amount" AS "amount", "t"."client_id" AS "client_id", "t"."supplier_id" AS "supplier_id", "t"."contact_id" AS "contact_id", NULL::integer AS "department_id", "t"."handler" AS "handler_id", "t"."created_by" AS "created_by", NULL::integer AS "erp_bank_id", true AS "have_invoice", true AS "is_verified" FROM "a57be577deb434"."tbl_erp_other_collect_tickets" "t" INNER JOIN "a57be577deb434"."tbl_erp_other_collect_ticket_payments" "p" ON p.erp_other_collect_ticket_id = t.id WHERE ("t"."status" IN (2, 5)) AND (NOT ("t"."bank_settle_at" IS NULL)) AND ("p"."amount" > 0) AND ("t"."bank_settle_at" >= '2026-05-01') AND ("t"."bank_settle_at" <= '2026-05-31 23:59:59') ) ) UNION ALL ( (SELECT 20020 AS "object_type", "t"."id" AS "object_id", 2 AS "event_type", "e"."id" AS "event_id", '收款'::text AS "business_node", "t"."serial_no" AS "bill_no", CAST(e.settle_at AS date) AS "bill_date", "e"."settle_at" AS "completed_at", "e"."amount" AS "amount", "t"."client_id" AS "client_id", "t"."supplier_id" AS "supplier_id", "t"."contact_id" AS "contact_id", NULL::integer AS "department_id", "t"."handler" AS "handler_id", "t"."created_by" AS "created_by", "e"."erp_bank_id" AS "erp_bank_id", true AS "have_invoice", true AS "is_verified" FROM "a57be577deb434"."tbl_erp_other_payment_tickets" "t" INNER JOIN "a57be577deb434"."tbl_erp_other_payment_ticket_bank_ins" "e" ON e.erp_other_payment_ticket_id = t.id WHERE ("t"."status" IN (2, 5)) AND (NOT ("e"."settle_at" IS NULL)) AND ("e"."amount" > 0) AND ("e"."settle_at" >= '2026-05-01') AND ("e"."settle_at" <= '2026-05-31 23:59:59')) UNION ALL ( SELECT 20020 AS "object_type", "t"."id" AS "object_id", 1 AS "event_type", "s"."id" AS "event_id", '付款'::text AS "business_node", "t"."serial_no" AS "bill_no", CAST(p.bank_settle_at AS date) AS "bill_date", "p"."bank_settle_at" AS "completed_at", "s"."amount" AS "amount", "t"."client_id" AS "client_id", "t"."supplier_id" AS "supplier_id", "t"."contact_id" AS "contact_id", NULL::integer AS "department_id", "t"."handler" AS "handler_id", "t"."created_by" AS "created_by", CASE WHEN COUNT(DISTINCT bo.erp_bank_id) = 1 THEN MIN(bo.erp_bank_id) ELSE NULL END AS "erp_bank_id", true AS "have_invoice", true AS "is_verified" FROM "a57be577deb434"."tbl_erp_payment_ticket_settles" "s" INNER JOIN "a57be577deb434"."tbl_erp_other_payment_tickets" "t" ON s.erp_other_payment_ticket_id = t.id INNER JOIN "a57be577deb434"."tbl_erp_payment_tickets" "p" ON s.erp_payment_ticket_id = p.id LEFT JOIN "a57be577deb434"."tbl_erp_payment_ticket_bank_outs" "bo" ON bo.erp_payment_ticket_id = p.id WHERE ("p"."status" IN (2, 5)) AND ("p"."is_payment_settle"=TRUE) AND (NOT ("p"."bank_settle_at" IS NULL)) AND ("s"."amount" > 0) AND ("p"."bank_settle_at" >= '2026-05-01') AND ("p"."bank_settle_at" <= '2026-05-31 23:59:59') GROUP BY "s"."id", "s"."amount", "t"."id", "t"."serial_no", "t"."client_id", "t"."supplier_id", "t"."contact_id", "t"."handler", "t"."created_by", "p"."bank_settle_at" ) ) UNION ALL ( SELECT 20015 AS "object_type", "t"."id" AS "object_id", 2 AS "event_type", "e"."id" AS "event_id", '收款'::text AS "business_node", "t"."serial_no" AS "bill_no", CAST(t.verify_at AS date) AS "bill_date", "e"."settle_at" AS "completed_at", "e"."amount" AS "amount", "t"."client_id" AS "client_id", "t"."supplier_id" AS "supplier_id", "t"."contact_id" AS "contact_id", CASE WHEN COUNT(DISTINCT u.department_id) = 1 THEN MIN(u.department_id) ELSE NULL END AS "department_id", CASE WHEN COUNT(DISTINCT h.user_id) = 1 THEN MIN(h.user_id) ELSE NULL END AS "handler_id", "t"."created_by" AS "created_by", "e"."erp_bank_id" AS "erp_bank_id", true AS "have_invoice", true AS "is_verified" FROM "a57be577deb434"."tbl_erp_other_income_tickets" "t" INNER JOIN "a57be577deb434"."tbl_erp_other_income_ticket_bank_ins" "e" ON e.erp_other_income_ticket_id = t.id LEFT JOIN "a57be577deb434"."tbl_erp_other_income_ticket_handlers" "h" ON h.erp_other_income_ticket_id = t.id LEFT JOIN "a57be577deb434"."tbl_users" "u" ON u.id = h.user_id WHERE ("t"."status"=2) AND (NOT ("t"."verify_at" IS NULL)) AND (NOT ("e"."settle_at" IS NULL)) AND ("e"."amount" > 0) AND ("t"."verify_at" >= '2026-05-01') AND ("t"."verify_at" <= '2026-05-31 23:59:59') GROUP BY "t"."id", "t"."serial_no", "t"."verify_at", "t"."client_id", "t"."supplier_id", "t"."contact_id", "t"."created_by", "e"."id", "e"."settle_at", "e"."amount", "e"."erp_bank_id" ) UNION ALL ( SELECT 20014 AS "object_type", "e"."id" AS "object_id", 0 AS "event_type", 0 AS "event_id", ''::text AS "business_node", "e"."serial_no" AS "bill_no", "e"."wrote_date" AS "bill_date", NULL::timestamp without time zone AS "completed_at", "e"."amount" AS "amount", "e"."client_id" AS "client_id", "e"."supplier_id" AS "supplier_id", "e"."contact_id" AS "contact_id", NULL::integer AS "department_id", NULL::integer AS "handler_id", "e"."created_by" AS "created_by", NULL::integer AS "erp_bank_id", true AS "have_invoice", true AS "is_verified" FROM "a57be577deb434"."tbl_erp_cost_tickets" "e" WHERE ("e"."status"=2) AND ("e"."wrote_date" >= '2026-05-01') AND ("e"."wrote_date" <= '2026-05-31') ) UNION ALL ( SELECT 20018 AS "object_type", "e"."id" AS "object_id", 0 AS "event_type", 0 AS "event_id", ''::text AS "business_node", "e"."serial_no" AS "bill_no", "e"."wrote_date" AS "bill_date", NULL::timestamp without time zone AS "completed_at", "e"."amount" AS "amount", "e"."client_id" AS "client_id", "e"."supplier_id" AS "supplier_id", NULL::integer AS "contact_id", NULL::integer AS "department_id", NULL::integer AS "handler_id", "e"."created_by" AS "created_by", NULL::integer AS "erp_bank_id", "e"."have_invoice" AS "have_invoice", true AS "is_verified" FROM "a57be577deb434"."tbl_erp_cash_cost_tickets" "e" WHERE ("e"."status"=2) AND ("e"."wrote_date" >= '2026-05-01') AND ("e"."wrote_date" <= '2026-05-31') ) UNION ALL ( SELECT 20011 AS "object_type", "e"."id" AS "object_id", 0 AS "event_type", 0 AS "event_id", ''::text AS "business_node", "e"."serial_no" AS "bill_no", "e"."wrote_date" AS "bill_date", NULL::timestamp without time zone AS "completed_at", COALESCE(SUM(s.actual_total_amount), 0) AS "amount", "e"."client_id" AS "client_id", NULL::integer AS "supplier_id", NULL::integer AS "contact_id", NULL::integer AS "department_id", "e"."handler" AS "handler_id", "e"."created_by" AS "created_by", NULL::integer AS "erp_bank_id", true AS "have_invoice", true AS "is_verified" FROM "a57be577deb434"."tbl_erp_sales_gifts" "e" LEFT JOIN "a57be577deb434"."tbl_erp_inventory_product_spents" "s" ON s.erp_sales_gift_id = e.id WHERE ("e"."status"=2) AND ("e"."wrote_date" >= '2026-05-01') AND ("e"."wrote_date" <= '2026-05-31') GROUP BY "e"."id", "e"."serial_no", "e"."wrote_date", "e"."client_id", "e"."handler", "e"."created_by" ) UNION ALL ( SELECT 20004 AS "object_type", "e"."id" AS "object_id", 0 AS "event_type", 0 AS "event_id", ''::text AS "business_node", "e"."serial_no" AS "bill_no", "e"."wrote_date" AS "bill_date", NULL::timestamp without time zone AS "completed_at", "e"."amount" AS "amount", NULL::integer AS "client_id", NULL::integer AS "supplier_id", NULL::integer AS "contact_id", NULL::integer AS "department_id", "e"."handler" AS "handler_id", "e"."created_by" AS "created_by", NULL::integer AS "erp_bank_id", true AS "have_invoice", true AS "is_verified" FROM "a57be577deb434"."tbl_erp_inventory_losts" "e" WHERE ("e"."status"=2) AND ("e"."wrote_date" >= '2026-05-01') AND ("e"."wrote_date" <= '2026-05-31') ) UNION ALL ( SELECT 20031 AS "object_type", "e"."id" AS "object_id", 0 AS "event_type", 0 AS "event_id", ''::text AS "business_node", "e"."serial_no" AS "bill_no", "e"."wrote_date" AS "bill_date", NULL::timestamp without time zone AS "completed_at", "e"."amount" AS "amount", NULL::integer AS "client_id", NULL::integer AS "supplier_id", NULL::integer AS "contact_id", NULL::integer AS "department_id", "e"."handler" AS "handler_id", "e"."created_by" AS "created_by", NULL::integer AS "erp_bank_id", true AS "have_invoice", true AS "is_verified" FROM "a57be577deb434"."tbl_erp_inventory_overflows" "e" WHERE ("e"."status"=2) AND ("e"."wrote_date" >= '2026-05-01') AND ("e"."wrote_date" <= '2026-05-31') ) UNION ALL ( SELECT 20023 AS "object_type", "t"."id" AS "object_id", 1 AS "event_type", "e"."id" AS "event_id", '付款'::text AS "business_node", "t"."serial_no" AS "bill_no", CAST(e.settle_at AS date) AS "bill_date", "e"."settle_at" AS "completed_at", "e"."amount" AS "amount", NULL::integer AS "client_id", NULL::integer AS "supplier_id", NULL::integer AS "contact_id", CASE WHEN COUNT(DISTINCT u.department_id) = 1 THEN MIN(u.department_id) ELSE NULL END AS "department_id", CASE WHEN COUNT(DISTINCT a.user_id) = 1 THEN MIN(a.user_id) ELSE NULL END AS "handler_id", NULL::integer AS "created_by", "e"."erp_bank_id" AS "erp_bank_id", true AS "have_invoice", true AS "is_verified" FROM "a57be577deb434"."tbl_erp_wage_tickets" "t" INNER JOIN "a57be577deb434"."tbl_erp_wage_ticket_bank_outs" "e" ON e.erp_wage_ticket_id = t.id LEFT JOIN "a57be577deb434"."tbl_erp_wage_ticket_amounts" "a" ON a.erp_wage_ticket_id = t.id LEFT JOIN "a57be577deb434"."tbl_users" "u" ON u.id = a.user_id WHERE ("t"."status" IN (2, 5)) AND (NOT ("e"."settle_at" IS NULL)) AND ("e"."amount" > 0) AND ("e"."settle_at" >= '2026-05-01') AND ("e"."settle_at" <= '2026-05-31 23:59:59') GROUP BY "t"."id", "t"."serial_no", "e"."id", "e"."settle_at", "e"."amount", "e"."erp_bank_id" ) UNION ALL ( SELECT 20024 AS "object_type", "t"."id" AS "object_id", 1 AS "event_type", "e"."id" AS "event_id", '付款'::text AS "business_node", "t"."serial_no" AS "bill_no", CAST(e.settle_at AS date) AS "bill_date", "e"."settle_at" AS "completed_at", "e"."amount" AS "amount", NULL::integer AS "client_id", NULL::integer AS "supplier_id", NULL::integer AS "contact_id", CASE WHEN COUNT(DISTINCT u.department_id) = 1 THEN MIN(u.department_id) ELSE NULL END AS "department_id", CASE WHEN COUNT(DISTINCT a.user_id) = 1 THEN MIN(a.user_id) ELSE NULL END AS "handler_id", NULL::integer AS "created_by", "e"."erp_bank_id" AS "erp_bank_id", true AS "have_invoice", true AS "is_verified" FROM "a57be577deb434"."tbl_erp_social_insurances" "t" INNER JOIN "a57be577deb434"."tbl_erp_social_insurance_bank_outs" "e" ON e.erp_social_insurance_id = t.id LEFT JOIN "a57be577deb434"."tbl_erp_social_insurance_amounts" "a" ON a.erp_social_insurance_id = t.id LEFT JOIN "a57be577deb434"."tbl_users" "u" ON u.id = a.user_id WHERE ("t"."status" IN (2, 5)) AND (NOT ("e"."settle_at" IS NULL)) AND ("e"."amount" > 0) AND ("e"."settle_at" >= '2026-05-01') AND ("e"."settle_at" <= '2026-05-31 23:59:59') GROUP BY "t"."id", "t"."serial_no", "e"."id", "e"."settle_at", "e"."amount", "e"."erp_bank_id" ) UNION ALL ( SELECT 20026 AS "object_type", "t"."id" AS "object_id", 1 AS "event_type", "e"."id" AS "event_id", '付款'::text AS "business_node", "t"."serial_no" AS "bill_no", CAST(e.settle_at AS date) AS "bill_date", "e"."settle_at" AS "completed_at", "e"."amount" AS "amount", NULL::integer AS "client_id", NULL::integer AS "supplier_id", NULL::integer AS "contact_id", CASE WHEN COUNT(DISTINCT u.department_id) = 1 THEN MIN(u.department_id) ELSE NULL END AS "department_id", CASE WHEN COUNT(DISTINCT a.user_id) = 1 THEN MIN(a.user_id) ELSE NULL END AS "handler_id", NULL::integer AS "created_by", "e"."erp_bank_id" AS "erp_bank_id", true AS "have_invoice", true AS "is_verified" FROM "a57be577deb434"."tbl_erp_personal_taxs" "t" INNER JOIN "a57be577deb434"."tbl_erp_personal_tax_bank_outs" "e" ON e.erp_personal_tax_id = t.id LEFT JOIN "a57be577deb434"."tbl_erp_personal_tax_amounts" "a" ON a.erp_personal_tax_id = t.id LEFT JOIN "a57be577deb434"."tbl_users" "u" ON u.id = a.user_id WHERE ("t"."status" IN (2, 5)) AND (NOT ("e"."settle_at" IS NULL)) AND ("e"."amount" > 0) AND ("e"."settle_at" >= '2026-05-01') AND ("e"."settle_at" <= '2026-05-31 23:59:59') GROUP BY "t"."id", "t"."serial_no", "e"."id", "e"."settle_at", "e"."amount", "e"."erp_bank_id" ) UNION ALL ( SELECT 20027 AS "object_type", "t"."id" AS "object_id", 1 AS "event_type", "e"."id" AS "event_id", '付款'::text AS "business_node", "t"."serial_no" AS "bill_no", CAST(e.settle_at AS date) AS "bill_date", "e"."settle_at" AS "completed_at", "e"."amount" AS "amount", NULL::integer AS "client_id", NULL::integer AS "supplier_id", NULL::integer AS "contact_id", CASE WHEN COUNT(DISTINCT u.department_id) = 1 THEN MIN(u.department_id) ELSE NULL END AS "department_id", CASE WHEN COUNT(DISTINCT a.user_id) = 1 THEN MIN(a.user_id) ELSE NULL END AS "handler_id", NULL::integer AS "created_by", "e"."erp_bank_id" AS "erp_bank_id", true AS "have_invoice", true AS "is_verified" FROM "a57be577deb434"."tbl_erp_wage_prizes" "t" INNER JOIN "a57be577deb434"."tbl_erp_wage_prize_bank_outs" "e" ON e.erp_wage_prize_id = t.id LEFT JOIN "a57be577deb434"."tbl_erp_wage_prize_amounts" "a" ON a.erp_wage_prize_id = t.id LEFT JOIN "a57be577deb434"."tbl_users" "u" ON u.id = a.user_id WHERE ("t"."status" IN (2, 5)) AND (NOT ("e"."settle_at" IS NULL)) AND ("e"."amount" > 0) AND ("e"."settle_at" >= '2026-05-01') AND ("e"."settle_at" <= '2026-05-31 23:59:59') GROUP BY "t"."id", "t"."serial_no", "e"."id", "e"."settle_at", "e"."amount", "e"."erp_bank_id" ) UNION ALL ( SELECT 20025 AS "object_type", "t"."id" AS "object_id", 1 AS "event_type", "e"."id" AS "event_id", '付款'::text AS "business_node", "t"."serial_no" AS "bill_no", CAST(e.settle_at AS date) AS "bill_date", "e"."settle_at" AS "completed_at", "e"."amount" AS "amount", NULL::integer AS "client_id", NULL::integer AS "supplier_id", NULL::integer AS "contact_id", CASE WHEN COUNT(DISTINCT u.department_id) = 1 THEN MIN(u.department_id) ELSE NULL END AS "department_id", CASE WHEN COUNT(DISTINCT a.user_id) = 1 THEN MIN(a.user_id) ELSE NULL END AS "handler_id", NULL::integer AS "created_by", "e"."erp_bank_id" AS "erp_bank_id", true AS "have_invoice", true AS "is_verified" FROM "a57be577deb434"."tbl_erp_provident_funds" "t" INNER JOIN "a57be577deb434"."tbl_erp_provident_fund_bank_outs" "e" ON e.erp_provident_fund_id = t.id LEFT JOIN "a57be577deb434"."tbl_erp_provident_fund_amounts" "a" ON a.erp_provident_fund_id = t.id LEFT JOIN "a57be577deb434"."tbl_users" "u" ON u.id = a.user_id WHERE ("t"."status" IN (2, 5)) AND (NOT ("e"."settle_at" IS NULL)) AND ("e"."amount" > 0) AND ("e"."settle_at" >= '2026-05-01') AND ("e"."settle_at" <= '2026-05-31 23:59:59') GROUP BY "t"."id", "t"."serial_no", "e"."id", "e"."settle_at", "e"."amount", "e"."erp_bank_id" )) "b" LEFT JOIN (SELECT "v"."object_type" AS "object_type", "v"."object_id" AS "object_id", COALESCE(v.event_type, 0) AS "event_type", COALESCE(v.event_id, 0) AS "event_id", COUNT(*) FILTER (WHERE v.status = 1) AS "success_count", COUNT(*) FILTER (WHERE v.status = 0) AS "fail_count", MAX(v.book_date) FILTER (WHERE v.status = 1) AS "last_book_date" FROM "a57be577deb434"."tbl_voucher_gen_items" "v" WHERE "v"."ledger_id"=1 GROUP BY "v"."object_type", "v"."object_id", COALESCE(v.event_type, 0), COALESCE(v.event_id, 0)) "g" ON g.object_type = b.object_type AND g.object_id = b.object_id AND g.event_type = b.event_type AND g.event_id = b.event_id WHERE (("g"."success_count" IS NULL) OR ("g"."success_count"=0)) AND (("b"."object_type" NOT IN (20, 20018)) OR ("b"."have_invoice"=TRUE)) AND ("b"."amount" > 0) AND (("b"."object_type" <> 109) OR (("b"."is_verified"=TRUE) AND ("b"."bill_date" >= '2026-06-01') AND ("b"."bill_date" <= '2026-06-30'))) |
| 17:43:29.360 | 29.4 ms | yii\db\Command::query | SELECT "b"."object_type" AS "object_type", "b"."object_id" AS "object_id", "b"."event_type" AS "event_type", "b"."event_id" AS "event_id", "b"."business_node" AS "business_node", "b"."bill_no" AS "bill_no", "b"."bill_date" AS "bill_date", "b"."completed_at" AS "completed_at", "b"."amount" AS "amount", "b"."client_id" AS "client_id", "b"."supplier_id" AS "supplier_id", "b"."contact_id" AS "contact_id", "b"."department_id" AS "department_id", "b"."handler_id" AS "handler_id", "b"."created_by" AS "created_by", "b"."erp_bank_id" AS "erp_bank_id", "b"."have_invoice" AS "have_invoice", "b"."is_verified" AS "is_verified", COALESCE(g.success_count, 0) AS "gen_success_count", COALESCE(g.fail_count, 0) AS "gen_fail_count", COALESCE(CAST(g.last_book_date AS text), '') AS "gen_book_date" FROM ((SELECT 107 AS "object_type", "i"."id" AS "object_id", 0 AS "event_type", 0 AS "event_id", ''::text AS "business_node", "i"."invoice_num" AS "bill_no", "i"."from_date" AS "bill_date", NULL::timestamp without time zone AS "completed_at", "i"."amount" AS "amount", "c"."client_id" AS "client_id", NULL::integer AS "supplier_id", NULL::integer AS "contact_id", NULL::integer AS "department_id", NULL::integer AS "handler_id", "i"."created_by" AS "created_by", NULL::integer AS "erp_bank_id", true AS "have_invoice", true AS "is_verified" FROM "a57be577deb434"."tbl_sales_contract_invoices" "i" LEFT JOIN "a57be577deb434"."tbl_sales_contracts" "c" ON c.id = i.contract_id WHERE (("i"."is_cancel"=FALSE) AND ("i"."is_draft"=FALSE)) AND (("i"."invoice_type" <> -1) OR ("i"."invoice_type" IS NULL)) AND ("i"."from_date" >= '2026-05-01') AND ("i"."from_date" <= '2026-05-31')) UNION ALL ( SELECT 107 AS "object_type", "i"."id" AS "object_id", 0 AS "event_type", 0 AS "event_id", ''::text AS "business_node", "i"."invoice_num" AS "bill_no", "i"."from_date" AS "bill_date", NULL::timestamp without time zone AS "completed_at", "i"."amount" AS "amount", "c"."client_id" AS "client_id", NULL::integer AS "supplier_id", NULL::integer AS "contact_id", NULL::integer AS "department_id", NULL::integer AS "handler_id", "i"."created_by" AS "created_by", NULL::integer AS "erp_bank_id", true AS "have_invoice", true AS "is_verified" FROM "a57be577deb434"."tbl_sales_contract_invoices" "i" LEFT JOIN "a57be577deb434"."tbl_sales_contracts" "c" ON c.id = i.contract_id WHERE (("i"."is_cancel"=FALSE) AND ("i"."is_draft"=FALSE)) AND ("i"."invoice_type"=-1) AND ("i"."from_date" >= '2026-05-01') AND ("i"."from_date" <= '2026-05-31') ) UNION ALL ( SELECT 109 AS "object_type", "i"."id" AS "object_id", 0 AS "event_type", 0 AS "event_id", ''::text AS "business_node", "i"."invoice_num" AS "bill_no", COALESCE(CAST(i.verify_at AS date), i.from_date) AS "bill_date", NULL::timestamp without time zone AS "completed_at", "i"."amount" AS "amount", NULL::integer AS "client_id", "i"."supplier_id" AS "supplier_id", NULL::integer AS "contact_id", NULL::integer AS "department_id", "i"."handler" AS "handler_id", "i"."created_by" AS "created_by", NULL::integer AS "erp_bank_id", true AS "have_invoice", "i"."is_verify" AS "is_verified" FROM "a57be577deb434"."tbl_purchase_contract_invoices" "i" WHERE ("i"."is_cancel"=FALSE) AND (("i"."invoice_type" <> -1) OR ("i"."invoice_type" IS NULL)) AND (COALESCE(CAST(i.verify_at AS date), i.from_date) >= '2026-05-01') AND (COALESCE(CAST(i.verify_at AS date), i.from_date) <= '2026-05-31') ) UNION ALL ( SELECT 109 AS "object_type", "i"."id" AS "object_id", 0 AS "event_type", 0 AS "event_id", ''::text AS "business_node", "i"."invoice_num" AS "bill_no", COALESCE(CAST(i.verify_at AS date), i.from_date) AS "bill_date", NULL::timestamp without time zone AS "completed_at", "i"."amount" AS "amount", NULL::integer AS "client_id", "i"."supplier_id" AS "supplier_id", NULL::integer AS "contact_id", NULL::integer AS "department_id", "i"."handler" AS "handler_id", "i"."created_by" AS "created_by", NULL::integer AS "erp_bank_id", true AS "have_invoice", "i"."is_verify" AS "is_verified" FROM "a57be577deb434"."tbl_purchase_contract_invoices" "i" WHERE ("i"."is_cancel"=FALSE) AND ("i"."invoice_type"=-1) AND (COALESCE(CAST(i.verify_at AS date), i.from_date) >= '2026-05-01') AND (COALESCE(CAST(i.verify_at AS date), i.from_date) <= '2026-05-31') ) UNION ALL ( SELECT 7 AS "object_type", "c"."id" AS "object_id", 0 AS "event_type", 0 AS "event_id", ''::text AS "business_node", "c"."serial_no" AS "bill_no", "c"."signed_at" AS "bill_date", NULL::timestamp without time zone AS "completed_at", ROUND((COALESCE(NULLIF(SUM(p.total_amount), 0), c.amount, 0) * 1.13)::numeric, 2) AS "amount", "c"."client_id" AS "client_id", NULL::integer AS "supplier_id", NULL::integer AS "contact_id", NULL::integer AS "department_id", "c"."handler" AS "handler_id", "c"."created_by" AS "created_by", NULL::integer AS "erp_bank_id", true AS "have_invoice", true AS "is_verified" FROM "a57be577deb434"."tbl_sales_contracts" "c" LEFT JOIN "a57be577deb434"."tbl_project_product_rels" "p" ON p.project_id = c.from_project WHERE (COALESCE(c.including_tax, false) = false) AND (NOT ("c"."from_project" IS NULL)) AND (COALESCE(c.is_draft, false) = false) AND (COALESCE(c.is_verify, false) = false) AND (COALESCE(c.is_edit_verify, false) = false) AND (COALESCE(c.is_chargeback_verify, false) = false) AND ("c"."signed_at" >= '2026-05-01') AND ("c"."signed_at" <= '2026-05-31') GROUP BY "c"."id", "c"."serial_no", "c"."signed_at", "c"."amount", "c"."client_id", "c"."handler", "c"."created_by" ) UNION ALL ( SELECT 13 AS "object_type", "c"."id" AS "object_id", 0 AS "event_type", 0 AS "event_id", ''::text AS "business_node", "c"."serial_no" AS "bill_no", "c"."signed_at" AS "bill_date", NULL::timestamp without time zone AS "completed_at", ROUND((COALESCE(NULLIF(SUM(p.total_amount), 0), c.amount, 0) * 1.13)::numeric, 2) AS "amount", NULL::integer AS "client_id", "c"."supplier_id" AS "supplier_id", NULL::integer AS "contact_id", NULL::integer AS "department_id", "c"."handler" AS "handler_id", "c"."created_by" AS "created_by", NULL::integer AS "erp_bank_id", true AS "have_invoice", true AS "is_verified" FROM "a57be577deb434"."tbl_purchase_contracts" "c" LEFT JOIN "a57be577deb434"."tbl_purchase_contract_product_rels" "p" ON p.purchase_contract_id = c.id WHERE (COALESCE(c.including_tax, false) = false) AND (COALESCE(c.cost_type, 1) = 1) AND (COALESCE(c.is_draft, false) = false) AND (COALESCE(c.is_chargeback, false) = false) AND (COALESCE(c.is_verify, false) = false) AND (COALESCE(c.is_edit_verify, false) = false) AND (COALESCE(c.is_chargeback_verify, false) = false) AND ("c"."signed_at" >= '2026-05-01') AND ("c"."signed_at" <= '2026-05-31') GROUP BY "c"."id", "c"."serial_no", "c"."signed_at", "c"."amount", "c"."supplier_id", "c"."handler", "c"."created_by" ) UNION ALL ( SELECT 20008 AS "object_type", "e"."id" AS "object_id", 0 AS "event_type", 0 AS "event_id", ''::text AS "business_node", "e"."serial_no" AS "bill_no", "e"."wrote_date" AS "bill_date", NULL::timestamp without time zone AS "completed_at", CASE WHEN COALESCE(e.amount, 0) > 0 THEN COALESCE(e.amount, 0) ELSE COALESCE(SUM(s.actual_total_amount), 0) END AS "amount", "e"."client_id" AS "client_id", NULL::integer AS "supplier_id", NULL::integer AS "contact_id", NULL::integer AS "department_id", "e"."handler" AS "handler_id", "e"."created_by" AS "created_by", NULL::integer AS "erp_bank_id", true AS "have_invoice", true AS "is_verified" FROM "a57be577deb434"."tbl_erp_sales_outbounds" "e" LEFT JOIN "a57be577deb434"."tbl_erp_inventory_product_spents" "s" ON s.erp_sales_outbound_id = e.id WHERE ("e"."status"=2) AND ("e"."wrote_date" >= '2026-05-01') AND ("e"."wrote_date" <= '2026-05-31') GROUP BY "e"."id", "e"."serial_no", "e"."wrote_date", "e"."amount", "e"."client_id", "e"."handler", "e"."created_by" ) UNION ALL ( SELECT 20009 AS "object_type", "e"."id" AS "object_id", 0 AS "event_type", 0 AS "event_id", ''::text AS "business_node", "e"."serial_no" AS "bill_no", "e"."wrote_date" AS "bill_date", NULL::timestamp without time zone AS "completed_at", "e"."amount" AS "amount", "e"."client_id" AS "client_id", NULL::integer AS "supplier_id", NULL::integer AS "contact_id", NULL::integer AS "department_id", "e"."handler" AS "handler_id", "e"."created_by" AS "created_by", NULL::integer AS "erp_bank_id", true AS "have_invoice", true AS "is_verified" FROM "a57be577deb434"."tbl_erp_sales_returns" "e" WHERE ("e"."status"=2) AND ("e"."wrote_date" >= '2026-05-01') AND ("e"."wrote_date" <= '2026-05-31') ) UNION ALL ( SELECT 20003 AS "object_type", "e"."id" AS "object_id", 0 AS "event_type", 0 AS "event_id", ''::text AS "business_node", "e"."serial_no" AS "bill_no", "e"."wrote_date" AS "bill_date", NULL::timestamp without time zone AS "completed_at", COALESCE(NULLIF(SUM(p.total_amount), 0), e.amount, 0) AS "amount", NULL::integer AS "client_id", "e"."supplier_id" AS "supplier_id", NULL::integer AS "contact_id", NULL::integer AS "department_id", "e"."handler" AS "handler_id", "e"."created_by" AS "created_by", NULL::integer AS "erp_bank_id", true AS "have_invoice", true AS "is_verified" FROM "a57be577deb434"."tbl_erp_purchase_returns" "e" LEFT JOIN "a57be577deb434"."tbl_erp_purchase_return_products" "p" ON p.erp_purchase_return_id = e.id WHERE ("e"."status"=2) AND ("e"."wrote_date" >= '2026-05-01') AND ("e"."wrote_date" <= '2026-05-31') GROUP BY "e"."id", "e"."serial_no", "e"."wrote_date", "e"."amount", "e"."supplier_id", "e"."handler", "e"."created_by" ) UNION ALL ( SELECT 20013 AS "object_type", "e"."id" AS "object_id", 0 AS "event_type", 0 AS "event_id", ''::text AS "business_node", "e"."serial_no" AS "bill_no", "e"."wrote_date" AS "bill_date", NULL::timestamp without time zone AS "completed_at", "e"."amount" AS "amount", "e"."client_id" AS "client_id", "e"."supplier_id" AS "supplier_id", NULL::integer AS "contact_id", NULL::integer AS "department_id", "e"."handler" AS "handler_id", "e"."created_by" AS "created_by", NULL::integer AS "erp_bank_id", true AS "have_invoice", true AS "is_verified" FROM "a57be577deb434"."tbl_erp_collect_tickets" "e" WHERE ("e"."status"=2) AND ("e"."wrote_date" >= '2026-05-01') AND ("e"."wrote_date" <= '2026-05-31') ) UNION ALL ( SELECT 20012 AS "object_type", "e"."id" AS "object_id", 0 AS "event_type", 0 AS "event_id", ''::text AS "business_node", "e"."serial_no" AS "bill_no", "e"."wrote_date" AS "bill_date", NULL::timestamp without time zone AS "completed_at", "e"."amount" AS "amount", "e"."client_id" AS "client_id", "e"."supplier_id" AS "supplier_id", NULL::integer AS "contact_id", NULL::integer AS "department_id", "e"."handler" AS "handler_id", "e"."created_by" AS "created_by", NULL::integer AS "erp_bank_id", true AS "have_invoice", true AS "is_verified" FROM "a57be577deb434"."tbl_erp_payment_tickets" "e" WHERE ("e"."status"=2) AND ("e"."wrote_date" >= '2026-05-01') AND ("e"."wrote_date" <= '2026-05-31') ) UNION ALL ( SELECT 20019 AS "object_type", "e"."id" AS "object_id", 0 AS "event_type", 0 AS "event_id", ''::text AS "business_node", "e"."serial_no" AS "bill_no", "e"."wrote_date" AS "bill_date", NULL::timestamp without time zone AS "completed_at", "e"."amount" AS "amount", "e"."client_id" AS "client_id", "e"."supplier_id" AS "supplier_id", NULL::integer AS "contact_id", NULL::integer AS "department_id", "e"."handler" AS "handler_id", "e"."created_by" AS "created_by", NULL::integer AS "erp_bank_id", true AS "have_invoice", true AS "is_verified" FROM "a57be577deb434"."tbl_erp_advance_payment_tickets" "e" WHERE ("e"."status"=2) AND ("e"."wrote_date" >= '2026-05-01') AND ("e"."wrote_date" <= '2026-05-31') ) UNION ALL ( (SELECT 20021 AS "object_type", "t"."id" AS "object_id", 1 AS "event_type", "e"."id" AS "event_id", '付款'::text AS "business_node", "t"."serial_no" AS "bill_no", CAST(e.settle_at AS date) AS "bill_date", "e"."settle_at" AS "completed_at", "e"."amount" AS "amount", "t"."client_id" AS "client_id", "t"."supplier_id" AS "supplier_id", "t"."contact_id" AS "contact_id", NULL::integer AS "department_id", "t"."handler" AS "handler_id", "t"."created_by" AS "created_by", "e"."erp_bank_id" AS "erp_bank_id", true AS "have_invoice", true AS "is_verified" FROM "a57be577deb434"."tbl_erp_other_collect_tickets" "t" INNER JOIN "a57be577deb434"."tbl_erp_other_collect_ticket_bank_outs" "e" ON e.erp_other_collect_ticket_id = t.id WHERE ("t"."status" IN (2, 5)) AND (NOT ("e"."settle_at" IS NULL)) AND ("e"."amount" > 0) AND ("e"."settle_at" >= '2026-05-01') AND ("e"."settle_at" <= '2026-05-31 23:59:59')) UNION ALL ( SELECT 20021 AS "object_type", "t"."id" AS "object_id", 2 AS "event_type", "p"."id" AS "event_id", '收款'::text AS "business_node", "t"."serial_no" AS "bill_no", CAST(t.bank_settle_at AS date) AS "bill_date", "t"."bank_settle_at" AS "completed_at", "p"."amount" AS "amount", "t"."client_id" AS "client_id", "t"."supplier_id" AS "supplier_id", "t"."contact_id" AS "contact_id", NULL::integer AS "department_id", "t"."handler" AS "handler_id", "t"."created_by" AS "created_by", NULL::integer AS "erp_bank_id", true AS "have_invoice", true AS "is_verified" FROM "a57be577deb434"."tbl_erp_other_collect_tickets" "t" INNER JOIN "a57be577deb434"."tbl_erp_other_collect_ticket_payments" "p" ON p.erp_other_collect_ticket_id = t.id WHERE ("t"."status" IN (2, 5)) AND (NOT ("t"."bank_settle_at" IS NULL)) AND ("p"."amount" > 0) AND ("t"."bank_settle_at" >= '2026-05-01') AND ("t"."bank_settle_at" <= '2026-05-31 23:59:59') ) ) UNION ALL ( (SELECT 20020 AS "object_type", "t"."id" AS "object_id", 2 AS "event_type", "e"."id" AS "event_id", '收款'::text AS "business_node", "t"."serial_no" AS "bill_no", CAST(e.settle_at AS date) AS "bill_date", "e"."settle_at" AS "completed_at", "e"."amount" AS "amount", "t"."client_id" AS "client_id", "t"."supplier_id" AS "supplier_id", "t"."contact_id" AS "contact_id", NULL::integer AS "department_id", "t"."handler" AS "handler_id", "t"."created_by" AS "created_by", "e"."erp_bank_id" AS "erp_bank_id", true AS "have_invoice", true AS "is_verified" FROM "a57be577deb434"."tbl_erp_other_payment_tickets" "t" INNER JOIN "a57be577deb434"."tbl_erp_other_payment_ticket_bank_ins" "e" ON e.erp_other_payment_ticket_id = t.id WHERE ("t"."status" IN (2, 5)) AND (NOT ("e"."settle_at" IS NULL)) AND ("e"."amount" > 0) AND ("e"."settle_at" >= '2026-05-01') AND ("e"."settle_at" <= '2026-05-31 23:59:59')) UNION ALL ( SELECT 20020 AS "object_type", "t"."id" AS "object_id", 1 AS "event_type", "s"."id" AS "event_id", '付款'::text AS "business_node", "t"."serial_no" AS "bill_no", CAST(p.bank_settle_at AS date) AS "bill_date", "p"."bank_settle_at" AS "completed_at", "s"."amount" AS "amount", "t"."client_id" AS "client_id", "t"."supplier_id" AS "supplier_id", "t"."contact_id" AS "contact_id", NULL::integer AS "department_id", "t"."handler" AS "handler_id", "t"."created_by" AS "created_by", CASE WHEN COUNT(DISTINCT bo.erp_bank_id) = 1 THEN MIN(bo.erp_bank_id) ELSE NULL END AS "erp_bank_id", true AS "have_invoice", true AS "is_verified" FROM "a57be577deb434"."tbl_erp_payment_ticket_settles" "s" INNER JOIN "a57be577deb434"."tbl_erp_other_payment_tickets" "t" ON s.erp_other_payment_ticket_id = t.id INNER JOIN "a57be577deb434"."tbl_erp_payment_tickets" "p" ON s.erp_payment_ticket_id = p.id LEFT JOIN "a57be577deb434"."tbl_erp_payment_ticket_bank_outs" "bo" ON bo.erp_payment_ticket_id = p.id WHERE ("p"."status" IN (2, 5)) AND ("p"."is_payment_settle"=TRUE) AND (NOT ("p"."bank_settle_at" IS NULL)) AND ("s"."amount" > 0) AND ("p"."bank_settle_at" >= '2026-05-01') AND ("p"."bank_settle_at" <= '2026-05-31 23:59:59') GROUP BY "s"."id", "s"."amount", "t"."id", "t"."serial_no", "t"."client_id", "t"."supplier_id", "t"."contact_id", "t"."handler", "t"."created_by", "p"."bank_settle_at" ) ) UNION ALL ( SELECT 20015 AS "object_type", "t"."id" AS "object_id", 2 AS "event_type", "e"."id" AS "event_id", '收款'::text AS "business_node", "t"."serial_no" AS "bill_no", CAST(t.verify_at AS date) AS "bill_date", "e"."settle_at" AS "completed_at", "e"."amount" AS "amount", "t"."client_id" AS "client_id", "t"."supplier_id" AS "supplier_id", "t"."contact_id" AS "contact_id", CASE WHEN COUNT(DISTINCT u.department_id) = 1 THEN MIN(u.department_id) ELSE NULL END AS "department_id", CASE WHEN COUNT(DISTINCT h.user_id) = 1 THEN MIN(h.user_id) ELSE NULL END AS "handler_id", "t"."created_by" AS "created_by", "e"."erp_bank_id" AS "erp_bank_id", true AS "have_invoice", true AS "is_verified" FROM "a57be577deb434"."tbl_erp_other_income_tickets" "t" INNER JOIN "a57be577deb434"."tbl_erp_other_income_ticket_bank_ins" "e" ON e.erp_other_income_ticket_id = t.id LEFT JOIN "a57be577deb434"."tbl_erp_other_income_ticket_handlers" "h" ON h.erp_other_income_ticket_id = t.id LEFT JOIN "a57be577deb434"."tbl_users" "u" ON u.id = h.user_id WHERE ("t"."status"=2) AND (NOT ("t"."verify_at" IS NULL)) AND (NOT ("e"."settle_at" IS NULL)) AND ("e"."amount" > 0) AND ("t"."verify_at" >= '2026-05-01') AND ("t"."verify_at" <= '2026-05-31 23:59:59') GROUP BY "t"."id", "t"."serial_no", "t"."verify_at", "t"."client_id", "t"."supplier_id", "t"."contact_id", "t"."created_by", "e"."id", "e"."settle_at", "e"."amount", "e"."erp_bank_id" ) UNION ALL ( SELECT 20014 AS "object_type", "e"."id" AS "object_id", 0 AS "event_type", 0 AS "event_id", ''::text AS "business_node", "e"."serial_no" AS "bill_no", "e"."wrote_date" AS "bill_date", NULL::timestamp without time zone AS "completed_at", "e"."amount" AS "amount", "e"."client_id" AS "client_id", "e"."supplier_id" AS "supplier_id", "e"."contact_id" AS "contact_id", NULL::integer AS "department_id", NULL::integer AS "handler_id", "e"."created_by" AS "created_by", NULL::integer AS "erp_bank_id", true AS "have_invoice", true AS "is_verified" FROM "a57be577deb434"."tbl_erp_cost_tickets" "e" WHERE ("e"."status"=2) AND ("e"."wrote_date" >= '2026-05-01') AND ("e"."wrote_date" <= '2026-05-31') ) UNION ALL ( SELECT 20018 AS "object_type", "e"."id" AS "object_id", 0 AS "event_type", 0 AS "event_id", ''::text AS "business_node", "e"."serial_no" AS "bill_no", "e"."wrote_date" AS "bill_date", NULL::timestamp without time zone AS "completed_at", "e"."amount" AS "amount", "e"."client_id" AS "client_id", "e"."supplier_id" AS "supplier_id", NULL::integer AS "contact_id", NULL::integer AS "department_id", NULL::integer AS "handler_id", "e"."created_by" AS "created_by", NULL::integer AS "erp_bank_id", "e"."have_invoice" AS "have_invoice", true AS "is_verified" FROM "a57be577deb434"."tbl_erp_cash_cost_tickets" "e" WHERE ("e"."status"=2) AND ("e"."wrote_date" >= '2026-05-01') AND ("e"."wrote_date" <= '2026-05-31') ) UNION ALL ( SELECT 20011 AS "object_type", "e"."id" AS "object_id", 0 AS "event_type", 0 AS "event_id", ''::text AS "business_node", "e"."serial_no" AS "bill_no", "e"."wrote_date" AS "bill_date", NULL::timestamp without time zone AS "completed_at", COALESCE(SUM(s.actual_total_amount), 0) AS "amount", "e"."client_id" AS "client_id", NULL::integer AS "supplier_id", NULL::integer AS "contact_id", NULL::integer AS "department_id", "e"."handler" AS "handler_id", "e"."created_by" AS "created_by", NULL::integer AS "erp_bank_id", true AS "have_invoice", true AS "is_verified" FROM "a57be577deb434"."tbl_erp_sales_gifts" "e" LEFT JOIN "a57be577deb434"."tbl_erp_inventory_product_spents" "s" ON s.erp_sales_gift_id = e.id WHERE ("e"."status"=2) AND ("e"."wrote_date" >= '2026-05-01') AND ("e"."wrote_date" <= '2026-05-31') GROUP BY "e"."id", "e"."serial_no", "e"."wrote_date", "e"."client_id", "e"."handler", "e"."created_by" ) UNION ALL ( SELECT 20004 AS "object_type", "e"."id" AS "object_id", 0 AS "event_type", 0 AS "event_id", ''::text AS "business_node", "e"."serial_no" AS "bill_no", "e"."wrote_date" AS "bill_date", NULL::timestamp without time zone AS "completed_at", "e"."amount" AS "amount", NULL::integer AS "client_id", NULL::integer AS "supplier_id", NULL::integer AS "contact_id", NULL::integer AS "department_id", "e"."handler" AS "handler_id", "e"."created_by" AS "created_by", NULL::integer AS "erp_bank_id", true AS "have_invoice", true AS "is_verified" FROM "a57be577deb434"."tbl_erp_inventory_losts" "e" WHERE ("e"."status"=2) AND ("e"."wrote_date" >= '2026-05-01') AND ("e"."wrote_date" <= '2026-05-31') ) UNION ALL ( SELECT 20031 AS "object_type", "e"."id" AS "object_id", 0 AS "event_type", 0 AS "event_id", ''::text AS "business_node", "e"."serial_no" AS "bill_no", "e"."wrote_date" AS "bill_date", NULL::timestamp without time zone AS "completed_at", "e"."amount" AS "amount", NULL::integer AS "client_id", NULL::integer AS "supplier_id", NULL::integer AS "contact_id", NULL::integer AS "department_id", "e"."handler" AS "handler_id", "e"."created_by" AS "created_by", NULL::integer AS "erp_bank_id", true AS "have_invoice", true AS "is_verified" FROM "a57be577deb434"."tbl_erp_inventory_overflows" "e" WHERE ("e"."status"=2) AND ("e"."wrote_date" >= '2026-05-01') AND ("e"."wrote_date" <= '2026-05-31') ) UNION ALL ( SELECT 20023 AS "object_type", "t"."id" AS "object_id", 1 AS "event_type", "e"."id" AS "event_id", '付款'::text AS "business_node", "t"."serial_no" AS "bill_no", CAST(e.settle_at AS date) AS "bill_date", "e"."settle_at" AS "completed_at", "e"."amount" AS "amount", NULL::integer AS "client_id", NULL::integer AS "supplier_id", NULL::integer AS "contact_id", CASE WHEN COUNT(DISTINCT u.department_id) = 1 THEN MIN(u.department_id) ELSE NULL END AS "department_id", CASE WHEN COUNT(DISTINCT a.user_id) = 1 THEN MIN(a.user_id) ELSE NULL END AS "handler_id", NULL::integer AS "created_by", "e"."erp_bank_id" AS "erp_bank_id", true AS "have_invoice", true AS "is_verified" FROM "a57be577deb434"."tbl_erp_wage_tickets" "t" INNER JOIN "a57be577deb434"."tbl_erp_wage_ticket_bank_outs" "e" ON e.erp_wage_ticket_id = t.id LEFT JOIN "a57be577deb434"."tbl_erp_wage_ticket_amounts" "a" ON a.erp_wage_ticket_id = t.id LEFT JOIN "a57be577deb434"."tbl_users" "u" ON u.id = a.user_id WHERE ("t"."status" IN (2, 5)) AND (NOT ("e"."settle_at" IS NULL)) AND ("e"."amount" > 0) AND ("e"."settle_at" >= '2026-05-01') AND ("e"."settle_at" <= '2026-05-31 23:59:59') GROUP BY "t"."id", "t"."serial_no", "e"."id", "e"."settle_at", "e"."amount", "e"."erp_bank_id" ) UNION ALL ( SELECT 20024 AS "object_type", "t"."id" AS "object_id", 1 AS "event_type", "e"."id" AS "event_id", '付款'::text AS "business_node", "t"."serial_no" AS "bill_no", CAST(e.settle_at AS date) AS "bill_date", "e"."settle_at" AS "completed_at", "e"."amount" AS "amount", NULL::integer AS "client_id", NULL::integer AS "supplier_id", NULL::integer AS "contact_id", CASE WHEN COUNT(DISTINCT u.department_id) = 1 THEN MIN(u.department_id) ELSE NULL END AS "department_id", CASE WHEN COUNT(DISTINCT a.user_id) = 1 THEN MIN(a.user_id) ELSE NULL END AS "handler_id", NULL::integer AS "created_by", "e"."erp_bank_id" AS "erp_bank_id", true AS "have_invoice", true AS "is_verified" FROM "a57be577deb434"."tbl_erp_social_insurances" "t" INNER JOIN "a57be577deb434"."tbl_erp_social_insurance_bank_outs" "e" ON e.erp_social_insurance_id = t.id LEFT JOIN "a57be577deb434"."tbl_erp_social_insurance_amounts" "a" ON a.erp_social_insurance_id = t.id LEFT JOIN "a57be577deb434"."tbl_users" "u" ON u.id = a.user_id WHERE ("t"."status" IN (2, 5)) AND (NOT ("e"."settle_at" IS NULL)) AND ("e"."amount" > 0) AND ("e"."settle_at" >= '2026-05-01') AND ("e"."settle_at" <= '2026-05-31 23:59:59') GROUP BY "t"."id", "t"."serial_no", "e"."id", "e"."settle_at", "e"."amount", "e"."erp_bank_id" ) UNION ALL ( SELECT 20026 AS "object_type", "t"."id" AS "object_id", 1 AS "event_type", "e"."id" AS "event_id", '付款'::text AS "business_node", "t"."serial_no" AS "bill_no", CAST(e.settle_at AS date) AS "bill_date", "e"."settle_at" AS "completed_at", "e"."amount" AS "amount", NULL::integer AS "client_id", NULL::integer AS "supplier_id", NULL::integer AS "contact_id", CASE WHEN COUNT(DISTINCT u.department_id) = 1 THEN MIN(u.department_id) ELSE NULL END AS "department_id", CASE WHEN COUNT(DISTINCT a.user_id) = 1 THEN MIN(a.user_id) ELSE NULL END AS "handler_id", NULL::integer AS "created_by", "e"."erp_bank_id" AS "erp_bank_id", true AS "have_invoice", true AS "is_verified" FROM "a57be577deb434"."tbl_erp_personal_taxs" "t" INNER JOIN "a57be577deb434"."tbl_erp_personal_tax_bank_outs" "e" ON e.erp_personal_tax_id = t.id LEFT JOIN "a57be577deb434"."tbl_erp_personal_tax_amounts" "a" ON a.erp_personal_tax_id = t.id LEFT JOIN "a57be577deb434"."tbl_users" "u" ON u.id = a.user_id WHERE ("t"."status" IN (2, 5)) AND (NOT ("e"."settle_at" IS NULL)) AND ("e"."amount" > 0) AND ("e"."settle_at" >= '2026-05-01') AND ("e"."settle_at" <= '2026-05-31 23:59:59') GROUP BY "t"."id", "t"."serial_no", "e"."id", "e"."settle_at", "e"."amount", "e"."erp_bank_id" ) UNION ALL ( SELECT 20027 AS "object_type", "t"."id" AS "object_id", 1 AS "event_type", "e"."id" AS "event_id", '付款'::text AS "business_node", "t"."serial_no" AS "bill_no", CAST(e.settle_at AS date) AS "bill_date", "e"."settle_at" AS "completed_at", "e"."amount" AS "amount", NULL::integer AS "client_id", NULL::integer AS "supplier_id", NULL::integer AS "contact_id", CASE WHEN COUNT(DISTINCT u.department_id) = 1 THEN MIN(u.department_id) ELSE NULL END AS "department_id", CASE WHEN COUNT(DISTINCT a.user_id) = 1 THEN MIN(a.user_id) ELSE NULL END AS "handler_id", NULL::integer AS "created_by", "e"."erp_bank_id" AS "erp_bank_id", true AS "have_invoice", true AS "is_verified" FROM "a57be577deb434"."tbl_erp_wage_prizes" "t" INNER JOIN "a57be577deb434"."tbl_erp_wage_prize_bank_outs" "e" ON e.erp_wage_prize_id = t.id LEFT JOIN "a57be577deb434"."tbl_erp_wage_prize_amounts" "a" ON a.erp_wage_prize_id = t.id LEFT JOIN "a57be577deb434"."tbl_users" "u" ON u.id = a.user_id WHERE ("t"."status" IN (2, 5)) AND (NOT ("e"."settle_at" IS NULL)) AND ("e"."amount" > 0) AND ("e"."settle_at" >= '2026-05-01') AND ("e"."settle_at" <= '2026-05-31 23:59:59') GROUP BY "t"."id", "t"."serial_no", "e"."id", "e"."settle_at", "e"."amount", "e"."erp_bank_id" ) UNION ALL ( SELECT 20025 AS "object_type", "t"."id" AS "object_id", 1 AS "event_type", "e"."id" AS "event_id", '付款'::text AS "business_node", "t"."serial_no" AS "bill_no", CAST(e.settle_at AS date) AS "bill_date", "e"."settle_at" AS "completed_at", "e"."amount" AS "amount", NULL::integer AS "client_id", NULL::integer AS "supplier_id", NULL::integer AS "contact_id", CASE WHEN COUNT(DISTINCT u.department_id) = 1 THEN MIN(u.department_id) ELSE NULL END AS "department_id", CASE WHEN COUNT(DISTINCT a.user_id) = 1 THEN MIN(a.user_id) ELSE NULL END AS "handler_id", NULL::integer AS "created_by", "e"."erp_bank_id" AS "erp_bank_id", true AS "have_invoice", true AS "is_verified" FROM "a57be577deb434"."tbl_erp_provident_funds" "t" INNER JOIN "a57be577deb434"."tbl_erp_provident_fund_bank_outs" "e" ON e.erp_provident_fund_id = t.id LEFT JOIN "a57be577deb434"."tbl_erp_provident_fund_amounts" "a" ON a.erp_provident_fund_id = t.id LEFT JOIN "a57be577deb434"."tbl_users" "u" ON u.id = a.user_id WHERE ("t"."status" IN (2, 5)) AND (NOT ("e"."settle_at" IS NULL)) AND ("e"."amount" > 0) AND ("e"."settle_at" >= '2026-05-01') AND ("e"."settle_at" <= '2026-05-31 23:59:59') GROUP BY "t"."id", "t"."serial_no", "e"."id", "e"."settle_at", "e"."amount", "e"."erp_bank_id" )) "b" LEFT JOIN (SELECT "v"."object_type" AS "object_type", "v"."object_id" AS "object_id", COALESCE(v.event_type, 0) AS "event_type", COALESCE(v.event_id, 0) AS "event_id", COUNT(*) FILTER (WHERE v.status = 1) AS "success_count", COUNT(*) FILTER (WHERE v.status = 0) AS "fail_count", MAX(v.book_date) FILTER (WHERE v.status = 1) AS "last_book_date" FROM "a57be577deb434"."tbl_voucher_gen_items" "v" WHERE "v"."ledger_id"=1 GROUP BY "v"."object_type", "v"."object_id", COALESCE(v.event_type, 0), COALESCE(v.event_id, 0)) "g" ON g.object_type = b.object_type AND g.object_id = b.object_id AND g.event_type = b.event_type AND g.event_id = b.event_id WHERE (("g"."success_count" IS NULL) OR ("g"."success_count"=0)) AND (("b"."object_type" NOT IN (20, 20018)) OR ("b"."have_invoice"=TRUE)) AND ("b"."amount" > 0) AND (("b"."object_type" <> 109) OR (("b"."is_verified"=TRUE) AND ("b"."bill_date" >= '2026-06-01') AND ("b"."bill_date" <= '2026-06-30'))) ORDER BY "bill_date" DESC, "object_type", "object_id" DESC, "event_type", "event_id" DESC LIMIT 200 |
| 17:43:29.327 | 28.7 ms | yii\db\Command::query | SELECT COALESCE(SUM(b.amount), 0) AS "total_amount" FROM ((SELECT 107 AS "object_type", "i"."id" AS "object_id", 0 AS "event_type", 0 AS "event_id", ''::text AS "business_node", "i"."invoice_num" AS "bill_no", "i"."from_date" AS "bill_date", NULL::timestamp without time zone AS "completed_at", "i"."amount" AS "amount", "c"."client_id" AS "client_id", NULL::integer AS "supplier_id", NULL::integer AS "contact_id", NULL::integer AS "department_id", NULL::integer AS "handler_id", "i"."created_by" AS "created_by", NULL::integer AS "erp_bank_id", true AS "have_invoice", true AS "is_verified" FROM "a57be577deb434"."tbl_sales_contract_invoices" "i" LEFT JOIN "a57be577deb434"."tbl_sales_contracts" "c" ON c.id = i.contract_id WHERE (("i"."is_cancel"=FALSE) AND ("i"."is_draft"=FALSE)) AND (("i"."invoice_type" <> -1) OR ("i"."invoice_type" IS NULL)) AND ("i"."from_date" >= '2026-05-01') AND ("i"."from_date" <= '2026-05-31')) UNION ALL ( SELECT 107 AS "object_type", "i"."id" AS "object_id", 0 AS "event_type", 0 AS "event_id", ''::text AS "business_node", "i"."invoice_num" AS "bill_no", "i"."from_date" AS "bill_date", NULL::timestamp without time zone AS "completed_at", "i"."amount" AS "amount", "c"."client_id" AS "client_id", NULL::integer AS "supplier_id", NULL::integer AS "contact_id", NULL::integer AS "department_id", NULL::integer AS "handler_id", "i"."created_by" AS "created_by", NULL::integer AS "erp_bank_id", true AS "have_invoice", true AS "is_verified" FROM "a57be577deb434"."tbl_sales_contract_invoices" "i" LEFT JOIN "a57be577deb434"."tbl_sales_contracts" "c" ON c.id = i.contract_id WHERE (("i"."is_cancel"=FALSE) AND ("i"."is_draft"=FALSE)) AND ("i"."invoice_type"=-1) AND ("i"."from_date" >= '2026-05-01') AND ("i"."from_date" <= '2026-05-31') ) UNION ALL ( SELECT 109 AS "object_type", "i"."id" AS "object_id", 0 AS "event_type", 0 AS "event_id", ''::text AS "business_node", "i"."invoice_num" AS "bill_no", COALESCE(CAST(i.verify_at AS date), i.from_date) AS "bill_date", NULL::timestamp without time zone AS "completed_at", "i"."amount" AS "amount", NULL::integer AS "client_id", "i"."supplier_id" AS "supplier_id", NULL::integer AS "contact_id", NULL::integer AS "department_id", "i"."handler" AS "handler_id", "i"."created_by" AS "created_by", NULL::integer AS "erp_bank_id", true AS "have_invoice", "i"."is_verify" AS "is_verified" FROM "a57be577deb434"."tbl_purchase_contract_invoices" "i" WHERE ("i"."is_cancel"=FALSE) AND (("i"."invoice_type" <> -1) OR ("i"."invoice_type" IS NULL)) AND (COALESCE(CAST(i.verify_at AS date), i.from_date) >= '2026-05-01') AND (COALESCE(CAST(i.verify_at AS date), i.from_date) <= '2026-05-31') ) UNION ALL ( SELECT 109 AS "object_type", "i"."id" AS "object_id", 0 AS "event_type", 0 AS "event_id", ''::text AS "business_node", "i"."invoice_num" AS "bill_no", COALESCE(CAST(i.verify_at AS date), i.from_date) AS "bill_date", NULL::timestamp without time zone AS "completed_at", "i"."amount" AS "amount", NULL::integer AS "client_id", "i"."supplier_id" AS "supplier_id", NULL::integer AS "contact_id", NULL::integer AS "department_id", "i"."handler" AS "handler_id", "i"."created_by" AS "created_by", NULL::integer AS "erp_bank_id", true AS "have_invoice", "i"."is_verify" AS "is_verified" FROM "a57be577deb434"."tbl_purchase_contract_invoices" "i" WHERE ("i"."is_cancel"=FALSE) AND ("i"."invoice_type"=-1) AND (COALESCE(CAST(i.verify_at AS date), i.from_date) >= '2026-05-01') AND (COALESCE(CAST(i.verify_at AS date), i.from_date) <= '2026-05-31') ) UNION ALL ( SELECT 7 AS "object_type", "c"."id" AS "object_id", 0 AS "event_type", 0 AS "event_id", ''::text AS "business_node", "c"."serial_no" AS "bill_no", "c"."signed_at" AS "bill_date", NULL::timestamp without time zone AS "completed_at", ROUND((COALESCE(NULLIF(SUM(p.total_amount), 0), c.amount, 0) * 1.13)::numeric, 2) AS "amount", "c"."client_id" AS "client_id", NULL::integer AS "supplier_id", NULL::integer AS "contact_id", NULL::integer AS "department_id", "c"."handler" AS "handler_id", "c"."created_by" AS "created_by", NULL::integer AS "erp_bank_id", true AS "have_invoice", true AS "is_verified" FROM "a57be577deb434"."tbl_sales_contracts" "c" LEFT JOIN "a57be577deb434"."tbl_project_product_rels" "p" ON p.project_id = c.from_project WHERE (COALESCE(c.including_tax, false) = false) AND (NOT ("c"."from_project" IS NULL)) AND (COALESCE(c.is_draft, false) = false) AND (COALESCE(c.is_verify, false) = false) AND (COALESCE(c.is_edit_verify, false) = false) AND (COALESCE(c.is_chargeback_verify, false) = false) AND ("c"."signed_at" >= '2026-05-01') AND ("c"."signed_at" <= '2026-05-31') GROUP BY "c"."id", "c"."serial_no", "c"."signed_at", "c"."amount", "c"."client_id", "c"."handler", "c"."created_by" ) UNION ALL ( SELECT 13 AS "object_type", "c"."id" AS "object_id", 0 AS "event_type", 0 AS "event_id", ''::text AS "business_node", "c"."serial_no" AS "bill_no", "c"."signed_at" AS "bill_date", NULL::timestamp without time zone AS "completed_at", ROUND((COALESCE(NULLIF(SUM(p.total_amount), 0), c.amount, 0) * 1.13)::numeric, 2) AS "amount", NULL::integer AS "client_id", "c"."supplier_id" AS "supplier_id", NULL::integer AS "contact_id", NULL::integer AS "department_id", "c"."handler" AS "handler_id", "c"."created_by" AS "created_by", NULL::integer AS "erp_bank_id", true AS "have_invoice", true AS "is_verified" FROM "a57be577deb434"."tbl_purchase_contracts" "c" LEFT JOIN "a57be577deb434"."tbl_purchase_contract_product_rels" "p" ON p.purchase_contract_id = c.id WHERE (COALESCE(c.including_tax, false) = false) AND (COALESCE(c.cost_type, 1) = 1) AND (COALESCE(c.is_draft, false) = false) AND (COALESCE(c.is_chargeback, false) = false) AND (COALESCE(c.is_verify, false) = false) AND (COALESCE(c.is_edit_verify, false) = false) AND (COALESCE(c.is_chargeback_verify, false) = false) AND ("c"."signed_at" >= '2026-05-01') AND ("c"."signed_at" <= '2026-05-31') GROUP BY "c"."id", "c"."serial_no", "c"."signed_at", "c"."amount", "c"."supplier_id", "c"."handler", "c"."created_by" ) UNION ALL ( SELECT 20008 AS "object_type", "e"."id" AS "object_id", 0 AS "event_type", 0 AS "event_id", ''::text AS "business_node", "e"."serial_no" AS "bill_no", "e"."wrote_date" AS "bill_date", NULL::timestamp without time zone AS "completed_at", CASE WHEN COALESCE(e.amount, 0) > 0 THEN COALESCE(e.amount, 0) ELSE COALESCE(SUM(s.actual_total_amount), 0) END AS "amount", "e"."client_id" AS "client_id", NULL::integer AS "supplier_id", NULL::integer AS "contact_id", NULL::integer AS "department_id", "e"."handler" AS "handler_id", "e"."created_by" AS "created_by", NULL::integer AS "erp_bank_id", true AS "have_invoice", true AS "is_verified" FROM "a57be577deb434"."tbl_erp_sales_outbounds" "e" LEFT JOIN "a57be577deb434"."tbl_erp_inventory_product_spents" "s" ON s.erp_sales_outbound_id = e.id WHERE ("e"."status"=2) AND ("e"."wrote_date" >= '2026-05-01') AND ("e"."wrote_date" <= '2026-05-31') GROUP BY "e"."id", "e"."serial_no", "e"."wrote_date", "e"."amount", "e"."client_id", "e"."handler", "e"."created_by" ) UNION ALL ( SELECT 20009 AS "object_type", "e"."id" AS "object_id", 0 AS "event_type", 0 AS "event_id", ''::text AS "business_node", "e"."serial_no" AS "bill_no", "e"."wrote_date" AS "bill_date", NULL::timestamp without time zone AS "completed_at", "e"."amount" AS "amount", "e"."client_id" AS "client_id", NULL::integer AS "supplier_id", NULL::integer AS "contact_id", NULL::integer AS "department_id", "e"."handler" AS "handler_id", "e"."created_by" AS "created_by", NULL::integer AS "erp_bank_id", true AS "have_invoice", true AS "is_verified" FROM "a57be577deb434"."tbl_erp_sales_returns" "e" WHERE ("e"."status"=2) AND ("e"."wrote_date" >= '2026-05-01') AND ("e"."wrote_date" <= '2026-05-31') ) UNION ALL ( SELECT 20003 AS "object_type", "e"."id" AS "object_id", 0 AS "event_type", 0 AS "event_id", ''::text AS "business_node", "e"."serial_no" AS "bill_no", "e"."wrote_date" AS "bill_date", NULL::timestamp without time zone AS "completed_at", COALESCE(NULLIF(SUM(p.total_amount), 0), e.amount, 0) AS "amount", NULL::integer AS "client_id", "e"."supplier_id" AS "supplier_id", NULL::integer AS "contact_id", NULL::integer AS "department_id", "e"."handler" AS "handler_id", "e"."created_by" AS "created_by", NULL::integer AS "erp_bank_id", true AS "have_invoice", true AS "is_verified" FROM "a57be577deb434"."tbl_erp_purchase_returns" "e" LEFT JOIN "a57be577deb434"."tbl_erp_purchase_return_products" "p" ON p.erp_purchase_return_id = e.id WHERE ("e"."status"=2) AND ("e"."wrote_date" >= '2026-05-01') AND ("e"."wrote_date" <= '2026-05-31') GROUP BY "e"."id", "e"."serial_no", "e"."wrote_date", "e"."amount", "e"."supplier_id", "e"."handler", "e"."created_by" ) UNION ALL ( SELECT 20013 AS "object_type", "e"."id" AS "object_id", 0 AS "event_type", 0 AS "event_id", ''::text AS "business_node", "e"."serial_no" AS "bill_no", "e"."wrote_date" AS "bill_date", NULL::timestamp without time zone AS "completed_at", "e"."amount" AS "amount", "e"."client_id" AS "client_id", "e"."supplier_id" AS "supplier_id", NULL::integer AS "contact_id", NULL::integer AS "department_id", "e"."handler" AS "handler_id", "e"."created_by" AS "created_by", NULL::integer AS "erp_bank_id", true AS "have_invoice", true AS "is_verified" FROM "a57be577deb434"."tbl_erp_collect_tickets" "e" WHERE ("e"."status"=2) AND ("e"."wrote_date" >= '2026-05-01') AND ("e"."wrote_date" <= '2026-05-31') ) UNION ALL ( SELECT 20012 AS "object_type", "e"."id" AS "object_id", 0 AS "event_type", 0 AS "event_id", ''::text AS "business_node", "e"."serial_no" AS "bill_no", "e"."wrote_date" AS "bill_date", NULL::timestamp without time zone AS "completed_at", "e"."amount" AS "amount", "e"."client_id" AS "client_id", "e"."supplier_id" AS "supplier_id", NULL::integer AS "contact_id", NULL::integer AS "department_id", "e"."handler" AS "handler_id", "e"."created_by" AS "created_by", NULL::integer AS "erp_bank_id", true AS "have_invoice", true AS "is_verified" FROM "a57be577deb434"."tbl_erp_payment_tickets" "e" WHERE ("e"."status"=2) AND ("e"."wrote_date" >= '2026-05-01') AND ("e"."wrote_date" <= '2026-05-31') ) UNION ALL ( SELECT 20019 AS "object_type", "e"."id" AS "object_id", 0 AS "event_type", 0 AS "event_id", ''::text AS "business_node", "e"."serial_no" AS "bill_no", "e"."wrote_date" AS "bill_date", NULL::timestamp without time zone AS "completed_at", "e"."amount" AS "amount", "e"."client_id" AS "client_id", "e"."supplier_id" AS "supplier_id", NULL::integer AS "contact_id", NULL::integer AS "department_id", "e"."handler" AS "handler_id", "e"."created_by" AS "created_by", NULL::integer AS "erp_bank_id", true AS "have_invoice", true AS "is_verified" FROM "a57be577deb434"."tbl_erp_advance_payment_tickets" "e" WHERE ("e"."status"=2) AND ("e"."wrote_date" >= '2026-05-01') AND ("e"."wrote_date" <= '2026-05-31') ) UNION ALL ( (SELECT 20021 AS "object_type", "t"."id" AS "object_id", 1 AS "event_type", "e"."id" AS "event_id", '付款'::text AS "business_node", "t"."serial_no" AS "bill_no", CAST(e.settle_at AS date) AS "bill_date", "e"."settle_at" AS "completed_at", "e"."amount" AS "amount", "t"."client_id" AS "client_id", "t"."supplier_id" AS "supplier_id", "t"."contact_id" AS "contact_id", NULL::integer AS "department_id", "t"."handler" AS "handler_id", "t"."created_by" AS "created_by", "e"."erp_bank_id" AS "erp_bank_id", true AS "have_invoice", true AS "is_verified" FROM "a57be577deb434"."tbl_erp_other_collect_tickets" "t" INNER JOIN "a57be577deb434"."tbl_erp_other_collect_ticket_bank_outs" "e" ON e.erp_other_collect_ticket_id = t.id WHERE ("t"."status" IN (2, 5)) AND (NOT ("e"."settle_at" IS NULL)) AND ("e"."amount" > 0) AND ("e"."settle_at" >= '2026-05-01') AND ("e"."settle_at" <= '2026-05-31 23:59:59')) UNION ALL ( SELECT 20021 AS "object_type", "t"."id" AS "object_id", 2 AS "event_type", "p"."id" AS "event_id", '收款'::text AS "business_node", "t"."serial_no" AS "bill_no", CAST(t.bank_settle_at AS date) AS "bill_date", "t"."bank_settle_at" AS "completed_at", "p"."amount" AS "amount", "t"."client_id" AS "client_id", "t"."supplier_id" AS "supplier_id", "t"."contact_id" AS "contact_id", NULL::integer AS "department_id", "t"."handler" AS "handler_id", "t"."created_by" AS "created_by", NULL::integer AS "erp_bank_id", true AS "have_invoice", true AS "is_verified" FROM "a57be577deb434"."tbl_erp_other_collect_tickets" "t" INNER JOIN "a57be577deb434"."tbl_erp_other_collect_ticket_payments" "p" ON p.erp_other_collect_ticket_id = t.id WHERE ("t"."status" IN (2, 5)) AND (NOT ("t"."bank_settle_at" IS NULL)) AND ("p"."amount" > 0) AND ("t"."bank_settle_at" >= '2026-05-01') AND ("t"."bank_settle_at" <= '2026-05-31 23:59:59') ) ) UNION ALL ( (SELECT 20020 AS "object_type", "t"."id" AS "object_id", 2 AS "event_type", "e"."id" AS "event_id", '收款'::text AS "business_node", "t"."serial_no" AS "bill_no", CAST(e.settle_at AS date) AS "bill_date", "e"."settle_at" AS "completed_at", "e"."amount" AS "amount", "t"."client_id" AS "client_id", "t"."supplier_id" AS "supplier_id", "t"."contact_id" AS "contact_id", NULL::integer AS "department_id", "t"."handler" AS "handler_id", "t"."created_by" AS "created_by", "e"."erp_bank_id" AS "erp_bank_id", true AS "have_invoice", true AS "is_verified" FROM "a57be577deb434"."tbl_erp_other_payment_tickets" "t" INNER JOIN "a57be577deb434"."tbl_erp_other_payment_ticket_bank_ins" "e" ON e.erp_other_payment_ticket_id = t.id WHERE ("t"."status" IN (2, 5)) AND (NOT ("e"."settle_at" IS NULL)) AND ("e"."amount" > 0) AND ("e"."settle_at" >= '2026-05-01') AND ("e"."settle_at" <= '2026-05-31 23:59:59')) UNION ALL ( SELECT 20020 AS "object_type", "t"."id" AS "object_id", 1 AS "event_type", "s"."id" AS "event_id", '付款'::text AS "business_node", "t"."serial_no" AS "bill_no", CAST(p.bank_settle_at AS date) AS "bill_date", "p"."bank_settle_at" AS "completed_at", "s"."amount" AS "amount", "t"."client_id" AS "client_id", "t"."supplier_id" AS "supplier_id", "t"."contact_id" AS "contact_id", NULL::integer AS "department_id", "t"."handler" AS "handler_id", "t"."created_by" AS "created_by", CASE WHEN COUNT(DISTINCT bo.erp_bank_id) = 1 THEN MIN(bo.erp_bank_id) ELSE NULL END AS "erp_bank_id", true AS "have_invoice", true AS "is_verified" FROM "a57be577deb434"."tbl_erp_payment_ticket_settles" "s" INNER JOIN "a57be577deb434"."tbl_erp_other_payment_tickets" "t" ON s.erp_other_payment_ticket_id = t.id INNER JOIN "a57be577deb434"."tbl_erp_payment_tickets" "p" ON s.erp_payment_ticket_id = p.id LEFT JOIN "a57be577deb434"."tbl_erp_payment_ticket_bank_outs" "bo" ON bo.erp_payment_ticket_id = p.id WHERE ("p"."status" IN (2, 5)) AND ("p"."is_payment_settle"=TRUE) AND (NOT ("p"."bank_settle_at" IS NULL)) AND ("s"."amount" > 0) AND ("p"."bank_settle_at" >= '2026-05-01') AND ("p"."bank_settle_at" <= '2026-05-31 23:59:59') GROUP BY "s"."id", "s"."amount", "t"."id", "t"."serial_no", "t"."client_id", "t"."supplier_id", "t"."contact_id", "t"."handler", "t"."created_by", "p"."bank_settle_at" ) ) UNION ALL ( SELECT 20015 AS "object_type", "t"."id" AS "object_id", 2 AS "event_type", "e"."id" AS "event_id", '收款'::text AS "business_node", "t"."serial_no" AS "bill_no", CAST(t.verify_at AS date) AS "bill_date", "e"."settle_at" AS "completed_at", "e"."amount" AS "amount", "t"."client_id" AS "client_id", "t"."supplier_id" AS "supplier_id", "t"."contact_id" AS "contact_id", CASE WHEN COUNT(DISTINCT u.department_id) = 1 THEN MIN(u.department_id) ELSE NULL END AS "department_id", CASE WHEN COUNT(DISTINCT h.user_id) = 1 THEN MIN(h.user_id) ELSE NULL END AS "handler_id", "t"."created_by" AS "created_by", "e"."erp_bank_id" AS "erp_bank_id", true AS "have_invoice", true AS "is_verified" FROM "a57be577deb434"."tbl_erp_other_income_tickets" "t" INNER JOIN "a57be577deb434"."tbl_erp_other_income_ticket_bank_ins" "e" ON e.erp_other_income_ticket_id = t.id LEFT JOIN "a57be577deb434"."tbl_erp_other_income_ticket_handlers" "h" ON h.erp_other_income_ticket_id = t.id LEFT JOIN "a57be577deb434"."tbl_users" "u" ON u.id = h.user_id WHERE ("t"."status"=2) AND (NOT ("t"."verify_at" IS NULL)) AND (NOT ("e"."settle_at" IS NULL)) AND ("e"."amount" > 0) AND ("t"."verify_at" >= '2026-05-01') AND ("t"."verify_at" <= '2026-05-31 23:59:59') GROUP BY "t"."id", "t"."serial_no", "t"."verify_at", "t"."client_id", "t"."supplier_id", "t"."contact_id", "t"."created_by", "e"."id", "e"."settle_at", "e"."amount", "e"."erp_bank_id" ) UNION ALL ( SELECT 20014 AS "object_type", "e"."id" AS "object_id", 0 AS "event_type", 0 AS "event_id", ''::text AS "business_node", "e"."serial_no" AS "bill_no", "e"."wrote_date" AS "bill_date", NULL::timestamp without time zone AS "completed_at", "e"."amount" AS "amount", "e"."client_id" AS "client_id", "e"."supplier_id" AS "supplier_id", "e"."contact_id" AS "contact_id", NULL::integer AS "department_id", NULL::integer AS "handler_id", "e"."created_by" AS "created_by", NULL::integer AS "erp_bank_id", true AS "have_invoice", true AS "is_verified" FROM "a57be577deb434"."tbl_erp_cost_tickets" "e" WHERE ("e"."status"=2) AND ("e"."wrote_date" >= '2026-05-01') AND ("e"."wrote_date" <= '2026-05-31') ) UNION ALL ( SELECT 20018 AS "object_type", "e"."id" AS "object_id", 0 AS "event_type", 0 AS "event_id", ''::text AS "business_node", "e"."serial_no" AS "bill_no", "e"."wrote_date" AS "bill_date", NULL::timestamp without time zone AS "completed_at", "e"."amount" AS "amount", "e"."client_id" AS "client_id", "e"."supplier_id" AS "supplier_id", NULL::integer AS "contact_id", NULL::integer AS "department_id", NULL::integer AS "handler_id", "e"."created_by" AS "created_by", NULL::integer AS "erp_bank_id", "e"."have_invoice" AS "have_invoice", true AS "is_verified" FROM "a57be577deb434"."tbl_erp_cash_cost_tickets" "e" WHERE ("e"."status"=2) AND ("e"."wrote_date" >= '2026-05-01') AND ("e"."wrote_date" <= '2026-05-31') ) UNION ALL ( SELECT 20011 AS "object_type", "e"."id" AS "object_id", 0 AS "event_type", 0 AS "event_id", ''::text AS "business_node", "e"."serial_no" AS "bill_no", "e"."wrote_date" AS "bill_date", NULL::timestamp without time zone AS "completed_at", COALESCE(SUM(s.actual_total_amount), 0) AS "amount", "e"."client_id" AS "client_id", NULL::integer AS "supplier_id", NULL::integer AS "contact_id", NULL::integer AS "department_id", "e"."handler" AS "handler_id", "e"."created_by" AS "created_by", NULL::integer AS "erp_bank_id", true AS "have_invoice", true AS "is_verified" FROM "a57be577deb434"."tbl_erp_sales_gifts" "e" LEFT JOIN "a57be577deb434"."tbl_erp_inventory_product_spents" "s" ON s.erp_sales_gift_id = e.id WHERE ("e"."status"=2) AND ("e"."wrote_date" >= '2026-05-01') AND ("e"."wrote_date" <= '2026-05-31') GROUP BY "e"."id", "e"."serial_no", "e"."wrote_date", "e"."client_id", "e"."handler", "e"."created_by" ) UNION ALL ( SELECT 20004 AS "object_type", "e"."id" AS "object_id", 0 AS "event_type", 0 AS "event_id", ''::text AS "business_node", "e"."serial_no" AS "bill_no", "e"."wrote_date" AS "bill_date", NULL::timestamp without time zone AS "completed_at", "e"."amount" AS "amount", NULL::integer AS "client_id", NULL::integer AS "supplier_id", NULL::integer AS "contact_id", NULL::integer AS "department_id", "e"."handler" AS "handler_id", "e"."created_by" AS "created_by", NULL::integer AS "erp_bank_id", true AS "have_invoice", true AS "is_verified" FROM "a57be577deb434"."tbl_erp_inventory_losts" "e" WHERE ("e"."status"=2) AND ("e"."wrote_date" >= '2026-05-01') AND ("e"."wrote_date" <= '2026-05-31') ) UNION ALL ( SELECT 20031 AS "object_type", "e"."id" AS "object_id", 0 AS "event_type", 0 AS "event_id", ''::text AS "business_node", "e"."serial_no" AS "bill_no", "e"."wrote_date" AS "bill_date", NULL::timestamp without time zone AS "completed_at", "e"."amount" AS "amount", NULL::integer AS "client_id", NULL::integer AS "supplier_id", NULL::integer AS "contact_id", NULL::integer AS "department_id", "e"."handler" AS "handler_id", "e"."created_by" AS "created_by", NULL::integer AS "erp_bank_id", true AS "have_invoice", true AS "is_verified" FROM "a57be577deb434"."tbl_erp_inventory_overflows" "e" WHERE ("e"."status"=2) AND ("e"."wrote_date" >= '2026-05-01') AND ("e"."wrote_date" <= '2026-05-31') ) UNION ALL ( SELECT 20023 AS "object_type", "t"."id" AS "object_id", 1 AS "event_type", "e"."id" AS "event_id", '付款'::text AS "business_node", "t"."serial_no" AS "bill_no", CAST(e.settle_at AS date) AS "bill_date", "e"."settle_at" AS "completed_at", "e"."amount" AS "amount", NULL::integer AS "client_id", NULL::integer AS "supplier_id", NULL::integer AS "contact_id", CASE WHEN COUNT(DISTINCT u.department_id) = 1 THEN MIN(u.department_id) ELSE NULL END AS "department_id", CASE WHEN COUNT(DISTINCT a.user_id) = 1 THEN MIN(a.user_id) ELSE NULL END AS "handler_id", NULL::integer AS "created_by", "e"."erp_bank_id" AS "erp_bank_id", true AS "have_invoice", true AS "is_verified" FROM "a57be577deb434"."tbl_erp_wage_tickets" "t" INNER JOIN "a57be577deb434"."tbl_erp_wage_ticket_bank_outs" "e" ON e.erp_wage_ticket_id = t.id LEFT JOIN "a57be577deb434"."tbl_erp_wage_ticket_amounts" "a" ON a.erp_wage_ticket_id = t.id LEFT JOIN "a57be577deb434"."tbl_users" "u" ON u.id = a.user_id WHERE ("t"."status" IN (2, 5)) AND (NOT ("e"."settle_at" IS NULL)) AND ("e"."amount" > 0) AND ("e"."settle_at" >= '2026-05-01') AND ("e"."settle_at" <= '2026-05-31 23:59:59') GROUP BY "t"."id", "t"."serial_no", "e"."id", "e"."settle_at", "e"."amount", "e"."erp_bank_id" ) UNION ALL ( SELECT 20024 AS "object_type", "t"."id" AS "object_id", 1 AS "event_type", "e"."id" AS "event_id", '付款'::text AS "business_node", "t"."serial_no" AS "bill_no", CAST(e.settle_at AS date) AS "bill_date", "e"."settle_at" AS "completed_at", "e"."amount" AS "amount", NULL::integer AS "client_id", NULL::integer AS "supplier_id", NULL::integer AS "contact_id", CASE WHEN COUNT(DISTINCT u.department_id) = 1 THEN MIN(u.department_id) ELSE NULL END AS "department_id", CASE WHEN COUNT(DISTINCT a.user_id) = 1 THEN MIN(a.user_id) ELSE NULL END AS "handler_id", NULL::integer AS "created_by", "e"."erp_bank_id" AS "erp_bank_id", true AS "have_invoice", true AS "is_verified" FROM "a57be577deb434"."tbl_erp_social_insurances" "t" INNER JOIN "a57be577deb434"."tbl_erp_social_insurance_bank_outs" "e" ON e.erp_social_insurance_id = t.id LEFT JOIN "a57be577deb434"."tbl_erp_social_insurance_amounts" "a" ON a.erp_social_insurance_id = t.id LEFT JOIN "a57be577deb434"."tbl_users" "u" ON u.id = a.user_id WHERE ("t"."status" IN (2, 5)) AND (NOT ("e"."settle_at" IS NULL)) AND ("e"."amount" > 0) AND ("e"."settle_at" >= '2026-05-01') AND ("e"."settle_at" <= '2026-05-31 23:59:59') GROUP BY "t"."id", "t"."serial_no", "e"."id", "e"."settle_at", "e"."amount", "e"."erp_bank_id" ) UNION ALL ( SELECT 20026 AS "object_type", "t"."id" AS "object_id", 1 AS "event_type", "e"."id" AS "event_id", '付款'::text AS "business_node", "t"."serial_no" AS "bill_no", CAST(e.settle_at AS date) AS "bill_date", "e"."settle_at" AS "completed_at", "e"."amount" AS "amount", NULL::integer AS "client_id", NULL::integer AS "supplier_id", NULL::integer AS "contact_id", CASE WHEN COUNT(DISTINCT u.department_id) = 1 THEN MIN(u.department_id) ELSE NULL END AS "department_id", CASE WHEN COUNT(DISTINCT a.user_id) = 1 THEN MIN(a.user_id) ELSE NULL END AS "handler_id", NULL::integer AS "created_by", "e"."erp_bank_id" AS "erp_bank_id", true AS "have_invoice", true AS "is_verified" FROM "a57be577deb434"."tbl_erp_personal_taxs" "t" INNER JOIN "a57be577deb434"."tbl_erp_personal_tax_bank_outs" "e" ON e.erp_personal_tax_id = t.id LEFT JOIN "a57be577deb434"."tbl_erp_personal_tax_amounts" "a" ON a.erp_personal_tax_id = t.id LEFT JOIN "a57be577deb434"."tbl_users" "u" ON u.id = a.user_id WHERE ("t"."status" IN (2, 5)) AND (NOT ("e"."settle_at" IS NULL)) AND ("e"."amount" > 0) AND ("e"."settle_at" >= '2026-05-01') AND ("e"."settle_at" <= '2026-05-31 23:59:59') GROUP BY "t"."id", "t"."serial_no", "e"."id", "e"."settle_at", "e"."amount", "e"."erp_bank_id" ) UNION ALL ( SELECT 20027 AS "object_type", "t"."id" AS "object_id", 1 AS "event_type", "e"."id" AS "event_id", '付款'::text AS "business_node", "t"."serial_no" AS "bill_no", CAST(e.settle_at AS date) AS "bill_date", "e"."settle_at" AS "completed_at", "e"."amount" AS "amount", NULL::integer AS "client_id", NULL::integer AS "supplier_id", NULL::integer AS "contact_id", CASE WHEN COUNT(DISTINCT u.department_id) = 1 THEN MIN(u.department_id) ELSE NULL END AS "department_id", CASE WHEN COUNT(DISTINCT a.user_id) = 1 THEN MIN(a.user_id) ELSE NULL END AS "handler_id", NULL::integer AS "created_by", "e"."erp_bank_id" AS "erp_bank_id", true AS "have_invoice", true AS "is_verified" FROM "a57be577deb434"."tbl_erp_wage_prizes" "t" INNER JOIN "a57be577deb434"."tbl_erp_wage_prize_bank_outs" "e" ON e.erp_wage_prize_id = t.id LEFT JOIN "a57be577deb434"."tbl_erp_wage_prize_amounts" "a" ON a.erp_wage_prize_id = t.id LEFT JOIN "a57be577deb434"."tbl_users" "u" ON u.id = a.user_id WHERE ("t"."status" IN (2, 5)) AND (NOT ("e"."settle_at" IS NULL)) AND ("e"."amount" > 0) AND ("e"."settle_at" >= '2026-05-01') AND ("e"."settle_at" <= '2026-05-31 23:59:59') GROUP BY "t"."id", "t"."serial_no", "e"."id", "e"."settle_at", "e"."amount", "e"."erp_bank_id" ) UNION ALL ( SELECT 20025 AS "object_type", "t"."id" AS "object_id", 1 AS "event_type", "e"."id" AS "event_id", '付款'::text AS "business_node", "t"."serial_no" AS "bill_no", CAST(e.settle_at AS date) AS "bill_date", "e"."settle_at" AS "completed_at", "e"."amount" AS "amount", NULL::integer AS "client_id", NULL::integer AS "supplier_id", NULL::integer AS "contact_id", CASE WHEN COUNT(DISTINCT u.department_id) = 1 THEN MIN(u.department_id) ELSE NULL END AS "department_id", CASE WHEN COUNT(DISTINCT a.user_id) = 1 THEN MIN(a.user_id) ELSE NULL END AS "handler_id", NULL::integer AS "created_by", "e"."erp_bank_id" AS "erp_bank_id", true AS "have_invoice", true AS "is_verified" FROM "a57be577deb434"."tbl_erp_provident_funds" "t" INNER JOIN "a57be577deb434"."tbl_erp_provident_fund_bank_outs" "e" ON e.erp_provident_fund_id = t.id LEFT JOIN "a57be577deb434"."tbl_erp_provident_fund_amounts" "a" ON a.erp_provident_fund_id = t.id LEFT JOIN "a57be577deb434"."tbl_users" "u" ON u.id = a.user_id WHERE ("t"."status" IN (2, 5)) AND (NOT ("e"."settle_at" IS NULL)) AND ("e"."amount" > 0) AND ("e"."settle_at" >= '2026-05-01') AND ("e"."settle_at" <= '2026-05-31 23:59:59') GROUP BY "t"."id", "t"."serial_no", "e"."id", "e"."settle_at", "e"."amount", "e"."erp_bank_id" )) "b" LEFT JOIN (SELECT "v"."object_type" AS "object_type", "v"."object_id" AS "object_id", COALESCE(v.event_type, 0) AS "event_type", COALESCE(v.event_id, 0) AS "event_id", COUNT(*) FILTER (WHERE v.status = 1) AS "success_count", COUNT(*) FILTER (WHERE v.status = 0) AS "fail_count", MAX(v.book_date) FILTER (WHERE v.status = 1) AS "last_book_date" FROM "a57be577deb434"."tbl_voucher_gen_items" "v" WHERE "v"."ledger_id"=1 GROUP BY "v"."object_type", "v"."object_id", COALESCE(v.event_type, 0), COALESCE(v.event_id, 0)) "g" ON g.object_type = b.object_type AND g.object_id = b.object_id AND g.event_type = b.event_type AND g.event_id = b.event_id WHERE (("g"."success_count" IS NULL) OR ("g"."success_count"=0)) AND (("b"."object_type" NOT IN (20, 20018)) OR ("b"."have_invoice"=TRUE)) AND ("b"."amount" > 0) AND (("b"."object_type" <> 109) OR (("b"."is_verified"=TRUE) AND ("b"."bill_date" >= '2026-06-01') AND ("b"."bill_date" <= '2026-06-30'))) |
| 17:43:29.393 | 2.7 ms | yii\db\Command::query | INSERT INTO "global"."tbl_api_log" ("code", "schema", "user_id", "device_type", "url", "request", "response", "php_error", "time", "duration") VALUES (200, 'a57be577deb434', 1001, 5, 'vue/voucher-center/bill-list', '{"page":"1","pageSize":"200","object_type":"0","generation_scope":"ungenerated","date_from":"2026-05-01","date_to":"2026-05-31","web_access_token":"G2-mdsiVx4ajd063Zd6C9RL7pLl9o1cd"}', '{"code":2000,"result":{"list":[],"pagenation":{"totalcount":0,"thispage":1,"pagesize":200},"total_amount":0},"status":1,"msg":[{"name":"success","success":"\u6210\u529f\u83b7\u53d6\u6570\u636e","error":""}],"mod":0,"ip":"221.216.117.25","ua":"Mozilla\/5.0 (Macintosh; Intel Mac OS X 10.15; rv:152.0) Gecko\/20100101 Firefox\/152.0"}', FALSE, '2026-06-29 17:43:29', 131790848) RETURNING "id" |
| 17:43:29.264 | 0.9 ms | yii\db\Command::query | SELECT * FROM "global"."vw_user_login" WHERE "id"=1001 |
| 17:43:29.266 | 0.8 ms | yii\db\Command::query | SELECT * FROM "global"."vw_user_login" WHERE "id"=1001 |
| 17:43:29.280 | 0.6 ms | yii\db\Command::query | SELECT "enabled_year", "enabled_month" FROM "a57be577deb434"."tbl_ledgers" WHERE "id"=1 |
| 17:43:29.268 | 0.5 ms | yii\db\Command::query | SELECT * FROM "a57be577deb434"."tbl_users" WHERE "id"=1001 |
| 17:43:29.263 | 0.4 ms | yii\db\Connection::open | Opening DB connection: pgsql:host=postgresql.server.local;port=5432;dbname=beta |
| 17:43:29.269 | 0.4 ms | yii\db\Command::query | SELECT * FROM "a57be577deb434"."tbl_ledgers" WHERE "is_stop"=FALSE ORDER BY "id" |