import Mock from 'mockjs'

function fakeSuccess() {
  return {code: 200, success: true, msg: '操作成功'};
}
let Random = Mock.Random;

export default ({mock}) => {
  if (!mock) return;

  Mock.mock(/\/api\/jobslink-system\/agentpay\/waiting[.]*?/, 'get', () => {
    const json = {code: 200, success: true, msg: '操作成功'};
    const list = [];
    for (let i = 0; i < 5; i++) {
      list.push(Mock.mock({
        telphone: '@increment',
        identity: '@increment',
        name: Mock.mock('@cname'),
        companyName: Mock.mock('@cname'),
        'total|1-99.0-99': 1,
      }))
    }

    json.data = {
      total: 10,
      size: 10,
      current: 1,
      searchCount: true,
      pages: 1,
      records: list,
    };
    return json;
  })

  Mock.mock(/\/api\/jobslink-system\/agentpay\/taxcount[.]*?/, 'get', () => {
    const json = {code: 200, success: true, msg: '操作成功'};
    const list = [];
    for (let i = 0; i < 5; i++) {
      list.push(Mock.mock({
        taxPayrollNo: '@increment',
        insureNo: '@increment',
        name: Mock.mock('@cname'),
        'preTotal|1-99': 1,
        'taxStatus|0-1': 1,
        'orderStatus|0-1': 1,
        createUser: Mock.mock('@cname'),
        createTime: Random.datetime('yyyy-MM-dd'),
      }))
    }

    json.data = {
      total: 10,
      size: 10,
      current: 1,
      searchCount: true,
      pages: 1,
      records: list,
    };
    return json;
  })

  Mock.mock(/\/api\/jobslink-system\/agentpay\/detail/, 'get', () => {
    const json = {code: 200, success: true, msg: '操作成功'};
    const list = [];
    for (let i = 0; i < 5; i++) {
      list.push(Mock.mock({
        id: '@increment',
        realName: Mock.mock('@cname'),
        cardNumber: '123456789987654321',
        'wage|1-9999.0-99': 1,
        'wageReal|1-9999.0-99': 1,
        'tax|1-9999.0-99': 1,
      }))
    }

    json.data = {
      total: 10,
      size: 10,
      current: 1,
      searchCount: true,
      pages: 1,
      records: list,
    };
    return json;
  })

  Mock.mock(/\/api\/jobslink-system\/insure\/submit/, 'post', fakeSuccess);
}
