|
|
@@ -1,7 +1,7 @@
|
|
|
/*
|
|
|
* @Author: YKH
|
|
|
* @Date: 2021-12-08 10:26:27
|
|
|
- * @LastEditTime: 2022-09-17 22:27:10
|
|
|
+ * @LastEditTime: 2022-09-19 17:55:06
|
|
|
* @Description:
|
|
|
* @FilePath: \cool-admin-3.x\cool-admin-midway-master\src\app\modules\shuyou\service\rent_computer.ts
|
|
|
*/
|
|
|
@@ -28,7 +28,7 @@ export class ShuyouRentComputerService extends BaseService {
|
|
|
*/
|
|
|
async add(param) {
|
|
|
const existsTask = await this.ShuyouRentComputerEntity.findOne({
|
|
|
- pc_num: param.pc_num
|
|
|
+ pc_num: param.pc_num,
|
|
|
});
|
|
|
if (!_.isEmpty(existsTask)) {
|
|
|
throw new CoolCommException('已存在相同编号的租机');
|
|
|
@@ -37,6 +37,9 @@ export class ShuyouRentComputerService extends BaseService {
|
|
|
param.updateTime = new Date();
|
|
|
param.rent_price_day = parseFloat(param.rent_price) / parseFloat(param.rent_duration); // 折算天租金
|
|
|
|
|
|
+ console.log('rent_price_day');
|
|
|
+ console.log(param.rent_price_day);
|
|
|
+
|
|
|
await this.updateTaskGame(param);
|
|
|
return super.add(param);
|
|
|
}
|
|
|
@@ -45,25 +48,28 @@ export class ShuyouRentComputerService extends BaseService {
|
|
|
* 更新租机-任务关系
|
|
|
* @param pc_task
|
|
|
*/
|
|
|
- async updateTaskGame(pc_task) {
|
|
|
+ async updateTaskGame(pc_task) {
|
|
|
await this.ShuyouRentComputerUsageEntity.delete({ pc_num: pc_task.pc_num });
|
|
|
if (pc_task.taskIdList) {
|
|
|
for (const task_id of pc_task.taskIdList) {
|
|
|
// console.log(task_id)
|
|
|
- await this.ShuyouRentComputerUsageEntity.save({ pc_num: pc_task.pc_num, task_id });
|
|
|
+ await this.ShuyouRentComputerUsageEntity.save({
|
|
|
+ pc_num: pc_task.pc_num,
|
|
|
+ task_id,
|
|
|
+ });
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
|
|
|
//表编码格式不一致导致报错解决办法
|
|
|
- //SHOW CREATE TABLE shuyou_rent_computer_usage;
|
|
|
- //ALTER TABLE shuyou_rent_computer_usage DEFAULT CHARACTER SET utf8mb4 COLLATE=utf8mb4_german2_ci;
|
|
|
- // ALTER TABLE shuyou_rent_computer_usage CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_german2_ci;
|
|
|
+ //SHOW CREATE TABLE shuyou_rent_computer_usage;
|
|
|
+ //ALTER TABLE shuyou_rent_computer_usage DEFAULT CHARACTER SET utf8mb4 COLLATE=utf8mb4_german2_ci;
|
|
|
+ // ALTER TABLE shuyou_rent_computer_usage CONVERT TO CHARACTER SET utf8mb4 COLLATE utf8mb4_german2_ci;
|
|
|
/**
|
|
|
* 根据ID获得信息
|
|
|
* @param id
|
|
|
*/
|
|
|
- public async info(id) {
|
|
|
+ public async info(id) {
|
|
|
const info = await this.ShuyouRentComputerEntity.findOne({ id });
|
|
|
if (info) {
|
|
|
const taskIds = await this.nativeQuery(
|
|
|
@@ -87,20 +93,26 @@ export class ShuyouRentComputerService extends BaseService {
|
|
|
* 修改
|
|
|
* @param param 数据
|
|
|
*/
|
|
|
- async update(param) {
|
|
|
+ async update(param) {
|
|
|
// console.log(param)
|
|
|
- const taskInfo = await this.ShuyouRentComputerEntity.findOne({ id: param.id });
|
|
|
+ const taskInfo = await this.ShuyouRentComputerEntity.findOne({
|
|
|
+ id: param.id,
|
|
|
+ });
|
|
|
if (!taskInfo) {
|
|
|
throw new CoolCommException('租机不存在');
|
|
|
}
|
|
|
+ param.rent_price_day = parseFloat(param.rent_price) / parseFloat(param.rent_duration); // 折算天租金
|
|
|
+
|
|
|
+ console.log('rent_price_day');
|
|
|
+ console.log(param.rent_price_day);
|
|
|
+
|
|
|
await this.ShuyouRentComputerEntity.save(param);
|
|
|
await this.updateTaskGame(param);
|
|
|
-
|
|
|
}
|
|
|
/**
|
|
|
- * 重写分页查询
|
|
|
- * @param query
|
|
|
- */
|
|
|
+ * 重写分页查询
|
|
|
+ * @param query
|
|
|
+ */
|
|
|
async page(query) {
|
|
|
const { pc_num } = query;
|
|
|
const sql = `
|
|
|
@@ -122,7 +134,4 @@ export class ShuyouRentComputerService extends BaseService {
|
|
|
`;
|
|
|
return this.sqlRenderPage(sql, query);
|
|
|
}
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
}
|