Commit 6e12e0c3 by 朱继来

Merge branch 'zjl_commit_20200526'

parents 456a5a2c 067b1512
...@@ -898,7 +898,8 @@ Class OrderController extends Controller ...@@ -898,7 +898,8 @@ Class OrderController extends Controller
$order_goods_type = $request->input('order_goods_type', 1); $order_goods_type = $request->input('order_goods_type', 1);
if ($order_goods_type == 1) { if ($order_goods_type == 1) {
$resData['status'] = $auditor_role == 3 ? 1 : 2; // 角色为‘查看自己’时,状态为待审核,否则为待付款 // $resData['status'] = $auditor_role == 3 ? 1 : 2; // 角色为‘查看自己’时,状态为待审核,否则为待付款
$resData['is_manager'] = $auditor_role == 3 ? 0 : 1; // 角色为‘查看自己’时,is_manager = 0
} }
$url = Config('website.api_domain').'order/changeOrder'; $url = Config('website.api_domain').'order/changeOrder';
...@@ -910,6 +911,23 @@ Class OrderController extends Controller ...@@ -910,6 +911,23 @@ Class OrderController extends Controller
} }
} }
// 申请主管审核
public function ajaxApplyManagerAudit(Request $request)
{
if ($request->isMethod('post')) {
$data['order_id'] = $request->input('order_id', '');
$data['operator_id'] = $request->user->userId;
$data['k1'] = time();
$data['k2'] = md5(md5($data['k1']).'fh6y5t4rr351d2c3bryi');
$url = Config('website.api_domain').'order/applyManagerAudit';
$temp = json_decode(curlApi($url, $data, "POST"), true);
return array('errcode'=>$temp['err_code'], 'errmsg'=>$temp['err_msg']);
}
}
// 主管审核 // 主管审核
public function ajaxAuditPass(Request $request) public function ajaxAuditPass(Request $request)
{ {
...@@ -2075,6 +2093,8 @@ Class OrderController extends Controller ...@@ -2075,6 +2093,8 @@ Class OrderController extends Controller
$CmsModel = new CmsModel(); $CmsModel = new CmsModel();
$sale_name = $CmsModel->getUserName($info['order_info']['sale_id']); //获取业务员 $sale_name = $CmsModel->getUserName($info['order_info']['sale_id']); //获取业务员
$to_user_array = [];
//循环订单详情 //循环订单详情
foreach ($info['order_items_info'] as $key => $value) { foreach ($info['order_items_info'] as $key => $value) {
if ($value['status'] == -1) continue; if ($value['status'] == -1) continue;
...@@ -2092,53 +2112,29 @@ Class OrderController extends Controller ...@@ -2092,53 +2112,29 @@ Class OrderController extends Controller
$tmp['currency'] = $info['order_info']['currency'] == 1?'人民币':'美元'; $tmp['currency'] = $info['order_info']['currency'] == 1?'人民币':'美元';
$tmp['totalPrice'] = number_format($value['goods_number'] * $value['single_pre_price'], 2, '.', ''); $tmp['totalPrice'] = number_format($value['goods_number'] * $value['single_pre_price'], 2, '.', '');
$tmp['remarks'] = $value['remarks']; $tmp['remarks'] = $value['remarks'];
$tmp['material'] = $value['erp_rec_id']; $tmp['material'] = $value['material_number'];
$tmp['purchasing'] = !empty($value['buyerName'])?$value['buyerName']:''; $tmp['purchasing'] = !empty($value['buyerName'])?$value['buyerName']:'';
$tmp['deliveryTime'] = $value['batch']; //批次 $tmp['deliveryTime'] = $value['batch']; //批次
$tmp['send_email'] = !empty($value['send_email'])?$value['send_email']:''; $tmp['send_email'] = !empty($value['send_email'])?$value['send_email']:'';
$send_buyers[$value['send_email']]['data'][] = $tmp; $send_buyers[$value['buyer_id']]['data'][] = $tmp;
$send_buyers[$value['send_email']]['toUser'] = $value['send_email']; $send_buyers[$value['buyer_id']]['toUser'] = $value['send_email'];
$send_buyers[$value['send_email']]['ccUser'] = []; $send_buyers[$value['buyer_id']]['date'] = date('Y-m-d',time());
$send_buyers[$value['send_email']]['date'] = date('Y-m-d',time()); $send_buyers[$value['buyer_id']]['date'] = intval($id);
$send_buyers[$value['send_email']]['date'] = intval($id); $send_buyers[$value['buyer_id']]['id'] = $sale_name;
$send_buyers[$value['send_email']]['id'] = $sale_name;
$tmp['projectId'] = $key+1; $to_user_array[] = $value['send_email'];
$data['data'][] = $tmp;
}
// 各个采购邮件推入队列 // $tmp['projectId'] = $key+1;
foreach ($send_buyers as &$v) { // $data['data'][] = $tmp;
$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'); // 固定抄送人 $cc_send_mail_array = Config('config.cc_email'); // 固定抄送人
$perm = new PermController; $perm = new PermController;
$kefu_manager_email = $perm->getManager($request->user->userId, 63); // 获取当前客服的上级主管邮箱,63-销售经理 $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); // 合并上级主管邮箱 $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); // 去重
$cc_email_arr = []; $cc_email_arr = [];
if ($cc_email) { // 后台选择的额外抄送人 if ($cc_email) { // 后台选择的额外抄送人
...@@ -2150,17 +2146,58 @@ Class OrderController extends Controller ...@@ -2150,17 +2146,58 @@ 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));
$data['combined'] = $info['order_info']['order_amount'];
$data['order_amount'] = $info['order_info']['order_amount']; // 各个采购邮件推入队列
$data['date'] = date('Y-m-d',time()); foreach ($send_buyers as $k => &$v) {
$data['kefu_remark'] = $info['order_temp_info']['kefu_remark']; // 客服备注 $v['combined'] = 0;
$data['id'] = $sale_name;
$data['order_id'] = intval($id); foreach ($v['data'] as $item) {
$data['operator_id'] = intval($request->user->userId); $v['combined'] += $item['totalPrice'];
$data['operator_event'] = '发送邮件成功,收件人邮箱:'.json_encode($data['toUser']).',抄送人邮箱:'.json_encode($data['ccUser']); }
// 若不属于自营采购部,则添加联营采购管理人员
if (!$perm->checkUserDepartment($k, 51)) {
$joint_purchase_manager = Config('config.joint_purchase_manager');
$cc_send_mail_array = array_merge($cc_send_mail_array, $joint_purchase_manager);
}
array_push($cc_send_mail_array, $request->user->email); // 默认抄送给当前客服
$cc_send_mail_array = array_unique($cc_send_mail_array);
$v['ccUser'] = $cc_send_mail_array;
$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());
// $data['id'] = $sale_name;
// $data['order_id'] = intval($id);
// $data['operator_id'] = intval($request->user->userId);
// $data['operator_event'] = '发送邮件成功,收件人邮箱:'.json_encode($data['toUser']).',抄送人邮箱:'.json_encode($data['ccUser']);
// $this->pushQueue($data);
$event = '发送邮件成功,收件人邮箱:'.json_encode($to_user_array).',抄送人邮箱:'.json_encode($cc_send_mail_array);
// 添加操作日志
$OrderActionLogModel = new OrderActionLogModel;
$OrderActionLogModel->addLog($id, $request->user->userId, 2, $event);
// 同步到ERP
$url = Config('website.api_domain').'order/sysiteminfo';
$resData['order_id'] = $id;
$resData['k1'] = time();
$resData['k2'] = md5(md5($resData['k1']).'fh6y5t4rr351d2c3bryi');
$temp = json_decode(curlApi($url, $resData, "POST"), true); // 连接API
$this->pushQueue($data); if ($temp['err_code'] != 0) return ['errcode'=>$temp['err_code'], 'errmsg'=>$temp['err_msg']];
return ['errcode'=>0, 'errmsg'=>'推送到邮件队列成功,请稍等...']; return ['errcode'=>0, 'errmsg'=>'推送到邮件队列成功,请稍等...'];
} }
......
...@@ -518,5 +518,15 @@ ...@@ -518,5 +518,15 @@
return $user; 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
...@@ -43,6 +43,7 @@ Route::group(['middleware' => 'web'], function () { ...@@ -43,6 +43,7 @@ Route::group(['middleware' => 'web'], function () {
Route::match(['get', 'post'], '/sendSales/{id?}', 'OrderController@sendSales'); Route::match(['get', 'post'], '/sendSales/{id?}', 'OrderController@sendSales');
Route::post('/ajaxdeletegoods', 'OrderController@ajaxdeletegoods'); Route::post('/ajaxdeletegoods', 'OrderController@ajaxdeletegoods');
Route::post('/ajaxSaveChange', 'OrderController@ajaxSaveChange'); Route::post('/ajaxSaveChange', 'OrderController@ajaxSaveChange');
Route::post('/ajaxApplyManagerAudit', 'OrderController@ajaxApplyManagerAudit');
Route::post('/ajaxAuditPass', 'OrderController@ajaxAuditPass'); Route::post('/ajaxAuditPass', 'OrderController@ajaxAuditPass');
Route::post('/ajaxReAudit', 'OrderController@ajaxReAudit'); Route::post('/ajaxReAudit', 'OrderController@ajaxReAudit');
Route::get('/check/{id}', 'OrderController@check'); Route::get('/check/{id}', 'OrderController@check');
......
...@@ -23,4 +23,9 @@ return [ ...@@ -23,4 +23,9 @@ return [
// 'zoe@ichunt.com', // 'zoe@ichunt.com',
], ],
// 联营采购负责人
'joint_purchase_manager' => [
'zty@ichunt.com',
],
]; ];
...@@ -4,6 +4,48 @@ ...@@ -4,6 +4,48 @@
$.extend($.lie, { $.extend($.lie, {
audit: { audit: {
index:function() { index:function() {
// 申请主管审核
$('.apply-manager-audit').click(function() {
var order_id = $(this).data('id');
// 弹出提示
layer.open({
area: ['360px'],
title: '提示信息',
content: '确定申请主管审核吗?',
btn:['确定', '取消'],
yes: function(index, layero){
$.ajax({
url : '/ajaxApplyManagerAudit',
type: 'post',
data: {order_id: order_id},
dataType: 'json',
success: function (resp) {
if(resp.errcode === 0){
layer.msg(resp.errmsg || '操作成功');
setTimeout(function(){
location.reload();
}, 1000);
return false;
}
layer.alert(resp.errmsg);
return false;
},
error: function (res) {
console.log(res);
}
})
layer.msg('申请中...', {icon: 16, time: 0, shade: 0.3}); // 阻止重复提交
},
btn2: function(index, layero){
layer.close(index);
}
});
})
// 主管审核 // 主管审核
$('.manager-audit').click(function() { $('.manager-audit').click(function() {
var order_id = $(this).data('id'); var order_id = $(this).data('id');
......
...@@ -15,7 +15,7 @@ ...@@ -15,7 +15,7 @@
<div class="tabs-box"> <div class="tabs-box">
<div class="order-change-main"> <div class="order-change-main">
@if (($order_info['order_goods_type'] == 1 && $order_info['status'] == 1) || ($order_info['order_goods_type'] == 2 && $order_info['adjust_count'] < 2)) @if (($order_info['order_goods_type'] == 1 && in_array($order_info['status'], [1, 2]) && $order_temp_info['is_manager_audit'] != 3) || ($order_info['order_goods_type'] == 2 && $order_info['adjust_count'] < 2))
<form id="checkOrderForm" class="form-horizontal table-responsive"> <form id="checkOrderForm" class="form-horizontal table-responsive">
<input type="hidden" name="auditor_role" value="{{ $role }}" > <input type="hidden" name="auditor_role" value="{{ $role }}" >
<input type="hidden" name="order_sn" value="{{$order_info['order_sn']}}"> <input type="hidden" name="order_sn" value="{{$order_info['order_sn']}}">
...@@ -396,7 +396,7 @@ ...@@ -396,7 +396,7 @@
</form> </form>
@endif @endif
@if (($order_info['order_goods_type'] == 1 && $order_info['status'] == 2) || ($order_info['order_goods_type'] != 1 && $order_info['adjust_count'] == 2)) @if (($order_info['order_goods_type'] == 1 && $order_info['status'] == 2 && $order_temp_info['is_manager_audit'] == 3) || ($order_info['order_goods_type'] == 2 && $order_info['status'] == 2 && $order_info['adjust_count'] == 2))
<div class="checked_section"> <div class="checked_section">
<div class="checked_left"> <div class="checked_left">
<p>交易状态:&nbsp;审核通过,请联系客户及时付款! <p>交易状态:&nbsp;审核通过,请联系客户及时付款!
......
...@@ -157,13 +157,18 @@ ...@@ -157,13 +157,18 @@
@endif @endif
@if (in_array('check_order', $userPerms) && $order_info['sale_id']) @if (in_array('check_order', $userPerms) && $order_info['sale_id'])
@if ($order_info['status'] == 1) @if (isset($order_temp_info['is_manager_audit']) && $order_temp_info['is_manager_audit'] != 1 && in_array($order_info['status'], [1, 2]))
<a class="btn btn-success" href="{{URL('change', ['order_id'=>$order_info['order_id']])}}" target="_blank">人工审单</a> <a class="btn btn-success" href="{{URL('change', ['order_id'=>$order_info['order_id']])}}" target="_blank">人工审单</a>
@elseif ($order_info['status'] == 2 && in_array($role, [1, 2])) @elseif ($order_info['status'] == 2 && $order_temp_info['is_manager_audit'] == 3 && in_array($role, [1, 2]))
<a class="btn btn-success re-audit" data-id="{{$order_info['order_id']}}">反审</a> <a class="btn btn-success re-audit" data-id="{{$order_info['order_id']}}">反审</a>
@endif @endif
@endif @endif
<!-- 申请主管审核 -->
@if (isset($order_temp_info['is_manager_audit']) && $order_temp_info['is_manager_audit'] == 1)
<a class="btn btn-info apply-manager-audit" data-id="{{$order_info['order_id']}}">申请主管审核</a>
@endif
<!-- 主管审核 --> <!-- 主管审核 -->
@if ($order_temp_info['is_manager_audit'] && in_array($role, [1, 2]) && $order_info['status'] == 1) @if ($order_temp_info['is_manager_audit'] && in_array($role, [1, 2]) && $order_info['status'] == 1)
<a class="btn btn-danger manager-audit" data-id="{{$order_info['order_id']}}">主管审核</a> <a class="btn btn-danger manager-audit" data-id="{{$order_info['order_id']}}">主管审核</a>
......
...@@ -30,12 +30,12 @@ ...@@ -30,12 +30,12 @@
<th>发货状态</th> <th>发货状态</th>
<th>物流单号</th> <th>物流单号</th>
<th>京东订单编号</th> <th>京东订单编号</th>
<th width="8%">自动确认收货时间</th> <th>自动确认收货时间</th>
</tr> </tr>
<tr> <tr>
<td>{{ $order_info['order_sn'] }}</td> <td>{{ $order_info['order_sn'] }}</td>
<td>{{ $order_temp_info['is_manager_audit'] ? '待主管审核' : Config('params.order_status')[$order_info['status']] }}</td> <td>{{ Config('params.order_status')[$order_info['status']] }}</td>
<td>{{ $user_info['mobile'] ? $user_info['mobile'] : $user_info['email'] }}</td> <td>{{ $user_info['mobile'] ? $user_info['mobile'] : $user_info['email'] }}</td>
<td> <td>
<?php <?php
......
...@@ -143,7 +143,7 @@ ...@@ -143,7 +143,7 @@
<td> <td>
<!-- <button type="button" class="btn btn-success btn-xs remarks">编辑</button> --> <!-- <button type="button" class="btn btn-success btn-xs remarks">编辑</button> -->
<?php if (in_array($order_info['status'], [1, 2, 3]) && $v['status'] == 1) { ?> <?php if (in_array($order_info['status'], [1, 2, 3, 4]) && $v['status'] == 1) { ?>
<button type="button" class="btn btn-success btn-xs edit-item" data-id="<?= $v['rec_id'] ?>" data-batch="<?= $v['batch'] ?>" data-bid="<?= $v['buyer_id'] ?>" data-remarks="<?= $v['remarks'] ?>">编辑</button> <button type="button" class="btn btn-success btn-xs edit-item" data-id="<?= $v['rec_id'] ?>" data-batch="<?= $v['batch'] ?>" data-bid="<?= $v['buyer_id'] ?>" data-remarks="<?= $v['remarks'] ?>">编辑</button>
<?php } ?> <?php } ?>
</td> </td>
......
...@@ -12,7 +12,7 @@ ...@@ -12,7 +12,7 @@
<script src="/js/md5.js"></script> <script src="/js/md5.js"></script>
<script src="/js/layui/layui.js"></script> <script src="/js/layui/layui.js"></script>
<script src="/js/details.js?v=<?= time() ?>"></script> <script src="/js/details.js?v=<?= time() ?>"></script>
<script src="/js/order_audit.js"></script> <script src="/js/order_audit.js?v=<?= time() ?>"></script>
<script src="/js/order_track.js"></script> <script src="/js/order_track.js"></script>
<script src="/js/order_cancel.js"></script> <script src="/js/order_cancel.js"></script>
<script src="/js/order_send_email.js"></script> <script src="/js/order_send_email.js"></script>
......
...@@ -250,6 +250,7 @@ ...@@ -250,6 +250,7 @@
<th class="pl30">ERP单号</th> <th class="pl30">ERP单号</th>
<th class="pl30">应付金额</th> <th class="pl30">应付金额</th>
<th class="pl30">订单状态</th> <th class="pl30">订单状态</th>
<th class="pl30">主管审核</th>
<th class="pl30">付款类型</th> <th class="pl30">付款类型</th>
<th class="pl30">支付方式</th> <th class="pl30">支付方式</th>
<th class="pl30">业务员</th> <th class="pl30">业务员</th>
...@@ -289,9 +290,6 @@ ...@@ -289,9 +290,6 @@
</td> </td>
<td class="show-list"> <td class="show-list">
<?php <?php
if (!empty($order_extend->is_manager_audit) && $v['status'] == 1) {
echo '<span class="list-text-checking"><b>待主管审核</b></span>';
} else {
switch ($v['status']) { switch ($v['status']) {
case -2: echo '<span class="list-text-no-check"><b>审核未通过</b></span>';break; case -2: echo '<span class="list-text-no-check"><b>审核未通过</b></span>';break;
case -1: echo '<span class="list-text-cancel"><b>已取消</b></span>';break; case -1: echo '<span class="list-text-cancel"><b>已取消</b></span>';break;
...@@ -303,6 +301,21 @@ ...@@ -303,6 +301,21 @@
case 8: echo '<span class="list-text-confirm"><b>待收货</b></span>';break; case 8: echo '<span class="list-text-confirm"><b>待收货</b></span>';break;
case 10: echo '<span class="list-text-success"><b>交易成功</b></span>';break; case 10: echo '<span class="list-text-success"><b>交易成功</b></span>';break;
} }
?>
</td>
<td class="show-list">
<?php
if ($v['status'] >= 1 && $v['status'] < 4 && isset($order_extend->is_manager_audit)) {
switch ($order_extend->is_manager_audit) {
case 1:
echo '<span class="list-text-checking"><b>未申请</b></span>';break;
case 2:
echo '<span class="list-text-checking"><b>待审核</b></span>';break;
case 3:
echo '<span class="list-text-success"><b>已审核</b></span>';break;
default:
echo ''; break;
}
} }
?> ?>
</td> </td>
...@@ -331,15 +344,20 @@ ...@@ -331,15 +344,20 @@
<td> <td>
<div class="btn-group btn-group-xs" style="min-width: 200px;"> <div class="btn-group btn-group-xs" style="min-width: 200px;">
@if (in_array('check_order', $userPerms) && $v['sale_id']) @if (in_array('check_order', $userPerms) && $v['sale_id'])
@if ($v['status'] == 1) @if (isset($order_extend->is_manager_audit) && $order_extend->is_manager_audit != 3 && in_array($v['status'], [1, 2]))
<a class="btn btn-success" href="{{URL('change', ['order_id'=>$v['order_id']])}}" target="_blank">人工审单</a> <a class="btn btn-success" href="{{URL('change', ['order_id'=>$v['order_id']])}}" target="_blank">人工审单</a>
@elseif ($v['status'] == 2 && in_array($role, [1, 2])) @elseif ($v['status'] == 2 && $order_extend->is_manager_audit == 3 && in_array($role, [1, 2]))
<a class="btn btn-success re-audit" data-id="{{$v['order_id']}}">反审</a> <a class="btn btn-success re-audit" data-id="{{$v['order_id']}}">反审</a>
@endif @endif
@endif @endif
<!-- 主管审核 --> <!-- 申请主管审核 -->
@if (isset($order_extend->is_manager_audit) && in_array($role, [1, 2]) && $v['status'] == 1) @if (isset($order_extend->is_manager_audit) && $order_extend->is_manager_audit == 1)
<a class="btn btn-info apply-manager-audit" data-id="{{$v['order_id']}}">申请主管审核</a>
@endif
<!-- 主管审核 (待付款且待主管审核 || 已付款且主管未审核) && 主管角色 && 未同步 -->
@if (isset($order_extend->is_manager_audit) && (($v['status'] == 2 && $order_extend->is_manager_audit == 2) || ($v['status'] > 2 && $order_extend->is_manager_audit != 3)) && in_array($role, [1, 2]) && empty($order_extend->erp_sn))
<a class="btn btn-danger manager-audit" data-id="{{$v['order_id']}}">主管审核</a> <a class="btn btn-danger manager-audit" data-id="{{$v['order_id']}}">主管审核</a>
@endif @endif
......
...@@ -11,7 +11,7 @@ ...@@ -11,7 +11,7 @@
<script src="/js/common.js"></script> <script src="/js/common.js"></script>
<script src="/js/layui/layui.js"></script> <script src="/js/layui/layui.js"></script>
<script src="/js/list.js?v=<?= time() ?>"></script> <script src="/js/list.js?v=<?= time() ?>"></script>
<script src="/js/order_audit.js"></script> <script src="/js/order_audit.js?v=<?= time() ?>"></script>
<script src="/js/order_track.js"></script> <script src="/js/order_track.js"></script>
<script src="/js/order_cancel.js"></script> <script src="/js/order_cancel.js"></script>
<script src="/js/order_send_email.js"></script> <script src="/js/order_send_email.js"></script>
......
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