初始版本

This commit is contained in:
贾祥聪
2025-08-19 14:16:51 +08:00
commit f937a1f9b9
4373 changed files with 359728 additions and 0 deletions

View File

@@ -0,0 +1,126 @@
<?php
// +----------------------------------------------------------------------
// | likeshop开源商城系统
// +----------------------------------------------------------------------
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
// | 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系列产品在gitee、github等公开渠道开源版本可免费商用未经许可不能去除前后端官方版权标识
// | likeshop系列产品收费版本务必购买商业授权购买去版权授权后方可去除前后端官方版权标识
// | 禁止对系统程序代码以任何目的,任何形式的再发布
// | likeshop团队版权所有并拥有最终解释权
// +----------------------------------------------------------------------
// | author: likeshop.cn.team
// +----------------------------------------------------------------------
namespace app\api\logic;
use app\common\logic\BaseLogic;
use app\common\model\coach\Collect;
use app\common\model\decorate\DecoratePage;
use app\common\model\goods\Goods;
use app\common\model\goods\GoodsCollect;
use app\common\model\goods\GoodsComment;
use app\common\model\order\OrderTime;
use app\common\service\ConfigService;
class GoodsLogic extends BaseLogic
{
/**
* @notes 服务详情
* @param $params
* @return array
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\DbException
* @throws \think\db\exception\ModelNotFoundException
* @author ljj
* @date 2022/2/18 10:40 上午
*/
public function detail($params)
{
$detail = Goods::where(['id'=>$params['id']])
->append(['goods_image'])
->field('id,name,price,duration,scribing_price,order_num+virtual_order_num as total_order_num,tags,content')
->findOrEmpty()
->toArray();
$goodsImage = array_column($detail['goods_image']->toArray(),'uri');
$detail['goods_image'] = $goodsImage;
$detail['comment_count'] = GoodsComment::where(['goods_id'=>$params['id']])->count();
$detail['is_collect'] =Collect::where(['relation_id'=>$params['id'],'user_id'=>$params['user_id'],'type'=>2])->findOrEmpty()->toArray() ? 1 : 0;;
$decorate = DecoratePage::where(['type'=>5,'source'=>1])->findOrEmpty()->toArray();
$decorateData = json_decode($decorate['data'],true);
$commentNum = 0;
$enabled = 1;
foreach($decorateData as $data){
if('goods-comment' == $data['name']){
$commentNum = $data['content']['num'] ?? 0;
$enabled = $data['content']['enabled'] ?? 0;
}
}
$detail['comment_lists'] = [];
if($commentNum > 0 && $enabled){
$goodsCommentLists = GoodsComment::alias('gc')
->leftjoin('goods_comment_image gci', 'gc.id = gci.comment_id')
->with(['goods_comment_image','user'])
->where(['gc.goods_id'=>$params['id']])
->field('gc.id,gc.goods_id,gc.user_id,gc.service_comment,gc.comment,gc.reply,gc.create_time')
->append(['comment_level'])
->order('gc.id','desc')
->group('gc.id')
->limit($commentNum)
->select()
->toArray();
$detail['comment_lists'] = $goodsCommentLists;
}
return $detail;
}
/**
* @notes 预约上门时间
* @return array
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\DbException
* @throws \think\db\exception\ModelNotFoundException
* @author ljj
* @date 2022/3/11 2:32 下午
*/
public function appointTime()
{
return [
'order_time' => ConfigService::get('order_time','time',7),
'appoint_time' => OrderTime::order(['sort'=>'desc','id'=>'desc'])->field('start_time,end_time')->select()->toArray(),
];
}
/**
* @notes 收藏服务
* @param $params
* @return bool
* @author ljj
* @date 2022/3/16 4:14 下午
*/
public function collect($params)
{
if($params['is_collect']){
$goods_collect = GoodsCollect::where(['goods_id'=>$params['id'],'user_id'=>$params['user_id']])->findOrEmpty();
if(!$goods_collect->isEmpty()){
return true;
}
$goods_collect->goods_id = $params['id'];
$goods_collect->user_id = $params['user_id'];
$goods_collect->save();
}else {
GoodsCollect::where(['goods_id'=>$params['id'],'user_id'=>$params['user_id']])->delete();
}
return true;
}
}