Commit 8c8a841d by 朱继来

添加已离职人员客户导出

parent d2f1b0fa
......@@ -7,6 +7,7 @@ use App\Http\Controllers\Controller;
use App\Model\OrderModel;
use App\Model\OrderActionLogModel;
use DB;
use Excel;
class SpecialController extends Controller
{
......@@ -63,4 +64,56 @@ class SpecialController extends Controller
echo '运费更新成功';
}
// 导出已离职人员数据 (业务ID、业务人、关联会员账号、公司名称)
public function exportDimission()
{
// 查找已离职人员
$dimission = DB::table('user_info')->where('status', 4)->select('userId', 'name')->get();
if (empty($dimission)) {
echo '无离职人员';die;
}
$sales = [];
$sale_ids = [];
foreach ($dimission as $v) {
$sales[$v->userId] = $v->name;
$sale_ids[] = $v->userId;
}
// 查找离职人员订单
$OrderModel = new OrderModel();
$order_info = $OrderModel->from('lie_order as o')
->leftJoin('lie_user_main as u', 'o.user_id', '=', 'u.user_id')
->leftJoin('lie_user_company as c', 'o.user_id', '=', 'c.user_id')
->whereIn('o.sale_id', $sale_ids)
->select('o.order_id', 'o.user_id', 'o.sale_id', 'u.mobile', 'u.email', 'c.com_name')
->get();
if (empty($order_info)) {
echo '无离职人员订单';die;
}
$cellData = [];
foreach ($order_info as $k=>$v) {
$cellData[$k]['sale_id'] = $v['sale_id'];
$cellData[$k]['sale_name'] = $sales[$v['sale_id']];
$cellData[$k]['account'] = $v['mobile'] ? $v['mobile'] : $v['email'];
$cellData[$k]['com_name'] = $v['com_name'];
}
$headerCell = ['业务ID', '业务员名称', '关联会员账号', '公司名称'];
array_unshift($cellData, $headerCell);
$fileName = '已离职人员关联客户'.date('_YmdHis');
Excel::create($fileName, function($excel) use ($cellData){
$excel->sheet('人员导出', function($sheet) use ($cellData){
$sheet->rows($cellData);
});
})->export('xls');
}
}
\ No newline at end of file
......@@ -126,6 +126,7 @@ Route::group(['middleware' => 'api'], function () {
Route::get ('/api/check/sendsms', 'OrderController@checkOrderSendSms');
Route::get ('/api/check/cancelorder', 'OrderController@checkOrderCancel');
Route::get ('/api/check/histroyorder', 'OrderController@checkHistroyOrder');
Route::get ('/api/check/changeprice', 'SpecialController@changeOrderPrice');
Route::get ('/api/check/changeprice', 'SpecialController@changeOrderPrice');
Route::get ('/api/check/exportdimission', 'SpecialController@exportDimission');
});
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