fix: 解决发现的问题

This commit is contained in:
yys 2026-04-21 14:37:54 +08:00
parent 20a063d6aa
commit 9ffe5c8152
27 changed files with 558 additions and 1040 deletions

View File

@ -9,36 +9,10 @@ export function listOrder(query) {
}) })
} }
// 查询团队(部门)充值退款订单详细 // 查询团队(部门)充值退款订单详细(只读)
export function getOrder(id) { export function getOrder(id) {
return request({ return request({
url: '/ai/order/' + id, url: '/ai/order/' + id,
method: 'get' method: 'get'
}) })
} }
// 新增团队(部门)充值退款订单
export function addOrder(data) {
return request({
url: '/ai/order',
method: 'post',
data: data
})
}
// 修改团队(部门)充值退款订单
export function updateOrder(data) {
return request({
url: '/ai/order',
method: 'put',
data: data
})
}
// 删除团队(部门)充值退款订单
export function delOrder(id) {
return request({
url: '/ai/order/' + id,
method: 'delete'
})
}

View File

@ -9,36 +9,10 @@ export function listRecord(query) {
}) })
} }
// 查询团队(部门)余额变动详细 // 查询团队(部门)余额变动详细(只读)
export function getRecord(id) { export function getRecord(id) {
return request({ return request({
url: '/ai/record/' + id, url: '/ai/record/' + id,
method: 'get' method: 'get'
}) })
} }
// 新增团队(部门)余额变动
export function addRecord(data) {
return request({
url: '/ai/record',
method: 'post',
data: data
})
}
// 修改团队(部门)余额变动
export function updateRecord(data) {
return request({
url: '/ai/record',
method: 'put',
data: data
})
}
// 删除团队(部门)余额变动
export function delRecord(id) {
return request({
url: '/ai/record/' + id,
method: 'delete'
})
}

View File

@ -149,7 +149,7 @@
</el-row> </el-row>
<el-row v-if="isSecondLevelCompanyForm"> <el-row v-if="isSecondLevelCompanyForm">
<el-col :span="24"> <el-col :span="24">
<el-form-item label="Byte API Key"> <el-form-item label="ApiKey">
<el-input <el-input
v-model="form.byteApiKey" v-model="form.byteApiKey"
type="password" type="password"

View File

@ -21,38 +21,6 @@
</el-form> </el-form>
<el-row :gutter="10" class="mb8"> <el-row :gutter="10" class="mb8">
<el-col :span="1.5">
<el-button
type="primary"
plain
icon="el-icon-plus"
size="mini"
@click="handleAdd"
v-hasPermi="['ai:order:add']"
>新增</el-button>
</el-col>
<el-col :span="1.5">
<el-button
type="success"
plain
icon="el-icon-edit"
size="mini"
:disabled="single"
@click="handleUpdate"
v-hasPermi="['ai:order:edit']"
>修改</el-button>
</el-col>
<el-col :span="1.5">
<el-button
type="danger"
plain
icon="el-icon-delete"
size="mini"
:disabled="multiple"
@click="handleDelete"
v-hasPermi="['ai:order:remove']"
>删除</el-button>
</el-col>
<el-col :span="1.5"> <el-col :span="1.5">
<el-button <el-button
type="warning" type="warning"
@ -66,8 +34,7 @@
<right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar> <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
</el-row> </el-row>
<el-table v-loading="loading" :data="orderList" @selection-change="handleSelectionChange"> <el-table v-loading="loading" :data="orderList">
<el-table-column type="selection" width="55" align="center" />
<el-table-column label="ID" align="center" prop="id" width="72" /> <el-table-column label="ID" align="center" prop="id" width="72" />
<el-table-column label="团队名称" align="center" prop="deptName" min-width="120" show-overflow-tooltip /> <el-table-column label="团队名称" align="center" prop="deptName" min-width="120" show-overflow-tooltip />
<el-table-column label="类型" align="center" width="100"> <el-table-column label="类型" align="center" width="100">
@ -83,24 +50,6 @@
</template> </template>
</el-table-column> </el-table-column>
<el-table-column label="备注" align="center" prop="remark" min-width="140" show-overflow-tooltip /> <el-table-column label="备注" align="center" prop="remark" min-width="140" show-overflow-tooltip />
<el-table-column label="操作" align="center" class-name="small-padding fixed-width" width="140">
<template slot-scope="scope">
<el-button
size="mini"
type="text"
icon="el-icon-edit"
@click="handleUpdate(scope.row)"
v-hasPermi="['ai:order:edit']"
>修改</el-button>
<el-button
size="mini"
type="text"
icon="el-icon-delete"
@click="handleDelete(scope.row)"
v-hasPermi="['ai:order:remove']"
>删除</el-button>
</template>
</el-table-column>
</el-table> </el-table>
<pagination <pagination
@ -110,94 +59,33 @@
:limit.sync="queryParams.pageSize" :limit.sync="queryParams.pageSize"
@pagination="getList" @pagination="getList"
/> />
<el-dialog :title="title" :visible.sync="open" width="560px" append-to-body>
<el-form ref="form" :model="form" :rules="rules" label-width="100px">
<el-form-item label="团队" prop="deptId">
<treeselect
v-model="form.deptId"
:options="deptOptions"
:normalizer="normalizer"
:show-count="true"
placeholder="请选择团队(二级部门)"
/>
</el-form-item>
<el-form-item label="类型" prop="orderType">
<el-select v-model="form.orderType" placeholder="请选择" style="width: 100%">
<el-option v-for="item in orderTypeOptions" :key="item.value" :label="item.label" :value="item.value" />
</el-select>
</el-form-item>
<el-form-item label="金额(元)" prop="money">
<el-input v-model="form.money" placeholder="可选,对账用金额" />
</el-form-item>
<el-form-item label="积分" prop="amount">
<el-input v-model="form.amount" placeholder="充值/退款填正数;手动修改可填负数表示扣减" />
</el-form-item>
<el-form-item label="状态" prop="status">
<el-select v-model="form.status" placeholder="请选择" style="width: 100%">
<el-option label="进行中" :value="0" />
<el-option label="已完成" :value="1" />
<el-option label="失败" :value="2" />
</el-select>
</el-form-item>
<el-form-item label="订单编号" prop="orderNum" v-if="form.id != null">
<el-input v-model="form.orderNum" disabled />
</el-form-item>
<el-form-item label="备注" prop="remark">
<el-input v-model="form.remark" type="textarea" :rows="3" placeholder="对账说明、打款信息等" maxlength="500" show-word-limit />
</el-form-item>
</el-form>
<div slot="footer" class="dialog-footer">
<el-button type="primary" @click="submitForm"> </el-button>
<el-button @click="cancel"> </el-button>
</div>
</el-dialog>
</div> </div>
</template> </template>
<script> <script>
import { listOrder, getOrder, delOrder, addOrder, updateOrder } from "@/api/ai/order" import { listOrder } from "@/api/ai/order"
import { deptTreeSelect } from "@/api/system/user"
import Treeselect from "@riophae/vue-treeselect"
import "@riophae/vue-treeselect/dist/vue-treeselect.css"
export default { export default {
name: "TeamChargeOrder", name: "TeamChargeOrder",
components: { Treeselect },
data() { data() {
return { return {
loading: true, loading: true,
ids: [],
single: true,
multiple: true,
showSearch: true, showSearch: true,
total: 0, total: 0,
orderList: [], orderList: [],
title: "",
open: false,
deptOptions: [],
orderTypeOptions: [ orderTypeOptions: [
{ label: "充值", value: 0 }, { label: "充值", value: 0 },
{ label: "退款", value: 1 }, { label: "退款", value: 1 }
{ label: "手动修改", value: 2 }
], ],
queryParams: { queryParams: {
pageNum: 1, pageNum: 1,
pageSize: 10, pageSize: 10,
deptName: null, deptName: null,
orderType: null orderType: null
},
form: {},
rules: {
deptId: [{ required: true, message: "请选择团队", trigger: "change" }],
orderType: [{ required: true, message: "请选择类型", trigger: "change" }],
amount: [{ required: true, message: "请填写积分", trigger: "blur" }],
status: [{ required: true, message: "请选择状态", trigger: "change" }]
} }
} }
}, },
created() { created() {
this.getDeptTree()
this.getList() this.getList()
}, },
methods: { methods: {
@ -206,21 +94,6 @@ export default {
const hit = this.orderTypeOptions.find(o => o.value === n) const hit = this.orderTypeOptions.find(o => o.value === n)
return hit ? hit.label : "—" return hit ? hit.label : "—"
}, },
getDeptTree() {
deptTreeSelect().then(response => {
this.deptOptions = response.data || []
})
},
normalizer(node) {
if (node.children && !node.children.length) {
delete node.children
}
return {
id: node.id,
label: node.label,
children: node.children
}
},
getList() { getList() {
this.loading = true this.loading = true
listOrder(this.queryParams).then(response => { listOrder(this.queryParams).then(response => {
@ -229,23 +102,6 @@ export default {
this.loading = false this.loading = false
}) })
}, },
cancel() {
this.open = false
this.reset()
},
reset() {
this.form = {
id: null,
deptId: undefined,
orderType: 0,
money: undefined,
amount: undefined,
remark: undefined,
status: 1,
orderNum: undefined
}
this.resetForm("form")
},
handleQuery() { handleQuery() {
this.queryParams.pageNum = 1 this.queryParams.pageNum = 1
this.getList() this.getList()
@ -254,53 +110,6 @@ export default {
this.resetForm("queryForm") this.resetForm("queryForm")
this.handleQuery() this.handleQuery()
}, },
handleSelectionChange(selection) {
this.ids = selection.map(item => item.id)
this.single = selection.length !== 1
this.multiple = !selection.length
},
handleAdd() {
this.reset()
this.open = true
this.title = "新增团队订单"
},
handleUpdate(row) {
this.reset()
const id = row.id || this.ids[0]
getOrder(id).then(response => {
this.form = response.data
this.open = true
this.title = "修改团队订单"
})
},
submitForm() {
this.$refs["form"].validate(valid => {
if (!valid) {
return
}
const payload = { ...this.form }
if (payload.id == null) {
addOrder(payload).then(() => {
this.$modal.msgSuccess("新增成功")
this.open = false
this.getList()
})
} else {
updateOrder(payload).then(() => {
this.$modal.msgSuccess("修改成功")
this.open = false
this.getList()
})
}
})
},
handleDelete(row) {
const ids = row.id || this.ids
this.$modal.confirm("是否确认删除所选团队订单?").then(() => delOrder(ids)).then(() => {
this.getList()
this.$modal.msgSuccess("删除成功")
}).catch(() => {})
},
handleExport() { handleExport() {
this.download("ai/order/export", { ...this.queryParams }, `team_orders_${new Date().getTime()}.xlsx`) this.download("ai/order/export", { ...this.queryParams }, `team_orders_${new Date().getTime()}.xlsx`)
} }

View File

@ -40,38 +40,6 @@
</el-form> </el-form>
<el-row :gutter="10" class="mb8"> <el-row :gutter="10" class="mb8">
<el-col :span="1.5">
<el-button
type="primary"
plain
icon="el-icon-plus"
size="mini"
@click="handleAdd"
v-hasPermi="['ai:record:add']"
>新增</el-button>
</el-col>
<el-col :span="1.5">
<el-button
type="success"
plain
icon="el-icon-edit"
size="mini"
:disabled="single"
@click="handleUpdate"
v-hasPermi="['ai:record:edit']"
>修改</el-button>
</el-col>
<el-col :span="1.5">
<el-button
type="danger"
plain
icon="el-icon-delete"
size="mini"
:disabled="multiple"
@click="handleDelete"
v-hasPermi="['ai:record:remove']"
>删除</el-button>
</el-col>
<el-col :span="1.5"> <el-col :span="1.5">
<el-button <el-button
type="warning" type="warning"
@ -85,8 +53,7 @@
<right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar> <right-toolbar :showSearch.sync="showSearch" @queryTable="getList"></right-toolbar>
</el-row> </el-row>
<el-table v-loading="loading" :data="recordList" @selection-change="handleSelectionChange"> <el-table v-loading="loading" :data="recordList">
<el-table-column type="selection" width="55" align="center" />
<el-table-column label="ID" align="center" prop="id" /> <el-table-column label="ID" align="center" prop="id" />
<el-table-column label="订单号" align="center" prop="relationOrderNo" /> <el-table-column label="订单号" align="center" prop="relationOrderNo" />
<el-table-column label="部门ID" align="center" prop="deptId" /> <el-table-column label="部门ID" align="center" prop="deptId" />
@ -94,22 +61,9 @@
<el-table-column label="变更金额" align="center" prop="changeAmount" /> <el-table-column label="变更金额" align="center" prop="changeAmount" />
<el-table-column label="变更后金额" align="center" prop="resultAmount" /> <el-table-column label="变更后金额" align="center" prop="resultAmount" />
<el-table-column label="备注" align="center" prop="remark" /> <el-table-column label="备注" align="center" prop="remark" />
<el-table-column label="操作" align="center" class-name="small-padding fixed-width"> <el-table-column label="创建时间" align="center" prop="createTime" width="160">
<template slot-scope="scope"> <template slot-scope="scope">
<el-button <span>{{ parseTime(scope.row.createTime) }}</span>
size="mini"
type="text"
icon="el-icon-edit"
@click="handleUpdate(scope.row)"
v-hasPermi="['ai:record:edit']"
>修改</el-button>
<el-button
size="mini"
type="text"
icon="el-icon-delete"
@click="handleDelete(scope.row)"
v-hasPermi="['ai:record:remove']"
>删除</el-button>
</template> </template>
</el-table-column> </el-table-column>
</el-table> </el-table>
@ -121,60 +75,20 @@
:limit.sync="queryParams.pageSize" :limit.sync="queryParams.pageSize"
@pagination="getList" @pagination="getList"
/> />
<!-- 添加或修改团队部门余额变动对话框 -->
<el-dialog :title="title" :visible.sync="open" width="500px" append-to-body>
<el-form ref="form" :model="form" :rules="rules" label-width="80px">
<el-form-item label="订单号" prop="relationOrderNo">
<el-input v-model="form.relationOrderNo" placeholder="请输入关联(充值/退款)订单号" />
</el-form-item>
<el-form-item label="部门ID" prop="deptId">
<el-input v-model="form.deptId" placeholder="请输入部门ID" />
</el-form-item>
<el-form-item label="变更金额" prop="changeAmount">
<el-input v-model="form.changeAmount" placeholder="请输入变更金额" />
</el-form-item>
<el-form-item label="变更后金额" prop="resultAmount">
<el-input v-model="form.resultAmount" placeholder="请输入变更后金额" />
</el-form-item>
<el-form-item label="备注" prop="remark">
<el-input v-model="form.remark" placeholder="请输入备注" />
</el-form-item>
</el-form>
<div slot="footer" class="dialog-footer">
<el-button type="primary" @click="submitForm"> </el-button>
<el-button @click="cancel"> </el-button>
</div>
</el-dialog>
</div> </div>
</template> </template>
<script> <script>
import { listRecord, getRecord, delRecord, addRecord, updateRecord } from "@/api/ai/record" import { listRecord } from "@/api/ai/record"
export default { export default {
name: "Record", name: "Record",
data() { data() {
return { return {
//
loading: true, loading: true,
//
ids: [],
//
single: true,
//
multiple: true,
//
showSearch: true, showSearch: true,
//
total: 0, total: 0,
//
recordList: [], recordList: [],
//
title: "",
//
open: false,
//
queryParams: { queryParams: {
pageNum: 1, pageNum: 1,
pageSize: 10, pageSize: 10,
@ -182,27 +96,7 @@ export default {
deptId: null, deptId: null,
type: null, type: null,
changeAmount: null, changeAmount: null,
resultAmount: null, resultAmount: null
},
//
form: {},
//
rules: {
deptId: [
{ required: true, message: "部门ID不能为空", trigger: "blur" }
],
type: [
{ required: true, message: "操作类型不能为空", trigger: "change" }
],
changeAmount: [
{ required: true, message: "变更金额不能为空", trigger: "blur" }
],
resultAmount: [
{ required: true, message: "变更后金额不能为空", trigger: "blur" }
],
createTime: [
{ required: true, message: "创建时间不能为空", trigger: "blur" }
],
} }
} }
}, },
@ -210,7 +104,6 @@ export default {
this.getList() this.getList()
}, },
methods: { methods: {
/** 查询团队(部门)余额变动列表 */
getList() { getList() {
this.loading = true this.loading = true
listRecord(this.queryParams).then(response => { listRecord(this.queryParams).then(response => {
@ -219,89 +112,14 @@ export default {
this.loading = false this.loading = false
}) })
}, },
//
cancel() {
this.open = false
this.reset()
},
//
reset() {
this.form = {
id: null,
relationOrderNo: null,
deptId: null,
type: null,
changeAmount: null,
resultAmount: null,
remark: null,
createTime: null,
updateTime: null
}
this.resetForm("form")
},
/** 搜索按钮操作 */
handleQuery() { handleQuery() {
this.queryParams.pageNum = 1 this.queryParams.pageNum = 1
this.getList() this.getList()
}, },
/** 重置按钮操作 */
resetQuery() { resetQuery() {
this.resetForm("queryForm") this.resetForm("queryForm")
this.handleQuery() this.handleQuery()
}, },
//
handleSelectionChange(selection) {
this.ids = selection.map(item => item.id)
this.single = selection.length!==1
this.multiple = !selection.length
},
/** 新增按钮操作 */
handleAdd() {
this.reset()
this.open = true
this.title = "添加团队(部门)余额变动"
},
/** 修改按钮操作 */
handleUpdate(row) {
this.reset()
const id = row.id || this.ids
getRecord(id).then(response => {
this.form = response.data
this.open = true
this.title = "修改团队(部门)余额变动"
})
},
/** 提交按钮 */
submitForm() {
this.$refs["form"].validate(valid => {
if (valid) {
if (this.form.id != null) {
updateRecord(this.form).then(response => {
this.$modal.msgSuccess("修改成功")
this.open = false
this.getList()
})
} else {
addRecord(this.form).then(response => {
this.$modal.msgSuccess("新增成功")
this.open = false
this.getList()
})
}
}
})
},
/** 删除按钮操作 */
handleDelete(row) {
const ids = row.id || this.ids
this.$modal.confirm('是否确认删除团队(部门)余额变动编号为"' + ids + '"的数据项?').then(function() {
return delRecord(ids)
}).then(() => {
this.getList()
this.$modal.msgSuccess("删除成功")
}).catch(() => {})
},
/** 导出按钮操作 */
handleExport() { handleExport() {
this.download('ai/record/export', { this.download('ai/record/export', {
...this.queryParams ...this.queryParams

View File

@ -239,8 +239,11 @@
placeholder="请选择生日" placeholder="请选择生日"
></el-date-picker> ></el-date-picker>
</el-form-item> </el-form-item>
<el-form-item label="余额" prop="balance"> <el-form-item v-if="form.id != null" label="余额" prop="balance">
<el-input v-model="form.balance" placeholder="请输入余额" /> <el-input v-model="form.balance" disabled placeholder="-" />
<div style="color: #909399; font-size: 12px; line-height: 1.5; margin-top: 4px">
余额仅可通过下放积分回收积分调整
</div>
</el-form-item> </el-form-item>
<el-form-item label="备注" prop="remark"> <el-form-item label="备注" prop="remark">
<el-input v-model="form.remark" type="textarea" placeholder="请输入内容" /> <el-input v-model="form.remark" type="textarea" placeholder="请输入内容" />
@ -689,7 +692,9 @@ export default {
this.getList(); this.getList();
}); });
} else { } else {
addUser(this.form).then(() => { const payload = { ...this.form };
delete payload.balance;
addUser(payload).then(() => {
this.$modal.msgSuccess("新增成功"); this.$modal.msgSuccess("新增成功");
this.open = false; this.open = false;
this.getList(); this.getList();

View File

@ -53,6 +53,11 @@
<span>{{ scope.row.maxUserCount != null && scope.row.maxUserCount > 0 ? scope.row.maxUserCount : '不限制' }}</span> <span>{{ scope.row.maxUserCount != null && scope.row.maxUserCount > 0 ? scope.row.maxUserCount : '不限制' }}</span>
</template> </template>
</el-table-column> </el-table-column>
<el-table-column prop="balance" label="剩余积分" width="120" align="right">
<template slot-scope="scope">
<span>{{ scope.row.balance != null ? scope.row.balance : '—' }}</span>
</template>
</el-table-column>
<el-table-column prop="status" label="状态" width="100"> <el-table-column prop="status" label="状态" width="100">
<template slot-scope="scope"> <template slot-scope="scope">
<dict-tag :options="dict.type.sys_normal_disable" :value="scope.row.status"/> <dict-tag :options="dict.type.sys_normal_disable" :value="scope.row.status"/>
@ -63,7 +68,7 @@
<span>{{ parseTime(scope.row.createTime) }}</span> <span>{{ parseTime(scope.row.createTime) }}</span>
</template> </template>
</el-table-column> </el-table-column>
<el-table-column label="操作" align="center" class-name="small-padding fixed-width"> <el-table-column label="操作" align="center" width="480" class-name="small-padding fixed-width">
<template slot-scope="scope"> <template slot-scope="scope">
<el-button <el-button
v-if="isFirstLevelRow(scope.row) || isSecondLevelRow(scope.row)" v-if="isFirstLevelRow(scope.row) || isSecondLevelRow(scope.row)"
@ -72,7 +77,23 @@
icon="el-icon-setting" icon="el-icon-setting"
@click="handleArkConfig(scope.row)" @click="handleArkConfig(scope.row)"
v-hasPermi="['system:dept:query', 'system:dept:edit']" v-hasPermi="['system:dept:query', 'system:dept:edit']"
>火山配置</el-button> >火山引擎</el-button>
<el-button
v-if="isFirstLevelRow(scope.row) || isSecondLevelRow(scope.row)"
size="mini"
type="text"
icon="el-icon-wallet"
@click="handleChargeRefund(scope.row)"
v-hasPermi="['system:dept:chargeRefund']"
>充值/退款</el-button>
<el-button
v-if="isFirstLevelRow(scope.row) || isSecondLevelRow(scope.row)"
size="mini"
type="text"
icon="el-icon-s-operation"
@click="handleEditScore(scope.row)"
v-hasPermi="['system:dept:chargeRefund']"
>积分更正</el-button>
<el-button <el-button
size="mini" size="mini"
type="text" type="text"
@ -179,11 +200,11 @@
</div> </div>
</el-dialog> </el-dialog>
<el-dialog title="火山配置" :visible.sync="arkOpen" width="800px" append-to-body @close="resetArkForm"> <el-dialog title="火山引擎" :visible.sync="arkOpen" width="800px" append-to-body @close="resetArkForm">
<el-form ref="arkFormRef" :model="arkForm" label-width="120px"> <el-form ref="arkFormRef" :model="arkForm" label-width="120px">
<el-row> <el-row>
<el-col :span="24"> <el-col :span="24">
<el-form-item label="Byte API Key"> <el-form-item label="ApiKey">
<el-input <el-input
v-model="arkForm.byteApiKey" v-model="arkForm.byteApiKey"
type="password" type="password"
@ -196,7 +217,7 @@
</el-row> </el-row>
<el-row> <el-row>
<el-col :span="24"> <el-col :span="24">
<el-form-item label="火山配置项目"> <el-form-item label="火山项目">
<el-input <el-input
v-model="arkForm.project" v-model="arkForm.project"
type="password" type="password"
@ -248,6 +269,91 @@
<el-button @click="arkOpen = false"> </el-button> <el-button @click="arkOpen = false"> </el-button>
</div> </div>
</el-dialog> </el-dialog>
<el-dialog
:title="'充值/退款 — ' + (chargeRefundForm.deptName || '')"
:visible.sync="chargeRefundOpen"
width="520px"
append-to-body
@close="resetChargeRefund"
>
<el-form ref="chargeRefundFormRef" :model="chargeRefundForm" :rules="chargeRefundRules" label-width="88px">
<el-form-item label="类型" prop="orderType">
<el-radio-group v-model="chargeRefundForm.orderType">
<el-radio :label="0">充值</el-radio>
<el-radio :label="1">退款</el-radio>
</el-radio-group>
</el-form-item>
<el-form-item label="金额" prop="money">
<el-input
:value="chargeRefundMoneyDisplay"
placeholder="财务记录(元),如 9,999,999.00"
clearable
@input="onChargeRefundMoneyInput"
@blur="onChargeRefundMoneyBlur"
/>
</el-form-item>
<el-form-item label="积分" prop="amount">
<el-input
:value="chargeRefundAmountDisplay"
placeholder="变动积分,如 99,999,999"
clearable
@input="onChargeRefundAmountInput"
/>
</el-form-item>
<el-form-item label="备注" prop="remark">
<el-input
v-model="chargeRefundForm.remark"
type="textarea"
:rows="2"
maxlength="50"
show-word-limit
placeholder="选填最多50字"
/>
</el-form-item>
</el-form>
<div slot="footer" class="dialog-footer">
<el-button type="primary" @click="submitChargeRefund"> </el-button>
<el-button @click="chargeRefundOpen = false"> </el-button>
</div>
</el-dialog>
<el-dialog
:title="'积分更正 — ' + (editScoreForm.deptName || '')"
:visible.sync="editScoreOpen"
width="520px"
append-to-body
@close="resetEditScore"
>
<el-form ref="editScoreFormRef" :model="editScoreForm" :rules="editScoreRules" label-width="88px">
<el-form-item label="积分" prop="score">
<el-input-number
v-model="editScoreForm.score"
:precision="0"
:step="1"
:min="-100000000"
:max="100000000"
controls-position="right"
class="edit-score-input-number"
placeholder="正数增加负数扣减不能为0"
/>
</el-form-item>
<el-form-item label="备注" prop="remark">
<el-input
v-model="editScoreForm.remark"
type="textarea"
:rows="2"
maxlength="50"
show-word-limit
placeholder="必填最多50字"
/>
</el-form-item>
</el-form>
<div slot="footer" class="dialog-footer">
<el-button type="primary" @click="submitEditScore"> </el-button>
<el-button @click="editScoreOpen = false"> </el-button>
</div>
</el-dialog>
</div> </div>
</template> </template>
@ -279,10 +385,23 @@
color: #e6a23c; color: #e6a23c;
font-size: 12px; font-size: 12px;
} }
.edit-score-input-number {
width: 100%;
}
</style> </style>
<script> <script>
import { listDept, getDept, delDept, addDept, updateDept, listDeptExcludeChild, getDeptArk, updateDeptArk } from "@/api/system/dept" import { listDept, getDept, delDept, addDept, updateDept, listDeptExcludeChild, getDeptArk, updateDeptArk, chargeRefundDept, editScore } from "@/api/system/dept"
import {
WESTERN_MONEY_MAX,
sanitizeMoneyDigits,
formatMoneyWesternDisplay,
moneyStringToNumber,
formatMoneyWesternFinal,
sanitizeIntDigits,
formatIntWesternDisplay,
intStringToNumber
} from "@/utils/westernNumberFormat"
import Treeselect from "@riophae/vue-treeselect" import Treeselect from "@riophae/vue-treeselect"
import "@riophae/vue-treeselect/dist/vue-treeselect.css" import "@riophae/vue-treeselect/dist/vue-treeselect.css"
@ -312,6 +431,75 @@ export default {
modelParm: undefined modelParm: undefined
}, },
arkModelParamRows: [{ label: '', value: '' }], arkModelParamRows: [{ label: '', value: '' }],
chargeRefundOpen: false,
chargeRefundMoneyDisplay: "",
chargeRefundAmountDisplay: "",
chargeRefundForm: {
deptId: undefined,
deptName: "",
orderType: 0,
money: undefined,
amount: undefined,
remark: ""
},
chargeRefundRules: {
orderType: [
{ required: true, message: "类型不能为空", trigger: "change" }
],
money: [
{ required: true, message: "金额不能为空", trigger: "blur" },
{ type: "number", min: 0, max: 10000000, message: "金额须在 010000000 之间", trigger: "blur" }
],
amount: [
{ required: true, message: "积分不能为空", trigger: "blur" },
{ type: "number", min: 1, max: 100000000, message: "积分须在 1100000000 之间", trigger: "blur" }
],
remark: [
{ max: 50, message: "备注不能超过50个字符", trigger: "blur" }
]
},
editScoreOpen: false,
editScoreForm: {
deptId: undefined,
deptName: "",
score: undefined,
remark: ""
},
editScoreRules: {
score: [
{ required: true, message: "积分不能为空", trigger: "blur" },
{
validator(rule, value, callback) {
if (value === undefined || value === null || value === "") {
callback(new Error("积分不能为空"))
} else if (!Number.isInteger(Number(value))) {
callback(new Error("积分须为整数"))
} else if (Number(value) === 0) {
callback(new Error("积分不能为0"))
} else if (Number(value) < -100000000 || Number(value) > 100000000) {
callback(new Error("积分须在 -100000000100000000 之间不含0"))
} else {
callback()
}
},
trigger: "blur"
}
],
remark: [
{ required: true, message: "备注不能为空", trigger: "blur" },
{
validator(rule, value, callback) {
if (!value || String(value).trim() === "") {
callback(new Error("备注不能为空"))
} else {
callback()
}
},
trigger: "blur"
},
{ max: 50, message: "备注不能超过50个字符", trigger: "blur" }
]
},
// //
isExpandAll: true, isExpandAll: true,
// //
@ -443,6 +631,138 @@ export default {
this.arkOpen = true this.arkOpen = true
}) })
}, },
resetChargeRefund() {
this.chargeRefundMoneyDisplay = ""
this.chargeRefundAmountDisplay = ""
this.chargeRefundForm = {
deptId: undefined,
deptName: "",
orderType: 0,
money: undefined,
amount: undefined,
remark: ""
}
this.$nextTick(() => {
if (this.$refs.chargeRefundFormRef) {
this.$refs.chargeRefundFormRef.clearValidate()
}
})
},
handleChargeRefund(row) {
if (!this.isFirstLevelRow(row) && !this.isSecondLevelRow(row)) {
return
}
this.chargeRefundMoneyDisplay = ""
this.chargeRefundAmountDisplay = ""
this.chargeRefundForm = {
deptId: row.deptId,
deptName: row.deptName,
orderType: 0,
money: undefined,
amount: undefined,
remark: ""
}
this.chargeRefundOpen = true
this.$nextTick(() => {
if (this.$refs.chargeRefundFormRef) {
this.$refs.chargeRefundFormRef.clearValidate()
}
})
},
onChargeRefundMoneyInput(val) {
const sanitized = sanitizeMoneyDigits(val)
if (!sanitized) {
this.chargeRefundMoneyDisplay = ""
this.chargeRefundForm.money = undefined
return
}
const raw = parseFloat(sanitized)
if (!isNaN(raw) && raw > WESTERN_MONEY_MAX) {
this.chargeRefundForm.money = WESTERN_MONEY_MAX
this.chargeRefundMoneyDisplay = formatMoneyWesternFinal(WESTERN_MONEY_MAX)
return
}
this.chargeRefundMoneyDisplay = formatMoneyWesternDisplay(sanitized)
this.chargeRefundForm.money = moneyStringToNumber(sanitized)
},
onChargeRefundMoneyBlur() {
if (this.chargeRefundForm.money !== undefined && this.chargeRefundForm.money !== null) {
this.chargeRefundMoneyDisplay = formatMoneyWesternFinal(this.chargeRefundForm.money)
}
},
onChargeRefundAmountInput(val) {
const digits = sanitizeIntDigits(val)
this.chargeRefundAmountDisplay = digits === "" ? "" : formatIntWesternDisplay(digits)
this.chargeRefundForm.amount = intStringToNumber(digits)
},
submitChargeRefund() {
this.onChargeRefundMoneyBlur()
this.$refs["chargeRefundFormRef"].validate(valid => {
if (!valid) {
return
}
const data = {
deptId: this.chargeRefundForm.deptId,
orderType: this.chargeRefundForm.orderType,
money: this.chargeRefundForm.money,
amount: this.chargeRefundForm.amount,
remark: this.chargeRefundForm.remark ? this.chargeRefundForm.remark.trim() : undefined
}
chargeRefundDept(data).then(() => {
this.$modal.msgSuccess("操作成功")
this.chargeRefundOpen = false
this.getList()
})
})
},
resetEditScore() {
this.editScoreForm = {
deptId: undefined,
deptName: "",
score: undefined,
remark: ""
}
this.$nextTick(() => {
if (this.$refs.editScoreFormRef) {
this.$refs.editScoreFormRef.clearValidate()
}
})
},
handleEditScore(row) {
if (!this.isFirstLevelRow(row) && !this.isSecondLevelRow(row)) {
return
}
this.editScoreForm = {
deptId: row.deptId,
deptName: row.deptName,
score: undefined,
remark: ""
}
this.editScoreOpen = true
this.$nextTick(() => {
if (this.$refs.editScoreFormRef) {
this.$refs.editScoreFormRef.clearValidate()
}
})
},
submitEditScore() {
this.$refs["editScoreFormRef"].validate(valid => {
if (!valid) {
return
}
const remark = (this.editScoreForm.remark || "").trim()
const data = {
deptId: this.editScoreForm.deptId,
score: this.editScoreForm.score,
remark: remark
}
editScore(data).then(() => {
this.$modal.msgSuccess("操作成功")
this.editScoreOpen = false
this.getList()
})
})
},
submitArkForm() { submitArkForm() {
this.buildArkModelParmPayload() this.buildArkModelParmPayload()
const payload = { const payload = {

View File

@ -6,10 +6,7 @@ import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log; import com.ruoyi.common.annotation.Log;
@ -68,37 +65,4 @@ public class AiChargeRefundOrderController extends BaseController
{ {
return success(aiChargeRefundOrderService.selectAiChargeRefundOrderById(id)); return success(aiChargeRefundOrderService.selectAiChargeRefundOrderById(id));
} }
/**
* 新增团队部门充值退款订单
*/
@PreAuthorize("@ss.hasPermi('ai:order:add')")
@Log(title = "团队(部门)充值退款订单", businessType = BusinessType.INSERT)
@PostMapping
public AjaxResult add(@RequestBody AiChargeRefundOrder aiChargeRefundOrder)
{
return toAjax(aiChargeRefundOrderService.insertAiChargeRefundOrder(aiChargeRefundOrder));
}
/**
* 修改团队部门充值退款订单
*/
@PreAuthorize("@ss.hasPermi('ai:order:edit')")
@Log(title = "团队(部门)充值退款订单", businessType = BusinessType.UPDATE)
@PutMapping
public AjaxResult edit(@RequestBody AiChargeRefundOrder aiChargeRefundOrder)
{
return toAjax(aiChargeRefundOrderService.updateAiChargeRefundOrder(aiChargeRefundOrder));
}
/**
* 删除团队部门充值退款订单
*/
@PreAuthorize("@ss.hasPermi('ai:order:remove')")
@Log(title = "团队(部门)充值退款订单", businessType = BusinessType.DELETE)
@DeleteMapping("/{ids}")
public AjaxResult remove(@PathVariable Long[] ids)
{
return toAjax(aiChargeRefundOrderService.deleteAiChargeRefundOrderByIds(ids));
}
} }

View File

@ -6,10 +6,7 @@ import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable; import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController; import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log; import com.ruoyi.common.annotation.Log;
@ -64,41 +61,8 @@ public class AiGroupBalanceChangeRecordController extends BaseController
*/ */
@PreAuthorize("@ss.hasPermi('ai:record:query')") @PreAuthorize("@ss.hasPermi('ai:record:query')")
@GetMapping(value = "/{id}") @GetMapping(value = "/{id}")
public AjaxResult getInfo(@PathVariable("id") String id) public AjaxResult getInfo(@PathVariable("id") Long id)
{ {
return success(aiGroupBalanceChangeRecordService.selectAiGroupBalanceChangeRecordById(id)); return success(aiGroupBalanceChangeRecordService.selectAiGroupBalanceChangeRecordById(id));
} }
/**
* 新增团队部门余额变动
*/
@PreAuthorize("@ss.hasPermi('ai:record:add')")
@Log(title = "团队(部门)余额变动", businessType = BusinessType.INSERT)
@PostMapping
public AjaxResult add(@RequestBody AiGroupBalanceChangeRecord aiGroupBalanceChangeRecord)
{
return toAjax(aiGroupBalanceChangeRecordService.insertAiGroupBalanceChangeRecord(aiGroupBalanceChangeRecord));
}
/**
* 修改团队部门余额变动
*/
@PreAuthorize("@ss.hasPermi('ai:record:edit')")
@Log(title = "团队(部门)余额变动", businessType = BusinessType.UPDATE)
@PutMapping
public AjaxResult edit(@RequestBody AiGroupBalanceChangeRecord aiGroupBalanceChangeRecord)
{
return toAjax(aiGroupBalanceChangeRecordService.updateAiGroupBalanceChangeRecord(aiGroupBalanceChangeRecord));
}
/**
* 删除团队部门余额变动
*/
@PreAuthorize("@ss.hasPermi('ai:record:remove')")
@Log(title = "团队(部门)余额变动", businessType = BusinessType.DELETE)
@DeleteMapping("/{ids}")
public AjaxResult remove(@PathVariable String[] ids)
{
return toAjax(aiGroupBalanceChangeRecordService.deleteAiGroupBalanceChangeRecordByIds(ids));
}
} }

View File

@ -38,7 +38,7 @@ public class SubteamGroupBalanceController extends BaseController {
@PreAuthorize("@ss.hasPermi('subteam:groupBalance:query')") @PreAuthorize("@ss.hasPermi('subteam:groupBalance:query')")
@GetMapping("/{id}") @GetMapping("/{id}")
public AjaxResult getInfo(@PathVariable String id) { public AjaxResult getInfo(@PathVariable Long id) {
subteamScopeService.assertGroupBalanceRecordBelongsToTeam(id); subteamScopeService.assertGroupBalanceRecordBelongsToTeam(id);
return success(aiGroupBalanceChangeRecordService.selectAiGroupBalanceChangeRecordById(id)); return success(aiGroupBalanceChangeRecordService.selectAiGroupBalanceChangeRecordById(id));
} }

View File

@ -1,13 +1,17 @@
package com.ruoyi.ai.domain; package com.ruoyi.ai.domain;
import java.io.Serializable;
import java.math.BigDecimal;
import java.util.Date;
import com.baomidou.mybatisplus.annotation.IdType; import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField; import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId; import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName; import com.baomidou.mybatisplus.annotation.TableName;
import java.math.BigDecimal; import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Data; import lombok.Data;
import com.ruoyi.common.annotation.Excel; import com.ruoyi.common.annotation.Excel;
import com.ruoyi.common.core.domain.BaseEntity;
/** /**
* 团队部门充值退款订单对象 ai_charge_refund_order * 团队部门充值退款订单对象 ai_charge_refund_order
@ -17,7 +21,7 @@ import com.ruoyi.common.core.domain.BaseEntity;
*/ */
@Data @Data
@TableName("ai_charge_refund_order") @TableName("ai_charge_refund_order")
public class AiChargeRefundOrder extends BaseEntity { public class AiChargeRefundOrder implements Serializable {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
@ -28,11 +32,22 @@ public class AiChargeRefundOrder extends BaseEntity {
/** 删除标志0代表存在 2代表删除 */ /** 删除标志0代表存在 2代表删除 */
private String delFlag; private String delFlag;
/** 创建者用户IDsys_user.user_id */
private Long createBy;
/** 创建时间 */
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private Date createTime;
/** 更新时间 */
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private Date updateTime;
/** 订单编号 */ /** 订单编号 */
@Excel(name = "订单编号") @Excel(name = "订单编号")
private String orderNum; private String orderNum;
/** 第三方单号(预留) */ /** 第三方单号(预留) */
@Excel(name = "第三方单号(预留)") @Excel(name = "第三方单号(预留)")
private String thirdPartyOrderNum; private String thirdPartyOrderNum;
@ -45,23 +60,25 @@ public class AiChargeRefundOrder extends BaseEntity {
@Excel(name = "团队名称") @Excel(name = "团队名称")
private String deptName; private String deptName;
/** 订单类型(0-充值;1-退款;2-手动修改) */ /** 订单类型0-充值1-退款) */
@Excel(name = "订单类型", readConverterExp = "0=充值,1=退款,2=手动修改") @Excel(name = "订单类型", readConverterExp = "0=充值,1=退款")
private Long orderType; private Integer orderType;
/** 金额(元) */ /** 充值金额(元) */
@Excel(name = "金额(元)") @Excel(name = "充值金额")
private BigDecimal money; private BigDecimal money;
/** /**
* 积分变动充值/退款为绝对值退款在统计中按负数计入 * 积分均为正数通过订单类型判断是加还是减
* 手动修改可为正增加或负扣减
*/ */
@Excel(name = "积分") @Excel(name = "积分")
private BigDecimal amount; private BigDecimal amount;
/** 备注 */
@Excel(name = "备注")
private String remark;
/** 状态0-进行中 1-已完成 2-失败 */ /** 状态0-进行中 1-已完成 2-失败 */
@Excel(name = "状态", readConverterExp = "0=进行中,1=已完成,2=失败") @Excel(name = "状态", readConverterExp = "0=进行中,1=已完成,2=失败")
private Integer status; private Integer status;
} }

View File

@ -3,11 +3,11 @@ package com.ruoyi.ai.domain;
import com.baomidou.mybatisplus.annotation.IdType; import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId; import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName; import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.annotation.JsonFormat;
import lombok.Data; import lombok.Data;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle; import java.io.Serializable;
import com.ruoyi.common.annotation.Excel; import java.util.Date;
import com.ruoyi.common.core.domain.BaseEntity;
/** /**
* 团队部门对应火山引擎配置对象 ai_dept_ark_config * 团队部门对应火山引擎配置对象 ai_dept_ark_config
@ -17,28 +17,36 @@ import com.ruoyi.common.core.domain.BaseEntity;
*/ */
@Data @Data
@TableName("ai_dept_ark_config") @TableName("ai_dept_ark_config")
public class AiDeptArkConfig extends BaseEntity { public class AiDeptArkConfig implements Serializable {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
/** $column.columnComment */
@TableId(type = IdType.AUTO) @TableId(type = IdType.AUTO)
private Long id; private Long id;
/** 部门ID */ /** 部门ID */
@Excel(name = "部门ID")
private Long deptId; private Long deptId;
/** 视频模型列表JSON(label+value) */ /** 视频模型列表JSON(label+value) */
@Excel(name = "视频模型列表JSON(label+value)")
private String modelParm; private String modelParm;
/** Byte project加密 */ /** Byte project加密 */
@Excel(name = "Byte project加密")
private String project; private String project;
/** Byte API Key加密 */ /** Byte API Key加密 */
@Excel(name = "Byte API Key加密")
private String byteApiKey; private String byteApiKey;
/** 创建者(与表 create_by BIGINT 一致) */
private Long createBy;
/** 创建时间 */
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private Date createTime;
/** 更新者(与表 update_by BIGINT 一致) */
private Long updateBy;
/** 更新时间 */
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private Date updateTime;
} }

View File

@ -1,14 +1,15 @@
package com.ruoyi.ai.domain; package com.ruoyi.ai.domain;
import java.math.BigDecimal;
import lombok.Data;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
import com.baomidou.mybatisplus.annotation.IdType; import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId; import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName; import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.ruoyi.common.annotation.Excel; import com.ruoyi.common.annotation.Excel;
import com.ruoyi.common.core.domain.BaseEntity; import lombok.Data;
import java.io.Serializable;
import java.math.BigDecimal;
import java.util.Date;
/** /**
* 团队部门余额变动对象 ai_group_balance_change_record * 团队部门余额变动对象 ai_group_balance_change_record
@ -18,15 +19,15 @@ import com.ruoyi.common.core.domain.BaseEntity;
*/ */
@Data @Data
@TableName("ai_group_balance_change_record") @TableName("ai_group_balance_change_record")
public class AiGroupBalanceChangeRecord extends BaseEntity { public class AiGroupBalanceChangeRecord implements Serializable {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
/** $column.columnComment */ /** 主键ID */
@TableId(type = IdType.AUTO) @TableId(type = IdType.AUTO)
private String id; private Long id;
/** 关联(充值/退款)订单号 */ /** 关联(充值/退款)订单号 */
@Excel(name = "关联(充值/退款)订单号") @Excel(name = "关联(充值/退款)订单号")
private String relationOrderNo; private String relationOrderNo;
@ -34,9 +35,11 @@ public class AiGroupBalanceChangeRecord extends BaseEntity {
@Excel(name = "部门ID") @Excel(name = "部门ID")
private Long deptId; private Long deptId;
/** 操作类型0-充值、1-退款、2-下发、3-回收、4-手动修改) */ /**
@Excel(name = "操作类型", readConverterExp = "0=-充值、1-退款、2-下发、3-回收、4-手动修改") * 操作类型0-充值1-退款2-下发3-回收4-手动修改
private Long type; */
@Excel(name = "操作类型", readConverterExp = "0=充值,1=退款,2=下发,3=回收,4=手动修改")
private Integer type;
/** 变更金额 */ /** 变更金额 */
@Excel(name = "变更金额") @Excel(name = "变更金额")
@ -46,4 +49,15 @@ public class AiGroupBalanceChangeRecord extends BaseEntity {
@Excel(name = "变更后金额") @Excel(name = "变更后金额")
private BigDecimal resultAmount; private BigDecimal resultAmount;
/** 备注(目前只作为手工修改时的备注) */
@Excel(name = "备注")
private String remark;
/** 创建时间 */
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private Date createTime;
/** 更新时间 */
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
private Date updateTime;
} }

View File

@ -19,6 +19,4 @@ public interface AiChargeRefundOrderMapper extends BaseMapper<AiChargeRefundOrde
List<AiChargeRefundOrder> selectAiChargeRefundOrderList(AiChargeRefundOrder query); List<AiChargeRefundOrder> selectAiChargeRefundOrderList(AiChargeRefundOrder query);
AiChargeRefundOrder selectAiChargeRefundOrderById(Long id); AiChargeRefundOrder selectAiChargeRefundOrderById(Long id);
int deleteAiChargeRefundOrderByIds(Long[] ids);
} }

View File

@ -44,28 +44,4 @@ public interface IAiChargeRefundOrderService {
* @return 结果 * @return 结果
*/ */
int insertAiChargeRefundOrder(AiChargeRefundOrder aiChargeRefundOrder); int insertAiChargeRefundOrder(AiChargeRefundOrder aiChargeRefundOrder);
/**
* 修改团队部门充值退款订单
*
* @param aiChargeRefundOrder 团队部门充值退款订单
* @return 结果
*/
int updateAiChargeRefundOrder(AiChargeRefundOrder aiChargeRefundOrder);
/**
* 批量删除团队部门充值退款订单
*
* @param ids 需要删除的团队部门充值退款订单主键集合
* @return 结果
*/
int deleteAiChargeRefundOrderByIds(Long[] ids);
/**
* 删除团队部门充值退款订单信息
*
* @param id 团队部门充值退款订单主键
* @return 结果
*/
int deleteAiChargeRefundOrderById(Long id);
} }

View File

@ -1,9 +1,8 @@
package com.ruoyi.ai.service; package com.ruoyi.ai.service;
import java.util.List;
import com.ruoyi.ai.domain.AiGroupBalanceChangeRecord; import com.ruoyi.ai.domain.AiGroupBalanceChangeRecord;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import java.util.List;
/** /**
* 团队部门余额变动Service接口 * 团队部门余额变动Service接口
@ -19,7 +18,7 @@ public interface IAiGroupBalanceChangeRecordService {
* @param id 团队部门余额变动主键 * @param id 团队部门余额变动主键
* @return 团队部门余额变动 * @return 团队部门余额变动
*/ */
AiGroupBalanceChangeRecord selectAiGroupBalanceChangeRecordById(String id); AiGroupBalanceChangeRecord selectAiGroupBalanceChangeRecordById(Long id);
/** /**
* 查询团队部门余额变动列表 * 查询团队部门余额变动列表
@ -28,44 +27,4 @@ public interface IAiGroupBalanceChangeRecordService {
* @return 团队部门余额变动集合 * @return 团队部门余额变动集合
*/ */
List<AiGroupBalanceChangeRecord> selectAiGroupBalanceChangeRecordList(AiGroupBalanceChangeRecord aiGroupBalanceChangeRecord); List<AiGroupBalanceChangeRecord> selectAiGroupBalanceChangeRecordList(AiGroupBalanceChangeRecord aiGroupBalanceChangeRecord);
/**
* 分页查询团队部门余额变动列表
*
* @param aiGroupBalanceChangeRecord 团队部门余额变动
* @return 团队部门余额变动集合
*/
IPage<AiGroupBalanceChangeRecord> selectAiGroupBalanceChangeRecordPage(Page page, AiGroupBalanceChangeRecord aiGroupBalanceChangeRecord);
/**
* 新增团队部门余额变动
*
* @param aiGroupBalanceChangeRecord 团队部门余额变动
* @return 结果
*/
int insertAiGroupBalanceChangeRecord(AiGroupBalanceChangeRecord aiGroupBalanceChangeRecord);
/**
* 修改团队部门余额变动
*
* @param aiGroupBalanceChangeRecord 团队部门余额变动
* @return 结果
*/
int updateAiGroupBalanceChangeRecord(AiGroupBalanceChangeRecord aiGroupBalanceChangeRecord);
/**
* 批量删除团队部门余额变动
*
* @param ids 需要删除的团队部门余额变动主键集合
* @return 结果
*/
int deleteAiGroupBalanceChangeRecordByIds(String[] ids);
/**
* 删除团队部门余额变动信息
*
* @param id 团队部门余额变动主键
* @return 结果
*/
int deleteAiGroupBalanceChangeRecordById(String id);
} }

View File

@ -89,55 +89,13 @@ public class AiChargeRefundOrderServiceImpl implements IAiChargeRefundOrderServi
aiChargeRefundOrder.setStatus(ChargeRefundOrderStatusType.SUCCESS.getCode()); aiChargeRefundOrder.setStatus(ChargeRefundOrderStatusType.SUCCESS.getCode());
} }
aiChargeRefundOrder.setDelFlag("0"); aiChargeRefundOrder.setDelFlag("0");
aiChargeRefundOrder.setCreateBy(SecurityUtils.getUsername()); aiChargeRefundOrder.setCreateBy(SecurityUtils.getUserId());
aiChargeRefundOrder.setCreateTime(DateUtils.getNowDate()); aiChargeRefundOrder.setCreateTime(DateUtils.getNowDate());
int rows = aiChargeRefundOrderMapper.insert(aiChargeRefundOrder); int rows = aiChargeRefundOrderMapper.insert(aiChargeRefundOrder);
syncRechargeReportData(aiChargeRefundOrder); syncRechargeReportData(aiChargeRefundOrder);
return rows; return rows;
} }
/**
* 修改团队部门充值退款订单
*
* @param aiChargeRefundOrder 团队部门充值退款订单
* @return 结果
*/
@Override
public int updateAiChargeRefundOrder(AiChargeRefundOrder aiChargeRefundOrder) {
validateChargeAmount(aiChargeRefundOrder);
aiChargeRefundOrder.setUpdateTime(DateUtils.getNowDate());
int rows = aiChargeRefundOrderMapper.updateById(aiChargeRefundOrder);
if (rows > 0) {
AiChargeRefundOrder fresh = aiChargeRefundOrderMapper.selectById(aiChargeRefundOrder.getId());
syncRechargeReportData(fresh);
}
return rows;
}
/**
* 批量删除团队部门充值退款订单
*
* @param ids 需要删除的团队部门充值退款订单主键
* @return 结果
*/
@Override
public int deleteAiChargeRefundOrderByIds(Long[] ids)
{
return aiChargeRefundOrderMapper.deleteAiChargeRefundOrderByIds(ids);
}
/**
* 删除团队部门充值退款订单信息
*
* @param id 团队部门充值退款订单主键
* @return 结果
*/
@Override
public int deleteAiChargeRefundOrderById(Long id)
{
return aiChargeRefundOrderMapper.deleteById(id);
}
/** /**
* 充值/退款单完成后订单创建时间同步到团队统计来源表 * 充值/退款单完成后订单创建时间同步到团队统计来源表
* *
@ -164,7 +122,7 @@ public class AiChargeRefundOrderServiceImpl implements IAiChargeRefundOrderServi
} }
/** /**
* 充值退款积分须为非负数手动修改允许正负 * 充值退款积分须为非负数
*/ */
private void validateChargeAmount(AiChargeRefundOrder o) { private void validateChargeAmount(AiChargeRefundOrder o) {
if (o.getOrderType() == null || o.getAmount() == null) { if (o.getOrderType() == null || o.getAmount() == null) {

View File

@ -92,14 +92,14 @@ public class AiDeptArkConfigServiceImpl implements IAiDeptArkConfigService {
row.setByteApiKey(encodeNullable(keyPlain)); row.setByteApiKey(encodeNullable(keyPlain));
row.setProject(encodeNullable(projectPlain)); row.setProject(encodeNullable(projectPlain));
row.setModelParm(modelPlain); row.setModelParm(modelPlain);
row.setCreateBy(SecurityUtils.getUsername()); row.setCreateBy(SecurityUtils.getUserId());
row.setCreateTime(DateUtils.getNowDate()); row.setCreateTime(DateUtils.getNowDate());
aiDeptArkConfigMapper.insert(row); aiDeptArkConfigMapper.insert(row);
} else { } else {
existing.setByteApiKey(encodeNullable(keyPlain)); existing.setByteApiKey(encodeNullable(keyPlain));
existing.setProject(encodeNullable(projectPlain)); existing.setProject(encodeNullable(projectPlain));
existing.setModelParm(modelPlain); existing.setModelParm(modelPlain);
existing.setUpdateBy(SecurityUtils.getUsername()); existing.setUpdateBy(SecurityUtils.getUserId());
existing.setUpdateTime(DateUtils.getNowDate()); existing.setUpdateTime(DateUtils.getNowDate());
aiDeptArkConfigMapper.updateById(existing); aiDeptArkConfigMapper.updateById(existing);
} }
@ -181,7 +181,7 @@ public class AiDeptArkConfigServiceImpl implements IAiDeptArkConfigService {
@Override @Override
public int insertAiDeptArkConfig(AiDeptArkConfig aiDeptArkConfig) { public int insertAiDeptArkConfig(AiDeptArkConfig aiDeptArkConfig) {
encryptSensitiveForStore(aiDeptArkConfig); encryptSensitiveForStore(aiDeptArkConfig);
aiDeptArkConfig.setCreateBy(SecurityUtils.getUsername()); aiDeptArkConfig.setCreateBy(SecurityUtils.getUserId());
aiDeptArkConfig.setCreateTime(DateUtils.getNowDate()); aiDeptArkConfig.setCreateTime(DateUtils.getNowDate());
int r = aiDeptArkConfigMapper.insert(aiDeptArkConfig); int r = aiDeptArkConfigMapper.insert(aiDeptArkConfig);
if (r > 0 && aiDeptArkConfig.getDeptId() != null) { if (r > 0 && aiDeptArkConfig.getDeptId() != null) {
@ -193,7 +193,7 @@ public class AiDeptArkConfigServiceImpl implements IAiDeptArkConfigService {
@Override @Override
public int updateAiDeptArkConfig(AiDeptArkConfig aiDeptArkConfig) { public int updateAiDeptArkConfig(AiDeptArkConfig aiDeptArkConfig) {
encryptSensitiveForStore(aiDeptArkConfig); encryptSensitiveForStore(aiDeptArkConfig);
aiDeptArkConfig.setUpdateBy(SecurityUtils.getUsername()); aiDeptArkConfig.setUpdateBy(SecurityUtils.getUserId());
aiDeptArkConfig.setUpdateTime(DateUtils.getNowDate()); aiDeptArkConfig.setUpdateTime(DateUtils.getNowDate());
int r = aiDeptArkConfigMapper.updateById(aiDeptArkConfig); int r = aiDeptArkConfigMapper.updateById(aiDeptArkConfig);
if (r > 0 && aiDeptArkConfig.getDeptId() != null) { if (r > 0 && aiDeptArkConfig.getDeptId() != null) {

View File

@ -1,16 +1,14 @@
package com.ruoyi.ai.service.impl; package com.ruoyi.ai.service.impl;
import java.util.List;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.core.metadata.IPage; import com.ruoyi.ai.domain.AiGroupBalanceChangeRecord;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.ruoyi.ai.mapper.AiGroupBalanceChangeRecordMapper;
import com.ruoyi.common.utils.DateUtils; import com.ruoyi.ai.service.IAiGroupBalanceChangeRecordService;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import com.ruoyi.ai.mapper.AiGroupBalanceChangeRecordMapper;
import com.ruoyi.ai.domain.AiGroupBalanceChangeRecord; import java.util.List;
import com.ruoyi.ai.service.IAiGroupBalanceChangeRecordService;
/** /**
* 团队部门余额变动Service业务层处理 * 团队部门余额变动Service业务层处理
@ -31,7 +29,7 @@ public class AiGroupBalanceChangeRecordServiceImpl implements IAiGroupBalanceCha
* @return 团队部门余额变动 * @return 团队部门余额变动
*/ */
@Override @Override
public AiGroupBalanceChangeRecord selectAiGroupBalanceChangeRecordById(String id) { public AiGroupBalanceChangeRecord selectAiGroupBalanceChangeRecordById(Long id) {
return aiGroupBalanceChangeRecordMapper.selectById(id); return aiGroupBalanceChangeRecordMapper.selectById(id);
} }
@ -47,64 +45,4 @@ public class AiGroupBalanceChangeRecordServiceImpl implements IAiGroupBalanceCha
query.orderByDesc(AiGroupBalanceChangeRecord::getId); query.orderByDesc(AiGroupBalanceChangeRecord::getId);
return aiGroupBalanceChangeRecordMapper.selectList(query); return aiGroupBalanceChangeRecordMapper.selectList(query);
} }
/**
* 分页查询团队部门余额变动列表
*
* @param aiGroupBalanceChangeRecord 团队部门余额变动
* @return 团队部门余额变动
*/
@Override
public IPage<AiGroupBalanceChangeRecord> selectAiGroupBalanceChangeRecordPage(Page page, AiGroupBalanceChangeRecord aiGroupBalanceChangeRecord) {
LambdaQueryWrapper<AiGroupBalanceChangeRecord> query = Wrappers.lambdaQuery(aiGroupBalanceChangeRecord);
return aiGroupBalanceChangeRecordMapper.selectPage(page, query);
}
/**
* 新增团队部门余额变动
*
* @param aiGroupBalanceChangeRecord 团队部门余额变动
* @return 结果
*/
@Override
public int insertAiGroupBalanceChangeRecord(AiGroupBalanceChangeRecord aiGroupBalanceChangeRecord) {
aiGroupBalanceChangeRecord.setCreateTime(DateUtils.getNowDate());
return aiGroupBalanceChangeRecordMapper.insert(aiGroupBalanceChangeRecord);
}
/**
* 修改团队部门余额变动
*
* @param aiGroupBalanceChangeRecord 团队部门余额变动
* @return 结果
*/
@Override
public int updateAiGroupBalanceChangeRecord(AiGroupBalanceChangeRecord aiGroupBalanceChangeRecord) {
aiGroupBalanceChangeRecord.setUpdateTime(DateUtils.getNowDate());
return aiGroupBalanceChangeRecordMapper.updateById(aiGroupBalanceChangeRecord);
}
/**
* 批量删除团队部门余额变动
*
* @param ids 需要删除的团队部门余额变动主键
* @return 结果
*/
@Override
public int deleteAiGroupBalanceChangeRecordByIds(String[] ids)
{
return aiGroupBalanceChangeRecordMapper.deleteBatchIds(java.util.Arrays.asList(ids));
}
/**
* 删除团队部门余额变动信息
*
* @param id 团队部门余额变动主键
* @return 结果
*/
@Override
public int deleteAiGroupBalanceChangeRecordById(String id)
{
return aiGroupBalanceChangeRecordMapper.deleteById(id);
}
} }

View File

@ -164,6 +164,7 @@ public class AiUserServiceImpl implements IAiUserService {
aiUser.setDelFlag("0"); aiUser.setDelFlag("0");
aiUser.setCreateBy(SecurityUtils.getUsername()); aiUser.setCreateBy(SecurityUtils.getUsername());
aiUser.setCreateTime(DateUtils.getNowDate()); aiUser.setCreateTime(DateUtils.getNowDate());
aiUser.setBalance(null);
return aiUserMapper.insert(aiUser); return aiUserMapper.insert(aiUser);
} }
@ -192,6 +193,7 @@ public class AiUserServiceImpl implements IAiUserService {
} else { } else {
aiUser.setPassword(null); aiUser.setPassword(null);
} }
aiUser.setBalance(old != null ? old.getBalance() : null);
return aiUserMapper.updateById(aiUser); return aiUserMapper.updateById(aiUser);
} }

View File

@ -6,6 +6,7 @@ import java.text.SimpleDateFormat;
import java.util.Date; import java.util.Date;
import java.util.UUID; import java.util.UUID;
import com.ruoyi.ai.mapper.AiGroupBalanceChangeRecordMapper;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
@ -13,7 +14,6 @@ import org.springframework.transaction.annotation.Transactional;
import com.ruoyi.ai.domain.AiChargeRefundOrder; import com.ruoyi.ai.domain.AiChargeRefundOrder;
import com.ruoyi.ai.domain.AiGroupBalanceChangeRecord; import com.ruoyi.ai.domain.AiGroupBalanceChangeRecord;
import com.ruoyi.ai.service.IAiChargeRefundOrderService; import com.ruoyi.ai.service.IAiChargeRefundOrderService;
import com.ruoyi.ai.service.IAiGroupBalanceChangeRecordService;
import com.ruoyi.ai.service.IDeptChargeRefundService; import com.ruoyi.ai.service.IDeptChargeRefundService;
import com.ruoyi.common.core.domain.entity.SysDept; import com.ruoyi.common.core.domain.entity.SysDept;
import com.ruoyi.common.core.request.system.DeptChargeRefundRequest; import com.ruoyi.common.core.request.system.DeptChargeRefundRequest;
@ -41,7 +41,7 @@ public class DeptChargeRefundServiceImpl implements IDeptChargeRefundService {
private IAiChargeRefundOrderService aiChargeRefundOrderService; private IAiChargeRefundOrderService aiChargeRefundOrderService;
@Autowired @Autowired
private IAiGroupBalanceChangeRecordService aiGroupBalanceChangeRecordService; private AiGroupBalanceChangeRecordMapper aiGroupBalanceChangeRecordMapper;
@Override @Override
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
@ -59,12 +59,12 @@ public class DeptChargeRefundServiceImpl implements IDeptChargeRefundService {
// 1) 手工入账订单状态直接为已完成 // 1) 手工入账订单状态直接为已完成
AiChargeRefundOrder order = new AiChargeRefundOrder(); AiChargeRefundOrder order = new AiChargeRefundOrder();
order.setDelFlag("0"); order.setDelFlag("0");
order.setCreateBy(SecurityUtils.getUsername()); order.setCreateBy(SecurityUtils.getUserId());
order.setCreateTime(now); order.setCreateTime(now);
order.setUpdateTime(now); order.setUpdateTime(now);
order.setOrderNum(orderNum); order.setOrderNum(orderNum);
order.setDeptId(request.getDeptId()); order.setDeptId(request.getDeptId());
order.setOrderType(Long.valueOf(request.getOrderType())); order.setOrderType(request.getOrderType());
// 金额两位小数向零截断非四舍五入避免入账金额被抬高 // 金额两位小数向零截断非四舍五入避免入账金额被抬高
order.setMoney(request.getMoney().setScale(2, RoundingMode.DOWN)); order.setMoney(request.getMoney().setScale(2, RoundingMode.DOWN));
order.setAmount(amountBd); order.setAmount(amountBd);
@ -82,7 +82,7 @@ public class DeptChargeRefundServiceImpl implements IDeptChargeRefundService {
} }
if (rows == 0) { if (rows == 0) {
if (orderType == ChargeRefundOrderType.REFUND) { if (orderType == ChargeRefundOrderType.REFUND) {
throw new ServiceException("余额不足或部门不存在"); throw new ServiceException("剩余积分不足");
} }
throw new ServiceException("部门不存在或已删除"); throw new ServiceException("部门不存在或已删除");
} }
@ -101,16 +101,15 @@ public class DeptChargeRefundServiceImpl implements IDeptChargeRefundService {
record.setRelationOrderNo(orderNum); record.setRelationOrderNo(orderNum);
record.setDeptId(request.getDeptId()); record.setDeptId(request.getDeptId());
record.setType(orderType == ChargeRefundOrderType.CHARGE record.setType(orderType == ChargeRefundOrderType.CHARGE
? Long.valueOf(GroupBalanceChangeType.RECHARGE.getCode()) ? GroupBalanceChangeType.RECHARGE.getCode()
: Long.valueOf(GroupBalanceChangeType.REFUND.getCode())); : GroupBalanceChangeType.REFUND.getCode());
record.setChangeAmount(signedChange); record.setChangeAmount(signedChange);
record.setResultAmount(dept.getBalance()); record.setResultAmount(dept.getBalance());
record.setRemark(request.getRemark()); record.setRemark(request.getRemark());
record.setCreateBy(SecurityUtils.getUsername());
record.setCreateTime(now); record.setCreateTime(now);
record.setUpdateTime(now); record.setUpdateTime(now);
aiGroupBalanceChangeRecordService.insertAiGroupBalanceChangeRecord(record); aiGroupBalanceChangeRecordMapper.insert(record);
} }
/** 业务单号前缀 + 日序 + 随机后缀,保证与流水 relation_order_no 一致。 */ /** 业务单号前缀 + 日序 + 随机后缀,保证与流水 relation_order_no 一致。 */

View File

@ -5,13 +5,13 @@ import java.text.SimpleDateFormat;
import java.util.Date; import java.util.Date;
import java.util.UUID; import java.util.UUID;
import com.ruoyi.ai.mapper.AiGroupBalanceChangeRecordMapper;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import com.ruoyi.ai.domain.AiGroupBalanceChangeRecord; import com.ruoyi.ai.domain.AiGroupBalanceChangeRecord;
import com.ruoyi.ai.mapper.AiOrderMapper; import com.ruoyi.ai.mapper.AiOrderMapper;
import com.ruoyi.ai.service.IAiGroupBalanceChangeRecordService;
import com.ruoyi.ai.service.IAiUserService; import com.ruoyi.ai.service.IAiUserService;
import com.ruoyi.common.constant.BalanceChangerConstants; import com.ruoyi.common.constant.BalanceChangerConstants;
import com.ruoyi.common.core.domain.entity.AiUser; import com.ruoyi.common.core.domain.entity.AiUser;
@ -19,7 +19,6 @@ import com.ruoyi.common.core.domain.entity.SysDept;
import com.ruoyi.common.core.request.ai.AiUserDeptScoreRequest; import com.ruoyi.common.core.request.ai.AiUserDeptScoreRequest;
import com.ruoyi.common.enums.GroupBalanceChangeType; import com.ruoyi.common.enums.GroupBalanceChangeType;
import com.ruoyi.common.exception.ServiceException; import com.ruoyi.common.exception.ServiceException;
import com.ruoyi.common.utils.SecurityUtils;
import com.ruoyi.common.utils.StringUtils; import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.system.service.ISysDeptService; import com.ruoyi.system.service.ISysDeptService;
@ -35,11 +34,10 @@ public class DeptUserScoreTransferTxService {
@Autowired @Autowired
private IAiUserService aiUserService; private IAiUserService aiUserService;
@Autowired
private IAiGroupBalanceChangeRecordService aiGroupBalanceChangeRecordService;
@Autowired @Autowired
private AiOrderMapper aiOrderMapper; private AiOrderMapper aiOrderMapper;
@Autowired
private AiGroupBalanceChangeRecordMapper aiGroupBalanceChangeRecordMapper;
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
public void transferIssue(AiUserDeptScoreRequest request) { public void transferIssue(AiUserDeptScoreRequest request) {
@ -109,7 +107,7 @@ public class DeptUserScoreTransferTxService {
if (amount == null || amount < 1) { if (amount == null || amount < 1) {
throw new ServiceException("积分必须为正整数"); throw new ServiceException("积分必须为正整数");
} }
return BigDecimal.valueOf(amount.longValue()); return BigDecimal.valueOf(amount);
} }
private String buildRemark(String input, String defaultPrefix) { private String buildRemark(String input, String defaultPrefix) {
@ -132,12 +130,11 @@ public class DeptUserScoreTransferTxService {
AiGroupBalanceChangeRecord record = new AiGroupBalanceChangeRecord(); AiGroupBalanceChangeRecord record = new AiGroupBalanceChangeRecord();
record.setRelationOrderNo(orderNum); record.setRelationOrderNo(orderNum);
record.setDeptId(deptId); record.setDeptId(deptId);
record.setType(Long.valueOf(type)); record.setType(type);
record.setChangeAmount(signedChange); record.setChangeAmount(signedChange);
record.setResultAmount(resultBalance); record.setResultAmount(resultBalance);
record.setRemark(remark); record.setRemark(remark);
record.setCreateBy(SecurityUtils.getUsername()); aiGroupBalanceChangeRecordMapper.insert(record);
aiGroupBalanceChangeRecordService.insertAiGroupBalanceChangeRecord(record);
} }
private static String buildOrderNum() { private static String buildOrderNum() {

View File

@ -1,19 +1,8 @@
package com.ruoyi.system.service.impl; package com.ruoyi.system.service.impl;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.Date;
import java.util.Iterator;
import java.util.List;
import java.util.Objects;
import java.util.stream.Collectors;
import com.ruoyi.ai.domain.AiGroupBalanceChangeRecord; import com.ruoyi.ai.domain.AiGroupBalanceChangeRecord;
import com.ruoyi.ai.mapper.AiGroupBalanceChangeRecordMapper;
import com.ruoyi.ai.service.IAiDeptArkConfigService; import com.ruoyi.ai.service.IAiDeptArkConfigService;
import com.ruoyi.ai.service.IAiGroupBalanceChangeRecordService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import com.ruoyi.common.annotation.DataScope; import com.ruoyi.common.annotation.DataScope;
import com.ruoyi.common.constant.UserConstants; import com.ruoyi.common.constant.UserConstants;
import com.ruoyi.common.core.domain.TreeSelect; import com.ruoyi.common.core.domain.TreeSelect;
@ -24,7 +13,6 @@ import com.ruoyi.common.core.request.system.DeptPointsCorrectionRequest;
import com.ruoyi.common.core.text.Convert; import com.ruoyi.common.core.text.Convert;
import com.ruoyi.common.enums.GroupBalanceChangeType; import com.ruoyi.common.enums.GroupBalanceChangeType;
import com.ruoyi.common.exception.ServiceException; import com.ruoyi.common.exception.ServiceException;
import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.common.utils.SecurityUtils; import com.ruoyi.common.utils.SecurityUtils;
import com.ruoyi.common.utils.StringUtils; import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.common.utils.spring.SpringUtils; import com.ruoyi.common.utils.spring.SpringUtils;
@ -32,15 +20,24 @@ import com.ruoyi.system.mapper.SysDeptMapper;
import com.ruoyi.system.mapper.SysRoleMapper; import com.ruoyi.system.mapper.SysRoleMapper;
import com.ruoyi.system.mapper.SysUserMapper; import com.ruoyi.system.mapper.SysUserMapper;
import com.ruoyi.system.service.ISysDeptService; import com.ruoyi.system.service.ISysDeptService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import java.util.Objects;
import java.util.stream.Collectors;
/** /**
* 部门管理 服务实现 * 部门管理 服务实现
* *
* @author ruoyi * @author ruoyi
*/ */
@Service @Service
public class SysDeptServiceImpl implements ISysDeptService public class SysDeptServiceImpl implements ISysDeptService {
{
@Autowired @Autowired
private SysDeptMapper deptMapper; private SysDeptMapper deptMapper;
@ -50,60 +47,53 @@ public class SysDeptServiceImpl implements ISysDeptService
@Autowired @Autowired
private SysUserMapper userMapper; private SysUserMapper userMapper;
@Autowired
private IAiGroupBalanceChangeRecordService aiGroupBalanceChangeRecordService;
@Autowired @Autowired
private IAiDeptArkConfigService aiDeptArkConfigService; private IAiDeptArkConfigService aiDeptArkConfigService;
@Autowired
private AiGroupBalanceChangeRecordMapper aiGroupBalanceChangeRecordMapper;
/** /**
* 查询部门管理数据 * 查询部门管理数据
* *
* @param dept 部门信息 * @param dept 部门信息
* @return 部门信息集合 * @return 部门信息集合
*/ */
@Override @Override
@DataScope(deptAlias = "d") @DataScope(deptAlias = "d")
public List<SysDept> selectDeptList(SysDept dept) public List<SysDept> selectDeptList(SysDept dept) {
{
return deptMapper.selectDeptList(dept); return deptMapper.selectDeptList(dept);
} }
/** /**
* 查询部门树结构信息 * 查询部门树结构信息
* *
* @param dept 部门信息 * @param dept 部门信息
* @return 部门树信息集合 * @return 部门树信息集合
*/ */
@Override @Override
public List<TreeSelect> selectDeptTreeList(SysDept dept) public List<TreeSelect> selectDeptTreeList(SysDept dept) {
{
List<SysDept> depts = SpringUtils.getAopProxy(this).selectDeptList(dept); List<SysDept> depts = SpringUtils.getAopProxy(this).selectDeptList(dept);
return buildDeptTreeSelect(depts); return buildDeptTreeSelect(depts);
} }
/** /**
* 构建前端所需要树结构 * 构建前端所需要树结构
* *
* @param depts 部门列表 * @param depts 部门列表
* @return 树结构列表 * @return 树结构列表
*/ */
@Override @Override
public List<SysDept> buildDeptTree(List<SysDept> depts) public List<SysDept> buildDeptTree(List<SysDept> depts) {
{
List<SysDept> returnList = new ArrayList<SysDept>(); List<SysDept> returnList = new ArrayList<SysDept>();
List<Long> tempList = depts.stream().map(SysDept::getDeptId).collect(Collectors.toList()); List<Long> tempList = depts.stream().map(SysDept::getDeptId).collect(Collectors.toList());
for (SysDept dept : depts) for (SysDept dept : depts) {
{
// 如果是顶级节点, 遍历该父节点的所有子节点 // 如果是顶级节点, 遍历该父节点的所有子节点
if (!tempList.contains(dept.getParentId())) if (!tempList.contains(dept.getParentId())) {
{
recursionFn(depts, dept); recursionFn(depts, dept);
returnList.add(dept); returnList.add(dept);
} }
} }
if (returnList.isEmpty()) if (returnList.isEmpty()) {
{
returnList = depts; returnList = depts;
} }
return returnList; return returnList;
@ -111,93 +101,85 @@ public class SysDeptServiceImpl implements ISysDeptService
/** /**
* 构建前端所需要下拉树结构 * 构建前端所需要下拉树结构
* *
* @param depts 部门列表 * @param depts 部门列表
* @return 下拉树结构列表 * @return 下拉树结构列表
*/ */
@Override @Override
public List<TreeSelect> buildDeptTreeSelect(List<SysDept> depts) public List<TreeSelect> buildDeptTreeSelect(List<SysDept> depts) {
{
List<SysDept> deptTrees = buildDeptTree(depts); List<SysDept> deptTrees = buildDeptTree(depts);
return deptTrees.stream().map(TreeSelect::new).collect(Collectors.toList()); return deptTrees.stream().map(TreeSelect::new).collect(Collectors.toList());
} }
/** /**
* 根据角色ID查询部门树信息 * 根据角色ID查询部门树信息
* *
* @param roleId 角色ID * @param roleId 角色ID
* @return 选中部门列表 * @return 选中部门列表
*/ */
@Override @Override
public List<Long> selectDeptListByRoleId(Long roleId) public List<Long> selectDeptListByRoleId(Long roleId) {
{
SysRole role = roleMapper.selectRoleById(roleId); SysRole role = roleMapper.selectRoleById(roleId);
return deptMapper.selectDeptListByRoleId(roleId, role.isDeptCheckStrictly()); return deptMapper.selectDeptListByRoleId(roleId, role.isDeptCheckStrictly());
} }
/** /**
* 根据部门ID查询信息 * 根据部门ID查询信息
* *
* @param deptId 部门ID * @param deptId 部门ID
* @return 部门信息 * @return 部门信息
*/ */
@Override @Override
public SysDept selectDeptById(Long deptId) public SysDept selectDeptById(Long deptId) {
{
return deptMapper.selectDeptById(deptId); return deptMapper.selectDeptById(deptId);
} }
/** /**
* 根据ID查询所有子部门正常状态 * 根据ID查询所有子部门正常状态
* *
* @param deptId 部门ID * @param deptId 部门ID
* @return 子部门数 * @return 子部门数
*/ */
@Override @Override
public int selectNormalChildrenDeptById(Long deptId) public int selectNormalChildrenDeptById(Long deptId) {
{
return deptMapper.selectNormalChildrenDeptById(deptId); return deptMapper.selectNormalChildrenDeptById(deptId);
} }
/** /**
* 是否存在子节点 * 是否存在子节点
* *
* @param deptId 部门ID * @param deptId 部门ID
* @return 结果 * @return 结果
*/ */
@Override @Override
public boolean hasChildByDeptId(Long deptId) public boolean hasChildByDeptId(Long deptId) {
{
int result = deptMapper.hasChildByDeptId(deptId); int result = deptMapper.hasChildByDeptId(deptId);
return result > 0; return result > 0;
} }
/** /**
* 查询部门是否存在用户 * 查询部门是否存在用户
* *
* @param deptId 部门ID * @param deptId 部门ID
* @return 结果 true 存在 false 不存在 * @return 结果 true 存在 false 不存在
*/ */
@Override @Override
public boolean checkDeptExistUser(Long deptId) public boolean checkDeptExistUser(Long deptId) {
{
int result = deptMapper.checkDeptExistUser(deptId); int result = deptMapper.checkDeptExistUser(deptId);
return result > 0; return result > 0;
} }
/** /**
* 校验部门名称是否唯一 * 校验部门名称是否唯一
* *
* @param dept 部门信息 * @param dept 部门信息
* @return 结果 * @return 结果
*/ */
@Override @Override
public boolean checkDeptNameUnique(SysDept dept) public boolean checkDeptNameUnique(SysDept dept) {
{
Long deptId = StringUtils.isNull(dept.getDeptId()) ? -1L : dept.getDeptId(); Long deptId = StringUtils.isNull(dept.getDeptId()) ? -1L : dept.getDeptId();
SysDept info = deptMapper.checkDeptNameUnique(dept.getDeptName(), dept.getParentId()); SysDept info = deptMapper.checkDeptNameUnique(dept.getDeptName(), dept.getParentId());
if (StringUtils.isNotNull(info) && info.getDeptId().longValue() != deptId.longValue()) if (StringUtils.isNotNull(info) && info.getDeptId().longValue() != deptId.longValue()) {
{
return UserConstants.NOT_UNIQUE; return UserConstants.NOT_UNIQUE;
} }
return UserConstants.UNIQUE; return UserConstants.UNIQUE;
@ -205,19 +187,16 @@ public class SysDeptServiceImpl implements ISysDeptService
/** /**
* 校验部门是否有数据权限 * 校验部门是否有数据权限
* *
* @param deptId 部门id * @param deptId 部门id
*/ */
@Override @Override
public void checkDeptDataScope(Long deptId) public void checkDeptDataScope(Long deptId) {
{ if (!SysUser.isAdmin(SecurityUtils.getUserId()) && StringUtils.isNotNull(deptId)) {
if (!SysUser.isAdmin(SecurityUtils.getUserId()) && StringUtils.isNotNull(deptId))
{
SysDept dept = new SysDept(); SysDept dept = new SysDept();
dept.setDeptId(deptId); dept.setDeptId(deptId);
List<SysDept> depts = SpringUtils.getAopProxy(this).selectDeptList(dept); List<SysDept> depts = SpringUtils.getAopProxy(this).selectDeptList(dept);
if (StringUtils.isEmpty(depts)) if (StringUtils.isEmpty(depts)) {
{
throw new ServiceException("没有权限访问部门数据!"); throw new ServiceException("没有权限访问部门数据!");
} }
} }
@ -225,21 +204,18 @@ public class SysDeptServiceImpl implements ISysDeptService
/** /**
* 新增保存部门信息 * 新增保存部门信息
* *
* @param dept 部门信息 * @param dept 部门信息
* @return 结果 * @return 结果
*/ */
@Override @Override
public int insertDept(SysDept dept) public int insertDept(SysDept dept) {
{
SysDept info = deptMapper.selectDeptById(dept.getParentId()); SysDept info = deptMapper.selectDeptById(dept.getParentId());
if (!isFirstLevelDept(info)) if (!isFirstLevelDept(info)) {
{
throw new ServiceException("仅允许在一级部门下创建二级部门"); throw new ServiceException("仅允许在一级部门下创建二级部门");
} }
// 如果父节点不为正常状态,则不允许新增子节点 // 如果父节点不为正常状态,则不允许新增子节点
if (!UserConstants.DEPT_NORMAL.equals(info.getStatus())) if (!UserConstants.DEPT_NORMAL.equals(info.getStatus())) {
{
throw new ServiceException("部门停用,不允许新增"); throw new ServiceException("部门停用,不允许新增");
} }
dept.setAncestors(info.getAncestors() + "," + dept.getParentId()); dept.setAncestors(info.getAncestors() + "," + dept.getParentId());
@ -248,23 +224,20 @@ public class SysDeptServiceImpl implements ISysDeptService
/** /**
* 修改保存部门信息 * 修改保存部门信息
* *
* @param dept 部门信息 * @param dept 部门信息
* @return 结果 * @return 结果
*/ */
@Override @Override
public int updateDept(SysDept dept) public int updateDept(SysDept dept) {
{
SysDept newParentDept = deptMapper.selectDeptById(dept.getParentId()); SysDept newParentDept = deptMapper.selectDeptById(dept.getParentId());
SysDept oldDept = deptMapper.selectDeptById(dept.getDeptId()); SysDept oldDept = deptMapper.selectDeptById(dept.getDeptId());
if (StringUtils.isNull(oldDept)) if (StringUtils.isNull(oldDept)) {
{
throw new ServiceException("部门不存在"); throw new ServiceException("部门不存在");
} }
validateDeptUpdateConstraint(dept, oldDept, newParentDept); validateDeptUpdateConstraint(dept, oldDept, newParentDept);
validateDeptMaxUserCountFloor(dept, oldDept); validateDeptMaxUserCountFloor(dept, oldDept);
if (StringUtils.isNotNull(newParentDept) && StringUtils.isNotNull(oldDept)) if (StringUtils.isNotNull(newParentDept) && StringUtils.isNotNull(oldDept)) {
{
String newAncestors = newParentDept.getAncestors() + "," + newParentDept.getDeptId(); String newAncestors = newParentDept.getAncestors() + "," + newParentDept.getDeptId();
String oldAncestors = oldDept.getAncestors(); String oldAncestors = oldDept.getAncestors();
dept.setAncestors(newAncestors); dept.setAncestors(newAncestors);
@ -272,8 +245,7 @@ public class SysDeptServiceImpl implements ISysDeptService
} }
int result = deptMapper.updateDept(dept); int result = deptMapper.updateDept(dept);
if (UserConstants.DEPT_NORMAL.equals(dept.getStatus()) && StringUtils.isNotEmpty(dept.getAncestors()) if (UserConstants.DEPT_NORMAL.equals(dept.getStatus()) && StringUtils.isNotEmpty(dept.getAncestors())
&& !StringUtils.equals("0", dept.getAncestors())) && !StringUtils.equals("0", dept.getAncestors())) {
{
// 如果该部门是启用状态则启用该部门的所有上级部门 // 如果该部门是启用状态则启用该部门的所有上级部门
updateParentDeptStatusNormal(dept); updateParentDeptStatusNormal(dept);
} }
@ -282,11 +254,10 @@ public class SysDeptServiceImpl implements ISysDeptService
/** /**
* 修改该部门的父级部门状态 * 修改该部门的父级部门状态
* *
* @param dept 当前部门 * @param dept 当前部门
*/ */
private void updateParentDeptStatusNormal(SysDept dept) private void updateParentDeptStatusNormal(SysDept dept) {
{
String ancestors = dept.getAncestors(); String ancestors = dept.getAncestors();
Long[] deptIds = Convert.toLongArray(ancestors); Long[] deptIds = Convert.toLongArray(ancestors);
deptMapper.updateDeptStatusNormal(deptIds); deptMapper.updateDeptStatusNormal(deptIds);
@ -295,68 +266,57 @@ public class SysDeptServiceImpl implements ISysDeptService
/** /**
* 账号上限调低时不能小于当前启用中用户数max_user_count 为空或0 表示不限制 * 账号上限调低时不能小于当前启用中用户数max_user_count 为空或0 表示不限制
*/ */
private void validateDeptMaxUserCountFloor(SysDept incoming, SysDept oldDept) private void validateDeptMaxUserCountFloor(SysDept incoming, SysDept oldDept) {
{
Integer newMax = incoming.getMaxUserCount() != null ? incoming.getMaxUserCount() : oldDept.getMaxUserCount(); Integer newMax = incoming.getMaxUserCount() != null ? incoming.getMaxUserCount() : oldDept.getMaxUserCount();
if (newMax == null || newMax <= 0) if (newMax == null || newMax <= 0) {
{
return; return;
} }
int enabledCnt = userMapper.countNormalUsersByDeptId(incoming.getDeptId(), null); int enabledCnt = userMapper.countNormalUsersByDeptId(incoming.getDeptId(), null);
if (enabledCnt > newMax) if (enabledCnt > newMax) {
{
throw new ServiceException(String.format("该团队当前启用中账号共 %d 个,账号上限不能小于该数量", enabledCnt)); throw new ServiceException(String.format("该团队当前启用中账号共 %d 个,账号上限不能小于该数量", enabledCnt));
} }
} }
/** /**
* 修改子元素关系 * 修改子元素关系
* *
* @param deptId 被修改的部门ID * @param deptId 被修改的部门ID
* @param newAncestors 新的父ID集合 * @param newAncestors 新的父ID集合
* @param oldAncestors 旧的父ID集合 * @param oldAncestors 旧的父ID集合
*/ */
public void updateDeptChildren(Long deptId, String newAncestors, String oldAncestors) public void updateDeptChildren(Long deptId, String newAncestors, String oldAncestors) {
{
List<SysDept> children = deptMapper.selectChildrenDeptById(deptId); List<SysDept> children = deptMapper.selectChildrenDeptById(deptId);
for (SysDept child : children) for (SysDept child : children) {
{
child.setAncestors(child.getAncestors().replaceFirst(oldAncestors, newAncestors)); child.setAncestors(child.getAncestors().replaceFirst(oldAncestors, newAncestors));
} }
if (children.size() > 0) if (children.size() > 0) {
{
deptMapper.updateDeptChildren(children); deptMapper.updateDeptChildren(children);
} }
} }
/** /**
* 删除部门管理信息 * 删除部门管理信息
* *
* @param deptId 部门ID * @param deptId 部门ID
* @return 结果 * @return 结果
*/ */
@Override @Override
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
public int deleteDeptById(Long deptId) public int deleteDeptById(Long deptId) {
{
int rows = deptMapper.deleteDeptById(deptId); int rows = deptMapper.deleteDeptById(deptId);
if (rows > 0) if (rows > 0) {
{
aiDeptArkConfigService.deleteByDeptId(deptId); aiDeptArkConfigService.deleteByDeptId(deptId);
} }
return rows; return rows;
} }
@Override @Override
public boolean isArkConfigurableDept(Long deptId) public boolean isArkConfigurableDept(Long deptId) {
{ if (deptId == null) {
if (deptId == null)
{
return false; return false;
} }
SysDept d = deptMapper.selectDeptById(deptId); SysDept d = deptMapper.selectDeptById(deptId);
if (d == null) if (d == null) {
{
return false; return false;
} }
return isFirstLevelDept(d) || isSecondLevelDept(d); return isFirstLevelDept(d) || isSecondLevelDept(d);
@ -368,52 +328,46 @@ public class SysDeptServiceImpl implements ISysDeptService
return maxOrder != null ? maxOrder : 1; return maxOrder != null ? maxOrder : 1;
} }
/** 委托 Mapper 原子更新 {@code sys_dept.balance}(充值)。 */ /**
* 委托 Mapper 原子更新 {@code sys_dept.balance}充值
*/
@Override @Override
public int addDeptBalance(Long deptId, BigDecimal amount) public int addDeptBalance(Long deptId, BigDecimal amount) {
{
return deptMapper.addDeptBalance(deptId, amount); return deptMapper.addDeptBalance(deptId, amount);
} }
/** 委托 Mapper 原子更新 {@code sys_dept.balance}(退款,防透支)。 */ /**
* 委托 Mapper 原子更新 {@code sys_dept.balance}退款防透支
*/
@Override @Override
public int subtractDeptBalance(Long deptId, BigDecimal amount) public int subtractDeptBalance(Long deptId, BigDecimal amount) {
{
return deptMapper.subtractDeptBalance(deptId, amount); return deptMapper.subtractDeptBalance(deptId, amount);
} }
@Override @Override
@Transactional(rollbackFor = Exception.class) @Transactional(rollbackFor = Exception.class)
public void editScore(DeptPointsCorrectionRequest request) public void editScore(DeptPointsCorrectionRequest request) {
{
Long score = request.getScore(); Long score = request.getScore();
if (score == null || score == 0L) if (score == null || score == 0L) {
{
throw new ServiceException("积分不能为0"); throw new ServiceException("积分不能为0");
} }
SysDept dept = selectDeptById(request.getDeptId()); SysDept dept = selectDeptById(request.getDeptId());
if (dept == null) if (dept == null) {
{
throw new ServiceException("部门不存在"); throw new ServiceException("部门不存在");
} }
BigDecimal delta = BigDecimal.valueOf(score); BigDecimal delta = BigDecimal.valueOf(score);
int rows; int rows;
if (delta.signum() > 0) if (delta.signum() > 0) {
{
rows = addDeptBalance(request.getDeptId(), delta); rows = addDeptBalance(request.getDeptId(), delta);
} } else {
else
{
rows = subtractDeptBalance(request.getDeptId(), delta.abs()); rows = subtractDeptBalance(request.getDeptId(), delta.abs());
} }
if (rows == 0) if (rows == 0) {
{ if (delta.signum() < 0) {
if (delta.signum() < 0) throw new ServiceException("剩余积分不足");
{
throw new ServiceException("余额不足或部门不存在");
} }
throw new ServiceException("部门不存在或已删除"); throw new ServiceException("部门不存在或已删除");
} }
@ -421,27 +375,22 @@ public class SysDeptServiceImpl implements ISysDeptService
AiGroupBalanceChangeRecord record = new AiGroupBalanceChangeRecord(); AiGroupBalanceChangeRecord record = new AiGroupBalanceChangeRecord();
record.setRelationOrderNo(null); record.setRelationOrderNo(null);
record.setDeptId(request.getDeptId()); record.setDeptId(request.getDeptId());
record.setType(Long.valueOf(GroupBalanceChangeType.MANUAL_ADJUST.getCode())); record.setType(GroupBalanceChangeType.MANUAL_ADJUST.getCode());
record.setChangeAmount(delta); record.setChangeAmount(delta);
record.setResultAmount(dept.getBalance()); record.setResultAmount(dept.getBalance());
record.setRemark(request.getRemark()); record.setRemark(request.getRemark());
record.setCreateBy(SecurityUtils.getUsername()); aiGroupBalanceChangeRecordMapper.insert(record);
aiGroupBalanceChangeRecordService.insertAiGroupBalanceChangeRecord(record);
} }
/** /**
* 递归列表 * 递归列表
*/ */
private void recursionFn(List<SysDept> list, SysDept t) private void recursionFn(List<SysDept> list, SysDept t) {
{
// 得到子节点列表 // 得到子节点列表
List<SysDept> childList = getChildList(list, t); List<SysDept> childList = getChildList(list, t);
t.setChildren(childList); t.setChildren(childList);
for (SysDept tChild : childList) for (SysDept tChild : childList) {
{ if (hasChild(list, tChild)) {
if (hasChild(list, tChild))
{
recursionFn(list, tChild); recursionFn(list, tChild);
} }
} }
@ -450,15 +399,12 @@ public class SysDeptServiceImpl implements ISysDeptService
/** /**
* 得到子节点列表 * 得到子节点列表
*/ */
private List<SysDept> getChildList(List<SysDept> list, SysDept t) private List<SysDept> getChildList(List<SysDept> list, SysDept t) {
{
List<SysDept> tlist = new ArrayList<SysDept>(); List<SysDept> tlist = new ArrayList<SysDept>();
Iterator<SysDept> it = list.iterator(); Iterator<SysDept> it = list.iterator();
while (it.hasNext()) while (it.hasNext()) {
{
SysDept n = (SysDept) it.next(); SysDept n = (SysDept) it.next();
if (StringUtils.isNotNull(n.getParentId()) && n.getParentId().longValue() == t.getDeptId().longValue()) if (StringUtils.isNotNull(n.getParentId()) && n.getParentId().longValue() == t.getDeptId().longValue()) {
{
tlist.add(n); tlist.add(n);
} }
} }
@ -468,29 +414,24 @@ public class SysDeptServiceImpl implements ISysDeptService
/** /**
* 判断是否有子节点 * 判断是否有子节点
*/ */
private boolean hasChild(List<SysDept> list, SysDept t) private boolean hasChild(List<SysDept> list, SysDept t) {
{
return getChildList(list, t).size() > 0; return getChildList(list, t).size() > 0;
} }
/** /**
* 约束仅允许创建/更新二级部门一级部门仅允许修改名称 * 约束仅允许创建/更新二级部门一级部门仅允许修改名称
* *
* @param newDept 前端提交的新部门参数 * @param newDept 前端提交的新部门参数
* @param oldDept 数据库中的原部门数据 * @param oldDept 数据库中的原部门数据
* @param newParentDept 修改后的父部门 * @param newParentDept 修改后的父部门
*/ */
private void validateDeptUpdateConstraint(SysDept newDept, SysDept oldDept, SysDept newParentDept) private void validateDeptUpdateConstraint(SysDept newDept, SysDept oldDept, SysDept newParentDept) {
{ if (isFirstLevelDept(oldDept)) {
if (isFirstLevelDept(oldDept))
{
validateFirstLevelDeptOnlyRename(newDept, oldDept); validateFirstLevelDeptOnlyRename(newDept, oldDept);
return; return;
} }
if (isSecondLevelDept(oldDept)) if (isSecondLevelDept(oldDept)) {
{ if (!isFirstLevelDept(newParentDept)) {
if (!isFirstLevelDept(newParentDept))
{
throw new ServiceException("仅允许更新二级部门,且其上级必须为一级部门"); throw new ServiceException("仅允许更新二级部门,且其上级必须为一级部门");
} }
return; return;
@ -504,8 +445,7 @@ public class SysDeptServiceImpl implements ISysDeptService
* @param newDept 前端提交的新部门参数 * @param newDept 前端提交的新部门参数
* @param oldDept 数据库中的原部门数据 * @param oldDept 数据库中的原部门数据
*/ */
private void validateFirstLevelDeptOnlyRename(SysDept newDept, SysDept oldDept) private void validateFirstLevelDeptOnlyRename(SysDept newDept, SysDept oldDept) {
{
if (!Objects.equals(newDept.getParentId(), oldDept.getParentId()) if (!Objects.equals(newDept.getParentId(), oldDept.getParentId())
|| !Objects.equals(newDept.getOrderNum(), oldDept.getOrderNum()) || !Objects.equals(newDept.getOrderNum(), oldDept.getOrderNum())
|| !Objects.equals(newDept.getLeader(), oldDept.getLeader()) || !Objects.equals(newDept.getLeader(), oldDept.getLeader())
@ -513,8 +453,7 @@ public class SysDeptServiceImpl implements ISysDeptService
|| !Objects.equals(newDept.getEmail(), oldDept.getEmail()) || !Objects.equals(newDept.getEmail(), oldDept.getEmail())
|| !Objects.equals(newDept.getStatus(), oldDept.getStatus()) || !Objects.equals(newDept.getStatus(), oldDept.getStatus())
|| !Objects.equals(newDept.getMaxUserCount(), oldDept.getMaxUserCount()) || !Objects.equals(newDept.getMaxUserCount(), oldDept.getMaxUserCount())
|| !Objects.equals(newDept.getBalance(), oldDept.getBalance())) || !Objects.equals(newDept.getBalance(), oldDept.getBalance())) {
{
throw new ServiceException("一级部门仅允许修改名称"); throw new ServiceException("一级部门仅允许修改名称");
} }
newDept.setAncestors(oldDept.getAncestors()); newDept.setAncestors(oldDept.getAncestors());
@ -526,8 +465,7 @@ public class SysDeptServiceImpl implements ISysDeptService
* @param dept 部门信息 * @param dept 部门信息
* @return true-一级部门false-非一级部门 * @return true-一级部门false-非一级部门
*/ */
private boolean isFirstLevelDept(SysDept dept) private boolean isFirstLevelDept(SysDept dept) {
{
return StringUtils.isNotNull(dept) return StringUtils.isNotNull(dept)
&& Objects.equals(0L, dept.getParentId()) && Objects.equals(0L, dept.getParentId())
&& "0".equals(dept.getAncestors()); && "0".equals(dept.getAncestors());
@ -539,10 +477,8 @@ public class SysDeptServiceImpl implements ISysDeptService
* @param dept 部门信息 * @param dept 部门信息
* @return true-二级部门false-非二级部门 * @return true-二级部门false-非二级部门
*/ */
private boolean isSecondLevelDept(SysDept dept) private boolean isSecondLevelDept(SysDept dept) {
{ if (StringUtils.isNull(dept) || StringUtils.isBlank(dept.getAncestors()) || StringUtils.isNull(dept.getParentId())) {
if (StringUtils.isNull(dept) || StringUtils.isBlank(dept.getAncestors()) || StringUtils.isNull(dept.getParentId()))
{
return false; return false;
} }
return Objects.equals(2, StringUtils.split(dept.getAncestors(), ",").length); return Objects.equals(2, StringUtils.split(dept.getAncestors(), ",").length);

View File

@ -18,7 +18,7 @@ public interface ISubteamScopeService {
void assertChargeRefundBelongsToTeam(Long orderPkId); void assertChargeRefundBelongsToTeam(Long orderPkId);
void assertGroupBalanceRecordBelongsToTeam(String recordId); void assertGroupBalanceRecordBelongsToTeam(Long recordId);
void assertAiBalanceRecordVisible(Long recordId, Long teamDeptId); void assertAiBalanceRecordVisible(Long recordId, Long teamDeptId);
} }

View File

@ -85,7 +85,7 @@ public class SubteamScopeServiceImpl implements ISubteamScopeService {
} }
@Override @Override
public void assertGroupBalanceRecordBelongsToTeam(String recordId) { public void assertGroupBalanceRecordBelongsToTeam(Long recordId) {
Long teamDeptId = currentTeamDeptId(); Long teamDeptId = currentTeamDeptId();
AiGroupBalanceChangeRecord r = aiGroupBalanceChangeRecordMapper.selectById(recordId); AiGroupBalanceChangeRecord r = aiGroupBalanceChangeRecordMapper.selectById(recordId);
if (r == null || r.getDeptId() == null || !teamDeptId.equals(r.getDeptId())) { if (r == null || r.getDeptId() == null || !teamDeptId.equals(r.getDeptId())) {

View File

@ -48,66 +48,4 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<include refid="selectAiChargeRefundOrderVo"/> <include refid="selectAiChargeRefundOrderVo"/>
where o.id = #{id} where o.id = #{id}
</select> </select>
<insert id="insertAiChargeRefundOrder" parameterType="AiChargeRefundOrder" useGeneratedKeys="true" keyProperty="id">
insert into ai_charge_refund_order
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="delFlag != null and delFlag != ''">del_flag,</if>
<if test="createBy != null">create_by,</if>
<if test="createTime != null">create_time,</if>
<if test="updateTime != null">update_time,</if>
<if test="orderNum != null and orderNum != ''">order_num,</if>
<if test="thirdPartyOrderNum != null">third_party_order_num,</if>
<if test="deptId != null">dept_id,</if>
<if test="orderType != null">order_type,</if>
<if test="money != null">money,</if>
<if test="amount != null">amount,</if>
<if test="remark != null">remark,</if>
<if test="status != null">status,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="delFlag != null and delFlag != ''">#{delFlag},</if>
<if test="createBy != null">#{createBy},</if>
<if test="createTime != null">#{createTime},</if>
<if test="updateTime != null">#{updateTime},</if>
<if test="orderNum != null and orderNum != ''">#{orderNum},</if>
<if test="thirdPartyOrderNum != null">#{thirdPartyOrderNum},</if>
<if test="deptId != null">#{deptId},</if>
<if test="orderType != null">#{orderType},</if>
<if test="money != null">#{money},</if>
<if test="amount != null">#{amount},</if>
<if test="remark != null">#{remark},</if>
<if test="status != null">#{status},</if>
</trim>
</insert>
<update id="updateAiChargeRefundOrder" parameterType="AiChargeRefundOrder">
update ai_charge_refund_order
<trim prefix="SET" suffixOverrides=",">
<if test="delFlag != null and delFlag != ''">del_flag = #{delFlag},</if>
<if test="createBy != null">create_by = #{createBy},</if>
<if test="createTime != null">create_time = #{createTime},</if>
<if test="updateTime != null">update_time = #{updateTime},</if>
<if test="orderNum != null and orderNum != ''">order_num = #{orderNum},</if>
<if test="thirdPartyOrderNum != null">third_party_order_num = #{thirdPartyOrderNum},</if>
<if test="deptId != null">dept_id = #{deptId},</if>
<if test="orderType != null">order_type = #{orderType},</if>
<if test="money != null">money = #{money},</if>
<if test="amount != null">amount = #{amount},</if>
<if test="remark != null">remark = #{remark},</if>
<if test="status != null">status = #{status},</if>
</trim>
where id = #{id}
</update>
<delete id="deleteAiChargeRefundOrderById" parameterType="Long">
delete from ai_charge_refund_order where id = #{id}
</delete>
<delete id="deleteAiChargeRefundOrderByIds" parameterType="String">
delete from ai_charge_refund_order where id in
<foreach item="id" collection="array" open="(" separator="," close=")">
#{id}
</foreach>
</delete>
</mapper> </mapper>

View File

@ -31,58 +31,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
</where> </where>
</select> </select>
<select id="selectAiGroupBalanceChangeRecordById" parameterType="String" resultMap="AiGroupBalanceChangeRecordResult"> <select id="selectAiGroupBalanceChangeRecordById" parameterType="long" resultMap="AiGroupBalanceChangeRecordResult">
<include refid="selectAiGroupBalanceChangeRecordVo"/> <include refid="selectAiGroupBalanceChangeRecordVo"/>
where id = #{id} where id = #{id}
</select> </select>
<insert id="insertAiGroupBalanceChangeRecord" parameterType="AiGroupBalanceChangeRecord" useGeneratedKeys="true" keyProperty="id">
insert into ai_group_balance_change_record
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="relationOrderNo != null">relation_order_no,</if>
<if test="deptId != null">dept_id,</if>
<if test="type != null">type,</if>
<if test="changeAmount != null">change_amount,</if>
<if test="resultAmount != null">result_amount,</if>
<if test="remark != null">remark,</if>
<if test="createTime != null">create_time,</if>
<if test="updateTime != null">update_time,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="relationOrderNo != null">#{relationOrderNo},</if>
<if test="deptId != null">#{deptId},</if>
<if test="type != null">#{type},</if>
<if test="changeAmount != null">#{changeAmount},</if>
<if test="resultAmount != null">#{resultAmount},</if>
<if test="remark != null">#{remark},</if>
<if test="createTime != null">#{createTime},</if>
<if test="updateTime != null">#{updateTime},</if>
</trim>
</insert>
<update id="updateAiGroupBalanceChangeRecord" parameterType="AiGroupBalanceChangeRecord">
update ai_group_balance_change_record
<trim prefix="SET" suffixOverrides=",">
<if test="relationOrderNo != null">relation_order_no = #{relationOrderNo},</if>
<if test="deptId != null">dept_id = #{deptId},</if>
<if test="type != null">type = #{type},</if>
<if test="changeAmount != null">change_amount = #{changeAmount},</if>
<if test="resultAmount != null">result_amount = #{resultAmount},</if>
<if test="remark != null">remark = #{remark},</if>
<if test="createTime != null">create_time = #{createTime},</if>
<if test="updateTime != null">update_time = #{updateTime},</if>
</trim>
where id = #{id}
</update>
<delete id="deleteAiGroupBalanceChangeRecordById" parameterType="String">
delete from ai_group_balance_change_record where id = #{id}
</delete>
<delete id="deleteAiGroupBalanceChangeRecordByIds" parameterType="String">
delete from ai_group_balance_change_record where id in
<foreach item="id" collection="array" open="(" separator="," close=")">
#{id}
</foreach>
</delete>
</mapper> </mapper>