import request from '@/router/axios';
/*获取列表*/
export const getList =
    (current, size, params) => {
      return request({
        url: '/api/jobslink-api/payment/businessOrder/tenant/order',
        method: 'get',
        params: {
          ...params,
          current,
          size,
        }
      })
    }

/*查看订单详情列表*/
export const getDetail =
    (payOrderId) => {
      return new Promise(function(resolve, reject) {
        request({
          url: '/api/jobslink-api/payment/businessOrder/find/detail',
          method: 'get',
          params: {payOrderId}
        })
            .then((resp) => {
              const data = resp.data.data;
              if (data.length !== 0) {
                const result = {
                  createUser1: data[0].createUser1,
                  createTime1: data[0].createTime1,
                  status1: data[0].status1,
                  payTime1: data[0].payTime1,
                  wageTotalNum: data[0].wageTotalNum,        //工资总额
                  serviceTotalNum: data[0].serviceTotalNum,  //服务费总额
                  data: []
                };
                data.forEach(element => {
                  result.data.push({
                    missionTitle: element.missionTitle,
                    type: 1,
                    payrollNo: element.payrollNo,
                    total: element.wageTotal  //工资
                  });
                  result.data.push({
                    missionTitle: element.missionTitle,
                    type: 2,
                    payrollNo: element.payrollNo,
                    total: element.serviceTotal  //服务费
                  });
                });
                resolve(result);
              } else {
                const result = {
                  createUser1: '',
                  createTime1: '',
                  status1: '',
                  payTime1: '',
                  wageTotalNum: '',
                  serviceTotalNum: '',
                  data: []
                };
                resolve(result);
              }
            })
            .catch(reject)
      })
    }

/*删除*/
export const remove =
    (payOrderId) => {
      return request({
        url: '/api/jobslink-api/payment/businessOrder/cancel',
        method: 'post',
        params: {payOrderId}
      })
    }

/*建行支付*/
export const cbc = (goodsId, total) => {
  return request({
    url: '/api/jobslink-api/payment/payment/send/cbc',
    method: 'post',
    params: {goodsId, total}
  })
}
