Commit e2aa0390 by 杨树贤

导出供应商

parent 47a5b647
......@@ -979,4 +979,70 @@ class DataService
});
})->store('csv');
}
public function exportNotUploadSkuSupplier()
{
ini_set('memory_limit', -1);
// $time = strtotime('2021-1-1');
// $suppliers = SupplierChannelModel::where('is_type', 0)->where('uploaded_sku', 1)
$time = strtotime('2021-1-1');
$suppliers = SupplierChannelModel::where('is_type', 0)->where('uploaded_sku', '!=', 1)
->whereRaw('supplier_name NOT LIKE "%-1"')
->where('create_time', '>', $time)->get();
$excelData = [];
$header = [
'供应商编码',
'供应商名称',
'采购员',
'部门',
];
$intraCodeModel = new IntracodeModel();
$users = $intraCodeModel->getSampleName(true);
foreach ($suppliers as $supplier) {
//去采购系统找采购单金额最多的用户
$purchaseAmountMap = [];
$channelUids = PurchaseOrderModel::where('supplier_id', $supplier['supplier_id'])->pluck('purchase_uid')->unique()->toArray();
if (empty($channelUids)) {
continue;
}
//去获取对应的uid的采购金额
foreach ($channelUids as $channelUid) {
//去采购系统取采购单金额
$purchaseOrders = PurchaseOrderModel::where('purchase_uid', $channelUid)->select([
'purchase_amount',
'exchange_rate',
'currency'
])->get()->toArray();
//计算出采购金额
$totalAmount = 0;
foreach ($purchaseOrders as $purchaseOrder) {
if ($purchaseOrder['currency'] == 1) {
$totalAmount += $purchaseOrder['purchase_amount'] * $purchaseOrder['exchange_rate'] * 1.13;
} else {
$totalAmount += $purchaseOrder['purchase_amount'] * $purchaseOrder['exchange_rate'];
}
}
$purchaseAmountMap[$channelUid] = $totalAmount;
}
asort($purchaseAmountMap);
dump($purchaseAmountMap);
$maxAmountPurchaseAdminId = array_keys($purchaseAmountMap)[0];
dump($maxAmountPurchaseAdminId);
$skuUserNameRaw = UserInfoModel::where('userId', $maxAmountPurchaseAdminId)->value('name');
$skuUserDepartment = (new DepartmentService())->getDepartmentNameByUserName($skuUserNameRaw);
$itemData = [
$supplier['supplier_code'],
$supplier['supplier_name'],
$skuUserNameRaw,
$skuUserDepartment
];
$excelData[] = $itemData;
}
array_unshift($excelData, $header);
Excel::create('供应商无sku做单导出', function ($excel) use ($excelData) {
$excel->sheet('sheet1', function ($sheet) use ($excelData) {
$sheet->fromArray($excelData);
});
})->store('csv');
}
}
\ No newline at end of file
......@@ -67,7 +67,5 @@ Route::group(['middleware' => ['external'], 'namespace' => 'Sync'], function ()
});
Route::match(['get', 'post'], '/test', function () {
$data['data']['title'] = "【猎芯网】 先生/女生您好,您的“云芯入驻申请”已收到,审核结果为:不通过,原因为:,如对审核结果有疑问,可联系您在猎芯的专属渠道经理(周强),联系电话:13512343214,联系邮箱:qiang@ichunt.com";
//// (new \App\Http\Services\MessageService())->sendMessage('supplier_apply_audit_mobile', $data, 18825159814, true);
// (new \App\Http\Services\MessageService())->sendMessage('supplier_apply_audit_email', $data, '648132694@qq.com', true);
(new \App\Http\Services\DataService())->exportNotUploadSkuSupplier();
});
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment