|
@@ -10,10 +10,10 @@ use think\facade\Db;
|
|
|
class Proorder extends Base
|
|
|
{
|
|
|
|
|
|
-public function __construct(App $app)
|
|
|
-{
|
|
|
- parent::__construct($app);
|
|
|
-}
|
|
|
+ public function __construct(App $app)
|
|
|
+ {
|
|
|
+ parent::__construct($app);
|
|
|
+ }
|
|
|
|
|
|
|
|
|
//已读列表
|
|
@@ -158,6 +158,7 @@ public function __construct(App $app)
|
|
|
|
|
|
//找到流程对应记录的所有人(创建人 or 申请人 or 采购员)
|
|
|
$holder_id = 0;
|
|
|
+
|
|
|
switch ($value['order_type']) {
|
|
|
//1.采购单流程
|
|
|
case 'CGD':
|
|
@@ -173,83 +174,91 @@ public function __construct(App $app)
|
|
|
break;
|
|
|
//4.销售订单流程
|
|
|
case 'XSQRD':
|
|
|
- $holder_id = Db::name('sale')->where(['id' => 'order_id', 'is_del' => 0])->value('apply_id', 0);
|
|
|
+ $holder_id = Db::name('sale')->where(['id' => $value['order_id'], 'is_del' => 0])->value('apply_id', 0);
|
|
|
break;
|
|
|
//5.发货申请单流程
|
|
|
case 'CKD':
|
|
|
- $holder_id = Db::name('order_out')->where(['id' => 'order_id', 'is_del' => 0])->value('apply_id', 0);
|
|
|
+ $holder_id = Db::name('order_out')->where(['id' => $value['order_id'], 'is_del' => 0])->value('apply_id', 0);
|
|
|
break;
|
|
|
//6.售后申请单流程
|
|
|
case 'SHD':
|
|
|
- $holder_id = Db::name('order_return')->where(['id' => 'order_id', 'is_del' => 0])->value('apply_id', 0);
|
|
|
+ $holder_id = Db::name('order_return')->where(['id' => $value['order_id'], 'is_del' => 0])->value('apply_id', 0);
|
|
|
break;
|
|
|
//7.售后退货单流程
|
|
|
case 'CKTHD':
|
|
|
- $holder_id = Db::name('order_back')->where(['id' => 'order_id', 'is_del' => 0])->value('apply_id', 0);
|
|
|
+ $holder_id = Db::name('order_back')->where(['id' => $value['order_id'], 'is_del' => 0])->value('apply_id', 0);
|
|
|
break;
|
|
|
//8.销售退货单流程
|
|
|
case 'XSTHD':
|
|
|
- $holder_id = Db::name('sale_return')->where(['id' => 'order_id', 'is_del' => 0])->value('apply_id', 0);
|
|
|
+ $holder_id = Db::name('sale_return')->where(['id' => $value['order_id'], 'is_del' => 0])->value('apply_id', 0);
|
|
|
break;
|
|
|
//9.采购工差单流程
|
|
|
case 'CGGCD':
|
|
|
- $holder_id = Db::name('purchease_diff')->where(['id' => 'order_id', 'is_del' => 0])->value('apply_id', 0);
|
|
|
+ $holder_id = Db::name('purchease_diff')->where(['id' => $value['order_id'], 'is_del' => 0])->value('apply_id', 0);
|
|
|
break;
|
|
|
//10.销售工差单流程
|
|
|
case 'XSGCD':
|
|
|
- $holder_id = Db::name('sale_diff')->where(['id' => 'order_id', 'is_del' => 0])->value('apply_id', 0);
|
|
|
+ $holder_id = Db::name('sale_diff')->where(['id' => $value['order_id'], 'is_del' => 0])->value('apply_id', 0);
|
|
|
break;
|
|
|
//11.调拨单流程
|
|
|
case 'DBD':
|
|
|
- $holder_id = Db::name('allot_stock')->where(['id' => 'order_id', 'is_del' => 0])->value('apply_id', 0);
|
|
|
+ $holder_id = Db::name('allot_stock')->where(['id' => $value['order_id'], 'is_del' => 0])->value('apply_id', 0);
|
|
|
break;
|
|
|
//12.盘点单流程
|
|
|
case 'PDD':
|
|
|
- $holder_id = Db::name('good_check')->where(['id' => 'order_id', 'is_del' => 0])->value('apply_id', 0);
|
|
|
+ $holder_id = Db::name('good_check')->where(['id' => $value['order_id'], 'is_del' => 0])->value('apply_id', 0);
|
|
|
break;
|
|
|
//13.议价单流程
|
|
|
case 'YJD':
|
|
|
- $holder_id = Db::name('bargain_order')->where(['id' => 'order_id', 'is_del' => 0])->value('createrid', 0);
|
|
|
+ $holder_id = Db::name('bargain_order')->where(['id' => $value['order_id'], 'is_del' => 0])->value('createrid', 0);
|
|
|
break;
|
|
|
//14.项目单流程
|
|
|
case 'PRO':
|
|
|
- $holder_id = Db::name('project')->where(['id' => 'order_id', 'is_del' => 0])->value('createrid', 0);
|
|
|
+ $holder_id = Db::name('project')->where(['id' => $value['order_id'], 'is_del' => 0])->value('createrid', 0);
|
|
|
break;
|
|
|
//15.商品成本流程
|
|
|
case 'SPCB':
|
|
|
- $holder_id = Db::name('good_basic')->where(['id' => 'order_id', 'is_del' => 0])->value('chargerid', 0);
|
|
|
+ $holder_id = Db::name('good_basic')->where(['id' => $value['order_id'], 'is_del' => 0])->value('chargerid', 0);
|
|
|
break;
|
|
|
//16.商品上线流程
|
|
|
case 'SPSX':
|
|
|
- $holder_id = Db::name('good')->where(['id' => 'order_id', 'is_del' => 0])->value('createrid', 0);
|
|
|
+ $holder_id = Db::name('good_platform')
|
|
|
+ ->alias('a')
|
|
|
+ ->where(['a.id' => $value['order_id']])
|
|
|
+ ->leftJoin('good g', 'g.spuCode=a.spuCode')
|
|
|
+ ->value('g.createrid', 0);
|
|
|
break;
|
|
|
//17.活动流程
|
|
|
case 'HD':
|
|
|
- $holder_id = Db::name('good_activity')->where(['id' => 'order_id', 'is_del' => 0])->value('createrid', 0);
|
|
|
+ $holder_id = Db::name('good_activity')->where(['id' => $value['order_id'], 'is_del' => 0])->value('createrid', 0);
|
|
|
break;
|
|
|
//19.有赞商品上架流程
|
|
|
case 'YZSX':
|
|
|
- $holder_id = Db::name('good_basic')->where(['id' => 'order_id', 'is_del' => 0])->value('createrid', 0);
|
|
|
+ $holder_id = Db::name('platform_youzan')
|
|
|
+ ->alias('a')
|
|
|
+ ->where(['a.id' => $value['order_id']])
|
|
|
+ ->leftJoin('good g', 'g.spuCode=a.spuCode')
|
|
|
+ ->value('g.createrid', 0);
|
|
|
break;
|
|
|
//20.有赞订单审核流程
|
|
|
// case 'YZQRD':
|
|
|
-// $holder_id = Db::name('')->where(['id' => 'order_id', 'is_del' => 0])->value('', 0);
|
|
|
+// $holder_id = Db::name('')->where(['id' => $value['order_id'], 'is_del' => 0])->value('', 0);
|
|
|
// break;
|
|
|
//22.离职交接流程
|
|
|
case 'LZJJ':
|
|
|
- $holder_id = Db::name('resign_info')->where(['id' => 'order_id', 'is_del' => 0])->value('hand_uid', 0);
|
|
|
+ $holder_id = Db::name('resign_info')->where(['id' => $value['order_id'], 'is_del' => 0])->value('hand_uid', 0);
|
|
|
break;
|
|
|
//23.采购单退货流程
|
|
|
case 'CGTHD':
|
|
|
- $holder_id = Db::name('purchease_return')->where(['id' => 'order_id', 'is_del' => 0])->value('apply_id', 0);
|
|
|
+ $holder_id = Db::name('purchease_return')->where(['id' => $value['order_id'], 'is_del' => 0])->value('apply_id', 0);
|
|
|
break;
|
|
|
//24.竞价单流程
|
|
|
case 'ZXD':
|
|
|
- $holder_id = Db::name('consult_order')->where(['id' => 'order_id', 'is_del' => 0])->value('createrid', 0);
|
|
|
+ $holder_id = Db::name('consult_order')->where(['id' => $value['order_id'], 'is_del' => 0])->value('createrid', 0);
|
|
|
break;
|
|
|
//25.商品下线流程
|
|
|
case 'GOL':
|
|
|
- $holder_id = Db::name('good_offline_log')->where(['id' => 'order_id', 'is_del' => 0])->value('createrid', 0);
|
|
|
+ $holder_id = Db::name('good_offline_log')->where(['id' => $value['order_id'], 'is_del' => 0])->value('createrid', 0);
|
|
|
break;
|
|
|
}
|
|
|
|
|
@@ -267,7 +276,7 @@ public function __construct(App $app)
|
|
|
])
|
|
|
->column('uid');
|
|
|
|
|
|
- $uids = array_intersect($uids_1['1'], $uids_2);
|
|
|
+ $uids = array_intersect($uids_1, $uids_2);
|
|
|
|
|
|
$users = Db::name('depart_user')->where(['is_del' => 0, 'status' => 1])->whereIn('uid', $uids)->column('nickname');
|
|
|
|
|
@@ -278,59 +287,53 @@ public function __construct(App $app)
|
|
|
}
|
|
|
return app_show(0, "获取成功", ["list" => $data, 'count' => $count]);
|
|
|
}
|
|
|
-public function all(){
|
|
|
- $token = isset($this->post['token']) ? trim($this->post['token']) : "";
|
|
|
- if($token==""){
|
|
|
- return error_show(101,'token不能为空');
|
|
|
- }
|
|
|
- $effetc = VerifyTokens($token);
|
|
|
- if(!empty($effetc) && $effetc['code']!=0){
|
|
|
- return error_show($effetc['code'],$effetc['message']);
|
|
|
- }
|
|
|
- $where=[["is_del","=",0]];
|
|
|
- $process_name = isset($this->post['process_name']) && $this->post['process_name'] !==""? trim($this->post['process_name']) :"";
|
|
|
- if($process_name!=""){
|
|
|
- $where[]=["process_name","like","%$process_name%"];
|
|
|
- }
|
|
|
- $process_type = isset($this->post['process_type']) && $this->post['process_type'] !==""? trim($this->post['process_type']) :"";
|
|
|
- if($process_type!=""){
|
|
|
- $where[]=["process_type","like","%$process_type%"];
|
|
|
+ public function all(){
|
|
|
+ $token = isset($this->post['token']) ? trim($this->post['token']) : "";
|
|
|
+ if($token==""){
|
|
|
+ return error_show(101,'token不能为空');
|
|
|
+ }
|
|
|
+ $effetc = VerifyTokens($token);
|
|
|
+ if(!empty($effetc) && $effetc['code']!=0){
|
|
|
+ return error_show($effetc['code'],$effetc['message']);
|
|
|
+ }
|
|
|
+ $where=[["is_del","=",0]];
|
|
|
+ $process_name = isset($this->post['process_name']) && $this->post['process_name'] !==""? trim($this->post['process_name']) :"";
|
|
|
+ if($process_name!=""){
|
|
|
+ $where[]=["process_name","like","%$process_name%"];
|
|
|
+ }
|
|
|
+ $process_type = isset($this->post['process_type']) && $this->post['process_type'] !==""? trim($this->post['process_type']) :"";
|
|
|
+ if($process_type!=""){
|
|
|
+ $where[]=["process_type","like","%$process_type%"];
|
|
|
+ }
|
|
|
+ $list = Db::name('process')->where($where)->order("addtime desc")->select();
|
|
|
+ return app_show(0,"获取成功",$list);
|
|
|
}
|
|
|
- $list = Db::name('process')->where($where)->order("addtime desc")->select();
|
|
|
- return app_show(0,"获取成功",$list);
|
|
|
-}
|
|
|
|
|
|
//我能被哪些人看到?
|
|
|
private function get_uids_by_group_share(int $uid = 0, string $api_url = '')
|
|
|
{
|
|
|
//原始数据
|
|
|
- $data = [1 => [$uid], 2 => [$uid], 3 => []];
|
|
|
+ $data = [];
|
|
|
|
|
|
//用户组
|
|
|
- $group = Db::name('data_group_userid')
|
|
|
- ->alias('a')
|
|
|
- ->leftJoin('data_group b', 'b.id=a.data_group_id')
|
|
|
- ->where([
|
|
|
- 'a.is_del' => 0,
|
|
|
- 'a.status' => 1,
|
|
|
- 'a.uid' => $uid,
|
|
|
- 'b.is_del' => 0,
|
|
|
- 'b.status' => 1,
|
|
|
- ])->order('a.data_group_id')
|
|
|
- ->column('b.type', 'a.data_group_id');
|
|
|
-
|
|
|
- $group_user = Db::name('data_group_userid')
|
|
|
- ->where([
|
|
|
- 'is_del' => 0,
|
|
|
- 'status' => 1,
|
|
|
- ])->whereIn('data_group_id', array_keys($group))
|
|
|
- ->field('id,data_group_id,uid')
|
|
|
- ->order('uid')
|
|
|
- ->cursor();
|
|
|
-
|
|
|
- foreach ($group_user as $g_u) {
|
|
|
- $data[$group[$g_u['data_group_id']]][] = $g_u['uid'];
|
|
|
- }
|
|
|
+// $group = Db::name('role_group')
|
|
|
+// ->where([
|
|
|
+// 'is_del' => 0,
|
|
|
+// 'status' => 1,
|
|
|
+// ])->whereFindInSet('group_user',$uid)
|
|
|
+// ->column('id');
|
|
|
+//
|
|
|
+// $group_user = Db::name('role_group')
|
|
|
+// ->where([
|
|
|
+// 'is_del' => 0,
|
|
|
+// 'status' => 1,
|
|
|
+// ])->whereIn('id', $group)
|
|
|
+// ->field('id,group_user')
|
|
|
+// ->cursor();
|
|
|
+//
|
|
|
+// foreach ($group_user as $g_u) {
|
|
|
+// $data = array_merge($data,explode(',',$g_u['group_user']));
|
|
|
+// }
|
|
|
|
|
|
//当前请求的接口地址
|
|
|
if ($api_url == '') $api_url = app('http')->getName() . '/' . request()->pathinfo();
|
|
@@ -340,37 +343,34 @@ public function all(){
|
|
|
|
|
|
if ($menu_id) {
|
|
|
//共享规则
|
|
|
- $share = Db::name('data_share')
|
|
|
- ->field('id,type,uid,data_group_id')
|
|
|
+ $share = Db::name('role_share')
|
|
|
+ ->field('id,to_user,to_group')
|
|
|
->where([
|
|
|
+ 'share_user' => $uid,
|
|
|
'is_del' => 0,
|
|
|
'status' => 1,
|
|
|
])
|
|
|
- ->whereFindInSet('menu_ids', $menu_id)
|
|
|
- ->where(function ($query) use ($uid, $group) {
|
|
|
- return $query->where('source_uid', $uid)->whereOr('source_data_group_id', 'in', array_keys($group));
|
|
|
- })
|
|
|
+ ->whereFindInSet('action_collect', $menu_id)
|
|
|
->cursor();
|
|
|
|
|
|
foreach ($share as $s) {
|
|
|
- $source_group_uid = Db::name('data_group_userid')
|
|
|
- ->where([
|
|
|
- 'is_del' => 0,
|
|
|
- 'status' => 1,
|
|
|
- 'data_group_id' => $s['data_group_id'],
|
|
|
- ])->order('uid')->column('uid');
|
|
|
-
|
|
|
- //$s['source_uid'] ? [$s['source_uid']] : [] 排除默认值0
|
|
|
- $data[$s['type']] = array_merge($data[$s['type']], $s['uid'] ? [$s['uid']] : [], $source_group_uid);
|
|
|
+ if ($s['to_user']) $data = array_merge($data, [$s['to_user']]);
|
|
|
+ elseif ($s['to_group']) {
|
|
|
+ $group_user = Db::name('role_group')
|
|
|
+ ->where([
|
|
|
+ 'id' => $s['to_group'],
|
|
|
+ 'is_del' => 0,
|
|
|
+ 'status' => 1,
|
|
|
+ ])->value('group_user');
|
|
|
+ $data = array_merge($data, explode(',', $group_user));
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- unset($data[3]);
|
|
|
-
|
|
|
- $data[0] = array_merge($data[1], $data[2]);
|
|
|
-
|
|
|
- sort($data[0]);
|
|
|
- $data[0] = array_unique($data[0]);
|
|
|
+ sort($data);
|
|
|
+ $data = array_unique($data);
|
|
|
|
|
|
return $data;
|
|
|
|