init
- 框架初始化 - 安装插件 - 修复PHP8.4报错
This commit is contained in:
506
public/assets/js/backend/shopro/commission/agent.js
Normal file
506
public/assets/js/backend/shopro/commission/agent.js
Normal file
@@ -0,0 +1,506 @@
|
||||
define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {
|
||||
|
||||
var Controller = {
|
||||
data: () => {
|
||||
return {
|
||||
statusStyle: {
|
||||
normal: { label: '正常', color: '#52c41a' },
|
||||
pending: { label: '审核中', color: '#faad14' },
|
||||
reject: { label: '拒绝', color: '#f56c6c' },
|
||||
freeze: { label: '冻结', color: '#409eff' },
|
||||
forbidden: { label: '禁用', color: '#999999' },
|
||||
}
|
||||
}
|
||||
},
|
||||
index: () => {
|
||||
const { reactive, onMounted } = Vue
|
||||
const index = {
|
||||
setup() {
|
||||
const state = reactive({
|
||||
data: [],
|
||||
filter: {
|
||||
drawer: false,
|
||||
data: {
|
||||
tabActive: 'all',
|
||||
user: { field: 'user_id', value: '' },
|
||||
level: '',
|
||||
status: '',
|
||||
createtime: [],
|
||||
},
|
||||
tools: {
|
||||
user: {
|
||||
type: 'tinputprepend',
|
||||
label: '会员信息',
|
||||
placeholder: '请输入查询内容',
|
||||
value: {
|
||||
field: 'user_id',
|
||||
value: '',
|
||||
},
|
||||
options: {
|
||||
data: [{
|
||||
label: '用户ID',
|
||||
value: 'user_id',
|
||||
},
|
||||
{
|
||||
label: '用户昵称',
|
||||
value: 'user.nickname',
|
||||
},
|
||||
{
|
||||
label: '用户手机号',
|
||||
value: 'user.mobile',
|
||||
}]
|
||||
}
|
||||
},
|
||||
level: {
|
||||
type: 'tselect',
|
||||
label: '分销商等级',
|
||||
value: '',
|
||||
options: {
|
||||
data: [],
|
||||
props: {
|
||||
label: 'name',
|
||||
value: 'level',
|
||||
},
|
||||
},
|
||||
},
|
||||
status: {
|
||||
type: 'tselect',
|
||||
label: '审核状态',
|
||||
value: '',
|
||||
options: {
|
||||
data: [{
|
||||
value: 'normal',
|
||||
label: '正常',
|
||||
},
|
||||
{
|
||||
value: 'forbidden',
|
||||
label: '禁用',
|
||||
},
|
||||
{
|
||||
value: 'pending',
|
||||
label: '审核中',
|
||||
},
|
||||
{
|
||||
value: 'freeze',
|
||||
label: '冻结',
|
||||
},
|
||||
{
|
||||
value: 'reject',
|
||||
label: '拒绝',
|
||||
}],
|
||||
},
|
||||
},
|
||||
createtime: {
|
||||
type: 'tdatetimerange',
|
||||
label: '更新时间',
|
||||
value: [],
|
||||
},
|
||||
},
|
||||
condition: {},
|
||||
}
|
||||
})
|
||||
|
||||
const type = reactive({
|
||||
data: {
|
||||
status: [{
|
||||
type: 'all',
|
||||
name: '分销商',
|
||||
},
|
||||
{
|
||||
type: 'pending',
|
||||
name: '待审核',
|
||||
},
|
||||
{
|
||||
type: '0',
|
||||
name: '待升级',
|
||||
}],
|
||||
}
|
||||
})
|
||||
|
||||
function getLevelSelect() {
|
||||
Fast.api.ajax({
|
||||
url: `shopro/commission/level/select`,
|
||||
type: 'GET',
|
||||
}, function (ret, res) {
|
||||
state.filter.tools.level.options.data = res.data;
|
||||
return false
|
||||
}, function (ret, res) { })
|
||||
}
|
||||
|
||||
function getData() {
|
||||
let tempSearch = JSON.parse(JSON.stringify(state.filter.data));
|
||||
let search = composeFilter(tempSearch, {
|
||||
'user.nickname': 'like',
|
||||
'user.mobile': 'like',
|
||||
createtime: 'range',
|
||||
});
|
||||
let temp = JSON.parse(search.search);
|
||||
if (temp && temp.tabActive) {
|
||||
if (temp.tabActive[0] == 'pending') {
|
||||
temp.status = ['pending', '='];
|
||||
delete temp.tabActive;
|
||||
} else if (temp.tabActive[0] == '0') {
|
||||
temp.level_status = ['0', '>'];
|
||||
delete temp.tabActive;
|
||||
}
|
||||
}
|
||||
search = { search: JSON.stringify(temp) };
|
||||
Fast.api.ajax({
|
||||
url: 'shopro/commission/agent',
|
||||
type: 'GET',
|
||||
data: {
|
||||
page: pagination.page,
|
||||
list_rows: pagination.list_rows,
|
||||
...search,
|
||||
},
|
||||
}, function (ret, res) {
|
||||
state.data = res.data.data
|
||||
pagination.total = res.data.total
|
||||
return false
|
||||
}, function (ret, res) { })
|
||||
}
|
||||
|
||||
function onOpenFilter() {
|
||||
state.filter.drawer = true
|
||||
}
|
||||
function onChangeFilter() {
|
||||
pagination.page = 1
|
||||
getData()
|
||||
state.filter.drawer && (state.filter.drawer = false)
|
||||
}
|
||||
|
||||
function onChangeTab() {
|
||||
pagination.page = 1
|
||||
getData()
|
||||
}
|
||||
|
||||
const pagination = reactive({
|
||||
page: 1,
|
||||
list_rows: 10,
|
||||
total: 0,
|
||||
})
|
||||
|
||||
function onEdit(id, data) {
|
||||
Fast.api.ajax({
|
||||
url: `shopro/commission/agent/edit/id/${id}`,
|
||||
type: 'POST',
|
||||
data: data,
|
||||
}, function (ret, res) {
|
||||
getData();
|
||||
}, function (ret, res) { })
|
||||
}
|
||||
|
||||
function onDetail(id) {
|
||||
Fast.api.open(`shopro/commission/agent/detail/id/${id}?id=${id}`, "详情", {
|
||||
callback() {
|
||||
getData()
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
onMounted(() => {
|
||||
getLevelSelect()
|
||||
getData()
|
||||
})
|
||||
|
||||
return {
|
||||
...Controller.data(),
|
||||
state,
|
||||
type,
|
||||
getData,
|
||||
onOpenFilter,
|
||||
onChangeFilter,
|
||||
onChangeTab,
|
||||
pagination,
|
||||
onEdit,
|
||||
onDetail,
|
||||
}
|
||||
}
|
||||
}
|
||||
createApp('index', index);
|
||||
},
|
||||
detail: () => {
|
||||
const { reactive, onMounted } = Vue
|
||||
const detail = {
|
||||
setup() {
|
||||
|
||||
const state = reactive({
|
||||
id: new URLSearchParams(location.search).get('id'),
|
||||
data: {},
|
||||
})
|
||||
|
||||
function getDetail() {
|
||||
Fast.api.ajax({
|
||||
url: `shopro/commission/agent/detail/id/${state.id}`,
|
||||
type: 'GET',
|
||||
}, function (ret, res) {
|
||||
state.data = res.data
|
||||
applyInfo.data = JSON.parse(JSON.stringify(state.data.apply_info))
|
||||
getLog()
|
||||
return false
|
||||
}, function (ret, res) { })
|
||||
}
|
||||
|
||||
function onChangeStatus(status) {
|
||||
onEdit({ status });
|
||||
}
|
||||
|
||||
function onChangeLevel() {
|
||||
Fast.api.open(`shopro/commission/level/select?level=${state.data.level}`, "更换分销等级", {
|
||||
callback(level) {
|
||||
onEdit({ level });
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
function onChangeParentUser() {
|
||||
Fast.api.open(`shopro/commission/agent/select?id=${state.data.user_id}`, "更换上级分销商", {
|
||||
callback() {
|
||||
getDetail()
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
const applyInfo = reactive({
|
||||
flag: false,
|
||||
data: []
|
||||
})
|
||||
function onCancelApplyInfo() {
|
||||
applyInfo.data = JSON.parse(JSON.stringify(state.data.apply_info));
|
||||
applyInfo.flag = false;
|
||||
}
|
||||
function onSaveApplyInfo() {
|
||||
onEdit({ apply_info: applyInfo.data });
|
||||
applyInfo.flag = false;
|
||||
}
|
||||
function onDeleteApplyInfo(index) {
|
||||
applyInfo.data.splice(index, 1);
|
||||
}
|
||||
|
||||
function onEdit(data) {
|
||||
Fast.api.ajax({
|
||||
url: `shopro/commission/agent/edit/id/${state.id}`,
|
||||
type: 'POST',
|
||||
data,
|
||||
}, function (ret, res) {
|
||||
getDetail()
|
||||
}, function (ret, res) { })
|
||||
}
|
||||
|
||||
function onTeam() {
|
||||
Fast.api.open(`shopro/commission/agent/team?id=${state.id}`, "查看团队")
|
||||
}
|
||||
|
||||
const log = reactive({
|
||||
tabActive: 'log',
|
||||
data: [],
|
||||
status: {
|
||||
0: 'info',
|
||||
1: 'success',
|
||||
'-1': 'warning',
|
||||
'-2': 'danger',
|
||||
}
|
||||
})
|
||||
|
||||
function getLog() {
|
||||
let search = composeFilter({ agent_id: state.id });
|
||||
Fast.api.ajax({
|
||||
url: `shopro/commission/${log.tabActive}`,
|
||||
type: 'GET',
|
||||
data: {
|
||||
page: pagination.page,
|
||||
list_rows: pagination.list_rows,
|
||||
...search,
|
||||
},
|
||||
}, function (ret, res) {
|
||||
if (log.tabActive == 'order') {
|
||||
log.data = res.data.list.data;
|
||||
pagination.total = res.data.list.total;
|
||||
} else {
|
||||
log.data = res.data.data;
|
||||
pagination.total = res.data.total;
|
||||
}
|
||||
return false
|
||||
}, function (ret, res) { })
|
||||
}
|
||||
|
||||
function onChangeTab() {
|
||||
pagination.page = 1
|
||||
log.data = []
|
||||
getLog()
|
||||
}
|
||||
|
||||
const pagination = reactive({
|
||||
page: 1,
|
||||
list_rows: 10,
|
||||
total: 0,
|
||||
})
|
||||
|
||||
function countCommission(item) {
|
||||
if (item) {
|
||||
let commission = 0;
|
||||
let commissioned = 0;
|
||||
item.forEach((r) => {
|
||||
if (r.status == 1) {
|
||||
commissioned += Number(r.commission);
|
||||
}
|
||||
commission += Number(r.commission);
|
||||
});
|
||||
|
||||
return `${commission}元/${commissioned}元`;
|
||||
}
|
||||
}
|
||||
|
||||
onMounted(() => {
|
||||
getDetail()
|
||||
})
|
||||
|
||||
return {
|
||||
...Controller.data(),
|
||||
state,
|
||||
getDetail,
|
||||
onChangeStatus,
|
||||
onChangeLevel,
|
||||
onChangeParentUser,
|
||||
applyInfo,
|
||||
onCancelApplyInfo,
|
||||
onSaveApplyInfo,
|
||||
onDeleteApplyInfo,
|
||||
onEdit,
|
||||
onTeam,
|
||||
log,
|
||||
getLog,
|
||||
onChangeTab,
|
||||
pagination,
|
||||
countCommission,
|
||||
}
|
||||
}
|
||||
}
|
||||
createApp('detail', detail);
|
||||
},
|
||||
select: () => {
|
||||
const { reactive, onMounted } = Vue
|
||||
const { ElMessage } = ElementPlus
|
||||
const select = {
|
||||
setup() {
|
||||
const state = reactive({
|
||||
id: new URLSearchParams(location.search).get('id'),
|
||||
data: [],
|
||||
filter: {
|
||||
data: {
|
||||
user: { field: 'user_id', value: '' },
|
||||
},
|
||||
},
|
||||
userDetail: {},
|
||||
parent_user_id: ''
|
||||
})
|
||||
|
||||
async function getUserDetail() {
|
||||
Fast.api.ajax({
|
||||
url: `shopro/user/user/detail/id/${state.id}`,
|
||||
type: 'GET',
|
||||
}, function (ret, res) {
|
||||
state.userDetail = res.data;
|
||||
state.parent_user_id = state.userDetail?.parent_user_id;
|
||||
return false
|
||||
}, function (ret, res) { })
|
||||
}
|
||||
|
||||
function getData() {
|
||||
let tempSearch = JSON.parse(JSON.stringify(state.filter.data));
|
||||
let search = composeFilter(tempSearch, {
|
||||
'user.nickname': 'like',
|
||||
'user.mobile': 'like',
|
||||
});
|
||||
Fast.api.ajax({
|
||||
url: 'shopro/commission/agent/select',
|
||||
type: 'GET',
|
||||
data: {
|
||||
page: pagination.page,
|
||||
list_rows: pagination.list_rows,
|
||||
...search,
|
||||
},
|
||||
}, function (ret, res) {
|
||||
state.data = res.data.data
|
||||
pagination.total = res.data.total
|
||||
return false
|
||||
}, function (ret, res) { })
|
||||
}
|
||||
|
||||
const pagination = reactive({
|
||||
page: 1,
|
||||
list_rows: 10,
|
||||
total: 0,
|
||||
})
|
||||
|
||||
function onSelect(row) {
|
||||
state.parent_user_id = row.user_id;
|
||||
}
|
||||
async function onConfirm() {
|
||||
if (state.parent_user_id == -1) {
|
||||
ElMessage.info('请选择上级');
|
||||
return;
|
||||
}
|
||||
Fast.api.ajax({
|
||||
url: `shopro/commission/agent/changeParentUser/id/${state.id}`,
|
||||
type: 'POST',
|
||||
data: {
|
||||
parent_user_id: state.parent_user_id,
|
||||
},
|
||||
}, function (ret, res) {
|
||||
Fast.api.close()
|
||||
}, function (ret, res) { })
|
||||
}
|
||||
|
||||
onMounted(() => {
|
||||
getUserDetail()
|
||||
getData()
|
||||
})
|
||||
|
||||
return {
|
||||
...Controller.data(),
|
||||
state,
|
||||
getData,
|
||||
pagination,
|
||||
onSelect,
|
||||
onConfirm,
|
||||
}
|
||||
}
|
||||
}
|
||||
createApp('select', select);
|
||||
},
|
||||
team: () => {
|
||||
const { reactive, onMounted } = Vue
|
||||
const team = {
|
||||
setup() {
|
||||
const state = reactive({
|
||||
id: new URLSearchParams(location.search).get('id'),
|
||||
data: {},
|
||||
})
|
||||
|
||||
async function getTeam(id) {
|
||||
Fast.api.ajax({
|
||||
url: `shopro/commission/agent/team/id/${id}`,
|
||||
type: 'GET',
|
||||
}, function (ret, res) {
|
||||
state.data = res.data;
|
||||
return false
|
||||
}, function (ret, res) { })
|
||||
}
|
||||
|
||||
onMounted(() => {
|
||||
getTeam(state.id)
|
||||
})
|
||||
|
||||
return {
|
||||
...Controller.data(),
|
||||
state,
|
||||
getTeam,
|
||||
}
|
||||
}
|
||||
}
|
||||
createApp('team', team);
|
||||
},
|
||||
};
|
||||
return Controller;
|
||||
});
|
||||
435
public/assets/js/backend/shopro/commission/goods.js
Normal file
435
public/assets/js/backend/shopro/commission/goods.js
Normal file
@@ -0,0 +1,435 @@
|
||||
define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {
|
||||
|
||||
var Controller = {
|
||||
index: () => {
|
||||
const { reactive, onMounted } = Vue
|
||||
const index = {
|
||||
setup() {
|
||||
const state = reactive({
|
||||
data: [],
|
||||
filter: {
|
||||
drawer: false,
|
||||
data: {
|
||||
keyword: { field: 'id', value: '' },
|
||||
'commission_goods.status': '',
|
||||
},
|
||||
tools: {
|
||||
keyword: {
|
||||
type: 'tinputprepend',
|
||||
label: '商品信息',
|
||||
placeholder: '请输入查询内容',
|
||||
value: {
|
||||
field: 'id',
|
||||
value: '',
|
||||
},
|
||||
options: {
|
||||
data: [{
|
||||
label: '商品ID',
|
||||
value: 'id',
|
||||
},
|
||||
{
|
||||
label: '商品名称',
|
||||
value: 'title',
|
||||
},
|
||||
{
|
||||
label: '商品副标题',
|
||||
value: 'subtitle',
|
||||
}],
|
||||
}
|
||||
},
|
||||
'commission_goods.status': {
|
||||
type: 'tselect',
|
||||
label: '分销状态',
|
||||
value: '',
|
||||
options: {
|
||||
data: [{
|
||||
label: '不参与',
|
||||
value: '0',
|
||||
},
|
||||
{
|
||||
label: '参与中',
|
||||
value: '1',
|
||||
}],
|
||||
},
|
||||
},
|
||||
},
|
||||
condition: {},
|
||||
},
|
||||
goodsStatusStyle: {
|
||||
0: 'danger',
|
||||
1: 'success',
|
||||
},
|
||||
statusStyle: {
|
||||
up: 'success',
|
||||
down: 'danger',
|
||||
hidden: 'info',
|
||||
},
|
||||
})
|
||||
|
||||
function getData() {
|
||||
let tempSearch = JSON.parse(JSON.stringify(state.filter.data));
|
||||
let search = composeFilter(tempSearch, {
|
||||
title: 'like',
|
||||
subtitle: 'like',
|
||||
});
|
||||
Fast.api.ajax({
|
||||
url: 'shopro/commission/goods',
|
||||
type: 'GET',
|
||||
data: {
|
||||
page: pagination.page,
|
||||
list_rows: pagination.list_rows,
|
||||
...search,
|
||||
},
|
||||
}, function (ret, res) {
|
||||
state.data = res.data.data
|
||||
pagination.total = res.data.total
|
||||
return false
|
||||
}, function (ret, res) { })
|
||||
}
|
||||
|
||||
function onOpenFilter() {
|
||||
state.filter.drawer = true
|
||||
}
|
||||
function onChangeFilter() {
|
||||
pagination.page = 1
|
||||
getData()
|
||||
state.filter.drawer && (state.filter.drawer = false)
|
||||
}
|
||||
|
||||
const pagination = reactive({
|
||||
page: 1,
|
||||
list_rows: 10,
|
||||
total: 0,
|
||||
})
|
||||
|
||||
const batchHandle = reactive({
|
||||
data: [],
|
||||
})
|
||||
function onChangeSelection(val) {
|
||||
batchHandle.data = val
|
||||
}
|
||||
function onBatchHandle(type) {
|
||||
let ids = []
|
||||
batchHandle.data.forEach((item) => {
|
||||
ids.push(item.id)
|
||||
})
|
||||
switch (type) {
|
||||
case 'edit':
|
||||
onEdit(ids.join(','), 'batch')
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
function onEdit(ids, rulesType = '') {
|
||||
Fast.api.open(`shopro/commission/goods/edit?type=edit&id=${ids}&rulesType=${rulesType}`, "设置佣金", {
|
||||
callback() {
|
||||
getData()
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
onMounted(() => {
|
||||
getData()
|
||||
})
|
||||
|
||||
return {
|
||||
state,
|
||||
getData,
|
||||
onOpenFilter,
|
||||
onChangeFilter,
|
||||
pagination,
|
||||
batchHandle,
|
||||
onChangeSelection,
|
||||
onBatchHandle,
|
||||
onEdit,
|
||||
}
|
||||
}
|
||||
}
|
||||
createApp('index', index);
|
||||
},
|
||||
edit: () => {
|
||||
Controller.form();
|
||||
},
|
||||
form: () => {
|
||||
const { reactive, onMounted } = Vue
|
||||
const { ElMessage } = ElementPlus
|
||||
const addEdit = {
|
||||
setup() {
|
||||
const state = reactive({
|
||||
type: new URLSearchParams(location.search).get('type'),
|
||||
id: new URLSearchParams(location.search).get('id'),
|
||||
rulesType: new URLSearchParams(location.search).get('rulesType'),
|
||||
detailData: {},
|
||||
commission_goods: {
|
||||
status: 1,
|
||||
self_rules: new URLSearchParams(location.search).get('rulesType') == 'batch' ? 2 : 0,
|
||||
commission_order_status: 1,
|
||||
commission_config: {},
|
||||
commission_rules: {},
|
||||
},
|
||||
defaultCommissionConfig: {
|
||||
status: 0,
|
||||
level: 2,
|
||||
self_buy: 0,
|
||||
reward_type: 'goods_price',
|
||||
reward_event: 'paid',
|
||||
},
|
||||
commission_config_temp: {},
|
||||
commission_rules: {},
|
||||
levelData: [],
|
||||
})
|
||||
|
||||
function getDetail() {
|
||||
Fast.api.ajax({
|
||||
url: `shopro/commission/goods/detail/id/${state.id}`,
|
||||
type: 'GET',
|
||||
}, function (ret, res) {
|
||||
state.data = res.data;
|
||||
|
||||
if (state.rulesType != 'batch') {
|
||||
state.detailData = state.data.goods[0];
|
||||
}
|
||||
|
||||
Object.keys(state.defaultCommissionConfig).forEach((key) => {
|
||||
if (key != 'status') state.defaultCommissionConfig[key] = state.data.config[key];
|
||||
});
|
||||
|
||||
state.commission_config_temp = JSON.parse(JSON.stringify(state.defaultCommissionConfig));
|
||||
|
||||
if (isEmpty(state.detailData.commission_goods)) {
|
||||
initCommission(state.commission_goods.self_rules);
|
||||
} else {
|
||||
state.commission_goods = state.detailData.commission_goods;
|
||||
|
||||
if (
|
||||
state.detailData.commission_goods.commission_config &&
|
||||
state.detailData.commission_goods.commission_config.status
|
||||
) {
|
||||
state.commission_config_temp = state.detailData.commission_goods.commission_config;
|
||||
}
|
||||
|
||||
initCommission(state.detailData.commission_goods.self_rules);
|
||||
}
|
||||
return false
|
||||
}, function (ret, res) { })
|
||||
}
|
||||
|
||||
function getLevelSelect() {
|
||||
Fast.api.ajax({
|
||||
url: `shopro/commission/level/select`,
|
||||
type: 'GET',
|
||||
data: {
|
||||
sort: 'level',
|
||||
order: 'asc',
|
||||
}
|
||||
}, function (ret, res) {
|
||||
state.levelData = res.data;
|
||||
state.type == 'edit' && getDetail()
|
||||
return false
|
||||
}, function (ret, res) { })
|
||||
}
|
||||
|
||||
function initCommission(type) {
|
||||
let rate_money = {
|
||||
1: {
|
||||
rate: '',
|
||||
money: '',
|
||||
},
|
||||
2: {
|
||||
rate: '',
|
||||
money: '',
|
||||
},
|
||||
3: {
|
||||
rate: '',
|
||||
money: '',
|
||||
},
|
||||
};
|
||||
if (!isObject(state.commission_goods.commission_rules)) {
|
||||
state.commission_goods.commission_rules = {};
|
||||
}
|
||||
if (type == 0) {
|
||||
state.commission_goods.commission_rules = null;
|
||||
} else if (type == 1) {
|
||||
state.detailData.sku_prices.forEach((i) => {
|
||||
if (state.commission_goods.commission_rules[i.id]) {
|
||||
state.levelData.forEach((j) => {
|
||||
if (state.commission_goods.commission_rules[i.id][j.level]) {
|
||||
for (let key in state.commission_goods.commission_rules[i.id][j.level]) {
|
||||
if (!state.commission_goods.commission_rules[i.id][j.level][key].rate) {
|
||||
state.commission_goods.commission_rules[i.id][j.level][key].rate = '';
|
||||
} else if (!state.commission_goods.commission_rules[i.id][j.level][key].money) {
|
||||
state.commission_goods.commission_rules[i.id][j.level][key].money = '';
|
||||
}
|
||||
}
|
||||
} else {
|
||||
state.commission_goods.commission_rules[i.id][j.level] = JSON.parse(JSON.stringify(rate_money));
|
||||
}
|
||||
});
|
||||
|
||||
for (var level in state.commission_goods.commission_rules[i.id]) {
|
||||
let index = state.levelData.findIndex((l) => Number(l.level) == Number(level));
|
||||
if (index == -1) {
|
||||
delete state.commission_goods.commission_rules[i.id][level];
|
||||
}
|
||||
}
|
||||
} else {
|
||||
state.commission_goods.commission_rules[i.id] = {};
|
||||
state.levelData.forEach((l) => {
|
||||
state.commission_goods.commission_rules[i.id][l.level] = JSON.parse(JSON.stringify(rate_money));
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
for (var sku in state.commission_goods.commission_rules) {
|
||||
let index = state.detailData.sku_prices.findIndex((s) => Number(s.id) == Number(sku));
|
||||
if (index == -1) {
|
||||
delete state.commission_goods.commission_rules[sku];
|
||||
}
|
||||
}
|
||||
} else if (type == 2) {
|
||||
state.levelData.forEach((l) => {
|
||||
if (state.commission_goods.commission_rules[l.level]) {
|
||||
} else {
|
||||
state.commission_goods.commission_rules[l.level] = JSON.parse(JSON.stringify(rate_money));
|
||||
}
|
||||
});
|
||||
|
||||
for (var level in state.commission_goods.commission_rules) {
|
||||
let index = state.levelData.findIndex((l) => Number(l.level) == Number(level));
|
||||
if (index == -1) {
|
||||
delete state.commission_goods.commission_rules[level];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function onChangeSelfRules(self_rules) {
|
||||
if (self_rules == 1 || self_rules == 2) {
|
||||
state.commission_goods.commission_rules = {};
|
||||
if (state.commission_config_temp.status == 0) {
|
||||
state.commission_config_temp = JSON.parse(JSON.stringify(state.defaultCommissionConfig));
|
||||
}
|
||||
} else if (self_rules == 0) {
|
||||
state.commission_goods.commission_rules = null;
|
||||
state.commission_config_temp = JSON.parse(JSON.stringify(state.defaultCommissionConfig));
|
||||
}
|
||||
initCommission(self_rules);
|
||||
}
|
||||
|
||||
function onChangeCommissionConfigStatus(val) {
|
||||
if (val == 0) {
|
||||
// 默认
|
||||
state.commission_config_temp = JSON.parse(JSON.stringify(state.defaultCommissionConfig));
|
||||
} else {
|
||||
// 自定义
|
||||
if (
|
||||
state.detailData.commission_goods &&
|
||||
state.detailData.commission_goods.commission_config
|
||||
) {
|
||||
state.commission_config_temp = state.detailData.commission_goods.commission_config;
|
||||
}
|
||||
|
||||
state.commission_config_temp.status = 1;
|
||||
}
|
||||
}
|
||||
|
||||
const commissionPopover = reactive({
|
||||
flag: {},
|
||||
form: {
|
||||
money: '',
|
||||
rate: '',
|
||||
},
|
||||
});
|
||||
function onConfirmCommissionPopover(cl) {
|
||||
if (state.commission_goods.self_rules == 1) {
|
||||
for (let sku in state.commission_goods.commission_rules) {
|
||||
for (let level in state.commission_goods.commission_rules[sku]) {
|
||||
state.commission_goods.commission_rules[sku][level][cl] = JSON.parse(JSON.stringify(commissionPopover.form))
|
||||
}
|
||||
}
|
||||
} else if (state.commission_goods.self_rules == 2) {
|
||||
for (let level in state.commission_goods.commission_rules) {
|
||||
state.commission_goods.commission_rules[level][cl] = JSON.parse(JSON.stringify(commissionPopover.form))
|
||||
}
|
||||
}
|
||||
onCancelCommissionPopover(cl);
|
||||
}
|
||||
function onCancelCommissionPopover(cl) {
|
||||
commissionPopover.flag[cl] = false;
|
||||
commissionPopover.form = {
|
||||
money: '',
|
||||
rate: '',
|
||||
};
|
||||
}
|
||||
|
||||
function onConfirm() {
|
||||
const commission_goods = {
|
||||
...state.commission_goods,
|
||||
};
|
||||
commission_goods.commission_config = JSON.stringify({
|
||||
...state.commission_config_temp,
|
||||
});
|
||||
|
||||
let flag = true
|
||||
if (commission_goods.self_rules == 1) {
|
||||
for (var key1 in commission_goods.commission_rules) {
|
||||
for (var key2 in commission_goods.commission_rules[key1]) {
|
||||
for (var key3 in commission_goods.commission_rules[key1][key2]) {
|
||||
if (key3 <= state.commission_config_temp.level) {
|
||||
if ((commission_goods.commission_rules[key1][key2][key3].rate === '' || commission_goods.commission_rules[key1][key2][key3].rate < 0)
|
||||
&& (commission_goods.commission_rules[key1][key2][key3].money === '' || commission_goods.commission_rules[key1][key2][key3].money < 0)) {
|
||||
flag = false
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (commission_goods.self_rules == 2) {
|
||||
for (var key1 in commission_goods.commission_rules) {
|
||||
for (var key2 in commission_goods.commission_rules[key1]) {
|
||||
if (key2 <= state.commission_config_temp.level) {
|
||||
if (commission_goods.commission_rules[key1][key2].rate === '' || commission_goods.commission_rules[key1][key2].rate < 0) {
|
||||
flag = false
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!flag) {
|
||||
ElMessage({
|
||||
message: '请将数据填写完整',
|
||||
type: 'warning',
|
||||
})
|
||||
return false
|
||||
}
|
||||
|
||||
Fast.api.ajax({
|
||||
url: `shopro/commission/goods/edit/id/${state.id}`,
|
||||
type: 'POST',
|
||||
data: JSON.parse(JSON.stringify(commission_goods))
|
||||
}, function (ret, res) {
|
||||
Fast.api.close()
|
||||
}, function (ret, res) { })
|
||||
}
|
||||
|
||||
onMounted(() => {
|
||||
getLevelSelect()
|
||||
})
|
||||
|
||||
return {
|
||||
state,
|
||||
onChangeSelfRules,
|
||||
onChangeCommissionConfigStatus,
|
||||
commissionPopover,
|
||||
onConfirmCommissionPopover,
|
||||
onCancelCommissionPopover,
|
||||
onConfirm,
|
||||
}
|
||||
}
|
||||
}
|
||||
createApp('addEdit', addEdit);
|
||||
}
|
||||
};
|
||||
return Controller;
|
||||
});
|
||||
401
public/assets/js/backend/shopro/commission/level.js
Normal file
401
public/assets/js/backend/shopro/commission/level.js
Normal file
@@ -0,0 +1,401 @@
|
||||
define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {
|
||||
|
||||
var Controller = {
|
||||
index: () => {
|
||||
const { reactive, onMounted } = Vue
|
||||
const index = {
|
||||
setup() {
|
||||
const state = reactive({
|
||||
data: [],
|
||||
})
|
||||
|
||||
function getData() {
|
||||
Fast.api.ajax({
|
||||
url: 'shopro/commission/level',
|
||||
type: 'GET',
|
||||
}, function (ret, res) {
|
||||
state.data = res.data
|
||||
return false
|
||||
}, function (ret, res) { })
|
||||
}
|
||||
|
||||
function onAdd() {
|
||||
Fast.api.open(`shopro/commission/level/add?type=add`, "添加", {
|
||||
callback() {
|
||||
getData()
|
||||
}
|
||||
})
|
||||
}
|
||||
function onEdit(id) {
|
||||
Fast.api.open(`shopro/commission/level/edit?type=edit&id=${id}`, "编辑", {
|
||||
callback() {
|
||||
getData()
|
||||
}
|
||||
})
|
||||
}
|
||||
function onDelete(id) {
|
||||
Fast.api.ajax({
|
||||
url: `shopro/commission/level/delete/id/${id}`,
|
||||
type: 'POST',
|
||||
}, function (ret, res) {
|
||||
getData();
|
||||
}, function (ret, res) { })
|
||||
}
|
||||
|
||||
onMounted(() => {
|
||||
getData()
|
||||
})
|
||||
|
||||
return {
|
||||
state,
|
||||
getData,
|
||||
onAdd,
|
||||
onEdit,
|
||||
onDelete,
|
||||
}
|
||||
}
|
||||
}
|
||||
createApp('index', index);
|
||||
},
|
||||
add: () => {
|
||||
Controller.form();
|
||||
},
|
||||
edit: () => {
|
||||
Controller.form();
|
||||
},
|
||||
form: () => {
|
||||
const { reactive, onMounted, getCurrentInstance } = Vue
|
||||
const addEdit = {
|
||||
setup() {
|
||||
const { proxy } = getCurrentInstance();
|
||||
|
||||
const state = reactive({
|
||||
type: new URLSearchParams(location.search).get('type'),
|
||||
id: new URLSearchParams(location.search).get('id')
|
||||
})
|
||||
|
||||
const form = reactive({
|
||||
model: {
|
||||
level: null,
|
||||
name: '',
|
||||
image: '',
|
||||
commission_rules: {
|
||||
commission_1: '0.00',
|
||||
commission_2: '0.00',
|
||||
commission_3: '0.00',
|
||||
},
|
||||
upgrade_type: 0,
|
||||
upgrade_rules: {},
|
||||
},
|
||||
rules: {
|
||||
level: [{ required: true, message: '请选择等级权重', trigger: 'blur' }],
|
||||
name: [{ required: true, message: '请输入等级名称', trigger: 'blur' }],
|
||||
commission_rules: {
|
||||
commission: [{ required: true, message: '佣金比例', trigger: 'blur' }],
|
||||
},
|
||||
upgrade_rules: [
|
||||
{
|
||||
validator: (rule, value, callback) => {
|
||||
if (isEmpty(value)) {
|
||||
callback(new Error('请填写升级条件'));
|
||||
} else {
|
||||
callback();
|
||||
}
|
||||
},
|
||||
trigger: 'blur',
|
||||
},
|
||||
],
|
||||
upgrade_rules_inner: {
|
||||
rules: [{ required: true, message: '请输入', trigger: 'blur' }],
|
||||
level: [{ required: true, message: '请选择分销商等级', trigger: 'blur' }],
|
||||
},
|
||||
},
|
||||
})
|
||||
|
||||
function getDetail() {
|
||||
Fast.api.ajax({
|
||||
url: `shopro/commission/level/detail/id/${state.id}`,
|
||||
type: 'GET',
|
||||
}, function (ret, res) {
|
||||
form.model = res.data;
|
||||
|
||||
if (!isObject(form.model.upgrade_rules)) form.model.upgrade_rules = {};
|
||||
|
||||
// level=1时 等级权重不可修改
|
||||
if (form.model.level == 1) {
|
||||
level.data = [
|
||||
{
|
||||
name: '一级',
|
||||
level: 1,
|
||||
},
|
||||
];
|
||||
|
||||
level.existLevel = [];
|
||||
level.data.forEach((e) => {
|
||||
level.existLevel.push(e.level);
|
||||
});
|
||||
} else {
|
||||
level.data = JSON.parse(JSON.stringify(defaultLevel));
|
||||
}
|
||||
|
||||
let index = level.existLevel.findIndex((l) => l == form.model.level);
|
||||
level.existLevel.splice(index, 1);
|
||||
return false
|
||||
}, function (ret, res) { })
|
||||
}
|
||||
|
||||
const defaultLevel = [
|
||||
{
|
||||
name: '一级',
|
||||
level: 1,
|
||||
},
|
||||
{
|
||||
name: '二级',
|
||||
level: 2,
|
||||
},
|
||||
{
|
||||
name: '三级',
|
||||
level: 3,
|
||||
},
|
||||
{
|
||||
name: '四级',
|
||||
level: 4,
|
||||
},
|
||||
{
|
||||
name: '五级',
|
||||
level: 5,
|
||||
},
|
||||
{
|
||||
name: '六级',
|
||||
level: 6,
|
||||
},
|
||||
{
|
||||
name: '七级',
|
||||
level: 7,
|
||||
},
|
||||
{
|
||||
name: '八级',
|
||||
level: 8,
|
||||
},
|
||||
{
|
||||
name: '九级',
|
||||
level: 9,
|
||||
},
|
||||
{
|
||||
name: '十级',
|
||||
level: 10,
|
||||
},
|
||||
];
|
||||
function onSelectLevel(l) {
|
||||
if (!level.existLevel.includes(l)) {
|
||||
form.model.level = l;
|
||||
// 清空规则
|
||||
form.model.upgrade_rules = {};
|
||||
}
|
||||
}
|
||||
|
||||
const level = reactive({
|
||||
data: [],
|
||||
select: [],
|
||||
existLevel: [],
|
||||
});
|
||||
function getLevelSelect() {
|
||||
Fast.api.ajax({
|
||||
url: `shopro/commission/level/select`,
|
||||
type: 'GET',
|
||||
}, function (ret, res) {
|
||||
level.select = res.data;
|
||||
level.select.forEach((e) => {
|
||||
level.existLevel.push(e.level);
|
||||
});
|
||||
return false
|
||||
}, function (ret, res) { })
|
||||
}
|
||||
|
||||
const upgradeCondition = {
|
||||
user: {
|
||||
total_consume: {
|
||||
name: '用户消费金额',
|
||||
},
|
||||
child_user_count_1: {
|
||||
name: '一级用户人数',
|
||||
},
|
||||
child_user_count_2: {
|
||||
name: '二级用户人数',
|
||||
},
|
||||
child_user_count_all: {
|
||||
name: '团队用户人数',
|
||||
},
|
||||
},
|
||||
order_money: {
|
||||
child_order_money_0: {
|
||||
name: '自购分销订单总金额',
|
||||
},
|
||||
child_order_money_1: {
|
||||
name: '一级分销订单金额',
|
||||
},
|
||||
child_order_money_2: {
|
||||
name: '二级分销订单金额',
|
||||
},
|
||||
child_order_money_all: {
|
||||
name: '团队分销订单金额',
|
||||
},
|
||||
},
|
||||
order_count: {
|
||||
child_order_count_0: {
|
||||
name: '自购分销订单数量',
|
||||
},
|
||||
child_order_count_1: {
|
||||
name: '一级分销订单数量',
|
||||
},
|
||||
child_order_count_2: {
|
||||
name: '二级分销订单数量',
|
||||
},
|
||||
child_order_count_all: {
|
||||
name: '团队分销订单数量',
|
||||
},
|
||||
},
|
||||
agent_count: {
|
||||
child_agent_count_1: {
|
||||
name: '一级分销商人数',
|
||||
},
|
||||
child_agent_count_2: {
|
||||
name: '二级分销商人数',
|
||||
},
|
||||
child_agent_count_all: {
|
||||
name: '团队分销商人数',
|
||||
},
|
||||
},
|
||||
agent_level: {
|
||||
child_agent_level_all: {
|
||||
name: '团队分销商等级统计',
|
||||
},
|
||||
child_agent_level_1: {
|
||||
name: '一级分销商等级统计',
|
||||
},
|
||||
},
|
||||
};
|
||||
function onSelectUpgradeCondition(key) {
|
||||
form.model.upgrade_rules[key] = '';
|
||||
if (key == 'child_agent_level_all' || key == 'child_agent_level_1') {
|
||||
form.model.upgrade_rules[key] = [
|
||||
{
|
||||
level: '',
|
||||
count: '',
|
||||
},
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
function onAddUpgradeRules(key) {
|
||||
form.model.upgrade_rules[key].push({
|
||||
level: '',
|
||||
count: '',
|
||||
});
|
||||
}
|
||||
function onDeleteRules(key, index) {
|
||||
if (key == 'child_agent_level_all' || key == 'child_agent_level_1') {
|
||||
form.model.upgrade_rules[key].splice(index, 1);
|
||||
if (form.model.upgrade_rules[key].length == 0) delete form.model.upgrade_rules[key];
|
||||
} else {
|
||||
delete form.model.upgrade_rules[key];
|
||||
}
|
||||
}
|
||||
|
||||
function initUnit(key) {
|
||||
if (key.includes('child_user_count') || key.includes('child_agent_count')) {
|
||||
return '人';
|
||||
}
|
||||
if (key.includes('total_consume') || key.includes('child_order_money')) {
|
||||
return '元';
|
||||
}
|
||||
if (key.includes('child_order_count')) {
|
||||
return '单';
|
||||
}
|
||||
}
|
||||
|
||||
function onConfirm() {
|
||||
proxy.$refs['formRef'].validate((valid) => {
|
||||
if (valid) {
|
||||
Fast.api.ajax({
|
||||
url: state.type == 'add' ? 'shopro/commission/level/add' : `shopro/commission/level/edit/id/${state.id}`,
|
||||
type: 'POST',
|
||||
data: JSON.parse(JSON.stringify(form.model))
|
||||
}, function (ret, res) {
|
||||
Fast.api.close()
|
||||
}, function (ret, res) { })
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
onMounted(() => {
|
||||
getLevelSelect()
|
||||
if (state.type == 'add') {
|
||||
level.data = JSON.parse(JSON.stringify(defaultLevel));
|
||||
} else if (state.type == 'edit') {
|
||||
getDetail()
|
||||
}
|
||||
})
|
||||
|
||||
return {
|
||||
state,
|
||||
form,
|
||||
onSelectLevel,
|
||||
defaultLevel,
|
||||
level,
|
||||
getLevelSelect,
|
||||
upgradeCondition,
|
||||
onSelectUpgradeCondition,
|
||||
onAddUpgradeRules,
|
||||
onDeleteRules,
|
||||
initUnit,
|
||||
onConfirm
|
||||
}
|
||||
}
|
||||
}
|
||||
createApp('addEdit', addEdit);
|
||||
},
|
||||
select: () => {
|
||||
const { reactive, onMounted } = Vue
|
||||
const select = {
|
||||
setup() {
|
||||
const state = reactive({
|
||||
level: new URLSearchParams(location.search).get('level'),
|
||||
data: [],
|
||||
})
|
||||
|
||||
function getData() {
|
||||
Fast.api.ajax({
|
||||
url: 'shopro/commission/level/select',
|
||||
type: 'GET',
|
||||
}, function (ret, res) {
|
||||
state.data = res.data
|
||||
return false
|
||||
}, function (ret, res) { })
|
||||
}
|
||||
|
||||
function onSelect(level) {
|
||||
state.level = level;
|
||||
}
|
||||
|
||||
function onConfirm() {
|
||||
Fast.api.close(state.level)
|
||||
}
|
||||
|
||||
onMounted(() => {
|
||||
getData()
|
||||
})
|
||||
|
||||
return {
|
||||
state,
|
||||
getData,
|
||||
onSelect,
|
||||
onConfirm,
|
||||
}
|
||||
}
|
||||
}
|
||||
createApp('select', select);
|
||||
},
|
||||
};
|
||||
return Controller;
|
||||
});
|
||||
109
public/assets/js/backend/shopro/commission/log.js
Normal file
109
public/assets/js/backend/shopro/commission/log.js
Normal file
@@ -0,0 +1,109 @@
|
||||
define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {
|
||||
|
||||
var Controller = {
|
||||
index: () => {
|
||||
const { reactive, onMounted } = Vue
|
||||
const index = {
|
||||
setup() {
|
||||
const state = reactive({
|
||||
data: [],
|
||||
filter: {
|
||||
drawer: false,
|
||||
data: {
|
||||
event: '',
|
||||
},
|
||||
tools: {
|
||||
event: {
|
||||
type: 'tselect',
|
||||
label: '动态类型',
|
||||
value: '',
|
||||
options: {
|
||||
data: [{
|
||||
label: '分销商',
|
||||
value: 'agent',
|
||||
},
|
||||
{
|
||||
label: '佣金',
|
||||
value: 'reward',
|
||||
},
|
||||
{
|
||||
label: '推荐',
|
||||
value: 'share',
|
||||
},
|
||||
{
|
||||
label: '绑定',
|
||||
value: 'bind',
|
||||
}],
|
||||
},
|
||||
},
|
||||
},
|
||||
condition: {},
|
||||
},
|
||||
})
|
||||
|
||||
function getData() {
|
||||
let tempSearch = JSON.parse(JSON.stringify(state.filter.data));
|
||||
let search = composeFilter(tempSearch);
|
||||
Fast.api.ajax({
|
||||
url: 'shopro/commission/log',
|
||||
type: 'GET',
|
||||
data: {
|
||||
page: pagination.page,
|
||||
list_rows: pagination.list_rows,
|
||||
...search,
|
||||
},
|
||||
}, function (ret, res) {
|
||||
state.data = res.data.data
|
||||
pagination.total = res.data.total
|
||||
return false
|
||||
}, function (ret, res) { })
|
||||
}
|
||||
|
||||
function onOpenFilter() {
|
||||
state.filter.drawer = true
|
||||
}
|
||||
function onChangeFilter() {
|
||||
pagination.page = 1
|
||||
getData()
|
||||
state.filter.drawer && (state.filter.drawer = false)
|
||||
}
|
||||
|
||||
const pagination = reactive({
|
||||
page: 1,
|
||||
list_rows: 10,
|
||||
total: 0,
|
||||
})
|
||||
|
||||
const really = reactive({
|
||||
reallyStatus: 0,
|
||||
reallyTimer: '',
|
||||
})
|
||||
function onChangeReallyStatus(val) {
|
||||
clearInterval(really.reallyTimer);
|
||||
if (val == 1) {
|
||||
really.reallyTimer = setInterval(() => {
|
||||
getData();
|
||||
}, 3000);
|
||||
}
|
||||
}
|
||||
|
||||
onMounted(() => {
|
||||
getData()
|
||||
})
|
||||
|
||||
return {
|
||||
state,
|
||||
getData,
|
||||
onOpenFilter,
|
||||
onChangeFilter,
|
||||
pagination,
|
||||
really,
|
||||
onChangeReallyStatus
|
||||
}
|
||||
}
|
||||
}
|
||||
createApp('index', index);
|
||||
},
|
||||
};
|
||||
return Controller;
|
||||
});
|
||||
405
public/assets/js/backend/shopro/commission/order.js
Normal file
405
public/assets/js/backend/shopro/commission/order.js
Normal file
@@ -0,0 +1,405 @@
|
||||
define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {
|
||||
|
||||
var Controller = {
|
||||
index: () => {
|
||||
const { reactive, onMounted, ref } = Vue
|
||||
const index = {
|
||||
setup() {
|
||||
const state = reactive({
|
||||
data: [],
|
||||
filter: {
|
||||
drawer: false,
|
||||
data: {
|
||||
buyer: { field: 'buyer_id', value: '' },
|
||||
agent: { field: 'agent_id', value: '' },
|
||||
reward: { field: 'reward.agent_id', value: '' },
|
||||
'order.order_sn': '',
|
||||
'order_item.goods_title': '',
|
||||
'order.createtime': [],
|
||||
commission_time: [],
|
||||
commission_order_status: '',
|
||||
commission_reward_status: '',
|
||||
},
|
||||
tools: {
|
||||
buyer: {
|
||||
type: 'tinputprepend',
|
||||
label: '下单用户',
|
||||
placeholder: '请输入查询内容',
|
||||
value: {
|
||||
field: 'buyer_id',
|
||||
value: '',
|
||||
},
|
||||
options: {
|
||||
data: [{
|
||||
label: '用户ID',
|
||||
value: 'buyer_id',
|
||||
},
|
||||
{
|
||||
label: '用户昵称',
|
||||
value: 'buyer.nickname',
|
||||
},
|
||||
{
|
||||
label: '用户手机号',
|
||||
value: 'buyer.mobile',
|
||||
}],
|
||||
}
|
||||
},
|
||||
agent: {
|
||||
type: 'tinputprepend',
|
||||
label: '推广分销商',
|
||||
placeholder: '请输入查询内容',
|
||||
value: {
|
||||
field: 'agent_id',
|
||||
value: '',
|
||||
},
|
||||
options: {
|
||||
data: [{
|
||||
label: '推广ID',
|
||||
value: 'agent_id',
|
||||
},
|
||||
{
|
||||
label: '推广昵称',
|
||||
value: 'agent.nickname',
|
||||
},
|
||||
{
|
||||
label: '推广手机号',
|
||||
value: 'agent.mobile',
|
||||
}],
|
||||
}
|
||||
},
|
||||
reward: {
|
||||
type: 'tinputprepend',
|
||||
label: '结算分销商',
|
||||
placeholder: '请输入查询内容',
|
||||
value: {
|
||||
field: 'reward.agent_id',
|
||||
value: '',
|
||||
},
|
||||
options: {
|
||||
data: [{
|
||||
label: '结算ID',
|
||||
value: 'reward.agent_id',
|
||||
},
|
||||
{
|
||||
label: '结算昵称',
|
||||
value: 'reward.agent_nickname',
|
||||
},
|
||||
{
|
||||
label: '结算手机号',
|
||||
value: 'reward.agent_mobile',
|
||||
}],
|
||||
}
|
||||
},
|
||||
'order.order_sn': {
|
||||
type: 'tinput',
|
||||
label: '订单号',
|
||||
placeholder: '请输入查询内容',
|
||||
value: '',
|
||||
},
|
||||
'order_item.goods_title': {
|
||||
type: 'tinput',
|
||||
label: '商品名称',
|
||||
placeholder: '请输入查询内容',
|
||||
value: '',
|
||||
},
|
||||
'order.createtime': {
|
||||
type: 'tdatetimerange',
|
||||
label: '下单时间',
|
||||
value: [],
|
||||
},
|
||||
commission_time: {
|
||||
type: 'tdatetimerange',
|
||||
label: '分佣时间',
|
||||
value: [],
|
||||
},
|
||||
commission_order_status: {
|
||||
type: 'tselect',
|
||||
label: '订单结算状态',
|
||||
value: '',
|
||||
options: {
|
||||
data: [{
|
||||
label: '已扣除',
|
||||
value: '-2',
|
||||
},
|
||||
{
|
||||
label: '已取消',
|
||||
value: '-1',
|
||||
},
|
||||
{
|
||||
label: '不计入',
|
||||
value: '0',
|
||||
},
|
||||
{
|
||||
label: '已计入',
|
||||
value: '1',
|
||||
}],
|
||||
},
|
||||
},
|
||||
commission_reward_status: {
|
||||
type: 'tselect',
|
||||
label: '佣金结算状态',
|
||||
value: '',
|
||||
options: {
|
||||
data: [{
|
||||
label: '已退回',
|
||||
value: '-2',
|
||||
},
|
||||
{
|
||||
label: '已取消',
|
||||
value: '-1',
|
||||
},
|
||||
{
|
||||
label: '未结算',
|
||||
value: '0',
|
||||
},
|
||||
{
|
||||
label: '已结算',
|
||||
value: '1',
|
||||
}],
|
||||
},
|
||||
},
|
||||
},
|
||||
condition: {},
|
||||
},
|
||||
count: {},
|
||||
statusStyle: {
|
||||
'-2': 'danger',
|
||||
'-1': 'warning',
|
||||
0: 'info',
|
||||
1: 'success',
|
||||
}
|
||||
})
|
||||
|
||||
function getData() {
|
||||
let tempSearch = JSON.parse(JSON.stringify(state.filter.data));
|
||||
let search = composeFilter(tempSearch, {
|
||||
'buyer.nickname': 'like',
|
||||
'buyer.mobile': 'like',
|
||||
'agent.nickname': 'like',
|
||||
'agent.mobile': 'like',
|
||||
'reward.agent_nickname': 'like',
|
||||
'reward.agent_mobile': 'like',
|
||||
'order.order_sn': 'like',
|
||||
'order_item.goods_title': 'like',
|
||||
'order.createtime': 'range',
|
||||
commission_time: 'range',
|
||||
});
|
||||
Fast.api.ajax({
|
||||
url: 'shopro/commission/order',
|
||||
type: 'GET',
|
||||
data: {
|
||||
page: pagination.page,
|
||||
list_rows: pagination.list_rows,
|
||||
...search,
|
||||
},
|
||||
}, function (ret, res) {
|
||||
state.count = res.data.count;
|
||||
state.data = res.data.list.data
|
||||
pagination.total = res.data.list.total
|
||||
return false
|
||||
}, function (ret, res) { })
|
||||
}
|
||||
|
||||
function onOpenFilter() {
|
||||
state.filter.drawer = true
|
||||
}
|
||||
function onChangeFilter() {
|
||||
pagination.page = 1
|
||||
getData()
|
||||
state.filter.drawer && (state.filter.drawer = false)
|
||||
}
|
||||
|
||||
const pagination = reactive({
|
||||
page: 1,
|
||||
list_rows: 10,
|
||||
total: 0,
|
||||
})
|
||||
|
||||
const arraySpanMethod = ({ row, column, rowIndex, columnIndex }) => {
|
||||
if (columnIndex == 1) {
|
||||
return [1, 6];
|
||||
} else if (
|
||||
columnIndex == 3 ||
|
||||
columnIndex == 4 ||
|
||||
columnIndex == 5 ||
|
||||
columnIndex == 6 ||
|
||||
columnIndex == 7
|
||||
) {
|
||||
return [0, 0];
|
||||
}
|
||||
};
|
||||
|
||||
function countRewards(row) {
|
||||
let commission = 0;
|
||||
let commissioned = 0;
|
||||
row.forEach((r) => {
|
||||
if (r.status == 1) {
|
||||
commissioned += Number(r.commission);
|
||||
}
|
||||
commission += Number(r.commission);
|
||||
});
|
||||
|
||||
return `${commission.toFixed(2)}元/${commissioned.toFixed(2)}元`;
|
||||
}
|
||||
|
||||
const rewardsPopover = reactive({
|
||||
flag: {},
|
||||
commission: '',
|
||||
});
|
||||
function onConfirmRewardsPopover(index, id) {
|
||||
Fast.api.ajax({
|
||||
url: 'shopro/commission/order/edit',
|
||||
type: 'POST',
|
||||
data: {
|
||||
commission_reward_id: id,
|
||||
commission: rewardsPopover.commission,
|
||||
},
|
||||
}, function (ret, res) {
|
||||
onCancelRewardsPopover(index)
|
||||
getData()
|
||||
}, function (ret, res) { })
|
||||
}
|
||||
function onCancelRewardsPopover(index) {
|
||||
rewardsPopover.flag[index] = false;
|
||||
rewardsPopover.commission = '';
|
||||
}
|
||||
|
||||
const commissionPopover = reactive({
|
||||
flag: {},
|
||||
type: null,
|
||||
isDelete: '1',
|
||||
});
|
||||
function onConfirmCommissionPopover(index, id) {
|
||||
let params = { commission_order_id: id };
|
||||
if (commissionPopover.type == 'confirm') {
|
||||
onConfirm(params);
|
||||
}
|
||||
if (commissionPopover.type == 'cancel') {
|
||||
params = { ...params, deduct_order_money: commissionPopover.isDelete };
|
||||
onCancel(params);
|
||||
}
|
||||
if (commissionPopover.type == 'back') {
|
||||
params = { ...params, deduct_order_money: commissionPopover.isDelete };
|
||||
onBack(params);
|
||||
}
|
||||
onCancelCommissionPopover(index);
|
||||
}
|
||||
function onCancelCommissionPopover(index) {
|
||||
commissionPopover.flag[index] = false;
|
||||
commissionPopover.isDelete = '1';
|
||||
}
|
||||
|
||||
function onConfirm(data) {
|
||||
Fast.api.ajax({
|
||||
url: 'shopro/commission/order/confirm',
|
||||
type: 'POST',
|
||||
data: data,
|
||||
}, function (ret, res) {
|
||||
getData();
|
||||
}, function (ret, res) { })
|
||||
}
|
||||
|
||||
function onCancel(data) {
|
||||
Fast.api.ajax({
|
||||
url: 'shopro/commission/order/cancel',
|
||||
type: 'POST',
|
||||
data: data,
|
||||
}, function (ret, res) {
|
||||
getData();
|
||||
}, function (ret, res) { })
|
||||
}
|
||||
|
||||
function onBack(data) {
|
||||
Fast.api.ajax({
|
||||
url: 'shopro/commission/order/back',
|
||||
type: 'POST',
|
||||
data: data,
|
||||
}, function (ret, res) {
|
||||
getData();
|
||||
}, function (ret, res) { })
|
||||
}
|
||||
|
||||
function onOpenGoodsDetail(id) {
|
||||
Fast.api.open(`shopro/goods/goods/add?type=edit&id=${id}`, "商品详情", {
|
||||
callback() {
|
||||
getData()
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
function onOpenOrderDetail(id) {
|
||||
Fast.api.open(`shopro/order/order/detail?id=${id}`, "订单详情", {
|
||||
callback() {
|
||||
getData()
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
const exportLoading = ref(false);
|
||||
function onExport(type) {
|
||||
exportLoading.value = true;
|
||||
let tempSearch = JSON.parse(JSON.stringify(state.filter.data));
|
||||
let search = composeFilter(tempSearch, {
|
||||
'buyer.nickname': 'like',
|
||||
'buyer.mobile': 'like',
|
||||
'agent.nickname': 'like',
|
||||
'agent.mobile': 'like',
|
||||
'reward.agent_nickname': 'like',
|
||||
'reward.agent_mobile': 'like',
|
||||
'order.order_sn': 'like',
|
||||
'order_item.goods_title': 'like',
|
||||
'order.createtime': 'range',
|
||||
commission_time: 'range',
|
||||
});
|
||||
if (Config.save_type == 'download') {
|
||||
window.location.href = `${Config.moduleurl}/shopro/commission/order/${type}?page=${pagination.page}&list_rows=${pagination.list_rows}&search=${search.search}`;
|
||||
exportLoading.value = false;
|
||||
} else if (Config.save_type == 'save') {
|
||||
Fast.api.ajax({
|
||||
url: `shopro/commission/order/${type}`,
|
||||
type: 'GET',
|
||||
data: {
|
||||
page: pagination.page,
|
||||
list_rows: pagination.list_rows,
|
||||
...search,
|
||||
},
|
||||
}, function (ret, res) {
|
||||
exportLoading.value = false;
|
||||
}, function (ret, res) { })
|
||||
}
|
||||
}
|
||||
|
||||
onMounted(() => {
|
||||
getData()
|
||||
})
|
||||
|
||||
return {
|
||||
onClipboard,
|
||||
state,
|
||||
getData,
|
||||
onOpenFilter,
|
||||
onChangeFilter,
|
||||
pagination,
|
||||
arraySpanMethod,
|
||||
countRewards,
|
||||
rewardsPopover,
|
||||
onConfirmRewardsPopover,
|
||||
onCancelRewardsPopover,
|
||||
commissionPopover,
|
||||
onConfirmCommissionPopover,
|
||||
onCancelCommissionPopover,
|
||||
onConfirm,
|
||||
onCancel,
|
||||
onBack,
|
||||
onOpenGoodsDetail,
|
||||
onOpenOrderDetail,
|
||||
exportLoading,
|
||||
onExport,
|
||||
}
|
||||
}
|
||||
}
|
||||
createApp('index', index);
|
||||
},
|
||||
};
|
||||
return Controller;
|
||||
});
|
||||
201
public/assets/js/backend/shopro/commission/reward.js
Normal file
201
public/assets/js/backend/shopro/commission/reward.js
Normal file
@@ -0,0 +1,201 @@
|
||||
define(['jquery', 'bootstrap', 'backend', 'table', 'form'], function ($, undefined, Backend, Table, Form) {
|
||||
|
||||
var Controller = {
|
||||
index: () => {
|
||||
const { reactive, onMounted, ref } = Vue
|
||||
const index = {
|
||||
setup() {
|
||||
const state = reactive({
|
||||
data: [],
|
||||
filter: {
|
||||
drawer: false,
|
||||
data: {
|
||||
buyer: { field: 'buyer_id', value: '' },
|
||||
agent: { field: 'agent_id', value: '' },
|
||||
'order.order_sn': '',
|
||||
commission_time: [],
|
||||
status: '',
|
||||
},
|
||||
tools: {
|
||||
buyer: {
|
||||
type: 'tinputprepend',
|
||||
label: '下单用户',
|
||||
placeholder: '请输入查询内容',
|
||||
value: {
|
||||
field: 'buyer_id',
|
||||
value: '',
|
||||
},
|
||||
options: {
|
||||
data: [{
|
||||
label: '用户ID',
|
||||
value: 'buyer_id',
|
||||
},
|
||||
{
|
||||
label: '用户昵称',
|
||||
value: 'buyer.nickname',
|
||||
},
|
||||
{
|
||||
label: '用户手机号',
|
||||
value: 'buyer.mobile',
|
||||
}],
|
||||
}
|
||||
},
|
||||
agent: {
|
||||
type: 'tinputprepend',
|
||||
label: '结算分销商',
|
||||
placeholder: '请输入查询内容',
|
||||
value: {
|
||||
field: 'agent_id',
|
||||
value: '',
|
||||
},
|
||||
options: {
|
||||
data: [{
|
||||
label: '结算ID',
|
||||
value: 'agent_id',
|
||||
},
|
||||
{
|
||||
label: '结算昵称',
|
||||
value: 'agent.nickname',
|
||||
},
|
||||
{
|
||||
label: '结算手机号',
|
||||
value: 'agent.mobile',
|
||||
}],
|
||||
}
|
||||
},
|
||||
'order.order_sn': {
|
||||
type: 'tinput',
|
||||
label: '订单号',
|
||||
placeholder: '请输入查询内容',
|
||||
value: '',
|
||||
},
|
||||
commission_time: {
|
||||
type: 'tdatetimerange',
|
||||
label: '分佣时间',
|
||||
value: [],
|
||||
},
|
||||
status: {
|
||||
type: 'tselect',
|
||||
label: '入账状态',
|
||||
value: '',
|
||||
options: {
|
||||
data: [{
|
||||
label: '已退回',
|
||||
value: '-2',
|
||||
},
|
||||
{
|
||||
label: '已取消',
|
||||
value: '-1',
|
||||
},
|
||||
{
|
||||
label: '未结算',
|
||||
value: '0',
|
||||
},
|
||||
{
|
||||
label: '已结算',
|
||||
value: '1',
|
||||
}],
|
||||
},
|
||||
},
|
||||
},
|
||||
condition: {},
|
||||
},
|
||||
statusStyle: {
|
||||
'-2': 'danger',
|
||||
'-1': 'warning',
|
||||
0: 'info',
|
||||
1: 'success',
|
||||
},
|
||||
})
|
||||
|
||||
function getData() {
|
||||
let tempSearch = JSON.parse(JSON.stringify(state.filter.data));
|
||||
let search = composeFilter(tempSearch, {
|
||||
'buyer.nickname': 'like',
|
||||
'buyer.mobile': 'like',
|
||||
'agent.nickname': 'like',
|
||||
'agent.mobile': 'like',
|
||||
'order.order_sn': 'like',
|
||||
commission_time: 'range',
|
||||
});
|
||||
Fast.api.ajax({
|
||||
url: 'shopro/commission/reward',
|
||||
type: 'GET',
|
||||
data: {
|
||||
page: pagination.page,
|
||||
list_rows: pagination.list_rows,
|
||||
...search,
|
||||
},
|
||||
}, function (ret, res) {
|
||||
state.data = res.data.data
|
||||
pagination.total = res.data.total
|
||||
return false
|
||||
}, function (ret, res) { })
|
||||
}
|
||||
|
||||
function onOpenFilter() {
|
||||
state.filter.drawer = true
|
||||
}
|
||||
function onChangeFilter() {
|
||||
pagination.page = 1
|
||||
getData()
|
||||
state.filter.drawer && (state.filter.drawer = false)
|
||||
}
|
||||
|
||||
const pagination = reactive({
|
||||
page: 1,
|
||||
list_rows: 10,
|
||||
total: 0,
|
||||
})
|
||||
|
||||
const exportLoading = ref(false);
|
||||
function onExport(type) {
|
||||
exportLoading.value = true;
|
||||
let tempSearch = JSON.parse(JSON.stringify(state.filter.data));
|
||||
let search = composeFilter(tempSearch, {
|
||||
'buyer.nickname': 'like',
|
||||
'buyer.mobile': 'like',
|
||||
'agent.nickname': 'like',
|
||||
'agent.mobile': 'like',
|
||||
'order.order_sn': 'like',
|
||||
commission_time: 'range',
|
||||
});
|
||||
|
||||
if (Config.save_type == 'download') {
|
||||
window.location.href = `${Config.moduleurl}/shopro/commission/reward/${type}?page=${pagination.page}&list_rows=${pagination.list_rows}&search=${search.search}`;
|
||||
exportLoading.value = false;
|
||||
} else if (Config.save_type == 'save') {
|
||||
Fast.api.ajax({
|
||||
url: `shopro/commission/reward/${type}`,
|
||||
type: 'GET',
|
||||
data: {
|
||||
page: pagination.page,
|
||||
list_rows: pagination.list_rows,
|
||||
...search,
|
||||
},
|
||||
}, function (ret, res) {
|
||||
exportLoading.value = false;
|
||||
}, function (ret, res) { })
|
||||
}
|
||||
}
|
||||
|
||||
onMounted(() => {
|
||||
getData()
|
||||
})
|
||||
|
||||
return {
|
||||
state,
|
||||
getData,
|
||||
onOpenFilter,
|
||||
onChangeFilter,
|
||||
pagination,
|
||||
exportLoading,
|
||||
onExport,
|
||||
}
|
||||
}
|
||||
}
|
||||
createApp('index', index);
|
||||
},
|
||||
};
|
||||
return Controller;
|
||||
});
|
||||
Reference in New Issue
Block a user