import 'request.dart';

const int limit = 10;
//登录接口
Future login(phone, passwrod) async {
  var response = await Http().post('app/uzer/logistics/phone_login', data: {
    "phone": phone,
    "password": passwrod
  });
  return response;
}

//token验证
Future checkToken(String token) async{
  var response = await Http().post('app/uzer/logistics/check_token',data:{'token':token});
  return response;
}

//获取接单列表
Future getOrderList(String stationId,String lineId, int page) async {
  var response = await Http().post('app/order/wait_order_list_pages', data: {
    'stationId':stationId,
    'lineId': lineId,
    'limit': limit,
    'page': page
  });
  return response;
}


//获取所有站点
Future getStationList() async {
  var response = await Http().get('app/station/station_list');
  return response;
}

//根据站点获取线路
Future getAllLine() async {
  var response = await Http().get('app/line/line_all');
  return response;
}

//修改密码
Future updataPasswrod(oldPassword, newPassword) async {
  var response = await Http().post('app/uzer/logistics/update_password', data: {
    'oldPassword': oldPassword,
    'newPassword': newPassword
  });
  return response;
}

//发件(创建订单)
Future createOrder(
  String lineId,
  String statiodId,//司机站点id
  String sendCompanyId, //寄件公司Id
  String sendCompanyName, //寄件公司名称 不能为空
  String sendCompanyPhone, //寄件公司电话 不能为空
  String sendCompanyCode, //寄件公司编码 
  String sendCompanyProvinceName, //寄件公司省名称 不能为空
  String sendCompanyProvinceCode, //寄件公司省编码 不能为空
  String sendCompanyCityName, //寄件公司市名称 不能为空
  String sendCompanyCityCode, //寄件公司市编码 不能为空
  String sendCompanyAreaName, //寄件公司区名称 不能为空
  String sendCompanyAreaCode, //寄件公司区编码 不能为空
  String sendCompanyAddress, //寄件公司详细地址，不能为空
  String receiptCompanyId, //收件公司id
  String receiptCompanyPhone, //收件公司电话 不能为空
  String receiptCompanyName, //收件公司名称 不能为空
  String receiptCompanyProvinceName, //收件公司省名称 不能为空
  String receiptCompanyProvinceCode, //收件公司省编码 不能为空
  String receiptCompanyCityName, //收件公司市名称 不能为空
  String receiptCompanyCityCode, //收件公市编码 不能为空
  String receiptCompanyAreaName, //收件公区名称 不能为空
  String receiptCompanyAreaCode, //收件公司区编码 不能为空
  String receiptCompanyAddress, //收件公司地址详情 不能为空
  String goods, //商品名称不能为空
  int goodsQuantity, //商品数量 不能为空
  int goodsPackingId, //商品包装ID 不能为空
  int goodsCategoryId, //商品类别ID 不能为空
  int goodsPaymentMethod, //付款方式 不能为空
  double goodsWeight, //商品重量 
  double goodsPriceProtection, //商品保价
  double goodsAgencyFund, //商品代收款
  double goodsFreight, //运费 不能为空
  String memo //备注
) async {
  var response = await Http().post('app/order/logistics_order_create', data: {
    'lineId':lineId,
    'stationId':statiodId,
    'sendCompanyId': sendCompanyId,
    'sendCompanyName': sendCompanyName,
    'sendCompanyPhone': sendCompanyPhone,
    'sendCompanyCode': sendCompanyCode,
    'sendCompanyProvinceName': sendCompanyProvinceName,
    'sendCompanyProvinceCode': sendCompanyProvinceCode,
    'sendCompanyCityName': sendCompanyCityName,
    'sendCompanyCityCode': sendCompanyCityCode,
    'sendCompanyAreaName': sendCompanyAreaName,
    'sendCompanyAreaCode': sendCompanyAreaCode,
    'sendCompanyAddress': sendCompanyAddress,
    'receiptCompanyId': receiptCompanyId,
    'receiptCompanyPhone': receiptCompanyPhone,
    'receiptCompanyName': receiptCompanyName,
    'receiptCompanyProvinceName': receiptCompanyProvinceName,
    'receiptCompanyProvinceCode': receiptCompanyProvinceCode,
    'receiptCompanyCityName': receiptCompanyCityName,
    'receiptCompanyCityCode': receiptCompanyCityCode,
    'receiptCompanyAreaName': receiptCompanyAreaName,
    'receiptCompanyAreaCode': receiptCompanyAreaCode,
    'receiptCompanyAddress': receiptCompanyAddress,
    'goods': goods,
    'goodsQuantity': goodsQuantity,
    'goodsPackingId': goodsPackingId,
    'goodsCategoryId': goodsCategoryId,
    'goodsPaymentMethod': goodsPaymentMethod,
    'goodsWeight': goodsWeight,
    'goodsPriceProtection': goodsPriceProtection,
    'goodsAgencyFund': goodsAgencyFund,
    'goodsFreight': goodsFreight,
    'memo': memo
  });
  return response;
}

//模糊匹配手机号
Future likePhone(String phone) {
  var response = Http().get('app/uzer_company/uzer_company_like', data: {
    'phone': phone
  });
  return response;
}

//商品类别
Future goodsCategory() {
  var response = Http().get('app/goods_category/goods_category_list');
  return response;
}
//商品包装类别
Future goodsPackage() {
  var response = Http().get('app/goods_packing/goods_packing_list');
  return response;
}

//订单详情
Future getOrderDetail(orderNo) {
  var response = Http().get('app/order/order_info', data: {
    'orderNo': orderNo
  });
  return response;
}

//接单接口
Future orderReception(orderNo) {
  var response = Http().get('app/order/order_reception', data: {
    'orderNo': orderNo
  });
  return response;
}

//订单管理接口  0:代收单，1：已接单，2:配送中，3:已签收，4:拒收
Future fromStatusGetOrderList(int orderStatus, int page, String orderNo) {
  var response = Http().post('app/order/logistics_order_list_pages', data: {
    'orderNo': orderNo,
    'orderStatus': orderStatus,
    'page': page,
    'limit': limit
  });
  return response;
}

//改单接口
Future updataOrder(String lineId,String orderNo, double afterTransportFee, double afterCollectingFee, int afterGoodsNumber) {
  var response = Http().post('app/order/update_order', data: {
    'orderNo': orderNo,
    'afterTransportFee': afterTransportFee * 100,
    'afterCollectingFee': afterCollectingFee * 100,
    'afterGoodsNumber': afterGoodsNumber
  });
  return response;
}

//作废、拒收、签收接口
Future updataOrderStatus(String orderNo, int orderStatus) {
  var response = Http().post('app/order/update_order_status', data: {
    'orderNo': orderNo,
    'orderStatus': orderStatus
  });
  return response;
}

//模糊匹配订单号
Future orderNoLike(String orderNo,int orderStatus) {
  var response = Http().get('app/order/order_no_like', data: {
    'orderNo': orderNo,
    'orderStatus':orderStatus
  });
  return response;
}

//根据公司id取得线路
Future getLineOfCompanyId(String companyId){
  var response = Http().get('app/company/line/relation/company_line_relation_list', data: {
    'companyId': companyId,
  });
    return response;
}