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
046debee
authored
Mar 08, 2021
by
hcy001
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
1
parent
aba2da9a
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
99 additions
and
22 deletions
app/Http/Controllers/ApiController.php
app/Model/InquiryItemsModel.php
app/Model/InquiryItemsReportModel.php
app/Model/QuoteModel.php
app/map/QuoteMap.php
app/Http/Controllers/ApiController.php
View file @
046debee
...
...
@@ -65,6 +65,10 @@ class ApiController extends Controller
public
function
ApiInquiryItemsClose
(
$input
,
$id
){
Export
((
new
InquiryItemsModel
())
->
inquiryItemsClose
(
$input
));
}
//询价: 选中 撤销 确认 -》 报价
public
function
ApiQuoteSure
(
$input
,
$id
){
Export
((
new
QuoteModel
())
->
updateStatus
(
$input
));
}
//吹报价
private
function
ApiUrgePrice
(
$input
,
$id
){
Export
((
new
InquiryItemsModel
())
->
urgePrice
(
$input
));
...
...
@@ -116,13 +120,12 @@ class ApiController extends Controller
//生成报价/销售 询价单
private
function
ApiAddInquiryReport
(
$input
,
$id
){
$InquiryItemsReportModel
=
new
InquiryItemsReportModel
();
$data
=
$InquiryItemsReportModel
->
addOffer
(
1
,
$input
);
$data
=
$InquiryItemsReportModel
->
addOffer
(
$input
);
if
(
$data
[
0
]
>
0
){
Export
(
$data
);
}
$report_sn
=
$data
[
2
][
"report_sn"
];
# $report_sn = "R2021030605803";
$InquiryItemsReportModel
->
createSalePdf
(
$report_sn
);
$inquiry_id
=
$data
[
2
][
"inquiry_id"
];
$InquiryItemsReportModel
->
createSalePdf
(
$inquiry_id
);
}
//删除询价列表
...
...
@@ -203,4 +206,11 @@ class ApiController extends Controller
ExportLayui
((
new
OpLogModel
())
->
getList
(
$input
));
}
//修改销售报价信息
public
function
ApiUpdateReport
(
$input
,
$id
)
{
Export
((
new
InquiryItemsReportModel
())
->
updateReport
(
$input
));
}
}
app/Model/InquiryItemsModel.php
View file @
046debee
...
...
@@ -132,6 +132,7 @@ class InquiryItemsModel extends Model
}
if
(
@
$input
[
"inquiry_items_id"
]){
$del
=
$this
->
where
([
"id"
=>
$input
[
"inquiry_items_id"
]])
->
delete
();
$del
=
(
new
InquiryItemsReportModel
())
->
where
([
"id"
=>
$input
[
"inquiry_items_id"
]])
->
delete
();
#同步输出报价表
}
return
[
0
,
"删除成功"
];
}
...
...
@@ -213,6 +214,12 @@ class InquiryItemsModel extends Model
$inquiryItemsId
=
$this
->
insertGetId
(
$insertArr
);
#插入销售报价表
(
new
InquiryItemsReportModel
())
->
insert
([
"inquiry_id"
=>
$b
[
"inquiry_id"
]
,
"inquiry_items_id"
=>
$inquiryItemsId
,
]);
#插入指定领取人
if
(
$b
[
"pur_s"
]
!==
""
){
$purArr
=
json_decode
(
$b
[
"pur_s"
],
true
);
...
...
@@ -230,6 +237,7 @@ class InquiryItemsModel extends Model
}
}
#日志
OplogModel
::
log
([
'types'
=>
1
,
...
...
@@ -371,6 +379,12 @@ class InquiryItemsModel extends Model
]);
}
}
#插入销售报价表
(
new
InquiryItemsReportModel
())
->
insert
([
"inquiry_id"
=>
$b
[
"inquiry_id"
]
,
"inquiry_items_id"
=>
$inquiryItemsId
,
]);
}
if
(
count
(
$assignInsert
)
>
0
){
#插入指定人
...
...
app/Model/InquiryItemsReportModel.php
View file @
046debee
...
...
@@ -21,16 +21,21 @@ class InquiryItemsReportModel extends Model
* 生成报价单或者销售单插入 report 表
* @param $types 类型: 1 报价单 2 (销售单)生成订单
*/
public
function
addOffer
(
$types
,
$input
){
public
function
addOffer
(
$input
){
$inquiry_id
=
$input
[
"inquiry_id"
];
$currency
=
$input
[
"currency"
];
#币种
if
(
$inquiry_id
<=
0
){
return
[
1001
,
"询价单号不得为空"
];
}
try
{
$con
=
DB
::
connection
(
'rfq'
);
$con
->
beginTransaction
();
$inquiry_id
=
$input
[
"inquiry_id"
];
$
currency
=
$input
[
"currency"
];
#币种
#先批量删除报价
$
this
->
where
(
"inquiry_id"
,
$inquiry_id
)
->
delete
();
$insertArr
=
[];
//批量插入数组
#最后批量添加
foreach
(
$input
[
"items"
]
as
$k
=>
$inquiry_items_id
){
$temp
=
[
"inquiry_id"
=>
$inquiry_id
,
...
...
@@ -48,16 +53,15 @@ class InquiryItemsReportModel extends Model
"create_name"
=>
$input
[
"user_name"
],
"create_time"
=>
time
()
,
];
if
(
$currency
==
1
){
$temp
[
"price_rmb"
]
=@
$input
[
"quote_price"
][
$k
]
?
$input
[
"quote_price"
][
$k
]
:
0
;
}
else
{
$temp
[
"price_origin"
]
=@
$input
[
"quote_price"
][
$k
]
?
$input
[
"quote_price"
][
$k
]
:
0
;
}
array_push
(
$insertArr
,
$temp
);
$this
->
where
(
"inquiry_items_id"
,
$inquiry_items_id
)
->
update
(
$temp
);
//更新销售报价
}
$this
->
insert
(
$insertArr
);
//批量插入
$con
->
commit
();
return
[
0
,
"成功"
,[
"inquiry_id"
=>
$inquiry_id
]];
}
catch
(
\Exception
$e
)
{
...
...
@@ -98,5 +102,26 @@ class InquiryItemsReportModel extends Model
Export
([
0
,
"成功"
,
"/server/DownPdf?file_name="
.
$name
]);
}
/*
* 更新内容
*/
public
function
updateReport
(
$data
){
$inquiry_items_id
=
$data
[
"inquiry_items_id"
];
if
(
$inquiry_items_id
<=
0
)
return
[
1001
,
"询价明细ID不得为空"
];
$temp
[
"price_origin"
]
=
@
$data
[
"price_origin"
]
?
$data
[
"price_origin"
]
:
0
;
$temp
[
"price_rmb"
]
=
@
$data
[
"price_rmb"
]
?
$data
[
"price_rmb"
]
:
0
;
$temp
[
"currency"
]
=
@
$data
[
"currency"
]
?
$data
[
"currency"
]
:
1
;
if
(
$temp
[
"currency"
]
==
1
){
$temp
[
"price_rmb"
]
=
$data
[
"price"
];
}
else
{
$temp
[
"price_origin"
]
=
$data
[
"price"
];
}
$up
=
$this
->
where
(
"inquiry_items_id"
,
$inquiry_items_id
)
->
update
(
$temp
);
(
new
QuoteModel
())
->
where
(
"id"
,
$data
[
"quote_id"
])
->
update
([
"status"
=>
$data
[
"status"
]]);
#更新报价选中
return
[
0
,
"成功"
];
}
}
\ No newline at end of file
app/Model/QuoteModel.php
View file @
046debee
...
...
@@ -490,4 +490,32 @@ class QuoteModel extends Model
return
[
0
,
'修改报价成功'
];
}
//询价: 选中 撤销 确认 -》 报价
public
function
updateStatus
(
$input
)
{
$id
=
$input
[
'id'
];
$status
=
$input
[
'status'
];
if
(
!
$id
)
return
[
-
1
,
'参数缺失'
];
try
{
$res
=
$this
->
where
(
'id'
,
$id
)
->
update
([
'status'
=>
$status
,
'update_time'
=>
time
()]);
$quote_info
=
$this
->
find
(
$id
);
$UserModel
=
new
UserModel
;
$data
=
[];
$data
[
'types'
]
=
1
;
$data
[
'relation_id'
]
=
$id
;
$data
[
'relation_sn'
]
=
$quote_info
[
'quote_sn'
];
$data
[
'content'
]
=
'询价操作报价:'
.
QuoteMap
::
$status
[
$status
];
$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
app/map/QuoteMap.php
View file @
046debee
...
...
@@ -3,24 +3,22 @@ namespace App\map;
//报价枚举
class
QuoteMap
{
//状态 -1:已
关闭 1:待报价 2:已报价 3:已选中 4:已固定 5
:已确认
//状态 -1:已
撤销 0:草稿 1:已报价 2:已选中 3
:已确认
const
status_close
=
-
1
;
const
status_cao
=
0
;
const
status_ready
=
1
;
const
status_replay
=
2
;
const
status_check
=
3
;
const
status_fix
=
4
;
const
status_sure
=
5
;
const
status_fix
=
2
;
const
status_sure
=
3
;
static
$status
=
[
self
::
status_close
=>
"已关闭"
,
self
::
status_ready
=>
"待报价"
,
self
::
status_replay
=>
"已报价"
,
self
::
status_check
=>
"已选中"
,
self
::
status_fix
=>
"已固定"
,
self
::
status_close
=>
"已撤销"
,
self
::
status_cao
=>
"草稿"
,
self
::
status_ready
=>
"已报价"
,
self
::
status_fix
=>
"已选中"
,
self
::
status_sure
=>
"已确认"
,
];
//可用报价状态
static
$status_used
=
[
self
::
status_ready
,
self
::
status_
replay
,
self
::
status_check
,
self
::
status_fix
,
self
::
status_sure
];
static
$status_used
=
[
self
::
status_ready
,
self
::
status_
fix
,
self
::
status_fix
];
}
...
...
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