Withdraw Page

This commit is contained in:
Mr Swift
2024-08-25 17:19:25 +03:30
parent b0566dd807
commit 617f596b72
4 changed files with 298 additions and 262 deletions
+1 -1
View File
@@ -358,7 +358,7 @@
<CSidebarNavItem <CSidebarNavItem
v-if="hasPermission('gps')" v-if="hasPermission('gps')"
name="درخواست های برداشت" name="درخواست های برداشت"
:to="{ name: 'admin-admins-admin', params: { admin: 'new' } }" :to="{ name: 'admin-gps-withdraw', query: { filter: 'all' }}"
font-icon="fal fa-credit-card" font-icon="fal fa-credit-card"
:exact="false" :exact="false"
/> />
+1 -1
View File
@@ -218,7 +218,7 @@ export default {
console.log(err) console.log(err)
return this.$message({ return this.$message({
type: 'warning', type: 'warning',
message: err.data.msg message: err.msg
}) })
} }
}) })
+83 -49
View File
@@ -1,5 +1,39 @@
<template> <template>
<div> <div>
<el-dialog title="اطلاعات کاربر" :visible.sync="centerDialogVisible" width="40%" center>
<el-descriptions title="" direction="vertical" :column="4" border>
<el-descriptions-item label="نام و نام خانودگی">{{
requestData.userId?.first_name + ' ' + requestData.userId?.last_name
}}</el-descriptions-item>
<el-descriptions-item label="شماره همراه">{{ requestData.userId?.mobile_number }}</el-descriptions-item>
<el-descriptions-item label="استان">{{ requestData.userId?.province_name }}</el-descriptions-item>
<el-descriptions-item label="شهر">{{ requestData.userId?.city_name }}</el-descriptions-item>
<el-descriptions-item label="کد ملی ">{{ requestData.userId?.national_code }}</el-descriptions-item>
<el-descriptions-item label="نام فروشگاه">{{ requestData.userId?.shopName }}</el-descriptions-item>
</el-descriptions>
<CCardBody>
<el-table :data="[requestData?.card]" style="width: 100%">
<el-table-column type="index" label="#"> </el-table-column>
<el-table-column prop="holderName" label="نام صاحب کارت" width="200px"> </el-table-column>
<el-table-column prop="PAN" label="شماره حساب" width="200px"> </el-table-column>
<el-table-column prop="IBAN" label="شماره شبا" width=""> </el-table-column>
</el-table>
</CCardBody>
<el-input
v-if="requestData.status === 1"
v-model="trackingNumber"
placeholder="شماره پیگیری"
style="display: inline-block; max-width: 500px; margin-top: 8px"
></el-input>
<span slot="footer" class="dialog-footer">
<el-button @click="centerDialogVisible = false">بستن</el-button>
<el-button type="primary" @click="patchIt(requestData._id, requestData.status, {trackingNumber})">{{
requestData.status == 1 ? 'تایید واریز' : 'تایید'
}}</el-button>
</span>
</el-dialog>
<CustomSubHeader> <CustomSubHeader>
<CBreadcrumb class="border-0 mb-0"> دستگاه های نصب شده</CBreadcrumb> <CBreadcrumb class="border-0 mb-0"> دستگاه های نصب شده</CBreadcrumb>
</CustomSubHeader> </CustomSubHeader>
@@ -21,18 +55,15 @@
<CButton color="primary" :class="filterType === 'all' && 'selected'" @click="filterType = 'all'" <CButton color="primary" :class="filterType === 'all' && 'selected'" @click="filterType = 'all'"
>همه</CButton >همه</CButton
> >
<CButton color="danger" :class="filterType === 'rej' && 'selected'" @click="filterType = 'rej'" <CButton color="success" :class="filterType === 'dep' && 'selected'" @click="filterType = 'dep'">
>رد شده</CButton واریز شده</CButton
> >
<CButton <CButton color="success" :class="filterType === 'accept' && 'selected'" @click="filterType = 'accept'"
color="success"
:class="filterType === 'accept' && 'selected'"
@click="filterType = 'accept'"
>تایید شده</CButton >تایید شده</CButton
> >
<CButton color="warning" :class="filterType === 'pend' && 'selected'" @click="filterType = 'pend'" <CButton color="warning" :class="filterType === 'pend' && 'selected'" @click="filterType = 'pend'"
>درانتظار تایید</CButton >درانتظار
> </CButton>
</CButtonGroup> </CButtonGroup>
</CCol> </CCol>
<CCol sm="12"> <CCol sm="12">
@@ -65,12 +96,12 @@
<el-table :data="filteredItems" :row-class-name="hasUnread" style="width: 100%"> <el-table :data="filteredItems" :row-class-name="hasUnread" style="width: 100%">
<el-table-column type="index" label="#"> </el-table-column> <el-table-column type="index" label="#"> </el-table-column>
<el-table-column label=دل" width="150px"> <el-table-column label=بلغ تومانی " width="150px">
<template slot-scope="scope"> <template slot-scope="scope">
{{ scope.row.deviceId.model }} {{ scope.row.amount }}
</template> </template>
</el-table-column> </el-table-column>
<el-table-column prop="IMEI" label=" IMEI" width="150px"> </el-table-column> <el-table-column prop="dollarAmount" label=" مبلغ دلاری" width="150px"> </el-table-column>
<el-table-column label="نام فروشگاه" width=""> <el-table-column label="نام فروشگاه" width="">
<template slot-scope="scope"> <template slot-scope="scope">
@@ -84,7 +115,7 @@
</el-table-column> </el-table-column>
<el-table-column label=" نام و نام خانوادگی" width=""> <el-table-column label=" نام و نام خانوادگی" width="">
<template slot-scope="scope"> <template slot-scope="scope">
{{ scope.row.userId.first_name + " " + scope.row.userId.last_name }} {{ scope.row.userId.first_name + ' ' + scope.row.userId.last_name }}
</template> </template>
</el-table-column> </el-table-column>
<el-table-column label=" شماره همراه" width=""> <el-table-column label=" شماره همراه" width="">
@@ -95,37 +126,21 @@
<el-table-column label="محل سکونت" width=""> <el-table-column label="محل سکونت" width="">
<template slot-scope="scope"> <template slot-scope="scope">
{{ scope.row.userId.province_name + ", "+ scope.row.userId.city_name }} {{ scope.row.userId.province_name + ', ' + scope.row.userId.city_name }}
</template> </template>
</el-table-column> </el-table-column>
<el-table-column label="وضعیت" width=""> <el-table-column label="وضعیت" width="">
<template slot-scope="scope"> <template slot-scope="scope">
<el-tag v-if="scope.row.status == 2" type="danger"> رد شده</el-tag> <el-tag v-if="scope.row.status == 2" color="info"> واریز شده</el-tag>
<el-tag v-if="scope.row.status == 1" type="success">تایید شده</el-tag> <el-tag v-if="scope.row.status == 1" type="success">تایید شده</el-tag>
<el-tag v-if="scope.row.status == 0" type="warning"> درانتظار</el-tag>
<el-tag v-if="scope.row.status == 0" type="warning"> درانتظار تایید</el-tag>
</template> </template>
</el-table-column> </el-table-column>
<el-table-column label="تایید" width="110" align="center"> <el-table-column label="بررسی" width="110" align="center">
<template slot-scope="scope"> <template slot-scope="scope">
<CButton <CButton :key="scope.row._id" color="info" variant="outline" @click="showDialog(scope.row)">
v-if="scope.row.status == 0 || scope.row.status == 2" <i class="fa fa-eye"></i>
:key="scope.row._id"
color="success"
variant="outline"
@click="post(scope.row._id, 'accept')"
>
<i class="fa fa-check-square"></i>
</CButton>
<CButton
v-if="scope.row.status == 0 || scope.row.status == 1"
:key="scope.row._id"
color="danger"
variant="outline"
@click="post(scope.row._id, 'reject')"
>
<i class="fa fa-window-close"></i>
</CButton> </CButton>
</template> </template>
</el-table-column> </el-table-column>
@@ -137,14 +152,14 @@
<script> <script>
export default { export default {
name: 'AdminGpsInstalledDevicesList', name: 'AdminGpsWithdrawList',
layout: 'admin', layout: 'admin',
async asyncData({ $axios, error, query }) { async asyncData({ $axios, error, query }) {
try { try {
const { data } = await $axios.get('/api/admin/gps/register-device') const { data } = await $axios.get('/api/admin/gps/withdraw')
return { return {
devices: data.data requestsData: data.data
} }
} catch (error) { } catch (error) {
console.log(error) console.log(error)
@@ -152,11 +167,11 @@
}, },
data() { data() {
return { return {
devices: [], requestsData: [],
centerDialogVisible: false,
device: {}, requestData: {},
filterText: '', filterText: '',
trackingNumber: null
} }
}, },
@@ -165,10 +180,10 @@
return this.$config return this.$config
}, },
filteredItems() { filteredItems() {
const filterUsersByType = this.devices.filter(item => { const filterUsersByType = this.requestsData.filter(item => {
if (this.filterType === 'all') return item if (this.filterType === 'all') return item
// eslint-disable-next-line eqeqeq // eslint-disable-next-line eqeqeq
else if (this.filterType === 'rej') return item.status == 2 else if (this.filterType === 'dep') return item.status == 2
// eslint-disable-next-line eqeqeq // eslint-disable-next-line eqeqeq
else if (this.filterType === 'accept') return item.status == 1 else if (this.filterType === 'accept') return item.status == 1
// eslint-disable-next-line eqeqeq // eslint-disable-next-line eqeqeq
@@ -178,7 +193,7 @@
const filterText = this.filterText const filterText = this.filterText
if (!this.filterText.length) return filterUsersByType if (!this.filterText.length) return filterUsersByType
else { else {
return this.devices.filter(item => { return this.requestsData.filter(item => {
return item.IMEI.includes(filterText) || item.deviceId.model.includes(filterText) return item.IMEI.includes(filterText) || item.deviceId.model.includes(filterText)
}) })
} }
@@ -188,17 +203,37 @@
return this.$route.query?.filter return this.$route.query?.filter
}, },
set(val) { set(val) {
this.$router.push({ name: 'admin-gps-installed-device', query: { filter: val } }) this.$router.push({ name: 'admin-gps-withdraw', query: { filter: val } })
} }
} }
}, },
methods: { methods: {
showDialog(data) {
console.log(data)
this.requestData = data
this.centerDialogVisible = true
},
hasUnread({ row, rowIndex }) { hasUnread({ row, rowIndex }) {
return row.status === 0 ? 'unreadMsgInCv' : null return row.status === 0 ? 'unreadMsgInCv' : null
}, },
post(id, status) { patchIt(id, status, data) {
let st
// eslint-disable-next-line eqeqeq
if (status == 1) {
st = 'deposit'
if (!data?.trackingNumber) {
return this.$message({
type: 'warning',
message: 'لطفا شماره پیگیری را وارد کنید'
})
}
} else {
st = 'accept'
}
this.$axios this.$axios
.patch(`/api/admin/gps/register-device/${id}/${status}`, {}) .patch(`/api/admin/gps/withdraw/${id}/${st}`, data)
.then(res => { .then(res => {
this.$message({ this.$message({
type: 'success', type: 'success',
@@ -218,7 +253,7 @@
console.log(err) console.log(err)
return this.$message({ return this.$message({
type: 'warning', type: 'warning',
message: err.data.msg message: err.msg
}) })
} }
}) })
@@ -231,4 +266,3 @@
background: rgba(orange, 0.1) !important; background: rgba(orange, 0.1) !important;
} }
</style> </style>
+24 -22
View File
@@ -17,6 +17,7 @@ module.exports.createRequest = [
res.status(400).json({ msg: 'شما درخواست درحال بررسی دارید' }) res.status(400).json({ msg: 'شما درخواست درحال بررسی دارید' })
}else{ }else{
const user = await User.findById(req.user_id) const user = await User.findById(req.user_id)
if(user.walletBalance < 50000){
const data = { const data = {
card: req.body.card, card: req.body.card,
userId: req.user_id, userId: req.user_id,
@@ -31,6 +32,9 @@ module.exports.createRequest = [
user.save() user.save()
// res.status(201).json({ msg: _sr.fa.response.success_save, data: request }) // res.status(201).json({ msg: _sr.fa.response.success_save, data: request })
res.status(201).json(request) res.status(201).json(request)
}else{
res.status(400).json({ msg: 'حداقل موجودی باید 50 هزار تومان باشد' })
}
} }
@@ -76,25 +80,25 @@ module.exports.getAllForUser = async (req, res) => {
} }
module.exports.getAllForAdmin = async (req, res) => { module.exports.getAllForAdmin = async (req, res) => {
let page; // let page;
let rows; // let rows;
if (!req.query?.rows || req.query?.rows <= 5) { // if (!req.query?.rows || req.query?.rows <= 5) {
rows = 10 // rows = 10
} else { // } else {
rows = parseInt(req.query.rows) // rows = parseInt(req.query.rows)
} // }
if (!req.query?.page) { // if (!req.query?.page) {
page = 0 // page = 0
// eslint-disable-next-line eqeqeq // // eslint-disable-next-line eqeqeq
} else if (req.query.page <= 1) { // } else if (req.query.page <= 1) {
page = 0 // page = 0
} else { // } else {
page = req.query.page // page = req.query.page
page = page * rows - rows // page = page * rows - rows
} // }
const data = await Withdraw.find().sort({ status: 1 }).skip(page).limit(rows) const data = await Withdraw.find().sort({ status: 1 })
.populate('userId', 'shopName shopNumber shopAddress birthDate score first_name last_name profilePic') .populate('userId', 'shopName national_code first_name last_name mobile_number city_name province_name')
const total = Math.ceil((await Withdraw.estimatedDocumentCount())) const total = Math.ceil((await Withdraw.estimatedDocumentCount()))
res.status(200).json({ data, total }) res.status(200).json({ data, total })
} }
@@ -115,8 +119,7 @@ module.exports.updateReq = [
case "accept": { case "accept": {
request.status = 1; request.status = 1;
request.save() request.save()
// res.status(201).json({ msg: _sr.fa.response.success_save, data: request }) res.status(201).json({ msg: _sr.fa.response.success_save, data: request })
res.status(201).json(request)
break; break;
} }
@@ -125,8 +128,7 @@ module.exports.updateReq = [
request.depositDate = new Date(); request.depositDate = new Date();
request.trackingNumber = req.body.trackingNumber || 0; request.trackingNumber = req.body.trackingNumber || 0;
request.save() request.save()
// res.status(201).json({ msg: _sr.fa.response.success_save, data: request }) res.status(201).json({ msg: _sr.fa.response.success_save, data: request })
res.status(201).json(request)
break; break;
} }