Paylog.php 10.1 KB
Newer Older
D
devil 已提交
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45
<?php
// +----------------------------------------------------------------------
// | ShopXO 国内领先企业级B2C免费开源电商系统
// +----------------------------------------------------------------------
// | Copyright (c) 2011~2019 http://shopxo.net All rights reserved.
// +----------------------------------------------------------------------
// | Licensed ( http://www.apache.org/licenses/LICENSE-2.0 )
// +----------------------------------------------------------------------
// | Author: Devil
// +----------------------------------------------------------------------
namespace app\admin\form;

use think\Db;
use app\service\PayLogService;

/**
 * 支付日志动态表格
 * @author  Devil
 * @blog    http://gong.gg/
 * @version 1.0.0
 * @date    2020-06-26
 * @desc    description
 */
class Paylog
{
    // 基础条件
    public $condition_base = [];

    /**
     * 入口
     * @author  Devil
     * @blog    http://gong.gg/
     * @version 1.0.0
     * @date    2020-06-26
     * @desc    description
     * @param   [array]           $params [输入参数]
     */
    public function Run($params = [])
    {
        return [
            // 基础配置
            'base' => [
                'key_field'     => 'id',
                'is_search'     => 1,
                'search_url'    => MyUrl('admin/paylog/index'),
D
devil 已提交
46
                'is_middle'     => 0,
D
devil 已提交
47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63
            ],
            // 表单配置
            'form' => [
                [
                    'label'         => '用户信息',
                    'view_type'     => 'module',
                    'view_key'      => 'lib/module/user',
                    'grid_size'     => 'sm',
                    'search_config' => [
                        'form_type'             => 'input',
                        'form_name'             => 'user_id',
                        'where_type'            => 'like',
                        'where_type_custom'     => 'in',
                        'where_handle_custom'   => 'WhereValueUserInfo',
                        'placeholder'           => '请输入用户名/昵称/手机/邮箱',
                    ],
                ],
D
devil 已提交
64 65 66 67 68 69 70 71 72
                [
                    'label'         => '支付单号',
                    'view_type'     => 'field',
                    'view_key'      => 'log_no',
                    'search_config' => [
                        'form_type'         => 'input',
                        'where_type'        => '=',
                    ],
                ],
D
devil 已提交
73 74 75 76 77 78 79 80
                [
                    'label'         => '支付方式',
                    'view_type'     => 'module',
                    'view_key'      => 'paylog/module/payment',
                    'search_config' => [
                        'form_type'         => 'select',
                        'form_name'         => 'payment',
                        'where_type'        => 'in',
D
devil 已提交
81
                        'data'              => $this->PayLogPaymentTypeList(),
D
devil 已提交
82 83 84 85 86
                        'data_key'          => 'id',
                        'data_name'         => 'name',
                        'is_multiple'       => 1,
                    ],
                ],
D
devil 已提交
87 88 89 90 91 92 93 94 95 96 97 98 99 100 101
                [
                    'label'         => '状态',
                    'view_type'     => 'field',
                    'view_key'      => 'status',
                    'view_data_key' => 'name',
                    'view_data'     => lang('common_pay_log_status_list'),
                    'search_config' => [
                        'form_type'         => 'select',
                        'where_type'        => 'in',
                        'data'              => lang('common_pay_log_status_list'),
                        'data_key'          => 'value',
                        'data_name'         => 'name',
                        'is_multiple'       => 1,
                    ],
                ],
D
devil 已提交
102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119
                [
                    'label'         => '业务订单金额(元)',
                    'view_type'     => 'field',
                    'view_key'      => 'total_price',
                    'search_config' => [
                        'form_type'         => 'section',
                        'is_point'          => 1,
                    ],
                ],
                [
                    'label'         => '支付金额(元)',
                    'view_type'     => 'field',
                    'view_key'      => 'pay_price',
                    'search_config' => [
                        'form_type'         => 'section',
                        'is_point'          => 1,
                    ],
                ],
D
devil 已提交
120 121 122
                [
                    'label'         => '业务类型',
                    'view_type'     => 'field',
D
devil 已提交
123
                    'view_key'      => 'business_type',
D
devil 已提交
124 125 126
                    'search_config' => [
                        'form_type'         => 'select',
                        'where_type'        => 'in',
D
devil 已提交
127 128
                        'data'              => $this->PayLogBusinessTypeList(),
                        'data_key'          => 'name',
D
devil 已提交
129 130 131 132 133
                        'data_name'         => 'name',
                        'is_multiple'       => 1,
                    ],
                ],
                [
D
devil 已提交
134 135 136 137 138 139 140 141 142 143 144 145
                    'label'         => '业务id/单号',
                    'view_type'     => 'module',
                    'view_key'      => 'paylog/module/business_list',
                    'width'         => 300,
                    'search_config' => [
                        'form_type'             => 'input',
                        'form_name'             => 'id',
                        'where_type'            => 'like',
                        'where_type_custom'     => 'in',
                        'where_handle_custom'   => 'WhereValueBusinessInfo',
                    ],
                ],
D
devil 已提交
146 147 148 149 150 151
                [
                    'label'         => '支付平台交易号',
                    'view_type'     => 'field',
                    'view_key'      => 'trade_no',
                    'search_config' => [
                        'form_type'         => 'input',
D
devil 已提交
152
                        'where_type'        => '=',
D
devil 已提交
153 154 155 156 157 158 159 160 161 162 163 164
                    ],
                ],
                [
                    'label'         => '支付平台用户帐号',
                    'view_type'     => 'field',
                    'view_key'      => 'buyer_user',
                    'search_config' => [
                        'form_type'         => 'input',
                        'where_type'        => 'like',
                    ],
                ],
                [
D
devil 已提交
165
                    'label'         => '订单名称',
D
devil 已提交
166
                    'view_type'     => 'field',
D
devil 已提交
167
                    'view_key'      => 'subject',
D
devil 已提交
168
                    'search_config' => [
D
devil 已提交
169 170
                        'form_type'         => 'input',
                        'where_type'        => 'like',
D
devil 已提交
171 172 173
                    ],
                ],
                [
D
devil 已提交
174
                    'label'         => '支付时间',
D
devil 已提交
175
                    'view_type'     => 'field',
D
devil 已提交
176
                    'view_key'      => 'pay_time',
D
devil 已提交
177
                    'search_config' => [
D
devil 已提交
178
                        'form_type'         => 'datetime',
D
devil 已提交
179 180 181
                    ],
                ],
                [
D
devil 已提交
182
                    'label'         => '关闭时间',
D
devil 已提交
183
                    'view_type'     => 'field',
D
devil 已提交
184
                    'view_key'      => 'close_time',
D
devil 已提交
185
                    'search_config' => [
D
devil 已提交
186
                        'form_type'         => 'datetime',
D
devil 已提交
187 188 189
                    ],
                ],
                [
D
devil 已提交
190
                    'label'         => '创建时间',
D
devil 已提交
191
                    'view_type'     => 'field',
D
devil 已提交
192
                    'view_key'      => 'add_time',
D
devil 已提交
193 194 195 196
                    'search_config' => [
                        'form_type'         => 'datetime',
                    ],
                ],
D
devil 已提交
197 198 199 200 201 202 203
                [
                    'label'         => '操作',
                    'view_type'     => 'operate',
                    'view_key'      => 'paylog/module/operate',
                    'align'         => 'center',
                    'fixed'         => 'right',
                ],
D
devil 已提交
204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238
            ],
        ];
    }

    /**
     * 用户信息条件处理
     * @author  Devil
     * @blog    http://gong.gg/
     * @version 1.0.0
     * @date    2020-06-26
     * @desc    description
     * @param   [string]          $value    [条件值]
     * @param   [array]           $params   [输入参数]
     */
    public function WhereValueUserInfo($value, $params = [])
    {
        if(!empty($value))
        {
            // 获取用户 id
            $ids = Db::name('User')->where('username|nickname|mobile|email', 'like', '%'.$value.'%')->column('id');

            // 避免空条件造成无效的错觉
            return empty($ids) ? [0] : $ids;
        }
        return $value;
    }

    /**
     * 支付方式类型
     * @author  Devil
     * @blog    http://gong.gg/
     * @version 1.0.0
     * @date    2020-06-26
     * @desc    description
     */
D
devil 已提交
239
    public function PayLogPaymentTypeList()
D
devil 已提交
240 241 242 243
    {
        $ret = PayLogService::PayLogTypeList();
        return empty($ret['data']) ? [] : $ret['data'];
    }
D
devil 已提交
244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279

    /**
     * 业务类型
     * @author  Devil
     * @blog    http://gong.gg/
     * @version 1.0.0
     * @date    2020-06-26
     * @desc    description
     */
    public function PayLogBusinessTypeList()
    {
        return Db::name('PayLog')->field('business_type as name')->group('business_type')->select();
    }

    /**
     * 关联业务条件处理
     * @author  Devil
     * @blog    http://gong.gg/
     * @version 1.0.0
     * @date    2020-06-30
     * @desc    description
     * @param   [string]          $value    [条件值]
     * @param   [array]           $params   [输入参数]
     */
    public function WhereValueBusinessInfo($value, $params = [])
    {
        if(!empty($value))
        {
            // 获取支持业务支付 id
            $ids = Db::name('PayLogValue')->where('business_id|business_no', '=', $value)->column('pay_log_id');

            // 避免空条件造成无效的错觉
            return empty($ids) ? [0] : $ids;
        }
        return $value;
    }
D
devil 已提交
280 281
}
?>