14 changed files with 1021 additions and 108 deletions
@ -0,0 +1,60 @@ |
|||||
|
import request from '@/utils/request' |
||||
|
|
||||
|
|
||||
|
|
||||
|
|
||||
|
|
||||
|
|
||||
|
|
||||
|
// USER_CODE_BEGIN -- campus_pay
|
||||
|
/** |
||||
|
* 获取账户及资金管理列表 |
||||
|
* @param params |
||||
|
* @returns |
||||
|
*/ |
||||
|
export function getCampusPayList(params: Record<string, any>) { |
||||
|
return request.get(`campus_pay/campus_pay`, {params}) |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* 获取账户及资金管理详情 |
||||
|
* @param id 账户及资金管理id |
||||
|
* @returns |
||||
|
*/ |
||||
|
export function getCampusPayInfo(id: number) { |
||||
|
return request.get(`campus_pay/campus_pay/${id}`); |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* 添加账户及资金管理 |
||||
|
* @param params |
||||
|
* @returns |
||||
|
*/ |
||||
|
export function addCampusPay(params: Record<string, any>) { |
||||
|
return request.post('campus_pay/campus_pay', params, { showErrorMessage: true, showSuccessMessage: true }) |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* 编辑账户及资金管理 |
||||
|
* @param id |
||||
|
* @param params |
||||
|
* @returns |
||||
|
*/ |
||||
|
export function editCampusPay(params: Record<string, any>) { |
||||
|
return request.put(`campus_pay/campus_pay/${params.id}`, params, { showErrorMessage: true, showSuccessMessage: true }) |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* 删除账户及资金管理 |
||||
|
* @param id |
||||
|
* @returns |
||||
|
*/ |
||||
|
export function deleteCampusPay(id: number) { |
||||
|
return request.delete(`campus_pay/campus_pay/${id}`, { showErrorMessage: true, showSuccessMessage: true }) |
||||
|
} |
||||
|
|
||||
|
export function getWithCampusList(params: Record<string,any>){ |
||||
|
return request.get('campus_pay/campus_all', {params}) |
||||
|
} |
||||
|
|
||||
|
// USER_CODE_END -- campus_pay
|
||||
@ -0,0 +1,25 @@ |
|||||
|
{ |
||||
|
"id":"", |
||||
|
"idPlaceholder":"请输入", |
||||
|
"campusId":"校区", |
||||
|
"campusIdPlaceholder":"全部", |
||||
|
"mchid":"商户号", |
||||
|
"mchidPlaceholder":"请输入商户号", |
||||
|
"paySignKey":"APIv3密钥", |
||||
|
"paySignKeyPlaceholder":"请输入APIv3密钥", |
||||
|
"apiclientKey":"商户私钥", |
||||
|
"apiclientKeyPlaceholder":"请输入商户私钥", |
||||
|
"apiclientCert":"商户公钥", |
||||
|
"apiclientCertPlaceholder":"请输入商户公钥", |
||||
|
"wxPayKey":"微信支付公钥", |
||||
|
"wxPayKeyPlaceholder":"请输入微信支付公钥", |
||||
|
"wxPayKeyId":"微信支付公钥ID", |
||||
|
"wxPayKeyIdPlaceholder":"请输入微信支付公钥ID", |
||||
|
"createdAt":"创建时间", |
||||
|
"createdAtPlaceholder":"请输入创建时间", |
||||
|
"addCampusPay":"添加账户及资金管理", |
||||
|
"updateCampusPay":"编辑账户及资金管理", |
||||
|
"campusPayDeleteTips":"确定要删除该数据吗?", |
||||
|
"startDate":"请选择开始时间", |
||||
|
"endDate":"请选择结束时间" |
||||
|
} |
||||
@ -0,0 +1,183 @@ |
|||||
|
<template> |
||||
|
<div class="main-container"> |
||||
|
<el-card class="box-card !border-none" shadow="never"> |
||||
|
|
||||
|
<div class="flex justify-between items-center"> |
||||
|
<span class="text-lg">{{pageName}}</span> |
||||
|
<el-button type="primary" @click="addEvent"> |
||||
|
{{ t('addCampusPay') }} |
||||
|
</el-button> |
||||
|
</div> |
||||
|
|
||||
|
<el-card class="box-card !border-none my-[10px] table-search-wrap" shadow="never"> |
||||
|
<el-form :inline="true" :model="campusPayTable.searchParam" ref="searchFormRef"> |
||||
|
|
||||
|
<el-form-item :label="t('campusId')" prop="campus_id"> |
||||
|
<el-select class="w-[280px]" v-model="campusPayTable.searchParam.campus_id" clearable :placeholder="t('campusIdPlaceholder')"> |
||||
|
<el-option |
||||
|
v-for="(item, index) in campusIdList" |
||||
|
:key="index" |
||||
|
:label="item['campus_name']" |
||||
|
:value="item['id']" |
||||
|
/> |
||||
|
</el-select> |
||||
|
</el-form-item> |
||||
|
|
||||
|
<el-form-item :label="t('createdAt')" prop="created_at"> |
||||
|
<el-date-picker v-model="campusPayTable.searchParam.created_at" type="datetimerange" format="YYYY-MM-DD hh:mm:ss" |
||||
|
:start-placeholder="t('startDate')" :end-placeholder="t('endDate')" /> |
||||
|
</el-form-item> |
||||
|
|
||||
|
<el-form-item> |
||||
|
<el-button type="primary" @click="loadCampusPayList()">{{ t('search') }}</el-button> |
||||
|
<el-button @click="resetForm(searchFormRef)">{{ t('reset') }}</el-button> |
||||
|
</el-form-item> |
||||
|
</el-form> |
||||
|
</el-card> |
||||
|
|
||||
|
<div class="mt-[10px]"> |
||||
|
<el-table :data="campusPayTable.data" size="large" v-loading="campusPayTable.loading"> |
||||
|
<template #empty> |
||||
|
<span>{{ !campusPayTable.loading ? t('emptyData') : '' }}</span> |
||||
|
</template> |
||||
|
<el-table-column prop="campus_id_name" :label="t('campusId')" min-width="120" :show-overflow-tooltip="true"/> |
||||
|
|
||||
|
<el-table-column prop="mchid" :label="t('mchid')" min-width="120" :show-overflow-tooltip="true"/> |
||||
|
|
||||
|
<el-table-column prop="created_at" :label="t('createdAt')" min-width="120" :show-overflow-tooltip="true"/> |
||||
|
|
||||
|
<el-table-column :label="t('operation')" fixed="right" min-width="120"> |
||||
|
<template #default="{ row }"> |
||||
|
<el-button type="primary" link @click="editEvent(row)">{{ t('edit') }}</el-button> |
||||
|
<el-button type="primary" link @click="deleteEvent(row.id)">{{ t('delete') }}</el-button> |
||||
|
</template> |
||||
|
</el-table-column> |
||||
|
|
||||
|
</el-table> |
||||
|
<div class="mt-[16px] flex justify-end"> |
||||
|
<el-pagination v-model:current-page="campusPayTable.page" v-model:page-size="campusPayTable.limit" |
||||
|
layout="total, sizes, prev, pager, next, jumper" :total="campusPayTable.total" |
||||
|
@size-change="loadCampusPayList()" @current-change="loadCampusPayList" /> |
||||
|
</div> |
||||
|
</div> |
||||
|
|
||||
|
<edit ref="editCampusPayDialog" @complete="loadCampusPayList" /> |
||||
|
</el-card> |
||||
|
</div> |
||||
|
</template> |
||||
|
|
||||
|
<script lang="ts" setup> |
||||
|
import { reactive, ref, watch } from 'vue' |
||||
|
import { t } from '@/lang' |
||||
|
import { useDictionary } from '@/app/api/dict' |
||||
|
import { getCampusPayList, deleteCampusPay, getWithCampusList } from '@/app/api/campus_pay' |
||||
|
import { img } from '@/utils/common' |
||||
|
import { ElMessageBox,FormInstance } from 'element-plus' |
||||
|
import Edit from '@/app/views/campus_pay/components/campus-pay-edit.vue' |
||||
|
import { useRoute } from 'vue-router' |
||||
|
const route = useRoute() |
||||
|
const pageName = route.meta.title; |
||||
|
|
||||
|
let campusPayTable = reactive({ |
||||
|
page: 1, |
||||
|
limit: 10, |
||||
|
total: 0, |
||||
|
loading: true, |
||||
|
data: [], |
||||
|
searchParam:{ |
||||
|
"campus_id":"", |
||||
|
"created_at":[] |
||||
|
} |
||||
|
}) |
||||
|
|
||||
|
const searchFormRef = ref<FormInstance>() |
||||
|
|
||||
|
// 选中数据 |
||||
|
const selectData = ref<any[]>([]) |
||||
|
|
||||
|
// 字典数据 |
||||
|
|
||||
|
|
||||
|
/** |
||||
|
* 获取账户及资金管理列表 |
||||
|
*/ |
||||
|
const loadCampusPayList = (page: number = 1) => { |
||||
|
campusPayTable.loading = true |
||||
|
campusPayTable.page = page |
||||
|
|
||||
|
getCampusPayList({ |
||||
|
page: campusPayTable.page, |
||||
|
limit: campusPayTable.limit, |
||||
|
...campusPayTable.searchParam |
||||
|
}).then(res => { |
||||
|
campusPayTable.loading = false |
||||
|
campusPayTable.data = res.data.data |
||||
|
campusPayTable.total = res.data.total |
||||
|
}).catch(() => { |
||||
|
campusPayTable.loading = false |
||||
|
}) |
||||
|
} |
||||
|
loadCampusPayList() |
||||
|
|
||||
|
const editCampusPayDialog: Record<string, any> | null = ref(null) |
||||
|
|
||||
|
/** |
||||
|
* 添加账户及资金管理 |
||||
|
*/ |
||||
|
const addEvent = () => { |
||||
|
editCampusPayDialog.value.setFormData() |
||||
|
editCampusPayDialog.value.showDialog = true |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* 编辑账户及资金管理 |
||||
|
* @param data |
||||
|
*/ |
||||
|
const editEvent = (data: any) => { |
||||
|
editCampusPayDialog.value.setFormData(data) |
||||
|
editCampusPayDialog.value.showDialog = true |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* 删除账户及资金管理 |
||||
|
*/ |
||||
|
const deleteEvent = (id: number) => { |
||||
|
ElMessageBox.confirm(t('campusPayDeleteTips'), t('warning'), |
||||
|
{ |
||||
|
confirmButtonText: t('confirm'), |
||||
|
cancelButtonText: t('cancel'), |
||||
|
type: 'warning', |
||||
|
} |
||||
|
).then(() => { |
||||
|
deleteCampusPay(id).then(() => { |
||||
|
loadCampusPayList() |
||||
|
}).catch(() => { |
||||
|
}) |
||||
|
}) |
||||
|
} |
||||
|
|
||||
|
|
||||
|
const campusIdList = ref([]) |
||||
|
const setCampusIdList = async () => { |
||||
|
campusIdList.value = await (await getWithCampusList({})).data |
||||
|
} |
||||
|
setCampusIdList() |
||||
|
|
||||
|
const resetForm = (formEl: FormInstance | undefined) => { |
||||
|
if (!formEl) return |
||||
|
formEl.resetFields() |
||||
|
loadCampusPayList() |
||||
|
} |
||||
|
</script> |
||||
|
|
||||
|
<style lang="scss" scoped> |
||||
|
/* 多行超出隐藏 */ |
||||
|
.multi-hidden { |
||||
|
word-break: break-all; |
||||
|
text-overflow: ellipsis; |
||||
|
overflow: hidden; |
||||
|
display: -webkit-box; |
||||
|
-webkit-line-clamp: 2; |
||||
|
-webkit-box-orient: vertical; |
||||
|
} |
||||
|
</style> |
||||
@ -0,0 +1,216 @@ |
|||||
|
<template> |
||||
|
<el-dialog v-model="showDialog" :title="formData.id ? t('updateCampusPay') : t('addCampusPay')" width="50%" class="diy-dialog-wrap" :destroy-on-close="true"> |
||||
|
<el-form :model="formData" label-width="120px" ref="formRef" :rules="formRules" class="page-form" v-loading="loading"> |
||||
|
<el-form-item :label="t('campusId')" prop="campus_id"> |
||||
|
<el-select class="input-width" v-model="formData.campus_id" clearable :placeholder="t('campusIdPlaceholder')"> |
||||
|
<el-option label="请选择" value=""></el-option> |
||||
|
<el-option |
||||
|
v-for="(item, index) in campusIdList" |
||||
|
:key="index" |
||||
|
:label="item['campus_name']" |
||||
|
:value="item['id']" |
||||
|
/> |
||||
|
</el-select> |
||||
|
</el-form-item> |
||||
|
|
||||
|
<el-form-item :label="t('mchid')" prop="mchid"> |
||||
|
<el-input v-model="formData.mchid" clearable :placeholder="t('mchidPlaceholder')" class="input-width" /> |
||||
|
</el-form-item> |
||||
|
|
||||
|
<el-form-item :label="t('paySignKey')" prop="pay_sign_key"> |
||||
|
<el-input v-model="formData.pay_sign_key" clearable :placeholder="t('paySignKeyPlaceholder')" class="input-width" /> |
||||
|
</el-form-item> |
||||
|
|
||||
|
<el-form-item :label="t('apiclientKey')"> |
||||
|
<upload-file v-model="formData.apiclient_key" /> |
||||
|
</el-form-item> |
||||
|
|
||||
|
<el-form-item :label="t('apiclientCert')"> |
||||
|
<upload-file v-model="formData.apiclient_cert" /> |
||||
|
</el-form-item> |
||||
|
|
||||
|
<el-form-item :label="t('wxPayKey')"> |
||||
|
<upload-file v-model="formData.wx_pay_key" /> |
||||
|
</el-form-item> |
||||
|
|
||||
|
<el-form-item :label="t('wxPayKeyId')" prop="wx_pay_key_id"> |
||||
|
<el-input v-model="formData.wx_pay_key_id" clearable :placeholder="t('wxPayKeyIdPlaceholder')" class="input-width" /> |
||||
|
</el-form-item> |
||||
|
|
||||
|
</el-form> |
||||
|
|
||||
|
<template #footer> |
||||
|
<span class="dialog-footer"> |
||||
|
<el-button @click="showDialog = false">{{ t('cancel') }}</el-button> |
||||
|
<el-button type="primary" :loading="loading" @click="confirm(formRef)">{{ |
||||
|
t('confirm') |
||||
|
}}</el-button> |
||||
|
</span> |
||||
|
</template> |
||||
|
</el-dialog> |
||||
|
</template> |
||||
|
|
||||
|
<script lang="ts" setup> |
||||
|
import { ref, reactive, computed, watch } from 'vue' |
||||
|
import { useDictionary } from '@/app/api/dict' |
||||
|
import { t } from '@/lang' |
||||
|
import type { FormInstance } from 'element-plus' |
||||
|
import { addCampusPay, editCampusPay, getCampusPayInfo, getWithCampusList } from '@/app/api/campus_pay' |
||||
|
|
||||
|
let showDialog = ref(false) |
||||
|
const loading = ref(false) |
||||
|
|
||||
|
/** |
||||
|
* 表单数据 |
||||
|
*/ |
||||
|
const initialFormData = { |
||||
|
id: '', |
||||
|
campus_id: '', |
||||
|
mchid: '', |
||||
|
pay_sign_key: '', |
||||
|
apiclient_key: '', |
||||
|
apiclient_cert: '', |
||||
|
wx_pay_key: '', |
||||
|
wx_pay_key_id: '', |
||||
|
} |
||||
|
const formData: Record<string, any> = reactive({ ...initialFormData }) |
||||
|
|
||||
|
const formRef = ref<FormInstance>() |
||||
|
|
||||
|
// 表单验证规则 |
||||
|
const formRules = computed(() => { |
||||
|
return { |
||||
|
campus_id: [ |
||||
|
{ required: true, message: t('campusIdPlaceholder'), trigger: 'blur' }, |
||||
|
|
||||
|
] |
||||
|
, |
||||
|
mchid: [ |
||||
|
{ required: true, message: t('mchidPlaceholder'), trigger: 'blur' }, |
||||
|
|
||||
|
] |
||||
|
, |
||||
|
pay_sign_key: [ |
||||
|
{ required: true, message: t('paySignKeyPlaceholder'), trigger: 'blur' }, |
||||
|
|
||||
|
] |
||||
|
, |
||||
|
apiclient_key: [ |
||||
|
{ required: true, message: t('apiclientKeyPlaceholder'), trigger: 'blur' }, |
||||
|
|
||||
|
] |
||||
|
, |
||||
|
apiclient_cert: [ |
||||
|
{ required: true, message: t('apiclientCertPlaceholder'), trigger: 'blur' }, |
||||
|
|
||||
|
] |
||||
|
, |
||||
|
wx_pay_key: [ |
||||
|
{ required: true, message: t('wxPayKeyPlaceholder'), trigger: 'blur' }, |
||||
|
|
||||
|
] |
||||
|
, |
||||
|
wx_pay_key_id: [ |
||||
|
{ required: true, message: t('wxPayKeyIdPlaceholder'), trigger: 'blur' }, |
||||
|
|
||||
|
] |
||||
|
, |
||||
|
} |
||||
|
}) |
||||
|
|
||||
|
const emit = defineEmits(['complete']) |
||||
|
|
||||
|
/** |
||||
|
* 确认 |
||||
|
* @param formEl |
||||
|
*/ |
||||
|
const confirm = async (formEl: FormInstance | undefined) => { |
||||
|
if (loading.value || !formEl) return |
||||
|
let save = formData.id ? editCampusPay : addCampusPay |
||||
|
|
||||
|
await formEl.validate(async (valid) => { |
||||
|
if (valid) { |
||||
|
loading.value = true |
||||
|
|
||||
|
let data = formData |
||||
|
|
||||
|
save(data).then(res => { |
||||
|
loading.value = false |
||||
|
showDialog.value = false |
||||
|
emit('complete') |
||||
|
}).catch(err => { |
||||
|
loading.value = false |
||||
|
}) |
||||
|
} |
||||
|
}) |
||||
|
} |
||||
|
|
||||
|
// 获取字典数据 |
||||
|
|
||||
|
|
||||
|
|
||||
|
const campusIdList = ref([] as any[]) |
||||
|
const setCampusIdList = async () => { |
||||
|
campusIdList.value = await (await getWithCampusList({})).data |
||||
|
} |
||||
|
setCampusIdList() |
||||
|
const setFormData = async (row: any = null) => { |
||||
|
Object.assign(formData, initialFormData) |
||||
|
loading.value = true |
||||
|
if(row){ |
||||
|
const data = await (await getCampusPayInfo(row.id)).data |
||||
|
if (data) Object.keys(formData).forEach((key: string) => { |
||||
|
if (data[key] != undefined) formData[key] = data[key] |
||||
|
}) |
||||
|
} |
||||
|
loading.value = false |
||||
|
} |
||||
|
|
||||
|
// 验证手机号格式 |
||||
|
const mobileVerify = (rule: any, value: any, callback: any) => { |
||||
|
if (value && !/^1[3-9]\d{9}$/.test(value)) { |
||||
|
callback(new Error(t('generateMobile'))) |
||||
|
} else { |
||||
|
callback() |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
// 验证身份证号 |
||||
|
const idCardVerify = (rule: any, value: any, callback: any) => { |
||||
|
if (value && !/^[1-9]\d{5}[1-9]\d{3}((0\d)|(1[0-2]))(([0|1|2]\d)|3[0-1])\d{3}([0-9]|X)$/.test(value)) { |
||||
|
callback(new Error(t('generateIdCard'))) |
||||
|
} else { |
||||
|
callback() |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
// 验证邮箱号 |
||||
|
const emailVerify = (rule: any, value: any, callback: any) => { |
||||
|
if (value && !/\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*/.test(value)) { |
||||
|
callback(new Error(t('generateEmail'))) |
||||
|
} else { |
||||
|
callback() |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
// 验证请输入整数 |
||||
|
const numberVerify = (rule: any, value: any, callback: any) => { |
||||
|
if (!Number.isInteger(value)) { |
||||
|
callback(new Error(t('generateNumber'))) |
||||
|
} else { |
||||
|
callback() |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
defineExpose({ |
||||
|
showDialog, |
||||
|
setFormData |
||||
|
}) |
||||
|
</script> |
||||
|
|
||||
|
<style lang="scss" scoped></style> |
||||
|
<style lang="scss"> |
||||
|
.diy-dialog-wrap .el-form-item__label{ |
||||
|
height: auto !important; |
||||
|
} |
||||
|
</style> |
||||
@ -0,0 +1,102 @@ |
|||||
|
<?php |
||||
|
// +---------------------------------------------------------------------- |
||||
|
// | Niucloud-admin 企业快速开发的多应用管理平台 |
||||
|
// +---------------------------------------------------------------------- |
||||
|
// | 官方网址:https://www.niucloud.com |
||||
|
// +---------------------------------------------------------------------- |
||||
|
// | niucloud团队 版权所有 开源版本可自由商用 |
||||
|
// +---------------------------------------------------------------------- |
||||
|
// | Author: Niucloud Team |
||||
|
// +---------------------------------------------------------------------- |
||||
|
|
||||
|
namespace app\adminapi\controller\campus_pay; |
||||
|
|
||||
|
use core\base\BaseAdminController; |
||||
|
use app\service\admin\campus_pay\CampusPayService; |
||||
|
|
||||
|
|
||||
|
/** |
||||
|
* 账户及资金管理控制器 |
||||
|
* Class CampusPay |
||||
|
* @package app\adminapi\controller\campus_pay |
||||
|
*/ |
||||
|
class CampusPay extends BaseAdminController |
||||
|
{ |
||||
|
/** |
||||
|
* 获取账户及资金管理列表 |
||||
|
* @return \think\Response |
||||
|
*/ |
||||
|
public function lists(){ |
||||
|
$data = $this->request->params([ |
||||
|
["campus_id",""], |
||||
|
["created_at",["",""]] |
||||
|
]); |
||||
|
return success((new CampusPayService())->getPage($data)); |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* 账户及资金管理详情 |
||||
|
* @param int $id |
||||
|
* @return \think\Response |
||||
|
*/ |
||||
|
public function info(int $id){ |
||||
|
return success((new CampusPayService())->getInfo($id)); |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* 添加账户及资金管理 |
||||
|
* @return \think\Response |
||||
|
*/ |
||||
|
public function add(){ |
||||
|
$data = $this->request->params([ |
||||
|
["campus_id",0], |
||||
|
["mchid",""], |
||||
|
["pay_sign_key",""], |
||||
|
["apiclient_key",""], |
||||
|
["apiclient_cert",""], |
||||
|
["wx_pay_key",""], |
||||
|
["wx_pay_key_id",""], |
||||
|
|
||||
|
]); |
||||
|
$this->validate($data, 'app\validate\campus_pay\CampusPay.add'); |
||||
|
$id = (new CampusPayService())->add($data); |
||||
|
return success('ADD_SUCCESS', ['id' => $id]); |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* 账户及资金管理编辑 |
||||
|
* @param $id 账户及资金管理id |
||||
|
* @return \think\Response |
||||
|
*/ |
||||
|
public function edit(int $id){ |
||||
|
$data = $this->request->params([ |
||||
|
["campus_id",0], |
||||
|
["mchid",""], |
||||
|
["pay_sign_key",""], |
||||
|
["apiclient_key",""], |
||||
|
["apiclient_cert",""], |
||||
|
["wx_pay_key",""], |
||||
|
["wx_pay_key_id",""], |
||||
|
|
||||
|
]); |
||||
|
$this->validate($data, 'app\validate\campus_pay\CampusPay.edit'); |
||||
|
(new CampusPayService())->edit($id, $data); |
||||
|
return success('EDIT_SUCCESS'); |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* 账户及资金管理删除 |
||||
|
* @param $id 账户及资金管理id |
||||
|
* @return \think\Response |
||||
|
*/ |
||||
|
public function del(int $id){ |
||||
|
(new CampusPayService())->del($id); |
||||
|
return success('DELETE_SUCCESS'); |
||||
|
} |
||||
|
|
||||
|
|
||||
|
public function getCampusAll(){ |
||||
|
return success(( new CampusPayService())->getCampusAll()); |
||||
|
} |
||||
|
|
||||
|
} |
||||
@ -0,0 +1,42 @@ |
|||||
|
<?php |
||||
|
// +---------------------------------------------------------------------- |
||||
|
// | Niucloud-admin 企业快速开发的多应用管理平台 |
||||
|
// +---------------------------------------------------------------------- |
||||
|
// | 官方网址:https://www.niucloud.com |
||||
|
// +---------------------------------------------------------------------- |
||||
|
// | niucloud团队 版权所有 开源版本可自由商用 |
||||
|
// +---------------------------------------------------------------------- |
||||
|
// | Author: Niucloud Team |
||||
|
// +---------------------------------------------------------------------- |
||||
|
|
||||
|
use think\facade\Route; |
||||
|
|
||||
|
use app\adminapi\middleware\AdminCheckRole; |
||||
|
use app\adminapi\middleware\AdminCheckToken; |
||||
|
use app\adminapi\middleware\AdminLog; |
||||
|
|
||||
|
|
||||
|
|
||||
|
// USER_CODE_BEGIN -- campus_pay |
||||
|
|
||||
|
Route::group('campus_pay', function () { |
||||
|
|
||||
|
//账户及资金管理列表 |
||||
|
Route::get('campus_pay', 'campus_pay.CampusPay/lists'); |
||||
|
//账户及资金管理详情 |
||||
|
Route::get('campus_pay/:id', 'campus_pay.CampusPay/info'); |
||||
|
//添加账户及资金管理 |
||||
|
Route::post('campus_pay', 'campus_pay.CampusPay/add'); |
||||
|
//编辑账户及资金管理 |
||||
|
Route::put('campus_pay/:id', 'campus_pay.CampusPay/edit'); |
||||
|
//删除账户及资金管理 |
||||
|
Route::delete('campus_pay/:id', 'campus_pay.CampusPay/del'); |
||||
|
|
||||
|
Route::get('campus_all','campus_pay.CampusPay/getCampusAll'); |
||||
|
|
||||
|
})->middleware([ |
||||
|
AdminCheckToken::class, |
||||
|
AdminCheckRole::class, |
||||
|
AdminLog::class |
||||
|
]); |
||||
|
// USER_CODE_END -- campus_pay |
||||
@ -0,0 +1,98 @@ |
|||||
|
<?php |
||||
|
// +---------------------------------------------------------------------- |
||||
|
// | Niucloud-admin 企业快速开发的多应用管理平台 |
||||
|
// +---------------------------------------------------------------------- |
||||
|
// | 官方网址:https://www.niucloud.com |
||||
|
// +---------------------------------------------------------------------- |
||||
|
// | niucloud团队 版权所有 开源版本可自由商用 |
||||
|
// +---------------------------------------------------------------------- |
||||
|
// | Author: Niucloud Team |
||||
|
// +---------------------------------------------------------------------- |
||||
|
|
||||
|
namespace app\model\campus_pay; |
||||
|
|
||||
|
use core\base\BaseModel; |
||||
|
use think\model\concern\SoftDelete; |
||||
|
use think\model\relation\HasMany; |
||||
|
use think\model\relation\HasOne; |
||||
|
|
||||
|
use app\model\campus\Campus; |
||||
|
|
||||
|
/** |
||||
|
* 账户及资金管理模型 |
||||
|
* Class CampusPay |
||||
|
* @package app\model\campus_pay |
||||
|
*/ |
||||
|
class CampusPay extends BaseModel |
||||
|
{ |
||||
|
|
||||
|
|
||||
|
|
||||
|
/** |
||||
|
* 数据表主键 |
||||
|
* @var string |
||||
|
*/ |
||||
|
protected $pk = 'id'; |
||||
|
|
||||
|
/** |
||||
|
* 模型名称 |
||||
|
* @var string |
||||
|
*/ |
||||
|
protected $name = 'campus_pay'; |
||||
|
|
||||
|
|
||||
|
|
||||
|
|
||||
|
|
||||
|
/** |
||||
|
* 搜索器:账户及资金管理 |
||||
|
* @param $value |
||||
|
* @param $data |
||||
|
*/ |
||||
|
public function searchIdAttr($query, $value, $data) |
||||
|
{ |
||||
|
if ($value) { |
||||
|
$query->where("id", $value); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* 搜索器:账户及资金管理校区 |
||||
|
* @param $value |
||||
|
* @param $data |
||||
|
*/ |
||||
|
public function searchCampusIdAttr($query, $value, $data) |
||||
|
{ |
||||
|
if ($value) { |
||||
|
$query->where("campus_id", $value); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* 搜索器:账户及资金管理创建时间 |
||||
|
* @param $value |
||||
|
* @param $data |
||||
|
*/ |
||||
|
public function searchCreatedAtAttr($query, $value, $data) |
||||
|
{ |
||||
|
$start = empty($value[0]) ? 0 : strtotime($value[0]); |
||||
|
$end = empty($value[1]) ? 0 : strtotime($value[1]); |
||||
|
if ($start > 0 && $end > 0) { |
||||
|
$query->where([["created_at", "between", [$start, $end]]]); |
||||
|
} else if ($start > 0 && $end == 0) { |
||||
|
$query->where([["created_at", ">=", $start]]); |
||||
|
} else if ($start == 0 && $end > 0) { |
||||
|
$query->where([["created_at", "<=", $end]]); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
|
||||
|
|
||||
|
|
||||
|
|
||||
|
|
||||
|
public function campus(){ |
||||
|
return $this->hasOne(Campus::class, 'id', 'campus_id')->joinType('left')->withField('campus_name,id')->bind(['campus_id_name'=>'campus_name']); |
||||
|
} |
||||
|
|
||||
|
} |
||||
@ -0,0 +1,105 @@ |
|||||
|
<?php |
||||
|
// +---------------------------------------------------------------------- |
||||
|
// | Niucloud-admin 企业快速开发的多应用管理平台 |
||||
|
// +---------------------------------------------------------------------- |
||||
|
// | 官方网址:https://www.niucloud.com |
||||
|
// +---------------------------------------------------------------------- |
||||
|
// | niucloud团队 版权所有 开源版本可自由商用 |
||||
|
// +---------------------------------------------------------------------- |
||||
|
// | Author: Niucloud Team |
||||
|
// +---------------------------------------------------------------------- |
||||
|
|
||||
|
namespace app\service\admin\campus_pay; |
||||
|
|
||||
|
use app\model\campus_pay\CampusPay; |
||||
|
use app\model\campus\Campus; |
||||
|
|
||||
|
use core\base\BaseAdminService; |
||||
|
|
||||
|
|
||||
|
/** |
||||
|
* 账户及资金管理服务层 |
||||
|
* Class CampusPayService |
||||
|
* @package app\service\admin\campus_pay |
||||
|
*/ |
||||
|
class CampusPayService extends BaseAdminService |
||||
|
{ |
||||
|
public function __construct() |
||||
|
{ |
||||
|
parent::__construct(); |
||||
|
$this->model = new CampusPay(); |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* 获取账户及资金管理列表 |
||||
|
* @param array $where |
||||
|
* @return array |
||||
|
*/ |
||||
|
public function getPage(array $where = []) |
||||
|
{ |
||||
|
$field = 'id,campus_id,mchid,pay_sign_key,apiclient_key,apiclient_cert,wx_pay_key,wx_pay_key_id,created_at,updated_at'; |
||||
|
$order = 'id desc'; |
||||
|
|
||||
|
$search_model = $this->model->withSearch(["id","campus_id","created_at"], $where)->with(['campus'])->field($field)->order($order); |
||||
|
$list = $this->pageQuery($search_model); |
||||
|
return $list; |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* 获取账户及资金管理信息 |
||||
|
* @param int $id |
||||
|
* @return array |
||||
|
*/ |
||||
|
public function getInfo(int $id) |
||||
|
{ |
||||
|
$field = 'id,campus_id,mchid,pay_sign_key,apiclient_key,apiclient_cert,wx_pay_key,wx_pay_key_id,created_at,updated_at'; |
||||
|
|
||||
|
$info = $this->model->field($field)->where([['id', "=", $id]])->with(['campus'])->findOrEmpty()->toArray(); |
||||
|
return $info; |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* 添加账户及资金管理 |
||||
|
* @param array $data |
||||
|
* @return mixed |
||||
|
*/ |
||||
|
public function add(array $data) |
||||
|
{ |
||||
|
$res = $this->model->create($data); |
||||
|
return $res->id; |
||||
|
|
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* 账户及资金管理编辑 |
||||
|
* @param int $id |
||||
|
* @param array $data |
||||
|
* @return bool |
||||
|
*/ |
||||
|
public function edit(int $id, array $data) |
||||
|
{ |
||||
|
|
||||
|
$this->model->where([['id', '=', $id]])->update($data); |
||||
|
return true; |
||||
|
} |
||||
|
|
||||
|
/** |
||||
|
* 删除账户及资金管理 |
||||
|
* @param int $id |
||||
|
* @return bool |
||||
|
*/ |
||||
|
public function del(int $id) |
||||
|
{ |
||||
|
$model = $this->model->where([['id', '=', $id]])->find(); |
||||
|
$res = $model->delete(); |
||||
|
return $res; |
||||
|
} |
||||
|
|
||||
|
|
||||
|
public function getCampusAll(){ |
||||
|
$campusModel = new Campus(); |
||||
|
return $campusModel->select()->toArray(); |
||||
|
} |
||||
|
|
||||
|
|
||||
|
} |
||||
@ -0,0 +1,47 @@ |
|||||
|
<?php |
||||
|
// +---------------------------------------------------------------------- |
||||
|
// | Niucloud-admin 企业快速开发的多应用管理平台 |
||||
|
// +---------------------------------------------------------------------- |
||||
|
// | 官方网址:https://www.niucloud.com |
||||
|
// +---------------------------------------------------------------------- |
||||
|
// | niucloud团队 版权所有 开源版本可自由商用 |
||||
|
// +---------------------------------------------------------------------- |
||||
|
// | Author: Niucloud Team |
||||
|
// +---------------------------------------------------------------------- |
||||
|
|
||||
|
namespace app\validate\campus_pay; |
||||
|
use core\base\BaseValidate; |
||||
|
/** |
||||
|
* 账户及资金管理验证器 |
||||
|
* Class CampusPay |
||||
|
* @package addon\app\validate\campus_pay |
||||
|
*/ |
||||
|
class CampusPay extends BaseValidate |
||||
|
{ |
||||
|
|
||||
|
protected $rule = [ |
||||
|
'campus_id' => 'require', |
||||
|
'mchid' => 'require', |
||||
|
'pay_sign_key' => 'require', |
||||
|
'apiclient_key' => 'require', |
||||
|
'apiclient_cert' => 'require', |
||||
|
'wx_pay_key' => 'require', |
||||
|
'wx_pay_key_id' => 'require', |
||||
|
]; |
||||
|
|
||||
|
protected $message = [ |
||||
|
'campus_id.require' => ['common_validate.require', ['campus_id']], |
||||
|
'mchid.require' => ['common_validate.require', ['mchid']], |
||||
|
'pay_sign_key.require' => ['common_validate.require', ['pay_sign_key']], |
||||
|
'apiclient_key.require' => ['common_validate.require', ['apiclient_key']], |
||||
|
'apiclient_cert.require' => ['common_validate.require', ['apiclient_cert']], |
||||
|
'wx_pay_key.require' => ['common_validate.require', ['wx_pay_key']], |
||||
|
'wx_pay_key_id.require' => ['common_validate.require', ['wx_pay_key_id']], |
||||
|
]; |
||||
|
|
||||
|
protected $scene = [ |
||||
|
"add" => ['campus_id', 'mchid', 'pay_sign_key', 'apiclient_key', 'apiclient_cert', 'wx_pay_key', 'wx_pay_key_id'], |
||||
|
"edit" => ['campus_id', 'mchid', 'pay_sign_key', 'apiclient_key', 'apiclient_cert', 'wx_pay_key', 'wx_pay_key_id'] |
||||
|
]; |
||||
|
|
||||
|
} |
||||
Loading…
Reference in new issue