diff --git a/app/common/dao/system/merchant/MerchantDao.php b/app/common/dao/system/merchant/MerchantDao.php index e6eaa89b..a6bdd26b 100644 --- a/app/common/dao/system/merchant/MerchantDao.php +++ b/app/common/dao/system/merchant/MerchantDao.php @@ -125,7 +125,6 @@ class MerchantDao extends BaseDao } }, function ($query) use ($order) { $query->order('is_best DESC, sort DESC,sales DESC'); - // $query->order('mer_id DESC'); }); return $query; } diff --git a/app/common/model/system/GeoStreet.php b/app/common/model/system/GeoStreet.php new file mode 100644 index 00000000..465e1308 --- /dev/null +++ b/app/common/model/system/GeoStreet.php @@ -0,0 +1,32 @@ + +// +---------------------------------------------------------------------- + + +namespace app\common\model\system; + + +use app\common\model\BaseModel; + +class GeoStreet extends BaseModel +{ + + + public static function tablePk(): string + { + return 'street_id'; + } + + public static function tableName(): string + { + return 'geo_street'; + } +} diff --git a/app/common/model/system/merchant/Merchant.php b/app/common/model/system/merchant/Merchant.php index 54be126d..b10dd7da 100644 --- a/app/common/model/system/merchant/Merchant.php +++ b/app/common/model/system/merchant/Merchant.php @@ -22,8 +22,10 @@ use app\common\model\store\product\Product; use app\common\model\store\product\Spu; use app\common\model\system\config\SystemConfigValue; use app\common\model\system\financial\Financial; +use app\common\model\system\GeoStreet; use app\common\model\system\serve\ServeOrder; use app\common\repositories\store\StoreActivityRepository; +use think\facade\Db; class Merchant extends BaseModel { @@ -250,7 +252,10 @@ class Merchant extends BaseModel { return $this->merchantType()->bind(['type_name']); } - + public function streetNames() + { + return $this->hasOne(GeoStreet::class, 'street_code', 'street_id')->bind(['street_name']); + } public function getMerCommissionRateAttr() { return $this->commission_rate > 0 ? $this->commission_rate : bcmul($this->merchantCategory->commission_rate, 100, 4); diff --git a/app/common/repositories/store/product/SpuRepository.php b/app/common/repositories/store/product/SpuRepository.php index 4555e2c0..34acca66 100644 --- a/app/common/repositories/store/product/SpuRepository.php +++ b/app/common/repositories/store/product/SpuRepository.php @@ -34,7 +34,7 @@ use think\facade\Queue; class SpuRepository extends BaseRepository { public $dao; - public $merchantFiled = 'mer_id,mer_name,mer_avatar,is_trader,mer_info,mer_keyword,type_id,long,lat'; + public $merchantFiled = 'mer_id,mer_name,mer_avatar,is_trader,mer_info,mer_keyword,type_id,long,lat,street_id'; public $productFiled = 'P.bar_code,S.product_id,S.store_name,S.image,activity_id,S.keyword,S.price,S.mer_id,spu_id,S.status,store_info,brand_id,cate_id,unit_name,S.star,S.rank,S.sort,sales,S.product_type,rate,reply_count,extension_type,S.sys_labels,S.mer_labels,P.delivery_way,P.delivery_free,P.ot_price,svip_price_type,stock,mer_svip_status'; public $userInfo; @@ -147,7 +147,7 @@ class SpuRepository extends BaseRepository $query->with([ 'merchant' => function ($query) { - $query->field($this->merchantFiled)->with(['type_names']); + $query->field($this->merchantFiled)->with(['type_names','street_names']); }, 'issetCoupon', 'product.attrValue', diff --git a/app/common/repositories/system/merchant/MerchantRepository.php b/app/common/repositories/system/merchant/MerchantRepository.php index 38233e4e..3090cbb6 100644 --- a/app/common/repositories/system/merchant/MerchantRepository.php +++ b/app/common/repositories/system/merchant/MerchantRepository.php @@ -293,7 +293,7 @@ class MerchantRepository extends BaseRepository */ public function getList($where, $page, $limit, $userInfo) { - $field = 'mer_id,mini_banner,mer_name,mer_avatar,product_score,service_score,postage_score,sales,status,create_time,long,lat,mer_address,care_count,type_id'; + $field = 'mer_id,mini_banner,mer_name,mer_avatar,product_score,service_score,postage_score,sales,status,create_time,long,lat,mer_address,care_count,type_id,street_id'; $where['status'] = 1; $where['mer_state'] = 1; $where['is_del'] = 0; @@ -316,7 +316,7 @@ class MerchantRepository extends BaseRepository $status = systemConfig('mer_location'); /** @var MerchantTakeRepository $repository */ $repository = app()->make(MerchantTakeRepository::class); - $list = $query->page($page, $limit)->setOption('field', [])->field($field)->select() + $list = $query->with('street_names')->page($page, $limit)->setOption('field', [])->field($field)->select() ->each(function ($item) use ($status, $where, $repository) { if ($status && $item['lat'] && $item['long'] && isset($where['location']['lat'], $where['location']['long'])) { $distance = getDistance($where['location']['lat'], $where['location']['long'], $item['lat'], $item['long']); diff --git a/app/controller/api/store/product/StoreSpu.php b/app/controller/api/store/product/StoreSpu.php index e5e4a775..a1264fcd 100644 --- a/app/controller/api/store/product/StoreSpu.php +++ b/app/controller/api/store/product/StoreSpu.php @@ -179,7 +179,7 @@ class StoreSpu extends BaseController [$page, $limit] = $this->getPage(); $where = $this->request->params(['common','mer_id']); $params = $this->request->params(['location']); - $typeIdArray = Db::name('MerchantType')->whereNotIn('type_code', Merchant::TypeCode['TypeCloudWarehouse'] . ',' .Merchant::TypeCode['TypeSupplyChain'])->column('mer_type_id'); + // $typeIdArray = Db::name('MerchantType')->whereNotIn('type_code', Merchant::TypeCode['TypeCloudWarehouse'] . ',' .Merchant::TypeCode['TypeSupplyChain'])->column('mer_type_id'); $where['is_gift_bag'] = 0; //1:星级 //2:用户收藏