2020-05-20 10:32:23 +00:00
|
|
|
<?php
|
|
|
|
|
// +----------------------------------------------------------------------
|
|
|
|
|
// | ShopXO 国内领先企业级B2C免费开源电商系统
|
|
|
|
|
// +----------------------------------------------------------------------
|
2021-03-16 02:34:52 +00:00
|
|
|
// | Copyright (c) 2011~2099 http://shopxo.net All rights reserved.
|
2020-05-20 10:32:23 +00:00
|
|
|
// +----------------------------------------------------------------------
|
2021-03-16 02:34:52 +00:00
|
|
|
// | Licensed ( https://opensource.org/licenses/mit-license.php )
|
2020-05-20 10:32:23 +00:00
|
|
|
// +----------------------------------------------------------------------
|
|
|
|
|
// | Author: Devil
|
|
|
|
|
// +----------------------------------------------------------------------
|
2020-06-02 15:32:29 +00:00
|
|
|
namespace app\admin\form;
|
2020-05-20 10:32:23 +00:00
|
|
|
|
2021-07-18 15:42:10 +00:00
|
|
|
use think\facade\Db;
|
2023-02-08 13:20:04 +00:00
|
|
|
use app\service\GoodsCategoryService;
|
2020-05-31 14:06:40 +00:00
|
|
|
use app\service\RegionService;
|
|
|
|
|
use app\service\BrandService;
|
2020-05-20 10:32:23 +00:00
|
|
|
|
|
|
|
|
/**
|
2020-06-08 06:03:33 +00:00
|
|
|
* 商品动态表格
|
2020-05-20 10:32:23 +00:00
|
|
|
* @author Devil
|
|
|
|
|
* @blog http://gong.gg/
|
|
|
|
|
* @version 1.0.0
|
|
|
|
|
* @date 2020-05-16
|
|
|
|
|
* @desc description
|
|
|
|
|
*/
|
2020-06-02 15:32:29 +00:00
|
|
|
class Goods
|
2020-05-20 10:32:23 +00:00
|
|
|
{
|
2020-06-05 15:29:04 +00:00
|
|
|
// 基础条件
|
|
|
|
|
public $condition_base = [
|
|
|
|
|
['is_delete_time', '=', 0],
|
|
|
|
|
];
|
|
|
|
|
|
2020-05-20 10:32:23 +00:00
|
|
|
/**
|
2020-06-02 15:32:29 +00:00
|
|
|
* 入口
|
2020-05-20 10:32:23 +00:00
|
|
|
* @author Devil
|
|
|
|
|
* @blog http://gong.gg/
|
|
|
|
|
* @version 1.0.0
|
|
|
|
|
* @date 2020-05-16
|
|
|
|
|
* @desc description
|
|
|
|
|
* @param [array] $params [输入参数]
|
|
|
|
|
*/
|
2020-06-02 15:32:29 +00:00
|
|
|
public function Run($params = [])
|
2020-05-20 10:32:23 +00:00
|
|
|
{
|
2023-02-02 15:54:37 +00:00
|
|
|
$lang = MyLang('goods.form_table');
|
2020-05-29 06:03:53 +00:00
|
|
|
return [
|
|
|
|
|
// 基础配置
|
|
|
|
|
'base' => [
|
|
|
|
|
'key_field' => 'id',
|
|
|
|
|
'status_field' => 'is_shelves',
|
2020-05-31 14:06:40 +00:00
|
|
|
'is_search' => 1,
|
2020-06-07 09:36:43 +00:00
|
|
|
'is_delete' => 1,
|
2021-08-14 03:48:51 +00:00
|
|
|
'is_middle' => 0,
|
2020-05-29 06:03:53 +00:00
|
|
|
],
|
|
|
|
|
// 表单配置
|
|
|
|
|
'form' => [
|
2020-06-05 15:29:04 +00:00
|
|
|
[
|
|
|
|
|
'view_type' => 'checkbox',
|
|
|
|
|
'is_checked' => 0,
|
2023-01-29 10:11:08 +00:00
|
|
|
'checked_text' => MyLang('reverse_select_title'),
|
|
|
|
|
'not_checked_text' => MyLang('select_all_title'),
|
2020-06-05 15:29:04 +00:00
|
|
|
'align' => 'center',
|
|
|
|
|
'width' => 80,
|
|
|
|
|
],
|
2020-05-29 06:03:53 +00:00
|
|
|
[
|
2023-02-02 15:54:37 +00:00
|
|
|
'label' => $lang['id'],
|
2020-05-29 06:03:53 +00:00
|
|
|
'view_type' => 'field',
|
|
|
|
|
'view_key' => 'id',
|
2024-01-19 06:49:32 +00:00
|
|
|
'width' => 110,
|
2024-04-15 02:25:01 +00:00
|
|
|
'is_copy' => 1,
|
2020-10-24 16:45:09 +00:00
|
|
|
'is_sort' => 1,
|
2020-06-05 15:29:04 +00:00
|
|
|
'search_config' => [
|
|
|
|
|
'form_type' => 'input',
|
|
|
|
|
'where_type' => '=',
|
|
|
|
|
],
|
2020-05-29 06:03:53 +00:00
|
|
|
],
|
|
|
|
|
[
|
2024-10-21 02:51:14 +00:00
|
|
|
'label' => $lang['info'],
|
|
|
|
|
'view_type' => 'module',
|
|
|
|
|
'view_key' => 'goods/module/info',
|
|
|
|
|
'grid_size' => 'lg',
|
|
|
|
|
'is_sort' => 1,
|
|
|
|
|
'sort_field' => 'title',
|
|
|
|
|
'params_where_name' => 'keywords',
|
|
|
|
|
'search_config' => [
|
2023-11-08 07:43:08 +00:00
|
|
|
'form_type' => 'input',
|
|
|
|
|
'form_name' => 'id',
|
|
|
|
|
'where_type_custom' => 'in',
|
2024-04-15 02:25:01 +00:00
|
|
|
'where_value_custom' => 'SystemModuleGoodsWhereHandle',
|
2023-11-08 07:43:08 +00:00
|
|
|
'placeholder' => $lang['info_placeholder'],
|
2020-07-02 14:42:01 +00:00
|
|
|
],
|
|
|
|
|
],
|
|
|
|
|
[
|
2024-10-21 02:51:14 +00:00
|
|
|
'label' => $lang['category_text'],
|
|
|
|
|
'view_type' => 'field',
|
|
|
|
|
'view_key' => 'category_text',
|
|
|
|
|
'params_where_name' => 'category_ids',
|
|
|
|
|
'search_config' => [
|
2020-07-29 07:54:38 +00:00
|
|
|
'form_type' => 'module',
|
2024-10-21 02:51:14 +00:00
|
|
|
'template' => 'lib/module/multi_level_category',
|
2020-07-29 07:54:38 +00:00
|
|
|
'form_name' => 'id',
|
|
|
|
|
'where_type' => 'in',
|
2020-08-20 15:38:41 +00:00
|
|
|
'where_value_custom' => 'WhereValueGoodsCategory',
|
2023-02-08 13:20:04 +00:00
|
|
|
'data' => GoodsCategoryService::GoodsCategoryAll(),
|
2020-07-29 07:54:38 +00:00
|
|
|
],
|
|
|
|
|
],
|
|
|
|
|
[
|
2024-10-21 02:51:14 +00:00
|
|
|
'label' => $lang['brand_name'],
|
|
|
|
|
'view_type' => 'field',
|
|
|
|
|
'view_key' => 'brand_name',
|
|
|
|
|
'params_where_name' => 'brand_ids',
|
|
|
|
|
'is_sort' => 1,
|
|
|
|
|
'width' => 140,
|
|
|
|
|
'search_config' => [
|
2022-05-06 15:46:47 +00:00
|
|
|
'form_type' => 'select',
|
2020-07-29 07:54:38 +00:00
|
|
|
'form_name' => 'brand_id',
|
2022-05-06 15:46:47 +00:00
|
|
|
'where_type' => 'in',
|
2020-07-29 07:54:38 +00:00
|
|
|
'data' => BrandService::CategoryBrand(),
|
|
|
|
|
'data_key' => 'id',
|
2020-07-02 14:42:01 +00:00
|
|
|
'data_name' => 'name',
|
2022-05-06 15:46:47 +00:00
|
|
|
'is_multiple' => 1,
|
2020-05-31 14:06:40 +00:00
|
|
|
],
|
2020-05-29 06:03:53 +00:00
|
|
|
],
|
|
|
|
|
[
|
2023-02-02 15:54:37 +00:00
|
|
|
'label' => $lang['price'],
|
2020-05-29 06:03:53 +00:00
|
|
|
'view_type' => 'field',
|
|
|
|
|
'view_key' => 'price',
|
2020-10-24 16:45:09 +00:00
|
|
|
'is_sort' => 1,
|
2020-05-31 14:06:40 +00:00
|
|
|
'search_config' => [
|
|
|
|
|
'form_type' => 'section',
|
|
|
|
|
'form_name' => 'min_price',
|
2020-06-02 15:32:29 +00:00
|
|
|
'is_point' => 1,
|
2020-05-31 14:06:40 +00:00
|
|
|
],
|
2020-05-29 06:03:53 +00:00
|
|
|
],
|
|
|
|
|
[
|
2023-02-02 15:54:37 +00:00
|
|
|
'label' => $lang['original_price'],
|
2020-05-29 06:03:53 +00:00
|
|
|
'view_type' => 'field',
|
|
|
|
|
'view_key' => 'original_price',
|
2020-10-24 16:45:09 +00:00
|
|
|
'is_sort' => 1,
|
2020-05-31 14:06:40 +00:00
|
|
|
'search_config' => [
|
|
|
|
|
'form_type' => 'section',
|
2020-06-02 15:32:29 +00:00
|
|
|
'form_name' => 'min_original_price',
|
|
|
|
|
'is_point' => 1,
|
2020-05-31 14:06:40 +00:00
|
|
|
],
|
2020-05-29 06:03:53 +00:00
|
|
|
],
|
|
|
|
|
[
|
2023-02-02 15:54:37 +00:00
|
|
|
'label' => $lang['inventory'],
|
2020-05-29 06:03:53 +00:00
|
|
|
'view_type' => 'field',
|
|
|
|
|
'view_key' => ['inventory', 'inventory_unit'],
|
|
|
|
|
'view_key_join' => ' ',
|
2020-10-24 16:45:09 +00:00
|
|
|
'is_sort' => 1,
|
2020-05-31 14:06:40 +00:00
|
|
|
'search_config' => [
|
|
|
|
|
'form_type' => 'section',
|
|
|
|
|
'form_name' => 'inventory',
|
|
|
|
|
],
|
2020-05-29 06:03:53 +00:00
|
|
|
],
|
|
|
|
|
[
|
2024-10-21 02:51:14 +00:00
|
|
|
'label' => $lang['is_shelves'],
|
|
|
|
|
'view_type' => 'status',
|
|
|
|
|
'view_key' => 'is_shelves',
|
|
|
|
|
'post_url' => MyUrl('admin/goods/statusupdate'),
|
|
|
|
|
'is_form_su' => 1,
|
|
|
|
|
'align' => 'center',
|
|
|
|
|
'is_sort' => 1,
|
|
|
|
|
'width' => 130,
|
|
|
|
|
'params_where_name' => 'is_shelves',
|
|
|
|
|
'search_config' => [
|
2020-05-31 14:06:40 +00:00
|
|
|
'form_type' => 'select',
|
2020-06-02 15:32:29 +00:00
|
|
|
'where_type' => 'in',
|
2023-08-27 08:59:15 +00:00
|
|
|
'data' => MyConst('common_is_shelves_list'),
|
2020-05-31 14:06:40 +00:00
|
|
|
'data_key' => 'id',
|
|
|
|
|
'data_name' => 'name',
|
|
|
|
|
'is_multiple' => 1,
|
|
|
|
|
],
|
2020-05-29 06:03:53 +00:00
|
|
|
],
|
|
|
|
|
[
|
2023-02-02 15:54:37 +00:00
|
|
|
'label' => $lang['is_deduction_inventory'],
|
2020-06-14 08:04:37 +00:00
|
|
|
'view_type' => 'status',
|
|
|
|
|
'view_key' => 'is_deduction_inventory',
|
|
|
|
|
'post_url' => MyUrl('admin/goods/statusupdate'),
|
2020-05-29 06:03:53 +00:00
|
|
|
'align' => 'center',
|
2020-10-24 16:45:09 +00:00
|
|
|
'is_sort' => 1,
|
2024-10-21 02:51:14 +00:00
|
|
|
'width' => 130,
|
2020-05-31 14:06:40 +00:00
|
|
|
'search_config' => [
|
|
|
|
|
'form_type' => 'select',
|
2020-06-02 15:32:29 +00:00
|
|
|
'where_type' => 'in',
|
2023-08-27 08:59:15 +00:00
|
|
|
'data' => MyConst('common_is_text_list'),
|
2020-05-31 14:06:40 +00:00
|
|
|
'data_key' => 'id',
|
|
|
|
|
'data_name' => 'name',
|
|
|
|
|
'is_multiple' => 1,
|
|
|
|
|
],
|
2020-05-29 06:03:53 +00:00
|
|
|
],
|
|
|
|
|
[
|
2023-02-02 15:54:37 +00:00
|
|
|
'label' => $lang['site_type'],
|
2020-05-31 14:06:40 +00:00
|
|
|
'view_type' => 'field',
|
2020-07-29 07:54:38 +00:00
|
|
|
'view_key' => 'site_type',
|
|
|
|
|
'view_data_key' => 'name',
|
2023-08-27 08:59:15 +00:00
|
|
|
'view_data' => MyConst('common_site_type_list'),
|
2020-10-24 16:45:09 +00:00
|
|
|
'is_sort' => 1,
|
2024-10-21 02:51:14 +00:00
|
|
|
'width' => 140,
|
2020-05-31 14:06:40 +00:00
|
|
|
'search_config' => [
|
2020-07-29 07:54:38 +00:00
|
|
|
'form_type' => 'select',
|
|
|
|
|
'where_type' => 'in',
|
2023-08-27 08:59:15 +00:00
|
|
|
'data' => MyConst('common_site_type_list'),
|
2020-07-29 07:54:38 +00:00
|
|
|
'data_key' => 'value',
|
|
|
|
|
'data_name' => 'name',
|
|
|
|
|
'is_multiple' => 1,
|
2020-05-31 14:06:40 +00:00
|
|
|
],
|
2020-05-29 06:03:53 +00:00
|
|
|
],
|
|
|
|
|
[
|
2023-02-02 15:54:37 +00:00
|
|
|
'label' => $lang['model'],
|
2020-05-29 06:03:53 +00:00
|
|
|
'view_type' => 'field',
|
2020-07-29 07:54:38 +00:00
|
|
|
'view_key' => 'model',
|
2020-10-24 16:45:09 +00:00
|
|
|
'is_sort' => 1,
|
2020-05-31 14:06:40 +00:00
|
|
|
'search_config' => [
|
2020-07-29 07:54:38 +00:00
|
|
|
'form_type' => 'input',
|
|
|
|
|
'where_type' => 'like',
|
2020-05-31 14:06:40 +00:00
|
|
|
],
|
|
|
|
|
],
|
2020-06-07 09:36:43 +00:00
|
|
|
[
|
2023-02-02 15:54:37 +00:00
|
|
|
'label' => $lang['place_origin_name'],
|
2020-06-07 09:36:43 +00:00
|
|
|
'view_type' => 'field',
|
|
|
|
|
'view_key' => 'place_origin_name',
|
2020-10-24 16:45:09 +00:00
|
|
|
'is_sort' => 1,
|
2020-06-07 09:36:43 +00:00
|
|
|
'search_config' => [
|
|
|
|
|
'form_type' => 'select',
|
|
|
|
|
'form_name' => 'place_origin',
|
|
|
|
|
'data' => RegionService::RegionItems(['pid'=>0]),
|
|
|
|
|
'data_key' => 'id',
|
|
|
|
|
'data_name' => 'name',
|
|
|
|
|
'where_type' => 'in',
|
|
|
|
|
'is_multiple' => 1,
|
|
|
|
|
],
|
|
|
|
|
],
|
2020-06-28 14:50:10 +00:00
|
|
|
[
|
2023-02-02 15:54:37 +00:00
|
|
|
'label' => $lang['give_integral'],
|
2020-06-28 14:50:10 +00:00
|
|
|
'view_type' => 'field',
|
|
|
|
|
'view_key' => 'give_integral',
|
|
|
|
|
'view_join_last'=> '%',
|
2020-10-24 16:45:09 +00:00
|
|
|
'is_sort' => 1,
|
2020-06-28 14:50:10 +00:00
|
|
|
'search_config' => [
|
|
|
|
|
'form_type' => 'section',
|
|
|
|
|
],
|
|
|
|
|
],
|
2020-06-14 08:04:37 +00:00
|
|
|
[
|
2023-02-02 15:54:37 +00:00
|
|
|
'label' => $lang['buy_min_number'],
|
2020-06-14 08:04:37 +00:00
|
|
|
'view_type' => 'field',
|
|
|
|
|
'view_key' => 'buy_min_number',
|
2020-10-24 16:45:09 +00:00
|
|
|
'is_sort' => 1,
|
2020-06-14 08:04:37 +00:00
|
|
|
'search_config' => [
|
|
|
|
|
'form_type' => 'section',
|
|
|
|
|
],
|
|
|
|
|
],
|
|
|
|
|
[
|
2023-02-02 15:54:37 +00:00
|
|
|
'label' => $lang['buy_max_number'],
|
2020-06-14 08:04:37 +00:00
|
|
|
'view_type' => 'field',
|
|
|
|
|
'view_key' => 'buy_max_number',
|
2020-10-24 16:45:09 +00:00
|
|
|
'is_sort' => 1,
|
2020-06-14 08:04:37 +00:00
|
|
|
'search_config' => [
|
|
|
|
|
'form_type' => 'section',
|
|
|
|
|
],
|
|
|
|
|
],
|
2024-12-25 09:35:54 +00:00
|
|
|
[
|
|
|
|
|
'label' => $lang['sort_level'],
|
|
|
|
|
'view_type' => 'field',
|
|
|
|
|
'view_key' => 'sort_level',
|
|
|
|
|
'search_config' => [
|
|
|
|
|
'form_type' => 'section',
|
|
|
|
|
],
|
|
|
|
|
],
|
2021-01-27 14:21:04 +00:00
|
|
|
[
|
2023-02-02 15:54:37 +00:00
|
|
|
'label' => $lang['sales_count'],
|
2021-01-27 14:21:04 +00:00
|
|
|
'view_type' => 'field',
|
|
|
|
|
'view_key' => 'sales_count',
|
|
|
|
|
'is_sort' => 1,
|
|
|
|
|
'search_config' => [
|
|
|
|
|
'form_type' => 'section',
|
|
|
|
|
],
|
|
|
|
|
],
|
2020-06-14 08:04:37 +00:00
|
|
|
[
|
2023-02-02 15:54:37 +00:00
|
|
|
'label' => $lang['access_count'],
|
2020-06-14 08:04:37 +00:00
|
|
|
'view_type' => 'field',
|
|
|
|
|
'view_key' => 'access_count',
|
2020-10-24 16:45:09 +00:00
|
|
|
'is_sort' => 1,
|
2020-06-14 08:04:37 +00:00
|
|
|
'search_config' => [
|
|
|
|
|
'form_type' => 'section',
|
|
|
|
|
],
|
|
|
|
|
],
|
2020-05-31 14:06:40 +00:00
|
|
|
[
|
2023-02-02 15:54:37 +00:00
|
|
|
'label' => $lang['add_time'],
|
2020-05-31 14:06:40 +00:00
|
|
|
'view_type' => 'field',
|
|
|
|
|
'view_key' => 'add_time',
|
2020-10-24 16:45:09 +00:00
|
|
|
'is_sort' => 1,
|
2020-05-31 14:06:40 +00:00
|
|
|
'search_config' => [
|
|
|
|
|
'form_type' => 'datetime',
|
2020-06-08 06:03:33 +00:00
|
|
|
],
|
|
|
|
|
],
|
|
|
|
|
[
|
2023-02-02 15:54:37 +00:00
|
|
|
'label' => $lang['upd_time'],
|
2020-06-08 06:03:33 +00:00
|
|
|
'view_type' => 'field',
|
|
|
|
|
'view_key' => 'upd_time',
|
2020-10-24 16:45:09 +00:00
|
|
|
'is_sort' => 1,
|
2020-06-08 06:03:33 +00:00
|
|
|
'search_config' => [
|
|
|
|
|
'form_type' => 'datetime',
|
2020-05-31 14:06:40 +00:00
|
|
|
],
|
2020-05-29 06:03:53 +00:00
|
|
|
],
|
|
|
|
|
[
|
2023-01-26 09:06:20 +00:00
|
|
|
'label' => MyLang('operate_title'),
|
2020-05-29 06:03:53 +00:00
|
|
|
'view_type' => 'operate',
|
|
|
|
|
'view_key' => 'goods/module/operate',
|
|
|
|
|
'align' => 'center',
|
|
|
|
|
'fixed' => 'right',
|
2024-12-25 09:35:54 +00:00
|
|
|
'width' => IsMobile() ? 120 : '',
|
2020-05-29 06:03:53 +00:00
|
|
|
],
|
2020-05-20 10:32:23 +00:00
|
|
|
],
|
2022-08-02 09:23:10 +00:00
|
|
|
// 数据配置
|
|
|
|
|
'data' => [
|
|
|
|
|
'table_name' => 'Goods',
|
|
|
|
|
'data_handle' => 'GoodsService::GoodsDataHandle',
|
|
|
|
|
'data_params' => [
|
|
|
|
|
'is_content_app' => 1,
|
|
|
|
|
'is_category' => 1,
|
|
|
|
|
],
|
|
|
|
|
'detail_where' => [
|
|
|
|
|
['is_delete_time', '=', 0],
|
|
|
|
|
],
|
|
|
|
|
],
|
2020-05-20 10:32:23 +00:00
|
|
|
];
|
|
|
|
|
}
|
2020-06-05 15:29:04 +00:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 商品分类条件处理
|
|
|
|
|
* @author Devil
|
|
|
|
|
* @blog http://gong.gg/
|
|
|
|
|
* @version 1.0.0
|
|
|
|
|
* @date 2020-06-03
|
|
|
|
|
* @desc description
|
2020-06-08 06:03:33 +00:00
|
|
|
* @param [array] $value [条件值]
|
2020-06-05 15:29:04 +00:00
|
|
|
* @param [array] $params [输入参数]
|
|
|
|
|
*/
|
|
|
|
|
public function WhereValueGoodsCategory($value, $params = [])
|
|
|
|
|
{
|
|
|
|
|
if(!empty($value))
|
|
|
|
|
{
|
|
|
|
|
// 是否为数组
|
|
|
|
|
if(!is_array($value))
|
|
|
|
|
{
|
|
|
|
|
$value = [$value];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 获取分类下的所有分类 id
|
2023-02-08 13:20:04 +00:00
|
|
|
$cids = GoodsCategoryService::GoodsCategoryItemsIds($value, 1);
|
2020-06-05 15:29:04 +00:00
|
|
|
|
|
|
|
|
// 获取商品 id
|
2020-06-08 06:03:33 +00:00
|
|
|
$ids = Db::name('GoodsCategoryJoin')->where(['category_id'=>$cids])->column('goods_id');
|
2020-06-05 15:29:04 +00:00
|
|
|
|
|
|
|
|
// 避免空条件造成无效的错觉
|
2020-06-08 06:03:33 +00:00
|
|
|
return empty($ids) ? [0] : $ids;
|
2020-06-05 15:29:04 +00:00
|
|
|
}
|
|
|
|
|
return $value;
|
|
|
|
|
}
|
2020-06-08 06:03:33 +00:00
|
|
|
}
|
|
|
|
|
?>
|