fix(owner-vue): order status 버그픽스

- order status 변경
This commit is contained in:
hoon7566
2022-03-17 15:17:44 +09:00
parent ce95517bad
commit 0123766d68
13 changed files with 62 additions and 258 deletions

View File

@@ -23,6 +23,7 @@ public class NotificationConsumer {
private final ObjectMapper objectMapper;
private final NotificationService notificationService;
@Transactional
@KafkaListener(topics = "orderPlaced")
public void orderPlaced(String kafkaMessage) throws JsonProcessingException {
log.debug("## NotificationConsumer.orderPlaced");

View File

@@ -12,7 +12,9 @@ public enum OrderStatus {
ACCEPTED("주문수락"),
REJECTED("주문거절"),
WAITING("픽업대기"),
FINISHED("픽업완료");
FINISHED("픽업완료"),
FAILED("실패");
private String message;

View File

@@ -83,13 +83,12 @@ public class Order extends BaseEntity {
return this;
}
public Order setOrderStatus(OrderStatus orderStatus){
public void setOrderStatus(OrderStatus orderStatus){
this.orderStatus = orderStatus;
return this;
}
public void order() {
this.orderStatus = OrderStatus.ORDER;
public void placed() {
this.orderStatus = OrderStatus.PLACED;
}
/**
@@ -104,6 +103,6 @@ public class Order extends BaseEntity {
}
public void fail() {
this.orderStatus = OrderStatus.FAIL;
this.orderStatus = OrderStatus.FAILED;
}
}

View File

@@ -20,16 +20,16 @@ public class OrderListener {
@PostUpdate
public void postUpdate(Order order){
OrderStatus orderStatus = order.getOrderStatus();
if (orderStatus == OrderStatus.ORDER) {
log.info("[OrderListener] {}", OrderStatus.ORDER.name());
if (orderStatus == OrderStatus.PLACED) {
log.info("[OrderListener] {}", OrderStatus.PLACED.name());
try{
orderSender.orderPlaced(OrderSender.KafkaSendOrderDto.createPrimitiveField(order));
}catch (Exception ex){
throw new OrderException(ex.getMessage());
}
} else if (orderStatus == OrderStatus.PLACED) {
log.info("[OrderListener] {}", OrderStatus.PLACED.name());
} else if (orderStatus == OrderStatus.ACCEPTED) {
log.info("[OrderListener] {}", OrderStatus.ACCEPTED.name());
}
}
}

View File

@@ -1,11 +1,18 @@
package com.justpickup.orderservice.domain.order.entity;
import lombok.Getter;
// 주문 대기 -> 주문 신청 --> 주문수락 -> 픽업대기 -> 픽업완료
// \
// ㄴ> 주문거절
@Getter
public enum OrderStatus {
PENDING("주문대기"),
ORDER("주문"),
PLACED("주문수락"),
REJECT("주문거절"),
FAIL("주문실패");
PENDING("주문대기(장바구니)"),
PLACED("주문신청"),
ACCEPTED("주문수락"),
REJECTED("주문거절"),
WAITING("픽업대기"),
FINISHED("픽업완료"),
FAILED("실패");
private String message;

View File

@@ -50,7 +50,7 @@ public class OrderRepositoryCustom {
order.orderTime.between(start, end),
order.storeId.eq(storeId),
order.orderStatus.ne(OrderStatus.PENDING),
order.orderStatus.ne(OrderStatus.FAIL)
order.orderStatus.ne(OrderStatus.FAILED)
)
.orderBy(order.id.desc())
.limit(pageSize + 1)

View File

@@ -9,15 +9,9 @@ import com.justpickup.orderservice.domain.order.repository.OrderRepositoryCustom
import com.justpickup.orderservice.domain.orderItem.dto.OrderItemDto;
import com.justpickup.orderservice.domain.orderItem.entity.OrderItem;
import com.justpickup.orderservice.domain.orderItemOption.entity.OrderItemOption;
import com.justpickup.orderservice.global.client.store.GetItemsResponse;
import com.justpickup.orderservice.global.client.store.GetStoreResponse;
import com.justpickup.orderservice.global.client.store.StoreByUserIdResponse;
import com.justpickup.orderservice.global.client.store.StoreClient;
import com.justpickup.orderservice.global.client.store.*;
import com.justpickup.orderservice.global.client.user.GetCustomerResponse;
import com.justpickup.orderservice.global.client.user.UserClient;
import com.justpickup.orderservice.global.client.store.GetItemResponse;
import com.justpickup.orderservice.global.client.store.GetStoreReseponse;
import com.justpickup.orderservice.global.client.store.StoreClient;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.data.domain.Page;
@@ -25,12 +19,10 @@ import org.springframework.data.domain.Pageable;
import org.springframework.data.domain.SliceImpl;
import org.springframework.data.support.PageableExecutionUtils;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;
import java.util.*;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
import java.util.stream.Collectors;
import static java.util.stream.Collectors.toList;
import static java.util.stream.Collectors.toMap;
@@ -258,7 +250,7 @@ public class OrderServiceImpl implements OrderService {
public void saveOrder(Long userId) {
orderRepository.findByUserIdAndOrderStatus(userId, OrderStatus.PENDING)
.orElseThrow(() -> new OrderException("장바구니 정보를 찾을 수 없습니다."))
.order();
.placed();
}
@Override

View File

@@ -26,7 +26,7 @@ public class OrderController {
public ResponseEntity<Result> patchOrder(@PathVariable("orderId") Long orderId,
@RequestBody PatchOrderRequest patchOrderRequest) {
OrderStatus orderStatus = patchOrderRequest.getOrderStatus();
if (orderStatus != OrderStatus.PLACED && orderStatus != OrderStatus.REJECT) {
if (orderStatus != OrderStatus.PLACED && orderStatus != OrderStatus.REJECTED) {
throw new OrderException("주문 수락, 거절 외에는 변경 불가능합니다.");
}

View File

@@ -77,8 +77,8 @@ public class SqlCommandLineRunner implements CommandLineRunner {
}
Order order = Order.of(userId, userCouponId, storeId, orderItems);
if (i % 2 == 0) order.setOrderStatus(OrderStatus.ORDER);
else order.setOrderStatus(OrderStatus.REJECT);
if (i % 2 == 0) order.setOrderStatus(OrderStatus.FINISHED);
else order.setOrderStatus(OrderStatus.REJECTED);
orders.add(order);
}

View File

@@ -128,7 +128,7 @@ class OrderOwnerApiControllerTest {
}
_Order order = _Order.builder()
.id(i).userId(i + 10).orderStatus(OrderStatus.ORDER)
.id(i).userId(i + 10).orderStatus(OrderStatus.ACCEPTED)
.orderTime(LocalDateTime.now()).orderItems(orderItems).storeName("가게명" + i)
.build();
orders.add(order);
@@ -208,7 +208,7 @@ class OrderOwnerApiControllerTest {
.id(2L)
.userId(1L)
.orderItems(List.of(orderItemDto_102, orderItemDto_103))
.orderStatus(OrderStatus.FAIL)
.orderStatus(OrderStatus.FAILED)
.orderTime(LocalDateTime.of(2022, 2, 3, 15, 0, 0))
.build();
orderDto_2.changeUserName("닉네임");

View File

@@ -29,29 +29,29 @@ const routes = [
component: DashboardLayout,
beforeEnter: authCheck,
children: [
{
path: "/dashboard",
name: 'dashboard',
component: () => import('./../views/Dashboard')
},
{
path: '/category',
name: 'category',
beforeEnter: authCheck,
component: () => import('./../views/Category')
},
{
path: '/menu',
name: 'menu',
beforeEnter: authCheck,
component: () => import('./../views/Menu')
},
{
path: '/prev-order',
name: 'prev-order',
beforeEnter: authCheck,
component: () => import('./../views/PrevOrder')
},
{
path: '/order',
name: 'order',
beforeEnter: authCheck,
component: () => import('./../views/Order.vue')
}
]

View File

@@ -1,212 +0,0 @@
<template>
<div class="dashboard">
<v-subheader class="py-0 d-flex justify-space-between rounded-lg">
<h3>Dashboard</h3>
<v-btn color="success">
View Orders
</v-btn>
</v-subheader>
<br>
<v-row>
<v-col lg="7" cols="12">
<v-alert dense text type="success">
Login Successfully! Welcome to <strong>Web Burden</strong>
</v-alert>
<v-row>
<v-col lg="6" cols="12" v-for="(item,index) in activityLog" :key="index">
<v-card elevation="2" class="rounded-lg">
<v-card-text class="d-flex justify-space-between align-center">
<div>
<strong>{{ item.title }}</strong> <br>
<span>Last 3 weeks</span>
</div>
<v-avatar size="60" :color="item.color" style="border: 3px solid #444">
<span style="color: white">{{item.amount}} +</span>
</v-avatar>
</v-card-text>
<v-card-actions class="d-flex justify-space-between">
</v-card-actions>
</v-card>
</v-col>
</v-row>
</v-col>
<v-col cols="12" lg="5">
<v-card>
<v-card-title>Activities</v-card-title>
<v-card-text class="py-0">
<v-timeline align-top dense>
<v-timeline-item color="indigo" small>
<strong>5 Minuts ago</strong>
<div class="text-caption">
You have new order please check this out
</div>
</v-timeline-item>
<v-timeline-item color="green" small>
<strong>35 Minuts ago</strong>
<div class="text-caption mb-2">
A Product has delivered!
</div>
</v-timeline-item>
<v-timeline-item color="indigo" small>
<strong>44 Minuts ago</strong>
<div class="text-caption">
You have new order please check this out
</div>
</v-timeline-item>
</v-timeline>
</v-card-text>
</v-card>
</v-col>
<v-col>
<v-card>
<v-data-table
caption="Recent Order list"
:headers="headers"
:items="desserts"
:items-per-page="5"
class="elevation-1"
>
<template v-slot:item.action="">
<v-btn color="success" outlined small shaped >View</v-btn>
</template>
</v-data-table>
</v-card>
</v-col>
</v-row>
</div>
</template>
<script>
export default {
name: "Dashboard",
data() {
return {
activityLog: [
{title: 'Total Products', amount: 50, icon: 'mdi-account', color: 'cyan lighten-3'},
{title: 'Total Customer', amount: 3433, icon: 'mdi-account-group-outline', color: 'green darken-2'},
{title: 'Total Sale', amount: 3433, icon: 'mdi-account-group-outline', color: 'blue-grey darken-1'},
{
title: 'Pending Orders',
amount: 3433,
icon: 'mdi-account-group-outline',
color: 'deep-orange darken-1'
},
],
headers: [
{
text: 'Dessert (100g serving)',
align: 'start',
sortable: false,
value: 'name',
},
{text: 'Calories', value: 'calories'},
{text: 'Fat (g)', value: 'fat'},
{text: 'Carbs (g)', value: 'carbs'},
{text: 'Protein (g)', value: 'protein'},
{text: 'Iron (%)', value: 'iron'},
{text: 'Actions', value: 'action'},
],
desserts: [
{
name: 'Frozen Yogurt',
calories: 159,
fat: 6.0,
carbs: 24,
protein: 4.0,
iron: '1%',
},
{
name: 'Ice cream sandwich',
calories: 237,
fat: 9.0,
carbs: 37,
protein: 4.3,
iron: '1%',
},
{
name: 'Eclair',
calories: 262,
fat: 16.0,
carbs: 23,
protein: 6.0,
iron: '7%',
},
{
name: 'Cupcake',
calories: 305,
fat: 3.7,
carbs: 67,
protein: 4.3,
iron: '8%',
},
{
name: 'Gingerbread',
calories: 356,
fat: 16.0,
carbs: 49,
protein: 3.9,
iron: '16%',
},
{
name: 'Jelly bean',
calories: 375,
fat: 0.0,
carbs: 94,
protein: 0.0,
iron: '0%',
},
{
name: 'Lollipop',
calories: 392,
fat: 0.2,
carbs: 98,
protein: 0,
iron: '2%',
},
{
name: 'Honeycomb',
calories: 408,
fat: 3.2,
carbs: 87,
protein: 6.5,
iron: '45%',
},
{
name: 'Donut',
calories: 452,
fat: 25.0,
carbs: 51,
protein: 4.9,
iron: '22%',
},
{
name: 'KitKat',
calories: 518,
fat: 26.0,
carbs: 65,
protein: 7,
iron: '6%',
},
],
}
},
methods: {
onButtonClick(item) {
console.log('click on ' + item.no)
}
}
}
</script>
<style scoped>
.overlap-icon {
position: absolute;
top: -33px;
text-align: center;
padding-top: 12px;
}
</style>

View File

@@ -1,10 +1,13 @@
<template>
<!-- <v-navigation-drawer v-model="drawer" app> -->
<v-navigation-drawer app>
<v-navigation-drawer
v-model="drawer"
app>
<v-img
height="140"
class="pa-4"
src="https://preview.pixlr.com/images/800wm/1439/2/1439104804.jpg"
>
<div class="text-center">
<v-avatar class="mb-4" color="grey darken-1" size="64">
@@ -18,13 +21,13 @@
</v-img>
<v-divider></v-divider>
<v-list>
<v-list-item v-for="[icon, text] in links" :key="icon" link>
<v-list-item v-for="(link,index) in links" :key="link.icon" link @click="clickGo(index, link.url)">
<v-list-item-icon>
<v-icon>{{ icon }}</v-icon>
<v-icon>{{ link.icon }}</v-icon>
</v-list-item-icon>
<v-list-item-content>
<v-list-item-title>{{ text }}</v-list-item-title>
<v-list-item-title>{{ link.name }}</v-list-item-title>
</v-list-item-content>
</v-list-item>
</v-list>
@@ -38,14 +41,26 @@ export default {
data() {
return {
links: [
["mdi-microsoft-windows", "Dashboard"],
["mdi-account", "Profile"],
["mdi-clipboard-list-outline", "Products"],
["mdi-card-account-details-outline", "Orders"],
["mdi-cog", "System Setting"],
{name: "지난 주문", url: "/prev-order", icon: "mdi-home-outline"},
{name: "카테고리", url: "/category", icon: "mdi-magnify"},
{name: "주문", url: "/order", icon: "mdi-cards-heart-outline"},
{name: "메뉴 관리", url: "/menu", icon: "mdi-cards-heart-outline"},
],
};
},
methods: {
clickGo: function (index, url) {
this.value = index;
this.$router.push(url);
}
},mounted() {
const path =this.$route.path
this.links.forEach((link, index) => {
if(link.url === path){
this.value = index
}
})
}
};
</script>