changes
This commit is contained in:
@@ -2,7 +2,7 @@
|
||||
import CartItem from "~/components/pos/CartItem.vue";
|
||||
|
||||
const emit = defineEmits(["close"]);
|
||||
const { $patchapi, $deleteapi, $insertapi, $dayjs, $snackbar } = useNuxtApp();
|
||||
const { $id, $patchapi, $deleteapi, $insertapi, $dayjs, $snackbar } = useNuxtApp();
|
||||
const id = "confirmOrder";
|
||||
const isPending = ref(false);
|
||||
const { activeCart, activeCartItems, orderInfo, getCarts } = inject("pos");
|
||||
@@ -19,10 +19,10 @@ async function createOrder() {
|
||||
isPending.value = true;
|
||||
const invoice = await $insertapi("Invoice", {
|
||||
data: {
|
||||
customer: "",
|
||||
customer_name: "",
|
||||
customer_phone: "",
|
||||
customer_email: "",
|
||||
customer: activeCart.value.customer,
|
||||
customer_name: activeCart.value.customer__fullname,
|
||||
customer_phone: activeCart.value.customer__phone,
|
||||
customer_email: activeCart.value.customer__email,
|
||||
shipping_address: shipping_address.value,
|
||||
product_amount: activeCartItems.value.length,
|
||||
shipping_fee: 0,
|
||||
@@ -32,7 +32,7 @@ async function createOrder() {
|
||||
order_type: "pos",
|
||||
status: "pending",
|
||||
ordered_at: new Date(),
|
||||
paid_at: new Date(),
|
||||
paid_at: null,
|
||||
delivery_method: orderInfo.value.deliveryMethod.id,
|
||||
},
|
||||
notify: false,
|
||||
@@ -64,6 +64,27 @@ async function createOrder() {
|
||||
notify: false,
|
||||
});
|
||||
|
||||
if (orderInfo.value.deliveryMethod.code === "HOME_DELIVERY") {
|
||||
const deliveryInfoPayload = {
|
||||
invoice: invoice.id,
|
||||
receiver_name: invoice.customer_name,
|
||||
receiver_phone: invoice.customer_phone,
|
||||
city: orderInfo.value.address.city,
|
||||
district: orderInfo.value.address.district,
|
||||
ward: orderInfo.value.address.ward,
|
||||
address: orderInfo.value.address.address_detail,
|
||||
shipping_fee: 0,
|
||||
carrier: orderInfo.value.deliveryMethod.id,
|
||||
tracking_code: $id(),
|
||||
status: "pending",
|
||||
};
|
||||
|
||||
const deliveryInfo = await $insertapi("Delivery_Info", {
|
||||
data: deliveryInfoPayload,
|
||||
notify: false,
|
||||
});
|
||||
}
|
||||
|
||||
$snackbar("Tạo đơn hàng thành công", "Success");
|
||||
|
||||
await Promise.all([
|
||||
|
||||
Reference in New Issue
Block a user