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
20ce6f1a
authored
Mar 04, 2021
by
朱继来
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
新增报价
parent
794a7c13
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
45 additions
and
5 deletions
app/Http/Controllers/ApiController.php
app/Model/QuoteModel.php
app/Http/Controllers/ApiController.php
View file @
20ce6f1a
...
...
@@ -46,6 +46,17 @@ class ApiController extends Controller
$this
->
$id
(
$input
,
$id
);
}
// 生成询报价单号
public
function
createSn
(
$model
,
$field
,
$prefix
=
''
,
$suffix
=
''
)
{
$sn
=
$prefix
.
time
()
.
rand
(
10000
,
99999
)
.
$suffix
;
$id
=
$model
->
where
(
$field
,
$sn
)
->
value
(
'id'
);
if
(
!
empty
(
$id
))
{
$sn
=
$this
->
createSn
(
$prefix
,
$suffix
);
}
return
$sn
;
}
//关闭整个询价单
private
function
ApiInquiryClose
(
$request
,
$id
){
Export
((
new
InquiryModel
())
->
inquiryClose
(
$request
->
input
(
'inquiry_id'
)));
...
...
@@ -135,9 +146,10 @@ class ApiController extends Controller
}
// 新增报价
public
function
ApiAddQuote
(
$
reques
t
,
$id
)
public
function
ApiAddQuote
(
$
inpu
t
,
$id
)
{
Export
((
new
QuoteModel
())
->
add
(
$request
));
$input
[
'quote_info'
][
'quote_sn'
]
=
$this
->
createSn
((
new
QuoteModel
()),
'quote_sn'
,
'B'
);
Export
((
new
QuoteModel
())
->
add
(
$input
));
}
}
app/Model/QuoteModel.php
View file @
20ce6f1a
...
...
@@ -10,6 +10,7 @@ use DB;
use
App\Model\OplogModel
;
use
App\Model\UserModel
;
use
App\Http\Controllers\PermController
;
use
RedisDB
;
//报价
class
QuoteModel
extends
Model
...
...
@@ -17,6 +18,7 @@ class QuoteModel extends Model
protected
$connection
=
'rfq'
;
protected
$table
=
'quote'
;
protected
$primaryKey
=
'id'
;
protected
$guarded
=
[
'id'
];
public
$timestamps
=
true
;
const
CREATED_AT
=
'create_time'
;
const
UPDATED_AT
=
'update_time'
;
...
...
@@ -202,15 +204,40 @@ class QuoteModel extends Model
}
// 新增
public
function
add
(
$
reques
t
)
public
function
add
(
$
inpu
t
)
{
$quote_info
=
$
request
->
input
(
'quote_info'
,
''
)
;
$quote_info
=
$
input
[
'quote_info'
]
;
// 待转发到go接口
if
(
!
$quote_info
)
return
[
1
,
'报价数据不存在'
];
try
{
$res
=
$this
->
create
(
$quote_info
);
if
(
$res
===
false
)
return
[
2
,
'新增报价失败'
];
// 通知询价人,放入redis
RedisDB
::
set
(
'frq_quote_urge'
,
$quote_info
[
'inquiry_items_id'
]);
$UserModel
=
new
UserModel
;
$data
=
[];
$data
[
'types'
]
=
2
;
$data
[
'relation_id'
]
=
$quote_info
[
'inquiry_items_id'
];
$data
[
'relation_sn'
]
=
''
;
$data
[
'content'
]
=
'新增报价,报价单号:'
.
$quote_info
[
'quote_sn'
];
$data
[
'create_uid'
]
=
$input
[
'user_id'
];
$data
[
'create_name'
]
=
$UserModel
->
FinduserInfoName
(
$input
[
'user_id'
]);
OplogModel
::
log
(
$data
);
}
catch
(
Exception
$e
)
{
return
[
1
,
$e
->
getMessage
()];
}
return
[
0
,
'新增报价成功'
];
}
}
\ 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