合并分支 'lxq'

Conflicts:
	app/admin/model/EbStoreProduct.php
This commit is contained in:
liuxiaoquan 2023-03-13 10:08:31 +08:00
commit 3947713abe
18 changed files with 1866 additions and 830 deletions

View File

@ -12,14 +12,16 @@ use think\facade\View;
use app\admin\model\Merchant; // 商户模型
use app\admin\model\EbStoreProduct; // 商品模型
use app\admin\model\StoreCategory; // 商品分类模型
use app\admin\model\GeoCity; // 省市模型
use app\admin\model\GeoArea; // 区域模型
use app\admin\model\GeoStreet; // 街道模型
use app\admin\model\SupplyChain; // 供应链模型
use app\api\model\Area as AreaModel; // 市场区域模型
use app\api\model\AreaManager as AreaManagerModel; // 区域负责人模型
use app\common\controller\FormatList;
// use app\admin\model\GeoCity; // 省市模型
// use app\admin\model\GeoArea; // 区域模型
// use app\admin\model\GeoStreet; // 街道模型
use app\admin\model\SupplyChain; // 供应链模型
// use app\api\model\Area as AreaModel; // 市场区域模型
// use app\api\model\AreaManager as AreaManagerModel; // 区域负责人模型
/**
*
* 商品控制器
@ -31,6 +33,7 @@ class Product extends BaseController
protected $adminInfo;
protected $url;
protected $product;
protected $mer_id = 4;//待开发成自动获取商城登陆商户id
public function __construct(EbStoreProduct $product)
{
@ -71,12 +74,12 @@ class Product extends BaseController
/**
*
* 供应链团队列表
* 商户商品列表
*
*/
public function index(StoreCategory $category)
{
if (true) {
if (request()->isAjax()) {
// request()->isAjax()
// Ajax 前端获取数据
$params= get_params();
@ -95,42 +98,38 @@ class Product extends BaseController
$where['cate_id'] = empty($params['plate_cate'])?'':$params['plate_cate'];
// 商户商品分类id
$where['mer_cate_id'] = empty($params['store_cate'])?'':$params['store_cate'];
$where['is_trader'] = isset($params['is_trader'])?$params['is_trader']:0; // 是否自营 1自营 0 不是自营
// $where['mer_cate_id'] = empty($params['store_cate'])?'':$params['store_cate'];
$where['is_trader'] = isset($params['is_trader'])?$params['is_trader']:1; // 是否自营 1自营 0 不是自营
// product
$where['is_gift_bag'] = empty($params['is_gift'])?'':$params['is_gift'];
$where['is_show'] = empty($params['state'])?'':$params['state'];
$where['temp_id'] = empty($params['shipping_tem'])?'':$params['shipping_tem'];
$where['labels'] = empty($params['tag'])?'':$params['tag'];
$where['type'] = 1;//实体商品0 虚拟商品:1
$where['status'] = 0;//管理、审核、通过
$where['type'] = empty($params['type'])?'':$params['type'];//实体商品0 虚拟商品:1
// $where['status'] = 0;//管理、审核、通过
// $where['is_ficti'] = 1;//是否虚拟销量
// $where['product_id'] = 0;
// ['order','sort']
// soft //软删除
if (!empty(get_params('mer_id'))) {
// $params['mer_id'] = $this->mer_id;
if (!empty($params['mer_id'])) {
$mer_id = get_params('mer_id');
$where = array_merge($where, $this->switchType($where['type'],$mer_id,0));
}
$mer_id = 77;
$this->product->getList($mer_id, $where, $page, $limit);
return;
$total = EbStoreProduct::where($where)->count();
$mer_id = isset($params['mer_id'])?$params['mer_id']:NULL;
$data = $this->product->getList($mer_id, $where, $page, $limit);
$list = EbStoreProduct::with(['merchant' => ['merchantType', 'category']])->order('product_id desc')->select();
// $list = EbStoreProduct::with(['merchant' => ['merchantType', 'category']])->order('product_id desc')->select();
View::assign('url', $this->url);
View::assign('list', $list);
View::assign('list', $data['list']);
$result = ['total' => $total, 'data' => $list];
$result = ['total' => $data['count'], 'data' => $data['list']];
return table_assign(0, '', $result);

View File

@ -1,216 +0,0 @@
<?php
/**
* @copyright Copyright (c) 2021 勾股工作室
* @license https://opensource.org/licenses/Apache-2.0
* @link https://www.gougucms.com
*/
namespace app\admin\controller\product;
use app\admin\BaseController;
use think\facade\Db;
use think\facade\View;
use app\admin\model\Merchant; // 商户模型
use app\admin\model\StoreCategory; // 商品分类模型
use app\admin\model\StoreProductReply; // 商品评论模型
use app\admin\model\StoreBrandCategory; // 商品品牌分类模型
use app\admin\model\Guarantee as GuaranteeModel; // 商品保障服务模型
use app\admin\model\GeoCity; // 省市模型
use app\admin\model\GeoArea; // 区域模型
use app\admin\model\GeoStreet; // 街道模型
use app\admin\model\SupplyChain; // 供应链模型
use app\api\model\Area as AreaModel; // 市场区域模型
use app\api\model\AreaManager as AreaManagerModel; // 区域负责人模型
/**
*
* 平台商品参数控制器
*
*
*/
class Specs extends BaseController
{
public function __construct()
{
$this->adminInfo = get_login_admin();
$this->category_id=354;
$this->url=[
'/admin/product.priceDescription/index?category_id='.$this->category_id,
'/admin/product.priceDescription/add',
'/admin/product.priceDescription/edit',
'/admin/product.priceDescription/del',
'/admin/product.priceDescription/index',
];
}
/**
*
* 商品价格列表
*
*/
public function index()
{
if (request()->isAjax()) {
$params= get_params();
$where = [];
if (isset($params['keywords']) && !empty($params['keywords'])){
$where[]= ['name','like','%'.$params['keywords'].'%'];
}
if($this->adminInfo['position_id'] != 1){ //不是超级管理员
$www['admin_id'] = $this->adminInfo['id'];
$user_address = Db::table('fa_szxc_information_useraddress')->where($www)->find();
if ($user_address){
if($user_address['auth_range'] == 1){
$where[] = ['village_id','=',$user_address['village_id']];
}elseif ($user_address['auth_range'] == 2){
$where[] = ['street_id','=',$user_address['street_id']];
}elseif ($user_address['auth_range'] == 3){
$where[] = ['area_id','=',$user_address['area_id']];
}else{
$where[] = ['village_id','=',$user_address['village_id']];
}
}else{
$where[] = ['village_id','=',''];
}
}
$total = StoreBrandCategory::where($where)->count();
$list = StoreBrandCategory::order('sort desc')->select();
View::assign('url', $this->url);
View::assign('list', $list);
$result = ['total' => $total, 'data' => $list];
return table_assign(0, '', $result);
}else{
$list = StoreBrandCategory::select();
View::assign('url', $this->url);
View::assign('list', $list);
return view();
}
}
/**
*
* 新增
*
*/
public function add()
{
if (request()->isAjax()) {
$params = get_params();
$data['cate_name'] = $params['cate_name']; // 分类名称
$data['is_show'] = isset($params['is_show']) && $params['is_show'] == 'on'? 1:0; // 是否显示
$data['pid'] = $params['pid']; // 上级分类
$data['sort'] = $params['sort']; // 排序
$data['create_time'] = date('Y-m-d H:i:s');
// 数据入库
$res = StoreBrandCategory::create($data);
if ($res){
return to_assign(0,'操作成功',['aid'=>$res]);
}
return to_assign(1, '操作失败,原因:'.$res);
}else{
View::assign('editor', get_system_config('other','editor'));
View::assign('url', $this->url);
return view();
}
}
/**
*
* 编辑
*
*/
public function edit()
{
$id = get_params("id");
if(!$id) return to_assign(1, '非法操作!');
if (request()->isAjax()) {
$params = get_params();
$data['cate_name'] = $params['cate_name']; // 分类名称
$data['is_show'] = isset($params['is_show']) && $params['is_show'] == 'on'? 1:0; // 是否显示
$data['pid'] = $params['pid']; // 上级分类
$data['sort'] = $params['sort']; // 排序
$data['create_time'] = date('Y-m-d H:i:s');
// 数据更新
$res = StoreBrandCategory::where('store_brand_category_id', $params['id'])->update($data);
if ($res){
return to_assign(0,'更新成功',['aid'=>$res]);
}
return to_assign(1, '更新失败,原因:'.$res);
}else{
$storeBrandCtegory = StoreBrandCategory::find($id); // 取出当前品牌分类信息
View::assign('detail', $storeBrandCtegory);
View::assign('url', $this->url);
return view();
}
}
/**
*
* 删除
*
*/
public function del()
{
$id = get_params("id");
if(!$id) return to_assign(1, '非法操作!');
// 验证下面是否有子分类
if(StoreBrandCategory::where('pid', $id)->count())
{
return to_assign(1, '请先删除子分类!');
}
$res = StoreBrandCategory::where('store_brand_category_id', $id)->delete();
if ($res){
return to_assign(0,'操作成功',['aid'=>$res]);
}
return to_assign(1, '操作失败,原因:'.$res);
}
/**
*
* 子分类
*
*/
public function street($pcode)
{
$storeBrandCategory = StoreBrandCategory::order('sort desc')
->where('is_show', 1)
->where('pid', $pcode)
->select();
return json($storeBrandCategory);
}
}

View File

@ -0,0 +1,56 @@
<?php
/**
* @date 2023年03月11日
* @author刘孝全
* @emailq8197264@126.com
*
* @ 商品分类列表
*/
namespace app\admin\controller\product;
use app\admin\BaseController;
use app\admin\model\StoreCategory as StoreCategoryModel;
use app\common\controller\FormatList;
use app\common\model\merchant\user\UserMerchant;
class StoreCategory extends BaseController
{
protected $category;
protected $mer_id = 4;
public function __construct(StoreCategoryModel $category)
{
$this->category = $category;
}
protected function getMerId(UserMerchant $user)
{
// $user->isMerUser($uid, $mer_id);
}
/**
* 平台商品分类Tree列表
*
*/
public function getList()
{
$where['mer_id'] = 0;
$where['is_show'] = 0;
$list = $this->category->getList($where);
$list = FormatList::DropDownMenu($list);
return to_assign(0,'', $list);
}
/**
* 商户商品分类Tree列表
*/
public function getStoreCategoryList(){
$data = $this->category->getStoreCategoryList($this->mer_id, 1);
$list = FormatList::FormatCategory($data,'store_category_id', 'pid', 'cate_name','child', 'id', 'title');
return to_assign(0, '', $list);
}
}

View File

@ -11,7 +11,8 @@
namespace app\admin\model;
use think\Model;
use StoreCategory as StoreCategoryModel;
use app\admin\model\store\ProductCate;
class EbStoreProduct extends Model
{
@ -31,10 +32,22 @@ class EbStoreProduct extends Model
*/
public function merchant()
{
return $this->hasOne(Merchant::class, 'mer_id', 'mer_id');
return $this->hasOne(Merchant::class,'mer_id','mer_id')->field('is_trader,type_id,mer_id,mer_name,mer_avatar,product_score,service_score,postage_score,service_phone,care_count');
}
public function storeCategory()
{
return $this->hasOne(StoreCategory::class,'store_category_id','cate_id')->field('store_category_id,cate_name');
}
public function merCateId()
{
return $this->hasMany(ProductCate::class,'product_id','product_id')->field('product_id, mer_cate_id');
}
public function brand()
{
return $this->hasOne(StoreBrand::class,'brand_id','brand_id')->field('brand_id,brand_name');
}
/**
@ -50,12 +63,15 @@ class EbStoreProduct extends Model
public function getList(?int $mer_id, array $where, int $page, int $limit)
{
$query = self::search($mer_id, $where)
->with(['merCateId.category', 'storeCategory', 'brand']);
->with(['merCateId.category', 'storeCategory', 'brand', 'Merchant']);
$count = $query->count();
$data = $query->field($this->filed)->page($page, $limit)->select();
$data = $query->field($this->filed)->page($page, $limit)
->order('Product.product_id desc')
// ->fetchSql()
->select();
// echo $data;exit('--');
$data->append(['us_status']);
$list = hasMany(
$data,
'mer_labels',
@ -98,17 +114,26 @@ class EbStoreProduct extends Model
$query = self::alias('Product');
if (isset($where['is_trader']) && $where['is_trader'] !== '') {
$query->hasWhere('merchant', function ($query) use ($where) {
$query->where('is_trader', $where['is_trader']);
});
// hasWhere添加别名不生效 alias 改为Join
// $query->hasWhere('merchant',
// function ($query) use ($where) {
// $query->where('is_trader', $where['is_trader']);
// }
// );
$query->Join('Merchant', 'Merchant.mer_id = Product.mer_id')
->where('Merchant.is_trader', $where['is_trader']);
}
$query->withSearch($keyArray, $whereArr)
->Join('StoreSpu U', 'Product.product_id = U.product_id')->where('U.product_type', $where['product_type'] ?? 0)
->when(($merId !== null), function ($query) use ($merId) {
->Join('StoreSpu U', 'Product.product_id = U.product_id')
->where('U.product_type', $where['product_type'] ?? 0)
->when(($merId !== null),
function ($query) use ($merId) {
$query->where('Product.mer_id', $merId);
})
->when(isset($where['hot_type']) && $where['hot_type'] !== '', function ($query) use ($where) {
}
)
->when(isset($where['hot_type']) && $where['hot_type'] !== '',
function ($query) use ($where) {
if ($where['hot_type'] == 'new')
$query->where('is_new', 1);
else if ($where['hot_type'] == 'hot')
@ -117,61 +142,146 @@ class EbStoreProduct extends Model
$query->where('is_best', 1);
else if ($where['hot_type'] == 'good')
$query->where('is_benefit', 1);
});
$query->when(
isset($where['pid']) && $where['pid'] !== '',
function ($query) use ($where) {
$ids = array_merge(self::findChildrenId((int)$where['pid']), [(int)$where['pid']]);
if (count($ids)) $query->whereIn('cate_id', $ids);
}
)
->when(isset($where['us_status']) && $where['us_status'] !== '', function ($query) use ($where) {
if ($where['us_status'] == 0) {
$query->where('Product.is_show', 0)->where('Product.is_used', 1)->where('Product.status', 1);
}
if ($where['us_status'] == 1) {
$query->where('Product.is_show', 1)->where('Product.is_used', 1)->where('Product.status', 1);
}
if ($where['us_status'] == -1) {
$query->where(function ($query) {
$query->where('Product.is_used', 0)->whereOr('Product.status', '<>', 1);
});
}
})
->when(isset($where['mer_labels']) && $where['mer_labels'] !== '', function ($query) use ($where) {
$query->whereLike('U.mer_labels', "%,{$where['mer_labels']},%");
})
->when(isset($where['sys_labels']) && $where['sys_labels'] !== '', function ($query) use ($where) {
$query->whereLike('U.sys_labels', "%,{$where['sys_labels']},%");
})
->when(isset($where['order']), function ($query) use ($where, $merId) {
if (in_array($where['order'], ['is_new', 'price_asc', 'price_desc', 'rate', 'sales'])) {
if ($where['order'] == 'price_asc') {
$where['order'] = 'price ASC';
} else if ($where['order'] == 'price_desc') {
$where['order'] = 'price DESC';
} else {
$where['order'] = $where['order'] . ' DESC';
}
$query->order($where['order'] . ',rank DESC ,create_time DESC ');
} else if ($where['order'] !== '') {
$query->order('U.' . $where['order'] . ' DESC,U.create_time DESC');
} else {
$query->order('U.create_time DESC');
}
})
->when(isset($where['star']), function ($query) use ($where) {
$query->when($where['star'] !== '', function ($query) use ($where) {
$query->where('U.star', $where['star']);
}
)
->when(isset($where['pid']) && $where['pid'] !== '',
function ($query) use ($where) {
$ids = array_merge(self::findChildrenId((int)$where['pid']), [(int)$where['pid']]);
if (count($ids)) $query->whereIn('cate_id', $ids);
}
)
->when(isset($where['us_status']) && $where['us_status'] !== '', function ($query) use ($where) {
if ($where['us_status'] == 0) {
$query->where('Product.is_show', 0)->where('Product.is_used', 1)->where('Product.status', 1);
}
if ($where['us_status'] == 1) {
$query->where('Product.is_show', 1)->where('Product.is_used', 1)->where('Product.status', 1);
}
if ($where['us_status'] == -1) {
$query->where(function ($query) {
$query->where('Product.is_used', 0)->whereOr('Product.status', '<>', 1);
});
$query->order('U.star DESC,U.rank DESC,Product.create_time DESC');
}
})
->when(isset($where['mer_labels']) && $where['mer_labels'] !== '', function ($query) use ($where) {
$query->whereLike('U.mer_labels', "%,{$where['mer_labels']},%");
})
->when(isset($where['sys_labels']) && $where['sys_labels'] !== '', function ($query) use ($where) {
$query->whereLike('U.sys_labels', "%,{$where['sys_labels']},%");
})
->when(isset($where['order']), function ($query) use ($where, $merId) {
if (in_array($where['order'], ['is_new', 'price_asc', 'price_desc', 'rate', 'sales'])) {
if ($where['order'] == 'price_asc') {
$where['order'] = 'price ASC';
} else if ($where['order'] == 'price_desc') {
$where['order'] = 'price DESC';
} else {
$where['order'] = $where['order'] . ' DESC';
}
$query->order($where['order'] . ',rank DESC ,create_time DESC ');
} else if ($where['order'] !== '') {
$query->order('U.' . $where['order'] . ' DESC,U.create_time DESC');
} else {
$query->order('U.create_time DESC');
}
})
->when(isset($where['star']), function ($query) use ($where) {
$query->when($where['star'] !== '', function ($query) use ($where) {
$query->where('U.star', $where['star']);
});
$query->order('U.star DESC,U.rank DESC,Product.create_time DESC');
});
return $query;
}
/**
*
*/
public function findChildrenId($id)
{
return StoreCategoryModel::whereLike('path', '%/'. $id . '/%')->column('store_category_id');
return StoreCategory::whereLike('path', '%/' . $id . '/%')->column('store_category_id');
}
protected function hasMany1($collection, $field, $model, $searchKey, $insertKey, $where = [] ,$select = '*')
{
$ids = [];
$link = [];
if (!$collection) return [];
$collection = $collection->toArray();
foreach ($collection as $k => $item) {
if (is_array($item[$field])) {
$link[$k] = array_unique($item[$field]);
$ids = array_merge($item[$field], $ids);
} else {
$link[$k] = array_unique(explode(',', $item[$field]));
}
$ids = array_merge($link[$k], $ids);
if (isset($collection[$k][$insertKey])) unset($collection[$k][$insertKey]);
}
$ids = array_filter(array_unique($ids));
if (!count($ids)) {
return $collection;
}
$many = $model::whereIn($searchKey, array_unique($ids))->where($where)->field($select)->select();
if (!$many) return $collection;
$many = $many->toArray();
foreach ($link as $k => $val) {
foreach ($many as $item) {
if (in_array($item[$searchKey], $val)) {
if (!isset($collection[$k][$insertKey])) $collection[$k][$insertKey] = [];
$collection[$k][$insertKey][] = $item;
}
}
}
return $collection;
}
}
if (!function_exists('hasMany')) {
function hasMany($collection, $field, $model, $searchKey, $insertKey, $where = [] ,$select = '*')
{
$ids = [];
$link = [];
if (!$collection) return [];
$collection = $collection->toArray();
foreach ($collection as $k => $item) {
if (is_array($item[$field])) {
$link[$k] = array_unique($item[$field]);
$ids = array_merge($item[$field], $ids);
} else {
$link[$k] = array_unique(explode(',', $item[$field]));
}
$ids = array_merge($link[$k], $ids);
if (isset($collection[$k][$insertKey])) unset($collection[$k][$insertKey]);
}
$ids = array_filter(array_unique($ids));
if (!count($ids)) {
return $collection;
}
$many = $model::whereIn($searchKey, array_unique($ids))->where($where)->field($select)->select();
if (!$many) return $collection;
$many = $many->toArray();
foreach ($link as $k => $val) {
foreach ($many as $item) {
if (in_array($item[$searchKey], $val)) {
if (!isset($collection[$k][$insertKey])) $collection[$k][$insertKey] = [];
$collection[$k][$insertKey][] = $item;
}
}
}
return $collection;
}
}

View File

@ -0,0 +1,58 @@
<?php
// +----------------------------------------------------------------------
// | CRMEB [ CRMEB赋能开发者助力企业发展 ]
// +----------------------------------------------------------------------
// | Copyright (c) 2016~2022 https://www.crmeb.com All rights reserved.
// +----------------------------------------------------------------------
// | Licensed CRMEB并不是自由软件未经许可不能去掉CRMEB相关版权
// +----------------------------------------------------------------------
// | Author: CRMEB Team <admin@crmeb.com>
// +----------------------------------------------------------------------
namespace app\common\model\store\product;
use app\common\model\BaseModel;
class ProductLabel extends BaseModel
{
/**
* TODO
* @return string
* @author Qinii
* @day 8/17/21
*/
public static function tablePk(): string
{
return 'product_label_id';
}
/**
* TODO
* @return string
* @author Qinii
* @day 8/17/21
*/
public static function tableName(): string
{
return 'store_product_label';
}
public function searchMerIdAttr($query, $value)
{
$query->where('mer_id', $value);
}
public function searchStatusAttr($query, $value)
{
$query->where('status', $value);
}
public function searchNameAttr($query, $value)
{
$query->whereLike('name', "%{$value}%");
}
public function searchIsDelAttr($query, $value)
{
$query->where('is_del', $value);
}
}

View File

@ -44,6 +44,38 @@
return $list;
}
public function getStoreCategoryList(int $merId = 0,$status = 0)
{
$data = self::getAllOptions($merId,$status);
return $data;
}
/**
* 获取列表 -- 筛选用
* @Date: 2020/5/16
* @param int|null $mer_id
* @return mixed
*/
protected function getAllOptions($mer_id = null,$status = null,$level = null)
{
$field = 'pid,cate_name';
$query = StoreCategory::when(($mer_id !== null),
function($query)use($mer_id){
$query->where('mer_id', $mer_id);
})
->when($status,function($query)use($status){
$query->where('is_show',$status);
})
->when(($level != '' && $level != null),function($query)use($level){
$query->where('level','<',$level);
}
);
return $query->order('sort DESC,'.$this->getPk().' DESC')->column($field, $this->getPk());
}
/**
* 查询语句构建
*@author Liuxiaoquan

View File

@ -0,0 +1,542 @@
<?php
// +----------------------------------------------------------------------
// | CRMEB [ CRMEB赋能开发者助力企业发展 ]
// +----------------------------------------------------------------------
// | Copyright (c) 2016~2022 https://www.crmeb.com All rights reserved.
// +----------------------------------------------------------------------
// | Licensed CRMEB并不是自由软件未经许可不能去掉CRMEB相关版权
// +----------------------------------------------------------------------
// | Author: CRMEB Team <admin@crmeb.com>
// +----------------------------------------------------------------------
namespace app\common\model\store\product;
use app\common\dao\store\StoreSeckillActiveDao;
use app\common\model\BaseModel;
use app\common\model\store\coupon\StoreCouponProduct;
use app\common\model\store\Guarantee;
use app\common\model\store\GuaranteeTemplate;
use app\common\model\store\GuaranteeValue;
use app\common\model\store\parameter\ParameterValue;
use app\common\model\store\shipping\ShippingTemplate;
use app\common\model\store\StoreBrand;
use app\common\model\store\StoreCategory;
use app\common\model\store\StoreSeckillActive;
use app\common\model\system\merchant\Merchant;
use app\common\repositories\store\StoreCategoryRepository;
use crmeb\services\VicWordService;
use Darabonba\GatewaySpi\Models\InterceptorContext\request;
use think\db\BaseQuery;
use think\facade\Db;
use think\model\concern\SoftDelete;
/**
* TODO:
*/
class Product extends BaseModel
{
use SoftDelete;
protected $deleteTime = 'is_del';
protected $defaultSoftDelete = 0;
/**
* @Author:Qinii
* @Date: 2020/5/8
* @return string
*/
public static function tablePk(): string
{
return 'product_id';
}
/**
* @Author:Qinii
* @Date: 2020/5/8
* @return string
*/
public static function tableName(): string
{
return 'store_product';
}
/*
* -----------------------------------------------------------------------------------------------------------------
* 属性
* -----------------------------------------------------------------------------------------------------------------
*/
public function getSliderImageAttr($value)
{
return $value ? explode(',',$value) : [];
}
public function getGiveCouponIdsAttr($value)
{
return $value ? explode(',',$value) : [];
}
public function getMaxExtensionAttr($value)
{
if($this->extension_type){
$org_extension = ($this->attrValue()->order('extension_two DESC')->value('extension_one'));
} else {
$org_extension = bcmul(($this->attrValue()->order('price DESC')->value('price')) , systemConfig('extension_one_rate'),2);
}
$spreadUser = (request()->isLogin() && request()->userType() == 1 ) ? request()->userInfo() : null;
if ($spreadUser && $spreadUser->brokerage_level > 0 && $spreadUser->brokerage && $spreadUser->brokerage->extension_one_rate > 0) {
$org_extension = bcmul($org_extension, 1 + $spreadUser->brokerage->extension_one_rate, 2);
}
return $org_extension;
}
public function getMinExtensionAttr($value)
{
if($this->extension_type){
$org_extension = ($this->attrValue()->order('extension_two ASC')->value('extension_two'));
} else {
$org_extension = bcmul(($this->attrValue()->order('price ASC')->value('price')) , systemConfig('extension_one_rate'),2);
}
$spreadUser = (request()->isLogin() && request()->userType() == 1 ) ? request()->userInfo() : null;
if ($spreadUser && $spreadUser->brokerage_level > 0 && $spreadUser->brokerage && $spreadUser->brokerage->extension_one_rate > 0) {
$org_extension = bcmul($org_extension, 1 + $spreadUser->brokerage->extension_one_rate, 2);
}
return $org_extension;
}
public function check()
{
if(!$this || !$this->is_show || !$this->is_used || !$this->status || $this->is_del || !$this->mer_status) return false;
return true;
}
/**
* TODO 秒杀商品结束时间
* @return false|int
* @author Qinii
* @day 2020-08-15
*/
public function getEndTimeAttr()
{
if($this->product_type !== 1) return true;
$day = date('Y-m-d',time());
$_day = strtotime($day);
$end_day = strtotime($this->seckillActive['end_day']);
if($end_day >= $_day)
return strtotime($day.$this->seckillActive['end_time'].':00:00');
if($end_day < strtotime($day))
return strtotime(date('Y-m-d',$end_day).$this->seckillActive['end_time'].':00:00');
}
/**
* TODO 秒杀商品状态
* @return array|int
* @author Qinii
* @day 2020-08-19
*/
public function getSeckillStatusAttr()
{
if($this->product_type !== 1) return true;
$day = strtotime(date('Y-m-d',time()));
$_h = date('H',time());
$start_day = strtotime($this->seckillActive['start_day']);
$end_day = strtotime($this->seckillActive['end_day']);
if(!$this->seckillActive) return '';
if($this->seckillActive['status'] !== -1){
//还未开始
if($start_day > time() || $this->is_show !== 1)return 0;
//已结束
if($end_day < $day) return -1;
//开始 - 结束
if($start_day <= $day && $day <= $end_day){
//未开始
if($this->seckillActive['start_time'] > $_h) return 0;
//已结束
if($this->seckillActive['end_time'] <= $_h) return -1;
//进行中
if($this->seckillActive['start_time'] <= $_h && $this->seckillActive['end_time'] > $_h) return 1;
}
}
//已结束
return -1;
}
public function getImageAttr($value)
{
if (is_int(strpos($value, 'http'))){
return $value;
}else{
return rtrim(systemConfig('site_url'),'/') .$value;
}
}
public function getTopReplyAttr()
{
$res = ProductReply::where('product_id',$this->product_id)->where('is_del',0)->with(['orderProduct'])->field('reply_id,uid,nickname,merchant_reply_content,avatar,order_product_id,product_id,product_score,service_score,postage_score,comment,pics,rate,create_time')
->order('sort DESC,create_time DESC')->limit(1)->find();
if(!$res) return null;
if ($res['orderProduct'])
$res['sku'] = $res['orderProduct']['cart_info']['productAttr']['sku'];
unset($res['orderProduct']);
if (strlen($res['nickname']) > 1) {
$str = mb_substr($res['nickname'],0,1) . '*';
if (strlen($res['nickname']) > 2) {
$str .= mb_substr($res['nickname'], -1,1);
}
$res['nickname'] = $str;
}
return $res;
}
public function getUsStatusAttr()
{
return ($this->status == 1) ? ($this->is_used == 1 ? ( $this->is_show ? 1 : 0 ) : -1) : -1;
}
public function getGuaranteeTemplateAttr()
{
$gua = GuaranteeTemplate::where('guarantee_template_id',$this->guarantee_template_id)->where('status',1)->where('is_del',0)->find();
if(!$gua) return [];
$guarantee_id = GuaranteeValue::where('guarantee_template_id',$this->guarantee_template_id)->column('guarantee_id');
return Guarantee::where('guarantee_id','in',$guarantee_id)->where('status',1)->where('is_del',0)->select();
}
public function getMaxIntegralAttr()
{
if(systemConfig('integral_status') && merchantConfig($this->mer_id,'mer_integral_status')){
$price = ($this->attrValue()->order('price DESC')->value('price'));
$rate = ($this->integral_rate < 0) ? merchantConfig($this->mer_id,'mer_integral_rate') : $this->integral_rate;
$rate = $rate < 0 ? $rate / 100 : 0;
return bcmul($price ,$rate,2);
}
return '0';
}
public function getHotRankingAttr()
{
if ($this->product_type == 0) {
$where = [
'is_show' => 1,
'status' => 1,
'is_used' => 1,
'product_type' => 0,
'mer_status' => 1,
'is_gift_bag' => 0,
'cate_id' => $this->cate_id
];
self::where($where)->order('sales DESC');
}
}
/**
* TODO 商品参数
* @author Qinii
* @day 2022/11/24
*/
public function getParamsAttr()
{
if(in_array($this->product_type,[0,2])) {
$product_id = $this->product_id;
} else {
$product_id = $this->old_product_id;
}
return ParameterValue::where('product_id',$product_id)->order('parameter_value_id ASC')->select();
}
public function getParamTempIdAttr($value)
{
return $value ? explode(',',$value) : $value;
}
/*
* -----------------------------------------------------------------------------------------------------------------
* 关联模型
* -----------------------------------------------------------------------------------------------------------------
*/
public function merCateId()
{
return $this->hasMany(ProductCate::class,'product_id','product_id')->field('product_id,mer_cate_id');
}
public function attr()
{
return $this->hasMany(ProductAttr::class,'product_id','product_id');
}
public function attrValue()
{
return $this->hasMany(ProductAttrValue::class,'product_id','product_id');
}
public function oldAttrValue()
{
return $this->hasMany(ProductAttrValue::class,'product_id','old_product_id');
}
public function content()
{
return $this->hasOne(ProductContent::class,'product_id','product_id');
}
protected function temp()
{
return $this->hasOne(ShippingTemplate::class,'shipping_template_id','temp_id');
}
public function storeCategory()
{
return $this->hasOne(StoreCategory::class,'store_category_id','cate_id')->field('store_category_id,cate_name');
}
public function merchant()
{
return $this->hasOne(Merchant::class,'mer_id','mer_id')->field('is_trader,type_id,mer_id,mer_name,mer_avatar,product_score,service_score,postage_score,service_phone,care_count');
}
public function reply()
{
return $this->hasMany(ProductReply::class,'product_id','product_id')->order('create_time DESC');
}
public function brand()
{
return $this->hasOne(StoreBrand::class,'brand_id','brand_id')->field('brand_id,brand_name');
}
public function seckillActive()
{
return $this->hasOne(StoreSeckillActive::class,'product_id','product_id');
}
public function issetCoupon()
{
return $this->hasOne(StoreCouponProduct::class, 'product_id', 'product_id')->alias('A')
->rightJoin('StoreCoupon B', 'A.coupon_id = B.coupon_id')->where(function (BaseQuery $query) {
$query->where('B.is_limited', 0)->whereOr(function (BaseQuery $query) {
$query->where('B.is_limited', 1)->where('B.remain_count', '>', 0);
});
})->where(function (BaseQuery $query) {
$query->where('B.is_timeout', 0)->whereOr(function (BaseQuery $query) {
$time = date('Y-m-d H:i:s');
$query->where('B.is_timeout', 1)->where('B.start_time', '<', $time)->where('B.end_time', '>', $time);
});
})->field('A.product_id,B.*')->where('status', 1)->where('type', 1)->where('send_type', 0)->where('is_del', 0)
->order('sort DESC,coupon_id DESC')->hidden(['is_del', 'status']);
}
public function assist()
{
return $this->hasOne(ProductAssist::class,'product_id','product_id');
}
public function productGroup()
{
return $this->hasOne(ProductGroup::class,'product_id','product_id');
}
public function guarantee()
{
return $this->hasOne(GuaranteeTemplate::class,'guarantee_template_id','guarantee_template_id')->where('status',1)->where('is_del',0);
}
/**
* TODO 是否是会员
* @return bool
* @author Qinii
* @day 2023/1/4
*/
public function getIsVipAttr()
{
if (request()->isLogin()) {
if (request()->userType() == 1) {
$userInfo = request()->userInfo();
return $userInfo->is_svip ? true : false;
} else {
return true;
}
}
return false;
}
/**
* TODO 是否展示会员价
* @return bool
* @author Qinii
* @day 2023/1/4
*/
public function getShowSvipPriceAttr()
{
if ($this->mer_svip_status != 0 && (systemConfig('svip_show_price') != 1 || $this->is_vip) && $this->svip_price_type > 0 ) {
return true;
}
return false;
}
/**
* TODO 是否显示会员价等信息
* @return array
* @author Qinii
* @day 2022/11/24
*/
public function getShowSvipInfoAttr()
{
$res = [
'show_svip' => true, //是否展示会员入口
'is_svip' => false, //当前用户是否是会员
'show_svip_price' => false, //是否展示会员价
'save_money' => 0, //当前商品会员优化多少钱
];
if ($this->product_type == 0) {
if (!systemConfig('svip_switch_status')) {
$res['show_svip'] = false;
} else {
$res['is_svip'] = $this->is_vip;
if ($this->show_svip_price) {
$res['show_svip_price'] = true;
$res['save_money'] = bcsub($this->price, $this->svip_price, 2);
}
}
}
return $res;
}
/**
* TODO 获取会员价
* @return int|string
* @author Qinii
* @day 2023/1/4
*/
public function getSvipPriceAttr()
{
if ($this->product_type == 0 && $this->mer_svip_status != 0 && $this->show_svip_price) {
//默认比例
if ($this->svip_price_type == 1) {
$rate = merchantConfig($this->mer_id,'svip_store_rate');
$svip_store_rate = $rate > 0 ? bcdiv($rate,100,2) : 0;
$price = $this->attrValue()->order('price ASC')->value('price');
return bcmul($price,$svip_store_rate,2);
}
//自定义
if ($this->svip_price_type == 2) {
return $this->getData('svip_price');
}
}
return 0;
}
/*
* -----------------------------------------------------------------------------------------------------------------
* 搜索器
* -----------------------------------------------------------------------------------------------------------------
*/
public function searchMerCateIdAttr($query, $value)
{
$cate_ids = (StoreCategory::where('path','like','%/'.$value.'/%'))->column('store_category_id');
$cate_ids[] = intval($value);
$product_id = ProductCate::whereIn('mer_cate_id',$cate_ids)->column('product_id');
$query->whereIn('Product.product_id',$product_id);
}
public function searchKeywordAttr($query, $value)
{
if (!$value) return;
if (is_numeric($value)) {
$query->whereLike("Product.store_name|Product.keyword|bar_code|Product.product_id", "%{$value}%");
} else {
$word = app()->make(VicWordService::class)->getWord($value);
$query->where(function ($query) use ($word, $value) {
foreach ($word as $item) {
$query->whereOr('Product.store_name|Product.keyword', 'LIKE', "%$item%");
}
$query->order(Db::raw('REPLACE(Product.store_name,\'' . $value . '\',\'\')'));
});
}
}
public function searchStatusAttr($query, $value)
{
if($value === -1){
$query->where('Product.status', 'in',[-1,-2]);
}else {
$query->where('Product.status',$value);
}
}
public function searchCateIdAttr($query, $value)
{
$query->where('cate_id',$value);
}
public function searchCateIdsAttr($query, $value)
{
$query->whereIn('cate_id',$value);
}
public function searchIsShowAttr($query, $value)
{
$query->where('is_show',$value);
}
public function searchPidAttr($query, $value)
{
$cateId = app()->make(StoreCategoryRepository::class)->allChildren(intval($value));
$query->whereIn('cate_id', $cateId);
}
public function searchStockAttr($query, $value)
{
$value ? $query->where('stock','<=', $value) : $query->where('stock', $value);
}
public function searchIsNewAttr($query, $value)
{
$query->where('is_new',$value);
}
public function searchPriceAttr($query, $value)
{
if(empty($value[0]) && !empty($value[1]))
$query->where('price','<',$value[1]);
if(!empty($value[0]) && empty($value[1]))
$query->where('price','>',$value[0]);
if(!empty($value[0]) && !empty($value[1]))
$query->whereBetween('price',[$value[0],$value[1]]);
}
public function searchBrandIdAttr($query, $value)
{
$query->whereIn('brand_id',$value);
}
public function searchIsGiftBagAttr($query, $value)
{
$query->where('is_gift_bag',$value);
}
public function searchIsGoodAttr($query, $value)
{
$query->where('is_good',$value);
}
public function searchIsUsedAttr($query, $value)
{
$query->where('is_used',$value);
}
public function searchProductTypeAttr($query, $value)
{
$query->where('Product.product_type',$value);
}
public function searchSeckillStatusAttr($query, $value)
{
$product_id = (new StoreSeckillActiveDao())->getStatus($value)->column('product_id');
$query->whereIn('Product.product_id',$product_id);
}
public function searchStoreNameAttr($query, $value)
{
$query->where('Product.store_name','like','%'.$value.'%');
}
public function searchMerStatusAttr($query, $value)
{
$query->where('mer_status',$value);
}
public function searchProductIdAttr($query, $value)
{
$query->where('Product.product_id',$value);
}
public function searchPriceOnAttr($query, $value)
{
$query->where('price','>=',$value);
}
public function searchPriceOffAttr($query, $value)
{
$query->where('price','<=',$value);
}
public function searchisFictiAttr($query, $value)
{
$query->where('type',$value);
}
public function searchGuaranteeTemplateIdAttr($query, $value)
{
$query->whereIn('guarantee_template_id',$value);
}
public function searchTempIdAttr($query, $value)
{
$query->whereIn('Product.temp_id',$value);
}
}

View File

@ -0,0 +1,32 @@
<?php
// +----------------------------------------------------------------------
// | CRMEB [ CRMEB赋能开发者助力企业发展 ]
// +----------------------------------------------------------------------
// | Copyright (c) 2016~2022 https://www.crmeb.com All rights reserved.
// +----------------------------------------------------------------------
// | Licensed CRMEB并不是自由软件未经许可不能去掉CRMEB相关版权
// +----------------------------------------------------------------------
// | Author: CRMEB Team <admin@crmeb.com>
// +----------------------------------------------------------------------
namespace app\admin\model\store;
use think\Model;
use app\admin\model\StoreCategory;
class ProductCate extends Model
{
protected $connection = 'shop';
protected $table = 'eb_store_product_cate';
public function category()
{
return $this->hasOne(StoreCategory::class,'store_category_id','mer_cate_id')->field('store_category_id, cate_name');
}
public function searchProductIdAttr($query, $value)
{
$query->where('product_id',$value);
}
}

View File

@ -0,0 +1,157 @@
<?php
namespace app\common\dao\user;
// use app\common\model\user\UserLabel;
use think\db\BaseQuery;
use think\Model;
/**
* Class UserMerchant
*/
class UserMerchant extends Model
{
/**
* @return string|null
* @author xaboy
*/
public static function tablePk(): ?string
{
return 'user_merchant_id';
}
/**
* @return string
* @author xaboy
* @day 2020/10/20
*/
public static function tableName(): string
{
return 'user_merchant';
}
public function user()
{
return $this->hasOne(User::class, 'uid', 'uid');
}
/**
* @param $value
* @return array
* @author xaboy
* @day 2020-05-09
*/
public function getLabelIdAttr($value)
{
return $value ? explode(',', $value) : [];
}
/**
* @param $value
* @return string
* @author xaboy
* @day 2020-05-09
*/
public function setLabelIdAttr($value)
{
return implode(',', $value);
}
public function getAuthLabelAttr()
{
return app()->make(UserLabel::class)->whereIn('label_id', $this->label_id)->where('mer_id', $this->mer_id)->where('type', 1)->column('label_id');
}
/**
* @return string
* @author xaboy
* @day 2020/10/20
*/
protected function getModel(): string
{
return UserMerchant::class;
}
/**
* @param $uid
* @param $mer_id
* @return bool
* @author xaboy
* @day 2020/10/20
*/
public function isMerUser($uid, $mer_id)
{
return $this->existsWhere(compact('uid', 'mer_id'));
}
/**
* @param $uid
* @param $mer_id
* @return int
* @throws \think\db\exception\DbException
* @author xaboy
* @day 2020/10/20
*/
public function updateLastTime($uid, $mer_id)
{
return UserMerchant::getDB()->where(compact('uid', 'mer_id'))->update([
'last_time' => date('Y-m-d H:i:s')
]);
}
/**
* @param array $where
* @return mixed
* @author xaboy
* @day 2020/10/20
*/
public function search(array $where)
{
return UserMerchant::getDB()->alias('A')->leftJoin('User B', 'A.uid = B.uid')
->when(isset($where['mer_id']) && $where['mer_id'] !== '', function ($query) use ($where) {
$query->where('A.mer_id', $where['mer_id']);
})->when(isset($where['nickname']) && $where['nickname'], function (BaseQuery $query) use ($where) {
return $query->where('B.nickname', 'like', '%' . $where['nickname'] . '%');
})->when(isset($where['sex']) && $where['sex'] !== '', function (BaseQuery $query) use ($where) {
return $query->where('B.sex', intval($where['sex']));
})->when(isset($where['is_promoter']) && $where['is_promoter'] !== '', function (BaseQuery $query) use ($where) {
return $query->where('B.is_promoter', $where['is_promoter']);
})->when(isset($where['uids']), function (BaseQuery $query) use ($where) {
return $query->whereIn('A.uid', $where['uids']);
})->when(isset($where['user_time_type']) && $where['user_time_type'] !== '' && $where['user_time'] != '', function ($query) use ($where) {
if ($where['user_time_type'] == 'visit') {
getModelTime($query, $where['user_time'], 'A.last_time');
}
if ($where['user_time_type'] == 'add_time') {
getModelTime($query, $where['user_time'], 'A.create_time');
}
})->when(isset($where['pay_count']) && $where['pay_count'] !== '', function ($query) use ($where) {
if ($where['pay_count'] == -1) {
$query->where('A.pay_num', 0);
} else {
$query->where('A.pay_num', '>', $where['pay_count']);
}
})->when(isset($where['label_id']) && $where['label_id'] !== '', function (BaseQuery $query) use ($where) {
return $query->whereRaw('CONCAT(\',\',A.label_id,\',\') LIKE \'%,' . $where['label_id'] . ',%\'');
})->when(isset($where['user_type']) && $where['user_type'] !== '', function (BaseQuery $query) use ($where) {
return $query->where('B.user_type', $where['user_type']);
})->where('A.status', 1);
}
public function numUserIds($mer_id, $min, $max = null)
{
return UserMerchant::getDB()->where('mer_id', $mer_id)->where('pay_num', '>=', $min)->when(!is_null($max), function ($query) use ($max) {
$query->where('pay_num', '<=', $max);
})->group('uid')->column('uid');
}
public function priceUserIds($mer_id, $min, $max = null)
{
return UserMerchant::getDB()->where('mer_id', $mer_id)->where('pay_price', '>=', $min)->when(!is_null($max), function ($query) use ($max, $min) {
$query->where('pay_price', $min == $max ? '<=' : '<', $max);
})->group('uid')->column('uid');
}
}

View File

@ -134,6 +134,134 @@ Route::group(function () {
]);
//商品分类
Route::group('store/category', function () {
Route::get('create/form', '/createForm')->name('merchantStoreCategoryCreateForm')->option([
'_alias' => '添加表单',
'_auth' => false,
'_form' => 'merchantStoreCategoryCreate',
]);
Route::get('update/form/:id', '/updateForm')->name('merchantStoreCategoryUpdateForm')->option([
'_alias' => '编辑表单',
'_auth' => false,
'_form' => 'merchantStoreCategoryUpdate',
]);
Route::post('update/:id', '/update')->name('merchantStoreCategoryUpdate')->option([
'_alias' => '编辑',
]);
Route::get('lst', '/lst')->name('merchantStoreCategoryLst')->option([
'_alias' => '列表',
]);
Route::get('detail/:id', '/detail')->name('merchantStoreCategoryDtailt')->option([
'_alias' => '详情',
]);
Route::post('create', '/create')->name('merchantStoreCategoryCreate')->option([
'_alias' => '添加',
]);
Route::delete('delete/:id', '/delete')->name('merchantStoreCategoryDelete')->option([
'_alias' => '删除',
]);
Route::post('status/:id', '/switchStatus')->name('merchantStoreCategorySwitchStatus')->option([
'_alias' => '修改状态',
]);
Route::get('list', '/getList')->option([
'_alias' => '筛选',
'_auth' => false,
])->append(['type' => 1]);
Route::get('select', '/getStoreCategoryList')->option([
'_alias' => '',
'_auth' => false,
]);
Route::get('brandlist', '/BrandList')->option([
'_alias' => '品牌列表',
'_auth' => false,
]);
})->prefix('product.StoreCategory')->option([
'_path' => '/product/classify',
'_auth' => true,
'_append'=> [
[
'_name' =>'merchantUploadImage',
'_path' =>'/product/classify',
'_alias' => '上传图片',
'_auth' => true,
],
[
'_name' =>'merchantAttachmentLst',
'_path' =>'/product/classify',
'_alias' => '图片列表',
'_auth' => true,
],
]
]);
//品牌分类
Route::group('store/brand/category', function () {
Route::get('create/form', '/createForm')->name('systemStoreBrandCategoryCreateForm')->option([
'_alias' => '添加表单',
'_auth' => false,
'_form' => 'systemStoreBrandCategoryCreate',
]);
Route::get('update/form/:id', '/updateForm')->name('systemStoreBrandCategoryUpdateForm')->option([
'_alias' => '编辑表单',
'_auth' => false,
'_form' => 'systemStoreBrandCategoryUpdate',
]);
Route::post('update/:id', '/update')->name('systemStoreBrandCategoryUpdate')->option([
'_alias' => '编辑',
]);
Route::get('lst', '/lst')->name('systemStoreBrandCategoryLst')->option([
'_alias' => '列表',
]);
Route::get('detail/:id', '/detail')->name('systemStoreBrandCategoryDtailt')->option([
'_alias' => '详情',
]);
Route::post('create', '/create')->name('systemStoreBrandCategoryCreate')->option([
'_alias' => '添加',
]);
Route::delete('delete/:id', '/delete')->name('systemStoreBrandCategoryDelete')->option([
'_alias' => '删除',
]);
Route::post('status/:id', '/switchStatus')->name('systemStoreBrandCategorySwitchStatus')->option([
'_alias' => '修改状态',
]);
})->prefix('admin.store.StoreBrandCategory')->option([
'_path' => '/product/band/brandClassify',
'_auth' => true,
]);
//品牌
Route::group('store/brand', function () {
Route::get('create/form', '/createForm')->name('systemStoreBrandCreateForm')->option([
'_alias' => '添加表单',
'_auth' => false,
'_form' => 'systemStoreBrandCreate',
]);
Route::get('update/form/:id', '/updateForm')->name('systemStoreBrandUpdateForm')->option([
'_alias' => '编辑表单',
'_auth' => false,
'_form' => 'systemStoreBrandUpdate',
]);
Route::get('lst', '/lst')->name('systemStoreBrandLst')->option([
'_alias' => '列表',
]);
Route::post('status/:id', '/switchStatus')->name('systemStoreBrandSwithStatus')->option([
'_alias' => '修改状态',
]);
Route::post('create', '/create')->name('systemStoreBrandCreate')->option([
'_alias' => '添加',
]);
Route::post('update/:id', '/update')->name('systemStoreBrandUpdate')->option([
'_alias' => '编辑',
]);
Route::delete('delete/:id', '/delete')->name('systemStoreBrandDelete')->option([
'_alias' => '删除',
]);
})->prefix('admin.store.StoreBrand')->option([
'_path' => '/product/band/brandList',
'_auth' => true,
]);
//商品标签
Route::group('product/label', function () {
Route::get('lst', '/lst')->name('merchantStoreProductLabelLst')->option([

View File

@ -0,0 +1,437 @@
{extend name="common/base"/}
<!-- 主体 -->
{block name="body"}
<style>
.layui-input-inline{
width:35% !important;
}
.layui-input-inline .layui-form-item{
display:flex;
}
.layui-input-inline .layui-form-item .layui-form-label{
width:30%;
}
.layui-input-block{
margin-left:unset !important;
width:75%;
}
#seleform{
border-color: #eee;
background-color: #fff;
color:#a39f9f;
width:100%;
}
</style>
<div class="p-3">
<div class="layui-form">
<form id="filterform" class="layui-form gg-form-bar border-t border-x" >
<div class="layui-form-item">
<div class="layui-input-inline">
<div class="layui-form-item">
<label class="layui-form-label">平台商品分类</label>
<div class="layui-input-block">
<select id="plate_cate" name="plate_cate" lay-filter="seleform">
<option value="">请选择商品分类</option>
{volist name="$cate_list" id="v"}
<option value="{$v.id}" >{$v.title}{$v.cate_name} </option>
{/volist}
</select>
</div>
</div>
</div>
<div class="layui-input-inline">
<div class="layui-form-item">
<label class="layui-form-label">商户商品分类</label>
<div class="layui-input-block">
<input id="store_cate" type="hidden" readonly="readonly" name="store_cate">
<button id="seleform" lay-filter="seleform" class="layui-btn">请选择</button>
</div>
</div>
</div>
</div>
<div class="layui-form-item">
<div class="layui-input-inline">
<div class="layui-form-item">
<label class="layui-form-label">是否为礼包</label>
<div class="layui-input-block">
<select name="is_gift" lay-filter="seleform">
<option value=""></option>
<option value="0"></option>
<option value="1"></option>
</select>
</div>
</div>
</div>
<div class="layui-input-inline">
<div class="layui-form-item">
<label class="layui-form-label">商品状态</label>
<div class="layui-input-block">
<select name="state" lay-filter="seleform">
<option value=""></option>
<option value="1">上架</option>
<option value="0">下架</option>
<option value="2">平台关闭</option>
</select>
</div>
</div>
</div>
</div>
<div class="layui-form-item">
<div class="layui-input-inline">
<div class="layui-form-item">
<label class="layui-form-label">标签</label>
<div class="layui-input-block">
<select name="tag" lay-filter="seleform" data-type="reload">
<option value=""></option>
<option value="0">写作</option>
<option value="1">阅读</option>
<option value="2">游戏</option>
<option value="3">音乐</option>
<option value="4">旅行</option>
</select>
</div>
</div>
</div>
<div class="layui-input-inline">
<div class="layui-form-item">
<label class="layui-form-label">运费模板</label>
<div class="layui-input-block">
<select name="shipping_tem" lay-filter="seleform">
<option value=""></option>
<option value="0">写作</option>
<option value="1">阅读</option>
<option value="2">游戏</option>
<option value="3">音乐</option>
<option value="4">旅行</option>
</select>
</div>
</div>
</div>
</div>
<div class="layui-form-item">
<div class="layui-input-inline" style="display:flex;">
<label class="layui-form-label">关键字搜索</label>
<div class="layui-input-block" style="display:flex">
<div class="layui-input-inline" style="width: 78% !important">
<input type="text" name="keywords" placeholder="请输入商品名称、关键字" class="layui-input" autocomplete="off" />
</div>
<button class="layui-btn layui-btn-normal" lay-submit="" lay-filter="searchform">搜索</button>
</div>
</div>
</div>
</form>
</div>
<table class="layui-hide" id="article" lay-filter="article"></table>
</div>
<script type="text/html" id="status">
<i class="layui-icon {{# if(d.status == 1){ }}layui-icon-ok{{# } else { }}layui-icon-close{{# } }}"></i>
</script>
<script type="text/html" id="is_home">
<i class="layui-icon {{# if(d.is_home == 1){ }}layui-icon-ok{{# } else { }}layui-icon-close{{# } }}"></i>
</script>
<script type="text/html" id="thumb">
</script>
<!-- <script type="text/html" id="toolbarDemo">
<div class="layui-btn-container">
{if {:auth_cache(session('gougu_admin')['id'],$url[1])}==true}
<span class="layui-btn layui-btn-sm" lay-event="add" data-title="添加虚拟评论">+ 添加虚拟评论</span>
{/if}
</div>
</script> -->
<script type="text/html" id="barDemo">
<div class="layui-btn-group">
{if {:auth_cache(session('gougu_admin')['id'],$url[2])}==true}
<a class="layui-btn layui-btn-normal layui-btn-xs" lay-event="read">查看</a>
{/if}
{if {:auth_cache(session('gougu_admin')['id'],$url[2])}==true}
<a class="layui-btn layui-btn-xs" lay-event="edit">编辑</a>
{/if}
{if {:auth_cache(session('gougu_admin')['id'],$url[3])}==true}
<a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="del">删除</a>
{/if}
</div>
</script>
{/block}
<!-- /主体 -->
<!-- 脚本 -->
{block name="script"}
<script>
const moduleInit = ['tool'];
function gouguInit() {
var table = layui.table,tool = layui.tool, form = layui.form;
layui.pageTable = table.render({
elem: '#article',
title: '列表',
toolbar: '#toolbarDemo',
url: '{$url[0]}',
page: true,
limit: 20,
cols: [
[
{
fixed: 'left',
field: 'product_id',
title: '编号',
align: 'center',
width:80,
},{
field: 'image',
title: '商品图',
align: 'center',
width:120,
templet: function (d)
{
var html = `<div data-v-d854fb86="" class="el-image" style="width: 36px; height: 36px;">
<img style="width:100%;" src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAQQAAACUCAYAAAB1GVf9AAAAAXNSR0IArs4c6QAAAERlWElmTU0AKgAAAAgAAYdpAAQAAAABAAAAGgAAAAAAA6ABAAMAAAABAAEAAKACAAQAAAABAAABBKADAAQAAAABAAAAlAAAAAD7OG/zAAAH8ElEQVR4Ae3dWXPUOBQGUGcYoKCAByi2///f2LewE5bAzVSXIBPfdu8y9/gFpdVedKT+4pbtcHRycnI6WAgQIPBL4B8KBAgQWAgIhIWEfwkQcIZgDBAg0AScITQLJQLlBQRC+SEAgEATEAjNQolAeQGBUH4IACDQBARCs1AiUF5AIJQfAgAINAGB0CyUCJQXEAjlhwAAAk1AIDQLJQLlBQRC+SEAgEATEAjNQolAeQGBUH4IACDQBARCs1AiUF5AIJQfAgAINAGB0CyUCJQXEAjlhwAAAk1AIDQLJQLlBQRC+SEAgEATEAjNQolAeQGBUH4IACDQBARCs1AiUF5AIJQfAgAINAGB0CyUCJQXEAjlhwAAAk1AIDQLJQLlBQRC+SEAgEATEAjNQolAeQGBUH4IACDQBARCs1AiUF5AIJQfAgAINAGB0CyUCJQXEAjlhwAAAk1AIDQLJQLlBQRC+SEAgEATEAjNQolAeQGBUH4IACDQBARCs1AiUF5AIJQfAgAINAGB0CyUCJQXEAjlhwAAAk1AIDQLJQLlBQRC+SEAgEATEAjNQolAeQGBUH4IACDQBARCs1AiUF5AIJQfAgAINAGB0CyUCJQXEAjlhwAAAk1AIDQLJQLlBQRC+SEAgEATEAjNQolAeQGBUH4IACDQBP5tRaW5CLx//374+PHjcHJyMnz//n24dOnScOXKleH69evDjRs35tIMx9mhwNGvQXXa4XE5pAsEvn79Orx8+XL48uXLBbX/vXT16tXhzp07w+XLl0ffo4LAmIBAGJPp7PUIgadPnw6np8vz++joaLh///4Q4WAhsIqAOYRVtA703giB58+fTwqDOMRV379Jsz5//jwcHx9vsgnrdiQgEDrqjLFDefv27dlcwVj9Ra/H3EKst8vl27dvZ0H15s2bs/mMXe7LtvcjIBD247zRXj59+rTW+uuuN2VncRby4sWL4cePH2dvj7kNy/wFBMIM+jCuJqyzrLvelH29evXqj8nN2FecKVjmLSAQ5t1/Bzn6d+/eDXHp8/wScwm7DKHz+/Pz9gUEwvZNt77FuMdgnWXd9bJ9xdWOODsYW3x1GJOZx+sCYQb9dO3atbWOct31xnYWE5VxtSNb4gzh9evX2VvUdSwgEDrunMWh3bp16+xuxMXPU/6NuxdjvalLXD5ctjx79mzS1Y64uuGrwzLNPusFQp/98sdRxY1Gd+/eHeLfKcuq74/T/Ljp6cOHD6Obj/es8iGPKxBTbqIa3aGKgwgIhIOwr77TuOvw4cOHS+8+nPq+xRHElYHFBGF8iOMZifNL1C/ec75u7Oe4zdpVhzGdfl9363K/fTN6ZPHh3MbDTbGdiyYB7927NyzmH2IS8cmTJ6PHsqziwYMHS0Ns2TbU709AIOzPuqs9RaBkE4TxLEQ8IPX48eNJ8wZjjYttxJnN1K87Y9vx+n4EBMJ+nLvay5QHpeIDHB/mVeYNxhp58+bN4fbt22PVXu9IwBxCR52xj0OJD3hcLVg24Rf12wiDaFPcyBQhZOlfQCD030dbO8J4GCnCYPH8wdY2PGFDrjpMQOrgLQKhg07YxyFECEy9j2AXxxNhlN3huIt92ubqAgJhdbPZrRGn/3GfQVwKPOQSVzWm3AB1yGOsvm+BUGAExNWEbc0HbMoVlzmXzV9sug/rry8gENa3m8Wa8QHc5d9FWBUhvjp41mFVtf29XyDsz3pre4r5gHjQaNkSH7xV7zBcts1t1MdVh55Cahtt+lu2IRBm1pPxQXr06NHZ3YPZnEB86Hb9J9Q2oYszl0Nc7djkmCusKxBm0svxvTtm6RdXCuLUO24pvuj6fjyk1PuMfpzh+OrQ3+ATCP31yf+OKCYE48Mfv/V/X+I3bFw9+P2BpJjFj2v+c1h6/DozB7ddHqP/uWmXulvYdoRA9ts+zhziKkL85yzxF5LiDMJCYF0BgbCu3I7Xi1PqVa4QxHvj+QOX9HbcMX/55gVChx0cXwHWmXQTBh125swOSSB01mERBL5bd9YphQ7HpGJnnS0MOuuQYocjEIp1uOYSyAQEQqajjkAxAYFQrMM1l0AmIBAyHXUEigkIhGIdrrkEMgGBkOmoI1BMwF9dLtbhmksgE3CGkOmoI1BMQCAU63DNJZAJCIRMRx2BYgICoViHay6BTEAgZDrqCBQTEAjFOlxzCWQCAiHTUUegmIBAKNbhmksgExAImY46AsUEBEKxDtdcApmAQMh01BEoJiAQinW45hLIBARCpqOOQDEBgVCswzWXQCYgEDIddQSKCQiEYh2uuQQyAYGQ6agjUExAIBTrcM0lkAkIhExHHYFiAgKhWIdrLoFMQCBkOuoIFBMQCMU6XHMJZAICIdNRR6CYgEAo1uGaSyATEAiZjjoCxQQEQrEO11wCmYBAyHTUESgmIBCKdbjmEsgEBEKmo45AMQGBUKzDNZdAJiAQMh11BIoJCIRiHa65BDIBgZDpqCNQTEAgFOtwzSWQCQiETEcdgWICAqFYh2sugUxAIGQ66ggUExAIxTpccwlkAgIh01FHoJiAQCjW4ZpLIBMQCJmOOgLFBARCsQ7XXAKZgEDIdNQRKCYgEIp1uOYSyAQEQqajjkAxAYFQrMM1l0AmIBAyHXUEigkIhGIdrrkEMgGBkOmoI1BMQCAU63DNJZAJCIRMRx2BYgICoViHay6BTEAgZDrqCBQTEAjFOlxzCWQCPwEYef7DpS5s4AAAAABJRU5ErkJggg==">
</div>`;
if(d.image)
{
html = `<div data-v-d854fb86="" class="el-image" style="width: 36px; height: 36px;">
<img style="width:100%;" src="` + d.image + `" />
</div>`;
}
return html;
},
},{
field: 'store_name',
title: '商品名称',
align: 'center',
width:120
},{
field: 'product_score',
title: '商户类别',
align: 'center',
width:150,
templet: function (d)
{
return d.storeCategory ? d.storeCategory.cate_name : '待定';
}
},{
field: 'price',
title: '商品售价',
align: 'center',
width:150,
},{
field: 'sales',
title: '销量',
align: 'center',
width:150,
},{
field: 'stock',
title: '库存',
align: 'center',
width:150,
},{
field: 'is_good',
title: '推荐级别',
align: 'center',
width:120,
},{
field: 'sort',
title: '排序',
align: 'center',
width:120,
},{
field: 'is_used',
title: '是否显示',
align: 'center',
width:150,
templet: function (d)
{
var html = d.is_used ? '显示' : '隐藏';
return html;
},
},{
field: 'is_show',
title: '商品状态',
align: 'center',
width:150,
templet: function (d)
{
var html = d.is_show ? '上架显示' : '平台关闭';
return html;
},
},{
field: 'keyword',
title: '标签',
align: 'center',
width:150,
},{
fixed: 'right',
field: 'right',
title: '操作',
toolbar: '#barDemo',
align: 'center',
width:180,
}
]
]
});
//监听表头工具栏事件
table.on('toolbar(article)', function(obj){
if (obj.event === 'add') {
tool.side('{$url[1]}');
return false;
}
});
//监听表格行工具事件
table.on('tool(article)', function(obj) {
var data = obj.data;
if (obj.event === 'read') {
tool.side('{$url[2]}?id='+obj.data.reply_id);
}
else if (obj.event === 'edit') {
tool.side('{$url[2]}?id='+obj.data.reply_id);
}
else if (obj.event === 'del') {
layer.confirm('确定要删除该记录吗?', {
icon: 3,
title: '提示'
}, function(index) {
let callback = function (e) {
layer.msg(e.msg);
if (e.code == 0) {
obj.del();
}
}
tool.delete('{$url[3]}', { id: data.reply_id }, callback);
layer.close(index);
});
}
return false;
});
layui.use(['rate','dropdown', 'util', 'layer', 'table'], function(){
var dropdown = layui.dropdown
,util = layui.util
,layer = layui.layer
,rate = layui.rate
// ,table = layui.table
,$ = layui.jquery;
var $ = layui.$, active = {
reload: function(){
let dataRload = getformdata();;
console.log(dataRload)
//执行重载
table.reload('article', {
page: {
curr: 1 //重新从第 1 页开始
}
,where: {
...dataRload
}
});
}
};
//商户商品分类菜单
$.ajax({
url: '/admin/store/category/select',
method: "get",
data: {},
success: function(res) {
if (res.code!==0)return ;
//高级演示 - 各种组合
dropdown.render({
elem: '#seleform'
,isAllowSpread: false //禁止菜单组展开收缩
,style: 'width: 200px' //定义宽度,默认自适应
,id: 'test777' //定义唯一索引
,title: 'title1'
,data: res.data
,click: function(item){
$('#seleform').text(item.title);
$('#seleform').css({color:'rgba(0,0,0,.85)'});
$('#store_cate').val(item.id);
active['reload'] ? active['reload'].call(this) : '';
}
});
},
fail:function(){}
});
//基础效果
rate.render({
elem: '#is_good'
})
//监听搜索提交
form.on('submit(searchform)', function(data) {
layui.pageTable.reload({
where: {
...data.field
},
page: {
curr: 1
}
});
return false;
});
//监听select提交
form.on('select(seleform)', function(data) {
active['reload'] ? active['reload'].call(this) : '';
return false;
});
});
// 获取表单所有参数
function getformdata() {
var form = $('#filterform').serializeArray();
var data = new Array();
for(let i=0;i<form.length; i++){
data[form[i].name] = form[i].value;
}
return data;
}
}
</script>
{/block}
<!-- /脚本 -->

View File

@ -15,11 +15,30 @@
margin-left:unset !important;
width:75%;
}
#seleform{
border-color: #eee;
background-color: #fff;
color:#a39f9f;
width:100%;
}
</style>
<div class="p-3">
<div class="layui-tab layui-tab-brief" lay-filter="docDemoTabBrief">
<ul class="layui-tab-title">
<li class="layui-this site-demo-active" type="1" data-type="reload">出售中的商品</li>
<li class="site-demo-active" type="2" data-type="reload">仓库中的商品</li>
<li class="site-demo-active" type="3" data-type="reload">已售罄的商品</li>
<li class="site-demo-active" type="4" data-type="reload">警戒库存</li>
<li class="site-demo-active" type="6" data-type="reload">待审核商品</li>
<li class="site-demo-active" type="7" data-type="reload">审核未通过商品</li>
<li class="site-demo-active" type="5" data-type="reload">回收站商品</li>
</ul>
</div>
<div class="layui-form">
<form id="filterform" class="layui-form gg-form-bar border-t border-x" >
<input id="protype" type="hidden" name="type" value="">
<div class="layui-form-item">
<div class="layui-input-inline">
@ -39,11 +58,8 @@
<div class="layui-form-item">
<label class="layui-form-label">商户商品分类</label>
<div class="layui-input-block">
<select name="store_cate" lay-filter="seleform">
<option value=""></option>
<option value="10">自营</option>
<option value="11">非自营</option>
</select>
<input id="store_cate" type="hidden" readonly="readonly" name="store_cate">
<button id="seleform" lay-filter="seleform" class="layui-btn">请选择</button>
</div>
</div>
</div>
@ -71,8 +87,8 @@
<div class="layui-input-block">
<select name="state" lay-filter="seleform">
<option value=""></option>
<option value="0">上架</option>
<option value="1">下架</option>
<option value="1">上架</option>
<option value="0">下架</option>
<option value="2">平台关闭</option>
</select>
</div>
@ -90,10 +106,6 @@
<select name="tag" lay-filter="seleform" data-type="reload">
<option value=""></option>
<option value="0">写作</option>
<option value="1">阅读</option>
<option value="2">游戏</option>
<option value="3">音乐</option>
<option value="4">旅行</option>
</select>
</div>
</div>
@ -108,8 +120,6 @@
<option value="0">写作</option>
<option value="1">阅读</option>
<option value="2">游戏</option>
<option value="3">音乐</option>
<option value="4">旅行</option>
</select>
</div>
</div>
@ -183,6 +193,7 @@
const moduleInit = ['tool'];
function gouguInit() {
var table = layui.table,tool = layui.tool, form = layui.form;
layui.pageTable = table.render({
elem: '#article',
title: '列表',
@ -221,16 +232,6 @@
title: '商品名称',
align: 'center',
width:120
},{
field: 'type_name',
title: '商户类型',
align: 'center',
width:150,
templet: function (d)
{
return d.merchant.merchantType ? d.merchant.merchantType.type_name : '待定';
}
},{
field: 'product_score',
title: '商户类别',
@ -238,7 +239,7 @@
width:150,
templet: function (d)
{
return d.merchant.category ? d.merchant.category.category_name : '待定';
return d.storeCategory ? d.storeCategory.cate_name : '待定';
}
},{
field: 'price',
@ -276,13 +277,13 @@
return html;
},
},{
field: 'is_used',
field: 'is_show',
title: '商品状态',
align: 'center',
width:150,
templet: function (d)
{
var html = d.is_used ? '上架显示' : '平台关闭';
var html = d.is_show ? '上架显示' : '平台关闭';
return html;
},
},{
@ -339,18 +340,17 @@
layui.use(['rate','table'], function(){
var rate = layui.rate;
layui.use(['rate','dropdown', 'util', 'layer', 'table'], function(){
var dropdown = layui.dropdown
,util = layui.util
,layer = layui.layer
,rate = layui.rate
// ,table = layui.table
,$ = layui.jquery;
//基础效果
rate.render({
elem: '#is_good'
})
var $ = layui.$, active = {
reload: function(){
let dataRload = getformdata();;
console.log(dataRload)
//执行重载
table.reload('article', {
page: {
@ -360,8 +360,45 @@
...dataRload
}
});
}
},
};
//商户商品分类菜单
$.ajax({
url: '/admin/store/category/select',
method: "get",
data: {},
success: function(res) {
if (res.code!==0)return ;
//高级演示 - 各种组合
dropdown.render({
elem: '#seleform'
,isAllowSpread: false //禁止菜单组展开收缩
,style: 'width: 200px' //定义宽度,默认自适应
,id: 'test777' //定义唯一索引
,title: 'title1'
,data: res.data
,click: function(item){
$('#seleform').text(item.title);
$('#seleform').css({color:'rgba(0,0,0,.85)'});
$('#store_cate').val(item.id);
active['reload'] ? active['reload'].call(this) : '';
}
});
},
fail:function(){}
});
//基础效果
rate.render({
elem: '#is_good'
})
//监听搜索提交
@ -380,16 +417,23 @@
//监听select提交
form.on('select(seleform)', function(data) {
active['reload'] ? active['reload'].call(this) : '';
return false;
});
// tab 状态列表切换
$('.site-demo-active').on('click', function(){
var othis = $(this), type = othis.data('type');
$('#protype').val(this.getAttribute('type'));
active[type] ? active[type].call(this, othis) : '';
});
});
// 获取表单所有参数
function getformdata() {
var form = $('#filterform').serializeArray();
var data = new Array();
for(let i=0;i<form.length; i++){
data[form[i].name] = form[i].value;

View File

@ -1,167 +0,0 @@
{extend name="common/base"/}
{block name="style"}
<style type="text/css">
.editormd-code-toolbar select {
display: inline-block
}
.editormd li {
list-style: inherit;
}
.layui-td-gray {
width: 110px;
}
.addrhelper-ok-btn {
display: none;
}
</style>
{/block}
<!-- 主体 -->
{block name="body"}
<form class="layui-form p-4">
<h3 class="pb-3">添加</h3>
<table class="layui-table layui-table-form">
<tr>
<td class="layui-td-gray">上级分类<font>*</font>
</td>
<td>
<select name="" lay-filter="storeBrandCategory" lay-search>
<option value="">选择分类</option>
{volist name='storeBrandCategory' id='vo'}
<option value="{$vo.store_brand_category_id}" >{$vo.cate_name}</option>
{/volist}
</select>
</td>
<td>
<div class="layui-col-md4">
<label class="layui-form-label">子分类</label>
<div class="layui-input-block">
<div id="demo1"></div>
</div>
</div>
</td>
</tr>
<tr>
<td class="layui-td-gray">品牌名称<font>*</font></td>
<td colspan="4">
<input type="text" name="brand_name" lay-verify="required" lay-reqText="请输入品牌名称"
autocomplete="off" placeholder="请输入品牌名称" class="layui-input">
</td>
</tr>
<tr>
<td>
<div class="layui-form-item">
<label class="layui-form-label">是否显示</label>
<div class="layui-input-block">
<input type="checkbox" name="is_show" lay-skin="switch">
</div>
</div>
</td>
<td class="layui-td-gray">排序</td>
<td>
<input type="text" name="sort" value="0" placeholder="请输入数字,越小越靠前" autocomplete="off"
class="layui-input">
</td>
</tr>
</table>
<div class="pt-3">
<button class="layui-btn layui-btn-normal" lay-submit="" lay-filter="webform">立即提交</button>
<button type="reset" class="layui-btn layui-btn-primary">重置</button>
</div>
</form>
{/block}
<!-- /主体 -->
<!-- 脚本 -->
{block name="script"}
<script src="/static/assets/js/jquery.min.js"></script>
<script src="/static/assets/js/addrHelper.js"></script>
<script src="/static/assets/js/xm-select.js"></script>
<script>
const editorType = '{$editor}';
var moduleInit = ['tool', 'tagpicker', 'tinymce'];
function gouguInit() {
var form = layui.form, tool = layui.tool, laydate = layui.laydate;
var editor = layui.tinymce;
var edit = editor.render({
selector: "#container_content",
height: 500
});
//上传缩略图
var upload_thumb = layui.upload.render({
elem: '#upload_btn_thumb',
url: '/admin/api/upload',
done: function (res) {
//如果上传失败
if (res.code == 1) {
return layer.msg('上传失败');
}
//上传成功
$('#upload_box_thumb input').attr('value', res.data.filepath);
$('#upload_box_thumb img').attr('src', res.data.filepath);
}
});
//监听提交
form.on('submit(webform)', function (data) {
let callback = function (e) {
layer.msg(e.msg);
if (e.code == 0) {
setTimeout(function () {
parent.location.reload();
}, 1000);
}
}
tool.post('/admin/product.band/add', data.field, callback);
return false;
});
form.on('select(storeBrandCategory)', function (data) {
street(data.value);
});
var group_access = "{:session('gougu_admin')['group_access']}";
function street (id) {
if(id == null || id == '')
{
return false;
}
var demo1 = xmSelect.render({
name: 'brand_category_id',
el: '#demo1',
prop: {
name: 'cate_name',
value: 'store_brand_category_id',
},
data: [],
radio: true,
initValue: [],
disabled: group_access == 2 || group_access==4 ? true : false,
});
$.get('/admin/product.brandClassify/street?pcode=' + id, function (result) {
demo1.update({
data: result
});
});
}
}
</script>
{/block}
<!-- /脚本 -->

View File

@ -1,165 +0,0 @@
{extend name="common/base"/}
{block name="style"}
<style type="text/css">
.editormd-code-toolbar select {
display: inline-block
}
.editormd li {
list-style: inherit;
}
.layui-td-gray{
width: 110px;
}
.addrhelper-ok-btn{
display: none;
}
</style>
{/block}
<!-- 主体 -->
{block name="body"}
<form class="layui-form p-4">
<input type="hidden" name="id" value="{$detail.brand_id}">
<h3 class="pb-3">编辑</h3>
<table class="layui-table layui-table-form">
<tr>
<td class="layui-td-gray">上级分类<font>*</font>
</td>
<td>
<select name="" lay-filter="storeBrandCategory" lay-search>
<option value="">选择分类</option>
{volist name='storeBrandCategory' id='vo'}
{if $detail.storeBrandCategory.pid == $vo.store_brand_category_id}
<option value="{$vo.store_brand_category_id}" selected >{$vo.cate_name}</option>
{else /}
<option value="{$vo.store_brand_category_id}" >{$vo.cate_name}</option>
{/if}
{/volist}
</select>
</td>
<td>
<div class="layui-col-md4">
<label class="layui-form-label">子分类</label>
<div class="layui-input-block">
<div id="demo1"></div>
</div>
</div>
</td>
</tr>
<tr>
<td class="layui-td-gray">品牌名称<font>*</font></td>
<td colspan="4">
<input type="text" name="brand_name" lay-verify="required" lay-reqText="请输入品牌名称"
autocomplete="off" value="{$detail.brand_name}" class="layui-input">
</td>
</tr>
<tr>
<td>
<div class="layui-form-item">
<label class="layui-form-label">是否显示</label>
<div class="layui-input-block">
<input type="checkbox" name="is_show" lay-skin="switch" {$detail.is_show?'checked':''}>
</div>
</div>
</td>
<td class="layui-td-gray">排序</td>
<td>
<input type="text" name="sort" value="{$detail.sort}" placeholder="请输入数字,越小越靠前" autocomplete="off"
class="layui-input">
</td>
</tr>
</table>
<div class="pt-3">
<button class="layui-btn layui-btn-normal" lay-submit="" lay-filter="webform">立即提交</button>
<button type="reset" class="layui-btn layui-btn-primary">重置</button>
</div>
</form>
{/block}
<!-- /主体 -->
<!-- 脚本 -->
{block name="script"}
<script src="/static/assets/js/jquery.min.js"></script>
<script src="/static/assets/js/addrHelper.js"></script>
<script src="/static/assets/js/xm-select.js"></script>
<script>
var moduleInit = ['tool','tinymce'];
function gouguInit() {
var form = layui.form, tool = layui.tool;
//上传缩略图
var upload_thumb = layui.upload.render({
elem: '#upload_btn_thumb',
url: '/admin/api/upload',
done: function (res) {
//如果上传失败
if (res.code == 1) {
return layer.msg('上传失败');
}
//上传成功
$('#upload_box_thumb input').attr('value', res.data.filepath);
$('#upload_box_thumb img').attr('src', res.data.filepath);
}
});
//监听提交
form.on('submit(webform)', function (data) {
let callback = function (e) {
console.log(e);
layer.msg(e.msg);
if (e.code == 0) {
tool.tabRefresh(71);
tool.sideClose(1000);
}
}
tool.post('{$url[2]}', data.field, callback);
return false;
});
form.on('select(storeBrandCategory)', function (data) {
street(data.value);
});
street("{$detail.storeBrandCategory.pid}");
var group_access = "{:session('gougu_admin')['group_access']}";
function street (id) {
if(id == null || id == '')
{
return false;
}
var demo1 = xmSelect.render({
name: 'brand_category_id',
el: '#demo1',
prop: {
name: 'cate_name',
value: 'store_brand_category_id',
},
data: [],
radio: true,
initValue: ['{$detail.storeBrandCategory.store_brand_category_id}'],
disabled: group_access == 2 || group_access==4 ? true : false,
});
$.get('/admin/product.brandClassify/street?pcode=' + id, function (result) {
demo1.update({
data: result
});
});
}
}
</script>
{/block}
<!-- /脚本 -->

View File

@ -1,152 +0,0 @@
{extend name="common/base"/}
<!-- 主体 -->
{block name="body"}
<div class="p-3">
<form class="layui-form gg-form-bar border-t border-x">
<div class="layui-input-inline" style="width:300px;">
<input type="text" name="keywords" placeholder="请输入供应链名称" class="layui-input" autocomplete="off" />
</div>
<button class="layui-btn layui-btn-normal" lay-submit="" lay-filter="searchform">搜索</button>
</form>
<table class="layui-hide" id="article" lay-filter="article"></table>
</div>
<script type="text/html" id="status">
<i class="layui-icon {{# if(d.status == 1){ }}layui-icon-ok{{# } else { }}layui-icon-close{{# } }}"></i>
</script>
<script type="text/html" id="is_home">
<i class="layui-icon {{# if(d.is_home == 1){ }}layui-icon-ok{{# } else { }}layui-icon-close{{# } }}"></i>
</script>
<script type="text/html" id="thumb">
</script>
<script type="text/html" id="toolbarDemo">
<div class="layui-btn-container">
{if {:auth_cache(session('gougu_admin')['id'],$url[1])}==true}
<span class="layui-btn layui-btn-sm" lay-event="add" data-title="添加品牌">+ 添加品牌</span>
{/if}
</div>
</script>
<script type="text/html" id="barDemo">
<div class="layui-btn-group">
<!-- {if {:auth_cache(session('gougu_admin')['id'],$url[2])}==true}
<a class="layui-btn layui-btn-normal layui-btn-xs" lay-event="read">查看</a>
{/if} -->
{if {:auth_cache(session('gougu_admin')['id'],$url[2])}==true}
<a class="layui-btn layui-btn-xs" lay-event="edit">编辑</a>
{/if}
{if {:auth_cache(session('gougu_admin')['id'],$url[3])}==true}
<a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="del">删除</a>
{/if}
</div>
</script>
{/block}
<!-- /主体 -->
<!-- 脚本 -->
{block name="script"}
<script>
const moduleInit = ['tool'];
function gouguInit() {
var table = layui.table,tool = layui.tool, form = layui.form;
layui.pageTable = table.render({
elem: '#article',
title: '列表',
toolbar: '#toolbarDemo',
url: '{$url[0]}',
page: true,
limit: 20,
cols: [
[
{
fixed: 'left',
field: 'brand_id',
title: '编号',
align: 'center',
width:80,
},{
field: 'brand_name',
title: '品牌名称',
align: 'center',
},{
field: 'sort',
title: '排序',
align: 'center',
},{
field: 'status',
title: '是否显示',
align: 'center',
templet: function (d)
{
return d.is_show ? '显示' : '隐藏';
},
},{
field: 'create_time',
title: '创建时间',
align: 'center',
},{
fixed: 'right',
field: 'right',
title: '操作',
toolbar: '#barDemo',
align: 'center'
}
]
]
});
//监听表头工具栏事件
table.on('toolbar(article)', function(obj){
if (obj.event === 'add') {
tool.side('{$url[1]}');
return false;
}
});
//监听表格行工具事件
table.on('tool(article)', function(obj) {
var data = obj.data;
if (obj.event === 'read') {
tool.side('{$url[2]}?id='+obj.data.brand_id);
}
else if (obj.event === 'edit') {
tool.side('{$url[2]}?id='+obj.data.brand_id);
}
else if (obj.event === 'del') {
layer.confirm('确定要删除该记录吗?', {
icon: 3,
title: '提示'
}, function(index) {
let callback = function (e) {
layer.msg(e.msg);
if (e.code == 0) {
obj.del();
}
}
tool.delete('{$url[3]}', { id: data.brand_id }, callback);
layer.close(index);
});
}
return false;
});
//监听搜索提交
form.on('submit(searchform)', function(data) {
layui.pageTable.reload({
where: {
keywords: data.field.keywords,
cate_id: data.field.cate_id
},
page: {
curr: 1
}
});
return false;
});
}
</script>
{/block}
<!-- /脚本 -->

View File

@ -17,21 +17,26 @@ class FormatList
* @param string $idName 主键
* @param string $fieldName 父级字段
* @param string $childrenKey 子级字段名
* @return array
* @param array $option 重命名字段 id name
* @return array
*
* @date 2023-03-3
*/
static function FormatCategory(array $data, string $idName = "id", string $fieldName = 'pid', $childrenKey = 'children')
static function FormatCategory(array $data, string $idName = "id", string $parentId = 'pid', string $fieldName='name', $childrenKey = 'children', ?string $addId='', ?string $addtitle='')
{
$items = [];
foreach ($data as $item) {
if (!empty($addId))
$item[$addId] = $item[$idName];
if (!empty($addtitle))
$item[$addtitle] = $item[$fieldName];
$items[$item[$idName]] = $item;
}
$result = array();
foreach ($items as $item) {
if (isset($items[$item[$fieldName]])) {
$items[$item[$fieldName]][$childrenKey][] = &$items[$item[$idName]];
} else if ($item[$fieldName] == 0) {
if (isset($items[$item[$parentId]])) {
$items[$item[$parentId]][$childrenKey][] = &$items[$item[$idName]];
} else if ($item[$parentId] == 0) {
$result[] = &$items[$item[$idName]];
}
}
@ -57,6 +62,7 @@ class FormatList
$level++;
foreach ($data as $k => $v) {
if ($v['pid'] == $pid) {
$v['title'] = '';
if ($pid != 0) {
$v['title'] = $space[$level] . $v['title'];
}

View File

@ -11,4 +11,5 @@ use think\Model;
class UserLabel extends Model
{
//
}

View File

@ -4,11 +4,145 @@ declare (strict_types = 1);
namespace app\common\model\merchant\user;
use think\Model;
use think\db\BaseQuery;
/**
* @mixin \think\Model
*/
class UserMerchant extends Model
{
//
/**
* @return string|null
* @author xaboy
* @day 2020/10/20
*/
public static function tablePk(): ?string
{
return 'user_merchant_id';
}
/**
* @return string
* @author xaboy
* @day 2020/10/20
*/
public static function tableName(): string
{
return 'user_merchant';
}
public function user()
{
return $this->hasOne(User::class, 'uid', 'uid');
}
/**
* @param $value
* @return array
* @author xaboy
* @day 2020-05-09
*/
public function getLabelIdAttr($value)
{
return $value ? explode(',', $value) : [];
}
/**
* @param $value
* @return string
* @author xaboy
* @day 2020-05-09
*/
public function setLabelIdAttr($value)
{
return implode(',', $value);
}
public function getAuthLabelAttr()
{
return app()->make(UserLabel::class)->whereIn('label_id', $this->label_id)->where('mer_id', $this->mer_id)->where('type', 1)->column('label_id');
}
/**
* @param $uid
* @param $mer_id
* @return bool
* @author xaboy
* @day 2020/10/20
*/
public function isMerUser($uid, $mer_id)
{
return $this->existsWhere(compact('uid', 'mer_id'));
}
/**
* @param $uid
* @param $mer_id
* @return int
* @throws \think\db\exception\DbException
* @author xaboy
* @day 2020/10/20
*/
public function updateLastTime($uid, $mer_id)
{
return UserMerchant::where(compact('uid', 'mer_id'))->update([
'last_time' => date('Y-m-d H:i:s')
]);
}
/**
* @param array $where
* @return mixed
* @author xaboy
* @day 2020/10/20
*/
public function search(array $where)
{
return UserMerchant::alias('A')->leftJoin('User B', 'A.uid = B.uid')
->when(isset($where['mer_id']) && $where['mer_id'] !== '',
function ($query) use ($where) {
$query->where('A.mer_id', $where['mer_id']);
}
)
->when(isset($where['nickname']) && $where['nickname'], function (BaseQuery $query) use ($where) {
return $query->where('B.nickname', 'like', '%' . $where['nickname'] . '%');
})->when(isset($where['sex']) && $where['sex'] !== '', function (BaseQuery $query) use ($where) {
return $query->where('B.sex', intval($where['sex']));
})->when(isset($where['is_promoter']) && $where['is_promoter'] !== '', function (BaseQuery $query) use ($where) {
return $query->where('B.is_promoter', $where['is_promoter']);
})->when(isset($where['uids']), function (BaseQuery $query) use ($where) {
return $query->whereIn('A.uid', $where['uids']);
})->when(isset($where['user_time_type']) && $where['user_time_type'] !== '' && $where['user_time'] != '', function ($query) use ($where) {
if ($where['user_time_type'] == 'visit') {
getModelTime($query, $where['user_time'], 'A.last_time');
}
if ($where['user_time_type'] == 'add_time') {
getModelTime($query, $where['user_time'], 'A.create_time');
}
})->when(isset($where['pay_count']) && $where['pay_count'] !== '', function ($query) use ($where) {
if ($where['pay_count'] == -1) {
$query->where('A.pay_num', 0);
} else {
$query->where('A.pay_num', '>', $where['pay_count']);
}
})->when(isset($where['label_id']) && $where['label_id'] !== '', function (BaseQuery $query) use ($where) {
return $query->whereRaw('CONCAT(\',\',A.label_id,\',\') LIKE \'%,' . $where['label_id'] . ',%\'');
})->when(isset($where['user_type']) && $where['user_type'] !== '', function (BaseQuery $query) use ($where) {
return $query->where('B.user_type', $where['user_type']);
})->where('A.status', 1);
}
public function numUserIds($mer_id, $min, $max = null)
{
return UserMerchant::where('mer_id', $mer_id)->where('pay_num', '>=', $min)->when(!is_null($max), function ($query) use ($max) {
$query->where('pay_num', '<=', $max);
})->group('uid')->column('uid');
}
public function priceUserIds($mer_id, $min, $max = null)
{
return UserMerchant::where('mer_id', $mer_id)->where('pay_price', '>=', $min)->when(!is_null($max), function ($query) use ($max, $min) {
$query->where('pay_price', $min == $max ? '<=' : '<', $max);
})->group('uid')->column('uid');
}
}