ShopService.php 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. <?php
  2. namespace bizHd\merchant\services;
  3. use bizHd\base\services\BaseService;
  4. use bizHd\merchant\classes\ShopClass;
  5. use common\components\stringUtil;
  6. use common\components\util;
  7. use Yii;
  8. class ShopService extends BaseService
  9. {
  10. public static $baseFile = '\bizHd\merchant\classes\ShopClass';
  11. //计算运费 ssh 2019.12.4
  12. public static function getSendCost($lat, $lng, $jsStatDistance, $shopInfo)
  13. {
  14. //门店纬度
  15. $shopLat = $shopInfo['lat'];
  16. //门店经度
  17. $shopLong = $shopInfo['long'];
  18. //后端计算距离再确认
  19. $phpStatDistance = util::getDistance($shopLat, $shopLong, $lat, $lng);
  20. if ($phpStatDistance > $jsStatDistance) {
  21. util::fail('前端计算距离有误!');
  22. }
  23. $sjId = $shopInfo['sjId'];
  24. $ext = MerchantExtendService::getBySjId($sjId);
  25. $freight = MerchantExtendService::getFreight($ext);
  26. $firstDistance = $freight[0];
  27. $addPrice = $freight[1];
  28. $remainDistance = $jsStatDistance > $firstDistance ? stringUtil::calcSub($jsStatDistance, $firstDistance) : 0;
  29. $sendCost = ceil($remainDistance * 1000 / 1000 / 1000) * $addPrice;
  30. return $sendCost;
  31. }
  32. //获取默认门店信息 ssh 2019.12.6
  33. public static function getDefaultShop($merchant)
  34. {
  35. $defaultShopId = $merchant['defaultShopId'];
  36. return ShopClass::getById($defaultShopId);
  37. }
  38. //验证门店
  39. public static function valid($shopInfo, $sjId)
  40. {
  41. ShopClass::valid($shopInfo, $sjId);
  42. }
  43. public static function getShopList($where)
  44. {
  45. $list = ShopClass::getShopList($where);
  46. return $list;
  47. }
  48. //获取默认门店 ssh 2020.1.19
  49. public static function getDefaultShopId($merchant)
  50. {
  51. return ShopClass::getDefaultShopId($merchant);
  52. }
  53. //删除门店 ssh 2020.3.1
  54. public static function deleteShop($shop)
  55. {
  56. return ShopClass::deleteShop($shop);
  57. }
  58. }