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
4e67cd37
authored
Jun 03, 2021
by
连敬荣
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
代码重构
parent
cfa88507
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
136 additions
and
3 deletions
app/Http/Controllers/InquiryController.php
app/Http/routes.php
app/Model/InquiryItemsAssignModel.php
app/Model/InquiryItemsModel.php
app/Model/InquiryModel.php
app/Model/LieBrandModell.php
app/Http/Controllers/InquiryController.php
0 → 100644
View file @
4e67cd37
<?php
namespace
App\Http\Controllers
;
use
App\Model\CommonModel
;
use
App\Model\InquiryItemsAssignModel
;
use
App\Model\InquiryItemsModel
;
use
App\Model\InquiryModel
;
use
Illuminate\Http\Request
;
class
InquiryController
extends
Controller
{
// 关闭询价单
public
function
close
(
Request
$request
)
{
$inquiry_id
=
$request
->
input
(
"inquiry_id"
);
$remark
=
$request
->
input
(
"remark"
);
$user
=
$this
->
user
();
$InquiryModel
=
new
InquiryModel
();
$inquiry_info
=
$InquiryModel
->
getInfoById
(
$inquiry_id
);
$inquiry_close_res
=
$InquiryModel
->
closeById
(
$inquiry_id
,
$remark
);
if
(
$inquiry_close_res
){
// 关闭询价单-明细
$InquiryItemsModel
=
new
InquiryItemsModel
;
$InquiryItemsModel
->
closeByInquiryId
(
$inquiry_id
);
$inquiry_related_items
=
$InquiryItemsModel
->
getListByInquiryId
(
$inquiry_id
);
if
(
$inquiry_related_items
){
$inquiry_item_ids
=
array_column
(
$inquiry_related_items
,
'id'
);
// 给领取询价单用户发送消息
$InquiryItemsAssignModel
=
new
InquiryItemsAssignModel
();
$assign_uids
=
$InquiryItemsAssignModel
->
getUniqAssignUidsByInquiryItemIds
(
$inquiry_item_ids
);
$CommonModel
=
new
CommonModel
();
foreach
(
$assign_uids
as
$assign_uid
){
$CommonModel
->
send_msg
(
$assign_uid
,
$user
[
"user_name"
]
.
'已关闭询价,询价单号:'
.
$inquiry_info
[
'inquiry_sn'
]);
}
}
}
$response_data
=
[
0
,
"关闭整个询价单成功"
];
Export
(
$response_data
);
}
//新增询价,sku查询接口
public
function
ApiSkuList
(
Request
$request
){
$k
=
$request
->
input
(
'k'
);
$types
=
$request
->
input
(
'types'
);
$url
=
Config
(
'website.search_url'
)
.
"/search/spu/think?spu_name="
.
$k
;
$res
=
post_curl
(
$url
,[]);
$resArr
=
\GuzzleHttp\json_decode
(
$res
,
true
);
$temp
=
[];
if
(
count
(
$resArr
[
"data"
])
==
0
&&
$types
==
1
){
#返回没查到的数据
array_push
(
$temp
,[
"value"
=>
""
,
"name"
=>
$k
]);
}
else
{
foreach
(
$resArr
[
"data"
]
as
$k
=>
$v
){
array_push
(
$temp
,[
"value"
=>
json_encode
(
$v
),
"name"
=>
$v
[
"spu_name"
]
.
" 品牌:"
.
$v
[
"brand_name"
]]);
}
}
echo
json_encode
(
$temp
,
JSON_UNESCAPED_UNICODE
)
;
}
//新增询价,品牌查询接口
public
function
ApiBrandList
(
Request
$request
){
$k
=
$request
->
input
(
'k'
);
$types
=
$request
->
input
(
'types'
);
}
}
\ No newline at end of file
app/Http/routes.php
View file @
4e67cd37
...
...
@@ -7,6 +7,29 @@
// Route::match(['get', 'post'],'/api/{key}', 'ApiController@Entrance');
// Route::match(['get', 'post'],'/hd/{key}', 'HdController@Entrance');
//});
Route
::
match
([
'get'
,
'post'
],
'/hd/{key}'
,
'HdController@Entrance'
);
Route
::
match
([
'get'
,
'post'
],
'/api/{key}'
,
'ApiController@Entrance'
);
Route
::
match
([
'get'
,
'post'
],
'/server/{key}'
,
'ServerController@Entrance'
);
//
对外提供导出回调接口
\ No newline at end of file
Route
::
match
([
'get'
,
'post'
],
'/server/{key}'
,
'ServerController@Entrance'
);
//对外提供导出回调接口
/*******************询价管理*************************/
//Route::Get('/api/ApiSkuList','InquiryController@ApiSkuList');//新增询价查询sku接口;
//Route::Get('/api/ApiBrandList','InquiryController@ApiBrandList');//新增询价查询品牌接口;
//Route::Post('/api/ApiCheckGoods','ApiController@ApiCheckGoods');//检查是否已经存在询价单;
//Route::Post('/api/ApiCreateOneItems','ApiController@ApiCreateOneItems');//创建一条明细;
//Route::Post('/api/ApiDeleteInquiryItems','ApiController@ApiDeleteInquiryItems');//删除一条明细;
//Route::Post('/api/ApiEditInquiry','ApiController@ApiEditInquiry');//新增询价;
//Route::Post('/api/ApiDeleteInquiryItems','ApiController@ApiDeleteInquiryItems');//删除询价列表;
//Route::Get('/api/ApiInquiryList','ApiController@ApiInquiryList');//询价列表;
//Route::Post('/api/ApiInquiryExport','ApiController@ApiInquiryExport');//导出询价;
//Route::Post('/api/ApiInquiryClose','InquiryController@close');//关闭询价;
/*******************报价管理*************************/
//Route:Post('/api/ApiInquiryListPool','ApiController@ApiInquiryListPool');//询价池;
//Route:Post('/api/ApiTakeInquiry','ApiController@ApiTakeInquiry');//领取询价;
//Route:Post('/api/ApiQuoteList','ApiController@ApiQuoteList');//报价列表;
/*******************操作日志*************************/
//
Route
::
Post
(
'/api/ApiOperationLog'
,
'ApiController@ApiOperationLog'
);
\ No newline at end of file
app/Model/InquiryItemsAssignModel.php
View file @
4e67cd37
...
...
@@ -17,6 +17,12 @@ class InquiryItemsAssignModel extends Model
const
ASSIGN_TYPE_SELECTED
=
2
;
public
function
getUniqAssignUidsByInquiryItemIds
(
$inquiry_item_ids
)
{
$res
=
$this
->
select
(
'assign_uid'
)
->
whereIn
(
"inquiry_item_id"
,
$inquiry_item_ids
)
->
distinct
()
->
get
();
return
(
$res
)
?
$res
->
toArray
()
:
[];
}
// 领取询价
public
function
assign
(
$inquiry_items_id
,
$assign_uid
,
$types
=
1
)
{
...
...
app/Model/InquiryItemsModel.php
View file @
4e67cd37
...
...
@@ -20,6 +20,8 @@ class InquiryItemsModel extends Model
const
CREATED_AT
=
'create_time'
;
const
UPDATED_AT
=
'update_time'
;
const
STATUS_CLOSE
=
-
1
;
// 状态-已关闭
public
function
fromDateTime
(
$value
)
{
return
strtotime
(
parent
::
fromDateTime
(
$value
));
...
...
@@ -30,6 +32,16 @@ class InquiryItemsModel extends Model
return
$this
->
whereIn
(
"id"
,
$ids
)
->
get
()
->
toArray
();
}
public
function
getListByInquiryId
(
$inquiry_id
)
{
$res
=
$this
->
where
(
"inquiry_id"
,
$inquiry_id
)
->
get
();
return
(
$res
)
?
$res
->
toArray
()
:
[];
}
public
function
closeByInquiryId
(
$inquiry_id
)
{
return
$this
->
where
(
"inquiry_id"
,
$inquiry_id
)
->
update
([
"status"
=>
self
::
STATUS_CLOSE
,
"update_time"
=>
time
()]);
}
//生成报价单详情
public
function
ItemsOfferDetail
(
$inquiry_id
)
...
...
app/Model/InquiryModel.php
View file @
4e67cd37
...
...
@@ -27,6 +27,12 @@ class InquiryModel extends Model
return
$this
->
whereIn
(
"id"
,
$ids
)
->
get
()
->
toArray
();
}
public
function
getInfoById
(
$id
)
{
$res
=
$this
->
where
(
"id"
,
$id
)
->
first
();
return
(
$res
)
?
$res
->
toArray
()
:
[];
}
/**
* 询价列表
*/
...
...
@@ -183,7 +189,7 @@ class InquiryModel extends Model
if
(
$export
==
0
){
$res
=
$Redis
->
SISMEMBER
(
'frq_quote_urge'
,
$v
[
'id'
]);
if
(
$res
)
{
$v
[
'inquiry_sn'
]
=
$v
[
'inquiry_sn'
]
.
"<span style='color:
red
;'> *</span>"
;
$v
[
'inquiry_sn'
]
=
$v
[
'inquiry_sn'
]
.
"<span style='color:
#f2f2f2
;'> *</span>"
;
}
}
...
...
@@ -231,6 +237,14 @@ class InquiryModel extends Model
return
[
0
,
"关闭整个询价单成功"
];
}
public
function
closeById
(
$inquiry_id
,
$remark
=
''
,
$user_name
=
''
)
{
if
(
empty
(
@
$inquiry_id
))
{
return
false
;
}
return
$this
->
where
(
"id"
,
$inquiry_id
)
->
update
([
"status"
=>
-
1
,
"remark"
=>
$remark
,
"update_time"
=>
time
()]);
}
/**
* 询价池
*/
...
...
app/Model/LieBrandModell.php
0 → 100644
View file @
4e67cd37
<?php
namespace
App\Model
;
use
Illuminate\Database\Eloquent\Model
;
class
LieBrandModell
extends
Model
{
//
}
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