初始版本

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
// +----------------------------------------------------------------------
// | 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\adminapi\logic\shop;
use app\common\logic\BaseLogic;
use app\common\model\deposit\DepositPackage;
class DepositPackageLogic extends BaseLogic
{
/**
* @notes 添加
* @param $params
* @return bool
* @author ljj
* @date 2022/2/8 5:03 下午
*/
public function add($params)
{
DepositPackage::create([
'name' => $params['name'],
'money' => $params['money'],
'coach_num' => $params['coach_num'],
'type' => 2,
'order_limit' => $params['order_limit'],
]);
return true;
}
/**
* @notes 查看服务分类详情
* @param $id
* @return array
* @author ljj
* @date 2022/2/8 5:21 下午
*/
public function detail($id)
{
$result = DepositPackage::where('id',$id)->withoutField('update_time,delete_time')->findOrEmpty()->toArray();
return $result;
}
/**
* @notes 编辑服务分类
* @param $params
* @return bool
* @author ljj
* @date 2022/2/8 6:25 下午
*/
public function edit($params)
{
DepositPackage::update([
'name' => $params['name'],
'money' => $params['money'],
'coach_num' => $params['coach_num'],
'order_limit' => $params['order_limit'],
],['id'=>$params['id']]);
return true;
}
/**
* @notes 删除服务
* @param $id
* @return bool
* @author ljj
* @date 2022/2/8 6:34 下午
*/
public function del($id)
{
return DepositPackage::destroy($id);
}
}

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;
}
}
}

View File

@@ -0,0 +1,535 @@
<?php
namespace app\adminapi\logic\shop;
use app\common\enum\accountLog\ShopAccountLogEnum;
use app\common\enum\shop\ShopEnum;
use app\common\logic\BaseLogic;
use app\common\logic\ShopAccountLogLogic;
use app\common\model\accountLog\ShopAccountLog;
use app\common\model\shop\Shop;
use app\common\model\shop\ShopCategoryIndex;
use app\common\model\shop\ShopGoodsIndex;
use app\common\model\shop\ShopImage;
use app\common\model\shop\ShopUpdate;
use app\common\model\shop\ShopUser;
use app\common\service\ConfigService;
use app\common\service\FileService;
use think\Exception;
use think\facade\Db;
use think\facade\Config;
/**
* 门店逻辑类
* Class ShopLogic
* @package app\adminapi\logic\shop
*/
class ShopLogic extends BaseLogic
{
/**
* @notes 添加门店
* @param array $params
* @return string|true
* @author cjhao
* @date 2024/10/3 13:30
*/
public function add(array $params)
{
try {
Db::startTrans();
$number = ShopUser::count()+1;
$sn = sprintf("%03d", $number);
$passwordSalt = Config::get('project.unique_identification');
$password = create_password($params['mobile'], $passwordSalt);
$avatar = ConfigService::get('default_image', 'user_avatar');
$shopUser = ShopUser::where('account','=',$params['mobile'])
->findOrEmpty();
if(!$shopUser->isEmpty()){
throw new Exception('手机号码已存在');
}
$shopUser = ShopUser::create([
'sn' => $sn,
'avatar' => $avatar,
'account' => $params['mobile'],
'password' => $password,
]);
$shop = Shop::create([
'name' => $params['name'],
'shop_user_id' => $shopUser['id'],
'mobile' => $params['mobile'],
'sn' => sprintf("%03d", Shop::count()+1),
'short_name' => $params['short_name'],
'business_start_time' => '10:00',
'business_end_time' => '22:00',
'type' => $params['type'],
'social_credit_ode' => $params['social_credit_ode'],
'legal_person' => $params['legal_person'],
'legal_id_card' => $params['legal_id_card'],
'province_id' => $params['province_id'],
'city_id' => $params['city_id'],
'region_id' => $params['region_id'],
'shop_address_detail' => $params['shop_address_detail'],
'longitude' => $params['longitude'],
'latitude' => $params['latitude'],
'id_card_front' => $params['id_card_front'],
'id_card_back' => $params['id_card_back'],
// 'portrait_shooting' => $params['portrait_shooting'],
'logo' => $params['logo'],
'business_license' => $params['business_license'],
'synopsis' => $params['synopsis'] ?? '',
'work_status' => $params['work_status'] ?? '',
'server_status' => $params['server_status'] ?? '',
'audit_status' => ShopEnum::AUDIT_STATUS_PASS,
]);
$categoryLists = [];
foreach ($params['category_ids'] as $categoryId){
$categoryLists[] = [
'shop_id' => $shop['id'],
'category_id' => $categoryId,
];
}
(new ShopCategoryIndex())->saveAll($categoryLists);
$goodsLists = [];
foreach ($params['goods_ids'] as $goodsId) {
$goodsLists[] = [
'shop_id' => $shop['id'],
'goods_id' => $goodsId,
];
}
(new ShopGoodsIndex())->saveAll($goodsLists);
$shopImageLists = [];
foreach ($params['shop_image'] as $image){
$shopImageLists[] = [
'shop_id' => $shop['id'],
'uri' => $image,
];
}
(new ShopImage())->saveAll($shopImageLists);
Db::commit();
return true;
}catch (Exception $e){
Db::rollback();
return $e->getMessage();
}
}
/**
* @notes 编辑门店
* @param array $params
* @return string|true
* @throws \Exception
* @author cjhao
* @date 2024/10/3 15:11
*/
public function edit(array $params)
{
try {
Db::startTrans();
$shop = Shop::where(['id'=>$params['id']])->findOrEmpty();
$shopUser = ShopUser::where('id','<>',$shop['shop_user_id'])
->where('account','=',$params['mobile'])
->findOrEmpty();
if(!$shopUser->isEmpty()){
throw new Exception('手机号码已存在');
}
ShopUser::where(['id'=>$shop['shop_user_id']])->update(['account'=>$params['mobile']]);
Shop::update([
'id' => $params['id'],
'name' => $params['name'],
'short_name' => $params['short_name'],
'type' => $params['type'],
'social_credit_ode' => $params['social_credit_ode'],
'mobile' => $params['mobile'],
'legal_person' => $params['legal_person'],
'legal_id_card' => $params['legal_id_card'],
'province_id' => $params['province_id'],
'city_id' => $params['city_id'],
'region_id' => $params['region_id'],
'shop_address_detail'=> $params['shop_address_detail'],
'longitude' => $params['longitude'],
'latitude' => $params['latitude'],
'id_card_front' => $params['id_card_front'],
'id_card_back' => $params['id_card_back'],
// 'portrait_shooting' => $params['portrait_shooting'],
'logo' => $params['logo'],
'business_license' => $params['business_license'],
'synopsis' => $params['synopsis'] ?? '',
'work_status' => $params['work_status'] ?? '',
'server_status' => $params['server_status'] ?? '',
]);
ShopCategoryIndex::where(['shop_id'=>$params['id']])->delete();
ShopGoodsIndex::where(['shop_id'=>$params['id']])->delete();
ShopImage::where(['shop_id'=>$params['id']])->delete();
$categoryLists = [];
foreach ($params['category_ids'] as $categoryId){
$categoryLists[] = [
'shop_id' => $params['id'],
'category_id' => $categoryId,
];
}
(new ShopCategoryIndex())->saveAll($categoryLists);
$goodsLists = [];
foreach ($params['goods_ids'] as $goodsId) {
$goodsLists[] = [
'shop_id' => $params['id'],
'goods_id' => $goodsId,
];
}
(new ShopGoodsIndex())->saveAll($goodsLists);
$shopImageLists = [];
foreach ($params['shop_image'] as $image){
$shopImageLists[] = [
'shop_id' => $params['id'],
'uri' => $image,
];
}
(new ShopImage())->saveAll($shopImageLists);
Db::commit();
return true;
}catch (Exception $e){
Db::rollback();
return $e->getMessage();
}
}
/**
* @notes 店铺详情接口
* @param int $id
* @return array
* @author cjhao
* @date 2024/10/4 00:12
*/
public function detail(int $id)
{
$detail = Shop::where(['id'=>$id])
->append(['shop_image','region_desc','province_name','city_name'])
->withoutField('update_time,delete_time')
->findOrEmpty()->toArray();
$categoryLists = ShopCategoryIndex::alias('SC')
->where(['SC.shop_id'=>$id,'is_show'=>1])
->join('goods_category GC','SC.category_id = GC.id')
->field('GC.id,GC.name')
->select()->toArray();
$goodsLists = ShopGoodsIndex::alias('SG')
->where(['SG.shop_id'=>$id,'G.status'=>1])
->join('goods G','SG.goods_id = G.id')
->field('G.id,G.image,G.name')
->select()->toArray();
$detail['shop_image'] = array_column($detail['shop_image']->toArray(),'uri');
$detail['category_lists'] = $categoryLists;
$detail['category_ids'] = array_column($categoryLists,'id');
$detail['goods_lists'] = $goodsLists;
return $detail;
}
/**
* @notes 调整余额
* @param array $params
* @return string|true
* @author cjhao
* @date 2024/10/3 16:08
*/
public function adjustMoney(array $params)
{
try {
Db::startTrans();
$shop = Shop::where(['id'=>$params['id']])->findOrEmpty();
if($shop->isEmpty()){
return '店铺不存在';
}
$action = $params['action'];
if(1 == $action){
$shop->money = $shop->money+$params['money'];
$shop->save();
ShopAccountLogLogic::add(
$shop->id,
ShopAccountLogEnum::MONEY,
ShopAccountLogEnum::ADMIN_INC_MONEY,
$action,
$params['money'],
'',
$params['admin_id']
);
}else{
if($params['money'] > $shop->money){
return '当前店铺金额仅剩:'.$shop->money;
}
$shop->money = $shop->money - $params['money'];
$shop->save();
ShopAccountLogLogic::add(
$shop->id,
ShopAccountLogEnum::MONEY,
ShopAccountLogEnum::ADMIN_DEC_MONEY,
$action,
$params['money'],
'',
$params['admin_id']
);
}
Db::commit();
return true;
}catch (Exception $e){
Db::rollback();
return $e->getMessage();
}
}
/**
* @notes 调整余额
* @param array $params
* @return string|true
* @author cjhao
* @date 2024/10/3 16:08
*/
public function adjustDeposit(array $params)
{
try {
Db::startTrans();
$shop = Shop::where(['id'=>$params['id']])->findOrEmpty();
if($shop->isEmpty()){
return '店铺不存在';
}
$action = $params['action'];
if(1 == $action){
$shop->deposit = $shop->deposit + $params['money'];
$shop->save();
ShopAccountLogLogic::add(
$shop->id,
ShopAccountLogEnum::DEPOSIT,
ShopAccountLogEnum::ADMIN_INC_DEPOSIT,
$action,
$params['money'],
'',
$params['admin_id']
);
}else{
if($params['money'] > $shop->deposit){
return '当前店铺保证金仅剩:'.$shop->deposit;
}
$shop->deposit = $shop->deposit - $params['money'];
$shop->save();
ShopAccountLogLogic::add(
$shop->id,
ShopAccountLogEnum::DEPOSIT,
ShopAccountLogEnum::ADMIN_DEC_DEPOSIT,
$action,
$params['money'],
'',
$params['admin_id']
);
}
Db::commit();
return true;
}catch (Exception $e){
Db::rollback();
return $e->getMessage();
}
}
/**
* @notes 店铺审核
* @param array $params
* @return string|true
* @author cjhao
* @date 2024/10/7 00:44
*/
public function shopAudit(array $params)
{
try {
// Db::startTrans();
$shop = Shop::where(['id'=>$params['id']])->findOrEmpty();
if($shop->isEmpty()){
throw new Exception('店铺不存在');
}
if(ShopEnum::AUDIT_STATUS_WAIT != $shop->audit_status){
throw new Exception( '店铺的审核状态已改变,请刷新页面');
}
$status = ShopEnum::AUDIT_STATUS_PASS;
$auditRemark = $params['audit_remark'] ?? '';
$auditStatus = $params['audit_status'] ?? 0;
if(0 == $auditStatus){
$status = ShopEnum::AUDIT_STATUS_REFUSE;
if(empty($auditRemark)){
throw new Exception("请输入备注");
}
}
$shop->audit_status = $status;
$shop->audit_remark = $params['audit_remark'] ?? '';
$shop->save();
return true;
}catch (Exception $e){
// Db::rollback();
return $e->getMessage();
}
}
public function updateDetail(int $id)
{
$updateShop = (new ShopUpdate())
->where(['id'=>$id])
->withoutField('create_time,update_time,delete_time')
->append(['region_name','province_name','city_name'])
->findOrEmpty()
->toArray();
$shop = (new Shop())
->where(['id'=>$updateShop['shop_id'],'audit_status'=>ShopEnum::AUDIT_STATUS_PASS])
->append(['category_ids','goods_ids','shop_image'])
->withoutField('create_time,update_time,delete_time')
->findOrEmpty()
->toArray();
foreach ($updateShop as $key => $update){
$cancel = ['id','shop_id','shop_user_id'];
if(in_array($key,$cancel)){
continue;
}
$data = $shop[$key] ?? '';
$updateShop[$key.'_update'] = $update == $data ? false: true;
if('goods_ids' == $key && $data){
$goodsIds = array_column($data->toArray(),'goods_id');
// foreach ($update as $goodsKey => $goodsId){
// $update[$goodsKey] = (int)$goodsId;
// }
sort($goodsIds);
sort($update);
$updateShop[$key.'_update'] = $update == $goodsIds ? false : true;
}
if('category_ids' == $key && $data){
$categoryIds = array_column($data->toArray(),'category_id');
// foreach ($update as $goodsKey => $goodsId){
// $update[$goodsKey] = (int)$goodsId;
// }
sort($categoryIds);
sort($update);
$updateShop[$key.'_update'] = $update == $categoryIds ? false : true;
}
if('shop_image' == $key && $data){
$uriLists = array_column($data->toArray(),'uri');
foreach ($uriLists as $uriKey => $uri){
$uriLists[$uriKey] = FileService::setFileUrl($uri);
}
sort($uriLists);
sort($update);
$updateShop[$key.'_update'] = $uriLists == $update ? false : true;
}
}
return $updateShop;
}
/**
* @notes 资料审核
* @param $params
* @return string|true
* @throws \Exception
* @author cjhao
* @date 2024/12/11 19:24
*/
public function updateAudit($params)
{
try {
Db::startTrans();
$shopUpdate = ShopUpdate::where(['id'=>$params['id']])->findOrEmpty();
if($shopUpdate->isEmpty()){
return '申请记录不存在';
}
if(ShopEnum::AUDIT_STATUS_WAIT != $shopUpdate->audit_status){
return '申请的审核状态已改变,请刷新页面';
}
$status = ShopEnum::AUDIT_STATUS_PASS;
if(0 == $params['audit_status']){
$status = ShopEnum::AUDIT_STATUS_REFUSE;
}
$shopUpdate->audit_status = $status;
$shopUpdate->audit_remark = $params['audit_remark'] ?? '';
$shopUpdate->save();
if(0 == $params){
Db::commit();
return true;
}
Shop::update([
'id' => $shopUpdate['shop_id'],
'name' => $shopUpdate['name'],
'short_name' => $shopUpdate['short_name'],
// 'mobile' => $shopUpdate['mobile'],
'type' => $shopUpdate['type'],
'business_start_time' => $shopUpdate['business_start_time'],
'business_end_time' => $shopUpdate['business_end_time'],
'social_credit_ode' => $shopUpdate['social_credit_ode'],
'legal_person' => $shopUpdate['legal_person'],
'legal_id_card' => $shopUpdate['legal_id_card'],
'province_id' => $shopUpdate['province_id'],
'city_id' => $shopUpdate['city_id'],
'region_id' => $shopUpdate['region_id'],
'shop_address_detail' => $shopUpdate['shop_address_detail'],
'longitude' => $shopUpdate['longitude'],
'latitude' => $shopUpdate['latitude'],
'id_card_front' => $shopUpdate['id_card_front'],
'id_card_back' => $shopUpdate['id_card_back'],
'portrait_shooting' => $shopUpdate['portrait_shooting'],
'logo' => $shopUpdate['logo'],
'business_license' => $shopUpdate['business_license'],
'synopsis' => $shopUpdate['synopsis'] ?? '',
]);
ShopCategoryIndex::where(['shop_id'=>$shopUpdate['shop_id']])->delete();
ShopGoodsIndex::where(['shop_id'=>$shopUpdate['shop_id']])->delete();
ShopImage::where(['shop_id'=>$shopUpdate['shop_id']])->delete();
// ShopUser::where(['id'=>$shopUpdate['shop_user_id']])->update(['mobile'=>$shopUpdate['mobile']]);
$categoryLists = [];
foreach ($shopUpdate['category_ids'] as $categoryId){
$categoryLists[] = [
'shop_id' => $shopUpdate['shop_id'],
'category_id' => $categoryId,
];
}
(new ShopCategoryIndex())->saveAll($categoryLists);
$goodsLists = [];
foreach ($shopUpdate['goods_ids'] as $goodsId) {
$goodsLists[] = [
'shop_id' => $shopUpdate['shop_id'],
'goods_id' => $goodsId,
];
}
(new ShopGoodsIndex())->saveAll($goodsLists);
$shopImageLists = [];
foreach ($shopUpdate['shop_image'] as $image){
$shopImageLists[] = [
'shop_id' => $shopUpdate['shop_id'],
'uri' => $image,
];
}
(new ShopImage())->saveAll($shopImageLists);
Db::commit();
return true;
}catch (Exception $e){
Db::rollback();
return $e->getMessage();
}
}
}