parent
87ae640c51
commit
54e9de66b6
@ -0,0 +1,18 @@ |
||||
import request from '@/utils/request' |
||||
|
||||
export function getOrderInfo(query) { |
||||
return request({ |
||||
url: '/order/info', |
||||
method: 'get', |
||||
params: query |
||||
}) |
||||
} |
||||
|
||||
export function updateOrderInfo(data) { |
||||
return request({ |
||||
url: '/order/info', |
||||
method: 'put', |
||||
data |
||||
}) |
||||
} |
||||
|
@ -0,0 +1,180 @@ |
||||
<template> |
||||
<div class="app-container"> |
||||
<el-form ref="postForm" :model="postForm" label-width="100px" :disabled="!is_edit"> |
||||
<el-row> |
||||
<el-col :span="12"> |
||||
<el-form-item label="用户ID"> |
||||
<el-row :gutter="12"> |
||||
<el-col :span="16"> |
||||
<el-input :value="postForm.user_id" disabled /> |
||||
</el-col> |
||||
</el-row> |
||||
</el-form-item> |
||||
<el-form-item label="商家名称"> |
||||
<el-row :gutter="12"> |
||||
<el-col :span="16"> |
||||
<el-input v-model="postForm.payment_name" disabled /> |
||||
</el-col> |
||||
</el-row> |
||||
</el-form-item> |
||||
<el-form-item label="支付类型"> |
||||
<el-row :gutter="12"> |
||||
<el-col :span="16"> |
||||
<el-select v-model="postForm.payment_type" class="filter-item" disabled> |
||||
<el-option v-for="item in postForm.payment_type_choices" :key="item.id" :label="item.name" :value="item.id" /> |
||||
</el-select> |
||||
</el-col> |
||||
</el-row> |
||||
</el-form-item> |
||||
<el-form-item label="创建时间" prop="timestamp"> |
||||
<el-row :gutter="20"> |
||||
<el-col :span="8"> |
||||
<el-date-picker :value="postForm.created_time" type="datetime" disabled /> |
||||
</el-col> |
||||
</el-row> |
||||
</el-form-item> |
||||
<el-form-item label="支付时间" prop="timestamp"> |
||||
<el-row :gutter="20"> |
||||
<el-col :span="8"> |
||||
<el-date-picker :value="postForm.pay_time" type="datetime" disabled /> |
||||
</el-col> |
||||
</el-row> |
||||
</el-form-item> |
||||
<el-form-item label="订单备注"> |
||||
<el-row :gutter="12"> |
||||
<el-col :span="16"> |
||||
<el-input v-model="postForm.description" :autosize="{ minRows: 4, maxRows: 6}" type="textarea" /> |
||||
</el-col> |
||||
</el-row> |
||||
</el-form-item> |
||||
</el-col> |
||||
<el-col :span="12"> |
||||
|
||||
<el-form-item label="服务器订单号" label-width="160px"> |
||||
<el-row :gutter="12"> |
||||
<el-col :span="16"> |
||||
<el-input v-model="postForm.order_number" disabled /> |
||||
</el-col> |
||||
</el-row> |
||||
</el-form-item> |
||||
<el-form-item label="第3方订单号" label-width="160px"> |
||||
<el-row :gutter="12"> |
||||
<el-col :span="16"> |
||||
<el-input v-model="postForm.payment_number" disabled /> |
||||
</el-col> |
||||
</el-row> |
||||
</el-form-item> |
||||
<el-form-item label="支付金额" label-width="160px"> |
||||
<el-row :gutter="12"> |
||||
<el-col :span="16"> |
||||
<el-input v-model="postForm.actual_amount" disabled /> |
||||
</el-col> |
||||
</el-row> |
||||
</el-form-item> |
||||
<el-form-item label="购买数量" label-width="160px"> |
||||
<el-row :gutter="12"> |
||||
<el-col :span="16"> |
||||
<el-input v-model="postForm.actual_download_times" disabled /> |
||||
</el-col> |
||||
</el-row> |
||||
</el-form-item> |
||||
<el-form-item label="赠送数量" label-width="160px"> |
||||
<el-row :gutter="12"> |
||||
<el-col :span="16"> |
||||
<el-input v-model="postForm.actual_download_gift_times" disabled /> |
||||
</el-col> |
||||
</el-row> |
||||
</el-form-item> |
||||
<el-form-item label="订单类型" label-width="160px"> |
||||
<el-row :gutter="12"> |
||||
<el-col :span="16"> |
||||
<el-select v-model="postForm.order_type" class="filter-item" disabled> |
||||
<el-option v-for="item in postForm.order_type_choices" :key="item.id" :label="item.name" :value="item.id" /> |
||||
</el-select> |
||||
</el-col> |
||||
</el-row> |
||||
</el-form-item> |
||||
<el-form-item label="支付状态" label-width="160px"> |
||||
<el-row :gutter="12"> |
||||
<el-col :span="16"> |
||||
<el-select v-model="postForm.status" class="filter-item"> |
||||
<el-option v-for="item in postForm.status_choices" :key="item.id" :label="item.name" :value="item.id" /> |
||||
</el-select> |
||||
</el-col> |
||||
</el-row> |
||||
</el-form-item> |
||||
</el-col> |
||||
</el-row> |
||||
</el-form> |
||||
<el-col :span="9" style="float: right"> |
||||
<el-button v-if="!is_edit" type="primary" :disabled="postForm.id === postForm.used_id" @click="is_edit=true">修改</el-button> |
||||
<div v-else> |
||||
<el-button type="primary" @click="is_edit=false">取消</el-button> |
||||
<el-button type="primary" @click="updateData">保存修改</el-button> |
||||
</div> |
||||
</el-col> |
||||
</div> |
||||
</template> |
||||
|
||||
<script> |
||||
import { getOrderInfo, updateOrderInfo } from '@/api/order' |
||||
|
||||
const defaultForm = { |
||||
user_id: undefined, |
||||
payment_type: undefined, |
||||
payment_number: undefined, |
||||
payment_name: undefined, |
||||
order_number: undefined, |
||||
actual_amount: undefined, |
||||
actual_download_times: undefined, |
||||
actual_download_gift_times: undefined, |
||||
description: undefined, |
||||
status: undefined, |
||||
order_type: undefined, |
||||
pay_time: undefined, |
||||
created_time: undefined |
||||
} |
||||
|
||||
export default { |
||||
name: 'OrderDetail', |
||||
components: { }, filters: {}, |
||||
data() { |
||||
return { |
||||
postForm: Object.assign({}, defaultForm), |
||||
loading: false, |
||||
is_edit: false |
||||
} |
||||
}, |
||||
computed: {}, |
||||
created() { |
||||
const id = this.$route.params && this.$route.params.id |
||||
this.fetchData(id) |
||||
}, |
||||
methods: { |
||||
fetchData(id) { |
||||
getOrderInfo({ id: id }).then(response => { |
||||
if (response.data.length === 1) { |
||||
this.postForm = response.data[0] |
||||
} |
||||
}).catch(err => { |
||||
console.log(err) |
||||
}) |
||||
}, |
||||
updateData() { |
||||
updateOrderInfo(this.postForm).then(response => { |
||||
this.$message.success('更新成功') |
||||
this.postForm = response.data |
||||
}).catch(err => { |
||||
console.log(err) |
||||
}) |
||||
} |
||||
} |
||||
} |
||||
</script> |
||||
|
||||
<style scoped> |
||||
.editor-container { |
||||
position: relative; |
||||
height: 100%; |
||||
} |
||||
</style> |
@ -0,0 +1,232 @@ |
||||
<template> |
||||
<div class="app-container"> |
||||
<div class="filter-container"> |
||||
<el-input v-model="listQuery.user_id" placeholder="用户ID" style="width: 140px;" class="filter-item" clearable @keyup.enter.native="handleFilter" /> |
||||
<el-input v-model="listQuery.payment_number" placeholder="payment_number" style="width: 300px;" class="filter-item" clearable @keyup.enter.native="handleFilter" /> |
||||
<el-input v-model="listQuery.order_number" placeholder="order_number" style="width: 200px;" class="filter-item" clearable @keyup.enter.native="handleFilter" /> |
||||
<el-input v-model="listQuery.payment_name" placeholder="支付商家" style="width: 200px;" class="filter-item" clearable @keyup.enter.native="handleFilter" /> |
||||
<el-select v-model="listQuery.payment_type" placeholder="支付类型" clearable class="filter-item" style="width: 140px" @change="handleFilter"> |
||||
<el-option v-for="item in payment_type_choices" :key="item.id" :label="item.name" :value="item.id" /> |
||||
</el-select> |
||||
<el-select v-model="listQuery.status" placeholder="订单状态" clearable class="filter-item" style="width: 140px" @change="handleFilter"> |
||||
<el-option v-for="item in status_choices" :key="item.id" :label="item.name" :value="item.id" /> |
||||
</el-select> |
||||
<el-select v-model="listQuery.order_type" placeholder="订单类型" clearable class="filter-item" style="width: 140px" @change="handleFilter"> |
||||
<el-option v-for="item in order_type_choices" :key="item.id" :label="item.name" :value="item.id" /> |
||||
</el-select> |
||||
<el-select v-model="listQuery.sort" style="width: 140px" class="filter-item" @change="handleFilter"> |
||||
<el-option v-for="item in sortOptions" :key="item.key" :label="item.label" :value="item.key" /> |
||||
</el-select> |
||||
<el-button v-waves class="filter-item" type="primary" icon="el-icon-search" @click="handleFilter"> |
||||
Search |
||||
</el-button> |
||||
</div> |
||||
<el-table |
||||
v-loading="listLoading" |
||||
:data="list" |
||||
element-loading-text="Loading" |
||||
border |
||||
fit |
||||
highlight-current-row |
||||
stripe |
||||
> |
||||
<el-table-column align="center" label="ID" width="90"> |
||||
<template slot-scope="scope"> |
||||
{{ scope.row.id }} |
||||
</template> |
||||
</el-table-column> |
||||
<el-table-column label="用户ID" width="100" align="center"> |
||||
<template slot-scope="scope"> |
||||
<router-link :to="{name: 'user_info_edit',params:{id:scope.row.user_id}}"> |
||||
<el-link type="primary"> {{ scope.row.user_id }}</el-link> |
||||
</router-link> |
||||
</template> |
||||
</el-table-column> |
||||
<el-table-column label="支付商家" width="80px"> |
||||
<template slot-scope="scope"> |
||||
{{ scope.row.payment_name }} |
||||
</template> |
||||
</el-table-column> |
||||
<el-table-column label="订单号" align="center"> |
||||
<template slot-scope="scope"> |
||||
<span>{{ scope.row.order_number }}</span> |
||||
</template> |
||||
</el-table-column> |
||||
<el-table-column label="第三方订单号" align="center"> |
||||
<template slot-scope="scope"> |
||||
<span>{{ scope.row.payment_number }}</span> |
||||
</template> |
||||
</el-table-column> |
||||
<el-table-column label="实付金额" align="center" width="80px"> |
||||
<template slot-scope="scope"> |
||||
{{ scope.row.actual_amount }} |
||||
</template> |
||||
</el-table-column> |
||||
<el-table-column label="购买数量" align="center" width="90px"> |
||||
<template slot-scope="scope"> |
||||
{{ scope.row.actual_download_times }} |
||||
</template> |
||||
</el-table-column> |
||||
<el-table-column label="赠送数量" align="center" width="90px"> |
||||
<template slot-scope="scope"> |
||||
{{ scope.row.actual_download_gift_times }} |
||||
</template> |
||||
</el-table-column> |
||||
<el-table-column class-name="status-col" label="支付类型" width="95" align="center"> |
||||
<template slot-scope="scope"> |
||||
<el-tag :type="scope.row.payment_type | payStatusFilter">{{ scope.row| payLableFilter }}</el-tag> |
||||
</template> |
||||
</el-table-column> |
||||
<el-table-column class-name="status-col" label="订单状态" width="95" align="center"> |
||||
<template slot-scope="scope"> |
||||
<el-tag :type="scope.row.status | certStatusFilter">{{ scope.row| statusLableFilter }}</el-tag> |
||||
</template> |
||||
</el-table-column> |
||||
<el-table-column align="center" prop="created_time" label="创建时间" width="120"> |
||||
<template slot-scope="scope"> |
||||
<i class="el-icon-time" /> |
||||
<el-tooltip :content="scope.row.created_time"> |
||||
<span>{{ scope.row.created_time|formatTime }}</span> |
||||
</el-tooltip> |
||||
</template> |
||||
</el-table-column> |
||||
<el-table-column align="center" prop="created_time" label="支付时间" width="120"> |
||||
<template slot-scope="scope"> |
||||
<i class="el-icon-time" /> |
||||
<el-tooltip :content="scope.row.pay_time"> |
||||
<span>{{ scope.row.pay_time|formatTime }}</span> |
||||
</el-tooltip> |
||||
</template> |
||||
</el-table-column> |
||||
<el-table-column label="操作" align="center" width="160" class-name="small-padding fixed-width"> |
||||
<template slot-scope="scope"> |
||||
<router-link :to="{name: 'order_info_edit',params:{id:scope.row.id}}"> |
||||
<el-button type="primary" size="mini"> |
||||
查看编辑 |
||||
</el-button> |
||||
</router-link> |
||||
<el-button type="danger" size="mini" @click="deleteApp(scope.row.id)"> |
||||
删除 |
||||
</el-button> |
||||
</template> |
||||
</el-table-column> |
||||
</el-table> |
||||
<pagination v-show="total>0" :total="total" :page.sync="listQuery.page" :limit.sync="listQuery.limit" @pagination="fetchData" /> |
||||
|
||||
</div> |
||||
</template> |
||||
|
||||
<script> |
||||
import { getOrderInfo } from '@/api/order' |
||||
import { baseFilter } from '@/utils' |
||||
import Pagination from '@/components/Pagination' // secondary package based on el-pagination |
||||
import waves from '@/directive/waves' // waves directive |
||||
|
||||
const sortOptions = [ |
||||
{ label: '创建时间 Ascending', key: 'reviewed_time' }, |
||||
{ label: '创建时间 Descending', key: '-reviewed_time' }, |
||||
] |
||||
|
||||
export default { |
||||
name: 'OrderInfo', |
||||
components: { Pagination }, |
||||
directives: { waves }, |
||||
filters: { |
||||
formatTime(time) { |
||||
if (time) { |
||||
return time.split('T')[0] |
||||
} |
||||
}, |
||||
payStatusFilter(status) { |
||||
const statusMap = { |
||||
'0': 'gray', |
||||
'1': 'success' } |
||||
return statusMap[status] |
||||
}, |
||||
certStatusFilter(status) { |
||||
const statusMap = { |
||||
'0': 'success', |
||||
'1': 'info', |
||||
'2': 'gray' } |
||||
return statusMap[status] |
||||
}, |
||||
payLableFilter(row) { |
||||
return baseFilter(row.payment_type, row.payment_type_choices) |
||||
}, |
||||
statusLableFilter(row) { |
||||
return baseFilter(row.status, row.status_choices) |
||||
}, |
||||
statusFilter(status) { |
||||
const statusMap = { |
||||
true: 'success', |
||||
false: 'danger' |
||||
} |
||||
return statusMap[status] |
||||
}, |
||||
appStatusNameFilter(row) { |
||||
for (const r of row.status_choices) { |
||||
if (r.id === row.status) { |
||||
return r.name |
||||
} |
||||
} |
||||
}, |
||||
appStatusFilter(status) { |
||||
const statusMap = { |
||||
'0': 'danger', |
||||
'1': 'success', |
||||
'2': 'gray' |
||||
} |
||||
return statusMap[status] |
||||
} |
||||
}, |
||||
data() { |
||||
return { |
||||
list: null, |
||||
listLoading: true, |
||||
total: 0, |
||||
listQuery: { |
||||
page: 1, |
||||
limit: 10, |
||||
user_id: undefined, |
||||
sort: '-created_time', |
||||
payment_type: undefined, |
||||
payment_name: undefined, |
||||
payment_number: undefined, |
||||
order_number: undefined, |
||||
status: undefined, |
||||
order_type: undefined |
||||
}, |
||||
sortOptions, |
||||
payment_type_choices: [], |
||||
status_choices: [], |
||||
order_type_choices: [] |
||||
} |
||||
}, |
||||
created() { |
||||
this.fetchData() |
||||
}, mounted() { |
||||
if (this.$route.query.user_id) { |
||||
this.listQuery.user_id = this.$route.query.user_id |
||||
} |
||||
}, |
||||
methods: { |
||||
handleFilter() { |
||||
this.listQuery.page = 1 |
||||
this.fetchData() |
||||
}, |
||||
fetchData() { |
||||
this.listLoading = true |
||||
getOrderInfo(this.listQuery).then(response => { |
||||
this.list = response.data |
||||
if (this.list && this.list.length > 0) { |
||||
this.payment_type_choices = this.list[0].payment_type_choices |
||||
this.status_choices = this.list[0].status_choices |
||||
this.order_type_choices = this.list[0].order_type_choices |
||||
} |
||||
this.total = response.total |
||||
this.listLoading = false |
||||
}) |
||||
} |
||||
} |
||||
} |
||||
</script> |
@ -0,0 +1,101 @@ |
||||
#!/usr/bin/env python |
||||
# -*- coding:utf-8 -*- |
||||
# project: 4月 |
||||
# author: liuyu |
||||
# date: 2021/4/11 |
||||
|
||||
from django.contrib import auth |
||||
|
||||
from api.base_views import storage_change |
||||
from api.models import Token, UserInfo, Order |
||||
from rest_framework.response import Response |
||||
from api.utils.auth import AdminTokenAuthentication |
||||
from api.utils.baseutils import get_dict_from_filter_fields |
||||
from api.utils.serializer import AdminStorageSerializer, AdminUserCertificationSerializer, AdminOrdersSerializer |
||||
from django.core.cache import cache |
||||
from rest_framework.views import APIView |
||||
import binascii |
||||
import os, datetime |
||||
from api.utils.utils import get_captcha, valid_captcha, get_choices_dict |
||||
from api.utils.response import BaseResponse |
||||
from fir_ser.settings import CACHE_KEY_TEMPLATE, LOGIN |
||||
from api.utils.storage.caches import login_auth_failed |
||||
import logging |
||||
from api.utils.throttle import VisitRegister1Throttle, VisitRegister2Throttle |
||||
from rest_framework.pagination import PageNumberPagination |
||||
from api.utils.baseutils import format_storage_selection |
||||
|
||||
logger = logging.getLogger(__name__) |
||||
|
||||
|
||||
class AppsPageNumber(PageNumberPagination): |
||||
page_size = 20 # 每页显示多少条 |
||||
page_size_query_param = 'limit' # URL中每页显示条数的参数 |
||||
page_query_param = 'page' # URL中页码的参数 |
||||
max_page_size = None # 最大页码数限制 |
||||
|
||||
|
||||
class OrderInfoView(APIView): |
||||
authentication_classes = [AdminTokenAuthentication, ] |
||||
|
||||
def get(self, request): |
||||
res = BaseResponse() |
||||
filter_fields = ["id", "user_id", "payment_type", "payment_name", "payment_number", "order_number", "status", |
||||
"order_type"] |
||||
filter_data = get_dict_from_filter_fields(filter_fields, request.query_params) |
||||
sort = request.query_params.get("sort", "-created_time") |
||||
page_obj = AppsPageNumber() |
||||
obj_list = Order.objects.filter(**filter_data).order_by(sort) |
||||
page_serializer = page_obj.paginate_queryset(queryset=obj_list, request=request, |
||||
view=self) |
||||
serializer = AdminOrdersSerializer(page_serializer, many=True) |
||||
res.data = serializer.data |
||||
res.total = obj_list.count() |
||||
return Response(res.dict) |
||||
|
||||
def put(self, request): |
||||
res = BaseResponse() |
||||
data = request.data |
||||
pk = data.get("id", None) |
||||
if not pk: |
||||
res.code = 1003 |
||||
res.msg = "参数错误" |
||||
return Response(res.dict) |
||||
obj = Order.objects.filter(pk=pk).first() |
||||
if obj: |
||||
data['pk'] = pk |
||||
serializer = AdminOrdersSerializer(obj, data=data, partial=True) |
||||
if serializer.is_valid(): |
||||
serializer.save() |
||||
res.data = serializer.data |
||||
return Response(res.dict) |
||||
res.code = 1004 |
||||
res.msg = "数据校验失败" |
||||
return Response(res.dict) |
||||
|
||||
|
||||
class OrderPayView(APIView): |
||||
authentication_classes = [AdminTokenAuthentication, ] |
||||
|
||||
def put(self, request): |
||||
res = BaseResponse() |
||||
data = request.data |
||||
pk = data.get("id", None) |
||||
if not pk: |
||||
res.code = 1003 |
||||
res.msg = "参数错误" |
||||
return Response(res.dict) |
||||
obj = UserInfo.objects.filter(pk=pk).first() |
||||
if obj: |
||||
logger.info("user %s update storage data:%s" % (obj, data)) |
||||
use_storage_id = data.get("use_storage_id", None) |
||||
force = data.get("force", None) |
||||
if use_storage_id: |
||||
if not storage_change(use_storage_id, obj, force): |
||||
res.code = 1006 |
||||
res.msg = '修改失败' |
||||
return Response(res.dict) |
||||
|
||||
res.code = 1004 |
||||
res.msg = "数据校验失败" |
||||
return Response(res.dict) |
@ -0,0 +1,49 @@ |
||||
# Generated by Django 3.0.3 on 2021-04-20 14:22 |
||||
|
||||
from django.db import migrations, models |
||||
|
||||
|
||||
class Migration(migrations.Migration): |
||||
dependencies = [ |
||||
('api', '0042_order_payment_name'), |
||||
] |
||||
|
||||
operations = [ |
||||
migrations.RemoveField( |
||||
model_name='appstorage', |
||||
name='additionalparameters', |
||||
), |
||||
migrations.AddField( |
||||
model_name='appstorage', |
||||
name='cnd_auth_key', |
||||
field=models.CharField(blank=True, max_length=128, null=True, verbose_name='阿里云cnd_auth_key'), |
||||
), |
||||
migrations.AddField( |
||||
model_name='appstorage', |
||||
name='download_auth_type', |
||||
field=models.SmallIntegerField( |
||||
choices=[(1, 'OSS模式: 需要把OSS权限开启私有模式'), (2, 'CDN模式: 请先配置好阿里云CDN,开启阿里云OSS私有Bucket回源,将使用鉴权A方式')], |
||||
default=1, verbose_name='阿里云下载授权方式'), |
||||
), |
||||
migrations.AddField( |
||||
model_name='appstorage', |
||||
name='endpoint', |
||||
field=models.CharField(blank=True, max_length=128, null=True, verbose_name='阿里云endpoint'), |
||||
), |
||||
migrations.AddField( |
||||
model_name='appstorage', |
||||
name='sts_role_arn', |
||||
field=models.CharField(blank=True, max_length=128, null=True, verbose_name='阿里云sts_role_arn'), |
||||
), |
||||
migrations.AlterField( |
||||
model_name='usercertificationinfo', |
||||
name='addr', |
||||
field=models.CharField(max_length=128, verbose_name='居住地址'), |
||||
), |
||||
migrations.AlterField( |
||||
model_name='usercertificationinfo', |
||||
name='status', |
||||
field=models.SmallIntegerField(choices=[(-1, '待认证'), (0, '认证中'), (1, '认证成功'), (2, '认证失败')], default=0, |
||||
verbose_name='认证状态'), |
||||
), |
||||
] |
@ -0,0 +1,17 @@ |
||||
# Generated by Django 3.0.3 on 2021-04-22 10:02 |
||||
|
||||
from django.db import migrations |
||||
|
||||
|
||||
class Migration(migrations.Migration): |
||||
dependencies = [ |
||||
('api', '0043_auto_20210420_1422'), |
||||
] |
||||
|
||||
operations = [ |
||||
migrations.RenameField( |
||||
model_name='order', |
||||
old_name='account', |
||||
new_name='user_id', |
||||
), |
||||
] |
Loading…
Reference in new issue