|
|
@@ -21,7 +21,6 @@ import { ShuyouGameAgentEntity } from '../entity/game_agent';
|
|
|
*/
|
|
|
@Provide()
|
|
|
export class ShuyouGameTaskService extends BaseService {
|
|
|
-
|
|
|
@InjectEntityModel(ShuyouGameTaskEntity)
|
|
|
ShuyouGameTaskEntity: Repository<ShuyouGameTaskEntity>;
|
|
|
|
|
|
@@ -68,58 +67,74 @@ export class ShuyouGameTaskService extends BaseService {
|
|
|
if (!_.isEmpty(existsTask)) {
|
|
|
throw new CoolCommException('本平台已存在相同任务id~');
|
|
|
}
|
|
|
- param.createTime = new Date()
|
|
|
- param.updateTime = new Date()
|
|
|
+ param.createTime = new Date();
|
|
|
+ param.updateTime = new Date();
|
|
|
// console.log(param)
|
|
|
- let target_new = 0
|
|
|
- let target_pay = 0
|
|
|
- let target_active = 0
|
|
|
- target_new = Math.floor(Math.random() * (parseInt(param.target_new_high) - parseInt(param.target_new_low) + 1) + parseInt(param.target_new_low))
|
|
|
- target_pay = Math.floor(Math.random() * (parseInt(param.target_pay_high) - parseInt(param.target_pay_low) + 1) + parseInt(param.target_pay_low))
|
|
|
- target_active = Math.floor(Math.random() * (parseInt(param.target_active_high) - parseInt(param.target_active_low) + 1) + parseInt(param.target_active_low))
|
|
|
+ let target_new = 0;
|
|
|
+ let target_pay = 0;
|
|
|
+ let target_active = 0;
|
|
|
+ target_new = Math.floor(
|
|
|
+ Math.random() *
|
|
|
+ (parseInt(param.target_new_high) - parseInt(param.target_new_low) + 1) +
|
|
|
+ parseInt(param.target_new_low)
|
|
|
+ );
|
|
|
+ target_pay = Math.floor(
|
|
|
+ Math.random() *
|
|
|
+ (parseInt(param.target_pay_high) - parseInt(param.target_pay_low) + 1) +
|
|
|
+ parseInt(param.target_pay_low)
|
|
|
+ );
|
|
|
+ target_active = Math.floor(
|
|
|
+ Math.random() *
|
|
|
+ (parseInt(param.target_active_high) -
|
|
|
+ parseInt(param.target_active_low) +
|
|
|
+ 1) +
|
|
|
+ parseInt(param.target_active_low)
|
|
|
+ );
|
|
|
//
|
|
|
//此处先创建机房后台的任务
|
|
|
//机房后台的任务开始=========================
|
|
|
//先查询出负责人名称与厂商端口名称
|
|
|
const gameDirectorEntity = await this.ShuyouGameDirectorEntity.findOne({
|
|
|
- id: param.directorId
|
|
|
+ id: param.directorId,
|
|
|
});
|
|
|
const gameAgentEntity = await this.ShuyouGameAgentEntity.findOne({
|
|
|
- id: param.game_agentId
|
|
|
+ id: param.game_agentId,
|
|
|
});
|
|
|
if (_.isEmpty(gameDirectorEntity || gameAgentEntity)) {
|
|
|
throw new CoolCommException('负责人名称与厂商端口名称错误~');
|
|
|
}
|
|
|
- const gameDirectorName = gameDirectorEntity.name
|
|
|
- const gameAgentName = gameAgentEntity.name
|
|
|
+ const gameDirectorName = gameDirectorEntity.name;
|
|
|
+ const gameAgentName = gameAgentEntity.name;
|
|
|
//
|
|
|
let xjf_object = {
|
|
|
- "date": param.new_date,
|
|
|
- "game_id": parseInt(param.id),
|
|
|
- "game_name": param.task_name,
|
|
|
- "new_target": target_new,
|
|
|
- "retained_target": 0,
|
|
|
- "pay_target": target_pay,
|
|
|
- "pay_price": parseInt(param.target_pay_low), //需要处理
|
|
|
- "remark": gameDirectorName,
|
|
|
- "spirit_package_name": '0',
|
|
|
- "game_package_name": '0',
|
|
|
- "game_id_xmy": param.xmy_id,
|
|
|
- "sy_data_id": parseInt(param.id),
|
|
|
- "new_retained": param.new_retained + '', //需要在数据库添加该字段
|
|
|
- "game_url": param.download,
|
|
|
- "game_port": gameAgentName
|
|
|
- }
|
|
|
+ date: param.new_date,
|
|
|
+ game_id: parseInt(param.id),
|
|
|
+ game_name: param.task_name,
|
|
|
+ new_target: target_new,
|
|
|
+ retained_target: 0,
|
|
|
+ pay_target: target_pay,
|
|
|
+ pay_price: parseInt(param.target_pay_low), //需要处理
|
|
|
+ remark: gameDirectorName,
|
|
|
+ spirit_package_name: '0',
|
|
|
+ game_package_name: '0',
|
|
|
+ game_id_xmy: param.xmy_id,
|
|
|
+ sy_data_id: parseInt(param.id),
|
|
|
+ new_retained: param.new_retained + '', //需要在数据库添加该字段
|
|
|
+ game_url: param.download,
|
|
|
+ game_port: gameAgentName,
|
|
|
+ };
|
|
|
//
|
|
|
- let createXJF
|
|
|
+ let createXJF;
|
|
|
createXJF = await this.ShuyouXJFUtilsService.createXJF(xjf_object);
|
|
|
// console.log(createXJF.data)
|
|
|
if (!_.isEmpty(createXJF) && createXJF.status == 200) {
|
|
|
- param['xjf_id'] = createXJF.data //获取到机房后台game_id
|
|
|
+ param['xjf_id'] = createXJF.data; //获取到机房后台game_id
|
|
|
// console.log('机房后台game_id' + createXJF.data)
|
|
|
//机房后台开始游戏
|
|
|
- let startXJF
|
|
|
- startXJF = await this.ShuyouXJFUtilsService.startXJF(parseInt(createXJF.data));
|
|
|
+ let startXJF;
|
|
|
+ startXJF = await this.ShuyouXJFUtilsService.startXJF(
|
|
|
+ parseInt(createXJF.data)
|
|
|
+ );
|
|
|
// console.log(startXJF)
|
|
|
if (_.isEmpty(startXJF) || startXJF.status != 200) {
|
|
|
throw new CoolCommException(startXJF.data);
|
|
|
@@ -132,7 +147,7 @@ export class ShuyouGameTaskService extends BaseService {
|
|
|
// 创建游戏目标start==========================
|
|
|
const existsTarget = await this.ShuyouGameTargetEntity.findOne({
|
|
|
task_id: param.id,
|
|
|
- new_date: param.new_date
|
|
|
+ new_date: param.new_date,
|
|
|
});
|
|
|
|
|
|
if (!_.isEmpty(existsTarget)) {
|
|
|
@@ -145,16 +160,15 @@ export class ShuyouGameTaskService extends BaseService {
|
|
|
target_active: target_active,
|
|
|
target_new_low: param.target_new_low,
|
|
|
target_pay_low: param.target_pay_low,
|
|
|
- target_active_low: param.target_active_low
|
|
|
- }
|
|
|
+ target_active_low: param.target_active_low,
|
|
|
+ };
|
|
|
// this.logger.info(targetValue)
|
|
|
- await this.ShuyouGameTargetEntity
|
|
|
- .createQueryBuilder()
|
|
|
+ await this.ShuyouGameTargetEntity.createQueryBuilder()
|
|
|
.update()
|
|
|
.set(targetValue)
|
|
|
.where('task_id = :task_id and new_date = :new_date', {
|
|
|
task_id: param.id,
|
|
|
- new_date: param.new_date
|
|
|
+ new_date: param.new_date,
|
|
|
})
|
|
|
.execute();
|
|
|
// this.logger.info(updateResult) //UpdateResult { generatedMaps: [], raw: [], affected: 1 }
|
|
|
@@ -173,17 +187,17 @@ export class ShuyouGameTaskService extends BaseService {
|
|
|
target_active: target_active,
|
|
|
target_new_low: param.target_new_low,
|
|
|
target_pay_low: param.target_pay_low,
|
|
|
- target_active_low: param.target_active_low
|
|
|
- }
|
|
|
+ target_active_low: param.target_active_low,
|
|
|
+ };
|
|
|
// this.logger.info(targetValue)
|
|
|
- await this.ShuyouGameTargetEntity.insert(targetValue)
|
|
|
+ await this.ShuyouGameTargetEntity.insert(targetValue);
|
|
|
}
|
|
|
// 创建游戏目标end==========================
|
|
|
// 创建游戏完成game_complete===============================
|
|
|
const existsComplete = await this.ShuyouGameCompleteEntity.findOne({
|
|
|
task_id: param.id,
|
|
|
- new_date: param.new_date
|
|
|
- })
|
|
|
+ new_date: param.new_date,
|
|
|
+ });
|
|
|
if (_.isEmpty(existsComplete)) {
|
|
|
// 添加任务完成game_complete
|
|
|
let completeObj = {
|
|
|
@@ -194,14 +208,14 @@ export class ShuyouGameTaskService extends BaseService {
|
|
|
updateTime: param.updateTime,
|
|
|
complete_new: 0,
|
|
|
complete_pay: 0,
|
|
|
- complete_active: 0
|
|
|
- }
|
|
|
+ complete_active: 0,
|
|
|
+ };
|
|
|
// this.logger.info(completeObj)
|
|
|
- await this.ShuyouGameCompleteEntity.insert(completeObj)
|
|
|
+ await this.ShuyouGameCompleteEntity.insert(completeObj);
|
|
|
}
|
|
|
// 创建游戏目标end==========================
|
|
|
// 记录端口对应的游戏数量start
|
|
|
- await this.ShuyouGameAgentService.recordGameNum(param.game_agentId)
|
|
|
+ await this.ShuyouGameAgentService.recordGameNum(param.game_agentId);
|
|
|
// this.logger.info(returnMsg)
|
|
|
// 记录端口对应的游戏数量end
|
|
|
await this.updateTaskGame(param);
|
|
|
@@ -209,12 +223,12 @@ export class ShuyouGameTaskService extends BaseService {
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- *
|
|
|
+ *
|
|
|
* @param {*} query
|
|
|
- * @return {*}
|
|
|
- * @memberof
|
|
|
+ * @return {*}
|
|
|
+ * @memberof
|
|
|
*/
|
|
|
- async taskList() {
|
|
|
+ async taskList() {
|
|
|
const sql = `
|
|
|
SELECT
|
|
|
id,
|
|
|
@@ -229,11 +243,19 @@ export class ShuyouGameTaskService extends BaseService {
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- * 重写分页查询
|
|
|
- * @param query
|
|
|
- */
|
|
|
+ * 重写分页查询
|
|
|
+ * @param query
|
|
|
+ */
|
|
|
async page(query) {
|
|
|
- const { id, task_name, is_run, login_modeId, directorId, game_agentId, account_typeId } = query;
|
|
|
+ const {
|
|
|
+ id,
|
|
|
+ task_name,
|
|
|
+ is_run,
|
|
|
+ login_modeId,
|
|
|
+ directorId,
|
|
|
+ game_agentId,
|
|
|
+ account_typeId,
|
|
|
+ } = query;
|
|
|
const sql = `
|
|
|
SELECT
|
|
|
a.id,a.task_name,a.new_date,a.createTime,a.updateTime,a.target_new_low,a.target_new_high,a.target_pay_low,a.target_pay_high,a.target_active_low,a.target_active_high,
|
|
|
@@ -255,8 +277,12 @@ export class ShuyouGameTaskService extends BaseService {
|
|
|
LEFT JOIN shuyou_game_list g ON t.game_id = g.id
|
|
|
WHERE 1 = 1
|
|
|
${this.setSql(id, 'and a.id = ?', [id])}
|
|
|
- ${this.setSql(task_name, 'and a.task_name LIKE ?', [`%${task_name}%`])}
|
|
|
- ${this.setSql((is_run == 1 || is_run == 0), 'and a.is_run = ?', [is_run])}
|
|
|
+ ${this.setSql(task_name, 'and a.task_name LIKE ?', [
|
|
|
+ `%${task_name}%`,
|
|
|
+ ])}
|
|
|
+ ${this.setSql(is_run == 1 || is_run == 0, 'and a.is_run = ?', [
|
|
|
+ is_run,
|
|
|
+ ])}
|
|
|
${this.setSql(directorId, 'and b.id = ?', [directorId])}
|
|
|
${this.setSql(game_agentId, 'and d.id = ?', [game_agentId])}
|
|
|
${this.setSql(account_typeId, 'and e.id = ?', [account_typeId])}
|
|
|
@@ -287,121 +313,136 @@ export class ShuyouGameTaskService extends BaseService {
|
|
|
}
|
|
|
return info;
|
|
|
}
|
|
|
+
|
|
|
+ /***
|
|
|
+ *
|
|
|
+ */
|
|
|
+ public async infoByGameId(game_id) {
|
|
|
+ const info = await this.ShuyouGameTaskEntity.findOne({ xjf_id: game_id });
|
|
|
+ // console.log(info);
|
|
|
+ return info;
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* 修改
|
|
|
* @param param 数据
|
|
|
*/
|
|
|
async update(param) {
|
|
|
// console.log(param)
|
|
|
- const new_game_agentId = param.game_agentId
|
|
|
- const new_login_modeId = param.login_modeId
|
|
|
- const new_directorId = param.directorId
|
|
|
- const new_task_name = param.task_name
|
|
|
+ const new_game_agentId = param.game_agentId;
|
|
|
+ const new_login_modeId = param.login_modeId;
|
|
|
+ const new_directorId = param.directorId;
|
|
|
+ const new_task_name = param.task_name;
|
|
|
const taskInfo = await this.ShuyouGameTaskEntity.findOne({ id: param.id });
|
|
|
if (!taskInfo) {
|
|
|
throw new CoolCommException('任务不存在');
|
|
|
}
|
|
|
- const xjf_id = taskInfo.xjf_id
|
|
|
+ const xjf_id = taskInfo.xjf_id;
|
|
|
if (xjf_id != 0) {
|
|
|
//修改机房后台任务信息开始=========================
|
|
|
//先查询出负责人名称与厂商端口名称
|
|
|
const gameDirectorEntity = await this.ShuyouGameDirectorEntity.findOne({
|
|
|
- id: param.directorId
|
|
|
+ id: param.directorId,
|
|
|
});
|
|
|
const gameAgentEntity = await this.ShuyouGameAgentEntity.findOne({
|
|
|
- id: param.game_agentId
|
|
|
+ id: param.game_agentId,
|
|
|
});
|
|
|
if (_.isEmpty(gameDirectorEntity || gameAgentEntity)) {
|
|
|
throw new CoolCommException('负责人名称与厂商端口名称错误~');
|
|
|
}
|
|
|
- const gameDirectorName = gameDirectorEntity.name
|
|
|
- const gameAgentName = gameAgentEntity.name
|
|
|
+ const gameDirectorName = gameDirectorEntity.name;
|
|
|
+ const gameAgentName = gameAgentEntity.name;
|
|
|
let xjf_object = {
|
|
|
- "date": this.utils.formatDate(new Date()),
|
|
|
- "game_id": xjf_id,
|
|
|
- "game_name": param.task_name,
|
|
|
- "new_target": 0,
|
|
|
- "retained_target": 0,
|
|
|
- "pay_target": 0,
|
|
|
- "pay_price": parseInt(param.target_pay_low), //需要处理
|
|
|
- "remark": gameDirectorName,
|
|
|
- "spirit_package_name": '0',
|
|
|
- "game_package_name": '0',
|
|
|
- "game_id_xmy": param.xmy_id,
|
|
|
- "sy_data_id": parseInt(param.id),
|
|
|
- "new_retained": param.new_retained + '',
|
|
|
- "game_url": param.download,
|
|
|
- "game_port": gameAgentName
|
|
|
- }
|
|
|
+ date: this.utils.formatDate(new Date()),
|
|
|
+ game_id: xjf_id,
|
|
|
+ game_name: param.task_name,
|
|
|
+ new_target: 0,
|
|
|
+ retained_target: 0,
|
|
|
+ pay_target: 0,
|
|
|
+ pay_price: parseInt(param.target_pay_low), //需要处理
|
|
|
+ remark: gameDirectorName,
|
|
|
+ spirit_package_name: '0',
|
|
|
+ game_package_name: '0',
|
|
|
+ game_id_xmy: param.xmy_id,
|
|
|
+ sy_data_id: parseInt(param.id),
|
|
|
+ new_retained: param.new_retained + '',
|
|
|
+ game_url: param.download,
|
|
|
+ game_port: gameAgentName,
|
|
|
+ };
|
|
|
//
|
|
|
- let queryXjfId
|
|
|
+ let queryXjfId;
|
|
|
queryXjfId = await this.ShuyouXJFUtilsService.queryXjfId(xjf_id);
|
|
|
- let xjfData
|
|
|
+ let xjfData;
|
|
|
if (_.isEmpty(queryXjfId) || queryXjfId == -1) {
|
|
|
xjfData = {
|
|
|
- "IdDong": 0,
|
|
|
- "IdYang": 0
|
|
|
- }
|
|
|
+ IdDong: 0,
|
|
|
+ IdYang: 0,
|
|
|
+ };
|
|
|
} else {
|
|
|
- xjfData = queryXjfId.data
|
|
|
+ xjfData = queryXjfId.data;
|
|
|
}
|
|
|
// console.log(xjfData.IdYang)
|
|
|
// console.log(xjfData.IdDong)
|
|
|
if (xjfData.IdDong > 0) {
|
|
|
- let updateXJF
|
|
|
- updateXJF = await this.ShuyouXJFUtilsService.updateXJF(xjfData.IdDong, xjf_object);
|
|
|
+ let updateXJF;
|
|
|
+ updateXJF = await this.ShuyouXJFUtilsService.updateXJF(
|
|
|
+ xjfData.IdDong,
|
|
|
+ xjf_object
|
|
|
+ );
|
|
|
// console.log(updateXJF.data)
|
|
|
- if (_.isEmpty(updateXJF) || updateXJF.status != 200 || updateXJF.data != 'OK') {
|
|
|
+ if (
|
|
|
+ _.isEmpty(updateXJF) ||
|
|
|
+ updateXJF.status != 200 ||
|
|
|
+ updateXJF.data != 'OK'
|
|
|
+ ) {
|
|
|
throw new CoolCommException(updateXJF.data);
|
|
|
}
|
|
|
}
|
|
|
//修改机房后台任务信息结束=================================
|
|
|
}
|
|
|
|
|
|
- const old_game_agentId = taskInfo.game_agentId
|
|
|
- const old_login_modeId = taskInfo.login_modeId
|
|
|
- const old_directorId = taskInfo.directorId
|
|
|
- const old_task_name = taskInfo.task_name
|
|
|
+ const old_game_agentId = taskInfo.game_agentId;
|
|
|
+ const old_login_modeId = taskInfo.login_modeId;
|
|
|
+ const old_directorId = taskInfo.directorId;
|
|
|
+ const old_task_name = taskInfo.task_name;
|
|
|
await this.ShuyouGameTaskEntity.save(param);
|
|
|
await this.updateTaskGame(param);
|
|
|
//检测负责人-厂商-端口,如有变化,则更新对应数量
|
|
|
if (new_game_agentId != old_game_agentId) {
|
|
|
- await this.ShuyouGameAgentService.recordGameNum(new_game_agentId)
|
|
|
- await this.ShuyouGameAgentService.reduceGameNum(old_game_agentId)
|
|
|
+ await this.ShuyouGameAgentService.recordGameNum(new_game_agentId);
|
|
|
+ await this.ShuyouGameAgentService.reduceGameNum(old_game_agentId);
|
|
|
}
|
|
|
if (new_login_modeId != old_login_modeId) {
|
|
|
- await this.ShuyouLoModeService.recordGameNum(new_game_agentId)
|
|
|
- await this.ShuyouLoModeService.reduceGameNum(old_game_agentId)
|
|
|
+ await this.ShuyouLoModeService.recordGameNum(new_game_agentId);
|
|
|
+ await this.ShuyouLoModeService.reduceGameNum(old_game_agentId);
|
|
|
}
|
|
|
if (new_directorId != old_directorId) {
|
|
|
- await this.ShuyouGameDirectorService.addGameNumById(new_game_agentId)
|
|
|
- await this.ShuyouGameDirectorService.reduceGameNumById(old_game_agentId)
|
|
|
+ await this.ShuyouGameDirectorService.addGameNumById(new_game_agentId);
|
|
|
+ await this.ShuyouGameDirectorService.reduceGameNumById(old_game_agentId);
|
|
|
}
|
|
|
//修改当天任务表里的任务名称(当名称变化时)
|
|
|
if (old_task_name != new_task_name) {
|
|
|
const existsTarget = await this.ShuyouGameTargetEntity.findOne({
|
|
|
task_id: param.id,
|
|
|
- new_date: this.utils.formatDate(new Date())
|
|
|
+ new_date: this.utils.formatDate(new Date()),
|
|
|
});
|
|
|
if (!_.isEmpty(existsTarget)) {
|
|
|
// 当天的任务目标已存在,执行更新目标
|
|
|
let targetValue = {
|
|
|
- task_name: new_task_name
|
|
|
- }
|
|
|
+ task_name: new_task_name,
|
|
|
+ };
|
|
|
// this.logger.info(targetValue)
|
|
|
- await this.ShuyouGameTargetEntity
|
|
|
- .createQueryBuilder()
|
|
|
+ await this.ShuyouGameTargetEntity.createQueryBuilder()
|
|
|
.update()
|
|
|
.set(targetValue)
|
|
|
.where('task_id = :task_id and new_date = :new_date', {
|
|
|
task_id: param.id,
|
|
|
- new_date: this.utils.formatDate(new Date())
|
|
|
+ new_date: this.utils.formatDate(new Date()),
|
|
|
})
|
|
|
.execute();
|
|
|
// this.logger.info(updateResult) //UpdateResult { generatedMaps: [], raw: [], affected: 1 }
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
}
|
|
|
/**
|
|
|
* 更新任务-游戏关系
|
|
|
@@ -411,7 +452,10 @@ export class ShuyouGameTaskService extends BaseService {
|
|
|
await this.ShuyouTaskGameRecordEntity.delete({ task_id: taskGame.id });
|
|
|
if (taskGame.gameIdList) {
|
|
|
for (const game_id of taskGame.gameIdList) {
|
|
|
- await this.ShuyouTaskGameRecordEntity.save({ task_id: taskGame.id, game_id });
|
|
|
+ await this.ShuyouTaskGameRecordEntity.save({
|
|
|
+ task_id: taskGame.id,
|
|
|
+ game_id,
|
|
|
+ });
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
@@ -422,7 +466,7 @@ export class ShuyouGameTaskService extends BaseService {
|
|
|
*/
|
|
|
async delete(ids) {
|
|
|
let idArr;
|
|
|
- console.log(ids)
|
|
|
+ console.log(ids);
|
|
|
if (ids instanceof Array) {
|
|
|
idArr = ids;
|
|
|
} else {
|
|
|
@@ -434,21 +478,24 @@ export class ShuyouGameTaskService extends BaseService {
|
|
|
if (taskInfo) {
|
|
|
// console.log(taskInfo)
|
|
|
if (taskInfo.is_run == 1) {
|
|
|
- await this.ShuyouGameAgentService.reduceGameNum(taskInfo.game_agentId)
|
|
|
- await this.ShuyouLoModeService.reduceGameNum(taskInfo.login_modeId)
|
|
|
- await this.ShuyouGameDirectorService.reduceGameNumById(taskInfo.directorId)
|
|
|
+ await this.ShuyouGameAgentService.reduceGameNum(
|
|
|
+ taskInfo.game_agentId
|
|
|
+ );
|
|
|
+ await this.ShuyouLoModeService.reduceGameNum(taskInfo.login_modeId);
|
|
|
+ await this.ShuyouGameDirectorService.reduceGameNumById(
|
|
|
+ taskInfo.directorId
|
|
|
+ );
|
|
|
}
|
|
|
}
|
|
|
//===================================================================================
|
|
|
await this.ShuyouTaskGameRecordEntity.delete({ task_id: id });
|
|
|
await this.ShuyouGameTaskEntity.delete({ id: id });
|
|
|
}
|
|
|
-
|
|
|
}
|
|
|
/**
|
|
|
- * 根据id删除任务
|
|
|
- * @param id
|
|
|
- */
|
|
|
+ * 根据id删除任务
|
|
|
+ * @param id
|
|
|
+ */
|
|
|
async deleteById(id) {
|
|
|
//===================================================================================
|
|
|
// console.log(id)
|
|
|
@@ -458,21 +505,21 @@ export class ShuyouGameTaskService extends BaseService {
|
|
|
if (!taskInfo) {
|
|
|
throw new CoolCommException('任务不存在');
|
|
|
}
|
|
|
- const xjf_id = taskInfo.xjf_id
|
|
|
+ const xjf_id = taskInfo.xjf_id;
|
|
|
if (xjf_id != 0) {
|
|
|
- let queryXjfId
|
|
|
+ let queryXjfId;
|
|
|
queryXjfId = await this.ShuyouXJFUtilsService.queryXjfId(xjf_id);
|
|
|
- let xjfData
|
|
|
+ let xjfData;
|
|
|
if (_.isEmpty(queryXjfId) || queryXjfId == -1) {
|
|
|
xjfData = {
|
|
|
- "IdDong": 0,
|
|
|
- "IdYang": 0
|
|
|
- }
|
|
|
+ IdDong: 0,
|
|
|
+ IdYang: 0,
|
|
|
+ };
|
|
|
} else {
|
|
|
- xjfData = queryXjfId.data
|
|
|
+ xjfData = queryXjfId.data;
|
|
|
}
|
|
|
if (xjfData.IdDong > 0) {
|
|
|
- let deleteXJF
|
|
|
+ let deleteXJF;
|
|
|
deleteXJF = await this.ShuyouXJFUtilsService.deleteXJF(xjfData.IdDong);
|
|
|
// console.log(deleteXJF)
|
|
|
if (_.isEmpty(deleteXJF) || deleteXJF.status != 200) {
|
|
|
@@ -483,9 +530,12 @@ export class ShuyouGameTaskService extends BaseService {
|
|
|
//=============================================
|
|
|
await this.ShuyouTaskGameRecordEntity.delete({ task_id: id });
|
|
|
await this.ShuyouGameTaskEntity.delete({ id: id });
|
|
|
- await this.ShuyouGameTargetEntity.delete({ task_id: id, new_date: this.utils.formatDate(new Date()) })
|
|
|
+ await this.ShuyouGameTargetEntity.delete({
|
|
|
+ task_id: id,
|
|
|
+ new_date: this.utils.formatDate(new Date()),
|
|
|
+ });
|
|
|
// await this.ShuyouGameCompleteEntity.delete({ task_id: id, new_date: this.utils.formatDate(new Date()) })
|
|
|
- return 1000
|
|
|
+ return 1000;
|
|
|
}
|
|
|
//
|
|
|
/**
|
|
|
@@ -494,14 +544,14 @@ export class ShuyouGameTaskService extends BaseService {
|
|
|
* @param {string} task_id
|
|
|
* @param {Date} stopTime
|
|
|
* @param {string} stopRemark
|
|
|
- * @return {*}
|
|
|
+ * @return {*}
|
|
|
* @memberof ShuyouGameTaskService
|
|
|
*/
|
|
|
async stopTask(task_id: string, stopTime: Date, stopRemark: string) {
|
|
|
// const { id_name } = query;
|
|
|
let obj = {
|
|
|
- id: task_id
|
|
|
- }
|
|
|
+ id: task_id,
|
|
|
+ };
|
|
|
const ShuyouGameTaskEntity = await this.ShuyouGameTaskEntity.findOne(obj);
|
|
|
if (ShuyouGameTaskEntity) {
|
|
|
if (new Date(stopTime).getTime() > new Date().getTime()) {
|
|
|
@@ -515,52 +565,58 @@ export class ShuyouGameTaskService extends BaseService {
|
|
|
await this.ShuyouGameTaskEntity.save(ShuyouGameTaskEntity);
|
|
|
//机房后台停止游戏=============================
|
|
|
if (ShuyouGameTaskEntity.xjf_id != 0) {
|
|
|
- let stopXJF
|
|
|
- stopXJF = await this.ShuyouXJFUtilsService.stopXJF(ShuyouGameTaskEntity.xjf_id);
|
|
|
+ let stopXJF;
|
|
|
+ stopXJF = await this.ShuyouXJFUtilsService.stopXJF(
|
|
|
+ ShuyouGameTaskEntity.xjf_id
|
|
|
+ );
|
|
|
// console.log(stopXJF)
|
|
|
if (_.isEmpty(stopXJF) || stopXJF.status != 200) {
|
|
|
throw new CoolCommException(stopXJF.data);
|
|
|
}
|
|
|
}
|
|
|
//=======================================
|
|
|
- return 1000
|
|
|
+ return 1000;
|
|
|
} else {
|
|
|
- return -1
|
|
|
+ return -1;
|
|
|
}
|
|
|
}
|
|
|
/**
|
|
|
*
|
|
|
*
|
|
|
* @param {string} task_id
|
|
|
- * @return {*}
|
|
|
+ * @return {*}
|
|
|
* @memberof ShuyouGameTaskService
|
|
|
*/
|
|
|
async startTask(task_id: string) {
|
|
|
// const { id_name } = query;
|
|
|
let obj = {
|
|
|
- id: task_id
|
|
|
- }
|
|
|
+ id: task_id,
|
|
|
+ };
|
|
|
const ShuyouGameTaskEntity = await this.ShuyouGameTaskEntity.findOne(obj);
|
|
|
if (ShuyouGameTaskEntity) {
|
|
|
ShuyouGameTaskEntity.is_run = 1;
|
|
|
- ShuyouGameTaskEntity.new_date = new Date(this.utils.formatDate(new Date()));
|
|
|
+ ShuyouGameTaskEntity.new_date = new Date(
|
|
|
+ this.utils.formatDate(new Date())
|
|
|
+ );
|
|
|
ShuyouGameTaskEntity.stopTime = new Date('2099-01-01');
|
|
|
ShuyouGameTaskEntity.stopRemark = '';
|
|
|
// this.logger.info(ShuyouGameTaskEntity)
|
|
|
await this.ShuyouGameTaskEntity.save(ShuyouGameTaskEntity);
|
|
|
//机房后台开始游戏=============================
|
|
|
if (ShuyouGameTaskEntity.xjf_id != 0) {
|
|
|
- let startXJF
|
|
|
- startXJF = await this.ShuyouXJFUtilsService.startXJF(ShuyouGameTaskEntity.xjf_id);
|
|
|
+ let startXJF;
|
|
|
+ startXJF = await this.ShuyouXJFUtilsService.startXJF(
|
|
|
+ ShuyouGameTaskEntity.xjf_id
|
|
|
+ );
|
|
|
// console.log(startXJF)
|
|
|
if (_.isEmpty(startXJF) || startXJF.status != 200) {
|
|
|
throw new CoolCommException(startXJF.data);
|
|
|
}
|
|
|
}
|
|
|
//=======================================
|
|
|
- return 1000
|
|
|
+ return 1000;
|
|
|
} else {
|
|
|
- return -1
|
|
|
+ return -1;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@@ -568,7 +624,7 @@ export class ShuyouGameTaskService extends BaseService {
|
|
|
* 获取新增账号
|
|
|
* @param {*} task_id
|
|
|
* @param {*} account_typeId
|
|
|
- * @return {*}
|
|
|
+ * @return {*}
|
|
|
* @memberof ShuyouGameTaskService
|
|
|
*/
|
|
|
async getAccountOne(task_id, account_typeId, account_state) {
|
|
|
@@ -590,7 +646,9 @@ export class ShuyouGameTaskService extends BaseService {
|
|
|
shuyou_game_account AS A
|
|
|
WHERE
|
|
|
1 = 1
|
|
|
- ${this.setSql(account_typeId, 'and type_id = ?', [account_typeId])}
|
|
|
+ ${this.setSql(account_typeId, 'and type_id = ?', [
|
|
|
+ account_typeId,
|
|
|
+ ])}
|
|
|
AND occupy_taskId = 0
|
|
|
${this.setSql(account_state, 'AND STATUS = ?', [account_state])}
|
|
|
AND
|
|
|
@@ -619,7 +677,7 @@ export class ShuyouGameTaskService extends BaseService {
|
|
|
* 获取留存账号
|
|
|
* @param {*} task_id
|
|
|
* @param {*} retained_day
|
|
|
- * @return {*}
|
|
|
+ * @return {*}
|
|
|
* @memberof ShuyouGameTaskService
|
|
|
*/
|
|
|
async getAccountRetainedOne(task_id, retained_date) {
|