|
@@ -1,3 +1,7 @@
|
|
|
|
|
+<!--
|
|
|
|
|
+ 上游采购售后页
|
|
|
|
|
+ 用途:对 xhGhsCgOrder 申请退货退款;支持当天减实付 / 隔天不减实付(sameDay)。
|
|
|
|
|
+-->
|
|
|
<template>
|
|
<template>
|
|
|
<view class="app-content">
|
|
<view class="app-content">
|
|
|
<view class="flex refund-item">
|
|
<view class="flex refund-item">
|
|
@@ -40,8 +44,9 @@
|
|
|
<view class="flex refund-item">
|
|
<view class="flex refund-item">
|
|
|
<view class="refund-label">订单金额:</view>
|
|
<view class="refund-label">订单金额:</view>
|
|
|
<view class="list">
|
|
<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>
|
|
</view>
|
|
|
<view class="flex refund-item">
|
|
<view class="flex refund-item">
|
|
@@ -64,16 +69,27 @@
|
|
|
<view class="flex-center btn" @tap="cancelRefund">取消</view>
|
|
<view class="flex-center btn" @tap="cancelRefund">取消</view>
|
|
|
<view class="flex-center btn active" @tap="confirmRefund" style="margin-left: 80upx">确定</view>
|
|
<view class="flex-center btn active" @tap="confirmRefund" style="margin-left: 80upx">确定</view>
|
|
|
</view>
|
|
</view>
|
|
|
|
|
+
|
|
|
|
|
+ <!-- 隔天售后确认:不减实付,退回采购账户余额 -->
|
|
|
|
|
+ <forward-options-popup
|
|
|
|
|
+ :show="showForwardPop"
|
|
|
|
|
+ mode="purchase"
|
|
|
|
|
+ :order-cleared="orderCleared"
|
|
|
|
|
+ @cancel="showForwardPop = false"
|
|
|
|
|
+ @confirm="onForwardConfirm"
|
|
|
|
|
+ />
|
|
|
</view>
|
|
</view>
|
|
|
</template>
|
|
</template>
|
|
|
<script>
|
|
<script>
|
|
|
import TuiListCell from "@/components/plugin/list-cell";
|
|
import TuiListCell from "@/components/plugin/list-cell";
|
|
|
import { getPurchaseDetailApi } from "@/api/purchase";
|
|
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 {
|
|
export default {
|
|
|
name: "refund",
|
|
name: "refund",
|
|
|
components: {
|
|
components: {
|
|
|
- TuiListCell
|
|
|
|
|
|
|
+ TuiListCell,
|
|
|
|
|
+ ForwardOptionsPopup
|
|
|
},
|
|
},
|
|
|
data() {
|
|
data() {
|
|
|
return {
|
|
return {
|
|
@@ -82,7 +98,12 @@ export default {
|
|
|
refundType:1,
|
|
refundType:1,
|
|
|
remark:'',
|
|
remark:'',
|
|
|
orderInfo:{},
|
|
orderInfo:{},
|
|
|
- couldRefundPrice:0
|
|
|
|
|
|
|
+ couldRefundPrice:0,
|
|
|
|
|
+ // 隔天售后预检
|
|
|
|
|
+ nextDayEligible: false,
|
|
|
|
|
+ showForwardPop: false,
|
|
|
|
|
+ orderCleared: false,
|
|
|
|
|
+ _pendingRefundParams: null
|
|
|
};
|
|
};
|
|
|
},
|
|
},
|
|
|
onShow() {
|
|
onShow() {
|
|
@@ -153,35 +174,110 @@ export default {
|
|
|
uni.showToast({title:'请选择花材',icon:'none'})
|
|
uni.showToast({title:'请选择花材',icon:'none'})
|
|
|
return;
|
|
return;
|
|
|
}
|
|
}
|
|
|
- let refundParams = {
|
|
|
|
|
|
|
+ if (!this.hasValidEntryTime()) {
|
|
|
|
|
+ uni.showToast({ title: '订单无入库时间,不能售后', icon: 'none' })
|
|
|
|
|
+ return
|
|
|
|
|
+ }
|
|
|
|
|
+ this._pendingRefundParams = {
|
|
|
id:this.orderInfo.id,
|
|
id:this.orderInfo.id,
|
|
|
product:JSON.stringify(product),
|
|
product:JSON.stringify(product),
|
|
|
price:this.refundMoney,
|
|
price:this.refundMoney,
|
|
|
remark:this.remark,
|
|
remark:this.remark,
|
|
|
refundType:this.refundType
|
|
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() {
|
|
async init() {
|
|
|
-
|
|
|
|
|
const res = await getPurchaseDetailApi(this.option.orderSn)
|
|
const res = await getPurchaseDetailApi(this.option.orderSn)
|
|
|
this.orderInfo = res.data
|
|
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=>{
|
|
this.product = res.data.itemInfo.map(ele=>{
|
|
|
return {...ele,refundCount:null}
|
|
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>
|