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
2ea3124c
authored
Jun 08, 2021
by
连敬荣
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
代码重构
parent
163cfd9a
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
182 additions
and
4 deletions
app/Http/Controllers/DataController.php
app/Http/Controllers/SearchController.php
app/Http/routes/api.php
app/Http/Controllers/DataController.php
View file @
2ea3124c
This diff is collapsed.
Click to expand it.
app/Http/Controllers/SearchController.php
View file @
2ea3124c
...
...
@@ -3,10 +3,15 @@
namespace
App\Http\Controllers
;
use
App\map\InquiryMap
;
use
App\map\QuoteMap
;
use
App\Model\BestGoodsModel
;
use
App\Model\InquiryItemsAssignModel
;
use
App\Model\InquiryItemsModel
;
use
App\Model\LieBrandModel
;
use
App\Model\QuoteModel
;
use
Illuminate\Http\Request
;
use
DB
;
class
SearchController
extends
Controller
{
...
...
@@ -39,8 +44,178 @@ class SearchController extends Controller
$lieBrandModel
->
getBrandList
(
$k
,
$types
);
}
public
function
checkUniqueGoods
(
Request
$request
)
{
var_dump
(
$request
->
input
());
exit
();
{
$InquiryItemsModel
=
new
InquiryItemsModel
();
$InquiryItemsModel
->
checkGoods
(
$request
->
input
());
}
public
function
getInquiryList
(
Request
$request
){
$input
=
$request
->
input
();
Export
(
$this
->
getList
(
$input
));
}
protected
function
getList
(
$input
=
[],
$export
=
0
)
//获取询价列表
{
$user_id
=
@
$input
[
"user_id"
];
$user_name
=
@
$input
[
"user_name"
];
$rqpConn
=
DB
::
connection
(
'rfq'
);
$list
=
$rqpConn
->
table
(
'inquiry as a'
)
->
join
(
'inquiry_items as b'
,
'a.id'
,
'='
,
'b.inquiry_id'
)
->
select
(
DB
::
Raw
(
"lie_a.inquiry_sn,lie_a.currency,lie_a.status as status_a,lie_a.user_name,lie_a.create_name,lie_b.*"
))
->
where
(
function
(
$query
)
use
(
$input
)
{
if
(
@
$input
[
"types"
]
==
5
){
$query
->
where
(
'a.status'
,
0
);
}
else
{
$query
->
whereIn
(
'a.status'
,
[
-
1
,
1
]);
}
foreach
(
$input
as
$k
=>
$v
)
{
$v
=
trim
(
$v
);
if
(
empty
(
$v
))
{
continue
;
}
switch
(
$k
)
{
case
"inquiry_sn"
:
$query
->
whereRaw
(
'lie_a.'
.
$k
.
' like "%'
.
$v
.
'%" '
);
break
;
case
"inquiry_id"
:
$query
->
where
(
'a.id'
,
'='
,
$v
);
break
;
case
"goods_name"
:
case
"brand_name"
:
$query
->
whereRaw
(
'lie_b.'
.
$k
.
' like "%'
.
$v
.
'%" '
);
break
;
case
"customer_name"
:
$query
->
whereRaw
(
'lie_a.user_name like "'
.
$v
.
'%" '
);
break
;
case
"status"
:
$query
->
whereRaw
(
'lie_b.status in ('
.
rtrim
(
$v
,
","
)
.
')'
);
break
;
case
"create_uid"
:
$query
->
where
(
'a.create_uid'
,
'='
,
$v
);
break
;
case
"assign_type"
:
$query
->
where
(
'b.assign_type'
,
'='
,
$v
);
break
;
case
"start_time"
:
$query
->
where
(
'b.create_time'
,
'>='
,
strtotime
(
$v
));
break
;
case
"end_time"
:
$query
->
where
(
'b.create_time'
,
'<='
,
strtotime
(
$v
)
);
break
;
}
}
});
#不同类别查询
switch
(
@
$input
[
"types"
])
{
case
"1"
:
//我的询价
$list
=
$list
->
where
(
'a.create_uid'
,
$user_id
);
break
;
case
"2"
:
//我的已关闭询价
$list
=
$list
->
where
(
'a.create_uid'
,
$user_id
)
->
where
(
"b.status"
,
-
1
);
case
"3"
:
//所有询价
$perm
=
new
PermController
;
$role
=
$perm
->
getUserRole
(
$user_id
,
$user_name
);
// 用户角色
switch
(
$role
)
{
case
2
:
// 销售查看下级
$sub_sale_ids
=
$perm
->
getSubSaleId
(
$user_id
);
$list
=
$list
->
whereIn
(
'a.create_uid'
,
$sub_sale_ids
)
->
whereIn
(
'a.status'
,
[
-
1
,
1
]);
break
;
case
3
:
// 销售查看自己
$list
=
$list
->
where
(
'a.create_uid'
,
$user_id
)
->
whereIn
(
'a.status'
,
[
-
1
,
1
]);
break
;
}
break
;
}
$page
=
isset
(
$input
[
'p'
])
?
$input
[
'p'
]
:
$input
[
'page'
];
#排序
if
(
@
$input
[
"inquiry_number_sort"
]){
$list
=
$list
->
orderBy
(
'b.inquiry_number'
,
$input
[
"inquiry_number_sort"
]);
}
else
if
(
@
$input
[
"create_time_sort"
]){
$list
=
$list
->
orderBy
(
'b.create_time'
,
$input
[
"create_time_sort"
]);
}
else
{
$list
=
$list
->
orderBy
(
'b.id'
,
"desc"
);
}
$list
=
$list
->
paginate
(
@
$input
[
'limit'
]
?
$input
[
"limit"
]
:
10
,
[
'*'
],
'p'
,
@
$page
?
$page
:
1
)
->
toArray
();
if
(
!
$list
)
return
[
20001
,
'没有数据'
];
$QuoteModel
=
new
QuoteModel
();
$InquiryItemsAssignModel
=
new
InquiryItemsAssignModel
();
$BestGoodsModel
=
new
BestGoodsModel
();
$Redis
=
\RedisDB
::
connection
();
foreach
(
$list
[
'data'
]
as
$k
=>
&
$v
)
{
$inquiry_items_id
=
$v
[
"id"
];
#明细id
//报价
$v
[
'status_val'
]
=
InquiryMap
::
$status
[
$v
[
"status"
]];
if
(
$v
[
"status_val"
]
==
"已报价"
)
{
$count
=
$QuoteModel
->
where
(
"inquiry_items_id"
,
$inquiry_items_id
)
->
whereIn
(
"status"
,
QuoteMap
::
$status_used
)
->
count
();
$v
[
'status_val'
]
=
$v
[
'status_val'
]
.
"("
.
$count
.
")"
;
}
$v
[
'create_time'
]
=
timeToDate
(
$v
[
'create_time'
]);
//创建时间
$v
[
"customer_name"
]
=
$v
[
'user_name'
]
;
#目标价
if
(
@
$input
[
"types"
]
!=
5
){
$v
[
'target_price'
]
=
InquiryMap
::
$currency_sign
[
$v
[
"currency"
]]
.
$v
[
'target_price'
]
.
"
\t
"
;
// 客户目标报价
}
#交货日期
$v
[
'delivery_time'
]
=
$v
[
'delivery_time'
]
>
6
?
(
$v
[
'delivery_time'
]
/
7
)
.
'周'
:
$v
[
'delivery_time'
]
.
"天"
;
#查询所有报价
$v
[
'quote_price'
]
=
"--"
;
$quote
=
$QuoteModel
->
select
(
"status"
,
"currency"
,
"price_origin"
,
"price_rmb"
)
->
where
(
"inquiry_items_id"
,
$v
[
"id"
])
->
whereIn
(
"status"
,
QuoteMap
::
$status_used
)
->
orderby
(
"status"
,
"desc"
)
->
orderby
(
"price_rmb"
,
"asc"
)
->
first
();
if
(
$quote
){
$b
=
$quote
->
toArray
();
$lowerPrice
=
$b
[
"currency"
]
==
1
?
"¥"
.
$b
[
"price_rmb"
]
:
InquiryMap
::
$currency_sign
[
$b
[
"currency"
]]
.
$b
[
"price_origin"
];
$v
[
"quote_price"
]
=
$lowerPrice
;
}
#查询指定采购
$v
[
"assign_name"
]
=
""
;
if
(
$v
[
"assign_type"
]
==
1
){
$assign
=
$InquiryItemsAssignModel
->
select
(
DB
::
Raw
(
"GROUP_CONCAT(assign_name) assign_name"
))
->
where
(
"inquiry_items_id"
,
$inquiry_items_id
)
->
first
();
if
(
$assign
){
$v
[
"assign_name"
]
=
$assign
->
assign_name
;
}
}
$v
[
'inquiry_sn_origin'
]
=
$v
[
"inquiry_sn"
];
// 查询历史报价数
$v
[
'history_quote_count'
]
=
$QuoteModel
->
GetHistoryQuotedCount
(
$v
[
'goods_name'
]);
// 查询优选匹配数
$v
[
'best_count'
]
=
$BestGoodsModel
->
getCountByWhere
([[
"goods_name"
,
'='
,
$v
[
'goods_name'
]],
[
"g_status"
,
'='
,
BestGoodsModel
::
STATUS_ENABLE
]]);
// 在Redis集合中检查是否有新的报价
if
(
$export
==
0
){
$res
=
$Redis
->
SISMEMBER
(
'frq_quote_urge'
,
$v
[
'id'
]);
if
(
$res
)
{
$v
[
'inquiry_sn'
]
=
$v
[
'inquiry_sn'
]
.
"<span style='color:#f2f2f2;'> *</span>"
;
}
}
$v
[
'is_quote_val'
]
=
$v
[
'is_quote'
]
==
1
?
'是'
:
'否'
;
}
$data
=
$list
[
'data'
];
if
(
@
$input
[
"is_export"
]
==
1
)
{
#如果是导出
$data
=
$this
->
clearExport
(
$data
);
}
return
[
0
,
'成功'
,
$data
,
$list
[
'total'
]];
}
}
\ No newline at end of file
app/Http/routes/api.php
View file @
2ea3124c
...
...
@@ -5,6 +5,7 @@ Route::Get('/ApiSkuList','SearchController@getSkuList');//新增询价查询sku
Route
::
Get
(
'/ApiBrandList'
,
'SearchController@getBrandList'
);
//新增询价查询品牌接口;
Route
::
Post
(
'/ApiCheckGoods'
,
'SearchController@checkUniqueGoods'
);
//检查是否已经存在询价单;
Route
::
Post
(
'/ApiCreateOneItems'
,
'DataController@createInquiryItemsDetail'
);
//创建一条询价明细;
Route
::
Post
(
'/
api/
ApiDeleteInquiryItems'
,
'DataController@deleteInquiryItemsDetail'
);
//删除询价明细;
Route
::
Post
(
'/
api/
ApiEditInquiry'
,
'DataController@creatInquiry'
);
//新增询价;
Route
::
Post
(
'/ApiDeleteInquiryItems'
,
'DataController@deleteInquiryItemsDetail'
);
//删除询价明细;
Route
::
Post
(
'/ApiEditInquiry'
,
'DataController@creatInquiry'
);
//新增询价;
Route
::
Post
(
'/ApiUpdateOneItems'
,
'DataController@editInquiryItemDetail'
);
//修改单条明细记录;
//
Route
::
Get
(
'/ApiInquiryList'
,
'SearchController@getInquiryList'
);
//
询价列表
;
\ No newline at end of file
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