wang hou sheng 7 months ago
parent 758083780c
commit 9b5455ce41
  1. 6
      app/common/model/Channel.php
  2. 7
      app/common/model/GoodsSpecRel.php
  3. 19
      app/common/model/Region.php
  4. 12
      cores/BaseModel.php

@ -13,8 +13,6 @@ declare (strict_types=1);
namespace app\common\model;
use cores\BaseModel;
use think\model\relation\BelongsTo;
use think\model\relation\HasOne;
/**
* 文章模型
@ -31,7 +29,7 @@ class Channel extends BaseModel
public static function init()
{
self::$storeId = 0;
app()->request->setStoreId(0);
// self::$storeId = 0;
// app()->request->setStoreId(0);
}
}

@ -14,8 +14,7 @@ namespace app\common\model;
use cores\BaseModel;
use think\model\relation\BelongsTo;
use app\common\model\Spec;
use app\common\model\SpecValue;
/**
* 商品规格关系模型
* Class GoodsSpecRel
@ -115,8 +114,8 @@ class GoodsSpecRel extends BaseModel
// echo "<pre>";
// print_r($list->toArray());
//exit();
self::$storeId = 0;
app()->request->setStoreId(0);
// self::$storeId = 0;
// app()->request->setStoreId(0);
return static::preload($list, ['spec', 'specValue']);
}

@ -12,9 +12,9 @@ declare (strict_types=1);
namespace app\common\model;
use app\common\library\helper;
use cores\BaseModel;
use think\facade\Cache;
use app\common\library\helper;
/**
* 地区模型
@ -44,11 +44,13 @@ class Region extends BaseModel
// 当前数据版本号
private static string $version = '1.0.3';
public static function init()
{
self::$storeId = 0;
app()->request->setStoreId(0);
// self::$storeId = 0;
// app()->request->setStoreId(0);
}
/**
* 根据ID获取地区名称
* @param int $id
@ -143,7 +145,9 @@ class Region extends BaseModel
}
return $cacheData[$item];
}
public function getNewTreeList(){
public function getNewTreeList()
{
$treeList = Cache::get('region2');
if ($treeList) {
return $treeList;
@ -152,7 +156,7 @@ class Region extends BaseModel
->field('id, pid, name, level')
->select()
->toArray();
$treeList = [];
$i = 0;
foreach ($allList as $pKey => $province) {
@ -161,7 +165,7 @@ class Region extends BaseModel
unset($allList[$pKey]);
$j = 0;
foreach ($allList as $cKey => $city) {
if ($city['level'] == 2 && $city['pid'] == $province['id']) { // 城市
$treeList[$i]['children'][$j] = $city;
unset($allList[$cKey]);
@ -181,8 +185,9 @@ class Region extends BaseModel
}
Cache::tag('cache')->set('region2', $treeList);
return $treeList;
}
/**
* 获取地区缓存
* @return array

@ -12,15 +12,15 @@ declare (strict_types=1);
namespace cores;
use think\Model;
use app\common\library\helper;
use cores\exception\BaseException;
use cores\extension\ModelExt;
use cores\traits\ErrorTrait;
use think\db\Query;
use think\Paginator;
use think\helper\Str;
use think\Model;
use think\model\Collection;
use app\common\library\helper;
use cores\traits\ErrorTrait;
use cores\extension\ModelExt;
use cores\exception\BaseException;
use think\Paginator;
/**
* 模型基类

Loading…
Cancel
Save