初始版本

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,97 @@
<?php
namespace app\adminapi\logic\shop;
use app\common\enum\GoodsEnum;
use app\common\logic\BaseLogic;
use app\common\model\goods\Goods;
use app\common\model\goods\GoodsCategory;
use app\common\model\goods\GoodsCityIndex;
use app\common\model\goods\GoodsSkillIndex;
use app\common\model\shop\Shop;
use think\Exception;
/**
* 项目服务类
* Class GoodsLogic
* @package app\adminapi\logic\shop
*/
class GoodsLogic extends BaseLogic
{
/**
* @notes 上下架
* @param $id
* @return true|void
* @author cjhao
* @date 2024/10/29 13:06
*/
public function status($id){
$goods = Goods::where(['id'=>$id])->findOrEmpty();
if($goods->isEmpty()){
return true;
}
$goods->status = $goods->status ? 0 : 1;
$goods->save();
}
/**
* @notes 服务详情
* @param $id
* @return array
* @author cjhao
* @date 2024/10/29 13:10
*/
public function detail($id)
{
$result = Goods::where('id',$id)
->withoutField('order_num,update_time,delete_time')
->append(['category_desc','goods_image'])
->findOrEmpty()
->toArray();
$goods_image = [];
foreach ($result['goods_image'] as &$image) {
$goods_image[] = $image['uri'];
}
$result['goods_image'] = $goods_image;
$result['city_id'] = GoodsCityIndex::where(['goods_id'=>$id])->column('city_id');
$result['skill_id'] = GoodsSkillIndex::where(['goods_id'=>$id])->column('skill_id');
// $result['category_name'] = GoodsCategory::where(['id'=>$result['category_id']])->column('name');
$result['shop_name'] = Shop::where(['id'=>$result['shop_id']])->value('name');
return $result;
}
/**
* @notes 审核
* @param $params
* @return bool
* @author cjhao
* @date 2024/10/29 13:29
*/
public function audit($params)
{
try {
$detail = Goods::where(['id'=>$params['id']])->findOrEmpty();
if($detail->isEmpty()){
throw new Exception('服务不存在');
}
if(0 != $detail->audit_status){
throw new Exception('审核状态已改变');
}
$status = GoodsEnum::AUDIT_STATUS_PASS;
if(0 == $params['audit_status']){
$status = GoodsEnum::AUDIT_STATUS_REFUSE;
$detail->status = GoodsEnum::UNSHELVE;
}
$detail->audit_status = $status;
$detail->audit_remark = $params['audit_remark'] ?? '';
$detail->save();
return true;
}catch (\Exception $e){
self::$error = $e->getMessage();
return false;
}
}
}