Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
E
Ecsite
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
shoei.kanno
Ecsite
Commits
d81f80a4
Commit
d81f80a4
authored
Oct 23, 2020
by
keita.onoguchi
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch '購入履歴調整' into 'master'
購入履歴検索機能追加 See merge request
!85
parents
44523d91
92a98090
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
118 additions
and
15 deletions
+118
-15
SalesLog.java
src/main/java/com/example/domain/SalesLog.java
+1
-0
SalesLogRepository.java
src/main/java/com/example/repository/SalesLogRepository.java
+5
-2
SalesLogService.java
src/main/java/com/example/service/SalesLogService.java
+5
-0
DateSearchForm.java
src/main/java/com/example/web/DateSearchForm.java
+12
-0
EcsiteController.java
src/main/java/com/example/web/EcsiteController.java
+47
-1
PriceSearchForm.java
src/main/java/com/example/web/PriceSearchForm.java
+11
-0
style.css
src/main/resources/static/css/style.css
+8
-0
log.js
src/main/resources/static/js/log.js
+6
-0
log.html
src/main/resources/templates/log.html
+23
-12
No files found.
src/main/java/com/example/domain/SalesLog.java
View file @
d81f80a4
...
@@ -22,6 +22,7 @@ public class SalesLog {
...
@@ -22,6 +22,7 @@ public class SalesLog {
private
Integer
id
;
private
Integer
id
;
private
Integer
userId
;
private
Integer
userId
;
private
Integer
shoesId
;
private
Integer
shoesId
;
private
Integer
quantity
;
private
Integer
price
;
private
Integer
price
;
private
Date
created
;
private
Date
created
;
...
...
src/main/java/com/example/repository/SalesLogRepository.java
View file @
d81f80a4
...
@@ -11,10 +11,13 @@ import com.example.domain.SalesLog;
...
@@ -11,10 +11,13 @@ import com.example.domain.SalesLog;
@Repository
@Repository
public
interface
SalesLogRepository
extends
JpaRepository
<
SalesLog
,
Integer
>{
public
interface
SalesLogRepository
extends
JpaRepository
<
SalesLog
,
Integer
>{
@Query
(
value
=
"SELECT id,user_id, shoes_id, SUM(price) AS price, created FROM sales_logs AS sl WHERE sl.user_id = ?1 GROUP BY sl.created"
,
@Query
(
value
=
"SELECT id,user_id, shoes_id,
quantity,
SUM(price) AS price, created FROM sales_logs AS sl WHERE sl.user_id = ?1 GROUP BY sl.created"
,
nativeQuery
=
true
)
nativeQuery
=
true
)
public
List
<
SalesLog
>
history
(
Integer
id
);
public
List
<
SalesLog
>
history
(
Integer
id
);
@Query
(
value
=
"SELECT id, user_id, shoes_id, price, created FROM sales_logs AS sl WHERE sl.created = ?1 && sl.user_id = ?2"
,
@Query
(
value
=
"SELECT id, user_id, shoes_id,
quantity,
price, created FROM sales_logs AS sl WHERE sl.created = ?1 && sl.user_id = ?2"
,
nativeQuery
=
true
)
nativeQuery
=
true
)
public
List
<
SalesLog
>
historyDetails
(
Date
created
,
Integer
id
);
public
List
<
SalesLog
>
historyDetails
(
Date
created
,
Integer
id
);
@Query
(
value
=
"SELECT id, user_id, shoes_id, quantity, price, created FROM sales_logs AS sl WHERE sl.price >= ?1 && sl.price <= ?2 && sl.user_id = ?3"
,
nativeQuery
=
true
)
public
List
<
SalesLog
>
searchPrice
(
Integer
lowPrice
,
Integer
highPrice
,
Integer
id
);
}
}
src/main/java/com/example/service/SalesLogService.java
View file @
d81f80a4
...
@@ -46,6 +46,7 @@ public class SalesLogService {
...
@@ -46,6 +46,7 @@ public class SalesLogService {
SalesLog
salesLog
=
new
SalesLog
();
SalesLog
salesLog
=
new
SalesLog
();
salesLog
.
setUserId
(
userId
);
salesLog
.
setUserId
(
userId
);
salesLog
.
setShoesId
((
cart
.
get
(
i
)).
getShoesId
());
salesLog
.
setShoesId
((
cart
.
get
(
i
)).
getShoesId
());
salesLog
.
setQuantity
((
cart
.
get
(
i
)).
getQuantity
());
salesLog
.
setPrice
((
cart
.
get
(
i
)).
getPrice
());
salesLog
.
setPrice
((
cart
.
get
(
i
)).
getPrice
());
salesLog
.
setCreated
(
today
);
salesLog
.
setCreated
(
today
);
salesLogRepository
.
save
(
salesLog
);
salesLogRepository
.
save
(
salesLog
);
...
@@ -59,4 +60,8 @@ public class SalesLogService {
...
@@ -59,4 +60,8 @@ public class SalesLogService {
public
List
<
SalesLog
>
historyDetails
(
Date
created
,
Integer
id
)
{
public
List
<
SalesLog
>
historyDetails
(
Date
created
,
Integer
id
)
{
return
salesLogRepository
.
historyDetails
(
created
,
id
);
return
salesLogRepository
.
historyDetails
(
created
,
id
);
}
}
public
List
<
SalesLog
>
searchPrice
(
Integer
lowPrice
,
Integer
highPrice
,
Integer
id
){
return
salesLogRepository
.
searchPrice
(
lowPrice
,
highPrice
,
id
);
}
}
}
src/main/java/com/example/web/DateSearchForm.java
0 → 100644
View file @
d81f80a4
package
com
.
example
.
web
;
import
java.sql.Date
;
import
lombok.Getter
;
import
lombok.Setter
;
@Setter
@Getter
public
class
DateSearchForm
{
private
Date
date
;
}
src/main/java/com/example/web/EcsiteController.java
View file @
d81f80a4
...
@@ -18,6 +18,7 @@ import org.springframework.web.bind.annotation.GetMapping;
...
@@ -18,6 +18,7 @@ import org.springframework.web.bind.annotation.GetMapping;
import
org.springframework.web.bind.annotation.ModelAttribute
;
import
org.springframework.web.bind.annotation.ModelAttribute
;
import
org.springframework.web.bind.annotation.PathVariable
;
import
org.springframework.web.bind.annotation.PathVariable
;
import
org.springframework.web.bind.annotation.PostMapping
;
import
org.springframework.web.bind.annotation.PostMapping
;
import
org.springframework.web.bind.annotation.PutMapping
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
com.example.domain.Items
;
import
com.example.domain.Items
;
...
@@ -47,6 +48,16 @@ public class EcsiteController {
...
@@ -47,6 +48,16 @@ public class EcsiteController {
return
new
WalletsForm
();
return
new
WalletsForm
();
}
}
@ModelAttribute
DateSearchForm
setForm
()
{
return
new
DateSearchForm
();
}
@ModelAttribute
PriceSearchForm
setPriceForm
()
{
return
new
PriceSearchForm
();
}
int
totalPrice
=
0
;
int
totalPrice
=
0
;
//写真の表示用メソッド
//写真の表示用メソッド
public
String
photoView
(
String
Photo
)
{
public
String
photoView
(
String
Photo
)
{
...
@@ -143,7 +154,11 @@ public class EcsiteController {
...
@@ -143,7 +154,11 @@ public class EcsiteController {
model
.
addAttribute
(
"cartValue"
,
session
.
getAttribute
(
"cartValue"
));
model
.
addAttribute
(
"cartValue"
,
session
.
getAttribute
(
"cartValue"
));
}
}
List
<
SalesLog
>
list
=
salesLogService
.
history
(
id
);
List
<
SalesLog
>
list
=
salesLogService
.
history
(
id
);
model
.
addAttribute
(
"log"
,
list
);
ArrayList
<
SalesLog
>
newList
=
new
ArrayList
<
SalesLog
>();
for
(
int
i
=
(
list
.
size
()
-
1
);
i
>=
0
;
i
--){
newList
.
add
(
list
.
get
(
i
));
}
model
.
addAttribute
(
"log"
,
newList
);
return
"log"
;
return
"log"
;
}
}
...
@@ -167,6 +182,37 @@ public class EcsiteController {
...
@@ -167,6 +182,37 @@ public class EcsiteController {
return
"logDetails"
;
return
"logDetails"
;
}
}
//購入履歴検索
@PostMapping
(
"log/search/{id}"
)
public
String
searchHistory
(
@PathVariable
Integer
id
,
DateSearchForm
dateSerchform
,
PriceSearchForm
priceSearchform
,
Model
model
,
@AuthenticationPrincipal
LoginUser
userDetails
){
User
user
=
userDetails
.
getUser
();
model
.
addAttribute
(
"user"
,
user
);
if
(
session
.
getAttribute
(
"cartValue"
)
==
null
)
{
model
.
addAttribute
(
"cartValue"
,
0
);
}
else
{
model
.
addAttribute
(
"cartValue"
,
session
.
getAttribute
(
"cartValue"
));
}
//金額の指定がなく日付での検索のみ
if
(
priceSearchform
.
getHighPrice
()
==
null
&&
priceSearchform
.
getLowPrice
()
==
null
&&
dateSerchform
.
getDate
()
!=
null
){
List
<
SalesLog
>
list
=
salesLogService
.
historyDetails
(
dateSerchform
.
getDate
(),
user
.
getId
());
model
.
addAttribute
(
"log"
,
list
);
return
"log"
;
}
//金額のみの検索
if
(
dateSerchform
.
getDate
()
==
null
&&
priceSearchform
.
getLowPrice
()
!=
null
&&
priceSearchform
.
getHighPrice
()
!=
null
){
if
(
priceSearchform
.
getLowPrice
()
==
null
){
priceSearchform
.
setLowPrice
(
0
);
}
if
(
priceSearchform
.
getHighPrice
()
==
null
){
priceSearchform
.
setHighPrice
(
1000000000
);
}
List
<
SalesLog
>
list
=
salesLogService
.
searchPrice
(
priceSearchform
.
getLowPrice
(),
priceSearchform
.
getHighPrice
(),
user
.
getId
());
model
.
addAttribute
(
"log"
,
list
);
return
"log"
;
}
return
"log"
;
}
//カート画面
//カート画面
@GetMapping
(
"cart"
)
@GetMapping
(
"cart"
)
public
String
Cart
(
Model
model
,
@AuthenticationPrincipal
LoginUser
userDetails
,
LinkedHashMap
<
String
,
Items
>
items
,
ArrayList
<
Items
>
cart
){
public
String
Cart
(
Model
model
,
@AuthenticationPrincipal
LoginUser
userDetails
,
LinkedHashMap
<
String
,
Items
>
items
,
ArrayList
<
Items
>
cart
){
...
...
src/main/java/com/example/web/PriceSearchForm.java
0 → 100644
View file @
d81f80a4
package
com
.
example
.
web
;
import
lombok.Getter
;
import
lombok.Setter
;
@Setter
@Getter
public
class
PriceSearchForm
{
private
Integer
lowPrice
;
private
Integer
highPrice
;
}
src/main/resources/static/css/style.css
View file @
d81f80a4
...
@@ -1816,6 +1816,14 @@ label {
...
@@ -1816,6 +1816,14 @@ label {
color
:
#000
;
color
:
#000
;
}
}
#sortButton
{
margin
:
100px
;
}
#sort
{
margin-left
:
200px
;
}
/* 管理画面(宮嶋) */
/* 管理画面(宮嶋) */
#management_wrapper
{
#management_wrapper
{
height
:
100%
;
height
:
100%
;
...
...
src/main/resources/static/js/log.js
0 → 100644
View file @
d81f80a4
$
(
function
(){
$
(
'#sort'
).
click
(
function
(){
window
.
location
.
href
=
(
$
(
'#purchase'
).
attr
(
'href'
));
});
});
\ No newline at end of file
src/main/resources/templates/log.html
View file @
d81f80a4
...
@@ -66,7 +66,7 @@
...
@@ -66,7 +66,7 @@
<ul
class=
"nav navbar-nav"
>
<ul
class=
"nav navbar-nav"
>
<li><a
th:href=
"@{/limited/top}"
>
Home
</a></li>
<li><a
th:href=
"@{/limited/top}"
>
Home
</a></li>
<li><a
th:href=
"@{/limited/list}"
>
Shop
</a></li>
<li><a
th:href=
"@{/limited/list}"
>
Shop
</a></li>
<li
class=
"active"
><a
th:href=
"@{/limited/log/{id}(id=${user.id})}"
>
My Purchase Log
</a></li>
<li
class=
"active"
><a
id=
"purchase"
th:href=
"@{/limited/log/{id}(id=${user.id})}"
>
My Purchase Log
</a></li>
<li><a
th:href=
"@{/limited/wallets/{id}(id=${user.id})}"
>
Wallets
</a></li>
<li><a
th:href=
"@{/limited/wallets/{id}(id=${user.id})}"
>
Wallets
</a></li>
</ul>
</ul>
<ul
class=
"nav navbar-nav navbar-right cart-menu"
>
<ul
class=
"nav navbar-nav navbar-right cart-menu"
>
...
@@ -82,22 +82,33 @@
...
@@ -82,22 +82,33 @@
<!-- ログインフォーム -->
<!-- ログインフォーム -->
<div
class=
"container"
>
<div
class=
"container"
>
<p
id=
"log-p-text"
><span
id=
"log-text"
>
Purchase History
</span></p>
<p
id=
"log-p-text"
><span
id=
"log-text"
>
Purchase History
</span></p>
<
!--<form id="login-form" method="post" th:action="@{/login
}">
<
form
id=
"dateSearch-form"
method=
"post"
th:action=
"@{/limited/log/search/{id}(id=${user.id})}"
th:object=
"${DateSearchForm
}"
>
<div id="email-form">
<
!-- <
div id="email-form">
<label for="login-email">Email</label>
<label for="login-email">Email</label>
<input type="email" class="login" name="email" id="login-email" placeholder="Email" required="required"/>
<input type="email" class="login" name="email" id="login-email" placeholder="Email" required="required"/>
</div>-->
<div
id=
"date-form"
>
<label
for=
"date-form"
>
Date Search
</label>
<input
type=
"date"
class=
"date"
name=
"date"
id=
"date"
/>
</div>
</div>
<div id="password-form">
<div
id=
"submit-form"
>
<label for="login-password">Password</label>
<button
type=
"submit"
class=
"search-submit details-btn"
id=
"dateserach-submit"
>
Go
</button>
<input type="password" class="login" name="password" id="login-password" placeholder="Password" required="required"/>
</div>
</form>
<form
id=
"PriceSearch-form"
method=
"post"
th:action=
"@{/limited/log/search/{id}(id=${user.id})}"
th:object=
"${PriceSearchForm}"
>
<!-- <div id="email-form">
<label for="login-email">Email</label>
<input type="email" class="login" name="email" id="login-email" placeholder="Email" required="required"/>
</div>-->
<div
id=
"Price-form"
>
<label
for=
"Price-form"
>
Price Search
</label>
<input
type=
"number"
class=
"lowPrice"
name=
"lowPrice"
id=
"lowPrice"
required=
"required"
/><span>
~
<input
type=
"number"
class=
"highPrice"
name=
"highPrice"
id=
"highPrice"
required=
"required"
/></span>
</div>
</div>
<div
id=
"submit-form"
>
<div
id=
"submit-form"
>
<input type="submit" class="login" id="btn" value="Login"/>
<button
type=
"submit"
class=
"search-submit details-btn"
id=
"serach-submit"
>
Go
</button>
会員登録ボタン
<button class="js-modal-open" id="sign-up">Sign Up</button>
</div>
</div>
</form>
-->
</form>
<!-- 購入履歴一覧 -->
<!-- 購入履歴一覧 -->
<div
id=
"log"
>
<div
id=
"log"
>
<table
id=
"log-table"
>
<table
id=
"log-table"
>
...
@@ -141,7 +152,7 @@
...
@@ -141,7 +152,7 @@
<script src="js/owl.carousel.min.js" th:src="@{/js/owl.carousel.min.js}"></script>
<script src="js/owl.carousel.min.js" th:src="@{/js/owl.carousel.min.js}"></script>
<script src="js/wow.min.js" th:src="@{/js/wow.min.js}"></script>
<script src="js/wow.min.js" th:src="@{/js/wow.min.js}"></script>
<script src="js/custom.js" th:src="@{/js/custom.js}"></script>-->
<script src="js/custom.js" th:src="@{/js/custom.js}"></script>-->
<script
src=
"js/
cart.js"
th:src=
"@{/js/cart
.js}"
></script>
<script
src=
"js/
log.js"
th:src=
"@{/js/log
.js}"
></script>
<!-- BootStrap -->
<!-- BootStrap -->
<!-- <script src="https://code.jquery.com/jquery-3.3.1.slim.min.js" integrity="sha384-q8i/X+965DzO0rT7abK41JStQIAqVgRVzpbzo5smXKp4YfRvH+8abtTE1Pi6jizo" crossorigin="anonymous"></script>
<!-- <script src="https://code.jquery.com/jquery-3.3.1.slim.min.js" integrity="sha384-q8i/X+965DzO0rT7abK41JStQIAqVgRVzpbzo5smXKp4YfRvH+8abtTE1Pi6jizo" crossorigin="anonymous"></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