fix: collation mismatch in SQL JOINs + billing date fields use uitype:date
This commit is contained in:
parent
997c7a445e
commit
8a3f1955d3
@ -56,9 +56,9 @@ async def get_my_credit_list(sor, orgid):
|
|||||||
ELSE 0
|
ELSE 0
|
||||||
END as usage_pct
|
END as usage_pct
|
||||||
FROM credit_limit cl
|
FROM credit_limit cl
|
||||||
LEFT JOIN organization org ON cl.orgid = org.id
|
LEFT JOIN organization org ON cl.orgid = org.id COLLATE utf8mb4_unicode_ci
|
||||||
LEFT JOIN account acc ON cl.accountid = acc.id
|
LEFT JOIN account acc ON cl.accountid = acc.id COLLATE utf8mb4_unicode_ci
|
||||||
LEFT JOIN subject sub ON acc.subjectid = sub.id
|
LEFT JOIN subject sub ON acc.subjectid = sub.id COLLATE utf8mb4_unicode_ci
|
||||||
WHERE cl.orgid = ${orgid}$
|
WHERE cl.orgid = ${orgid}$
|
||||||
ORDER BY cl.created_at DESC
|
ORDER BY cl.created_at DESC
|
||||||
"""
|
"""
|
||||||
@ -88,9 +88,9 @@ async def get_all_customer_credits(sor, orgid, status_filter=None):
|
|||||||
ELSE 0
|
ELSE 0
|
||||||
END as usage_pct
|
END as usage_pct
|
||||||
FROM credit_limit cl
|
FROM credit_limit cl
|
||||||
LEFT JOIN organization org ON cl.orgid = org.id
|
LEFT JOIN organization org ON cl.orgid = org.id COLLATE utf8mb4_unicode_ci
|
||||||
LEFT JOIN account acc ON cl.accountid = acc.id
|
LEFT JOIN account acc ON cl.accountid = acc.id COLLATE utf8mb4_unicode_ci
|
||||||
LEFT JOIN subject sub ON acc.subjectid = sub.id
|
LEFT JOIN subject sub ON acc.subjectid = sub.id COLLATE utf8mb4_unicode_ci
|
||||||
{where_clause}
|
{where_clause}
|
||||||
ORDER BY cl.updated_at DESC
|
ORDER BY cl.updated_at DESC
|
||||||
"""
|
"""
|
||||||
|
|||||||
@ -42,7 +42,7 @@ async def get_accounting_stats(request):
|
|||||||
sql_today = """
|
sql_today = """
|
||||||
SELECT COALESCE(SUM(amount), 0) as total
|
SELECT COALESCE(SUM(amount), 0) as total
|
||||||
FROM acc_detail a
|
FROM acc_detail a
|
||||||
JOIN account b ON a.accountid = b.id
|
JOIN account b ON a.accountid = b.id COLLATE utf8mb4_unicode_ci
|
||||||
WHERE b.orgid = ${orgid}$
|
WHERE b.orgid = ${orgid}$
|
||||||
AND a.acc_dir = 1
|
AND a.acc_dir = 1
|
||||||
AND a.acc_date >= ${from_date}$
|
AND a.acc_date >= ${from_date}$
|
||||||
@ -60,7 +60,7 @@ async def get_accounting_stats(request):
|
|||||||
sql_month = """
|
sql_month = """
|
||||||
SELECT COALESCE(SUM(amount), 0) as total
|
SELECT COALESCE(SUM(amount), 0) as total
|
||||||
FROM acc_detail a
|
FROM acc_detail a
|
||||||
JOIN account b ON a.accountid = b.id
|
JOIN account b ON a.accountid = b.id COLLATE utf8mb4_unicode_ci
|
||||||
WHERE b.orgid = ${orgid}$
|
WHERE b.orgid = ${orgid}$
|
||||||
AND a.acc_dir = 1
|
AND a.acc_dir = 1
|
||||||
AND a.acc_date >= ${from_date}$
|
AND a.acc_date >= ${from_date}$
|
||||||
|
|||||||
@ -21,8 +21,8 @@ async with get_sor_context(request._run_ns, 'accounting') as sor:
|
|||||||
sql = """select d.acc_date, d.acc_timestamp, d.acc_dir, d.summary,
|
sql = """select d.acc_date, d.acc_timestamp, d.acc_dir, d.summary,
|
||||||
d.amount, d.balance, s.name as subject_name
|
d.amount, d.balance, s.name as subject_name
|
||||||
from acc_detail d
|
from acc_detail d
|
||||||
join account a on d.accountid = a.id
|
join account a on d.accountid = a.id COLLATE utf8mb4_unicode_ci
|
||||||
join subject s on a.subjectid = s.id
|
join subject s on a.subjectid = s.id COLLATE utf8mb4_unicode_ci
|
||||||
where a.orgid = ${orgid}$
|
where a.orgid = ${orgid}$
|
||||||
and d.acc_date >= ${start_date}$
|
and d.acc_date >= ${start_date}$
|
||||||
and d.acc_date <= ${end_date}$"""
|
and d.acc_date <= ${end_date}$"""
|
||||||
|
|||||||
@ -22,13 +22,13 @@
|
|||||||
{
|
{
|
||||||
"name":"start_date",
|
"name":"start_date",
|
||||||
"label":"开始日期",
|
"label":"开始日期",
|
||||||
"uitype":"str",
|
"uitype":"date",
|
||||||
"value":"{{start_date}}"
|
"value":"{{start_date}}"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name":"end_date",
|
"name":"end_date",
|
||||||
"label":"结束日期",
|
"label":"结束日期",
|
||||||
"uitype":"str",
|
"uitype":"date",
|
||||||
"value":"{{end_date}}"
|
"value":"{{end_date}}"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
|
|||||||
@ -28,18 +28,17 @@
|
|||||||
"widgettype": "VBox",
|
"widgettype": "VBox",
|
||||||
"options": {
|
"options": {
|
||||||
"bgcolor": "#1E293B",
|
"bgcolor": "#1E293B",
|
||||||
"padding": "16px",
|
"padding": "12px",
|
||||||
"borderRadius": "10px",
|
"borderRadius": "10px",
|
||||||
"border": "1px solid #334155",
|
"border": "1px solid #334155",
|
||||||
"flex": "1",
|
"flex": "none"
|
||||||
"minHeight": "100px"
|
|
||||||
},
|
},
|
||||||
"subwidgets": [
|
"subwidgets": [
|
||||||
{
|
{
|
||||||
"widgettype": "HBox",
|
"widgettype": "HBox",
|
||||||
"options": {
|
"options": {
|
||||||
"alignItems": "center",
|
"alignItems": "center",
|
||||||
"marginBottom": "8px"
|
"marginBottom": "6px"
|
||||||
},
|
},
|
||||||
"subwidgets": [
|
"subwidgets": [
|
||||||
{
|
{
|
||||||
@ -57,7 +56,7 @@
|
|||||||
"widgettype": "Text",
|
"widgettype": "Text",
|
||||||
"options": {
|
"options": {
|
||||||
"text": "¥{{'%.2f' % cstats.total_credit}}",
|
"text": "¥{{'%.2f' % cstats.total_credit}}",
|
||||||
"fontSize": "26px",
|
"fontSize": "22px",
|
||||||
"fontWeight": "700",
|
"fontWeight": "700",
|
||||||
"color": "#3B82F6",
|
"color": "#3B82F6",
|
||||||
"lineHeight": "1.2"
|
"lineHeight": "1.2"
|
||||||
@ -69,7 +68,7 @@
|
|||||||
"text": "授信总额度",
|
"text": "授信总额度",
|
||||||
"fontSize": "13px",
|
"fontSize": "13px",
|
||||||
"color": "#94A3B8",
|
"color": "#94A3B8",
|
||||||
"marginTop": "4px"
|
"marginTop": "2px"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
@ -78,18 +77,17 @@
|
|||||||
"widgettype": "VBox",
|
"widgettype": "VBox",
|
||||||
"options": {
|
"options": {
|
||||||
"bgcolor": "#1E293B",
|
"bgcolor": "#1E293B",
|
||||||
"padding": "16px",
|
"padding": "12px",
|
||||||
"borderRadius": "10px",
|
"borderRadius": "10px",
|
||||||
"border": "1px solid #334155",
|
"border": "1px solid #334155",
|
||||||
"flex": "1",
|
"flex": "none"
|
||||||
"minHeight": "100px"
|
|
||||||
},
|
},
|
||||||
"subwidgets": [
|
"subwidgets": [
|
||||||
{
|
{
|
||||||
"widgettype": "HBox",
|
"widgettype": "HBox",
|
||||||
"options": {
|
"options": {
|
||||||
"alignItems": "center",
|
"alignItems": "center",
|
||||||
"marginBottom": "8px"
|
"marginBottom": "6px"
|
||||||
},
|
},
|
||||||
"subwidgets": [
|
"subwidgets": [
|
||||||
{
|
{
|
||||||
@ -107,7 +105,7 @@
|
|||||||
"widgettype": "Text",
|
"widgettype": "Text",
|
||||||
"options": {
|
"options": {
|
||||||
"text": "¥{{'%.2f' % cstats.total_used}}",
|
"text": "¥{{'%.2f' % cstats.total_used}}",
|
||||||
"fontSize": "26px",
|
"fontSize": "22px",
|
||||||
"fontWeight": "700",
|
"fontWeight": "700",
|
||||||
"color": "#F59E0B",
|
"color": "#F59E0B",
|
||||||
"lineHeight": "1.2"
|
"lineHeight": "1.2"
|
||||||
@ -119,7 +117,7 @@
|
|||||||
"text": "已用额度",
|
"text": "已用额度",
|
||||||
"fontSize": "13px",
|
"fontSize": "13px",
|
||||||
"color": "#94A3B8",
|
"color": "#94A3B8",
|
||||||
"marginTop": "4px"
|
"marginTop": "2px"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
@ -128,18 +126,17 @@
|
|||||||
"widgettype": "VBox",
|
"widgettype": "VBox",
|
||||||
"options": {
|
"options": {
|
||||||
"bgcolor": "#1E293B",
|
"bgcolor": "#1E293B",
|
||||||
"padding": "16px",
|
"padding": "12px",
|
||||||
"borderRadius": "10px",
|
"borderRadius": "10px",
|
||||||
"border": "1px solid #334155",
|
"border": "1px solid #334155",
|
||||||
"flex": "1",
|
"flex": "none"
|
||||||
"minHeight": "100px"
|
|
||||||
},
|
},
|
||||||
"subwidgets": [
|
"subwidgets": [
|
||||||
{
|
{
|
||||||
"widgettype": "HBox",
|
"widgettype": "HBox",
|
||||||
"options": {
|
"options": {
|
||||||
"alignItems": "center",
|
"alignItems": "center",
|
||||||
"marginBottom": "8px"
|
"marginBottom": "6px"
|
||||||
},
|
},
|
||||||
"subwidgets": [
|
"subwidgets": [
|
||||||
{
|
{
|
||||||
@ -157,7 +154,7 @@
|
|||||||
"widgettype": "Text",
|
"widgettype": "Text",
|
||||||
"options": {
|
"options": {
|
||||||
"text": "¥{{'%.2f' % cstats.total_available}}",
|
"text": "¥{{'%.2f' % cstats.total_available}}",
|
||||||
"fontSize": "26px",
|
"fontSize": "22px",
|
||||||
"fontWeight": "700",
|
"fontWeight": "700",
|
||||||
"color": "#22C55E",
|
"color": "#22C55E",
|
||||||
"lineHeight": "1.2"
|
"lineHeight": "1.2"
|
||||||
@ -169,7 +166,7 @@
|
|||||||
"text": "剩余额度",
|
"text": "剩余额度",
|
||||||
"fontSize": "13px",
|
"fontSize": "13px",
|
||||||
"color": "#94A3B8",
|
"color": "#94A3B8",
|
||||||
"marginTop": "4px"
|
"marginTop": "2px"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
@ -178,18 +175,17 @@
|
|||||||
"widgettype": "VBox",
|
"widgettype": "VBox",
|
||||||
"options": {
|
"options": {
|
||||||
"bgcolor": "#1E293B",
|
"bgcolor": "#1E293B",
|
||||||
"padding": "16px",
|
"padding": "12px",
|
||||||
"borderRadius": "10px",
|
"borderRadius": "10px",
|
||||||
"border": "1px solid #334155",
|
"border": "1px solid #334155",
|
||||||
"flex": "1",
|
"flex": "none"
|
||||||
"minHeight": "100px"
|
|
||||||
},
|
},
|
||||||
"subwidgets": [
|
"subwidgets": [
|
||||||
{
|
{
|
||||||
"widgettype": "HBox",
|
"widgettype": "HBox",
|
||||||
"options": {
|
"options": {
|
||||||
"alignItems": "center",
|
"alignItems": "center",
|
||||||
"marginBottom": "8px"
|
"marginBottom": "6px"
|
||||||
},
|
},
|
||||||
"subwidgets": [
|
"subwidgets": [
|
||||||
{
|
{
|
||||||
@ -207,7 +203,7 @@
|
|||||||
"widgettype": "Text",
|
"widgettype": "Text",
|
||||||
"options": {
|
"options": {
|
||||||
"text": "{{cstats.usage_pct}}%",
|
"text": "{{cstats.usage_pct}}%",
|
||||||
"fontSize": "26px",
|
"fontSize": "22px",
|
||||||
"fontWeight": "700",
|
"fontWeight": "700",
|
||||||
"color": "#A78BFA",
|
"color": "#A78BFA",
|
||||||
"lineHeight": "1.2"
|
"lineHeight": "1.2"
|
||||||
@ -219,7 +215,7 @@
|
|||||||
"text": "额度使用率 ({{cstats.active_count}}/{{cstats.customer_count}}户)",
|
"text": "额度使用率 ({{cstats.active_count}}/{{cstats.customer_count}}户)",
|
||||||
"fontSize": "13px",
|
"fontSize": "13px",
|
||||||
"color": "#94A3B8",
|
"color": "#94A3B8",
|
||||||
"marginTop": "4px"
|
"marginTop": "2px"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
@ -294,7 +290,8 @@
|
|||||||
"id": "credit_content",
|
"id": "credit_content",
|
||||||
"options": {
|
"options": {
|
||||||
"width": "100%",
|
"width": "100%",
|
||||||
"flex": "1"
|
"css": "filler",
|
||||||
|
"marginTop": "8px"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|||||||
@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"widgettype": "VBox",
|
"widgettype": "VBox",
|
||||||
"options": {
|
"options": {
|
||||||
"cheight": 40,
|
"height": "100%",
|
||||||
"width": "100%"
|
"width": "100%"
|
||||||
},
|
},
|
||||||
"subwidgets": [
|
"subwidgets": [
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user