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
7b63e761
authored
May 11, 2021
by
朱继来
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
调整报价列表
parent
4bf749d1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
75 additions
and
39 deletions
app/Model/QuoteModel.php
app/Model/QuoteModel.php
View file @
7b63e761
...
...
@@ -137,7 +137,7 @@ class QuoteModel extends Model
$map
[
'start_time'
]
=
!
empty
(
$input
[
'start_time'
])
?
strtotime
(
$input
[
'start_time'
])
:
''
;
$map
[
'end_time'
]
=
!
empty
(
$input
[
'end_time'
])
?
strtotime
(
$input
[
'end_time'
])
+
86399
:
''
;
$map
=
array_filter
(
$map
)
?
$map
:
[];
//
$map = array_filter($map) ? $map : [];
$field
=
[
'q.id'
,
'q.inquiry_id'
,
...
...
@@ -165,42 +165,7 @@ class QuoteModel extends Model
'it.inquiry_number'
];
if
(
$map
)
{
$list
=
$this
->
from
(
'quote as q'
)
->
join
(
'inquiry_items as it'
,
'q.inquiry_items_id'
,
'='
,
'it.id'
)
->
where
(
function
(
$query
)
use
(
$map
)
{
if
(
$map
[
'inquiry_sn'
])
{
$query
->
where
(
'q.inquiry_sn'
,
'='
,
$map
[
'inquiry_sn'
]);
}
if
(
$map
[
'goods_name'
])
{
$query
->
where
(
'it.goods_name'
,
'like'
,
$map
[
'goods_name'
]
.
'%'
);
}
if
(
$map
[
'brand_name'
])
{
$query
->
where
(
'it.brand_name'
,
'like'
,
$map
[
'brand_name'
]
.
'%'
);
}
if
(
$map
[
'quote_sn'
])
{
$query
->
where
(
'q.quote_sn'
,
'='
,
$map
[
'quote_sn'
]);
}
if
(
$map
[
'status'
])
{
$query
->
where
(
'q.status'
,
'='
,
$map
[
'status'
]);
}
// 创建时间
if
(
!
empty
(
$map
[
'start_time'
])
&&
!
empty
(
$map
[
'end_time'
]))
{
$query
->
whereBetween
(
'q.create_time'
,
[
$map
[
'start_time'
],
$map
[
'end_time'
]]);
}
else
{
if
(
!
empty
(
$map
[
'start_time'
]))
{
$query
->
where
(
'q.create_time'
,
'>='
,
$map
[
'start_time'
]);
}
else
{
if
(
!
empty
(
$map
[
'end_time'
]))
{
$query
->
where
(
'q.create_time'
,
'<='
,
$map
[
'end_time'
]);
}
}
}
});
$list
=
$this
->
commonQuery
(
$map
,
$input
);
}
else
{
$list
=
$this
->
from
(
'quote as q'
)
->
join
(
'inquiry_items as it'
,
'q.inquiry_items_id'
,
'='
,
'it.id'
);
...
...
@@ -249,11 +214,40 @@ class QuoteModel extends Model
$list
[
'data'
]
=
$this
->
handleData
(
$list
[
'data'
],
$type
);
return
[
0
,
'获取成功'
,
$list
[
'data'
],
$list
[
'total'
]];
if
(
$type
==
1
)
{
// 我的报价
if
(
$map
[
'status'
])
{
switch
(
$map
[
'status'
])
{
case
1
:
$list
[
'count'
][
'quoted_status'
]
=
$this
->
commonQuery
(
$map
,
$input
,
2
);
$list
[
'count'
][
'selected_status'
]
=
0
;
$list
[
'count'
][
'confirmed_status'
]
=
0
;
break
;
case
2
:
$list
[
'count'
][
'quoted_status'
]
=
0
;
$list
[
'count'
][
'selected_status'
]
=
$this
->
commonQuery
(
$map
,
$input
,
2
);
$list
[
'count'
][
'confirmed_status'
]
=
0
;
break
;
case
3
:
$list
[
'count'
][
'quoted_status'
]
=
0
;
$list
[
'count'
][
'selected_status'
]
=
0
;
$list
[
'count'
][
'confirmed_status'
]
=
$this
->
commonQuery
(
$map
,
$input
,
2
);
break
;
}
}
else
{
$map
[
'status'
]
=
1
;
$list
[
'count'
][
'quoted_status'
]
=
$this
->
commonQuery
(
$map
,
$input
,
2
);
$map
[
'status'
]
=
2
;
$list
[
'count'
][
'selected_status'
]
=
$this
->
commonQuery
(
$map
,
$input
,
2
);
$map
[
'status'
]
=
3
;
$list
[
'count'
][
'confirmed_status'
]
=
$this
->
commonQuery
(
$map
,
$input
,
2
);
}
}
// return [0, '获取成功', $list['data'], $list['total']];
return
[
0
,
$list
[
'count'
],
$list
[
'data'
],
$list
[
'total'
]];
}
}
// 获取历史报价
public
function
historyList
(
$input
)
{
...
...
@@ -333,6 +327,48 @@ class QuoteModel extends Model
return
$data
;
}
// 通用查询
public
function
commonQuery
(
$map
,
$input
,
$type
=
1
)
{
$list
=
$this
->
from
(
'quote as q'
)
->
join
(
'inquiry_items as it'
,
'q.inquiry_items_id'
,
'='
,
'it.id'
)
->
where
(
function
(
$query
)
use
(
$map
)
{
if
(
$map
[
'inquiry_sn'
])
{
$query
->
where
(
'q.inquiry_sn'
,
'='
,
$map
[
'inquiry_sn'
]);
}
if
(
$map
[
'goods_name'
])
{
$query
->
where
(
'it.goods_name'
,
'like'
,
$map
[
'goods_name'
]
.
'%'
);
}
if
(
$map
[
'brand_name'
])
{
$query
->
where
(
'it.brand_name'
,
'like'
,
$map
[
'brand_name'
]
.
'%'
);
}
if
(
$map
[
'quote_sn'
])
{
$query
->
where
(
'q.quote_sn'
,
'='
,
$map
[
'quote_sn'
]);
}
if
(
$map
[
'status'
])
{
$query
->
where
(
'q.status'
,
'='
,
$map
[
'status'
]);
}
// 创建时间
if
(
!
empty
(
$map
[
'start_time'
])
&&
!
empty
(
$map
[
'end_time'
]))
{
$query
->
whereBetween
(
'q.create_time'
,
[
$map
[
'start_time'
],
$map
[
'end_time'
]]);
}
else
if
(
!
empty
(
$map
[
'start_time'
]))
{
$query
->
where
(
'q.create_time'
,
'>='
,
$map
[
'start_time'
]);
}
else
if
(
!
empty
(
$map
[
'end_time'
]))
{
$query
->
where
(
'q.create_time'
,
'<='
,
$map
[
'end_time'
]);
}
});
if
(
$type
==
1
)
return
$list
;
return
$list
->
where
(
'q.create_uid'
,
$input
[
'user_id'
])
->
whereNotIn
(
'q.status'
,
[
0
,
-
1
])
->
count
();
}
// 撤销报价
public
function
cancel
(
$input
)
{
...
...
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