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
e0ec3925
authored
Apr 28, 2021
by
杜文军
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
报价导入导出
parent
4e2b4e09
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
64 additions
and
123 deletions
app/Http/Controllers/ApiController.php
app/Http/Controllers/ServerController.php
app/Http/LogReport.php
app/Model/ExportModel.php
app/Model/QuoteModel.php
public/index.php
app/Http/Controllers/ApiController.php
View file @
e0ec3925
...
...
@@ -178,11 +178,6 @@ class ApiController extends Controller
(
new
ExportModel
())
->
InquiryExport
(
$input
,
$this
->
user_id
);
}
private
function
ApiReceiveInquiryExport
(
$input
)
{
(
new
ExportModel
())
->
MyReceiveInquiryExport
(
$input
,
$this
->
user_id
);
}
//生成报价pdf
private
function
ApiOfferPdf
(
$request
){
(
new
CommonModel
())
->
Pdf
();
...
...
@@ -234,6 +229,8 @@ class ApiController extends Controller
Export
((
new
InquiryItemsModel
())
->
import
(
$input
));
}
// 删除报价草稿
public
function
ApiDeleteQuoteDraft
(
$input
,
$id
)
{
...
...
app/Http/Controllers/ServerController.php
View file @
e0ec3925
...
...
@@ -47,49 +47,6 @@ class ServerController extends Controller
return
ExportLayuiReturn
(
$res
);
}
public
function
MyReceiveInquiryExport
()
{
$server
=
new
Hprose\Http\Service
();
$server
->
addMethod
(
'MyReceiveInquiryServer'
,
$this
);
$server
->
handle
();
}
public
function
MyReceiveInquiryServer
(
$info
){
$params
=
json_decode
(
$info
,
true
);
$inquiry_item_ids
=
explode
(
","
,
$params
[
'inquiry_item_ids'
]);
$inquiry_item_ids
=
array_values
(
array_filter
(
$inquiry_item_ids
));
$data
=
[];
$InquiryItemsModel
=
new
InquiryItemsModel
();
$inquire_item_list
=
$InquiryItemsModel
->
GetInquireItemsListByIds
(
$inquiry_item_ids
);
if
(
$inquire_item_list
&&
is_array
(
$inquire_item_list
)){
$inquiry_ids
=
array_column
(
$inquire_item_list
,
'inquiry_id'
);
$InquiryModel
=
new
InquiryModel
();
$inquire_list
=
$InquiryModel
->
GetInquiryListByIds
(
$inquiry_ids
);
$inquire_info_map
=
array_combine
(
array_column
(
$inquire_list
,
'id'
),
$inquire_list
);
foreach
(
$inquire_item_list
as
$inquire_item_info
){
$data
[]
=
[
"inquiry_item_id"
=>
(
int
)
$inquire_item_info
[
'id'
],
"goods_name"
=>
(
string
)
$inquire_item_info
[
'goods_name'
],
"brand_name"
=>
(
string
)
$inquire_item_info
[
'brand_name'
],
"inquiry_number"
=>
(
int
)
$inquire_item_info
[
'inquiry_number'
],
"target_price"
=>
$inquire_item_info
[
'target_price'
],
"delivery_place"
=>
(
int
)
$inquire_info_map
[
$inquire_item_info
[
'inquiry_id'
]][
'delivery_place'
],
"delivery_time"
=>
(
int
)
$inquire_item_info
[
'delivery_time'
],
"supplier_name"
=>
''
,
"currency"
=>
''
,
"price_origin"
=>
''
,
"price_rmb"
=>
''
,
"price_other"
=>
''
,
"batch"
=>
''
,
"quote_delivery_time"
=>
''
,
];
}
}
$res
=
[
0
,
'成功'
,
$data
,
count
(
$inquiry_item_ids
)];
return
ExportLayuiReturn
(
$res
);
}
//下载pdf文件
private
function
DownPdf
(
$input
,
$id
){
$filename
=
base_path
()
.
"/public/pdf/"
.
$input
[
"file_name"
];
...
...
app/Http/LogReport.php
View file @
e0ec3925
...
...
@@ -8,7 +8,7 @@ defined('REPORT_APP_NAME') or define('REPORT_APP_NAME', 'frq_api');
defined
(
'LOG_FILE_SIZE'
)
or
define
(
'LOG_FILE_SIZE'
,
2097152
);
//2MB
// 设定错误和异常处理
error_reporting
(
0
);
error_reporting
(
E_ERROR
);
LogReport
::
auto
();
...
...
app/Model/ExportModel.php
View file @
e0ec3925
...
...
@@ -63,24 +63,4 @@ class ExportModel
echo
self
::
push
(
$data
);
}
public
function
MyReceiveInquiryExport
(
$input
,
$create_uid
){
$input
[
"is_export"
]
=
1
;
#导出状态
$header
=
[
"明细id"
,
"型号"
,
"品牌"
,
"数量"
,
"目标价"
,
"交货地"
,
"交货时间"
,
"供应商"
,
"报价币种"
,
"单价"
,
"含税价格"
,
"采购费"
,
"批次"
,
"交期"
];
$file_name
=
"已领取的询价"
;
$data
=
[
"type"
=>
2
,
# 类型 1:模板调用 2: api回调
"source_items_id"
=>
config
(
"website.export_source_items_id"
),
#来源明细id,必填
"file_name"
=>
$file_name
,
"excel_suf"
=>
"csv"
,
#导出文件格式 csv,xls
"header"
=>
$header
,
"query_param"
=>
$input
,
#查询参数
"callbackurl"
=>
$this
->
frqApiUrl
.
"/server/MyReceiveInquiryExport"
,
#rpc回调网址
"callbackfuc"
=>
"InquiryServer"
,
#rpc回调函数
"create_uid"
=>
$create_uid
,
#创建人id
];
echo
self
::
push
(
$data
);
}
}
\ No newline at end of file
app/Model/QuoteModel.php
View file @
e0ec3925
...
...
@@ -222,6 +222,10 @@ class QuoteModel extends Model
$list
=
$list
->
where
(
'q.status'
,
'<>'
,
0
);
// 过滤报价草稿
}
elseif
(
@
$input
[
'inquiry_items_id'
]
>
0
)
{
$list
=
$list
->
where
(
'q.status'
,
0
)
->
where
(
'q.inquiry_items_id'
,
$input
[
'inquiry_items_id'
]);
}
elseif
(
isset
(
$input
[
'inquiry_items_ids'
])
&&
$input
[
'inquiry_items_ids'
])
{
$inquiry_items_ids
=
explode
(
","
,
$input
[
'inquiry_items_ids'
]);
$inquiry_items_ids
=
array_values
(
array_filter
(
$inquiry_items_ids
));
$list
=
$list
->
where
(
'q.status'
,
0
)
->
whereIn
(
'q.inquiry_items_id'
,
$inquiry_items_ids
);
}
}
...
...
@@ -626,7 +630,7 @@ class QuoteModel extends Model
}
$map
=
Config
(
'quote.import_quote_map'
);
if
(
count
(
$map
)
!=
count
(
$excel
[
0
]))
{
if
(
count
(
$map
)
!=
count
(
$excel
[
2
]))
{
return
[
2
,
'导入模板错误'
];
}
...
...
@@ -712,7 +716,7 @@ class QuoteModel extends Model
{
$count
=
count
(
$excel
);
if
(
$count
==
1
)
{
if
(
$count
==
3
)
{
return
[
3
,
'未填写报价信息'
];
}
...
...
@@ -863,77 +867,82 @@ class QuoteModel extends Model
// 批量提交报价
public
function
batchQuote
(
$input
)
{
if
(
!
$input
[
'inquiry_items_id'
]
)
{
if
(
empty
(
$input
[
'inquiry_items_ids'
])
)
{
return
[
-
1
,
'参数缺失'
];
}
// 询价明细单状态
$inquiry_items_status
=
InquiryItemsModel
::
where
(
'id'
,
$input
[
'inquiry_items_id'
])
->
value
(
'status'
);
if
(
$inquiry_items_status
==
-
1
)
{
return
[
1
,
'批量提交报价失败,该询价明细已关闭'
];
}
$inquiry_items_ids
=
explode
(
","
,
$input
[
'inquiry_items_ids'
]);
$inquiry_items_ids
=
array_values
(
array_filter
(
$inquiry_items_ids
));
try
{
$map
=
[];
$map
[
'inquiry_items_id'
]
=
$input
[
'inquiry_items_id'
];
$map
[
'status'
]
=
0
;
// 草稿状态
foreach
(
$inquiry_items_ids
as
$inquiry_items_id
){
// 询价明细单状态
$inquiry_items_status
=
InquiryItemsModel
::
where
(
'id'
,
$inquiry_items_id
)
->
value
(
'status'
);
if
(
$inquiry_items_status
==
-
1
)
{
return
[
1
,
'批量提交报价失败,该询价明细已关闭'
];
}
$count
=
$this
->
where
(
$map
)
->
count
();
$map
=
[];
$map
[
'inquiry_items_id'
]
=
$inquiry_items_id
;
$map
[
'status'
]
=
0
;
// 草稿状态
if
(
!
$count
)
{
return
[
1
,
'当前没有导入报价单'
];
}
$count
=
$this
->
where
(
$map
)
->
count
();
$quote_info
=
$this
->
where
(
$map
)
->
get
()
->
toArray
();
// 获取草稿信息
if
(
!
$count
)
{
return
[
1
,
'当前没有导入报价单'
];
}
$this
->
where
(
$map
)
->
update
([
'status'
=>
1
]);
$quote_info
=
$this
->
where
(
$map
)
->
get
()
->
toArray
();
// 获取草稿信息
if
(
$inquiry_items_status
==
1
)
{
// 询价明细为待报价时,更新为已报价
InquiryItemsModel
::
where
(
'id'
,
$input
[
'inquiry_items_id'
])
->
update
([
'status'
=>
2
]);
}
$this
->
where
(
$map
)
->
update
([
'status'
=>
1
]);
// 从询价池过来的,自动领取
$InquiryItemsAssignModel
=
new
InquiryItemsAssignModel
;
$where
=
[];
$where
[
'inquiry_items_id'
]
=
$input
[
'inquiry_items_id'
];
$where
[
'assign_uid'
]
=
$input
[
'user_id'
];
$assign_id
=
$InquiryItemsAssignModel
->
where
(
$where
)
->
value
(
'id'
);
if
(
$inquiry_items_status
==
1
)
{
// 询价明细为待报价时,更新为已报价
InquiryItemsModel
::
where
(
'id'
,
$inquiry_items_id
)
->
update
([
'status'
=>
2
]);
}
if
(
!
$assign_id
)
{
$InquiryItemsAssignModel
->
assign
(
$input
[
'inquiry_items_id'
],
$input
[
'user_id'
]);
}
// 从询价池过来的,自动领取
$InquiryItemsAssignModel
=
new
InquiryItemsAssignModel
;
$where
=
[];
$where
[
'inquiry_items_id'
]
=
$inquiry_items_id
;
$where
[
'assign_uid'
]
=
$input
[
'user_id'
];
$assign_id
=
$InquiryItemsAssignModel
->
where
(
$where
)
->
value
(
'id'
);
// 通知询价人,放入redis
RedisDB
::
sadd
(
'frq_quote_urge'
,
$input
[
'inquiry_items_id'
]);
if
(
!
$assign_id
)
{
$InquiryItemsAssignModel
->
assign
(
$inquiry_items_id
,
$input
[
'user_id'
]);
}
// 推送消息
$InquiryModel
=
new
InquiryModel
;
$inquiry_uid
=
$InquiryModel
->
where
(
'id'
,
$quote_info
[
0
][
'inquiry_id'
])
->
value
(
'create_uid'
);
// 询价人
// 通知询价人,放入redis
RedisDB
::
sadd
(
'frq_quote_urge'
,
$inquiry_items_id
);
$contents
=
$input
[
'user_name'
]
.
'已报价,请及时查看!'
;
// 推送消息
$InquiryModel
=
new
InquiryModel
;
$inquiry_uid
=
$InquiryModel
->
where
(
'id'
,
$quote_info
[
0
][
'inquiry_id'
])
->
value
(
'create_uid'
);
// 询价人
foreach
(
$quote_info
as
$v
)
{
$data
=
[];
$data
[
'types'
]
=
2
;
$data
[
'relation_id'
]
=
$v
[
'id'
];
$data
[
'relation_sn'
]
=
''
;
$data
[
'content'
]
=
'批量提交报价,报价单号:'
.
$v
[
'quote_sn'
];
$data
[
'create_uid'
]
=
$input
[
'user_id'
];
$data
[
'create_name'
]
=
$input
[
'user_name'
];
$contents
=
$input
[
'user_name'
]
.
'已报价,请及时查看!'
;
OpLogModel
::
log
(
$data
);
foreach
(
$quote_info
as
$v
)
{
$data
=
[];
$data
[
'types'
]
=
2
;
$data
[
'relation_id'
]
=
$v
[
'id'
];
$data
[
'relation_sn'
]
=
''
;
$data
[
'content'
]
=
'批量提交报价,报价单号:'
.
$v
[
'quote_sn'
];
$data
[
'create_uid'
]
=
$input
[
'user_id'
];
$data
[
'create_name'
]
=
$input
[
'user_name'
];
if
(
$v
[
'currency'
]
==
1
)
{
$price
=
'¥'
.
$v
[
'price_rmb'
];
}
else
{
$price
=
'$'
.
$v
[
'price_origin'
];
OpLogModel
::
log
(
$data
);
if
(
$v
[
'currency'
]
==
1
)
{
$price
=
'¥'
.
$v
[
'price_rmb'
];
}
else
{
$price
=
'$'
.
$v
[
'price_origin'
];
}
$contents
.=
'报价单号:'
.
$v
[
'quote_sn'
]
.
',单价:'
.
$price
.
';'
;
}
$contents
.=
'报价单号:'
.
$v
[
'quote_sn'
]
.
',单价:'
.
$price
.
';'
;
$CommonModel
=
new
CommonModel
;
$CommonModel
->
send_msg
(
$inquiry_uid
,
trim
(
$contents
,
';'
));
}
$CommonModel
=
new
CommonModel
;
$CommonModel
->
send_msg
(
$inquiry_uid
,
trim
(
$contents
,
';'
));
}
catch
(
Exception
$e
)
{
return
[
1
,
$e
->
getMessage
()];
}
...
...
public/index.php
View file @
e0ec3925
...
...
@@ -18,7 +18,6 @@ ini_set('mongo.long_as_object', 1);
| loading any of our classes later on. It feels nice to relax.
|
*/
require
__DIR__
.
'/../bootstrap/autoload.php'
;
/*
...
...
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