Order.php 18.9 KB
Newer Older
D
devil 已提交
1 2 3 4 5 6 7 8 9 10 11 12 13 14
<?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\PaymentService;
D
devil 已提交
15
use app\service\ExpressService;
D
devil 已提交
16 17

/**
D
devil 已提交
18
 * 订单动态表格
D
devil 已提交
19 20 21
 * @author  Devil
 * @blog    http://gong.gg/
 * @version 1.0.0
D
devil 已提交
22
 * @date    2020-06-08
D
devil 已提交
23 24 25 26 27 28 29 30 31 32 33 34 35 36
 * @desc    description
 */
class Order
{
    // 基础条件
    public $condition_base = [
        ['is_delete_time', '=', 0],
    ];

    /**
     * 入口
     * @author  Devil
     * @blog    http://gong.gg/
     * @version 1.0.0
D
devil 已提交
37
     * @date    2020-06-08
D
devil 已提交
38 39 40 41 42 43 44 45 46 47 48
     * @desc    description
     * @param   [array]           $params [输入参数]
     */
    public function Run($params = [])
    {
        return [
            // 基础配置
            'base' => [
                'key_field'     => 'id',
                'is_search'     => 1,
                'search_url'    => MyUrl('admin/order/index'),
49
                'detail_title'  => '基础信息',
D
devil 已提交
50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75
            ],
            // 表单配置
            'form' => [
                [
                    'label'         => '订单ID',
                    'view_type'     => 'field',
                    'view_key'      => 'id',
                    'width'         => 105,
                    'search_config' => [
                        'form_type'         => 'input',
                        'where_type'        => '=',
                    ],
                ],
                [
                    'label'         => '订单号',
                    'view_type'     => 'field',
                    'view_key'      => 'order_no',
                    'width'         => 170,
                    'search_config' => [
                        'form_type'         => 'input',
                        'where_type'        => '=',
                    ],
                ],
                [
                    'label'         => '基础信息',
                    'view_type'     => 'module',
D
devil 已提交
76
                    'view_key'      => 'order/module/goods',
D
devil 已提交
77
                    'grid_size'     => 'lg',
78
                    'is_detail'     => 0,
D
devil 已提交
79
                    'search_config' => [
D
devil 已提交
80 81 82 83 84 85
                        'form_type'             => 'input',
                        'form_name'             => 'id',
                        'where_type'            => 'like',
                        'where_type_custom'     => 'in',
                        'where_handle_custom'   => 'WhereValueBaseInfo',
                        'placeholder'           => '请输入商品名称/型号',
D
devil 已提交
86 87 88 89 90
                    ],
                ],
                [
                    'label'         => '用户信息',
                    'view_type'     => 'module',
D
devil 已提交
91
                    'view_key'      => 'lib/module/user',
D
devil 已提交
92 93
                    'grid_size'     => 'sm',
                    'search_config' => [
D
devil 已提交
94 95 96 97 98 99
                        'form_type'             => 'input',
                        'form_name'             => 'user_id',
                        'where_type'            => 'like',
                        'where_type_custom'     => 'in',
                        'where_handle_custom'   => 'WhereValueUserInfo',
                        'placeholder'           => '请输入用户名/昵称/手机/邮箱',
D
devil 已提交
100 101 102 103 104 105 106
                    ],
                ],
                [
                    'label'         => '地址信息',
                    'view_type'     => 'module',
                    'view_key'      => 'order/module/address',
                    'grid_size'     => 'sm',
107
                    'is_detail'     => 0,
D
devil 已提交
108
                    'search_config' => [
D
devil 已提交
109 110 111 112 113
                        'form_type'             => 'input',
                        'form_name'             => 'id',
                        'where_type'            => 'like',
                        'where_type_custom'     => 'in',
                        'where_handle_custom'   => 'WhereValueAddressInfo',
D
devil 已提交
114 115 116 117 118 119
                    ],
                ],
                [
                    'label'         => '取货信息',
                    'view_type'     => 'module',
                    'view_key'      => 'order/module/take',
D
devil 已提交
120
                    'width'         => 125,
121
                    'is_detail'     => 0,
D
devil 已提交
122
                    'search_config' => [
D
devil 已提交
123 124 125 126 127
                        'form_type'             => 'input',
                        'form_name'             => 'id',
                        'where_type'            => 'like',
                        'where_type_custom'     => 'in',
                        'where_handle_custom'   => 'WhereValueTakeInfo',
D
devil 已提交
128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162
                    ],
                ],
                [
                    'label'         => '订单状态',
                    'view_type'     => 'module',
                    'view_key'      => 'order/module/status',
                    'width'         => 120,
                    'search_config' => [
                        'form_type'         => 'select',
                        'form_name'         => 'status',
                        'where_type'        => 'in',
                        'data'              => lang('common_order_admin_status'),
                        'data_key'          => 'id',
                        'data_name'         => 'name',
                        'is_multiple'       => 1,
                    ],
                ],
                [
                    'label'         => '支付状态',
                    'view_type'     => 'module',
                    'view_key'      => 'order/module/pay_status',
                    'width'         => 120,
                    'search_config' => [
                        'form_type'         => 'select',
                        'form_name'         => 'pay_status',
                        'where_type'        => 'in',
                        'data'              => lang('common_order_pay_status'),
                        'data_key'          => 'id',
                        'data_name'         => 'name',
                        'is_multiple'       => 1,
                    ],
                ],
                [
                    'label'         => '订单模式',
                    'view_type'     => 'field',
D
devil 已提交
163 164 165
                    'view_key'      => 'order_model',
                    'view_data_key' => 'name',
                    'view_data'     => lang('common_site_type_list'),
D
devil 已提交
166 167 168 169 170
                    'width'         => 120,
                    'search_config' => [
                        'form_type'         => 'select',
                        'where_type'        => 'in',
                        'data'              => lang('common_site_type_list'),
D
devil 已提交
171
                        'data_key'          => 'value',
D
devil 已提交
172 173 174 175 176 177 178
                        'data_name'         => 'name',
                        'is_multiple'       => 1,
                    ],
                ],
                [
                    'label'         => '来源',
                    'view_type'     => 'field',
D
devil 已提交
179 180 181
                    'view_key'      => 'client_type',
                    'view_data_key' => 'name',
                    'view_data'     => lang('common_platform_type'),
D
devil 已提交
182 183 184 185 186
                    'width'         => 120,
                    'search_config' => [
                        'form_type'         => 'select',
                        'where_type'        => 'in',
                        'data'              => lang('common_platform_type'),
D
devil 已提交
187
                        'data_key'          => 'value',
D
devil 已提交
188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 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
                        'data_name'         => 'name',
                        'is_multiple'       => 1,
                    ],
                ],
                [
                    'label'         => '单价(元)',
                    'view_type'     => 'field',
                    'view_key'      => 'price',
                    'search_config' => [
                        'form_type'         => 'section',
                        'is_point'          => 1,
                    ],
                ],
                [
                    '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,
                    ],
                ],
                [
                    'label'         => '退款金额(元)',
                    'view_type'     => 'field',
                    'view_key'      => 'refund_price',
                    'search_config' => [
                        'form_type'         => 'section',
                        'is_point'          => 1,
                    ],
                ],
                [
                    'label'         => '退货数量',
                    'view_type'     => 'field',
                    'view_key'      => 'returned_quantity',
                    'search_config' => [
                        'form_type'         => 'section',
                    ],
                ],
236 237 238 239 240 241 242 243
                [
                    'label'         => '购买总数',
                    'view_type'     => 'field',
                    'view_key'      => 'buy_number_count',
                    'search_config' => [
                        'form_type'         => 'section',
                    ],
                ],
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
                [
                    'label'         => '增加金额(元)',
                    'view_type'     => 'field',
                    'view_key'      => 'increase_price',
                    'search_config' => [
                        'form_type'         => 'section',
                        'is_point'          => 1,
                    ],
                ],
                [
                    'label'         => '优惠金额(元)',
                    'view_type'     => 'field',
                    'view_key'      => 'preferential_price',
                    'search_config' => [
                        'form_type'         => 'section',
                        'is_point'          => 1,
                    ],
                ],
                [
                    'label'         => '支付方式',
                    'view_type'     => 'field',
                    'view_key'      => 'payment_name',
                    'search_config' => [
                        'form_type'         => 'select',
                        'form_name'         => 'payment_id',
                        'where_type'        => 'in',
                        'data'              => PaymentService::PaymentList(),
                        'data_key'          => 'id',
                        'data_name'         => 'name',
                        'is_multiple'       => 1,
                    ],
                ],
276 277 278 279 280 281 282 283 284 285
                [
                    'label'         => '用户备注',
                    'view_type'     => 'field',
                    'view_key'      => 'user_note',
                    'width'         => 120,
                    'search_config' => [
                        'form_type'         => 'select',
                        'where_type'        => 'like',
                    ],
                ],
D
devil 已提交
286 287 288 289 290 291 292 293 294 295 296 297
                [
                    'label'         => '扩展信息',
                    'view_type'     => 'module',
                    'view_key'      => 'order/module/extension',
                    'grid_size'     => 'sm',
                    'search_config' => [
                        'form_type'         => 'input',
                        'form_name'         => 'extension_data',
                        'where_type'        => 'like',
                    ],
                ],
                [
D
devil 已提交
298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314
                    'label'         => '快递公司',
                    'view_type'     => 'field',
                    'view_key'      => 'express_name',
                    'search_config' => [
                        'form_type'         => 'select',
                        'form_name'         => 'express_id',
                        'data'              => ExpressService::ExpressList(),
                        'where_type'        => 'in',
                        'data_key'          => 'id',
                        'data_name'         => 'name',
                        'is_multiple'       => 1,
                    ],
                ],
                [
                    'label'         => '快递单号',
                    'view_type'     => 'field',
                    'view_key'      => 'express_number',
D
devil 已提交
315 316 317 318 319 320 321 322 323 324 325
                    'search_config' => [
                        'form_type'         => 'input',
                        'where_type'        => 'like',
                    ],
                ],
                [
                    'label'         => '最新售后',
                    'view_type'     => 'module',
                    'view_key'      => 'order/module/aftersale',
                    'grid_size'     => 'sm',
                ],
326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373
                [
                    'label'         => '确认时间',
                    'view_type'     => 'field',
                    'view_key'      => 'confirm_time',
                    'search_config' => [
                        'form_type'         => 'datetime',
                    ],
                ],
                [
                    'label'         => '支付时间',
                    'view_type'     => 'field',
                    'view_key'      => 'pay_time',
                    'search_config' => [
                        'form_type'         => 'datetime',
                    ],
                ],
                [
                    'label'         => '发货时间',
                    'view_type'     => 'field',
                    'view_key'      => 'delivery_time',
                    'search_config' => [
                        'form_type'         => 'datetime',
                    ],
                ],
                [
                    'label'         => '完成时间',
                    'view_type'     => 'field',
                    'view_key'      => 'collect_time',
                    'search_config' => [
                        'form_type'         => 'datetime',
                    ],
                ],
                [
                    'label'         => '取消时间',
                    'view_type'     => 'field',
                    'view_key'      => 'cancel_time',
                    'search_config' => [
                        'form_type'         => 'datetime',
                    ],
                ],
                [
                    'label'         => '关闭时间',
                    'view_type'     => 'field',
                    'view_key'      => 'close_time',
                    'search_config' => [
                        'form_type'         => 'datetime',
                    ],
                ],
D
devil 已提交
374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389
                [
                    'label'         => '创建时间',
                    'view_type'     => 'field',
                    'view_key'      => 'add_time',
                    'search_config' => [
                        'form_type'         => 'datetime',
                    ],
                ],
                [
                    'label'         => '更新时间',
                    'view_type'     => 'field',
                    'view_key'      => 'upd_time',
                    'search_config' => [
                        'form_type'         => 'datetime',
                    ],
                ],
D
devil 已提交
390 391 392 393 394 395 396 397 398 399 400 401
                [
                    'label'         => '操作',
                    'view_type'     => 'operate',
                    'view_key'      => 'order/module/operate',
                    'align'         => 'center',
                    'fixed'         => 'right',
                ],
            ],
        ];
    }

    /**
D
devil 已提交
402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448
     * 取货码条件处理
     * @author  Devil
     * @blog    http://gong.gg/
     * @version 1.0.0
     * @date    2020-06-08
     * @desc    description
     * @param   [string]          $value    [条件值]
     * @param   [array]           $params   [输入参数]
     */
    public function WhereValueTakeInfo($value, $params = [])
    {
        if(!empty($value))
        {
            // 获取订单 id
            $ids = Db::name('OrderExtractionCode')->where('code', '=', $value)->column('order_id');

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

    /**
     * 收件地址条件处理
     * @author  Devil
     * @blog    http://gong.gg/
     * @version 1.0.0
     * @date    2020-06-08
     * @desc    description
     * @param   [string]          $value    [条件值]
     * @param   [array]           $params   [输入参数]
     */
    public function WhereValueAddressInfo($value, $params = [])
    {
        if(!empty($value))
        {
            // 获取订单 id
            $ids = Db::name('OrderAddress')->where('name|tel|address', 'like', '%'.$value.'%')->column('order_id');

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

    /**
     * 用户信息条件处理
D
devil 已提交
449 450 451
     * @author  Devil
     * @blog    http://gong.gg/
     * @version 1.0.0
D
devil 已提交
452
     * @date    2020-06-08
D
devil 已提交
453
     * @desc    description
D
devil 已提交
454
     * @param   [string]          $value    [条件值]
D
devil 已提交
455 456
     * @param   [array]           $params   [输入参数]
     */
D
devil 已提交
457
    public function WhereValueUserInfo($value, $params = [])
D
devil 已提交
458 459 460
    {
        if(!empty($value))
        {
D
devil 已提交
461 462
            // 获取用户 id
            $ids = Db::name('User')->where('username|nickname|mobile|email', 'like', '%'.$value.'%')->column('id');
D
devil 已提交
463

D
devil 已提交
464 465 466 467 468
            // 避免空条件造成无效的错觉
            return empty($ids) ? [0] : $ids;
        }
        return $value;
    }
D
devil 已提交
469

D
devil 已提交
470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485
    /**
     * 基础信息条件处理
     * @author  Devil
     * @blog    http://gong.gg/
     * @version 1.0.0
     * @date    2020-06-08
     * @desc    description
     * @param   [string]          $value    [条件值]
     * @param   [array]           $params   [输入参数]
     */
    public function WhereValueBaseInfo($value, $params = [])
    {
        if(!empty($value))
        {
            // 获取订单详情搜索的订单 id
            $ids = Db::name('OrderDetail')->where('title|model', 'like', '%'.$value.'%')->column('order_id');
D
devil 已提交
486 487

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