Files
chazhi_shop_backend/app/admin/logic/PayConfigLogic.php
2026-04-14 17:46:22 +08:00

182 lines
5.9 KiB
PHP
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<?php
// +----------------------------------------------------------------------
// | likeshop开源商城系统
// +----------------------------------------------------------------------
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
// | gitee下载https://gitee.com/likeshop_gitee
// | github下载https://github.com/likeshop-github
// | 访问官网https://www.likeshop.cn
// | 访问社区https://home.likeshop.cn
// | 访问手册http://doc.likeshop.cn
// | 微信公众号likeshop技术社区
// | likeshop系列产品在gitee、github等公开渠道开源版本可免费商用未经许可不能去除前后端官方版权标识
// | likeshop系列产品收费版本务必购买商业授权购买去版权授权后方可去除前后端官方版权标识
// | 禁止对系统程序代码以任何目的,任何形式的再发布
// | likeshop团队版权所有并拥有最终解释权
// +----------------------------------------------------------------------
// | author: likeshop.cn.team
// +----------------------------------------------------------------------
namespace app\admin\logic;
use app\common\basics\Logic;
use app\common\model\Pay;
use app\common\server\UrlServer;
/**
* 支付配置 - 逻辑
* Class PayConfigLogic
* @package app\admin\logic
*/
class PayConfigLogic extends Logic
{
/**
* Notes: 配置列表
* @author 段誉(2021/5/7 18:15)
* @return array
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\DbException
* @throws \think\db\exception\ModelNotFoundException
*/
public static function lists()
{
$count = Pay::count();
$lists = Pay::withAttr('status', function($value, $data) {
return $value == 1 ? '启用' : '关闭';
})->order('sort')->select();
return ['lists' => $lists, 'count' => $count];
}
/**
* Notes: 详情
* @param $pay_code
* @author 段誉(2021/5/7 18:15)
* @return array|\think\Model|null
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\DbException
* @throws \think\db\exception\ModelNotFoundException
*/
public static function info($pay_code)
{
return Pay::where(['code' => $pay_code])->find();
}
/**
* Notes: 余额
* @param $post
* @author 段誉(2021/5/7 18:15)
* @return Pay
*/
public static function editBalance($post)
{
return Pay::where('code', 'balance')->update([
'short_name' => $post['short_name'],
'image' => UrlServer::setFileUrl($post['image']) ?? '',
'status' => $post['status'],
'sort' => $post['sort'] ?? 0,
]);
}
/**
* Notes: 微信
* @param $post
* @author 段誉(2021/5/7 18:16)
* @return Pay
*/
public static function editWechat($post)
{
$data = [
'short_name' => $post['short_name'],
'image' => UrlServer::setFileUrl($post['image']) ?? '',
'status' => $post['status'],
'sort' => $post['sort'] ?? 0,
'config' => [
'pay_sign_key' => $post['pay_sign_key'],
'mch_id' => $post['mch_id'],
'apiclient_cert' => $post['apiclient_cert'],
'apiclient_key' => $post['apiclient_key']
]
];
return Pay::where('code', 'wechat')->update($data);
}
/**
* Notes: 支付宝
* @param $post
* @author 段誉(2021/5/7 18:16)
* @return Pay
*/
public static function editAlipay($post)
{
$data = [
'short_name' => $post['short_name'],
'image' => UrlServer::setFileUrl($post['image']) ?? '',
'status' => $post['status'],
'sort' => $post['sort'] ?? 0,
'config' => [
// 应用id
'app_id' => $post['app_id'],
// 应用私钥
'private_key' => $post['private_key'],
// 接口加密
'api_type' => $post['api_type'] ?? 'certificate',
// 应用公钥证书
'app_cert' => $post['app_cert'] ?? '',
// 支付宝公钥
// 'ali_public_key' => $post['ali_public_key'],
// 支付宝公钥证书
'ali_public_cert' => $post['ali_public_cert'] ?? '',
// 支付宝CA根证书
'ali_root_cert' => $post['ali_root_cert'] ?? '',
]
];
return Pay::where('code', 'alipay')->update($data);
}
static function editHfdgWechat($post)
{
$data = [
'short_name' => $post['short_name'],
'image' => UrlServer::setFileUrl($post['image']) ?? '',
'status' => $post['status'],
'sort' => $post['sort'] ?? 0,
];
return Pay::where('code', 'hfdg_wechat')->update($data);
}
static function editHfdgAlipay($post)
{
$data = [
'short_name' => $post['short_name'],
'image' => UrlServer::setFileUrl($post['image']) ?? '',
'status' => $post['status'],
'sort' => $post['sort'] ?? 0,
];
return Pay::where('code', 'hfdg_alipay')->update($data);
}
/**
* @notes 线下支付
* @param $post
* @return Pay
* @author ljj
* @date 2024/7/19 下午3:15
*/
public static function editOffline($post)
{
return Pay::where('code', 'offline')->update([
'short_name' => $post['short_name'],
'image' => UrlServer::setFileUrl($post['image']) ?? '',
'status' => $post['status'],
'sort' => $post['sort'] ?? 0,
]);
}
}