Merge branch 'dev' of https://gitea.lihaink.cn/mkm/shop-php into dev
This commit is contained in:
commit
f31d3548db
@ -17,6 +17,7 @@ use app\common\model\store\StoreCategory;
|
|||||||
use app\common\repositories\store\StoreCategoryRepository;
|
use app\common\repositories\store\StoreCategoryRepository;
|
||||||
use app\common\repositories\system\merchant\MerchantRepository;
|
use app\common\repositories\system\merchant\MerchantRepository;
|
||||||
use crmeb\services\VicWordService;
|
use crmeb\services\VicWordService;
|
||||||
|
use think\facade\Db;
|
||||||
|
|
||||||
class SpuDao extends BaseDao
|
class SpuDao extends BaseDao
|
||||||
{
|
{
|
||||||
@ -188,9 +189,22 @@ class SpuDao extends BaseDao
|
|||||||
})
|
})
|
||||||
->when(isset($where['svip']) && $where['svip'] !== '',function($query)use($where){
|
->when(isset($where['svip']) && $where['svip'] !== '',function($query)use($where){
|
||||||
$query->where('svip_price_type','>',0)->where('mer_svip_status',1);
|
$query->where('svip_price_type','>',0)->where('mer_svip_status',1);
|
||||||
|
})->when($order, function ($query) use ($where, $order) {
|
||||||
|
if(isset($where['long'])&&$where['long']!='' &&isset($where['lat'])&&$where['lat']!=''){
|
||||||
|
$lng=$where['long'];
|
||||||
|
$lat=$where['lat'];
|
||||||
|
$query->whereNotNull('lat')->whereNotNull('long')
|
||||||
|
->order(Db::raw("(2 * 6378.137 * ASIN(
|
||||||
|
SQRT(
|
||||||
|
POW( SIN( PI( ) * ( $lng- `long` ) / 360 ), 2 ) + COS( PI( ) * $lat / 180 ) * COS( `lat` * PI( ) / 180 ) * POW( SIN( PI( ) * ( $lat- `lat` ) / 360 ), 2 )
|
||||||
|
)
|
||||||
|
)
|
||||||
|
) ASC "));
|
||||||
|
}else{
|
||||||
|
$query->orderRaw($order);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
return $query;
|
||||||
return $query->orderRaw($order);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public function findOrCreateAll(array $where)
|
public function findOrCreateAll(array $where)
|
||||||
|
@ -97,7 +97,14 @@ class SpuRepository extends BaseRepository
|
|||||||
'sort' => $param['sort'] ?? 0,
|
'sort' => $param['sort'] ?? 0,
|
||||||
'mer_labels' => $param['mer_labels'] ?? '',
|
'mer_labels' => $param['mer_labels'] ?? '',
|
||||||
];
|
];
|
||||||
if (isset($param['mer_id'])) $data['mer_id'] = $param['mer_id'];
|
if (isset($param['mer_id'])){
|
||||||
|
$data['mer_id'] = $param['mer_id'];
|
||||||
|
$find=Db::name('merchant')->where('mer_id',$param['mer_id'])->find();
|
||||||
|
if($find){
|
||||||
|
$data['long']=$find['long'];
|
||||||
|
$data['lat']=$find['lat'];
|
||||||
|
}
|
||||||
|
}
|
||||||
return $data;
|
return $data;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -161,7 +168,7 @@ class SpuRepository extends BaseRepository
|
|||||||
|
|
||||||
if ($limit == 0) {
|
if ($limit == 0) {
|
||||||
$list = $query->setOption('field', [])->field($this->productFiled)->select()
|
$list = $query->setOption('field', [])->field($this->productFiled)->select()
|
||||||
->each(function ($item) use ($is_sku, $productMake, $userInfo) {
|
->each(function ($item) use ($is_sku, $productMake, $userInfo,$where) {
|
||||||
if ($is_sku == true) {
|
if ($is_sku == true) {
|
||||||
$sku = $productMake->detailAttrValue($item['product']['attrValue'], $userInfo);
|
$sku = $productMake->detailAttrValue($item['product']['attrValue'], $userInfo);
|
||||||
$item['sku'] = $sku;
|
$item['sku'] = $sku;
|
||||||
@ -172,10 +179,22 @@ class SpuRepository extends BaseRepository
|
|||||||
$item['merchant']['village_name']=$village_name.'集体经营合作店铺';
|
$item['merchant']['village_name']=$village_name.'集体经营合作店铺';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (isset($item['merchant']['lat'] , $item['merchant']['long']) && isset($where['lat'], $where['long'])) {
|
||||||
|
$distance = getDistance($where['lat'], $where['long'], $item['merchant']['lat'], $item['merchant']['long']);
|
||||||
|
if ($distance < 0.9) {
|
||||||
|
$distance = max(bcmul($distance, 1000, 0), 1).'m';
|
||||||
|
if ($distance == '1m') {
|
||||||
|
$distance = '100m以内';
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
$distance .= 'km';
|
||||||
|
}
|
||||||
|
$item['distance'] = $distance;
|
||||||
|
}
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
$list = $query->page($page, $limit)->setOption('field', [])->field($this->productFiled)->select()
|
$list = $query->page($page, $limit)->setOption('field', [])->field($this->productFiled)->select()
|
||||||
->each(function ($item) use ($is_sku, $productMake, $userInfo) {
|
->each(function ($item) use ($is_sku, $productMake, $userInfo,$where) {
|
||||||
if ($is_sku == true) {
|
if ($is_sku == true) {
|
||||||
$sku = $productMake->detailAttrValue($item['product']['attrValue'], $userInfo);
|
$sku = $productMake->detailAttrValue($item['product']['attrValue'], $userInfo);
|
||||||
$item['sku'] = $sku;
|
$item['sku'] = $sku;
|
||||||
@ -186,6 +205,18 @@ class SpuRepository extends BaseRepository
|
|||||||
$item['merchant']['village_name']=$village_name.'集体经营合作店铺';
|
$item['merchant']['village_name']=$village_name.'集体经营合作店铺';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (isset($item['merchant']['lat'] , $item['merchant']['long']) && isset($where['lat'], $where['long'])) {
|
||||||
|
$distance = getDistance($where['lat'], $where['long'], $item['merchant']['lat'], $item['merchant']['long']);
|
||||||
|
if ($distance < 0.9) {
|
||||||
|
$distance = max(bcmul($distance, 1000, 0), 1).'m';
|
||||||
|
if ($distance == '1m') {
|
||||||
|
$distance = '100m以内';
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
$distance .= 'km';
|
||||||
|
}
|
||||||
|
$item['distance'] = $distance;
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -32,6 +32,10 @@ class Demo extends BaseController
|
|||||||
{
|
{
|
||||||
public function index()
|
public function index()
|
||||||
{
|
{
|
||||||
|
$merchant = Db::name('merchant')->where('mer_id','>=',39)->where('long','<>','')->where('status',1)->select();
|
||||||
|
foreach($merchant as $k=>$v){
|
||||||
|
Db::name('store_spu')->where('mer_id',$v['mer_id'])->update(['long'=>$v['long'],'lat'=>$v['lat']]);
|
||||||
|
}
|
||||||
return app('json')->success('修改成功');
|
return app('json')->success('修改成功');
|
||||||
//[31,32,118,39,167,236,237,238,239]
|
//[31,32,118,39,167,236,237,238,239]
|
||||||
// return app('json')->success('修改成功');>whereIn('mer_id',[110,116,149,227,226,35,117,148,156,104,137,151,136,183,140,229,79,133,235])->
|
// return app('json')->success('修改成功');>whereIn('mer_id',[110,116,149,227,226,35,117,148,156,104,137,151,136,183,140,229,79,133,235])->
|
||||||
|
@ -66,23 +66,25 @@ class StoreSpu extends BaseController
|
|||||||
'village_id',
|
'village_id',
|
||||||
'location'
|
'location'
|
||||||
]);
|
]);
|
||||||
if ($where['type_id']||$where['type_code']) {
|
|
||||||
[$lat, $lng] = (new CityAreaDao())->getLngAndLat($where['location'], $where['street_id']);
|
[$lat, $lng] = (new CityAreaDao())->getLngAndLat($where['location'], $where['street_id']);
|
||||||
|
$where['long']=$lng;
|
||||||
|
$where['lat']=$lat;
|
||||||
|
if ($where['type_id']||$where['type_code']) {
|
||||||
$arr = ['status' => 1, 'mer_state' => 1, 'is_del' => 0];
|
$arr = ['status' => 1, 'mer_state' => 1, 'is_del' => 0];
|
||||||
$query = Merchant::where($arr);
|
$query = Merchant::where($arr);
|
||||||
$merIds = (new MerchantDao())->getValidMerchantByDistance($lat, $lng);
|
// $merIds = (new MerchantDao())->getValidMerchantByDistance($lat, $lng);
|
||||||
if (!empty($merIds)) {
|
// if (!empty($merIds)) {
|
||||||
$query->whereIn('mer_id', $merIds);
|
// $query->whereIn('mer_id', $merIds);
|
||||||
}
|
// }
|
||||||
if ($where['village_id']) {
|
// if ($where['village_id']) {
|
||||||
$query->where('village_id', $where['village_id']);
|
// $query->where('village_id', $where['village_id']);
|
||||||
}
|
// }
|
||||||
if($where['type_code']){
|
// if($where['type_code']){
|
||||||
$mer_type_id=Db::name('merchant_type')->where('type_code',$where['type_code'])->value('mer_type_id');
|
// $mer_type_id=Db::name('merchant_type')->where('type_code',$where['type_code'])->value('mer_type_id');
|
||||||
if($mer_type_id){
|
// if($mer_type_id){
|
||||||
$query->where('type_id', $mer_type_id);
|
// $query->where('type_id', $mer_type_id);
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
$where['mer_ids'] = $query->whereIn('type_id', explode(',', $where['type_id']))->column('mer_id');
|
$where['mer_ids'] = $query->whereIn('type_id', explode(',', $where['type_id']))->column('mer_id');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user