支付订单后台管理

This commit is contained in:
chenbo 2023-11-29 09:44:22 +08:00
parent 9c4ee10d05
commit 875bb256fd
5 changed files with 466 additions and 0 deletions

View File

@ -0,0 +1,108 @@
<?php
// +----------------------------------------------------------------------
// | likeadmin快速开发前后端分离管理后台PHP版
// +----------------------------------------------------------------------
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
// | 开源版本可自由商用可去除界面版权logo
// | gitee下载https://gitee.com/likeshop_gitee/likeadmin
// | github下载https://github.com/likeshop-github/likeadmin
// | 访问官网https://www.likeadmin.cn
// | likeadmin团队 版权所有 拥有最终解释权
// +----------------------------------------------------------------------
// | author: likeadminTeam
// +----------------------------------------------------------------------
namespace app\adminapi\controller;
use app\adminapi\controller\BaseAdminController;
use app\adminapi\lists\PayOrderLists;
use app\adminapi\logic\PayOrderLogic;
use app\adminapi\validate\PayOrderValidate;
/**
* PayOrder控制器
* Class PayOrderController
* @package app\adminapi\controller
*/
class PayOrderController extends BaseAdminController
{
/**
* @notes 获取列表
* @return \think\response\Json
* @author likeadmin
* @date 2023/11/24 18:08
*/
public function lists()
{
return $this->dataLists(new PayOrderLists());
}
/**
* @notes 添加
* @return \think\response\Json
* @author likeadmin
* @date 2023/11/24 18:08
*/
public function add()
{
$params = (new PayOrderValidate())->post()->goCheck('add');
$result = PayOrderLogic::add($params);
if (true === $result) {
return $this->success('添加成功', [], 1, 1);
}
return $this->fail(PayOrderLogic::getError());
}
/**
* @notes 编辑
* @return \think\response\Json
* @author likeadmin
* @date 2023/11/24 18:08
*/
public function edit()
{
$params = (new PayOrderValidate())->post()->goCheck('edit');
$result = PayOrderLogic::edit($params);
if (true === $result) {
return $this->success('编辑成功', [], 1, 1);
}
return $this->fail(PayOrderLogic::getError());
}
/**
* @notes 删除
* @return \think\response\Json
* @author likeadmin
* @date 2023/11/24 18:08
*/
public function delete()
{
$params = (new PayOrderValidate())->post()->goCheck('delete');
PayOrderLogic::delete($params);
return $this->success('删除成功', [], 1, 1);
}
/**
* @notes 获取详情
* @return \think\response\Json
* @author likeadmin
* @date 2023/11/24 18:08
*/
public function detail()
{
$params = (new PayOrderValidate())->goCheck('detail');
$result = PayOrderLogic::detail($params);
return $this->data($result);
}
}

View File

@ -0,0 +1,78 @@
<?php
// +----------------------------------------------------------------------
// | likeadmin快速开发前后端分离管理后台PHP版
// +----------------------------------------------------------------------
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
// | 开源版本可自由商用可去除界面版权logo
// | gitee下载https://gitee.com/likeshop_gitee/likeadmin
// | github下载https://github.com/likeshop-github/likeadmin
// | 访问官网https://www.likeadmin.cn
// | likeadmin团队 版权所有 拥有最终解释权
// +----------------------------------------------------------------------
// | author: likeadminTeam
// +----------------------------------------------------------------------
namespace app\adminapi\lists;
use app\adminapi\lists\BaseAdminDataLists;
use app\common\model\PayOrder;
use app\common\lists\ListsSearchInterface;
/**
* PayOrder列表
* Class PayOrderLists
* @package app\adminapi\lists
*/
class PayOrderLists extends BaseAdminDataLists implements ListsSearchInterface
{
/**
* @notes 设置搜索条件
* @return \string[][]
* @author likeadmin
* @date 2023/11/24 18:08
*/
public function setSearch(): array
{
return [
'=' => ['collection_account', 'order_no', 'business_order_no', 'pay_type', 'pay_status', 'transaction_id', 'finish_time'],
'between' => ['order_from', 'order_type'],
];
}
/**
* @notes 获取列表
* @return array
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\DbException
* @throws \think\db\exception\ModelNotFoundException
* @author likeadmin
* @date 2023/11/24 18:08
*/
public function lists(): array
{
return PayOrder::where($this->searchWhere)
->field(['id', 'order_from', 'order_type', 'collection_account', 'pay_user_role', 'pay_user_info', 'order_no', 'business_order_no', 'total_fee', 'pay_type', 'pay_status', 'transaction_id', 'finish_time'])
->limit($this->limitOffset, $this->limitLength)
->order(['id' => 'desc'])
->select()
->toArray();
}
/**
* @notes 获取数量
* @return int
* @author likeadmin
* @date 2023/11/24 18:08
*/
public function count(): int
{
return PayOrder::where($this->searchWhere)->count();
}
}

View File

@ -0,0 +1,130 @@
<?php
// +----------------------------------------------------------------------
// | likeadmin快速开发前后端分离管理后台PHP版
// +----------------------------------------------------------------------
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
// | 开源版本可自由商用可去除界面版权logo
// | gitee下载https://gitee.com/likeshop_gitee/likeadmin
// | github下载https://github.com/likeshop-github/likeadmin
// | 访问官网https://www.likeadmin.cn
// | likeadmin团队 版权所有 拥有最终解释权
// +----------------------------------------------------------------------
// | author: likeadminTeam
// +----------------------------------------------------------------------
namespace app\adminapi\logic;
use app\common\model\PayOrder;
use app\common\logic\BaseLogic;
use think\facade\Db;
/**
* PayOrder逻辑
* Class PayOrderLogic
* @package app\adminapi\logic
*/
class PayOrderLogic extends BaseLogic
{
/**
* @notes 添加
* @param array $params
* @return bool
* @author likeadmin
* @date 2023/11/24 18:08
*/
public static function add(array $params): bool
{
Db::startTrans();
try {
PayOrder::create([
'order_from' => $params['order_from'],
'order_type' => $params['order_type'],
'collection_account' => $params['collection_account'],
'pay_user_role' => $params['pay_user_role'],
'pay_user_info' => $params['pay_user_info'],
'order_no' => $params['order_no'],
'business_order_no' => $params['business_order_no'],
'total_fee' => $params['total_fee'],
'pay_type' => $params['pay_type'],
'pay_status' => $params['pay_status'],
'business_callback_url' => $params['business_callback_url'],
'transaction_id' => $params['transaction_id'],
'finish_time' => $params['finish_time']
]);
Db::commit();
return true;
} catch (\Exception $e) {
Db::rollback();
self::setError($e->getMessage());
return false;
}
}
/**
* @notes 编辑
* @param array $params
* @return bool
* @author likeadmin
* @date 2023/11/24 18:08
*/
public static function edit(array $params): bool
{
Db::startTrans();
try {
PayOrder::where('id', $params['id'])->update([
'order_from' => $params['order_from'],
'order_type' => $params['order_type'],
'collection_account' => $params['collection_account'],
'pay_user_role' => $params['pay_user_role'],
'pay_user_info' => $params['pay_user_info'],
'order_no' => $params['order_no'],
'business_order_no' => $params['business_order_no'],
'total_fee' => $params['total_fee'],
'pay_type' => $params['pay_type'],
'pay_status' => $params['pay_status'],
'business_callback_url' => $params['business_callback_url'],
'transaction_id' => $params['transaction_id'],
'finish_time' => $params['finish_time']
]);
Db::commit();
return true;
} catch (\Exception $e) {
Db::rollback();
self::setError($e->getMessage());
return false;
}
}
/**
* @notes 删除
* @param array $params
* @return bool
* @author likeadmin
* @date 2023/11/24 18:08
*/
public static function delete(array $params): bool
{
return PayOrder::destroy($params['id']);
}
/**
* @notes 获取详情
* @param $params
* @return array
* @author likeadmin
* @date 2023/11/24 18:08
*/
public static function detail($params): array
{
return PayOrder::findOrEmpty($params['id'])->toArray();
}
}

View File

@ -0,0 +1,116 @@
<?php
// +----------------------------------------------------------------------
// | likeadmin快速开发前后端分离管理后台PHP版
// +----------------------------------------------------------------------
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
// | 开源版本可自由商用可去除界面版权logo
// | gitee下载https://gitee.com/likeshop_gitee/likeadmin
// | github下载https://github.com/likeshop-github/likeadmin
// | 访问官网https://www.likeadmin.cn
// | likeadmin团队 版权所有 拥有最终解释权
// +----------------------------------------------------------------------
// | author: likeadminTeam
// +----------------------------------------------------------------------
namespace app\adminapi\validate;
use app\common\validate\BaseValidate;
/**
* PayOrder验证器
* Class PayOrderValidate
* @package app\adminapi\validate
*/
class PayOrderValidate extends BaseValidate
{
/**
* 设置校验规则
* @var string[]
*/
protected $rule = [
'id' => 'require',
'order_from' => 'require',
'order_type' => 'require',
'collection_account' => 'require',
'pay_user_role' => 'require',
'pay_user_info' => 'require',
'order_no' => 'require',
'business_order_no' => 'require',
'total_fee' => 'require',
'pay_type' => 'require',
'pay_status' => 'require',
'business_callback_url' => 'require',
];
/**
* 参数描述
* @var string[]
*/
protected $field = [
'id' => 'id',
'order_from' => '订单来源1商城2供销',
'order_type' => '订单类型',
'collection_account' => '收款账户',
'pay_user_role' => '付款角色',
'pay_user_info' => '付款方信息',
'order_no' => '支付订单编号',
'business_order_no' => '业务系统订单编号',
'total_fee' => '总金额',
'pay_type' => '支付方式',
'pay_status' => '支付状态',
'business_callback_url' => '业务系统异步通知地址',
];
/**
* @notes 添加场景
* @return PayOrderValidate
* @author likeadmin
* @date 2023/11/24 18:08
*/
public function sceneAdd()
{
return $this->only(['order_from','order_type','collection_account','pay_user_role','pay_user_info','order_no','business_order_no','total_fee','pay_type','pay_status','business_callback_url']);
}
/**
* @notes 编辑场景
* @return PayOrderValidate
* @author likeadmin
* @date 2023/11/24 18:08
*/
public function sceneEdit()
{
return $this->only(['id','order_from','order_type','collection_account','pay_user_role','pay_user_info','order_no','business_order_no','total_fee','pay_type','pay_status','business_callback_url']);
}
/**
* @notes 删除场景
* @return PayOrderValidate
* @author likeadmin
* @date 2023/11/24 18:08
*/
public function sceneDelete()
{
return $this->only(['id']);
}
/**
* @notes 详情场景
* @return PayOrderValidate
* @author likeadmin
* @date 2023/11/24 18:08
*/
public function sceneDetail()
{
return $this->only(['id']);
}
}

View File

@ -0,0 +1,34 @@
<?php
// +----------------------------------------------------------------------
// | likeadmin快速开发前后端分离管理后台PHP版
// +----------------------------------------------------------------------
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
// | 开源版本可自由商用可去除界面版权logo
// | gitee下载https://gitee.com/likeshop_gitee/likeadmin
// | github下载https://github.com/likeshop-github/likeadmin
// | 访问官网https://www.likeadmin.cn
// | likeadmin团队 版权所有 拥有最终解释权
// +----------------------------------------------------------------------
// | author: likeadminTeam
// +----------------------------------------------------------------------
namespace app\common\model;
use app\common\model\BaseModel;
/**
* PayOrder模型
* Class PayOrder
* @package app\common\model
*/
class PayOrder extends BaseModel
{
protected $name = 'pay_order';
}