| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140 |
- <?php
- namespace biz\shop\services;
- use biz\base\services\BaseService;
- use biz\shop\classes\ShopClass;
- use common\components\stringUtil;
- use common\components\util;
- use Yii;
- class ShopService extends BaseService
- {
- public static $baseFile = '\biz\shop\classes\ShopClass';
- //计算运费 ssh 2019.12.4
- public static function getSendCost($lat, $lng, $jsStatDistance, $shopInfo)
- {
- //门店纬度
- $shopLat = $shopInfo['shopLat'];
- //门店经度
- $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.2.29
- /*public static function updateShop($id, $data)
- {
- return ShopClass::updateShop($id, $data);
- }*/
- //删除门店 ssh 2020.3.1
- /*public static function deleteShop($shop)
- {
- return ShopClass::deleteShop($shop);
- }*/
- //获取收款码 ssh 2020.3.9
- /*public static function generateGatheringCode($sjId, $shopId)
- {
- return ShopClass::generateGatheringCode($sjId, $shopId);
- }*/
- //根据商家ID,获取所有门店 shopIds lqh 2021.3.4
- public static function getShopIds($sjId)
- {
- $shops = ShopClass::getAllShop($sjId);
- $shopIds = [];
- if($shops){
- $shopIds = array_column($shops,'id');
- }
- return $shopIds;
- }
- //获取门店资产信息 lqh 2021.4.14
- public static function getById($shopId, $returnObj = false)
- {
- return ShopClass::getById($shopId, $returnObj);
- }
- //总订单加1
- public static function totalOrderPlus($shopId)
- {
- $shop = ShopClass::getById($shopId);
- if($shop){
- $data = [
- 'totalOrder'=>$shop['totalOrder'] + 1
- ];
- ShopClass::updateById($shopId,$data);
- }
- }
- //更新总收入
- public static function updateTotalIncome($shopId,$amount)
- {
- $shop = ShopClass::getById($shopId);
- if($shop){
- $data = [
- 'totalIncome'=>bcadd($shop['totalIncome'],$amount,2)
- ];
- ShopClass::updateById($shopId,$data);
- }
- }
- //更新总访问数 +1
- public static function totalViewPlus($shopId)
- {
- $shop = ShopClass::getById($shopId);
- if($shop){
- $data = [
- 'totalView'=>$shop['totalView'] + 1
- ];
- ShopClass::updateById($shopId,$data);
- }
- }
- }
|