/*
 * @Author: YKH
 * @Date: 2021-12-08 10:26:27
 * @LastEditTime: 2022-06-28 11:29:40
 * @Description: 
 * @FilePath: \cool-admin\cool-admin-midway-master\src\app\modules\shuyou\service\data_23.ts
 */
import { Inject, Provide } from '@midwayjs/decorator';
import { BaseService } from 'midwayjs-cool-core';
import { InjectEntityModel } from '@midwayjs/orm';
import { Repository } from 'typeorm';
import * as _ from 'lodash';
import { ShuyouData23Entity } from '../entity/data_23';
import { Utils } from '../../../comm/utils';

/**
 * 游戏目标
 */
@Provide()
export class ShuyouData23Service extends BaseService {

  @InjectEntityModel(ShuyouData23Entity)
  ShuyouData23Entity: Repository<ShuyouData23Entity>;

  @Inject()
  utils: Utils;
  /**
  * 重写list查询
  * @param query
  */
  async list(query) {
    const { date } = query;
    // console.log(date)
    const sql = `
          SELECT
            a.*,
            b.name as director_name
          FROM
            shuyou_data_23 a
            LEFT JOIN shuyou_game_director b ON a.directorId = b.id 
          WHERE 1 = 1
            and incomplete_pay > 0
            ${this.setSql(date, 'and a.new_date >= ? and a.new_date <= ?', [this.utils.formatDate(new Date(date[0])), this.utils.formatDate(new Date(date[1]))])}
        `;
    return this.nativeQuery(sql);
  }


}
