This commit is contained in:
mkm 2023-11-10 10:09:46 +08:00
parent b351b78253
commit 878cf9c0d7
6 changed files with 43 additions and 7 deletions

View File

@ -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;
}

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\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';
}
}

View File

@ -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);

View File

@ -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',

View File

@ -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']);

View File

@ -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:用户收藏