Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
朱继来
/
后台订单管理
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
0283bc37
authored
Jun 11, 2020
by
朱继来
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
调整邮件发送
parent
d9f9b8da
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
66 additions
and
59 deletions
app/Http/Controllers/OrderController.php
app/Http/Controllers/PermController.php
public/js/order_send_email.js
resources/views/orderlist/content.blade.php
app/Http/Controllers/OrderController.php
View file @
0283bc37
...
...
@@ -699,7 +699,7 @@ Class OrderController extends Controller
}
}
else
{
$perm
=
new
PermController
;
$info
[
'buyers'
]
=
$perm
->
getUserBy
Condition
(
''
,
39
);
// 获取采购员, ID - 39
$info
[
'buyers'
]
=
$perm
->
getUserBy
DepartmentId
(
8
,
0
);
// 获取采购部人员
$perm
=
new
PermController
;
$sale_list
=
$perm
->
getUserByDepartmentId
(
Config
(
'perm_args.sales_department_id'
),
0
);
// 获取所有的销售
...
...
@@ -2069,13 +2069,18 @@ 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'
]);
//获取业务员
//循环订单详情
foreach
(
$info
[
'order_items_info'
]
as
$key
=>
$value
)
{
if
(
empty
(
$value
[
'batch'
]))
return
[
'errcode'
=>-
1
,
'errmsg'
=>
'商品:'
.
$
tmp
[
'goods
'
]
.
'缺少批次<br/>'
.
'请填写批次后再发送'
];
if
(
empty
(
$value
[
'buyerName'
]))
return
[
'errcode'
=>-
1
,
'errmsg'
=>
'商品:'
.
$
tmp
[
'goods
'
]
.
'缺少采购人员<br/>'
.
'请填写采购后再发送'
];
if
(
empty
(
$value
[
'batch'
]))
return
[
'errcode'
=>-
1
,
'errmsg'
=>
'商品:'
.
$
value
[
'goods_name
'
]
.
'缺少批次<br/>'
.
'请填写批次后再发送'
];
if
(
empty
(
$value
[
'buyerName'
]))
return
[
'errcode'
=>-
1
,
'errmsg'
=>
'商品:'
.
$
value
[
'goods_name
'
]
.
'缺少采购人员<br/>'
.
'请填写采购后再发送'
];
$tmp
=
[];
$tmp
[
'orderNum'
]
=
$info
[
'order_temp_info'
][
'erp_sn'
];
$tmp
[
'goods'
]
=
$value
[
'goods_name'
];
$tmp
[
'purchasingPrice'
]
=
$value
[
'goods_price'
];
//采购价
...
...
@@ -2086,35 +2091,50 @@ Class OrderController extends Controller
$tmp
[
'totalPrice'
]
=
$value
[
'goods_amount'
];
$tmp
[
'remarks'
]
=
$value
[
'remarks'
];
$tmp
[
'material'
]
=
$value
[
'erp_rec_id'
];
$tmp
[
'purchasing'
]
=
!
empty
(
$value
[
'buyerName'
])
?
$value
[
'buyerName'
]
:
''
;
$tmp
[
'projectId'
]
=
$key
+
1
;
$tmp
[
'purchasing'
]
=
!
empty
(
$value
[
'buyerName'
])
?
$value
[
'buyerName'
]
:
''
;
$tmp
[
'deliveryTime'
]
=
$value
[
'batch'
];
//批次
$tmp
[
'send_email'
]
=
!
empty
(
$value
[
'send_email'
])
?
$value
[
'send_email'
]
:
''
;
$data
[
'data'
][]
=
$tmp
;
}
$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
;
//循环出邮件接收人
foreach
(
$data
[
'data'
]
as
$key
=>
$value
)
{
$send_mail_array
[]
=
$value
[
'send_email'
];
$tmp
[
'projectId'
]
=
$key
+
1
;
$data
[
'data'
][]
=
$tmp
;
}
$send_mail_array
=
array_unique
(
$send_mail_array
);
if
(
empty
(
$send_mail_array
[
0
]))
return
[
'errcode'
=>-
1
,
'errmsg'
=>
'没有填写采购人员,请至少填写一个采购人员'
]
;
// 各个采购邮件推入队列
foreach
(
$send_buyers
as
&
$v
)
{
$v
[
'combined'
]
=
0
;
$data
[
'toUser'
]
=
$send_mail_array
;
// 收件人
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
;
$manager_email
=
$perm
->
getManager
(
$request
->
user
->
userId
);
// 获取上级主管邮箱
$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'
));
if
(
$manager_email
)
{
$cc_send_mail_array
=
array_merge
(
$cc_send_mail_array
,
$manager_email
);
// 合并上级主管邮箱
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
[]
=
$request
->
user
->
email
;
// 默认抄送给自己
$cc_send_mail_array
=
array_unique
(
$cc_send_mail_array
);
// 去重
$cc_email_arr
=
[];
...
...
@@ -2128,46 +2148,27 @@ Class OrderController extends Controller
}
}
$data
[
'ccUser'
]
=
array_unique
(
array_merge
(
$cc_send_mail_array
,
$cc_email_arr
));
$data
[
'combined'
]
=
$info
[
'order_info'
][
'order_amount'
];
$data
[
'order_amount'
]
=
$info
[
'order_info'
][
'order_amount'
];
$data
[
'date'
]
=
date
(
'Y-m-d'
,
time
());
$data
[
'kefu_remark'
]
=
$info
[
'order_temp_info'
][
'kefu_remark'
];
// 客服备注
$CmsModel
=
new
CmsModel
();
$data
[
'id'
]
=
$CmsModel
->
getUserName
(
$info
[
'order_info'
][
'sale_id'
]);
//获取业务员
$data
[
'ccUser'
]
=
array_unique
(
array_merge
(
$cc_send_mail_array
,
$cc_email_arr
));
$data
[
'combined'
]
=
$info
[
'order_info'
][
'order_amount'
];
$data
[
'order_amount'
]
=
$info
[
'order_info'
][
'order_amount'
];
$data
[
'date'
]
=
date
(
'Y-m-d'
,
time
());
$data
[
'kefu_remark'
]
=
$info
[
'order_temp_info'
][
'kefu_remark'
];
// 客服备注
$data
[
'id'
]
=
$sale_name
;
$data
[
'order_id'
]
=
intval
(
$id
);
$data
[
'operator_id'
]
=
intval
(
$request
->
user
->
userId
);
$data
[
'operator_event'
]
=
'发送邮件成功,收件人邮箱:'
.
json_encode
(
$send_mail_array
)
.
',抄送人邮箱:'
.
json_encode
(
$data
[
'ccUser'
]);
$data
[
'operator_event'
]
=
'发送邮件成功,收件人邮箱:'
.
json_encode
(
$data
[
'toUser'
])
.
',抄送人邮箱:'
.
json_encode
(
$data
[
'ccUser'
]);
$this
->
pushQueue
(
$data
);
return
[
'errcode'
=>
0
,
'errmsg'
=>
'推送到邮件队列成功,请稍等...'
];
}
public
function
pushQueue
(
$data
)
{
// 推入到邮件队列
$QueuedModel
=
new
QueuedModel
();
$queued_name
=
'send_buyer_mail'
;
$QueuedModel
->
pushAmq
(
'ichunt_order_msg'
,
$queued_name
,
$queued_name
,
json_encode
(
$data
));
return
[
'errcode'
=>
0
,
'errmsg'
=>
'推送到邮件队列成功,请稍等...'
];
// $crm_url = Config('website.crm_domain').'/api/sendCaiGouEmailByOrderAdmin';
// $data = json_encode($data);
// $crm_header = array('api-key: crm a1b2c3d4e5f6g7h8i9jk');
// $res = json_decode(post_curl($crm_url, $data,$crm_header));
// if(!empty($res->err_code) && $res->err_code == 0){
// // 操作日志
// $OrderActionLogModel = new OrderActionLogModel();
// $event = '发送邮件成功,收件人邮箱:'.json_encode($send_mail_array).',抄送人邮箱:'.json_encode($data['ccUser']);
// $actionLog = $OrderActionLogModel->addLog($id, $request->user->userId, 2, $event);
// echo json_encode(['errcode'=>1,'errmsg'=>'发送成功']);
// exit;
// }else{
// echo json_encode(['errcode'=>-1,'errmsg'=>'邮件发送接口错误,邮件发送失败']);
// exit;
// }
}
}
\ No newline at end of file
app/Http/Controllers/PermController.php
View file @
0283bc37
...
...
@@ -369,8 +369,13 @@
// return $email;
// }
// 获取角色对应的主管邮箱
public
function
getManager
(
$userId
)
/**
* 获取角色对应的主管邮箱
* @param [type] $userId [description]
* @param [type] $position_id [主管ID]
* @return [type] [description]
*/
public
function
getManager
(
$userId
,
$position_id
)
{
// 获取当前所在部门
$department_id
=
DB
::
table
(
'user_info'
)
->
where
(
'userId'
,
$userId
)
->
value
(
'department_id'
);
...
...
@@ -379,7 +384,7 @@
$map
=
[];
$map
[
'department_id'
]
=
$department_id
;
$map
[
'position_id'
]
=
63
;
// 销售经理
$map
[
'position_id'
]
=
$position_id
;
$email
=
DB
::
table
(
'user_info'
)
->
where
(
$map
)
->
select
(
'email'
)
->
get
();
...
...
@@ -457,7 +462,7 @@
return
DB
::
table
(
'user_info'
)
->
where
(
$map
)
->
select
(
'userId'
,
'name'
,
'position_id'
,
'position_name'
,
'department_id'
,
'department_name'
,
'status'
)
->
get
();
}
// 获取下级所有人员
// 获取
指定用户
下级所有人员
public
function
getSubSaleId
(
$userId
)
{
$sale_ids
=
[];
...
...
public/js/order_send_email.js
View file @
0283bc37
...
...
@@ -52,6 +52,8 @@
layer
.
alert
(
'网络异常'
);
}
});
layer
.
msg
(
'推送中...'
,
{
icon
:
16
,
time
:
0
,
shade
:
0.3
});
},
btn2
:
function
(
index
){
layer
.
close
(
index
);
...
...
resources/views/orderlist/content.blade.php
View file @
0283bc37
...
...
@@ -289,7 +289,7 @@
</td>
<td
class=
"show-list"
>
<?php
if
(
$order_extend
->
is_manager_audit
)
{
if
(
isset
(
$order_extend
->
is_manager_audit
)
&&
$v
[
'status'
]
==
1
)
{
echo
'<span class="list-text-checking"><b>待主管审核</b></span>'
;
}
else
{
switch
(
$v
[
'status'
])
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment