| 12345678910111213141516171819202122232425262728293031323334 |
- <?php
- namespace bizHd\merchant\services;
- use bizHd\base\services\BaseService;
- use bizHd\merchant\classes\ShopClass;
- use common\components\mapUtil;
- use common\components\stringUtil;
- use common\components\util;
- use Yii;
- class ExpressService extends BaseService
- {
-
- public static $baseFile = '\bizHd\merchant\classes\ExpressClass';
-
- //计算客户的距离和运费 ssh 2020.5.14
- public static function getUserDistance($lng, $lat, $shopId, $extend)
- {
- $shop = ShopClass::getById($shopId);
- $shopLat = isset($shop['lat']) ? $shop['lat'] : '';
- $shopLong = isset($shop['long']) ? $shop['long'] : '';
- $distance = mapUtil::calculateDistance($shopLong, $shopLat, $lng, $lat);
- $perKiloFee = isset($extend['freight']) ? $extend['freight'] : 10;
- $freeDistance = isset($extend['freeDistance']) ? $extend['freeDistance'] : 5;
- $fee = 0;
- if ($distance > $freeDistance * 1000) {
- $fee = ceil(($distance - $freeDistance * 1000) / 1000) * $perKiloFee;
- }
- $showDistance = sprintf("%.1f", ($distance / 1000));
- return ['distance' => $distance, 'showDistance' => $showDistance, 'fee' => $fee];
- }
- }
|