Kaynağa Gözat

see also (3&4) #110

ali 3 yıl önce
ebeveyn
işleme
2efe01c200

+ 37 - 0
src/api/models/Payment.js

@@ -8,6 +8,8 @@ export default class PaymentAPI extends APIRepository {
     this.APIAdresses = {
       base: '/accounting/payments',
       requestWithdraw: '/accounting/payments/request_withdraw',
+      confirmWithdraw: (id) => '/accounting/payments/' + id + '/confirm_withdraw',
+      rejectWithdraw: (id) => '/accounting/payments/' + id + '/reject_withdraw',
       byId: (id) => '/accounting/payments/' + id
     }
     this.CacheList = {
@@ -71,4 +73,39 @@ export default class PaymentAPI extends APIRepository {
       }
     })
   }
+
+  confirmWithdraw(paymentId, data) {
+    return this.sendRequest({
+      apiMethod: 'put',
+      api: this.api,
+      request: this.APIAdresses.confirmWithdraw(paymentId),
+      data,
+      // receipt: null, // File
+      // description: null // String
+
+      resolveCallback: (response) => {
+        return new Payment(response.data)
+      },
+      rejectCallback: (error) => {
+        return error
+      }
+    })
+  }
+
+  rejectWithdraw(data) {
+    return this.sendRequest({
+      apiMethod: 'put',
+      api: this.api,
+      request: this.APIAdresses.rejectWithdraw(data.paymentId),
+      data: this.getNormalizedSendData({
+        description: null // String
+      }, data),
+      resolveCallback: (response) => {
+        return new Payment(response.data)
+      },
+      rejectCallback: (error) => {
+        return error
+      }
+    })
+  }
 }

+ 6 - 1
src/components/Template/SideBard/UserPanelSideBar.vue

@@ -77,11 +77,16 @@ export default {
           children: [
             {
               title: 'صورتحساب ها',
-              scrollTo: '#introSection',
               routeName: 'UserPanel.Invoice.List',
               show: true,
               active: false
             },
+            {
+              title: 'پرداخت ها',
+              routeName: 'UserPanel.Payment.List',
+              show: true,
+              active: false
+            },
             {
               title: 'کیف پول الکترونیک',
               routeName: 'UserPanel.Wallet',

+ 2 - 2
src/components/Widgets/Payment/AdminPaymentList/AdminPaymentList.vue

@@ -19,7 +19,7 @@
         </template>
         <template v-else-if="inputData.col.name === 'action'">
           <q-btn color="primary"
-                 :to="{name: 'UserPanel.Payment.Show', params: {id: inputData.props.row.id}}">
+                 :to="{name: 'Admin.Payment.Show', params: {id: inputData.props.row.id}}">
             مشاهده جزییات
           </q-btn>
         </template>
@@ -35,7 +35,7 @@
             </template>
             <template v-else-if="col.name === 'action'">
               <q-btn color="primary"
-                     :to="{name: 'UserPanel.Payment.Show', params: {id: row.id}}">
+                     :to="{name: 'Admin.Payment.Show', params: {id: row.id}}">
                 مشاهده جزییات
               </q-btn>
             </template>

+ 90 - 25
src/components/Widgets/Payment/AdminPaymentShow/AdminPaymentShow.vue

@@ -31,13 +31,52 @@
                @click="showInvoice">
           مشاهده سفارش
         </q-btn>
+
+        <div v-if="payment.type === 'WITHDRAW_REQUEST'">
+          <div class="row q-col-gutter-md q-mt-lg">
+            <div class="col-md-6 col-12">
+              رسید پرداخت:
+              {{ payment.receipt }}
+            </div>
+            <div class="col-md-6 col-12">
+              شماره شبا:
+              {{ payment.IBAN }}
+            </div>
+          </div>
+          <form-builder ref="requestForm"
+                        v-model:value="requestInputs"
+                        :loading="requestLoading"
+                        class="q-mt-md" />
+        </div>
       </template>
     </entity-show>
+    <div v-if="payment.type === 'WITHDRAW_REQUEST'"
+         class="row q-col-gutter-md q-mt-md">
+      <div class="col-md-6 col-12" />
+      <div class="col-md-3 col-12">
+        <q-btn color="primary"
+               class="full-width"
+               :loading="requestLoading"
+               @click="confirmWithdraw">
+          تایید درخواست
+        </q-btn>
+      </div>
+      <div class="col-md-3 col-12">
+        <q-btn color="red"
+               class="full-width"
+               :loading="requestLoading"
+               outline
+               @click="rejectWithdraw">
+          رد درخواست
+        </q-btn>
+      </div>
+    </div>
   </div>
 </template>
 
 <script>
 import { EntityShow } from 'quasar-crud'
+import { FormBuilder, FormBuilderAssist } from 'quasar-form-builder'
 import { Payment } from 'src/models/Payment.js'
 import { mixinWidget } from 'src/mixin/Mixins.js'
 import { APIGateway } from 'src/api/APIGateway.js'
@@ -45,13 +84,15 @@ import { APIGateway } from 'src/api/APIGateway.js'
 export default {
   name: 'AdminPaymentShow',
   components: {
-    EntityShow
+    EntityShow,
+    FormBuilder
   },
   mixins: [mixinWidget],
   data: () => {
     return {
       mounted: false,
       entityLoading: true,
+      requestLoading: false,
       api: null,
       payment: new Payment(),
       entityIdKey: 'id',
@@ -59,36 +100,31 @@ export default {
       showRouteName: 'Admin.Content.Show',
       indexRouteName: 'Admin.Content.List',
       inputs: [
-        { type: 'input', name: 'amount', responseKey: 'amount', label: 'مبلغ', placeholder: ' ', col: 'col-md-4 col-12' },
-        { type: 'dateTime', name: 'creation_time', responseKey: 'creation_time', label: 'تاریخ ایجاد', placeholder: ' ', col: 'col-md-4 col-12' },
+        { type: 'separator', name: 'space', label: 'مشخصات کاربر', className: 'custom-separator', col: 'col-12' },
+        { type: 'input', name: 'creator_info.firstname', responseKey: 'creator_info.firstname', label: 'نام', placeholder: ' ', col: 'col-md-3 col-12' },
+        { type: 'input', name: 'creator_info.lastname', responseKey: 'creator_info.lastname', label: 'نام خانوادگی', placeholder: ' ', col: 'col-md-3 col-12' },
+        { type: 'input', name: 'creator_info.mobile_number', responseKey: 'creator_info.mobile_number', label: 'تلفن همراه', placeholder: ' ', col: 'col-md-3 col-12' },
+        { type: 'input', name: 'creator_info.email', responseKey: 'creator_info.email', label: 'ایمیل', placeholder: ' ', col: 'col-md-3 col-12' },
+
+        { type: 'separator', name: 'space', label: 'مشخصات حساب', className: 'custom-separator', col: 'col-12' },
+        { type: 'input', name: 'id', responseKey: 'id', label: 'شناسه', placeholder: ' ', col: 'col-md-2 col-12' },
         {
           type: 'select',
           name: 'type',
           responseKey: 'type',
-          label: 'نوع',
-          options: [
-            {
-              label: 'برداشت',
-              value: 'WITHDRAW'
-            },
-            {
-              label: 'درخواست برداشت',
-              value: 'WITHDRAW_REQUEST'
-            },
-            {
-              label: 'برداشت رد شده',
-              value: 'WITHDRAW_REJECT'
-            },
-            {
-              label: 'واریز',
-              value: 'DEPOSIT'
-            }
-          ],
+          label: 'نوع درخواست',
+          options: (new Payment()).typeEnums,
           placeholder: ' ',
-          col: 'col-md-4 col-12'
+          col: 'col-md-3 col-12'
         },
-        { type: 'input', name: 'creator_info.firstname', responseKey: 'creator_info.firstname', label: 'نام پرداخت کننده', placeholder: ' ', col: 'col-md-6 col-12' },
-        { type: 'input', name: 'creator_info.lastname', responseKey: 'creator_info.lastname', label: 'نام خانوادگی پرداخت کننده', placeholder: ' ', col: 'col-md-6 col-12' }
+        { type: 'input', name: 'amount', responseKey: 'amount', label: 'مبلغ کل(ریال)', placeholder: ' ', col: 'col-md-3 col-12' },
+        { type: 'dateTime', name: 'creation_time', responseKey: 'creation_time', label: 'تاریخ ثبت', placeholder: ' ', col: 'col-md-4 col-12' }
+        // { type: 'input', name: 'IBAN', responseKey: 'IBAN', label: 'شماره شبا', placeholder: ' ', col: 'col-md-6 col-12' },
+        // { type: 'input', name: 'receipt', responseKey: 'receipt', label: 'رسید پرداخت', placeholder: ' ', col: 'col-md-6 col-12' }
+      ],
+      requestInputs: [
+        { type: 'file', name: 'receipt', label: 'فایل رسید پرداخت', placeholder: ' ', col: 'col-md-3 col-12' },
+        { type: 'InputEditor', name: 'description', label: 'توضیحات', placeholder: ' ', col: 'col-12' }
       ]
     }
   },
@@ -125,6 +161,35 @@ export default {
           this.$refs.entityEdit.getData()
           this.entityLoading = false
         })
+    },
+    confirmWithdraw () {
+      this.requestLoading = true
+      APIGateway.payment.confirmWithdraw(this.payment.id, this.getRequestFormData())
+        .then(() => {
+          this.requestLoading = false
+        })
+        .catch(() => {
+          this.requestLoading = false
+        })
+    },
+    rejectWithdraw () {
+      this.requestLoading = true
+      APIGateway.payment.rejectWithdraw({
+        paymentId: this.payment.id,
+        description: FormBuilderAssist.getInputsByName(this.requestInputs, 'description').value
+      })
+        .then(() => {
+          this.requestLoading = false
+        })
+        .catch(() => {
+          this.requestLoading = false
+        })
+    },
+    getRequestFormData () {
+      return this.$refs.requestForm.getFormData()
+    },
+    reloadData () {
+      return this.$refs.entityEdit.getData()
     }
   }
 }

+ 5 - 6
src/components/Widgets/Payment/PaymentList/PaymentList.vue

@@ -76,21 +76,20 @@ export default {
       },
       inputs: [
         {
-          type: 'date',
-          name: 'creation_time',
+          type: 'dateTime',
+          name: 'creation_time__gte',
           label: 'از تاریخ',
           placeholder: ' ',
           col: 'col-md-3 col-12'
         },
         {
-          type: 'date',
-          name: 'creation_time',
+          type: 'dateTime',
+          name: 'creation_time__lt',
           label: 'تا تاریخ',
           placeholder: ' ',
           col: 'col-md-3 col-12'
         },
-        { type: 'select', name: 'category', options: [], label: 'نوع تراکنش', placeholder: ' ', col: 'col-md-2 col-12' },
-        { type: 'input', name: 'category', label: 'عنوان تراکنش', placeholder: ' ', col: 'col-md-2 col-12' },
+        { type: 'select', name: 'type', options: (new Payment()).typeEnums, label: 'نوع تراکنش', placeholder: ' ', col: 'col-md-3 col-12' },
         { type: 'hidden', name: 'owner', value: null },
         { type: BtnControlComp, name: 'btn', responseKey: 'btn', label: 'جستجو', placeholder: ' ', atClick: () => {}, col: 'col-md-2 col-12' }
       ],

+ 23 - 25
src/components/Widgets/Payment/PaymentShow/PaymentShow.vue

@@ -12,7 +12,7 @@
     <entity-show v-if="mounted"
                  ref="entityEdit"
                  v-model:value="inputs"
-                 title="اطلاعات پرداخت"
+                 title="تراکنش کیف پول"
                  :api="api"
                  :entity-id-key="entityIdKey"
                  :index-route-name="'UserPanel.Wallet'"
@@ -31,6 +31,19 @@
                @click="showInvoice">
           مشاهده سفارش
         </q-btn>
+
+        <div v-if="payment.type === 'WITHDRAW_REQUEST'">
+          <div class="row q-col-gutter-md q-mt-lg">
+            <div class="col-md-6 col-12">
+              رسید پرداخت:
+              {{ payment.receipt }}
+            </div>
+            <div class="col-md-6 col-12">
+              شماره شبا:
+              {{ payment.IBAN }}
+            </div>
+          </div>
+        </div>
       </template>
     </entity-show>
   </div>
@@ -59,36 +72,21 @@ export default {
       showRouteName: 'Admin.Content.Show',
       indexRouteName: 'Admin.Content.List',
       inputs: [
-        { type: 'input', name: 'amount', responseKey: 'amount', label: 'مبلغ', placeholder: ' ', col: 'col-md-4 col-12' },
-        { type: 'dateTime', name: 'creation_time', responseKey: 'creation_time', label: 'تاریخ ایجاد', placeholder: ' ', col: 'col-md-4 col-12' },
+        // { type: 'separator', name: 'space', label: 'مشخصات حساب', className: 'custom-separator', col: 'col-12' },
+        { type: 'input', name: 'id', responseKey: 'id', label: 'شناسه', placeholder: ' ', col: 'col-md-2 col-12' },
+        { type: 'dateTime', name: 'creation_time', responseKey: 'creation_time', label: 'تاریخ ثبت', placeholder: ' ', col: 'col-md-4 col-12' },
         {
           type: 'select',
           name: 'type',
           responseKey: 'type',
-          label: 'نوع',
-          options: [
-            {
-              label: 'برداشت',
-              value: 'WITHDRAW'
-            },
-            {
-              label: 'درخواست برداشت',
-              value: 'WITHDRAW_REQUEST'
-            },
-            {
-              label: 'برداشت رد شده',
-              value: 'WITHDRAW_REJECT'
-            },
-            {
-              label: 'واریز',
-              value: 'DEPOSIT'
-            }
-          ],
+          label: 'نوع درخواست',
+          options: (new Payment()).typeEnums,
           placeholder: ' ',
-          col: 'col-md-4 col-12'
+          col: 'col-md-3 col-12'
         },
-        { type: 'input', name: 'creator_info.firstname', responseKey: 'creator_info.firstname', label: 'نام پرداخت کننده', placeholder: ' ', col: 'col-md-6 col-12' },
-        { type: 'input', name: 'creator_info.lastname', responseKey: 'creator_info.lastname', label: 'نام خانوادگی پرداخت کننده', placeholder: ' ', col: 'col-md-6 col-12' }
+        { type: 'input', name: 'amount', responseKey: 'amount', label: 'مبلغ کل(ریال)', placeholder: ' ', col: 'col-md-3 col-12' }
+        // { type: 'input', name: 'IBAN', responseKey: 'IBAN', label: 'شماره شبا', placeholder: ' ', col: 'col-md-6 col-12' },
+        // { type: 'input', name: 'receipt', responseKey: 'receipt', label: 'رسید پرداخت', placeholder: ' ', col: 'col-md-6 col-12' }
       ]
     }
   },

+ 1 - 1
src/pages/Admin/Payment/Show.vue

@@ -13,7 +13,7 @@ export default {
   mixins: [mixinPageOptions],
   data: () => {
     return {
-      sections: [{ data: { rows: [{ cols: [{ widgets: [{ name: 'AdminInvoiceShow' }], options: { style: { paddingTop: '', marginBottom: '124px' } } }], options: { className: '', height: 'auto', boxed: true, boxedWidth: 1200, gutterXSize: 'md', gutterYSize: 'md', absolute: 'none', paddingOfBoxedInFullWidth: '10px', alignment: { justifyContent: { global: null, xl: null, lg: null, md: null, sm: null, xs: null }, alignItems: { global: null, xl: null, lg: null, md: null, sm: null, xs: null }, alignContent: { global: null, xl: null, lg: null, md: null, sm: null, xs: null } }, style: { maxWidth: '1200px', width: '1200px' } } }] } }]
+      sections: [{ data: { rows: [{ cols: [{ widgets: [{ name: 'AdminPaymentShow' }], options: { style: { paddingTop: '', marginBottom: '124px' } } }], options: { className: '', height: 'auto', boxed: true, boxedWidth: 1200, gutterXSize: 'md', gutterYSize: 'md', absolute: 'none', paddingOfBoxedInFullWidth: '10px', alignment: { justifyContent: { global: null, xl: null, lg: null, md: null, sm: null, xs: null }, alignItems: { global: null, xl: null, lg: null, md: null, sm: null, xs: null }, alignContent: { global: null, xl: null, lg: null, md: null, sm: null, xs: null } }, style: { maxWidth: '1200px', width: '1200px' } } }] } }]
     }
   },
   created() {

+ 24 - 0
src/pages/User/Payment/List.vue

@@ -0,0 +1,24 @@
+<template>
+  <q-page-builder v-model:sections="currenSections"
+                  v-model:options="pageConfig"
+                  :editable="pageBuilderEditable"
+                  :loading="pageBuilderLoading" />
+</template>
+
+<script>
+import { mixinPageOptions } from 'src/mixin/Mixins.js'
+
+export default {
+  name: 'AdminPanel.Invoice.List',
+  mixins: [mixinPageOptions],
+  data: () => {
+    return {
+      sections: [{ data: { rows: [{ cols: [{ widgets: [{ name: 'PaymentList' }], options: { style: { paddingTop: '' } } }], options: { className: '', height: 'auto', boxed: true, boxedWidth: 1200, gutterXSize: 'md', gutterYSize: 'md', absolute: 'none', paddingOfBoxedInFullWidth: '10px', alignment: { justifyContent: { global: null, xl: null, lg: null, md: null, sm: null, xs: null }, alignItems: { global: null, xl: null, lg: null, md: null, sm: null, xs: null }, alignContent: { global: null, xl: null, lg: null, md: null, sm: null, xs: null } }, style: { maxWidth: '1200px', width: '1200px', marginBottom: '10px' } } }] } }]
+    }
+  },
+  created() {
+    this.currenSections = this.sections
+    this.pageBuilderLoading = false
+  }
+}
+</script>

+ 5 - 0
src/router/routes.js

@@ -370,6 +370,11 @@ const routes = [
             name: 'UserPanel.Payment',
             component: () => import('src/layouts/bareLayout.vue'),
             children: [
+              {
+                path: '',
+                name: 'UserPanel.Payment.List',
+                component: () => import('src/pages/User/Payment/List.vue')
+              },
               {
                 name: 'UserPanel.Payment.Show',
                 path: ':id',