123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182 |
- <?php
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- namespace app\admin\logic;
-
- use app\common\basics\Logic;
- use app\common\model\Pay;
- use app\common\server\UrlServer;
-
-
- class PayConfigLogic extends Logic
- {
-
-
-
- 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];
- }
-
-
-
-
- public static function info($pay_code)
- {
- return Pay::where(['code' => $pay_code])->find();
- }
-
-
-
-
- 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,
- ]);
- }
-
-
-
-
- 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);
- }
-
-
-
-
- public static function editAlipay($post)
- {
- $data = [
- 'short_name' => $post['short_name'],
- 'image' => UrlServer::setFileUrl($post['image']) ?? '',
- 'status' => $post['status'],
- 'sort' => $post['sort'] ?? 0,
- 'config' => [
-
- 'app_id' => $post['app_id'],
-
- 'private_key' => $post['private_key'],
-
- 'api_type' => $post['api_type'] ?? 'certificate',
-
- 'app_cert' => $post['app_cert'] ?? '',
-
-
-
- 'ali_public_cert' => $post['ali_public_cert'] ?? '',
-
- '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);
- }
-
-
-
- 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,
- ]);
- }
- }
|