Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
黄成意
/
php_frq_api
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
a45fd43e
authored
May 11, 2021
by
朱继来
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
调整销售首页报价列表
parent
7b63e761
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
40 additions
and
22 deletions
app/Model/QuoteModel.php
app/Model/QuoteModel.php
View file @
a45fd43e
...
...
@@ -125,9 +125,9 @@ class QuoteModel extends Model
// 获取报价列表
public
function
lists
(
$input
,
$export
=
''
)
{
$page
=
$input
[
'page'
];
$page
=
$input
[
'page'
];
$limit
=
$input
[
'limit'
];
$type
=
$input
[
'type'
];
// 1-我的报价,2-所有报价,3-报价草稿
$type
=
$input
[
'type'
];
// 1-我的报价,2-所有报价,3-报价草稿,4-销售首页
$map
[
'inquiry_sn'
]
=
isset
(
$input
[
'inquiry_sn'
])
?
trim
(
$input
[
'inquiry_sn'
])
:
''
;
// 询价单号
$map
[
'goods_name'
]
=
isset
(
$input
[
'goods_name'
])
?
trim
(
$input
[
'goods_name'
])
:
''
;
// 型号
...
...
@@ -174,24 +174,22 @@ class QuoteModel extends Model
$map
[
'create_uid'
]
=
isset
(
$input
[
'create_uid'
])
?
$input
[
'create_uid'
]
:
''
;
// 报价制单人
if
(
$type
==
1
)
{
$list
=
$list
->
where
(
'q.create_uid'
,
$input
[
'user_id'
])
->
whereNotIn
(
'q.status'
,
[
0
,
-
1
]);
// 过滤报价草稿
}
else
{
if
(
$type
==
2
)
{
$perm
=
new
PermController
;
$role
=
$perm
->
getUserRole
(
$input
[
'user_id'
],
$input
[
'email'
]);
// 用户角色
if
(
$role
==
4
)
{
// 采购查看下级
$sub_sale_ids
=
$perm
->
getSubSaleId
(
$input
[
'user_id'
]);
$list
=
$list
->
whereIn
(
'q.create_uid'
,
$sub_sale_ids
);
}
}
elseif
(
$type
==
2
)
{
$perm
=
new
PermController
;
$role
=
$perm
->
getUserRole
(
$input
[
'user_id'
],
$input
[
'email'
]);
// 用户角色
$list
=
$list
->
whereNotIn
(
'q.status'
,
[
0
,
-
1
]);
// 过滤报价草稿
}
elseif
(
@
$input
[
'inquiry_items_id'
]
>
0
)
{
$list
=
$list
->
whereNotIn
(
'q.status'
,
[
0
,
-
1
])
->
where
(
'q.inquiry_items_id'
,
$input
[
'inquiry_items_id'
]);
}
elseif
(
isset
(
$input
[
'inquiry_items_ids'
])
&&
$input
[
'inquiry_items_ids'
])
{
$inquiry_items_ids
=
explode
(
","
,
$input
[
'inquiry_items_ids'
]);
$inquiry_items_ids
=
array_values
(
array_filter
(
$inquiry_items_ids
));
$list
=
$list
->
whereNotIn
(
'q.status'
,
[
0
,
-
1
])
->
whereIn
(
'q.inquiry_items_id'
,
$inquiry_items_ids
);
if
(
$role
==
4
)
{
// 采购查看下级
$sub_sale_ids
=
$perm
->
getSubSaleId
(
$input
[
'user_id'
]);
$list
=
$list
->
whereIn
(
'q.create_uid'
,
$sub_sale_ids
);
}
$list
=
$list
->
whereNotIn
(
'q.status'
,
[
0
,
-
1
]);
// 过滤报价草稿
}
elseif
(
@
$input
[
'inquiry_items_id'
]
>
0
)
{
$list
=
$list
->
whereNotIn
(
'q.status'
,
[
0
,
-
1
])
->
where
(
'q.inquiry_items_id'
,
$input
[
'inquiry_items_id'
]);
}
elseif
(
isset
(
$input
[
'inquiry_items_ids'
])
&&
$input
[
'inquiry_items_ids'
])
{
$inquiry_items_ids
=
explode
(
","
,
$input
[
'inquiry_items_ids'
]);
$inquiry_items_ids
=
array_values
(
array_filter
(
$inquiry_items_ids
));
$list
=
$list
->
whereNotIn
(
'q.status'
,
[
0
,
-
1
])
->
whereIn
(
'q.inquiry_items_id'
,
$inquiry_items_ids
);
}
if
(
$map
[
'create_uid'
])
{
// 制单人
...
...
@@ -214,6 +212,7 @@ class QuoteModel extends Model
$list
[
'data'
]
=
$this
->
handleData
(
$list
[
'data'
],
$type
);
$msg
=
'成功'
;
if
(
$type
==
1
)
{
// 我的报价
if
(
$map
[
'status'
])
{
switch
(
$map
[
'status'
])
{
...
...
@@ -241,10 +240,12 @@ class QuoteModel extends Model
$map
[
'status'
]
=
3
;
$list
[
'count'
][
'confirmed_status'
]
=
$this
->
commonQuery
(
$map
,
$input
,
2
);
}
$msg
=
$list
[
'count'
];
}
// return [0, '获取成功', $list['data'], $list['total']];
return
[
0
,
$
list
[
'count'
]
,
$list
[
'data'
],
$list
[
'total'
]];
return
[
0
,
$
msg
,
$list
[
'data'
],
$list
[
'total'
]];
}
}
...
...
@@ -330,9 +331,26 @@ class QuoteModel extends Model
// 通用查询
public
function
commonQuery
(
$map
,
$input
,
$type
=
1
)
{
$list
=
$this
->
from
(
'quote as q'
)
->
join
(
'inquiry_items as it'
,
'q.inquiry_items_id'
,
'='
,
'it.id'
)
->
where
(
function
(
$query
)
use
(
$map
)
{
$list
=
$this
->
from
(
'quote as q'
)
->
join
(
'inquiry_items as it'
,
'q.inquiry_items_id'
,
'='
,
'it.id'
);
if
(
isset
(
$input
[
'type'
])
&&
$input
[
'type'
]
==
4
)
{
$list
=
$list
->
leftJoin
(
'inquiry as i'
,
'it.inquiry_id'
,
'='
,
'i.id'
);
$perm
=
new
PermController
;
$role
=
$perm
->
getUserRole
(
$input
[
'user_id'
],
$input
[
'user_name'
]);
// 用户角色
switch
(
$role
)
{
case
2
:
// 销售查看下级
$sub_sale_ids
=
$perm
->
getSubSaleId
(
$input
[
'user_id'
]);
$list
=
$list
->
whereIn
(
'i.create_uid'
,
$sub_sale_ids
);
break
;
case
3
:
// 销售查看自己
$list
=
$list
->
where
(
'i.create_uid'
,
$input
[
'user_id'
]);
break
;
}
}
$list
=
$list
->
where
(
function
(
$query
)
use
(
$map
)
{
if
(
$map
[
'inquiry_sn'
])
{
$query
->
where
(
'q.inquiry_sn'
,
'='
,
$map
[
'inquiry_sn'
]);
}
...
...
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