初始版本

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

View File

@@ -0,0 +1,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\shopapi\http\middleware\InitMiddleware::class,
app\shopapi\http\middleware\LoginMiddleware::class,//登录验证
],
];

View 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\shopapi\controller;
use app\common\controller\BaseLikeShopController;
class BaseShopController extends BaseLikeShopController
{
protected int $shopId = 0;
protected int $shopUserId = 0;
protected array $shopInfo = [];
public function initialize()
{
if (isset($this->request->shopInfo) && $this->request->shopInfo) {
$this->shopInfo = $this->request->shopInfo;
$this->shopId = $this->shopInfo['shop_id'] ?? 0;
$this->shopUserId = $this->shopInfo['shop_user_id'] ?? 0;
}
}
}

View File

@@ -0,0 +1,88 @@
<?php
namespace app\shopapi\controller;
use app\shopapi\logic\CityLogic;
/**
* 城市控制器类
* Class CityController
* @package app\shopapi\controller
*/
class CityController extends BaseShopController
{
public function getCityLists()
{
$lists = (new CityLogic())->getCityLists();
return $this->success('',$lists);
}
/**
* @notes 搜索附近地址
* @return \think\response\Json
* @author ljj
* @date 2024/7/23 上午11:21
*/
public function getNearbyLocation()
{
$params = $this->request->get();
$result = (new CityLogic())->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 CityLogic())->getNearbyCity($params);
if(false === $result){
return $this->fail(CityLogic::getError());
}
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 CityLogic())->city($params);
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 = (new CityLogic())->geocoderCoordinate($get);
if ($result['status'] !== 0) {
return $this->fail($result['message']);
}
return $this->success('',$result);
}
}

View File

@@ -0,0 +1,147 @@
<?php
namespace app\shopapi\controller;
use app\shopapi\lists\ShopCoachLists;
use app\shopapi\logic\CoachLogic;
use app\shopapi\lists\CoachApplyLists;
use app\shopapi\logic\ShopLogic;
use app\shopapi\validate\ShopApplyValidate;
/**
* 技师控制器类
* Class CoachController
* @package app\shopapi\controller
*/
class CoachController extends BaseShopController
{
/**
* @notes 获取技师信息
* @return \think\response\Json
* @author cjhao
* @date 2024/12/8 22:22
*/
public function info()
{
$id = $this->request->get('id');
$result = (new CoachLogic())->info($id,$this->shopId);
if(false === $result){
return $this->success(CoachLogic::getError());
}
return $this->success('',$result);
}
/**
* @notes 门店技师列表
* @return \think\response\Json
* @author cjhao
* @date 2024/10/19 10:43
*/
public function shopCoachLists()
{
return $this->dataLists(new ShopCoachLists());
}
/**
* @notes 申请列表
* @return \think\response\Json
* @author cjhao
* @date 2024/10/15 20:35
*/
public function applyLists()
{
return $this->dataLists((new CoachApplyLists()));
}
/**
* @notes 申请详情
* @return \think\response\Json
* @author cjhao
* @date 2024/10/16 02:02
*/
public function applyDetail()
{
$id = $this->request->get('id',0);
$result = (new CoachLogic())->applyDetail($id);
if(false === $result){
return $this->success(CoachLogic::getError());
}
return $this->success('',$result);
}
/**
* @notes 技师申请审核
* @return \think\response\Json
* @author cjhao
* @date 2024/10/16 00:06
*/
public function applyAudit()
{
$params = (new ShopApplyValidate())->post()->goCheck('',['shop_id'=>$this->shopId]);
$result = (new CoachLogic())->applyAudit($params);
if(true === $result){
return $this->success('操作成功');
}
return $this->fail($result);
}
/**
* @notes 获取师傅服务时间
* @return \think\response\Json
* @author cjhao
* @date 2024/8/29 18:36
*/
public function getServerTime()
{
$id = $this->request->get('id');
$result = (new CoachLogic())->getServerTime($id);
if(is_array($result)){
return $this->success('',$result);
}
return $this->fail($result);
}
/**
* @notes 设置技师服务时间
* @return \think\response\Json
* @author cjhao
* @date 2024/9/2 17:28
*/
public function setServerTime()
{
$params = $this->request->post();
$params['shop_id'] = $this->shopId;
$result = (new ShopLogic())->setServerTime($params);
if(true === $result){
return $this->success('设置成功');
}
return $this->fail($result);
}
/**
* @notes 设置技师服务时间
* @return \think\response\Json
* @author cjhao
* @date 2024/9/2 17:28
*/
public function setWorkStatus()
{
$params = $this->request->post();
$params['shop_id'] = $this->shopId;
$result = (new ShopLogic())->setWorkStatus($params);
if(true === $result){
return $this->success('设置成功');
}
return $this->fail($result);
}
}

View File

@@ -0,0 +1,50 @@
<?php
namespace app\shopapi\controller;
use app\shopapi\logic\ConfigLogic;
class ConfigController extends BaseShopController
{
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);
}
}

View File

@@ -0,0 +1,52 @@
<?php
namespace app\shopapi\controller;
use app\api\controller\BaseApiController;
use app\shopapi\logic\DecorateLogic;
/**
* 装修风格控制器类
* Class DecorateController
* @package app\api\controller
*/
class DecorateController extends BaseShopController
{
public array $notNeedLogin = ['page','style','tabbar'];
/**
* @notes 获取装修页面
* @return \think\response\Json
* @author cjhao
* @date 2024/10/8 15:13
*/
public function page()
{
$type = $this->request->get('type',1);
$detail = (new DecorateLogic())->page($type);
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);
}
}

View File

@@ -0,0 +1,42 @@
<?php
namespace app\shopapi\controller;
use app\shopapi\logic\DepositLogic;
/**
* 保证金控制器类
* Class CoachController
* @package app\coachapi\controller
*/
class DepositController extends BaseShopController
{
/**
* @notes 获取保证金套餐
* @return \think\response\Json
* @author cjhao
* @date 2024/8/27 18:22
*/
public function depositPackage()
{
$result = (new DepositLogic())->depositPackage($this->shopUserId);
return $this->success('',$result);
}
/**
* @notes 提交订单
* @return \think\response\Json
* @author cjhao
* @date 2024/8/27 18:37
*/
public function sumbitOrder()
{
$params = $this->request->post();
$result = (new DepositLogic())->sumbitOrder($params,$this->shopId);
if(false === $result){
return $this->fail(DepositLogic::getError());
}
return $this->success('',$result);
}
}

View File

@@ -0,0 +1,22 @@
<?php
namespace app\shopapi\controller;
use app\shopapi\controller\BaseShopController;
/**
* 财务控制器类
* Class FinanceController
* @package app\shopapi\controller
*/
class FinanceController extends BaseShopController
{
public function lists()
{
return $this->dataLists();
}
}

View File

@@ -0,0 +1,37 @@
<?php
namespace app\shopapi\controller;
use app\shopapi\lists\CommentGoodsLists;
use app\shopapi\logic\GoodsCommentLogic;
/**
* 评论控制器类
* Class GoodsCommentController
* @package app\shopapi\controller
*/
class GoodsCommentController extends BaseShopController
{
/**
* @notes 服务评价列表
* @return \think\response\Json
* @author ljj
* @date 2022/2/18 11:24 上午
*/
public function lists()
{
return $this->dataLists(new CommentGoodsLists());
}
/**
* @notes 服务评价分类
* @return \think\response\Json
* @author ljj
* @date 2022/2/18 2:10 下午
*/
public function commentCategory()
{
$result = (new GoodsCommentLogic())->commentCategory($this->shopId);
return $this->success('',$result);
}
}

View File

@@ -0,0 +1,157 @@
<?php
namespace app\shopapi\controller;
use app\shopapi\lists\MyGoodsLists;
use app\shopapi\lists\ShopGoodsLists;
use app\shopapi\logic\GoodsLogic;
use app\shopapi\validate\GoodsValidate;
/**
* 服务控制器类
* Class GoodsController
* @package app\shopapi\controller
*/
class GoodsController extends BaseShopController
{
public array $notNeedLogin = ['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/10/5 14:48
*/
public function categoryLists()
{
$lists = (new GoodsLogic())->categoryLists();
return $this->success('',$lists);
}
/**
* @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/16 16:47
*/
public function skillLists()
{
$lists = (new GoodsLogic())->skillLists();
return $this->success('',$lists);
}
/**
* @notes 服务列表
* @return \think\response\Json
* @author cjhao
* @date 2024/10/5 14:49
*/
public function lists()
{
return $this->dataLists();
}
/**
* @notes 添加服务
* @return \think\response\Json
* @author cjhao
* @date 2024/10/16 17:38
*/
public function add()
{
$params = (new GoodsValidate())->post()->goCheck('add',['shop_id'=>$this->shopId]);
$result = (new GoodsLogic())->add($params);
if(true === $result){
return $this->success('添加成功,请等待管理员审核');
}
return $this->fail($result);
}
/**
* @notes 编辑服务
* @return \think\response\Json
* @author cjhao
* @date 2024/10/16 18:13
*/
public function edit()
{
$params = (new GoodsValidate())->post()->goCheck('',['shop_id'=>$this->shopId]);
$result = (new GoodsLogic())->edit($params);
if(true === $result){
return $this->success('编辑成功,请等待管理员审核');
}
return $this->fail($result);
}
/**
* @notes 我的项目列表
* @return \think\response\Json
* @author cjhao
* @date 2024/12/11 17:30
*/
public function myGoodsLists()
{
return $this->dataLists((new MyGoodsLists()));
}
/**
* @notes 门店服务列表
* @return \think\response\Json
* @author cjhao
* @date 2024/10/16 16:57
*/
public function shopGoodsLists()
{
return $this->dataLists((new ShopGoodsLists()));
}
/**
* @notes 查看服务详情
* @return \think\response\Json
* @author ljj
* @date 2022/2/9 3:52 下午
*/
public function detail()
{
$params = (new GoodsValidate())->get()->goCheck('detail');
$result = (new GoodsLogic())->detail($params['id']);
return $this->success('获取成功',$result);
}
/**
* @notes 删除服务
* @return \think\response\Json
* @author ljj
* @date 2022/2/9 4:13 下午
*/
public function del()
{
$params = (new GoodsValidate())->post()->goCheck('del',['shop_id'=>$this->shopId]);
$result = (new GoodsLogic())->del($params['id'],$this->shopId);
if (true !== $result) {
return $this->fail($result);
}
return $this->success('操作成功',[],1,1);
}
/**
* @notes 修改服务状态
* @return \think\response\Json
* @author ljj
* @date 2022/2/9 4:55 下午
*/
public function status()
{
$params = (new GoodsValidate())->post()->goCheck('status');
(new GoodsLogic)->status($params,$this->shopId);
return $this->success('操作成功',[],1,1);
}
}

View File

@@ -0,0 +1,19 @@
<?php
namespace app\shopapi\controller;
use app\shopapi\logic\IndexLogic;
class IndexController extends BaseShopController
{
/**
* @notes 首页商家数据
* @return \think\response\Json
* @author cjhao
* @date 2024/11/12 17:55
*/
public function shopData()
{
$result = (new IndexLogic())->shopData($this->shopId);
return $this->success('',$result);
}
}

View File

@@ -0,0 +1,118 @@
<?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\shopapi\controller;
use app\shopapi\validate\{LoginAccountValidate, PasswordValidate, RegisterValidate};
use app\shopapi\logic\LoginLogic;
/**
* 登录注册
* Class LoginController
* @package app\coachapi\controller
*/
class LoginController extends BaseShopController
{
public array $notNeedLogin = ['register', 'account', 'logout','resetPassword'];
/**
* @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(),[],LoginLogic::getReturnCode());
}
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->shopInfo);
return $this->success();
}
/**
* @notes 重置密码
* @return \think\response\Json
* @author 段誉
* @date 2022/9/16 18:06
*/
public function resetPassword()
{
$params = (new PasswordValidate())->post()->goCheck('resetPassword');
$result = (new LoginLogic())->resetPassword($params);
if (true === $result) {
return $this->success('操作成功', [], 1, 1);
}
return $this->fail(LoginLogic::getError());
}
/**
* @notes 修改密码
* @return \think\response\Json
* @author cjhao
* @date 2024/11/27 09:46
*/
public function changePassword()
{
$params = (new PasswordValidate())->post()->goCheck('changePassword',['shop_info'=>$this->shopInfo]);
$params['shop_info'] = $this->shopInfo;
$result = (new LoginLogic())->changePassword($params);
if (true === $result) {
return $this->success('操作成功', [], 1, 1);
}
return $this->fail(LoginLogic::getError());
}
}

View File

@@ -0,0 +1,90 @@
<?php
namespace app\shopapi\controller;
use app\shopapi\lists\CoachOrderLists;
use app\shopapi\lists\IncomeLists;
use app\shopapi\logic\OrderLogic;
/**
* 订单控制器类
* Class OrderController
* @package app\shopapi\controller
*/
class OrderController extends BaseShopController
{
public function lists()
{
return $this->dataLists();
}
/**
* @notes 订单详情
* @return \think\response\Json
* @author cjhao
* @date 2024/9/20 02:18
*/
public function detail()
{
$id = $this->request->get('id');
$result = (new OrderLogic())->detail($id);
return $this->success('', $result);
}
/**
* @notes 师傅订单
* @return \think\response\Json
* @author cjhao
* @date 2024/12/8 21:55
*/
public function coachOrderLists()
{
return $this->dataLists((new CoachOrderLists()));
}
/**
* @notes 收入列表
* @return \think\response\Json
* @author cjhao
* @date 2024/11/5 18:11
*/
public function incomeLists()
{
return $this->dataLists((new IncomeLists()));
}
/**
* @notes 订单更换技师时获取技师列表
* @return \think\response\Json
* @author cjhao
* @date 2024/9/29 10:25
*/
public function coachLists()
{
$params = $this->request->get();
$result = (new OrderLogic())->coachLists($params,$this->shopId);
if (false !== $result) {
return $this->success('', $result);
}
return $this->fail(OrderLogic::getError());
}
/**
* @notes 指派技师
* @return \think\response\Json
* @author cjhao
* @date 2024/10/10 23:05
*/
public function dispatchCoach()
{
$params = $this->request->post();
$params['shop_id'] = $this->shopId;
$result = (new OrderLogic())->dispatchCoach($params);
if (false !== $result) {
return $this->success('操作成功', [], 1, 1);
}
return $this->fail(OrderLogic::getError());
}
}

View 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\shopapi\controller;
use app\shopapi\logic\PayLogic;
use app\shopapi\validate\PayValidate;
use app\common\enum\user\UserTerminalEnum;
use app\common\service\AliPayService;
use app\common\service\WeChatPayService;
class PayController extends BaseShopController
{
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',['shop_id'=>$this->shopId]);
$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->shopInfo['terminal'],$params['code'] ?? '');
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);
}
}

View File

@@ -0,0 +1,137 @@
<?php
namespace app\shopapi\controller;
use app\shopapi\logic\ShopLogic;
use app\shopapi\validate\ShopValidate;
class ShopController extends BaseShopController
{
/**
* @notes 个人中心
* @return \think\response\Json
* @author cjhao
* @date 2024/10/20 03:11
*/
public function centre()
{
$result = (new ShopLogic())->centre($this->shopId);
return $this->success('',$result);
}
/**
* @notes 获取商家信息
* @return \think\response\Json
* @author cjhao
* @date 2024/11/19 11:03
*/
public function info()
{
$result = (new ShopLogic())->info($this->shopId);
return $this->success('',$result);
}
/**
* @notes 申请
* @return \think\response\Json
* @author cjhao
* @date 2024/10/5 17:33
*/
public function apply()
{
$params = (new ShopValidate())->post()->goCheck('',$this->shopInfo);
$result = (new ShopLogic())->apply($params);
if(true === $result){
return $this->success('申请成功,请等待管理员审核',[],1,1);
}
return $this->fail($result);
}
/**
* @notes 店铺详情
* @return \think\response\Json
* @author cjhao
* @date 2024/10/5 20:25
*/
public function detail()
{
$result = (new ShopLogic())->detail($this->shopUserId);
return $this->success('',$result);
}
/**
* @notes 更新信息
* @return \think\response\Json
* @author cjhao
* @date 2024/10/6 12:13
*/
public function updateInfo()
{
$params = (new ShopValidate())->post()->goCheck('update',$this->shopInfo);
$result = (new ShopLogic())->updateInfo($params);
if ($result === true){
return $this->success('提交成功,请等待管理员审核',[],1,1);
}
return $this->fail($result);
}
/**
* @notes 获取更新资料接口
* @return \think\response\Json
* @author cjhao
* @date 2024/11/25 11:10
*/
public function updateInfoDetail(){
$result = (new ShopLogic())->updateInfoDetail($this->shopUserId);
return $this->success('',$result);
}
/**
* @notes 设置营业时间
* @return \think\response\Json
* @author cjhao
* @date 2024/10/22 09:25
*/
public function getBusiness()
{
$result = (new ShopLogic())->getBusiness($this->shopId);
return $this->success('',$result);
}
/**
* @notes 设置营业时间
* @return \think\response\Json
* @author cjhao
* @date 2024/10/22 09:25
*/
public function setBusiness()
{
$params = $this->request->post();
$params['shop_id'] = $this->shopId;
(new ShopLogic())->setBusiness($params);
return $this->success('设置成功',[],1,1);
}
/**
* @notes 绑定手机号
* @return \think\response\Json
* @author Tab
* @date 2021/8/25 17:46
*/
public function bindMobile()
{
$params = $this->request->post();
$params['shop_id'] = $this->shopId;
$result = (new ShopLogic())->bindMobile($params);
if($result === true) {
return $this->success('绑定成功', [], 1, 1);
}
return $this->fail($result);
}
}

View 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\shopapi\controller;
use app\shopapi\logic\SmsLogic;
use app\shopapi\validate\SendSmsValidate;
/**
* 短信
* Class SmsController
* @package app\api\controller
*/
class SmsController extends BaseShopController
{
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());
}
}

View 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\shopapi\controller;
use app\coachapi\controller\BaseCoachController;
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 BaseShopController
{
/**
* @notes 上传图片
* @return Json
* @author 段誉
* @date 2022/9/20 18:11
*/
public function image()
{
try {
$result = UploadService::image(0, $this->shopId,FileEnum::SOURCE_SHOP);
return $this->success('上传成功', $result);
} catch (Exception $e) {
return $this->fail($e->getMessage());
}
}
}

View File

@@ -0,0 +1,113 @@
<?php
namespace app\shopapi\controller;
use app\shopapi\lists\WithdrawalLogLists;
use app\shopapi\logic\WithdrawLogic;
/**
* 提现列表
* Class WithdrawController
* @package app\shopapi\controller
*/
class WithdrawController extends BaseShopController
{
public function lists()
{
$lists = (new WithdrawLogic())->lists($this->shopId);
return $this->success('',$lists);
}
/**
* @notes 获取提现配置
* @return \think\response\Json
* @author cjhao
* @date 2024/9/26 00:09
*/
public function getWithDrawWay()
{
$type = $this->request->get('type',1);
$lists = (new WithdrawLogic())->getWithDrawWay($this->shopId,$type);
return $this->success('',$lists);
}
/**
* @notes 设置提现配置
* @return \think\response\Json
* @author cjhao
* @date 2024/9/26 00:24
*/
public function setWithDrawWay()
{
$post = $this->request->post();
$result = (new WithdrawLogic())->setWithDrawWay($this->shopId,$post);
if(true === $result){
return $this->success('设置成功',[],1,1);
}
return $this->fail($result);
}
/**
* @notes 提现
* @return \think\response\Json
* @author cjhao
* @date 2024/10/29 18:00
*/
public function apply(){
$params = $this->request->post();
$params['shop_id'] = $this->shopId;
$result = (new WithdrawLogic())->apply($params);
if(true === $result){
return $this->success('申请提现成功,请等待审核');
}
return $this->fail(WithdrawLogic::getError());
}
/**
* @notes 获取提现配置
* @return \think\response\Json
* @author cjhao
* @date 2024/10/29 17:21
*/
public function getWithdrawInfo()
{
$result = (new WithdrawLogic())->getWithdrawInfo($this->shopId);
return $this->success('',$result,1,1);
}
/**
* @notes 记录列表
* @return \think\response\Json
* @author cjhao
* @date 2024/10/30 23:46
*/
public function logLists()
{
return $this->dataLists((new WithdrawalLogLists()));
}
/**
* @notes 提现详情
* @return \think\response\Json
* @throws \Exception
* @author cjhao
* @date 2024/10/31 09:07
*/
public function detail()
{
$id = $this->request->get('id');
$result = (new WithdrawLogic())->detail($id,$this->shopId);
return $this->success('',$result);
}
}

View File

@@ -0,0 +1,86 @@
<?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\shopapi\http\middleware;
use app\common\exception\ControllerExtendException;
use app\common\service\JsonService;
use app\shopapi\controller\BaseShopController;
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\\shopapi\\controller\\' . $controller . 'Controller';
$controllerClass = invoke($controller);
if (($controllerClass instanceof BaseShopController) === 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);
}
}

View File

@@ -0,0 +1,90 @@
<?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\shopapi\http\middleware;
use app\common\cache\ShopUserTokenCache;
use app\common\enum\shop\ShopEnum;
use app\common\model\shop\Shop;
use app\common\service\JsonService;
use app\shopapi\service\ShopUserTokenService;
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);
}
$shopInfo = (new ShopUserTokenCache())->getShopUserInfo($token);
if (empty($shopInfo) && !$isNotNeedLogin) {
//token过期无效并且该地址需要登录才能访问
return JsonService::fail('登录超时,请重新登录', [], -1, 0);
}
//token临近过期自动续期
if ($shopInfo) {
//获取临近过期自动续期时长
$beExpireDuration = Config::get('project.user_token.be_expire_duration');
//token续期
if (time() > ($shopInfo['expire_time'] - $beExpireDuration)) {
$result = ShopUserTokenService::overtimeToken($token);
//续期失败(数据表被删除导致)
if (empty($result)) {
return JsonService::fail('登录过期', [], -1);
}
}
}
//todo 重新查询sql赋值这里有优化的空间
if($shopInfo && ShopEnum::AUDIT_STATUS_WAIT == $shopInfo['audit_status']){
$shop = Shop::where(['shop_user_id'=>$shopInfo['shop_user_id']])
->order('id desc')
->field('id,audit_status')
->find();
}
$shopInfo['audit_status'] = $shop->audit_status ?? 0;
//给request赋值用于控制器
$request->shopInfo = $shopInfo;
$request->shopId = $shop->id ?? 0;
$request->shopUserId = $shopInfo['shop_user_id'] ?? 0;
return $next($request);
}
}

View File

@@ -0,0 +1,45 @@
<?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\shopapi\lists;
use app\common\lists\BaseDataLists;
abstract class BaseShopApiDataLists extends BaseDataLists
{
protected int $shopId = 0;
protected int $shopUserId = 0;
protected array $shopInfo = [];
public string $export;
public function __construct()
{
parent::__construct();
if (isset($this->request->shopInfo) && $this->request->shopInfo) {
$this->shopInfo = $this->request->shopInfo;
$this->shopId = $this->shopInfo['shop_id'] ?? 0;
$this->shopUserId = $this->shopInfo['shop_user_id'] ?? 0;
}
$this->export = $this->request->get('export', '');
}
}

View File

@@ -0,0 +1,51 @@
<?php
namespace app\shopapi\lists;
use app\common\enum\shop\ShopEnum;
use app\common\model\coach\Coach;
use app\common\model\goods\GoodsComment;
use app\common\model\skill\Skill;
use app\shopapi\lists\BaseShopApiDataLists;
/**
*
* Class CoachController
* @package app\shopapi\controller
*/
class CoachApplyLists extends BaseShopApiDataLists{
public function setWhere()
{
$where = [];
$type = $this->params['type'] ?? 1;
$where[] = ['SCA.shop_id','=',$this->shopId];
$where[] = ['SCA.type','=',$type];
$where[] = ['SCA.audit_status','=',ShopEnum::AUDIT_STATUS_WAIT];
return $where;
}
public function lists(): array
{
$lists = Coach::alias('C')
->join('shop_coach_apply SCA','C.id = SCA.coach_id')
->field('SCA.id,SCA.coach_id,SCA.type,C.name,C.good_comment,C.work_photo,C.order_num,C.skill_id')
->limit($this->limitOffset, $this->limitLength)
->where($this->setWhere())
->select()
->toArray();
$skillIds = array_column($lists,'skill_id');
$skillLists = Skill::where(['id'=>$skillIds])->column('name','id');
foreach ($lists as $key => $coach){
$lists[$key]['good_comment'] = $coach['good_comment'].'%';
$lists[$key]['skill_name'] = $skillLists[$coach['skill_id']] ?? '';
}
return $lists;
}
public function count(): int
{
return Coach::alias('C')
->join('shop_coach_apply SCA','C.id = SCA.coach_id')
->where($this->setWhere())
->count();
}
}

View File

@@ -0,0 +1,97 @@
<?php
namespace app\shopapi\lists;
use app\common\enum\OrderEnum;
use app\common\enum\PayEnum;
use app\common\enum\shop\ShopEnum;
use app\common\lists\ListsExtendInterface;
use app\common\model\coach\Coach;
use app\common\model\order\Order;
/**
* 订单列表
* Class OrderLists
* @package app\coachapi\lists
*/
class CoachOrderLists extends BaseShopApiDataLists implements ListsExtendInterface
{
public function setWhere()
{
$where[] = ['order_status','in',[
OrderEnum::ORDER_STATUS_WAIT_RECEIVING,
OrderEnum::ORDER_STATUS_WAIT_DEPART,
OrderEnum::ORDER_STATUS_DEPART,
OrderEnum::ORDER_STATUS_START_SERVER,
OrderEnum::ORDER_STATUS_ARRIVE,
// OrderEnum::ORDER_STATUS_SERVER_FINISH
]];
$where[] = ['pay_status','=',PayEnum::ISPAID];
$coachId = $this->params['coach_id'] ?? '';
if($coachId){
$where[] = ['coach_id','=',$coachId];
$where[] = ['shop_id','=',$this->shopId];
}else{
$where[] = ['shop_id','=',$this->shopId];
}
if(isset($this->params['start_time']) && $this->params['start_time']){
$where[] = ['create_time','>',strtotime($this->params['start_time'])];
}
if(isset($this->params['end_time']) && $this->params['end_time']){
$where[] = ['create_time','<',strtotime($this->params['end_time'])];
}
return $where;
}
public function lists(): array
{
$lists = Order::field('id,sn,order_status,user_remark,pay_status,appoint_time,total_order_amount,order_amount,user_remark,address_snap,server_finish_time,create_time,coach_id,order_distance')
->order('appoint_time','asc')
->append(['order_distance_desc','appoint_time','appoint_date','order_status_desc','order_cancel_time'])
->with(['order_goods' => function($query){
$query->field('order_id,goods_snap,goods_num,duration,goods_image,goods_name,goods_price')->hidden(['goods_snap']);
}])
->where($this->setWhere())
->limit($this->limitOffset, $this->limitLength)
->select()
->toArray();
return $lists;
}
public function count(): int
{
return Order::where($this->setWhere())
->limit($this->limitOffset, $this->limitLength)
->count();
}
public function extend()
{
$where = $this->setWhere();
unset($where[0]);
$where = array_values($where);
return [
'wait_take_num' => Order::where($where)
->where(['order_status'=>OrderEnum::ORDER_STATUS_WAIT_RECEIVING])
->count(),
'wait_server_num' => Order::where($where)
->where('order_status','in',[
OrderEnum::ORDER_STATUS_WAIT_DEPART,
OrderEnum::ORDER_STATUS_DEPART,
OrderEnum::ORDER_STATUS_START_SERVER,
OrderEnum::ORDER_STATUS_ARRIVE
])
->count(),
'wait_settle_num' => Order::where($where)
->where('order_status','in',[OrderEnum::ORDER_STATUS_SERVER_FINISH,OrderEnum::ORDER_STATUS_CLOSE])
->where(['is_settle'=>0])
->whereRaw('total_order_amount>total_refund_amount')
->count(),
];
}
}

View File

@@ -0,0 +1,104 @@
<?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\shopapi\lists;
use app\common\enum\OrderEnum;
use app\common\model\coach\Coach;
use app\common\model\goods\GoodsComment;
use app\common\model\order\Order;
use app\common\model\order\OrderGoods;
use app\common\model\user\User;
use app\common\service\FileService;
class CommentGoodsLists extends BaseShopApiDataLists
{
/**
* @notes 搜索条件
* @return array
* @author ljj
* @date 2022/2/18 2:25 下午
*/
public function setWhere()
{
$shopId = $this->shopId;
$where = [];
$id = $this->params['id'] ?? 0;
switch ($id){
case 1:
$goodsCommentId = GoodsComment::alias('GC')
->where(['shop_id'=>$shopId])
->join('goods_comment_image GCI','GC.id = GCI.comment_id')
->column('GC.id') ?: [];
empty($goodsCommentId) && $goodsCommentId = [];
$where[] = ['id','in',implode(',',$goodsCommentId)];
break;
case 2:
$where[] = ['service_comment','>',3];
break;
case 3:
$where[] = ['service_comment','<=',3];
break;
}
return $where;
}
/**
* @notes 评价商品列表
* @return array
* @author ljj
* @date 2022/2/21 5:59 下午
*/
public function lists(): array
{
$lists = GoodsComment::where(['shop_id'=>$this->shopId])
->where($this->setWhere())
->with(['goods_comment_image'])
->field('id,user_id,service_comment,comment,reply,create_time')
->order('id desc')
->limit($this->limitOffset, $this->limitLength)
->select()->toArray();
$userIds = array_column($lists,'user_id');
$userLists = [];
if($userIds){
$userLists = User::where(['id'=>$userIds])->field('id,nickname,avatar')->select()->toArray();
$userLists = array_column($userLists,null,'id');
}
foreach ($lists as $key => $goodsComment){
$lists[$key]['nickname'] = $userLists[$goodsComment['user_id']]['nickname'];
$lists[$key]['avatar'] = $userLists[$goodsComment['user_id']]['avatar'];
}
return $lists;
}
/**
* @notes 评价商品总数
* @return int
* @author ljj
* @date 2022/2/21 5:59 下午
*/
public function count(): int
{
return GoodsComment::where(['shop_id'=>$this->shopId])
->where($this->setWhere())
->count();
}
}

View File

@@ -0,0 +1,59 @@
<?php
namespace app\shopapi\lists;
use app\common\enum\accountLog\ShopAccountLogEnum;
use app\common\model\accountLog\ShopAccountLog;
use app\common\model\shop\Shop;
use app\common\lists\ListsExtendInterface;
/**
* 财务管理列表
* Class FinanceLists
* @package app\shopapi\lists
*/
class FinanceLists extends BaseShopApiDataLists implements ListsExtendInterface
{
public function setWhere()
{
$where = [];
$type = $this->params['type'] ?? '';
$where[] = ['shop_id','=',$this->shopId];
switch ($type){
case 1:
$where[] = ['change_type','in',ShopAccountLogEnum::MONEY_DESC];
break;
case 2:
$where[] = ['change_type','in',ShopAccountLogEnum::DEPOSIT_DESC];
break;
}
return $where;
}
public function lists(): array
{
$lists = ShopAccountLog::where(['shop_id'=>$this->shopId])
->where($this->setWhere())
->field('id,sn,action,change_object,change_type,change_amount,left_amount,create_time')
->append(['change_type_desc'])
->order('id desc')
->limit($this->limitOffset, $this->limitLength)
->select()->toArray();
return $lists;
}
public function count(): int
{
return ShopAccountLog::where(['shop_id'=>$this->shopId])
->where($this->setWhere())
->count();
}
public function extend()
{
$shop = Shop::where(['id'=>$this->shopId])->field('money,deposit')->findOrEmpty();
return [
'money' => $shop['money'],
'deposit' => $shop['deposit'],
];
}
}

View File

@@ -0,0 +1,49 @@
<?php
namespace app\shopapi\lists;
use app\coachapi\lists\BaseCoachApiDataLists;
use app\common\enum\GoodsEnum;
use app\common\model\goods\Goods;
use app\common\model\goods\GoodsCategory;
/**
* 服务列表
* Class GoodsLists
* @package app\shopapi\lists
*/
class GoodsLists extends BaseShopApiDataLists
{
public function setWhere()
{
$where = [];
$where[] = ['status','=',1];
$where[] = ['audit_status','=',GoodsEnum::AUDIT_STATUS_PASS];
$where[] = ['shop_id','=',0];
if(isset($this->params['category_id']) && $this->params['category_id']){
if(is_array(explode(',',$this->params['category_id']))) {
$categoryIds = explode(',',$this->params['category_id']);
}else{
$categoryIds[] = $this->params['category_id'];
}
$categoryId = GoodsCategory::where(['pid'=>$categoryIds])->column('id');
$categoryIds = array_merge($categoryId,$categoryIds);
$where[] = ['category_id','in',$categoryIds];
}
return $where;
}
public function lists(): array
{
$lists = Goods::where($this->setWhere())
->field('id,name,image,status,price,audit_status,virtual_order_num+order_num as order_num')
->append(['audit_status_desc','status_desc'])
->limit($this->limitOffset, $this->limitLength)
->select()->toArray();
return $lists;
}
public function count(): int
{
return Goods::where($this->setWhere())->count();
}
}

View File

@@ -0,0 +1,98 @@
<?php
namespace app\shopapi\lists;
use app\coachapi\lists\BaseCoachApiDataLists;
use app\common\enum\OrderEnum;
use app\common\lists\ListsExtendInterface;
use app\common\model\coach\Coach;
use app\common\model\order\Order;
use app\common\model\settle\Settle;
use app\common\model\settle\SettleOrder;
use app\common\model\shop\Shop;
use think\facade\Db;
class IncomeLists extends BaseShopApiDataLists implements ListsExtendInterface
{
public function setWhere()
{
$where = [];
$where[] = ['shop_id','=',$this->shopId];
$type = $this->params['type'] ?? 1;
$where[] = ['is_settle','=',$type];
if(isset($this->params['start_time']) && $this->params['start_time']){
$where[] = ['create_time','>',strtotime($this->params['start_time'])];
}
if(isset($this->params['end_time']) && $this->params['end_time']){
$where[] = ['create_time','<',strtotime($this->params['end_time'])+86399];
}
$whereOr1 = array_merge($where,[['order_status','not in',[OrderEnum::ORDER_STATUS_WAIT_PAY,OrderEnum::ORDER_STATUS_WAIT_RECEIVING,OrderEnum::ORDER_STATUS_CLOSE]]],);
$whereOr2 = array_merge($where, [
['order_status','=',OrderEnum::ORDER_STATUS_CLOSE],
['total_order_amount','exp',Db::raw('>total_refund_amount')],
]);
return [$whereOr1,$whereOr2];
}
public function lists(): array
{
$lists = Order::field('id,sn,order_status,total_refund_amount,total_order_amount,user_remark,pay_status,appoint_time,is_settle,total_num,order_amount,user_remark,address_snap,true_server_finish_time,server_finish_time,create_time,coach_id,order_distance')
->order('id','desc')
->append(['order_distance_desc','true_server_finish_time_desc','appoint_time','appoint_date','order_status_desc','order_cancel_time'])
->with(['order_goods' => function($query){
$query->field('order_id,goods_snap,duration,goods_num,goods_image,goods_name,goods_price')->hidden(['goods_snap']);
}])
->whereOr($this->setWhere())
->limit($this->limitOffset, $this->limitLength)
->select()->toArray();
$orderIds = array_column($lists,'id');
$settleOrderLists = SettleOrder::where(['order_id'=>$orderIds])->column('*','order_id');
foreach ($lists as $key => $order){
$status = 0;
$settleOrder = $settleOrderLists[$order['id']] ?? [];
if($settleOrder){
$status = 1;
}
$shopCommission = $settleOrder['shop_commission'] ?? 0;
$shopCarAmount = $settleOrder['shop_car_amount'] ?? 0;
$coachCommission = $settleOrder['coach_commission'] ?? 0;
$coachCarAmount = $settleOrder['coach_car_amount'] ?? 0;
$lists[$key]['settle_info'] = [
'status' => $status,
'order_amount' => $settleOrder['order_amount'] ?? 0,
'refund_amount' => $order['total_refund_amount'] ,
'settle_car' => $settleOrder['shop_car_amount'] ?? 0 ,
'settle_amount' => $settleOrder['total_commission'] ?? 0 ,
'coach_settle' => $coachCommission,
'shop_settle' => round($shopCommission-$shopCarAmount,2),
];
}
return $lists;
}
public function count(): int
{
return Order::whereOr($this->setWhere())
->limit($this->limitOffset, $this->limitLength)
->count();
}
public function extend()
{
$type = $this->params['type'] ?? 1;
if(1 == $type){
$settleAmount = Order::whereOr($this->setWhere())->where(['is_settle'=>1])->value('sum(settle_shop_amount)') ?:0;
}else{
$settleAmount = Order::whereOr($this->setWhere())->value('sum(total_order_amount - total_refund_amount)') ?:0;
}
return [
'settle_amount' => $settleAmount
];
}
}

View File

@@ -0,0 +1,41 @@
<?php
namespace app\shopapi\lists;
use app\coachapi\lists\BaseCoachApiDataLists;
use app\common\enum\GoodsEnum;
use app\common\model\goods\Goods;
use app\common\model\goods\GoodsCategory;
use app\common\model\shop\ShopGoodsIndex;
/**
* 服务列表
* Class MyGoodsLists
* @package app\shopapi\lists
*/
class MyGoodsLists extends BaseShopApiDataLists
{
public function setWhere()
{
$where = [];
$where[] = ['status','=',1];
$where[] = ['audit_status','=',GoodsEnum::AUDIT_STATUS_PASS];
$goodsIds = ShopGoodsIndex::where(['shop_id'=>$this->shopId])->column('goods_id');
empty($goodsIds) && $goodsIds = [];
$where[] = ['id','in',implode(',',$goodsIds)];
return $where;
}
public function lists(): array
{
$lists = Goods::where($this->setWhere())
->field('id,name,image,status,price,audit_status,virtual_order_num+order_num as order_num')
->append(['audit_status_desc','status_desc'])
->limit($this->limitOffset, $this->limitLength)
->select()->toArray();
return $lists;
}
public function count(): int
{
return Goods::where($this->setWhere())->count();
}
}

View File

@@ -0,0 +1,70 @@
<?php
namespace app\shopapi\lists;
use app\coachapi\lists\BaseCoachApiDataLists;
use app\common\enum\OrderEnum;
use app\common\enum\PayEnum;
use app\common\model\coach\Coach;
use app\common\model\order\Order;
/**
* 订单列表
* Class OrderLists
* @package app\coachapi\lists
*/
class OrderLists extends BaseShopApiDataLists
{
public function setWhere()
{
$where = [];
$where[] = ['shop_id','=',$this->shopId];
$where[] = ['pay_status','=',PayEnum::ISPAID];
if (isset($this->params['order_status']) && $this->params['order_status'] != '') {
switch ($this->params['order_status']) {
case 1:
$where[] = ['order_status','=',OrderEnum::ORDER_STATUS_WAIT_RECEIVING];
break;
case 2:
$where[] = ['order_status','in',[OrderEnum::ORDER_STATUS_WAIT_DEPART,OrderEnum::ORDER_STATUS_DEPART,OrderEnum::ORDER_STATUS_START_SERVER,OrderEnum::ORDER_STATUS_ARRIVE]];
break;
case 3:
$where[] = ['order_status','=',OrderEnum::ORDER_STATUS_SERVER_FINISH];
break;
case 4:
$where[] = ['order_status','=',OrderEnum::ORDER_STATUS_CLOSE];
break;
}
}
return $where;
}
public function lists(): array
{
$lists = Order::field('id,sn,order_status,total_order_amount,user_remark,pay_status,appoint_time,order_amount,user_remark,address_snap,server_finish_time,create_time,coach_id,order_distance')
->order('id','desc')
->append(['order_distance_desc','appoint_time','appoint_date','order_status_desc','order_cancel_time'])
->with(['order_goods' => function($query){
$query->field('order_id,goods_snap,goods_num,duration,goods_image,goods_name,goods_price')->hidden(['goods_snap']);
}])
->where($this->setWhere())
->limit($this->limitOffset, $this->limitLength)
->select()
->toArray();
foreach ($lists as $key => $order){
if(!isset($order['address_snap']['house_number'])){
$lists[$key]['address_snap']['house_number'] = '';
}
}
return $lists;
}
public function count(): int
{
return Order::where($this->setWhere())
->limit($this->limitOffset, $this->limitLength)
->count();
}
}

View File

@@ -0,0 +1,45 @@
<?php
namespace app\shopapi\lists;
use app\common\model\coach\Coach;
use app\common\model\skill\Skill;
/**
*
* Class CoachController
* @package app\shopapi\controller
*/
class ShopCoachLists extends BaseShopApiDataLists{
public function setWhere()
{
$where = [];
$where[] = ['shop_id','=',$this->shopId];
if(isset($this->params['keyword']) && $this->params['keyword']){
$where[] = ['keyword','like','%'.$this->params['keyword'].'%'];
}
return $where;
}
public function lists(): array
{
$lists = Coach::where($this->setWhere())
->field('id,name,good_comment,work_photo,order_num,location')
->limit($this->limitOffset, $this->limitLength)
->select()
->toArray();
// $ids = array_column($lists,'coach_id');
// $skillIds = array_column($lists,'skill_id');
// $skillLists = Skill::where(['id'=>$skillIds])->column('name','id');
foreach ($lists as $key => $coach){
$lists[$key]['good_comment'] = $coach['good_comment'].'%';
// $lists[$key]['skill_name'] = $skillLists[$coach['skill_id']] ?? '';
}
return $lists;
}
public function count(): int
{
return Coach::where($this->setWhere())
->count();
}
}

View File

@@ -0,0 +1,42 @@
<?php
namespace app\shopapi\lists;
use app\coachapi\lists\BaseCoachApiDataLists;
use app\common\enum\GoodsEnum;
use app\common\model\goods\Goods;
/**
* 服务列表
* Class GoodsShopLists
* @package app\shopapi\lists
*/
class ShopGoodsLists extends BaseShopApiDataLists
{
public function setWhere()
{
$where = [];
// $where[] = ['status','=',1];
// $where[] = ['audit_status','=',GoodsEnum::AUDIT_STATUS_PASS];
$where[] = ['shop_id','=',$this->shopId];
if(isset($this->params['category_id']) && $this->params['category_id']){
$where[] = ['category_id','=',$this->params['category_id']];
}
if(isset($this->params['status']) && '' !== $this->params['status']){
$where[] = ['audit_status','=',$this->params['status']];
}
return $where;
}
public function lists(): array
{
$lists = Goods::where($this->setWhere())
->field('id,name,image,audit_status,price,virtual_order_num+order_num as order_num,status')
->limit($this->limitOffset, $this->limitLength)
->select()->toArray();
return $lists;
}
public function count(): int
{
return Goods::where($this->setWhere())->count();
}
}

View File

@@ -0,0 +1,58 @@
<?php
namespace app\shopapi\lists;
use app\coachapi\lists\BaseCoachApiDataLists;
use app\common\model\withdraw\WithdrawApply;
/**
* 提现记录
* Class LogLists
* @package app\coachapi\lists
*/
class WithdrawalLogLists extends BaseShopApiDataLists
{
public function setWhere(){
$where = [];
$where[] = ['source','=',2];
$where[] = ['apply_type','=',$this->params['type'] ?? 1];
$where[] = ['relation_id','=',$this->shopId];
$status = $this->params['status'] ?? '';
switch ($status){
case 1:
$where[] = ['status','=',1];
break;
case 2:
$where[] = ['status','=',4];
break;
case 3:
$where[] = ['status','in',[2,5]];
break;
case 4:
$where[] = ['status','in',[2,3,6]];
break;
}
return $where;
}
public function lists(): array
{
$lists = WithdrawApply::where($this->setWhere())
->field('id,status,money,create_time')
->append(['status_desc'])
->limit($this->limitOffset, $this->limitLength)
->order('id desc')
->select()
->toArray();
foreach ($lists as $key => $log){
$lists[$key]['desc'] = '提现';
}
return $lists;
}
public function count(): int
{
return WithdrawApply::where($this->setWhere())->count();
}
}

View File

@@ -0,0 +1,308 @@
<?php
namespace app\shopapi\logic;
use app\common\logic\BaseLogic;
use app\common\model\city\City;
use app\common\service\ConfigService;
use app\common\service\TencentMapKeyService;
use Exception;
class CityLogic extends BaseLogic
{
/**
* @notes 地级市列表
* @return array
* @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)
{
$where = [];
$where[] = ['level','=',2];
if(isset($params['keyword']) && $params['keyword']){
$where[] = ['name','like','%'.$params['keyword'].'%'];
}
$lists = City::where($where)
->field('id,parent_id,level,name,gcj02_lng,gcj02_lat,db09_lng,db09_lat')
->select()
->toArray();
$lists = self::groupByInitials($lists);
unset($lists[null]);
return $lists;
}
/*
* 二维数组根据首字母分组排序
* @param array $data 二维数组
* @param string $targetKey 首字母的键名
* @return array 根据首字母关联的二维数组
*/
public function groupByInitials(array $data, $targetKey = 'name')
{
$data = array_map(function ($item) use ($targetKey) {
return array_merge($item, [
'initials' => $this->getInitials($item[$targetKey]),
]);
}, $data);
$data = $this->sortInitials($data);
return $data;
}
/**
* 按字母排序
* @param array $data
* @return array
*/
public function sortInitials(array $data)
{
$sortData = [];
foreach ($data as $key => $value) {
$sortData[$value['initials']][] = $value;
}
ksort($sortData);
return $sortData;
}
/**
* 获取首字母
* @param string $str 汉字字符串
* @return string 首字母
*/
public function getInitials($str)
{
if (empty($str)) {return '';}
$fchar = ord($str[0]);
if ($fchar >= ord('A') && $fchar <= ord('z')) {
return strtoupper($str[0]);
}
$s1 = iconv('UTF-8', 'GBK', $str);
$s2 = iconv('GBK', 'UTF-8', $s1);
$s = $s2 == $str ? $s1 : $str;
$asc = ord($s[0]) * 256 + ord($s[1]) - 65536;
if ($asc >= -20319 && $asc <= -20284) {
return 'A';
}
if ($asc >= -20283 && $asc <= -19776) {
return 'B';
}
if ($asc >= -19775 && $asc <= -19219) {
return 'C';
}
if ($asc >= -19218 && $asc <= -18711) {
return 'D';
}
if ($asc >= -18710 && $asc <= -18527) {
return 'E';
}
if ($asc >= -18526 && $asc <= -18240) {
return 'F';
}
if ($asc >= -18239 && $asc <= -17923) {
return 'G';
}
if ($asc >= -17922 && $asc <= -17418) {
return 'H';
}
if ($asc >= -17417 && $asc <= -16475) {
return 'J';
}
if ($asc >= -16474 && $asc <= -16213) {
return 'K';
}
if ($asc >= -16212 && $asc <= -15641) {
return 'L';
}
if ($asc >= -15640 && $asc <= -15166) {
return 'M';
}
if ($asc >= -15165 && $asc <= -14923) {
return 'N';
}
if ($asc >= -14922 && $asc <= -14915) {
return 'O';
}
if ($asc >= -14914 && $asc <= -14631) {
return 'P';
}
if ($asc >= -14630 && $asc <= -14150) {
return 'Q';
}
if ($asc >= -14149 && $asc <= -14091) {
return 'R';
}
if ($asc >= -14090 && $asc <= -13319) {
return 'S';
}
if ($asc >= -13318 && $asc <= -12839) {
return 'T';
}
if ($asc >= -12838 && $asc <= -12557) {
return 'W';
}
if ($asc >= -12556 && $asc <= -11848) {
return 'X';
}
if ($asc >= -11847 && $asc <= -11056) {
return 'Y';
}
if ($asc >= -11055 && $asc <= -10247) {
return 'Z';
}
return null;
}
/**
* @notes 城市列表
* @return array
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\DbException
* @throws \think\db\exception\ModelNotFoundException
* @author cjhao
* @date 2024/11/6 10:55
*/
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);
}
/**
* @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 = \app\common\logic\CityLogic::getNearbyCity($longitude,$latitude);
return $cityLists[0] ?? [];
}catch (Exception $e){
self::$error = $e->getMessage();
return false;
}
}
/**
* @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|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;
}
}

View File

@@ -0,0 +1,254 @@
<?php
namespace app\shopapi\logic;
use app\common\enum\coach\CoachEnum;
use app\common\enum\GoodsEnum;
use app\common\enum\shop\ShopEnum;
use app\common\logic\BaseLogic;
use app\common\model\coach\Coach;
use app\common\model\coach\CoachGoodsIndex;
use app\common\model\coach\CoachServerTime;
use app\common\model\deposit\DepositPackage;
use app\common\model\goods\Goods;
use app\common\model\shop\Shop;
use app\common\model\shop\ShopCoachApply;
use app\common\service\ConfigService;
use think\Exception;
use think\facade\Db;
/**
* 技师逻辑类
* Class CoachLogic
* @package app\shopapi\logic
*/
class CoachLogic extends BaseLogic
{
/**
* @notes 获取技师信息
* @param $id
* @return array|false
* @author cjhao
* @date 2024/12/8 22:26
*/
public function info($id,$shopId)
{
try {
if(empty($id)){
throw new Exception('请选择技师');
}
$coach = Coach::where(['id'=>$id,'shop_id'=>$shopId])
->field('id,sn,mobile,name,work_photo,work_status,gender,age,shop_id')
->findOrEmpty()->toArray();
return $coach;
}catch (Exception $e){
self::$error = $e->getMessage();
return false;
}
}
/**
* @notes 申请详情
* @param int $id
* @return false
* @author cjhao
* @date 2024/10/16 02:10
*/
public function applyDetail(int $id)
{
try {
$shopCoachApply = ShopCoachApply::where(['id'=>$id])->findOrEmpty();
if($shopCoachApply->isEmpty()){
throw new Exception('记录不存在');
}
$coach = Coach::alias('C')
->join('skill S','C.skill_id = S.id')
->where(['C.id'=>$shopCoachApply['coach_id']])
->field('C.id,C.name,mobile,work_photo,order_num,good_comment,S.name as skill_name,C.audit_status,introduction')
->findOrEmpty()->toArray();
$coach['good_comment'] = $coach['good_comment'].'%';
return $coach;
}catch (Exception $e){
self::$error = $e->getMessage();
return false;
}
}
/**
* @notes 门店申请审核
* @param array $params
* @return string|true
* @author cjhao
* @date 2024/10/16 01:59
*/
public function applyAudit(array $params)
{
try {
$id = $params['id'] ?? '';
$auditStatus = $params['audit_status'] ?? '';
$auditRemark = $params['audit_remark'] ?? '';
if(empty($id)){
throw new Exception('请选择审核记录');
}
if(empty($auditStatus)){
throw new Exception('请选择审核状态');
}
Db::startTrans();
$shopCoachApply = ShopCoachApply::where(['id'=>$params['id']])
->findOrEmpty();
if($shopCoachApply->isEmpty()){
throw new Exception('记录不存在');
}
if(ShopEnum::AUDIT_STATUS_WAIT != $shopCoachApply->audit_status){
throw new Exception('当前记录状态已改变');
}
$shopCoachApply->audit_status = $auditStatus;
$shopCoachApply->audit_remark = $auditRemark;
$shopCoachApply->save();
if(ShopEnum::AUDIT_STATUS_PASS == $shopCoachApply->audit_status){
if(1 == $shopCoachApply['type']){
$deposit = Shop::where(['id'=>$params['shop_id'],'audit_status'=>ShopEnum::AUDIT_STATUS_PASS])->value('deposit');
$depositPackageLists = DepositPackage::where(['type'=>2])->order('money desc')->select()->toArray();
//套餐列表
$coachNum = ConfigService::get('server_setting', 'shop_coach_limit');
foreach ($depositPackageLists as $depositPackage){
if($deposit >= $depositPackage['money']){
$coachNum = $depositPackage['coach_num'];
break;
}
}
$nowCoachNum = Coach::where(['shop_id'=>$params['shop_id'],'audit_status'=>CoachEnum::AUDIT_STATUS_PASS])->count();
if($nowCoachNum >= $coachNum){
throw new Exception('服务人员已达到上限');
}
Coach::where(['id'=>$shopCoachApply['coach_id']])->update([
'shop_id' => $shopCoachApply['shop_id']
]);
}else{
//退出申请
Coach::where(['id'=>$shopCoachApply['coach_id']])->update([
'shop_id' => 0
]);
//清理技师管理的商家项目
$goodsIds = Goods::where(['shop_id'=>$shopCoachApply['shop_id'],'audit_status'=>GoodsEnum::AUDIT_STATUS_PASS])
->column('id');
if($goodsIds){
CoachGoodsIndex::where(['coach_id'=>$shopCoachApply['coach_id'],'goods_id'=>$goodsIds])->delete();
}
}
}
Db::commit();
return true;
}catch (Exception $e){
Db::rollback();
return $e->getMessage();
}
}
/**
* @notes 获取师傅服务
* @param $id
* @return array
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\DbException
* @throws \think\db\exception\ModelNotFoundException
* @author cjhao
* @date 2024/10/21 00:25
*/
public function getServerTime($id)
{
try {
if(empty($id)){
throw new Exception('请选择技师');
}
$advanceAppoint = ConfigService::get('server_setting', 'advance_appoint');
$timestampLists[date('m-d',time())] = time()+60*60;
//现在的时间戳和明天,后天零点的时间戳
for ($i = 1;$i < $advanceAppoint;$i++){
$timestampLists[date('m-d',strtotime('+ '.$i.' days'))] = strtotime('+ '.$i.' days midnight');
}
$intervalsLists = [];
foreach ($timestampLists as $date => $timestamp){
$intervalsLists[$date] = get_hour_to_midnight($timestamp);
}
//订单预约时间
$orderAppointLists = \app\common\logic\CoachLogic::getCoachOrderAppoint($id);
//师傅空闲时间
$serverTimeLists = [];
//师傅忙碌时间
$serverTimeBusyLists = [];
$coachServerTime = CoachServerTime::where(['coach_id'=>$id])
->field('date,time,status')
->select();
foreach ($coachServerTime as $time)
{
if(1 == $time['status']){
$serverTimeLists[$time['date']][] = $time['time'];
}else{
$serverTimeBusyLists[$time['date']][] = $time['time'];
}
}
// 获取当前日期的时间戳
$currentDate = strtotime(date('Y-m-d'));
// 获取明天和后天的时间戳
$tomorrowDate = strtotime('tomorrow');
$afterTomorrowDate = strtotime('+2 days',$currentDate);
foreach ($intervalsLists as $date => $intervals){
$timeTips = '';
$timestamp = strtotime(date('Y-'.$date));
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];
}
foreach ($intervals as $key => $interval){
$orderAppoint = $orderAppointLists[$date] ?? [];
$serverTime = $serverTimeLists[$date] ?? [];
$serverTimeBusy = $serverTimeBusyLists[$date]?? [];
// $intervalsLists[$date][$key]['status'] = 0;
//空闲时间
if(in_array($interval['time'],$serverTime) || empty($serverTime)){
$intervals[$key]['status'] = 1;
}
//忙
if(in_array($interval['time'],$serverTimeBusy)){
$intervals[$key]['status'] = 2;
}
//已预约
if(in_array($interval['time'],$orderAppoint)){
$intervals[$key]['status'] = 3;
}
}
$timeLists[] = [
'time_date' => $date,
'time_tips' => $timeTips,
'time_lists' => $intervals
];
}
return $timeLists;
}catch (\think\Exception $e){
return $e->getMessage();
}
}
}

View File

@@ -0,0 +1,151 @@
<?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\shopapi\logic;
use app\common\logic\BaseLogic;
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',''),
//名称
'name' => ConfigService::get('shop', 'name',''),
//logo
'logo' => FileService::getFileUrl(ConfigService::get('shop', 'logo','')),
//版本号
'version' => request()->header('version'),
//默认头像
'default_avatar' => ConfigService::get('config', 'default_shop_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().'/',
//网站名称
'web_name' => ConfigService::get('platform_logo', 'platform_name',''),
//网站logo
'web_logo' => FileService::getFileUrl(ConfigService::get('platform_logo', 'platform_logo')),
//商城名称
'shop_name' => ConfigService::get('shop', 'shop_name',''),
//商城logo
'shop_logo' => FileService::getFileUrl(ConfigService::get('shop', 'shop_logo','')),
];
return $config;
}
/**
* @notes 政策协议
* @return array
* @author ljj
* @date 2022/2/23 11:42 上午
*/
public function agreement()
{
$service = TextList::where(['id'=>5])->field('title,content')->findOrEmpty();
$privacy = TextList::where(['id'=>6])->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' => '',
'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;
}
}

View File

@@ -0,0 +1,53 @@
<?php
namespace app\shopapi\logic;
use app\common\model\decorate\DecoratePage;
use app\common\model\decorate\DecorateStyle;
use app\common\model\decorate\DecorateTabbar;
/**
* 装修逻辑类
* Class DecorateLogic
* @package app\api\logic
*/
class DecorateLogic
{
/**
* @notes 获取装修页面
* @param int $id
* @return array
* @author cjhao
* @date 2024/10/8 15:11
*/
public function page(int $type)
{
$detail = DecoratePage::where(['type'=>$type,'source'=>3])->findOrEmpty()->toArray();
return $detail;
}
/**
* @notes 获取装修风格
* @return array
* @author cjhao
* @date 2024/10/8 15:13
*/
public function style()
{
$detail = DecorateStyle::where(['source'=>3])->findOrEmpty()->toArray();
return $detail;
}
/**
* @notes 底部菜单
* @return array
* @author cjhao
* @date 2024/10/8 15:59
*/
public function tabbar()
{
$detail = DecorateTabbar::where(['source'=>3])->findOrEmpty()->toArray();
return $detail;
}
}

View File

@@ -0,0 +1,80 @@
<?php
namespace app\shopapi\logic;
use app\common\enum\shop\ShopEnum;
use app\common\logic\BaseLogic;
use app\common\model\deposit\DepositOrder;
use app\common\model\deposit\DepositPackage;
use app\common\model\shop\Shop;
use think\Exception;
/**
* 保证金套餐逻辑类
* Class DepositLogic
* @package app\coachapi\logic
*/
class DepositLogic extends BaseLogic
{
/**
* @notes 套餐列表
* @param $coachId
* @return array
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\DbException
* @throws \think\db\exception\ModelNotFoundException
* @author cjhao
* @date 2024/8/27 18:25
*/
public function depositPackage($shopUserId)
{
$deposit = Shop::where(['shop_user_id'=>$shopUserId,'audit_status'=>ShopEnum::AUDIT_STATUS_PASS])->value('deposit');
$packageLists = DepositPackage::where(['type'=>2])
->withoutField('is_show,create_time,update_time,delete_time')
->order('id desc')
->select();
return [
'deposit' => $deposit,
'package_list' => $packageLists,
];
}
/**
* @notes 提交订单
* @param array $params
* @param int $shopId
* @return array|bool
* @author cjhao
* @date 2024/8/27 18:52
*/
public function sumbitOrder(array $params,int $shopId)
{
try {
$money = $params['money'] ?? 0;
$payWay = $params['pay_way'] ?? 0;
if($money < 0){
throw new Exception('充值金额不能小于零');
}
if(empty($payWay)){
throw new Exception('请选择支付方式');
}
$depositOrder = DepositOrder::create([
'sn' => generate_sn((new DepositOrder()), 'sn'),
'type' => 2,
'order_amount' => $money,
'relation_id' => $shopId,
'pay_way' => $payWay,
]);
return [
'id' => $depositOrder->id,
'sn' => $depositOrder->sn,
'type' => 'deposit'
];
}catch (Exception $e) {
self::$error = $e->getMessage();
return false;
}
}
}

View File

@@ -0,0 +1,108 @@
<?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\shopapi\logic;
use app\common\logic\BaseLogic;
use app\common\model\coach\Coach;
use app\common\model\goods\GoodsComment;
use app\common\model\order\Order;
/**
* 评论控制器类
* Class GoodsCommentLogic
* @package app\shopapi\logic
*/
class GoodsCommentLogic extends BaseLogic
{
/**
* @notes 评论分类
* @param $shopId
* @return array
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\DbException
* @throws \think\db\exception\ModelNotFoundException
* @author cjhao
* @date 2024/11/1 17:49
*/
public function commentCategory($shopId)
{
$orderGoodsIds = Order::alias('O')
->join('order_goods OG', 'O.id = OG.order_id')
->where(['shop_id' => $shopId, '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,
];
}
}

View File

@@ -0,0 +1,299 @@
<?php
namespace app\shopapi\logic;
use app\common\enum\DefaultEnum;
use app\common\enum\GoodsEnum;
use app\common\enum\shop\ShopEnum;
use app\common\logic\BaseLogic;
use app\common\model\goods\Goods;
use app\common\model\goods\GoodsCategory;
use app\common\model\goods\GoodsCityIndex;
use app\common\model\goods\GoodsImage;
use app\common\model\goods\GoodsSkillIndex;
use app\common\model\shop\Shop;
use app\common\model\skill\Skill;
use think\facade\Db;
/**
* 服务逻辑类
* Class GoodsLogic
* @package app\shopapi\logic
*/
class GoodsLogic extends BaseLogic
{
/**
* @notes 分类列表
* @return GoodsCategory[]|array|\think\Collection
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\DbException
* @throws \think\db\exception\ModelNotFoundException
* @author cjhao
* @date 2024/10/5 14:48
*/
public function categoryLists()
{
$lists = (new GoodsCategory())->where(['is_show'=>1,'level'=>1])->field('id,name')->select()->toArray();
return $lists;
}
/**
* @notes 技能列表
* @return Skill[]|array|\think\Collection
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\DbException
* @throws \think\db\exception\ModelNotFoundException
* @author cjhao
* @date 2024/10/16 16:48
*/
public function skillLists()
{
$lists = (new Skill())->where(['is_show'=>1])->field('id,name')->select()->toArray();
return $lists;
}
/**
* @notes 添加商品
* @param array $params
* @return string|true
* @author cjhao
* @date 2024/10/16 17:38
*/
public function add(array $params)
{
// 启动事务
Db::startTrans();
try {
$goodsImage = $params['goods_image'];
$image = array_shift($params['goods_image']);
//添加服务信息
$goods = Goods::create([
'name' => $params['name'],
'category_id' => $params['category_id'],
'shop_id' => $params['shop_id'],
'image' => $image,
'price' => $params['price'],
'duration' => $params['duration'],
'scribing_price' => $params['scribing_price'] ?? 0.00,
'status' => $params['status'],
'sort' => $params['sort'] ?? DefaultEnum::SORT,
'tags' => $params['tags'] ?? '',
'content' => $params['content'] ?? '',
'overtime_price' => $params['overtime_price'] ?? '',
'overtime_duration' => $params['overtime_duration'] ?? '',
'commission_ratio' => $params['commission_ratio'] ?? '',
'shop_ration' => $params['shop_ration'] ?? '',
'virtual_order_num' => $params['virtual_order_num'] ?? '',
'appoint_start_time' => $params['appoint_start_time'] ?? '',
'appoint_end_time' => $params['appoint_end_time'] ?? '',
]);
$goodsImageLists = [];
//添加服务轮播图信息
foreach ($goodsImage as $image_uri) {
$goodsImageLists[] = [
'goods_id' => $goods->id,
'uri' => $image_uri,
];
}
(new GoodsImage())->saveAll($goodsImageLists);
$goodsSkillLists = [];
foreach ($params['skill_id'] as $skillId)
{
$goodsSkillLists[] = [
'goods_id' => $goods->id,
'skill_id' => $skillId
];
}
(new GoodsSkillIndex())->saveAll($goodsSkillLists);
$shopCityId = Shop::where(['id'=>$params['shop_id']])->value('city_id');
(new GoodsCityIndex())->save([
'goods_id' => $goods->id,
'city_id' => $shopCityId
]);
// 提交事务
Db::commit();
return true;
} catch (\Exception $e) {
// 回滚事务
Db::rollback();
return $e->getMessage();
}
}
/**
* @notes 编辑服务
* @param array $params
* @return string|true
* @author cjhao
* @date 2024/10/17 14:43
*/
public function edit(array $params)
{
// 启动事务
Db::startTrans();
try {
$goodsImage = $params['goods_image'];
$image = array_shift($params['goods_image']);
$goods = Goods::where(['id'=>$params['id']])->findOrEmpty();
$auditStatus = GoodsEnum::AUDIT_STATUS_PASS;
if(GoodsEnum::AUDIT_STATUS_REFUSE == $goods->audit_status){
$auditStatus = GoodsEnum::AUDIT_STATUS_WAIT;
}
$needAudit = ['price','duration','overtime_price','overtime_duration','commission_ratio'];
foreach ($params as $field=> $value){
if(!isset($needAudit[$field])){
$goodsValue = $goods[$field] ?? '';
if($value != $goodsValue){
$auditStatus = GoodsEnum::AUDIT_STATUS_WAIT;
}
}
}
// if($goods->price != $params['price']){
// }
// if($goods->price != $params['price']){
// $auditStatus = GoodsEnum::AUDIT_STATUS_WAIT;
// }
// if($goods->duration != $params['duration']){
// $auditStatus = GoodsEnum::AUDIT_STATUS_WAIT;
// }
// if($goods->overtime_price != $params['overtime_price']){
// $auditStatus = GoodsEnum::AUDIT_STATUS_WAIT;
// }
// if($goods->overtime_duration != $params['overtime_duration']){
// $auditStatus = GoodsEnum::AUDIT_STATUS_WAIT;
// }
//更新服务信息
Goods::update([
'name' => $params['name'],
'category_id' => $params['category_id'],
'image' => $image,
'price' => $params['price'],
'duration' => $params['duration'],
'scribing_price' => $params['scribing_price'] ?? 0.00,
'status' => $params['status'],
'sort' => $params['sort'] ?? DefaultEnum::SORT,
'tags' => $params['tags'] ?? '',
'content' => $params['content'] ?? '',
'overtime_price' => $params['overtime_price'] ?? '',
'overtime_duration' => $params['overtime_duration'] ?? '',
'commission_ratio' => $params['commission_ratio'] ?? '',
// 'shop_ration' => $params['shop_ration'] ?? '',
'audit_status' => $auditStatus,
'virtual_order_num' => $params['virtual_order_num'] ?? '',
'appoint_start_time' => $params['appoint_start_time'] ?? '',
'appoint_end_time' => $params['appoint_end_time'] ?? '',
],['id'=>$params['id']]);
$goodsImageLists = [];
//删除旧的轮播图
GoodsImage::where('goods_id',$params['id'])->delete();
//添加服务轮播图信息
foreach ($goodsImage as $image_uri) {
$goodsImageLists[] = [
'goods_id' => $params['id'],
'uri' => $image_uri,
];
}
(new GoodsImage())->saveAll($goodsImageLists);
//删除管理图片,删除管理城市
GoodsSkillIndex::where('goods_id',$params['id'])->delete();
$goodsSkillLists = [];
foreach ($params['skill_id'] as $skillId)
{
$goodsSkillLists[] = [
'goods_id' => $params['id'],
'skill_id' => $skillId
];
}
(new GoodsSkillIndex())->saveAll($goodsSkillLists);
// 提交事务
Db::commit();
return true;
} catch (\Exception $e) {
// 回滚事务
Db::rollback();
return $e->getMessage();
}
}
/**
* @notes 删除接口
* @param $id
* @param $shopId
* @return string|true
* @author cjhao
* @date 2024/11/14 15:24
*/
public static function del($id,$shopId){
// 启动事务
// Db::startTrans();
try {
//删除师傅绑定的服务
// foreach ($ids as $id) {
// $staff_lists = Staff::whereRaw("FIND_IN_SET($id,goods_ids)")->select()->toArray();
// foreach ($staff_lists as $list) {
// $goods_ids = str_replace(','.$id.',',',',$list['goods_ids']);
// if ($goods_ids == ',') {
// $goods_ids = '';
// }
// Staff::update(['goods_ids'=>$goods_ids],['id'=>$list['id']]);
// }
// }
//删除服务
Goods::destroy(['id'=>$id,'shop_id'=>$shopId]);
// 提交事务
// Db::commit();
return true;
} catch (\Exception $e) {
// 回滚事务
// Db::rollback();
return $e->getMessage();
}
}
/**
* @notes 修改服务状态
* @param $params
* @return Goods
* @author ljj
* @date 2022/2/9 4:54 下午
*/
public function status($params,$shopId)
{
return Goods::update(['status'=>$params['status']],['id'=>$params['id'],'shop_id'=>$shopId]);
}
/**
* @notes 查看服务详情
* @param $id
* @return array
* @author ljj
* @date 2022/2/9 3:51 下午
*/
public function detail($id)
{
$result = Goods::where('id',$id)
->withoutField('order_num,update_time,delete_time')
->append(['category_desc','goods_image'])
->findOrEmpty()
->toArray();
$result['commission_ratio'] = floatval($result['commission_ratio']);
$goods_image = [];
foreach ($result['goods_image'] as &$image) {
$goods_image[] = $image['uri'];
}
$result['goods_image'] = $goods_image;
$result['city_id'] = GoodsCityIndex::where(['goods_id'=>$id])->column('city_id');
$result['skill_id'] = GoodsSkillIndex::where(['goods_id'=>$id])->column('skill_id');
return $result;
}
}

View File

@@ -0,0 +1,98 @@
<?php
namespace app\shopapi\logic;
use app\common\enum\coach\CoachEnum;
use app\common\enum\OrderEnum;
use app\common\enum\PayEnum;
use app\common\enum\shop\ShopEnum;
use app\common\logic\BaseLogic;
use app\common\model\coach\Coach;
use app\common\model\order\Order;
use app\common\model\shop\Shop;
use app\common\model\shop\ShopCoachApply;
use app\common\model\shop\ShopVisit;
class IndexLogic extends BaseLogic
{
public function shopData(int $shopId)
{
$todayShopVisit = ShopVisit::where(['shop_id'=>$shopId])->whereDay('create_time')->sum('visit');
$yesterdayShopVisit = ShopVisit::where(['shop_id'=>$shopId])->whereDay('create_time','yesterday')->sum('visit');
$todayOrderNum = Order::where(['shop_id'=>$shopId,'pay_status'=>PayEnum::ISPAID])->whereDay('create_time')->count();
$yesterdayOrderNum = Order::where(['shop_id'=>$shopId,'pay_status'=>PayEnum::ISPAID])->whereDay('create_time','yesterday')->count();
$todayOrderIncome = Order::where(['shop_id'=>$shopId,'pay_status'=>PayEnum::ISPAID])->whereDay('create_time')->sum('total_amount');
$yesterdayOrderIncome = Order::where(['shop_id'=>$shopId,'pay_status'=>PayEnum::ISPAID])->whereDay('create_time','yesterday')->sum('total_amount');
// 计算浏览量的变化
$viewChange =$todayShopVisit - $yesterdayShopVisit;
// 计算百分比变化
if ($yesterdayShopVisit > 0) {
$shopVisitPercentChange = round(($viewChange / $yesterdayShopVisit) * 100,2);
} else {
$shopVisitPercentChange = $viewChange* 100;
}
0 == $shopVisitPercentChange && $shopVisitPercentChange = intval($shopVisitPercentChange);
$shopVisitPercentChange > 100 && $shopVisitPercentChange = 100;
// 计算订单数量的变化
$viewChange =$todayOrderNum - $yesterdayOrderNum;
// 计算百分比变化
if ($yesterdayOrderNum > 0) {
$orderNumChange = round(($viewChange / $yesterdayOrderNum) * 100,2);
} else {
$orderNumChange = $viewChange* 100;
}
0 == $orderNumChange && $orderNumChange = intval($orderNumChange);
$orderNumChange > 100 && $orderNumChange = 100;
// 计算订单数量的变化
$viewChange = $todayOrderIncome - $yesterdayOrderIncome;
// 计算百分比变化
if ($yesterdayOrderIncome > 0) {
$orderIncomeChange = round(($viewChange / $yesterdayOrderIncome) * 100,2);
} else {
$orderIncomeChange = $viewChange* 100;
}
0 == $orderIncomeChange && $orderIncomeChange = intval($orderIncomeChange);
$orderIncomeChange > 100 && $orderIncomeChange = 100;
$todayDate = date('Y-m-d',time());
//今天的时间戳
$todayStart = strtotime($todayDate);
$todayEnd = strtotime($todayDate . ' 23:59:59');
//明天的时间戳
$tomorrowStart = strtotime('+1 day',$todayStart);
$tomorrowEnd = strtotime('+1 day',$todayEnd);
//后天的时间戳
$dayAfterTomorrowStart = strtotime('+2 day',$todayStart);
$dayAfterTomorrowEnd = strtotime('+2 day',$todayEnd);
return [
'shop_name' => Shop::where(['id'=>$shopId])->value('name'),
'shop_data' => [
'shop_visit' => $todayShopVisit,
'visit_compare' => $shopVisitPercentChange.'%',
'order_num' => $todayOrderNum,
'order_num_compare' => $orderNumChange.'%',
'order_income' => $todayOrderIncome,
'order_income_compare' => $orderIncomeChange.'%',
],
'wait_order_data' => [
'today_order_num' => Order::where(['shop_id'=>$shopId,'pay_status'=>PayEnum::ISPAID])->where('order_status','>',OrderEnum::ORDER_STATUS_WAIT_PAY)->where('order_status','<',OrderEnum::ORDER_STATUS_SERVER_FINISH)->whereDay('create_time','today')->count(),
'tomorrow_order_num' => Order::where(['shop_id'=>$shopId,'pay_status'=>PayEnum::ISPAID])->where('order_status','>',OrderEnum::ORDER_STATUS_WAIT_PAY)->where('order_status','<',OrderEnum::ORDER_STATUS_SERVER_FINISH)->whereTime('appoint_time','between',[$tomorrowStart,$tomorrowEnd])->count(),
'dayafter_order_num' => Order::where(['shop_id'=>$shopId,'pay_status'=>PayEnum::ISPAID])->where('order_status','>',OrderEnum::ORDER_STATUS_WAIT_PAY)->where('order_status','<',OrderEnum::ORDER_STATUS_SERVER_FINISH)->whereTime('appoint_time','between',[$dayAfterTomorrowStart,$dayAfterTomorrowEnd])->count(),
],
'order_data' => [
'wait_server_num' => Order::where(['shop_id'=>$shopId])->where('order_status','>',OrderEnum::ORDER_STATUS_WAIT_RECEIVING)->where('order_status','<',OrderEnum::ORDER_STATUS_SERVER_FINISH)->count(),
'wait_take_num' => Order::where(['shop_id'=>$shopId])->where('order_status','=',OrderEnum::ORDER_STATUS_WAIT_RECEIVING)->count(),
'depart_num' => Order::where(['shop_id'=>$shopId])->where('order_status','=',OrderEnum::ORDER_STATUS_DEPART)->count(),
'arrive_num' => Order::where(['shop_id'=>$shopId])->where('order_status','=',OrderEnum::ORDER_STATUS_ARRIVE)->count(),
'start_server_num' => Order::where(['shop_id'=>$shopId])->where('order_status','=',OrderEnum::ORDER_STATUS_START_SERVER)->count(),
'finish_server_num' => Order::where(['shop_id'=>$shopId])->where('order_status','=',OrderEnum::ORDER_STATUS_SERVER_FINISH)->count(),
],
'coach_data' => [
'wait_audtit_num' => ShopCoachApply::where(['shop_id'=>$shopId,'audit_status'=>ShopEnum::AUDIT_STATUS_WAIT])->count(),
'online_coach_num' => Coach::where(['shop_id'=>$shopId,'audit_status'=>CoachEnum::AUDIT_STATUS_PASS,'work_status'=>CoachEnum::WORK_STATUS_ONLINE])->count(),
'downline_coach_num' => Coach::where(['shop_id'=>$shopId,'audit_status'=>CoachEnum::AUDIT_STATUS_PASS,'work_status'=>CoachEnum::WORK_STATUS_DOWNLINE])->count(),
],
];
}
}

View File

@@ -0,0 +1,453 @@
<?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\shopapi\logic;
use app\common\enum\notice\NoticeEnum;
use app\common\enum\shop\ShopEnum;
use app\common\logic\BaseLogic;
use app\common\model\coach\Coach;
use app\common\model\shop\Shop;
use app\common\model\shop\ShopUser;
use app\shopapi\service\ShopUserTokenService;
use app\common\service\{ConfigService, FileService, sms\SmsDriver, WeChatService};
use think\facade\{Db, Config};
use think\Exception;
/**
* 登录逻辑
* Class LoginLogic
* @package app\coachapi\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 {
$smsDriver = new SmsDriver();
$result = $smsDriver->verify($params['account'], $params['code'], NoticeEnum::REGISTER_CAPTCHA_SHOP);
if (!$result) {
throw new Exception('验证码错误');
}
$number = ShopUser::count()+1;
$sn = sprintf("%03d", $number);
$passwordSalt = Config::get('project.unique_identification');
$password = create_password($params['password'], $passwordSalt);
$avatar = ConfigService::get('default_image', 'user_avatar');
ShopUser::create([
'sn' => $sn,
'avatar' => $avatar,
'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' => $params['account']];
$shopUser = ShopUser::where($where)->findOrEmpty();
if ($shopUser->isEmpty()) {
throw new Exception('账号不存在');
}
$shop = Shop::where(['shop_user_id'=>$shopUser['id']])->order('id desc')->findOrEmpty();
// if($shop->isEmpty()){
// throw new Exception('您的账号未申请入驻,请先申请入驻',-10);
// }
// //待审核
// if(ShopEnum::AUDIT_STATUS_WAIT == $shop->audit_status){
// throw new Exception('感谢您对我们平台的支持我们将在13个工作日内审核');
// }
// //审核不通过
// if(ShopEnum::AUDIT_STATUS_REFUSE == $shop->audit_status){
// throw new Exception($shop->audit_remark,-20);
// }
//更新登录信息
$shopUser->login_time = time();
$shopUser->login_ip = request()->ip();
$shopUser->save();
//设置token
$shopUserInfo = ShopUserTokenService::setToken($shopUser->id, $params['terminal']);
//返回登录信息
$avatar = $shopUser->avatar ?: Config::get('project.default_image.user_avatar');
$avatar = FileService::getFileUrl($avatar);
return [
'sn' => $shopUserInfo['sn'],
'account' => $shopUserInfo['account'],
'avatar' => $avatar,
'token' => $shopUserInfo['token'],
'audit_status' => $shop->audit_status,
'audit_remark' => $shop->audit_remark,
];
} catch (Exception $e) {
self::setError($e->getMessage());
self::setReturnCode($e->getCode());
return false;
}
}
/**
* @notes 退出登录
* @param $shopInfo
* @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($shopInfo)
{
//token不存在不注销
if (!isset($shopInfo['token'])) {
return false;
}
//设置token过期
return ShopUserTokenService::expireToken($shopInfo['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;
}
/**
* @notes 重置登录密码
* @param $params
* @return bool
* @author 段誉
* @date 2022/9/16 18:06
*/
public function resetPassword(array $params): bool
{
try {
// Db::startTrans();
// 校验验证码
$smsDriver = new SmsDriver();
if (!$smsDriver->verify($params['mobile'], $params['code'], NoticeEnum::RESET_PASSWORD_CAPTCHA_SHOP)) {
throw new \Exception('验证码错误');
}
// 重置密码
$passwordSalt = Config::get('project.unique_identification');
$password = create_password($params['password'], $passwordSalt);
// 更新
ShopUser::where('account', $params['mobile'])->update([
'password' => $password
]);
Db::commit();
// return true;
} catch (\Exception $e) {
// Db::rollback();
self::setError($e->getMessage());
return false;
}
}
/**
* @notes 重置登录密码
* @param $params
* @return bool
* @author 段誉
* @date 2022/9/16 18:06
*/
public function changePassword(array $params): bool
{
try {
// 重置密码
$passwordSalt = Config::get('project.unique_identification');
$password = create_password($params['password'], $passwordSalt);
$shopUser = ShopUser::where(['id'=>$params['shop_info']['shop_user_id']])->findOrEmpty();
// if($coachUser->isEmpty()){
// throw new \Exception('账号不存在');
// }
// 更新
$shopUser->password = $password;
$shopUser->save();
return true;
} catch (\Exception $e) {
self::setError($e->getMessage());
return false;
}
}
}

View File

@@ -0,0 +1,164 @@
<?php
namespace app\shopapi\logic;
use app\common\enum\OrderEnum;
use app\common\enum\OrderLogEnum;
use app\common\logic\BaseLogic;
use app\common\logic\CoachLogic;
use app\common\logic\OrderLogLogic;
use app\common\model\coach\Coach;
use app\common\model\order\Order;
use app\common\model\order\OrderLog;
use app\common\model\settle\SettleOrder;
use app\common\service\FileService;
use Exception;
use think\facade\Db;
class OrderLogic extends BaseLogic
{
/**
* @notes 订单详情
* @param int $id
* @return array
* @author cjhao
* @date 2024/9/20 02:19
*/
public function detail(int $id)
{
$detail = Order::field('id,sn,order_status,total_order_amount,total_refund_amount,user_remark,total_order_amount,pay_status,pay_way,goods_price,order_amount,total_amount,total_gap_amount,total_append_amount,appoint_time,order_amount,user_remark,address_snap,is_settle,server_finish_time,create_time,refund_amount,coach_id,car_amount,order_distance,update_time,true_server_finish_time')
->order('id','desc')
->append(['order_distance_desc','dispatch_btn','pay_way_desc','appoint_time','appoint_date','order_status_desc','order_cancel_time'])
->with(['order_goods' => function($query){
$query->field('order_id,goods_id,goods_num,goods_snap,duration,goods_image,goods_name,goods_price')->hidden(['goods_snap']);
},'order_gap','order_append','coach_info'])
->where(['id'=>$id])
->findOrEmpty()
->toArray();
if(!isset($detail['address_snap']['house_number'])){
$detail['address_snap']['house_number'] = '';
}
$orderLog = OrderLog::where(['order_id'=>$id,'type'=>OrderLogEnum::TYPE_COACH])
->field('content,location,extra,create_time')
->select()->toArray();
$logLists = [];
foreach ($orderLog as $key => $log){
$date = date('Y-m-d',strtotime($log['create_time']));
if($log['extra']){
foreach ($log['extra'] as $key => $extra){
$log['extra'][$key] = FileService::getFileUrl($extra);
}
}
$logLists[$date][] = $log;
}
// $logLists = $orderLog;
$settleOrder = [];
if($detail['is_settle']){
$settleOrder = SettleOrder::where(['order_id'=>$detail['id']])->findOrEmpty();
}
$shopCommission = $settleOrder['shop_commission'] ?? 0;
$shopCarAmount = $settleOrder['shop_car_amount'] ?? 0;
$coachCommission = $settleOrder['coach_commission'] ?? 0;
$coachCarAmount = $settleOrder['coach_car_amount'] ?? 0;
// $totalOrderAmount = $settleOrder['order_amount'] ?? 0;
// $carAmount = $settleOrder['car_amount'] ?? 0;
$detail['settle_info'] = [
'status' => $detail['is_settle'],
'order_amount' => $settleOrder['order_amount'] ?? 0,
'refund_amount' => $detail['total_refund_amount'],
'settle_car' => $settleOrder['car_amount'] ?? 0,
'settle_amount' => $settleOrder['total_commission'] ?? 0,
'coach_settle' => $settleOrder['coach_commission'] ?? 0,
'shop_settle' => $settleOrder['shop_commission'] ?? 0,
// 'total_settle_amount'=> round($totalOrderAmount + $carAmount ,2),
];
$detail['server_log_lists'] = $logLists;
return $detail;
}
/**
* @notes 订单更换技师时获取技师列表
* @param $params
* @return array|bool
* @author cjhao
* @date 2024/10/9 16:30
*/
public function coachLists($params,$shopId)
{
try {
$id = $params['id'] ?? '';
$keyword = $params['keyword'] ?? '';
if(empty($id)){
throw new Exception('请选择订单');
}
$order = Order::where(['id'=>$id])->findOrEmpty();
if(OrderEnum::ORDER_STATUS_WAIT_PAY == $order->order_status || OrderEnum::ORDER_STATUS_DEPART < $order->order_status){
throw new Exception('当前订单不可更改技师');
}
$startTime = $order->getData('appoint_time');
$serverFinishTime = $order->getData('server_finish_time');
$coachLists = CoachLogic::getLeisureCoach($order['coach_id'],$startTime,$serverFinishTime,$order,$keyword);
return $coachLists;
}catch (Exception $e){
self::$error = $e->getMessage();
return false;
}
}
/**
* @notes 指派技师
* @param array $params
* @return bool
* @author cjhao
* @date 2024/11/6 14:36
*/
public function dispatchCoach(array $params)
{
try {
Db::startTrans();
$id = $params['id'] ?? '';
$coachId = $params['coach_id'] ?? '';
if(empty($id)){
throw new Exception('请选择订单');
}
if(empty($coachId)){
throw new Exception('请选择技师');
}
$order = Order::where(['id'=>$id])
->findOrEmpty();
if(OrderEnum::ORDER_STATUS_WAIT_PAY == $order->order_status || OrderEnum::ORDER_STATUS_DEPART < $order->order_status){
throw new Exception('当前订单不可更改技师');
}
$startTime = $order->getData('appoint_time');
$serverFinishTime = $order->getData('server_finish_time');
$coachLists = CoachLogic::getLeisureCoach($order['coach_id'],$startTime,$serverFinishTime,$order);
$coachIds = array_column($coachLists,'id');
if(!in_array($coachId,$coachIds)){
throw new Exception('该技师该时间段忙');
}
//技师更换
$order->coach_id = $coachId;
$order->save();
$originalCoachId = $order['coach_id'];
$extra = [
'original_coach_id' => $originalCoachId,
'coach_id' => $coachId
];
(new OrderLogLogic())
->record(OrderLogEnum::TYPE_SHOP,OrderLogEnum::SHOP_CHANGE_COACH,$order['id'],$params['shop_id'],'','',$extra);
Db::commit();
return true;
}catch (Exception $e){
Db::rollback();
self::$error = $e->getMessage();
return false;
}
}
}

View File

@@ -0,0 +1,240 @@
<?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\shopapi\logic;
use app\common\enum\PayEnum;
use app\common\enum\user\UserTerminalEnum;
use app\common\enum\YesNoEnum;
use app\common\logic\BaseLogic;
use app\common\logic\CoachPayNotifyLogic;
use app\common\logic\ShopPayNotifyLogic;
use app\common\model\deposit\DepositOrder;
use app\common\model\pay\PayWay;
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\ShopBalancePayService;
use app\common\service\WeChatPayService;
use app\common\service\WeChatService;
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'] == 'deposit') {
// // 订单
// $order = DepositOrder::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'],['deposit'])){
// 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::ALI_PAY) {
$item['extra'] = '支付宝支付';
}
// 充值时去除余额支付
if ( $item['pay_way'] == PayEnum::BALANCE_PAY) {
unset($pay_way[$k]);
}
// 充值时去除微信支付
if ( $item['pay_way'] == PayEnum::WECHAT_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,$wechatCode = '')
{
$order = [];
//更新支付方式
switch ($from) {
case 'deposit':
DepositOrder::update(['pay_way' => $payWay], ['id' => $order_id]);
$order = DepositOrder::where('id',$order_id)->findOrEmpty()->toArray();
break;
}
if (empty($order)) {
self::setError('订单错误');
}
if($order['order_amount'] == 0) {
ShopPayNotifyLogic::handle($from, $order['sn']);
return ['pay_way'=>$payWay];
}
switch ($payWay) {
case PayEnum::WECHAT_PAY:
if (isset($wechatCode) && $wechatCode != '') {
switch ($terminal) {
case UserTerminalEnum::WECHAT_MMP:
$response = (new WeChatService())->getMnpResByCode($wechatCode);
$order['openid'] = $response['openid'];
break;
case UserTerminalEnum::WECHAT_OA:
$response = (new WeChatService())->getOaResByCode($wechatCode);
$order['openid'] = $response['openid'];
break;
}
DepositOrder::update(['openid' => $order['openid']], ['id' => $order_id]);
}
$payService = (new WeChatPayService($terminal, null));
$result = $payService->pay($from, $order);
break;
case PayEnum::BALANCE_PAY:
//余额支付
$payService = (new ShopBalancePayService());
$result = $payService->pay($from, $order);
if (false !== $result) {
ShopPayNotifyLogic::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 'deposit' :
$result = DepositOrder::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;
default :
$result = [];
}
if (empty($result)) {
self::$error = '订单信息不存在';
}
$result['pay_way_desc'] = PayEnum::getPayTypeDesc($result['pay_way']);
$result['pay_time'] = empty($result['pay_time']) ? '-' : date('Y-m-d H:i:s', $result['pay_time']);
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;
}
}

View File

@@ -0,0 +1,447 @@
<?php
namespace app\shopapi\logic;
use app\common\enum\coach\CoachEnum;
use app\common\enum\GoodsEnum;
use app\common\enum\shop\ShopEnum;
use app\common\logic\BaseLogic;
use app\common\model\coach\Coach;
use app\common\model\coach\CoachServerTime;
use app\common\model\coach\CoachUser;
use app\common\model\goods\Goods;
use app\common\model\shop\Shop;
use app\common\model\shop\ShopCategoryIndex;
use app\common\model\shop\ShopGoodsIndex;
use app\common\model\shop\ShopImage;
use app\common\model\shop\ShopUpdate;
use app\common\model\shop\ShopUser;
use app\common\service\sms\SmsDriver;
use Exception;
use think\facade\Db;
class ShopLogic extends BaseLogic
{
/**
* @notes 个人中心
* @param int $shopId
* @return Shop|array|\think\Model
* @author cjhao
* @date 2024/10/20 03:23
*/
public function centre(int $shopId)
{
$shop = Shop::where(['id'=>$shopId])
->field('sn,name,mobile,logo,audit_status,audit_remark,money,deposit')
->findOrEmpty()->toArray();
$shop['coach_count'] = Coach::where(['shop_id'=>$shopId])->count();
$shop['shop_goods_count'] = Goods::where(['shop_id'=>$shopId,'audit_status'=>GoodsEnum::AUDIT_STATUS_PASS])->count();
$shop['goods_count'] = ShopGoodsIndex::where(['shop_id'=>$shopId])->count();
$shop['audit_status'] = $shop['audit_status'] ?? 0;
$shop['audit_remark'] = $shop['audit_remark'] ?? '';
return $shop;
}
/**
* @notes 获取手机号码
* @param int $shopId
* @return array
* @author cjhao
* @date 2024/11/19 11:34
*/
public function info(int $shopId)
{
$shop = Shop::where(['id'=>$shopId])
->field('sn,name,mobile,logo,audit_status,audit_remark,money,deposit,create_time')
->findOrEmpty()
->toArray();
return $shop;
}
/**
* @notes 申请
* @param array $params
* @return string|true
* @author cjhao
* @date 2024/10/5 20:26
*/
public function apply(array $params)
{
try {
Db::startTrans();
$shop = shop::where(['shop_user_id'=>$params['shop_user_id']])
->order('id desc')
->findOrEmpty();
if( !$shop->isEmpty() && ShopEnum::AUDIT_STATUS_PASS == $shop->audit_status ){
return '当前账号已经入驻成功,请勿重复申请';
}
if( !$shop->isEmpty() && ShopEnum::AUDIT_STATUS_WAIT == $shop->audit_status ){
return '当前账号申请正在审核中,请耐心等待';
}
$shopUser = ShopUser::where(['id'=>$params['shop_user_id']])->findOrEmpty();
$shop = Shop::create([
'name' => $params['name'],
'mobile' => $shopUser['account'],
'shop_user_id' => $params['shop_user_id'],
'sn' => sprintf("%03d", Shop::count()+1),
'short_name' => $params['short_name'],
'type' => $params['type'],
'social_credit_ode' => $params['social_credit_ode'],
'legal_person' => $params['legal_person'],
'legal_id_card' => $params['legal_id_card'],
'province_id' => $params['province_id'],
'city_id' => $params['city_id'],
'region_id' => $params['region_id'],
'shop_address_detail'=> $params['shop_address_detail'],
'longitude' => $params['longitude'],
'latitude' => $params['latitude'],
'id_card_front' => $params['id_card_front'],
'id_card_back' => $params['id_card_back'],
'portrait_shooting' => $params['portrait_shooting'],
'logo' => $params['logo'],
'business_license' => $params['business_license'],
'synopsis' => $params['synopsis'] ?? '',
'audit_status' => ShopEnum::AUDIT_STATUS_WAIT,
'work_status' => $params['work_status'] ?? 0,
'server_status' => $params['server_status'] ?? 1,
'business_start_time' => $params['business_start_time'] ?? '',
'business_end_time' => $params['business_end_time'] ?? '',
]);
$categoryLists = [];
foreach ($params['category_ids'] as $categoryId){
$categoryLists[] = [
'shop_id' => $shop['id'],
'category_id' => $categoryId,
];
}
(new ShopCategoryIndex())->saveAll($categoryLists);
$goodsLists = [];
foreach ($params['goods_ids'] as $goodsId) {
$goodsLists[] = [
'shop_id' => $shop['id'],
'goods_id' => $goodsId,
];
}
(new ShopGoodsIndex())->saveAll($goodsLists);
$shopImageLists = [];
$params['shop_image'] = $params['shop_image'] ? : [];
foreach ($params['shop_image'] as $image){
$shopImageLists[] = [
'shop_id' => $shop['id'],
'uri' => $image,
];
}
(new ShopImage())->saveAll($shopImageLists);
Db::commit();
return true;
}catch (Exception $e){
Db::rollback();
return $e->getMessage();
}
}
/**
* @notes 详情接口
* @param int $id
* @param int $shopUserId
* @return array
* @author cjhao
* @date 2024/10/5 20:28
*/
public function detail($shopUserId)
{
$detail = Shop::where(['shop_user_id'=>$shopUserId])
->with(['shop_image'])
->append(['audit_status_desc','region_desc','province_name','city_name','region_name'])
->withoutField('update_time,delete_time')
->order('id desc')
->findOrEmpty()
->toArray();
$categoryLists = ShopCategoryIndex::alias('SC')
->where(['SC.shop_id'=>$detail['id'],'is_show'=>1])
->join('goods_category GC','SC.category_id = GC.id')
->field('GC.id,GC.name')
->select()
->toArray();
$goodsLists = ShopGoodsIndex::alias('SG')
->where(['SG.shop_id'=>$detail['id'],'G.status'=>1])
->join('goods G','SG.goods_id = G.id')
->field('G.id,G.name')
->select()
->toArray();
$detail['category_lists'] = $categoryLists;
$detail['goods_lists'] = $goodsLists;
$detail['goods_ids'] = array_column($goodsLists,'id');
$detail['category_ids'] = array_column($categoryLists,'id');
return $detail;
}
/**
* @notes 更新店铺信息
* @param array $params
* @return string|true
* @author cjhao
* @date 2024/10/6 16:39
*/
public function updateInfo(array $params)
{
try {
if(!$params['shop_id']){
throw new Exception('请等待你店铺申请通过后,才能提交资料');
}
$shopUpdate = ShopUpdate::where(['shop_id'=>$params['shop_id'],'audit_status'=>CoachEnum::AUDIT_STATUS_WAIT])
->findOrEmpty();
if(!$shopUpdate->isEmpty()){
throw new Exception('您提交资料正在审核中,请勿重复提交');
}
// $mobile = Shop::where(['mobile'=>$params['mobile']])->where('id','<>',$params['shop_id'])->findOrEmpty();
// if(!$mobile->isEmpty()){
// throw new Exception('手机号码已存在');
// }
// ShopUpdate::where(['mobile'=>$params['mobile'],'audit_status'=>ShopEnum::AUDIT_STATUS_WAIT])->where('id','<>',$params['shop_id'])->findOrEmpty();
// if(!$mobile->isEmpty()){
// throw new Exception('手机号码已存在');
// }
$shopUser = ShopUser::where(['id'=>$params['shop_user_id']])->findOrEmpty();
ShopUpdate::create([
'name' => $params['name'],
'shop_user_id' => $params['shop_user_id'],
'shop_id' => $params['shop_id'],
'sn' => $params['sn'],
'short_name' => $params['short_name'],
'mobile' => $shopUser['account'],
'business_start_time' => $params['business_start_time'],
'business_end_time' => $params['business_end_time'],
'type' => $params['type'],
'social_credit_ode' => $params['social_credit_ode'],
'legal_person' => $params['legal_person'],
'legal_id_card' => $params['legal_id_card'],
// 'shop_adress' => $params['shop_adress'],
'shop_address_detail' => $params['shop_address_detail'],
'province_id' => $params['province_id'],
'city_id' => $params['city_id'],
'region_id' => $params['region_id'],
'longitude' => $params['longitude'],
'latitude' => $params['latitude'],
'id_card_front' => $params['id_card_front'],
'id_card_back' => $params['id_card_back'],
'portrait_shooting' => $params['portrait_shooting'],
'logo' => $params['logo'],
'business_license' => $params['business_license'],
'synopsis' => $params['synopsis'] ?? '',
'category_ids' => $params['category_ids'],
'goods_ids' => $params['goods_ids'],
'shop_image' => $params['shop_image'] ?? []
]);
return true;
}catch (Exception $e){
return $e->getMessage();
}
}
/**
* @notes 设置服务时间
* @param array $params
* @return string|true
* @author cjhao
* @date 2024/10/21 00:27
*/
public function setServerTime(array $params)
{
try {
$coach = Coach::where(['id'=>$params['id'],'shop_id'=>$params['shop_id']])->findOrEmpty();
if($coach->isEmpty()){
throw new \think\Exception('您无法设置当前技师服务时间');
}
Db::startTrans();
$serverTime = [];
foreach ($params['server_time'] as $key => $time){
$times = [];
foreach ($time['time_lists'] as $timeList){
if(in_array($timeList['time'],$times)){
continue;
}
$serverTime[] = [
'coach_id' => $params['id'],
'date' => $time['time_date'],
'time' => $timeList['time'],
'status' => $timeList['status']
];
$times[] = $timeList['time'];
}
}
CoachServerTime::where(['coach_id'=>$params['id']])->delete();
(new CoachServerTime())->saveAll($serverTime);
Db::commit();
return true;
} catch (Exception $e) {
Db::rollback();
return $e->getMessage();
}
}
/**
* @notes 获取营业时间
* @param int $shopId
* @return Shop|array|\think\Model
* @author cjhao
* @date 2024/10/22 09:32
*/
public function getBusiness(int $shopId){
$detail = Shop::where(['id'=>$shopId])
->field('id,monday,tuesday,wednesday,thursday,friday,saturday,sunday,business_start_time,business_end_time')
->findOrEmpty()->toArray();
$detail['monday'] = 1 == $detail['monday'] ? true : false;
$detail['tuesday'] = 1 == $detail['tuesday'] ? true : false;
$detail['wednesday'] = 1 == $detail['wednesday'] ? true : false;
$detail['thursday'] = 1 == $detail['thursday'] ? true : false;
$detail['friday'] = 1 == $detail['friday'] ? true : false;
$detail['saturday'] = 1 == $detail['saturday'] ? true : false;
$detail['sunday'] = 1 == $detail['sunday'] ? true : false;
return $detail;
}
/**
* @notes 设置营业时间
* @param array $params
* @return true
* @author cjhao
* @date 2024/10/22 09:43
*/
public function setBusiness(array $params)
{
$monday = $params['monday'] ?? 0;
$tuesday = $params['tuesday'] ?? 0;
$wednesday = $params['wednesday'] ?? 0;
$thursday = $params['thursday'] ?? 0;
$friday = $params['friday'] ?? 0;
$saturday = $params['saturday'] ?? 0;
$sunday = $params['sunday'] ?? 0;
$businessStartTime = $params['business_start_time'] ?? 0;
$businessEndTime = $params['business_end_time'] ?? 0;
Shop::where(['id'=>$params['shop_id']])
->update([
'monday' => $monday,
'tuesday' => $tuesday,
'wednesday' => $wednesday,
'thursday' => $thursday,
'friday' => $friday,
'saturday' => $saturday,
'sunday' => $sunday,
'business_start_time' => $businessStartTime,
'business_end_time' => $businessEndTime,
]);
return true;
}
/**
* @notes 获取资料详情
* @param $shopId
* @return array
* @author cjhao
* @date 2024/11/25 11:24
*/
public function updateInfoDetail($shopUserId)
{
$detail = ShopUpdate::where(['shop_user_id'=>$shopUserId])
->append(['audit_status_desc','region_desc','province_name','city_name','region_name'])
->order('id desc')->findOrEmpty()->toArray();
if(empty($detail)){
$detail = $this->detail($shopUserId);
$detail['audit_status'] = '';
$detail['audit_remark'] = '';
$detail['category_ids'] = array_column($detail['category_lists'],'id');
$detail['goods_ids'] = array_column($detail['goods_lists'],'id');
$detail['shop_image'] = array_column($detail['shop_image'],'uri');
}
foreach ($detail['goods_ids'] as $key => $val){
$detail['goods_ids'][$key] = intval($val);
}
foreach ($detail['category_ids'] as $key => $val){
$detail['category_ids'][$key] = intval($val);
}
return $detail;
}
/**
* @notes 设置服务状态
* @param $params
* @return string|true
* @author cjhao
* @date 2024/12/3 20:49
*/
public function setWorkStatus($params)
{
try {
$coach = Coach::where(['id'=>$params['id'],'shop_id'=>$params['shop_id']])->findOrEmpty();
if($coach->isEmpty()){
throw new \think\Exception('您无法设置当前技师服务时间');
}
$status = $params['status'] ?? '';
if('' === $status){
throw new \think\Exception('请选择状态');
}
$coach->work_status = $status;
$coach->save();
return true;
} catch (Exception $e) {
return $e->getMessage();
}
}
public function bindMobile($params)
{
try {
$mobile = $params['mobile'] ?? '';
$code = $params['code'] ?? '';
if (empty($mobile) || empty($code)) {
throw new \Exception('请输入手机号和验证码');
}
$smsDriver = new SmsDriver();
$result = $smsDriver->verify($params['mobile'], $params['code']);
if(!$result) {
throw new \Exception('验证码错误');
}
$user = Shop::where(['mobile'=>$params['mobile']])->where('id','<>',$params['shop_id'])->findOrEmpty();
if(!$user->isEmpty()) {
throw new \Exception('该手机号已被其他账号绑定');
}
// $user = ShopUpdate::where(['mobile'=>$params['mobile'],'audit_status'=>ShopEnum::AUDIT_STATUS_WAIT])->where('id','<>',$params['shop_id'])->findOrEmpty();
// if(!$user->isEmpty()) {
// throw new \Exception('该手机号已被其他账号绑定');
// }
unset($params['code']);
$coach = Shop::findOrEmpty($params['shop_id'])->toArray();
Shop::update(['mobile'=>$params['mobile'],'id'=>$params['shop_id']]);
ShopUser::update(['account'=>$params['mobile'],'id'=>$coach['shop_user_id']]);
return true;
} catch (\Exception $e) {
return $e->getMessage();
}
}
}

View File

@@ -0,0 +1,60 @@
<?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\shopapi\logic;
use app\common\enum\notice\NoticeEnum;
use app\common\logic\BaseLogic;
/**
* 短信逻辑
* Class SmsLogic
* @package app\coachapi\logic
*/
class SmsLogic extends BaseLogic
{
/**
* @notes 发送验证码
* @param $params
* @return false|mixed
* @author 段誉
* @date 2022/9/15 16:17
*/
public static function sendCode($params)
{
try {
$scene = NoticeEnum::getSceneByShopTag($params['scene']);
if (empty($scene)) {
throw new \Exception('场景值异常');
}
$result = event('Notice', [
'scene_id' => $scene,
'params' => [
'mobile' => $params['mobile'],
'code' => mt_rand(1000, 9999),
]
]);
return $result[0];
} catch (\Exception $e) {
self::$error = $e->getMessage();
return false;
}
}
}

View File

@@ -0,0 +1,428 @@
<?php
namespace app\shopapi\logic;
use app\common\enum\accountLog\CoachAccountLogEnum;
use app\common\enum\accountLog\ShopAccountLogEnum;
use app\common\logic\BaseLogic;
use app\common\logic\ShopAccountLogLogic;
use app\common\model\accountLog\CoachAccountLog;
use app\common\model\accountLog\ShopAccountLog;
use app\common\model\coach\Coach;
use app\common\model\shop\Shop;
use app\common\model\withdraw\WithdrawApply;
use app\common\model\withdraw\WithdrawConfig;
use app\common\service\ConfigService;
use DateTime;
use think\Exception;
use think\facade\Db;
/**
* 提现逻辑类
* Class WithdrawLogic
* @package app\shopapi\logic
*/
class WithdrawLogic extends BaseLogic
{
public function lists(int $shopId)
{
$lists = WithdrawConfig::where(['relation_id'=>$shopId,'source'=>2])
->column('type,config','type');
$configDefault = [
[
'type' => 1,
],
[
'type' => 2,
],
[
'type' => 3,
],
];
foreach ($configDefault as $default){
$config = $lists[$default['type']] ?? [];
if(empty($config)){
$lists[$default['type']] = [
'type' => $default['type'],
'config' => [],
];
}
}
if(empty($lists)){
$lists = [];
}
$wayLists = ConfigService::get('withdraw', 'way_list');
foreach ($lists as $key => $config)
{
if(!in_array($config['type'],$wayLists)){
unset($lists[$key]);
}
}
return array_values($lists);
}
/**
* @notes 获取提现方式配置
* @param $shopId
* @param $type
* @return WithdrawConfig|array|\think\Model
* @author cjhao
* @date 2024/9/26 00:22
*/
public function getWithDrawWay($shopId,$type)
{
$detail = WithdrawConfig::where(['relation_id'=>$shopId,'type'=>$type,'source'=>2])
->findOrEmpty()->toArray();
if(empty($detail)){
$detail = [
'type' => $type,
'config' => [],
];
}
switch ($type){
case 1:
$detail['config']['name'] = $detail['config']['name'] ?? '';
$detail['config']['mobile'] = $detail['config']['mobile'] ?? '';
break;
case 2:
$detail['config']['name'] = $detail['config']['name'] ?? '';
$detail['config']['account'] = $detail['config']['account'] ?? '';
break;
case 3:
$detail['config']['name'] = $detail['config']['name'] ?? '';
$detail['config']['bank'] = $detail['config']['bank'] ?? '';
$detail['config']['bank_card'] = $detail['config']['bank_card'] ?? '';
break;
}
return $detail;
}
/**
* @notes 设置提现方式
* @param $shopId
* @param $post
* @return string|true
* @author cjhao
* @date 2024/9/26 11:36
*/
public function setWithDrawWay($shopId,$post)
{
$type = $post['type'] ?? '';
if(empty($type)){
return '提现配置错误';
}
switch ($type){
case 1:
$name = $post['config']['name'] ?? '';
$mobile = $post['config']['mobile'] ?? '';
if(empty($name)){
return '请输入名称';
}
if(empty($mobile)){
return '请输入手机号码';
}
break;
case 2:
$name = $post['config']['name'] ?? '';
$account = $post['config']['account'] ?? '';
if(empty($name)){
return '请输入名称';
}
if(empty($account)){
return '请输入账号';
}
break;
case 3:
$name = $post['config']['name'] ?? '';
$bank = $post['config']['bank'] ?? '';
$bankCard = $post['config']['bank_card'] ?? '';
if(empty($name)){
return '请输入名称';
}
if(empty($bank)){
return '请输入开户名';
}
if(empty($bankCard)){
return '请输入银行卡号';
}
break;
}
$post['shop_id'] = $shopId;
$config = WithdrawConfig::where(['type'=>$type,'relation_id'=>$shopId,'source'=>2])->findOrEmpty();
if($config->isEmpty()){
WithdrawConfig::create([
'relation_id' => $shopId,
'type' => $type,
'config' => $post['config'],
'source' => 2,
]);
}else{
$config->config = $post['config'];
$config->save();
}
return true;
}
/**
* @notes 提现信息
* @param int $coachId
* @return array
* @author cjhao
* @date 2024/10/29 17:54
*/
public function getWithdrawInfo(int $shopId){
$lists = WithdrawConfig::where(['relation_id'=>$shopId,'source'=>2])
->column('type,config','type');
$configDefault = [
[
'type' => 1,
],
[
'type' => 2,
],
[
'type' => 3,
],
];
foreach ($configDefault as $default){
$config = $lists[$default['type']] ?? [];
if(empty($config)){
$lists[$default['type']] = [
'type' => $default['type'],
'config' => [],
];
}
}
if(empty($lists)){
$lists = [];
}
$wayLists = ConfigService::get('withdraw', 'way_list');
foreach ($lists as $key => $config)
{
if(!in_array($config['type'],$wayLists)){
unset($lists[$key]);
}
}
$config = [
'way_list' => array_values($lists),
'min_money' => ConfigService::get('withdraw', 'min_money'),
'max_money' => ConfigService::get('withdraw', 'max_money'),
'service_charge' => ConfigService::get('withdraw', 'service_charge'),
'money' => Shop::where(['id'=>$shopId])->value('money'),
'deposit' => Shop::where(['id'=>$shopId])->value('deposit'),
'withdraw_cycle_type' => ConfigService::get('withdraw', 'withdraw_cycle_type'),
'withdraw_cycle_date' => ConfigService::get('withdraw', 'withdraw_cycle_date'),
];
$tips = '';
if($config['withdraw_cycle_type']){
// $dayOfWeek = date('w'); // 注意:'w'返回的是数字其中0表示周日6表示周六
// $dayOfWeek = $dayOfWeek === 0 ? 7 : $dayOfWeek;
$weekDay = getWeekdayByNumber($config['withdraw_cycle_date']);
$tips = "平台设置每".$weekDay."可提现";
}else{
// 获取今天的日期(几号)
// $dayOfMonth = date('j'); // 'j'返回不带前导零的日期
$tips = "平台设置每月".$config['withdraw_cycle_date']."号可提现";
}
$config['tips'] = $tips;
return $config;
}
/**
* @notes 提现申请
* @param $params
* @return bool
* @author cjhao
* @date 2024/9/26 15:15
*/
public function withdrawalApply($params)
{
try {
Db::startTrans();
$cycleType = ConfigService::get('withdraw', 'withdraw_cycle_type');
$cycleDate = ConfigService::get('withdraw', 'withdraw_cycle_date');
$date = new DateTime();
if(1 == $cycleType){
$dayOfWeek =$date->format('N'); // 1表示星期一到 7表示星期日
if($cycleDate != $dayOfWeek){
throw new Exception('提现仅在每周'.getWeekdayByNumber($cycleDate).'可提现');
}
}else{
$dayOfMonth =$date->format('j'); // 1 到 31
if($cycleDate != $dayOfMonth){
throw new Exception('提现仅在每月'.$cycleDate.'号可提现');
}
}
$coach = Coach::where(['id'=>$params['coach_id']])->findOrEmpty();
if($coach->money < $params['money']){
throw new Exception('当前可提现金额仅剩:'.$coach->money.'元');
}
$minMoney = ConfigService::get('withdraw', 'min_money');
$maxMoney = ConfigService::get('withdraw', 'max_money');
$serviceCharge = ConfigService::get('withdraw', 'service_charge');
if($maxMoney < $params['money']){
throw new Exception('最高可提现'.$maxMoney.'元');
}
if($minMoney > $params['money']){
throw new Exception('最低提现'.$minMoney.'元');
}
$applyType = $params['apply_type'];
$config = WithdrawConfig::where(['type'=>$applyType,'coach_id'=>$params['coach_id']])->findOrEmpty();
if($config->isEmpty()){
throw new Exception('请配置提现账户');
}
$coach->money = round($coach->money - $params['money']);
$coach->save();
$handlingFee = round( ($params['money'] * $serviceCharge/100),2);
(new WithdrawApply())->save([
'sn' => generate_sn((new WithdrawApply()), 'sn'),
'coach_id' => $params['shop_id'],
'type' => $params['apply_type'],
'money' => $params['money'],
'left_money' => $coach->money,
'handling_fee' => $handlingFee,
'service_charge' => $serviceCharge,
'withdraw_config_snap' => $config
]);
//提交事务
Db::commit();
return true;
}catch (Exception $e) {
Db::rollback();
return $e->getMessage();
}
}
/**
* @notes 提现接口
* @param $params
* @return string|true
* @throws \Exception
* @author cjhao
* @date 2024/10/30 15:05
*/
public function apply($params)
{
try {
Db::startTrans();
$money = $params['money'] ?? 0;
$type = $params['type'] ?? '';
$applyType = $params['apply_type'] ?? 1;
if(empty($type)){
throw new Exception('请选择提现账号');
}
$config = [
'min_money' => ConfigService::get('withdraw', 'min_money'),
'max_money' => ConfigService::get('withdraw', 'max_money'),
'service_charge' => ConfigService::get('withdraw', 'service_charge'),
'withdraw_cycle_type' => ConfigService::get('withdraw', 'withdraw_cycle_type'),
'withdraw_cycle_date' => ConfigService::get('withdraw', 'withdraw_cycle_date'),
];
$withdrawConfig = WithdrawConfig::where(['relation_id'=>$params['shop_id'],'source'=>2,'type'=>$type])
->value('config');
if(empty($withdrawConfig)){
throw new Exception('请先配置提现账号信息');
}
if($config['withdraw_cycle_type']){
$dayOfWeek = date('w'); // 注意:'w'返回的是数字其中0表示周日6表示周六
if($config['withdraw_cycle_date'] != $dayOfWeek){
$weekDay = getWeekdayByNumber($config['withdraw_cycle_date']);
throw new Exception('请在每'.$weekDay.'来申请提现');
}
}else{
// 获取今天的日期(几号)
$dayOfMonth = date('j'); // 'j'返回不带前导零的日期
if($config['withdraw_cycle_date'] != $dayOfMonth){
throw new Exception('请在每月'.$dayOfMonth.'号来申请提现');
}
}
$shop = shop::where(['id'=> $params['shop_id']])->findOrEmpty();
$shopMoney = $shop->money;
if(2 == $applyType){
$shopMoney = $shop->deposit;
}
if($shopMoney< $money){
throw new Exception('当前可提现余额仅剩'.$shopMoney);
}
if($money < $config['min_money']){
throw new Exception('最小提现额度不能小于'.$config['min_money']);
}
if($money > $config['max_money']){
throw new Exception('最大提现额度不能小于'.$config['max_money']);
}
$serviceFree = 0;
if(1 == $applyType){
//手续费
$serviceFree = round($money*($config['service_charge']/100),2);
}
//手续费
// $serviceFree = round($money*($config['service_charge']/100),2);
//提现操作
$withdrawApply = WithdrawApply::create([
'sn' => generate_sn((new WithdrawApply()), 'sn', 20),
'relation_id' => $params['shop_id'],
'source' => 2,
'type' => $type,
'money' => $money,
'apply_type' => $applyType,
'left_money' => round($money - $serviceFree,2),
'handling_fee' => $serviceFree,
'service_charge' => $config['service_charge'],
'withdraw_config_snap' => $withdrawConfig,
]);
if(1 == $applyType){
$shop->money = round($shop->money - $money,2);
$shop->save();
ShopAccountLogLogic::add(
$shop->id,
ShopAccountLogEnum::MONEY,
ShopAccountLogEnum::WITHDRAW_DEC_MONEY,
2,
$money,
$withdrawApply['sn'],
);
}else{
$shop->deposit = round($shop->deposit - $money,2);
$shop->save();
ShopAccountLogLogic::add(
$shop->id,
ShopAccountLogEnum::DEPOSIT,
ShopAccountLogEnum::WITHDRAW_DEC_DEPOSIT,
2,
$money,
$withdrawApply['sn'],
);
}
Db::commit();
return true;
}catch (Exception $e){
Db::rollback();
self::$error = $e->getMessage();
return false;
}
}
/**
* @notes 详情
* @param $id
* @return WithdrawApply|array|\think\Model
* @author cjhao
* @date 2024/10/31 09:08
*/
public function detail($id,$shopId)
{
$detail = WithdrawApply::where(['id'=>$id,'source'=>2,'relation_id'=>$shopId])
->append(['status_desc','type_desc'])
->withoutField('delete_time')
->findOrEmpty()->toArray();
return $detail;
}
}

View File

@@ -0,0 +1,121 @@
<?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\shopapi\service;
use app\common\cache\ShopUserTokenCache;
use app\common\model\shop\ShopUserSession;
use think\facade\Config;
class ShopUserTokenService
{
/**
* @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();
$shopUserSession = ShopUserSession::where([['shop_user_id', '=', $userId], ['terminal', '=', $terminal]])->find();
//获取token延长过期的时间
$expireTime = $time + Config::get('project.coach_user_token.expire_duration');
$shopUserTokenCache = new ShopUserTokenCache();
//token处理
if ($shopUserSession) {
//清空缓存
$shopUserTokenCache->deleteShopUserInfo($shopUserSession->token);
//重新获取token
$shopUserSession->token = create_token($userId);
$shopUserSession->expire_time = $expireTime;
$shopUserSession->update_time = $time;
$shopUserSession->save();
} else {
//找不到在该终端的token记录创建token记录
$shopUserSession = ShopUserSession::create([
'shop_user_id' => $userId,
'terminal' => $terminal,
'token' => create_token($userId),
'expire_time' => $expireTime
]);
}
return $shopUserTokenCache->setShopUserInfo($shopUserSession->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 = ShopUserSession::where('token', '=', $token)->find();
//延长token过期时间
$adminSession->expire_time = $time + Config::get('project.admin_token.expire_duration');
$adminSession->update_time = $time;
$adminSession->save();
return (new ShopUserTokenCache())->setShopUserInfo($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 = ShopUserSession::where('token', '=', $token)
->find();
if (empty($userSession)) {
return false;
}
$time = time();
$userSession->expire_time = $time;
$userSession->update_time = $time;
$userSession->save();
return (new ShopUserTokenCache())->deleteShopUserInfo($token);
}
}

View File

@@ -0,0 +1,198 @@
<?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\shopapi\validate;
use app\common\model\city\City;
use app\common\model\goods\Goods;
use app\common\model\goods\GoodsCategory;
use app\common\model\skill\Skill;
use app\common\validate\BaseValidate;
class GoodsValidate extends BaseValidate
{
protected $rule = [
'id' => 'require|checkId',
'name' => 'require|max:64|checkGoodsName',
'category_id' => 'require|checkCategory',
'goods_image' => 'require|array|max:10',
'price' => 'require|float|egt:0',
'scribing_price' => 'float|egt:0',
'status' => 'require|in:0,1',
'duration' => 'require|float|egt:0',
'overtime_price'=> 'require|float|egt:0',
'overtime_duration'=> 'require|float|egt:0',
'commission_ratio' =>' require|float|egt:0',
'appoint_start_time' => 'require',
'appoint_end_time' => 'require',
'skill_id' => 'require|array|checkSkill',
// 'city_id' => 'require|array|checkCity',
];
protected $message = [
'id.require' => '参数错误',
'name.require' => '请输入服务名称',
'name.max' => '服务名称已超过限制字数',
'name.unique' => '服务名称重复',
'category_id.require' => '请选择服务分类',
'goods_image.require' => '请上传轮播图',
'goods_image.array' => '轮播图格式不正确',
'goods_image.max' => '轮播图数量不能大于10张',
'price.require' => '请输入价格',
'price.float' => '价格必须为浮点数',
'price.egt' => '价格必须大于或等于零',
'duration.require' => '请输入时长',
'overtime_price.require' => '请输入加时费用',
'overtime_price.float' => '加时费用必须为浮点数',
'overtime_price.egt' => '加时费用必须大于或等于零',
'overtime_duration.require' => '请输入加时时长',
'overtime_duration.float' => '加时时长必须为浮点数',
'overtime_duration.egt' => '加时时长必须大于或等于零',
'commission_ratio.require' => '请输入服务佣金',
'commission_ratio.float' => '服务佣金必须为浮点数',
'commission_ratio.egt' => '服务佣金必须大于或等于零',
'scribing_price.float' => '划线价必须为浮点数',
'scribing_price.egt' => '划线价必须大于或等于零',
'status.require' => '请选择服务状态',
'status.in' => '服务状态取值范围在[0,1]',
'ids.require' => '请选择服务',
'ids.array' => '参数格式错误',
'skill_id.require' => '请选择技能',
'city_id.require' => '请选择开通城市',
'appoint_start_time.require'=> '请输入预约开始时间',
'appoint_end_time.require'=> '请输入预约结束时间'
];
public function sceneAdd()
{
return $this->remove(['id'=>true,'ids'=>true]);
}
public function sceneDetail()
{
return $this->only(['id']);
}
public function sceneEdit()
{
return $this->remove(['ids'=>true]);
}
public function sceneDel()
{
return $this->only(['id'])
->append('id','checkDel');
}
public function sceneStatus()
{
return $this->only(['id','status']);
}
/**
* @notes 检验服务ID
* @param $value
* @param $rule
* @param $data
* @return bool|string
* @author ljj
* @date 2022/2/9 12:02 下午
*/
public function checkId($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/9 12:06 下午
*/
public function checkCategory($value,$rule,$data)
{
$result = GoodsCategory::where(['id'=>$value])->findOrEmpty();
if ($result->isEmpty()) {
return '服务分类不存在,请重新选择';
}
return true;
}
/**
* @notes 检验服务能否被删除
* @param $value
* @param $rule
* @param $data
* @return bool|string
* @throws \think\db\exception\DataNotFoundException
* @throws \think\db\exception\DbException
* @throws \think\db\exception\ModelNotFoundException
* @author ljj
* @date 2022/4/1 3:37 下午
*/
public function checkDel($value,$rule,$data)
{
// $goods = Goods::column('name','id');
// foreach ($value as $val) {
// $result = Staff::whereRaw("FIND_IN_SET($val,goods_ids)")->select()->toArray();
// if ($result) {
// return '服务:'.$goods[$val].'已被师傅绑定,无法删除';
// }
// }
return true;
}
public function checkSkill($value,$rule,$data){
$lists = Skill::where(['id'=>$value])->select();
if(count($lists)!=count($value)){
return '技能数据错误';
}
return true;
}
public function checkGoodsName($value,$rule,$data)
{
$where[] = ['name','=',$value];
if(isset($data['id']) && $data['id']){
$where[] = ['id','<>',$data['id']];
}
if(isset($data['shop_id']) && $data['shop_id']){
$where[] = ['shop_id','<>',$data['shop_id']];
}
$goods = Goods::where($where)->findOrEmpty();
if($goods->isEmpty()){
return true;
}
return '服务名称已存在';
}
}

View File

@@ -0,0 +1,159 @@
<?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\shopapi\validate;
use app\common\cache\ShopUserAccountSafeCache;
use app\common\enum\LoginEnum;
use app\common\enum\notice\NoticeEnum;
use app\common\enum\shop\ShopUserTerminalEnum;
use app\common\enum\YesNoEnum;
use app\common\model\shop\ShopUser;
use app\common\service\sms\SmsDriver;
use app\common\validate\BaseValidate;
use think\facade\Config;
/**
* 账号密码登录校验
* Class LoginValidate
* @package app\coachapi\validate
*/
class LoginAccountValidate extends BaseValidate
{
protected $rule = [
'terminal' => 'require|in:' . ShopUserTerminalEnum::WECHAT_MMP . ',' . ShopUserTerminalEnum::WECHAT_OA . ','
. ShopUserTerminalEnum::H5 . ',' . ShopUserTerminalEnum::PC . ',' . ShopUserTerminalEnum::IOS .
',' . ShopUserTerminalEnum::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)
{
//账号安全机制,连续输错后锁定,防止账号密码暴力破解
$shopUserAccountSafeCache = new ShopUserAccountSafeCache();
if (!$shopUserAccountSafeCache->isSafe()) {
return '密码连续' . $shopUserAccountSafeCache->count . '次输入错误,请' . $shopUserAccountSafeCache->minute . '分钟后重试';
}
$where = [];
if ($data['scene'] == LoginEnum::ACCOUNT_PASSWORD) {
// 手机号密码登录
$where = ['account' => $data['account']];
}
$shopUserInfo = ShopUser::where($where)
->field(['password'])
->findOrEmpty();
if ($shopUserInfo->isEmpty()) {
return '用户不存在';
}
// if ($shopUserInfo['is_disable'] === YesNoEnum::YES) {
// return '用户已禁用';
// }
if (empty($shopUserInfo['password'])) {
$shopUserAccountSafeCache->record();
return '用户不存在';
}
$passwordSalt = Config::get('project.unique_identification');
if ($shopUserInfo['password'] !== create_password($password, $passwordSalt)) {
$shopUserAccountSafeCache->record();
return '密码错误';
}
$shopUserAccountSafeCache->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_SHOP);
if ($result) {
return true;
}
return '验证码错误';
}
}

View File

@@ -0,0 +1,86 @@
<?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\shopapi\validate;
use app\common\model\coach\CoachUser;
use app\common\model\shop\ShopUser;
use app\common\validate\BaseValidate;
use think\facade\Config;
/**
* 密码校验
* 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',
'old_password' => 'require|checkPassword'
];
protected $message = [
'mobile.require' => '请输入手机号',
'mobile.mobile' => '请输入正确手机号',
'code.require' => '请填写验证码',
'password.require' => '请输入密码',
'password.length' => '密码须在6-25位之间',
'password.alphaNum' => '密码须为字母数字组合',
'password_confirm.require' => '请确认密码',
'password_confirm.confirm' => '两次输入的密码不一致',
'old_password.require' => '请输入原密码'
];
/**
* @notes 重置登录密码
* @return PasswordValidate
* @author 段誉
* @date 2022/9/16 18:11
*/
public function sceneResetPassword()
{
return $this->only(['mobile', 'code', 'password']);
}
/**
* @notes 修改密码场景
* @return PasswordValidate
* @author 段誉
* @date 2022/9/20 19:14
*/
public function sceneChangePassword()
{
return $this->only(['password', 'password_confirm','old_password']);
}
public function checkPassword($value,$rule,$data)
{
$passwordSalt = Config::get('project.unique_identification');
$shopUserInfo = ShopUser::where(['id'=>$data['shop_info']['shop_user_id']])->findOrEmpty();
if ($shopUserInfo['password'] !== create_password($value, $passwordSalt)) {
return '原密码错误';
}
return true;
}
}

View 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\shopapi\validate;
use app\common\enum\OrderEnum;
use app\common\enum\PayEnum;
use app\common\model\deposit\DepositOrder;
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',
'scene' => 'require',
];
protected $message = [
'from.require' => '参数缺失',
'pay_way.require' => '支付方式参数缺失',
'pay_way.in' => '支付方式参数错误',
'order_id.require' => '订单参数缺失',
'scene.require' => '场景参数缺失'
];
public function scenePayway()
{
return $this->only(['scene']);
}
public function scenePrepay()
{
return $this->only(['from', 'pay_way', 'order_id'])
->append('order_id','checkOrder');
}
public function sceneGetPayResult()
{
return $this->only(['from', 'order_id'])
->remove('order_id','checkOrderId');
}
/**
* @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 'deposit':
$result = DepositOrder::where('id',$value)->findOrEmpty();
break;
}
if ($result->isEmpty()) {
return '订单不存在';
}
if ($result['pay_status'] == PayEnum::ISPAID) {
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 'deposit':
$result = DepositOrder::where('id',$value)->findOrEmpty()->toArray();
// if ($result['order_status'] == OrderEnum::ORDER_STATUS_CLOSE) {
// return '订单已关闭';
// }
if ($result['pay_status'] == PayEnum::ISPAID) {
return '订单已支付';
}
break;
}
return true;
}
}

View 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\shopapi\validate;
use app\common\model\coach\CoachUser;
use app\common\model\shop\ShopUser;
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:' . ShopUser::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' => '两次输入的密码不一致'
];
}

View 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\shopapi\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::getSceneByShopTag($value);
if(empty($scene)){
return '场景值错误';
}
return true;
}
}

View File

@@ -0,0 +1,19 @@
<?php
namespace app\shopapi\validate;
use app\common\validate\BaseValidate;
class ShopApplyValidate extends BaseValidate
{
protected $rule = [
'id' => 'require',
'audit_status' => 'require|in:1,2',
'audit_remark' => 'max:255',
];
protected $message = [
'id.require' => '请选择申请记录',
'audit_status.require' => '请选择审核状态',
'audit_status.in' => '审核状态错误',
'audit_remark.max' => '备注超过255字符',
];
}

View File

@@ -0,0 +1,117 @@
<?php
namespace app\shopapi\validate;
use app\common\model\goods\Goods;
use app\common\model\goods\GoodsCategory;
use app\common\model\shop\Shop;
use app\common\validate\BaseValidate;
class ShopValidate extends BaseValidate
{
protected $rule = [
// 'id' => 'require',
'name' => 'require|max:50|unique:'.Shop::class.',name',
'short_name' => 'require|max:20|unique:'.Shop::class.',short_name',
// 'mobile' => 'require|mobile|unique:'.Shop::class.',mobile',
'business_start_time' => 'require',
'business_end_time' => 'require',
'type' => 'require|in:1,2',
'social_credit_ode' => 'require',
'legal_person' => 'require',
'legal_id_card' => 'require|idCard',
'shop_address_detail' => 'require',
'longitude' => 'require',
'latitude' => 'require',
'category_ids' => 'require|array|checkCategory',
'goods_ids' => 'require|array|checkGoods',
'id_card_front' => 'require',
'id_card_back' => 'require',
// 'portrait_shooting' => 'require',
'logo' => 'require',
'business_license' => 'require',
// 'shop_image' => 'array'
// 'work_status' => 'require|in:0,1',
// 'server_status' => 'require|in:0,1'
];
protected $message = [
'id.require' => '请选择店铺',
'name.require' => '请输入店铺名称',
'name.max' => '店铺名称不能超过50个字符',
'name.unique' => '店铺名称重复',
'business_start_time.require' => '请选择营业时间',
'business_end_time.require' => '请选择营业时间',
'short_name.require' => '请输入店铺简称',
'mobile.require' => '请输入手机号码',
'mobile.mobile' => '手机号码格式错误',
'mobile.unique' => '手机号码已存在',
'short_name.max' => '店铺简称不能超过20个字符',
'short_name.unique' => '店铺简称重复',
'type.require' => '请输入店铺类型',
'type.in' => '店铺类型错误',
'social_credit_ode.require' => '请输入社会统一信用代码',
'legal_person.require' => '请输入法人',
'legal_id_card.require' => '请输入法人身份证',
'legal_id_card.idCard' => '法人身份证错误',
'shop_address_detail.require' => '请输入店铺详情地址',
'longitude.require' => '请在地图上标记位置',
'latitude.require' => '请在地图上标记位置',
'category_ids.require' => '请选择分类',
'category_ids.array' => '分类数据错误',
'goods_ids.require' => '请选择服务',
'goods_ids.array' => '服务数据错误',
'id_card_front.require' => '请上传身份证正面照',
'id_card_back.require' => '请上传身份证背面照',
// 'portrait_shooting.require' => '请上传人像实照',
'logo.require' => '请上传logo',
'business_license.require' => '请上传营业执照',
'work_status.require' => '请选择工作状态',
'work_status.in' => '工作状态错误',
'server_status.require' => '请选择服务状态',
'server_status.in' => '服务状态错误',
'shop_image.array' => '商家相册数据错误'
];
// protected function sceneAdd()
// {
// return $this->remove(['id'=>true]);
// }
//
// protected function sceneId()
// {
// return $this->only(['id']);
// }
public function sceneUpdate()
{
return $this->remove(['work_status'=>true,'server_status'=>true,'name'=>'unique','short_name'=>'unique','mobile'=>'unique']);
// ->append(['name'=>'checkName','short_name'=>'checkShortName','mobile'=>'checkMobile']);
}
public function checkName($value,$rule,$data)
{
}
protected function checkCategory($value,$rule,$data)
{
$categoryLists = GoodsCategory::where(['id'=>$value])->select()->toArray();
if(count($categoryLists) != count($value)){
return '分类错误,请刷新列表重新选择';
}
return true;
}
protected function checkGoods($value,$rule,$data)
{
$categoryIds = GoodsCategory::where(['pid'=>$data['category_ids']])->column('id');
$goodsLists = Goods::where(['category_id'=>array_merge($data['category_ids'],$categoryIds)])->column('id');
foreach ($value as $goodsId) {
if(!in_array($goodsId,$goodsLists)){
return '服务错误,请刷新列表重新选择';
}
}
return true;
}
}