Commit e7b57553 by 朱继来

调整邮件

parent 4fe55788
......@@ -2069,11 +2069,11 @@ Class OrderController extends Controller
{
$id = $request->input('id');
$cc_email = $request->input('cc_email', ''); // 额外抄送人
$info = $this->orderDetail($request, $id);
$info = $this->orderDetail($request, $id);
$send_buyers = []; // 发送采购邮件数据
$CmsModel = new CmsModel();
$sale_name = $CmsModel->getUserName($info['order_info']['sale_id']); //获取业务员
$sale_name = $CmsModel->getUserName($info['order_info']['sale_id']); //获取业务员
//循环订单详情
foreach ($info['order_items_info'] as $key => $value) {
......@@ -2097,47 +2097,24 @@ Class OrderController extends Controller
$tmp['deliveryTime'] = $value['batch']; //批次
$tmp['send_email'] = !empty($value['send_email'])?$value['send_email']:'';
$send_buyers[$value['send_email']]['data'][] = $tmp;
$send_buyers[$value['send_email']]['toUser'] = $value['send_email'];
$send_buyers[$value['send_email']]['ccUser'] = [];
$send_buyers[$value['send_email']]['date'] = date('Y-m-d',time());
$send_buyers[$value['send_email']]['date'] = intval($id);
$send_buyers[$value['send_email']]['id'] = $sale_name;
$send_buyers[$value['buyer_id']]['data'][] = $tmp;
$send_buyers[$value['buyer_id']]['toUser'] = $value['send_email'];
$send_buyers[$value['buyer_id']]['date'] = date('Y-m-d',time());
$send_buyers[$value['buyer_id']]['date'] = intval($id);
$send_buyers[$value['buyer_id']]['id'] = $sale_name;
$send_buyers[$value['buyer_id']]['ccUser'] = [];
$tmp['projectId'] = $key+1;
$data['data'][] = $tmp;
}
// 各个采购邮件推入队列
foreach ($send_buyers as &$v) {
$v['combined'] = 0;
foreach ($v['data'] as $item) {
$v['combined'] += $item['totalPrice'];
}
$this->pushQueue($v);
}
$data['toUser'] = $request->user->email; // 收件人
$cc_send_mail_array = Config('config.cc_email'); // 固定抄送人
$perm = new PermController;
$kefu_manager_email = $perm->getManager($request->user->userId, 63); // 获取当前客服的上级主管邮箱,63-销售经理
$kefu_manager_email && $cc_send_mail_array = array_merge($cc_send_mail_array, $kefu_manager_email); // 合并上级主管邮箱
// 获取采购经理
$buyer_ids = array_unique(array_column($info['order_items_info'], 'buyer_id'));
foreach ($buyer_ids as $v) {
$buyer_manager_email = $perm->getManager($v, 41); // 获取当前采购的上级主管邮箱,41-采购经理
$buyer_manager_email && $cc_send_mail_array = array_merge($cc_send_mail_array, $buyer_manager_email);
}
$cc_send_mail_array = array_unique($cc_send_mail_array); // 去重
$kefu_manager_email && $cc_send_mail_array = array_merge($cc_send_mail_array, $kefu_manager_email); // 合并上级主管邮箱
$cc_email_arr = [];
......@@ -2150,7 +2127,28 @@ Class OrderController extends Controller
}
}
$data['ccUser'] = array_unique(array_merge($cc_send_mail_array, $cc_email_arr));
$cc_send_mail_array = array_unique(array_merge($cc_send_mail_array, $cc_email_arr));
// 各个采购邮件推入队列
foreach ($send_buyers as $k => &$v) {
$v['combined'] = 0;
$v['ccUser'] = $cc_send_mail_array;
foreach ($v['data'] as $item) {
$v['combined'] += $item['totalPrice'];
}
// 若不属于自营采购部,则添加联营采购管理人员
if (!$perm->checkUserDepartment($k, 51)) {
$joint_purchase_manager = Config('config.joint_purchase_manager');
$v['ccUser'] = array_merge($cc_send_mail_array, $joint_purchase_manager);
}
$this->pushQueue($v);
}
$data['toUser'] = $request->user->email; // 收件人
$data['ccUser'] = $cc_send_mail_array;
$data['combined'] = $info['order_info']['order_amount'];
$data['order_amount'] = $info['order_info']['order_amount'];
$data['date'] = date('Y-m-d',time());
......
......@@ -518,5 +518,15 @@
return $user;
}
// 检查用户是否属于某部门
public function checkUserDepartment($userId, $department_id)
{
$map = [];
$map['userId'] = $userId;
$map['department_id'] = $department_id;
return DB::table('user_info')->where($map)->select('userId')->first();
}
}
\ No newline at end of file
......@@ -23,4 +23,9 @@ return [
// 'zoe@ichunt.com',
],
// 联营采购负责人
'joint_purchase_manager' => [
'zty@ichunt.com',
],
];
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