Просмотр исходного кода

增加获取游戏最新脚本的接口,用于中控获取脚本文件地址

倚楼听风雨 лет назад: 3
Родитель
Сommit
ff3dab0ca8

+ 138 - 78
cool-admin-midway-master/src/app/modules/shuyou/controller/app/game_task.ts

@@ -18,7 +18,6 @@ import { ShuyouFileListService } from '../../service/file_list';
 // /**同一渠道身份证最大使用次数 **/
 // const repeatTime = 20
 
-
 /**
  * 商品
  */
@@ -29,7 +28,6 @@ import { ShuyouFileListService } from '../../service/file_list';
   // 设置表实体
   entity: ShuyouGameTaskEntity,
   service: ShuyouGameTaskService,
-
 })
 export class ShuyouAppGameTaskController extends BaseController {
   @Inject()
@@ -65,32 +63,32 @@ export class ShuyouAppGameTaskController extends BaseController {
   //接口添加上任务对应的文件,每个类型只返回一个最高版本号的
   @Get('/getTaskTAndC')
   async getTaskTAndC(@Query(ALL) queryObject) {
-    let { task_id, new_date } = queryObject
+    let { task_id, new_date } = queryObject;
     if (!new_date) {
-      new_date = this.utils.formatDate(new Date(new_date))
+      new_date = this.utils.formatDate(new Date(new_date));
     }
-    let queryObj
+    let queryObj;
     if (task_id && task_id != '') {
       const taskInfo = await this.ShuyouGameTaskService.info(task_id);
       if (!taskInfo) {
-        return this.fail('task_id不存在', -1)
+        return this.fail('task_id不存在', -1);
       }
       if (taskInfo.is_run == 0) {
-        return this.fail('该任务未运行', -1)
+        return this.fail('该任务未运行', -1);
       }
       queryObj = {
         task_id: task_id,
-        new_date: new_date
-      }
+        new_date: new_date,
+      };
     } else {
       queryObj = {
-        new_date: new_date
-      }
+        new_date: new_date,
+      };
     }
     const list = await this.ShuyouGameTargetService.getTaskTAndC(queryObj);
     // this.logger.info(list)
     if (list.length > 0) {
-      let resT = []
+      let resT = [];
       const allFile = await this.ShuyouFileListService.queryAll();
       list.forEach(e => {
         //
@@ -111,17 +109,17 @@ export class ShuyouAppGameTaskController extends BaseController {
           qq_channel: e.qq_channel,
           mz_id: e.mz_id,
           mz_channel: e.mz_channel,
-          game_rate: e.game_rate,  //群控效率
-          game_rate_xmy: e.game_rate_xmy,  //小绵羊后台效率
-          is_complete: e.is_complete,  //是否完成
-          amount: e.amount,   //付费流水
+          game_rate: e.game_rate, //群控效率
+          game_rate_xmy: e.game_rate_xmy, //小绵羊后台效率
+          is_complete: e.is_complete, //是否完成
+          amount: e.amount, //付费流水
           incomplete_typeId: e.type_id, //未完成类型
           incomplete_reason: e.reason, //未完成原因
           incomplete_solution: e.solution, //解决办法
           incomplete_new: parseInt(e.incomplete_new),
           incomplete_pay: parseInt(e.incomplete_pay),
-          incomplete_active: parseInt(e.incomplete_active)
-        }
+          incomplete_active: parseInt(e.incomplete_active),
+        };
         //此处传入文件相关信息
         if (allFile.length > 0) {
           allFile.forEach(file => {
@@ -130,68 +128,120 @@ export class ShuyouAppGameTaskController extends BaseController {
                 file_type: file.type,
                 file_version: file.fileVersion,
                 qn_address: file.qiniuAddress,
-                qn_hash: file.qiniuHash
-              }
-              obj['type' + file.type] = fileObj
+                qn_hash: file.qiniuHash,
+              };
+              obj['type' + file.type] = fileObj;
             }
           });
         }
         //
-        resT.push(obj)
+        resT.push(obj);
       });
 
-      return { code: 1000, message: '获取游戏数据成功', date: new_date, data: resT };
+      return {
+        code: 1000,
+        message: '获取游戏数据成功',
+        date: new_date,
+        data: resT,
+      };
     } else {
       return this.fail('任务' + task_id + '获取失败', -1);
     }
   }
 
+  /**http://ykhvip.fun/api/app/shuyou/game_task/getScript?game_id=1000058
+   * http://127.0.0.1:8001/app/shuyou/game_task/getScript?game_id=1000058
+   * @param queryObject
+   * @returns
+   */
+  @Get('/getScript')
+  async getScript(@Query(ALL) queryObject) {
+    let { game_id } = queryObject;
+    const taskInfo = await this.ShuyouGameTaskService.infoByGameId(game_id);
+    if (_.isEmpty(taskInfo)) {
+      return this.fail('task_id不存在', -1);
+    }
+    const task_id = taskInfo.id;
+    //type=11 指获取脚本类型的文件
+    const fileEntity = await this.ShuyouFileListService.queryVersionByType(
+      task_id,
+      11
+    );
+    // console.log(fileEntity);
+    if (fileEntity) {
+      let reqObj = {
+        task_id: fileEntity.task_id,
+        file_version: fileEntity.fileVersion,
+        file_address: fileEntity.qiniuAddress,
+        file_hash: fileEntity.qiniuHash,
+      };
+      return {
+        code: 1000,
+        message: '获取成功',
+        fileData: reqObj,
+      };
+    } else {
+      return {
+        code: 1001,
+        message: '无脚本信息',
+      };
+    }
+  }
+
   /**
    * http://127.0.0.1:8001/app/shuyou/game_task/get_account?task_id=3520&status=0
    * 拉取任务账号-新增账号{status 0.正常 1.冻结 2.密错 5.人脸验证  6.信用分不足}
    * @param {*} queryObject
-   * @return {*} 
+   * @return {*}
    * @memberof ShuyouAppGameTaskController
    */
   @Get('/get_account')
   async getAccount(@Query(ALL) queryObject) {
-    let { task_id, status } = queryObject
+    let { task_id, status } = queryObject;
     if (!task_id) {
-      return this.fail('缺少必要参数[task_id=任务id]', -1)
+      return this.fail('缺少必要参数[task_id=任务id]', -1);
     }
     const taskInfo = await this.ShuyouGameTaskService.info(task_id);
     if (!taskInfo) {
-      return this.fail('task_id不存在', -1)
+      return this.fail('task_id不存在', -1);
     }
-    let account_state = 0
+    let account_state = 0;
     if (!status) {
       account_state = 0;
     } else {
       account_state = status;
     }
-    const account_typeId = taskInfo.account_typeId
-    const gameIdList = taskInfo.gameIdList
-    const list = await this.ShuyouGameTaskService.getAccountOne(task_id, account_typeId, account_state);
+    const account_typeId = taskInfo.account_typeId;
+    const gameIdList = taskInfo.gameIdList;
+    const list = await this.ShuyouGameTaskService.getAccountOne(
+      task_id,
+      account_typeId,
+      account_state
+    );
     // this.logger.info(list)
     if (list.length > 0) {
-      const account_id = list[0].id
+      const account_id = list[0].id;
       await this.ShuyouGameAccountService.updateOccupy(account_id, task_id);
-      const inserTaskAccountRecord = await this.ShuyouTaskAccountRecordEntity.createQueryBuilder()
-        .insert()
-        .into(ShuyouTaskAccountRecordEntity)
-        .values({
-          task_id: task_id,
-          account_id: account_id,
-          new_date: new Date(this.utils.formatDate(new Date())),
-          getTimeNew: new Date()  // 新增取号时间
-        })
-        .execute();
+      const inserTaskAccountRecord =
+        await this.ShuyouTaskAccountRecordEntity.createQueryBuilder()
+          .insert()
+          .into(ShuyouTaskAccountRecordEntity)
+          .values({
+            task_id: task_id,
+            account_id: account_id,
+            new_date: new Date(this.utils.formatDate(new Date())),
+            getTimeNew: new Date(), // 新增取号时间
+          })
+          .execute();
       if (!inserTaskAccountRecord) {
-        return this.fail('插入记录表失败', -1)
+        return this.fail('插入记录表失败', -1);
       }
       // this.logger.info(inserTaskAccountRecord.identifiers[0].id)
       for (const game_id of gameIdList) {
-        await this.ShuyouGameAccountRecordEntity.save({ account_id: account_id + '', game_id: game_id + '' });
+        await this.ShuyouGameAccountRecordEntity.save({
+          account_id: account_id + '',
+          game_id: game_id + '',
+        });
       }
       let obj = {
         record_id: inserTaskAccountRecord.identifiers[0].id,
@@ -205,8 +255,8 @@ export class ShuyouAppGameTaskController extends BaseController {
         imsi: list[0].imsi,
         simserial: list[0].simserial,
         androidid: list[0].androidid,
-        mac: list[0].mac
-      }
+        mac: list[0].mac,
+      };
       return this.ok(obj);
     } else {
       return this.fail('任务' + task_id + '无账号可取', -1);
@@ -216,39 +266,42 @@ export class ShuyouAppGameTaskController extends BaseController {
    * 留存获取账号接口
    * http://127.0.0.1:8001/app/shuyou/game_task/get_account_retained?task_id=3520&retained_day=2
    * @param {*} queryObject{task_id:任务id,retained_day:留存天数}
-   * @return {*} 
+   * @return {*}
    * @memberof ShuyouAppGameTaskController
    */
   @Get('/get_account_retained')
   async getAccountRetained(@Query(ALL) queryObject) {
-    let { task_id, retained_day } = queryObject
+    let { task_id, retained_day } = queryObject;
     if (!task_id || !retained_day) {
-      return this.fail('缺少必要参数[task_id=任务id&retained_day=几留]', -1)
+      return this.fail('缺少必要参数[task_id=任务id&retained_day=几留]', -1);
     }
     const taskInfo = await this.ShuyouGameTaskService.info(task_id);
     if (!taskInfo) {
-      return this.fail('task_id不存在', -1)
+      return this.fail('task_id不存在', -1);
     }
-    let retained_date = this.utils.getNextDate(new Date, 1 - retained_day)
+    let retained_date = this.utils.getNextDate(new Date(), 1 - retained_day);
     // this.logger.info(retained_date)
-    const list = await this.ShuyouGameTaskService.getAccountRetainedOne(task_id, retained_date);
+    const list = await this.ShuyouGameTaskService.getAccountRetainedOne(
+      task_id,
+      retained_date
+    );
     // this.logger.info(list)
     if (list.length > 0) {
-      const record_id = list[0].id
-      const updateTaskAccountRecord = await this.ShuyouTaskAccountRecordEntity
-        .createQueryBuilder()
-        .update()
-        .set({
-          statusRetained: -1,
-          getTimeRetained: new Date()  // 留存取号时间
-        })
-        .where('id = :id', {
-          id: record_id
-        })
-        .execute();
+      const record_id = list[0].id;
+      const updateTaskAccountRecord =
+        await this.ShuyouTaskAccountRecordEntity.createQueryBuilder()
+          .update()
+          .set({
+            statusRetained: -1,
+            getTimeRetained: new Date(), // 留存取号时间
+          })
+          .where('id = :id', {
+            id: record_id,
+          })
+          .execute();
       // this.logger.warn(updateTaskAccountRecord.affected)
       if (updateTaskAccountRecord.affected < 1) {
-        return this.fail('修改记录表失败', -1)
+        return this.fail('修改记录表失败', -1);
       }
       let obj = {
         record_id: record_id,
@@ -262,42 +315,49 @@ export class ShuyouAppGameTaskController extends BaseController {
         imsi: list[0].imsi,
         simserial: list[0].simserial,
         androidid: list[0].androidid,
-        mac: list[0].mac
-      }
+        mac: list[0].mac,
+      };
       return this.ok(obj);
     } else {
-      return this.fail('任务' + task_id + ' ' + retained_day + '留已无可取账号', -1);
+      return this.fail(
+        '任务' + task_id + ' ' + retained_day + '留已无可取账号',
+        -1
+      );
     }
   }
 
-
   /**
    * 更新账号状态
    * http://127.0.0.1:8001/app/shuyou/game_task/updateAccount?record_id=10&status=0
    * status 0.新增留存成功 1.冻结 2.密错 3.禁用 4.新增出现留存 5.人脸验证  6.信用分不足
    * @param {*} queryObject
-   * @return {*} 
+   * @return {*}
    * @memberof ShuyouAppGameTaskController
    */
   @Get('/updateAccount')
   async updateAccount(@Query(ALL) queryObject) {
-    const { record_id, status } = queryObject
+    const { record_id, status } = queryObject;
     // status 0.新增留存成功 1.冻结 2.密错 3.禁用 4.新增出现留存 5.人脸验证
-    const TaskAccountRecord = await this.ShuyouTaskAccountRecordService.updateAccount(record_id, status);
+    const TaskAccountRecord =
+      await this.ShuyouTaskAccountRecordService.updateAccount(
+        record_id,
+        status
+      );
     if (TaskAccountRecord.code == 1) {
-      await this.ShuyouGameAccountService.updateAccountState(TaskAccountRecord.account_id, status);
+      await this.ShuyouGameAccountService.updateAccountState(
+        TaskAccountRecord.account_id,
+        status
+      );
       return this.ok('修改成功');
     } else if (TaskAccountRecord.code == 2) {
       return this.fail(TaskAccountRecord.message, 2);
     } else {
       return this.fail('修改失败', -1);
     }
-
   }
 
   @Get('/getQiniuToken')
   async getQiniuToken() {
-
     var accessKey = '7_ZqHdxygi4b2rDfeYlRGcNzAotKIHny4Pw7FlrH';
     var secretKdy = 'LHkKpphENfKFMooSwptLo18xySESdS-EdY1yI59_';
     var mac = new qiNiu.auth.digest.Mac(accessKey, secretKdy);
@@ -307,10 +367,10 @@ export class ShuyouAppGameTaskController extends BaseController {
     var putPolicy = new qiNiu.rs.PutPolicy(options);
     var uploadToken = putPolicy.uploadToken(mac);
 
-    this.logger.warn(uploadToken)
+    this.logger.warn(uploadToken);
 
     return {
-      token: uploadToken
-    }
+      token: uploadToken,
+    };
   }
 }

+ 28 - 32
cool-admin-midway-master/src/app/modules/shuyou/service/file_list.ts

@@ -1,8 +1,8 @@
 /*
  * @Author: YKH
  * @Date: 2022-04-06 15:38:44
- * @LastEditTime: 2022-04-11 16:50:31
- * @Description: 
+ * @LastEditTime: 2022-11-24 15:33:08
+ * @Description:
  * @FilePath: \cool-admin\cool-admin-midway-master\src\app\modules\shuyou\service\file_list.ts
  */
 import { Provide } from '@midwayjs/decorator';
@@ -17,14 +17,13 @@ import { ShuyouFileListEntity } from '../entity/file_list';
  */
 @Provide()
 export class ShuyouFileListService extends BaseService {
-
   @InjectEntityModel(ShuyouFileListEntity)
   ShuyouFileListEntity: Repository<ShuyouFileListEntity>;
 
   /**
-  * 重写分页查询
-  * @param query
-  */
+   * 重写分页查询
+   * @param query
+   */
   async page(query) {
     const { task_id } = query;
     // console.log(query)
@@ -55,7 +54,7 @@ export class ShuyouFileListService extends BaseService {
   async add(param) {
     const exists = await this.ShuyouFileListEntity.findOne({
       task_id: param.task_id,
-      fileName: param.fileName
+      fileName: param.fileName,
     });
     // console.log(exists)
     if (!_.isEmpty(exists)) {
@@ -70,33 +69,34 @@ export class ShuyouFileListService extends BaseService {
    * @memberof ShuyouFileListService
    */
   async deleteById(id) {
-    const deleteResult = await this.ShuyouFileListEntity
-      .createQueryBuilder()
+    const deleteResult = await this.ShuyouFileListEntity.createQueryBuilder()
       .delete()
       .where('id = :id', {
-        id: id
-      }).execute()
+        id: id,
+      })
+      .execute();
     // console.log(deleteResult)
     if (deleteResult.affected >= 0) {
-      return 1000
+      return 1000;
     } else {
-      return -1
+      return -1;
     }
   }
   /**
    * 查询某task_id下某一类型文件最新一个渠道号
    * @param {*} task_id
    * @param {*} type
-   * @return {*} 
+   * @return {*}
    * @memberof ShuyouFileListService
    */
   async queryVersionByType(task_id, type) {
-    const res = await this.ShuyouFileListEntity
-      .createQueryBuilder()
+    const res = await this.ShuyouFileListEntity.createQueryBuilder()
       .where('task_id = :task_id AND type = :type', {
         task_id: task_id,
-        type: type
-      }).orderBy("fileVersion", "DESC").getOne();
+        type: type,
+      })
+      .orderBy('fileVersion', 'DESC')
+      .getOne();
     // console.log(deleteResult)
     return res;
   }
@@ -104,7 +104,7 @@ export class ShuyouFileListService extends BaseService {
   /**
    * 查询所有
    *
-   * @return {*} 
+   * @return {*}
    * @memberof ShuyouFileListService
    */
   async queryAll() {
@@ -120,32 +120,28 @@ export class ShuyouFileListService extends BaseService {
         ORDER BY task_id,type,fileVersion 
     `;
     return this.nativeQuery(sql);
-
   }
   /**
    * 删除数据库记录
    * @param {*} task_id
-   * @return {*} 
+   * @return {*}
    * @memberof ShuyouFileListService
    */
   async deleteAllByTaskId(task_id) {
     const exists = await this.ShuyouFileListEntity.find({
-      task_id: task_id
-    })
+      task_id: task_id,
+    });
     if (!_.isEmpty(exists)) {
       //删除数据库记录
-      await this.ShuyouFileListEntity
-        .createQueryBuilder()
+      await this.ShuyouFileListEntity.createQueryBuilder()
         .delete()
         .where('task_id = :task_id', {
-          task_id: task_id
-        }).execute()
-      return { code: 1, data: exists }
+          task_id: task_id,
+        })
+        .execute();
+      return { code: 1, data: exists };
     } else {
-      return { code: -1 }
+      return { code: -1 };
     }
-
-
   }
-
 }

+ 204 - 146
cool-admin-midway-master/src/app/modules/shuyou/service/game_task.ts

@@ -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) {

+ 3 - 3
cool-admin-midway-master/src/config/config.local.ts

@@ -1,8 +1,8 @@
 /*
  * @Author: YKH
  * @Date: 2021-12-08 10:26:27
- * @LastEditTime: 2022-03-31 15:48:13
- * @Description: 
+ * @LastEditTime: 2022-11-24 15:01:23
+ * @Description:
  * @FilePath: \cool-admin\cool-admin-midway-master\src\config\config.local.ts
  */
 import { EggAppConfig, EggAppInfo, PowerPartial } from 'egg';
@@ -31,7 +31,7 @@ export default (appInfo: EggAppInfo) => {
     port: 3306,
     username: 'root',
     password: 'root',
-    database: 'cool-admin',
+    database: 'cool-admin-company',
     // 自动建表 注意:线上部署的时候不要使用,有可能导致数据丢失
     synchronize: true,
     // 打印日志