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
67baa6cb
authored
Mar 16, 2021
by
hcy001
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
1
parent
5c013844
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
91 additions
and
9 deletions
app/Http/Controllers/ApiController.php
app/Http/Controllers/HdController.php
app/Http/Controllers/ServerController.php
app/Http/function.php
app/Model/QuoteModel.php
app/Http/Controllers/ApiController.php
View file @
67baa6cb
...
...
@@ -42,8 +42,8 @@ class ApiController extends Controller
$this
->
email
=
$loginInfo
[
"email"
];
$input
=
$_REQUEST
;
$input
[
"user_id"
]
=
$this
->
user_id
;
$input
[
"email"
]
=
$this
->
email
;
$input
[
"user_id"
]
=
$this
->
user_id
;
#用户id
$input
[
"email"
]
=
$this
->
email
;
#邮箱
$input
[
"user_name"
]
=
$this
->
user_name
;
#用户中文名称
$this
->
$id
(
$input
,
$id
);
...
...
app/Http/Controllers/HdController.php
View file @
67baa6cb
...
...
@@ -3,6 +3,7 @@
namespace
App\Http\Controllers
;
use
App\Http\Requests
;
use
App\Http\Controllers\Controller
;
use
App\Model\QuoteModel
;
use
Dompdf\Dompdf
;
use
Request
;
use
Barryvdh\DomPDF\PDF
;
...
...
@@ -19,6 +20,11 @@ class HdController extends Controller
echo
json_encode
([
'errcode'
=>
$errcode
,
'errmsg'
=>
$errmsg
,
'data'
=>
$data
]);
exit
();
}
//添加参数
private
function
cf
(){
$t
=
'{"data":{"0":{"inquiry_sn":"A161398670712345","inquiry_items_id":"1","currency":2,"goods_id":"353535","goods_name":"LM358","brand_id":"0","brand_name":"TI","supplier_id":7,"supplier_name":"digikey","quote_number":"25","status":1,"create_uid":0,"create_name":"digikey","create_time":1615880179,"update_time":1615880179,"price_origin":0.37,"raw_goods_sn":"497-1591-1-ND","raw_goods_packing":"Cut Tape (CT)","raw_brand_nam e":"STMicroelectronics"},"1":{"inquiry_sn":"A161398670712345","inquiry_items_id":"1","currency":2,"goods_id":"353535","goods_name":"LM358","brand_id":"0","brand_name":"TI","supplier_id":7,"supplier_name":"d igikey","quote_number":"25","status":1,"create_uid":0,"create_name":"digikey","create_time":1615880179,"update_time":1615880179,"price_origin":0.37,"raw_goods_sn":"497-1591-6-ND","raw_goods_packing":"Digi-R eel®","raw_brand_name":"STMicroelectronics"},"2":{"inquiry_sn":"A161398670712345","inquiry_items_id":"1","currency":2,"goods_id":"353535","goods_name":"LM358","brand_id":"0","brand_name":"TI","supplier_id":7,"supplier_name":"digikey","quote_number":"25","status":1,"create_uid":0,"create_name":"digikey","create_time":1615880179,"update_time":1615880179,"price_origin":0.65,"raw_goods_sn":"LM358DTCT-ND","raw_goo ds_packing":"Cut Tape (CT)","raw_brand_name":"Rohm Semiconductor"},"3":{"inquiry_sn":"A161398670712345","inquiry_items_id":"1","currency":2,"goods_id":"353535","goods_name":"LM358","brand_id":"0","brand_nam e":"TI","supplier_id":7,"supplier_name":"digikey","quote_number":"25","status":1,"create_uid":0,"create_name":"digikey","create_time":1615880179,"update_time":1615880179,"price_origin":0.65,"raw_goods_sn":" LM358DTDKR-ND","raw_goods_packing":"Digi-Reel®","raw_brand_name":"Rohm Semiconductor"}}}'
;
$res
=
(
new
QuoteModel
())
->
addBatch
(
$t
);
}
//pdf添加
private
function
a
(){
...
...
app/Http/Controllers/ServerController.php
View file @
67baa6cb
...
...
@@ -6,6 +6,7 @@ use App\Model\InquiryItemsModel;
use
App\Model\InquiryItemsReportModel
;
use
App\Model\InquiryModel
;
use
App\Model\LoginModel
;
use
App\Model\QuoteModel
;
use
Illuminate\Http\Request
;
use
App\Http\Requests
;
use
DB
;
...
...
@@ -27,6 +28,11 @@ class ServerController extends Controller
(
new
LoginModel
())
->
CreatePcToken
(
$request
);
}
//生成登录token(目前只有pc在用)
public
function
BatchQuote
(
$request
){
Export
((
new
QuoteModel
())
->
addBatch
(
@
$_REQUEST
[
"data"
]));
}
/*
* 询报价导出
*/
...
...
app/Http/function.php
View file @
67baa6cb
<?php
/*
* 生成订单号
*/
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
;
}
/*
* 根据当前环境获取目标网址
*/
function
getHostUrl
(
$sys
)
...
...
app/Model/QuoteModel.php
View file @
67baa6cb
...
...
@@ -216,8 +216,70 @@ class QuoteModel extends Model
return
[
0
,
'撤销成功'
];
}
/*
* 批量新增报价
*
*/
public
function
addBatch
(
$indata
)
{
$input
=
json_decode
(
$indata
,
true
);
if
(
!
$input
||
count
(
$input
)
==
0
)
return
[
1
,
'数据不得为空'
];
// 询价明细单状态
$inquiry_items_id
=
$input
[
0
][
'inquiry_items_id'
];
$inquiry_items_status
=
InquiryItemsModel
::
where
(
'id'
,
$inquiry_items_id
)
->
value
(
'status'
);
if
(
$inquiry_items_status
==
-
1
)
return
[
1
,
'新增报价失败,该询价明细已关闭'
];
try
{
$con
=
DB
::
connection
(
'rfq'
);
$con
->
beginTransaction
();
$QuoteModel
=
new
QuoteModel
();
#拼接批量插入明细
foreach
(
$input
as
$k
=>&
$v
){
$check
=
$this
->
where
([
"inquiry_items_id"
=>
$inquiry_items_id
,
"raw_goods_sn"
=>
$v
[
"raw_goods_sn"
]])
->
first
();
if
(
$check
){
#存在更新
$v
[
"create_time"
]
=
time
();
$this
->
where
([
"inquiry_items_id"
=>
$inquiry_items_id
,
"raw_goods_sn"
=>
$v
[
"raw_goods_sn"
]])
->
update
(
$v
)
;
OpLogModel
::
log
([
'types'
=>
2
,
'relation_id'
=>
$inquiry_items_id
,
'relation_sn'
=>
$check
->
quote_sn
,
'content'
=>
'自动报价-更新,价格:'
+
(
$v
[
"currency"
]
==
"1"
?
"¥"
.
$v
[
""
]
:
"$"
.
$v
[
""
]),
'create_name'
=>
"系统"
,
]);
}
else
{
$v
[
"quote_sn"
]
=
createSn
(
$QuoteModel
,
'quote_sn'
,
'B'
);
$v
[
"create_time"
]
=
time
();
$v
[
"update_time"
]
=
time
();
print_r
(
$v
);
$this
->
insert
(
$v
);
OpLogModel
::
log
([
'types'
=>
2
,
'relation_id'
=>
$inquiry_items_id
,
'relation_sn'
=>
$v
[
"quote_sn"
],
'content'
=>
'自动报价-插入'
,
'create_name'
=>
"系统"
,
]);
}
}
if
(
$inquiry_items_status
==
1
)
{
// 询价明细为待报价时,更新为已报价
InquiryItemsModel
::
where
(
'id'
,
$inquiry_items_id
)
->
update
([
'status'
=>
2
]);
}
// 通知询价人,放入redis
RedisDB
::
sadd
(
'frq_quote_urge'
,
$inquiry_items_id
);
$con
->
commit
();
return
[
0
,
"新增成功"
];
}
catch
(
\Exception
$e
)
{
$con
->
rollBack
();
return
[
1001
,
"新增失败"
.
$e
->
getMessage
()];
}
}
// 新增
//
单个
新增
public
function
add
(
$input
)
{
$quote_info
=
$input
[
'quote_info'
];
...
...
@@ -229,12 +291,9 @@ class QuoteModel extends Model
$inquiry_items_status
=
InquiryItemsModel
::
where
(
'id'
,
$quote_info
[
'inquiry_items_id'
])
->
value
(
'status'
);
if
(
$inquiry_items_status
==
-
1
)
return
[
1
,
'新增报价失败,该询价明细已关闭'
];
$UserModel
=
new
UserModel
;
$create_name
=
$UserModel
->
FinduserInfoName
(
$input
[
'user_id'
]);
$quote_info
[
'status'
]
=
1
;
// 已报价
$quote_info
[
'create_uid'
]
=
$input
[
'user_id'
];
$quote_info
[
'create_name'
]
=
$
create_name
;
$quote_info
[
'create_name'
]
=
$
input
[
'user_name'
]
;
$res
=
$this
->
create
(
$quote_info
);
if
(
$res
===
false
)
return
[
2
,
'新增报价失败'
];
...
...
@@ -252,13 +311,12 @@ class QuoteModel extends Model
$data
[
'relation_sn'
]
=
''
;
$data
[
'content'
]
=
'新增报价,报价单号:'
.
$quote_info
[
'quote_sn'
];
$data
[
'create_uid'
]
=
$input
[
'user_id'
];
$data
[
'create_name'
]
=
$
create_name
;
$data
[
'create_name'
]
=
$
input
[
'user_name'
]
;
OpLogModel
::
log
(
$data
);
}
catch
(
Exception
$e
)
{
return
[
1
,
$e
->
getMessage
()];
}
return
[
0
,
'新增报价成功'
];
}
...
...
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