Browse Source

套餐分配完善

master
La123123 1 month ago
parent
commit
9c0eb11838
  1. 23
      im-admin-ui/src/api/im/chatPackage/index.ts
  2. 44
      im-admin-ui/src/views/im/chatPackage/index.vue
  3. 4
      im-admin/ruoyi-im/src/main/java/org/dromara/im/controller/ImChatPackageController.java
  4. 2
      im-admin/ruoyi-im/src/main/java/org/dromara/im/controller/ImUserController.java
  5. 10
      im-admin/ruoyi-im/src/main/java/org/dromara/im/domain/ImAgent.java
  6. 6
      im-admin/ruoyi-im/src/main/java/org/dromara/im/service/impl/ImChatPackageServiceImpl.java
  7. 11
      im-admin/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/system/domain/ImAgentAdmin.java

23
im-admin-ui/src/api/im/chatPackage/index.ts

@ -61,3 +61,26 @@ export const delChatPackage = (id: string | number | Array<string | number>) =>
method: 'delete' method: 'delete'
}); });
}; };
/**
* id
* @param data
*/
export const getAllAgentNameList = () => {
return request({
url: '/im/agent/getAllAgentNameList',
method: 'post'
});
};
/**
*
* @param data
*/
export const allocatePackages = (data: { agentId: number; packageId: number }) => {
return request({
url: '/im/chatPackage/allocatePackages',
method: 'post',
data: data
});
};

44
im-admin-ui/src/views/im/chatPackage/index.vue

@ -27,16 +27,16 @@
<el-col :span="1.5"> <el-col :span="1.5">
<el-button v-hasPermi="['im:chatPackage:add']" type="primary" plain icon="Plus" @click="handleAdd">新增</el-button> <el-button v-hasPermi="['im:chatPackage:add']" type="primary" plain icon="Plus" @click="handleAdd">新增</el-button>
</el-col> </el-col>
<el-col :span="1.5"> <!-- <el-col :span="1.5">
<el-button v-hasPermi="['im:chatPackage:edit']" type="success" plain icon="Edit" :disabled="single" @click="handleUpdate()" <el-button v-hasPermi="['im:chatPackage:edit']" type="success" plain icon="Edit" :disabled="single" @click="handleUpdate()"
>修改</el-button >修改</el-button
> >
</el-col> </el-col> -->
<el-col :span="1.5"> <!-- <el-col :span="1.5">
<el-button v-hasPermi="['im:chatPackage:remove']" type="danger" plain icon="Delete" :disabled="multiple" @click="handleDelete()" <el-button v-hasPermi="['im:chatPackage:remove']" type="danger" plain icon="Delete" :disabled="multiple" @click="handleDelete()"
>删除</el-button >删除</el-button
> >
</el-col> </el-col> -->
<!-- <el-col :span="1.5"> <!-- <el-col :span="1.5">
<el-button v-hasPermi="['im:chatPackage:export']" type="warning" plain icon="Download" @click="handleExport">导出</el-button> <el-button v-hasPermi="['im:chatPackage:export']" type="warning" plain icon="Download" @click="handleExport">导出</el-button>
</el-col> --> </el-col> -->
@ -45,7 +45,7 @@
</template> </template>
<el-table v-loading="loading" :data="chatPackageList" @selection-change="handleSelectionChange"> <el-table v-loading="loading" :data="chatPackageList" @selection-change="handleSelectionChange">
<el-table-column type="selection" width="55" align="center" /> <!-- <el-table-column type="selection" width="55" align="center" /> -->
<!-- <el-table-column label="主键ID" align="center" prop="id" v-if="true" /> --> <!-- <el-table-column label="主键ID" align="center" prop="id" v-if="true" /> -->
<el-table-column label="套餐名称" align="center" prop="packageName" /> <el-table-column label="套餐名称" align="center" prop="packageName" />
<el-table-column label="客服数量" align="center" prop="customerServiceNumber" /> <el-table-column label="客服数量" align="center" prop="customerServiceNumber" />
@ -62,6 +62,15 @@
</el-table-column> </el-table-column>
<el-table-column label="操作" align="center" class-name="small-padding fixed-width"> <el-table-column label="操作" align="center" class-name="small-padding fixed-width">
<template #default="scope"> <template #default="scope">
<el-tooltip content="套餐分配" placement="top">
<el-button
v-hasPermi="['im:chatPackage:allocatePackages']"
link
type="primary"
icon="Plus"
@click="handleAllocatePackages(scope.row)"
></el-button>
</el-tooltip>
<el-tooltip content="修改" placement="top"> <el-tooltip content="修改" placement="top">
<el-button v-hasPermi="['im:chatPackage:edit']" link type="primary" icon="Edit" @click="handleUpdate(scope.row)"></el-button> <el-button v-hasPermi="['im:chatPackage:edit']" link type="primary" icon="Edit" @click="handleUpdate(scope.row)"></el-button>
</el-tooltip> </el-tooltip>
@ -109,12 +118,15 @@
</div> </div>
</template> </template>
</el-dialog> </el-dialog>
<AllocatePackagesDialog ref="allocatePackagesDialogRef" :package-id="form.id" @success="getList" @close="handleAllocatePackagesClose" />
</div> </div>
</template> </template>
<script setup name="ChatPackage" lang="ts"> <script setup name="ChatPackage" lang="ts">
import { listChatPackage, getChatPackage, delChatPackage, addChatPackage, updateChatPackage } from '@/api/im/chatPackage'; import { listChatPackage, getChatPackage, delChatPackage, addChatPackage, updateChatPackage } from '@/api/im/chatPackage';
import { ChatPackageVO, ChatPackageQuery, ChatPackageForm } from '@/api/im/chatPackage/types'; import { ChatPackageVO, ChatPackageQuery, ChatPackageForm } from '@/api/im/chatPackage/types';
import AllocatePackagesDialog from './component/allocatePackagesDialog.vue';
const { proxy } = getCurrentInstance() as ComponentInternalInstance; const { proxy } = getCurrentInstance() as ComponentInternalInstance;
const { commom_status } = toRefs<any>(proxy?.useDict('commom_status')); const { commom_status } = toRefs<any>(proxy?.useDict('commom_status'));
@ -130,6 +142,7 @@ const total = ref(0);
const queryFormRef = ref<ElFormInstance>(); const queryFormRef = ref<ElFormInstance>();
const chatPackageFormRef = ref<ElFormInstance>(); const chatPackageFormRef = ref<ElFormInstance>();
const allocatePackagesDialogRef = ref();
const dialog = reactive<DialogOption>({ const dialog = reactive<DialogOption>({
visible: false, visible: false,
@ -263,6 +276,27 @@ const handleExport = () => {
); );
}; };
/** 分配套餐 */
const handleAllocatePackages = async (row?: ChatPackageVO) => {
const packageId = row?.id || ids.value[0];
if (!packageId) {
proxy?.$modal.msgError('请先选择要分配的套餐');
return;
}
// ID
form.value.id = packageId;
//
allocatePackagesDialogRef.value.openDialog();
};
/** 分配套餐对话框关闭 */
const handleAllocatePackagesClose = () => {
// ID
ids.value = [];
};
onMounted(() => { onMounted(() => {
getList(); getList();
}); });

4
im-admin/ruoyi-im/src/main/java/org/dromara/im/controller/ImChatPackageController.java

@ -109,9 +109,9 @@ public class ImChatPackageController extends BaseController {
* 分配套餐 * 分配套餐
*/ */
@SaCheckPermission("im:chatPackage:allocatePackages") @SaCheckPermission("im:chatPackage:allocatePackages")
@Log(title = "套餐", businessType = BusinessType.UPDATE) @Log(title = "分配套餐", businessType = BusinessType.UPDATE)
@RepeatSubmit() @RepeatSubmit()
@PostMapping() @PostMapping("/allocatePackages")
public R<Void> allocatePackages(@RequestBody JSONObject data) { public R<Void> allocatePackages(@RequestBody JSONObject data) {
Long packageId = data.getLong("packageId"); Long packageId = data.getLong("packageId");
Long agentId = data.getLong("agentId"); Long agentId = data.getLong("agentId");

2
im-admin/ruoyi-im/src/main/java/org/dromara/im/controller/ImUserController.java

@ -173,6 +173,8 @@ public class ImUserController extends BaseController {
return R.fail("用户名已存在"); return R.fail("用户名已存在");
} }
//检查是否已达当前角色使用的套餐客服上限
// 设置默认值 // 设置默认值
String username = user.getUserName(); String username = user.getUserName();
String nickname = user.getNickName(); String nickname = user.getNickName();

10
im-admin/ruoyi-im/src/main/java/org/dromara/im/domain/ImAgent.java

@ -51,10 +51,20 @@ public class ImAgent implements TransPojo {
*/ */
private Date updatedTime; private Date updatedTime;
/**
* 当前使用套餐
*/
private Long packageId;
/** /**
* 套餐到期时间 * 套餐到期时间
*/ */
private Date packageExpireTime; private Date packageExpireTime;
/**
* 客服人数上限
*/
private Long maxCustomer;
} }

6
im-admin/ruoyi-im/src/main/java/org/dromara/im/service/impl/ImChatPackageServiceImpl.java

@ -181,13 +181,15 @@ public class ImChatPackageServiceImpl implements IImChatPackageService {
} }
// 将durationDays加到packageExpireTime上 // 将durationDays加到packageExpireTime上
packageExpireTime = DateUtil.offsetDay(packageExpireTime, durationDays.intValue()); packageExpireTime = DateUtil.offsetDay(packageExpireTime, durationDays.intValue() + 1);
// 格式化为该日期的零点零分零秒 // 格式化为该日期加上一天后的零点零分零秒
packageExpireTime = DateUtil.beginOfDay(packageExpireTime); packageExpireTime = DateUtil.beginOfDay(packageExpireTime);
// 更新ImAgent的packageExpireTime // 更新ImAgent的packageExpireTime
agent.setPackageExpireTime(packageExpireTime); agent.setPackageExpireTime(packageExpireTime);
agent.setPackageId(packageId);
agent.setMaxCustomer(chatPackage.getCustomerServiceNumber());
return imAgentMapper.updateById(agent) > 0; return imAgentMapper.updateById(agent) > 0;
} }

11
im-admin/ruoyi-modules/ruoyi-system/src/main/java/org/dromara/system/domain/ImAgentAdmin.java

@ -51,10 +51,21 @@ public class ImAgentAdmin implements TransPojo {
*/ */
private Date updatedTime; private Date updatedTime;
/**
* 当前使用套餐
*/
private Long packageId;
/** /**
* 套餐到期时间 * 套餐到期时间
*/ */
private Date packageExpireTime; private Date packageExpireTime;
/**
* 客服人数上限
*/
private Long maxCustomer;
} }

Loading…
Cancel
Save