初始版本
This commit is contained in:
340
server/app/common/model/shop/Shop.php
Executable file
340
server/app/common/model/shop/Shop.php
Executable file
@@ -0,0 +1,340 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | likeshop100%开源免费商用商城系统
|
||||
// +----------------------------------------------------------------------
|
||||
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
|
||||
// | 开源版本可自由商用,可去除界面版权logo
|
||||
// | 商业版本务必购买商业授权,以免引起法律纠纷
|
||||
// | 禁止对系统程序代码以任何目的,任何形式的再发布
|
||||
// | gitee下载:https://gitee.com/likeshop_gitee
|
||||
// | github下载:https://github.com/likeshop-github
|
||||
// | 访问官网:https://www.likeshop.cn
|
||||
// | 访问社区:https://home.likeshop.cn
|
||||
// | 访问手册:http://doc.likeshop.cn
|
||||
// | 微信公众号:likeshop技术社区
|
||||
// | likeshop团队 版权所有 拥有最终解释权
|
||||
// +----------------------------------------------------------------------
|
||||
// | author: likeshopTeam
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
namespace app\common\model\shop;
|
||||
|
||||
use app\common\enum\shop\ShopEnum;
|
||||
use app\common\model\BaseModel;
|
||||
use app\common\model\coach\Coach;
|
||||
use app\common\model\Region;
|
||||
use app\common\service\FileService;
|
||||
|
||||
/**
|
||||
* 店铺模型类
|
||||
* Class Shop
|
||||
* @package app\common\model\shop
|
||||
*/
|
||||
class Shop extends BaseModel
|
||||
{
|
||||
|
||||
public function coach()
|
||||
{
|
||||
return $this->hasMany(Coach::class,'shop_id');
|
||||
}
|
||||
public function categoryIds()
|
||||
{
|
||||
return $this->hasMany(ShopCategoryIndex::class,'shop_id');
|
||||
}
|
||||
|
||||
public function goods()
|
||||
{
|
||||
return $this->hasMany(ShopGoodsIndex::class,'shop_id');
|
||||
}
|
||||
|
||||
public function goodsIds()
|
||||
{
|
||||
return $this->hasMany(ShopGoodsIndex::class,'shop_id');
|
||||
}
|
||||
|
||||
public function shopImage()
|
||||
{
|
||||
return $this->hasMany(ShopImage::class,'shop_id');
|
||||
}
|
||||
|
||||
|
||||
public function getTakeOrderAttr($value,$data)
|
||||
{
|
||||
return [
|
||||
'everyday' => 2,
|
||||
'total_order' => 1
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @notes 获取工作状态
|
||||
* @param $value
|
||||
* @param $data
|
||||
* @return string|string[]
|
||||
* @author cjhao
|
||||
* @date 2024/10/3 15:43
|
||||
*/
|
||||
public function getWorkStatusDescAttr($value,$data)
|
||||
{
|
||||
return ShopEnum::getWorkStatus($data['work_status']);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @notes 获取工作状态
|
||||
* @param $value
|
||||
* @param $data
|
||||
* @return string|string[]
|
||||
* @author cjhao
|
||||
* @date 2024/10/3 15:43
|
||||
*/
|
||||
public function getServerStatusDescAttr($value,$data)
|
||||
{
|
||||
return ShopEnum::getServerStatus($data['server_status']);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 公共处理图片,补全路径
|
||||
* @param $value
|
||||
* @return string
|
||||
* @author 张无忌
|
||||
* @date 2021/9/10 11:02
|
||||
*/
|
||||
public function getIdCardFrontAttr($value)
|
||||
{
|
||||
return trim($value) ? FileService::getFileUrl($value) : '';
|
||||
}
|
||||
|
||||
/**
|
||||
* @notes 公共图片处理,去除图片域名
|
||||
* @param $value
|
||||
* @return mixed|string
|
||||
* @author 张无忌
|
||||
* @date 2021/9/10 11:04
|
||||
*/
|
||||
public function setIdCardFrontAttr($value)
|
||||
{
|
||||
return trim($value) ? FileService::setFileUrl($value) : '';
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @notes 公共处理图片,补全路径
|
||||
* @param $value
|
||||
* @return string
|
||||
* @author 张无忌
|
||||
* @date 2021/9/10 11:02
|
||||
*/
|
||||
public function getIdCardBackAttr($value)
|
||||
{
|
||||
return trim($value) ? FileService::getFileUrl($value) : '';
|
||||
}
|
||||
|
||||
/**
|
||||
* @notes 公共图片处理,去除图片域名
|
||||
* @param $value
|
||||
* @return mixed|string
|
||||
* @author 张无忌
|
||||
* @date 2021/9/10 11:04
|
||||
*/
|
||||
public function setIdCardBackAttr($value)
|
||||
{
|
||||
return trim($value) ? FileService::setFileUrl($value) : '';
|
||||
}
|
||||
|
||||
/**
|
||||
* @notes 公共处理图片,补全路径
|
||||
* @param $value
|
||||
* @return string
|
||||
* @author 张无忌
|
||||
* @date 2021/9/10 11:02
|
||||
*/
|
||||
public function getPortraitShootingAttr($value)
|
||||
{
|
||||
return trim($value) ? FileService::getFileUrl($value) : '';
|
||||
}
|
||||
|
||||
/**
|
||||
* @notes 公共图片处理,去除图片域名
|
||||
* @param $value
|
||||
* @return mixed|string
|
||||
* @author 张无忌
|
||||
* @date 2021/9/10 11:04
|
||||
*/
|
||||
public function setPortraitShootingAttr($value)
|
||||
{
|
||||
return trim($value) ? FileService::setFileUrl($value) : '';
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 公共处理图片,补全路径
|
||||
* @param $value
|
||||
* @return string
|
||||
* @author 张无忌
|
||||
* @date 2021/9/10 11:02
|
||||
*/
|
||||
public function getLogoAttr($value)
|
||||
{
|
||||
return trim($value) ? FileService::getFileUrl($value) : '';
|
||||
}
|
||||
|
||||
/**
|
||||
* @notes 公共图片处理,去除图片域名
|
||||
* @param $value
|
||||
* @return mixed|string
|
||||
* @author 张无忌
|
||||
* @date 2021/9/10 11:04
|
||||
*/
|
||||
public function setLogoAttr($value)
|
||||
{
|
||||
return trim($value) ? FileService::setFileUrl($value) : '';
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 公共处理图片,补全路径
|
||||
* @param $value
|
||||
* @return string
|
||||
* @author 张无忌
|
||||
* @date 2021/9/10 11:02
|
||||
*/
|
||||
public function getBusinessLicenseAttr($value)
|
||||
{
|
||||
return trim($value) ? FileService::getFileUrl($value) : '';
|
||||
}
|
||||
|
||||
/**
|
||||
* @notes 公共图片处理,去除图片域名
|
||||
* @param $value
|
||||
* @return mixed|string
|
||||
* @author 张无忌
|
||||
* @date 2021/9/10 11:04
|
||||
*/
|
||||
public function setBusinessLicenseAttr($value)
|
||||
{
|
||||
return trim($value) ? FileService::setFileUrl($value) : '';
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 获取店铺地址
|
||||
* @param $value
|
||||
* @param $data
|
||||
* @return string
|
||||
* @author cjhao
|
||||
* @date 2024/10/7 00:34
|
||||
*/
|
||||
public function getRegionDescAttr($value,$data)
|
||||
{
|
||||
$cityIds = [];
|
||||
$cityLists = '';
|
||||
$data['province_id'] && $cityIds[] = $data['province_id'];
|
||||
$data['city_id'] && $cityIds[] = $data['city_id'];
|
||||
$data['region_id'] && $cityIds[] = $data['region_id'];
|
||||
if($cityIds){
|
||||
$cityLists = Region::where(['id'=>$cityIds])->column('name');
|
||||
$cityLists = implode('',$cityLists);
|
||||
}
|
||||
return $cityLists;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @notes 审核状态
|
||||
* @param $value
|
||||
* @return string|string[]
|
||||
* @author cjhao
|
||||
* @date 2024/10/7 00:25
|
||||
*/
|
||||
public function getAuditStatusDescAttr($value,$data)
|
||||
{
|
||||
return ShopEnum::getAuditStatusDesc($data['audit_status']);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @notes 将距离转成km格式显示
|
||||
* @param $value
|
||||
* @param $data
|
||||
* @return string
|
||||
* @author cjhao
|
||||
* @date 2024/9/3 22:56
|
||||
*/
|
||||
public function getDistanceDescAttr($value,$data){
|
||||
return !empty($data['distance']) ? round($data['distance'],2).'km' : '';
|
||||
}
|
||||
|
||||
/**
|
||||
* @notes 获取营业时间
|
||||
* @param $value
|
||||
* @param $data
|
||||
* @return string
|
||||
* @author cjhao
|
||||
* @date 2024/11/20 20:44
|
||||
*/
|
||||
public function getBusinessTimeDescAttr($value,$data)
|
||||
{
|
||||
$businessTimeLists = [
|
||||
'周一' => $data['monday'],
|
||||
'周二' => $data['tuesday'],
|
||||
'周三' => $data['wednesday'],
|
||||
'周四' => $data['thursday'],
|
||||
'周五' => $data['friday'],
|
||||
'周六' => $data['saturday'],
|
||||
'周日' => $data['sunday']
|
||||
];
|
||||
$businessTime = displayBusinessHours($businessTimeLists);
|
||||
if(empty($businessTime)){
|
||||
return '';
|
||||
}
|
||||
return $businessTime . ' '.$data['business_start_time'].'-'.$data['business_end_time'];
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @notes 获取地区
|
||||
* @param $value
|
||||
* @param $data
|
||||
* @return string
|
||||
* @author cjhao
|
||||
* @date 2024/8/26 12:52
|
||||
*/
|
||||
public function getRegionNameAttr($value,$data)
|
||||
{
|
||||
return Region::where(['id'=>$data['region_id']])->value('name');
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 省份id
|
||||
* @param $value
|
||||
* @param $data
|
||||
* @return mixed
|
||||
* @author cjhao
|
||||
* @date 2024/11/26 14:47
|
||||
*/
|
||||
public function getProvinceNameAttr($value,$data)
|
||||
{
|
||||
return Region::where(['id'=>$data['province_id']])->value('name');
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @notes 省份id
|
||||
* @param $value
|
||||
* @param $data
|
||||
* @return mixed
|
||||
* @author cjhao
|
||||
* @date 2024/11/26 14:47
|
||||
*/
|
||||
public function getCityNameAttr($value,$data)
|
||||
{
|
||||
return Region::where(['id'=>$data['city_id']])->value('name');
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user