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
814339c1
authored
Mar 10, 2021
by
hcy001
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
1
parent
5604124a
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
85 additions
and
11 deletions
app/Http/Controllers/ApiController.php
app/Model/CommonModel.php
app/Model/InquiryItemsReportModel.php
app/Model/InquiryModel.php
app/Model/QuoteModel.php
resources/views/web/InquiryDetail.blade.php
app/Http/Controllers/ApiController.php
View file @
814339c1
...
...
@@ -223,5 +223,10 @@ class ApiController extends Controller
{
(
new
CommonModel
())
->
getUser
(
$input
[
"k"
],
$input
[
"types"
]);
}
// 统计询价数据
public
function
ApiInquiryCount
(
$input
,
$id
)
{
Export
((
new
InquiryModel
())
->
inquiryCount
(
$input
));
}
}
app/Model/CommonModel.php
View file @
814339c1
...
...
@@ -9,6 +9,11 @@ use DB;
//公共模型
class
CommonModel
extends
Model
{
//获取汇率
public
function
getRate
(
$k
=
"美元"
){
$Redis
=
\RedisDB
::
connection
();
return
$Redis
->
hget
(
"erp_rate"
,
$k
);
}
//搜索用户或者公司
public
function
getUser
(
$k
,
$types
=
1
)
{
...
...
app/Model/InquiryItemsReportModel.php
View file @
814339c1
...
...
@@ -110,12 +110,20 @@ class InquiryItemsReportModel extends Model
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"
];
$currency
=
@
$data
[
"currency"
]
?
$data
[
"currency"
]
:
1
;
#报价币种
$inquiryItem
=
(
new
InquiryItemsModel
())
->
select
(
"inquiry_id"
)
->
where
(
"id"
,
$inquiry_items_id
)
->
first
()
->
toArray
();
$inquiry
=
(
new
InquiryModel
())
->
select
(
"currency"
)
->
where
(
"id"
,
$inquiryItem
[
"inquiry_id"
])
->
first
()
->
toArray
();
$mainCurrency
=
$inquiry
[
"currency"
];
#询价币种
$rate
=
(
new
CommonModel
())
->
getRate
(
"美元"
);
#获取美元汇率
if
(
$mainCurrency
==
1
){
#询价币种人民币
$temp
[
"price_rmb"
]
=
$currency
!=
$mainCurrency
?
round
(
$data
[
"price"
]
*
$rate
,
6
)
:
$data
[
"price"
];
}
if
(
$mainCurrency
==
2
){
#询价币种美金
$temp
[
"price_origin"
]
=
$currency
!=
$mainCurrency
?
round
(
$data
[
"price"
]
/
$rate
,
6
)
:
$data
[
"price"
];
}
$up
=
$this
->
where
(
"inquiry_items_id"
,
$inquiry_items_id
)
->
update
(
$temp
);
(
new
QuoteModel
())
->
where
(
"id"
,
$data
[
"quote_id"
])
->
update
([
"status"
=>
$data
[
"status"
]]);
#更新报价选中
...
...
app/Model/InquiryModel.php
View file @
814339c1
...
...
@@ -28,6 +28,7 @@ class InquiryModel extends Model
$user_id
=
@
$input
[
"user_id"
];
$user_name
=
@
$input
[
"user_name"
];
$rqpConn
=
DB
::
connection
(
'rfq'
);
$list
=
$rqpConn
->
table
(
'inquiry as a'
)
...
...
@@ -101,7 +102,7 @@ class InquiryModel extends Model
$QuoteModel
=
new
QuoteModel
();
$InquiryItemsUrgeModel
=
new
InquiryItemsUrgeModel
;
$Redis
=
\RedisDB
::
connection
();
foreach
(
$list
[
'data'
]
as
$k
=>&
$v
){
//报价
$v
[
'status_val'
]
=
InquiryMap
::
$status
[
$v
[
"status"
]];
...
...
@@ -127,7 +128,7 @@ class InquiryModel extends Model
$v
[
'quote_price'
]
=
@
$quote
[
"quote_price"
]
>
0
?
$quote
[
"quote_price"
]
:
"------"
;
//存在报价
// 在Redis集合中检查是否有新的报价
$res
=
RedisDB
::
sIsMember
(
'frq_quote_urge'
,
$v
[
'id'
]);
$res
=
$Redis
->
SISMEMBER
(
'frq_quote_urge'
,
$v
[
'id'
]);
if
(
$res
)
{
$v
[
'inquiry_sn'
]
=
$v
[
'inquiry_sn'
]
.
"<span style='color:red;'> *</span>"
;
}
...
...
@@ -353,5 +354,59 @@ class InquiryModel extends Model
return
[
0
,
"操作成功"
];
}
// 报价统计
public
function
inquiryCount
(
$input
)
{
$data
=
[];
$curr_zero_time
=
strtotime
(
date
(
'Y-m-d'
,
time
()));
// 当日0点
switch
(
$input
[
'time_day'
])
{
case
1
:
for
(
$i
=
0
;
$i
<
24
;
$i
++
)
{
$start_time
=
$curr_zero_time
+
$i
*
3600
;
$end_time
=
$start_time
+
3600
;
$data
[
'today_quote'
][]
=
$this
->
inquiryCountRun
(
1
,
$input
,
$start_time
,
$end_time
);
$data
[
'today_no_quote'
][]
=
$this
->
inquiryCountRun
(
2
,
$input
,
$start_time
,
$end_time
);
$data
[
'x_axis_data'
][]
=
$i
.
'点'
;
}
break
;
case
7
:
for
(
$i
=
7
;
$i
>
0
;
$i
--
)
{
$start_time
=
$curr_zero_time
-
$i
*
86400
;
$end_time
=
$start_time
+
86399
;
$data
[
'today_quote'
][]
=
$this
->
inquiryCountRun
(
1
,
$input
,
$start_time
,
$end_time
);
$data
[
'today_no_quote'
][]
=
$this
->
inquiryCountRun
(
2
,
$input
,
$start_time
,
$end_time
);
$data
[
'x_axis_data'
][]
=
date
(
'Y-m-d'
,
$curr_zero_time
-
$i
*
86400
);
}
break
;
case
30
:
for
(
$i
=
30
;
$i
>
0
;
$i
--
)
{
$start_time
=
$curr_zero_time
-
$i
*
86400
;
$end_time
=
$start_time
+
86399
;
$data
[
'today_quote'
][]
=
$this
->
inquiryCountRun
(
1
,
$input
,
$start_time
,
$end_time
);
$data
[
'today_no_quote'
][]
=
$this
->
inquiryCountRun
(
2
,
$input
,
$start_time
,
$end_time
);
$data
[
'x_axis_data'
][]
=
date
(
'Y-m-d'
,
$curr_zero_time
-
$i
*
86400
);
}
break
;
}
return
[
0
,
''
,
$data
];
}
// 询价统计
public
function
inquiryCountRun
(
$types
=
1
,
$input
,
$start_time
,
$end_time
)
{
$con
=
DB
::
connection
(
'rfq'
);
if
(
$types
==
1
){
#时间段询价总计
$sql1
=
"select count(1) count from lie_inquiry WHERE create_time >=
$start_time
and create_time <=
$end_time
and create_uid="
.
$input
[
"user_id"
];
}
else
{
#时间段选中报价统计
$sql1
=
"select count(1) count from lie_inquiry a,lie_inquiry_items b WHERE a.id=b.inquiry_id
and a.create_time >=
$start_time
and a.create_time <=
$end_time
and b.status=3 and a.create_uid="
.
$input
[
"user_id"
];
}
$res
=
$con
->
select
(
$sql1
);
return
@
$res
[
0
][
"count"
];
}
}
\ No newline at end of file
app/Model/QuoteModel.php
View file @
814339c1
...
...
@@ -139,7 +139,7 @@ class QuoteModel extends Model
$sub_sale_ids
=
$perm
->
getSubSaleId
(
$input
[
'user_id'
]);
$list
=
$list
->
whereIn
(
'q.create_uid'
,
$sub_sale_ids
);
}
}
else
{
}
else
if
(
@
$input
[
'inquiry_items_id'
]
>
0
)
{
$list
=
$list
->
where
(
'q.status'
,
0
)
->
where
(
'q.inquiry_items_id'
,
$input
[
'inquiry_items_id'
]);
}
...
...
@@ -444,7 +444,7 @@ class QuoteModel extends Model
$this
->
where
(
$map
)
->
update
([
'status'
=>
1
]);
// 通知询价人,放入redis
RedisDB
::
s
et
(
'frq_quote_urge'
,
$input
[
'inquiry_items_id'
]);
RedisDB
::
s
add
(
'frq_quote_urge'
,
$input
[
'inquiry_items_id'
]);
$UserModel
=
new
UserModel
;
...
...
resources/views/web/InquiryDetail.blade.php
View file @
814339c1
...
...
@@ -72,9 +72,9 @@
<script
type=
"text/html"
id=
"main"
>
<
a
href
=
"/web/InquiryItemsDetail?inquiry_items_id=@{{ d.id }}"
class
=
"btn btn-xs btn-outline btn-primary"
><
strong
>
查看详情
<
/strong></
a
>
@{{
#
if
(
d
.
status_val
==
'待报价'
){
}}
<
a
class
=
"btn btn-xs btn-outline btn-primary"
><
strong
>
催报价
<
/strong></
a
>
<
a
class
=
"btn btn-xs btn-outline btn-primary"
onclick
=
"urgePrice(@{{ d.id }})"
><
strong
>
催报价
<
/strong></
a
>
@{{
#
}
}}
<
a
class
=
"btn btn-xs btn-outline btn-primary"
><
strong
>
关闭询价
<
/strong></
a
>
<
a
class
=
"btn btn-xs btn-outline btn-primary"
onclick
=
"inquiryClose(@{{ d.id }})"
><
strong
>
关闭询价
<
/strong></
a
>
</script>
<!--子操作栏-->
...
...
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