Преглед изворни кода

Merge branch 'master' of http://39.101.143.165:8090/hxl13994548489/LocalLivingServicesUniapp

baijunde пре 2 недеља
родитељ
комит
533f0f29c4

+ 8 - 0
api/merchantDish.js

@@ -203,6 +203,14 @@ const api = {
 		})
 	},
 
+	/** 商户端预约单批量直接退款(一次请求,后端逐用户订单处理) */
+	packageOrderReservationDirectRefundBatch(hostOrderId, userOrderIds) {
+		return http.post('/groupmeal/merchantPackageOrder/reservation/directRefundBatch', {
+			hostOrderId,
+			userOrderIds
+		})
+	},
+
 	/** 商户团餐订单出餐 */
 	packageOrderReady(orderId) {
 		return http.get('/groupmeal/merchantPackageOrder/orderReady', {

+ 16 - 9
pages/merchantDish/orders/order-details.vue

@@ -86,7 +86,7 @@
 		<view v-if="refundVisible" class="refund-mask" @click.self="closeRefundModal">
 			<view class="refund-dialog" @click.stop>
 				<text class="refund-title">提示</text>
-				<text class="refund-message">是否要发起退款</text>
+				<text class="refund-message">确认对{{ refundTargets.length }}个用户订单发起退款吗</text>
 				<view class="refund-actions">
 					<view class="refund-action cancel" @click="closeRefundModal">取消</view>
 					<view class="refund-action confirm" @click="confirmRefund">确定</view>
@@ -151,7 +151,8 @@ export default {
 			})
 		},
 		getItemKey(item, index) {
-			return item.merchantOrderPackageId || item.userOrderId || item.packageId || `item-${index}`
+			// 预约单退款的业务粒度是用户子订单;同一用户有多个套餐时必须一起选中。
+			return item.userOrderId || item.merchantOrderPackageId || item.packageId || `item-${index}`
 		},
 		isSelected(item, index) {
 			return this.selectedKeys.includes(this.getItemKey(item, index))
@@ -167,19 +168,19 @@ export default {
 				this.selectedKeys = []
 				return
 			}
-			this.selectedKeys = this.items.map((item, index) => this.getItemKey(item, index))
+			this.selectedKeys = [...new Set(this.items.map((item, index) => this.getItemKey(item, index)))]
 		},
 		handleRefund() {
 			const selected = this.items.filter((item, index) => this.isSelected(item, index))
 			if (!selected.length) {
-				uni.showToast({ title: '请选择要退款的套餐', icon: 'none' })
+				uni.showToast({ title: '请选择要退款的用户订单', icon: 'none' })
 				return
 			}
-			if (selected.some(item => !item.userOrderId)) {
+			if (selected.some((item) => !item.userOrderId)) {
 				uni.showToast({ title: '退款缺少用户子订单号', icon: 'none' })
 				return
 			}
-			this.refundTargets = selected
+			this.refundTargets = [...new Set(selected.map((item) => item.userOrderId))]
 			this.refundVisible = true
 		},
 		closeRefundModal() {
@@ -190,16 +191,22 @@ export default {
 		confirmRefund() {
 			if (!this.refundTargets.length || this.refundSubmitting) return
 			this.refundSubmitting = true
-			const userOrderIds = this.refundTargets.map(item => item.userOrderId)
-			merchantDishApi.packageOrderDirectRefund(userOrderIds).then((res) => {
+			merchantDishApi.packageOrderReservationDirectRefundBatch(
+				this.hostOrderId,
+				this.refundTargets
+			).then((res) => {
 				if (res.data.code !== 200) {
 					uni.showToast({ title: res.data.message || '退款失败', icon: 'none' })
 					return
 				}
+				const result = res.data.result || {}
 				this.refundVisible = false
 				this.refundTargets = []
 				this.selectedKeys = []
-				uni.showToast({ title: res.data.message || '退款成功', icon: 'success' })
+				uni.showToast({
+					title: res.data.message || '退款已受理',
+					icon: Number(result.rejectedCount || 0) > 0 ? 'none' : 'success'
+				})
 				this.loadDetail()
 			}).catch(() => {
 				uni.showToast({ title: '退款失败', icon: 'none' })

+ 3 - 0
pages/merchantDish/orders/refund-details.vue

@@ -187,6 +187,9 @@ export default {
 			if (this.product.boxFee != null) return this.product.boxFee
 			return Number(this.product.boxPrice || 0) * this.quantity
 		},
+		containerFeeExcluded() {
+			return this.product.containerFeeExcluded === true
+		},
 		userPhone() {
 			return this.product.phone || this.product.maskedPhone || this.product.mobile || ''
 		},

+ 5 - 2
pages/merchantDish/orders/refund-record.vue

@@ -36,7 +36,7 @@
 						<text class="refund-label">退款金额</text>
 						<text class="refund-currency">¥</text>
 						<text class="refund-value">{{ formatMoney(refundAmount) }}</text>
-						<text class="refund-note">不包含餐盒费</text>
+						<text v-if="containerFeeExcluded" class="refund-note">不包含餐盒费</text>
 					</view>
 				</view>
 			</view>
@@ -189,11 +189,14 @@ export default {
 			if (this.data.boxFee != null) return this.data.boxFee
 			return Number(this.data.boxPrice || 0) * this.quantity
 		},
+		containerFeeExcluded() {
+			return this.data.containerFeeExcluded === true
+		},
 		userPhone() {
 			return this.data.phone || this.data.maskedPhone || this.data.mobile || ''
 		},
 		showActions() {
-			return this.data.orderStatusName === '售后申请中' || Number(this.data.fundStatus) === 2
+			return this.data.merchantReviewable === true
 		}
 	},
 	onLoad(query) {