| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970 |
- <?php
- namespace bizHd\merchant\services;
- use bizHd\base\services\BaseService;
- use bizHd\merchant\classes\ShopClass;
- use common\components\stringUtil;
- use common\components\util;
- use Yii;
- class ShopService extends BaseService
- {
-
- public static $baseFile = '\bizHd\merchant\classes\ShopClass';
-
- //计算运费 ssh 2019.12.4
- public static function getSendCost($lat, $lng, $jsStatDistance, $shopInfo)
- {
- //门店纬度
- $shopLat = $shopInfo['lat'];
- //门店经度
- $shopLong = $shopInfo['long'];
- //后端计算距离再确认
- $phpStatDistance = util::getDistance($shopLat, $shopLong, $lat, $lng);
- if ($phpStatDistance > $jsStatDistance) {
- util::fail('前端计算距离有误!');
- }
- $sjId = $shopInfo['sjId'];
- $ext = MerchantExtendService::getBySjId($sjId);
- $freight = MerchantExtendService::getFreight($ext);
- $firstDistance = $freight[0];
- $addPrice = $freight[1];
- $remainDistance = $jsStatDistance > $firstDistance ? stringUtil::calcSub($jsStatDistance, $firstDistance) : 0;
- $sendCost = ceil($remainDistance * 1000 / 1000 / 1000) * $addPrice;
- return $sendCost;
- }
-
- //获取默认门店信息 ssh 2019.12.6
- public static function getDefaultShop($merchant)
- {
- $defaultShopId = $merchant['defaultShopId'];
- return ShopClass::getById($defaultShopId);
- }
-
- //验证门店
- public static function valid($shopInfo, $sjId)
- {
- ShopClass::valid($shopInfo, $sjId);
- }
-
- public static function getShopList($where)
- {
- $list = ShopClass::getShopList($where);
- return $list;
- }
-
- //获取默认门店 ssh 2020.1.19
- public static function getDefaultShopId($merchant)
- {
- return ShopClass::getDefaultShopId($merchant);
- }
- //删除门店 ssh 2020.3.1
- public static function deleteShop($shop)
- {
- return ShopClass::deleteShop($shop);
- }
- }
|