feat(user-center): merge promotion rewards into revenue
This commit is contained in:
1 parent
a87fd32fa3
commit
39c92017d9
14 files changed
+1048
-159
No files matched your search
@@ -1,24 +1,520 @@
|
|||||||
.uc-content .uc-revenue-card { margin: 0 0 24px; padding: 20px; border: 1px solid var(--color-line-soft, rgba(0,0,0,.06)); border-radius: 14px; background: var(--surface-1); }
|
/**
|
||||||
.uc-content .uc-revenue-card__header { display: flex; align-items: center; gap: 12px; margin-bottom: 18px; }
|
* User Center - commission and promotion rewards.
|
||||||
.uc-content .uc-revenue-card__icon { display: grid; width: 42px; height: 42px; place-items: center; border-radius: 12px; color: #fff; background: #ce6b35; }
|
*/
|
||||||
.uc-content .uc-revenue-card__header p { margin: 0 0 2px; color: var(--color-ink-4); font-size: 12px; }
|
|
||||||
.uc-content .uc-revenue-card__header h3 { margin: 0; color: var(--color-ink); font-size: 18px; }
|
.uc-content #panel-revenue.dashboard-panel {
|
||||||
.uc-content .uc-revenue-card .aksrt-revenue-page__stats { margin-bottom: 18px; }
|
padding: 0;
|
||||||
.uc-content #panel-revenue.dashboard-panel { padding: 0; border: 0; border-radius: 0; background: transparent; box-shadow: none; }
|
border: 0;
|
||||||
.uc-content .uc-revenue-panel { padding: 4px 0; }
|
border-radius: 0;
|
||||||
.uc-content .uc-revenue-panel__header { margin-bottom: 20px; }
|
background: transparent;
|
||||||
.uc-content .uc-revenue-panel__header p { margin: 0 0 4px; color: var(--color-primary); font-size: 12px; font-weight: 700; }
|
box-shadow: none;
|
||||||
.uc-content .uc-revenue-panel__header h2 { margin: 0; color: var(--color-ink); font-size: 22px; }
|
}
|
||||||
.uc-content .uc-revenue-panel__header > span { display: block; margin-top: 7px; color: var(--color-ink-4); font-size: 13px; }
|
|
||||||
.uc-content .aksrt-revenue-page__layout { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px; margin-bottom: 20px; }
|
.uc-revenue-panel {
|
||||||
.uc-content .aksrt-revenue-page__panel,
|
display: grid;
|
||||||
.uc-content .aksrt-revenue-page__section { padding: 20px; border: 1px solid var(--color-line-soft, rgba(0,0,0,.06)); border-radius: 14px; background: var(--surface-1); }
|
gap: 20px;
|
||||||
.uc-content .aksrt-revenue-page__panel h3,
|
padding: 4px 0;
|
||||||
.uc-content .aksrt-revenue-page__section h3 { margin: 0 0 14px; font-size: 16px; }
|
}
|
||||||
.uc-content .aksrt-revenue-page__withdraw-form { display: grid; gap: 12px; }
|
|
||||||
.uc-content .aksrt-revenue-page__withdraw-form label { display: grid; gap: 6px; color: var(--color-ink-3); font-size: 13px; }
|
.uc-commission-summary {
|
||||||
.uc-content .aksrt-revenue-page__withdraw-form input,
|
display: grid;
|
||||||
.uc-content .aksrt-revenue-page__withdraw-form select,
|
grid-template-columns: repeat(2, minmax(0, 1fr));
|
||||||
.uc-content .aksrt-revenue-page__withdraw-form textarea { width: 100%; padding: 9px 11px; border: 1px solid var(--color-line-soft, rgba(0,0,0,.1)); border-radius: 8px; color: var(--color-ink); background: var(--surface-2); }
|
gap: 16px;
|
||||||
.uc-content .aksrt-revenue-page__form-msg.is-error { color: var(--color-error, #dc2626); }
|
}
|
||||||
@media (max-width: 640px) { .uc-content .aksrt-revenue-page__layout { grid-template-columns: 1fr; } }
|
|
||||||
|
.uc-commission-card {
|
||||||
|
position: relative;
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
gap: 15px;
|
||||||
|
min-width: 0;
|
||||||
|
min-height: 142px;
|
||||||
|
padding: 22px;
|
||||||
|
overflow: hidden;
|
||||||
|
border: 1px solid var(--color-line-soft, rgba(15, 23, 42, .08));
|
||||||
|
border-radius: 8px;
|
||||||
|
background: var(--surface-1);
|
||||||
|
box-shadow: 0 6px 18px rgba(15, 23, 42, .05);
|
||||||
|
}
|
||||||
|
|
||||||
|
.uc-commission-card__icon {
|
||||||
|
display: grid;
|
||||||
|
flex: 0 0 48px;
|
||||||
|
width: 48px;
|
||||||
|
height: 48px;
|
||||||
|
place-items: center;
|
||||||
|
border-radius: 8px;
|
||||||
|
color: #fff;
|
||||||
|
background: #2563a8;
|
||||||
|
font-size: 19px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.uc-commission-card--balance .uc-commission-card__icon {
|
||||||
|
background: #c95a31;
|
||||||
|
}
|
||||||
|
|
||||||
|
.uc-commission-card__body {
|
||||||
|
min-width: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.uc-commission-card__body > span,
|
||||||
|
.uc-commission-card__body > p {
|
||||||
|
display: block;
|
||||||
|
color: var(--color-ink-4);
|
||||||
|
font-size: 12px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.uc-commission-card__body > span {
|
||||||
|
margin-bottom: 5px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.uc-commission-card__body strong {
|
||||||
|
display: block;
|
||||||
|
color: var(--color-ink);
|
||||||
|
font-size: 30px;
|
||||||
|
font-variant-numeric: tabular-nums;
|
||||||
|
line-height: 1.15;
|
||||||
|
}
|
||||||
|
|
||||||
|
.uc-commission-card--ratio .uc-commission-card__body strong {
|
||||||
|
color: #2563a8;
|
||||||
|
}
|
||||||
|
|
||||||
|
.uc-commission-card__body strong small {
|
||||||
|
margin-left: 2px;
|
||||||
|
font-size: 16px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.uc-commission-card__body p {
|
||||||
|
margin: 6px 0 0;
|
||||||
|
line-height: 1.45;
|
||||||
|
}
|
||||||
|
|
||||||
|
.uc-commission-card__action {
|
||||||
|
display: inline-flex;
|
||||||
|
align-items: center;
|
||||||
|
gap: 7px;
|
||||||
|
flex: 0 0 auto;
|
||||||
|
margin-left: auto;
|
||||||
|
padding: 9px 13px;
|
||||||
|
border: 0;
|
||||||
|
border-radius: 7px;
|
||||||
|
color: #fff;
|
||||||
|
background: var(--color-primary);
|
||||||
|
font-size: 13px;
|
||||||
|
cursor: pointer;
|
||||||
|
}
|
||||||
|
|
||||||
|
.uc-commission-card__action:hover {
|
||||||
|
color: #fff;
|
||||||
|
filter: brightness(.95);
|
||||||
|
}
|
||||||
|
|
||||||
|
.uc-reward-area {
|
||||||
|
display: grid;
|
||||||
|
gap: 16px;
|
||||||
|
padding: 4px 0 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.uc-reward-area__heading {
|
||||||
|
display: flex;
|
||||||
|
align-items: baseline;
|
||||||
|
justify-content: space-between;
|
||||||
|
gap: 12px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.uc-reward-area__heading h3,
|
||||||
|
.uc-reward-list-heading h4,
|
||||||
|
.uc-reward-block h4 {
|
||||||
|
margin: 0;
|
||||||
|
color: var(--color-ink);
|
||||||
|
font-size: 16px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.uc-reward-area__heading > span,
|
||||||
|
.uc-reward-list-heading p,
|
||||||
|
.uc-reward-block__heading p {
|
||||||
|
margin: 0;
|
||||||
|
color: var(--color-ink-4);
|
||||||
|
font-size: 12px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.uc-reward-tabs {
|
||||||
|
display: flex;
|
||||||
|
gap: 4px;
|
||||||
|
overflow-x: auto;
|
||||||
|
border-bottom: 1px solid var(--color-line-soft, rgba(15, 23, 42, .08));
|
||||||
|
}
|
||||||
|
|
||||||
|
.uc-reward-tabs a {
|
||||||
|
position: relative;
|
||||||
|
flex: 0 0 auto;
|
||||||
|
padding: 10px 16px;
|
||||||
|
color: var(--color-ink-3);
|
||||||
|
font-size: 14px;
|
||||||
|
text-decoration: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
.uc-reward-tabs a::after {
|
||||||
|
position: absolute;
|
||||||
|
right: 12px;
|
||||||
|
bottom: -1px;
|
||||||
|
left: 12px;
|
||||||
|
height: 2px;
|
||||||
|
background: transparent;
|
||||||
|
content: "";
|
||||||
|
}
|
||||||
|
|
||||||
|
.uc-reward-tabs a:hover,
|
||||||
|
.uc-reward-tabs a.is-active {
|
||||||
|
color: var(--color-primary);
|
||||||
|
}
|
||||||
|
|
||||||
|
.uc-reward-tabs a.is-active {
|
||||||
|
font-weight: 700;
|
||||||
|
}
|
||||||
|
|
||||||
|
.uc-reward-tabs a.is-active::after {
|
||||||
|
background: var(--color-primary);
|
||||||
|
}
|
||||||
|
|
||||||
|
.uc-reward-pane {
|
||||||
|
display: grid;
|
||||||
|
gap: 16px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.uc-reward-pane--detail {
|
||||||
|
grid-template-columns: repeat(2, minmax(0, 1fr));
|
||||||
|
}
|
||||||
|
|
||||||
|
.uc-reward-block {
|
||||||
|
display: grid;
|
||||||
|
gap: 14px;
|
||||||
|
min-width: 0;
|
||||||
|
padding: 18px;
|
||||||
|
border: 1px solid var(--color-line-soft, rgba(15, 23, 42, .07));
|
||||||
|
border-radius: 8px;
|
||||||
|
background: var(--surface-2);
|
||||||
|
}
|
||||||
|
|
||||||
|
.uc-reward-block__heading {
|
||||||
|
display: grid;
|
||||||
|
gap: 5px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.uc-reward-block__heading p {
|
||||||
|
line-height: 1.5;
|
||||||
|
}
|
||||||
|
|
||||||
|
.uc-invite-share {
|
||||||
|
display: grid;
|
||||||
|
gap: 10px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.uc-invite-code {
|
||||||
|
display: flex;
|
||||||
|
align-items: baseline;
|
||||||
|
gap: 10px;
|
||||||
|
color: var(--color-ink-4);
|
||||||
|
font-size: 13px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.uc-invite-code strong {
|
||||||
|
color: var(--color-ink);
|
||||||
|
font-size: 19px;
|
||||||
|
letter-spacing: .08em;
|
||||||
|
}
|
||||||
|
|
||||||
|
.uc-invite-link-row {
|
||||||
|
display: flex;
|
||||||
|
gap: 8px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.uc-invite-link-row input {
|
||||||
|
flex: 1 1 auto;
|
||||||
|
min-width: 0;
|
||||||
|
height: 40px;
|
||||||
|
padding: 0 10px;
|
||||||
|
border: 1px solid var(--color-line-soft, rgba(15, 23, 42, .12));
|
||||||
|
border-radius: 7px;
|
||||||
|
color: var(--color-ink);
|
||||||
|
background: var(--surface-1);
|
||||||
|
}
|
||||||
|
|
||||||
|
.uc-reward-status,
|
||||||
|
.uc-reward-copy-feedback {
|
||||||
|
min-height: 17px;
|
||||||
|
margin: 0;
|
||||||
|
color: var(--color-ink-4);
|
||||||
|
font-size: 12px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.uc-reward-status.is-error,
|
||||||
|
.uc-reward-copy-feedback.is-error {
|
||||||
|
color: var(--color-error, #dc2626);
|
||||||
|
}
|
||||||
|
|
||||||
|
.uc-ratio-list {
|
||||||
|
display: grid;
|
||||||
|
gap: 0;
|
||||||
|
margin: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.uc-ratio-list > div {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: space-between;
|
||||||
|
padding: 10px 0;
|
||||||
|
border-bottom: 1px solid var(--color-line-soft, rgba(15, 23, 42, .07));
|
||||||
|
}
|
||||||
|
|
||||||
|
.uc-ratio-list > div:last-child {
|
||||||
|
border-bottom: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.uc-ratio-list dt {
|
||||||
|
color: var(--color-ink-3);
|
||||||
|
font-size: 13px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.uc-ratio-list dd {
|
||||||
|
margin: 0;
|
||||||
|
color: var(--color-primary);
|
||||||
|
font-weight: 700;
|
||||||
|
}
|
||||||
|
|
||||||
|
.uc-total-commission {
|
||||||
|
display: flex;
|
||||||
|
align-items: baseline;
|
||||||
|
gap: 10px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.uc-total-commission strong {
|
||||||
|
color: var(--color-ink);
|
||||||
|
font-size: 28px;
|
||||||
|
font-variant-numeric: tabular-nums;
|
||||||
|
}
|
||||||
|
|
||||||
|
.uc-total-commission span {
|
||||||
|
color: var(--color-ink-4);
|
||||||
|
font-size: 12px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.uc-reward-richtext {
|
||||||
|
color: var(--color-ink-3);
|
||||||
|
font-size: 13px;
|
||||||
|
line-height: 1.75;
|
||||||
|
}
|
||||||
|
|
||||||
|
.uc-reward-richtext p {
|
||||||
|
margin: 0 0 8px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.uc-reward-richtext p:last-child {
|
||||||
|
margin-bottom: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.uc-reward-list-heading {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
justify-content: space-between;
|
||||||
|
gap: 12px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.uc-reward-list-heading > div {
|
||||||
|
display: grid;
|
||||||
|
gap: 5px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.uc-reward-list-heading > strong {
|
||||||
|
color: var(--color-ink-4);
|
||||||
|
font-size: 12px;
|
||||||
|
font-weight: 500;
|
||||||
|
}
|
||||||
|
|
||||||
|
.uc-commission-list,
|
||||||
|
.uc-invite-list {
|
||||||
|
display: grid;
|
||||||
|
gap: 0;
|
||||||
|
border-top: 1px solid var(--color-line-soft, rgba(15, 23, 42, .08));
|
||||||
|
}
|
||||||
|
|
||||||
|
.uc-commission-row,
|
||||||
|
.uc-invite-record {
|
||||||
|
display: flex;
|
||||||
|
align-items: center;
|
||||||
|
gap: 12px;
|
||||||
|
min-width: 0;
|
||||||
|
padding: 13px 0;
|
||||||
|
border-bottom: 1px solid var(--color-line-soft, rgba(15, 23, 42, .08));
|
||||||
|
}
|
||||||
|
|
||||||
|
.uc-commission-row__icon {
|
||||||
|
display: grid;
|
||||||
|
flex: 0 0 34px;
|
||||||
|
width: 34px;
|
||||||
|
height: 34px;
|
||||||
|
place-items: center;
|
||||||
|
border-radius: 8px;
|
||||||
|
color: #c95a31;
|
||||||
|
background: rgba(201, 90, 49, .12);
|
||||||
|
}
|
||||||
|
|
||||||
|
.uc-commission-row__main,
|
||||||
|
.uc-invite-record__main {
|
||||||
|
display: grid;
|
||||||
|
flex: 1 1 auto;
|
||||||
|
min-width: 0;
|
||||||
|
gap: 3px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.uc-commission-row__main strong,
|
||||||
|
.uc-invite-record__main strong {
|
||||||
|
overflow: hidden;
|
||||||
|
color: var(--color-ink);
|
||||||
|
font-size: 13px;
|
||||||
|
text-overflow: ellipsis;
|
||||||
|
white-space: nowrap;
|
||||||
|
}
|
||||||
|
|
||||||
|
.uc-commission-row__main span,
|
||||||
|
.uc-commission-row__main time,
|
||||||
|
.uc-invite-record__main span {
|
||||||
|
overflow: hidden;
|
||||||
|
color: var(--color-ink-4);
|
||||||
|
font-size: 12px;
|
||||||
|
text-overflow: ellipsis;
|
||||||
|
white-space: nowrap;
|
||||||
|
}
|
||||||
|
|
||||||
|
.uc-commission-row__value {
|
||||||
|
display: grid;
|
||||||
|
justify-items: end;
|
||||||
|
gap: 4px;
|
||||||
|
flex: 0 0 auto;
|
||||||
|
}
|
||||||
|
|
||||||
|
.uc-commission-row__value strong {
|
||||||
|
color: #16816c;
|
||||||
|
font-size: 14px;
|
||||||
|
font-variant-numeric: tabular-nums;
|
||||||
|
}
|
||||||
|
|
||||||
|
.uc-commission-row__value span {
|
||||||
|
padding: 2px 7px;
|
||||||
|
border-radius: 999px;
|
||||||
|
color: var(--color-ink-4);
|
||||||
|
background: var(--surface-1);
|
||||||
|
font-size: 11px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.uc-commission-row__value span.is-settled {
|
||||||
|
color: #16816c;
|
||||||
|
background: rgba(22, 129, 108, .1);
|
||||||
|
}
|
||||||
|
|
||||||
|
.uc-commission-row__value span.is-pending {
|
||||||
|
color: #a86d28;
|
||||||
|
background: rgba(168, 109, 40, .12);
|
||||||
|
}
|
||||||
|
|
||||||
|
.uc-invite-record__avatar {
|
||||||
|
display: grid;
|
||||||
|
flex: 0 0 36px;
|
||||||
|
width: 36px;
|
||||||
|
height: 36px;
|
||||||
|
place-items: center;
|
||||||
|
overflow: hidden;
|
||||||
|
border-radius: 50%;
|
||||||
|
color: var(--color-primary);
|
||||||
|
background: var(--surface-2);
|
||||||
|
}
|
||||||
|
|
||||||
|
.uc-invite-record__avatar img {
|
||||||
|
width: 100%;
|
||||||
|
height: 100%;
|
||||||
|
object-fit: cover;
|
||||||
|
}
|
||||||
|
|
||||||
|
.uc-invite-record__status {
|
||||||
|
flex: 0 0 auto;
|
||||||
|
color: var(--color-ink-4);
|
||||||
|
font-size: 12px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.uc-reward-pagination {
|
||||||
|
display: flex;
|
||||||
|
justify-content: center;
|
||||||
|
gap: 6px;
|
||||||
|
padding-top: 4px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.uc-reward-pagination a {
|
||||||
|
display: grid;
|
||||||
|
width: 30px;
|
||||||
|
height: 30px;
|
||||||
|
place-items: center;
|
||||||
|
border-radius: 6px;
|
||||||
|
color: var(--color-ink-3);
|
||||||
|
background: var(--surface-2);
|
||||||
|
font-size: 12px;
|
||||||
|
text-decoration: none;
|
||||||
|
}
|
||||||
|
|
||||||
|
.uc-reward-pagination a.is-active,
|
||||||
|
.uc-reward-pagination a:hover {
|
||||||
|
color: #fff;
|
||||||
|
background: var(--color-primary);
|
||||||
|
}
|
||||||
|
|
||||||
|
.uc-reward-empty {
|
||||||
|
margin: 0;
|
||||||
|
padding: 30px 12px;
|
||||||
|
color: var(--color-ink-4);
|
||||||
|
font-size: 13px;
|
||||||
|
text-align: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
@media (max-width: 720px) {
|
||||||
|
.uc-commission-summary,
|
||||||
|
.uc-reward-pane--detail {
|
||||||
|
grid-template-columns: 1fr;
|
||||||
|
}
|
||||||
|
|
||||||
|
.uc-commission-card {
|
||||||
|
min-height: 120px;
|
||||||
|
padding: 18px;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@media (max-width: 480px) {
|
||||||
|
.uc-reward-area {
|
||||||
|
padding: 4px 0 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.uc-commission-card {
|
||||||
|
align-items: flex-start;
|
||||||
|
flex-wrap: wrap;
|
||||||
|
}
|
||||||
|
|
||||||
|
.uc-commission-card__action {
|
||||||
|
margin-left: 63px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.uc-invite-link-row {
|
||||||
|
flex-direction: column;
|
||||||
|
}
|
||||||
|
|
||||||
|
.uc-invite-link-row .btn-primary {
|
||||||
|
width: 100%;
|
||||||
|
}
|
||||||
|
|
||||||
|
.uc-invite-record,
|
||||||
|
.uc-commission-row {
|
||||||
|
align-items: flex-start;
|
||||||
|
}
|
||||||
|
|
||||||
|
.uc-commission-row__value {
|
||||||
|
text-align: right;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,225 @@
|
|||||||
|
/**
|
||||||
|
* Commission center referral link and invited-user records.
|
||||||
|
*/
|
||||||
|
(function () {
|
||||||
|
'use strict';
|
||||||
|
|
||||||
|
var root = document.querySelector('[data-aksrt-revenue-page]');
|
||||||
|
if (!root) return;
|
||||||
|
|
||||||
|
var data = window.aksrtData || {};
|
||||||
|
var rest = data.restUrl || data.apiUrl || ((data.siteUrl || '').replace(/\/$/, '') + '/wp-json/aksrt/v1');
|
||||||
|
if (!rest) return;
|
||||||
|
rest = rest.replace(/\/?$/, '');
|
||||||
|
|
||||||
|
function api(path) {
|
||||||
|
return fetch(rest + path, {
|
||||||
|
credentials: 'same-origin',
|
||||||
|
headers: { 'X-WP-Nonce': data.restNonce || data.nonce || '' }
|
||||||
|
}).then(function (response) {
|
||||||
|
return response.json().catch(function () { return {}; }).then(function (json) {
|
||||||
|
return { ok: response.ok, json: json };
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
function escapeHtml(value) {
|
||||||
|
return String(value == null ? '' : value).replace(/&/g, '&').replace(/</g, '<').replace(/>/g, '>').replace(/"/g, '"').replace(/'/g, ''');
|
||||||
|
}
|
||||||
|
|
||||||
|
function formatDate(value) {
|
||||||
|
if (!value || value === '0000-00-00 00:00:00') return '';
|
||||||
|
var date = new Date(String(value).replace(' ', 'T') + 'Z');
|
||||||
|
return isNaN(date.getTime()) ? String(value).slice(0, 16) : date.toLocaleString();
|
||||||
|
}
|
||||||
|
|
||||||
|
var linkInput = root.querySelector('[data-invite-link]');
|
||||||
|
var codeEl = root.querySelector('[data-invite-code]');
|
||||||
|
var copyBtn = root.querySelector('[data-invite-copy]');
|
||||||
|
var statusEl = root.querySelector('[data-invite-status]');
|
||||||
|
var feedbackEl = root.querySelector('[data-invite-copy-feedback]');
|
||||||
|
var listEl = root.querySelector('[data-invite-list]');
|
||||||
|
var totalEl = root.querySelector('[data-invite-total]');
|
||||||
|
|
||||||
|
function setStatus(text, error) {
|
||||||
|
if (!statusEl) return;
|
||||||
|
statusEl.textContent = text || '';
|
||||||
|
statusEl.classList.toggle('is-error', !!error);
|
||||||
|
}
|
||||||
|
|
||||||
|
api('/invite/me').then(function (result) {
|
||||||
|
if (!result.ok) {
|
||||||
|
setStatus((result.json && result.json.message) || '推广数据加载失败', true);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
var payload = result.json || {};
|
||||||
|
if (linkInput) linkInput.value = payload.invite_url || '';
|
||||||
|
if (codeEl) codeEl.textContent = payload.code || '--';
|
||||||
|
if (copyBtn) copyBtn.disabled = !payload.invite_url;
|
||||||
|
setStatus('推广数据已更新', false);
|
||||||
|
}).catch(function () {
|
||||||
|
setStatus('推广数据加载失败,请稍后重试', true);
|
||||||
|
});
|
||||||
|
|
||||||
|
function renderPagination(total, current) {
|
||||||
|
if (!listEl || total <= 10) return;
|
||||||
|
var nav = root.querySelector('[data-invite-pagination]');
|
||||||
|
if (!nav) {
|
||||||
|
nav = document.createElement('nav');
|
||||||
|
nav.className = 'uc-reward-pagination';
|
||||||
|
nav.setAttribute('data-invite-pagination', 'true');
|
||||||
|
nav.setAttribute('aria-label', '邀请记录分页');
|
||||||
|
listEl.parentNode.appendChild(nav);
|
||||||
|
}
|
||||||
|
nav.innerHTML = '';
|
||||||
|
var pages = Math.ceil(total / 10);
|
||||||
|
for (var page = 1; page <= pages; page++) {
|
||||||
|
var url = new URL(window.location.href);
|
||||||
|
url.searchParams.set('reward_tab', 'users');
|
||||||
|
if (page > 1) url.searchParams.set('invite_page', String(page));
|
||||||
|
else url.searchParams.delete('invite_page');
|
||||||
|
var link = document.createElement('a');
|
||||||
|
link.href = url.toString();
|
||||||
|
link.textContent = String(page);
|
||||||
|
link.className = page === current ? 'is-active' : '';
|
||||||
|
nav.appendChild(link);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function renderList(payload, page) {
|
||||||
|
if (!listEl) return;
|
||||||
|
var items = Array.isArray(payload.items) ? payload.items : [];
|
||||||
|
var total = Number(payload.total || 0);
|
||||||
|
listEl.classList.remove('is-loading');
|
||||||
|
if (totalEl) totalEl.textContent = total ? total + ' 条' : '暂无记录';
|
||||||
|
if (!items.length) {
|
||||||
|
listEl.innerHTML = '<p class="uc-reward-empty">分享链接后,邀请记录会显示在这里。</p>';
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
listEl.innerHTML = items.map(function (item) {
|
||||||
|
var name = item.invitee_name || (item.invitee_id ? '用户 #' + item.invitee_id : '受邀用户');
|
||||||
|
var avatar = item.invitee_avatar ? '<img src="' + escapeHtml(item.invitee_avatar) + '" alt="">' : '<span>' + escapeHtml(name.charAt(0)) + '</span>';
|
||||||
|
var status = item.status === 'rewarded' ? '已奖励' : (item.status === 'verified' ? '已验证' : '已注册');
|
||||||
|
return '<article class="uc-invite-record"><span class="uc-invite-record__avatar">' + avatar + '</span><span class="uc-invite-record__main"><strong>' + escapeHtml(name) + '</strong><span>' + escapeHtml(formatDate(item.created_at)) + '</span></span><span class="uc-invite-record__status">' + status + '</span></article>';
|
||||||
|
}).join('');
|
||||||
|
var currentPage = Number(payload.page || page);
|
||||||
|
renderPagination(total, isNaN(currentPage) ? 1 : currentPage);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (listEl) {
|
||||||
|
var invitePage = 1;
|
||||||
|
try {
|
||||||
|
var requestedPage = parseInt(new URLSearchParams(window.location.search).get('invite_page') || '1', 10);
|
||||||
|
invitePage = isNaN(requestedPage) ? 1 : Math.max(1, requestedPage);
|
||||||
|
} catch (_) {}
|
||||||
|
api('/invite/list?per_page=10&page=' + invitePage).then(function (result) {
|
||||||
|
if (!result.ok) {
|
||||||
|
listEl.classList.remove('is-loading');
|
||||||
|
listEl.innerHTML = '<p class="uc-reward-empty">邀请记录加载失败,请稍后重试。</p>';
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
renderList(result.json || {}, invitePage);
|
||||||
|
}).catch(function () {
|
||||||
|
listEl.classList.remove('is-loading');
|
||||||
|
listEl.innerHTML = '<p class="uc-reward-empty">邀请记录加载失败,请稍后重试。</p>';
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
if (copyBtn && linkInput) {
|
||||||
|
copyBtn.addEventListener('click', function () {
|
||||||
|
if (!linkInput.value) return;
|
||||||
|
var done = function () {
|
||||||
|
if (feedbackEl) feedbackEl.textContent = '推广链接已复制';
|
||||||
|
copyBtn.disabled = false;
|
||||||
|
};
|
||||||
|
if (navigator.clipboard && navigator.clipboard.writeText) {
|
||||||
|
navigator.clipboard.writeText(linkInput.value).then(done).catch(function () { linkInput.select(); document.execCommand('copy'); done(); });
|
||||||
|
} else {
|
||||||
|
linkInput.select();
|
||||||
|
document.execCommand('copy');
|
||||||
|
done();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
var withdrawModal = document.querySelector('[data-aksrt-commission-withdraw-modal]');
|
||||||
|
var withdrawForm = withdrawModal && withdrawModal.querySelector('[data-aksrt-commission-withdraw-form]');
|
||||||
|
var withdrawTip = withdrawModal && withdrawModal.querySelector('[data-aksrt-commission-withdraw-tip]');
|
||||||
|
var withdrawSubmit = withdrawModal && withdrawModal.querySelector('[data-aksrt-commission-withdraw-submit]');
|
||||||
|
var lastWithdrawTrigger = null;
|
||||||
|
var withdrawBusy = false;
|
||||||
|
function setWithdrawTip(text, error) {
|
||||||
|
if (!withdrawTip) return;
|
||||||
|
withdrawTip.textContent = text || '';
|
||||||
|
withdrawTip.classList.toggle('is-error', !!error);
|
||||||
|
}
|
||||||
|
function setWithdrawBusy(isBusy) {
|
||||||
|
withdrawBusy = isBusy;
|
||||||
|
if (withdrawSubmit) withdrawSubmit.disabled = isBusy;
|
||||||
|
}
|
||||||
|
function getWithdrawFocusable() {
|
||||||
|
return Array.prototype.slice.call(withdrawModal.querySelectorAll('button:not([disabled]), [href], input:not([disabled]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex="-1"])'));
|
||||||
|
}
|
||||||
|
function closeWithdrawModal() {
|
||||||
|
if (!withdrawModal || withdrawModal.hidden) return;
|
||||||
|
withdrawModal.hidden = true;
|
||||||
|
document.body.classList.remove('uc-modal-open');
|
||||||
|
if (lastWithdrawTrigger && typeof lastWithdrawTrigger.focus === 'function') {
|
||||||
|
lastWithdrawTrigger.focus();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (withdrawModal && withdrawForm) {
|
||||||
|
document.querySelectorAll('[data-aksrt-commission-withdraw-open]').forEach(function (button) {
|
||||||
|
button.addEventListener('click', function () {
|
||||||
|
lastWithdrawTrigger = button;
|
||||||
|
withdrawModal.hidden = false;
|
||||||
|
document.body.classList.add('uc-modal-open');
|
||||||
|
window.requestAnimationFrame(function () {
|
||||||
|
var amountInput = withdrawForm.querySelector('[data-aksrt-commission-withdraw-amount]');
|
||||||
|
if (amountInput) amountInput.focus();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
withdrawModal.querySelectorAll('[data-aksrt-commission-withdraw-close]').forEach(function (button) {
|
||||||
|
button.addEventListener('click', closeWithdrawModal);
|
||||||
|
});
|
||||||
|
document.addEventListener('keydown', function (event) {
|
||||||
|
if (withdrawModal.hidden) return;
|
||||||
|
if (event.key === 'Escape') {
|
||||||
|
event.preventDefault();
|
||||||
|
closeWithdrawModal();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (event.key !== 'Tab') return;
|
||||||
|
var focusable = getWithdrawFocusable();
|
||||||
|
if (!focusable.length) return;
|
||||||
|
var first = focusable[0];
|
||||||
|
var last = focusable[focusable.length - 1];
|
||||||
|
if (event.shiftKey && document.activeElement === first) {
|
||||||
|
event.preventDefault();
|
||||||
|
last.focus();
|
||||||
|
} else if (!event.shiftKey && document.activeElement === last) {
|
||||||
|
event.preventDefault();
|
||||||
|
first.focus();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
withdrawForm.addEventListener('submit', function (event) {
|
||||||
|
event.preventDefault();
|
||||||
|
if (withdrawBusy) return;
|
||||||
|
var values = new FormData(withdrawForm);
|
||||||
|
var amount = Number(values.get('amount') || 0);
|
||||||
|
var minimum = Number(root.getAttribute('data-min-amount') || 50);
|
||||||
|
var account = String(values.get('account_info') || '').trim();
|
||||||
|
if (amount < minimum) { setWithdrawTip('提现金额未达到最低额度', true); return; }
|
||||||
|
if (!account) { setWithdrawTip('请填写收款账户信息', true); return; }
|
||||||
|
setWithdrawTip('正在提交...', false);
|
||||||
|
setWithdrawBusy(true);
|
||||||
|
fetch(rest + '/pay/balance/withdraw', { method: 'POST', credentials: 'same-origin', headers: { 'Content-Type': 'application/json', 'X-WP-Nonce': data.restNonce || data.nonce || '' }, body: JSON.stringify({ amount: amount, method: values.get('method') || 'alipay', account_info: account }) }).then(function (response) {
|
||||||
|
return response.json().catch(function () { return {}; }).then(function (json) { return { ok: response.ok, json: json }; });
|
||||||
|
}).then(function (result) {
|
||||||
|
if (!result.ok || !result.json || !result.json.success) { setWithdrawBusy(false); setWithdrawTip((result.json && result.json.message) || '提现申请失败', true); return; }
|
||||||
|
setWithdrawTip('提现申请已提交', false);
|
||||||
|
window.setTimeout(function () { window.location.reload(); }, 700);
|
||||||
|
}).catch(function () { setWithdrawBusy(false); setWithdrawTip('网络错误,请稍后重试', true); });
|
||||||
|
});
|
||||||
|
}
|
||||||
|
})();
|
||||||
@@ -104,7 +104,7 @@ if (!function_exists('aksrt_get_user_center_tab_url')) {
|
|||||||
function aksrt_get_user_center_tab_url(string $tab): string {
|
function aksrt_get_user_center_tab_url(string $tab): string {
|
||||||
$tab = sanitize_key($tab);
|
$tab = sanitize_key($tab);
|
||||||
if ('invite' === $tab || 'promotion' === $tab) {
|
if ('invite' === $tab || 'promotion' === $tab) {
|
||||||
$tab = 'promotion';
|
$tab = 'revenue';
|
||||||
}
|
}
|
||||||
$url = remove_query_arg([
|
$url = remove_query_arg([
|
||||||
'tab', 'posts_page', 'comments_page', 'favorites_page', 'credits_page',
|
'tab', 'posts_page', 'comments_page', 'favorites_page', 'credits_page',
|
||||||
@@ -154,7 +154,6 @@ if (!function_exists('aksrt_capture_user_center_view')) {
|
|||||||
'vip' => 'vip',
|
'vip' => 'vip',
|
||||||
'orders' => 'orders',
|
'orders' => 'orders',
|
||||||
'auth' => 'auth',
|
'auth' => 'auth',
|
||||||
'promotion' => 'promotion',
|
|
||||||
'revenue' => 'revenue',
|
'revenue' => 'revenue',
|
||||||
'settings' => 'settings',
|
'settings' => 'settings',
|
||||||
'header' => 'header',
|
'header' => 'header',
|
||||||
@@ -180,7 +179,7 @@ if (!function_exists('aksrt_capture_user_center_panel')) {
|
|||||||
* Capture a built-in or registered user-center panel body.
|
* Capture a built-in or registered user-center panel body.
|
||||||
*/
|
*/
|
||||||
function aksrt_capture_user_center_panel(string $tab_key, array $tab, array $context): string {
|
function aksrt_capture_user_center_panel(string $tab_key, array $tab, array $context): string {
|
||||||
$built_in_tabs = ['profile', 'level', 'posts', 'comments', 'favorites', 'credits', 'vip', 'orders', 'auth', 'promotion', 'revenue', 'settings'];
|
$built_in_tabs = ['profile', 'level', 'posts', 'comments', 'favorites', 'credits', 'vip', 'orders', 'auth', 'revenue', 'settings'];
|
||||||
if (in_array($tab_key, $built_in_tabs, true)) {
|
if (in_array($tab_key, $built_in_tabs, true)) {
|
||||||
return aksrt_capture_user_center_view($tab_key, $context);
|
return aksrt_capture_user_center_view($tab_key, $context);
|
||||||
}
|
}
|
||||||
@@ -288,7 +287,7 @@ if (!function_exists('aksrt_user_center_resolve_tabs')) {
|
|||||||
if ('signin' === $active || 'assets' === $active) {
|
if ('signin' === $active || 'assets' === $active) {
|
||||||
$active = 'credits';
|
$active = 'credits';
|
||||||
} elseif ('invite' === $active || 'promotion' === $active) {
|
} elseif ('invite' === $active || 'promotion' === $active) {
|
||||||
$active = 'promotion';
|
$active = 'revenue';
|
||||||
} elseif ('vip' === $active) {
|
} elseif ('vip' === $active) {
|
||||||
// Prefer dedicated vip tab when registered; else credits (VIP shop).
|
// Prefer dedicated vip tab when registered; else credits (VIP shop).
|
||||||
$active = in_array('vip', $keys, true) ? 'vip' : 'credits';
|
$active = in_array('vip', $keys, true) ? 'vip' : 'credits';
|
||||||
@@ -347,9 +346,9 @@ if (!function_exists('aksrt_user_center_runtime_config')) {
|
|||||||
'activeTab' => $active_tab,
|
'activeTab' => $active_tab,
|
||||||
'tabAliases' => [
|
'tabAliases' => [
|
||||||
'signin' => 'credits',
|
'signin' => 'credits',
|
||||||
'invite' => 'promotion',
|
'invite' => 'revenue',
|
||||||
'promotion' => 'promotion',
|
'promotion' => 'revenue',
|
||||||
'assets' => 'credits',
|
'assets' => 'credits',
|
||||||
// vip → vip when panel exists; SPA may still map missing keys via server resolve.
|
// vip → vip when panel exists; SPA may still map missing keys via server resolve.
|
||||||
'vip' => 'vip',
|
'vip' => 'vip',
|
||||||
],
|
],
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
<?php
|
<?php
|
||||||
/**
|
/**
|
||||||
* User center revenue panel.
|
* User center commission and promotion rewards panel.
|
||||||
*
|
*
|
||||||
* @package AKSRT
|
* @package AKSRT
|
||||||
*/
|
*/
|
||||||
@@ -10,52 +10,190 @@ defined('ABSPATH') || exit;
|
|||||||
$context = is_array($args['context'] ?? null) ? $args['context'] : [];
|
$context = is_array($args['context'] ?? null) ? $args['context'] : [];
|
||||||
$user_id = (int) ($context['user_id'] ?? get_current_user_id());
|
$user_id = (int) ($context['user_id'] ?? get_current_user_id());
|
||||||
if ($user_id <= 0) {
|
if ($user_id <= 0) {
|
||||||
echo '<div class="uc-panel-empty muted-2-color">' . esc_html__('请先登录', 'aksrt') . '</div>';
|
echo '<div class="uc-panel-empty muted-2-color">' . esc_html__('请先登录', 'aksrt') . '</div>';
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$show_revenue_section = !empty($context['show_revenue_section']);
|
$affiliate = class_exists('\AKSRT\Settings\Settings')
|
||||||
$revenue_view = function_exists('aksrt_get_revenue_page_view')
|
? \AKSRT\Settings\Settings::get_payment_affiliate_settings()
|
||||||
? aksrt_get_revenue_page_view($user_id)
|
: [];
|
||||||
: ['balance' => 0, 'total_earned' => 0, 'total_withdrawn' => 0, 'records' => []];
|
$withdrawal = class_exists('\AKSRT\Settings\Settings')
|
||||||
$settings = class_exists('\AKSRT\Settings\Settings') ? \AKSRT\Settings\Settings::get_withdrawal_settings() : [];
|
? \AKSRT\Settings\Settings::get_withdrawal_settings()
|
||||||
$min_amount = (float) ($settings['min_amount'] ?? 50);
|
: [];
|
||||||
$fee_rate = (float) ($settings['service_charge_rate'] ?? 0);
|
$all_settings = class_exists('\AKSRT\Settings\Settings')
|
||||||
$withdraw_text = (string) ($settings['text'] ?? '');
|
? \AKSRT\Settings\Settings::get_all()
|
||||||
$withdrawals = class_exists('\AKSRT\Payment\Withdrawal')
|
: [];
|
||||||
? \AKSRT\Payment\Withdrawal::get_instance()->get_user_withdrawals($user_id, ['limit' => 20])
|
$withdraw_on = !empty($all_settings['pay_balance_withdraw_s'])
|
||||||
: [];
|
&& class_exists('\AKSRT\Credits\Balance')
|
||||||
$records = (array) ($revenue_view['records'] ?? []);
|
&& \AKSRT\Credits\Balance::enabled();
|
||||||
$page = max(1, isset($_GET['rev_page']) ? (int) $_GET['rev_page'] : 1);
|
if ($withdraw_on && class_exists('\AKSRT\Settings\Capabilities') && !\AKSRT\Settings\Capabilities::user_can('balance_withdraw', $user_id)) {
|
||||||
$per_page = 20;
|
$withdraw_on = false;
|
||||||
$total_pages = max(1, (int) ceil(max(1, count($records)) / $per_page));
|
}
|
||||||
$paged_records = array_slice($records, ($page - 1) * $per_page, $per_page);
|
$withdraw_min = max(1, (float) ($all_settings['pay_balance_withdraw_lowest_money'] ?? $all_settings['pay_rebate_withdraw_lowest_money'] ?? $withdrawal['min_amount'] ?? 50));
|
||||||
$revenue_url = static function (int $target_page): string {
|
|
||||||
$url = function_exists('aksrt_get_user_center_tab_url') ? aksrt_get_user_center_tab_url('revenue') : home_url('/profile/?tab=revenue');
|
|
||||||
return $target_page > 1 ? add_query_arg('rev_page', $target_page, $url) : $url;
|
|
||||||
};
|
|
||||||
?>
|
|
||||||
<div class="aksrt-revenue-page uc-revenue-panel" data-aksrt-revenue-page data-min-amount="<?php echo esc_attr((string) $min_amount); ?>" data-fee-rate="<?php echo esc_attr((string) $fee_rate); ?>">
|
|
||||||
|
|
||||||
<?php if ($show_revenue_section) : ?>
|
$commission_stats = class_exists('\AKSRT\Payment\Rebate')
|
||||||
<section class="uc-revenue-card" aria-labelledby="uc-account-revenue-title">
|
? \AKSRT\Payment\Rebate::get_instance()->get_stats($user_id)
|
||||||
<header class="uc-revenue-card__header">
|
: ['total' => 0, 'pending' => 0, 'pending_amount' => 0, 'settled' => 0, 'total_amount' => 0, 'settled_amount' => 0];
|
||||||
<span class="uc-revenue-card__icon"><i class="fas fa-chart-line" aria-hidden="true"></i></span>
|
$available_commission = class_exists('\AKSRT\Credits\Balance')
|
||||||
<div>
|
? (float) \AKSRT\Credits\Balance::balance($user_id)
|
||||||
<p><?php esc_html_e('账户收益', 'aksrt'); ?></p>
|
: (float) ($commission_stats['settled_amount'] ?? 0);
|
||||||
<h3 id="uc-account-revenue-title"><?php esc_html_e('收益与提现', 'aksrt'); ?></h3>
|
$vip_ratios = is_array($affiliate['user_ratio'] ?? null) ? $affiliate['user_ratio'] : [];
|
||||||
</div>
|
$commission_ratio = (int) ($vip_ratios['user'] ?? $affiliate['ratio'] ?? 0);
|
||||||
</header>
|
$current_vip = function_exists('aksrt_get_user_vip_level') ? (int) aksrt_get_user_vip_level($user_id) : 0;
|
||||||
<div class="aksrt-revenue-page__stats" aria-label="<?php esc_attr_e('收益概览', 'aksrt'); ?>">
|
if ($current_vip >= 2 && !empty($vip_ratios['vip2'])) {
|
||||||
<div class="aksrt-revenue-page__stat-card"><div class="aksrt-revenue-page__stat-icon"><i class="fas fa-wallet" aria-hidden="true"></i></div><div class="aksrt-revenue-page__stat-info"><strong class="aksrt-revenue-page__stat-value" data-aksrt-revenue-balance>¥<?php echo esc_html(number_format_i18n((float) ($revenue_view['balance'] ?? 0), 2)); ?></strong><span class="aksrt-revenue-page__stat-label"><?php esc_html_e('可提现余额', 'aksrt'); ?></span></div></div>
|
$commission_ratio = (int) $vip_ratios['vip2'];
|
||||||
<div class="aksrt-revenue-page__stat-card"><div class="aksrt-revenue-page__stat-icon"><i class="fas fa-chart-line" aria-hidden="true"></i></div><div class="aksrt-revenue-page__stat-info"><strong class="aksrt-revenue-page__stat-value">¥<?php echo esc_html(number_format_i18n((float) ($revenue_view['total_earned'] ?? 0), 2)); ?></strong><span class="aksrt-revenue-page__stat-label"><?php esc_html_e('累计收益', 'aksrt'); ?></span></div></div>
|
} elseif ($current_vip >= 1 && !empty($vip_ratios['vip1'])) {
|
||||||
<div class="aksrt-revenue-page__stat-card"><div class="aksrt-revenue-page__stat-icon"><i class="fas fa-money-check-alt" aria-hidden="true"></i></div><div class="aksrt-revenue-page__stat-info"><strong class="aksrt-revenue-page__stat-value">¥<?php echo esc_html(number_format_i18n((float) ($revenue_view['total_withdrawn'] ?? 0), 2)); ?></strong><span class="aksrt-revenue-page__stat-label"><?php esc_html_e('已提现', 'aksrt'); ?></span></div></div>
|
$commission_ratio = (int) $vip_ratios['vip1'];
|
||||||
</div>
|
}
|
||||||
<div class="aksrt-revenue-page__layout">
|
$details_title = trim((string) ($affiliate['text']['details_title'] ?? '')) ?: __('返佣详解', 'aksrt');
|
||||||
<section class="aksrt-revenue-page__panel"><h3><?php esc_html_e('申请提现', 'aksrt'); ?></h3><?php if ($withdraw_text !== '') : ?><div class="aksrt-revenue-page__note"><?php echo wp_kses_post(wpautop($withdraw_text)); ?></div><?php endif; ?><form class="aksrt-revenue-page__withdraw-form" data-aksrt-withdraw-form><label><span><?php esc_html_e('提现金额', 'aksrt'); ?></span><input type="number" name="amount" min="<?php echo esc_attr((string) $min_amount); ?>" step="0.01" required></label><label><span><?php esc_html_e('提现方式', 'aksrt'); ?></span><select name="method"><option value="alipay"><?php esc_html_e('支付宝', 'aksrt'); ?></option><option value="wechat"><?php esc_html_e('微信', 'aksrt'); ?></option><option value="bank"><?php esc_html_e('银行卡', 'aksrt'); ?></option></select></label><label><span><?php esc_html_e('收款账户信息', 'aksrt'); ?></span><textarea name="account_info" rows="3" required></textarea></label><p class="aksrt-revenue-page__fee-hint"><?php printf(esc_html__('手续费 %s%%', 'aksrt'), esc_html((string) $fee_rate)); ?></p><button type="submit" class="btn-primary"><?php esc_html_e('提交提现申请', 'aksrt'); ?></button><p class="aksrt-revenue-page__form-msg" data-aksrt-withdraw-msg hidden></p></form></section>
|
$details_text = trim((string) ($affiliate['text']['details'] ?? ''));
|
||||||
<section class="aksrt-revenue-page__panel"><h3><?php esc_html_e('提现记录', 'aksrt'); ?></h3><div class="aksrt-revenue-page__list" data-aksrt-withdraw-list><?php if ($withdrawals) : foreach ($withdrawals as $withdrawal) : ?><div class="aksrt-revenue-page__item"><div><strong>¥<?php echo esc_html(number_format_i18n((float) ($withdrawal['amount'] ?? 0), 2)); ?></strong><span><?php echo esc_html((string) ($withdrawal['method'] ?? '')); ?></span></div><div><span><?php echo esc_html((string) ($withdrawal['status'] ?? '')); ?></span><time><?php echo esc_html((string) ($withdrawal['created_at'] ?? '')); ?></time></div></div><?php endforeach; else : ?><p class="aksrt-revenue-page__empty"><?php esc_html_e('暂无提现记录', 'aksrt'); ?></p><?php endif; ?></div></section>
|
if ($details_text === '') {
|
||||||
</div>
|
$details_text = trim((string) ($affiliate['note'] ?? '')) ?: __('好友通过推广链接完成符合条件的订单后,系统会按当前佣金比例记录返佣,结算后进入可提现余额。', 'aksrt');
|
||||||
<section class="aksrt-revenue-page__section"><h3><?php esc_html_e('收益明细', 'aksrt'); ?></h3><?php if ($paged_records) : ?><div class="aksrt-revenue-page__list"><?php foreach ($paged_records as $record) : ?><div class="aksrt-revenue-page__item"><div><strong><?php echo esc_html((string) ($record['title'] ?? '')); ?></strong><time><?php echo esc_html((string) ($record['created_at'] ?? '')); ?></time></div><span class="<?php echo ($record['type'] ?? '') === 'withdrawal' ? 'is-out' : 'is-in'; ?>"><?php echo ($record['type'] ?? '') === 'withdrawal' ? '-' : '+'; ?>¥<?php echo esc_html(number_format_i18n((float) ($record['amount'] ?? 0), 2)); ?></span></div><?php endforeach; ?></div><?php if ($total_pages > 1) : ?><nav class="aksrt-revenue-page__pagination" aria-label="<?php esc_attr_e('收益分页', 'aksrt'); ?>"><?php for ($index = 1; $index <= $total_pages; $index++) : ?><a class="aksrt-revenue-page__page-chip<?php echo $index === $page ? ' is-active' : ''; ?>" href="<?php echo esc_url($revenue_url($index)); ?>"><?php echo esc_html((string) $index); ?></a><?php endfor; ?></nav><?php endif; ?><?php else : ?><p class="aksrt-revenue-page__empty"><?php esc_html_e('暂无收益明细', 'aksrt'); ?></p><?php endif; ?></section>
|
}
|
||||||
</section>
|
|
||||||
<?php endif; ?>
|
$active_reward_tab = sanitize_key((string) ($_GET['reward_tab'] ?? 'detail'));
|
||||||
|
if (!in_array($active_reward_tab, ['detail', 'orders', 'users'], true)) {
|
||||||
|
$active_reward_tab = 'detail';
|
||||||
|
}
|
||||||
|
$base_url = function_exists('aksrt_get_user_center_tab_url')
|
||||||
|
? aksrt_get_user_center_tab_url('revenue')
|
||||||
|
: home_url('/profile/?tab=revenue');
|
||||||
|
$reward_url = static function (string $tab, array $extra = []) use ($base_url): string {
|
||||||
|
return add_query_arg(array_merge(['reward_tab' => $tab], $extra), $base_url);
|
||||||
|
};
|
||||||
|
$format_amount = static function ($amount): string {
|
||||||
|
return number_format_i18n((float) $amount, 2);
|
||||||
|
};
|
||||||
|
|
||||||
|
$commission_page = max(1, (int) ($_GET['commission_page'] ?? 1));
|
||||||
|
$commission_view = class_exists('\AKSRT\Payment\Rebate')
|
||||||
|
? \AKSRT\Payment\Rebate::get_instance()->get_list([
|
||||||
|
'user_id' => $user_id,
|
||||||
|
'limit' => 10,
|
||||||
|
'offset' => ($commission_page - 1) * 10,
|
||||||
|
])
|
||||||
|
: ['items' => [], 'total' => 0, 'max_pages' => 1, 'page' => 1];
|
||||||
|
$commission_items = (array) ($commission_view['items'] ?? []);
|
||||||
|
$commission_total_pages = max(1, (int) ($commission_view['max_pages'] ?? ceil(max(1, (int) ($commission_view['total'] ?? 0)) / 10)));
|
||||||
|
if ($commission_page > $commission_total_pages) {
|
||||||
|
$commission_page = $commission_total_pages;
|
||||||
|
if (class_exists('\AKSRT\Payment\Rebate')) {
|
||||||
|
$commission_view = \AKSRT\Payment\Rebate::get_instance()->get_list([
|
||||||
|
'user_id' => $user_id,
|
||||||
|
'limit' => 10,
|
||||||
|
'offset' => ($commission_page - 1) * 10,
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$commission_items = (array) ($commission_view['items'] ?? []);
|
||||||
|
$status_labels = [
|
||||||
|
'pending' => __('待结算', 'aksrt'),
|
||||||
|
'settled' => __('已结算', 'aksrt'),
|
||||||
|
'cancelled' => __('已取消', 'aksrt'),
|
||||||
|
];
|
||||||
|
?>
|
||||||
|
<div class="aksrt-revenue-page uc-revenue-panel" data-aksrt-revenue-page data-min-amount="<?php echo esc_attr((string) $withdraw_min); ?>">
|
||||||
|
<section class="uc-commission-summary" aria-label="<?php esc_attr_e('佣金概览', 'aksrt'); ?>">
|
||||||
|
<article class="uc-commission-card uc-commission-card--ratio">
|
||||||
|
<div class="uc-commission-card__icon"><i class="fas fa-percentage" aria-hidden="true"></i></div>
|
||||||
|
<div class="uc-commission-card__body">
|
||||||
|
<span><?php esc_html_e('佣金比例', 'aksrt'); ?></span>
|
||||||
|
<strong><?php echo esc_html((string) $commission_ratio); ?><small>%</small></strong>
|
||||||
|
<p><?php esc_html_e('普通用户推广订单返佣比例', 'aksrt'); ?></p>
|
||||||
|
</div>
|
||||||
|
</article>
|
||||||
|
<article class="uc-commission-card uc-commission-card--balance">
|
||||||
|
<div class="uc-commission-card__icon"><i class="fas fa-wallet" aria-hidden="true"></i></div>
|
||||||
|
<div class="uc-commission-card__body">
|
||||||
|
<span><?php esc_html_e('我的佣金', 'aksrt'); ?></span>
|
||||||
|
<strong><?php echo esc_html($format_amount($available_commission)); ?></strong>
|
||||||
|
<p><?php printf(esc_html__('累计佣金 %s,待结算 %s', 'aksrt'), esc_html($format_amount($commission_stats['total_amount'] ?? 0)), esc_html($format_amount($commission_stats['pending_amount'] ?? 0))); ?></p>
|
||||||
|
</div>
|
||||||
|
<?php if ($withdraw_on) : ?>
|
||||||
|
<button type="button" class="uc-commission-card__action" data-aksrt-commission-withdraw-open><i class="fas fa-arrow-right" aria-hidden="true"></i><?php esc_html_e('立即提现', 'aksrt'); ?></button>
|
||||||
|
<?php endif; ?>
|
||||||
|
</article>
|
||||||
|
</section>
|
||||||
|
|
||||||
|
<section class="uc-reward-area" aria-labelledby="uc-reward-area-title">
|
||||||
|
<div class="uc-reward-area__heading">
|
||||||
|
<h3 id="uc-reward-area-title"><?php esc_html_e('推广奖励', 'aksrt'); ?></h3>
|
||||||
|
<span><?php esc_html_e('邀请与返佣数据', 'aksrt'); ?></span>
|
||||||
|
</div>
|
||||||
|
<nav class="uc-reward-tabs" aria-label="<?php esc_attr_e('推广奖励', 'aksrt'); ?>">
|
||||||
|
<a <?php echo $active_reward_tab === 'detail' ? 'aria-current="page"' : ''; ?> class="<?php echo $active_reward_tab === 'detail' ? 'is-active' : ''; ?>" href="<?php echo esc_url($reward_url('detail')); ?>"><?php esc_html_e('佣金详细', 'aksrt'); ?></a>
|
||||||
|
<a <?php echo $active_reward_tab === 'orders' ? 'aria-current="page"' : ''; ?> class="<?php echo $active_reward_tab === 'orders' ? 'is-active' : ''; ?>" href="<?php echo esc_url($reward_url('orders')); ?>"><?php esc_html_e('佣金明细', 'aksrt'); ?></a>
|
||||||
|
<a <?php echo $active_reward_tab === 'users' ? 'aria-current="page"' : ''; ?> class="<?php echo $active_reward_tab === 'users' ? 'is-active' : ''; ?>" href="<?php echo esc_url($reward_url('users')); ?>"><?php esc_html_e('推荐用户', 'aksrt'); ?></a>
|
||||||
|
</nav>
|
||||||
|
|
||||||
|
<?php if ($active_reward_tab === 'detail') : ?>
|
||||||
|
<div class="uc-reward-pane uc-reward-pane--detail">
|
||||||
|
<section class="uc-reward-block" aria-labelledby="uc-referral-link-title">
|
||||||
|
<div class="uc-reward-block__heading"><h4 id="uc-referral-link-title"><?php esc_html_e('推广链接', 'aksrt'); ?></h4><p><?php esc_html_e('分享链接,好友注册后会自动建立邀请关系。', 'aksrt'); ?></p></div>
|
||||||
|
<div class="uc-invite-share">
|
||||||
|
<div class="uc-invite-code"><span><?php esc_html_e('我的邀请码', 'aksrt'); ?></span><strong data-invite-code>--</strong></div>
|
||||||
|
<label class="screen-reader-text" for="aksrt-invite-link"><?php esc_html_e('推广链接', 'aksrt'); ?></label>
|
||||||
|
<div class="uc-invite-link-row"><input id="aksrt-invite-link" type="text" data-invite-link readonly value=""><button type="button" class="btn-primary btn-sm" data-invite-copy disabled><i class="fas fa-copy" aria-hidden="true"></i><span><?php esc_html_e('复制链接', 'aksrt'); ?></span></button></div>
|
||||||
|
<p class="uc-reward-status" data-invite-status role="status" aria-live="polite"><?php esc_html_e('正在加载推广数据...', 'aksrt'); ?></p>
|
||||||
|
<p class="uc-reward-copy-feedback" data-invite-copy-feedback role="status" aria-live="polite"></p>
|
||||||
|
</div>
|
||||||
|
</section>
|
||||||
|
<section class="uc-reward-block" aria-labelledby="uc-ratio-title">
|
||||||
|
<div class="uc-reward-block__heading"><h4 id="uc-ratio-title"><?php esc_html_e('佣金比例', 'aksrt'); ?></h4><p><?php esc_html_e('当前推广身份对应的返佣规则。', 'aksrt'); ?></p></div>
|
||||||
|
<dl class="uc-ratio-list">
|
||||||
|
<div><dt><?php esc_html_e('普通用户', 'aksrt'); ?></dt><dd><?php echo esc_html((string) ($vip_ratios['user'] ?? $commission_ratio)); ?>%</dd></div>
|
||||||
|
<div><dt>VIP 1</dt><dd><?php echo esc_html((string) ($vip_ratios['vip1'] ?? 0)); ?>%</dd></div>
|
||||||
|
<div><dt>VIP 2</dt><dd><?php echo esc_html((string) ($vip_ratios['vip2'] ?? 0)); ?>%</dd></div>
|
||||||
|
</dl>
|
||||||
|
</section>
|
||||||
|
<section class="uc-reward-block" aria-labelledby="uc-total-title">
|
||||||
|
<div class="uc-reward-block__heading"><h4 id="uc-total-title"><?php esc_html_e('累计佣金', 'aksrt'); ?></h4><p><?php esc_html_e('按已创建的返佣记录汇总。', 'aksrt'); ?></p></div>
|
||||||
|
<div class="uc-total-commission"><strong><?php echo esc_html($format_amount($commission_stats['total_amount'] ?? 0)); ?></strong><span><?php printf(esc_html__('%d 笔佣金记录', 'aksrt'), (int) ($commission_stats['total'] ?? 0)); ?></span></div>
|
||||||
|
</section>
|
||||||
|
<section class="uc-reward-block" aria-labelledby="uc-details-title">
|
||||||
|
<div class="uc-reward-block__heading"><h4 id="uc-details-title"><?php echo esc_html($details_title); ?></h4></div>
|
||||||
|
<div class="uc-reward-richtext"><?php echo wp_kses_post(wpautop($details_text)); ?></div>
|
||||||
|
</section>
|
||||||
|
</div>
|
||||||
|
<?php elseif ($active_reward_tab === 'orders') : ?>
|
||||||
|
<div class="uc-reward-pane">
|
||||||
|
<div class="uc-reward-list-heading"><div><h4><?php esc_html_e('佣金订单', 'aksrt'); ?></h4><p><?php esc_html_e('每页显示 10 条佣金记录。', 'aksrt'); ?></p></div><strong><?php printf(esc_html__('%d 条', 'aksrt'), (int) ($commission_view['total'] ?? 0)); ?></strong></div>
|
||||||
|
<?php if ($commission_items) : ?>
|
||||||
|
<div class="uc-commission-list">
|
||||||
|
<?php foreach ($commission_items as $item) :
|
||||||
|
$status = sanitize_key((string) ($item['status'] ?? 'pending'));
|
||||||
|
$source_user = !empty($item['source_user_id']) ? get_userdata((int) $item['source_user_id']) : null;
|
||||||
|
$source_name = $source_user instanceof WP_User ? $source_user->display_name : __('推广用户', 'aksrt');
|
||||||
|
?>
|
||||||
|
<article class="uc-commission-row"><span class="uc-commission-row__icon"><i class="fas fa-receipt" aria-hidden="true"></i></span><div class="uc-commission-row__main"><strong><?php echo esc_html($source_name); ?></strong><span><?php printf(esc_html__('订单 %s', 'aksrt'), esc_html((string) ($item['order_number'] ?? '-'))); ?></span><time><?php echo esc_html((string) ($item['created_at'] ?? '')); ?></time></div><div class="uc-commission-row__value"><strong>+<?php echo esc_html($format_amount($item['amount'] ?? 0)); ?></strong><span class="is-<?php echo esc_attr($status); ?>"><?php echo esc_html($status_labels[$status] ?? $status); ?></span></div></article>
|
||||||
|
<?php endforeach; ?>
|
||||||
|
</div>
|
||||||
|
<?php if ($commission_total_pages > 1) : ?><nav class="uc-reward-pagination" aria-label="<?php esc_attr_e('佣金明细分页', 'aksrt'); ?>"><?php for ($i = 1; $i <= $commission_total_pages; $i++) : ?><a class="<?php echo $i === $commission_page ? 'is-active' : ''; ?>" href="<?php echo esc_url($reward_url('orders', ['commission_page' => $i])); ?>"><?php echo esc_html((string) $i); ?></a><?php endfor; ?></nav><?php endif; ?>
|
||||||
|
<?php else : ?><p class="uc-reward-empty"><?php esc_html_e('暂无佣金订单', 'aksrt'); ?></p><?php endif; ?>
|
||||||
|
</div>
|
||||||
|
<?php else : ?>
|
||||||
|
<div class="uc-reward-pane">
|
||||||
|
<div class="uc-reward-list-heading"><div><h4><?php esc_html_e('邀请记录', 'aksrt'); ?></h4><p><?php esc_html_e('通过推广链接注册的用户会显示在这里。', 'aksrt'); ?></p></div><strong data-invite-total><?php esc_html_e('加载中...', 'aksrt'); ?></strong></div>
|
||||||
|
<div class="uc-invite-list is-loading" data-invite-list aria-live="polite"><p class="uc-reward-empty"><?php esc_html_e('正在加载邀请记录...', 'aksrt'); ?></p></div>
|
||||||
|
</div>
|
||||||
|
<?php endif; ?>
|
||||||
|
</section>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<?php if ($withdraw_on) : ?>
|
||||||
|
<div class="uc-modal" id="aksrt-commission-withdraw-modal" hidden data-aksrt-commission-withdraw-modal>
|
||||||
|
<div class="uc-modal__overlay" data-aksrt-commission-withdraw-close></div>
|
||||||
|
<div class="uc-modal__dialog" role="dialog" tabindex="-1" aria-modal="true" aria-labelledby="aksrt-commission-withdraw-title">
|
||||||
|
<button type="button" class="uc-modal__close" data-aksrt-commission-withdraw-close aria-label="<?php esc_attr_e('关闭', 'aksrt'); ?>"><i class="fas fa-times" aria-hidden="true"></i></button>
|
||||||
|
<h3 class="uc-modal__title" id="aksrt-commission-withdraw-title"><?php esc_html_e('立即提现', 'aksrt'); ?></h3>
|
||||||
|
<form data-aksrt-commission-withdraw-form>
|
||||||
|
<label><?php esc_html_e('提现金额', 'aksrt'); ?><input type="number" name="amount" min="<?php echo esc_attr((string) $withdraw_min); ?>" step="0.01" data-aksrt-commission-withdraw-amount required></label>
|
||||||
|
<p class="muted-2-color em09"><?php printf(esc_html__('最低提现 %s,当前可提现 %s', 'aksrt'), esc_html($format_amount($withdraw_min)), esc_html($format_amount($available_commission))); ?></p>
|
||||||
|
<label><?php esc_html_e('提现方式', 'aksrt'); ?><select name="method" data-aksrt-commission-withdraw-method><option value="alipay"><?php esc_html_e('支付宝', 'aksrt'); ?></option><option value="wechat"><?php esc_html_e('微信', 'aksrt'); ?></option><option value="bank"><?php esc_html_e('银行卡', 'aksrt'); ?></option></select></label>
|
||||||
|
<label><?php esc_html_e('收款账户信息', 'aksrt'); ?><textarea name="account_info" rows="3" data-aksrt-commission-withdraw-account required placeholder="<?php esc_attr_e('姓名 + 账号 / 卡号', 'aksrt'); ?>"></textarea></label>
|
||||||
|
<p class="uc-modal__tip" data-aksrt-commission-withdraw-tip role="status" aria-live="polite"></p>
|
||||||
|
<button type="submit" class="btn-primary btn-block" data-aksrt-commission-withdraw-submit><?php esc_html_e('提交申请', 'aksrt'); ?></button>
|
||||||
|
</form>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<?php endif; ?>
|
||||||
@@ -11,7 +11,6 @@ $level_url = isset($dashboard_tabs['level'])
|
|||||||
? aksrt_get_user_center_tab_url('level')
|
? aksrt_get_user_center_tab_url('level')
|
||||||
: '';
|
: '';
|
||||||
$auth_url = isset($dashboard_tabs['auth']) ? aksrt_get_user_center_tab_url('auth') : '';
|
$auth_url = isset($dashboard_tabs['auth']) ? aksrt_get_user_center_tab_url('auth') : '';
|
||||||
$promotion_url = isset($dashboard_tabs['promotion']) ? aksrt_get_user_center_tab_url('promotion') : '';
|
|
||||||
$orders_available = isset($dashboard_tabs['orders']);
|
$orders_available = isset($dashboard_tabs['orders']);
|
||||||
$orders_url = $orders_available ? (string) ($orders_url ?? '') : '';
|
$orders_url = $orders_available ? (string) ($orders_url ?? '') : '';
|
||||||
|
|
||||||
@@ -22,13 +21,7 @@ $services = array_values(array_filter([
|
|||||||
'tone' => 'level',
|
'tone' => 'level',
|
||||||
'url' => $level_url,
|
'url' => $level_url,
|
||||||
],
|
],
|
||||||
[
|
|
||||||
'label' => __('推广中心', 'aksrt'),
|
|
||||||
'icon' => 'bullhorn',
|
|
||||||
'tone' => 'promotion',
|
|
||||||
'url' => $promotion_url,
|
|
||||||
'tab' => 'promotion',
|
|
||||||
],
|
|
||||||
[
|
[
|
||||||
'label' => __('官方认证', 'aksrt'),
|
'label' => __('官方认证', 'aksrt'),
|
||||||
'icon' => 'id-badge',
|
'icon' => 'id-badge',
|
||||||
|
|||||||
@@ -32,8 +32,8 @@ function aksrt_get_user_center_url(string $tab = ''): string {
|
|||||||
'assets' => 'credits',
|
'assets' => 'credits',
|
||||||
'vip' => 'vip', // dedicated vip tab when registered; resolver falls back if missing
|
'vip' => 'vip', // dedicated vip tab when registered; resolver falls back if missing
|
||||||
'signin' => 'credits',
|
'signin' => 'credits',
|
||||||
'invite' => 'promotion',
|
'invite' => 'revenue',
|
||||||
'promotion' => 'promotion',
|
'promotion' => 'revenue',
|
||||||
];
|
];
|
||||||
if (isset($aliases[$tab])) {
|
if (isset($aliases[$tab])) {
|
||||||
$tab = $aliases[$tab];
|
$tab = $aliases[$tab];
|
||||||
|
|||||||
@@ -702,7 +702,7 @@ $hmb_js = get_template_directory() . '/assets/js/header-newadd.js';
|
|||||||
&& isset($_GET['tab'])
|
&& isset($_GET['tab'])
|
||||||
&& 'revenue' === sanitize_key((string) wp_unslash($_GET['tab']))
|
&& 'revenue' === sanitize_key((string) wp_unslash($_GET['tab']))
|
||||||
);
|
);
|
||||||
if ($is_revenue_surface) {
|
if ($is_revenue_surface && !$is_profile_page) {
|
||||||
$revenue_js = get_template_directory() . '/assets/js/revenue.js';
|
$revenue_js = get_template_directory() . '/assets/js/revenue.js';
|
||||||
wp_enqueue_script(
|
wp_enqueue_script(
|
||||||
'aksrt-revenue',
|
'aksrt-revenue',
|
||||||
@@ -919,6 +919,18 @@ $hmb_js = get_template_directory() . '/assets/js/header-newadd.js';
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
if ($is_profile_page) {
|
||||||
|
$revenue_invite_js_path = get_template_directory() . '/assets/js/revenue-invite.js';
|
||||||
|
if (file_exists($revenue_invite_js_path)) {
|
||||||
|
wp_enqueue_script(
|
||||||
|
'aksrt-revenue-invite',
|
||||||
|
$base_uri . '/assets/js/revenue-invite.js',
|
||||||
|
['aksrt-script'],
|
||||||
|
(string) filemtime($revenue_invite_js_path),
|
||||||
|
true
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
// Badges UI: user center + public profile (zibll medal modal/list).
|
// Badges UI: user center + public profile (zibll medal modal/list).
|
||||||
if (class_exists('\AKSRT\User\Badges') && \AKSRT\User\Badges::enabled()) {
|
if (class_exists('\AKSRT\User\Badges') && \AKSRT\User\Badges::enabled()) {
|
||||||
$is_badge_surface = $is_profile_page
|
$is_badge_surface = $is_profile_page
|
||||||
|
|||||||
@@ -368,6 +368,7 @@ class Balance {
|
|||||||
'admin' => __('管理员调整', 'aksrt'),
|
'admin' => __('管理员调整', 'aksrt'),
|
||||||
'exchange_from_credits' => __('积分兑换', 'aksrt'),
|
'exchange_from_credits' => __('积分兑换', 'aksrt'),
|
||||||
'creator_income' => __('创作收益结算', 'aksrt'),
|
'creator_income' => __('创作收益结算', 'aksrt'),
|
||||||
|
'rebate' => __('推广返佣结算', 'aksrt'),
|
||||||
'withdraw_hold' => __('提现冻结', 'aksrt'),
|
'withdraw_hold' => __('提现冻结', 'aksrt'),
|
||||||
'withdraw_refund' => __('提现退回', 'aksrt'),
|
'withdraw_refund' => __('提现退回', 'aksrt'),
|
||||||
];
|
];
|
||||||
|
|||||||
+23
-9
@@ -59,18 +59,30 @@ class Invite {
|
|||||||
'permission_callback' => function () {
|
'permission_callback' => function () {
|
||||||
return is_user_logged_in();
|
return is_user_logged_in();
|
||||||
},
|
},
|
||||||
|
'args' => [
|
||||||
|
'page' => [
|
||||||
|
'type' => 'integer',
|
||||||
|
'default' => 1,
|
||||||
|
'minimum' => 1,
|
||||||
|
],
|
||||||
|
'per_page' => [
|
||||||
|
'type' => 'integer',
|
||||||
|
'default' => 10,
|
||||||
|
'minimum' => 1,
|
||||||
|
'maximum' => 50,
|
||||||
|
],
|
||||||
|
],
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
/** Capture ?ref=XYZ, with legacy ?invite=XYZ support. */
|
||||||
/** 捕获 ?invite=XYZ */
|
|
||||||
public function capture_invite_cookie(): void {
|
public function capture_invite_cookie(): void {
|
||||||
if (is_admin()) return;
|
if (is_admin()) return;
|
||||||
if (empty($_GET['invite'])) return;
|
$raw_code = $_GET['ref'] ?? $_GET['invite'] ?? '';
|
||||||
|
if ($raw_code === '') return;
|
||||||
// 邀请注册功能关闭时不处理
|
// 邀请注册功能关闭时不处理
|
||||||
if (class_exists('\AKSRT\Settings\Settings') && !\AKSRT\Settings\Settings::invite_registration_enabled()) return;
|
if (class_exists('\AKSRT\Settings\Settings') && !\AKSRT\Settings\Settings::invite_registration_enabled()) return;
|
||||||
|
|
||||||
$code = sanitize_key((string) $_GET['invite']);
|
$code = sanitize_key(wp_unslash((string) $raw_code));
|
||||||
if ($code === '') return;
|
if ($code === '') return;
|
||||||
|
|
||||||
// 校验邀请码是否对应真实用户
|
// 校验邀请码是否对应真实用户
|
||||||
@@ -609,7 +621,7 @@ class Invite {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$invite_url = add_query_arg('invite', $code, aksrt_get_register_url());
|
$invite_url = add_query_arg('ref', $code, home_url('/'));
|
||||||
|
|
||||||
return new \WP_REST_Response([
|
return new \WP_REST_Response([
|
||||||
'code' => $code,
|
'code' => $code,
|
||||||
@@ -626,9 +638,7 @@ class Invite {
|
|||||||
global $wpdb;
|
global $wpdb;
|
||||||
$user_id = get_current_user_id();
|
$user_id = get_current_user_id();
|
||||||
$page = max(1, (int) $request->get_param('page'));
|
$page = max(1, (int) $request->get_param('page'));
|
||||||
$per_page = min(50, max(1, (int) $request->get_param('per_page') ?: 20));
|
$per_page = min(50, max(1, (int) $request->get_param('per_page') ?: 10));
|
||||||
$offset = ($page - 1) * $per_page;
|
|
||||||
|
|
||||||
$table = \AKSRT\Core\DBMigrator::table('invite');
|
$table = \AKSRT\Core\DBMigrator::table('invite');
|
||||||
if (!$table) {
|
if (!$table) {
|
||||||
return new \WP_REST_Response(['items' => [], 'total' => 0], 200);
|
return new \WP_REST_Response(['items' => [], 'total' => 0], 200);
|
||||||
@@ -638,6 +648,9 @@ class Invite {
|
|||||||
"SELECT COUNT(*) FROM {$table} WHERE inviter_id = %d",
|
"SELECT COUNT(*) FROM {$table} WHERE inviter_id = %d",
|
||||||
$user_id
|
$user_id
|
||||||
));
|
));
|
||||||
|
$total_pages = max(1, (int) ceil($total / $per_page));
|
||||||
|
$page = min($page, $total_pages);
|
||||||
|
$offset = ($page - 1) * $per_page;
|
||||||
$rows = $wpdb->get_results($wpdb->prepare(
|
$rows = $wpdb->get_results($wpdb->prepare(
|
||||||
"SELECT * FROM {$table} WHERE inviter_id = %d ORDER BY created_at DESC LIMIT %d OFFSET %d",
|
"SELECT * FROM {$table} WHERE inviter_id = %d ORDER BY created_at DESC LIMIT %d OFFSET %d",
|
||||||
$user_id,
|
$user_id,
|
||||||
@@ -664,6 +677,7 @@ class Invite {
|
|||||||
'total' => $total,
|
'total' => $total,
|
||||||
'page' => $page,
|
'page' => $page,
|
||||||
'per_page' => $per_page,
|
'per_page' => $per_page,
|
||||||
|
'total_pages' => $total_pages,
|
||||||
], 200);
|
], 200);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
+61
-28
@@ -79,31 +79,56 @@ class Rebate {
|
|||||||
public function settle(int $id): bool {
|
public function settle(int $id): bool {
|
||||||
global $wpdb;
|
global $wpdb;
|
||||||
|
|
||||||
$row = $wpdb->get_row($wpdb->prepare(
|
if (!class_exists('\AKSRT\Credits\Balance')) {
|
||||||
"SELECT * FROM {$this->table()} WHERE id = %d AND status = %s",
|
return false;
|
||||||
$id, self::STATUS_PENDING
|
|
||||||
), ARRAY_A);
|
|
||||||
|
|
||||||
if (!$row) return false;
|
|
||||||
|
|
||||||
$user_id = (int) $row['user_id'];
|
|
||||||
$amount = (float) $row['amount'];
|
|
||||||
|
|
||||||
$result = $wpdb->update($this->table(), [
|
|
||||||
'status' => self::STATUS_SETTLED,
|
|
||||||
'settled_at' => current_time('mysql'),
|
|
||||||
], ['id' => $id]);
|
|
||||||
|
|
||||||
if ($result && class_exists('\AKSRT\Credits\Credits')) {
|
|
||||||
\AKSRT\Credits\Credits::add($user_id, (int) $amount, 'rebate', [
|
|
||||||
'ref_type' => 'rebate',
|
|
||||||
'ref_id' => $id,
|
|
||||||
]);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return (bool) $result;
|
$wpdb->query('START TRANSACTION');
|
||||||
}
|
try {
|
||||||
|
$row = $wpdb->get_row($wpdb->prepare(
|
||||||
|
"SELECT id, user_id, amount, order_number FROM {$this->table()} WHERE id = %d AND status = %s FOR UPDATE",
|
||||||
|
$id,
|
||||||
|
self::STATUS_PENDING
|
||||||
|
), ARRAY_A);
|
||||||
|
if (!is_array($row)) {
|
||||||
|
$wpdb->query('ROLLBACK');
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
$credited = \AKSRT\Credits\Balance::add(
|
||||||
|
(int) $row['user_id'],
|
||||||
|
(float) $row['amount'],
|
||||||
|
'rebate',
|
||||||
|
['type' => 'rebate', 'id' => (int) $row['id']],
|
||||||
|
sprintf(__('推广返佣结算(订单 %s)', 'aksrt'), (string) $row['order_number'])
|
||||||
|
);
|
||||||
|
if (is_wp_error($credited)) {
|
||||||
|
$wpdb->query('ROLLBACK');
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
$settled = $wpdb->update(
|
||||||
|
$this->table(),
|
||||||
|
[
|
||||||
|
'status' => self::STATUS_SETTLED,
|
||||||
|
'settled_at' => current_time('mysql'),
|
||||||
|
],
|
||||||
|
['id' => $id, 'status' => self::STATUS_PENDING],
|
||||||
|
['%s', '%s'],
|
||||||
|
['%d', '%s']
|
||||||
|
);
|
||||||
|
if ($settled !== 1) {
|
||||||
|
$wpdb->query('ROLLBACK');
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
$wpdb->query('COMMIT');
|
||||||
|
return true;
|
||||||
|
} catch (\Throwable $e) {
|
||||||
|
$wpdb->query('ROLLBACK');
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
/**
|
/**
|
||||||
* 取消返佣
|
* 取消返佣
|
||||||
*/
|
*/
|
||||||
@@ -159,24 +184,32 @@ class Rebate {
|
|||||||
/**
|
/**
|
||||||
* 获取统计
|
* 获取统计
|
||||||
*/
|
*/
|
||||||
public function get_stats(): array {
|
public function get_stats(int $user_id = 0): array {
|
||||||
global $wpdb;
|
global $wpdb;
|
||||||
$table = $this->table();
|
$table = $this->table();
|
||||||
|
$where = '';
|
||||||
|
$params = [];
|
||||||
|
if ($user_id > 0) {
|
||||||
|
$where = 'WHERE user_id = %d';
|
||||||
|
$params[] = $user_id;
|
||||||
|
}
|
||||||
|
|
||||||
$row = $wpdb->get_row(
|
$sql = "SELECT
|
||||||
"SELECT
|
|
||||||
COUNT(*) as total,
|
COUNT(*) as total,
|
||||||
SUM(CASE WHEN status = 'pending' THEN 1 ELSE 0 END) as pending,
|
SUM(CASE WHEN status = 'pending' THEN 1 ELSE 0 END) as pending,
|
||||||
|
SUM(CASE WHEN status = 'pending' THEN amount ELSE 0 END) as pending_amount,
|
||||||
SUM(CASE WHEN status = 'settled' THEN 1 ELSE 0 END) as settled,
|
SUM(CASE WHEN status = 'settled' THEN 1 ELSE 0 END) as settled,
|
||||||
SUM(amount) as total_amount,
|
SUM(amount) as total_amount,
|
||||||
SUM(CASE WHEN status = 'settled' THEN amount ELSE 0 END) as settled_amount
|
SUM(CASE WHEN status = 'settled' THEN amount ELSE 0 END) as settled_amount
|
||||||
FROM {$table}",
|
FROM {$table} {$where}";
|
||||||
ARRAY_A
|
$row = $params
|
||||||
);
|
? $wpdb->get_row($wpdb->prepare($sql, $params), ARRAY_A)
|
||||||
|
: $wpdb->get_row($sql, ARRAY_A);
|
||||||
|
|
||||||
return [
|
return [
|
||||||
'total' => (int) ($row['total'] ?? 0),
|
'total' => (int) ($row['total'] ?? 0),
|
||||||
'pending' => (int) ($row['pending'] ?? 0),
|
'pending' => (int) ($row['pending'] ?? 0),
|
||||||
|
'pending_amount' => (float) ($row['pending_amount'] ?? 0),
|
||||||
'settled' => (int) ($row['settled'] ?? 0),
|
'settled' => (int) ($row['settled'] ?? 0),
|
||||||
'total_amount' => (float) ($row['total_amount'] ?? 0),
|
'total_amount' => (float) ($row['total_amount'] ?? 0),
|
||||||
'settled_amount' => (float) ($row['settled_amount'] ?? 0),
|
'settled_amount' => (float) ($row['settled_amount'] ?? 0),
|
||||||
|
|||||||
@@ -90,7 +90,7 @@ class UserRuntime {
|
|||||||
|
|
||||||
// Built-in switchable panels. VIP is always auto-injected when enabled
|
// Built-in switchable panels. VIP is always auto-injected when enabled
|
||||||
// by AKSRT\User\Center — keep it allowed for explicit config too.
|
// by AKSRT\User\Center — keep it allowed for explicit config too.
|
||||||
$allowed_tabs = ['profile', 'level', 'posts', 'comments', 'favorites', 'credits', 'promotion', 'revenue', 'vip', 'orders', 'auth', 'settings'];
|
$allowed_tabs = ['profile', 'level', 'posts', 'comments', 'favorites', 'credits', 'revenue', 'vip', 'orders', 'auth', 'settings'];
|
||||||
$normalized_tabs = ['profile'];
|
$normalized_tabs = ['profile'];
|
||||||
|
|
||||||
foreach ((array) $tabs as $tab) {
|
foreach ((array) $tabs as $tab) {
|
||||||
|
|||||||
+5
-31
@@ -91,12 +91,6 @@ class Center {
|
|||||||
'priority' => 50,
|
'priority' => 50,
|
||||||
'type' => 'panel',
|
'type' => 'panel',
|
||||||
],
|
],
|
||||||
'promotion' => [
|
|
||||||
'label' => __('推广中心', 'aksrt'),
|
|
||||||
'icon' => 'bullhorn',
|
|
||||||
'priority' => 52,
|
|
||||||
'type' => 'panel',
|
|
||||||
],
|
|
||||||
'revenue' => [
|
'revenue' => [
|
||||||
'label' => __('收益中心', 'aksrt'),
|
'label' => __('收益中心', 'aksrt'),
|
||||||
'icon' => 'chart-line',
|
'icon' => 'chart-line',
|
||||||
@@ -133,17 +127,9 @@ class Center {
|
|||||||
&& !empty(\AKSRT\User\Level::settings()['enabled']);
|
&& !empty(\AKSRT\User\Level::settings()['enabled']);
|
||||||
$credits_on = class_exists('\AKSRT\Settings\Settings') && \AKSRT\Settings\Settings::credits_enabled();
|
$credits_on = class_exists('\AKSRT\Settings\Settings') && \AKSRT\Settings\Settings::credits_enabled();
|
||||||
$balance_on = class_exists('\AKSRT\Credits\Balance') && \AKSRT\Credits\Balance::enabled();
|
$balance_on = class_exists('\AKSRT\Credits\Balance') && \AKSRT\Credits\Balance::enabled();
|
||||||
$invite_on = $credits_on
|
|
||||||
&& class_exists('\AKSRT\Settings\Settings')
|
|
||||||
&& \AKSRT\Settings\Settings::invite_enabled()
|
|
||||||
&& \AKSRT\Settings\Settings::invite_registration_enabled();
|
|
||||||
// Promotion (invite) center is its own tab; revenue stays pure earnings/withdrawal.
|
|
||||||
$promotion_on = $invite_on;
|
|
||||||
$revenue_tab_on = class_exists('\AKSRT\Settings\Settings')
|
$revenue_tab_on = class_exists('\AKSRT\Settings\Settings')
|
||||||
&& (
|
&& !empty(\AKSRT\Settings\Settings::get_payment_affiliate_settings()['enabled'])
|
||||||
!empty(\AKSRT\Settings\Settings::get_payment_revenue_settings()['enabled'])
|
&& \AKSRT\Settings\Settings::invite_registration_enabled();
|
||||||
|| !empty(\AKSRT\Settings\Settings::get_payment_affiliate_settings()['enabled'])
|
|
||||||
);
|
|
||||||
$vip_on = class_exists('\AKSRT\Settings\Settings')
|
$vip_on = class_exists('\AKSRT\Settings\Settings')
|
||||||
&& !empty(\AKSRT\Settings\Settings::get_payment_vip_settings()['enabled']);
|
&& !empty(\AKSRT\Settings\Settings::get_payment_vip_settings()['enabled']);
|
||||||
|
|
||||||
@@ -190,20 +176,10 @@ class Center {
|
|||||||
if (($credits_on || $balance_on) && !in_array('credits', $order, true)) {
|
if (($credits_on || $balance_on) && !in_array('credits', $order, true)) {
|
||||||
$order[] = 'credits';
|
$order[] = 'credits';
|
||||||
}
|
}
|
||||||
if ($promotion_on && !in_array('promotion', $order, true)) {
|
|
||||||
$insert_at = count($order);
|
|
||||||
foreach (['credits', 'favorites', 'posts'] as $anchor) {
|
|
||||||
$idx = array_search($anchor, $order, true);
|
|
||||||
if ($idx !== false) {
|
|
||||||
$insert_at = (int) $idx + 1;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
array_splice($order, $insert_at, 0, ['promotion']);
|
|
||||||
}
|
|
||||||
if ($revenue_tab_on && !in_array('revenue', $order, true)) {
|
if ($revenue_tab_on && !in_array('revenue', $order, true)) {
|
||||||
$insert_at = count($order);
|
$insert_at = count($order);
|
||||||
foreach (['promotion', 'credits', 'favorites', 'posts'] as $anchor) {
|
foreach (['credits', 'favorites', 'posts'] as $anchor) {
|
||||||
$idx = array_search($anchor, $order, true);
|
$idx = array_search($anchor, $order, true);
|
||||||
if ($idx !== false) {
|
if ($idx !== false) {
|
||||||
$insert_at = (int) $idx + 1;
|
$insert_at = (int) $idx + 1;
|
||||||
@@ -234,9 +210,7 @@ class Center {
|
|||||||
if ($key === 'revenue' && !$revenue_tab_on) {
|
if ($key === 'revenue' && !$revenue_tab_on) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if ($key === 'promotion' && !$promotion_on) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
if ($key === 'vip' && !$vip_on) {
|
if ($key === 'vip' && !$vip_on) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -122,7 +122,9 @@ if ($_SERVER['REQUEST_METHOD'] === 'POST' && isset($_POST['user_login'], $_POST[
|
|||||||
}
|
}
|
||||||
|
|
||||||
$invite_prefill = '';
|
$invite_prefill = '';
|
||||||
if (!empty($_GET['invite'])) {
|
if (!empty($_GET['ref'])) {
|
||||||
|
$invite_prefill = sanitize_key(wp_unslash($_GET['ref']));
|
||||||
|
} elseif (!empty($_GET['invite'])) {
|
||||||
$invite_prefill = sanitize_key(wp_unslash($_GET['invite']));
|
$invite_prefill = sanitize_key(wp_unslash($_GET['invite']));
|
||||||
} elseif (!empty($_COOKIE['aksrt_invite'])) {
|
} elseif (!empty($_COOKIE['aksrt_invite'])) {
|
||||||
$invite_prefill = sanitize_key(wp_unslash($_COOKIE['aksrt_invite']));
|
$invite_prefill = sanitize_key(wp_unslash($_COOKIE['aksrt_invite']));
|
||||||
|
|||||||
@@ -39,7 +39,9 @@ if (class_exists('\AKSRT\Settings\Settings')) {
|
|||||||
: (string) ($invite_cfg['open_desc'] ?? '');
|
: (string) ($invite_cfg['open_desc'] ?? '');
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!empty($_GET['invite'])) {
|
if (!empty($_GET['ref'])) {
|
||||||
|
$invite_prefill = sanitize_key(wp_unslash($_GET['ref']));
|
||||||
|
} elseif (!empty($_GET['invite'])) {
|
||||||
$invite_prefill = sanitize_key(wp_unslash($_GET['invite']));
|
$invite_prefill = sanitize_key(wp_unslash($_GET['invite']));
|
||||||
} elseif (!empty($_COOKIE['aksrt_invite'])) {
|
} elseif (!empty($_COOKIE['aksrt_invite'])) {
|
||||||
$invite_prefill = sanitize_key(wp_unslash($_COOKIE['aksrt_invite']));
|
$invite_prefill = sanitize_key(wp_unslash($_COOKIE['aksrt_invite']));
|
||||||
|
|||||||
Reference in new issue
Block a user