This commit is contained in:
weipengfei 2024-07-02 18:36:30 +08:00
parent f5171c9498
commit 6134522554
11 changed files with 142 additions and 35 deletions

View File

@ -21,6 +21,12 @@ export function cartChangeApi(id, data) {
return request.post(`user/cart/change/${id}`, data) return request.post(`user/cart/change/${id}`, data)
} }
/**
* @description 下单前校验数量库存
*/
export function storeOrdeCheckInventoryrApi(data) {
return request.post(`/store_order/storeOrder/checkInventory`, data)
}
/** /**
* @description 结算 * @description 结算

View File

@ -61,12 +61,14 @@ const changeActive = (e) => {
const form = ref({}); const form = ref({});
const cart_id = ref([]); const cart_id = ref([]);
const uid = ref(''); const uid = ref('');
const reservation = ref(null);
const isRePay = ref(false); const isRePay = ref(false);
let is_storage = 0; let is_storage = 0;
const setForm = (e) => { const setForm = (e) => {
form.value = e.data; form.value = e.data;
cart_id.value = e.cart_id; cart_id.value = e.cart_id;
uid.value = e.uid; uid.value = e.uid;
reservation.value = e.reservation || null;
is_storage = e.is_storage || 0; is_storage = e.is_storage || 0;
console.log('选择了用户==', uid.value || '游客'); console.log('选择了用户==', uid.value || '游客');
isRePay.value = e.isRePay || false; isRePay.value = e.isRePay || false;
@ -125,6 +127,7 @@ const handleEnter = () => {
pay_type: pay_type, pay_type: pay_type,
is_storage: is_storage, is_storage: is_storage,
auth_code: input.value, auth_code: input.value,
reservation: reservation.value,
uid: uid.value uid: uid.value
}) })
.then((res) => { .then((res) => {
@ -182,6 +185,7 @@ const orderPay = () => {
pay_type: pay_type, pay_type: pay_type,
is_storage: is_storage, is_storage: is_storage,
auth_code: input.value, auth_code: input.value,
reservation: reservation.value,
uid: uid.value uid: uid.value
}).then((res) => { }).then((res) => {
if (res.msg?.includes('成功')) { if (res.msg?.includes('成功')) {
@ -351,6 +355,7 @@ const cashBnt = () => {
cart_id: cart_id.value, cart_id: cart_id.value,
pay_type: "17", // 17 pay_type: "17", // 17
is_storage: is_storage, is_storage: is_storage,
reservation: reservation.value,
uid: uid.value uid: uid.value
}) })
.then((res) => { .then((res) => {
@ -438,8 +443,10 @@ const getSms = () => {
if (!uid.value) return ElMessage.error('请先选择用户'); if (!uid.value) return ElMessage.error('请先选择用户');
let type = 1; // let type = 1; //
if (active.value == 4) type = 2; // if (active.value == 4) type = 2; //
if (active.value == 5) type = 3; //
storeOrderCheckSmsApi({ storeOrderCheckSmsApi({
cart_id: cart_id.value, cart_id: cart_id.value,
reservation: reservation.value,
uid: uid.value, uid: uid.value,
type: type type: type
}).then(res => { }).then(res => {
@ -462,6 +469,7 @@ const handlecodeEnter = () => {
is_storage: is_storage, is_storage: is_storage,
sms_code: smsCode.value, sms_code: smsCode.value,
cart_id: cart_id.value, cart_id: cart_id.value,
reservation: reservation.value,
uid: uid.value uid: uid.value
}).then(res => { }).then(res => {
drawer.value = false; drawer.value = false;

View File

@ -94,7 +94,7 @@ defineExpose({
</div> </div>
<div class="bottom flex" style="justify-content: space-between;"> <div class="bottom flex" style="justify-content: space-between;">
<div>采购款: <span class="red">{{ item.purchase_funds }}</span></div> <div>采购款: <span class="red">{{ item.purchase_funds }}</span></div>
<div>礼品券: <span class="red">{{ item.get_frozen?.toFixed(2) || item.get_frozen }}</span></div> <div>礼品券: <span class="red">{{ item.get_frozen }}</span></div>
<div>余额: <span class="red">{{ item.now_money }}</span></div> <div>余额: <span class="red">{{ item.now_money }}</span></div>
</div> </div>
</div> </div>

View File

@ -116,7 +116,9 @@ export const printTicket = (obj = {}, test = false) => {
if (!obj || !obj.order_id) obj = testObj; if (!obj || !obj.order_id) obj = testObj;
str += Esc.Size2(2) + Esc.Center() + Esc.boldFontOn() + obj.system_store_name + Esc.Size1() + "\n"; str += Esc.Size2(2) + Esc.Center() + Esc.boldFontOn() + obj.system_store_name + Esc.Size1() + "\n";
str += Esc.fillLine(" ") + Esc.boldFontOff() + "\n"; str += Esc.fillLine(" ") + Esc.boldFontOff() + "\n";
if (obj.shipping_type) str += Esc.Left() + "核销码: " + Esc.boldFontOn() + obj.verify_code + Esc.boldFontOff() + "\n"; if (obj.shipping_type) {
str += Esc.Left() + "核销码: " + Esc.boldFontOn() + obj.verify_code + Esc.boldFontOff() + (obj.reservation ? " (次日提)" : " ") + "\n";
}
str += Esc.Left() + "单号: " + obj.order_id + "\n"; str += Esc.Left() + "单号: " + obj.order_id + "\n";
str += Esc.Left() + "下单时间: " + obj.create_time + "\n"; str += Esc.Left() + "下单时间: " + obj.create_time + "\n";
@ -128,7 +130,8 @@ export const printTicket = (obj = {}, test = false) => {
str += Esc.Left() + item.store_name + "\n"; str += Esc.Left() + item.store_name + "\n";
let total = +item.price || 0; let total = +item.price || 0;
total *= +item.cart_num; total *= +item.cart_num;
str += Esc.inline3(`${item.price || '0.00'}`, `${item.cart_num}${item.unit_name || ''}`, `${total}`, " ", 1) + "\n"; total = total.toFixed(2);
str += Esc.inline3(`${item.price || '0.00'}`, `${item.cart_num}${item.unit_name || ''}`, `${item.cart_info?.pay_price || total}`, " ", 1) + "\n";
}) })
str += Esc.fillLine("=") + "\n"; str += Esc.fillLine("=") + "\n";

View File

@ -46,7 +46,7 @@ const getList = () => {
cartListApi().then((res) => { cartListApi().then((res) => {
extend.value = res.data.extend; extend.value = res.data.extend;
list.value = res.data.lists || []; list.value = res.data.lists || [];
if (!extend.value?.pay_price) userInfo.value.uid = ""; // if (!extend.value?.pay_price) userInfo.value.uid = "";
// if (res.data?.lists?.length > 0) { // if (res.data?.lists?.length > 0) {
// list.value = res.data.lists; // list.value = res.data.lists;
// allPrice.value = res.data?.lists.reduce((previous, current) => { // allPrice.value = res.data?.lists.reduce((previous, current) => {
@ -165,7 +165,7 @@ onUnmounted(() => {
<div class="user-money"> <div class="user-money">
<div style="margin-right: 0.5rem;">采购款: <span style="color: #f70;">{{ <div style="margin-right: 0.5rem;">采购款: <span style="color: #f70;">{{
userInfo.purchase_funds }}</span></div> userInfo.purchase_funds }}</span></div>
<div style="margin-right: 0.5rem;">礼品券: <span style="color: #f70;">{{ userInfo.get_frozen?.toFixed(2) || userInfo.get_frozen <div style="margin-right: 0.5rem;">礼品券: <span style="color: #f70;">{{ userInfo.get_frozen
}}</span></div> }}</span></div>
<div>余额: <span style="color: #f70;">{{ userInfo.now_money }}</span></div> <div>余额: <span style="color: #f70;">{{ userInfo.now_money }}</span></div>
</div> </div>

View File

@ -32,8 +32,8 @@ const loadMore = () => {
}; };
const changeItem = (item) => { const changeItem = (item) => {
if (item.is_used == 0) return ElMessage.error("该商品已被平台关闭"); // if (item.is_used == 0) return ElMessage.error("");
if (item.stock == 0) return ElMessage.warning("该商品无库存"); // if (item.stock == 0) return ElMessage.warning("");
emit("changeItem", item); emit("changeItem", item);
}; };
@ -113,18 +113,23 @@ onUnmounted(() => {
¥<span>{{ item[priceKey.op_price] }}</span> ¥<span>{{ item[priceKey.op_price] }}</span>
<span class="unit-name">/{{ item.unit_name }}</span> <span class="unit-name">/{{ item.unit_name }}</span>
</div> </div>
<div class="no-stock" v-if="item.stock == 0"> <div class="no-stock-re" v-if="item.stock <= 0">
<div>
<span>次日提</span>
</div>
</div>
<!-- <div class="no-stock" v-if="item.stock == 0">
<div> <div>
<span>暂无</span> <span>暂无</span>
<span>库存</span> <span>库存</span>
</div> </div>
</div> </div> -->
<div class="no-stock" v-if="item.is_used == 0"> <!-- <div class="no-stock" v-if="item.is_used == 0">
<div> <div>
<span>平台</span> <span>平台</span>
<span>关闭</span> <span>关闭</span>
</div> </div>
</div> </div> -->
</div> </div>
</el-space> </el-space>
<div class="no-data" v-if="!storeList.length"> <div class="no-data" v-if="!storeList.length">
@ -283,6 +288,29 @@ onUnmounted(() => {
justify-content: center; justify-content: center;
} }
} }
.no-stock-re{
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
background-color: rgba($color: #000000, $alpha: 0.1);
display: flex;
justify-content: center;
align-items: center;
div {
background-color: rgba($color: #E6A23C, $alpha: 0.8);
color: #fff;
border-radius: 50%;
width: 5rem;
height: 5rem;
display: flex;
flex-direction: column;
align-items: center;
justify-content: center;
}
}
} }
} }

View File

@ -6,7 +6,7 @@ import pupop from "./component/pupop.vue";
import classify from "./component/classify.vue"; import classify from "./component/classify.vue";
import pay from "@/components/pay.vue"; import pay from "@/components/pay.vue";
import { ref, reactive, nextTick, onMounted, onUnmounted } from "vue"; import { ref, reactive, nextTick, onMounted, onUnmounted } from "vue";
import { cartCreateApi, orderCheckApi } from "@/api/store.js"; import { cartCreateApi, orderCheckApi, storeOrdeCheckInventoryrApi } from "@/api/store.js";
import { saleStoreListApi } from "@/api/shop.js"; import { saleStoreListApi } from "@/api/shop.js";
import { useUserStore } from "@/store/user.js"; import { useUserStore } from "@/store/user.js";
import { useRoute } from "vue-router"; import { useRoute } from "vue-router";
@ -14,6 +14,7 @@ import mitt from "@/utils/mitt.js";
import moment from "moment"; import moment from "moment";
import { printTicket } from "@/utils/EscPos.js"; import { printTicket } from "@/utils/EscPos.js";
import { ElMessage } from "element-plus"; import { ElMessage } from "element-plus";
import feedback from "@/utils/feedback";
const pupopRef = ref(null); const pupopRef = ref(null);
const orderRef = ref(null); const orderRef = ref(null);
@ -104,12 +105,16 @@ const editPupop = (item) => {
const orderForm = ref({}); const orderForm = ref({});
// //
const checkOut = () => { const checkOut = async () => {
let cart_id = orderRef.value.list.map((item) => item.id); let cart_id = orderRef.value.list.map((item) => item.id);
let query = { let query = {
cart_id: cart_id, cart_id: cart_id,
uid: orderRef.value?.userInfo?.uid || "", uid: orderRef.value?.userInfo?.uid || "",
}; };
let {data} = await storeOrdeCheckInventoryrApi(query);
if(data.reservation>0){
await feedback.confirm('部分商品暂无现货, 需要次日提货, 是否确认购买?')
}
if (orderRef.value.discounts > 0) { if (orderRef.value.discounts > 0) {
query.deduction_price = orderRef.value.discounts.toFixed(2); query.deduction_price = orderRef.value.discounts.toFixed(2);
query.pay_type = "micropay"; query.pay_type = "micropay";
@ -118,17 +123,18 @@ const checkOut = () => {
orderForm.value = res.data.order; orderForm.value = res.data.order;
payRef.value.setForm({ payRef.value.setForm({
data: res.data.order, data: res.data.order,
reservation: data.reservation,
cart_id: cart_id, cart_id: cart_id,
uid: orderRef.value?.userInfo?.uid || "", uid: orderRef.value?.userInfo?.uid || "",
is_storage: orderRef.value?.is_storage ? 1 : 0, is_storage: orderRef.value?.is_storage ? 1 : 0,
}); });
}); });
payRef.value.drawer = true;
}; };
const goPay = () => { const goPay = () => {
if(orderRef.value?.is_storage && !orderRef.value?.userInfo?.uid) return ElMessage.error("选择用户才可以存货"); if(orderRef.value?.is_storage && !orderRef.value?.userInfo?.uid) return ElMessage.error("选择用户才可以存货");
checkOut(); checkOut();
payRef.value.drawer = true;
}; };
const paySuccess = (data = null) => { const paySuccess = (data = null) => {

View File

@ -9,7 +9,9 @@ const where = ref({
page_no: 1, page_no: 1,
page_size: 20, page_size: 20,
loadend: false, loadend: false,
type: 1 store_name: '',
status: null,
stock: null
}); });
const loading = ref(false); const loading = ref(false);
@ -20,7 +22,9 @@ const getOrderList = () => {
storeProductListsApi({ storeProductListsApi({
page_no: where.value.page_no, page_no: where.value.page_no,
page_size: where.value.page_size, page_size: where.value.page_size,
type: where.value.type store_name: where.value.store_name,
stock: where.value.stock,
status: where.value.status,
}).then((res) => { }).then((res) => {
orderList.value = [...orderList.value, ...res.data.lists]; orderList.value = [...orderList.value, ...res.data.lists];
if (res.data.lists.length < where.value.page_size) where.value.loadend = true; if (res.data.lists.length < where.value.page_size) where.value.loadend = true;
@ -38,35 +42,65 @@ const reload = ()=>{
getOrderList(); getOrderList();
}; };
const statusLable = ref(0);
const changeProducStatus = (e)=>{
if(e==0) {
where.value.status = null;
where.value.stock = null;
}else if(e==1){
where.value.status = 1;
where.value.stock = null;
}else if(e==2){
where.value.status = 0;
where.value.stock = null;
}else if(e==3){
where.value.status = null;
where.value.stock = 10;
}else if(e==4){
where.value.status = null;
where.value.stock = 0;
}
reload();
}
</script> </script>
<template> <template>
<div class="my-card put-storage"> <div class="my-card put-storage">
<el-radio-group style="margin-bottom: 20px" v-model="where.type" @change="reload"> <div class="storage-header">
<el-radio-button :label="1" :value="1">售卖库存</el-radio-button> <div class="flex">
<el-radio-button :label="2" :value="2">兑换库存</el-radio-button> <el-input placeholder="请输入商品名称" style="width: 20rem;" v-model="where.store_name" @keydown.enter="reload"></el-input>
</el-radio-group> <el-button style="margin-left: 1rem" type="primary" @click="reload">搜索</el-button>
<el-button style="margin-left: 1rem" @click="where.store_name = '';reload()">重置</el-button>
</div>
<el-radio-group style="margin-bottom: 20px" v-model="statusLable" @change="changeProducStatus">
<el-radio-button :label="0" :value="0">全部</el-radio-button>
<el-radio-button :label="1" :value="1">上架</el-radio-button>
<el-radio-button :label="2" :value="2">下架</el-radio-button>
<el-radio-button :label="3" :value="3">库存预警</el-radio-button>
<el-radio-button :label="4" :value="4">已售罄</el-radio-button>
</el-radio-group>
</div>
<div class="order-lists" v-loading="loading" v-infinite-scroll="getOrderList" :infinite-scroll-distance="300" <div class="order-lists" v-loading="loading" v-infinite-scroll="getOrderList" :infinite-scroll-distance="300"
:infinite-scroll-delay="500" :infinite-scroll-immediate="false" style="overflow: auto"> :infinite-scroll-delay="500" :infinite-scroll-immediate="false" style="overflow: auto">
<el-table :data="orderList"> <el-table :data="orderList">
<el-table-column label="导入人员" prop="admin_name" /> <el-table-column label="ID" prop="id" min-width="55" />
<el-table-column label="门店确认人员" prop="staff_name" /> <el-table-column label="商品图" prop="image" width="100">
<el-table-column label="商品图" prop="image">
<template #default="{ row }"> <template #default="{ row }">
<el-image class="image" :src="row.image" /> <el-image class="image" :src="row.image" />
</template> </template>
</el-table-column> </el-table-column>
<el-table-column label="商品" prop="store_name" /> <el-table-column label="商品名" prop="store_name" min-width="200" />
<el-table-column label="数量" prop="nums" /> <el-table-column label="分类" prop="cate_name" />
<el-table-column label="销量" prop="sales" />
<el-table-column label="库存" prop="stock" />
<el-table-column label="状态" prop="status"> <el-table-column label="状态" prop="status">
<template #default="{ row }"> <template #default="{ row }">
<el-tag type="success" v-if="row.status === 1">已入库</el-tag> <el-tag class="el-tag" v-if="row.status == 1" type="success">上架</el-tag>
<el-tag type="warning" v-else-if="row.status === 0">待确认</el-tag> <el-tag class="el-tag" v-else-if="row.status == 0" type="info">下架</el-tag>
<el-tag type="danger" v-else-if="row.status === -1">库存不足</el-tag> <el-tag class="el-tag" v-if="row.stock<=10&&row.stock>0" type="warning">库存预警</el-tag>
<el-tag class="el-tag" v-if="row.stock==0" type="danger">已售罄</el-tag>
</template> </template>
</el-table-column> </el-table-column>
<el-table-column label="备注" prop="mark" />
</el-table> </el-table>
</div> </div>
</div> </div>
@ -92,6 +126,22 @@ const reload = ()=>{
flex: 1; flex: 1;
width: 100%; width: 100%;
} }
.storage-header{
display: flex;
width: 100%;
justify-content: space-between;
align-items: center;
.flex{
height: 100%;
display: flex;
align-items: flex-start
}
}
.el-tag{
margin-right: 1rem;
}
} }
.my-card {} .my-card {}

View File

@ -119,7 +119,9 @@ const props = {
const userShip = ref([]) const userShip = ref([])
const getUserShip = () => { const getUserShip = () => {
userShipApi().then(res => { userShipApi({
type_id: 4
}).then(res => {
userShip.value = res.data.lists?.filter((item) => { userShip.value = res.data.lists?.filter((item) => {
return item.id == 0 || item.id == 4 return item.id == 0 || item.id == 4
}); });

View File

@ -48,7 +48,9 @@ const paySuccess = (e = null) => {
const updateShip = ref(false); const updateShip = ref(false);
const userShip = ref([]); const userShip = ref([]);
const getUserShip = () => { const getUserShip = () => {
userShipApi().then(res => { userShipApi({
type_id: 4
}).then(res => {
userShip.value = res.data.lists; userShip.value = res.data.lists;
}) })
} }
@ -422,7 +424,7 @@ onUnmounted(() => {
</div> </div>
<div class="info-item"> <div class="info-item">
<div class="info-item-title">礼品券:</div> <div class="info-item-title">礼品券:</div>
<div class="info-item-info red">¥{{ formData.get_frozen?.toFixed(2) }}</div> <div class="info-item-info red">¥{{ formData.get_frozen }}</div>
</div> </div>
<div class="info-item"> <div class="info-item">
<div class="info-item-title">冻结礼品券:</div> <div class="info-item-title">冻结礼品券:</div>

View File

@ -82,7 +82,9 @@ const addSuccess = () => {
const userShip = ref([]) const userShip = ref([])
const getUserShip = () => { const getUserShip = () => {
userShipApi().then(res => { userShipApi({
type_id: 4
}).then(res => {
userShip.value = res.data.lists; userShip.value = res.data.lists;
}) })
} }
@ -250,7 +252,7 @@ onUnmounted(() => {
<div>余额: <span class="red">{{ item.now_money }}</span></div> <div>余额: <span class="red">{{ item.now_money }}</span></div>
<div>采购款: <span class="red">{{ item.purchase_funds }}</span></div> <div>采购款: <span class="red">{{ item.purchase_funds }}</span></div>
<div>返还金: <span class="red">{{ item.return_money?.toFixed(2) }}</span></div> <div>返还金: <span class="red">{{ item.return_money?.toFixed(2) }}</span></div>
<div>礼品券: <span class="red">{{ item.get_frozen?.toFixed(2) }}</span></div> <div>礼品券: <span class="red">{{ item.get_frozen }}</span></div>
<div> <div>
<el-tag type="primary" v-if="item.user_ship == 0 || item.user_ship == 4">{{ item.user_ship_name }}</el-tag> <el-tag type="primary" v-if="item.user_ship == 0 || item.user_ship == 4">{{ item.user_ship_name }}</el-tag>
<el-tag type="success" v-else>{{ item.user_ship_name }}</el-tag> <el-tag type="success" v-else>{{ item.user_ship_name }}</el-tag>