1.优化会员扫码充值订单状态查询
This commit is contained in:
parent
745b8675ea
commit
d08a629b0a
|
|
@ -207,3 +207,16 @@ export function orderPrint(data) {
|
|||
data,
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询会员充值支付状态
|
||||
* @param {*} data
|
||||
* @returns
|
||||
*/
|
||||
export function queryPayStatus(params) {
|
||||
return request({
|
||||
method: "get",
|
||||
url: "/order/pay/queryPayStatus",
|
||||
params,
|
||||
});
|
||||
}
|
||||
|
|
|
|||
|
|
@ -171,7 +171,7 @@ async function findCouponAjax() {
|
|||
} else {
|
||||
let arr = []
|
||||
let ids = props.orderList.map(item => item.productId)
|
||||
res.map(item => {
|
||||
res && res.map(item => {
|
||||
if (ids.includes(item.proId)) {
|
||||
let pro = props.orderList.find(val => val.productId == item.proId)
|
||||
arr.push({
|
||||
|
|
@ -193,9 +193,7 @@ function show(userId) {
|
|||
showDialog.value = true
|
||||
query.value.userId = userId
|
||||
findCouponAjax()
|
||||
|
||||
console.log('couponModal.orderList===', props.orderList);
|
||||
|
||||
}
|
||||
|
||||
defineExpose({
|
||||
|
|
|
|||
|
|
@ -69,36 +69,6 @@
|
|||
</div>
|
||||
<scanModal ref="scanModalRef" :amount="props.amount" :money="money" :orderId="props.orderId"
|
||||
:selecttype="props.selecttype" :payType="payType" :payData="payData" @success="scanCodeSuccess" />
|
||||
<el-dialog :title="`选择会员`" top="3vh" v-model="showDialog" width="80%">
|
||||
<el-form inline>
|
||||
<el-form-item>
|
||||
<el-input placeholder="请输入手机号搜索会员" v-model="tableData.phone" />
|
||||
</el-form-item>
|
||||
<el-form-item>
|
||||
<el-button type="primary" @click="getMemberList">搜索</el-button>
|
||||
<el-button @click="resetTable">重置</el-button>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
<el-table :data="tableData.list" height="440px" border stripe v-loading="tableData.loading">
|
||||
<el-table-column prop="name" label="昵称" width="120px" />
|
||||
<el-table-column prop="telephone" label="手机" width="150px" />
|
||||
<el-table-column prop="code" label="编号" width="120px" />
|
||||
<el-table-column prop="level" label="等级" />
|
||||
<el-table-column prop="levelConsume" label="积分" />
|
||||
<el-table-column prop="amount" label="余额" width="100px">
|
||||
<template v-slot="scope">
|
||||
¥{{ formatDecimal(scope.row.amount) }}
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="操作" width="120px">
|
||||
<template v-slot="scope">
|
||||
<el-button type="primary" @click="toHomeMember(scope.row)">选择</el-button>
|
||||
</template>
|
||||
</el-table-column>
|
||||
</el-table>
|
||||
<el-pagination layout="prev, pager, next, total" background style="margin-top: 20px"
|
||||
:total="Number(tableData.total)" v-model:current-page="tableData.page" @current-change="getMemberList" />
|
||||
</el-dialog>
|
||||
<!-- 选择挂账人员 -->
|
||||
<el-dialog title="挂账" top="1vh" v-model="showBuyer" width="90%" @closed="resetBuyerTable">
|
||||
<el-form inline>
|
||||
|
|
@ -362,10 +332,10 @@ async function payCreditPayHandle(row) {
|
|||
buyerTable.loading = false;
|
||||
emit("paySuccess");
|
||||
} catch (error) {
|
||||
buyerTable.loading = false;
|
||||
payLoading.value = false;
|
||||
console.log(error);
|
||||
}
|
||||
buyerTable.loading = false;
|
||||
payLoading.value = false;
|
||||
}
|
||||
// 显示选择挂账人 end
|
||||
|
||||
|
|
@ -374,6 +344,27 @@ function scanCodeSuccess() {
|
|||
emit("paySuccess");
|
||||
}
|
||||
|
||||
// 会员支付
|
||||
async function vipPayAjax(row) {
|
||||
try {
|
||||
if (row.amount < money.value) {
|
||||
ElMessage.error('余额不足')
|
||||
return
|
||||
}
|
||||
|
||||
payData.value.payType = 'userPay'
|
||||
payData.value.shopUserId = row.id
|
||||
payData.value.checkOrderPay.userId = row.userId
|
||||
payLoading.value = true;
|
||||
|
||||
await vipPay(payData.value)
|
||||
emit("paySuccess");
|
||||
} catch (error) {
|
||||
console.log(error);
|
||||
}
|
||||
payLoading.value = false;
|
||||
}
|
||||
|
||||
// 切换支付类型
|
||||
async function payTypeChange(index, item) {
|
||||
try {
|
||||
|
|
@ -384,9 +375,12 @@ async function payTypeChange(index, item) {
|
|||
if (item.payType == "scanCode") {
|
||||
scanModalRef.value.show();
|
||||
}
|
||||
if (item.payType == "vipPay") {
|
||||
showDialog.value = true;
|
||||
getMemberList();
|
||||
if (item.payType == "member-account") {
|
||||
if (goodsStore.vipUserInfo.id) {
|
||||
// await vipPayAjax(goodsStore.vipUserInfo)
|
||||
} else {
|
||||
SelectVipUserRef.value.show()
|
||||
}
|
||||
}
|
||||
if (item.payType == "buyer") {
|
||||
showBuyerHandle();
|
||||
|
|
@ -434,11 +428,14 @@ async function confirmOrder() {
|
|||
} else {
|
||||
}
|
||||
break
|
||||
case "vipPay":
|
||||
case "member-account":
|
||||
// 会员支付
|
||||
console.log("使用会员id支付");
|
||||
payLoading.value = false;
|
||||
showDialog.value = true;
|
||||
if (goodsStore.vipUserInfo.id) {
|
||||
await vipPayAjax(goodsStore.vipUserInfo)
|
||||
} else {
|
||||
SelectVipUserRef.value.show()
|
||||
}
|
||||
return;
|
||||
default:
|
||||
break;
|
||||
|
|
@ -500,66 +497,6 @@ async function queryPayTypeAjax() {
|
|||
}
|
||||
}
|
||||
|
||||
const showDialog = ref(false);
|
||||
const tableData = reactive({
|
||||
phone: "",
|
||||
loading: false,
|
||||
list: [],
|
||||
page: 1,
|
||||
size: 10,
|
||||
total: 0,
|
||||
});
|
||||
|
||||
// 重置表格
|
||||
function resetTable() {
|
||||
tableData.phone = "";
|
||||
tableData.page = 1;
|
||||
getMemberList();
|
||||
}
|
||||
|
||||
// 获取会员列表
|
||||
async function getMemberList() {
|
||||
try {
|
||||
tableData.loading = true;
|
||||
const res = await queryMembermember({
|
||||
shopId: store.userInfo.shopId,
|
||||
phone: tableData.phone,
|
||||
page: tableData.page,
|
||||
pageSize: tableData.size,
|
||||
isFlag: 1,
|
||||
});
|
||||
tableData.loading = false;
|
||||
tableData.list = res.list;
|
||||
tableData.total = res.total;
|
||||
} catch (error) {
|
||||
console.log(error);
|
||||
}
|
||||
}
|
||||
|
||||
// 选择会员去下单
|
||||
async function toHomeMember(row) {
|
||||
try {
|
||||
showDialog.value = false;
|
||||
payLoading.value = true;
|
||||
const res = await vipPay({
|
||||
orderId: props.orderId,
|
||||
vipUserId: row.id,
|
||||
payAmount: props.discount > 0 ? money.value : "",
|
||||
discountAmount:
|
||||
props.discount > 0 ? formatDecimal(props.amount - money.value) : "",
|
||||
});
|
||||
global.setOrderTable();
|
||||
global.setOrderMember();
|
||||
|
||||
payLoading.value = false;
|
||||
ElMessage.success("支付成功");
|
||||
emit("paySuccess");
|
||||
} catch (error) {
|
||||
payLoading.value = false;
|
||||
console.log(error);
|
||||
}
|
||||
}
|
||||
|
||||
// 取消折扣
|
||||
function cancelDiscount() {
|
||||
discountRateVlaue.value = 0
|
||||
|
|
@ -607,31 +544,29 @@ function clearCouponUser() {
|
|||
}
|
||||
|
||||
// 折扣格式化
|
||||
function discountInput(e) {
|
||||
const discountInput = _.debounce(function (e) {
|
||||
couponForm.value.amount = couponForm.value.originAmount
|
||||
setTimeout(() => {
|
||||
couponForm.value.discountRatio = inputFilterFloat(e)
|
||||
if (couponForm.value.discountRatio > 9.9) {
|
||||
couponForm.value.discountRatio = 9.9
|
||||
}
|
||||
if (couponForm.value.discountRatio < 0.1) {
|
||||
couponForm.value.discountRatio = 0.1
|
||||
}
|
||||
couponForm.value.discountRatio = inputFilterFloat(e)
|
||||
if (couponForm.value.discountRatio > 9.9) {
|
||||
couponForm.value.discountRatio = 9.9
|
||||
}
|
||||
if (couponForm.value.discountRatio < 0.1) {
|
||||
couponForm.value.discountRatio = 0.1
|
||||
}
|
||||
|
||||
if (couponForm.value.discountRatio) {
|
||||
couponForm.value.amount = formatDecimal(couponForm.value.amount * (couponForm.value.discountRatio / couponFormDiscountRate.value))
|
||||
} else {
|
||||
couponForm.value.amount = formatDecimal(+couponForm.value.originAmount)
|
||||
}
|
||||
if (couponForm.value.discountRatio) {
|
||||
couponForm.value.amount = formatDecimal(couponForm.value.amount * (couponForm.value.discountRatio / couponFormDiscountRate.value))
|
||||
} else {
|
||||
couponForm.value.amount = formatDecimal(+couponForm.value.originAmount)
|
||||
}
|
||||
|
||||
// 将优惠券/积分所有设置初始化
|
||||
couponResList1.value = []
|
||||
couponResList2.value = []
|
||||
// 将优惠券/积分所有设置初始化
|
||||
couponResList1.value = []
|
||||
couponResList2.value = []
|
||||
|
||||
couponForm.value.pointsNum = ''
|
||||
pointOptions.value.amount = 0
|
||||
}, 50)
|
||||
}
|
||||
couponForm.value.pointsNum = ''
|
||||
pointOptions.value.amount = 0
|
||||
}, 500)
|
||||
|
||||
// 积分输入格式化
|
||||
function pointInput(e) {
|
||||
|
|
@ -704,19 +639,29 @@ function resetCouponFormHandle() {
|
|||
}
|
||||
|
||||
// 选择会员完成后
|
||||
function selectUserHandle(row) {
|
||||
couponFormUserList.value = [
|
||||
{
|
||||
id: row.userId,
|
||||
nickName: row.nickName,
|
||||
}
|
||||
]
|
||||
couponFormUser.value = row
|
||||
pointOptionsAjax()
|
||||
async function selectUserHandle(row) {
|
||||
try {
|
||||
if (showCoupon.value) {
|
||||
couponFormUserList.value = [
|
||||
{
|
||||
id: row.userId,
|
||||
nickName: row.nickName,
|
||||
}
|
||||
]
|
||||
couponFormUser.value = row
|
||||
pointOptionsAjax()
|
||||
|
||||
// 已存在选择的用户,并且切换了不通用户
|
||||
if (couponFormUser.id && row.userId != couponFormUser.value.userId) {
|
||||
resetCoupon()
|
||||
// 已存在选择的用户,并且切换了不通用户
|
||||
if (couponFormUser.id && row.userId != couponFormUser.value.userId) {
|
||||
resetCoupon()
|
||||
}
|
||||
}
|
||||
|
||||
if (payList.value[payActive.value].payType == 'member-account') {
|
||||
vipPayAjax(row)
|
||||
}
|
||||
} catch (error) {
|
||||
console.log(error);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -859,7 +804,7 @@ function reset() {
|
|||
buyerRemark: "", // 订单备注
|
||||
checkOrderPay: {
|
||||
orderId: goodsStore.orderListInfo.id,
|
||||
vipPrice: store.shopInfo.isMemberPrice || goodsStore.showVipPrice, // 是否使用会员价
|
||||
vipPrice: store.shopInfo.isMemberPrice ? goodsStore.showVipPrice : 0, // 是否使用会员价
|
||||
allPack: goodsStore.allSelected, // 是否整单打包
|
||||
userId: goodsStore.vipUserInfo.id,
|
||||
seatNum: goodsStore.tableInfo.num, // 用餐人数
|
||||
|
|
|
|||
|
|
@ -58,7 +58,7 @@ import { scanpay, queryOrder, quickPay, queryQuickPayStatus, accountPay, querySc
|
|||
import { useUser } from "@/store/user.js";
|
||||
import { useGlobal } from '@/store/global.js'
|
||||
import { formatDecimal } from '@/utils'
|
||||
import { microPay, queryOrderStatus, microPayVip, vipPay } from '@/api/order.js'
|
||||
import { microPay, queryOrderStatus, microPayVip, vipPay, queryPayStatus } from '@/api/order.js'
|
||||
|
||||
const store = useUser();
|
||||
const global = useGlobal()
|
||||
|
|
@ -113,6 +113,7 @@ const userPayWait = ref(false);
|
|||
const checkPayStatusLoading = ref(false);
|
||||
|
||||
const fastOrder = ref('')
|
||||
const vipPayOrder = ref('')
|
||||
|
||||
// 提交扫码支付
|
||||
async function submitHandle() {
|
||||
|
|
@ -210,8 +211,11 @@ async function checkPayStauts(tips = true) {
|
|||
try {
|
||||
if (props.selecttype == 1) {
|
||||
// 会员扫码充值
|
||||
const res = await queryScanPay({ flowId: fastOrder.value.id });
|
||||
if (res.status == 0) {
|
||||
const res = await queryPayStatus({
|
||||
shopId: store.shopInfo.id,
|
||||
payOrderNo: fastOrder.value.payOrderNo,
|
||||
});
|
||||
if (res == 'TRADE_SUCCESS') {
|
||||
userPayWait.value = false
|
||||
loading.value = false;
|
||||
scanCode.value = "";
|
||||
|
|
@ -220,8 +224,7 @@ async function checkPayStauts(tips = true) {
|
|||
clearAutoCheckOrder()
|
||||
emits("success");
|
||||
return;
|
||||
}
|
||||
if (res.status == 7) {
|
||||
} else if (res == 'TRADE_AWAIT') {
|
||||
if (tips) {
|
||||
ElMessage.warning("用户支付中...");
|
||||
}
|
||||
|
|
@ -263,7 +266,6 @@ async function checkPayStauts(tips = true) {
|
|||
userPayWait.value = false
|
||||
loading.value = false;
|
||||
scanCode.value = "";
|
||||
ElMessage.success("支付成功");
|
||||
dialogVisible.value = false;
|
||||
clearAutoCheckOrder()
|
||||
emits("success");
|
||||
|
|
@ -276,7 +278,7 @@ async function checkPayStauts(tips = true) {
|
|||
return;
|
||||
} else {
|
||||
clearAutoCheckOrder()
|
||||
ElMessage.error(res.msg);
|
||||
ElMessage.error(res.msg || '');
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
|
@ -292,7 +294,9 @@ function resetScanCode() {
|
|||
userPayWait.value = false;
|
||||
loading.value = false;
|
||||
scanCode.value = "";
|
||||
inputRef.value.focus();
|
||||
setTimeout(() => {
|
||||
inputRef.value.focus();
|
||||
}, 500)
|
||||
}
|
||||
|
||||
// 输入
|
||||
|
|
|
|||
|
|
@ -17,9 +17,9 @@
|
|||
</el-form-item>
|
||||
</el-form>
|
||||
<el-table :data="tableData.list" height="440px" border stripe v-loading="tableData.loading">
|
||||
<el-table-column prop="nickName" label="昵称" width="120px" />
|
||||
<el-table-column prop="nickName" label="昵称" width="150px" />
|
||||
<el-table-column prop="phone" label="手机" width="150px" />
|
||||
<el-table-column prop="code" label="编号" width="120px" />
|
||||
<el-table-column prop="code" label="编号" width="150px" />
|
||||
<el-table-column prop="level" label="等级" />
|
||||
<el-table-column prop="accountPoints" label="积分" />
|
||||
<el-table-column prop="amount" label="余额" width="120px">
|
||||
|
|
@ -27,7 +27,7 @@
|
|||
¥{{ formatDecimal(scope.row.amount) }}
|
||||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="操作" width="120px">
|
||||
<el-table-column label="操作" width="120px" fixed="right">
|
||||
<template v-slot="scope">
|
||||
<el-button type="primary" @click="toHomeMember(scope.row)">选择</el-button>
|
||||
</template>
|
||||
|
|
|
|||
|
|
@ -109,6 +109,10 @@ export const useGlobal = defineStore("global", {
|
|||
type: "cash_pay",
|
||||
label: "现金支付",
|
||||
},
|
||||
{
|
||||
type: "credit_pay",
|
||||
label: "挂账支付",
|
||||
},
|
||||
],
|
||||
bizCodes: [
|
||||
{
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@ import { ElMessage } from "element-plus";
|
|||
// 商品store + 购物车store
|
||||
export const useGoods = defineStore("goods", {
|
||||
state: () => ({
|
||||
showVipPrice: false,
|
||||
showVipPrice: 0,
|
||||
allSelected: 0, // 是否整单打包
|
||||
vipUserInfo: {}, // 会员信息
|
||||
// tableInfo: {
|
||||
|
|
@ -444,6 +444,7 @@ export const useGoods = defineStore("goods", {
|
|||
item.packFee = val.packFee;
|
||||
item.unitName = val.unitName;
|
||||
}
|
||||
item.pack_number = item.packNumber;
|
||||
item.product_name = item.productName;
|
||||
item.number = item.num;
|
||||
});
|
||||
|
|
|
|||
|
|
@ -203,13 +203,15 @@
|
|||
<el-dialog v-model="showPackModal" title="打包数量" @open="packModalOpen" width="350">
|
||||
<div class="dialog">
|
||||
<div class="el-popover__title content">
|
||||
<el-form ref="packNumerFormRef" :model="packNumberForm" :rules="packNumberFormRules" label-width="60px"
|
||||
<el-form ref="packNumerFormRef" :model="packNumberForm" :rules="packNumberFormRules" label-width="100px"
|
||||
label-position="left">
|
||||
<el-form-item label="数量" prop="number">
|
||||
<el-input v-model="packNumberForm.number"
|
||||
<el-form-item :label="`数量(${packItem.unitName})`" prop="number">
|
||||
<!-- <el-input v-model="packNumberForm.number"
|
||||
:placeholder="`最多输入${+packItem.number}${packItem.unitName}`" @input="packNumberInput">
|
||||
<template #append>{{ packItem.unitName }}</template>
|
||||
</el-input>
|
||||
<template #append></template>
|
||||
</el-input> -->
|
||||
<el-input-number v-model="packNumberForm.number" :min="1"
|
||||
:max="+packItem.number"></el-input-number>
|
||||
</el-form-item>
|
||||
</el-form>
|
||||
</div>
|
||||
|
|
@ -347,12 +349,17 @@ async function returnOrderItemAjax(num = 1) {
|
|||
function packHandle() {
|
||||
let item = goodsStore.cartList[goodsStore.cartActiveIndex]
|
||||
if (item && item.id) {
|
||||
if (item.number > 1) {
|
||||
// 大于1时需要编辑
|
||||
showPackModal.value = true
|
||||
if (!item.pack_number || item.pack_number <= 0) {
|
||||
if (item.number > 1) {
|
||||
// 大于1时需要编辑
|
||||
showPackModal.value = true
|
||||
} else {
|
||||
// 小于1时直接提交
|
||||
goodsStore.operateCart({ ...item, pack_number: item.number }, 'edit')
|
||||
}
|
||||
} else {
|
||||
// 小于1时直接提交
|
||||
goodsStore.operateCart({ ...item, pack_number: item.number }, 'edit')
|
||||
// 取消打包
|
||||
goodsStore.operateCart({ ...item, pack_number: 0 }, 'edit')
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -576,14 +583,9 @@ function validatePackNumber(rule, value, callback) {
|
|||
}
|
||||
}
|
||||
|
||||
function packNumberInput(e) {
|
||||
setTimeout(() => {
|
||||
packNumberForm.value.number = inputFilterFloat(e)
|
||||
}, 50)
|
||||
}
|
||||
|
||||
// modal打开时
|
||||
function packModalOpen() {
|
||||
packNumberForm.value.number = 1
|
||||
packItem.value = goodsStore.cartList[goodsStore.cartActiveIndex]
|
||||
}
|
||||
|
||||
|
|
@ -616,6 +618,10 @@ function packFormSubmit() {
|
|||
background-color: #efefef;
|
||||
border-radius: 6px;
|
||||
|
||||
&:active {
|
||||
background-color: #d3d3d3;
|
||||
}
|
||||
|
||||
&.disabled {
|
||||
|
||||
.t {
|
||||
|
|
|
|||
|
|
@ -31,8 +31,8 @@ const dialogVisible = ref(false)
|
|||
|
||||
// 恢复挂单
|
||||
async function select(item) {
|
||||
await goodsStore.recoverPending(item)
|
||||
dialogVisible.value = false
|
||||
await goodsStore.recoverPending(item)
|
||||
}
|
||||
|
||||
function show() {
|
||||
|
|
|
|||
|
|
@ -190,7 +190,10 @@ async function printOrderLable(isBefore = false) {
|
|||
if (printStore.deviceNoteList.length) {
|
||||
// 使用本地打印机打印
|
||||
const data = await getOrderByIdAjax(goodsStore.orderListInfo.id);
|
||||
printStore.labelPrint(commOrderPrintData(data))
|
||||
if (!isBefore) {
|
||||
// 预结算不打印标签
|
||||
printStore.labelPrint(commOrderPrintData(data))
|
||||
}
|
||||
printStore.pushReceiptData(commOrderPrintData({ ...data, isBefore: isBefore }));
|
||||
} else {
|
||||
// 本地没有可用打印机使用云打印机
|
||||
|
|
|
|||
|
|
@ -225,7 +225,7 @@ const createOrderLoading = ref(false);
|
|||
function selectUser(row) {
|
||||
goodsStore.vipUserInfo = { ...row }
|
||||
if (store.shopInfo.isMemberPrice && row.isVip) {
|
||||
goodsStore.showVipPrice = true
|
||||
goodsStore.showVipPrice = 1
|
||||
goodsStore.calcCartInfo()
|
||||
}
|
||||
}
|
||||
|
|
@ -339,7 +339,7 @@ function showTableMerging() {
|
|||
// 清除会员与会员价
|
||||
function clearVipUserHandle() {
|
||||
goodsStore.vipUserInfo = ''
|
||||
goodsStore.showVipPrice = false
|
||||
goodsStore.showVipPrice = 0
|
||||
goodsStore.calcCartInfo()
|
||||
}
|
||||
</script>
|
||||
|
|
|
|||
|
|
@ -17,9 +17,9 @@
|
|||
<div class="btm" style="width: 80px;">
|
||||
<el-button type="primary"
|
||||
v-if="item.bizCode == 'cashIn' || item.bizCode == 'wechatIn' || item.bizCode == 'alipayIn'"
|
||||
@click="showRefundHandle(item)" :disabled="item.refundAmount > 0">
|
||||
<template v-if="item.refundAmount == 0">退款</template>
|
||||
<template v-if="item.refundAmount > 0">已退</template>
|
||||
@click="showRefundHandle(item)" :disabled="item.amount == item.refundAmount">
|
||||
<template v-if="item.refundAmount < item.amount">退款</template>
|
||||
<template v-if="item.amount == item.refundAmount">已退</template>
|
||||
</el-button>
|
||||
</div>
|
||||
</div>
|
||||
|
|
@ -221,7 +221,7 @@ async function passwordSuccess(e = '') {
|
|||
showDialog.value = false
|
||||
loading.value = false
|
||||
emits('refund')
|
||||
// memberqueryMemberAccountAjax()
|
||||
memberqueryMemberAccountAjax()
|
||||
} catch (error) {
|
||||
loading.value = false
|
||||
console.log(error);
|
||||
|
|
|
|||
|
|
@ -31,7 +31,7 @@
|
|||
</template>
|
||||
</el-table-column>
|
||||
<el-table-column label="手机" prop="phone" width="150"></el-table-column>
|
||||
<el-table-column label="性别" prop="sex" width="80">
|
||||
<el-table-column label="性别" prop="sex">
|
||||
<template v-slot="scope">
|
||||
{{ scope.row.sex == 1 ? '男' : '女' }}
|
||||
</template>
|
||||
|
|
|
|||
|
|
@ -4,34 +4,34 @@
|
|||
<h4>订单号:{{ item.orderNo }}</h4>
|
||||
</template>
|
||||
<template #default>
|
||||
<div class="order_info">
|
||||
<!-- <div class="row"><span>订单类型:</span>{{ filterLable('orderType', item.orderType) }}</div>
|
||||
<!-- <div class="order_info">
|
||||
<div class="row"><span>订单类型:</span>{{ filterLable('orderType', item.orderType) }}</div>
|
||||
<div class="row"><span>平台类型:</span>{{ filterLable('platformType', item.platformType) }}</div>
|
||||
<div class="row"><span>用餐模式:</span>{{ filterLable('dineMode', item.dineMode) }}</div>
|
||||
<div class="row"><span>订单备注:</span>{{ item.remark }}</div> -->
|
||||
<!-- <div class="row"><span>支付类型:</span>{{ filterLable('payType', item.payType) }}</div>
|
||||
<div class="row"><span>订单备注:</span>{{ item.remark }}</div>
|
||||
<div class="row"><span>支付类型:</span>{{ filterLable('payType', item.payType) }}</div>
|
||||
<div class="row"><span>支付单号:</span>{{ item.payOrderNo }}</div>
|
||||
<div class="row"><span>支付金额:</span>¥{{ item.payAmount }}</div>
|
||||
<div class="row"><span>支付时间:</span>{{ item.paidTime }}</div>
|
||||
<div class="row"><span>订单金额(含折扣):</span>¥{{ item.orderAmount }}</div>
|
||||
<div class="row"><span>订单原金额(不含折扣):</span>¥{{ item.originAmount }}</div> -->
|
||||
</div>
|
||||
<div class="row"><span>订单原金额(不含折扣):</span>¥{{ item.originAmount }}</div>
|
||||
</div> -->
|
||||
<div class="table">
|
||||
<div class="tab_head">
|
||||
<el-radio-group v-model="refundType" @change="refundTypeChange">
|
||||
<el-radio-button label="整单退" :value="1" />
|
||||
<el-radio-button label="部分退" :value="2" />
|
||||
<el-radio-button label="自定义" :value="3" />
|
||||
<!-- <el-radio-button label="自定义" :value="3" /> -->
|
||||
</el-radio-group>
|
||||
<div class="amount">
|
||||
<el-input v-model="customAmount" v-if="refundType == 3" style="width: 370px;height: 42px;"
|
||||
placeholder="请输入退款金额" @input="inputChange">
|
||||
<el-input v-model="refundAmount" style="width: 370px;height: 42px;" placeholder="请输入退款金额"
|
||||
@input="inputChange">
|
||||
<template #prepend>¥</template>
|
||||
<template #append>最多可退¥{{ formatDecimal(item.payAmount - item.refundAmount, 2) }}</template>
|
||||
</el-input>
|
||||
<template v-else>
|
||||
<!-- <template>
|
||||
退款金额:¥{{ formatDecimal(refundType == 1 ? item.originAmount - item.refundAmount : amount) }}
|
||||
</template>
|
||||
</template> -->
|
||||
</div>
|
||||
</div>
|
||||
<el-table ref="tableRef" :data="item.onGoods" brder stripe @selection-change="tabSelectChange">
|
||||
|
|
@ -45,7 +45,7 @@
|
|||
<span>{{ scope.row.productName }}</span>
|
||||
</div>
|
||||
<div class="sku" v-if="scope.row.skuName">{{ scope.row.skuName }}</div>
|
||||
<div class="sku">¥{{ formatDecimal(+scope.row.payAmount) }}</div>
|
||||
<div class="sku">¥{{ formatDecimal(+scope.row.unitPrice) }}</div>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
|
@ -58,7 +58,8 @@
|
|||
</el-table-column>
|
||||
<el-table-column label="退款数量" width="170">
|
||||
<template v-slot="scope">
|
||||
<el-input-number v-model="scope.row.refund_number" :min="1" :max="scope.row.num"
|
||||
<el-input-number v-model="scope.row.refund_number" :disabled="refundType == 1" :min="0"
|
||||
:max="formatDecimal(scope.row.num - scope.row.refundNum - scope.row.returnNum, 2, true)"
|
||||
style="width: 130px;" @change="numberChange">
|
||||
</el-input-number>
|
||||
</template>
|
||||
|
|
@ -76,7 +77,7 @@
|
|||
<span>{{ scope.row.productName }}</span>
|
||||
</div>
|
||||
<div class="sku" v-if="scope.row.skuName">{{ scope.row.skuName }}</div>
|
||||
<div class="sku">¥{{ formatDecimal(+scope.row.payAmount) }}</div>
|
||||
<div class="sku">¥{{ formatDecimal(+scope.row.unitPrice) }}</div>
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
|
|
@ -98,7 +99,7 @@
|
|||
</el-table>
|
||||
</template>
|
||||
<div class="ipt">
|
||||
<el-input type="textarea" rows="4" v-model="remark" placeholder="请输入退单原因" />
|
||||
<el-input type="textarea" :rows="4" v-model="remark" placeholder="请输入退单原因" />
|
||||
</div>
|
||||
<div class="remark_tag">
|
||||
<div class="item" v-for="(item, index) in remarkTagList" :key="index" @click="addRmarkHandle(item)">
|
||||
|
|
@ -122,6 +123,7 @@
|
|||
</template>
|
||||
|
||||
<script setup>
|
||||
import _ from 'lodash'
|
||||
import { ref } from 'vue'
|
||||
import { useGlobal } from '@/store/global.js'
|
||||
import { formatDecimal, inputFilterFloat } from "@/utils/index.js";
|
||||
|
|
@ -140,8 +142,7 @@ const isShow = ref(false)
|
|||
const item = ref({})
|
||||
const tableRef = ref(null)
|
||||
const modify = ref(false)
|
||||
const amount = ref(0)
|
||||
const customAmount = ref('')
|
||||
const refundAmount = ref('')
|
||||
const refundType = ref(1)
|
||||
const remark = ref('')
|
||||
const remarkTagList = ref([
|
||||
|
|
@ -166,11 +167,7 @@ function handleRefund() {
|
|||
async function refundHandle(cash = false) {
|
||||
try {
|
||||
let rows = tableRef.value.getSelectionRows()
|
||||
|
||||
if (refundType.value == 1) {
|
||||
tableRef.value.clearSelection()
|
||||
tableRef.value.toggleAllSelection()
|
||||
} else if (refundType.value == 2) {
|
||||
if (refundType.value == 2) {
|
||||
if (!rows.length) {
|
||||
ElNotification({
|
||||
title: '错误',
|
||||
|
|
@ -179,15 +176,24 @@ async function refundHandle(cash = false) {
|
|||
})
|
||||
return
|
||||
}
|
||||
} else if (refundType.value == 3) {
|
||||
if (!customAmount.value) {
|
||||
ElNotification({
|
||||
title: '错误',
|
||||
message: '请请输入退款金额',
|
||||
type: 'error',
|
||||
})
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
if (!refundAmount.value) {
|
||||
ElNotification({
|
||||
title: '错误',
|
||||
message: '请请输入退款金额',
|
||||
type: 'error',
|
||||
})
|
||||
return
|
||||
}
|
||||
|
||||
if (!remark.value) {
|
||||
ElNotification({
|
||||
title: '错误',
|
||||
message: '请请输入退款原因',
|
||||
type: 'error',
|
||||
})
|
||||
return
|
||||
}
|
||||
|
||||
let refundDetails = []
|
||||
|
|
@ -201,22 +207,7 @@ async function refundHandle(cash = false) {
|
|||
})
|
||||
}
|
||||
|
||||
let refundAmount = ''
|
||||
switch (refundType.value) {
|
||||
case 1:
|
||||
refundAmount = item.value.orderAmount
|
||||
break;
|
||||
case 2:
|
||||
refundAmount = amount.value
|
||||
break;
|
||||
case 3:
|
||||
refundAmount = customAmount.value
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
if (refundAmount <= 0) {
|
||||
if (refundAmount.value <= 0) {
|
||||
ElNotification({
|
||||
title: '错误',
|
||||
message: '无可退金额',
|
||||
|
|
@ -227,7 +218,7 @@ async function refundHandle(cash = false) {
|
|||
|
||||
let data = {
|
||||
orderId: item.value.id,
|
||||
refundAmount: refundAmount,
|
||||
refundAmount: formatDecimal(+refundAmount.value),
|
||||
modify: modify.value,
|
||||
cash: cash,
|
||||
refundReason: remark.value,
|
||||
|
|
@ -259,7 +250,7 @@ async function printRefund(rows) {
|
|||
shop_name: store.shopInfo.shopName,
|
||||
loginAccount: store.userInfo.name,
|
||||
carts: [],
|
||||
amount: item.value.orderAmount,
|
||||
amount: formatDecimal(+refundAmount.value),
|
||||
remark: item.value.remark,
|
||||
orderInfo: item.value,
|
||||
outNumber: item.value.id,
|
||||
|
|
@ -273,8 +264,8 @@ async function printRefund(rows) {
|
|||
name: item.productName,
|
||||
number: item.num,
|
||||
skuName: item.skuName,
|
||||
salePrice: formatDecimal(item.payAmount / item.num),
|
||||
totalAmount: formatDecimal(item.payAmount)
|
||||
salePrice: formatDecimal(+item.unitPrice),
|
||||
totalAmount: formatDecimal(+item.payAmount)
|
||||
}
|
||||
)
|
||||
})
|
||||
|
|
@ -301,12 +292,18 @@ function numberChange() {
|
|||
}
|
||||
|
||||
// 选择退款项
|
||||
function tabSelectChange(val) {
|
||||
amount.value = 0
|
||||
const tabSelectChange = _.debounce(function (val) {
|
||||
refundAmount.value = ''
|
||||
let num = 0
|
||||
val.map(item => {
|
||||
amount.value += item.refund_number * item.payAmount
|
||||
if ((+item.refundNum + +item.returnNum) < item.num) {
|
||||
num += item.refund_number * item.unitPrice
|
||||
}
|
||||
})
|
||||
}
|
||||
if (num) {
|
||||
refundAmount.value = formatDecimal(num)
|
||||
}
|
||||
}, 100)
|
||||
|
||||
// 禁用所有行的选择
|
||||
const selectable = (row, index) => {
|
||||
|
|
@ -316,23 +313,26 @@ const selectable = (row, index) => {
|
|||
// 初始化抽屉
|
||||
function resetDrawer() {
|
||||
modify.value = false
|
||||
amount.value = 0
|
||||
customAmount.value = ''
|
||||
refundAmount.value = ''
|
||||
refundType.value = 1
|
||||
remark.value = ''
|
||||
}
|
||||
|
||||
function show(row) {
|
||||
resetDrawer()
|
||||
|
||||
isShow.value = true
|
||||
item.value = { ...row }
|
||||
let newRow = { ...row }
|
||||
remark.value = ''
|
||||
|
||||
let onGoods = []
|
||||
let returnGoods = []
|
||||
item.value.goods.map(item => {
|
||||
newRow.goods.map(item => {
|
||||
// 可退的最大数量,下单数量 - 已退数量 - 退菜数量
|
||||
let refundMaxNum = item.num - item.refundNum - item.returnNum
|
||||
|
||||
if (refundMaxNum <= 0) {
|
||||
item.refund_number = item.num
|
||||
// 已经退过,不在允许操作
|
||||
returnGoods.push(item)
|
||||
} else {
|
||||
|
|
@ -342,13 +342,10 @@ function show(row) {
|
|||
}
|
||||
})
|
||||
|
||||
item.value.onGoods = onGoods
|
||||
item.value.returnGoods = returnGoods
|
||||
newRow.onGoods = onGoods
|
||||
newRow.returnGoods = returnGoods
|
||||
|
||||
console.log('item.value===', item.value);
|
||||
|
||||
|
||||
resetDrawer()
|
||||
item.value = newRow
|
||||
|
||||
setTimeout(() => {
|
||||
tableRef.value.clearSelection()
|
||||
|
|
@ -372,16 +369,20 @@ function refundTypeChange(val) {
|
|||
case 1:
|
||||
modify.value = false
|
||||
// tableRef.value.toggleAllSelection()
|
||||
|
||||
// 遍历数据,将每一行设置为选中状态
|
||||
item.value.goods.forEach((row) => {
|
||||
item.value.onGoods.forEach((row) => {
|
||||
tableRef.value.toggleRowSelection(row, true);
|
||||
});
|
||||
|
||||
break;
|
||||
case 2:
|
||||
modify.value = false
|
||||
tableRef.value.clearSelection()
|
||||
if (item.value.onGoods.length == 1) {
|
||||
item.value.onGoods.forEach((row) => {
|
||||
tableRef.value.toggleRowSelection(row, true);
|
||||
});
|
||||
} else {
|
||||
tableRef.value.clearSelection()
|
||||
}
|
||||
break;
|
||||
case 3:
|
||||
modify.value = true
|
||||
|
|
@ -392,15 +393,13 @@ function refundTypeChange(val) {
|
|||
}
|
||||
|
||||
// 自定义退款金额输入
|
||||
function inputChange(n) {
|
||||
setTimeout(() => {
|
||||
if (n > item.value.payAmount - item.value.refundAmount) {
|
||||
customAmount.value = formatDecimal(item.value.payAmount - item.value.refundAmount, 2)
|
||||
} else {
|
||||
customAmount.value = inputFilterFloat(n)
|
||||
}
|
||||
}, 100)
|
||||
}
|
||||
const inputChange = _.debounce(function (n) {
|
||||
if (n > item.value.payAmount - item.value.refundAmount) {
|
||||
refundAmount.value = formatDecimal(item.value.payAmount - item.value.refundAmount, 2)
|
||||
} else {
|
||||
refundAmount.value = inputFilterFloat(n)
|
||||
}
|
||||
}, 300)
|
||||
|
||||
// 添加备注
|
||||
function addRmarkHandle(item) {
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@
|
|||
<div class="table_wrap">
|
||||
<div class="table">
|
||||
<el-table :data="tableData.list" v-loading="tableData.loading" border strip height="100%">
|
||||
<el-table-column label="台桌" prop="tableName" width="80" align="center">
|
||||
<el-table-column label="台桌" prop="tableName" align="center">
|
||||
<template v-slot="scope">
|
||||
<span v-if="scope.row.tableName">{{ scope.row.tableName }}</span>
|
||||
<span v-else>无</span>
|
||||
|
|
@ -76,11 +76,31 @@
|
|||
<div class="column">
|
||||
<div class="row">
|
||||
<el-button type="warning" :disabled="scope.row.status != 'unpaid'" :loading="scope.row.payLoading"
|
||||
@click="orderDoneHandle(scope.row)">结算订单</el-button>
|
||||
@click="orderDoneHandle(scope.row)">
|
||||
<template v-if="scope.row.status == 'unpaid'">
|
||||
结算订单
|
||||
</template>
|
||||
<template v-else>
|
||||
订单完成
|
||||
</template>
|
||||
</el-button>
|
||||
</div>
|
||||
<div class="row">
|
||||
<el-button type="primary" :disabled="refundState(scope.row.status)"
|
||||
@click="RefundDrawerRef.show(scope.row)">订单退款</el-button>
|
||||
<el-button type="primary" :disabled="refundState(scope.row)" @click="RefundDrawerRef.show(scope.row)">
|
||||
<template v-if="scope.row.status == 'done'">
|
||||
订单退款
|
||||
</template>
|
||||
<template
|
||||
v-else-if="scope.row.status == 'part_refund' || (scope.row.status == 'refund' && scope.row.refundAmount < scope.row.payAmount)">
|
||||
部分退单
|
||||
</template>
|
||||
<template v-else-if="scope.row.status == 'refund'">
|
||||
已退订单
|
||||
</template>
|
||||
<template v-else>
|
||||
不可退单
|
||||
</template>
|
||||
</el-button>
|
||||
</div>
|
||||
<div class="row">
|
||||
<el-button type="success" @click="PrintDrawerRef.show(scope.row)">
|
||||
|
|
@ -173,8 +193,8 @@ function filterLable(key, type) {
|
|||
}
|
||||
|
||||
// 过滤退款条件
|
||||
function refundState(state) {
|
||||
switch (state) {
|
||||
function refundState(row) {
|
||||
switch (row.status) {
|
||||
case 'unpaid':
|
||||
return true;
|
||||
case 'in-production':
|
||||
|
|
@ -186,7 +206,11 @@ function refundState(state) {
|
|||
case 'refunding':
|
||||
return false;
|
||||
case 'refund':
|
||||
return true;
|
||||
if (row.refundAmount < row.payAmount) {
|
||||
return false
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
case 'part-refund':
|
||||
return false;
|
||||
case 'cancelled':
|
||||
|
|
|
|||
Loading…
Reference in New Issue