فهرست منبع

采购单隔天售后

shish 10 ساعت پیش
والد
کامیت
1b5314f315

+ 1 - 1
ghsApp/src/admin/stat/profit.vue

@@ -13,7 +13,7 @@
 							<t-th>金额</t-th>
 						</t-tr>
 						<block v-for="(item, inIndex) in profit.income" :key="inIndex">
-							<t-tr v-if="Number(item.amount)>0">
+							<t-tr v-if="Number(item.amount)!=0">
 								<t-td><view style="color:black;font-size:30upx;">{{item.name}}</view></t-td>
 								<t-td><view style="color:black;font-size:30upx;">{{item.amount}}</view></t-td>
 							</t-tr>

+ 6 - 1
ghsApp/src/api/cg-refund/index.js

@@ -10,4 +10,9 @@ export const getRefundList = data => {
 
 export const getRefundFullInfo = data => {
 	return https.get('/cg-refund/get-refund-full-info', data)
-}
+}
+
+/** 采购原单是否可走隔天售后(售后页预检) */
+export const checkNextDayEligible = data => {
+	return https.get('/cg-refund/check-next-day-eligible', data)
+}

+ 8 - 1
ghsApp/src/components/forward-options-popup.vue

@@ -1,6 +1,7 @@
 <!--
   隔天售后确认弹框
   用途:隔天/已结账售后二次确认;资金默认原路,不再选手选 fundType。
+  mode=purchase:上游采购文案(退回采购账户余额)
 -->
 <template>
 	<view v-if="show" class="mask" @click="onCancel">
@@ -22,7 +23,7 @@ export default {
 		show: { type: Boolean, default: false },
 		// 已结账单当天售后也走隔天口径
 		orderCleared: { type: Boolean, default: false },
-		// free=无原单退款文案(兼容旧调用)
+		// free=无原单退款;purchase=上游采购隔天
 		mode: { type: String, default: '' }
 	},
 	computed: {
@@ -30,6 +31,12 @@ export default {
 			if (this.mode === 'free') {
 				return '无关联销售单:退货回库;资金请在成功页确认按原路退回或返充余额。'
 			}
+			if (this.mode === 'purchase') {
+				if (this.orderCleared) {
+					return '采购单已结清,本次售后不减实付,只会算作今天退款;金额将退回采购账户余额。'
+				}
+				return '本次售后不减采购实付,只会算作今天退款;金额将退回采购账户余额。'
+			}
 			if (this.orderCleared) {
 				return '订单已结账,本次售后不减订单实付,只会算作今天退款;资金将原路退回。'
 			}

+ 20 - 8
ghsApp/src/pagesPurchase/info.vue

@@ -55,10 +55,11 @@
 					<view>{{ detailInfo.status==1?'待确认' :detailInfo.status==2?'待发货' :detailInfo.status==3?'待入库' :detailInfo.status==4?'已入库' :'已取消' }}</view>
 				</view>
 
-				<view v-if="detailInfo.refund == 2" class="order-info_box">
+				<!-- 累计退款 = 当天 tkPrice + 隔天 nextDayTkPrice -->
+				<view v-if="detailInfo.refund == 2 || Number(detailInfo.nextDayTkPrice)>0" class="order-info_box">
 					<view style="color:red;font-weight:bold;">累计退款:</view>
-					<view style="color:red;font-weight:bold;font-size:30upx;">¥{{detailInfo.tkPrice?parseFloat(detailInfo.tkPrice):0}}</view>
-					<view class="price" v-if="detailInfo.refund==2">
+					<view style="color:red;font-weight:bold;font-size:30upx;">¥{{ totalRefundPrice }}</view>
+					<view class="price">
 						<text @click="pageTo({url: '/pagesPurchase/refundList',query: {orderSn: detailInfo.orderSn}})" style="font-weight:normal;color:#3385FF;">售后记录</text>
 					</view>
 				</view>
@@ -184,9 +185,10 @@
 						<div class="tui-title">总金额</div>
 						<div class="detail-price_box" style="font-size: 30upx;">¥{{ detailInfo.prePrice ? parseFloat(detailInfo.prePrice) : 0 }}</div>
 					</tui-list-cell>
-					<tui-list-cell v-if="detailInfo.refundPrice > 0" class="line-cell" :hover="false">
-						<div class="tui-title">退款金额</div>
-						<div class="detail-price_box red" style="font-size:30upx">-¥{{ detailInfo.tkPrice ? parseFloat(detailInfo.tkPrice) : 0 }}</div>
+					<!-- 金额明细里只展示当天退款(tkPrice),隔天不减实付故不进此行 -->
+					<tui-list-cell v-if="sameDayRefundPrice > 0" class="line-cell" :hover="false">
+						<div class="tui-title">当天退款</div>
+						<div class="detail-price_box red" style="font-size:30upx">-¥{{ sameDayRefundPrice }}</div>
 					</tui-list-cell>
 					<tui-list-cell v-if="detailInfo.discountAmount > 0" class="line-cell" :hover="false">
 						<div class="tui-title">减免</div>
@@ -340,6 +342,16 @@ export default {
 	computed: {
     	...mapGetters(["getLoginInfo"]),
 		...mapGetters({ dictInfo:"getDictionariesInfo" }),
+		/** 当天退款:仅 tkPrice(减过实付) */
+		sameDayRefundPrice() {
+			return parseFloat(Number(this.detailInfo.tkPrice || 0).toFixed(2))
+		},
+		/** 累计退款:当天 tkPrice + 隔天 nextDayTkPrice */
+		totalRefundPrice() {
+			const tk = Number(this.detailInfo.tkPrice || 0)
+			const next = Number(this.detailInfo.nextDayTkPrice || 0)
+			return parseFloat((tk + next).toFixed(2))
+		}
   	},
 	mixins: [productMins],
 	data() {
@@ -722,8 +734,8 @@ export default {
 			let ghsName = this.detailInfo.ghsName ? this.detailInfo.ghsName : ''
 			let actPrice = this.detailInfo.actPrice ? parseFloat(this.detailInfo.actPrice) : 0
 			this.title = ghsName+' '+this.detailInfo.entryTime.substr(5,11)+' ¥'+actPrice
-			if(this.detailInfo.tkPrice && Number(this.detailInfo.tkPrice)>0){
-				this.title = this.title+' 已退¥'+parseFloat(this.detailInfo.tkPrice)
+			if(this.totalRefundPrice > 0){
+				this.title = this.title+' 已退¥'+this.totalRefundPrice
 			}
 			this.title = this.title+' 核销码'+this.detailInfo.checkCode
 		}

+ 115 - 19
ghsApp/src/pagesPurchase/refund.vue

@@ -1,3 +1,7 @@
+<!--
+  上游采购售后页
+  用途:对 xhGhsCgOrder 申请退货退款;支持当天减实付 / 隔天不减实付(sameDay)。
+-->
 <template>
 	<view class="app-content">
 		<view class="flex refund-item">
@@ -40,8 +44,9 @@
 		<view class="flex refund-item">
 			<view class="refund-label">订单金额:</view>
 			<view class="list">
-				¥{{parseFloat(orderInfo.orderPrice)||0}}
-				<text style="margin-left:25upx;font-size:25upx;color:green;" v-if="Number(orderInfo.tkPrice)>0">已退¥{{orderInfo.tkPrice ? parseFloat(orderInfo.tkPrice) : 0}}</text>
+				¥{{parseFloat(orderInfo.actPrice || orderInfo.orderPrice)||0}}
+				<text style="margin-left:25upx;font-size:25upx;color:green;" v-if="Number(orderInfo.tkPrice)>0">当天已退¥{{orderInfo.tkPrice ? parseFloat(orderInfo.tkPrice) : 0}}</text>
+				<text style="margin-left:15upx;font-size:25upx;color:#e6a23c;" v-if="Number(orderInfo.nextDayTkPrice)>0">隔天已退¥{{parseFloat(orderInfo.nextDayTkPrice)}}</text>
 			</view>
 		</view>
 		<view class="flex refund-item">
@@ -64,16 +69,27 @@
 			<view class="flex-center btn" @tap="cancelRefund">取消</view>
 			<view class="flex-center btn active" @tap="confirmRefund" style="margin-left: 80upx">确定</view>
 		</view>
+
+		<!-- 隔天售后确认:不减实付,退回采购账户余额 -->
+		<forward-options-popup
+			:show="showForwardPop"
+			mode="purchase"
+			:order-cleared="orderCleared"
+			@cancel="showForwardPop = false"
+			@confirm="onForwardConfirm"
+		/>
 	</view>
 </template>
 <script>
 import TuiListCell from "@/components/plugin/list-cell";
 import { getPurchaseDetailApi } from "@/api/purchase";
-import { createOrder } from "@/api/cg-refund"
+import { createOrder, checkNextDayEligible } from "@/api/cg-refund"
+import ForwardOptionsPopup from "@/components/forward-options-popup"
 export default {
 	name: "refund",
 	components: {
-		TuiListCell
+		TuiListCell,
+		ForwardOptionsPopup
 	},
 	data() {
 		return {
@@ -82,7 +98,12 @@ export default {
 			refundType:1,
 			remark:'',
 			orderInfo:{},
-			couldRefundPrice:0
+			couldRefundPrice:0,
+			// 隔天售后预检
+			nextDayEligible: false,
+			showForwardPop: false,
+			orderCleared: false,
+			_pendingRefundParams: null
 		};
 	},
 	onShow() {
@@ -153,35 +174,110 @@ export default {
 				uni.showToast({title:'请选择花材',icon:'none'})
 				return;
 			}
-			let refundParams = {
+			if (!this.hasValidEntryTime()) {
+				uni.showToast({ title: '订单无入库时间,不能售后', icon: 'none' })
+				return
+			}
+			this._pendingRefundParams = {
 				id:this.orderInfo.id,
 				product:JSON.stringify(product),
 				price:this.refundMoney,
 				remark:this.remark,
 				refundType:this.refundType
 			};
-			that.$util.confirmModal({content:'确认申请?'},() => {
-				uni.showLoading({title: "提交中",mask:true})
-				createOrder(refundParams).then(res => {
-					if(res.code == 1){
-						uni.hideLoading()
-						that.$util.pageTo({url:'/pagesPurchase/refundSuccess',type:2})
-					}
-				})
+			// 跨入库日 / 已结清 → 必须隔天售后
+			if (this.nextDayEligible || this.isMustNextDayOrder()) {
+				if (!this.nextDayEligible) {
+					this.orderCleared = Number(this.orderInfo.clearId) > 0 || Number(this.orderInfo.debt) === 2
+				}
+				this.showForwardPop = true
+				return
+			}
+			that.$util.confirmModal({content:'确认申请?提交后将退回采购账户余额'},() => {
+				that.submitRefund(that._pendingRefundParams)
+			})
+		},
+		/** 是否有有效入库时间(与后端 hasValidEntryTime 一致) */
+		hasValidEntryTime() {
+			const entryTime = (this.orderInfo && this.orderInfo.entryTime) || ''
+			return !!entryTime && entryTime !== '0000-00-00 00:00:00'
+		},
+		/**
+		 * 本地判断是否必须隔天售后:非当天入库 / 已结清 / 已进结账单
+		 */
+		isMustNextDayOrder() {
+			const info = this.orderInfo || {}
+			if (!this.hasValidEntryTime()) {
+				return false
+			}
+			if (Number(info.clearId) > 0) {
+				return true
+			}
+			if (Number(info.debt) === 2) {
+				return true
+			}
+			const entryDay = String(info.entryTime).substr(0, 10)
+			const now = new Date()
+			const m = now.getMonth() + 1
+			const d = now.getDate()
+			const today = now.getFullYear() + '-' + (m < 10 ? '0' + m : m) + '-' + (d < 10 ? '0' + d : d)
+			return entryDay !== today
+		},
+		/** 隔天售后确认:写 sameDay=0 */
+		onForwardConfirm() {
+			this.showForwardPop = false
+			const params = Object.assign({}, this._pendingRefundParams || {}, {
+				sameDay: 0
+			})
+			this.submitRefund(params)
+		},
+		submitRefund(refundParams) {
+			const that = this
+			uni.showLoading({title: "提交中",mask:true})
+			createOrder(refundParams).then(res => {
+				uni.hideLoading()
+				if(res.code == 1){
+					that.$util.pageTo({
+						url:'/pagesPurchase/refundSuccess',
+						type:2,
+						query: { tip: encodeURIComponent('已退回采购账户余额') }
+					})
+				}
 			})
 		},
 		async init() {
-
 			const res = await getPurchaseDetailApi(this.option.orderSn)
 			this.orderInfo = res.data
 
-			this.couldRefundPrice = Number(res.data.orderPrice) - Number(res.data.tkPrice)
-			this.couldRefundPrice = this.couldRefundPrice.toFixed(2)
-			this.couldRefundPrice = parseFloat(this.couldRefundPrice)
+			// 可退:隔天用 actPrice-nextDayTkPrice;当天用 realPrice(与后端一致)
+			const nextDay = Number(res.data.nextDayTkPrice || 0)
+			const actPrice = Number(res.data.actPrice || res.data.orderPrice || 0)
+			const realPrice = Number(res.data.realPrice || actPrice)
+			if (this.isMustNextDayOrder()) {
+				this.couldRefundPrice = parseFloat((actPrice - nextDay).toFixed(2))
+			} else {
+				this.couldRefundPrice = parseFloat(realPrice.toFixed(2))
+			}
 
 			this.product = res.data.itemInfo.map(ele=>{
 				return {...ele,refundCount:null}
 			})
+
+			checkNextDayEligible({ orderId: this.orderInfo.id }).then(r => {
+				if (r.code == 1 && r.data && r.data.ok) {
+					this.nextDayEligible = true
+					this.orderCleared = Number(r.data.orderCleared) === 1
+					if (r.data.couldRefundPrice != null) {
+						this.couldRefundPrice = parseFloat(Number(r.data.couldRefundPrice).toFixed(2))
+					}
+				} else {
+					this.nextDayEligible = false
+					this.orderCleared = false
+				}
+			}).catch(() => {
+				this.nextDayEligible = false
+				this.orderCleared = false
+			})
 		}
 	}
 };
@@ -296,4 +392,4 @@ export default {
 			}
 		}
 	}
-</style>
+</style>

+ 9 - 0
ghsApp/src/pagesPurchase/refundSuccess.vue

@@ -1,3 +1,7 @@
+<!--
+  采购售后成功页
+  tip 查询参数可展示「已退回采购账户余额」等说明
+-->
 <template>
   <appResult :title="title">
 	<button class="admin-button-com big blue" style="width:80%;margin-top:50upx;" @click="goBack">返回</button>
@@ -15,6 +19,11 @@ export default {
 			title:'操作成功',
 		};
 	},
+	onLoad(options){
+		if (options && options.tip) {
+			this.title = decodeURIComponent(options.tip) || '操作成功'
+		}
+	},
 	onShow(){
 
 	},