Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
students
shopping-mall
Commits
6ff1b7f2
Commit
6ff1b7f2
authored
Jan 27, 2021
by
kusang96
Browse files
Merge remote-tracking branch 'origin/jiwon' into kimpen
parents
07a6689c
beb80a05
Changes
5
Show whitespace changes
Inline
Side-by-side
client/src/Pages/Payment.js
View file @
6ff1b7f2
...
@@ -302,6 +302,7 @@ function Payment({ match, location }) {
...
@@ -302,6 +302,7 @@ function Payment({ match, location }) {
<
div
className
=
"
my-1 pt-2 border-top font-weight-bold
"
>
<
div
className
=
"
my-1 pt-2 border-top font-weight-bold
"
>
결제금액
<
span
className
=
"
float-right
"
>
{
finalPrice
+
2500
}
원
<
/span
>
결제금액
<
span
className
=
"
float-right
"
>
{
finalPrice
+
2500
}
원
<
/span
>
<
/div
>
<
/div
>
<
/div
>
<
div
>
<
div
>
<
h5
className
=
"
font-weight-bold py-3 border-top border-bottom text-center
"
style
=
{{
background
:
'
#F7F3F3
'
}}
>
결제수단
<
/h5
>
<
h5
className
=
"
font-weight-bold py-3 border-top border-bottom text-center
"
style
=
{{
background
:
'
#F7F3F3
'
}}
>
결제수단
<
/h5
>
<
div
className
=
"
text-center m-3
"
>
<
div
className
=
"
text-center m-3
"
>
...
@@ -313,7 +314,6 @@ function Payment({ match, location }) {
...
@@ -313,7 +314,6 @@ function Payment({ match, location }) {
<
div
className
=
"
text-center
"
>
<
div
className
=
"
text-center
"
>
<
Button
type
=
"
button
"
onClick
=
{
paymentCompleted
}
className
=
"
px-5
"
style
=
{{
background
:
"
#91877F
"
,
borderColor
:
'
#91877F
'
}}
block
>
결제완료
<
/Button
>
<
Button
type
=
"
button
"
onClick
=
{
paymentCompleted
}
className
=
"
px-5
"
style
=
{{
background
:
"
#91877F
"
,
borderColor
:
'
#91877F
'
}}
block
>
결제완료
<
/Button
>
<
/div
>
<
/div
>
<
/div
>
<
/Container
>
<
/Container
>
)
)
}
}
...
...
client/src/Pages/Product.js
View file @
6ff1b7f2
...
@@ -29,16 +29,15 @@ function Product({ match, location }) {
...
@@ -29,16 +29,15 @@ function Product({ match, location }) {
if
(
size
&&
color
)
{
if
(
size
&&
color
)
{
pushOptions
()
pushOptions
()
}
}
getRecommend
()
},
[
size
,
color
])
},
[
size
,
color
])
async
function
r
ecommend
(){
async
function
getR
ecommend
(){
try
{
try
{
console
.
log
(
"
pro=
"
,
product
.
id
)
const
response
=
await
axios
.
get
(
`/api/order/recommend?products=
${
product
.
id
}
`
)
const
response
=
await
axios
.
post
(
'
/api/order/recommend
'
,
{
productId
:
product
.
id
})
console
.
log
(
"
recommend res=
"
,
response
.
data
)
setProductList
(
response
.
data
)
setProductList
(
response
.
data
)
}
catch
(
error
)
{
}
catch
(
error
)
{
catchErrors
(
error
,
setError
)
catchErrors
(
error
,
setError
)
}
}
}
}
...
@@ -155,6 +154,7 @@ function Product({ match, location }) {
...
@@ -155,6 +154,7 @@ function Product({ match, location }) {
return
(
return
(
<
div
>
<
div
>
{
console
.
log
(
product
)}
<
style
type
=
"
text/css
"
>
<
style
type
=
"
text/css
"
>
{
`
{
`
.btn {
.btn {
...
...
server/controllers/cart.controller.js
View file @
6ff1b7f2
...
@@ -20,6 +20,7 @@ const changeCart = async (req, res) => {
...
@@ -20,6 +20,7 @@ const changeCart = async (req, res) => {
console
.
log
(
products
)
console
.
log
(
products
)
try
{
try
{
const
cart
=
await
Cart
.
findOne
({
userId
:
userId
})
const
cart
=
await
Cart
.
findOne
({
userId
:
userId
})
console
.
log
(
cart
)
await
Cart
.
updateOne
(
await
Cart
.
updateOne
(
{
_id
:
cart
.
_id
},
{
_id
:
cart
.
_id
},
{
$set
:
{
products
:
products
}
}
{
$set
:
{
products
:
products
}
}
...
@@ -38,7 +39,7 @@ const showCart = async (req, res) => {
...
@@ -38,7 +39,7 @@ const showCart = async (req, res) => {
model
:
'
Product
'
model
:
'
Product
'
})
})
res
.
status
(
200
).
json
(
cart
.
products
)
res
.
status
(
200
).
json
(
cart
.
products
)
console
.
log
(
"
cart-products :
"
,
cart
.
products
);
console
.
log
(
"
cart-products :
"
,
cart
);
}
catch
(
error
)
{
}
catch
(
error
)
{
console
.
log
(
"
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
"
)
console
.
log
(
"
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
"
)
console
.
log
(
error
)
console
.
log
(
error
)
...
...
server/controllers/order.controller.js
View file @
6ff1b7f2
import
mongoose
from
'
mongoose
'
;
import
mongoose
from
'
mongoose
'
;
import
Order
from
"
../schemas/Order.js
"
;
import
Order
from
"
../schemas/Order.js
"
;
import
User
from
"
../schemas/User.js
"
;
import
User
from
"
../schemas/User.js
"
;
import
Product
from
"
../schemas/Product.js
"
;
const
addorder
=
async
(
req
,
res
)
=>
{
const
addorder
=
async
(
req
,
res
)
=>
{
const
{
userId
,
products
,
receiverInfo
,
total
}
=
req
.
body
const
{
userId
,
products
,
receiverInfo
,
total
}
=
req
.
body
...
@@ -51,26 +52,41 @@ const orderById = async (req, res, next, id) => {
...
@@ -51,26 +52,41 @@ const orderById = async (req, res, next, id) => {
}
}
const
recommendPro
=
async
(
req
,
res
)
=>
{
const
recommendPro
=
async
(
req
,
res
)
=>
{
const
{
productId
}
=
req
.
body
const
productId
=
req
.
query
.
products
console
.
log
(
productId
)
try
{
try
{
const
recommend
=
await
Order
.
aggregate
([
const
recommend
=
await
Order
.
aggregate
([
{
{
$match
:
{
$match
:
{
'
products.productId
'
:
{
$ne
:
[
"
$productId[0]
"
,
mongoose
.
Types
.
ObjectId
(
productId
)
]
}
'
products.productId
'
:
mongoose
.
Types
.
ObjectId
(
productId
)
}
}
},
},
{
"
$unwind
"
:
"
$products
"
},
{
"
$unwind
"
:
"
$products
"
},
{
{
$group
:
{
$group
:
{
productI
d
:
"
$products.productId
"
,
_i
d
:
"
$products.productId
"
,
total
:
{
$sum
:
1
}
count
:
{
$sum
:
1
}
}
}
}
}
])
])
const
sorting
=
recommend
.
filter
({})
console
.
log
(
'
recommend=
'
,
recommend
)
console
.
log
(
'
recommend=
'
,
recommend
)
res
.
send
(
'
dddkfdskfsa fsk
'
)
const
filteredRecommend
=
recommend
.
filter
((
el
)
=>
String
(
el
.
_id
)
!==
String
(
productId
))
console
.
log
(
'
filtering=
'
,
filteredRecommend
)
filteredRecommend
.
sort
(
function
(
a
,
b
)
{
if
(
a
.
count
>
b
.
count
)
{
return
-
1
;
}
if
(
a
.
count
<
b
.
count
)
{
return
1
;
}
// a must be equal to b
return
0
;
});
const
array
=
filteredRecommend
.
map
(
async
(
el
)
=>
{
const
aa
=
await
Product
.
findById
(
el
.
_id
)
return
aa
})
const
bb
=
await
Promise
.
all
(
array
)
res
.
json
(
bb
)
}
catch
(
error
)
{
}
catch
(
error
)
{
console
.
log
(
'
error in order
'
,
error
)
console
.
log
(
'
error in order
'
,
error
)
}
}
...
...
server/routes/order.routes.js
View file @
6ff1b7f2
...
@@ -6,6 +6,9 @@ const router = express.Router()
...
@@ -6,6 +6,9 @@ const router = express.Router()
router
.
route
(
'
/addorder
'
)
router
.
route
(
'
/addorder
'
)
.
post
(
orderCtrl
.
addorder
)
.
post
(
orderCtrl
.
addorder
)
router
.
route
(
'
/recommend
'
)
.
get
(
orderCtrl
.
recommendPro
)
router
.
route
(
'
/showorder/:userId
'
)
router
.
route
(
'
/showorder/:userId
'
)
.
get
(
orderCtrl
.
showorder
)
.
get
(
orderCtrl
.
showorder
)
...
...
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