初始版本
This commit is contained in:
26
server/app/api/config/route.php
Executable file
26
server/app/api/config/route.php
Executable file
@@ -0,0 +1,26 @@
|
||||
<?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
|
||||
// +----------------------------------------------------------------------
|
||||
return [
|
||||
|
||||
'middleware' => [
|
||||
app\api\http\middleware\InitMiddleware::class,
|
||||
app\api\http\middleware\LoginMiddleware::class,//登录验证
|
||||
],
|
||||
|
||||
];
|
||||
37
server/app/api/controller/AccountLogController.php
Executable file
37
server/app/api/controller/AccountLogController.php
Executable file
@@ -0,0 +1,37 @@
|
||||
<?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\controller;
|
||||
|
||||
|
||||
use app\api\lists\AccountLogLists;
|
||||
|
||||
class AccountLogController extends BaseApiController
|
||||
{
|
||||
/**
|
||||
* @notes 账户明细列表
|
||||
* @return \think\response\Json
|
||||
* @author ljj
|
||||
* @date 2022/6/9 10:21 上午
|
||||
*/
|
||||
public function lists()
|
||||
{
|
||||
return $this->dataLists(new AccountLogLists());
|
||||
}
|
||||
}
|
||||
40
server/app/api/controller/AdController.php
Executable file
40
server/app/api/controller/AdController.php
Executable file
@@ -0,0 +1,40 @@
|
||||
<?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\controller;
|
||||
|
||||
|
||||
use app\api\lists\AdLists;
|
||||
|
||||
class AdController extends BaseApiController
|
||||
{
|
||||
public array $notNeedLogin = ['lists'];
|
||||
|
||||
|
||||
/**
|
||||
* @notes 广告列表
|
||||
* @return \think\response\Json
|
||||
* @author ljj
|
||||
* @date 2022/3/25 9:55 上午
|
||||
*/
|
||||
public function lists()
|
||||
{
|
||||
return $this->dataLists(new AdLists());
|
||||
}
|
||||
}
|
||||
40
server/app/api/controller/BaseApiController.php
Executable file
40
server/app/api/controller/BaseApiController.php
Executable file
@@ -0,0 +1,40 @@
|
||||
<?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\api\controller;
|
||||
|
||||
|
||||
use app\common\controller\BaseLikeShopController;
|
||||
|
||||
class BaseApiController extends BaseLikeShopController
|
||||
{
|
||||
protected int $userId = 0;
|
||||
protected array $userInfo = [];
|
||||
|
||||
|
||||
public function initialize()
|
||||
{
|
||||
|
||||
if (isset($this->request->userInfo) && $this->request->userInfo) {
|
||||
$this->userInfo = $this->request->userInfo;
|
||||
$this->userId = $this->request->userInfo['user_id'];
|
||||
}
|
||||
}
|
||||
}
|
||||
21
server/app/api/controller/CityController.php
Executable file
21
server/app/api/controller/CityController.php
Executable file
@@ -0,0 +1,21 @@
|
||||
<?php
|
||||
namespace app\api\controller;
|
||||
use app\api\logic\CityLogic;
|
||||
|
||||
class CityController extends BaseApiController
|
||||
{
|
||||
/**
|
||||
* @notes 获取城市列表
|
||||
* @return \think\response\Json
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
* @author cjhao
|
||||
* @date 2024/10/6 17:50
|
||||
*/
|
||||
public function getCityLists()
|
||||
{
|
||||
$lists = (new CityLogic())->getCityLists();
|
||||
return $this->success('',$lists);
|
||||
}
|
||||
}
|
||||
63
server/app/api/controller/CoachController.php
Executable file
63
server/app/api/controller/CoachController.php
Executable file
@@ -0,0 +1,63 @@
|
||||
<?php
|
||||
namespace app\api\controller;
|
||||
use app\api\lists\CoachLists;
|
||||
use app\api\logic\CoachLogic;
|
||||
|
||||
/**
|
||||
* 技师控制器类
|
||||
* Class CoachController
|
||||
* @package app\api\controller
|
||||
*/
|
||||
class CoachController extends BaseApiController
|
||||
{
|
||||
public array $notNeedLogin = ['skillLists','lists','detail'];
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @notes 技能列表
|
||||
* @return \think\response\Json
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
* @author cjhao
|
||||
* @date 2024/9/4 17:03
|
||||
*/
|
||||
public function skillLists()
|
||||
{
|
||||
$data = ((new CoachLogic())->skillLists());
|
||||
return $this->success('',$data);
|
||||
}
|
||||
/**
|
||||
* @notes 获取技师列表
|
||||
* @return \think\response\Json
|
||||
* @author cjhao
|
||||
* @date 2024/9/3 23:37
|
||||
*/
|
||||
public function lists()
|
||||
{
|
||||
return $this->dataLists((new CoachLists()));
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @notes 详情
|
||||
* @return \think\response\Json
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
* @author cjhao
|
||||
* @date 2024/9/4 17:05
|
||||
*/
|
||||
public function detail()
|
||||
{
|
||||
$params = $this->request->get();
|
||||
$params['user_id'] = $this->userId;
|
||||
$data = (new CoachLogic())->detail($params);
|
||||
return $this->success('',$data);
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
69
server/app/api/controller/ConfigController.php
Executable file
69
server/app/api/controller/ConfigController.php
Executable file
@@ -0,0 +1,69 @@
|
||||
<?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\controller;
|
||||
|
||||
|
||||
use app\api\logic\ConfigLogic;
|
||||
|
||||
class ConfigController extends BaseApiController
|
||||
{
|
||||
public array $notNeedLogin = ['config','agreement'];
|
||||
|
||||
|
||||
/**
|
||||
* @notes 基础配置信息
|
||||
* @return \think\response\Json
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
* @author ljj
|
||||
* @date 2022/2/23 10:31 上午
|
||||
*/
|
||||
public function config()
|
||||
{
|
||||
$result = (new ConfigLogic())->config();
|
||||
return $this->success('获取成功',$result);
|
||||
}
|
||||
|
||||
/**
|
||||
* @notes 政策协议
|
||||
* @return \think\response\Json
|
||||
* @author ljj
|
||||
* @date 2022/2/23 11:42 上午
|
||||
*/
|
||||
public function agreement()
|
||||
{
|
||||
$result = (new ConfigLogic())->agreement();
|
||||
return $this->success('获取成功',$result);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 获取客服配置
|
||||
* @return \think\response\Json
|
||||
* @author cjhao
|
||||
* @date 2024/11/1 18:16
|
||||
*/
|
||||
public function getKefuConfig()
|
||||
{
|
||||
$result = (new ConfigLogic())->getKefuConfig();
|
||||
return $this->success('',$result);
|
||||
}
|
||||
}
|
||||
53
server/app/api/controller/DecorateController.php
Executable file
53
server/app/api/controller/DecorateController.php
Executable file
@@ -0,0 +1,53 @@
|
||||
<?php
|
||||
namespace app\api\controller;
|
||||
use app\api\logic\DecorateLogic;
|
||||
|
||||
/**
|
||||
* 装修风格控制器类
|
||||
* Class DecorateController
|
||||
* @package app\api\controller
|
||||
*/
|
||||
class DecorateController extends BaseApiController
|
||||
{
|
||||
public array $notNeedLogin = ['page','style','tabbar','decorateGoods'];
|
||||
/**
|
||||
* @notes 获取装修页面
|
||||
* @return \think\response\Json
|
||||
* @author cjhao
|
||||
* @date 2024/10/8 15:13
|
||||
*/
|
||||
public function page()
|
||||
{
|
||||
$type = $this->request->get('type',1);
|
||||
$cityId = $this->request->get('city_id',0);
|
||||
$detail = (new DecorateLogic())->page($type,$cityId);
|
||||
return $this->success('',$detail);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 获取装修风格
|
||||
* @return \think\response\Json
|
||||
* @author cjhao
|
||||
* @date 2024/10/8 15:14
|
||||
*/
|
||||
public function style()
|
||||
{
|
||||
$detail = (new DecorateLogic())->style();
|
||||
return $this->success('',$detail);
|
||||
}
|
||||
|
||||
/**
|
||||
* @notes 底部菜单
|
||||
* @return \think\response\Json
|
||||
* @author cjhao
|
||||
* @date 2024/10/8 15:57
|
||||
*/
|
||||
public function tabbar()
|
||||
{
|
||||
$detail = (new DecorateLogic())->tabbar();
|
||||
return $this->success('',$detail);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
56
server/app/api/controller/GoodsCategoryController.php
Executable file
56
server/app/api/controller/GoodsCategoryController.php
Executable file
@@ -0,0 +1,56 @@
|
||||
<?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\controller;
|
||||
|
||||
|
||||
use app\api\lists\GoodsCategoryLists;
|
||||
use app\api\logic\GoodsCategoryLogic;
|
||||
|
||||
class GoodsCategoryController extends BaseApiController
|
||||
{
|
||||
public array $notNeedLogin = ['lists','otherLists'];
|
||||
|
||||
/**
|
||||
* @notes 服务分类列表
|
||||
* @return \think\response\Json
|
||||
* @author ljj
|
||||
* @date 2022/2/18 10:55 上午
|
||||
*/
|
||||
public function lists()
|
||||
{
|
||||
return $this->dataLists(new GoodsCategoryLists());
|
||||
}
|
||||
|
||||
/**
|
||||
* @notes 其它分类列表
|
||||
* @return \think\response\Json
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
* @author ljj
|
||||
* @date 2022/3/29 3:16 下午
|
||||
*/
|
||||
public function otherLists()
|
||||
{
|
||||
$id = $this->request->get('id',0);
|
||||
$result = (new GoodsCategoryLogic)->otherLists($id);
|
||||
return $this->success('',$result);
|
||||
}
|
||||
}
|
||||
116
server/app/api/controller/GoodsCommentController.php
Executable file
116
server/app/api/controller/GoodsCommentController.php
Executable file
@@ -0,0 +1,116 @@
|
||||
<?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\controller;
|
||||
|
||||
|
||||
use app\api\lists\CommentGoodsLists;
|
||||
use app\api\lists\GoodsCommentLists;
|
||||
use app\api\logic\GoodsCommentLogic;
|
||||
use app\api\validate\GoodsCommentValidate;
|
||||
|
||||
class GoodsCommentController extends BaseApiController
|
||||
{
|
||||
public array $notNeedLogin = ['lists','commentCategory'];
|
||||
|
||||
|
||||
/**
|
||||
* @notes 服务评价列表
|
||||
* @return \think\response\Json
|
||||
* @author ljj
|
||||
* @date 2022/2/18 11:24 上午
|
||||
*/
|
||||
public function lists()
|
||||
{
|
||||
return $this->dataLists(new GoodsCommentLists());
|
||||
}
|
||||
|
||||
/**
|
||||
* @notes 服务评价分类
|
||||
* @return \think\response\Json
|
||||
* @author ljj
|
||||
* @date 2022/2/18 2:10 下午
|
||||
*/
|
||||
public function commentCategory()
|
||||
{
|
||||
$params = (new GoodsCommentValidate())->get()->goCheck('CommentCategory');
|
||||
$result = (new GoodsCommentLogic())->commentCategory($params);
|
||||
return $this->success('',$result);
|
||||
}
|
||||
|
||||
/**
|
||||
* @notes 评价商品列表
|
||||
* @return \think\response\Json
|
||||
* @author ljj
|
||||
* @date 2022/2/21 6:00 下午
|
||||
*/
|
||||
public function commentGoodsLists()
|
||||
{
|
||||
return $this->dataLists(new CommentGoodsLists());
|
||||
}
|
||||
|
||||
/**
|
||||
* @notes 评价服务信息
|
||||
* @return \think\response\Json
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
* @author ljj
|
||||
* @date 2022/2/21 6:12 下午
|
||||
*/
|
||||
public function commentGoodsInfo()
|
||||
{
|
||||
$params = (new GoodsCommentValidate())->goCheck('CommentGoodsInfo',['user_id'=>$this->userId]);
|
||||
$result = (new GoodsCommentLogic())->commentGoodsInfo($params);
|
||||
return $this->success('',$result);
|
||||
}
|
||||
|
||||
/**
|
||||
* @notes 添加服务评价
|
||||
* @return \think\response\Json
|
||||
* @author ljj
|
||||
* @date 2022/2/21 6:23 下午
|
||||
*/
|
||||
public function add()
|
||||
{
|
||||
$params = (new GoodsCommentValidate())->post()->goCheck('add');
|
||||
$params['user_id'] = $this->userId;
|
||||
$result = (new GoodsCommentLogic())->add($params);
|
||||
if (false === $result) {
|
||||
return $this->fail(GoodsCommentLogic::getError());
|
||||
}
|
||||
return $this->success('评价成功',[],1,1);
|
||||
}
|
||||
|
||||
/**
|
||||
* @notes 评价详情
|
||||
* @return \think\response\Json
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
* @author ljj
|
||||
* @date 2024/7/31 下午5:37
|
||||
*/
|
||||
public function commentDetail()
|
||||
{
|
||||
$params = (new GoodsCommentValidate())->goCheck('commentDetail',['user_id'=>$this->userId]);
|
||||
$result = (new GoodsCommentLogic())->commentDetail($params);
|
||||
return $this->success('',$result);
|
||||
}
|
||||
}
|
||||
89
server/app/api/controller/GoodsController.php
Executable file
89
server/app/api/controller/GoodsController.php
Executable file
@@ -0,0 +1,89 @@
|
||||
<?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\controller;
|
||||
|
||||
|
||||
use app\api\lists\GoodsLists;
|
||||
use app\api\logic\GoodsLogic;
|
||||
use app\api\validate\GoodsValidate;
|
||||
|
||||
class GoodsController extends BaseApiController
|
||||
{
|
||||
public array $notNeedLogin = ['lists','detail'];
|
||||
|
||||
|
||||
/**
|
||||
* @notes 服务列表
|
||||
* @return \think\response\Json
|
||||
* @author ljj
|
||||
* @date 2022/2/17 5:51 下午
|
||||
*/
|
||||
public function lists()
|
||||
{
|
||||
return $this->dataLists(new GoodsLists());
|
||||
}
|
||||
|
||||
/**
|
||||
* @notes 服务详情
|
||||
* @return \think\response\Json
|
||||
* @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(): \think\response\Json
|
||||
{
|
||||
$params = (new GoodsValidate())->get()->goCheck('detail');
|
||||
$params['user_id'] = $this->userId;
|
||||
$result = (new GoodsLogic())->detail($params);
|
||||
return $this->success('获取成功',$result);
|
||||
}
|
||||
|
||||
/**
|
||||
* @notes 预约上门时间
|
||||
* @return \think\response\Json
|
||||
* @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()
|
||||
{
|
||||
$result = (new GoodsLogic())->appointTime();
|
||||
return $this->success('获取成功',$result);
|
||||
}
|
||||
|
||||
/**
|
||||
* @notes 收藏服务
|
||||
* @return \think\response\Json
|
||||
* @author ljj
|
||||
* @date 2022/3/16 4:14 下午
|
||||
*/
|
||||
public function collect()
|
||||
{
|
||||
$params = (new GoodsValidate())->post()->goCheck('collect');
|
||||
$params['user_id'] = $this->userId;
|
||||
(new GoodsLogic())->collect($params);
|
||||
return $this->success('操作成功',[],1,1);
|
||||
}
|
||||
|
||||
}
|
||||
172
server/app/api/controller/IndexController.php
Executable file
172
server/app/api/controller/IndexController.php
Executable file
@@ -0,0 +1,172 @@
|
||||
<?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\controller;
|
||||
|
||||
|
||||
use app\api\lists\IndexServerLists;
|
||||
use app\api\logic\IndexLogic;
|
||||
|
||||
class IndexController extends BaseApiController
|
||||
{
|
||||
public array $notNeedLogin = ['searchLog','getNearbyLocation','index','visit','geocoder','geocoderCoordinate','address','getNearbyCity','serverLists'];
|
||||
|
||||
/**
|
||||
* @notes 搜索记录
|
||||
* @return \think\response\Json
|
||||
* @author cjhao
|
||||
* @date 2024/9/5 10:44
|
||||
*/
|
||||
public function searchLog()
|
||||
{
|
||||
$result = (new IndexLogic())->searchLog($this->userId);
|
||||
return $this->success('',$result);
|
||||
}
|
||||
|
||||
/**
|
||||
* @notes 首页信息
|
||||
* @return \think\response\Json
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
* @author ljj
|
||||
* @date 2022/2/23 4:49 下午
|
||||
*/
|
||||
public function index()
|
||||
{
|
||||
$get = $this->request->get();
|
||||
$result = (new IndexLogic())->index($get);
|
||||
return $this->success('',$result);
|
||||
}
|
||||
|
||||
/**
|
||||
* @notes 首页访客记录
|
||||
* @author Tab
|
||||
* @date 2021/9/11 9:16
|
||||
*/
|
||||
public function visit()
|
||||
{
|
||||
$result = IndexLogic::visit();
|
||||
if ($result) {
|
||||
return $this->success('');
|
||||
}
|
||||
return $this->fail(IndexLogic::getError(), [], 0, 0);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @notes 地址解析(地址转坐标)
|
||||
* @return \think\response\Json
|
||||
* @author ljj
|
||||
* @date 2022/10/13 12:06 下午
|
||||
* 本接口提供由文字地址到经纬度的转换能力,并同时提供结构化的省市区地址信息。
|
||||
*/
|
||||
public function geocoder()
|
||||
{
|
||||
$get = $this->request->get();
|
||||
if (!isset($get['address']) || $get['address'] == '') {
|
||||
return $this->fail('地址缺失');
|
||||
}
|
||||
|
||||
$result = IndexLogic::geocoder($get);
|
||||
if ($result['status'] !== 0) {
|
||||
return $this->fail($result['message']);
|
||||
}
|
||||
return $this->success('',$result);
|
||||
}
|
||||
|
||||
/**
|
||||
* @notes 逆地址解析(坐标位置描述)
|
||||
* @return \think\response\Json
|
||||
* @author ljj
|
||||
* @date 2022/10/13 2:44 下午
|
||||
* 本接口提供由经纬度到文字地址及相关位置信息的转换能力
|
||||
*/
|
||||
public function geocoderCoordinate()
|
||||
{
|
||||
$get = $this->request->get();
|
||||
if (!isset($get['location']) || $get['location'] == '') {
|
||||
return $this->fail('经纬度缺失');
|
||||
}
|
||||
|
||||
$result = IndexLogic::geocoderCoordinate($get);
|
||||
if ($result['status'] !== 0) {
|
||||
return $this->fail($result['message']);
|
||||
}
|
||||
return $this->success('',$result);
|
||||
}
|
||||
|
||||
/**
|
||||
* @notes 搜索附近地址
|
||||
* @return \think\response\Json
|
||||
* @author ljj
|
||||
* @date 2024/7/23 上午11:21
|
||||
*/
|
||||
public function getNearbyLocation()
|
||||
{
|
||||
$params = $this->request->get();
|
||||
$result = (new IndexLogic())->getNearbyLocation($params);
|
||||
if ($result['status'] !== 0) {
|
||||
return $this->fail($result['message']);
|
||||
}
|
||||
return $this->success('',$result);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 获取当前位置最近的城市
|
||||
* @return \think\response\Json
|
||||
* @author cjhao
|
||||
* @date 2024/9/3 17:34
|
||||
*/
|
||||
public function getNearbyCity()
|
||||
{
|
||||
$params = $this->request->get();
|
||||
$result = (new IndexLogic())->getNearbyCity($params);
|
||||
if(false === $result){
|
||||
return $this->fail(IndexLogic::getError());
|
||||
}
|
||||
return $this->success('',$result);
|
||||
}
|
||||
|
||||
/**
|
||||
* @notes 获取首页的服务列表
|
||||
* @return \think\response\Json
|
||||
* @author cjhao
|
||||
* @date 2024/9/3 23:01
|
||||
*/
|
||||
public function serverLists()
|
||||
{
|
||||
return $this->dataLists((new IndexServerLists()));
|
||||
}
|
||||
|
||||
/**
|
||||
* @notes 收藏接口
|
||||
* @return \think\response\Json
|
||||
* @author cjhao
|
||||
* @date 2024/9/5 09:32
|
||||
*/
|
||||
public function collect()
|
||||
{
|
||||
$params = $this->request->post();
|
||||
(new IndexLogic())->collect($params,$this->userId);
|
||||
return $this->success('操作成功');
|
||||
}
|
||||
}
|
||||
193
server/app/api/controller/LoginController.php
Executable file
193
server/app/api/controller/LoginController.php
Executable file
@@ -0,0 +1,193 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | likeadmin快速开发前后端分离管理后台(PHP版)
|
||||
// +----------------------------------------------------------------------
|
||||
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
|
||||
// | 开源版本可自由商用,可去除界面版权logo
|
||||
// | gitee下载:https://gitee.com/likeshop_gitee/likeadmin
|
||||
// | github下载:https://github.com/likeshop-github/likeadmin
|
||||
// | 访问官网:https://www.likeadmin.cn
|
||||
// | likeadmin团队 版权所有 拥有最终解释权
|
||||
// +----------------------------------------------------------------------
|
||||
// | author: likeadminTeam
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
namespace app\api\controller;
|
||||
|
||||
use app\api\logic\LoginLogic;
|
||||
use app\api\validate\{LoginAccountValidate, RegisterValidate, WechatLoginValidate};
|
||||
|
||||
/**
|
||||
* 登录注册
|
||||
* Class LoginController
|
||||
* @package app\api\controller
|
||||
*/
|
||||
class LoginController extends BaseApiController
|
||||
{
|
||||
|
||||
public array $notNeedLogin = ['register', 'account', 'logout', 'codeUrl', 'oaLogin', 'mnpLogin'];
|
||||
|
||||
|
||||
/**
|
||||
* @notes 注册账号
|
||||
* @return \think\response\Json
|
||||
* @author 段誉
|
||||
* @date 2022/9/7 15:38
|
||||
*/
|
||||
public function register()
|
||||
{
|
||||
$params = (new RegisterValidate())->post()->goCheck('register');
|
||||
$result = LoginLogic::register($params);
|
||||
if (true === $result) {
|
||||
return $this->success('注册成功', [], 1, 1);
|
||||
}
|
||||
return $this->fail(LoginLogic::getError());
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 账号密码/手机号密码/手机号验证码登录
|
||||
* @return \think\response\Json
|
||||
* @author 段誉
|
||||
* @date 2022/9/16 10:42
|
||||
*/
|
||||
public function account()
|
||||
{
|
||||
$params = (new LoginAccountValidate())->post()->goCheck();
|
||||
$result = LoginLogic::login($params);
|
||||
if (false === $result) {
|
||||
return $this->fail(LoginLogic::getError());
|
||||
}
|
||||
return $this->data($result);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 退出登录
|
||||
* @return \think\response\Json
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
* @author 段誉
|
||||
* @date 2022/9/16 10:42
|
||||
*/
|
||||
public function logout()
|
||||
{
|
||||
LoginLogic::logout($this->userInfo);
|
||||
return $this->success();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 获取微信请求code的链接
|
||||
* @return \think\response\Json
|
||||
* @author 段誉
|
||||
* @date 2022/9/15 18:27
|
||||
*/
|
||||
public function codeUrl()
|
||||
{
|
||||
$url = $this->request->get('url');
|
||||
$result = ['url' => LoginLogic::codeUrl($url)];
|
||||
return $this->success('获取成功', $result);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 公众号登录
|
||||
* @return \think\response\Json
|
||||
* @throws \GuzzleHttp\Exception\GuzzleException
|
||||
* @author 段誉
|
||||
* @date 2022/9/20 19:48
|
||||
*/
|
||||
public function oaLogin()
|
||||
{
|
||||
$params = (new WechatLoginValidate())->post()->goCheck('oa');
|
||||
$res = LoginLogic::oaLogin($params);
|
||||
if (false === $res) {
|
||||
return $this->fail(LoginLogic::getError());
|
||||
}
|
||||
return $this->success('', $res);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 小程序-登录接口
|
||||
* @return \think\response\Json
|
||||
* @author 段誉
|
||||
* @date 2022/9/20 19:48
|
||||
*/
|
||||
public function mnpLogin()
|
||||
{
|
||||
$params = (new WechatLoginValidate())->post()->goCheck('mnpLogin');
|
||||
$res = LoginLogic::mnpLogin($params);
|
||||
if (false === $res) {
|
||||
return $this->fail(LoginLogic::getError());
|
||||
}
|
||||
return $this->success('', $res);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 小程序绑定微信
|
||||
* @return \think\response\Json
|
||||
* @author 段誉
|
||||
* @date 2022/9/20 19:48
|
||||
*/
|
||||
public function mnpAuthBind()
|
||||
{
|
||||
$params = (new WechatLoginValidate())->post()->goCheck("wechatAuth");
|
||||
$params['user_id'] = $this->userId;
|
||||
$result = LoginLogic::mnpAuthLogin($params);
|
||||
if ($result === false) {
|
||||
return $this->fail(LoginLogic::getError());
|
||||
}
|
||||
return $this->success('绑定成功', [], 1, 1);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @notes 公众号绑定微信
|
||||
* @return \think\response\Json
|
||||
* @throws \GuzzleHttp\Exception\GuzzleException
|
||||
* @author 段誉
|
||||
* @date 2022/9/20 19:48
|
||||
*/
|
||||
public function oaAuthBind()
|
||||
{
|
||||
$params = (new WechatLoginValidate())->post()->goCheck("wechatAuth");
|
||||
$params['user_id'] = $this->userId;
|
||||
$result = LoginLogic::oaAuthLogin($params);
|
||||
if ($result === false) {
|
||||
return $this->fail(LoginLogic::getError());
|
||||
}
|
||||
return $this->success('绑定成功', [], 1, 1);
|
||||
}
|
||||
|
||||
/**
|
||||
* @notes 解绑微信(测试用)
|
||||
* @return \think\response\Json
|
||||
* @author ljj
|
||||
* @date 2023/1/11 10:35 上午
|
||||
*/
|
||||
public function unbinding()
|
||||
{
|
||||
LoginLogic::unbinding($this->userId);
|
||||
return $this->success('解绑成功', [], 1, 1);
|
||||
}
|
||||
|
||||
/**
|
||||
* @notes 更新用户头像昵称
|
||||
* @return \think\response\Json
|
||||
* @throws \think\db\exception\DbException
|
||||
* @author ljj
|
||||
* @date 2023/2/2 6:36 下午
|
||||
*/
|
||||
public function updateUser()
|
||||
{
|
||||
$params = (new WechatLoginValidate())->post()->goCheck("updateUser");
|
||||
LoginLogic::updateUser($params,$this->userId);
|
||||
|
||||
return $this->success('操作成功',[],1,1);
|
||||
}
|
||||
}
|
||||
235
server/app/api/controller/OrderController.php
Executable file
235
server/app/api/controller/OrderController.php
Executable file
@@ -0,0 +1,235 @@
|
||||
<?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\controller;
|
||||
|
||||
|
||||
use app\api\lists\OrderLists;
|
||||
use app\api\logic\OrderLogic;
|
||||
use app\api\validate\OrderAppendValidate;
|
||||
use app\api\validate\OrderCommentValidate;
|
||||
use app\api\validate\OrderGapValidate;
|
||||
use app\api\validate\OrderValidate;
|
||||
use app\api\validate\PlaceOrderValidate;
|
||||
use app\common\service\ConfigService;
|
||||
use app\common\service\storage\Driver as StorageDriver;
|
||||
use Exception;
|
||||
|
||||
/**
|
||||
* 订单控制器类
|
||||
* Class OrderController
|
||||
* @package app\api\controller
|
||||
*/
|
||||
class OrderController extends BaseApiController
|
||||
{
|
||||
public array $notNeedLogin = ['test'];
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @notes 提交订单
|
||||
* @return \think\response\Json
|
||||
* @author ljj
|
||||
* @date 2022/2/25 10:12 上午
|
||||
*/
|
||||
public function placeOrder()
|
||||
{
|
||||
$data = [
|
||||
'terminal' => $this->userInfo['terminal'],
|
||||
'user_id'=> $this->userId
|
||||
];
|
||||
$params = (new PlaceOrderValidate())->post()->goCheck('', $data);
|
||||
//订单结算信息
|
||||
$settlement = (new OrderLogic())->settlement($params);
|
||||
if (false === $settlement) {
|
||||
return $this->fail(OrderLogic::getError());
|
||||
}
|
||||
//结算信息
|
||||
if ($params['action'] == 'settlement') {
|
||||
unset($settlement['city']);
|
||||
return $this->data($settlement);
|
||||
}
|
||||
//提交订单
|
||||
$result = (new OrderLogic())->submitOrder($settlement);
|
||||
if (false === $result) {
|
||||
return $this->fail(OrderLogic::getError());
|
||||
}
|
||||
return $this->data($result);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 获取技师服务时间
|
||||
* @return \think\response\Json
|
||||
* @author cjhao
|
||||
* @date 2024/9/14 14:03
|
||||
*/
|
||||
public function getCoachServerTime()
|
||||
{
|
||||
$coachId = $this->request->get('coach_id');
|
||||
$goodsId = $this->request->get('goods_id');
|
||||
$result = (new OrderLogic())->getCoachServerTime($coachId,$goodsId);
|
||||
if (false === $result) {
|
||||
return $this->fail(OrderLogic::getError());
|
||||
}
|
||||
return $this->data($result);
|
||||
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @notes 订单列表
|
||||
* @return \think\response\Json
|
||||
* @author ljj
|
||||
* @date 2022/2/28 10:01 上午
|
||||
*/
|
||||
public function lists()
|
||||
{
|
||||
return $this->dataLists(new OrderLists());
|
||||
}
|
||||
|
||||
/**
|
||||
* @notes 订单详情
|
||||
* @return \think\response\Json
|
||||
* @author ljj
|
||||
* @date 2022/2/28 11:23 上午
|
||||
*/
|
||||
public function detail()
|
||||
{
|
||||
$params = (new OrderValidate())->get()->goCheck('detail');
|
||||
$result = (new OrderLogic())->detail($params['id']);
|
||||
return $this->success('',$result);
|
||||
}
|
||||
|
||||
/**
|
||||
* @notes 取消订单
|
||||
* @return \think\response\Json
|
||||
* @author ljj
|
||||
* @date 2022/2/28 11:36 上午
|
||||
*/
|
||||
public function cancel()
|
||||
{
|
||||
$params = (new OrderValidate())->post()->goCheck('cancel');
|
||||
$params['user_id'] = $this->userId;
|
||||
$result = (new OrderLogic())->cancel($params);
|
||||
if (true !== $result) {
|
||||
return $this->fail($result);
|
||||
}
|
||||
return $this->success('操作成功',[],1,1);
|
||||
}
|
||||
|
||||
/**
|
||||
* @notes 删除订单
|
||||
* @return \think\response\Json
|
||||
* @author ljj
|
||||
* @date 2022/2/28 11:50 上午
|
||||
*/
|
||||
public function del()
|
||||
{
|
||||
$params = (new OrderValidate())->post()->goCheck('del');
|
||||
(new OrderLogic())->del($params['id']);
|
||||
return $this->success('操作成功',[],1,1);
|
||||
}
|
||||
|
||||
/**
|
||||
* @notes 支付方式
|
||||
* @return \think\response\Json
|
||||
* @author ljj
|
||||
* @date 2024/7/24 下午7:08
|
||||
*/
|
||||
public function payWay()
|
||||
{
|
||||
$params = (new OrderValidate())->get()->goCheck('payWay',['user_id'=>$this->userId]);
|
||||
$result = OrderLogic::payWay($params);
|
||||
if(false === $result){
|
||||
return $this->fail(OrderLogic::getError());
|
||||
}
|
||||
return $this->data($result);
|
||||
}
|
||||
|
||||
/**
|
||||
* @notes 订单补差价
|
||||
* @return \think\response\Json
|
||||
* @author cjhao
|
||||
* @date 2024/9/18 12:34
|
||||
*/
|
||||
public function orderGap()
|
||||
{
|
||||
$params = (new OrderGapValidate())->post()->goCheck('',['user_id'=>$this->userId]);
|
||||
$result = (new OrderLogic())->orderGap($params);
|
||||
if (false === $result) {
|
||||
return $this->fail(OrderLogic::getError());
|
||||
}
|
||||
return $this->data($result);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 订单加钟
|
||||
* @return \think\response\Json
|
||||
* @author cjhao
|
||||
* @date 2024/9/18 13:45
|
||||
*/
|
||||
public function orderAppend()
|
||||
{
|
||||
$params = (new OrderAppendValidate())->post()->goCheck('',['user_id'=>$this->userId]);
|
||||
$result = (new OrderLogic())->orderAppend($params);
|
||||
if (false === $result) {
|
||||
return $this->fail(OrderLogic::getError());
|
||||
}
|
||||
return $this->data($result);
|
||||
}
|
||||
|
||||
/**
|
||||
* @notes 订单评论
|
||||
* @return \think\response\Json
|
||||
* @author cjhao
|
||||
* @date 2024/9/24 20:43
|
||||
*/
|
||||
public function comment()
|
||||
{
|
||||
$params = (new OrderCommentValidate())->post()->goCheck('',['user_id'=>$this->userId]);
|
||||
$result = (new OrderLogic())->comment($params);
|
||||
if (false === $result) {
|
||||
return $this->fail(OrderLogic::getError());
|
||||
}
|
||||
return $this->success('评论成功',[],1,1,);
|
||||
|
||||
}
|
||||
|
||||
public function test(){
|
||||
// 存储引擎
|
||||
$config = [
|
||||
'default' => ConfigService::get('storage', 'default', 'local'),
|
||||
'engine' => ConfigService::get('storage')
|
||||
];
|
||||
|
||||
// 第三方存储
|
||||
$avatar = 'uploads/user/avatar/' . md5(22 . time()) . '.jpeg';
|
||||
$headimgurl = 'https://thirdwx.qlogo.cn/mmopen/vi_32/PiajxSqBRaEK0ymicw4pcTUx7ZZaQrsnK46O8atVibKY4WbcBpaic9rUapwlul4fJXx87EgkYQwypzYNnAib3evXM9hU8a54IMtE02OXNeAxxDCXmmGKUmwbCbw/132';
|
||||
$StorageDriver = new StorageDriver($config);
|
||||
dd($StorageDriver->fetch($headimgurl, $avatar));
|
||||
if (!$StorageDriver->fetch($headimgurl, $avatar)) {
|
||||
throw new Exception('头像保存失败:' . $StorageDriver->getError());
|
||||
}
|
||||
dd(123);
|
||||
}
|
||||
|
||||
}
|
||||
128
server/app/api/controller/PayController.php
Executable file
128
server/app/api/controller/PayController.php
Executable file
@@ -0,0 +1,128 @@
|
||||
<?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\controller;
|
||||
|
||||
|
||||
use app\api\logic\PayLogic;
|
||||
use app\api\validate\PayValidate;
|
||||
use app\common\enum\user\UserTerminalEnum;
|
||||
use app\common\service\AliPayService;
|
||||
use app\common\service\WeChatPayService;
|
||||
use think\facade\Log;
|
||||
|
||||
class PayController extends BaseApiController
|
||||
{
|
||||
public array $notNeedLogin = ['notifyMnp','notifyOa','aliNotify'];
|
||||
|
||||
|
||||
/**
|
||||
* @notes 支付方式
|
||||
* @return \think\response\Json
|
||||
* @author ljj
|
||||
* @date 2022/2/28 2:56 下午
|
||||
*/
|
||||
public function payWay()
|
||||
{
|
||||
$params = (new PayValidate())->get()->goCheck('payWay',['user_id'=>$this->userId]);
|
||||
$result = PayLogic::payWay($params);
|
||||
if ($result === false) {
|
||||
return $this->fail(PayLogic::getError());
|
||||
}
|
||||
return $this->data($result);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 预支付
|
||||
* @return \think\response\Json
|
||||
* @throws \Exception
|
||||
* @author ljj
|
||||
* @date 2022/3/1 11:20 上午
|
||||
*/
|
||||
public function prepay()
|
||||
{
|
||||
$params = (new PayValidate())->post()->goCheck('prepay');
|
||||
//支付流程
|
||||
$result = PayLogic::pay($params['pay_way'], $params['from'], $params['order_id'], $this->userInfo['terminal']);
|
||||
if (false === $result) {
|
||||
return $this->fail(PayLogic::getError(), $params);
|
||||
}
|
||||
return $this->success('', $result);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 小程序支付回调
|
||||
* @return \Symfony\Component\HttpFoundation\Response
|
||||
* @author 段誉
|
||||
* @date 2021/8/13 14:17
|
||||
*/
|
||||
public function notifyMnp()
|
||||
{
|
||||
return (new WeChatPayService(UserTerminalEnum::WECHAT_MMP))->notify();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 公众号支付回调
|
||||
* @return \Symfony\Component\HttpFoundation\Response
|
||||
* @author 段誉
|
||||
* @date 2021/8/13 14:17
|
||||
*/
|
||||
public function notifyOa()
|
||||
{
|
||||
return (new WeChatPayService(UserTerminalEnum::WECHAT_OA))->notify();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 支付宝回调
|
||||
* @return bool
|
||||
* @author 段誉
|
||||
* @date 2021/8/13 14:16
|
||||
*/
|
||||
public function aliNotify()
|
||||
{
|
||||
$params = $this->request->post();
|
||||
$result = (new AliPayService())->notify($params);
|
||||
if (true === $result) {
|
||||
echo 'success';
|
||||
} else {
|
||||
echo 'fail';
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @notes 获取支付结果
|
||||
* @return \think\response\Json
|
||||
* @author ljj
|
||||
* @date 2024/3/21 5:49 下午
|
||||
*/
|
||||
public function getPayResult()
|
||||
{
|
||||
$params = (new PayValidate())->get()->goCheck('getPayResult');
|
||||
//支付流程
|
||||
$result = PayLogic::getPayResult($params);
|
||||
if (false === $result) {
|
||||
return $this->fail(PayLogic::getError());
|
||||
}
|
||||
return $this->success('', $result);
|
||||
}
|
||||
}
|
||||
53
server/app/api/controller/RechargeController.php
Executable file
53
server/app/api/controller/RechargeController.php
Executable file
@@ -0,0 +1,53 @@
|
||||
<?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\controller;
|
||||
|
||||
|
||||
use app\api\lists\RechargeLists;
|
||||
use app\api\logic\RechargeLogic;
|
||||
use app\api\validate\RechargeValidate;
|
||||
|
||||
class RechargeController extends BaseApiController
|
||||
{
|
||||
/**
|
||||
* @notes 充值
|
||||
* @return \think\response\Json
|
||||
* @throws \think\Exception
|
||||
* @author ljj
|
||||
* @date 2022/12/16 16:03
|
||||
*/
|
||||
public function recharge()
|
||||
{
|
||||
$params = (new RechargeValidate())->post()->goCheck('recharge',['user_id'=>$this->userId,'terminal'=>$this->userInfo['terminal']]);
|
||||
$result = (new RechargeLogic())->recharge($params);
|
||||
return $this->success('',$result);
|
||||
}
|
||||
|
||||
/**
|
||||
* @notes 充值记录列表
|
||||
* @return \think\response\Json
|
||||
* @author ljj
|
||||
* @date 2022/6/9 3:13 下午
|
||||
*/
|
||||
public function logLists()
|
||||
{
|
||||
return $this->dataLists(new RechargeLists());
|
||||
}
|
||||
}
|
||||
60
server/app/api/controller/RegionController.php
Executable file
60
server/app/api/controller/RegionController.php
Executable file
@@ -0,0 +1,60 @@
|
||||
<?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\controller;
|
||||
|
||||
|
||||
use app\common\logic\RegionLogic;
|
||||
|
||||
class RegionController extends BaseApiController
|
||||
{
|
||||
public array $notNeedLogin = ['region','city'];
|
||||
|
||||
/**
|
||||
* @notes 地区
|
||||
* @return \think\response\Json
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
* @author ljj
|
||||
* @date 2022/4/6 10:51 上午
|
||||
*/
|
||||
public function region()
|
||||
{
|
||||
$params = $this->request->get();
|
||||
$result = (new RegionLogic())->region($params);
|
||||
return $this->success('获取成功',$result);
|
||||
}
|
||||
|
||||
/**
|
||||
* @notes 地级市列表
|
||||
* @return \think\response\Json
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
* @author ljj
|
||||
* @date 2022/4/6 2:41 下午
|
||||
*/
|
||||
public function city()
|
||||
{
|
||||
$params = $this->request->get();
|
||||
$result = (new RegionLogic())->city($params);
|
||||
return $this->success('获取成功',$result);
|
||||
}
|
||||
}
|
||||
74
server/app/api/controller/RegisterController.php
Executable file
74
server/app/api/controller/RegisterController.php
Executable file
@@ -0,0 +1,74 @@
|
||||
<?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\api\controller;
|
||||
|
||||
use app\api\logic\RegisterLogic;
|
||||
use app\api\validate\RegisterValidate;
|
||||
use app\common\enum\notice\NoticeEnum;
|
||||
|
||||
/**
|
||||
* 注册控制器
|
||||
* Class RegisterController
|
||||
* @package app\api\controller
|
||||
*/
|
||||
class RegisterController extends BaseApiController
|
||||
{
|
||||
public array $notNeedLogin = ['captcha', 'register'];
|
||||
|
||||
/**
|
||||
* @notes 发送验证码 - 注册
|
||||
* @author Tab
|
||||
* @date 2021/8/25 11:20
|
||||
*/
|
||||
public function captcha()
|
||||
{
|
||||
$params = (new RegisterValidate())->post()->goCheck('captcha');
|
||||
$code = mt_rand(1000, 9999);
|
||||
$result = event('Notice', [
|
||||
'scene_id' => NoticeEnum::LOGIN_CAPTCHA,
|
||||
'params' => [
|
||||
'mobile' => $params['mobile'],
|
||||
'code' => $code,
|
||||
]
|
||||
]);
|
||||
|
||||
if ($result[0] === true) {
|
||||
return $this->success('发送成功',[],1,1);
|
||||
}
|
||||
|
||||
return $this->fail($result[0], [], 0, 1);
|
||||
}
|
||||
|
||||
/**
|
||||
* @notes 手机号注册
|
||||
* @return \think\response\Json
|
||||
* @author Tab
|
||||
* @date 2021/8/25 11:47
|
||||
*/
|
||||
public function register()
|
||||
{
|
||||
$params = (new RegisterValidate())->post()->goCheck('register');
|
||||
$result = RegisterLogic::register($params);
|
||||
if($result) {
|
||||
return $this->success('注册成功', [], 1, 1);
|
||||
}
|
||||
return $this->fail(RegisterLogic::getError());
|
||||
}
|
||||
}
|
||||
41
server/app/api/controller/SearchController.php
Executable file
41
server/app/api/controller/SearchController.php
Executable file
@@ -0,0 +1,41 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | likeadmin快速开发前后端分离管理后台(PHP版)
|
||||
// +----------------------------------------------------------------------
|
||||
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
|
||||
// | 开源版本可自由商用,可去除界面版权logo
|
||||
// | gitee下载:https://gitee.com/likeshop_gitee/likeadmin
|
||||
// | github下载:https://github.com/likeshop-github/likeadmin
|
||||
// | 访问官网:https://www.likeadmin.cn
|
||||
// | likeadmin团队 版权所有 拥有最终解释权
|
||||
// +----------------------------------------------------------------------
|
||||
// | author: likeadminTeam
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
namespace app\api\controller;
|
||||
|
||||
|
||||
use app\api\logic\SearchLogic;
|
||||
|
||||
/**
|
||||
* 搜索
|
||||
* Class HotSearchController
|
||||
* @package app\api\controller
|
||||
*/
|
||||
class SearchController extends BaseApiController
|
||||
{
|
||||
|
||||
public array $notNeedLogin = ['hotLists'];
|
||||
|
||||
/**
|
||||
* @notes 热门搜素
|
||||
* @return \think\response\Json
|
||||
* @author 段誉
|
||||
* @date 2022/9/22 10:14
|
||||
*/
|
||||
public function hotLists()
|
||||
{
|
||||
return $this->data(SearchLogic::hotLists());
|
||||
}
|
||||
|
||||
}
|
||||
49
server/app/api/controller/ShareController.php
Executable file
49
server/app/api/controller/ShareController.php
Executable file
@@ -0,0 +1,49 @@
|
||||
<?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\api\controller;
|
||||
|
||||
use app\api\logic\ShareLogic;
|
||||
use app\api\validate\ShareValidate;
|
||||
|
||||
/**
|
||||
* 分享控制器
|
||||
* Class ShareController
|
||||
* @package app\shopapi\controller
|
||||
*/
|
||||
class ShareController extends BaseApiController
|
||||
{
|
||||
public array $notNeedLogin = ['getMnpQrCode'];
|
||||
|
||||
/**
|
||||
* @notes 获取小程序码
|
||||
* @return \think\response\Json
|
||||
* @author ljj
|
||||
* @date 2023/2/28 5:08 下午
|
||||
*/
|
||||
public function getMnpQrCode()
|
||||
{
|
||||
$params = (new ShareValidate())->goCheck('getMnpQrCode');
|
||||
$res = (new ShareLogic())->getMnpQrCode($params);
|
||||
if(true !== $res){
|
||||
return $this->fail(ShareLogic::getReturnData());
|
||||
}
|
||||
return $this->success('获取成功',['qr_code'=>ShareLogic::getReturnData()]);
|
||||
|
||||
}
|
||||
}
|
||||
65
server/app/api/controller/ShopController.php
Executable file
65
server/app/api/controller/ShopController.php
Executable file
@@ -0,0 +1,65 @@
|
||||
<?php
|
||||
namespace app\api\controller;
|
||||
use app\api\lists\ShopCommentGoodsLists;
|
||||
use app\api\lists\ShopLists;
|
||||
use app\api\logic\ShopLogic;
|
||||
|
||||
/**
|
||||
* 门店控制器类
|
||||
* Class ShopController
|
||||
* @package app\api\controller
|
||||
*/
|
||||
class ShopController extends BaseApiController
|
||||
{
|
||||
public array $notNeedLogin = ['lists','detail','commentCategory','commentLists'];
|
||||
|
||||
/**
|
||||
* @notes 商家列表
|
||||
* @return \think\response\Json
|
||||
* @author cjhao
|
||||
* @date 2024/11/20 20:40
|
||||
*/
|
||||
public function lists()
|
||||
{
|
||||
return $this->dataLists((new ShopLists()));
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 门店详情
|
||||
* @return \think\response\Json
|
||||
* @author cjhao
|
||||
* @date 2024/10/18 01:54
|
||||
*/
|
||||
public function detail(){
|
||||
$params = $this->request->get();
|
||||
$detail = (new ShopLogic())->detail($params,$this->userInfo);
|
||||
return $this->success('',$detail);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 分类列表
|
||||
* @return \think\response\Json
|
||||
* @author cjhao
|
||||
* @date 2024/10/28 15:26
|
||||
*/
|
||||
public function commentCategory()
|
||||
{
|
||||
$shopId = $this->request->get('shop_id');
|
||||
$lists = (new ShopLogic())->commentCategory($shopId);
|
||||
return $this->success('',$lists);
|
||||
}
|
||||
|
||||
/**
|
||||
* @notes 分类列表
|
||||
* @return \think\response\Json
|
||||
* @author cjhao
|
||||
* @date 2024/10/28 16:06
|
||||
*/
|
||||
public function commentLists()
|
||||
{
|
||||
return $this->dataLists((new ShopCommentGoodsLists()));
|
||||
}
|
||||
}
|
||||
49
server/app/api/controller/SmsController.php
Executable file
49
server/app/api/controller/SmsController.php
Executable file
@@ -0,0 +1,49 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | likeadmin快速开发前后端分离管理后台(PHP版)
|
||||
// +----------------------------------------------------------------------
|
||||
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
|
||||
// | 开源版本可自由商用,可去除界面版权logo
|
||||
// | gitee下载:https://gitee.com/likeshop_gitee/likeadmin
|
||||
// | github下载:https://github.com/likeshop-github/likeadmin
|
||||
// | 访问官网:https://www.likeadmin.cn
|
||||
// | likeadmin团队 版权所有 拥有最终解释权
|
||||
// +----------------------------------------------------------------------
|
||||
// | author: likeadminTeam
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
namespace app\api\controller;
|
||||
|
||||
|
||||
use app\api\validate\SendSmsValidate;
|
||||
use app\common\logic\SmsLogic;
|
||||
|
||||
|
||||
/**
|
||||
* 短信
|
||||
* Class SmsController
|
||||
* @package app\api\controller
|
||||
*/
|
||||
class SmsController extends BaseApiController
|
||||
{
|
||||
|
||||
public array $notNeedLogin = ['sendCode'];
|
||||
|
||||
|
||||
/**
|
||||
* @notes 发送短信验证码
|
||||
* @return \think\response\Json
|
||||
* @author 段誉
|
||||
* @date 2022/9/15 16:17
|
||||
*/
|
||||
public function sendCode()
|
||||
{
|
||||
$params = (new SendSmsValidate())->post()->goCheck();
|
||||
$result = SmsLogic::sendCode($params);
|
||||
if (true === $result) {
|
||||
return $this->success('发送成功');
|
||||
}
|
||||
return $this->fail(SmsLogic::getError());
|
||||
}
|
||||
|
||||
}
|
||||
35
server/app/api/controller/SubscribeController.php
Executable file
35
server/app/api/controller/SubscribeController.php
Executable file
@@ -0,0 +1,35 @@
|
||||
<?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\api\controller;
|
||||
|
||||
use app\api\logic\SubscribeLogic;
|
||||
|
||||
/**
|
||||
* 小程序订阅消息
|
||||
*/
|
||||
class SubscribeController extends BaseApiController
|
||||
{
|
||||
public array $notNeedLogin = ['lists'];
|
||||
|
||||
public function lists()
|
||||
{
|
||||
$result = SubscribeLogic::lists();
|
||||
return $this->data($result);
|
||||
}
|
||||
}
|
||||
48
server/app/api/controller/UploadController.php
Executable file
48
server/app/api/controller/UploadController.php
Executable file
@@ -0,0 +1,48 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | likeadmin快速开发前后端分离管理后台(PHP版)
|
||||
// +----------------------------------------------------------------------
|
||||
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
|
||||
// | 开源版本可自由商用,可去除界面版权logo
|
||||
// | gitee下载:https://gitee.com/likeshop_gitee/likeadmin
|
||||
// | github下载:https://github.com/likeshop-github/likeadmin
|
||||
// | 访问官网:https://www.likeadmin.cn
|
||||
// | likeadmin团队 版权所有 拥有最终解释权
|
||||
// +----------------------------------------------------------------------
|
||||
// | author: likeadminTeam
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
namespace app\api\controller;
|
||||
|
||||
use app\common\enum\FileEnum;
|
||||
use app\common\service\UploadService;
|
||||
use Exception;
|
||||
use think\response\Json;
|
||||
|
||||
|
||||
/** 上传文件
|
||||
* Class UploadController
|
||||
* @package app\api\controller
|
||||
*/
|
||||
class UploadController extends BaseApiController
|
||||
{
|
||||
|
||||
/**
|
||||
* @notes 上传图片
|
||||
* @return Json
|
||||
* @author 段誉
|
||||
* @date 2022/9/20 18:11
|
||||
*/
|
||||
public function image()
|
||||
{
|
||||
try {
|
||||
$result = UploadService::image(0, $this->userId,FileEnum::SOURCE_USER);
|
||||
return $this->success('上传成功', $result);
|
||||
} catch (Exception $e) {
|
||||
return $this->fail($e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
111
server/app/api/controller/UserAddressController.php
Executable file
111
server/app/api/controller/UserAddressController.php
Executable file
@@ -0,0 +1,111 @@
|
||||
<?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\controller;
|
||||
|
||||
|
||||
use app\api\logic\UserAddressLogic;
|
||||
use app\api\validate\UserAddressValidate;
|
||||
|
||||
class UserAddressController extends BaseApiController
|
||||
{
|
||||
/**
|
||||
* @notes 地址列表
|
||||
* @return \think\response\Json
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
* @author ljj
|
||||
* @date 2022/2/24 10:45 上午
|
||||
*/
|
||||
public function lists()
|
||||
{
|
||||
$params = $this->request->get();
|
||||
$result = (new UserAddressLogic())->lists($this->userId,$params);
|
||||
return $this->success('',$result);
|
||||
}
|
||||
|
||||
/**
|
||||
* @notes 添加地址
|
||||
* @return \think\response\Json
|
||||
* @author ljj
|
||||
* @date 2022/2/24 10:52 上午
|
||||
*/
|
||||
public function add()
|
||||
{
|
||||
$params = (new UserAddressValidate())->post()->goCheck('add');
|
||||
$params['user_id'] = $this->userId;
|
||||
(new UserAddressLogic())->add($params);
|
||||
return $this->success('操作成功',[],1,1);
|
||||
}
|
||||
|
||||
/**
|
||||
* @notes 地址详情
|
||||
* @return \think\response\Json
|
||||
* @author ljj
|
||||
* @date 2022/2/24 11:56 上午
|
||||
*/
|
||||
public function detail()
|
||||
{
|
||||
$id = $this->request->get('id');
|
||||
$result = (new UserAddressLogic())->detail($id);
|
||||
return $this->success('',$result);
|
||||
}
|
||||
|
||||
/**
|
||||
* @notes 编辑地址
|
||||
* @return \think\response\Json
|
||||
* @author ljj
|
||||
* @date 2022/2/24 11:59 上午
|
||||
*/
|
||||
public function edit()
|
||||
{
|
||||
$params = (new UserAddressValidate())->post()->goCheck('edit');
|
||||
$params['user_id'] = $this->userId;
|
||||
(new UserAddressLogic())->edit($params);
|
||||
return $this->success('操作成功',[],1,1);
|
||||
}
|
||||
|
||||
/**
|
||||
* @notes 设置默认地址
|
||||
* @return \think\response\Json
|
||||
* @author ljj
|
||||
* @date 2022/2/24 12:08 下午
|
||||
*/
|
||||
public function setDefault()
|
||||
{
|
||||
$params['id'] = $this->request->post('id');
|
||||
$params['user_id'] = $this->userId;
|
||||
(new UserAddressLogic())->setDefault($params);
|
||||
return $this->success('操作成功',[],1,1);
|
||||
}
|
||||
|
||||
/**
|
||||
* @notes 删除地址
|
||||
* @return \think\response\Json
|
||||
* @author ljj
|
||||
* @date 2022/2/24 2:35 下午
|
||||
*/
|
||||
public function del()
|
||||
{
|
||||
$id = $this->request->post('id');
|
||||
(new UserAddressLogic())->del($id);
|
||||
return $this->success('操作成功',[],1,1);
|
||||
}
|
||||
}
|
||||
294
server/app/api/controller/UserController.php
Executable file
294
server/app/api/controller/UserController.php
Executable file
@@ -0,0 +1,294 @@
|
||||
<?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\controller;
|
||||
|
||||
|
||||
use app\api\lists\CollectLists;
|
||||
use app\api\logic\UserLogic;
|
||||
use app\api\validate\PasswordValidate;
|
||||
use app\api\validate\UserValidate;
|
||||
use app\common\enum\notice\NoticeEnum;
|
||||
|
||||
class UserController extends BaseApiController
|
||||
{
|
||||
public array $notNeedLogin = ['customerService','resetPasswordCaptcha','resetPassword'];
|
||||
|
||||
|
||||
/**
|
||||
* @notes 用户中心
|
||||
* @return \think\response\Json
|
||||
* @author ljj
|
||||
* @date 2022/2/23 5:25 下午
|
||||
*/
|
||||
public function center()
|
||||
{
|
||||
$result = (new UserLogic())->center($this->userInfo);
|
||||
return $this->success('',$result);
|
||||
}
|
||||
|
||||
/**
|
||||
* @notes 收藏列表
|
||||
* @return \think\response\Json
|
||||
* @author cjhao
|
||||
* @date 2024/10/17 15:14
|
||||
*/
|
||||
public function collectLists()
|
||||
{
|
||||
return $this->dataLists(new CollectLists());
|
||||
}
|
||||
|
||||
/**
|
||||
* @notes 客服配置
|
||||
* @return \think\response\Json
|
||||
* @author ljj
|
||||
* @date 2022/2/24 2:53 下午
|
||||
*/
|
||||
public function customerService()
|
||||
{
|
||||
$result = (new UserLogic())->customerService();
|
||||
return $this->success('',$result);
|
||||
}
|
||||
|
||||
// /**
|
||||
// * @notes 用户收藏列表
|
||||
// * @return \think\response\Json
|
||||
// * @author ljj
|
||||
// * @date 2022/2/24 3:07 下午
|
||||
// */
|
||||
// public function collectLists()
|
||||
// {
|
||||
// $lists = (new UserLogic())->collectLists($this->userId);
|
||||
// return $this->success('',$lists);
|
||||
// }
|
||||
|
||||
/**
|
||||
* @notes 用户信息
|
||||
* @return \think\response\Json
|
||||
* @author ljj
|
||||
* @date 2022/3/7 5:53 下午
|
||||
*/
|
||||
public function info()
|
||||
{
|
||||
$code = $this->request->get('code');
|
||||
$result = UserLogic::info($this->userId,$code);
|
||||
if(false === $result){
|
||||
return $this->fail(UserLogic::getError());
|
||||
}
|
||||
return $this->data($result);
|
||||
}
|
||||
|
||||
/**
|
||||
* @notes 设置用户信息
|
||||
* @return \think\response\Json
|
||||
* @author ljj
|
||||
* @date 2022/2/24 3:44 下午
|
||||
*/
|
||||
public function setInfo()
|
||||
{
|
||||
$params = (new UserValidate())->post()->goCheck('setInfo', ['id' => $this->userId]);
|
||||
(new UserLogic)->setInfo($this->userId, $params);
|
||||
return $this->success('操作成功', [],1,1);
|
||||
}
|
||||
|
||||
/**
|
||||
* @notes 获取微信手机号并绑定
|
||||
* @return \think\response\Json
|
||||
* @author ljj
|
||||
* @date 2022/2/24 4:41 下午
|
||||
*/
|
||||
public function getMobileByMnp()
|
||||
{
|
||||
$params = (new UserValidate())->post()->goCheck('getMobileByMnp');
|
||||
$params['user_id'] = $this->userId;
|
||||
$result = UserLogic::getMobileByMnp($params);
|
||||
if($result === false) {
|
||||
return $this->fail(UserLogic::getError());
|
||||
}
|
||||
return $this->success('操作成功', [], 1, 1);
|
||||
}
|
||||
|
||||
/**
|
||||
* @notes 发送验证码 - 重置登录密码
|
||||
* @author Tab
|
||||
* @date 2021/8/25 16:33
|
||||
*/
|
||||
public function resetPasswordCaptcha()
|
||||
{
|
||||
$params = (new UserValidate())->post()->goCheck('resetPasswordCaptcha');
|
||||
$code = mt_rand(1000, 9999);
|
||||
$result = event('Notice', [
|
||||
'scene_id' => NoticeEnum::RESET_PASSWORD_CAPTCHA,
|
||||
'params' => [
|
||||
'user_id' => $this->userId,
|
||||
'code' => $code,
|
||||
'mobile' => $params['mobile']
|
||||
]
|
||||
]);
|
||||
if ($result[0] === true) {
|
||||
return $this->success('发送成功');
|
||||
}
|
||||
|
||||
return $this->fail($result[0], [], 0, 1);
|
||||
}
|
||||
|
||||
/**
|
||||
* @notes 重置密码
|
||||
* @return \think\response\Json
|
||||
* @author 段誉
|
||||
* @date 2022/9/16 18:06
|
||||
*/
|
||||
public function resetPassword()
|
||||
{
|
||||
$params = (new PasswordValidate())->post()->goCheck('resetPassword');
|
||||
$result = UserLogic::resetPassword($params);
|
||||
if (true === $result) {
|
||||
return $this->success('操作成功', [], 1, 1);
|
||||
}
|
||||
return $this->fail(UserLogic::getError());
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 设置登录密码
|
||||
* @return \think\response\Json
|
||||
* @author Tab
|
||||
* @date 2021/10/22 18:09
|
||||
*/
|
||||
public function setPassword()
|
||||
{
|
||||
$params = (new UserValidate())->post()->goCheck('setPassword');
|
||||
$params['user_id'] = $this->userId;
|
||||
$result = UserLogic::setPassword($params);
|
||||
if($result) {
|
||||
return $this->success('设置成功',[], 1, 1);
|
||||
}
|
||||
return $this->fail(UserLogic::getError());
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 修改密码
|
||||
* @return \think\response\Json
|
||||
* @author 段誉
|
||||
* @date 2022/9/20 19:16
|
||||
*/
|
||||
public function changePassword()
|
||||
{
|
||||
$params = (new PasswordValidate())->post()->goCheck('changePassword');
|
||||
$result = UserLogic::changePassword($params, $this->userId);
|
||||
if (true === $result) {
|
||||
return $this->success('操作成功', [], 1, 1);
|
||||
}
|
||||
return $this->fail(UserLogic::getError());
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 判断用户是否设置登录密码
|
||||
* @return mixed
|
||||
* @author Tab
|
||||
* @date 2021/10/22 18:24
|
||||
*/
|
||||
public function hasPassword()
|
||||
{
|
||||
$result = UserLogic::hasPassword($this->userId);
|
||||
return $this->data([
|
||||
'has_password' => $result
|
||||
]);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 发送验证码 - 绑定手机号
|
||||
* @author Tab
|
||||
* @date 2021/8/25 17:35
|
||||
*/
|
||||
public function bindMobileCaptcha()
|
||||
{
|
||||
$params = (new UserValidate())->post()->goCheck('bindMobileCaptcha');
|
||||
$code = mt_rand(1000, 9999);
|
||||
$result = event('Notice', [
|
||||
'scene_id' => NoticeEnum::BIND_MOBILE_CAPTCHA,
|
||||
'params' => [
|
||||
'user_id' => $this->userId,
|
||||
'code' => $code,
|
||||
'mobile' => $params['mobile']
|
||||
]
|
||||
]);
|
||||
if ($result[0] === true) {
|
||||
return $this->success('发送成功');
|
||||
}
|
||||
|
||||
return $this->fail($result[0], [], 0, 1);
|
||||
}
|
||||
|
||||
/**
|
||||
* @notes 发送验证码 - 变更手机号
|
||||
* @author Tab
|
||||
* @date 2021/8/25 17:35
|
||||
*/
|
||||
public function changeMobileCaptcha()
|
||||
{
|
||||
$params = (new UserValidate())->post()->goCheck('changeMobileCaptcha');
|
||||
$code = mt_rand(1000, 9999);
|
||||
$result = event('Notice', [
|
||||
'scene_id' => NoticeEnum::CHANGE_MOBILE_CAPTCHA,
|
||||
'params' => [
|
||||
'user_id' => $this->userId,
|
||||
'code' => $code,
|
||||
'mobile' => $params['mobile']
|
||||
]
|
||||
]);
|
||||
if ($result[0] === true) {
|
||||
return $this->success('发送成功');
|
||||
}
|
||||
|
||||
return $this->fail($result[0], [], 0, 1);
|
||||
}
|
||||
|
||||
/**
|
||||
* @notes 绑定手机号
|
||||
* @return \think\response\Json
|
||||
* @author Tab
|
||||
* @date 2021/8/25 17:46
|
||||
*/
|
||||
public function bindMobile()
|
||||
{
|
||||
$params = (new UserValidate())->post()->goCheck('bindMobile');
|
||||
$params['id'] = $this->userId;
|
||||
$result = UserLogic::bindMobile($params);
|
||||
if($result) {
|
||||
return $this->success('绑定成功', [], 1, 1);
|
||||
}
|
||||
return $this->fail(UserLogic::getError());
|
||||
}
|
||||
|
||||
/**
|
||||
* @notes 我的钱包
|
||||
* @return \think\response\Json
|
||||
* @author ljj
|
||||
* @date 2022/12/12 9:35 上午
|
||||
*/
|
||||
public function wallet()
|
||||
{
|
||||
$result = UserLogic::wallet($this->userId);
|
||||
return $this->data($result);
|
||||
}
|
||||
}
|
||||
45
server/app/api/controller/WechatController.php
Executable file
45
server/app/api/controller/WechatController.php
Executable file
@@ -0,0 +1,45 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | LikeShop有特色的全开源社交分销电商系统
|
||||
// +----------------------------------------------------------------------
|
||||
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
|
||||
// | 商业用途务必购买系统授权,以免引起不必要的法律纠纷
|
||||
// | 禁止对系统程序代码以任何目的,任何形式的再发布
|
||||
// | 微信公众号:好象科技
|
||||
// | 访问官网:http://www.likemarket.net
|
||||
// | 访问社区:http://bbs.likemarket.net
|
||||
// | 访问手册:http://doc.likemarket.net
|
||||
// | 好象科技开发团队 版权所有 拥有最终解释权
|
||||
// +----------------------------------------------------------------------
|
||||
// | Author: LikeShopTeam
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
namespace app\api\controller;
|
||||
|
||||
use app\api\logic\WechatLogic;
|
||||
use app\api\validate\WechatValidate;
|
||||
|
||||
/**
|
||||
* 微信控制器
|
||||
* Class WechatController
|
||||
* @package app\api\controller
|
||||
*/
|
||||
class WechatController extends BaseApiController
|
||||
{
|
||||
public array $notNeedLogin = ['jsConfig'];
|
||||
/**
|
||||
* @notes 微信JSSDK授权接口
|
||||
* @return \think\response\Json
|
||||
* @author Tab
|
||||
* @date 2021/8/30 19:20
|
||||
*/
|
||||
public function jsConfig()
|
||||
{
|
||||
$params = (new WechatValidate())->goCheck('jsConfig');
|
||||
$result = WechatLogic::jsConfig($params);
|
||||
if ($result === false) {
|
||||
return $this->fail(WechatLogic::getError());
|
||||
}
|
||||
return $this->data($result);
|
||||
}
|
||||
}
|
||||
87
server/app/api/http/middleware/InitMiddleware.php
Executable file
87
server/app/api/http/middleware/InitMiddleware.php
Executable file
@@ -0,0 +1,87 @@
|
||||
<?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
|
||||
// +----------------------------------------------------------------------
|
||||
declare (strict_types=1);
|
||||
|
||||
namespace app\api\http\middleware;
|
||||
|
||||
|
||||
use app\common\exception\ControllerExtendException;
|
||||
use app\common\service\JsonService;
|
||||
use app\api\controller\BaseApiController;
|
||||
use think\exception\ClassNotFoundException;
|
||||
use think\exception\HttpException;
|
||||
|
||||
class InitMiddleware
|
||||
{
|
||||
/**
|
||||
* @notes 初始化
|
||||
* @param $request
|
||||
* @param \Closure $next
|
||||
* @return mixed
|
||||
* @author 令狐冲
|
||||
* @date 2021/7/2 19:29
|
||||
*/
|
||||
public function handle($request, \Closure $next)
|
||||
{
|
||||
//接口版本判断
|
||||
$version = $request->header('version');
|
||||
|
||||
if (empty($version) && !$this->nocheck($request)) {
|
||||
// 指定show为0,前端不弹出此报错
|
||||
return JsonService::fail('请求参数缺少接口版本号', [], 0, 0);
|
||||
}
|
||||
|
||||
//获取控制器
|
||||
try {
|
||||
$controller = str_replace('.', '\\', $request->controller());
|
||||
$controller = '\\app\\api\\controller\\' . $controller . 'Controller';
|
||||
$controllerClass = invoke($controller);
|
||||
if (($controllerClass instanceof BaseApiController) === false) {
|
||||
throw new ControllerExtendException($controller, '404');
|
||||
}
|
||||
} catch (ClassNotFoundException $e) {
|
||||
throw new HttpException(404, 'controller not exists:' . $e->getClass());
|
||||
}
|
||||
//创建控制器对象
|
||||
$request->controllerObject = invoke($controller);
|
||||
|
||||
return $next($request);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 是否验证版本号
|
||||
* @param $request
|
||||
* @return bool
|
||||
* @author 段誉
|
||||
* @date 2021/9/7 11:37
|
||||
*/
|
||||
public function nocheck($request)
|
||||
{
|
||||
//特殊方法不验证版本号参数
|
||||
$noCheck = [
|
||||
'Pay/notifyMnp',
|
||||
'Pay/notifyOa',
|
||||
'Pay/aliNotify',
|
||||
];
|
||||
$requestAction = $request->controller() . '/'. $request->action();
|
||||
return in_array($requestAction, $noCheck);
|
||||
}
|
||||
|
||||
}
|
||||
84
server/app/api/http/middleware/LoginMiddleware.php
Executable file
84
server/app/api/http/middleware/LoginMiddleware.php
Executable file
@@ -0,0 +1,84 @@
|
||||
<?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
|
||||
// +----------------------------------------------------------------------
|
||||
declare (strict_types=1);
|
||||
|
||||
namespace app\api\http\middleware;
|
||||
|
||||
|
||||
use app\common\cache\UserTokenCache;
|
||||
use app\common\service\JsonService;
|
||||
use app\api\service\UserTokenService;
|
||||
use think\facade\Config;
|
||||
|
||||
class LoginMiddleware
|
||||
{
|
||||
/**
|
||||
* @notes 登录验证
|
||||
* @param $request
|
||||
* @param \Closure $next
|
||||
* @return mixed|\think\response\Json
|
||||
* @author 令狐冲
|
||||
* @date 2021/7/1 17:33
|
||||
*/
|
||||
public function handle($request, \Closure $next)
|
||||
{
|
||||
$token = $request->header('token');
|
||||
//判断接口是否免登录
|
||||
$isNotNeedLogin = $request->controllerObject->isNotNeedLogin();
|
||||
|
||||
//不直接判断$isNotNeedLogin结果,使不需要登录的接口通过,为了兼容某些接口可以登录或不登录访问
|
||||
if (empty($token) && !$isNotNeedLogin) {
|
||||
//没有token并且该地址需要登录才能访问, 指定show为0,前端不弹出此报错
|
||||
return JsonService::fail('请求参数缺token', [], 0, 0);
|
||||
}
|
||||
|
||||
$userInfo = (new UserTokenCache())->getUserInfo($token);
|
||||
|
||||
if (empty($userInfo) && !$isNotNeedLogin) {
|
||||
//token过期无效并且该地址需要登录才能访问
|
||||
return JsonService::fail('登录超时,请重新登录', [], -1, 0);
|
||||
}
|
||||
|
||||
|
||||
//token临近过期,自动续期
|
||||
if ($userInfo) {
|
||||
//获取临近过期自动续期时长
|
||||
$beExpireDuration = Config::get('project.user_token.be_expire_duration');
|
||||
|
||||
//token续期
|
||||
if (time() > ($userInfo['expire_time'] - $beExpireDuration)) {
|
||||
|
||||
$result = UserTokenService::overtimeToken($token);
|
||||
|
||||
//续期失败(数据表被删除导致)
|
||||
if (empty($result)) {
|
||||
return JsonService::fail('登录过期', [], -1);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
//给request赋值,用于控制器
|
||||
$request->userInfo = $userInfo;
|
||||
$request->userId = $userInfo['user_id'] ?? 0;
|
||||
|
||||
return $next($request);
|
||||
}
|
||||
|
||||
}
|
||||
81
server/app/api/lists/AccountLogLists.php
Executable file
81
server/app/api/lists/AccountLogLists.php
Executable file
@@ -0,0 +1,81 @@
|
||||
<?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\lists;
|
||||
|
||||
|
||||
use app\common\enum\accountLog\AccountLogEnum;
|
||||
use app\common\model\accountLog\AccountLog;
|
||||
|
||||
class AccountLogLists extends BaseApiDataLists
|
||||
{
|
||||
/**
|
||||
* @notes 搜索条件
|
||||
* @return array
|
||||
* @author ljj
|
||||
* @date 2022/6/9 10:20 上午
|
||||
*/
|
||||
public function where()
|
||||
{
|
||||
$where[] = ['user_id','=',$this->userId];
|
||||
if (isset($this->params['change_object']) && $this->params['change_object'] != '') {
|
||||
$where[] = ['change_object','=',$this->params['change_object']];
|
||||
}else {
|
||||
$where[] = ['change_object','=',AccountLogEnum::MONEY];
|
||||
}
|
||||
if (isset($this->params['action']) && $this->params['action'] != '') {
|
||||
$where[] = ['action','=',$this->params['action']];
|
||||
}
|
||||
|
||||
return $where;
|
||||
}
|
||||
|
||||
/**
|
||||
* @notes 账户明细列表
|
||||
* @return array
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
* @author ljj
|
||||
* @date 2022/6/9 10:21 上午
|
||||
*/
|
||||
public function lists(): array
|
||||
{
|
||||
$lists = AccountLog::field('id,change_amount,change_type,remark,create_time,action')
|
||||
->append(['change_type_desc'])
|
||||
->where(self::where())
|
||||
->limit($this->limitOffset, $this->limitLength)
|
||||
->order('id','desc')
|
||||
->select()
|
||||
->toArray();
|
||||
|
||||
return $lists;
|
||||
}
|
||||
|
||||
/**
|
||||
* @notes 账户明细数量
|
||||
* @return int
|
||||
* @author ljj
|
||||
* @date 2022/6/9 10:21 上午
|
||||
*/
|
||||
public function count(): int
|
||||
{
|
||||
return AccountLog::where(self::where())->count();
|
||||
}
|
||||
}
|
||||
85
server/app/api/lists/AdLists.php
Executable file
85
server/app/api/lists/AdLists.php
Executable file
@@ -0,0 +1,85 @@
|
||||
<?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\lists;
|
||||
|
||||
|
||||
use app\common\enum\AdEnum;
|
||||
use app\common\enum\MenuEnum;
|
||||
use app\common\lists\BaseDataLists;
|
||||
use app\common\model\ad\Ad;
|
||||
use app\common\model\goods\Goods;
|
||||
|
||||
class AdLists extends BaseDataLists
|
||||
{
|
||||
/**
|
||||
* @notes 搜索条件
|
||||
* @return array
|
||||
* @author ljj
|
||||
* @date 2022/3/25 9:54 上午
|
||||
*/
|
||||
public function where()
|
||||
{
|
||||
$where[] = ['pid','=',$this->params['pid'] ?? 1];
|
||||
$where[] = ['status','=',1];
|
||||
|
||||
return $where;
|
||||
}
|
||||
|
||||
/**
|
||||
* @notes 广告列表
|
||||
* @return array
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
* @author ljj
|
||||
* @date 2022/3/25 9:54 上午
|
||||
*/
|
||||
public function lists(): array
|
||||
{
|
||||
$where = self::where();
|
||||
|
||||
$lists = Ad::field('id,name,pid,image,link_type,link_address')
|
||||
->where($where)
|
||||
->order(['sort'=>'desc','id'=>'desc'])
|
||||
->select()
|
||||
->toArray();
|
||||
|
||||
foreach ($lists as &$list) {
|
||||
if ($list['link_type'] == AdEnum::LINK_SHOP) {
|
||||
$shop_page = array_column(MenuEnum::SHOP_PAGE,NULL,'index');
|
||||
$list['link_address'] = $shop_page[$list['link_address']]['path'];
|
||||
}
|
||||
}
|
||||
|
||||
return $lists;
|
||||
}
|
||||
|
||||
/**
|
||||
* @notes 广告数量
|
||||
* @return int
|
||||
* @author ljj
|
||||
* @date 2022/3/25 9:55 上午
|
||||
*/
|
||||
public function count(): int
|
||||
{
|
||||
$where = self::where();
|
||||
return Ad::where($where)->count();
|
||||
}
|
||||
}
|
||||
42
server/app/api/lists/BaseApiDataLists.php
Executable file
42
server/app/api/lists/BaseApiDataLists.php
Executable file
@@ -0,0 +1,42 @@
|
||||
<?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\api\lists;
|
||||
|
||||
use app\common\lists\BaseDataLists;
|
||||
|
||||
abstract class BaseApiDataLists extends BaseDataLists
|
||||
{
|
||||
protected array $userInfo = [];
|
||||
protected int $userId = 0;
|
||||
|
||||
public string $export;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
if (isset($this->request->userInfo) && $this->request->userInfo) {
|
||||
$this->userInfo = $this->request->userInfo;
|
||||
$this->userId = $this->request->userId;
|
||||
}
|
||||
$this->export = $this->request->get('export', '');
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
107
server/app/api/lists/CoachLists.php
Executable file
107
server/app/api/lists/CoachLists.php
Executable file
@@ -0,0 +1,107 @@
|
||||
<?php
|
||||
namespace app\api\lists;
|
||||
use app\common\enum\coach\CoachEnum;
|
||||
use app\common\logic\CityLogic;
|
||||
use app\common\logic\CoachLogic;
|
||||
use app\common\model\coach\Coach;
|
||||
use app\common\model\coach\CoachGoodsIndex;
|
||||
use app\common\model\coach\Collect;
|
||||
use app\common\model\goods\GoodsComment;
|
||||
use app\common\service\ConfigService;
|
||||
|
||||
/**
|
||||
* 技师列表类
|
||||
* Class CoachLists
|
||||
* @package app\api\lists
|
||||
*/
|
||||
class CoachLists extends BaseApiDataLists
|
||||
{
|
||||
public $longitude = '';
|
||||
public $latitude = '';
|
||||
public $where = '';
|
||||
|
||||
public function setWhere()
|
||||
{
|
||||
$this->longitude = $this->params['longitude'] ?? '';
|
||||
$this->latitude = $this->params['latitude'] ?? '';
|
||||
$keyword = $this->params['keyword'] ?? '';
|
||||
$skillId = $this->params['skill_id'] ?? '';
|
||||
$goodsId = $this->params['goods_id'] ?? '';
|
||||
$shopId = $this->params['shop_id'] ?? '';
|
||||
$cityLists = CityLogic::getNearbyCity($this->longitude,$this->latitude);
|
||||
$cityId = $cityLists[0]['city_id'] ?? '';
|
||||
$where[] = ['city_id','=',$cityId];
|
||||
$where[] = ['server_status','=',1];
|
||||
$where[] = ['work_status','=',1];
|
||||
$where[] = ['audit_status','=',CoachEnum::AUDIT_STATUS_PASS];
|
||||
if($keyword){
|
||||
$where[] = ['name','like','%'.$keyword.'%'];
|
||||
}
|
||||
if($skillId){
|
||||
$where[] = ['skill_id','=',$skillId];
|
||||
}
|
||||
if($goodsId){
|
||||
$coachId = CoachGoodsIndex::where(['goods_id'=>$goodsId])->column('coach_id');
|
||||
empty($coachId) && $coachId = [0];
|
||||
$where[] = ['id','in',implode(',',$coachId)];
|
||||
}
|
||||
if($shopId){
|
||||
$where[] = ['shop_id','=',$shopId];
|
||||
}
|
||||
$this->where = $where;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 技师列表
|
||||
* @return array
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
* @author cjhao
|
||||
* @date 2024/9/4 16:32
|
||||
*/
|
||||
public function lists(): array
|
||||
{
|
||||
$coachServerScope = ConfigService::get('server_setting', 'coach_server_scope');
|
||||
$this->setWhere();
|
||||
$field = 'id,work_status,work_photo,shop_id,name,round(st_distance_sphere(point('.$this->longitude.','.$this->latitude.'),
|
||||
point(longitude, latitude))/1000,2) as distance,order_num,good_comment';
|
||||
$coachLists = Coach::where($this->where)
|
||||
->append(['distance_desc'])
|
||||
->order('distance asc')
|
||||
->limit($this->limitOffset, $this->limitLength)
|
||||
->having('distance < '.$coachServerScope)
|
||||
->field($field)
|
||||
->select()
|
||||
->toArray();
|
||||
$userId = $this->userId;
|
||||
$collect = '';
|
||||
if($userId){
|
||||
$collect = Collect::where(['user_id'=>$userId,'type'=>1])->value('relation_id');
|
||||
}
|
||||
$coachIds = array_column($coachLists,'id');
|
||||
$collectLists = Collect::where(['type'=>1,'relation_id'=>$coachIds])
|
||||
->group('relation_id')
|
||||
->column('count(id) as num','relation_id');
|
||||
$commentLists = GoodsComment::where(['coach_id'=>$coachIds])
|
||||
->group('coach_id')
|
||||
->column('count(id) as num','coach_id');
|
||||
|
||||
foreach ($coachLists as $key => $coach)
|
||||
{
|
||||
$coachLists[$key]['first_appoint'] = CoachLogic::getLatelyLeisureTime($coach['id']);
|
||||
$coachLists[$key]['is_collect'] = $collect ? 1 : 0;
|
||||
$coachLists[$key]['comment_num'] = $commentLists[$coach['id']] ?? 0;
|
||||
$coachLists[$key]['good_comment'] = $coach['good_comment'].'%';
|
||||
$coachLists[$key]['collect_num'] = $collectLists[$coach['id']] ?? 0;
|
||||
}
|
||||
return $coachLists;
|
||||
|
||||
}
|
||||
|
||||
public function count(): int
|
||||
{
|
||||
return Coach::where($this->where)->count();
|
||||
}
|
||||
}
|
||||
92
server/app/api/lists/CollectLists.php
Executable file
92
server/app/api/lists/CollectLists.php
Executable file
@@ -0,0 +1,92 @@
|
||||
<?php
|
||||
namespace app\api\lists;
|
||||
use app\common\enum\GoodsEnum;
|
||||
use app\common\logic\CoachLogic;
|
||||
use app\common\model\coach\Coach;
|
||||
use app\common\model\coach\Collect;
|
||||
use app\common\model\goods\Goods;
|
||||
use app\common\model\goods\GoodsCategory;
|
||||
use app\common\model\goods\GoodsComment;
|
||||
use app\common\model\shop\Shop;
|
||||
|
||||
class CollectLists extends BaseApiDataLists
|
||||
{
|
||||
public $where = [];
|
||||
public function setWhere(){
|
||||
$where[] = ['user_id','=',$this->userId];
|
||||
$type = $this->params['type'] ?? 1;
|
||||
|
||||
// if(isset($type) && $type){
|
||||
// }
|
||||
$relationIds = Collect::where(['user_id'=>$this->userId,'type'=>$type])
|
||||
->column('relation_id');
|
||||
$this->where[] = ['id','in',$relationIds];
|
||||
}
|
||||
|
||||
public function lists(): array
|
||||
{
|
||||
|
||||
$this->setWhere();
|
||||
$lists = [];
|
||||
switch ($this->params['type']){
|
||||
case 1:
|
||||
$lists = Coach::where($this->where)
|
||||
->append(['distance_desc'])
|
||||
->order('distance asc')
|
||||
->limit($this->limitOffset, $this->limitLength)
|
||||
->field('id,work_status,shop_id,work_photo,name,round(st_distance_sphere(point('.$this->params['longitude'].','.$this->params['latitude'].'),
|
||||
point(longitude, latitude))/1000,2) as distance,order_num,good_comment')
|
||||
->select()
|
||||
->toArray();
|
||||
$collect = Collect::where(['user_id'=>$this->userId,'type'=>1])->value('relation_id');
|
||||
$coachIds = array_column($lists,'id');
|
||||
$collectLists = Collect::where(['type'=>1,'relation_id'=>$coachIds])
|
||||
->group('relation_id')
|
||||
->column('count(id) as num','relation_id');
|
||||
foreach ($lists as $key => $coach)
|
||||
{
|
||||
$lists[$key]['first_appoint'] = CoachLogic::getLatelyLeisureTime($coach['id']);;
|
||||
$lists[$key]['is_collect'] = $collect ? 1 : 0;
|
||||
$lists[$key]['comment_num'] = GoodsComment::where(['coach_id'=>$coach['id']])->count('id');
|
||||
$lists[$key]['good_comment'] = $coach['good_comment'].'%';
|
||||
$lists[$key]['collect_num'] = $collectLists[$coach['id']] ?? 0;
|
||||
}
|
||||
break;
|
||||
case 2:
|
||||
$lists = Goods::field('id,name,image,tags,price,order_num+virtual_order_num as order_num,duration,scribing_price')
|
||||
->where($this->where)
|
||||
->limit($this->limitOffset, $this->limitLength)
|
||||
->select()
|
||||
->toArray();
|
||||
break;
|
||||
case 3:
|
||||
$lists = Shop::where($this->where)
|
||||
->append(['distance_desc','categoryIds'])
|
||||
->order('distance asc')
|
||||
->field('id,name,good_comment,logo,round(st_distance_sphere(point('.$this->params['longitude'].','.$this->params['latitude'].'),
|
||||
point(longitude, latitude))/1000,2) as distance,work_status')
|
||||
->limit($this->limitOffset, $this->limitLength)
|
||||
->select()
|
||||
->toArray();
|
||||
$categoryLists = GoodsCategory::where(['is_show'=>1])->column('name','id');
|
||||
foreach ($lists as $key => $coach)
|
||||
{
|
||||
$categoryNameLists = [];
|
||||
foreach ($coach['categoryIds'] as $category){
|
||||
$categoryNameLists[] = $categoryLists[$category['category_id']] ?? '';
|
||||
}
|
||||
$lists[$key]['consumption'] = '¥56';
|
||||
$lists[$key]['category_name'] = $categoryNameLists;
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
return $lists;
|
||||
}
|
||||
|
||||
public function count(): int
|
||||
{
|
||||
return Coach::where($this->where)->count();
|
||||
|
||||
}
|
||||
}
|
||||
132
server/app/api/lists/CommentGoodsLists.php
Executable file
132
server/app/api/lists/CommentGoodsLists.php
Executable file
@@ -0,0 +1,132 @@
|
||||
<?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\lists;
|
||||
|
||||
|
||||
use app\common\enum\OrderEnum;
|
||||
use app\common\enum\YesNoEnum;
|
||||
use app\common\lists\ListsExtendInterface;
|
||||
use app\common\model\coach\Coach;
|
||||
use app\common\model\goods\Goods;
|
||||
use app\common\model\order\OrderGoods;
|
||||
use app\common\service\FileService;
|
||||
|
||||
class CommentGoodsLists extends BaseApiDataLists implements ListsExtendInterface
|
||||
{
|
||||
/**
|
||||
* @notes 搜索条件
|
||||
* @return array
|
||||
* @author ljj
|
||||
* @date 2022/2/18 2:25 下午
|
||||
*/
|
||||
public function setSearch()
|
||||
{
|
||||
$where = [];
|
||||
$where[] = ['o.user_id', '=', $this->userId];
|
||||
$where[] = ['o.order_status', '=', OrderEnum::ORDER_STATUS_SERVER_FINISH];
|
||||
$where[] = ['og.is_comment','=',$this->params['type'] ?? 0];
|
||||
return $where;
|
||||
}
|
||||
|
||||
/**
|
||||
* @notes 评价商品列表
|
||||
* @return array
|
||||
* @author ljj
|
||||
* @date 2022/2/21 5:59 下午
|
||||
*/
|
||||
public function lists(): array
|
||||
{
|
||||
$lists = OrderGoods::alias('og')
|
||||
->join('order o', 'o.id = og.order_id')
|
||||
->join('goods_comment gc','gc.order_goods_id = og.id')
|
||||
->field('og.id,o.coach_id,og.goods_id,og.goods_name,og.goods_price,og.is_comment,appoint_time,og.goods_snap,gc.create_time')
|
||||
->append(['goods_comment'])
|
||||
->where($this->setSearch())
|
||||
->limit($this->limitOffset, $this->limitLength)
|
||||
->order('gc.id','desc')
|
||||
->group('og.id')
|
||||
->select()
|
||||
->toArray();
|
||||
$goodsIds = array_column($lists,'goods_id');
|
||||
$coachIds = array_column($lists,'coach_id');
|
||||
$goodsLists = Goods::where(['id'=>$goodsIds])->column('tags,order_num','id');
|
||||
$coachLists = Coach::where(['id'=>$coachIds])->column('name,work_photo','id');
|
||||
foreach ($lists as &$list) {
|
||||
$list['goods_snap']['image'] = FileService::getFileUrl($list['goods_snap']['image']);
|
||||
$list['goods_snap']['tags'] = $goodsLists[$list['goods_id']]['tags'] ?? 0;
|
||||
$list['goods_snap']['order_num'] = $goodsLists[$list['goods_id']]['order_num'] ?? 0;
|
||||
$list['appoint_date'] = date('m-d',$list['appoint_time']);
|
||||
$list['appoint_time'] = date('H:i',$list['appoint_time']);
|
||||
$list['coach_info'] = $coachLists[$list['coach_id']] ?? [];
|
||||
$list['coach_info']['work_photo'] = FileService::getFileUrl($list['coach_info']['work_photo'] ?? '');
|
||||
}
|
||||
|
||||
return $lists;
|
||||
}
|
||||
|
||||
/**
|
||||
* @notes 评价商品总数
|
||||
* @return int
|
||||
* @author ljj
|
||||
* @date 2022/2/21 5:59 下午
|
||||
*/
|
||||
public function count(): int
|
||||
{
|
||||
return OrderGoods::alias('og')
|
||||
->join('order o', 'o.id = og.order_id')
|
||||
->where($this->setSearch())
|
||||
->group('og.id')
|
||||
->count();
|
||||
}
|
||||
|
||||
/**
|
||||
* @notes 评价商品数据统计
|
||||
* @return array
|
||||
* @author ljj
|
||||
* @date 2022/2/21 6:00 下午
|
||||
*/
|
||||
public function extend()
|
||||
{
|
||||
$waitWhere = [
|
||||
['o.user_id', '=', $this->userId],
|
||||
['o.order_status', '=', 3],
|
||||
['og.is_comment', '=', YesNoEnum::NO],
|
||||
];
|
||||
$wait = OrderGoods::alias('og')
|
||||
->leftJoin('order o', 'o.id = og.order_id')
|
||||
->where($waitWhere)
|
||||
->count();
|
||||
$finishWhere = [
|
||||
['o.user_id', '=', $this->userId],
|
||||
['o.order_status', '=', 3],
|
||||
['og.is_comment', '=', YesNoEnum::YES],
|
||||
];
|
||||
$finish = OrderGoods::alias('og')
|
||||
->leftJoin('order o', 'o.id = og.order_id')
|
||||
->Join('goods_comment go', 'og.id = go.order_goods_id')
|
||||
->where($finishWhere)
|
||||
->whereNull('go.delete_time')
|
||||
->count();
|
||||
return [
|
||||
'wait' => $wait,
|
||||
'finish' => $finish
|
||||
];
|
||||
}
|
||||
}
|
||||
58
server/app/api/lists/GoodsCategoryLists.php
Executable file
58
server/app/api/lists/GoodsCategoryLists.php
Executable file
@@ -0,0 +1,58 @@
|
||||
<?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\lists;
|
||||
|
||||
|
||||
use app\common\model\goods\GoodsCategory;
|
||||
|
||||
class GoodsCategoryLists extends BaseApiDataLists
|
||||
{
|
||||
/**
|
||||
* @notes 服务分类列表
|
||||
* @return array
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
* @author ljj
|
||||
* @date 2022/2/18 10:55 上午
|
||||
*/
|
||||
public function lists(): array
|
||||
{
|
||||
$lists = (new GoodsCategory())->field('id,pid,name,level,image')
|
||||
->order(['sort'=>'desc','id'=>'asc'])
|
||||
->where(['is_show'=>1])
|
||||
->select()
|
||||
->toArray();
|
||||
|
||||
$lists = linear_to_tree($lists,'sons');
|
||||
return $lists;
|
||||
}
|
||||
|
||||
/**
|
||||
* @notes 服务分类总数
|
||||
* @return int
|
||||
* @author ljj
|
||||
* @date 2022/2/18 10:55 上午
|
||||
*/
|
||||
public function count(): int
|
||||
{
|
||||
return (new GoodsCategory())->where(['is_show'=>1])->count();
|
||||
}
|
||||
}
|
||||
94
server/app/api/lists/GoodsCommentLists.php
Executable file
94
server/app/api/lists/GoodsCommentLists.php
Executable file
@@ -0,0 +1,94 @@
|
||||
<?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\lists;
|
||||
|
||||
|
||||
use app\common\model\goods\GoodsComment;
|
||||
|
||||
class GoodsCommentLists extends BaseApiDataLists
|
||||
{
|
||||
/**
|
||||
* @notes 搜索条件
|
||||
* @return array
|
||||
* @author ljj
|
||||
* @date 2022/2/18 11:18 上午
|
||||
*/
|
||||
public function setSearch()
|
||||
{
|
||||
$where= [];
|
||||
$where[] = ['gc.goods_id','=',$this->params['goods_id'] ?? 0];
|
||||
if (!isset($this->params['id']) || $this->params['id'] == '') {
|
||||
return $where;
|
||||
}
|
||||
switch ($this->params['id']){
|
||||
case 1://有图
|
||||
$where[]= ['gci.uri','not null',''];
|
||||
break;
|
||||
case 2://好评
|
||||
$where[]= ['gc.service_comment','>',3];
|
||||
break;
|
||||
case 3://中差评
|
||||
$where[]= ['gc.service_comment','<=',3];
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return $where;
|
||||
}
|
||||
|
||||
/**
|
||||
* @notes 服务评价列表
|
||||
* @return array
|
||||
* @author ljj
|
||||
* @date 2022/2/18 11:18 上午
|
||||
*/
|
||||
public function lists(): array
|
||||
{
|
||||
$lists = GoodsComment::alias('gc')
|
||||
->leftjoin('goods_comment_image gci', 'gc.id = gci.comment_id')
|
||||
->with(['goods_comment_image','user'])
|
||||
->field('gc.id,gc.goods_id,gc.user_id,gc.service_comment,gc.comment,gc.reply,gc.create_time')
|
||||
->append(['comment_level'])
|
||||
->where($this->setSearch())
|
||||
->limit($this->limitOffset, $this->limitLength)
|
||||
->order('gc.id','desc')
|
||||
->group('gc.id')
|
||||
->select()
|
||||
->toArray();
|
||||
|
||||
|
||||
return $lists;
|
||||
}
|
||||
|
||||
/**
|
||||
* @notes 服务评价总数
|
||||
* @return int
|
||||
* @author ljj
|
||||
* @date 2022/2/18 11:23 上午
|
||||
*/
|
||||
public function count(): int
|
||||
{
|
||||
return GoodsComment::alias('gc')
|
||||
->leftjoin('goods_comment_image gci', 'gc.id = gci.comment_id')
|
||||
->field('gc.id,gc.goods_id,gc.user_id,gc.service_comment,gc.comment,gc.reply')
|
||||
->where($this->setSearch())
|
||||
->count();
|
||||
}
|
||||
}
|
||||
76
server/app/api/lists/GoodsLists.php
Executable file
76
server/app/api/lists/GoodsLists.php
Executable file
@@ -0,0 +1,76 @@
|
||||
<?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\lists;
|
||||
|
||||
|
||||
use app\common\enum\GoodsEnum;
|
||||
use app\common\model\goods\Goods;
|
||||
|
||||
class GoodsLists extends BaseApiDataLists
|
||||
{
|
||||
/**
|
||||
* @notes 搜索条件
|
||||
* @return array
|
||||
* @author ljj
|
||||
* @date 2022/2/17 5:18 下午
|
||||
*/
|
||||
public function setSearch(): array
|
||||
{
|
||||
return array_diff(array_keys($this->params), ['page_no', 'page_size']);
|
||||
}
|
||||
|
||||
/**
|
||||
* @notes 服务列表
|
||||
* @return array
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
* @author ljj
|
||||
* @date 2022/2/17 5:17 下午
|
||||
*/
|
||||
public function lists(): array
|
||||
{
|
||||
$lists = Goods::field('id,name,image,scribing_price,duration,tags,price')
|
||||
->withSearch($this->setSearch(), $this->params)
|
||||
->where(['status'=>GoodsEnum::SHELVE])
|
||||
->limit($this->limitOffset, $this->limitLength)
|
||||
->select()
|
||||
->toArray();
|
||||
|
||||
foreach ($lists as &$list) {
|
||||
$list['price'] = trim(rtrim(sprintf("%.4f", $list['price'] ), '0'),'.');
|
||||
}
|
||||
|
||||
return $lists;
|
||||
}
|
||||
|
||||
/**
|
||||
* @notes 服务总数
|
||||
* @return int
|
||||
* @author ljj
|
||||
* @date 2022/2/17 5:17 下午
|
||||
*/
|
||||
public function count(): int
|
||||
{
|
||||
return Goods::withSearch($this->setSearch(), $this->params)
|
||||
->where(['status'=>GoodsEnum::SHELVE])
|
||||
->count();
|
||||
}
|
||||
}
|
||||
126
server/app/api/lists/IndexServerLists.php
Executable file
126
server/app/api/lists/IndexServerLists.php
Executable 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\lists;
|
||||
|
||||
|
||||
use app\common\enum\GoodsEnum;
|
||||
use app\common\model\coach\CoachGoodsIndex;
|
||||
use app\common\model\goods\Goods;
|
||||
use app\common\model\goods\GoodsComment;
|
||||
use app\common\model\goods\GoodsSearchLog;
|
||||
use app\common\model\HotSearch;
|
||||
|
||||
class IndexServerLists extends BaseApiDataLists
|
||||
{
|
||||
|
||||
public $wehre = [];
|
||||
public $sort = [];
|
||||
public $sortRaw = 'sort desc,id desc';
|
||||
|
||||
public function setWhere()
|
||||
{
|
||||
$where[] = ['status','=',1];
|
||||
$where[] = ['audit_status','=',GoodsEnum::AUDIT_STATUS_PASS];
|
||||
$cityId = $this->params['city_id'] ?? '';
|
||||
$keyword = $this->params['keyword'] ?? '';
|
||||
$orderSales = $this->params['order_sales'] ?? '';
|
||||
$commentSales = $this->params['comment_sales'] ?? '';
|
||||
$price = $this->params['price'] ?? '';
|
||||
$coachId = $this->params['coach_id'] ?? '';
|
||||
$sort = [];
|
||||
if($keyword){
|
||||
$where[] = ['name','like','%'.$keyword.'%'];
|
||||
}
|
||||
if($orderSales){
|
||||
$sort = ['order_num',$orderSales];
|
||||
}
|
||||
if($price){
|
||||
$sort = ['price',$price];
|
||||
}
|
||||
if($coachId){
|
||||
$goodsIds = CoachGoodsIndex::where(['coach_id'=>$coachId])->column('goods_id');
|
||||
$where = ['id','in',$goodsIds];
|
||||
}else{
|
||||
$allCityGoodsIds = Goods::alias('G')
|
||||
->leftjoin('goods_city_index GCI','G.id = GCI.goods_id')
|
||||
->where(['GCI.id '=>null,'status'=>1])
|
||||
->column('G.id');
|
||||
$cityGoodsIds = Goods::alias('G')
|
||||
->leftjoin('goods_city_index GCI','G.id = GCI.goods_id')
|
||||
->where(['status'=>1,'city_id'=>$cityId])
|
||||
->column('G.id');
|
||||
$goodsIds = array_merge($allCityGoodsIds,$cityGoodsIds);
|
||||
empty($goodsIds) && $goodsIds = [];
|
||||
$where[] = ['id','in',implode(',',$goodsIds)];
|
||||
}
|
||||
if($sort){
|
||||
$this->sortRaw = implode(' ',$sort);
|
||||
}
|
||||
if($commentSales){
|
||||
$commentGoodsIds = GoodsComment::where('service_comment','>',3)->column('goods_id');
|
||||
$goodsIds = Goods::where('id','not in',$commentGoodsIds)->order('sort desc,id desc')->column('id');
|
||||
$goodsIds = array_merge($commentGoodsIds,$goodsIds);
|
||||
$this->sortRaw = 'field(id,'.implode(',',$goodsIds).')';
|
||||
}
|
||||
// $sort['sort'] = 'desc';
|
||||
$this->wehre = $where;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @notes 获取列表
|
||||
* @return array
|
||||
* @author cjhao
|
||||
* @date 2024/9/3 23:13
|
||||
*/
|
||||
public function lists(): array
|
||||
{
|
||||
$this->setWhere();
|
||||
$lists = Goods::where($this->wehre)
|
||||
->field('id,name,image,price,scribing_price,duration,order_num+virtual_order_num as order_num')
|
||||
->limit($this->limitOffset, $this->limitLength)
|
||||
->orderRaw($this->sortRaw)
|
||||
// ->order($this->sort)
|
||||
->select()
|
||||
->toArray();
|
||||
$keyword = $this->params['keyword'] ?? '';
|
||||
//记录搜索记录
|
||||
if($this->userId && $keyword){
|
||||
GoodsSearchLog::create([
|
||||
'user_id' => $this->userId,
|
||||
'keyword' => $keyword
|
||||
]);
|
||||
}
|
||||
return $lists;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 获取数量
|
||||
* @return int
|
||||
* @author cjhao
|
||||
* @date 2024/9/3 23:13
|
||||
*/
|
||||
public function count(): int
|
||||
{
|
||||
return Goods::where($this->wehre)
|
||||
->count();
|
||||
}
|
||||
}
|
||||
114
server/app/api/lists/OrderLists.php
Executable file
114
server/app/api/lists/OrderLists.php
Executable file
@@ -0,0 +1,114 @@
|
||||
<?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\lists;
|
||||
|
||||
|
||||
use app\common\enum\OrderEnum;
|
||||
use app\common\model\coach\Coach;
|
||||
use app\common\model\order\Order;
|
||||
|
||||
class OrderLists extends BaseApiDataLists
|
||||
{
|
||||
/**
|
||||
* @notes 搜索条件
|
||||
* @return array
|
||||
* @author ljj
|
||||
* @date 2022/2/28 9:31 上午
|
||||
*/
|
||||
public function where()
|
||||
{
|
||||
$where = [];
|
||||
$where[] = ['user_id','=',$this->userId];
|
||||
if (isset($this->params['order_status']) && $this->params['order_status'] != '') {
|
||||
switch ($this->params['order_status']) {
|
||||
case 1:
|
||||
$where[] = ['order_status','=',OrderEnum::ORDER_STATUS_WAIT_PAY];
|
||||
break;
|
||||
case 2:
|
||||
$where[] = ['order_status','in',[OrderEnum::ORDER_STATUS_WAIT_RECEIVING,OrderEnum::ORDER_STATUS_ARRIVE,OrderEnum::ORDER_STATUS_DEPART]];
|
||||
break;
|
||||
case 3:
|
||||
$where[] = ['order_status','=',OrderEnum::ORDER_STATUS_START_SERVER];
|
||||
break;
|
||||
case 4:
|
||||
$where[] = ['order_status','=',OrderEnum::ORDER_STATUS_SERVER_FINISH];
|
||||
break;
|
||||
case 5:
|
||||
$where[] = ['order_status','=',OrderEnum::ORDER_STATUS_CLOSE];
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return $where;
|
||||
}
|
||||
|
||||
/**
|
||||
* @notes 订单列表
|
||||
* @return array
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
* @author ljj
|
||||
* @date 2022/2/28 9:31 上午
|
||||
*/
|
||||
public function lists(): array
|
||||
{
|
||||
$lists = Order::field('id,sn,order_status,pay_status,total_order_amount,appoint_time,user_remark,address_snap,order_amount,server_finish_time,create_time,coach_id')
|
||||
->order('id','desc')
|
||||
->with(['order_goods' => function($query){
|
||||
$query->field('id,order_id,goods_id,goods_snap,goods_num,duration,goods_image,goods_name,goods_price')->hidden(['goods_snap']);
|
||||
}])
|
||||
->append(['appoint_time','appoint_date','order_status_desc','pay_btn','gap_btn','append_btn','user_cancel_btn','del_btn','comment_btn','look_comment_btn','order_cancel_time'])
|
||||
->where($this->where())
|
||||
->limit($this->limitOffset, $this->limitLength)
|
||||
->select()
|
||||
->toArray();
|
||||
$coachIds = array_column($lists,'coach_id');
|
||||
$coachLists = Coach::where(['id'=>$coachIds])
|
||||
->field('name,work_photo,mobile,sn,id')->select()->toArray();
|
||||
$coachLists = array_column($coachLists,null,'id');
|
||||
foreach ($lists as $key => $order){
|
||||
$lists[$key]['coach_info'] = [];
|
||||
if(in_array($order['order_status'],[OrderEnum::ORDER_STATUS_DEPART,OrderEnum::ORDER_STATUS_ARRIVE,OrderEnum::ORDER_STATUS_START_SERVER,OrderEnum::ORDER_STATUS_SERVER_FINISH])){
|
||||
$lists[$key]['coach_info'] = [
|
||||
'name' => $coachLists[$order['coach_id']]['name'] ?? '',
|
||||
'work_photo' => $coachLists[$order['coach_id']]['work_photo'] ?? '',
|
||||
'sn' => $coachLists[$order['coach_id']]['sn'] ?? '',
|
||||
'mobile' => $coachLists[$order['coach_id']]['mobile'] ?? ''
|
||||
];
|
||||
}
|
||||
if(!isset($order['address_snap']['house_number'])){
|
||||
$lists[$key]['address_snap']['house_number'] = '';
|
||||
}
|
||||
}
|
||||
return $lists;
|
||||
}
|
||||
|
||||
/**
|
||||
* @notes 订单数量
|
||||
* @return int
|
||||
* @author ljj
|
||||
* @date 2022/2/28 9:32 上午
|
||||
*/
|
||||
public function count(): int
|
||||
{
|
||||
return Order::where($this->where())->count();
|
||||
}
|
||||
}
|
||||
58
server/app/api/lists/RechargeLists.php
Executable file
58
server/app/api/lists/RechargeLists.php
Executable file
@@ -0,0 +1,58 @@
|
||||
<?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\lists;
|
||||
|
||||
|
||||
use app\common\enum\PayEnum;
|
||||
use app\common\model\RechargeOrder;
|
||||
|
||||
class RechargeLists extends BaseApiDataLists
|
||||
{
|
||||
/**
|
||||
* @notes 充值记录列表
|
||||
* @return array
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
* @author ljj
|
||||
* @date 2022/12/16 16:19
|
||||
*/
|
||||
public function lists(): array
|
||||
{
|
||||
$lists = RechargeOrder::field('order_amount,create_time')
|
||||
->where(['user_id' => $this->userId,'pay_status' => PayEnum::ISPAID])
|
||||
->order('id', 'desc')
|
||||
->select()
|
||||
->toArray();
|
||||
|
||||
return $lists;
|
||||
}
|
||||
|
||||
/**
|
||||
* @notes 充值记录数量
|
||||
* @return int
|
||||
* @author ljj
|
||||
* @date 2022/12/16 16:20
|
||||
*/
|
||||
public function count(): int
|
||||
{
|
||||
return RechargeOrder::where(['user_id' => $this->userId,'pay_status' => PayEnum::ISPAID])->count();
|
||||
}
|
||||
}
|
||||
111
server/app/api/lists/ShopCommentGoodsLists.php
Executable file
111
server/app/api/lists/ShopCommentGoodsLists.php
Executable file
@@ -0,0 +1,111 @@
|
||||
<?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\lists;
|
||||
|
||||
|
||||
use app\common\enum\OrderEnum;
|
||||
use app\common\enum\YesNoEnum;
|
||||
use app\common\lists\ListsExtendInterface;
|
||||
use app\common\model\coach\Coach;
|
||||
use app\common\model\goods\Goods;
|
||||
use app\common\model\order\Order;
|
||||
use app\common\model\order\OrderGoods;
|
||||
use app\common\model\user\User;
|
||||
use app\common\service\FileService;
|
||||
|
||||
class ShopCommentGoodsLists extends BaseApiDataLists
|
||||
{
|
||||
/**
|
||||
* @notes 搜索条件
|
||||
* @return array
|
||||
* @author ljj
|
||||
* @date 2022/2/18 2:25 下午
|
||||
*/
|
||||
public function setSearch()
|
||||
{
|
||||
$shopId = $this->params['shop_id'];
|
||||
$coachIds = Coach::where(['shop_id'=>$shopId])->field('id')->select()->toArray();
|
||||
$coachIds = array_column($coachIds,'id');
|
||||
$orderGoodsIds = Order::alias('O')
|
||||
->join('order_goods OG','O.id = OG.order_id')
|
||||
->where(['coach_id'=>$coachIds])
|
||||
->field('OG.id')->select()->toArray();
|
||||
$orderGoodsIds = array_column($orderGoodsIds,'id');
|
||||
$where[] = ['og.id','in',$orderGoodsIds];
|
||||
$where[] = ['o.order_status', '=', OrderEnum::ORDER_STATUS_SERVER_FINISH];
|
||||
$where[] = ['og.is_comment','=',1];
|
||||
return $where;
|
||||
}
|
||||
|
||||
/**
|
||||
* @notes 评价商品列表
|
||||
* @return array
|
||||
* @author ljj
|
||||
* @date 2022/2/21 5:59 下午
|
||||
*/
|
||||
public function lists(): array
|
||||
{
|
||||
$lists = OrderGoods::alias('og')
|
||||
->join('order o', 'o.id = og.order_id')
|
||||
->field('o.user_id,og.id,coach_id,og.goods_id,og.goods_name,og.goods_price,og.is_comment,appoint_time,og.goods_snap')
|
||||
->append(['goods_comment'])
|
||||
->where($this->setSearch())
|
||||
->limit($this->limitOffset, $this->limitLength)
|
||||
->order('og.id','desc')
|
||||
->group('og.id')
|
||||
->select()
|
||||
->toArray();
|
||||
// $goodsIds = array_column($lists,'goods_id');
|
||||
// $coachIds = array_column($lists,'coach_id');
|
||||
// $goodsLists = Goods::where(['id'=>$goodsIds])->column('tags,order_num','id');
|
||||
// $coachLists = Coach::where(['id'=>$coachIds])->column('name,work_photo','id');
|
||||
$userIds = array_column($lists,'user_id');
|
||||
$userLists = User::where(['id'=>$userIds])->column('id,nickname,avatar','id');
|
||||
foreach ($lists as &$list) {
|
||||
// $list['goods_snap']['image'] = FileService::getFileUrl($list['goods_snap']['image']);
|
||||
// $list['goods_snap']['tags'] = $goodsLists[$list['goods_id']]['tags'];
|
||||
// $list['goods_snap']['order_num'] = $goodsLists[$list['goods_id']]['order_num'];
|
||||
// $list['appoint_date'] = date('m-d',$list['appoint_time']);
|
||||
// $list['appoint_time'] = date('H:i',$list['appoint_time']);
|
||||
// $list['coach_info'] = $coachLists[$list['coach_id']] ?? [];
|
||||
$list['nickname'] = $userLists[$list['user_id']]['nickname'] ?? '';
|
||||
$list['avatar'] = FileService::getFileUrl($userLists[$list['user_id']]['avatar'] ?? '');
|
||||
}
|
||||
|
||||
return $lists;
|
||||
}
|
||||
|
||||
/**
|
||||
* @notes 评价商品总数
|
||||
* @return int
|
||||
* @author ljj
|
||||
* @date 2022/2/21 5:59 下午
|
||||
*/
|
||||
public function count(): int
|
||||
{
|
||||
return OrderGoods::alias('og')
|
||||
->join('order o', 'o.id = og.order_id')
|
||||
->where($this->setSearch())
|
||||
->group('og.id')
|
||||
->select()
|
||||
->count();
|
||||
}
|
||||
|
||||
}
|
||||
117
server/app/api/lists/ShopLists.php
Executable file
117
server/app/api/lists/ShopLists.php
Executable file
@@ -0,0 +1,117 @@
|
||||
<?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\lists;
|
||||
|
||||
|
||||
use app\common\enum\AdEnum;
|
||||
use app\common\enum\MenuEnum;
|
||||
use app\common\enum\PayEnum;
|
||||
use app\common\enum\shop\ShopEnum;
|
||||
use app\common\lists\BaseDataLists;
|
||||
use app\common\model\ad\Ad;
|
||||
use app\common\model\goods\Goods;
|
||||
use app\common\model\goods\GoodsCategory;
|
||||
use app\common\model\order\Order;
|
||||
use app\common\model\shop\Shop;
|
||||
use app\common\model\shop\ShopCategoryIndex;
|
||||
|
||||
class ShopLists extends BaseDataLists
|
||||
{
|
||||
/**
|
||||
* @notes 搜索条件
|
||||
* @return array
|
||||
* @author ljj
|
||||
* @date 2022/3/25 9:54 上午
|
||||
*/
|
||||
public function where()
|
||||
{
|
||||
$where = [];
|
||||
if(isset($this->params['keyword']) && $this->params['keyword']){
|
||||
$where[] = ['name','like','%'.$this->params['keyword'].'%'];
|
||||
}
|
||||
if(isset($this->params['category_id']) && $this->params['category_id']){
|
||||
$shopIds = ShopCategoryIndex::where(['category_id'=>$this->params['category_id']])->column('shop_id');
|
||||
empty($shopIds) && $shopIds = [];
|
||||
$where[] = ['id','in',$shopIds];
|
||||
}
|
||||
if(isset($this->params['city_id']) && $this->params['city_id']){
|
||||
$where[] = ['city_id','=',$this->params['city_id']];
|
||||
}
|
||||
$where[] = ['audit_status','=',ShopEnum::AUDIT_STATUS_PASS];
|
||||
$where[] = ['server_status','=',ShopEnum::SERVERSTATUSOPEN];
|
||||
return $where;
|
||||
}
|
||||
|
||||
/**
|
||||
* @notes 广告列表
|
||||
* @return array
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
* @author ljj
|
||||
* @date 2022/3/25 9:54 上午
|
||||
*/
|
||||
public function lists(): array
|
||||
{
|
||||
$field = 'id,name,good_comment,logo,work_status,0 as distance';
|
||||
if (!empty($params['longitude']) && !empty($params['latitude'])) {
|
||||
$field = 'id,name,good_comment,logo,work_status,round(st_distance_sphere(point('.$this->params['longitude'].','.$this->params['latitude'].'),point(longitude, latitude))/1000,2) as distance';
|
||||
}
|
||||
$lists = Shop::where($this->where())
|
||||
->append(['distance_desc','categoryIds','work_status_desc'])
|
||||
->order('distance asc')
|
||||
->field($field)
|
||||
->limit($this->limitOffset, $this->limitLength)
|
||||
->select()
|
||||
->toArray();
|
||||
$categoryLists = GoodsCategory::where(['is_show'=>1])->column('name','id');
|
||||
$consumptionLists = Order::where(['pay_status'=>PayEnum::ISPAID])
|
||||
->where('shop_id','>',0)
|
||||
->group('shop_id')
|
||||
->column('round(sum(order_amount)/count(id),2) as consumption,shop_id');
|
||||
$consumptionLists = array_column($consumptionLists,null,'shop_id');
|
||||
foreach ($lists as $key => $shop)
|
||||
{
|
||||
$categoryNameLists = [];
|
||||
foreach ($shop['categoryIds'] as $category){
|
||||
$categoryNameLists[] = $categoryLists[$category['category_id']] ?? '';
|
||||
}
|
||||
$lists[$key]['consumption'] = $consumptionLists[$shop['id']]['consumption'] ?? 0;
|
||||
$lists[$key]['category_name'] = $categoryNameLists;
|
||||
|
||||
}
|
||||
|
||||
return $lists;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @notes 广告数量
|
||||
* @return int
|
||||
* @author ljj
|
||||
* @date 2022/3/25 9:55 上午
|
||||
*/
|
||||
public function count(): int
|
||||
{
|
||||
return Shop::where($this->where())
|
||||
->count();
|
||||
|
||||
}
|
||||
}
|
||||
75
server/app/api/lists/StaffLists.php
Executable file
75
server/app/api/lists/StaffLists.php
Executable file
@@ -0,0 +1,75 @@
|
||||
<?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\lists;
|
||||
|
||||
|
||||
use app\common\enum\DefaultEnum;
|
||||
use app\common\model\staff\Staff;
|
||||
|
||||
class StaffLists extends BaseApiDataLists
|
||||
{
|
||||
/**
|
||||
* @notes 搜索条件
|
||||
* @return \string[][]
|
||||
* @author ljj
|
||||
* @date 2022/2/23 5:48 下午
|
||||
*/
|
||||
public function where(): array
|
||||
{
|
||||
$where[] = ['status','=',DefaultEnum::SHOW];
|
||||
if (isset($this->params['name']) && $this->params['name'] != '') {
|
||||
$where[] = ['name','like','%'.$this->params['name'].'%'];
|
||||
}
|
||||
|
||||
return $where;
|
||||
}
|
||||
|
||||
/**
|
||||
* @notes 师傅列表
|
||||
* @return array
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
* @author ljj
|
||||
* @date 2022/2/23 5:56 下午
|
||||
*/
|
||||
public function lists(): array
|
||||
{
|
||||
$lists = Staff::field('id,user_id,name,goods_ids,province_id,city_id,district_id,address')
|
||||
->where($this->where())
|
||||
->append(['goods_name','user_image','province','city','district'])
|
||||
->order(['id'=>'desc'])
|
||||
->select()
|
||||
->toArray();
|
||||
|
||||
return $lists;
|
||||
}
|
||||
|
||||
/**
|
||||
* @notes 师傅总数
|
||||
* @return int
|
||||
* @author ljj
|
||||
* @date 2022/2/23 5:56 下午
|
||||
*/
|
||||
public function count(): int
|
||||
{
|
||||
return Staff::where($this->where())->count();
|
||||
}
|
||||
}
|
||||
94
server/app/api/lists/StaffOrderLists.php
Executable file
94
server/app/api/lists/StaffOrderLists.php
Executable file
@@ -0,0 +1,94 @@
|
||||
<?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\lists;
|
||||
|
||||
|
||||
use app\common\enum\OrderEnum;
|
||||
use app\common\model\order\Order;
|
||||
use app\common\model\staff\Staff;
|
||||
|
||||
class StaffOrderLists extends BaseApiDataLists
|
||||
{
|
||||
/**
|
||||
* @notes 搜索条件
|
||||
* @return array
|
||||
* @author ljj
|
||||
* @date 2022/3/1 2:46 下午
|
||||
*/
|
||||
public function where()
|
||||
{
|
||||
$where = [];
|
||||
$staff_id = Staff::where('user_id',$this->userId)->value('id');
|
||||
$where[] = ['staff_id','=',$staff_id];
|
||||
if (isset($this->params['order_status']) && $this->params['order_status'] != '') {
|
||||
switch ($this->params['order_status']) {
|
||||
case 1:
|
||||
$where[] = ['order_status','=',OrderEnum::ORDER_STATUS_APPOINT];
|
||||
break;
|
||||
case 2:
|
||||
$where[] = ['order_status','=',OrderEnum::ORDER_STATUS_SERVICE];
|
||||
break;
|
||||
case 3:
|
||||
$where[] = ['order_status','=',OrderEnum::ORDER_STATUS_FINISH];
|
||||
break;
|
||||
case 4:
|
||||
$where[] = ['order_status','=',OrderEnum::ORDER_STATUS_CLOSE];
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return $where;
|
||||
}
|
||||
|
||||
/**
|
||||
* @notes 订单服务列表
|
||||
* @return array
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
* @author ljj
|
||||
* @date 2022/3/1 3:01 下午
|
||||
*/
|
||||
public function lists(): array
|
||||
{
|
||||
$lists = Order::field('id,sn,order_status,pay_status,order_amount,appoint_time_start,appoint_time_end')
|
||||
->order('id','desc')
|
||||
->append(['appoint_time','appoint_week','order_status_desc','confirm_service_btn','verification_btn'])
|
||||
->with(['order_goods' => function($query){
|
||||
$query->field('order_id,goods_snap,goods_name')->append(['goods_image'])->hidden(['goods_snap']);
|
||||
}])
|
||||
->where($this->where())
|
||||
->select()
|
||||
->toArray();
|
||||
|
||||
return $lists;
|
||||
}
|
||||
|
||||
/**
|
||||
* @notes 订单服务数量
|
||||
* @return int
|
||||
* @author ljj
|
||||
* @date 2022/3/1 3:12 下午
|
||||
*/
|
||||
public function count(): int
|
||||
{
|
||||
return Order::where($this->where())->count();
|
||||
}
|
||||
}
|
||||
44
server/app/api/logic/CityLogic.php
Executable file
44
server/app/api/logic/CityLogic.php
Executable file
@@ -0,0 +1,44 @@
|
||||
<?php
|
||||
namespace app\api\logic;
|
||||
use app\common\model\city\City;
|
||||
|
||||
class CityLogic
|
||||
{
|
||||
|
||||
/**
|
||||
* @notes 获取城市列表
|
||||
* @return array
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
* @author cjhao
|
||||
* @date 2024/10/6 17:49
|
||||
*/
|
||||
public function getCityLists()
|
||||
{
|
||||
$lists = City::where(['level'=>2])->select()->toArray();
|
||||
$cityLists = [];
|
||||
foreach ($lists as $city){
|
||||
$parent = $cityLists[$city['parent_id']] ?? [];
|
||||
if($parent){
|
||||
$parent['sons'][] =[
|
||||
'id' => $city['city_id'],
|
||||
'name' => $city['name'],
|
||||
];
|
||||
}else{
|
||||
$parent = [
|
||||
'id' => $city['parent_id'],
|
||||
'name' => $city['parent_name'],
|
||||
'sons' => [
|
||||
[
|
||||
'id' => $city['city_id'],
|
||||
'name' => $city['name'],
|
||||
],
|
||||
],
|
||||
];
|
||||
}
|
||||
$cityLists[$city['parent_id']] = $parent;
|
||||
}
|
||||
return array_values($cityLists);
|
||||
}
|
||||
}
|
||||
124
server/app/api/logic/CoachLogic.php
Executable file
124
server/app/api/logic/CoachLogic.php
Executable file
@@ -0,0 +1,124 @@
|
||||
<?php
|
||||
namespace app\api\logic;
|
||||
use app\common\enum\coach\CoachEnum;
|
||||
use app\common\enum\PayEnum;
|
||||
use app\common\logic\BaseLogic;
|
||||
use app\common\model\coach\Coach;
|
||||
use app\common\model\coach\CoachLifePhoto;
|
||||
use app\common\model\coach\Collect;
|
||||
use app\common\model\goods\Goods;
|
||||
use app\common\model\goods\GoodsComment;
|
||||
use app\common\model\order\Order;
|
||||
use app\common\model\shop\Shop;
|
||||
use app\common\model\skill\Skill;
|
||||
use app\common\service\FileService;
|
||||
|
||||
class CoachLogic extends BaseLogic
|
||||
{
|
||||
|
||||
/**
|
||||
* @notes 技能列表
|
||||
* @return array
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
* @author cjhao
|
||||
* @date 2024/9/4 17:00
|
||||
*/
|
||||
public function skillLists()
|
||||
{
|
||||
$lists = Skill::where(['is_show'=>1])
|
||||
->field('id,name')
|
||||
->select()
|
||||
->toArray();
|
||||
array_unshift($lists,['id'=>0,'name'=>'全部']);
|
||||
|
||||
return $lists;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 师傅详情
|
||||
* @param $params
|
||||
* @return array|void
|
||||
* @author cjhao
|
||||
* @date 2024/9/4 17:23
|
||||
*/
|
||||
public function detail($params)
|
||||
{
|
||||
$id = $params['id'] ?? '';
|
||||
$cityId = $params['city_id'] ?? '';
|
||||
$longitude = $params['longitude'] ?? '';
|
||||
$latitude = $params['latitude'] ?? '';
|
||||
if(empty($id) && empty($cityId)){
|
||||
return [];
|
||||
}
|
||||
$field = 'id,skill_id,gender,age,shop_id,education,nation,work_status,work_photo,name,0 as distance,introduction,id_card,order_num,good_comment,certification,health_certificate';
|
||||
if($latitude && $longitude){
|
||||
$field = 'id,skill_id,gender,age,shop_id,education,nation,work_status,work_photo,name,round(st_distance_sphere(point('.$longitude.','.$latitude.'),
|
||||
point(longitude,latitude))/1000,2) as distance,introduction,id_card,order_num,good_comment,certification,health_certificate';
|
||||
}
|
||||
|
||||
$detail = Coach::where(['id'=>$id,'audit_status'=>CoachEnum::AUDIT_STATUS_PASS])
|
||||
->append(['distance_desc'])
|
||||
->field($field)
|
||||
->findOrEmpty()
|
||||
->toArray();
|
||||
$lifePhoto = CoachLifePhoto::where(['coach_id'=>$id])->field('uri')->select()->toArray();
|
||||
array_unshift($lifePhoto,['uri'=>$detail['work_photo']]);
|
||||
$detail['life_photo'] = array_column($lifePhoto,'uri');
|
||||
$detail['shop_name'] = '';
|
||||
$detail['shop'] = [];
|
||||
if($detail['shop_id']){
|
||||
$field = 'id,name,good_comment,logo,work_status,0 as distance';
|
||||
if($latitude && $longitude){
|
||||
$field = 'id,name,good_comment,logo,work_status,round(st_distance_sphere(point('.$longitude.','.$latitude.'),point(longitude, latitude))/1000,2) as distance';
|
||||
}
|
||||
$detail['shop'] = Shop::where(['id'=>$detail['shop_id']])
|
||||
->field($field)
|
||||
->findOrEmpty();
|
||||
$consumption = Order::where(['pay_status'=>PayEnum::ISPAID])
|
||||
->where('shop_id','=',$detail['shop_id'])
|
||||
->value('round(sum(order_amount)/count(id),2) as consumption');
|
||||
$detail['shop']['consumption'] = $consumption;
|
||||
}
|
||||
$detail['id_card'] = substr_replace($detail['id_card'], '***************', 3);
|
||||
|
||||
$detail['skill_name'] = Skill::where(['id'=>$detail['skill_id']])->value('name');
|
||||
$detail['first_appoint'] = \app\common\logic\CoachLogic::getLatelyLeisureTime($detail['id']);
|
||||
$detail['comment_num'] = GoodsComment::where(['coach_id'=>$id])->count();
|
||||
$detail['good_comment'] = $detail['good_comment'].'%';
|
||||
$allCityGoodsIds = Goods::alias('G')
|
||||
->leftjoin('goods_city_index GCI','G.id = GCI.goods_id')
|
||||
->where(['GCI.id '=>null,'status'=>1])
|
||||
->column('G.id') ?: [];
|
||||
$cityGoodsIds = Goods::alias('G')
|
||||
->leftjoin('goods_city_index GCI','G.id = GCI.goods_id')
|
||||
->where(['status'=>1,'city_id'=>$cityId])
|
||||
->column('G.id') ?: [];
|
||||
$detail['goods_lists'] = Goods::alias('G')
|
||||
->join('coach_goods_index GCI','G.id = GCI.goods_id')
|
||||
->where(['GCI.coach_id'=>$id])
|
||||
->where(['G.id'=>array_merge($allCityGoodsIds,$cityGoodsIds)])
|
||||
->field('G.id,name,image,price,scribing_price,duration,order_num')
|
||||
->limit(8)
|
||||
->select()->toArray();
|
||||
//评论列表
|
||||
$detail['comment_lists'] = GoodsComment::alias('GC')
|
||||
->join('user U','GC.user_id = U.id')
|
||||
->where(['coach_id'=>$params['id']])
|
||||
->field('GC.id,U.nickname,U.avatar,comment,service_comment,reply,GC.create_time')
|
||||
->append(['goods_comment_image'])
|
||||
->limit(8)
|
||||
->select()
|
||||
->toArray();
|
||||
foreach ($detail['comment_lists'] as $key => $commentLists){
|
||||
$detail['comment_lists'][$key]['avatar'] = FileService::getFileUrl($commentLists['avatar']);
|
||||
}
|
||||
$detail['is_collect'] = Collect::where(['relation_id'=>$params['id'],'user_id'=>$params['user_id'],'type'=>1])->findOrEmpty()->toArray() ? 1 : 0;
|
||||
return $detail;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
153
server/app/api/logic/ConfigLogic.php
Executable file
153
server/app/api/logic/ConfigLogic.php
Executable file
@@ -0,0 +1,153 @@
|
||||
<?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\decorate\DecorateTabbar;
|
||||
use app\common\model\decorate\Navigation;
|
||||
use app\common\model\TextList;
|
||||
use app\common\service\ConfigService;
|
||||
use app\common\service\FileService;
|
||||
|
||||
class ConfigLogic extends BaseLogic
|
||||
{
|
||||
/**
|
||||
* @notes 基础配置信息
|
||||
* @return array
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
* @author ljj
|
||||
* @date 2022/2/23 10:30 上午
|
||||
*/
|
||||
public function config()
|
||||
{
|
||||
$config = [
|
||||
// 登录方式
|
||||
'login_way' => ConfigService::get('login', 'login_way', config('project.login.login_way')),
|
||||
// 注册强制绑定手机
|
||||
'coerce_mobile' => ConfigService::get('login', 'coerce_mobile', config('project.login.coerce_mobile')),
|
||||
// 政策协议
|
||||
'login_agreement' => ConfigService::get('login', 'login_agreement', config('project.login.login_agreement')),
|
||||
// 第三方登录 开关
|
||||
'third_auth' => ConfigService::get('login', 'third_auth', config('project.login.third_auth')),
|
||||
// 微信授权登录
|
||||
'wechat_auth' => ConfigService::get('login', 'wechat_auth', config('project.login.wechat_auth')),
|
||||
// qq授权登录
|
||||
'qq_auth' => ConfigService::get('login', 'qq_auth', config('project.login.qq_auth')),
|
||||
//版权信息
|
||||
'info' => ConfigService::get('copyright', 'info'),
|
||||
//ICP备案号
|
||||
'icp_number' => ConfigService::get('copyright', 'icp_number'),
|
||||
//ICP备案链接
|
||||
'icp_link' => ConfigService::get('copyright', 'icp_link'),
|
||||
// //底部导航
|
||||
// 'navigation_menu' => DecorateTabbar::getTabbarLists(1),
|
||||
// 导航颜色
|
||||
// 'style' => ConfigService::get('tabbar', 'style', '{}'),
|
||||
//地图key
|
||||
'tencent_map_key' => ConfigService::get('map','tencent_map_key',''),
|
||||
//网站名称
|
||||
'web_name' => ConfigService::get('platform_logo', 'platform_name',''),
|
||||
//网站logo
|
||||
'web_logo' => FileService::getFileUrl(ConfigService::get('platform_logo', 'platform_logo')),
|
||||
//商城名称
|
||||
'shop_name' => ConfigService::get('user', 'user_name',''),
|
||||
'short_name' => ConfigService::get('user', 'short_name',''),
|
||||
//商城logo
|
||||
'shop_logo' => FileService::getFileUrl(ConfigService::get('user', 'user_logo','')),
|
||||
//版本号
|
||||
'version' => request()->header('version'),
|
||||
//默认头像
|
||||
'default_avatar' => ConfigService::get('config', 'default_avatar', FileService::getFileUrl(config('project.default_image.user_avatar'))),
|
||||
//H5设置
|
||||
'h5_settings' => [
|
||||
// 渠道状态 0-关闭 1-开启
|
||||
'status' => ConfigService::get('web_page', 'status', 1),
|
||||
// 关闭后渠道后访问页面 0-空页面 1-自定义链接
|
||||
'page_status' => ConfigService::get('web_page', 'page_status', 0),
|
||||
// 自定义链接
|
||||
'page_url' => ConfigService::get('web_page', 'page_url', ''),
|
||||
'url' => request()->domain() . '/mobile'
|
||||
],
|
||||
//文件域名
|
||||
'domain' => request()->domain().'/',
|
||||
//联系客服
|
||||
'service_mobile' => ConfigService::get('platform', 'service_mobile',''),
|
||||
'copyright'=>ConfigService::get('copyright', 'config', [])
|
||||
|
||||
];
|
||||
return $config;
|
||||
}
|
||||
|
||||
/**
|
||||
* @notes 政策协议
|
||||
* @return array
|
||||
* @author ljj
|
||||
* @date 2022/2/23 11:42 上午
|
||||
*/
|
||||
public function agreement()
|
||||
{
|
||||
$service = TextList::where(['id'=>1])->field('title,content')->findOrEmpty();
|
||||
$privacy = TextList::where(['id'=>2])->field('title,content')->findOrEmpty();
|
||||
$config = [
|
||||
//隐私协议
|
||||
'service_title' => $service['title'],
|
||||
'service_agreement' => $service['content'],
|
||||
//服务协议
|
||||
'privacy_title' => $privacy['title'],
|
||||
'privacy_agreement' => $privacy['content'],
|
||||
];
|
||||
return $config;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 获取客服配置
|
||||
* @return array
|
||||
* @author ljj
|
||||
* @date 2024/8/28 下午4:06
|
||||
*/
|
||||
public function getKefuConfig()
|
||||
{
|
||||
$defaultData = [
|
||||
'way' => 1,
|
||||
'name' => '',
|
||||
'remarks' => '',
|
||||
'phone' => '',
|
||||
'service_phone' => '',
|
||||
'business_time' => '',
|
||||
'qr_code' => '',
|
||||
'enterprise_id' => '',
|
||||
'kefu_link' => ''
|
||||
];
|
||||
$config = [
|
||||
'mnp' => ConfigService::get('kefu_config', 'mnp', $defaultData),
|
||||
'oa' => ConfigService::get('kefu_config', 'oa', $defaultData),
|
||||
'h5' => ConfigService::get('kefu_config', 'h5', $defaultData),
|
||||
];
|
||||
if (!empty($config['mnp']['qr_code'])) $config['mnp']['qr_code'] = FileService::getFileUrl($config['mnp']['qr_code']);
|
||||
if (!empty($config['oa']['qr_code'])) $config['oa']['qr_code'] = FileService::getFileUrl($config['oa']['qr_code']);
|
||||
if (!empty($config['h5']['qr_code'])) $config['h5']['qr_code'] = FileService::getFileUrl($config['h5']['qr_code']);
|
||||
|
||||
return $config;
|
||||
}
|
||||
}
|
||||
84
server/app/api/logic/DecorateLogic.php
Executable file
84
server/app/api/logic/DecorateLogic.php
Executable file
@@ -0,0 +1,84 @@
|
||||
<?php
|
||||
namespace app\api\logic;
|
||||
use app\common\model\decorate\DecoratePage;
|
||||
use app\common\model\decorate\DecorateStyle;
|
||||
use app\common\model\decorate\DecorateTabbar;
|
||||
use app\common\model\goods\Goods;
|
||||
|
||||
/**
|
||||
* 装修逻辑类
|
||||
* Class DecorateLogic
|
||||
* @package app\api\logic
|
||||
*/
|
||||
class DecorateLogic
|
||||
{
|
||||
|
||||
|
||||
/**
|
||||
* @notes 获取装修页面
|
||||
* @param int $id
|
||||
* @param int $cityId
|
||||
* @return array
|
||||
* @author cjhao
|
||||
* @date 2024/10/8 15:11
|
||||
*/
|
||||
public function page(int $type,$cityId)
|
||||
{
|
||||
$detail = DecoratePage::where(['type'=>$type,'source'=>1])->findOrEmpty()->toArray();
|
||||
if(1 == $type && $cityId){
|
||||
$data = json_decode($detail['data'],true);
|
||||
foreach ($data as $key => $datum){
|
||||
if('area-goods' == $datum['name']){
|
||||
$allCityGoodsIds = Goods::alias('G')
|
||||
->leftjoin('goods_city_index GCI','G.id = GCI.goods_id')
|
||||
->where(['GCI.id '=>null,'status'=>1])
|
||||
->column('G.id');
|
||||
$cityGoodsIds = Goods::alias('G')
|
||||
->leftjoin('goods_city_index GCI','G.id = GCI.goods_id')
|
||||
->where(['status'=>1,'city_id'=>$cityId])
|
||||
->column('G.id');
|
||||
$goodsIds = array_merge($allCityGoodsIds,$cityGoodsIds);
|
||||
$showNum = $datum['content']['show_num'] ?? 1;
|
||||
$goodsLists = Goods::where(['status'=>1,'id'=>$goodsIds])
|
||||
->field('id,name,image,price,scribing_price,duration,order_num+virtual_order_num as order_num')
|
||||
->limit($showNum)
|
||||
->order('sort desc,id desc')
|
||||
->select()
|
||||
->toArray();
|
||||
$datum['content']['goods_list'] = $goodsLists;
|
||||
$data[$key] = $datum;
|
||||
$detail['data'] = json_encode($data);
|
||||
}
|
||||
}
|
||||
}
|
||||
return $detail;
|
||||
}
|
||||
|
||||
/**
|
||||
* @notes 获取装修风格
|
||||
* @return array
|
||||
* @author cjhao
|
||||
* @date 2024/10/8 15:13
|
||||
*/
|
||||
public function style()
|
||||
{
|
||||
$detail = DecorateStyle::where(['source'=>1])->findOrEmpty()->toArray();
|
||||
return $detail;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 底部菜单
|
||||
* @return array
|
||||
* @author cjhao
|
||||
* @date 2024/10/8 15:59
|
||||
*/
|
||||
public function tabbar()
|
||||
{
|
||||
$detail = DecorateTabbar::where(['source'=>1])->findOrEmpty()->toArray();
|
||||
return $detail;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
56
server/app/api/logic/GoodsCategoryLogic.php
Executable file
56
server/app/api/logic/GoodsCategoryLogic.php
Executable file
@@ -0,0 +1,56 @@
|
||||
<?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\goods\GoodsCategory;
|
||||
|
||||
class GoodsCategoryLogic extends BaseLogic
|
||||
{
|
||||
/**
|
||||
* @notes 其它分类列表
|
||||
* @param $id
|
||||
* @return array
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
* @author ljj
|
||||
* @date 2022/3/29 3:15 下午
|
||||
*/
|
||||
public function otherLists($id)
|
||||
{
|
||||
if (!$id) {
|
||||
return [];
|
||||
}
|
||||
|
||||
$category = GoodsCategory::where(['id'=>$id,'is_show'=>1])->order(['sort'=>'desc','id'=>'asc'])->findOrEmpty()->toArray();
|
||||
if (!$category) {
|
||||
return [];
|
||||
}
|
||||
|
||||
if ($category['level'] == 2) {
|
||||
$category = GoodsCategory::where(['id'=>$category['pid'],'is_show'=>1])->order(['sort'=>'desc','id'=>'asc'])->findOrEmpty()->toArray();
|
||||
}
|
||||
|
||||
$sons = GoodsCategory::where(['pid'=>$category['id'],'is_show'=>1])->order(['sort'=>'desc','id'=>'asc'])->select()->toArray();
|
||||
return ['info'=>$category,'sons'=>$sons];
|
||||
}
|
||||
}
|
||||
203
server/app/api/logic/GoodsCommentLogic.php
Executable file
203
server/app/api/logic/GoodsCommentLogic.php
Executable file
@@ -0,0 +1,203 @@
|
||||
<?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\Coach;
|
||||
use app\common\model\goods\GoodsComment;
|
||||
use app\common\model\goods\GoodsCommentImage;
|
||||
use app\common\model\order\Order;
|
||||
use app\common\model\order\OrderGoods;
|
||||
use app\common\model\shop\Shop;
|
||||
use app\common\service\FileService;
|
||||
use think\facade\Db;
|
||||
|
||||
class GoodsCommentLogic extends BaseLogic
|
||||
{
|
||||
/**
|
||||
* @notes 服务评价分类
|
||||
* @param $parmas
|
||||
* @return array
|
||||
* @author ljj
|
||||
* @date 2022/2/18 2:09 下午
|
||||
*/
|
||||
public function commentCategory($parmas)
|
||||
{
|
||||
$all_count = GoodsComment::where('goods_id', $parmas['goods_id'])->count();
|
||||
$image_count = GoodsComment::alias('gc')->where('goods_id', $parmas['goods_id'])->join('goods_comment_image gci', 'gc.id = gci.comment_id')->group('gci.comment_id')->count();
|
||||
$good_count = GoodsComment::where('goods_id', $parmas['goods_id'])->where('service_comment','>',3)->count();
|
||||
$medium_bad_count = GoodsComment::where('goods_id', $parmas['goods_id'])->where('service_comment','<=',3)->count();
|
||||
|
||||
if($all_count == 0) {
|
||||
$percentStr = '100%';
|
||||
$star = 5;
|
||||
}else {
|
||||
$percent = round((($good_count / $all_count) * 100));
|
||||
$percentStr = round((($good_count / $all_count) * 100)).'%';
|
||||
if ($percent >= 100) {
|
||||
$star = 5;
|
||||
} else if ($percent >= 80) {
|
||||
$star = 4;
|
||||
} else if ($percent >= 60) {
|
||||
$star = 3;
|
||||
} else if ($percent >= 40) {
|
||||
$star = 2;
|
||||
} else if ($percent >= 20) {
|
||||
$star = 1;
|
||||
} else {
|
||||
$star = 0;
|
||||
}
|
||||
}
|
||||
|
||||
return ['comment'=>
|
||||
[
|
||||
[
|
||||
'id' => 0,
|
||||
'name' => '全部',
|
||||
'count' => $all_count
|
||||
],
|
||||
[
|
||||
'id' => 1,
|
||||
'name' => '有图',
|
||||
'count' => $image_count
|
||||
],
|
||||
[
|
||||
'id' => 2,
|
||||
'name' => '好评',
|
||||
'count' => $good_count
|
||||
],
|
||||
[
|
||||
'id' => 3,
|
||||
'name' => '中差评',
|
||||
'count' => $medium_bad_count
|
||||
]
|
||||
] ,
|
||||
'percent' => $percentStr,
|
||||
'star' => $star,
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @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/21 6:12 下午
|
||||
*/
|
||||
public function commentGoodsInfo($params)
|
||||
{
|
||||
$info = GoodsComment::alias('GC')
|
||||
->where(['order_goods_id'=>$params['order_goods_id'],'user_id'=>$params['user_id']])
|
||||
->join('user U','U.id = GC.user_id')
|
||||
->append(['goods_comment_image'])
|
||||
->field('U.nickname,U.avatar,GC.id,GC.service_comment,GC.comment,GC.reply,GC.create_time')
|
||||
->findOrEmpty()
|
||||
->toArray();
|
||||
$info['avatar'] = FileService::getFileUrl($info['avatar']);
|
||||
|
||||
return $info;
|
||||
}
|
||||
|
||||
/**
|
||||
* @notes 添加服务评价
|
||||
* @param $params
|
||||
* @return bool
|
||||
* @author ljj
|
||||
* @date 2022/2/21 6:23 下午
|
||||
*/
|
||||
public function add($params)
|
||||
{
|
||||
// 启动事务
|
||||
Db::startTrans();
|
||||
try {
|
||||
//获取订单商品信息
|
||||
$order_goods = OrderGoods::where(['id'=>$params['order_goods_id']])->findOrEmpty();
|
||||
$order = Order::where(['id'=>$order_goods['order_id']])->findOrEmpty();
|
||||
//添加评价数据
|
||||
$goods_comment = GoodsComment::create([
|
||||
'goods_id' => $order_goods['goods_id'],
|
||||
'user_id' => $params['user_id'],
|
||||
'coach_id' => $order['coach_id'],
|
||||
'shop_id' => $order['shop_id'],
|
||||
'order_goods_id' => $order_goods['id'],
|
||||
'service_comment' => $params['service_comment'],
|
||||
'comment' => $params['comment'] ?? '',
|
||||
]);
|
||||
//添加评价图片数据
|
||||
if (isset($params['image'])) {
|
||||
$image_data = [];
|
||||
foreach ($params['image'] as $val) {
|
||||
$image_data[] = [
|
||||
'comment_id' => $goods_comment->id,
|
||||
'uri' => $val,
|
||||
];
|
||||
}
|
||||
$goods_comment_image = new GoodsCommentImage;
|
||||
$goods_comment_image->saveAll($image_data);
|
||||
}
|
||||
|
||||
//技师的好评
|
||||
\app\common\logic\CoachLogic::updateCoachComment($order['coach_id']);
|
||||
if($order['shop_id']){
|
||||
\app\common\logic\ShopLogic::updateShopComment($order['shop_id']);
|
||||
}
|
||||
//修改订单商品表评价状态
|
||||
OrderGoods::update(['is_comment' => 1], ['id' => $order_goods['id']]);
|
||||
|
||||
// 提交事务
|
||||
Db::commit();
|
||||
return true;
|
||||
} catch (\Exception $e) {
|
||||
// 回滚事务
|
||||
Db::rollback();
|
||||
self::$error = $e->getMessage();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 评价详情
|
||||
* @param $params
|
||||
* @return array
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
* @author ljj
|
||||
* @date 2024/7/31 下午5:37
|
||||
*/
|
||||
public function commentDetail($params)
|
||||
{
|
||||
$info = GoodsComment::alias('GC')
|
||||
->where(['order_goods_id'=>$params['id'],'user_id'=>$params['user_id']])
|
||||
->join('user U','U.id = GC.user_id')
|
||||
->append(['goods_comment_image'])
|
||||
->field('U.nickname,U.avatar,GC.id,GC.service_comment,GC.comment,GC.reply,GC.create_time')
|
||||
->findOrEmpty()
|
||||
->toArray();
|
||||
$info['avatar'] = FileService::getFileUrl($info['avatar']);
|
||||
|
||||
return $info;
|
||||
}
|
||||
}
|
||||
126
server/app/api/logic/GoodsLogic.php
Executable file
126
server/app/api/logic/GoodsLogic.php
Executable 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;
|
||||
}
|
||||
}
|
||||
375
server/app/api/logic/IndexLogic.php
Executable file
375
server/app/api/logic/IndexLogic.php
Executable file
@@ -0,0 +1,375 @@
|
||||
<?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\enum\DefaultEnum;
|
||||
use app\common\enum\user\UserTerminalEnum;
|
||||
use app\common\logic\BaseLogic;
|
||||
use app\common\logic\CityLogic;
|
||||
use app\common\model\coach\Collect;
|
||||
use app\common\model\decorate\DecoratePage;
|
||||
use app\common\model\goods\Goods;
|
||||
use app\common\model\goods\GoodsCategory;
|
||||
use app\common\model\goods\GoodsSearchLog;
|
||||
use app\common\model\HotSearch;
|
||||
use app\common\model\IndexVisit;
|
||||
use app\common\model\staff\Staff;
|
||||
use app\common\service\ConfigService;
|
||||
use app\common\service\TencentMapKeyService;
|
||||
use think\Exception;
|
||||
|
||||
class IndexLogic extends BaseLogic
|
||||
{
|
||||
|
||||
/**
|
||||
* @notes 搜索记录
|
||||
* @param int $userId
|
||||
* @return array
|
||||
* @author cjhao
|
||||
* @date 2024/9/5 10:47
|
||||
*/
|
||||
public function searchLog(int $userId)
|
||||
{
|
||||
$searchLog = GoodsSearchLog::where(['user_id'=>$userId])->column('keyword');
|
||||
$hotSearchLog = HotSearch::where(['user_id'=>$userId])->column('name');
|
||||
return [
|
||||
'search_log' => $searchLog,
|
||||
'hot_search_log' => $hotSearchLog
|
||||
];
|
||||
|
||||
}
|
||||
/**
|
||||
* @notes 首页信息
|
||||
* @return array
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
* @author ljj
|
||||
* @date 2022/2/23 4:48 下午
|
||||
*/
|
||||
public function index($get)
|
||||
{
|
||||
// //首页菜单
|
||||
// $home_menu = Menu::where(['decorate_type'=>MenuEnum::NAVIGATION_HOME,'status'=>DefaultEnum::SHOW])
|
||||
// ->field('id,name,image,link_type,link_address')
|
||||
// ->order(['sort'=>'asc','id'=>'desc'])
|
||||
// ->append(['link'])
|
||||
// ->select()
|
||||
// ->toArray();
|
||||
//
|
||||
// $shop_page = array_column(MenuEnum::SHOP_PAGE,NULL,'index');
|
||||
// foreach ($home_menu as &$menu) {
|
||||
// $menu['is_tab'] = 0;
|
||||
// if ($menu['link_type'] == 1) {
|
||||
// $menu['is_tab'] = $shop_page[$menu['link_address']]['is_tab'];
|
||||
// }
|
||||
// }
|
||||
|
||||
// 装修配置
|
||||
$decoratePage = DecoratePage::where('id',1)->json(['data'],true)->value('data');
|
||||
|
||||
//热门服务
|
||||
$hot_service = Goods::where(['status'=>DefaultEnum::SHOW])
|
||||
->field('id,name,remarks,image')
|
||||
->order(['order_num'=>'desc','sort'=>'asc','id'=>'desc'])
|
||||
->limit(5)
|
||||
->select()
|
||||
->toArray();
|
||||
|
||||
//师傅推荐
|
||||
$staff_where = [];
|
||||
if (isset($get['city_id']) && $get['city_id'] != '') {
|
||||
$staff_where[] = ['city_id','=',$get['city_id']];
|
||||
}
|
||||
$recommend_staff = Staff::where(['status'=>DefaultEnum::SHOW,'is_recommend'=>DefaultEnum::SHOW])
|
||||
->field('id,user_id,name,goods_ids')
|
||||
->append(['goods_name','user_image'])
|
||||
->order(['id'=>'desc'])
|
||||
->where($staff_where)
|
||||
->limit(5)
|
||||
->select()
|
||||
->toArray();
|
||||
|
||||
//首页推荐服务分类
|
||||
$recommend_goods_category = GoodsCategory::where(['is_show'=>DefaultEnum::SHOW,'is_recommend'=>DefaultEnum::SHOW,'level'=>1])
|
||||
->field('id,name')
|
||||
->order(['sort'=>'desc','id'=>'desc'])
|
||||
->select()
|
||||
->toArray();
|
||||
foreach ($recommend_goods_category as &$category) {
|
||||
$categoryIds = GoodsCategory::where(['pid'=>$category['id']])->column('id');
|
||||
Array_push($categoryIds,$category['id']);
|
||||
$category['goods'] = Goods::where(['category_id' => $categoryIds,'status'=>DefaultEnum::SHOW])
|
||||
->field('id,name,unit_id,image,price')
|
||||
->order(['sort'=>'asc','id'=>'desc'])
|
||||
->append(['unit_desc'])
|
||||
->limit(3)
|
||||
->select()->toArray();
|
||||
|
||||
foreach ($category['goods'] as &$goods) {
|
||||
$goods['price'] = trim(rtrim(sprintf("%.4f", $goods['price'] ), '0'),'.');
|
||||
}
|
||||
}
|
||||
|
||||
return [
|
||||
'decorate_age' => $decoratePage,
|
||||
'hot_service' => $hot_service,
|
||||
'recommend_staff' => $recommend_staff,
|
||||
'recommend_goods_category' => $recommend_goods_category,
|
||||
];
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 首页访客记录
|
||||
* @return bool
|
||||
* @author Tab
|
||||
* @date 2021/9/11 9:29
|
||||
*/
|
||||
public static function visit()
|
||||
{
|
||||
try {
|
||||
$params = request()->post();
|
||||
if (!isset($params['terminal']) || !in_array($params['terminal'], UserTerminalEnum::ALL_TERMINAL)) {
|
||||
throw new \Exception('终端参数缺失或有误');
|
||||
}
|
||||
$ip = request()->ip();
|
||||
// 一个ip一个终端一天只生成一条记录
|
||||
$record = IndexVisit::where([
|
||||
'ip' => $ip,
|
||||
'terminal' => $params['terminal']
|
||||
])->whereDay('create_time')->findOrEmpty();
|
||||
if (!$record->isEmpty()) {
|
||||
// 增加访客在终端的浏览量
|
||||
$record->visit += 1;
|
||||
$record->save();
|
||||
return true;
|
||||
}
|
||||
// 生成访客记录
|
||||
IndexVisit::create([
|
||||
'ip' => $ip,
|
||||
'terminal' => $params['terminal'],
|
||||
'visit' => 1
|
||||
]);
|
||||
|
||||
return true;
|
||||
} catch (\Exception $e) {
|
||||
self::setError($e->getMessage());
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @notes 地址解析(地址转坐标)
|
||||
* @param $get
|
||||
* @return array|mixed
|
||||
* @author ljj
|
||||
* @date 2022/10/13 12:06 下午
|
||||
* 本接口提供由文字地址到经纬度的转换能力,并同时提供结构化的省市区地址信息。
|
||||
*/
|
||||
public static function geocoder($get)
|
||||
{
|
||||
try {
|
||||
$get['key'] = (new TencentMapKeyService())->getTencentMapKey();
|
||||
if (empty($get['key'])) {
|
||||
return ['status'=>1,'message'=>'腾讯地图开发密钥不能为空'];
|
||||
}
|
||||
|
||||
$query = http_build_query($get);
|
||||
$url = 'https://apis.map.qq.com/ws/geocoder/v1/';
|
||||
$result = json_decode(file_get_contents($url.'?'.$query),true);
|
||||
$check = (new TencentMapKeyService())->checkResult($result);
|
||||
|
||||
|
||||
}catch (\Exception $e){
|
||||
return $e->getMessage();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @notes 逆地址解析(坐标位置描述)
|
||||
* @param $get
|
||||
* @return array|mixed
|
||||
* @author ljj
|
||||
* @date 2022/10/13 2:44 下午
|
||||
* 本接口提供由经纬度到文字地址及相关位置信息的转换能力
|
||||
*/
|
||||
public static function geocoderCoordinate($get)
|
||||
{
|
||||
$get['key'] = (new TencentMapKeyService())->getTencentMapKey();
|
||||
if (empty($get['key'])) {
|
||||
return ['status'=>1,'message'=>'腾讯地图开发密钥不能为空'];
|
||||
}
|
||||
|
||||
$query = http_build_query($get);
|
||||
$url = 'https://apis.map.qq.com/ws/geocoder/v1/';
|
||||
$result = json_decode(file_get_contents($url.'?'.$query),true);
|
||||
if ($result['status'] !== 0) {
|
||||
$check = (new TencentMapKeyService())->checkResult($result);
|
||||
while (!$check) {
|
||||
$data['key'] = (new TencentMapKeyService())->getTencentMapKey(true);
|
||||
if (empty($data['key'])) {
|
||||
break;
|
||||
}
|
||||
|
||||
$query = http_build_query($data);
|
||||
$result = json_decode(file_get_contents($url . '?' . $query), true);
|
||||
$check = (new TencentMapKeyService())->checkResult($result);
|
||||
}
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* @notes 搜索附近地址
|
||||
* @param $params
|
||||
* @return array|mixed
|
||||
* @author ljj
|
||||
* @date 2024/7/23 上午11:20
|
||||
*/
|
||||
public function getNearbyLocation($params)
|
||||
{
|
||||
$longitude = $params['longitude'] ?? '';
|
||||
$latitude = $params['latitude'] ?? '';
|
||||
if(empty($longitude) || empty($latitude)){
|
||||
throw new Exception('请授权获取位置');
|
||||
}
|
||||
//开发秘钥
|
||||
$data['key'] = (new TencentMapKeyService())->getTencentMapKey();
|
||||
if (empty($data['key'])) {
|
||||
return ['status'=>1,'message'=>'腾讯地图开发密钥不能为空'];
|
||||
}
|
||||
|
||||
//排序,按距离由近到远排序
|
||||
$data['orderby'] = '_distance';
|
||||
//排序,按距离由近到远排序
|
||||
$data['boundary'] = "nearby(" . $params['latitude'] . "," . $params['longitude'] . ",1000,1)";
|
||||
//搜索关键字
|
||||
$keyword = $params['keyword'] ?? '';
|
||||
//api地址
|
||||
//未输入搜索关键词时,默认使用周边推荐api
|
||||
$url = 'https://apis.map.qq.com/ws/place/v1/explore';
|
||||
|
||||
if (!empty($keyword)) {
|
||||
$data['keyword'] = $keyword;
|
||||
//输入搜索关键词时,使用周边搜索api
|
||||
$url = 'https://apis.map.qq.com/ws/place/v1/search';
|
||||
}
|
||||
$query = http_build_query($data);
|
||||
$result = json_decode(file_get_contents($url . '?' . $query), true);
|
||||
if ($result['status'] !== 0) {
|
||||
$check = (new TencentMapKeyService())->checkResult($result);
|
||||
while (!$check) {
|
||||
$data['key'] = (new TencentMapKeyService())->getTencentMapKey(true);
|
||||
if (empty($data['key'])) {
|
||||
break;
|
||||
}
|
||||
|
||||
$query = http_build_query($data);
|
||||
$result = json_decode(file_get_contents($url . '?' . $query), true);
|
||||
$check = (new TencentMapKeyService())->checkResult($result);
|
||||
}
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 获取当前位置最近的城市
|
||||
* @param $get
|
||||
* @return array|false
|
||||
* @author cjhao
|
||||
* @date 2024/9/3 22:58
|
||||
*/
|
||||
public function getNearbyCity($get)
|
||||
{
|
||||
try {
|
||||
$longitude = $get['longitude'] ?? '';
|
||||
$latitude = $get['latitude'] ?? '';
|
||||
// if(empty($longitude) || empty($latitude)){
|
||||
// throw new Exception('请授权获取位置');
|
||||
// }
|
||||
$cityLists = CityLogic::getNearbyCity($longitude,$latitude);
|
||||
return $cityLists[0] ?? [];
|
||||
|
||||
}catch (Exception $e){
|
||||
self::$error = $e->getMessage();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @notes 获取首页服务列表
|
||||
* @param $params
|
||||
* @return string
|
||||
* @author cjhao
|
||||
* @date 2024/9/3 23:10
|
||||
*/
|
||||
public function serverLists($params)
|
||||
{
|
||||
try {
|
||||
$cityId = $params['city_id'] ?? '';
|
||||
if(empty($cityId)){
|
||||
throw new Exception('请先授权获取当前位置');
|
||||
}
|
||||
$lists = Goods::alias('G')
|
||||
->join('goods_city_index GCI','G.id = GCI.goods_id')
|
||||
->where(['city_id'=>$cityId])
|
||||
->field('G.id,name,image,price,scribing_price,duration,order_num')
|
||||
->limit()
|
||||
->select()
|
||||
->toArray();
|
||||
return $lists;
|
||||
|
||||
}catch (Exception $e) {
|
||||
return $e->getMessage();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @notes 收藏接口
|
||||
* @param $params
|
||||
* @param $userId
|
||||
* @return true
|
||||
* @author cjhao
|
||||
* @date 2024/9/5 09:32
|
||||
*/
|
||||
public function collect($params,$userId)
|
||||
{
|
||||
$id = $params['id'] ?? '';
|
||||
$type = $params['type'] ?? '';
|
||||
$collect = Collect::where(['user_id'=>$userId,'type'=>$type,'relation_id'=>$id])
|
||||
->findOrEmpty();
|
||||
if($collect->isEmpty()){
|
||||
Collect::create([
|
||||
'user_id'=>$userId,
|
||||
'relation_id'=>$id,
|
||||
'type' => $type
|
||||
]);
|
||||
}else{
|
||||
$collect->delete();
|
||||
}
|
||||
return true;
|
||||
|
||||
}
|
||||
}
|
||||
369
server/app/api/logic/LoginLogic.php
Executable file
369
server/app/api/logic/LoginLogic.php
Executable file
@@ -0,0 +1,369 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | likeadmin快速开发前后端分离管理后台(PHP版)
|
||||
// +----------------------------------------------------------------------
|
||||
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
|
||||
// | 开源版本可自由商用,可去除界面版权logo
|
||||
// | gitee下载:https://gitee.com/likeshop_gitee/likeadmin
|
||||
// | github下载:https://github.com/likeshop-github/likeadmin
|
||||
// | 访问官网:https://www.likeadmin.cn
|
||||
// | likeadmin团队 版权所有 拥有最终解释权
|
||||
// +----------------------------------------------------------------------
|
||||
// | author: likeadminTeam
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
namespace app\api\logic;
|
||||
|
||||
use app\api\service\{UserTokenService, WechatUserService};
|
||||
use app\common\enum\{LoginEnum, user\UserTerminalEnum};
|
||||
use app\common\logic\BaseLogic;
|
||||
use app\common\model\user\{User, UserAuth, UserSession};
|
||||
use app\common\service\{ConfigService, FileService, WeChatService};
|
||||
use think\facade\{Config, Db};
|
||||
|
||||
/**
|
||||
* 登录逻辑
|
||||
* Class LoginLogic
|
||||
* @package app\api\logic
|
||||
*/
|
||||
class LoginLogic extends BaseLogic
|
||||
{
|
||||
|
||||
/**
|
||||
* @notes 账号密码注册
|
||||
* @param array $params
|
||||
* @return bool
|
||||
* @author 段誉
|
||||
* @date 2022/9/7 15:37
|
||||
*/
|
||||
public static function register(array $params)
|
||||
{
|
||||
try {
|
||||
$userSn = User::createUserSn();
|
||||
$passwordSalt = Config::get('project.unique_identification');
|
||||
$password = create_password($params['password'], $passwordSalt);
|
||||
$avatar = ConfigService::get('default_image', 'user_avatar');
|
||||
|
||||
User::create([
|
||||
'sn' => $userSn,
|
||||
'avatar' => $avatar,
|
||||
'nickname' => '用户' . $userSn,
|
||||
'account' => $params['account'],
|
||||
'password' => $password,
|
||||
'channel' => $params['channel'],
|
||||
]);
|
||||
|
||||
return true;
|
||||
} catch (\Exception $e) {
|
||||
self::setError($e->getMessage());
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 账号/手机号登录,手机号验证码
|
||||
* @param $params
|
||||
* @return array|false
|
||||
* @author 段誉
|
||||
* @date 2022/9/6 19:26
|
||||
*/
|
||||
public static function login($params)
|
||||
{
|
||||
try {
|
||||
// 账号/手机号 密码登录
|
||||
$where = ['account|mobile' => $params['account']];
|
||||
if ($params['scene'] == LoginEnum::MOBILE_CAPTCHA) {
|
||||
//手机验证码登录
|
||||
$where = ['mobile' => $params['account']];
|
||||
}
|
||||
|
||||
$user = User::where($where)->findOrEmpty();
|
||||
if ($user->isEmpty()) {
|
||||
throw new \Exception('用户不存在');
|
||||
}
|
||||
|
||||
//更新登录信息
|
||||
$user->login_time = time();
|
||||
$user->login_ip = request()->ip();
|
||||
$user->save();
|
||||
|
||||
//设置token
|
||||
$userInfo = UserTokenService::setToken($user->id, $params['terminal']);
|
||||
|
||||
//返回登录信息
|
||||
$avatar = $user->avatar ?: Config::get('project.default_image.user_avatar');
|
||||
$avatar = FileService::getFileUrl($avatar);
|
||||
|
||||
return [
|
||||
'nickname' => $userInfo['nickname'],
|
||||
'sn' => $userInfo['sn'],
|
||||
'mobile' => $userInfo['mobile'],
|
||||
'avatar' => $avatar,
|
||||
'token' => $userInfo['token'],
|
||||
];
|
||||
} catch (\Exception $e) {
|
||||
self::setError($e->getMessage());
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 退出登录
|
||||
* @param $userInfo
|
||||
* @return bool
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
* @author 段誉
|
||||
* @date 2022/9/16 17:56
|
||||
*/
|
||||
public static function logout($userInfo)
|
||||
{
|
||||
//token不存在,不注销
|
||||
if (!isset($userInfo['token'])) {
|
||||
return false;
|
||||
}
|
||||
|
||||
//设置token过期
|
||||
return UserTokenService::expireToken($userInfo['token']);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 获取微信请求code的链接
|
||||
* @param string $url
|
||||
* @return string
|
||||
* @author 段誉
|
||||
* @date 2022/9/20 19:47
|
||||
*/
|
||||
public static function codeUrl(string $url)
|
||||
{
|
||||
return WeChatService::getCodeUrl($url);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 公众号登录
|
||||
* @param array $params
|
||||
* @return array|false
|
||||
* @throws \GuzzleHttp\Exception\GuzzleException
|
||||
* @author 段誉
|
||||
* @date 2022/9/20 19:47
|
||||
*/
|
||||
public static function oaLogin(array $params)
|
||||
{
|
||||
Db::startTrans();
|
||||
try {
|
||||
//通过code获取微信 openid
|
||||
$response = WeChatService::getOaResByCode($params);
|
||||
$userServer = new WechatUserService($response, UserTerminalEnum::WECHAT_OA);
|
||||
$userInfo = $userServer->getResopnseByUserInfo()->authUserLogin()->getUserInfo();
|
||||
|
||||
// 更新登录信息
|
||||
self::updateLoginInfo($userInfo['id']);
|
||||
|
||||
Db::commit();
|
||||
return $userInfo;
|
||||
|
||||
} catch (\Exception $e) {
|
||||
Db::rollback();
|
||||
self::$error = $e->getMessage();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 小程序-静默登录
|
||||
* @param array $params
|
||||
* @return array|false
|
||||
* @author 段誉
|
||||
* @date 2022/9/20 19:47
|
||||
*/
|
||||
public static function silentLogin(array $params)
|
||||
{
|
||||
try {
|
||||
//通过code获取微信 openid
|
||||
$response = WeChatService::getMnpResByCode($params);
|
||||
$userServer = new WechatUserService($response, UserTerminalEnum::WECHAT_MMP);
|
||||
$userInfo = $userServer->getResopnseByUserInfo('silent')->getUserInfo();
|
||||
|
||||
if (!empty($userInfo)) {
|
||||
// 更新登录信息
|
||||
self::updateLoginInfo($userInfo['id']);
|
||||
}
|
||||
|
||||
return $userInfo;
|
||||
} catch (\Exception $e) {
|
||||
self::$error = $e->getMessage();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 小程序-授权登录
|
||||
* @param array $params
|
||||
* @return array|false
|
||||
* @author 段誉
|
||||
* @date 2022/9/20 19:47
|
||||
*/
|
||||
public static function mnpLogin(array $params)
|
||||
{
|
||||
Db::startTrans();
|
||||
try {
|
||||
//通过code获取微信 openid
|
||||
$response = WeChatService::getMnpResByCode($params);
|
||||
$userServer = new WechatUserService($response, UserTerminalEnum::WECHAT_MMP);
|
||||
$userInfo = $userServer->getResopnseByUserInfo()->authUserLogin()->getUserInfo();
|
||||
|
||||
// 更新登录信息
|
||||
self::updateLoginInfo($userInfo['id']);
|
||||
|
||||
Db::commit();
|
||||
return $userInfo;
|
||||
} catch (\Exception $e) {
|
||||
Db::rollback();
|
||||
self::$error = $e->getMessage();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 更新登录信息
|
||||
* @param $userId
|
||||
* @throws \Exception
|
||||
* @author 段誉
|
||||
* @date 2022/9/20 19:46
|
||||
*/
|
||||
public static function updateLoginInfo($userId)
|
||||
{
|
||||
$user = User::findOrEmpty($userId);
|
||||
if ($user->isEmpty()) {
|
||||
throw new \Exception('用户不存在');
|
||||
}
|
||||
|
||||
$time = time();
|
||||
$user->login_time = $time;
|
||||
$user->login_ip = request()->ip();
|
||||
$user->update_time = $time;
|
||||
$user->save();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 小程序端绑定微信
|
||||
* @param array $params
|
||||
* @return bool
|
||||
* @author 段誉
|
||||
* @date 2022/9/20 19:46
|
||||
*/
|
||||
public static function mnpAuthLogin(array $params)
|
||||
{
|
||||
try {
|
||||
//通过code获取微信openid
|
||||
$response = WeChatService::getMnpResByCode($params);
|
||||
$response['user_id'] = $params['user_id'];
|
||||
$response['terminal'] = UserTerminalEnum::WECHAT_MMP;
|
||||
|
||||
return self::createAuth($response);
|
||||
|
||||
} catch (\Exception $e) {
|
||||
self::$error = $e->getMessage();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 公众号端绑定微信
|
||||
* @param array $params
|
||||
* @return bool
|
||||
* @throws \GuzzleHttp\Exception\GuzzleException
|
||||
* @author 段誉
|
||||
* @date 2022/9/16 10:43
|
||||
*/
|
||||
public static function oaAuthLogin(array $params)
|
||||
{
|
||||
try {
|
||||
//通过code获取微信openid
|
||||
$response = WeChatService::getOaResByCode($params);
|
||||
$response['user_id'] = $params['user_id'];
|
||||
$response['terminal'] = UserTerminalEnum::WECHAT_OA;
|
||||
|
||||
return self::createAuth($response);
|
||||
|
||||
} catch (\Exception $e) {
|
||||
self::$error = $e->getMessage();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 生成授权记录
|
||||
* @param $response
|
||||
* @return bool
|
||||
* @throws \Exception
|
||||
* @author 段誉
|
||||
* @date 2022/9/16 10:43
|
||||
*/
|
||||
public static function createAuth($response)
|
||||
{
|
||||
//先检查openid是否有记录
|
||||
$isAuth = UserAuth::where('openid', '=', $response['openid'])->findOrEmpty();
|
||||
if (!$isAuth->isEmpty()) {
|
||||
throw new \Exception('当前已绑定该微信');
|
||||
}
|
||||
|
||||
if (isset($response['unionid']) && !empty($response['unionid'])) {
|
||||
//在用unionid找记录,防止生成两个账号,同个unionid的问题
|
||||
$userAuth = UserAuth::where(['unionid' => $response['unionid']])
|
||||
->findOrEmpty();
|
||||
if (!$userAuth->isEmpty() && $userAuth->user_id != $response['user_id']) {
|
||||
throw new \Exception('当前已绑定该微信');
|
||||
}
|
||||
}
|
||||
|
||||
//如果没有授权,直接生成一条微信授权记录
|
||||
UserAuth::create([
|
||||
'user_id' => $response['user_id'],
|
||||
'openid' => $response['openid'],
|
||||
'unionid' => $response['unionid'] ?? '',
|
||||
'terminal' => $response['terminal'],
|
||||
]);
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @notes 解绑微信(测试用)
|
||||
* @param $user_id
|
||||
* @return bool
|
||||
* @author ljj
|
||||
* @date 2023/1/11 10:35 上午
|
||||
*/
|
||||
public static function unbinding($user_id)
|
||||
{
|
||||
$session = UserSession::where(['user_id'=>$user_id])->findOrEmpty()->toArray();
|
||||
UserAuth::where(['user_id'=>$user_id,'terminal'=>$session['terminal']])->delete();
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @notes 更新用户头像昵称
|
||||
* @param $post
|
||||
* @param $user_id
|
||||
* @return bool
|
||||
* @throws \think\db\exception\DbException
|
||||
* @author ljj
|
||||
* @date 2023/2/2 6:36 下午
|
||||
*/
|
||||
public static function updateUser($post,$user_id)
|
||||
{
|
||||
Db::name('user')->where(['id'=>$user_id])->update(['nickname'=>$post['nickname'],'avatar'=>FileService::setFileUrl($post['avatar']),'is_new_user'=>0]);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
892
server/app/api/logic/OrderLogic.php
Executable file
892
server/app/api/logic/OrderLogic.php
Executable file
@@ -0,0 +1,892 @@
|
||||
<?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\enum\GoodsEnum;
|
||||
use app\common\enum\notice\NoticeEnum;
|
||||
use app\common\enum\OrderEnum;
|
||||
use app\common\enum\OrderLogEnum;
|
||||
use app\common\enum\OrderRefundEnum;
|
||||
use app\common\enum\PayEnum;
|
||||
use app\common\enum\YesNoEnum;
|
||||
use app\common\logic\BaseLogic;
|
||||
use app\common\logic\OrderLogLogic;
|
||||
use app\common\logic\RefundLogic;
|
||||
use app\common\model\city\City;
|
||||
use app\common\model\coach\Coach;
|
||||
use app\common\model\deposit\DepositPackage;
|
||||
use app\common\model\goods\Goods;
|
||||
use app\common\model\goods\GoodsComment;
|
||||
use app\common\model\goods\GoodsCommentImage;
|
||||
use app\common\model\order\Order;
|
||||
use app\common\model\order\OrderAppend;
|
||||
use app\common\model\order\OrderGap;
|
||||
use app\common\model\order\OrderGoods;
|
||||
use app\common\model\pay\PayWay;
|
||||
use app\common\model\RechargeOrder;
|
||||
use app\common\model\shop\Shop;
|
||||
use app\common\model\user\User;
|
||||
use app\common\model\user\UserAddress;
|
||||
use app\common\service\ConfigService;
|
||||
use app\common\service\FileService;
|
||||
use DateTime;
|
||||
use think\Exception;
|
||||
use think\facade\Db;
|
||||
|
||||
class OrderLogic extends BaseLogic
|
||||
{
|
||||
/**
|
||||
* @notes 订单结算详情
|
||||
* @param $params
|
||||
* @return array|false
|
||||
* @author ljj
|
||||
* @date 2022/2/24 6:19 下午
|
||||
*/
|
||||
public function settlement($params)
|
||||
{
|
||||
try {
|
||||
//获取用户信息
|
||||
$user = User::findOrEmpty($params['user_id'])->toArray();
|
||||
$addressId = $params['address_id'] ?? 0;
|
||||
$tripWay = $params['trip_way'] ?? 0;
|
||||
$appointTime = $params['appoint_time'] ?? '';
|
||||
$carAmount = 0;//车费
|
||||
$city = [];//当前城市
|
||||
$tripWayLists = [];//出行方式列表
|
||||
$userAddress = []; //地址
|
||||
$coach = [];//技师信息
|
||||
$distance = '';//订单距离
|
||||
$tips = '';
|
||||
$coach = Coach::where(['id'=>$params['coach_id']])
|
||||
->field( 'id,shop_id,sn,work_photo,name,longitude,latitude,longitude_location,latitude_location,deposit,work_status,server_status')
|
||||
->findOrEmpty()
|
||||
->toArray();
|
||||
if(empty($coach)){
|
||||
throw new Exception('技师不存在');
|
||||
}
|
||||
if(0 == $coach['work_status']){
|
||||
throw new Exception('技师休息中');
|
||||
}
|
||||
if(0 == $coach['server_status']){
|
||||
throw new Exception('技师已暂停服务');
|
||||
}
|
||||
//获取服务信息
|
||||
$goodsInfo = self::getOrderGoods($params['goods'],$params['appoint_time'] ?? 0);
|
||||
if($appointTime){
|
||||
if($appointTime <= time()){
|
||||
throw new Exception('服务时间不能小于当前时间');
|
||||
}
|
||||
$serverTimeLists = $this->getCoachServerTime($params['coach_id'],$params['goods'][0]['id']);
|
||||
$serverTimeLists = array_column($serverTimeLists,null,'time_date');
|
||||
//预约天
|
||||
$appointTimeMd = date('m-d',$appointTime);
|
||||
//预约小时
|
||||
$appointTimeHi = date('H:i',$appointTime);
|
||||
$timeLists = $serverTimeLists[$appointTimeMd]['time_lists'] ?? [];
|
||||
|
||||
if(empty($timeLists)){
|
||||
throw new Exception('预约时间错误');
|
||||
}
|
||||
$timeLists = array_column($timeLists,null,'time');
|
||||
$time = $timeLists[$appointTimeHi] ?? [];
|
||||
if(empty($time)){
|
||||
throw new Exception('预约时间段错误');
|
||||
}
|
||||
if(2 == $time['status']){
|
||||
throw new Exception('当前时间技师休息中,无法预约');
|
||||
}
|
||||
if(3 == $time['status']){
|
||||
throw new Exception('当前时间区间有被预约,请更换其他时间区间');
|
||||
}
|
||||
$totalDuration = $goodsInfo['total_duration'];
|
||||
$dateTime = new DateTime(date('Y-m-d H:i:s',$appointTime));
|
||||
if($totalDuration > 30){
|
||||
$nums = intval($totalDuration / 30);
|
||||
for ($i = 0;$nums > $i;$i++){
|
||||
$dateTime->modify('+30 minutes');
|
||||
$appointTimeEnd = strtotime($dateTime->format('Y-m-d H:i'));
|
||||
}
|
||||
}else{
|
||||
$dateTime->modify('+'. $totalDuration.' minutes');
|
||||
$appointTimeEnd = strtotime($dateTime->format('Y-m-d H:i'));
|
||||
}
|
||||
$appointTimeEnd = round_date_time($appointTimeEnd);
|
||||
$appointTimeEndMd = date('m-d',$appointTimeEnd);
|
||||
$appointTimeEndHi = date('H:i',$appointTimeEnd);
|
||||
$timeLists = $serverTimeLists[$appointTimeEndMd]['time_lists'] ?? [];
|
||||
$timeLists = array_column($timeLists,null,'time');
|
||||
$time = $timeLists[$appointTimeEndHi] ?? [];
|
||||
if(empty($time)){
|
||||
throw new Exception('当前时间区间有被预约,请更换其他时间区间');
|
||||
}
|
||||
if(2 == $time['status']){
|
||||
throw new Exception('当前时间技师休息中,无法预约');
|
||||
}
|
||||
if(3 == $time['status']){
|
||||
throw new Exception('当前时间区间有被预约,请更换其他时间区间');
|
||||
}
|
||||
}
|
||||
//验证技师的接单数量
|
||||
// $this->ckechCoachTakeOrderNum($coach);
|
||||
|
||||
|
||||
//设置用户地址
|
||||
$userAddress = UserAddress::getUserAddress($params['user_id'], $addressId);
|
||||
$goodsCityLists = $goodsInfo['city_lists'];
|
||||
if($userAddress){
|
||||
$file = 'id,shop_id,sn,work_photo,name,round(st_distance_sphere(point('.$userAddress['longitude'].','.$userAddress['latitude'].'),
|
||||
point(longitude_location, latitude_location))/1000,2) as distance';
|
||||
if(empty($coach['longitude_location']) || empty($coach['latitude_location'])){
|
||||
$file ='id,shop_id,sn,work_photo,name,round(st_distance_sphere(point('.$userAddress['longitude'].','.$userAddress['latitude'].'),
|
||||
point(longitude, latitude))/1000,2) as distance';
|
||||
}
|
||||
$coach = Coach::where(['id'=>$params['coach_id']])
|
||||
->field( $file)
|
||||
->findOrEmpty()
|
||||
->toArray();
|
||||
|
||||
// if(empty($userAddress)){
|
||||
// throw new Exception('用户地址不存在,请重新选择');
|
||||
// }
|
||||
$city = City::where(['city_id'=>$userAddress['city_id']])->findOrEmpty()->toArray();
|
||||
if($addressId && empty($city)){
|
||||
throw new Exception('当前城市未开通出行方式,请联系管理员');
|
||||
}
|
||||
if($addressId && true !== $goodsCityLists && !in_array($userAddress['city_id'],$goodsCityLists)){
|
||||
throw new Exception('抱歉,商品暂不支持该服务地址');
|
||||
}
|
||||
$coachServerScope = ConfigService::get('server_setting', 'coach_server_scope');
|
||||
if($addressId && $coach['distance'] > $coachServerScope){
|
||||
throw new Exception('当前最大服务范围'.$coachServerScope.'公里,请重新选择地址');
|
||||
}
|
||||
$distance = intval(ceil($coach['distance']));
|
||||
$tips = '全程'.$coach['distance'].'公里,出租出行收取来回费用,白天起步价'.$city['start_price'].'元,超过'.$city['start_km'].'公里部分,每公里'.$city['continue_price'].'元';
|
||||
if($city['taxi']){
|
||||
$amount = 0;
|
||||
if($distance <= $city['start_km']){
|
||||
$amount = $city['start_price'];
|
||||
}else{
|
||||
$amount += $city['start_price'];
|
||||
$surplus = round($distance-$city['start_km'],2);
|
||||
$amount += round($city['continue_price'] * $surplus,2);
|
||||
}
|
||||
$tripWayLists[] = [
|
||||
'type' => OrderEnum::TRIP_WAY_TAXI,
|
||||
'type_desc' => OrderEnum::getTripWayDesc(OrderEnum::TRIP_WAY_TAXI),
|
||||
'tips' => $tips,
|
||||
'amount' => round($amount,2),
|
||||
];
|
||||
}
|
||||
$nowH = date('H');
|
||||
if($city['bus'] && $nowH > $city['bus_start_time'] && $city['bus_end_time'] > $nowH){
|
||||
$tips = '当前城市'.$city['bus_start_time'].'-'.$city['bus_end_time'].'可选择交通地铁出行方式';
|
||||
$tripWayLists[] = [
|
||||
'type' => OrderEnum::TRIP_WAY_BUS,
|
||||
'type_desc' => OrderEnum::getTripWayDesc(OrderEnum::TRIP_WAY_BUS),
|
||||
'tips' => $tips,
|
||||
'amount' => $city['bus_fare'],
|
||||
];
|
||||
}
|
||||
$tripWayLists = array_column($tripWayLists,null,'type');
|
||||
$carAmount = $tripWayLists[$tripWay]['amount'] ?? 0;
|
||||
}
|
||||
// 订单金额
|
||||
$totalAmount = round($goodsInfo['total_amount']+$carAmount,2);
|
||||
//订单应付金额
|
||||
$orderAmount = $totalAmount;
|
||||
//订单服务总数量
|
||||
$totalNum = $goodsInfo['total_num'];
|
||||
//订单服务总价
|
||||
$totalGoodsPrice = $goodsInfo['total_amount'];
|
||||
$result = [
|
||||
'terminal' => $params['terminal'],
|
||||
'total_num' => $totalNum,
|
||||
'total_goods_price' => $totalGoodsPrice,
|
||||
'total_amount' => $orderAmount,
|
||||
'order_amount' => $orderAmount,
|
||||
'user_id' => $user['id'],
|
||||
'user_remark' => $params['user_remark'] ?? '',
|
||||
'appoint_time' => $params['appoint_time'] ?? '',
|
||||
'address' => $userAddress,
|
||||
'goods' => $goodsInfo['goods_lists'],
|
||||
'trip_way_lists' => array_values($tripWayLists),
|
||||
'trip_way' => $tripWay,
|
||||
'city' => $city,
|
||||
'coach_id' => $params['coach_id'] ?? '',
|
||||
'coach' => $coach,
|
||||
'total_duration' => $goodsInfo['total_duration'],
|
||||
'distance' => $distance,
|
||||
'distance_desc' => $distance ? $coach['distance'].'km' : $distance,
|
||||
'pay_way_list' => PayLogic::getPayWayList($params['terminal'],$params['user_id']),
|
||||
'car_amount' => $carAmount,
|
||||
'city_lists' => $goodsInfo['city_lists'],
|
||||
];
|
||||
return $result;
|
||||
|
||||
} catch (\Exception $e) {
|
||||
self::$error = $e->getMessage();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 验证技师的接单数量
|
||||
* @param $coach
|
||||
* @return int|mixed
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
* @author cjhao
|
||||
* @date 2024/11/26 23:44
|
||||
*/
|
||||
public function ckechCoachTakeOrderNum($coach){
|
||||
$deposit = $coach['deposit'];
|
||||
$depositPackageLists = [];
|
||||
$takeOrderNum = 0;
|
||||
if($coach['shop_id']){
|
||||
$deposit = Shop::where(['id'=>$coach['shop_id']])->value('deposit');
|
||||
$where[] = ['type','=',1];
|
||||
$orderNum = Order::where(['shop_id'=>$coach['shop_id']])
|
||||
->where('order_status','>=',OrderEnum::ORDER_STATUS_WAIT_RECEIVING)
|
||||
->where('order_status','<',OrderEnum::ORDER_STATUS_CLOSE)
|
||||
->whereDay('create_time')->count();
|
||||
}else{
|
||||
$where[] = ['type','=',2];
|
||||
$orderNum = Order::where(['coach_id'=>$coach['id']])
|
||||
->where('order_status','>=',OrderEnum::ORDER_STATUS_WAIT_RECEIVING)
|
||||
->where('order_status','<',OrderEnum::ORDER_STATUS_CLOSE)
|
||||
->whereDay('create_time')->count();
|
||||
}
|
||||
$depositPackageLists = DepositPackage::where($where)->order('money desc')->select()->toArray();
|
||||
//套餐列表
|
||||
foreach ($depositPackageLists as $depositPackage){
|
||||
if($deposit >= $depositPackage['money']){
|
||||
$takeOrderNum = $depositPackage['order_limit'];
|
||||
break;
|
||||
|
||||
}
|
||||
}
|
||||
if($orderNum >= $takeOrderNum){
|
||||
throw new Exception('技师接单数量已达上限');
|
||||
}
|
||||
}
|
||||
/**
|
||||
* @notes 获取订单服务信息
|
||||
* @param $goods
|
||||
* @return array
|
||||
* @author ljj
|
||||
* @date 2022/2/24 6:09 下午
|
||||
*/
|
||||
public function getOrderGoods($postGoods,$appointTime)
|
||||
{
|
||||
$postGoods = array_column($postGoods,null,'id');
|
||||
$goodsLists = (new Goods())->field('id,status,name,shop_id,tags,duration,image,price,overtime_price,overtime_duration,shop_ratio,commission_ratio,appoint_start_time,appoint_end_time')
|
||||
->where(['id'=>array_keys($postGoods),'audit_status'=>GoodsEnum::AUDIT_STATUS_PASS])
|
||||
->with(['goods_city'])
|
||||
->select()
|
||||
->toArray();
|
||||
if(count($goodsLists) != count($postGoods)){
|
||||
throw new Exception('商品已失效,请返回上个页面重新选择服务');
|
||||
}
|
||||
$totalAmount = 0;
|
||||
$totalNum = 0;
|
||||
$totalDuration = 0;
|
||||
$cityLists = [];
|
||||
$appointStartI = date('H:i',$appointTime);
|
||||
foreach ($goodsLists as $key => $goods){
|
||||
$goodsNum = $postGoods[$goods['id']]['goods_num'] ?? 0;
|
||||
if(0 >= $goodsNum){
|
||||
throw new Exception('商品数量或商品数据错误');
|
||||
}
|
||||
$goodsLists[$key]['goods_num'] = $goodsNum;
|
||||
$totalAmount += round($goods['price'] * $goodsNum,2);
|
||||
$totalNum += $goodsNum;
|
||||
$totalDuration += ($goods['duration'] * $goodsNum);
|
||||
$appointEndI = date('H:i',$appointTime+$goods['duration'] * 60);
|
||||
if($goods['appoint_start_time'] >! $appointStartI && $goods['appoint_start_time'] <! $appointEndI){
|
||||
throw new Exception('商品服务时间为:'.$goods['appoint_start_time'].'~'.$goods['appoint_end_time']);
|
||||
}
|
||||
if($goods['appoint_end_time'] >! $appointStartI && $goods['appoint_end_time'] < !$appointEndI){
|
||||
throw new Exception('商品服务时间为:'.$goods['appoint_start_time'].'~'.$goods['appoint_end_time']);
|
||||
}
|
||||
if(empty($goods['status'])){
|
||||
throw new Exception('商品已下架,请返回上个页面重新选择服务');
|
||||
}
|
||||
if($goods['goods_city']){
|
||||
foreach ($goods['goods_city'] as $city){
|
||||
$cityLists[] = $city['city_id'];
|
||||
}
|
||||
}else{
|
||||
$cityLists = true;
|
||||
}
|
||||
}
|
||||
//服务数量
|
||||
return [
|
||||
'goods_lists' => $goodsLists,
|
||||
'total_amount' => $totalAmount,
|
||||
'total_num' => $totalNum,
|
||||
'total_duration'=> $totalDuration,
|
||||
'city_lists' => $cityLists,
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @notes 提交订单
|
||||
* @param $params
|
||||
* @return array|false
|
||||
* @author ljj
|
||||
* @date 2022/2/25 9:40 上午
|
||||
*/
|
||||
public function submitOrder($params)
|
||||
{
|
||||
Db::startTrans();
|
||||
try {
|
||||
|
||||
$this->submitOrderCheck($params);
|
||||
//创建订单信息
|
||||
$order = self::addOrder($params);
|
||||
//订单日志
|
||||
(new OrderLogLogic())->record(OrderLogEnum::TYPE_USER,OrderLogEnum::USER_ADD_ORDER,$order['id'],$params['user_id']);
|
||||
|
||||
//提交事务
|
||||
Db::commit();
|
||||
return ['order_id' => $order['id'], 'type' => 'order'];
|
||||
} catch (\Exception $e) {
|
||||
Db::rollback();
|
||||
self::$error = $e->getMessage();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @notes 创建订单信息
|
||||
* @param $params
|
||||
* @return Order|\think\Model
|
||||
* @author ljj
|
||||
* @date 2022/2/25 9:40 上午
|
||||
*/
|
||||
public static function addOrder($params)
|
||||
{
|
||||
|
||||
$serverFinishTime = $params['appoint_time'] + ($params['total_duration'] * 60);
|
||||
$shopId = 0;
|
||||
if($params['goods'][0]['shop_id']){
|
||||
$shopId = $params['goods'][0]['shop_id'];
|
||||
}
|
||||
if($params['coach']['shop_id']){
|
||||
$shopId = $params['coach']['shop_id'];
|
||||
}
|
||||
//创建订单信息
|
||||
$order = Order::create([
|
||||
'sn' => generate_sn((new Order()), 'sn'),
|
||||
'user_id' => $params['user_id'],
|
||||
'shop_id' => $shopId,
|
||||
'coach_id' => $params['coach_id'],
|
||||
'order_terminal' => $params['terminal'],
|
||||
'goods_price' => $params['total_goods_price'],
|
||||
'total_order_amount' => $params['order_amount'],
|
||||
'order_amount' => $params['order_amount'],
|
||||
'total_amount' => $params['total_amount'],
|
||||
'total_num' => $params['total_num'],
|
||||
'user_remark' => $params['user_remark'],
|
||||
'contact' => $params['address']['contact'],
|
||||
'mobile' => $params['address']['mobile'],
|
||||
'province_id' => $params['address']['province_id'],
|
||||
'city_id' => $params['address']['city_id'],
|
||||
'district_id' => $params['address']['district_id'],
|
||||
'address_id' => $params['address']['id'],
|
||||
'address_snap' => json_encode($params['address']),
|
||||
'trip_way' => $params['trip_way'],
|
||||
'appoint_time' => $params['appoint_time'],
|
||||
'server_finish_time' => $serverFinishTime,
|
||||
'car_amount' => $params['car_amount'],
|
||||
'car_config_snap' => $params['city'],
|
||||
'order_distance' => $params['distance'],
|
||||
'total_duration' => $params['total_duration'],
|
||||
]);
|
||||
$orderGoods = [];
|
||||
foreach ($params['goods'] as $goods){
|
||||
$orderGoods[] = [
|
||||
'order_id' => $order->id,
|
||||
'goods_id' => $goods['id'],
|
||||
'goods_name' => $goods['name'],
|
||||
'goods_num' => $goods['goods_num'],
|
||||
'goods_image' => FileService::setFileUrl($goods['image']),
|
||||
'goods_price' => $goods['price'],
|
||||
'total_price' => round($goods['price'] * $goods['goods_num'],2),
|
||||
'total_pay_price' => round($goods['price'] * $goods['goods_num'],2),
|
||||
'duration' => $goods['duration'],
|
||||
'goods_snap' => $goods
|
||||
];
|
||||
}
|
||||
//创建订单服务信息
|
||||
(new OrderGoods())->saveAll($orderGoods);
|
||||
|
||||
return $order;
|
||||
}
|
||||
|
||||
/**
|
||||
* @notes 订单详情
|
||||
* @param $id
|
||||
* @return array
|
||||
* @author ljj
|
||||
* @date 2022/2/28 11:23 上午
|
||||
*/
|
||||
public function detail($id)
|
||||
{
|
||||
$result = Order::field('id,sn,pay_way,goods_price,order_status,pay_status,appoint_time,order_amount,server_finish_time,create_time,coach_id,cancel_time,total_gap_amount,total_append_amount,total_order_amount,order_distance,address_snap,car_amount,user_remark')
|
||||
->where(['id'=>$id])
|
||||
->order('id','desc')
|
||||
->append(['appoint_time','pay_way_desc','appoint_date','order_status_desc','pay_btn','gap_btn','append_btn','user_cancel_btn','del_btn','comment_btn','look_comment_btn','order_cancel_time'])
|
||||
->with(['order_goods' => function($query){
|
||||
$query->field('id,order_id,goods_id,goods_snap,is_comment,duration,goods_image,goods_num,goods_name,goods_price')->hidden(['goods_snap']);
|
||||
},'order_gap','order_append'])
|
||||
->findOrEmpty()
|
||||
->toArray();
|
||||
|
||||
if(!isset($result['address_snap']['house_number'])){
|
||||
$result['address_snap']['house_number'] = '';
|
||||
}
|
||||
// if(in_array($result['order_status'],[OrderEnum::ORDER_STATUS_DEPART,OrderEnum::ORDER_STATUS_ARRIVE,OrderEnum::ORDER_STATUS_START_SERVER,OrderEnum::ORDER_STATUS_SERVER_FINISH])){
|
||||
$coach = Coach::where(['id'=>$result['coach_id']])->field('id,mobile,name,work_photo,sn')->findOrEmpty()->toArray();
|
||||
$result['coach_info'] = [
|
||||
'name' => $coach['name'] ?? '',
|
||||
'work_photo' => $coach['work_photo'] ?? '',
|
||||
'sn' => $coach['sn'] ?? '',
|
||||
'mobile'=> $coach['mobile'],
|
||||
];
|
||||
// }
|
||||
return $result;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @notes 取消订单
|
||||
* @param $params
|
||||
* @return bool|string
|
||||
* @author ljj
|
||||
* @date 2022/2/28 11:36 上午
|
||||
*/
|
||||
public function cancel($params)
|
||||
{
|
||||
// 启动事务
|
||||
Db::startTrans();
|
||||
try {
|
||||
|
||||
//TODO 已支付订单原路退回金额
|
||||
$order = Order::where('id',$params['id'])->findOrEmpty()->toArray();
|
||||
$totalRefundAmount = 0;
|
||||
if($order['pay_status'] == PayEnum::ISPAID) {
|
||||
$totalRefundAmount = $order['total_order_amount'];
|
||||
(new RefundLogic())->refund($order,$order['total_order_amount'],0,OrderRefundEnum::TYPE_USER,1,$params['user_id']);
|
||||
}
|
||||
//更新订单状态
|
||||
Order::update([
|
||||
'total_refund_amount' => $totalRefundAmount,
|
||||
'order_status' => OrderEnum::ORDER_STATUS_CLOSE,
|
||||
'cancel_time' => time(),
|
||||
],['id'=>$params['id']]);
|
||||
|
||||
//添加订单日志
|
||||
(new OrderLogLogic())->record(OrderLogEnum::TYPE_USER,OrderLogEnum::USER_CANCEL_ORDER,$params['id'],$params['user_id']);
|
||||
//取消订单-通知用户
|
||||
event('Notice', [
|
||||
'scene_id' => NoticeEnum::ORDER_CANCEL_NOTICE,
|
||||
'params' => [
|
||||
'user_id' => $order['user_id'],
|
||||
'order_id' => $order['id']
|
||||
]
|
||||
]);
|
||||
//取消订单-通知师傅
|
||||
event('Notice', [
|
||||
'scene_id' => NoticeEnum::ORDER_CANCEL_NOTICE_STAFF,
|
||||
'params' => [
|
||||
'coach_id' => $order['coach_id'],
|
||||
'order_id' => $order['id']
|
||||
]
|
||||
]);
|
||||
// 提交事务
|
||||
Db::commit();
|
||||
return true;
|
||||
} catch (\Exception $e) {
|
||||
// 回滚事务
|
||||
Db::rollback();
|
||||
return $e->getMessage();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @notes 删除订单
|
||||
* @param $id
|
||||
* @return bool
|
||||
* @author ljj
|
||||
* @date 2022/2/28 11:50 上午
|
||||
*/
|
||||
public function del($id)
|
||||
{
|
||||
Order::destroy($id);
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @notes 支付方式
|
||||
* @param $params
|
||||
* @return mixed
|
||||
* @author ljj
|
||||
* @date 2024/7/24 下午7:08
|
||||
*/
|
||||
public static function payWay($params)
|
||||
{
|
||||
try {
|
||||
// 获取待支付金额
|
||||
if ($params['from'] == 'order') {
|
||||
// 订单
|
||||
$order = Order::findOrEmpty($params['order_id'])->toArray();
|
||||
}
|
||||
if ($params['from'] == 'recharge') {
|
||||
// 充值
|
||||
$order = RechargeOrder::findOrEmpty($params['order_id'])->toArray();
|
||||
}
|
||||
|
||||
if ($params['from'] == 'orderGap') {
|
||||
// 补差价
|
||||
$order = OrderGap::findOrEmpty($params['order_id'])->toArray();
|
||||
}
|
||||
if ($params['from'] == 'orderAppend') {
|
||||
// 加钟
|
||||
$order = OrderAppend::findOrEmpty($params['order_id'])->toArray();
|
||||
}
|
||||
if (empty($order)) {
|
||||
throw new \Exception('订单不存在');
|
||||
}
|
||||
|
||||
// 获取订单剩余支付时间
|
||||
$cancelUnpaidOrders = ConfigService::get('transaction', 'cancel_unpaid_orders',1);
|
||||
$cancelUnpaidOrdersTimes = ConfigService::get('transaction', 'cancel_unpaid_orders_times',30);
|
||||
$cancelTime = 0;
|
||||
if(!in_array($params['from'],['order_gap','order_append'])){
|
||||
if (empty($cancelUnpaidOrders)) {
|
||||
// 不自动取消待支付订单
|
||||
$cancelTime = 0;
|
||||
} else {
|
||||
// 指定时间内取消待支付订单
|
||||
$cancelTime = strtotime($order['create_time']) + intval($cancelUnpaidOrdersTimes) * 60;
|
||||
}
|
||||
}
|
||||
$pay_way = PayWay::alias('pw')
|
||||
->join('dev_pay dp', 'pw.pay_id = dp.id')
|
||||
->where(['pw.scene'=>$params['scene'],'pw.status'=>YesNoEnum::YES])
|
||||
->field('dp.id,dp.name,dp.pay_way,dp.image,pw.is_default')
|
||||
->order(['sort'=>'asc','id'=>'desc'])
|
||||
->select()
|
||||
->toArray();
|
||||
foreach ($pay_way as $k=>&$item) {
|
||||
if ($item['pay_way'] == PayEnum::BALANCE_PAY) {
|
||||
$user_money = User::where(['id' => $params['user_id']])->value('user_money');
|
||||
$item['extra'] = '可用余额:'.$user_money;
|
||||
}
|
||||
// 充值时去除余额支付
|
||||
if ($params['from'] == 'recharge' && $item['pay_way'] == PayEnum::BALANCE_PAY) {
|
||||
unset($pay_way[$k]);
|
||||
}
|
||||
}
|
||||
|
||||
return [
|
||||
'lists' => array_values($pay_way),
|
||||
'order_amount' => $order['order_amount'],
|
||||
'cancel_time' => $cancelTime,
|
||||
];
|
||||
} catch (\Exception $e) {
|
||||
self::setError($e->getMessage());
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @notes 获取技师服务时间
|
||||
* @param $coachId
|
||||
* @param $goodsId
|
||||
* @return array|false
|
||||
* @author cjhao
|
||||
* @date 2024/11/26 22:44
|
||||
*/
|
||||
public function getCoachServerTime($coachId,$goodsId)
|
||||
{
|
||||
try {
|
||||
if(empty($coachId)){
|
||||
throw new Exception('请选择技师');
|
||||
}
|
||||
$coachServerTimeLists = \app\common\logic\CoachLogic::getCoachServerTime($coachId,$goodsId);
|
||||
$timeLists = [];
|
||||
// 获取当前日期的时间戳
|
||||
$currentDate = strtotime(date('Y-m-d'));
|
||||
// 获取明天和后天的时间戳
|
||||
$tomorrowDate = strtotime('tomorrow');
|
||||
$afterTomorrowDate = strtotime('+2 days',$currentDate);
|
||||
foreach ($coachServerTimeLists as $key => $serverTimeList){
|
||||
$timeTips = '';
|
||||
$timestamp = strtotime(date('Y-'.$key));
|
||||
if ($timestamp >=$currentDate && $timestamp <$tomorrowDate) {
|
||||
$timeTips = '今天';
|
||||
} elseif ($timestamp >=$tomorrowDate && $timestamp <$afterTomorrowDate) {
|
||||
$timeTips = '明天';
|
||||
} elseif ($timestamp >=$afterTomorrowDate && $timestamp < strtotime('+3 days',$currentDate)) {
|
||||
$timeTips = '后天';
|
||||
} else {
|
||||
$weekdays = array('星期日', '星期一', '星期二', '星期三', '星期四', '星期五', '星期六');
|
||||
$weekdayIndex = date('w',$timestamp);
|
||||
$timeTips = $weekdays[$weekdayIndex];
|
||||
}
|
||||
$timeLists[] = [
|
||||
'time_date' => $key,
|
||||
'time_tips' => $timeTips,
|
||||
'time_lists' => $serverTimeList
|
||||
];
|
||||
|
||||
}
|
||||
return $timeLists;
|
||||
|
||||
}catch (Exception $e) {
|
||||
self::$error = $e->getMessage();
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @notes 订单差价
|
||||
* @param array $params
|
||||
* @return array|false
|
||||
* @author cjhao
|
||||
* @date 2024/9/19 11:04
|
||||
*/
|
||||
public function orderGap(array $params)
|
||||
{
|
||||
// 启动事务
|
||||
// Db::startTrans();
|
||||
try {
|
||||
$order = Order::where(['id'=>$params['order_id'],'user_id'=>$params['user_id']])->findOrEmpty();
|
||||
if($order->isEmpty()){
|
||||
throw new Exception('订单不存在');
|
||||
}
|
||||
if(PayEnum::UNPAID == $order->pay_status){
|
||||
throw new Exception('当前订单未支付');
|
||||
}
|
||||
if(OrderEnum::ORDER_STATUS_SERVER_FINISH == $order->order_status){
|
||||
throw new Exception('订单已完成');
|
||||
}
|
||||
$orderGap = OrderGap::create([
|
||||
'sn' => generate_sn((new OrderGap()), 'sn'),
|
||||
'user_id' => $params['user_id'],
|
||||
'order_id' => $order->id,
|
||||
'order_amount' => $params['order_amount'],
|
||||
'remark' => $params['remark'],
|
||||
]);
|
||||
// 提交事务
|
||||
// Db::commit();
|
||||
return [
|
||||
'id' => $orderGap->id,
|
||||
'order_id' => $order->id,
|
||||
'sn' => $orderGap->sn,
|
||||
'type' => 'orderGap'
|
||||
];
|
||||
}catch (Exception $e){
|
||||
// Db::rollback();
|
||||
self::$error = $e->getMessage();
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @notes 订单加钟
|
||||
* @param array $params
|
||||
* @return array|bool
|
||||
* @author cjhao
|
||||
* @date 2024/9/20 00:40
|
||||
*/
|
||||
public function orderAppend(array $params)
|
||||
{
|
||||
Db::startTrans();
|
||||
try {
|
||||
$order = Order::where(['id'=>$params['order_id'],'user_id'=>$params['user_id']])->findOrEmpty();
|
||||
if($order->isEmpty()){
|
||||
throw new Exception('订单不存在');
|
||||
}
|
||||
if(PayEnum::UNPAID == $order->pay_status){
|
||||
throw new Exception('当前订单未支付');
|
||||
}
|
||||
if(OrderEnum::ORDER_STATUS_SERVER_FINISH == $order->order_status){
|
||||
throw new Exception('订单已完成');
|
||||
}
|
||||
$goods = Goods::where(['id'=>$params['goods'][0]['id']])->findOrEmpty()->toArray();
|
||||
//加钟时长
|
||||
$overtimeDuration = $goods['overtime_duration'];
|
||||
//加钟价
|
||||
$overtimePrice = round($goods['overtime_price'] * $params['goods'][0]['goods_num'],2);
|
||||
$action = $params['action'] ?? 'settlement';
|
||||
if('settlement' === $action){
|
||||
return [
|
||||
'order_id' => $order->id,
|
||||
'goods_id' => $goods['id'],
|
||||
'goods_name' => $goods['name'],
|
||||
'goods_num' => (int)$params['goods'][0]['goods_num'],
|
||||
'duration' => $overtimeDuration,
|
||||
'goods_price' => $goods['overtime_price'],
|
||||
'order_amount' => $overtimePrice,
|
||||
];
|
||||
}
|
||||
$serverFinishTime = $order['server_finish_time'];
|
||||
$totalDurations = $overtimeDuration;
|
||||
//判断下订单也没有加时
|
||||
$totalDuration = OrderAppend::where(['order_id'=>$order->id,'pay_status'=>PayEnum::ISPAID])->sum('duration');
|
||||
if($totalDuration){
|
||||
$totalDurations += $totalDuration;
|
||||
}
|
||||
$serverTime = point_timestamps($serverFinishTime,$totalDurations*60*$params['goods'][0]['goods_num']);
|
||||
$dateTime = date('m-d',$serverFinishTime);
|
||||
$coachServerTime = \app\common\logic\CoachLogic::getCoachServerTime($order['coach_id'])[$dateTime] ?? [];
|
||||
$coachServerTime = array_column($coachServerTime,null,'time');
|
||||
foreach ($serverTime as $key => $time){
|
||||
|
||||
$coachTime = $coachServerTime[$time['time']] ?? [];
|
||||
if(empty($coachTime)){
|
||||
throw new Exception('技师当前占无时间段可预约');
|
||||
}
|
||||
//开始时间是重叠的,第一个key不判断
|
||||
if(0 != $key && 3 == $coachTime['status']){
|
||||
throw new Exception('当前时段已被预约');
|
||||
}
|
||||
if(2 == $coachTime['status']){
|
||||
throw new Exception( '当前时段技师在休息');
|
||||
}
|
||||
}
|
||||
$orderAppend = OrderAppend::create([
|
||||
'sn' => generate_sn((new OrderAppend()), 'sn'),
|
||||
'user_id' => $params['user_id'],
|
||||
'order_id' => $order->id,
|
||||
'goods_id' => $goods['id'],
|
||||
'goods_name' => $goods['name'],
|
||||
'goods_image' => $goods['image'],
|
||||
'goods_num' => $params['goods'][0]['goods_num'],
|
||||
'goods_price' => $goods['overtime_price'],
|
||||
'goods_snap' => $goods,
|
||||
'order_amount' => $overtimePrice,
|
||||
'duration' => $overtimeDuration,
|
||||
]);
|
||||
|
||||
Db::commit();
|
||||
return [
|
||||
'id' => $orderAppend->id,
|
||||
'order_id' => $order->id,
|
||||
'sn' => $orderAppend->sn,
|
||||
'type' => 'orderAppend'
|
||||
];
|
||||
}catch (Exception $e){
|
||||
Db::rollback();
|
||||
self::$error = $e->getMessage();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @notes 订单评论
|
||||
* @param $params
|
||||
* @return false|void
|
||||
* @author cjhao
|
||||
* @date 2024/9/24 20:45
|
||||
*/
|
||||
public function comment($params)
|
||||
{
|
||||
Db::startTrans();
|
||||
try {
|
||||
$order = Order::where(['id'=>$params['id'],'user_id'=>$params['user_id']])->with(['order_goods'])->findOrEmpty();
|
||||
if($order->isEmpty()){
|
||||
throw new Exception('订单不存在');
|
||||
}
|
||||
if(OrderEnum::ORDER_STATUS_SERVER_FINISH != $order->order_status){
|
||||
throw new Exception('订单未完成服务,不能评论');
|
||||
}
|
||||
$comment = GoodsComment::where(['order_goods_id'=>$order['order_goods'][0]['id']])->findOrEmpty();
|
||||
if(!$comment->isEmpty()){
|
||||
throw new Exception('订单已评论');
|
||||
}
|
||||
$goodsComment = GoodsComment::create([
|
||||
'goods_id' => $order['order_goods'][0]['goods_id'],
|
||||
'user_id' => $params['user_id'],
|
||||
'order_goods_id' => $order['order_goods'][0]['id'],
|
||||
'service_comment' => $params['service_comment'],
|
||||
'comment' => $params['content'],
|
||||
]);
|
||||
$imageLists = $params['image_lists'] ?? [];
|
||||
if($imageLists){
|
||||
$commentImage = [];
|
||||
foreach ($imageLists as $image){
|
||||
$commentImage[] = [
|
||||
'comment_id' => $goodsComment['id'],
|
||||
'uri' => $image,
|
||||
];
|
||||
}
|
||||
(new GoodsCommentImage())->saveAll($commentImage);
|
||||
}
|
||||
|
||||
Db::commit();
|
||||
return true;
|
||||
}catch (Exception $e){
|
||||
Db::rollback();
|
||||
self::$error = $e->getMessage();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @notes 下单前验证
|
||||
* @param $params
|
||||
* @return true
|
||||
* @author cjhao
|
||||
* @date 2025/4/27 10:56
|
||||
*/
|
||||
public function submitOrderCheck($params)
|
||||
{
|
||||
//验证在默认使用地址的情况下,默认地址是否可用
|
||||
$city = $params['city'] ?? '';
|
||||
$userAddress = $params['address'] ?? [];
|
||||
$coach = $params['coach'] ?? [];
|
||||
$goodsCityLists = $params['city_lists'] ?? [];
|
||||
if(empty($params['address_id'])){
|
||||
if(empty($city)){
|
||||
throw new Exception('当前城市未开通出行方式,请联系管理员');
|
||||
}
|
||||
if(true !== $goodsCityLists && !in_array($userAddress['city_id'],$goodsCityLists)){
|
||||
throw new Exception('抱歉,商品暂不支持该服务地址');
|
||||
}
|
||||
$coachServerScope = ConfigService::get('server_setting', 'coach_server_scope');
|
||||
if($coach['distance'] > $coachServerScope){
|
||||
throw new Exception('当前最大服务范围'.$coachServerScope.'公里,请重新选择地址');
|
||||
}
|
||||
}
|
||||
return true;
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
272
server/app/api/logic/PayLogic.php
Executable file
272
server/app/api/logic/PayLogic.php
Executable file
@@ -0,0 +1,272 @@
|
||||
<?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\enum\PayEnum;
|
||||
use app\common\enum\YesNoEnum;
|
||||
use app\common\logic\BaseLogic;
|
||||
use app\common\logic\PayNotifyLogic;
|
||||
use app\common\model\order\Order;
|
||||
use app\common\model\order\OrderAppend;
|
||||
use app\common\model\order\OrderGap;
|
||||
use app\common\model\pay\PayWay;
|
||||
use app\common\model\RechargeOrder;
|
||||
use app\common\model\user\User;
|
||||
use app\common\service\AliPayService;
|
||||
use app\common\service\BalancePayService;
|
||||
use app\common\service\ConfigService;
|
||||
use app\common\service\WeChatPayService;
|
||||
|
||||
class PayLogic extends BaseLogic
|
||||
{
|
||||
/**
|
||||
* @notes 支付方式
|
||||
* @param $params
|
||||
* @return array|false
|
||||
* @author ljj
|
||||
* @date 2022/2/28 2:56 下午
|
||||
*/
|
||||
public static function payWay($params)
|
||||
{
|
||||
try {
|
||||
$order = [];
|
||||
// 获取待支付金额
|
||||
if ($params['from'] == 'order') {
|
||||
// 订单
|
||||
$order = Order::findOrEmpty($params['order_id'])->toArray();
|
||||
}
|
||||
if ($params['from'] == 'recharge') {
|
||||
// 充值
|
||||
$order = RechargeOrder::findOrEmpty($params['order_id'])->toArray();
|
||||
}
|
||||
|
||||
if ($params['from'] == 'order_gap') {
|
||||
// 补差价
|
||||
$order = OrderGap::findOrEmpty($params['order_id'])->toArray();
|
||||
}
|
||||
if ($params['from'] == 'order_append') {
|
||||
// 加钟
|
||||
$order = OrderAppend::findOrEmpty($params['order_id'])->toArray();
|
||||
}
|
||||
|
||||
if (empty($order)) {
|
||||
throw new \Exception('订单不存在');
|
||||
}
|
||||
|
||||
// 获取订单剩余支付时间
|
||||
$cancelUnpaidOrders = ConfigService::get('transaction', 'cancel_unpaid_orders',1);
|
||||
$cancelUnpaidOrdersTimes = ConfigService::get('transaction', 'cancel_unpaid_orders_times',30);
|
||||
$cancelTime = 0;
|
||||
if(!in_array($params['from'],['order_gap','order_append'])){
|
||||
if (empty($cancelUnpaidOrders)) {
|
||||
// 不自动取消待支付订单
|
||||
$cancelTime = 0;
|
||||
} else {
|
||||
// 指定时间内取消待支付订单
|
||||
$cancelTime = strtotime($order['create_time']) + intval($cancelUnpaidOrdersTimes) * 60;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
$pay_way = PayWay::alias('pw')
|
||||
->join('dev_pay dp', 'pw.pay_id = dp.id')
|
||||
->where(['pw.scene'=>$params['scene'],'pw.status'=>YesNoEnum::YES])
|
||||
->field('dp.id,dp.name,dp.pay_way,dp.image,pw.is_default')
|
||||
->order(['sort'=>'asc','id'=>'desc'])
|
||||
->select()
|
||||
->toArray();
|
||||
foreach ($pay_way as $k=>&$item) {
|
||||
if ($item['pay_way'] == PayEnum::WECHAT_PAY) {
|
||||
$item['extra'] = '微信快捷支付';
|
||||
}
|
||||
|
||||
if ($item['pay_way'] == PayEnum::BALANCE_PAY) {
|
||||
$user_money = User::where(['id' => $params['user_id']])->value('user_money');
|
||||
$item['extra'] = '可用余额:'.$user_money;
|
||||
}
|
||||
// 充值时去除余额支付
|
||||
if ($params['from'] == 'recharge' && $item['pay_way'] == PayEnum::BALANCE_PAY) {
|
||||
unset($pay_way[$k]);
|
||||
}
|
||||
}
|
||||
|
||||
return [
|
||||
'lists' => array_values($pay_way),
|
||||
'order_amount' => $order['order_amount'],
|
||||
'cancel_time' => $cancelTime,
|
||||
];
|
||||
} catch (\Exception $e) {
|
||||
self::setError($e->getMessage());
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 支付
|
||||
* @param $payWay // 支付方式
|
||||
* @param $from //订单来源(商品订单?充值订单?其他订单?)
|
||||
* @param $order_id //订单id
|
||||
* @param $terminal //终端
|
||||
* @return array|bool|string|void
|
||||
* @throws \Exception
|
||||
* @author 段誉
|
||||
* @date 2021/7/29 14:49
|
||||
*/
|
||||
public static function pay($payWay, $from, $order_id, $terminal)
|
||||
{
|
||||
$order = [];
|
||||
//更新支付方式
|
||||
switch ($from) {
|
||||
case 'order':
|
||||
Order::update(['pay_way' => $payWay], ['id' => $order_id]);
|
||||
$order = Order::where('id',$order_id)->findOrEmpty()->toArray();
|
||||
break;
|
||||
case 'recharge':
|
||||
RechargeOrder::update(['pay_way' => $payWay], ['id' => $order_id]);
|
||||
$order = RechargeOrder::where('id',$order_id)->findOrEmpty()->toArray();
|
||||
break;
|
||||
case 'orderGap':
|
||||
$order = OrderGap::where('id',$order_id)->findOrEmpty();
|
||||
$order->pay_way = $payWay;
|
||||
$order->save();
|
||||
$order = $order->toArray();
|
||||
break;
|
||||
case 'orderAppend':
|
||||
$order = OrderAppend::where('id',$order_id)->findOrEmpty();
|
||||
$order->pay_way = $payWay;
|
||||
$order->save();
|
||||
$order = $order->toArray();
|
||||
break;
|
||||
}
|
||||
|
||||
if (empty($order)) {
|
||||
self::setError('订单错误');
|
||||
}
|
||||
|
||||
if($order['order_amount'] == 0) {
|
||||
PayNotifyLogic::handle($from, $order['sn']);
|
||||
return ['pay_way'=>$payWay];
|
||||
}
|
||||
|
||||
switch ($payWay) {
|
||||
case PayEnum::WECHAT_PAY:
|
||||
$payService = (new WeChatPayService($terminal, $order['user_id'] ?? null));
|
||||
$result = $payService->pay($from, $order);
|
||||
break;
|
||||
case PayEnum::BALANCE_PAY:
|
||||
//余额支付
|
||||
$payService = (new BalancePayService());
|
||||
$result = $payService->pay($from, $order);
|
||||
if (false !== $result) {
|
||||
PayNotifyLogic::handle($from, $order['sn']);
|
||||
}
|
||||
break;
|
||||
case PayEnum::ALI_PAY:
|
||||
$payService = (new AliPayService($terminal));
|
||||
$result = $payService->pay($from, $order);
|
||||
break;
|
||||
default:
|
||||
self::$error = '订单异常';
|
||||
$result = false;
|
||||
}
|
||||
|
||||
//支付成功, 执行支付回调
|
||||
if (false === $result && !self::hasError()) {
|
||||
self::setError($payService->getError());
|
||||
}
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* @notes 获取支付结果
|
||||
* @param $params
|
||||
* @return array
|
||||
* @author ljj
|
||||
* @date 2024/3/21 5:48 下午
|
||||
*/
|
||||
public static function getPayResult($params)
|
||||
{
|
||||
switch ($params['from']) {
|
||||
case 'order' :
|
||||
$result = Order::where(['id' => $params['order_id']])
|
||||
->field(['id', 'sn', 'pay_time', 'pay_way', 'order_amount', 'pay_status'])
|
||||
->findOrEmpty()
|
||||
->toArray();
|
||||
$result['total_amount'] = '¥' . $result['order_amount'];
|
||||
break;
|
||||
case 'recharge' :
|
||||
$result = RechargeOrder::where(['id' => $params['order_id']])
|
||||
->field(['id','sn','pay_time','pay_way','order_amount','pay_status'])
|
||||
->findOrEmpty()
|
||||
->toArray();
|
||||
$result['total_amount'] = '¥' . $result['order_amount'];
|
||||
break;
|
||||
case 'orderGap':
|
||||
// 补差价
|
||||
$result = OrderGap::where('id',$params['order_id'])->findOrEmpty()->toArray();
|
||||
$result['total_amount'] = '¥' . $result['order_amount'];
|
||||
break;
|
||||
case 'orderAppend':
|
||||
// 加钟
|
||||
$result = OrderAppend::where('id',$params['order_id'])->findOrEmpty()->toArray();
|
||||
$result['total_amount'] = '¥' . $result['order_amount'];
|
||||
break;
|
||||
default :
|
||||
$result = [];
|
||||
}
|
||||
if (empty($result)) {
|
||||
self::$error = '订单信息不存在';
|
||||
}
|
||||
$result['pay_way_desc'] = PayEnum::getPayTypeDesc($result['pay_way']);
|
||||
return $result;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 获取支付方式
|
||||
* @param int $scene
|
||||
* @param int $userId
|
||||
* @return array
|
||||
* @author cjhao
|
||||
* @date 2024/10/11 22:49
|
||||
*/
|
||||
public static function getPayWayList(int $scene,int $userId){
|
||||
$pay_way = PayWay::alias('pw')
|
||||
->join('dev_pay dp', 'pw.pay_id = dp.id')
|
||||
->where(['pw.scene'=>$scene,'pw.status'=>YesNoEnum::YES])
|
||||
->field('dp.id,dp.name,dp.pay_way,dp.image,pw.is_default')
|
||||
->order(['sort'=>'asc','id'=>'desc'])
|
||||
->select()
|
||||
->toArray();
|
||||
foreach ($pay_way as $k=>&$item) {
|
||||
if ($item['pay_way'] == PayEnum::WECHAT_PAY) {
|
||||
$item['extra'] = '微信快捷支付';
|
||||
}
|
||||
|
||||
if ($item['pay_way'] == PayEnum::BALANCE_PAY) {
|
||||
$user_money = User::where(['id' => $userId])->value('user_money');
|
||||
$item['extra'] = '可用余额:'.$user_money;
|
||||
}
|
||||
}
|
||||
return $pay_way;
|
||||
}
|
||||
}
|
||||
50
server/app/api/logic/RechargeLogic.php
Executable file
50
server/app/api/logic/RechargeLogic.php
Executable file
@@ -0,0 +1,50 @@
|
||||
<?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\RechargeOrder;
|
||||
|
||||
class RechargeLogic extends BaseLogic
|
||||
{
|
||||
/**
|
||||
* @notes 充值
|
||||
* @param $params
|
||||
* @return array
|
||||
* @author ljj
|
||||
* @date 2022/12/16 16:09
|
||||
*/
|
||||
public function recharge($params)
|
||||
{
|
||||
$order = RechargeOrder::create([
|
||||
'sn' => generate_sn((new RechargeOrder()),'sn'),
|
||||
'user_id' => $params['user_id'],
|
||||
'order_terminal'=> $params['terminal'],
|
||||
'pay_way' => $params['pay_way'] ?? 0,
|
||||
'order_amount' => $params['money'],
|
||||
]);
|
||||
|
||||
return [
|
||||
'order_id' => $order->id,
|
||||
'from' => 'recharge'
|
||||
];
|
||||
}
|
||||
}
|
||||
63
server/app/api/logic/RegisterLogic.php
Executable file
63
server/app/api/logic/RegisterLogic.php
Executable file
@@ -0,0 +1,63 @@
|
||||
<?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\api\logic;
|
||||
|
||||
use app\common\logic\BaseLogic;
|
||||
use app\common\model\user\User;
|
||||
use app\common\service\ConfigService;
|
||||
use app\common\service\FileService;
|
||||
use think\facade\Config;
|
||||
|
||||
/**
|
||||
* 注册逻辑层
|
||||
* Class RegisterLogic
|
||||
* @package app\api\logic
|
||||
*/
|
||||
class RegisterLogic extends BaseLogic
|
||||
{
|
||||
public static function register($params)
|
||||
{
|
||||
try {
|
||||
$defaultAvatar = ConfigService::get('config', 'default_avatar', FileService::getFileUrl(config('project.default_image.user_avatar')));
|
||||
$passwordSalt = Config::get('project.unique_identification');
|
||||
$password = create_password($params['password'], $passwordSalt);
|
||||
// 创建用户
|
||||
$data = [
|
||||
'channel' => $params['channel'],
|
||||
'sn' => create_user_sn(),
|
||||
'nickname' => $params['mobile'],
|
||||
'avatar' => $defaultAvatar,
|
||||
'mobile' => $params['mobile'],
|
||||
'account' => $params['mobile'],
|
||||
'password' => $password,
|
||||
];
|
||||
$user = User::create($data);
|
||||
|
||||
return true;
|
||||
} catch(\Exception $e) {
|
||||
self::setError($e->getMessage());
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
53
server/app/api/logic/SearchLogic.php
Executable file
53
server/app/api/logic/SearchLogic.php
Executable file
@@ -0,0 +1,53 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | likeadmin快速开发前后端分离管理后台(PHP版)
|
||||
// +----------------------------------------------------------------------
|
||||
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
|
||||
// | 开源版本可自由商用,可去除界面版权logo
|
||||
// | gitee下载:https://gitee.com/likeshop_gitee/likeadmin
|
||||
// | github下载:https://github.com/likeshop-github/likeadmin
|
||||
// | 访问官网:https://www.likeadmin.cn
|
||||
// | likeadmin团队 版权所有 拥有最终解释权
|
||||
// +----------------------------------------------------------------------
|
||||
// | author: likeadminTeam
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
namespace app\api\logic;
|
||||
|
||||
|
||||
use app\common\logic\BaseLogic;
|
||||
use app\common\model\HotSearch;
|
||||
use app\common\service\ConfigService;
|
||||
|
||||
/**
|
||||
* 搜索逻辑
|
||||
* Class SearchLogic
|
||||
* @package app\api\logic
|
||||
*/
|
||||
class SearchLogic extends BaseLogic
|
||||
{
|
||||
|
||||
/**
|
||||
* @notes 热搜列表
|
||||
* @return array
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
* @author 段誉
|
||||
* @date 2022/9/23 14:34
|
||||
*/
|
||||
public static function hotLists()
|
||||
{
|
||||
$data = HotSearch::field(['name', 'sort'])
|
||||
->order(['sort' => 'desc', 'id' => 'desc'])
|
||||
->select()->toArray();
|
||||
|
||||
return [
|
||||
// 功能状态 0-关闭 1-开启
|
||||
'status' => ConfigService::get('hot_search', 'status', 0),
|
||||
// 热门搜索数据
|
||||
'data' => $data,
|
||||
];
|
||||
}
|
||||
|
||||
}
|
||||
49
server/app/api/logic/ShareLogic.php
Executable file
49
server/app/api/logic/ShareLogic.php
Executable file
@@ -0,0 +1,49 @@
|
||||
<?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\api\logic;
|
||||
|
||||
|
||||
use app\common\logic\BaseLogic;
|
||||
use app\common\service\WeChatService;
|
||||
|
||||
/**
|
||||
* 分享逻辑层
|
||||
* Class ShareLogic
|
||||
* @package app\shopapi\logic
|
||||
*/
|
||||
class ShareLogic extends BaseLogic
|
||||
{
|
||||
/**
|
||||
* @notes 获取小程序码
|
||||
* @param $params
|
||||
* @return bool|mixed|string
|
||||
* @author ljj
|
||||
* @date 2023/2/28 5:09 下午
|
||||
*/
|
||||
public function getMnpQrCode($params)
|
||||
{
|
||||
$data['page'] = $params['page'];
|
||||
if (isset($params['id']) && $params['id'] != '') {
|
||||
$data['scene'] = 'id='.$params['id'];
|
||||
}
|
||||
|
||||
$result = WeChatService::makeMpQrCode($data,'base64');
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
190
server/app/api/logic/ShopLogic.php
Executable file
190
server/app/api/logic/ShopLogic.php
Executable file
@@ -0,0 +1,190 @@
|
||||
<?php
|
||||
namespace app\api\logic;
|
||||
|
||||
use app\common\enum\GoodsEnum;
|
||||
use app\common\enum\PayEnum;
|
||||
use app\common\enum\shop\ShopEnum;
|
||||
use app\common\model\coach\Coach;
|
||||
use app\common\model\coach\Collect;
|
||||
use app\common\model\goods\Goods;
|
||||
use app\common\model\goods\GoodsCategory;
|
||||
use app\common\model\goods\GoodsComment;
|
||||
use app\common\model\IndexVisit;
|
||||
use app\common\model\order\Order;
|
||||
use app\common\model\shop\Shop;
|
||||
use app\common\model\shop\ShopCoachApply;
|
||||
use app\common\model\shop\ShopVisit;
|
||||
use app\common\model\user\User;
|
||||
use app\common\service\FileService;
|
||||
|
||||
class ShopLogic
|
||||
{
|
||||
|
||||
/**
|
||||
* @notes 商家详情
|
||||
* @param $params
|
||||
* @param $userInfo
|
||||
* @return array
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
* @author cjhao
|
||||
* @date 2024/11/19 12:14
|
||||
*/
|
||||
public function detail($params,$userInfo)
|
||||
{
|
||||
$field = 'id,name,good_comment,logo,work_status,province_id,region_id,city_id,shop_address_detail,longitude,latitude,monday,tuesday,wednesday,thursday,friday,saturday,sunday,business_start_time,business_end_time,synopsis,business_license,mobile';
|
||||
if (!empty($params['longitude']) && !empty($params['latitude'])) {
|
||||
$field .= ',round(st_distance_sphere(point('.$params['longitude'].','.$params['latitude'].'),
|
||||
point(longitude, latitude))/1000,2) as distance';
|
||||
}
|
||||
$detail = Shop::where(['id'=>$params['id'],'audit_status'=>ShopEnum::AUDIT_STATUS_PASS,'server_status'=>ShopEnum::SERVERSTATUSOPEN])
|
||||
->with(['shop_image'])
|
||||
->field($field)
|
||||
->append(['distance_desc','category_ids','work_status_desc','region_desc','business_time_desc'])
|
||||
->findOrEmpty();
|
||||
$ids = array_column($detail->category_ids->toArray(),'category_id');
|
||||
$categoryLists = GoodsCategory::where(['is_show'=>1,'id'=>$ids])->column('name');
|
||||
$detail['category_name'] = implode('|',$categoryLists);
|
||||
if (!is_array($detail['category_name'])) {
|
||||
$detail['category_name'] = [$detail['category_name']];
|
||||
}
|
||||
$week = strtolower(date('l'));
|
||||
$shopWeek = $detail[$week] ?? 0;
|
||||
if(!$shopWeek){
|
||||
$detail['work_status'] = 0;
|
||||
$detail['work_status_desc'] = ShopEnum::getWorkStatus($detail['work_status']);
|
||||
}else{
|
||||
$nowHi = date('H:i');
|
||||
$detail['business_start_time'] = format_business_time($detail['business_start_time']);
|
||||
$detail['business_end_time'] = format_business_time($detail['business_end_time']);
|
||||
if($detail['business_start_time'] > $nowHi || $detail['business_end_time'] < $nowHi){
|
||||
$detail['work_status'] = 0;
|
||||
$detail['work_status_desc'] = ShopEnum::getWorkStatus($detail['work_status']);
|
||||
}
|
||||
}
|
||||
$consumption = Order::where(['pay_status'=>PayEnum::ISPAID])
|
||||
->where('shop_id','=',$params['id'])
|
||||
->value('round(sum(order_amount)/count(id),2) as consumption');
|
||||
$detail['consumption'] = $consumption ? : 0;
|
||||
$map1 = [
|
||||
['SGI.shop_id','=',$params['id']],
|
||||
];
|
||||
|
||||
$detail['goods_lists'] = Goods::alias('G')
|
||||
->leftjoin('shop_goods_index SGI','G.id = SGI.goods_id')
|
||||
->whereRaw('(SGI.shop_id ='. $params['id'].') or (G.shop_id = '.$params['id'].' and G.audit_status = '.GoodsEnum::AUDIT_STATUS_PASS .')')
|
||||
->field('G.id,name,image,price,scribing_price,duration,order_num')
|
||||
->limit(8)
|
||||
->select()
|
||||
->toArray();
|
||||
|
||||
$coachIds = ShopCoachApply::where(['shop_id'=>$params['id'],'audit_status'=>ShopEnum::AUDIT_STATUS_PASS])->column('coach_id');
|
||||
$commentLists = GoodsComment::where(['coach_id'=>$coachIds])
|
||||
->field('id,user_id,service_comment,comment,reply')
|
||||
->append(['goods_comment_image'])
|
||||
->limit(5)
|
||||
->select()
|
||||
->toArray();
|
||||
$userIds = array_column($commentLists,'user_id');
|
||||
$userLists = User::where(['id'=>$userIds])->column('nickname,avatar','id');
|
||||
foreach ($commentLists as $key => $comment_list){
|
||||
$commentLists[$key]['nickname'] = $userLists[$comment_list['user_id']]['nickname'] ?? '';
|
||||
$commentLists[$key]['avatar'] = FileService::getFileUrl($userLists[$comment_list['user_id']]['avatar'] ?? '');
|
||||
}
|
||||
$detail['comment_lists'] = $commentLists;
|
||||
if(!empty($params['terminal'])){
|
||||
$ip = request()->ip();
|
||||
// 一个ip一个终端一天只生成一条记录
|
||||
$record = ShopVisit::where([
|
||||
'shop_id' => $params['id'],
|
||||
'ip' => $ip,
|
||||
'terminal' => $params['terminal']
|
||||
])->whereDay('create_time')->findOrEmpty();
|
||||
if (!$record->isEmpty()) {
|
||||
// 增加访客在终端的浏览量
|
||||
$record->visit += 1;
|
||||
$record->save();
|
||||
}
|
||||
// 生成访客记录
|
||||
ShopVisit::create([
|
||||
'shop_id' => $params['id'],
|
||||
'ip' => $ip,
|
||||
'terminal' => $params['terminal'],
|
||||
'visit' => 1
|
||||
]);
|
||||
}
|
||||
|
||||
$detail['is_collect'] = Collect::where(['relation_id'=>$params['id'],'user_id'=>$userInfo['user_id'] ?? 0,'type'=>3])->findOrEmpty()->toArray() ? 1 : 0;
|
||||
|
||||
return $detail->toArray();
|
||||
|
||||
}
|
||||
|
||||
|
||||
public function commentCategory($shopId)
|
||||
{
|
||||
$coachIds = Coach::where(['shop_id'=>$shopId])->field('id')->select()->toArray();
|
||||
$coachIds = array_column($coachIds,'id');
|
||||
$orderGoodsIds = Order::alias('O')
|
||||
->join('order_goods OG','O.id = OG.order_id')
|
||||
->where(['coach_id'=>$coachIds,'is_comment'=>1])
|
||||
->field('OG.id')
|
||||
->select()
|
||||
->toArray();
|
||||
$orderGoodsIds = array_column($orderGoodsIds,'id');
|
||||
$all_count = GoodsComment::where('order_goods_id','in', $orderGoodsIds)->count();
|
||||
$image_count = GoodsComment::alias('gc')->where('order_goods_id','in',$orderGoodsIds)->join('goods_comment_image gci', 'gc.id = gci.comment_id')->group('gci.comment_id')->count();
|
||||
$good_count = GoodsComment::where('order_goods_id', 'in',$orderGoodsIds)->where('service_comment','>',3)->count();
|
||||
$medium_bad_count = GoodsComment::where('order_goods_id', 'in',$orderGoodsIds)->where('service_comment','<=',3)->count();
|
||||
|
||||
if($all_count == 0) {
|
||||
$percentStr = '100%';
|
||||
$star = 5;
|
||||
}else {
|
||||
$percent = round((($good_count / $all_count) * 100));
|
||||
$percentStr = round((($good_count / $all_count) * 100)).'%';
|
||||
if ($percent >= 100) {
|
||||
$star = 5;
|
||||
} else if ($percent >= 80) {
|
||||
$star = 4;
|
||||
} else if ($percent >= 60) {
|
||||
$star = 3;
|
||||
} else if ($percent >= 40) {
|
||||
$star = 2;
|
||||
} else if ($percent >= 20) {
|
||||
$star = 1;
|
||||
} else {
|
||||
$star = 0;
|
||||
}
|
||||
}
|
||||
|
||||
return ['comment'=>
|
||||
[
|
||||
[
|
||||
'id' => 0,
|
||||
'name' => '全部',
|
||||
'count' => $all_count
|
||||
],
|
||||
[
|
||||
'id' => 1,
|
||||
'name' => '有图',
|
||||
'count' => $image_count
|
||||
],
|
||||
[
|
||||
'id' => 2,
|
||||
'name' => '好评',
|
||||
'count' => $good_count
|
||||
],
|
||||
[
|
||||
'id' => 3,
|
||||
'name' => '中差评',
|
||||
'count' => $medium_bad_count
|
||||
]
|
||||
] ,
|
||||
'percent' => $percentStr,
|
||||
'star' => $star,
|
||||
];
|
||||
}
|
||||
|
||||
}
|
||||
58
server/app/api/logic/StaffLogic.php
Executable file
58
server/app/api/logic/StaffLogic.php
Executable file
@@ -0,0 +1,58 @@
|
||||
<?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\enum\DefaultEnum;
|
||||
use app\common\logic\BaseLogic;
|
||||
use app\common\model\goods\Goods;
|
||||
use app\common\model\staff\Staff;
|
||||
|
||||
class StaffLogic extends BaseLogic
|
||||
{
|
||||
/**
|
||||
* @notes 师傅详情
|
||||
* @param $id
|
||||
* @return array
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
* @author ljj
|
||||
* @date 2022/2/23 6:34 下午
|
||||
*/
|
||||
public function detail($id)
|
||||
{
|
||||
$result = Staff::where(['id'=>$id])
|
||||
->field('id,user_id,name,mobile,goods_ids,province_id,city_id,district_id,address,create_time')
|
||||
->append(['user_image','province','city','district'])
|
||||
->findOrEmpty()
|
||||
->toArray();
|
||||
|
||||
if ($result) {
|
||||
$goods_ids = explode(',',trim($result['goods_ids'],','));
|
||||
$result['goods'] = Goods::where(['id'=>$goods_ids,'status'=>DefaultEnum::SHOW])
|
||||
->field('id,name,unit_id,image,price')
|
||||
->append(['unit_desc'])
|
||||
->select()->toArray();
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
122
server/app/api/logic/StaffOrderLogic.php
Executable file
122
server/app/api/logic/StaffOrderLogic.php
Executable file
@@ -0,0 +1,122 @@
|
||||
<?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\enum\notice\NoticeEnum;
|
||||
use app\common\enum\OrderEnum;
|
||||
use app\common\enum\OrderLogEnum;
|
||||
use app\common\logic\BaseLogic;
|
||||
use app\common\logic\OrderLogLogic;
|
||||
use app\common\model\order\Order;
|
||||
use think\facade\Db;
|
||||
|
||||
class StaffOrderLogic extends BaseLogic
|
||||
{
|
||||
/**
|
||||
* @notes 订单服务详情
|
||||
* @param $id
|
||||
* @return array
|
||||
* @author ljj
|
||||
* @date 2022/3/1 3:24 下午
|
||||
*/
|
||||
public function detail($id)
|
||||
{
|
||||
$result = Order::where('id',$id)
|
||||
->append(['appoint_time','appoint_week','door_time','order_status_desc','pay_way_desc','confirm_service_btn','verification_btn','province','city','district'])
|
||||
->with(['order_goods' => function($query){
|
||||
$query->field('order_id,goods_snap,goods_name,goods_price,goods_num,unit_name')->append(['goods_image'])->hidden(['goods_snap']);
|
||||
},'staff' => function($query){
|
||||
$query->field('id,name,mobile,user_id');
|
||||
}])
|
||||
->findOrEmpty()
|
||||
->toArray();
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* @notes 确认服务
|
||||
* @param $id
|
||||
* @return bool
|
||||
* @author ljj
|
||||
* @date 2022/3/1 3:43 下午
|
||||
*/
|
||||
public function confirmService($id)
|
||||
{
|
||||
Order::update(['order_status'=>OrderEnum::ORDER_STATUS_SERVICE],['id'=>$id]);
|
||||
|
||||
$order = Order::where('id',$id)->findOrEmpty()->toArray();
|
||||
|
||||
// 师傅确认服务通知 - 通知买家
|
||||
event('Notice', [
|
||||
'scene_id' => NoticeEnum::STAFF_CONFIRM_ORDER_NOTICE,
|
||||
'params' => [
|
||||
'user_id' => $order['user_id'],
|
||||
'order_id' => $order['id']
|
||||
]
|
||||
]);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @notes 订单核销
|
||||
* @param $params
|
||||
* @return Order|bool
|
||||
* @author ljj
|
||||
* @date 2022/3/1 3:59 下午
|
||||
*/
|
||||
public function verification($params)
|
||||
{
|
||||
// 启动事务
|
||||
Db::startTrans();
|
||||
try {
|
||||
$order = Order::where('verification_code',$params['verification_code'])->findOrEmpty()->toArray();
|
||||
|
||||
//更新订单状态
|
||||
Order::update([
|
||||
'order_status' => OrderEnum::ORDER_STATUS_FINISH,
|
||||
'verification_status' => OrderEnum::VERIFICATION,
|
||||
'finish_time' => time(),
|
||||
],['id'=>$order['id']]);
|
||||
|
||||
//添加订单日志
|
||||
(new OrderLogLogic())->record(OrderLogEnum::TYPE_USER,OrderLogEnum::USER_VERIFICATION,$order['id'],$params['user_id']);
|
||||
|
||||
// 订单完成通知 - 通知买家
|
||||
event('Notice', [
|
||||
'scene_id' => NoticeEnum::ORDER_FINISH_NOTICE,
|
||||
'params' => [
|
||||
'user_id' => $order['user_id'],
|
||||
'order_id' => $order['id']
|
||||
]
|
||||
]);
|
||||
|
||||
// 提交事务
|
||||
Db::commit();
|
||||
return true;
|
||||
} catch (\Exception $e) {
|
||||
// 回滚事务
|
||||
Db::rollback();
|
||||
return $e->getMessage();
|
||||
}
|
||||
}
|
||||
}
|
||||
59
server/app/api/logic/SubscribeLogic.php
Executable file
59
server/app/api/logic/SubscribeLogic.php
Executable file
@@ -0,0 +1,59 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | LikeShop有特色的全开源社交分销电商系统
|
||||
// +----------------------------------------------------------------------
|
||||
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
|
||||
// | 商业用途务必购买系统授权,以免引起不必要的法律纠纷
|
||||
// | 禁止对系统程序代码以任何目的,任何形式的再发布
|
||||
// | 微信公众号:好象科技
|
||||
// | 访问官网:http://www.likemarket.net
|
||||
// | 访问社区:http://bbs.likemarket.net
|
||||
// | 访问手册:http://doc.likemarket.net
|
||||
// | 好象科技开发团队 版权所有 拥有最终解释权
|
||||
// +----------------------------------------------------------------------
|
||||
// | Author: LikeShopTeam
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
namespace app\api\logic;
|
||||
|
||||
use app\common\enum\YesNoEnum;
|
||||
use app\common\logic\BaseLogic;
|
||||
use app\common\model\notice\NoticeSetting;
|
||||
|
||||
/**
|
||||
* 小程序订阅消息
|
||||
*/
|
||||
class SubscribeLogic extends BaseLogic
|
||||
{
|
||||
/**
|
||||
* @notes 获取小程序模板ID (取已启用的3条)
|
||||
* @param $params
|
||||
* @return array
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
* @author Tab
|
||||
* @date 2021/10/12 11:56
|
||||
*/
|
||||
public static function lists()
|
||||
{
|
||||
$where = [
|
||||
['mnp_notice', '<>', ''],
|
||||
['type', '=', 1]
|
||||
];
|
||||
$lists = NoticeSetting::where($where)->field('mnp_notice')->select()->toArray();
|
||||
|
||||
$template_id = [];
|
||||
foreach ($lists as $item) {
|
||||
if (isset($item['mnp_notice']['status']) && $item['mnp_notice']['status'] != YesNoEnum::YES) {
|
||||
continue;
|
||||
}
|
||||
$template_id[] = $item['mnp_notice']['template_id'] ?? '';
|
||||
// 限制3条
|
||||
if (count($template_id) == 3) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
return $template_id;
|
||||
}
|
||||
}
|
||||
204
server/app/api/logic/UserAddressLogic.php
Executable file
204
server/app/api/logic/UserAddressLogic.php
Executable file
@@ -0,0 +1,204 @@
|
||||
<?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\enum\YesNoEnum;
|
||||
use app\common\logic\BaseLogic;
|
||||
use app\common\model\city\City;
|
||||
use app\common\model\coach\Coach;
|
||||
use app\common\model\goods\GoodsCityIndex;
|
||||
use app\common\model\user\UserAddress;
|
||||
use app\common\service\ConfigService;
|
||||
|
||||
class UserAddressLogic extends BaseLogic
|
||||
{
|
||||
/**
|
||||
* @notes 地址列表
|
||||
* @param $user_id
|
||||
* @return array
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
* @author ljj
|
||||
* @date 2022/2/24 10:45 上午
|
||||
*/
|
||||
public function lists($user_id,$params)
|
||||
{
|
||||
$goodsId = $params['goods_id'] ?? '';
|
||||
$coachId = $params['coach_id'] ?? '';
|
||||
$field = 'id,contact,gender,mobile,province_id,city_id,district_id,house_number,address,is_default,0 as distance';
|
||||
if($coachId){
|
||||
$coach = Coach::where(['id'=>$coachId])->findOrEmpty();
|
||||
if(!$coach->isEmpty()){
|
||||
$longitude = $coach['longitude_location'] ?: $coach['longitude'];
|
||||
$latitude = $coach['latitude_location'] ?: $coach['latitude'];
|
||||
$field = 'id,contact,gender,mobile,province_id,city_id,district_id,house_number,address,is_default,round(st_distance_sphere(point('.$longitude.','.$latitude.'),
|
||||
point(longitude, latitude))/1000,2) as distance';
|
||||
}
|
||||
}
|
||||
$lists = UserAddress::field($field)
|
||||
->order(['is_default'=>'desc','id'=>'desc'])
|
||||
->append(['province','city','district','gender_desc'])
|
||||
->where(['user_id'=>$user_id])
|
||||
->select()
|
||||
->toArray();
|
||||
$userAddressLists = [
|
||||
'usable' => [],
|
||||
'distance_disable' => [],
|
||||
'server_disable' => [],
|
||||
];
|
||||
$coachServerScope = ConfigService::get('server_setting', 'coach_server_scope');
|
||||
if($goodsId){
|
||||
$cityLists = GoodsCityIndex::where(['goods_id'=>$goodsId])->column('city_id');
|
||||
if(empty($cityLists)){
|
||||
$cityLists = true;
|
||||
}
|
||||
}else{
|
||||
$cityLists = City::column('city_id');
|
||||
}
|
||||
foreach ($lists as $userAddress){
|
||||
if($goodsId){
|
||||
if(true === $cityLists){
|
||||
$userAddressLists['usable'][] = $userAddress;
|
||||
continue;
|
||||
}
|
||||
if(!in_array($userAddress['city_id'],$cityLists)){
|
||||
$userAddressLists['server_disable'][] = $userAddress;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
if($coachId && !$coach->isEmpty() && $coachServerScope < $userAddress['distance']){
|
||||
$userAddressLists['distance_disable'][] = $userAddress;
|
||||
continue;
|
||||
}
|
||||
|
||||
$userAddressLists['usable'][] = $userAddress;
|
||||
}
|
||||
return $userAddressLists;
|
||||
}
|
||||
|
||||
/**
|
||||
* @notes 添加地址
|
||||
* @param $params
|
||||
* @return bool
|
||||
* @author ljj
|
||||
* @date 2022/2/24 10:51 上午
|
||||
*/
|
||||
public function add($params)
|
||||
{
|
||||
if (isset($params['is_default']) && $params['is_default'] == YesNoEnum::YES) {
|
||||
UserAddress::where(['user_id' => $params['user_id']])->update(['is_default' => YesNoEnum::NO]);
|
||||
} else {
|
||||
$isFirst = UserAddress::where(['user_id' => $params['user_id']])->findOrEmpty();
|
||||
if ($isFirst->isEmpty()) {
|
||||
$params['is_default'] = YesNoEnum::YES;
|
||||
}
|
||||
}
|
||||
|
||||
UserAddress::create([
|
||||
'user_id' => $params['user_id'],
|
||||
'contact' => $params['contact'],
|
||||
'mobile' => $params['mobile'],
|
||||
'gender' => $params['gender'] ?? 1,
|
||||
'province_id' => $params['province_id'],
|
||||
'city_id' => $params['city_id'],
|
||||
'district_id' => $params['district_id'],
|
||||
'address' => $params['address'] ?? '',
|
||||
'longitude' => $params['longitude'],
|
||||
'latitude' => $params['latitude'],
|
||||
'house_number'=> $params['house_number'],
|
||||
'is_default' => $params['is_default'] ?? 0,
|
||||
]);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @notes 地址详情
|
||||
* @param $id
|
||||
* @return array
|
||||
* @author ljj
|
||||
* @date 2022/2/24 11:55 上午
|
||||
*/
|
||||
public function detail($id)
|
||||
{
|
||||
return UserAddress::where(['id'=>$id])->append(['province','city','district','gender_desc'])->findOrEmpty()->toArray();
|
||||
}
|
||||
|
||||
/**
|
||||
* @notes 编辑地址
|
||||
* @param $params
|
||||
* @return bool
|
||||
* @author ljj
|
||||
* @date 2022/2/24 11:59 上午
|
||||
*/
|
||||
public function edit($params)
|
||||
{
|
||||
if (isset($params['is_default']) && $params['is_default'] == YesNoEnum::YES) {
|
||||
UserAddress::where(['user_id' => $params['user_id']])->update(['is_default' => YesNoEnum::NO]);
|
||||
}
|
||||
|
||||
UserAddress::update([
|
||||
'contact' => $params['contact'],
|
||||
'mobile' => $params['mobile'],
|
||||
'gender' => $params['gender'] ?? 1,
|
||||
'province_id' => $params['province_id'],
|
||||
'city_id' => $params['city_id'],
|
||||
'district_id' => $params['district_id'],
|
||||
'address' => $params['address'] ?? '',
|
||||
'longitude' => $params['longitude'] ?? 0,
|
||||
'latitude' => $params['latitude'] ?? 0,
|
||||
'is_default' => $params['is_default'] ?? 0,
|
||||
'house_number'=> $params['house_number'],
|
||||
],['id'=>$params['id'],'user_id'=>$params['user_id']]);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @notes 设置默认地址
|
||||
* @param $params
|
||||
* @return bool
|
||||
* @author ljj
|
||||
* @date 2022/2/24 12:08 下午
|
||||
*/
|
||||
public function setDefault($params)
|
||||
{
|
||||
UserAddress::where(['user_id' => $params['user_id']])->update(['is_default' => YesNoEnum::NO]);
|
||||
|
||||
UserAddress::update(['is_default' => YesNoEnum::YES],['id'=>$params['id'],'user_id'=>$params['user_id']]);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @notes 删除地址
|
||||
* @param $id
|
||||
* @return bool
|
||||
* @author ljj
|
||||
* @date 2022/2/24 2:35 下午
|
||||
*/
|
||||
public function del($id)
|
||||
{
|
||||
UserAddress::destroy($id);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
392
server/app/api/logic/UserLogic.php
Executable file
392
server/app/api/logic/UserLogic.php
Executable file
@@ -0,0 +1,392 @@
|
||||
<?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\api\service\WechatUserService;
|
||||
use app\common\enum\notice\NoticeEnum;
|
||||
use app\common\enum\OrderEnum;
|
||||
use app\common\enum\user\UserTerminalEnum;
|
||||
use app\common\enum\YesNoEnum;
|
||||
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\GoodsComment;
|
||||
use app\common\model\order\Order;
|
||||
use app\common\model\user\User;
|
||||
use app\common\model\user\UserAuth;
|
||||
use app\common\service\ConfigService;
|
||||
use app\common\service\sms\SmsDriver;
|
||||
use app\common\service\WeChatConfigService;
|
||||
use app\common\service\WeChatService;
|
||||
use EasyWeChat\Factory;
|
||||
use think\facade\Config;
|
||||
|
||||
class UserLogic extends BaseLogic
|
||||
{
|
||||
/**
|
||||
* @notes 用户中心
|
||||
* @param $userInfo
|
||||
* @return array
|
||||
* @author ljj
|
||||
* @date 2022/2/23 5:24 下午
|
||||
*/
|
||||
public function center($userInfo)
|
||||
{
|
||||
$userId = $userInfo['user_id'] ?? 0;
|
||||
$terminal = $userInfo['terminal'] ?? 0;
|
||||
$user = User::where(['id'=>$userId])
|
||||
->field('id,sn,nickname,account,avatar,user_money,mobile,sex,create_time,is_new_user')
|
||||
->findOrEmpty()
|
||||
->toArray();
|
||||
//支付是否需要授权
|
||||
$user['pay_auth'] = 1;
|
||||
if (in_array($terminal, [UserTerminalEnum::WECHAT_MMP, UserTerminalEnum::WECHAT_OA])) {
|
||||
$auth = self::hasWechatAuth($userId);
|
||||
$user['pay_auth'] = $auth ? YesNoEnum::YES : YesNoEnum::NO;
|
||||
}
|
||||
$user['collect_coach_num'] = Collect::where(['type'=>1,'user_id'=>$userId])->count();
|
||||
$user['collect_goods_num'] = Collect::where(['type'=>2,'user_id'=>$userId])->count();
|
||||
$user['collect_shop_num'] = Collect::where(['type'=>3,'user_id'=>$userId])->count();
|
||||
$user['goods_comment_num'] = GoodsComment::where(['user_id'=>$userId])->count();
|
||||
$user['wait_comment_num'] = Order::alias('O')
|
||||
->join('order_goods OG','O.id = OG.order_id')
|
||||
->where(['user_id'=>$userId,'order_status'=>OrderEnum::ORDER_STATUS_SERVER_FINISH,'is_comment'=>0])
|
||||
->count();
|
||||
|
||||
$user['waitpay_order_num'] = Order::where(['user_id'=>$userId,'order_status'=>OrderEnum::ORDER_STATUS_WAIT_PAY])->count();
|
||||
$user['appoint_order_num'] = Order::where(['user_id'=>$userId,'order_status'=>OrderEnum::ORDER_STATUS_WAIT_RECEIVING])->count();
|
||||
$user['server_order_num'] = Order::where(['user_id'=>$userId,'order_status'=>OrderEnum::ORDER_STATUS_START_SERVER])->count();
|
||||
$user['complete_order_num'] = Order::where(['user_id'=>$userId,'order_status'=>OrderEnum::ORDER_STATUS_SERVER_FINISH])->count();
|
||||
|
||||
return $user;
|
||||
}
|
||||
|
||||
/**
|
||||
* @notes 客服配置
|
||||
* @return array
|
||||
* @author ljj
|
||||
* @date 2022/2/24 2:53 下午
|
||||
*/
|
||||
public function customerService()
|
||||
{
|
||||
// $qrCode = ConfigService::get('customer_service', 'qr_code');
|
||||
// $qrCode = empty($qrCode) ? '' : FileService::getFileUrl($qrCode);
|
||||
// $config = [
|
||||
// 'qr_code' => $qrCode,
|
||||
// 'wechat' => ConfigService::get('customer_service', 'wechat', ''),
|
||||
// 'phone' => ConfigService::get('customer_service', 'phone', ''),
|
||||
// 'service_time' => ConfigService::get('customer_service', 'service_time', ''),
|
||||
// ];
|
||||
|
||||
// 装修配置
|
||||
$decoratePage = DecoratePage::where('id',3)->json(['data'],true)->value('data');
|
||||
|
||||
return $decoratePage;
|
||||
}
|
||||
|
||||
/**
|
||||
* @notes 用户收藏列表
|
||||
* @param $user_id
|
||||
* @return mixed
|
||||
* @author ljj
|
||||
* @date 2022/2/24 3:07 下午
|
||||
*/
|
||||
public function collectLists($user_id)
|
||||
{
|
||||
$lists = Goods::alias('g')
|
||||
->join('goods_collect gc', 'g.id = gc.goods_id')
|
||||
->field('gc.goods_id,g.image,g.name,g.price,g.unit_id,g.status')
|
||||
->append(['unit_desc'])
|
||||
->where(['gc.user_id'=>$user_id])
|
||||
->order('gc.id','desc')
|
||||
->select()
|
||||
->toArray();
|
||||
|
||||
return $lists;
|
||||
}
|
||||
|
||||
/**
|
||||
* @notes 用户信息
|
||||
* @param $userId
|
||||
* @return array|bool
|
||||
* @author ljj
|
||||
* @date 2022/3/7 5:52 下午
|
||||
*/
|
||||
public static function info($user_id,$code = '')
|
||||
{
|
||||
try {
|
||||
$user = User::where(['id'=>$user_id])
|
||||
->field('id,sn,sex,account,password,nickname,real_name,avatar,mobile,create_time')
|
||||
->findOrEmpty();
|
||||
$user['has_password'] = !empty($user['password']);
|
||||
$user['has_auth'] = self::hasWechatAuth($user_id);
|
||||
$user['version'] = config('project.version');
|
||||
$user['wx_nickname'] = $user['nickname'];
|
||||
if('' != $code){
|
||||
$params['code'] = $code;
|
||||
$response = WeChatService::getOaResByCode($params);
|
||||
$user['wx_nickname'] = $response['nickname'] ?? '';
|
||||
}
|
||||
$user->hidden(['password']);
|
||||
return $user->toArray();
|
||||
}catch (\Exception $e){
|
||||
self::$error = $e->getMessage();
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @notes 设置用户信息
|
||||
* @param int $userId
|
||||
* @param array $params
|
||||
* @return bool
|
||||
* @author ljj
|
||||
* @date 2022/2/24 3:44 下午
|
||||
*/
|
||||
public static function setInfo(int $userId,array $params):bool
|
||||
{
|
||||
User::update(['id'=>$userId,$params['field']=>$params['value']]);
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @notes 获取微信手机号并绑定
|
||||
* @param $params
|
||||
* @return bool
|
||||
* @author ljj
|
||||
* @date 2022/2/24 4:41 下午
|
||||
*/
|
||||
public static function getMobileByMnp(array $params)
|
||||
{
|
||||
try {
|
||||
$getMnpConfig = WeChatConfigService::getMnpConfig();
|
||||
$app = Factory::miniProgram($getMnpConfig);
|
||||
$response = $app->phone_number->getUserPhoneNumber($params['code']);
|
||||
|
||||
$phoneNumber = $response['phone_info']['purePhoneNumber'] ?? '';
|
||||
if (empty($phoneNumber)) {
|
||||
throw new \Exception('获取手机号码失败');
|
||||
}
|
||||
|
||||
$user = User::where([
|
||||
['mobile', '=', $phoneNumber],
|
||||
['id', '<>', $params['user_id']]
|
||||
])->findOrEmpty();
|
||||
|
||||
if (!$user->isEmpty()) {
|
||||
throw new \Exception('手机号已被其他账号绑定');
|
||||
}
|
||||
|
||||
// 绑定手机号
|
||||
User::update([
|
||||
'id' => $params['user_id'],
|
||||
'mobile' => $phoneNumber
|
||||
]);
|
||||
|
||||
return true;
|
||||
} catch (\Exception $e) {
|
||||
self::setError($e->getMessage());
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 重置登录密码
|
||||
* @param $params
|
||||
* @return bool
|
||||
* @author 段誉
|
||||
* @date 2022/9/16 18:06
|
||||
*/
|
||||
public static function resetPassword(array $params)
|
||||
{
|
||||
try {
|
||||
// 校验验证码
|
||||
$smsDriver = new SmsDriver();
|
||||
if (!$smsDriver->verify($params['mobile'], $params['code'], NoticeEnum::RESET_PASSWORD_CAPTCHA)) {
|
||||
throw new \Exception('验证码错误');
|
||||
}
|
||||
|
||||
// 重置密码
|
||||
$passwordSalt = Config::get('project.unique_identification');
|
||||
$password = create_password($params['password'], $passwordSalt);
|
||||
|
||||
// 更新
|
||||
User::where('account', $params['mobile'])->update([
|
||||
'password' => $password
|
||||
]);
|
||||
|
||||
return true;
|
||||
} catch (\Exception $e) {
|
||||
self::setError($e->getMessage());
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @notes 设置登录密码
|
||||
* @author Tab
|
||||
* @date 2021/10/22 18:10
|
||||
*/
|
||||
public static function setPassword($params)
|
||||
{
|
||||
try {
|
||||
$user = User::findOrEmpty($params['user_id']);
|
||||
if ($user->isEmpty()) {
|
||||
throw new \Exception('用户不存在');
|
||||
}
|
||||
if (!empty($user->password)) {
|
||||
throw new \Exception('用户已设置登录密码');
|
||||
}
|
||||
$passwordSalt = Config::get('project.unique_identification');
|
||||
$password = create_password($params['password'], $passwordSalt);
|
||||
$user->password = $password;
|
||||
$user->save();
|
||||
|
||||
return true;
|
||||
} catch (\Exception $e) {
|
||||
self::setError($e->getMessage());
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 修稿密码
|
||||
* @param $params
|
||||
* @param $userId
|
||||
* @return bool
|
||||
* @author 段誉
|
||||
* @date 2022/9/20 19:13
|
||||
*/
|
||||
public static function changePassword(array $params, int $userId)
|
||||
{
|
||||
try {
|
||||
$user = User::findOrEmpty($userId);
|
||||
if ($user->isEmpty()) {
|
||||
throw new \Exception('用户不存在');
|
||||
}
|
||||
|
||||
// 密码盐
|
||||
$passwordSalt = Config::get('project.unique_identification');
|
||||
|
||||
if (!empty($user['password'])) {
|
||||
if (empty($params['old_password'])) {
|
||||
throw new \Exception('请填写旧密码');
|
||||
}
|
||||
$oldPassword = create_password($params['old_password'], $passwordSalt);
|
||||
if ($oldPassword != $user['password']) {
|
||||
throw new \Exception('原密码不正确');
|
||||
}
|
||||
}
|
||||
|
||||
// 保存密码
|
||||
$password = create_password($params['password'], $passwordSalt);
|
||||
$user->password = $password;
|
||||
$user->save();
|
||||
|
||||
return true;
|
||||
} catch (\Exception $e) {
|
||||
self::setError($e->getMessage());
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @notes 判断用户是否有设置登录密码
|
||||
* @param $userId
|
||||
* @author Tab
|
||||
* @date 2021/10/22 18:25
|
||||
*/
|
||||
public static function hasPassword($userId)
|
||||
{
|
||||
$user = User::findOrEmpty($userId);
|
||||
return empty($user->password) ? false : true;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 绑定手机号
|
||||
* @param $params
|
||||
* @return bool
|
||||
* @author Tab
|
||||
* @date 2021/8/25 17:55
|
||||
*/
|
||||
public static function bindMobile($params)
|
||||
{
|
||||
try {
|
||||
$smsDriver = new SmsDriver();
|
||||
$result = $smsDriver->verify($params['mobile'], $params['code']);
|
||||
if(!$result) {
|
||||
throw new \Exception('验证码错误');
|
||||
}
|
||||
$user = User::where('mobile', $params['mobile'])->findOrEmpty();
|
||||
if(!$user->isEmpty()) {
|
||||
throw new \Exception('该手机号已被其他账号绑定');
|
||||
}
|
||||
unset($params['code']);
|
||||
User::update($params);
|
||||
return true;
|
||||
} catch (\Exception $e) {
|
||||
self::setError($e->getMessage());
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 是否有微信授权信息
|
||||
* @param $userId
|
||||
* @return bool
|
||||
* @author 段誉
|
||||
* @date 2022/9/20 19:36
|
||||
*/
|
||||
public static function hasWechatAuth(int $userId)
|
||||
{
|
||||
//是否有微信授权登录
|
||||
$terminal = [UserTerminalEnum::WECHAT_MMP, UserTerminalEnum::WECHAT_OA];
|
||||
$auth = UserAuth::where(['user_id' => $userId])
|
||||
->whereIn('terminal', $terminal)
|
||||
->findOrEmpty();
|
||||
return !$auth->isEmpty();
|
||||
}
|
||||
|
||||
/**
|
||||
* @notes 我的钱包
|
||||
* @param int $userId
|
||||
* @return array
|
||||
* @author ljj
|
||||
* @date 2022/12/12 9:35 上午
|
||||
*/
|
||||
public static function wallet(int $userId): array
|
||||
{
|
||||
$result = User::where(['id' => $userId])
|
||||
->field('id,user_money,user_earnings')
|
||||
->findOrEmpty()
|
||||
->toArray();
|
||||
$result['total_money'] = round($result['user_money'] + $result['user_earnings'],2);
|
||||
$result['recharge_open'] = ConfigService::get('recharge', 'recharge_open',1);
|
||||
|
||||
return $result;
|
||||
}
|
||||
}
|
||||
78
server/app/api/logic/WechatLogic.php
Executable file
78
server/app/api/logic/WechatLogic.php
Executable file
@@ -0,0 +1,78 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | LikeShop有特色的全开源社交分销电商系统
|
||||
// +----------------------------------------------------------------------
|
||||
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
|
||||
// | 商业用途务必购买系统授权,以免引起不必要的法律纠纷
|
||||
// | 禁止对系统程序代码以任何目的,任何形式的再发布
|
||||
// | 微信公众号:好象科技
|
||||
// | 访问官网:http://www.likemarket.net
|
||||
// | 访问社区:http://bbs.likemarket.net
|
||||
// | 访问手册:http://doc.likemarket.net
|
||||
// | 好象科技开发团队 版权所有 拥有最终解释权
|
||||
// +----------------------------------------------------------------------
|
||||
// | Author: LikeShopTeam
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
namespace app\api\logic;
|
||||
|
||||
use app\common\logic\BaseLogic;
|
||||
use app\common\service\WeChatConfigService;
|
||||
use EasyWeChat\Factory;
|
||||
use EasyWeChat\Kernel\Exceptions\Exception;
|
||||
|
||||
/**
|
||||
* 微信逻辑层
|
||||
* Class WechatLogic
|
||||
* @package app\api\logic
|
||||
*/
|
||||
class WechatLogic extends BaseLogic
|
||||
{
|
||||
/**
|
||||
* @notes 微信JSSDK授权接口
|
||||
* @param $params
|
||||
* @return array|false|string
|
||||
* @throws \EasyWeChat\Kernel\Exceptions\InvalidArgumentException
|
||||
* @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
|
||||
* @throws \EasyWeChat\Kernel\Exceptions\RuntimeException
|
||||
* @throws \GuzzleHttp\Exception\GuzzleException
|
||||
* @throws \Psr\SimpleCache\InvalidArgumentException
|
||||
* @author Tab
|
||||
* @date 2021/8/30 19:20
|
||||
*/
|
||||
public static function jsConfig($params)
|
||||
{
|
||||
try {
|
||||
// $config = [
|
||||
// 'app_id' => ConfigService::get('official_account','app_id'),
|
||||
// 'secret' => ConfigService::get('official_account','app_secret')
|
||||
// ];
|
||||
$config = WeChatConfigService::getOaConfig();
|
||||
$app = Factory::officialAccount($config);
|
||||
$url = urldecode($params['url']);
|
||||
$app->jssdk->setUrl($url);
|
||||
$apis = [
|
||||
'onMenuShareTimeline',
|
||||
'onMenuShareAppMessage',
|
||||
'onMenuShareQQ',
|
||||
'onMenuShareWeibo',
|
||||
'onMenuShareQZone',
|
||||
'openLocation',
|
||||
'getLocation',
|
||||
'chooseWXPay',
|
||||
'updateAppMessageShareData',
|
||||
'updateTimelineShareData',
|
||||
'openAddress',
|
||||
'scanQRCode'
|
||||
];
|
||||
|
||||
$data = $app->jssdk->getConfigArray($apis, $debug = false, $beta = false);
|
||||
|
||||
return $data;
|
||||
} catch (Exception |\think\Exception $e) {
|
||||
|
||||
self::setError('公众号配置出错:' . $e->getMessage());
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
122
server/app/api/service/UserTokenService.php
Executable file
122
server/app/api/service/UserTokenService.php
Executable file
@@ -0,0 +1,122 @@
|
||||
<?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\api\service;
|
||||
|
||||
|
||||
use app\common\cache\UserTokenCache;
|
||||
use app\common\model\user\UserSession;
|
||||
use think\facade\Config;
|
||||
|
||||
class UserTokenService
|
||||
{
|
||||
/**
|
||||
* @notes 设置或更新用户token
|
||||
* @param $userId
|
||||
* @param $terminal
|
||||
* @param int $multipointLogin
|
||||
* @return array|false|mixed
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
* @author 令狐冲
|
||||
* @date 2021/7/13 23:07
|
||||
*/
|
||||
public static function setToken($userId, $terminal)
|
||||
{
|
||||
$time = time();
|
||||
$userSession = UserSession::where([['user_id', '=', $userId], ['terminal', '=', $terminal]])->find();
|
||||
|
||||
//获取token延长过期的时间
|
||||
$expireTime = $time + Config::get('project.user_token.expire_duration');
|
||||
$userTokenCache = new UserTokenCache();
|
||||
|
||||
//token处理
|
||||
if ($userSession) {
|
||||
|
||||
//清空缓存
|
||||
$userTokenCache->deleteUserInfo($userSession->token);
|
||||
//重新获取token
|
||||
$userSession->token = create_token($userId);
|
||||
$userSession->expire_time = $expireTime;
|
||||
$userSession->update_time = $time;
|
||||
$userSession->save();
|
||||
} else {
|
||||
//找不到在该终端的token记录,创建token记录
|
||||
$userSession = UserSession::create([
|
||||
'user_id' => $userId,
|
||||
'terminal' => $terminal,
|
||||
'token' => create_token($userId),
|
||||
'expire_time' => $expireTime
|
||||
]);
|
||||
|
||||
}
|
||||
return $userTokenCache->setUserInfo($userSession->token);
|
||||
}
|
||||
|
||||
/**
|
||||
* @notes 延长token过期时间
|
||||
* @param $token
|
||||
* @return array|false|mixed
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
* @author 令狐冲
|
||||
* @date 2021/7/5 14:25
|
||||
*/
|
||||
public static function overtimeToken($token)
|
||||
{
|
||||
$time = time();
|
||||
$adminSession = UserSession::where('token', '=', $token)->find();
|
||||
//延长token过期时间
|
||||
$adminSession->expire_time = $time + Config::get('project.admin_token.expire_duration');
|
||||
$adminSession->update_time = $time;
|
||||
$adminSession->save();
|
||||
return (new UserTokenCache())->setUserInfo($adminSession->token);
|
||||
}
|
||||
|
||||
/**
|
||||
* @notes 设置token为过期
|
||||
* @param $token
|
||||
* @return bool
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
* @author 令狐冲
|
||||
* @date 2021/7/5 14:31
|
||||
*/
|
||||
public static function expireToken($token)
|
||||
{
|
||||
$userSession = UserSession::where('token', '=', $token)
|
||||
->find();
|
||||
if (empty($userSession)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$time = time();
|
||||
$userSession->expire_time = $time;
|
||||
$userSession->update_time = $time;
|
||||
$userSession->save();
|
||||
|
||||
return (new UserTokenCache())->deleteUserInfo($token);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
259
server/app/api/service/WechatUserService.php
Executable file
259
server/app/api/service/WechatUserService.php
Executable file
@@ -0,0 +1,259 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | likeadmin快速开发前后端分离管理后台(PHP版)
|
||||
// +----------------------------------------------------------------------
|
||||
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
|
||||
// | 开源版本可自由商用,可去除界面版权logo
|
||||
// | gitee下载:https://gitee.com/likeshop_gitee/likeadmin
|
||||
// | github下载:https://github.com/likeshop-github/likeadmin
|
||||
// | 访问官网:https://www.likeadmin.cn
|
||||
// | likeadmin团队 版权所有 拥有最终解释权
|
||||
// +----------------------------------------------------------------------
|
||||
// | author: likeadminTeam
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
namespace app\api\service;
|
||||
|
||||
|
||||
use think\facade\Log;
|
||||
use app\common\model\user\{User, UserAuth};
|
||||
use app\common\enum\user\UserTerminalEnum;
|
||||
use app\common\service\{ConfigService, storage\Driver as StorageDriver};
|
||||
use think\Exception;
|
||||
/**
|
||||
* 用户功能类(主要微信登录后创建和更新用户)
|
||||
* Class WechatUserService
|
||||
* @package app\api\service
|
||||
*/
|
||||
class WechatUserService
|
||||
{
|
||||
|
||||
protected int $terminal = UserTerminalEnum::WECHAT_MMP;
|
||||
protected array $response = [];
|
||||
protected ?string $code = null;
|
||||
protected ?string $openid = null;
|
||||
protected ?string $unionid = null;
|
||||
protected ?string $nickname = null;
|
||||
protected ?string $headimgurl = null;
|
||||
protected User $user;
|
||||
|
||||
|
||||
public function __construct(array $response, int $terminal)
|
||||
{
|
||||
$this->terminal = $terminal;
|
||||
$this->setParams($response);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 设置微信返回的用户信息
|
||||
* @param $response
|
||||
* @author cjhao
|
||||
* @date 2021/8/2 11:49
|
||||
*/
|
||||
private function setParams($response): void
|
||||
{
|
||||
$this->response = $response;
|
||||
$this->openid = $response['openid'];
|
||||
$this->unionid = $response['unionid'] ?? '';
|
||||
$this->nickname = $response['nickname'] ?? '';
|
||||
$this->headimgurl = $response['headimgurl'] ?? '';
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 根据opendid或unionid获取系统用户信息
|
||||
* @return $this
|
||||
* @author 段誉
|
||||
* @date 2022/9/23 16:09
|
||||
*/
|
||||
public function getResopnseByUserInfo(): self
|
||||
{
|
||||
$openid = $this->openid;
|
||||
$unionid = $this->unionid;
|
||||
|
||||
$user = User::alias('u')
|
||||
->field('u.id,u.sn,u.nickname,u.avatar,u.mobile,u.is_disable,u.is_new_user')
|
||||
->join('user_auth au', 'au.user_id = u.id')
|
||||
->where(function ($query) use ($openid, $unionid) {
|
||||
$query->whereOr(['au.openid' => $openid]);
|
||||
if (isset($unionid) && $unionid) {
|
||||
$query->whereOr(['au.unionid' => $unionid]);
|
||||
}
|
||||
})
|
||||
->findOrEmpty();
|
||||
|
||||
$this->user = $user;
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 获取用户信息
|
||||
* @param bool $isCheck 是否验证账号是否可用
|
||||
* @return array
|
||||
* @throws Exception
|
||||
* @author cjhao
|
||||
* @date 2021/8/3 11:42
|
||||
*/
|
||||
public function getUserInfo($isCheck = true): array
|
||||
{
|
||||
if (!$this->user->isEmpty() && $isCheck) {
|
||||
$this->checkAccount();
|
||||
}
|
||||
if (!$this->user->isEmpty()) {
|
||||
$this->getToken();
|
||||
}
|
||||
return $this->user->toArray();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 校验账号
|
||||
* @throws Exception
|
||||
* @author 段誉
|
||||
* @date 2022/9/16 10:14
|
||||
*/
|
||||
private function checkAccount()
|
||||
{
|
||||
if ($this->user->is_disable) {
|
||||
throw new Exception('您的账号异常,请联系客服。');
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 创建用户
|
||||
* @throws Exception
|
||||
* @author 段誉
|
||||
* @date 2022/9/16 10:06
|
||||
*/
|
||||
private function createUser(): void
|
||||
{
|
||||
|
||||
//设置头像
|
||||
if (empty($this->headimgurl)) {
|
||||
// 默认头像
|
||||
$defaultAvatar = config('project.default_image.user_avatar');
|
||||
$avatar = ConfigService::get('default_image', 'user_avatar', $defaultAvatar);
|
||||
} else {
|
||||
// 微信获取到的头像信息
|
||||
$avatar = $this->getAvatarByWechat();
|
||||
}
|
||||
|
||||
$userSn = User::createUserSn();
|
||||
$this->user->sn = $userSn;
|
||||
$this->user->account = 'u' . $userSn;
|
||||
$this->user->nickname = $this->nickname ?:"用户" . $userSn;
|
||||
$this->user->avatar = $avatar;
|
||||
$this->user->channel = $this->terminal;
|
||||
$this->user->is_new_user = 1;
|
||||
if (empty($this->nickname)) {
|
||||
$this->user->nickname = '用户' . $this->user->sn;
|
||||
}
|
||||
|
||||
$this->user->save();
|
||||
|
||||
UserAuth::create([
|
||||
'user_id' => $this->user->id,
|
||||
'openid' => $this->openid,
|
||||
'unionid' => $this->unionid,
|
||||
'terminal' => $this->terminal,
|
||||
]);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 更新用户信息
|
||||
* @throws Exception
|
||||
* @author 段誉
|
||||
* @date 2022/9/16 10:06
|
||||
* @remark 该端没授权信息,重新写入一条该端的授权信息
|
||||
*/
|
||||
private function updateUser(): void
|
||||
{
|
||||
// 无头像需要更新头像
|
||||
if (empty($this->user->avatar)) {
|
||||
$this->user->avatar = $this->getAvatarByWechat();
|
||||
$this->user->save();
|
||||
}
|
||||
|
||||
$userAuth = UserAuth::where(['user_id' => $this->user->id, 'openid' => $this->openid])
|
||||
->findOrEmpty();
|
||||
|
||||
// 无该端授权信息,新增一条
|
||||
if ($userAuth->isEmpty()) {
|
||||
$userAuth->user_id = $this->user->id;
|
||||
$userAuth->openid = $this->openid;
|
||||
$userAuth->unionid = $this->unionid;
|
||||
$userAuth->terminal = $this->terminal;
|
||||
$userAuth->save();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 获取token
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
* @author cjhao
|
||||
* @date 2021/8/2 16:45
|
||||
*/
|
||||
private function getToken(): void
|
||||
{
|
||||
$user = UserTokenService::setToken($this->user->id, $this->terminal);
|
||||
$this->user->token = $user['token'];
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 用户授权登录,
|
||||
* 如果用户不存在,创建用户;用户存在,更新用户信息,并检查该端信息是否需要写入
|
||||
* @return WechatUserService
|
||||
* @throws Exception
|
||||
* @author cjhao
|
||||
* @date 2021/8/2 16:35
|
||||
*/
|
||||
public function authUserLogin(): self
|
||||
{
|
||||
if ($this->user->isEmpty()) {
|
||||
$this->createUser();
|
||||
} else {
|
||||
$this->updateUser();
|
||||
}
|
||||
return $this;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 处理从微信获取到的头像信息
|
||||
* @return string
|
||||
* @throws Exception
|
||||
* @author 段誉
|
||||
* @date 2022/9/16 9:50
|
||||
*/
|
||||
public function getAvatarByWechat(): string
|
||||
{
|
||||
// 存储引擎
|
||||
$config = [
|
||||
'default' => ConfigService::get('storage', 'default', 'local'),
|
||||
'engine' => ConfigService::get('storage')
|
||||
];
|
||||
if ($config['default'] == 'local') {
|
||||
// 本地存储
|
||||
$file_name = md5($this->openid . time()) . '.jpeg';
|
||||
$avatar = download_file($this->headimgurl, 'uploads/user/avatar/', $file_name);
|
||||
} else {
|
||||
// 第三方存储
|
||||
$avatar = 'uploads/user/avatar/' . md5($this->openid . time()) . '.jpeg';
|
||||
$StorageDriver = new StorageDriver($config);
|
||||
if (!$StorageDriver->fetch($this->headimgurl, $avatar)) {
|
||||
throw new Exception('头像保存失败:' . $StorageDriver->getError());
|
||||
}
|
||||
}
|
||||
return $avatar;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
105
server/app/api/validate/GoodsCommentValidate.php
Executable file
105
server/app/api/validate/GoodsCommentValidate.php
Executable file
@@ -0,0 +1,105 @@
|
||||
<?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\validate;
|
||||
|
||||
|
||||
use app\common\model\goods\Goods;
|
||||
use app\common\model\order\OrderGoods;
|
||||
use app\common\validate\BaseValidate;
|
||||
|
||||
class GoodsCommentValidate extends BaseValidate
|
||||
{
|
||||
protected $rule = [
|
||||
'goods_id' => 'require|checkGoodsId',
|
||||
'order_goods_id' => 'require|checkOrderGoodsId',
|
||||
'service_comment' => 'require|number|in:1,2,3,4,5',
|
||||
'image' => 'array|max:4',
|
||||
'id' => 'require',
|
||||
];
|
||||
|
||||
protected $message = [
|
||||
'goods_id.require' => '参数错误',
|
||||
'order_goods_id.require' => '参数错误',
|
||||
'service_comment.require' => '请给服务评分',
|
||||
'service_comment.number' => '服务评分值错误',
|
||||
'service_comment.in' => '请给服务评分',
|
||||
'image.array' => '图片数据必须为数组结构',
|
||||
'id.require' => '参数缺失',
|
||||
];
|
||||
|
||||
public function sceneCommentCategory()
|
||||
{
|
||||
return $this->only(['goods_id']);
|
||||
}
|
||||
|
||||
public function sceneCommentGoodsInfo()
|
||||
{
|
||||
return $this->only(['order_goods_id']);
|
||||
}
|
||||
|
||||
public function sceneAdd()
|
||||
{
|
||||
return $this->only(['order_goods_id','service_comment','image']);
|
||||
}
|
||||
|
||||
public function sceneCommentDetail()
|
||||
{
|
||||
return $this->only(['id']);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 检查商品ID
|
||||
* @param $value
|
||||
* @param $rule
|
||||
* @param $data
|
||||
* @return bool|string
|
||||
* @author ljj
|
||||
* @date 2022/2/18 12:05 下午
|
||||
*/
|
||||
public function checkGoodsId($value,$rule,$data)
|
||||
{
|
||||
$result = Goods::where('id', $value)->findOrEmpty();
|
||||
if ($result->isEmpty()) {
|
||||
return '商品不存在';
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @notes 检验订单商品id
|
||||
* @param $value
|
||||
* @param $rule
|
||||
* @param $data
|
||||
* @return bool|string
|
||||
* @author ljj
|
||||
* @date 2022/2/21 6:06 下午
|
||||
*/
|
||||
public function checkOrderGoodsId($value,$rule,$data)
|
||||
{
|
||||
$result = OrderGoods::where('order_id', $value)->findOrEmpty();
|
||||
if ($result->isEmpty()) {
|
||||
return '订单商品不存在';
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
72
server/app/api/validate/GoodsValidate.php
Executable file
72
server/app/api/validate/GoodsValidate.php
Executable file
@@ -0,0 +1,72 @@
|
||||
<?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\validate;
|
||||
|
||||
|
||||
use app\common\enum\GoodsEnum;
|
||||
use app\common\model\goods\Goods;
|
||||
use app\common\validate\BaseValidate;
|
||||
|
||||
class GoodsValidate extends BaseValidate
|
||||
{
|
||||
protected $rule = [
|
||||
'id' => 'require|checkId',
|
||||
'is_collect' => 'require|in:0,1',
|
||||
];
|
||||
|
||||
protected $message = [
|
||||
'id.require' => '参数错误',
|
||||
'is_collect.require' => '参数缺失',
|
||||
'is_collect.in' => '参数值错误',
|
||||
];
|
||||
|
||||
|
||||
public function sceneDetail()
|
||||
{
|
||||
return $this->only(['id']);
|
||||
}
|
||||
|
||||
public function sceneCollect()
|
||||
{
|
||||
return $this->only(['id','is_collect']);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 检验服务id
|
||||
* @param $value
|
||||
* @param $rule
|
||||
* @param $data
|
||||
* @return bool|string
|
||||
* @author ljj
|
||||
* @date 2022/2/17 5:58 下午
|
||||
*/
|
||||
public function checkId($value,$rule,$data)
|
||||
{
|
||||
$result = Goods::where('id',$value)->findOrEmpty();
|
||||
if ($result->isEmpty()) {
|
||||
return '服务不存在';
|
||||
}
|
||||
if ($result['status'] == GoodsEnum::UNSHELVE) {
|
||||
return '服务已下架';
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
161
server/app/api/validate/LoginAccountValidate.php
Executable file
161
server/app/api/validate/LoginAccountValidate.php
Executable file
@@ -0,0 +1,161 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | likeadmin快速开发前后端分离管理后台(PHP版)
|
||||
// +----------------------------------------------------------------------
|
||||
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
|
||||
// | 开源版本可自由商用,可去除界面版权logo
|
||||
// | gitee下载:https://gitee.com/likeshop_gitee/likeadmin
|
||||
// | github下载:https://github.com/likeshop-github/likeadmin
|
||||
// | 访问官网:https://www.likeadmin.cn
|
||||
// | likeadmin团队 版权所有 拥有最终解释权
|
||||
// +----------------------------------------------------------------------
|
||||
// | author: likeadminTeam
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
namespace app\api\validate;
|
||||
|
||||
use app\common\cache\UserAccountSafeCache;
|
||||
use app\common\enum\LoginEnum;
|
||||
use app\common\enum\notice\NoticeEnum;
|
||||
use app\common\enum\user\UserTerminalEnum;
|
||||
use app\common\enum\YesNoEnum;
|
||||
use app\common\service\ConfigService;
|
||||
use app\common\service\sms\SmsDriver;
|
||||
use app\common\validate\BaseValidate;
|
||||
use app\common\model\user\User;
|
||||
use think\facade\Config;
|
||||
|
||||
/**
|
||||
* 账号密码登录校验
|
||||
* Class LoginValidate
|
||||
* @package app\api\validate
|
||||
*/
|
||||
class LoginAccountValidate extends BaseValidate
|
||||
{
|
||||
|
||||
protected $rule = [
|
||||
'terminal' => 'require|in:' . UserTerminalEnum::WECHAT_MMP . ',' . UserTerminalEnum::WECHAT_OA . ','
|
||||
. UserTerminalEnum::H5 . ',' . UserTerminalEnum::PC . ',' . UserTerminalEnum::IOS .
|
||||
',' . UserTerminalEnum::ANDROID,
|
||||
'scene' => 'require|in:' . LoginEnum::ACCOUNT_PASSWORD . ',' . LoginEnum::MOBILE_CAPTCHA . '|checkConfig',
|
||||
'account' => 'require',
|
||||
];
|
||||
|
||||
|
||||
protected $message = [
|
||||
'terminal.require' => '终端参数缺失',
|
||||
'terminal.in' => '终端参数状态值不正确',
|
||||
'scene.require' => '场景不能为空',
|
||||
'scene.in' => '场景值错误',
|
||||
'account.require' => '请输入账号',
|
||||
'password.require' => '请输入密码',
|
||||
];
|
||||
|
||||
|
||||
/**
|
||||
* @notes 登录场景相关校验
|
||||
* @param $scene
|
||||
* @param $rule
|
||||
* @param $data
|
||||
* @return bool|string
|
||||
* @author 段誉
|
||||
* @date 2022/9/15 14:37
|
||||
*/
|
||||
public function checkConfig($scene, $rule, $data)
|
||||
{
|
||||
$config = ConfigService::get('login', 'login_way', config('project.login.login_way'));
|
||||
if (!in_array($scene, $config)) {
|
||||
return '不支持的登录方式';
|
||||
}
|
||||
|
||||
// 账号密码登录
|
||||
if (LoginEnum::ACCOUNT_PASSWORD == $scene) {
|
||||
if (!isset($data['password'])) {
|
||||
return '请输入密码';
|
||||
}
|
||||
return $this->checkPassword($data['password'], [], $data);
|
||||
}
|
||||
|
||||
// 手机验证码登录
|
||||
if (LoginEnum::MOBILE_CAPTCHA == $scene) {
|
||||
if (!isset($data['code'])) {
|
||||
return '请输入手机验证码';
|
||||
}
|
||||
return $this->checkCode($data['code'], [], $data);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 登录密码校验
|
||||
* @param $password
|
||||
* @param $other
|
||||
* @param $data
|
||||
* @return bool|string
|
||||
* @author 段誉
|
||||
* @date 2022/9/15 14:39
|
||||
*/
|
||||
public function checkPassword($password, $other, $data)
|
||||
{
|
||||
//账号安全机制,连续输错后锁定,防止账号密码暴力破解
|
||||
$userAccountSafeCache = new UserAccountSafeCache();
|
||||
if (!$userAccountSafeCache->isSafe()) {
|
||||
return '密码连续' . $userAccountSafeCache->count . '次输入错误,请' . $userAccountSafeCache->minute . '分钟后重试';
|
||||
}
|
||||
|
||||
$where = [];
|
||||
if ($data['scene'] == LoginEnum::ACCOUNT_PASSWORD) {
|
||||
// 手机号密码登录
|
||||
$where = ['account|mobile' => $data['account']];
|
||||
}
|
||||
|
||||
$userInfo = User::where($where)
|
||||
->field(['password,is_disable'])
|
||||
->findOrEmpty();
|
||||
|
||||
if ($userInfo->isEmpty()) {
|
||||
return '用户不存在';
|
||||
}
|
||||
|
||||
if ($userInfo['is_disable'] === YesNoEnum::YES) {
|
||||
return '用户已禁用';
|
||||
}
|
||||
|
||||
if (empty($userInfo['password'])) {
|
||||
$userAccountSafeCache->record();
|
||||
return '用户不存在';
|
||||
}
|
||||
|
||||
$passwordSalt = Config::get('project.unique_identification');
|
||||
if ($userInfo['password'] !== create_password($password, $passwordSalt)) {
|
||||
$userAccountSafeCache->record();
|
||||
return '密码错误';
|
||||
}
|
||||
|
||||
$userAccountSafeCache->relieve();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 校验验证码
|
||||
* @param $code
|
||||
* @param $rule
|
||||
* @param $data
|
||||
* @return bool|string
|
||||
* @author Tab
|
||||
* @date 2021/8/25 15:43
|
||||
*/
|
||||
public function checkCode($code, $rule, $data)
|
||||
{
|
||||
$smsDriver = new SmsDriver();
|
||||
$result = $smsDriver->verify($data['account'], $code, NoticeEnum::LOGIN_CAPTCHA);
|
||||
if ($result) {
|
||||
return true;
|
||||
}
|
||||
return '验证码错误';
|
||||
}
|
||||
}
|
||||
48
server/app/api/validate/OrderAppendValidate.php
Executable file
48
server/app/api/validate/OrderAppendValidate.php
Executable file
@@ -0,0 +1,48 @@
|
||||
<?php
|
||||
namespace app\api\validate;
|
||||
use app\common\model\order\OrderGoods;
|
||||
use app\common\validate\BaseValidate;
|
||||
|
||||
/**
|
||||
* 订单加钟价逻辑类
|
||||
* Class OrderGapValidate
|
||||
* @package app\api\validate
|
||||
*/
|
||||
class OrderAppendValidate extends BaseValidate
|
||||
{
|
||||
protected $rule = [
|
||||
'order_id' => 'require',
|
||||
'goods' => 'require|array|checkGoods',// 下单服务
|
||||
'action' => 'require',
|
||||
];
|
||||
|
||||
protected $message = [
|
||||
'order_id.require' => '请选择订单',
|
||||
'goods.require' => '缺失下单服务信息',
|
||||
'goods.array' => '下单服务信息格式不正确',
|
||||
'action.require' => '参数缺少',
|
||||
];
|
||||
|
||||
|
||||
/**
|
||||
* @notes 验证下单服务信息
|
||||
* @param $value
|
||||
* @param $rule
|
||||
* @param $data
|
||||
* @return bool|string
|
||||
* @author ljj
|
||||
* @date 2022/2/24 5:01 下午
|
||||
*/
|
||||
public function checkGoods($value, $rule, $data)
|
||||
{
|
||||
$orderGoods = OrderGoods::where(['order_id'=>$data['order_id']])->field('goods_id')->select()->toArray();
|
||||
$orderGoods = array_column($orderGoods,'goods_id');
|
||||
foreach ($value as $goods){
|
||||
if(!in_array($goods['id'],$orderGoods)){
|
||||
return '订单服务不存在';
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
44
server/app/api/validate/OrderCommentValidate.php
Executable file
44
server/app/api/validate/OrderCommentValidate.php
Executable file
@@ -0,0 +1,44 @@
|
||||
<?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\validate;
|
||||
|
||||
|
||||
use app\common\enum\OrderEnum;
|
||||
use app\common\model\order\Order;
|
||||
use app\common\validate\BaseValidate;
|
||||
|
||||
class OrderCommentValidate extends BaseValidate
|
||||
{
|
||||
protected $rule = [
|
||||
'id' => 'require',
|
||||
'service_comment' => 'require|between:1,5',
|
||||
'content' => 'require|max:200',
|
||||
'image_lists' => 'max:4',
|
||||
];
|
||||
|
||||
protected $message = [
|
||||
'id.require' => '请选择订单',
|
||||
'service_comment.require' => '请选择评论星数',
|
||||
'service_comment.between' => '评论星数在1-5',
|
||||
'content.require' => '参数缺失',
|
||||
];
|
||||
|
||||
|
||||
}
|
||||
25
server/app/api/validate/OrderGapValidate.php
Executable file
25
server/app/api/validate/OrderGapValidate.php
Executable file
@@ -0,0 +1,25 @@
|
||||
<?php
|
||||
namespace app\api\validate;
|
||||
use app\common\validate\BaseValidate;
|
||||
|
||||
/**
|
||||
* 订单补差价逻辑类
|
||||
* Class OrderGapValidate
|
||||
* @package app\api\validate
|
||||
*/
|
||||
class OrderGapValidate extends BaseValidate
|
||||
{
|
||||
protected $rule = [
|
||||
'order_id' => 'require',
|
||||
'order_amount' => 'require|gt:0',
|
||||
'remark' => 'require|max:128',
|
||||
];
|
||||
|
||||
protected $message = [
|
||||
'order_id.require' => '请选择订单',
|
||||
'order_amount.require' => '请输入订单金额',
|
||||
'order_amount.gt' => '订单金额不能小于零',
|
||||
'remark.require' => '请输入备注',
|
||||
'remark.max' => '备注不能超过128个字符'
|
||||
];
|
||||
}
|
||||
117
server/app/api/validate/OrderValidate.php
Executable file
117
server/app/api/validate/OrderValidate.php
Executable file
@@ -0,0 +1,117 @@
|
||||
<?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\validate;
|
||||
|
||||
|
||||
use app\common\enum\OrderEnum;
|
||||
use app\common\model\order\Order;
|
||||
use app\common\validate\BaseValidate;
|
||||
|
||||
class OrderValidate extends BaseValidate
|
||||
{
|
||||
protected $rule = [
|
||||
'id' => 'require|checkId',
|
||||
'from' => 'require',
|
||||
'scene' => 'require',
|
||||
];
|
||||
|
||||
protected $message = [
|
||||
'id.require' => '参数错误',
|
||||
'from.require' => '参数缺失',
|
||||
'scene.require' => '参数缺失',
|
||||
];
|
||||
|
||||
public function sceneDetail()
|
||||
{
|
||||
return $this->only(['id']);
|
||||
}
|
||||
|
||||
public function sceneCancel()
|
||||
{
|
||||
return $this->only(['id'])
|
||||
->append('id','checkCancel');
|
||||
}
|
||||
|
||||
public function sceneDel()
|
||||
{
|
||||
return $this->only(['id'])
|
||||
->append('id','checkDel');
|
||||
}
|
||||
|
||||
public function scenePayWay()
|
||||
{
|
||||
return $this->only(['from','scene']);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 检验订单id
|
||||
* @param $value
|
||||
* @param $rule
|
||||
* @param $data
|
||||
* @return bool|string
|
||||
* @author ljj
|
||||
* @date 2022/2/28 10:12 上午
|
||||
*/
|
||||
public function checkId($value,$rule,$data)
|
||||
{
|
||||
$result = Order::where(['id'=>$value])->findOrEmpty();
|
||||
if ($result->isEmpty()) {
|
||||
return '订单不存在';
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @notes 检验订单能否取消
|
||||
* @param $value
|
||||
* @param $rule
|
||||
* @param $data
|
||||
* @return bool|string
|
||||
* @author ljj
|
||||
* @date 2022/2/28 11:28 上午
|
||||
*/
|
||||
public function checkCancel($value,$rule,$data)
|
||||
{
|
||||
$result = Order::where(['id'=>$value])->findOrEmpty()->toArray();
|
||||
if ($result['order_status'] != OrderEnum::ORDER_STATUS_WAIT_PAY && $result['order_status'] != OrderEnum::ORDER_STATUS_WAIT_RECEIVING) {
|
||||
return '该订单无法取消';
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @notes 检验订单能否删除
|
||||
* @param $value
|
||||
* @param $rule
|
||||
* @param $data
|
||||
* @return bool|string
|
||||
* @author ljj
|
||||
* @date 2022/2/28 11:48 上午
|
||||
*/
|
||||
public function checkDel($value,$rule,$data)
|
||||
{
|
||||
$result = Order::where(['id'=>$value])->findOrEmpty()->toArray();
|
||||
if ($result['order_status'] != OrderEnum::ORDER_STATUS_CLOSE) {
|
||||
return '该订单无法删除';
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
69
server/app/api/validate/PasswordValidate.php
Executable file
69
server/app/api/validate/PasswordValidate.php
Executable file
@@ -0,0 +1,69 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | likeadmin快速开发前后端分离管理后台(PHP版)
|
||||
// +----------------------------------------------------------------------
|
||||
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
|
||||
// | 开源版本可自由商用,可去除界面版权logo
|
||||
// | gitee下载:https://gitee.com/likeshop_gitee/likeadmin
|
||||
// | github下载:https://github.com/likeshop-github/likeadmin
|
||||
// | 访问官网:https://www.likeadmin.cn
|
||||
// | likeadmin团队 版权所有 拥有最终解释权
|
||||
// +----------------------------------------------------------------------
|
||||
// | author: likeadminTeam
|
||||
// +----------------------------------------------------------------------
|
||||
namespace app\api\validate;
|
||||
|
||||
use app\common\validate\BaseValidate;
|
||||
|
||||
/**
|
||||
* 密码校验
|
||||
* Class PasswordValidate
|
||||
* @package app\api\validate
|
||||
*/
|
||||
class PasswordValidate extends BaseValidate
|
||||
{
|
||||
|
||||
protected $rule = [
|
||||
'mobile' => 'require|mobile',
|
||||
'code' => 'require',
|
||||
'password' => 'require|length:6,20|alphaNum',
|
||||
'password_confirm' => 'require|confirm',
|
||||
];
|
||||
|
||||
|
||||
protected $message = [
|
||||
'mobile.require' => '请输入手机号',
|
||||
'mobile.mobile' => '请输入正确手机号',
|
||||
'code.require' => '请填写验证码',
|
||||
'password.require' => '请输入密码',
|
||||
'password.length' => '密码须在6-25位之间',
|
||||
'password.alphaNum' => '密码须为字母数字组合',
|
||||
'password_confirm.require' => '请确认密码',
|
||||
'password_confirm.confirm' => '两次输入的密码不一致'
|
||||
];
|
||||
|
||||
|
||||
/**
|
||||
* @notes 重置登录密码
|
||||
* @return PasswordValidate
|
||||
* @author 段誉
|
||||
* @date 2022/9/16 18:11
|
||||
*/
|
||||
public function sceneResetPassword()
|
||||
{
|
||||
return $this->only(['mobile', 'code']);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 修改密码场景
|
||||
* @return PasswordValidate
|
||||
* @author 段誉
|
||||
* @date 2022/9/20 19:14
|
||||
*/
|
||||
public function sceneChangePassword()
|
||||
{
|
||||
return $this->only(['password', 'password_confirm']);
|
||||
}
|
||||
|
||||
}
|
||||
146
server/app/api/validate/PayValidate.php
Executable file
146
server/app/api/validate/PayValidate.php
Executable file
@@ -0,0 +1,146 @@
|
||||
<?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\validate;
|
||||
|
||||
|
||||
use app\common\enum\OrderEnum;
|
||||
use app\common\enum\PayEnum;
|
||||
use app\common\model\order\Order;
|
||||
use app\common\model\order\OrderAppend;
|
||||
use app\common\model\order\OrderGap;
|
||||
use app\common\model\RechargeOrder;
|
||||
use app\common\validate\BaseValidate;
|
||||
|
||||
class PayValidate extends BaseValidate
|
||||
{
|
||||
protected $rule = [
|
||||
'from' => 'require',
|
||||
'pay_way' => 'require|in:' . PayEnum::BALANCE_PAY . ',' . PayEnum::WECHAT_PAY . ',' . PayEnum::ALI_PAY,
|
||||
'order_id' => 'require|checkOrderId'
|
||||
];
|
||||
|
||||
protected $message = [
|
||||
'from.require' => '参数缺失',
|
||||
'pay_way.require' => '支付方式参数缺失',
|
||||
'pay_way.in' => '支付方式参数错误',
|
||||
'order_id.require' => '订单参数缺失'
|
||||
];
|
||||
|
||||
public function scenePayway()
|
||||
{
|
||||
return $this->only(['from', 'order_id', 'scene'])
|
||||
->append('scene','require');
|
||||
}
|
||||
|
||||
public function scenePrepay()
|
||||
{
|
||||
return $this->only(['from', 'pay_way', 'order_id'])
|
||||
->append('order_id','checkOrder');
|
||||
}
|
||||
|
||||
public function sceneGetPayResult()
|
||||
{
|
||||
return $this->only(['from', 'order_id']);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 检验订单id
|
||||
* @param $value
|
||||
* @param $rule
|
||||
* @param $data
|
||||
* @return bool|string
|
||||
* @author ljj
|
||||
* @date 2022/2/28 5:58 下午
|
||||
*/
|
||||
public function checkOrderId($value,$rule,$data)
|
||||
{
|
||||
switch ($data['from']) {
|
||||
case 'order':
|
||||
$result = Order::where('id',$value)->findOrEmpty();
|
||||
break;
|
||||
case 'recharge':
|
||||
$result = RechargeOrder::where('id',$value)->findOrEmpty();
|
||||
break;
|
||||
case 'orderGap':
|
||||
// 补差价
|
||||
$result = OrderGap::where('id',$value)->findOrEmpty();
|
||||
break;
|
||||
case 'orderAppend':
|
||||
// 加钟
|
||||
$result = OrderAppend::where('id',$value)->findOrEmpty();
|
||||
break;
|
||||
}
|
||||
if ($result->isEmpty()) {
|
||||
return '订单不存在';
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @notes 检验订单状态
|
||||
* @param $value
|
||||
* @param $rule
|
||||
* @param $data
|
||||
* @return bool|string
|
||||
* @author ljj
|
||||
* @date 2022/2/28 6:02 下午
|
||||
*/
|
||||
public function checkOrder($value,$rule,$data)
|
||||
{
|
||||
switch ($data['from']) {
|
||||
case 'order':
|
||||
$result = Order::where('id',$value)->findOrEmpty();
|
||||
if ($result['order_status'] == OrderEnum::ORDER_STATUS_CLOSE) {
|
||||
return '订单已关闭';
|
||||
}
|
||||
if ($result['pay_status'] == PayEnum::ISPAID) {
|
||||
return '订单已支付';
|
||||
}
|
||||
$appointTime = $result->getData('appoint_time');
|
||||
if($appointTime < time()){
|
||||
return '预约时间已超时,请重新下单';
|
||||
}
|
||||
break;
|
||||
case 'recharge':
|
||||
$result = RechargeOrder::where('id',$value)->findOrEmpty()->toArray();
|
||||
if ($result['pay_status'] == PayEnum::ISPAID) {
|
||||
return '订单已支付';
|
||||
}
|
||||
break;
|
||||
case 'orderGap':
|
||||
// 补差价
|
||||
$result = OrderGap::findOrEmpty($value);
|
||||
if ($result['pay_status'] == PayEnum::ISPAID) {
|
||||
return '订单已支付';
|
||||
}
|
||||
break;
|
||||
case 'orderAppend':
|
||||
// 加钟
|
||||
$result = OrderAppend::findOrEmpty($value);
|
||||
if ($result['pay_status'] == PayEnum::ISPAID) {
|
||||
return '订单已支付';
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
164
server/app/api/validate/PlaceOrderValidate.php
Executable file
164
server/app/api/validate/PlaceOrderValidate.php
Executable file
@@ -0,0 +1,164 @@
|
||||
<?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\validate;
|
||||
|
||||
|
||||
use app\common\enum\GoodsEnum;
|
||||
use app\common\enum\OrderEnum;
|
||||
use app\common\enum\user\UserTerminalEnum;
|
||||
use app\common\logic\CoachLogic;
|
||||
use app\common\model\coach\Coach;
|
||||
use app\common\model\goods\Goods;
|
||||
use app\common\model\user\User;
|
||||
use app\common\validate\BaseValidate;
|
||||
|
||||
class PlaceOrderValidate extends BaseValidate
|
||||
{
|
||||
protected $rule = [
|
||||
// 'terminal' => 'require|in:' . UserTerminalEnum::WECHAT_MMP . ',' . UserTerminalEnum::WECHAT_OA . ','
|
||||
// . UserTerminalEnum::H5 . ',' . UserTerminalEnum::PC . ',' . UserTerminalEnum::IOS .
|
||||
// ',' . UserTerminalEnum::ANDROID,
|
||||
'action' => 'require',// 下单动作(结算/下单)
|
||||
'goods' => 'require|array|checkGoods',// 下单服务
|
||||
'trip_way' => 'requireIf:action,sumbit|in:'.OrderEnum::TRIP_WAY_TAXI.','.OrderEnum::TRIP_WAY_BUS,
|
||||
'coach_id' => 'requireIf:action,sumbit|checkCoach',
|
||||
'appoint_time' => 'requireIf:action,sumbit|checkAppoint',// 预约时间
|
||||
'address_id' => 'requireIf:action,sumbit|checkAddress',
|
||||
// 'pay_way' => 'requireIf:action,sumbit',
|
||||
];
|
||||
|
||||
|
||||
protected $message = [
|
||||
'user_id.require' => '参数缺失',
|
||||
'action.require' => '下单动作缺失',
|
||||
'goods.require' => '缺失下单服务信息',
|
||||
'goods.array' => '下单服务信息格式不正确',
|
||||
'trip_way.requireIf' => '请选择出行方式',
|
||||
'trip_way.in' => '出行方式错误',
|
||||
'coach_id.requireIf' => '请选择技师',
|
||||
'appoint_time.requireIf' => '请选择预约时间',
|
||||
'address_id.requireIf' => '请选择地址',
|
||||
'terminal.require' => '终端参数缺失',
|
||||
'terminal.in' => '终端参数状态值不正确',
|
||||
'pay_way.requireIf' => '请选择支付方式',
|
||||
// 'appoint_time_start.require' => '请选择预约上门开始时间',
|
||||
// 'appoint_time_end.require' => '请选择预约上门结束时间',
|
||||
];
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @notes 验证下单服务信息
|
||||
* @param $value
|
||||
* @param $rule
|
||||
* @param $data
|
||||
* @return bool|string
|
||||
* @author ljj
|
||||
* @date 2022/2/24 5:01 下午
|
||||
*/
|
||||
public function checkGoods($value, $rule, $data)
|
||||
{
|
||||
foreach ($value as $goods){
|
||||
if (!isset($goods['id']) || !isset($goods['goods_num'])) {
|
||||
return '下单服务参数缺失';
|
||||
}
|
||||
$result = Goods::where(['id'=>$goods['id']])->findOrEmpty();
|
||||
if ($result->isEmpty()) {
|
||||
return '下单服务不存在';
|
||||
}
|
||||
if ($result['status'] == GoodsEnum::UNSHELVE) {
|
||||
return '服务已下架';
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @notes 获取预约时间
|
||||
* @param $value
|
||||
* @param $rule
|
||||
* @param $data
|
||||
* @return string|true
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
* @author cjhao
|
||||
* @date 2024/9/9 14:45
|
||||
*/
|
||||
public function checkAppoint($value,$rule,$data)
|
||||
{
|
||||
if('sumbit' != $data['action']){
|
||||
return true;
|
||||
}
|
||||
$dateMd = date('m-d',$value);
|
||||
$dateHi = date('H:i',$value);
|
||||
$coachOrderAppoint = CoachLogic::getCoachServerTime($data['coach_id']);
|
||||
$dateMdOrderAppoint = $coachOrderAppoint[$dateMd] ?? [];
|
||||
$dateMdOrderAppoint = array_column($dateMdOrderAppoint,null,'time');
|
||||
$dateTime = $dateMdOrderAppoint[$dateHi] ?? [];
|
||||
if(empty($dateTime)){
|
||||
return '预约时间段错误';
|
||||
}
|
||||
if(3 == $dateTime['status']){
|
||||
return '当前时段已被预约';
|
||||
}
|
||||
if(2 == $dateTime['status']){
|
||||
return '当前时段技师在休息';
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public function checkAddress($value,$rule,$data)
|
||||
{
|
||||
if(empty($value) && 'sumbit' == $data['action']){
|
||||
return '请选择地址';
|
||||
}
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @notes 验证技师
|
||||
* @param $value
|
||||
* @param $rule
|
||||
* @param $data
|
||||
* @return string|true
|
||||
* @author cjhao
|
||||
* @date 2024/9/9 15:00
|
||||
*/
|
||||
public function checkCoach($value,$rule,$data)
|
||||
{
|
||||
if('sumbit' != $data['action']){
|
||||
return true;
|
||||
}
|
||||
$coach = Coach::where(['id'=>$value])->findOrEmpty();
|
||||
if($coach->isEmpty()){
|
||||
return '技师不存在';
|
||||
}
|
||||
if(0 == $coach->work_status){
|
||||
return '技师休息中';
|
||||
}
|
||||
if(0 == $coach->server_status){
|
||||
return '技师已停止服务';
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
85
server/app/api/validate/RechargeValidate.php
Executable file
85
server/app/api/validate/RechargeValidate.php
Executable file
@@ -0,0 +1,85 @@
|
||||
<?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\validate;
|
||||
|
||||
|
||||
use app\common\service\ConfigService;
|
||||
use app\common\validate\BaseValidate;
|
||||
|
||||
class RechargeValidate extends BaseValidate
|
||||
{
|
||||
protected $rule = [
|
||||
'money' => 'require|float|gt:0|checkMoney',
|
||||
'pay_way' => 'require|checkRecharge',
|
||||
];
|
||||
|
||||
protected $message = [
|
||||
'money.require' => '请输入充值金额',
|
||||
'money.float' => '充值金额必须为浮点数',
|
||||
'money.gt' => '充值金额必须大于零',
|
||||
'pay_way.require' => '请选择支付方式',
|
||||
];
|
||||
|
||||
|
||||
public function sceneRecharge()
|
||||
{
|
||||
return $this->only(['money']);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 检验充值金额
|
||||
* @param $value
|
||||
* @param $rule
|
||||
* @param $data
|
||||
* @return bool|string
|
||||
* @author ljj
|
||||
* @date 2022/12/16 16:02
|
||||
*/
|
||||
public function checkMoney($value,$rule,$data)
|
||||
{
|
||||
$min_amount = ConfigService::get('recharge', 'min_recharge_amount',0);
|
||||
if($value < $min_amount) {
|
||||
return '最低充值金额:'.$min_amount.'元';
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 校验是否已开启充值功能
|
||||
* @param $value
|
||||
* @param $rule
|
||||
* @param $data
|
||||
* @return bool|string
|
||||
* @author ljj
|
||||
* @date 2022/12/16 16:02
|
||||
*/
|
||||
public function checkRecharge($value,$rule,$data)
|
||||
{
|
||||
$result = ConfigService::get('recharge', 'recharge_open',1);
|
||||
if($result != 1) {
|
||||
return '充值功能已关闭';
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
47
server/app/api/validate/RegisterValidate.php
Executable file
47
server/app/api/validate/RegisterValidate.php
Executable file
@@ -0,0 +1,47 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | likeadmin快速开发前后端分离管理后台(PHP版)
|
||||
// +----------------------------------------------------------------------
|
||||
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
|
||||
// | 开源版本可自由商用,可去除界面版权logo
|
||||
// | gitee下载:https://gitee.com/likeshop_gitee/likeadmin
|
||||
// | github下载:https://github.com/likeshop-github/likeadmin
|
||||
// | 访问官网:https://www.likeadmin.cn
|
||||
// | likeadmin团队 版权所有 拥有最终解释权
|
||||
// +----------------------------------------------------------------------
|
||||
// | author: likeadminTeam
|
||||
// +----------------------------------------------------------------------
|
||||
namespace app\api\validate;
|
||||
|
||||
|
||||
use app\common\model\user\User;
|
||||
use app\common\validate\BaseValidate;
|
||||
|
||||
/**
|
||||
* 注册验证器
|
||||
* Class RegisterValidate
|
||||
* @package app\api\validate
|
||||
*/
|
||||
class RegisterValidate extends BaseValidate
|
||||
{
|
||||
protected $rule = [
|
||||
'channel' => 'require',
|
||||
'account' => 'require|alphaNum|length:3,12|unique:' . User::class,
|
||||
'password' => 'require|length:6,20|alphaNum',
|
||||
'password_confirm' => 'require|confirm'
|
||||
];
|
||||
|
||||
protected $message = [
|
||||
'channel.require' => '注册来源参数缺失',
|
||||
'account.require' => '请输入账号',
|
||||
'account.alphaNum' => '账号须为字母数字组合',
|
||||
'account.length' => '账号须为3-12位之间',
|
||||
'account.unique' => '账号已存在',
|
||||
'password.require' => '请输入密码',
|
||||
'password.length' => '密码须在6-20位之间',
|
||||
'password.alphaNum' => '密码须为字母数字组合',
|
||||
'password_confirm.require' => '请确认密码',
|
||||
'password_confirm.confirm' => '两次输入的密码不一致'
|
||||
];
|
||||
|
||||
}
|
||||
51
server/app/api/validate/SendSmsValidate.php
Executable file
51
server/app/api/validate/SendSmsValidate.php
Executable file
@@ -0,0 +1,51 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | likeadmin快速开发前后端分离管理后台(PHP版)
|
||||
// +----------------------------------------------------------------------
|
||||
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
|
||||
// | 开源版本可自由商用,可去除界面版权logo
|
||||
// | gitee下载:https://gitee.com/likeshop_gitee/likeadmin
|
||||
// | github下载:https://github.com/likeshop-github/likeadmin
|
||||
// | 访问官网:https://www.likeadmin.cn
|
||||
// | likeadmin团队 版权所有 拥有最终解释权
|
||||
// +----------------------------------------------------------------------
|
||||
// | author: likeadminTeam
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
namespace app\api\validate;
|
||||
|
||||
|
||||
use app\common\enum\notice\NoticeEnum;
|
||||
use app\common\enum\SmsEnum;
|
||||
use app\common\validate\BaseValidate;
|
||||
|
||||
|
||||
/**
|
||||
* 短信验证
|
||||
* Class SmsValidate
|
||||
* @package app\api\validate
|
||||
*/
|
||||
class SendSmsValidate extends BaseValidate
|
||||
{
|
||||
|
||||
protected $rule = [
|
||||
'mobile' => 'require|mobile',
|
||||
'scene' => 'require|checkScene',
|
||||
];
|
||||
|
||||
protected $message = [
|
||||
'mobile.require' => '请输入手机号',
|
||||
'mobile.mobile' => '请输入正确手机号',
|
||||
'scene.require' => '请输入场景值',
|
||||
'scene.in' => '场景值错误',
|
||||
];
|
||||
|
||||
public function checkScene($value)
|
||||
{
|
||||
$scene = NoticeEnum::getSceneByUserTag($value);
|
||||
if(empty($scene)){
|
||||
return '场景值错误';
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
59
server/app/api/validate/ShareValidate.php
Executable file
59
server/app/api/validate/ShareValidate.php
Executable file
@@ -0,0 +1,59 @@
|
||||
<?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\api\validate;
|
||||
|
||||
|
||||
use app\common\enum\GoodsEnum;
|
||||
use app\common\model\goods\Goods;
|
||||
use app\common\validate\BaseValidate;
|
||||
|
||||
/**
|
||||
* 分享验证器
|
||||
* Class ShareValidate
|
||||
* @package app\shopapi\validate
|
||||
*/
|
||||
class ShareValidate extends BaseValidate
|
||||
{
|
||||
protected $rule = [
|
||||
'id' => 'checkGoods',
|
||||
'page' => 'require',
|
||||
];
|
||||
|
||||
protected $message = [
|
||||
'page.require' => '路径缺失',
|
||||
];
|
||||
|
||||
public function sceneGetMnpQrCode()
|
||||
{
|
||||
return $this->only(['id','page']);
|
||||
}
|
||||
|
||||
protected function checkGoods($value,$rule,$data)
|
||||
{
|
||||
$goods = Goods::where('id',$value)->findOrEmpty()->toArray();
|
||||
if(empty($goods)){
|
||||
return '商品不存在';
|
||||
}
|
||||
if(GoodsEnum::STATUS_STORE == $goods['status']){
|
||||
return '商品已下架';
|
||||
}
|
||||
return true;
|
||||
|
||||
}
|
||||
}
|
||||
125
server/app/api/validate/StaffOrderValidate.php
Executable file
125
server/app/api/validate/StaffOrderValidate.php
Executable file
@@ -0,0 +1,125 @@
|
||||
<?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\validate;
|
||||
|
||||
|
||||
use app\common\enum\OrderEnum;
|
||||
use app\common\model\order\Order;
|
||||
use app\common\model\staff\Staff;
|
||||
use app\common\validate\BaseValidate;
|
||||
|
||||
class StaffOrderValidate extends BaseValidate
|
||||
{
|
||||
protected $rule = [
|
||||
'id' => 'require|checkId',
|
||||
'verification_code' => 'require',
|
||||
];
|
||||
|
||||
protected $message = [
|
||||
'id.require' => '参数错误',
|
||||
'verification_code.require' => '核销码不能为空',
|
||||
];
|
||||
|
||||
public function sceneDetail()
|
||||
{
|
||||
return $this->only(['id']);
|
||||
}
|
||||
|
||||
public function sceneConfirmService()
|
||||
{
|
||||
return $this->only(['id'])
|
||||
->append('id','checkConfirmService');
|
||||
}
|
||||
|
||||
public function sceneVerification()
|
||||
{
|
||||
return $this->only(['verification_code'])
|
||||
->append('verification_code','checkVerification');
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 检验订单id
|
||||
* @param $value
|
||||
* @param $rule
|
||||
* @param $data
|
||||
* @return bool|string
|
||||
* @author ljj
|
||||
* @date 2022/2/28 10:12 上午
|
||||
*/
|
||||
public function checkId($value,$rule,$data)
|
||||
{
|
||||
$result = Order::where(['id'=>$value])->findOrEmpty();
|
||||
if ($result->isEmpty()) {
|
||||
return '订单不存在';
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @notes 检验是否能确认服务
|
||||
* @param $value
|
||||
* @param $rule
|
||||
* @param $data
|
||||
* @return bool|string
|
||||
* @author ljj
|
||||
* @date 2022/3/1 3:28 下午
|
||||
*/
|
||||
public function checkConfirmService($value,$rule,$data)
|
||||
{
|
||||
$result = Order::where(['id'=>$value])->findOrEmpty();
|
||||
if ($result['order_status'] != OrderEnum::ORDER_STATUS_APPOINT) {
|
||||
return '订单状态不正确,无法确认服务';
|
||||
}
|
||||
$staff_id = Staff::where('user_id',$data['user_id'])->value('id');
|
||||
if ($result['staff_id'] != $staff_id) {
|
||||
return '订单错误,无法确认服务';
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @notes 检验是否能核销
|
||||
* @param $value
|
||||
* @param $rule
|
||||
* @param $data
|
||||
* @return bool|string
|
||||
* @author ljj
|
||||
* @date 2022/3/1 3:56 下午
|
||||
*/
|
||||
public function checkVerification($value,$rule,$data)
|
||||
{
|
||||
$result = Order::where(['verification_code'=>$value])->findOrEmpty();
|
||||
if ($result->isEmpty()) {
|
||||
return '核销码不正确';
|
||||
}
|
||||
if ($result['order_status'] != OrderEnum::ORDER_STATUS_SERVICE) {
|
||||
return '订单状态不正确,无法核销';
|
||||
}
|
||||
$staff_id = Staff::where('user_id',$data['user_id'])->value('id');
|
||||
if ($result['staff_id'] != $staff_id) {
|
||||
return '订单错误,无法核销';
|
||||
}
|
||||
if ($result['verification_status'] == OrderEnum::VERIFICATION) {
|
||||
return '订单已核销';
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
63
server/app/api/validate/UserAddressValidate.php
Executable file
63
server/app/api/validate/UserAddressValidate.php
Executable file
@@ -0,0 +1,63 @@
|
||||
<?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\validate;
|
||||
|
||||
|
||||
use app\common\validate\BaseValidate;
|
||||
|
||||
class UserAddressValidate extends BaseValidate
|
||||
{
|
||||
protected $rule = [
|
||||
'id' => 'require',
|
||||
'contact' => 'require',
|
||||
'mobile' => 'require|mobile',
|
||||
'province_id' => 'require',
|
||||
'city_id' => 'require',
|
||||
'district_id' => 'require',
|
||||
'is_default' => 'in:0,1',
|
||||
'longitude' => 'require',
|
||||
'latitude' => 'require',
|
||||
];
|
||||
|
||||
|
||||
protected $message = [
|
||||
'id.require' => '参数错误',
|
||||
'contact.require' => '请输入联系人',
|
||||
'mobile.require' => '请输入手机号码',
|
||||
'mobile.mobile' => '手机号码格式不正确',
|
||||
'province_id.require' => '请选择省',
|
||||
'city_id.require' => '请选择市',
|
||||
'district_id.require' => '请选择区',
|
||||
'is_default.in' => '设为默认项的取值范围是[0,1]',
|
||||
'longitude.require' => '经纬度不能为空',
|
||||
'latitude.require' => '经纬度不能为空',
|
||||
];
|
||||
|
||||
|
||||
public function sceneAdd()
|
||||
{
|
||||
return $this->only(['contact','mobile','province_id','city_id','district_id','is_default','longitude','latitude']);
|
||||
}
|
||||
|
||||
public function sceneEdit()
|
||||
{
|
||||
return $this->only(['id','contact','mobile','province_id','city_id','district_id','is_default','longitude','latitude']);
|
||||
}
|
||||
}
|
||||
173
server/app/api/validate/UserValidate.php
Executable file
173
server/app/api/validate/UserValidate.php
Executable file
@@ -0,0 +1,173 @@
|
||||
<?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\validate;
|
||||
|
||||
|
||||
use app\common\model\user\User;
|
||||
use app\common\validate\BaseValidate;
|
||||
|
||||
class UserValidate extends BaseValidate
|
||||
{
|
||||
protected $rule = [
|
||||
'field' => 'require|checkField',
|
||||
'value' => 'require',
|
||||
'code' => 'require',
|
||||
'encrypted_data' => 'require',
|
||||
'iv' => 'require',
|
||||
'mobile' => 'require|mobile',
|
||||
'password' => 'require|length:6,20|alphaDash',
|
||||
'old_password' => 'require',
|
||||
];
|
||||
|
||||
protected $message = [
|
||||
'field.require' => '参数缺失',
|
||||
'value.require' => '值不存在',
|
||||
'code.require' => '参数缺失',
|
||||
'encrypted_data.require' => '参数缺失',
|
||||
'iv.require' => '参数缺失',
|
||||
'mobile.require' => '请输入手机号码',
|
||||
'mobile.mobile' => '无效的手机号码',
|
||||
'old_password.require' => '请输入原密码',
|
||||
'password.require' => '请输入登录密码',
|
||||
'password.length' => '登录密码须在6-20位之间',
|
||||
'password.alphaDash' => '登录密码须为字母数字下划线或破折号',
|
||||
];
|
||||
|
||||
public function sceneSetInfo()
|
||||
{
|
||||
return $this->only(['field','value']);
|
||||
}
|
||||
|
||||
public function sceneGetMobileByMnp()
|
||||
{
|
||||
return $this->only(['code', 'encrypted_data', 'iv']);
|
||||
}
|
||||
|
||||
public function sceneResetPasswordCaptcha()
|
||||
{
|
||||
return $this->only(['mobile']);
|
||||
}
|
||||
|
||||
public function sceneResetPassword()
|
||||
{
|
||||
return $this->only(['mobile', 'code']);
|
||||
// ->append('password', 'require|length:6,20|alphaDash|checkComplexity');
|
||||
}
|
||||
|
||||
public function sceneSetPassword()
|
||||
{
|
||||
return $this->only(['password']);
|
||||
}
|
||||
|
||||
public function sceneChangePassword()
|
||||
{
|
||||
return $this->only(['password', 'old_password']);
|
||||
}
|
||||
|
||||
public function sceneBindMobileCaptcha()
|
||||
{
|
||||
return $this->only(['mobile']);
|
||||
}
|
||||
|
||||
public function sceneChangeMobileCaptcha()
|
||||
{
|
||||
return $this->only(['mobile']);
|
||||
}
|
||||
|
||||
public function sceneBindMobile()
|
||||
{
|
||||
return $this->only(['mobile', 'code']);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 校验字段
|
||||
* @param $value
|
||||
* @param $rule
|
||||
* @param $data
|
||||
* @return bool|string
|
||||
* @author ljj
|
||||
* @date 2022/2/24 3:42 下午
|
||||
*/
|
||||
protected function checkField($value,$rule,$data)
|
||||
{
|
||||
$allowField = [
|
||||
'nickname','sex','avatar','mobile', 'account', 'real_name'
|
||||
|
||||
];
|
||||
if(!in_array($value,$allowField)){
|
||||
return '参数错误';
|
||||
}
|
||||
if($value != 'mobile') {
|
||||
return true;
|
||||
}
|
||||
$user = User::where([
|
||||
['mobile', '=', $data['value']],
|
||||
['id', '<>', $data['id']]
|
||||
])->findOrEmpty();
|
||||
if(!$user->isEmpty()) {
|
||||
return '该手机号已被绑定';
|
||||
}
|
||||
|
||||
if ($value == 'account') {
|
||||
$user = User::where([
|
||||
['account', '=', $data['value']],
|
||||
['id', '<>', $data['id']]
|
||||
])->findOrEmpty();
|
||||
if (!$user->isEmpty()) {
|
||||
return '账号已被使用!';
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @notes 校验密码复杂度
|
||||
* @param $value
|
||||
* @param $rue
|
||||
* @param $data
|
||||
* @author Tab
|
||||
* @date 2021/12/10 15:06
|
||||
*/
|
||||
public function checkComplexity($value, $rue, $data)
|
||||
{
|
||||
$lowerCase = range('a', 'z');
|
||||
$upperCase = range('A', 'Z');
|
||||
$numbers = range(0, 9);
|
||||
$cases = array_merge($lowerCase, $upperCase);
|
||||
$caseCount = 0;
|
||||
$numberCount = 0;
|
||||
$passwordArr = str_split(trim(($data['password'] . '')));
|
||||
foreach ($passwordArr as $value) {
|
||||
if (in_array($value, $numbers)) {
|
||||
$numberCount++;
|
||||
}
|
||||
if (in_array($value, $cases)) {
|
||||
$caseCount++;
|
||||
}
|
||||
}
|
||||
if ($numberCount >= 1 && $caseCount >= 1) {
|
||||
return true;
|
||||
}
|
||||
return '密码需包含数字和字母';
|
||||
}
|
||||
}
|
||||
81
server/app/api/validate/WechatLoginValidate.php
Executable file
81
server/app/api/validate/WechatLoginValidate.php
Executable file
@@ -0,0 +1,81 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | likeadmin快速开发前后端分离管理后台(PHP版)
|
||||
// +----------------------------------------------------------------------
|
||||
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
|
||||
// | 开源版本可自由商用,可去除界面版权logo
|
||||
// | gitee下载:https://gitee.com/likeshop_gitee/likeadmin
|
||||
// | github下载:https://github.com/likeshop-github/likeadmin
|
||||
// | 访问官网:https://www.likeadmin.cn
|
||||
// | likeadmin团队 版权所有 拥有最终解释权
|
||||
// +----------------------------------------------------------------------
|
||||
// | author: likeadminTeam
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
namespace app\api\validate;
|
||||
|
||||
use app\common\validate\BaseValidate;
|
||||
|
||||
class WechatLoginValidate extends BaseValidate
|
||||
{
|
||||
protected $rule = [
|
||||
'code' => 'require',
|
||||
'nickname' => 'require',
|
||||
'headimgurl' => 'require',
|
||||
'openid' => 'require',
|
||||
'access_token' => 'require',
|
||||
'terminal' => 'require',
|
||||
'avatar' => 'require',
|
||||
];
|
||||
|
||||
protected $message = [
|
||||
'code.require' => 'code缺少',
|
||||
'nickname.require' => '昵称缺少',
|
||||
'headimgurl.require' => '头像缺少',
|
||||
'openid.require' => 'opendid缺少',
|
||||
'access_token.require' => 'access_token缺少',
|
||||
'terminal.require' => '终端参数缺少',
|
||||
'avatar.require' => '头像缺少',
|
||||
];
|
||||
|
||||
|
||||
/**
|
||||
* @notes 公众号登录场景
|
||||
* @return WechatLoginValidate
|
||||
* @author 段誉
|
||||
* @date 2022/9/16 10:57
|
||||
*/
|
||||
public function sceneOa()
|
||||
{
|
||||
return $this->only(['code']);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 小程序-授权登录场景
|
||||
* @return WechatLoginValidate
|
||||
* @author 段誉
|
||||
* @date 2022/9/16 11:15
|
||||
*/
|
||||
public function sceneMnpLogin()
|
||||
{
|
||||
return $this->only(['code']);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes
|
||||
* @return WechatLoginValidate
|
||||
* @author 段誉
|
||||
* @date 2022/9/16 11:15
|
||||
*/
|
||||
public function sceneWechatAuth()
|
||||
{
|
||||
return $this->only(['code']);
|
||||
}
|
||||
|
||||
public function sceneUpdateUser()
|
||||
{
|
||||
return $this->only(['nickname','avatar']);
|
||||
}
|
||||
}
|
||||
40
server/app/api/validate/WechatValidate.php
Executable file
40
server/app/api/validate/WechatValidate.php
Executable file
@@ -0,0 +1,40 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | LikeShop有特色的全开源社交分销电商系统
|
||||
// +----------------------------------------------------------------------
|
||||
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
|
||||
// | 商业用途务必购买系统授权,以免引起不必要的法律纠纷
|
||||
// | 禁止对系统程序代码以任何目的,任何形式的再发布
|
||||
// | 微信公众号:好象科技
|
||||
// | 访问官网:http://www.likemarket.net
|
||||
// | 访问社区:http://bbs.likemarket.net
|
||||
// | 访问手册:http://doc.likemarket.net
|
||||
// | 好象科技开发团队 版权所有 拥有最终解释权
|
||||
// +----------------------------------------------------------------------
|
||||
// | Author: LikeShopTeam
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
namespace app\api\validate;
|
||||
|
||||
use app\common\validate\BaseValidate;
|
||||
|
||||
/**
|
||||
* 微信验证器
|
||||
* Class WechatValidate
|
||||
* @package app\api\validate
|
||||
*/
|
||||
class WechatValidate extends BaseValidate
|
||||
{
|
||||
public $rule = [
|
||||
'url' => 'require'
|
||||
];
|
||||
|
||||
public $message = [
|
||||
'url.require' => '请提供url'
|
||||
];
|
||||
|
||||
public function sceneJsConfig()
|
||||
{
|
||||
return $this->only(['url']);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user