Commit 312801f0 by 朱继来

Merge branch 'master' of http://119.23.72.7/zhujilai/Order into zjl_add_order_20210624

parents b38f375a ce1b629e
......@@ -722,4 +722,15 @@ class ApiController extends Controller
$this->Export($temp['err_code'], $temp['err_msg'], $delivery_place);
}
// 解锁审单
public function unlock_check($request)
{
$order_id = $request->input('order_id');
$key = 'changeOrder_'.$order_id;
Redis::del($key);
$this->Export(0, '成功');
}
}
......@@ -355,6 +355,14 @@ function getOrderServiceNum($order_id, $erp_rec_id, $status=1, $field='adjust_nu
->sum('i.'.$field);
}
// 检查是否锁定审单
function isLockCheck($order_id)
{
$key = 'changeOrder_'.$order_id;
$redis = Redis::connection('read');
return $redis->get($key);
}
Class OrderController extends Controller
{
......@@ -819,6 +827,22 @@ Class OrderController extends Controller
{
$info = $this->orderDetail($request, $id);
// 设置页面缓存,只允许单人操作审单
$key = 'changeOrder_'.$id;
$redis = Redis::connection('read');
$val = $redis->get($key);
if (!$val) {
Redis::set($key, $request->user->userId);
}
// 校验页面缓存用户与当前登录用户是否一致,不一致则阻止进入
if ($val && $val != $request->user->userId) {
$CmsModel = new CmsModel;
$name = $CmsModel->getUserName($val);
return redirect('/prompt')->with(['message'=>'此订单已被'.$name.'锁定,不能编辑审单!','url' =>'/list', 'jumpTime'=>3,'status'=>false]);
}
$this->pageHeader($request, $info, '人工审单', ["title" => '人工审单', "href" => '#']);
if ($info['order_info']['order_goods_type'] == 2 && in_array($info['order_info']['order_type'], [1, 3])) { // 平台自营订单
......@@ -884,10 +908,43 @@ Class OrderController extends Controller
public function ajaxSaveChange(Request $request)
{
if($request->isMethod('post')){
$order_id = $request->input('order_id', '');
$order_id = $request->input('order_id', '');
if (!$order_id) return array('errcode'=>Error::E_PARAM, 'errmsg'=>'订单参数有误!');
$key = 'changeOrder_'.$order_id;
$redis = Redis::connection('read');
$val = $redis->get($key);
// 校验页面缓存用户与当前登录用户是否一致,不一致则阻止进入
if ($val && $val != $request->user->userId) {
$CmsModel = new CmsModel;
$name = $CmsModel->getUserName($val);
return ['errcode'=>-1, 'errmsg'=>'此订单已被'.$name.'锁定,不能提交审单!'];
}
$perm = new PermController;
$OrderModel = new OrderModel;
$relation_id = [];
$order_sale_id = $OrderModel->where('order_id', $order_id)->value('sale_id'); // 获取当前订单销售
array_push($relation_id, $order_sale_id);
$manager = $perm->getSuperiorManager($order_sale_id, '销售经理'); // 获取销售主管
if ($manager) {
$manager_id = array_column($manager, 'userId');
$relation_id = array_merge($relation_id, $manager_id);
}
$director = $perm->getSuperiorDirector($order_sale_id, '销售总监'); // 获取销售总监
if ($director) {
$director_id = array_column($director, 'userId');
$relation_id = array_merge($relation_id, $director_id);
}
// 校验此是否为此订单销售或者对应主管,总监
if (!in_array($request->user->userId, $relation_id)) return ['errcode'=>-1, 'errmsg'=>'你没有权限操作此销售订单!'];
if (!$request->input('pay_time_limit')) {
$payTime = $request->input('payTime', '');
$payTimeOther = $request->input('payTimeOther', '');
......
......@@ -6,6 +6,7 @@
use App\Http\Controllers\Controller;
use DB;
use Illuminate\Support\Facades\Redis;
use App\Model\CmsModel;
class PermController extends Controller
{
......@@ -393,6 +394,47 @@
return $data;
}
// 通过职位名称获取指定销售对应的上级主管 (本地和外网的职位ID不一致,最好使用职位名称)
public function getSuperiorManager($userId, $position_name, $field='userId')
{
$CmsModel = new CmsModel;
$department_id = $CmsModel->where('userId', $userId)->value('department_id'); // 获取当前所在部门
if (!$department_id) return false;
$data = $CmsModel->where('department_id', $department_id)
->where('position_name', 'like', '%'.$position_name)
->select($field)
->get()
->toArray();
if (empty($data)) return false;
return $data;
}
// 通过职位名称获取指定销售对应的上级总监
public function getSuperiorDirector($userId, $position_name, $field='userId')
{
$CmsModel = new CmsModel;
$department_id = $CmsModel->where('userId', $userId)->value('department_id'); // 获取当前所在部门
if (!$department_id) return false;
// 获取上级部门ID
$parent_id = DB::table('user_department')->where('department_id', $department_id)->value('parent_id');
$data = $CmsModel->where('department_id', $parent_id)
->where('position_name', 'like', '%'.$position_name)
->select($field)
->get()
->toArray();
if (empty($data)) return false;
return $data;
}
/* 订单系统权限调整 --- 20200511 */
// 获取部门人员
public function getUserByDepartmentId($department_id, $status='', $filter='')
......
......@@ -613,7 +613,7 @@
var order_id = $(this).data('oid');
layer.open({
area: ['300px'],
area: ['300px'],
title: '同步ERP',
content: '确定同步到ERP吗?',
btn:['确认', '取消'],
......@@ -641,6 +641,43 @@
})
})
// 解锁审单
$('.unlock_check').click(function() {
var order_id = $(this).data('oid');
layer.open({
area: ['300px'],
title: '解锁审单',
content: '确定解锁该审单吗?',
btn:['确认', '取消'],
btn1: function(index) {
$.ajax({
url: '/api/unlock_check',
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.msg(resp.errmsg);
}
})
layer.msg('提交中...', {icon:16, time: 0, shade: 0.3});
},
btn2: function(index) {
layer.close(index)
}
})
})
},
}
......
......@@ -60,6 +60,8 @@
<?php if ($order_info['order_goods_type'] == 1) { ?>
<th>生产跟踪</th>
<th>包装</th>
<th>内部编码</th>
<?php } ?>
<th>商品备注</th>
......@@ -142,6 +144,8 @@
<?php if ($order_info['order_goods_type'] == 1) { ?>
<td><a class="order-track" data-rid="<?= $v['rec_id'] ?>"><?= App\Http\Controllers\getLastTrack($v['rec_id']) ?></a></td>
<td><?= $v['goods_packing'] ?></td>
<td><?= $v['material_number'] ?></td>
<?php } ?>
<td><?= !empty($v['remarks']) ? $v['remarks'] : '' ?></td>
......@@ -177,36 +181,36 @@
<?php if ($order_info['order_remark']) { ?>
<tr>
<td>订单备注信息:</td>
<td colspan="20"><?= $order_info['order_remark'] ?></td>
<td colspan="24"><?= $order_info['order_remark'] ?></td>
</tr>
<?php } ?>
<?php if ($order_temp_info['kefu_remark']) { ?>
<tr>
<td>客服备注信息:</td>
<td colspan="20"><?= $order_temp_info['kefu_remark'] ?></td>
<td colspan="24"><?= $order_temp_info['kefu_remark'] ?></td>
</tr>
<?php } ?>
<?php if ($order_info['order_goods_type'] == 2 && $order_temp_info['business_type'] == 1) { ?>
<tr>
<td>项目需求描述:</td>
<td colspan="20"><?= $order_temp_info['sample_demand_desc'] ?></td>
<td colspan="24"><?= $order_temp_info['sample_demand_desc'] ?></td>
</tr>
<?php } ?>
<?php if ($order_info['order_goods_type'] == 1 && $order_temp_info['business_type'] == 1) { ?>
<tr>
<td>项目名称:</td>
<td colspan="20"><?= $order_temp_info['sample_project_name'] ?></td>
<td colspan="24"><?= $order_temp_info['sample_project_name'] ?></td>
</tr>
<tr>
<td>项目阶段:</td>
<td colspan="20"><?= $order_temp_info['sample_project_stage'] ?></td>
<td colspan="24"><?= $order_temp_info['sample_project_stage'] ?></td>
</tr>
<tr>
<td>申请理由:</td>
<td colspan="20"><?= $order_temp_info['sample_project_reason'] ?></td>
<td colspan="24"><?= $order_temp_info['sample_project_reason'] ?></td>
</tr>
<?php } ?>
</tfoot>
......
......@@ -452,6 +452,12 @@
@if (isset($order_extend) && empty($order_extend->erp_sn) && $order_extend->is_manager_audit == 3)
<a class="btn btn-info syn_erp" data-oid="{{$v['order_id']}}">同步ERP</a>
@endif
<!-- 解锁审单 -->
<?php $is_lock_check = App\Http\Controllers\isLockCheck($v['order_id']); ?>
@if (in_array($role, [1, 2]) && $is_lock_check)
<a class="btn btn-danger unlock_check" data-oid="{{$v['order_id']}}">解锁审单</a>
@endif
</div>
</td>
</tr>
......
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