初始版本
This commit is contained in:
26
server/app/coachapi/config/route.php
Executable file
26
server/app/coachapi/config/route.php
Executable file
@@ -0,0 +1,26 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | likeshop100%开源免费商用商城系统
|
||||
// +----------------------------------------------------------------------
|
||||
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
|
||||
// | 开源版本可自由商用,可去除界面版权logo
|
||||
// | 商业版本务必购买商业授权,以免引起法律纠纷
|
||||
// | 禁止对系统程序代码以任何目的,任何形式的再发布
|
||||
// | gitee下载:https://gitee.com/likeshop_gitee
|
||||
// | github下载:https://github.com/likeshop-github
|
||||
// | 访问官网:https://www.likeshop.cn
|
||||
// | 访问社区:https://home.likeshop.cn
|
||||
// | 访问手册:http://doc.likeshop.cn
|
||||
// | 微信公众号:likeshop技术社区
|
||||
// | likeshop团队 版权所有 拥有最终解释权
|
||||
// +----------------------------------------------------------------------
|
||||
// | author: likeshopTeam
|
||||
// +----------------------------------------------------------------------
|
||||
return [
|
||||
|
||||
'middleware' => [
|
||||
app\coachapi\http\middleware\InitMiddleware::class,
|
||||
app\coachapi\http\middleware\LoginMiddleware::class,//登录验证
|
||||
],
|
||||
|
||||
];
|
||||
42
server/app/coachapi/controller/BaseCoachController.php
Executable file
42
server/app/coachapi/controller/BaseCoachController.php
Executable file
@@ -0,0 +1,42 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | likeshop100%开源免费商用商城系统
|
||||
// +----------------------------------------------------------------------
|
||||
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
|
||||
// | 开源版本可自由商用,可去除界面版权logo
|
||||
// | 商业版本务必购买商业授权,以免引起法律纠纷
|
||||
// | 禁止对系统程序代码以任何目的,任何形式的再发布
|
||||
// | gitee下载:https://gitee.com/likeshop_gitee
|
||||
// | github下载:https://github.com/likeshop-github
|
||||
// | 访问官网:https://www.likeshop.cn
|
||||
// | 访问社区:https://home.likeshop.cn
|
||||
// | 访问手册:http://doc.likeshop.cn
|
||||
// | 微信公众号:likeshop技术社区
|
||||
// | likeshop团队 版权所有 拥有最终解释权
|
||||
// +----------------------------------------------------------------------
|
||||
// | author: likeshopTeam
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
|
||||
namespace app\coachapi\controller;
|
||||
|
||||
|
||||
use app\common\controller\BaseLikeShopController;
|
||||
|
||||
class BaseCoachController extends BaseLikeShopController
|
||||
{
|
||||
protected int $coachId = 0;
|
||||
protected int $coachUserId = 0;
|
||||
protected array $coachInfo = [];
|
||||
|
||||
|
||||
public function initialize()
|
||||
{
|
||||
|
||||
if (isset($this->request->coachInfo) && $this->request->coachInfo) {
|
||||
$this->coachInfo = $this->request->coachInfo;
|
||||
$this->coachId = $this->coachInfo['coach_id'] ?? 0;
|
||||
$this->coachUserId = $this->coachInfo['coach_user_id'] ?? 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
75
server/app/coachapi/controller/CityController.php
Executable file
75
server/app/coachapi/controller/CityController.php
Executable file
@@ -0,0 +1,75 @@
|
||||
<?php
|
||||
namespace app\coachapi\controller;
|
||||
use app\api\controller\BaseApiController;
|
||||
use app\coachapi\logic\CityLogic;
|
||||
|
||||
class CityController extends BaseCoachController
|
||||
{
|
||||
/**
|
||||
* @notes 获取城市列表
|
||||
* @return \think\response\Json
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
* @author cjhao
|
||||
* @date 2024/10/6 17:50
|
||||
*/
|
||||
public function getCityLists()
|
||||
{
|
||||
$lists = (new CityLogic())->getCityLists();
|
||||
return $this->success('',$lists);
|
||||
}
|
||||
|
||||
/**
|
||||
* @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
|
||||
* @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);
|
||||
}
|
||||
}
|
||||
250
server/app/coachapi/controller/CoachController.php
Executable file
250
server/app/coachapi/controller/CoachController.php
Executable file
@@ -0,0 +1,250 @@
|
||||
<?php
|
||||
namespace app\coachapi\controller;
|
||||
use app\coachapi\lists\CoachOrderLists;
|
||||
use app\coachapi\lists\GoodsLists;
|
||||
use app\coachapi\logic\CoachLogic;
|
||||
use app\coachapi\validate\CoachValidate;
|
||||
|
||||
/**
|
||||
* 技师控制器类
|
||||
* Class CoachController
|
||||
* @package app\coachapi\controller
|
||||
*/
|
||||
class CoachController extends BaseCoachController
|
||||
{
|
||||
|
||||
/**
|
||||
* @notes 个人中心
|
||||
* @return \think\response\Json
|
||||
* @author cjhao
|
||||
* @date 2024/8/23 16:09
|
||||
*/
|
||||
public function center()
|
||||
{
|
||||
$result = (new CoachLogic())->center($this->coachInfo);
|
||||
return $this->success('',$result);
|
||||
}
|
||||
|
||||
/**
|
||||
* @notes 个人中心
|
||||
* @return \think\response\Json
|
||||
* @author cjhao
|
||||
* @date 2024/8/23 16:09
|
||||
*/
|
||||
public function info()
|
||||
{
|
||||
$result = (new CoachLogic())->info($this->coachId);
|
||||
return $this->success('',$result);
|
||||
}
|
||||
|
||||
/**
|
||||
* @notes 技能列表
|
||||
* @return \think\response\Json
|
||||
* @author cjhao
|
||||
* @date 2024/8/20 17:45
|
||||
*/
|
||||
public function skillLists()
|
||||
{
|
||||
$lists = (new CoachLogic())->skillLists();
|
||||
return $this->success('',$lists);
|
||||
}
|
||||
|
||||
/**
|
||||
* @notes 获取服务列表
|
||||
* @return \think\response\Json
|
||||
* @author cjhao
|
||||
* @date 2024/10/13 01:55
|
||||
*/
|
||||
public function goodsLists()
|
||||
{
|
||||
return $this->dataLists((new GoodsLists()));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 数据列表
|
||||
* @return \think\response\Json
|
||||
* @author cjhao
|
||||
* @date 2024/8/21 18:13
|
||||
*/
|
||||
public function otherLists()
|
||||
{
|
||||
$dataLists = (new CoachLogic())->otherLists();
|
||||
return $this->success('',$dataLists);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 申请技师接口
|
||||
* @return \think\response\Json
|
||||
* @author cjhao
|
||||
* @date 2024/8/23 17:19
|
||||
*/
|
||||
public function apply()
|
||||
{
|
||||
$params = (new CoachValidate())->post()->goCheck('apply',['coach_id'=>$this->coachId]);
|
||||
$params['coach_id'] = $this->coachId;
|
||||
$params['coach_user_id'] = $this->coachUserId;
|
||||
$result = (new CoachLogic())->apply($params);
|
||||
if(true === $result){
|
||||
return $this->success('申请成功,请等待平台审核');
|
||||
}
|
||||
return $this->fail($result);
|
||||
}
|
||||
|
||||
/**
|
||||
* @notes 详情
|
||||
* @return \think\response\Json
|
||||
* @author cjhao
|
||||
* @date 2024/8/21 15:29
|
||||
*/
|
||||
public function detail()
|
||||
{
|
||||
$result = (new CoachLogic())->detail($this->coachUserId);
|
||||
return $this->success('',$result);
|
||||
}
|
||||
|
||||
/**
|
||||
* @notes 更新资料
|
||||
* @return \think\response\Json
|
||||
* @author cjhao
|
||||
* @date 2024/8/28 10:05
|
||||
*/
|
||||
public function updateInfo()
|
||||
{
|
||||
$params = (new CoachValidate())->post()->goCheck('update');
|
||||
$params['coach_id'] = $this->coachId;
|
||||
$params['coach_user_id'] = $this->coachUserId;
|
||||
$result = (new CoachLogic())->updateInfo($params);
|
||||
if(true === $result){
|
||||
return $this->success('提交成功,请等待平台审核',[],1,1);
|
||||
}
|
||||
return $this->fail($result);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 获取技师资料详情
|
||||
* @return \think\response\Json
|
||||
* @author cjhao
|
||||
* @date 2024/11/26 17:12
|
||||
*/
|
||||
public function updateInfoDetail()
|
||||
{
|
||||
$result = (new CoachLogic())->updateInfoDetail($this->coachUserId);
|
||||
return $this->success('',$result);
|
||||
}
|
||||
|
||||
/**
|
||||
* @notes 更新技师位置
|
||||
* @return \think\response\Json
|
||||
* @author cjhao
|
||||
* @date 2024/8/29 16:00
|
||||
*/
|
||||
public function updateLocation()
|
||||
{
|
||||
$get = $this->request->get();
|
||||
if (!isset($get['latitude']) || $get['longitude'] == '') {
|
||||
return $this->fail('请上传位置');
|
||||
}
|
||||
$result = (new CoachLogic())->updateLocation($get,$this->coachId);
|
||||
if(true === $result){
|
||||
return $this->success('位置更新成功');
|
||||
}
|
||||
return $this->fail($result);
|
||||
}
|
||||
|
||||
/**
|
||||
* @notes 更新技师状态
|
||||
* @return \think\response\Json
|
||||
* @author cjhao
|
||||
* @date 2024/8/29 16:29
|
||||
*/
|
||||
public function updateWorkStatus()
|
||||
{
|
||||
(new CoachLogic())->updateWorkStatus($this->coachId);
|
||||
return $this->success('状态更新成功');
|
||||
}
|
||||
|
||||
/**
|
||||
* @notes 获取技师服务时间
|
||||
* @return \think\response\Json
|
||||
* @author cjhao
|
||||
* @date 2024/8/29 18:36
|
||||
*/
|
||||
public function getServerTime()
|
||||
{
|
||||
$result = (new CoachLogic())->getServerTime($this->coachId);
|
||||
return $this->success('',$result);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 设置技师服务时间
|
||||
* @return \think\response\Json
|
||||
* @author cjhao
|
||||
* @date 2024/9/2 17:28
|
||||
*/
|
||||
public function setServerTime()
|
||||
{
|
||||
$params = $this->request->post();
|
||||
$result = (new CoachLogic())->setServerTime($params,$this->coachId);
|
||||
if(true === $result){
|
||||
return $this->success('设置成功');
|
||||
}
|
||||
return $this->fail($result);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 订单列表
|
||||
* @return \think\response\Json
|
||||
* @author cjhao
|
||||
* @date 2024/9/23 02:25
|
||||
*/
|
||||
public function orderLists()
|
||||
{
|
||||
return $this->dataLists((new CoachOrderLists()));
|
||||
}
|
||||
|
||||
/**
|
||||
* @notes 个人资料
|
||||
* @return \think\response\Json
|
||||
* @author ljj
|
||||
* @date 2024/12/3 下午3:52
|
||||
*/
|
||||
public function personalData()
|
||||
{
|
||||
$result = (new CoachLogic())->personalData($this->coachId);
|
||||
return $this->success('',$result);
|
||||
}
|
||||
|
||||
/**
|
||||
* @notes 设置个人资料
|
||||
* @return \think\response\Json
|
||||
* @author ljj
|
||||
* @date 2024/12/3 下午3:57
|
||||
*/
|
||||
public function setPersonalData()
|
||||
{
|
||||
$params = (new CoachValidate())->post()->goCheck('setPersonalData', ['coach_id' => $this->coachId]);
|
||||
(new CoachLogic)->setPersonalData($params);
|
||||
return $this->success('操作成功', [],1,1);
|
||||
}
|
||||
|
||||
/**
|
||||
* @notes 绑定手机号
|
||||
* @return \think\response\Json
|
||||
* @author Tab
|
||||
* @date 2021/8/25 17:46
|
||||
*/
|
||||
public function bindMobile()
|
||||
{
|
||||
$params = (new CoachValidate())->post()->goCheck('bindMobile',['coach_id'=>$this->coachId]);
|
||||
$result = CoachLogic::bindMobile($params);
|
||||
if($result === true) {
|
||||
return $this->success('绑定成功', [], 1, 1);
|
||||
}
|
||||
return $this->fail($result);
|
||||
}
|
||||
}
|
||||
49
server/app/coachapi/controller/ConfigController.php
Executable file
49
server/app/coachapi/controller/ConfigController.php
Executable file
@@ -0,0 +1,49 @@
|
||||
<?php
|
||||
namespace app\coachapi\controller;
|
||||
use app\coachapi\logic\ConfigLogic;
|
||||
|
||||
class ConfigController extends BaseCoachController
|
||||
{
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
51
server/app/coachapi/controller/DecorateController.php
Executable file
51
server/app/coachapi/controller/DecorateController.php
Executable file
@@ -0,0 +1,51 @@
|
||||
<?php
|
||||
namespace app\coachapi\controller;
|
||||
|
||||
use app\coachapi\logic\DecorateLogic;
|
||||
|
||||
/**
|
||||
* 装修风格控制器类
|
||||
* Class DecorateController
|
||||
* @package app\api\controller
|
||||
*/
|
||||
class DecorateController extends BaseCoachController
|
||||
{
|
||||
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);
|
||||
}
|
||||
}
|
||||
42
server/app/coachapi/controller/DepositController.php
Executable file
42
server/app/coachapi/controller/DepositController.php
Executable file
@@ -0,0 +1,42 @@
|
||||
<?php
|
||||
namespace app\coachapi\controller;
|
||||
|
||||
use app\coachapi\logic\DepositLogic;
|
||||
|
||||
/**
|
||||
* 保证金控制器类
|
||||
* Class CoachController
|
||||
* @package app\coachapi\controller
|
||||
*/
|
||||
class DepositController extends BaseCoachController
|
||||
{
|
||||
|
||||
/**
|
||||
* @notes 获取保证金套餐
|
||||
* @return \think\response\Json
|
||||
* @author cjhao
|
||||
* @date 2024/8/27 18:22
|
||||
*/
|
||||
public function depositPackage()
|
||||
{
|
||||
$result = (new DepositLogic())->depositPackage($this->coachUserId);
|
||||
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->coachId);
|
||||
if(false === $result){
|
||||
return $this->fail(DepositLogic::getError());
|
||||
}
|
||||
return $this->success('',$result);
|
||||
|
||||
}
|
||||
}
|
||||
51
server/app/coachapi/controller/FinanceController.php
Executable file
51
server/app/coachapi/controller/FinanceController.php
Executable file
@@ -0,0 +1,51 @@
|
||||
<?php
|
||||
namespace app\coachapi\controller;
|
||||
use app\coachapi\lists\WithdrawalLogLists;
|
||||
use app\coachapi\logic\WithdrawLogic;
|
||||
use app\coachapi\validate\WithdrawalApplyValidate;
|
||||
|
||||
/**
|
||||
* 财务控制器类
|
||||
* Class FinanceController
|
||||
* @package app\coachapi\controller
|
||||
*/
|
||||
class FinanceController extends BaseCoachController
|
||||
{
|
||||
|
||||
public function lists()
|
||||
{
|
||||
return $this->dataLists();
|
||||
}
|
||||
|
||||
/**
|
||||
* @notes 提现申请
|
||||
* @return \think\response\Json
|
||||
* @author cjhao
|
||||
* @date 2024/9/26 15:13
|
||||
*/
|
||||
public function withdrawalApply()
|
||||
{
|
||||
|
||||
$params = (new WithdrawalApplyValidate())->post()->goCheck('',['coach_id'=>$this->coachId]);
|
||||
$result = (new WithdrawLogic())->withdrawalApply($params);
|
||||
if(true === $result){
|
||||
return $this->success('申请成功');
|
||||
}
|
||||
return $this->fail($result);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @notes 提现记录
|
||||
* @return \think\response\Json
|
||||
* @author cjhao
|
||||
* @date 2024/9/27 01:34
|
||||
*/
|
||||
public function withdrawalLog()
|
||||
{
|
||||
return $this->dataLists(new WithdrawalLogLists());
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
32
server/app/coachapi/controller/GoodsCommentController.php
Executable file
32
server/app/coachapi/controller/GoodsCommentController.php
Executable file
@@ -0,0 +1,32 @@
|
||||
<?php
|
||||
namespace app\coachapi\controller;
|
||||
|
||||
|
||||
use app\coachapi\logic\GoodsCommentLogic;
|
||||
|
||||
/**
|
||||
* 订单评论金控制器类
|
||||
* Class CoachController
|
||||
* @package app\coachapi\controller
|
||||
*/
|
||||
class GoodsCommentController extends BaseCoachController
|
||||
{
|
||||
/**
|
||||
* @notes 服务评价分类
|
||||
* @return \think\response\Json
|
||||
* @author ljj
|
||||
* @date 2022/2/18 2:10 下午
|
||||
*/
|
||||
public function commentCategory()
|
||||
{
|
||||
$result = (new GoodsCommentLogic())->commentCategory($this->coachId);
|
||||
return $this->success('',$result);
|
||||
}
|
||||
|
||||
|
||||
public function lists()
|
||||
{
|
||||
return $this->dataLists();
|
||||
}
|
||||
|
||||
}
|
||||
31
server/app/coachapi/controller/GoodsController.php
Executable file
31
server/app/coachapi/controller/GoodsController.php
Executable file
@@ -0,0 +1,31 @@
|
||||
<?php
|
||||
namespace app\coachapi\controller;
|
||||
use app\coachapi\logic\GoodsLogic;
|
||||
|
||||
/**
|
||||
* 服务控制器类
|
||||
* Class CoachController
|
||||
* @package app\coachapi\controller
|
||||
*/
|
||||
class GoodsController extends BaseCoachController
|
||||
{
|
||||
public function lists()
|
||||
{
|
||||
return $this->dataLists();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 获取详情接口
|
||||
* @return \think\response\Json
|
||||
* @author cjhao
|
||||
* @date 2024/11/27 14:38
|
||||
*/
|
||||
public function detail()
|
||||
{
|
||||
$params = $this->request->get();
|
||||
$result = (new GoodsLogic())->detail($params['id']);
|
||||
return $this->success('',$result);
|
||||
}
|
||||
|
||||
}
|
||||
116
server/app/coachapi/controller/LoginController.php
Executable file
116
server/app/coachapi/controller/LoginController.php
Executable file
@@ -0,0 +1,116 @@
|
||||
<?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\coachapi\controller;
|
||||
|
||||
use app\coachapi\validate\{LoginAccountValidate, PasswordValidate, RegisterValidate};
|
||||
use app\coachapi\logic\LoginLogic;
|
||||
|
||||
/**
|
||||
* 登录注册
|
||||
* Class LoginController
|
||||
* @package app\coachapi\controller
|
||||
*/
|
||||
class LoginController extends BaseCoachController
|
||||
{
|
||||
|
||||
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());
|
||||
}
|
||||
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->coachInfo);
|
||||
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',['coach_info'=>$this->coachInfo]);
|
||||
// $params['coach_info'] = $this->coachInfo;
|
||||
$result = (new LoginLogic())->changePassword($params);
|
||||
if (true === $result) {
|
||||
return $this->success('操作成功', [], 1, 1);
|
||||
}
|
||||
return $this->fail(LoginLogic::getError());
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
147
server/app/coachapi/controller/OrderController.php
Executable file
147
server/app/coachapi/controller/OrderController.php
Executable file
@@ -0,0 +1,147 @@
|
||||
<?php
|
||||
namespace app\coachapi\controller;
|
||||
use app\coachapi\lists\IncomeLists;
|
||||
use app\coachapi\logic\OrderLogic;
|
||||
use app\coachapi\validate\OrderValidate;
|
||||
use app\common\logic\PayNotifyLogic;
|
||||
|
||||
/**
|
||||
* 订单控制器类
|
||||
* Class OrderController
|
||||
* @package app\coachapi\controller
|
||||
*/
|
||||
class OrderController extends BaseCoachController
|
||||
{
|
||||
public array $notNeedLogin = ['test'];
|
||||
|
||||
|
||||
/**
|
||||
* @notes 订单列表
|
||||
* @return \think\response\Json
|
||||
* @author cjhao
|
||||
* @date 2024/9/16 21:14
|
||||
*/
|
||||
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/9/13 17:23
|
||||
*/
|
||||
public function take()
|
||||
{
|
||||
$params = (new OrderValidate())->post()->goCheck('',['coach_id'=>$this->coachId]);
|
||||
$result = (new OrderLogic())->take($params);
|
||||
if (true === $result) {
|
||||
return $this->success('接单成功', ['msg'=>'接单成功'], 1, 0);
|
||||
}
|
||||
return $this->success(OrderLogic::getError(), ['msg'=>OrderLogic::getError()], 1, 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* @notes 出发操作
|
||||
* @return \think\response\Json
|
||||
* @author cjhao
|
||||
* @date 2024/9/13 17:24
|
||||
*/
|
||||
public function depart()
|
||||
{
|
||||
$params = (new OrderValidate())->post()->goCheck('',['coach_id'=>$this->coachId]);
|
||||
$result = (new OrderLogic())->depart($params);
|
||||
if (true === $result) {
|
||||
return $this->success('操作成功', [], 1, 1);
|
||||
}
|
||||
return $this->fail(OrderLogic::getError());
|
||||
}
|
||||
|
||||
/**
|
||||
* @notes 达到操作
|
||||
* @return \think\response\Json
|
||||
* @author cjhao
|
||||
* @date 2024/9/13 17:24
|
||||
*/
|
||||
public function arrive()
|
||||
{
|
||||
$params = (new OrderValidate())->post()->goCheck('',['coach_id'=>$this->coachId]);
|
||||
$result = (new OrderLogic())->arrive($params);
|
||||
if (true === $result) {
|
||||
return $this->success('操作成功', [], 1, 0);
|
||||
}
|
||||
return $this->fail(OrderLogic::getError());
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 服务开始
|
||||
* @return \think\response\Json
|
||||
* @author cjhao
|
||||
* @date 2024/9/14 14:47
|
||||
*/
|
||||
public function startServer()
|
||||
{
|
||||
$params = (new OrderValidate())->post()->goCheck('',['coach_id'=>$this->coachId]);
|
||||
$result = (new OrderLogic())->startServer($params);
|
||||
if (true === $result) {
|
||||
return $this->success('操作成功', [], 1, 1);
|
||||
}
|
||||
return $this->fail(OrderLogic::getError());
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 服务完成
|
||||
* @return \think\response\Json
|
||||
* @author cjhao
|
||||
* @date 2024/9/14 14:53
|
||||
*/
|
||||
public function finishServer()
|
||||
{
|
||||
$params = (new OrderValidate())->post()->goCheck('',['coach_id'=>$this->coachId]);
|
||||
$result = (new OrderLogic())->finishServer($params);
|
||||
if (true === $result) {
|
||||
return $this->success('操作成功', [], 1, 0);
|
||||
}
|
||||
return $this->fail(OrderLogic::getError());
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 收入列表
|
||||
* @return \think\response\Json
|
||||
* @author cjhao
|
||||
* @date 2024/11/5 18:11
|
||||
*/
|
||||
public function incomeLists()
|
||||
{
|
||||
return $this->dataLists((new IncomeLists()));
|
||||
}
|
||||
|
||||
public function test()
|
||||
{
|
||||
|
||||
// PayNotifyLogic::handle('deposit', 202411290022494214, []);
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
127
server/app/coachapi/controller/PayController.php
Executable file
127
server/app/coachapi/controller/PayController.php
Executable file
@@ -0,0 +1,127 @@
|
||||
<?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\coachapi\controller;
|
||||
|
||||
|
||||
use app\coachapi\logic\PayLogic;
|
||||
use app\coachapi\validate\PayValidate;
|
||||
use app\common\enum\user\UserTerminalEnum;
|
||||
use app\common\service\AliPayService;
|
||||
use app\common\service\WeChatPayService;
|
||||
|
||||
class PayController extends BaseCoachController
|
||||
{
|
||||
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',['coach_id'=>$this->coachId]);
|
||||
$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->coachInfo['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);
|
||||
}
|
||||
}
|
||||
99
server/app/coachapi/controller/ShopController.php
Executable file
99
server/app/coachapi/controller/ShopController.php
Executable file
@@ -0,0 +1,99 @@
|
||||
<?php
|
||||
namespace app\coachapi\controller;
|
||||
use app\coachapi\logic\ShopLogic;
|
||||
use app\coachapi\validate\PasswordValidate;
|
||||
|
||||
class ShopController extends BaseCoachController
|
||||
{
|
||||
|
||||
public function lists()
|
||||
{
|
||||
return $this->dataLists();
|
||||
}
|
||||
|
||||
/**
|
||||
* @notes 店铺详情
|
||||
* @return \think\response\Json
|
||||
* @author cjhao
|
||||
* @date 2024/10/12 00:26
|
||||
*/
|
||||
public function detail()
|
||||
{
|
||||
$params = $this->request->get();
|
||||
$params['coach_id'] = $this->coachId;
|
||||
$detail = (new ShopLogic())->detail($params);
|
||||
return $this->success('',$detail);
|
||||
}
|
||||
|
||||
/**
|
||||
* @notes 申请
|
||||
* @return \think\response\Json
|
||||
* @author cjhao
|
||||
* @date 2024/10/14 11:51
|
||||
*/
|
||||
public function applyJoin()
|
||||
{
|
||||
$params = $this->request->post();
|
||||
$params['coach_id'] = $this->coachId;
|
||||
$result = (new ShopLogic())->applyJoin($params);
|
||||
if(true === $result){
|
||||
return $this->success('申请成功,请等待门店审核',[],1,1);
|
||||
}
|
||||
return $this->fail(ShopLogic::getError());
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 申请列表
|
||||
* @return \think\response\Json
|
||||
* @author cjhao
|
||||
* @date 2024/10/20 03:44
|
||||
*/
|
||||
public function applyDetail()
|
||||
{
|
||||
$params = $this->request->get();
|
||||
$params['coach_id'] = $this->coachId;
|
||||
$result = (new ShopLogic())->applyDetail($params);
|
||||
return $this->success('',$result);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 取消申请
|
||||
* @return \think\response\Json
|
||||
* @author cjhao
|
||||
* @date 2024/10/20 23:03
|
||||
*/
|
||||
public function cancel()
|
||||
{
|
||||
$params = $this->request->post();
|
||||
$params['coach_id'] = $this->coachId;
|
||||
$result = (new ShopLogic())->cancel($params);
|
||||
if(true === $result){
|
||||
return $this->success('取消成功');
|
||||
}
|
||||
return $this->fail($result);
|
||||
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @notes 申请
|
||||
* @return \think\response\Json
|
||||
* @author cjhao
|
||||
* @date 2024/10/14 11:51
|
||||
*/
|
||||
public function applyQuit()
|
||||
{
|
||||
// $params = $this->request->post();
|
||||
// $params['coach_id'] = $this->coachId;
|
||||
$result = (new ShopLogic())->applyQuit($this->coachId);
|
||||
if(true === $result){
|
||||
return $this->success('申请成功,请等待门店审核');
|
||||
}
|
||||
return $this->fail(ShopLogic::getError());
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
48
server/app/coachapi/controller/SmsController.php
Executable file
48
server/app/coachapi/controller/SmsController.php
Executable file
@@ -0,0 +1,48 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | likeadmin快速开发前后端分离管理后台(PHP版)
|
||||
// +----------------------------------------------------------------------
|
||||
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
|
||||
// | 开源版本可自由商用,可去除界面版权logo
|
||||
// | gitee下载:https://gitee.com/likeshop_gitee/likeadmin
|
||||
// | github下载:https://github.com/likeshop-github/likeadmin
|
||||
// | 访问官网:https://www.likeadmin.cn
|
||||
// | likeadmin团队 版权所有 拥有最终解释权
|
||||
// +----------------------------------------------------------------------
|
||||
// | author: likeadminTeam
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
namespace app\coachapi\controller;
|
||||
|
||||
use app\coachapi\logic\SmsLogic;
|
||||
use app\coachapi\validate\SendSmsValidate;
|
||||
|
||||
|
||||
/**
|
||||
* 短信
|
||||
* Class SmsController
|
||||
* @package app\coachapi\controller
|
||||
*/
|
||||
class SmsController extends BaseCoachController
|
||||
{
|
||||
|
||||
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());
|
||||
}
|
||||
|
||||
}
|
||||
48
server/app/coachapi/controller/UploadController.php
Executable file
48
server/app/coachapi/controller/UploadController.php
Executable file
@@ -0,0 +1,48 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | likeadmin快速开发前后端分离管理后台(PHP版)
|
||||
// +----------------------------------------------------------------------
|
||||
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
|
||||
// | 开源版本可自由商用,可去除界面版权logo
|
||||
// | gitee下载:https://gitee.com/likeshop_gitee/likeadmin
|
||||
// | github下载:https://github.com/likeshop-github/likeadmin
|
||||
// | 访问官网:https://www.likeadmin.cn
|
||||
// | likeadmin团队 版权所有 拥有最终解释权
|
||||
// +----------------------------------------------------------------------
|
||||
// | author: likeadminTeam
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
namespace app\coachapi\controller;
|
||||
|
||||
use app\common\enum\FileEnum;
|
||||
use app\common\service\UploadService;
|
||||
use Exception;
|
||||
use think\response\Json;
|
||||
|
||||
|
||||
/** 上传文件
|
||||
* Class UploadController
|
||||
* @package app\api\controller
|
||||
*/
|
||||
class UploadController extends BaseCoachController
|
||||
{
|
||||
|
||||
/**
|
||||
* @notes 上传图片
|
||||
* @return Json
|
||||
* @author 段誉
|
||||
* @date 2022/9/20 18:11
|
||||
*/
|
||||
public function image()
|
||||
{
|
||||
try {
|
||||
$result = UploadService::image(0, $this->coachId,FileEnum::SOURCE_COACH);
|
||||
return $this->success('上传成功', $result);
|
||||
} catch (Exception $e) {
|
||||
return $this->fail($e->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
46
server/app/coachapi/controller/WechatController.php
Executable file
46
server/app/coachapi/controller/WechatController.php
Executable file
@@ -0,0 +1,46 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | LikeShop有特色的全开源社交分销电商系统
|
||||
// +----------------------------------------------------------------------
|
||||
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
|
||||
// | 商业用途务必购买系统授权,以免引起不必要的法律纠纷
|
||||
// | 禁止对系统程序代码以任何目的,任何形式的再发布
|
||||
// | 微信公众号:好象科技
|
||||
// | 访问官网:http://www.likemarket.net
|
||||
// | 访问社区:http://bbs.likemarket.net
|
||||
// | 访问手册:http://doc.likemarket.net
|
||||
// | 好象科技开发团队 版权所有 拥有最终解释权
|
||||
// +----------------------------------------------------------------------
|
||||
// | Author: LikeShopTeam
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
namespace app\coachapi\controller;
|
||||
|
||||
use app\coachapi\controller\BaseCoachController;
|
||||
use app\coachapi\logic\WechatLogic;
|
||||
use app\coachapi\validate\WechatValidate;
|
||||
|
||||
/**
|
||||
* 微信控制器
|
||||
* Class WechatController
|
||||
* @package app\api\controller
|
||||
*/
|
||||
class WechatController extends BaseCoachController
|
||||
{
|
||||
public array $notNeedLogin = ['jsConfig'];
|
||||
/**
|
||||
* @notes 微信JSSDK授权接口
|
||||
* @return \think\response\Json
|
||||
* @author Tab
|
||||
* @date 2021/8/30 19:20
|
||||
*/
|
||||
public function jsConfig()
|
||||
{
|
||||
$params = (new WechatValidate())->goCheck('jsConfig');
|
||||
$result = WechatLogic::jsConfig($params);
|
||||
if ($result === false) {
|
||||
return $this->fail(WechatLogic::getError());
|
||||
}
|
||||
return $this->data($result);
|
||||
}
|
||||
}
|
||||
110
server/app/coachapi/controller/WithdrawController.php
Executable file
110
server/app/coachapi/controller/WithdrawController.php
Executable file
@@ -0,0 +1,110 @@
|
||||
<?php
|
||||
namespace app\coachapi\controller;
|
||||
use app\coachapi\lists\WithdrawalLogLists;
|
||||
use app\coachapi\logic\WithdrawLogic;
|
||||
|
||||
/**
|
||||
* 提现列表
|
||||
* Class WithdrawController
|
||||
* @package app\coachapi\controller
|
||||
*/
|
||||
class WithdrawController extends BaseCoachController
|
||||
{
|
||||
|
||||
public function configLists()
|
||||
{
|
||||
$lists = (new WithdrawLogic())->configLists($this->coachId);
|
||||
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->coachId,$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->coachId,$post);
|
||||
if(true === $result){
|
||||
return $this->success('设置成功',[],1,1);
|
||||
}
|
||||
return $this->fail($result);
|
||||
}
|
||||
|
||||
/**
|
||||
* @notes 获取提现配置
|
||||
* @return \think\response\Json
|
||||
* @author cjhao
|
||||
* @date 2024/10/29 17:21
|
||||
*/
|
||||
public function getWithdrawInfo()
|
||||
{
|
||||
$result = (new WithdrawLogic())->getWithdrawInfo($this->coachId);
|
||||
return $this->success('',$result,1,1);
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 提现
|
||||
* @return \think\response\Json
|
||||
* @author cjhao
|
||||
* @date 2024/10/29 18:00
|
||||
*/
|
||||
public function apply(){
|
||||
$params = $this->request->post();
|
||||
$params['coach_id'] = $this->coachId;
|
||||
$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/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->coachId);
|
||||
return $this->success('',$result);
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
86
server/app/coachapi/http/middleware/InitMiddleware.php
Executable file
86
server/app/coachapi/http/middleware/InitMiddleware.php
Executable 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\coachapi\http\middleware;
|
||||
|
||||
|
||||
use app\coachapi\controller\BaseCoachController;
|
||||
use app\common\exception\ControllerExtendException;
|
||||
use app\common\service\JsonService;
|
||||
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\\coachapi\\controller\\' . $controller . 'Controller';
|
||||
$controllerClass = invoke($controller);
|
||||
if (($controllerClass instanceof BaseCoachController) === 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);
|
||||
}
|
||||
|
||||
}
|
||||
91
server/app/coachapi/http/middleware/LoginMiddleware.php
Executable file
91
server/app/coachapi/http/middleware/LoginMiddleware.php
Executable file
@@ -0,0 +1,91 @@
|
||||
<?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\coachapi\http\middleware;
|
||||
|
||||
|
||||
use app\coachapi\service\CoachUserTokenService;
|
||||
use app\common\cache\CoachUserTokenCache;
|
||||
use app\common\enum\coach\CoachEnum;
|
||||
use app\common\model\coach\Coach;
|
||||
use app\common\service\JsonService;
|
||||
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);
|
||||
}
|
||||
$coachInfo = (new CoachUserTokenCache())->getCoachUserInfo($token);
|
||||
if (empty($coachInfo) && !$isNotNeedLogin) {
|
||||
//token过期无效并且该地址需要登录才能访问
|
||||
return JsonService::fail('登录超时,请重新登录', [], -1, 0);
|
||||
}
|
||||
|
||||
//token临近过期,自动续期
|
||||
if ($coachInfo) {
|
||||
//获取临近过期自动续期时长
|
||||
$beExpireDuration = Config::get('project.user_token.be_expire_duration');
|
||||
|
||||
//token续期
|
||||
if (time() > ($coachInfo['expire_time'] - $beExpireDuration)) {
|
||||
|
||||
$result = CoachUserTokenService::overtimeToken($token);
|
||||
|
||||
//续期失败(数据表被删除导致)
|
||||
if (empty($result)) {
|
||||
return JsonService::fail('登录过期', [], -1);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
//todo 重新查询sql,赋值,这里有优化的空间
|
||||
if($coachInfo && (CoachEnum::AUDIT_STATUS_WAIT == $coachInfo['audit_status'] || empty($coachInfo['audit_status']))){
|
||||
$coach = Coach::where(['coach_user_id'=>$coachInfo['coach_user_id']])
|
||||
->order('id desc')
|
||||
->field('id,audit_status')
|
||||
->find();
|
||||
$coachInfo['audit_status'] = $coach->audit_status ?? 0;
|
||||
$coachInfo['coach_id'] = $coach->id ?? 0;
|
||||
$request->coachId = $coach->id ?? 0;
|
||||
|
||||
}
|
||||
//给request赋值,用于控制器
|
||||
$request->coachInfo = $coachInfo;
|
||||
$request->coachUserId = $coachInfo['coach_user_id'] ?? 0;
|
||||
return $next($request);
|
||||
}
|
||||
|
||||
}
|
||||
45
server/app/coachapi/lists/BaseCoachApiDataLists.php
Executable file
45
server/app/coachapi/lists/BaseCoachApiDataLists.php
Executable 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\coachapi\lists;
|
||||
|
||||
use app\common\lists\BaseDataLists;
|
||||
|
||||
abstract class BaseCoachApiDataLists extends BaseDataLists
|
||||
{
|
||||
protected int $coachId = 0;
|
||||
protected int $coachUserId = 0;
|
||||
protected array $coachInfo = [];
|
||||
|
||||
public string $export;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
parent::__construct();
|
||||
|
||||
if (isset($this->request->coachInfo) && $this->request->coachInfo) {
|
||||
$this->coachInfo = $this->request->coachInfo;
|
||||
$this->coachId = $this->coachInfo['coach_id'] ?? 0;
|
||||
$this->coachUserId = $this->coachInfo['coach_user_id'] ?? 0;
|
||||
}
|
||||
$this->export = $this->request->get('export', '');
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
55
server/app/coachapi/lists/CoachOrderLists.php
Executable file
55
server/app/coachapi/lists/CoachOrderLists.php
Executable file
@@ -0,0 +1,55 @@
|
||||
<?php
|
||||
namespace app\coachapi\lists;
|
||||
use app\common\enum\OrderEnum;
|
||||
use app\common\enum\PayEnum;
|
||||
use app\common\model\order\Order;
|
||||
|
||||
/**
|
||||
* 订单列表
|
||||
* Class OrderLists
|
||||
* @package app\coachapi\lists
|
||||
*/
|
||||
class CoachOrderLists extends BaseCoachApiDataLists
|
||||
{
|
||||
public function setWhere()
|
||||
{
|
||||
$where = [];
|
||||
$where[] = ['coach_id','=',$this->coachId];
|
||||
$where[] = ['pay_status','=',PayEnum::ISPAID];
|
||||
$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
|
||||
]];
|
||||
return $where;
|
||||
}
|
||||
|
||||
public function lists(): array
|
||||
{
|
||||
$lists = Order::field('id,sn,order_status,user_remark,pay_status,appoint_time,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,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();
|
||||
|
||||
}
|
||||
}
|
||||
56
server/app/coachapi/lists/FinanceLists.php
Executable file
56
server/app/coachapi/lists/FinanceLists.php
Executable file
@@ -0,0 +1,56 @@
|
||||
<?php
|
||||
namespace app\coachapi\lists;
|
||||
|
||||
use app\common\enum\accountLog\CoachAccountLogEnum;
|
||||
use app\common\lists\ListsExtendInterface;
|
||||
use app\common\model\accountLog\CoachAccountLog;
|
||||
use app\common\model\coach\Coach;
|
||||
|
||||
/**
|
||||
* 财务管理列表
|
||||
* Class FinanceLists
|
||||
* @package app\coachapi\lists
|
||||
*/
|
||||
class FinanceLists extends BaseCoachApiDataLists implements ListsExtendInterface
|
||||
{
|
||||
public function setWhere()
|
||||
{
|
||||
$where = [];
|
||||
$where[] = ['coach_id','=',$this->coachId];
|
||||
$type = $this->params['type'] ?? '';
|
||||
switch ($type){
|
||||
case 1:
|
||||
$where[] = ['change_type','in',CoachAccountLogEnum::MONEY_DESC];
|
||||
break;
|
||||
case 2:
|
||||
$where[] = ['change_type','in',CoachAccountLogEnum::DEPOSIT_DESC];
|
||||
break;
|
||||
}
|
||||
return $where;
|
||||
}
|
||||
|
||||
public function lists(): array
|
||||
{
|
||||
$lists = CoachAccountLog::where($this->setWhere())
|
||||
->field('id,sn,action,change_object,change_type,action,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 CoachAccountLog::where($this->setWhere())->count();
|
||||
}
|
||||
|
||||
public function extend()
|
||||
{
|
||||
$coach = Coach::where(['id'=>$this->coachId])->field('deposit,money')->findOrEmpty();
|
||||
return [
|
||||
'money' => $coach['money'],
|
||||
'deposit' => $coach['deposit'],
|
||||
];
|
||||
}
|
||||
}
|
||||
68
server/app/coachapi/lists/GoodsCommentLists.php
Executable file
68
server/app/coachapi/lists/GoodsCommentLists.php
Executable file
@@ -0,0 +1,68 @@
|
||||
<?php
|
||||
|
||||
namespace app\coachapi\lists;
|
||||
|
||||
use app\common\model\goods\GoodsComment;
|
||||
use app\common\model\user\User;
|
||||
|
||||
/**
|
||||
* 订单评论列表
|
||||
* Class GoodsComment
|
||||
* @package app\coachapi\lists
|
||||
*/
|
||||
class GoodsCommentLists extends BaseCoachApiDataLists
|
||||
{
|
||||
|
||||
public function setWhere()
|
||||
{
|
||||
$where = [];
|
||||
$id = $this->params['id'] ?? 0;
|
||||
switch ($id){
|
||||
case 1:
|
||||
$coachOrderId = GoodsComment::alias('GC')
|
||||
->where(['GC.coach_id'=>$this->coachId])
|
||||
->join('goods_comment_image GCI','GC.id = GCI.comment_id')
|
||||
->column('GC.id') ?: [];
|
||||
$where[] = ['id','in',$coachOrderId];
|
||||
break;
|
||||
case 2:
|
||||
$where[] = ['service_comment','>',3];
|
||||
break;
|
||||
case 3:
|
||||
$where[] = ['service_comment','<=',3];
|
||||
break;
|
||||
}
|
||||
return $where;
|
||||
|
||||
}
|
||||
|
||||
public function lists(): array
|
||||
{
|
||||
$lists = GoodsComment::where(['coach_id'=>$this->coachId])
|
||||
->where($this->setWhere())
|
||||
->with(['goods_comment_image'])
|
||||
->field('id,user_id,service_comment,comment,reply,create_time')
|
||||
->limit($this->limitOffset, $this->limitLength)
|
||||
->order('id desc')
|
||||
->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;
|
||||
|
||||
}
|
||||
|
||||
public function count(): int
|
||||
{
|
||||
return GoodsComment::where(['coach_id'=>$this->coachId])
|
||||
->where($this->setWhere())
|
||||
->count();
|
||||
}
|
||||
}
|
||||
52
server/app/coachapi/lists/GoodsLists.php
Executable file
52
server/app/coachapi/lists/GoodsLists.php
Executable file
@@ -0,0 +1,52 @@
|
||||
<?php
|
||||
namespace app\coachapi\lists;
|
||||
use app\common\enum\coach\CoachEnum;
|
||||
use app\common\enum\GoodsEnum;
|
||||
use app\common\model\coach\Coach;
|
||||
use app\common\model\coach\CoachGoodsIndex;
|
||||
use app\common\model\goods\Goods;
|
||||
use app\common\model\goods\GoodsSkillIndex;
|
||||
|
||||
class GoodsLists extends BaseCoachApiDataLists
|
||||
{
|
||||
public function setWhere(){
|
||||
$where = [];
|
||||
$where[] = ['status','=',1];
|
||||
$id = $this->params['id'] ?? 0;
|
||||
$isCoach = $this->params['is_coach'] ?? 0;
|
||||
$where[] = ['audit_status','=',GoodsEnum::AUDIT_STATUS_PASS];
|
||||
$shopId = Coach::where(['id'=>$this->coachId])->value('shop_id');
|
||||
if($shopId){
|
||||
$where[] = ['shop_id','in',[$shopId,0]];
|
||||
}else{
|
||||
$where[] = ['shop_id','=',0];
|
||||
}
|
||||
if($id){
|
||||
$goodsIds = GoodsSkillIndex::where(['skill_id'=>$id])->column('goods_id');
|
||||
empty($goodsIds) && $goodsIds = [];
|
||||
$where[] = ['id','in',implode(',',$goodsIds)];
|
||||
}
|
||||
if($isCoach){
|
||||
$goodsIds = CoachGoodsIndex::where(['coach_id'=>$this->coachId])->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,price')
|
||||
->limit($this->limitOffset, $this->limitLength)
|
||||
->select()->toArray();
|
||||
return $lists;
|
||||
}
|
||||
|
||||
public function count(): int
|
||||
{
|
||||
return Goods::where(['status'=>1])
|
||||
->where($this->setWhere())
|
||||
->count();
|
||||
}
|
||||
}
|
||||
103
server/app/coachapi/lists/IncomeLists.php
Executable file
103
server/app/coachapi/lists/IncomeLists.php
Executable file
@@ -0,0 +1,103 @@
|
||||
<?php
|
||||
namespace app\coachapi\lists;
|
||||
|
||||
use app\common\enum\OrderEnum;
|
||||
use app\common\lists\ListsExtendInterface;
|
||||
use app\common\model\order\Order;
|
||||
use app\common\model\settle\Settle;
|
||||
use app\common\model\settle\SettleOrder;
|
||||
use think\facade\Db;
|
||||
|
||||
class IncomeLists extends BaseCoachApiDataLists implements ListsExtendInterface
|
||||
{
|
||||
public function setWhere()
|
||||
{
|
||||
$where = [];
|
||||
$where[] = ['coach_id','=',$this->coachId];
|
||||
$type = $this->params['type'] ?? 1;
|
||||
if(1 == $type){
|
||||
$where[] = ['shop_id','=',0];
|
||||
}else{
|
||||
$where[] = ['shop_id','>',0];
|
||||
}
|
||||
$where[] = ['order_status','not in',[OrderEnum::ORDER_STATUS_WAIT_PAY,OrderEnum::ORDER_STATUS_WAIT_RECEIVING]];
|
||||
|
||||
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_order_amount,user_remark,pay_status,appoint_time,is_settle,total_num,order_amount,user_remark,total_refund_amount,address_snap,true_server_finish_time,server_finish_time,is_settle,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_image,goods_name,goods_price')->hidden(['goods_snap']);
|
||||
}])
|
||||
->whereOr($this->setWhere())
|
||||
->limit($this->limitOffset, $this->limitLength)
|
||||
->select()->toArray();
|
||||
|
||||
$orderIds = array_column($lists,'id');
|
||||
$settleOrderLists = [];
|
||||
if($orderIds){
|
||||
$settleOrderLists = SettleOrder::where(['order_id'=>$orderIds])->column('*','order_id');
|
||||
}
|
||||
foreach ($lists as $key => $order){
|
||||
$status = 0;
|
||||
$settleOrder = $settleOrderLists[$order['id']] ?? [];
|
||||
if($settleOrder){
|
||||
$status = 1;
|
||||
}
|
||||
$coachCommission = $settleOrder['coach_commission'] ?? 0;
|
||||
$coachCarCommission = $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['coach_car_amount'] ?? 0 ,
|
||||
'settle_amount' => $settleOrder['total_commission'] ?? 0,
|
||||
'coach_settle' => round($coachCommission - $coachCarCommission,2),
|
||||
'shop_settle' => 0,
|
||||
];
|
||||
}
|
||||
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_coach_amount)') ?: 0;
|
||||
|
||||
}else{
|
||||
$settleAmount = Order::whereOr($this->setWhere())->where(['is_settle'=>1])->value('sum(settle_coach_amount)') ?: 0;
|
||||
}
|
||||
return [
|
||||
'settle_amount' => round($settleAmount,2)
|
||||
];
|
||||
|
||||
}
|
||||
}
|
||||
94
server/app/coachapi/lists/OrderLists.php
Executable file
94
server/app/coachapi/lists/OrderLists.php
Executable file
@@ -0,0 +1,94 @@
|
||||
<?php
|
||||
namespace app\coachapi\lists;
|
||||
use app\common\enum\OrderEnum;
|
||||
use app\common\enum\PayEnum;
|
||||
use app\common\model\order\Order;
|
||||
|
||||
/**
|
||||
* 订单列表
|
||||
* Class OrderLists
|
||||
* @package app\coachapi\lists
|
||||
*/
|
||||
class OrderLists extends BaseCoachApiDataLists
|
||||
{
|
||||
public function setWhere()
|
||||
{
|
||||
$where = [];
|
||||
$where[] = ['coach_id','=',$this->coachId];
|
||||
$where[] = ['pay_status','=',PayEnum::ISPAID];
|
||||
// if (isset($this->params['date_type']) && '' != $this->params['date_type']){
|
||||
// $todayDate = date('Y-m-d',time());
|
||||
// //今天的时间戳
|
||||
// $todayStart = strtotime($todayDate);
|
||||
// $todayEnd = strtotime($todayDate . ' 23:59:59');
|
||||
// switch ($this->params['date_type']){
|
||||
// case 1:
|
||||
// $where[] = ['appoint_time','>=',$todayStart];
|
||||
// $where[] = ['appoint_time','<=',$todayEnd];
|
||||
// break;
|
||||
// case 2:
|
||||
// //明天的时间戳
|
||||
// $tomorrowStart = strtotime('+1 day',$todayStart);
|
||||
// $tomorrowEnd = strtotime('+1 day',$todayEnd);
|
||||
// $where[] = ['appoint_time','>=',$tomorrowStart];
|
||||
// $where[] = ['appoint_time','<=',$tomorrowEnd];
|
||||
// break;
|
||||
// case 3:
|
||||
// //后天的时间戳
|
||||
// $dayAfterTomorrowStart = strtotime('+2 day',$todayStart);
|
||||
// $dayAfterTomorrowEnd = strtotime('+2 day',$todayEnd);
|
||||
// $where[] = ['appoint_time','>=',$dayAfterTomorrowStart];
|
||||
// $where[] = ['appoint_time','<=',$dayAfterTomorrowEnd];
|
||||
// break;
|
||||
// }
|
||||
// }
|
||||
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','take_order_btn','depart_btn','arrive_btn','server_start_btn','server_finish_btn','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']);
|
||||
}])
|
||||
->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();
|
||||
|
||||
}
|
||||
}
|
||||
62
server/app/coachapi/lists/ShopLists.php
Executable file
62
server/app/coachapi/lists/ShopLists.php
Executable file
@@ -0,0 +1,62 @@
|
||||
<?php
|
||||
namespace app\coachapi\lists;
|
||||
use app\common\enum\shop\ShopEnum;
|
||||
use app\common\model\city\City;
|
||||
use app\common\model\coach\Coach;
|
||||
use app\common\model\goods\GoodsCategory;
|
||||
use app\common\model\shop\Shop;
|
||||
|
||||
class ShopLists extends BaseCoachApiDataLists
|
||||
{
|
||||
|
||||
public function setWhere()
|
||||
{
|
||||
$where[] = ['audit_status','=',ShopEnum::AUDIT_STATUS_PASS];
|
||||
$where[] = ['server_status','=',ShopEnum::SERVERSTATUSOPEN];
|
||||
if(isset($this->params['keyword']) && $this->params['keyword']){
|
||||
$where[] = ['name|sn','like','%'.$this->params['keyword'].'%'];
|
||||
}
|
||||
else{
|
||||
$coachInfo = Coach::where(['id'=>$this->coachId])->field('city_id')->findOrEmpty();
|
||||
$where[] = ['city_id','=',$coachInfo['city_id']];
|
||||
}
|
||||
return $where;
|
||||
}
|
||||
|
||||
public function lists(): array
|
||||
{
|
||||
|
||||
$shopLists = Shop::where($this->setWhere())
|
||||
->field('id,logo,sn,name,synopsis,city_id')
|
||||
->append(['category_ids'])
|
||||
->limit($this->limitOffset, $this->limitLength)
|
||||
->select()->toArray();
|
||||
$coach = Coach::where(['id'=>$this->coachId])->field('shop_id,city_id')->findOrEmpty();
|
||||
$categoryLists = GoodsCategory::column('name','id');
|
||||
foreach ($shopLists as $key => $shop){
|
||||
$shopLists[$key]['category_name'] = '';
|
||||
$isJoin = false;
|
||||
if(0 == $coach['shop_id'] && $coach['city_id'] == $shop['city_id']){
|
||||
$isJoin = true;
|
||||
}
|
||||
$shopLists[$key]['is_join'] = $isJoin;
|
||||
$categoryIds = array_column($shop['category_ids']->toArray(),'id');
|
||||
$categoryNameLists = [];
|
||||
foreach ($categoryIds as $id){
|
||||
$categoryNameLists[] = $categoryLists[$id] ??'';
|
||||
}
|
||||
|
||||
$shopLists[$key]['category_name'] = implode(' ',$categoryNameLists);
|
||||
|
||||
|
||||
}
|
||||
return $shopLists;
|
||||
|
||||
}
|
||||
|
||||
public function count(): int
|
||||
{
|
||||
return Shop::where($this->setWhere())
|
||||
->count();
|
||||
}
|
||||
}
|
||||
56
server/app/coachapi/lists/WithdrawalLogLists.php
Executable file
56
server/app/coachapi/lists/WithdrawalLogLists.php
Executable file
@@ -0,0 +1,56 @@
|
||||
<?php
|
||||
namespace app\coachapi\lists;
|
||||
|
||||
use app\common\model\withdraw\WithdrawApply;
|
||||
|
||||
/**
|
||||
* 提现记录
|
||||
* Class LogLists
|
||||
* @package app\coachapi\lists
|
||||
*/
|
||||
class WithdrawalLogLists extends BaseCoachApiDataLists
|
||||
{
|
||||
|
||||
public function setWhere(){
|
||||
$where = [];
|
||||
$where[] = ['source','=',1];
|
||||
$where[] = ['relation_id','=',$this->coachId];
|
||||
$where[] = ['apply_type','=',$this->params['type'] ?? 1];
|
||||
$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();
|
||||
}
|
||||
}
|
||||
285
server/app/coachapi/logic/CityLogic.php
Executable file
285
server/app/coachapi/logic/CityLogic.php
Executable file
@@ -0,0 +1,285 @@
|
||||
<?php
|
||||
namespace app\coachapi\logic;
|
||||
use app\common\model\city\City;
|
||||
use app\common\model\Region;
|
||||
use app\common\service\ConfigService;
|
||||
use app\common\service\TencentMapKeyService;
|
||||
use Exception;
|
||||
|
||||
class CityLogic
|
||||
{
|
||||
|
||||
/**
|
||||
* @notes 获取城市列表
|
||||
* @return array
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
* @author cjhao
|
||||
* @date 2024/10/6 17:49
|
||||
*/
|
||||
public function getCityLists()
|
||||
{
|
||||
$lists = City::where(['level'=>2])->select()->toArray();
|
||||
$cityLists = [];
|
||||
foreach ($lists as $city){
|
||||
$parent = $cityLists[$city['parent_id']] ?? [];
|
||||
if($parent){
|
||||
$parent['sons'][] =[
|
||||
'id' => $city['city_id'],
|
||||
'name' => $city['name'],
|
||||
];
|
||||
}else{
|
||||
$parent = [
|
||||
'id' => $city['parent_id'],
|
||||
'name' => $city['parent_name'],
|
||||
'sons' => [
|
||||
[
|
||||
'id' => $city['city_id'],
|
||||
'name' => $city['name'],
|
||||
],
|
||||
],
|
||||
];
|
||||
}
|
||||
$cityLists[$city['parent_id']] = $parent;
|
||||
}
|
||||
return array_values($cityLists);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @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 地级市列表
|
||||
* @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 逆地址解析(坐标位置描述)
|
||||
* @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;
|
||||
}
|
||||
|
||||
}
|
||||
710
server/app/coachapi/logic/CoachLogic.php
Executable file
710
server/app/coachapi/logic/CoachLogic.php
Executable file
@@ -0,0 +1,710 @@
|
||||
<?php
|
||||
namespace app\coachapi\logic;
|
||||
use app\common\enum\coach\CoachEnum;
|
||||
use app\common\enum\coach\CoachUserEnum;
|
||||
use app\common\enum\DefaultEnum;
|
||||
use app\common\enum\notice\NoticeEnum;
|
||||
use app\common\enum\OrderEnum;
|
||||
use app\common\enum\PayEnum;
|
||||
use app\common\enum\shop\ShopEnum;
|
||||
use app\common\model\coach\Coach;
|
||||
use app\common\model\coach\CoachGoodsIndex;
|
||||
use app\common\model\coach\CoachLifePhoto;
|
||||
use app\common\model\coach\CoachServerTime;
|
||||
use app\common\model\coach\CoachUpdate;
|
||||
use app\common\model\coach\CoachUser;
|
||||
use app\common\model\goods\Goods;
|
||||
use app\common\model\order\Order;
|
||||
use app\common\model\shop\ShopCoachApply;
|
||||
use app\common\model\skill\Skill;
|
||||
use app\common\service\ConfigService;
|
||||
use app\common\service\FileService;
|
||||
use app\common\service\sms\SmsDriver;
|
||||
use app\common\service\TencentMapKeyService;
|
||||
use Exception;
|
||||
use think\facade\Db;
|
||||
|
||||
/**
|
||||
* 技师逻辑类
|
||||
* Class CoachLogic
|
||||
* @package app\coachapi\logic
|
||||
*/
|
||||
class CoachLogic
|
||||
{
|
||||
|
||||
/**
|
||||
* @notes 个人中心
|
||||
* @return array
|
||||
* @author cjhao
|
||||
* @date 2024/8/23 16:09
|
||||
*/
|
||||
public function center($coachInfo)
|
||||
{
|
||||
$coachUser = CoachUser::where(['id'=>$coachInfo['coach_user_id']])->field('sn,avatar')->findOrEmpty();
|
||||
$coachUser->location = '';
|
||||
$coachUser->work_status = '';
|
||||
$coach = Coach::where(['coach_user_id'=>$coachInfo['coach_user_id']])
|
||||
->order('id desc')
|
||||
->append(['province_name','city_name','region_name','region_desc'])
|
||||
->field('id,shop_id,province_id,city_id,region_id,longitude,latitude,longitude_location,latitude_location,name,sn,work_photo,money,deposit,work_status,location,work_photo,audit_status,audit_remark')
|
||||
->findOrEmpty();
|
||||
$coachUser->audit_status = $coach->audit_status;
|
||||
$coachUser->audit_remark = $coach->audit_remark;
|
||||
$coachUser->avatar = $coach->work_photo ? : $coachUser->avatar;
|
||||
$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);
|
||||
|
||||
$todayOrderCount = Order::where(['coach_id'=>$coachInfo['coach_id'],'pay_status'=>PayEnum::ISPAID])
|
||||
->whereNotIn('order_status',[OrderEnum::ORDER_STATUS_WAIT_PAY,OrderEnum::ORDER_STATUS_WAIT_RECEIVING,OrderEnum::ORDER_STATUS_CLOSE,OrderEnum::ORDER_STATUS_SERVER_FINISH])
|
||||
->whereBetweenTime('appoint_time',$todayStart,$todayEnd)
|
||||
->count();
|
||||
$tomorrowOrderCount = Order::where(['coach_id'=>$coachInfo['coach_id'],'pay_status'=>PayEnum::ISPAID])
|
||||
->whereNotIn('order_status',[OrderEnum::ORDER_STATUS_WAIT_PAY,OrderEnum::ORDER_STATUS_WAIT_RECEIVING,OrderEnum::ORDER_STATUS_CLOSE,OrderEnum::ORDER_STATUS_SERVER_FINISH])
|
||||
->whereBetweenTime('appoint_time',$tomorrowStart,$tomorrowEnd)
|
||||
->count();
|
||||
$afterTomorrowOrderCount = Order::where(['coach_id'=>$coachInfo['coach_id'],'pay_status'=>PayEnum::ISPAID])
|
||||
->whereNotIn('order_status',[OrderEnum::ORDER_STATUS_WAIT_PAY,OrderEnum::ORDER_STATUS_WAIT_RECEIVING,OrderEnum::ORDER_STATUS_CLOSE,OrderEnum::ORDER_STATUS_SERVER_FINISH])
|
||||
->whereBetweenTime('appoint_time',$dayAfterTomorrowStart,$dayAfterTomorrowEnd)
|
||||
->count();
|
||||
$location = $coach->location;
|
||||
$location['longitude'] = $coach->longitude_location;
|
||||
$location['latitude'] = $coach->latitude_location;
|
||||
|
||||
if(CoachEnum::AUDIT_STATUS_PASS == $coach->audit_status){
|
||||
$coachUser->work_status = $coach->work_status;
|
||||
$coachUser->work_photo = $coach->work_photo;
|
||||
$coachUser->location = $location;
|
||||
}
|
||||
$coachUser->today_order_count = $todayOrderCount;
|
||||
$coachUser->tomoroow_order_count = $tomorrowOrderCount;
|
||||
$coachUser->after_tomoroow_order_count = $afterTomorrowOrderCount;
|
||||
if(!$coach->isEmpty()){
|
||||
$coachUser->name = $coach->name;
|
||||
$coachUser->sn = $coach->sn;
|
||||
}
|
||||
$coachUser->money = $coach->money;
|
||||
$coachUser->deposit = $coach->deposit;
|
||||
$coachUser->province_id = $coach->province_id;
|
||||
$coachUser->city_id = $coach->city_id;
|
||||
$coachUser->region_id = $coach->region_id;
|
||||
$coachUser->province_name = $coach->province_name;
|
||||
$coachUser->city_name = $coach->city_name;
|
||||
$coachUser->region_name = $coach->region_name;
|
||||
$coachUser->region_desc = $coach->region_desc;
|
||||
$coachUser->longitude = $coach->longitude;
|
||||
$coachUser->latitude = $coach->latitude;
|
||||
$coachUser->id = $coach->id;
|
||||
$coachUser->shop_id = $coach->shop_id;
|
||||
if(!$coach->shop_id){
|
||||
$apply = ShopCoachApply::where(['coach_id'=>$coach['id']])
|
||||
->order('id desc')
|
||||
->field('shop_id,id,type,audit_status')
|
||||
->findOrEmpty();
|
||||
if(!$apply->isEmpty()){
|
||||
$shopId = $apply['shop_id'];
|
||||
//申请商家取消;退出商家同意;退出商家取消
|
||||
if((1 == $apply['type'] && 3 == $apply['audit_status']) || (2 == $apply['type'] && 1 == $apply['audit_status']) || (2 == $apply['type'] && 1 == $apply['audit_status'])){
|
||||
$shopId = 0;
|
||||
}
|
||||
$coachUser->shop_id = $shopId;
|
||||
}
|
||||
|
||||
}
|
||||
//服务项目
|
||||
$coachUser->server_count = CoachGoodsIndex::where(['coach_id'=>$coachInfo['coach_id']])->count();
|
||||
|
||||
|
||||
|
||||
return $coachUser->toArray();
|
||||
}
|
||||
|
||||
/**
|
||||
* @notes 获取详情接口
|
||||
* @param $coachId
|
||||
* @return Coach|array|\think\Model
|
||||
* @author cjhao
|
||||
* @date 2024/11/23 18:15
|
||||
*/
|
||||
public function info($coachId)
|
||||
{
|
||||
$detail = Coach::where(['id'=>$coachId,'audit_status'=>CoachEnum::AUDIT_STATUS_PASS])
|
||||
->field('id,name,id_card,id_card_front,portrait_shooting,id_card_back,work_photo')
|
||||
->findOrEmpty()->toArray();
|
||||
if(empty($detail)){
|
||||
$detail = [
|
||||
'id' => $coachId,
|
||||
'name' => '',
|
||||
'id_card' => '',
|
||||
'id_card_back' => '',
|
||||
'id_card_front' => '',
|
||||
'work_photo' => ''
|
||||
];
|
||||
}
|
||||
return $detail;
|
||||
}
|
||||
|
||||
/**
|
||||
* @notes 技能列表
|
||||
* @return array
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
* @author cjhao
|
||||
* @date 2024/8/20 18:02
|
||||
*/
|
||||
public function skillLists()
|
||||
{
|
||||
$skillLists = Skill::field('name,id')->select()->toArray();
|
||||
// $goodsLists = Goods::alias('G')
|
||||
// ->where(['G.status'=>1])
|
||||
// ->append(['category_desc','skill_desc'])
|
||||
// ->join('goods_skill_index GSI','G.id = GSI.goods_id')
|
||||
// ->field('G.id,G.price,G.name,G.category_id,G.image,GSI.skill_id')
|
||||
// ->select()->toArray();
|
||||
// foreach ($skillLists as $key => $skill){
|
||||
// $skillGoodsLists = [];
|
||||
// foreach ($goodsLists as $goods){
|
||||
// if($skill['id'] == $goods['skill_id']){
|
||||
// $skillGoodsLists[] = $goods;
|
||||
// }
|
||||
// }
|
||||
// $skillLists[$key]['goods_list'] = $skillGoodsLists;
|
||||
// }
|
||||
return $skillLists;
|
||||
}
|
||||
|
||||
public function goodsLists(int $id)
|
||||
{
|
||||
$where[] = ['status','=',1];
|
||||
if($id){
|
||||
$goodsIds = CoachGoodsIndex::where(['skill_id'=>$id])->column('goods_id');
|
||||
empty($goodsIds) && $goodsIds = [];
|
||||
$where[] = ['id','in',implode(',',$goodsIds)];
|
||||
}
|
||||
$lists = Goods::where($where)
|
||||
->field('id,name,price,image')
|
||||
->select()
|
||||
->toArray();
|
||||
return $lists;
|
||||
}
|
||||
|
||||
/**
|
||||
* @notes 其他数据
|
||||
* @return array
|
||||
* @author cjhao
|
||||
* @date 2024/8/21 18:16
|
||||
*/
|
||||
public function otherLists()
|
||||
{
|
||||
$educationLists = DefaultEnum::getEducationLists();
|
||||
$nationLists = DefaultEnum::getNationLists();
|
||||
return [
|
||||
'education_lists' => $educationLists,
|
||||
'nation_lists' => $nationLists,
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @notes 申请技师
|
||||
* @param array $params
|
||||
* @return string|true
|
||||
* @author cjhao
|
||||
* @date 2024/8/23 17:24
|
||||
*/
|
||||
public function apply(array $params)
|
||||
{
|
||||
try {
|
||||
Db::startTrans();
|
||||
$coach = Coach::where(['coach_user_id'=>$params['coach_user_id']])
|
||||
->order('id desc')
|
||||
->findOrEmpty();
|
||||
if( !$coach->isEmpty() && CoachEnum::AUDIT_STATUS_PASS == $coach->audit_status ){
|
||||
return '当前账号已经入驻成功,请勿重复申请';
|
||||
}
|
||||
if( !$coach->isEmpty() && CoachEnum::AUDIT_STATUS_WAIT == $coach->audit_status ){
|
||||
return '当前账号申请正在审核中,请耐心等待';
|
||||
}
|
||||
$coachUser = CoachUser::where(['id'=>$params['coach_user_id']])->findOrEmpty();
|
||||
$coach = (new Coach());
|
||||
$coach->name = $params['name'];
|
||||
$coach->sn = $coachUser->sn;
|
||||
$coach->gender = $params['gender'];
|
||||
$coach->age = $params['age'];
|
||||
$coach->id_card = $params['id_card'];
|
||||
$coach->mobile = $coachUser['account'];
|
||||
$coach->education = $params['education'];
|
||||
$coach->nation = $params['nation'];
|
||||
$coach->province_id = $params['province_id'];
|
||||
$coach->city_id = $params['city_id'];
|
||||
$coach->region_id = $params['region_id'];
|
||||
$coach->address_detail = $params['address_detail'];
|
||||
$coach->coach_user_id = $params['coach_user_id'];
|
||||
$coach->skill_id = $params['skill_id'];
|
||||
$coach->id_card_front = $params['id_card_front'];
|
||||
$coach->id_card_back = $params['id_card_back'];
|
||||
$coach->portrait_shooting = $params['portrait_shooting'];
|
||||
$coach->work_photo = $params['work_photo'];
|
||||
$coach->certification = $params['certification'] ?? '';
|
||||
$coach->health_certificate = $params['health_certificate'] ?? '';
|
||||
$coach->work_status = $params['work_status'];
|
||||
$coach->server_status = $params['server_status'];
|
||||
$coach->longitude = $params['longitude'] ?? '';
|
||||
$coach->latitude = $params['latitude'] ?? '';
|
||||
$coach->save();
|
||||
|
||||
//生活照
|
||||
$lifePhoto = $params['life_photo'] ?? [];
|
||||
$lifePhotoLists = [];
|
||||
foreach ($lifePhoto as $photo){
|
||||
$lifePhotoLists[] = [
|
||||
'uri' => $photo,
|
||||
'coach_id' => $coach->id
|
||||
];
|
||||
}
|
||||
(new CoachLifePhoto())->saveAll($lifePhotoLists);
|
||||
|
||||
//关联服务
|
||||
$goodsIds = $params['goods_ids'] ?? [];
|
||||
$goodsLists = [];
|
||||
foreach ($goodsIds as $goodsId)
|
||||
{
|
||||
$goodsLists[] = [
|
||||
'goods_id' => $goodsId,
|
||||
'coach_id' => $coach->id,
|
||||
];
|
||||
}
|
||||
(new CoachGoodsIndex())->saveAll($goodsLists);
|
||||
$mobile = ConfigService::get('platform', 'mobile','');
|
||||
if($mobile){
|
||||
//入驻申请通知-平台
|
||||
event('Notice', [
|
||||
'scene_id' => NoticeEnum::STAFF_APPLY_NOTICE_PLATFORM,
|
||||
'params' => [
|
||||
'coach_id' => $coach['id'],
|
||||
'mobile' => $mobile
|
||||
]
|
||||
]);
|
||||
}
|
||||
|
||||
Db::commit();
|
||||
|
||||
return true;
|
||||
}catch (Exception $e){
|
||||
Db::rollback();
|
||||
return $e->getMessage();
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @notes 详情
|
||||
* @param int $id
|
||||
* @return array
|
||||
* @author cjhao
|
||||
* @date 2024/8/21 15:30
|
||||
*/
|
||||
public function detail(int $id)
|
||||
{
|
||||
$coach = (new Coach())
|
||||
->where(['coach_user_id'=>$id])
|
||||
->append(['life_photo','region_desc','province_name','city_name','region_name'])
|
||||
->withoutField('create_time,update_time,delete_time')
|
||||
->order('id desc')
|
||||
->findOrEmpty()
|
||||
->toArray();
|
||||
if($coach){
|
||||
$coach['skill_name'] = Skill::where(['id'=>$coach['skill_id']])->value('name');
|
||||
$goodsLists = Goods::alias('G')
|
||||
->where(['CGI.coach_id'=>$coach['id']])
|
||||
->join('coach_goods_index CGI','G.id=CGI.goods_id')
|
||||
->field('G.id,G.name,G.image')
|
||||
->select()->toArray();
|
||||
$coach['goods_lists'] = $goodsLists;
|
||||
}else{
|
||||
$coach['audit_status'] = '';
|
||||
}
|
||||
|
||||
return $coach;
|
||||
}
|
||||
|
||||
/**
|
||||
* @notes 获取更新资料接口
|
||||
* @param $id
|
||||
* @return array
|
||||
* @author cjhao
|
||||
* @date 2024/11/26 17:36
|
||||
*/
|
||||
public function updateInfoDetail($coachUserId)
|
||||
{
|
||||
$detail = CoachUpdate::where(['coach_user_id'=>$coachUserId])
|
||||
->append(['province_name','city_name','region_name','region_desc','goods_lists'])
|
||||
->order('id desc')->findOrEmpty()->toArray();
|
||||
|
||||
if(empty($detail)){
|
||||
|
||||
$detail = $this->detail($coachUserId);
|
||||
$detail['audit_status'] = '';
|
||||
$detail['audit_remark'] = '';
|
||||
|
||||
$goodsLists = $detail['goods_lists'] ?? [];
|
||||
$lifePhoto = $detail['life_photo']->toArray() ?? [];
|
||||
if($goodsLists) {
|
||||
$detail['goods_ids'] = array_column($goodsLists,'id');
|
||||
}
|
||||
if($lifePhoto) {
|
||||
$detail['life_photo'] = array_column($lifePhoto,'uri');
|
||||
}
|
||||
}
|
||||
if($detail['goods_ids']){
|
||||
foreach ($detail['goods_ids'] as $key => $val){
|
||||
$detail['goods_ids'][$key] = intval($val);
|
||||
}
|
||||
}
|
||||
|
||||
return $detail;
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 技师资料更新
|
||||
* @param array $params
|
||||
* @return string|true
|
||||
* @author cjhao
|
||||
* @date 2024/8/28 10:16
|
||||
*/
|
||||
public function updateInfo(array $params)
|
||||
{
|
||||
try {
|
||||
if(empty($params['coach_user_id'])){
|
||||
throw new Exception('您技师申请在审核中,暂时不允许修改资料');
|
||||
}
|
||||
// Db::startTrans();
|
||||
$coachUpdate = CoachUpdate::where(['coach_id'=>$params['coach_id'],'audit_status'=>CoachEnum::AUDIT_STATUS_WAIT])
|
||||
->findOrEmpty();
|
||||
if(!$coachUpdate->isEmpty()){
|
||||
throw new Exception( '您提交资料正在审核中,请勿重复提交');
|
||||
}
|
||||
$coachUpdate = (new CoachUpdate());
|
||||
$coachUpdate->coach_id = $params['coach_id'];
|
||||
$coachUpdate->coach_user_id = $params['coach_user_id'];
|
||||
$coachUpdate->name = $params['name'];
|
||||
$coachUpdate->gender = $params['gender'];
|
||||
$coachUpdate->age = $params['age'];
|
||||
$coachUpdate->id_card = $params['id_card'];
|
||||
$coachUpdate->mobile = $params['mobile'];
|
||||
$coachUpdate->education = $params['education'];
|
||||
$coachUpdate->nation = $params['nation'];
|
||||
$coachUpdate->province_id = $params['province_id'];
|
||||
$coachUpdate->city_id = $params['city_id'];
|
||||
$coachUpdate->region_id = $params['region_id'];
|
||||
$coachUpdate->longitude = $params['longitude'];
|
||||
$coachUpdate->latitude = $params['latitude'];
|
||||
$coachUpdate->address_detail = $params['address_detail'];
|
||||
$coachUpdate->skill_id = $params['skill_id'];
|
||||
$coachUpdate->id_card_front = $params['id_card_front'];
|
||||
$coachUpdate->id_card_back = $params['id_card_back'];
|
||||
$coachUpdate->portrait_shooting = $params['portrait_shooting'];
|
||||
$coachUpdate->work_photo = $params['work_photo'];
|
||||
$coachUpdate->certification = $params['certification'] ?? '';
|
||||
$coachUpdate->health_certificate = $params['health_certificate'] ?? '';
|
||||
// $coachUpdate->work_status = $params['work_status'];
|
||||
// $coachUpdate->server_status = $params['server_status'];
|
||||
|
||||
$lifePhoto = $params['life_photo'] ?? [];
|
||||
foreach ($lifePhoto as $key => $photo){
|
||||
$lifePhoto[$key] = FileService::setFileUrl($photo);
|
||||
}
|
||||
$lifePhoto = implode(',',$lifePhoto);
|
||||
$goodsIds = $params['goods_ids'] ?? [];
|
||||
$goodsIds = implode(',',$goodsIds);
|
||||
$coachUpdate->life_photo = $lifePhoto;
|
||||
$coachUpdate->goods_ids = $goodsIds;
|
||||
$coachUpdate->save();
|
||||
// Db::commit();
|
||||
|
||||
return true;
|
||||
} catch (Exception $e) {
|
||||
// Db::rollback();
|
||||
return $e->getMessage();
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @notes 地址解析(地址转坐标)
|
||||
* @param $get
|
||||
* @return array|mixed
|
||||
* @author ljj
|
||||
* @date 2022/10/13 12:06 下午
|
||||
* 本接口提供由文字地址到经纬度的转换能力,并同时提供结构化的省市区地址信息。
|
||||
*/
|
||||
public static function updateLocation($get,$coachId)
|
||||
{
|
||||
try {
|
||||
$coach = Coach::where(['id'=>$coachId])->findOrEmpty();
|
||||
if($coach->isEmpty()){
|
||||
return true;
|
||||
// throw new Exception('请先申请成为技师');
|
||||
}
|
||||
$key = (new TencentMapKeyService())->getTencentMapKey();
|
||||
if ($key == '') {
|
||||
throw new Exception('请联系管理员检查腾讯地图配置');
|
||||
}
|
||||
$data = [
|
||||
'key' => $key,
|
||||
'location' => $get['latitude'].','.$get['longitude']
|
||||
];
|
||||
$query = http_build_query($data);
|
||||
$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);
|
||||
}
|
||||
}
|
||||
$data = $result['result']['address_component'];
|
||||
$coach->longitude_location = $get['longitude'];
|
||||
$coach->latitude_location = $get['latitude'];
|
||||
$coach->location = $data;
|
||||
$coach->save();
|
||||
|
||||
return true;
|
||||
|
||||
}catch (\Exception $e){
|
||||
return $e->getMessage();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 更新工作状态
|
||||
* @param $coachId
|
||||
* @return true
|
||||
* @author cjhao
|
||||
* @date 2024/8/29 16:33
|
||||
*/
|
||||
public function updateWorkStatus($coachId)
|
||||
{
|
||||
$coach = Coach::where(['id'=>$coachId])->findOrEmpty();
|
||||
$coach->work_status = $coach->work_status ? 0 : 1;
|
||||
$coach->save();
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @notes 获取技师服务时间
|
||||
* @param $coachId
|
||||
* @return array
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
* @author cjhao
|
||||
* @date 2024/9/2 16:15
|
||||
*/
|
||||
public function getServerTime($coachId)
|
||||
{
|
||||
$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($coachId);
|
||||
//师傅空闲时间
|
||||
$serverTimeLists = [];
|
||||
//师傅忙碌时间
|
||||
$serverTimeBusyLists = [];
|
||||
$coachServerTime = CoachServerTime::where(['coach_id'=>$coachId])
|
||||
->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;
|
||||
}
|
||||
|
||||
/**
|
||||
* @notes 设置服务时间
|
||||
* @param $params
|
||||
* @param $coachId
|
||||
* @return string|true
|
||||
* @author cjhao
|
||||
* @date 2024/9/3 16:39
|
||||
*/
|
||||
public function setServerTime($params,$coachId)
|
||||
{
|
||||
try {
|
||||
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' => $coachId,
|
||||
'date' => $time['time_date'],
|
||||
'time' => $timeList['time'],
|
||||
'status' => $timeList['status']
|
||||
];
|
||||
$times[] = $timeList['time'];
|
||||
}
|
||||
}
|
||||
CoachServerTime::where(['coach_id'=>$coachId])->delete();
|
||||
(new CoachServerTime())->saveAll($serverTime);
|
||||
|
||||
Db::commit();
|
||||
return true;
|
||||
} catch (Exception $e) {
|
||||
Db::rollback();
|
||||
return $e->getMessage();
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @notes 个人资料
|
||||
* @param $coachId
|
||||
* @return array
|
||||
* @author ljj
|
||||
* @date 2024/12/3 下午3:47
|
||||
*/
|
||||
public function personalData($coachId)
|
||||
{
|
||||
$detail = Coach::alias('c')
|
||||
->join('coach_user cu', 'cu.id = c.coach_user_id')
|
||||
->where(['c.id'=>$coachId])
|
||||
->field('c.id,cu.sn,c.work_photo,c.name,c.gender,c.age,c.mobile,c.introduction')
|
||||
->findOrEmpty()
|
||||
->toArray();
|
||||
$detail['gender_desc'] = CoachUserEnum::getSexDesc($detail['gender']);
|
||||
|
||||
return $detail;
|
||||
}
|
||||
|
||||
/**
|
||||
* @notes 设置个人资料
|
||||
* @param $params
|
||||
* @return bool
|
||||
* @author ljj
|
||||
* @date 2024/12/3 下午3:57
|
||||
*/
|
||||
public static function setPersonalData($params): bool
|
||||
{
|
||||
Coach::update(['id' => $params['coach_id'], $params['field'] => $params['value']]);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 绑定手机号
|
||||
* @param $params
|
||||
* @return bool
|
||||
* @author Tab
|
||||
* @date 2021/8/25 17:55
|
||||
*/
|
||||
public static function bindMobile($params)
|
||||
{
|
||||
try {
|
||||
if (empty($params['mobile']) || empty($params['code'])) {
|
||||
throw new \Exception('请输入手机号和验证码');
|
||||
}
|
||||
|
||||
$smsDriver = new SmsDriver();
|
||||
$result = $smsDriver->verify($params['mobile'], $params['code']);
|
||||
if(!$result) {
|
||||
throw new \Exception('验证码错误');
|
||||
}
|
||||
$user = Coach::where(['mobile'=>$params['mobile']])->where('id','<>',$params['coach_id'])->findOrEmpty();
|
||||
if(!$user->isEmpty()) {
|
||||
throw new \Exception('该手机号已被其他账号绑定');
|
||||
}
|
||||
$user = CoachUpdate::where(['coach_id'=>$params['coach_id']])->where(['mobile'=>$params['mobile'],'audit_status'=>ShopEnum::AUDIT_STATUS_WAIT])->where('id','<>',$params['coach_id'])->findOrEmpty();
|
||||
if(!$user->isEmpty()) {
|
||||
throw new \Exception('该手机号已被其他账号绑定');
|
||||
}
|
||||
unset($params['code']);
|
||||
$coach = Coach::findOrEmpty($params['coach_id'])->toArray();
|
||||
Coach::update(['mobile'=>$params['mobile'],'id'=>$params['coach_id']]);
|
||||
CoachUser::update(['account'=>$params['mobile'],'id'=>$coach['coach_user_id']]);
|
||||
return true;
|
||||
} catch (\Exception $e) {
|
||||
return $e->getMessage();
|
||||
}
|
||||
}
|
||||
}
|
||||
138
server/app/coachapi/logic/ConfigLogic.php
Executable file
138
server/app/coachapi/logic/ConfigLogic.php
Executable file
@@ -0,0 +1,138 @@
|
||||
<?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\coachapi\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'),
|
||||
//名称
|
||||
'name' => ConfigService::get('coach', 'name',''),
|
||||
//logo
|
||||
'logo' => FileService::getFileUrl(ConfigService::get('coach', 'logo','')),
|
||||
//地图key
|
||||
'tencent_map_key' => ConfigService::get('map','tencent_map_key',''),
|
||||
|
||||
//版本号
|
||||
'version' => request()->header('version'),
|
||||
//默认头像
|
||||
'default_avatar' => ConfigService::get('config', 'default_coach_avatar', FileService::getFileUrl(config('project.default_image.user_avatar'))),
|
||||
//文件域名
|
||||
'domain' => request()->domain().'/',
|
||||
//联系客服
|
||||
'service_mobile' => ConfigService::get('platform', 'service_mobile',''),
|
||||
//网站名称
|
||||
'web_name' => ConfigService::get('platform_logo', 'platform_name',''),
|
||||
//网站logo
|
||||
'web_logo' => FileService::getFileUrl(ConfigService::get('platform_logo', 'platform_logo')),
|
||||
//商城名称
|
||||
'shop_name' => ConfigService::get('coach', 'coach_name',''),
|
||||
//商城logo
|
||||
'shop_logo' => FileService::getFileUrl(ConfigService::get('coach', 'coach_logo','')),
|
||||
|
||||
];
|
||||
return $config;
|
||||
}
|
||||
|
||||
/**
|
||||
* @notes 政策协议
|
||||
* @return array
|
||||
* @author ljj
|
||||
* @date 2022/2/23 11:42 上午
|
||||
*/
|
||||
public function agreement()
|
||||
{
|
||||
$service = TextList::where(['id'=>3])->field('title,content')->findOrEmpty();
|
||||
$privacy = TextList::where(['id'=>4])->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;
|
||||
}
|
||||
}
|
||||
54
server/app/coachapi/logic/DecorateLogic.php
Executable file
54
server/app/coachapi/logic/DecorateLogic.php
Executable file
@@ -0,0 +1,54 @@
|
||||
<?php
|
||||
namespace app\coachapi\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 $type
|
||||
* @return array
|
||||
* @author cjhao
|
||||
* @date 2024/10/8 15:11
|
||||
*/
|
||||
public function page(int $type)
|
||||
{
|
||||
$detail = DecoratePage::where(['type'=>$type,'source'=>2])->findOrEmpty()->toArray();
|
||||
return $detail;
|
||||
}
|
||||
|
||||
/**
|
||||
* @notes 获取装修风格
|
||||
* @return array
|
||||
* @author cjhao
|
||||
* @date 2024/10/8 15:13
|
||||
*/
|
||||
public function style()
|
||||
{
|
||||
$detail = DecorateStyle::where(['source'=>2])->findOrEmpty()->toArray();
|
||||
return $detail;
|
||||
}
|
||||
|
||||
/**
|
||||
* @notes 底部菜单
|
||||
* @return array
|
||||
* @author cjhao
|
||||
* @date 2024/10/8 15:59
|
||||
*/
|
||||
public function tabbar()
|
||||
{
|
||||
$detail = DecorateTabbar::where(['source'=>2])->findOrEmpty()->toArray();
|
||||
return $detail;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
83
server/app/coachapi/logic/DepositLogic.php
Executable file
83
server/app/coachapi/logic/DepositLogic.php
Executable file
@@ -0,0 +1,83 @@
|
||||
<?php
|
||||
namespace app\coachapi\logic;
|
||||
use app\common\enum\coach\CoachEnum;
|
||||
use app\common\logic\BaseLogic;
|
||||
use app\common\model\coach\Coach;
|
||||
use app\common\model\deposit\DepositOrder;
|
||||
use app\common\model\deposit\DepositPackage;
|
||||
use app\common\model\order\OrderAppend;
|
||||
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($coachUserId)
|
||||
{
|
||||
$deposit = Coach::where(['coach_user_id'=>$coachUserId,'audit_status'=>CoachEnum::AUDIT_STATUS_PASS])->order('id desc')->value('deposit');
|
||||
$packageLists = DepositPackage::where(['type'=>1])
|
||||
->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 $coachId
|
||||
* @return array|bool
|
||||
* @author cjhao
|
||||
* @date 2024/8/27 18:52
|
||||
*/
|
||||
public function sumbitOrder(array $params,int $coachId)
|
||||
{
|
||||
try {
|
||||
$money = $params['money'] ?? 0;
|
||||
$payWay = $params['pay_way'] ?? 0;
|
||||
if(empty($coachId)){
|
||||
return '请先申请成为技师';
|
||||
}
|
||||
if($money <= 0){
|
||||
throw new Exception('充值金额不能小于零');
|
||||
}
|
||||
if(empty($payWay)){
|
||||
throw new Exception('请选择支付方式');
|
||||
}
|
||||
$depositOrder = DepositOrder::create([
|
||||
'sn' => generate_sn((new DepositOrder()), 'sn'),
|
||||
'order_amount' => $money,
|
||||
'relation_id' => $coachId,
|
||||
'pay_way' => $payWay,
|
||||
]);
|
||||
return [
|
||||
'id' => $depositOrder->id,
|
||||
'sn' => $depositOrder->sn,
|
||||
'type' => 'deposit'
|
||||
];
|
||||
|
||||
}catch (Exception $e) {
|
||||
self::$error = $e->getMessage();
|
||||
return false;
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
64
server/app/coachapi/logic/GoodsCommentLogic.php
Executable file
64
server/app/coachapi/logic/GoodsCommentLogic.php
Executable file
@@ -0,0 +1,64 @@
|
||||
<?php
|
||||
namespace app\coachapi\logic;
|
||||
use app\common\model\goods\GoodsComment;
|
||||
|
||||
class GoodsCommentLogic
|
||||
{
|
||||
|
||||
public function commentCategory(int $coachId)
|
||||
{
|
||||
|
||||
$all_count = GoodsComment::where('coach_id', $coachId)->count();
|
||||
$image_count = GoodsComment::alias('gc')->where('coach_id',$coachId)->join('goods_comment_image gci', 'gc.id = gci.comment_id')->group('gci.comment_id')->count();
|
||||
$good_count = GoodsComment::where('coach_id', $coachId)->where('service_comment','>',3)->count();
|
||||
$medium_bad_count = GoodsComment::where('coach_id', $coachId)->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,
|
||||
];
|
||||
}
|
||||
}
|
||||
59
server/app/coachapi/logic/GoodsLogic.php
Executable file
59
server/app/coachapi/logic/GoodsLogic.php
Executable file
@@ -0,0 +1,59 @@
|
||||
<?php
|
||||
namespace app\coachapi\logic;
|
||||
use app\common\model\goods\Goods;
|
||||
use app\common\model\goods\GoodsCityIndex;
|
||||
use app\common\model\goods\GoodsSkillIndex;
|
||||
use app\common\model\skill\Skill;
|
||||
|
||||
/**
|
||||
* 服务逻辑类
|
||||
* Class GoodsLogic
|
||||
* @package app\coachapi\logic
|
||||
*/
|
||||
class GoodsLogic
|
||||
{
|
||||
|
||||
|
||||
/**
|
||||
* @notes 获取技能列表
|
||||
* @return mixed
|
||||
* @author cjhao
|
||||
* @date 2024/10/13 00:25
|
||||
*/
|
||||
public function skillLists($coachId)
|
||||
{
|
||||
$lists = Skill::alias('S')
|
||||
->join('coach C','S.id = C.skill_id')
|
||||
->where(['C.id'=>$coachId])
|
||||
->field('S.id,S.name')
|
||||
->select()->toArray();
|
||||
array_unshift($lists,['id'=>0,'name'=>'全部']);
|
||||
return $lists;
|
||||
}
|
||||
|
||||
/**
|
||||
* @notes 商品详情
|
||||
* @param $id
|
||||
* @return array
|
||||
* @author cjhao
|
||||
* @date 2024/11/27 14:41
|
||||
*/
|
||||
public function detail($id)
|
||||
{
|
||||
$result = Goods::where('id',$id)
|
||||
->withoutField('update_time,delete_time')
|
||||
->append(['category_desc','goods_image'])
|
||||
->findOrEmpty()
|
||||
->toArray();
|
||||
$result['virtual_order_num'] = $result['virtual_order_num'] + $result['order_num'];
|
||||
$goods_image = [];
|
||||
foreach ($result['goods_image'] as &$image) {
|
||||
$goods_image[] = $image['uri'];
|
||||
}
|
||||
$result['goods_image'] = $goods_image;
|
||||
$result['skill_id'] = GoodsSkillIndex::where(['goods_id'=>$id])->column('skill_id');
|
||||
return $result;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
11
server/app/coachapi/logic/IndexLogic.php
Executable file
11
server/app/coachapi/logic/IndexLogic.php
Executable file
@@ -0,0 +1,11 @@
|
||||
<?php
|
||||
namespace app\coachapi\logic;
|
||||
use app\common\logic\BaseLogic;
|
||||
use app\common\model\coach\Coach;
|
||||
use app\common\service\ConfigService;
|
||||
use think\Exception;
|
||||
|
||||
class IndexLogic extends BaseLogic
|
||||
{
|
||||
|
||||
}
|
||||
445
server/app/coachapi/logic/LoginLogic.php
Executable file
445
server/app/coachapi/logic/LoginLogic.php
Executable file
@@ -0,0 +1,445 @@
|
||||
<?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\coachapi\logic;
|
||||
|
||||
use app\coachapi\service\CoachUserTokenService;
|
||||
use app\coachapi\service\ShopUserTokenService;
|
||||
use app\common\enum\coach\CoachEnum;
|
||||
use app\common\enum\notice\NoticeEnum;
|
||||
use app\common\logic\BaseLogic;
|
||||
use app\common\model\coach\Coach;
|
||||
use app\common\model\coach\CoachUser;
|
||||
use app\common\service\{ConfigService, FileService, sms\SmsDriver, WeChatService};
|
||||
use think\facade\{Db, Config};
|
||||
use 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_STAFF);
|
||||
if (!$result) {
|
||||
throw new Exception('验证码错误');
|
||||
}
|
||||
$number = CoachUser::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');
|
||||
|
||||
CoachUser::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']];
|
||||
|
||||
$coachUser = CoachUser::where($where)->findOrEmpty();
|
||||
if ($coachUser->isEmpty()) {
|
||||
throw new \Exception('账号不存在');
|
||||
}
|
||||
|
||||
//更新登录信息
|
||||
$coachUser->login_time = time();
|
||||
$coachUser->login_ip = request()->ip();
|
||||
$coachUser->save();
|
||||
|
||||
//设置token
|
||||
$coachUserInfo = CoachUserTokenService::setToken($coachUser->id, $params['terminal']);
|
||||
|
||||
//返回登录信息
|
||||
$avatar = $coachUser->avatar ?: Config::get('project.default_image.user_avatar');
|
||||
$avatar = FileService::getFileUrl($avatar);
|
||||
// $coach = Coach::where(['coach_user_id'=>$coachUser->id])->order('id desc')->findOrEmpty();
|
||||
// if(!$coach->isEmpty()){
|
||||
// $avatar = $coach->work_photo;
|
||||
// }
|
||||
return [
|
||||
'sn' => $coachUserInfo['sn'],
|
||||
'account' => $coachUserInfo['account'],
|
||||
'avatar' => $avatar,
|
||||
'token' => $coachUserInfo['token'],
|
||||
];
|
||||
} catch (\Exception $e) {
|
||||
self::setError($e->getMessage());
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 退出登录
|
||||
* @param $userInfo
|
||||
* @return bool
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
* @author 段誉
|
||||
* @date 2022/9/16 17:56
|
||||
*/
|
||||
public static function logout($coachInfo)
|
||||
{
|
||||
//token不存在,不注销
|
||||
if (!isset($coachInfo['token'])) {
|
||||
return false;
|
||||
}
|
||||
|
||||
//设置token过期
|
||||
return CoachUserTokenService::expireToken($coachInfo['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_STAFF)) {
|
||||
throw new \Exception('验证码错误');
|
||||
}
|
||||
|
||||
// 重置密码
|
||||
$passwordSalt = Config::get('project.unique_identification');
|
||||
$password = create_password($params['password'], $passwordSalt);
|
||||
$coachUser = CoachUser::where(['account'=>$params['mobile']])->findOrEmpty();
|
||||
if($coachUser->isEmpty()){
|
||||
throw new \Exception('账号不存在');
|
||||
}
|
||||
// 更新
|
||||
$coachUser->password = $password;
|
||||
$coachUser->save();
|
||||
// Coach::where(['coach_user_id'=>$coachUser->id,'audit_status'=>CoachEnum::AUDIT_STATUS_PASS])->update([
|
||||
// 'mobile' => $params['mobile']
|
||||
// ]);
|
||||
// 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 {
|
||||
// Db::startTrans();
|
||||
// 重置密码
|
||||
$passwordSalt = Config::get('project.unique_identification');
|
||||
$password = create_password($params['password'], $passwordSalt);
|
||||
$coachUser = CoachUser::where(['id'=>$params['coach_info']['coach_user_id']])->findOrEmpty();
|
||||
// if($coachUser->isEmpty()){
|
||||
// throw new \Exception('账号不存在');
|
||||
// }
|
||||
// 更新
|
||||
$coachUser->password = $password;
|
||||
$coachUser->save();
|
||||
// Db::commit();
|
||||
return true;
|
||||
} catch (\Exception $e) {
|
||||
// Db::rollback();
|
||||
self::setError($e->getMessage());
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
366
server/app/coachapi/logic/OrderLogic.php
Executable file
366
server/app/coachapi/logic/OrderLogic.php
Executable file
@@ -0,0 +1,366 @@
|
||||
<?php
|
||||
namespace app\coachapi\logic;
|
||||
use app\common\enum\notice\NoticeEnum;
|
||||
use app\common\enum\OrderEnum;
|
||||
use app\common\enum\OrderLogEnum;
|
||||
use app\common\logic\BaseLogic;
|
||||
use app\common\logic\OrderLogLogic;
|
||||
use app\common\model\coach\Coach;
|
||||
use app\common\model\order\Order;
|
||||
use app\common\model\order\OrderLog;
|
||||
use app\common\model\settle\SettleOrder;
|
||||
use app\common\service\ConfigService;
|
||||
use app\common\service\FileService;
|
||||
use app\common\service\TencentMapKeyService;
|
||||
use think\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,user_remark,pay_status,pay_way,total_refund_amount,goods_price,order_amount,total_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','pay_way_desc','appoint_time','appoint_date','order_status_desc','take_order_btn','depart_btn','arrive_btn','server_start_btn','server_finish_btn','order_cancel_time'])
|
||||
->with(['order_goods' => function($query){
|
||||
$query->field('order_id,goods_id,goods_snap,goods_num,duration,goods_image,goods_name,goods_price')->hidden(['goods_snap']);
|
||||
},'order_gap','order_append'])
|
||||
->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')
|
||||
->order('id asc')
|
||||
->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();
|
||||
}
|
||||
$coachCommission = $settleOrder['coach_commission'] ?? 0;
|
||||
$coachCarCommission = $settleOrder['coach_car_amount'] ?? 0;
|
||||
// $totalOrderAmount = $settleOrder['order_amount'] ?? 0;
|
||||
// $carAmount = $settleOrder['car_amount'] ?? 0;
|
||||
$detail['settle_info'] = [
|
||||
'status' => $detail['is_settle'],
|
||||
'refund_amount' => $detail['total_refund_amount'],
|
||||
'order_amount' => $settleOrder['order_amount'] ?? 0,
|
||||
'settle_car' => $settleOrder['car_amount'] ?? 0 ,
|
||||
'settle_amount' => $settleOrder['total_commission'] ?? 0 ,
|
||||
'coach_settle' => $settleOrder['coach_commission'] ?? 0,
|
||||
'shop_settle' => 0,
|
||||
// 'total_settle_amount'=> round($totalOrderAmount + $carAmount ,2),
|
||||
];
|
||||
$detail['server_log_lists'] = $logLists;
|
||||
|
||||
return $detail;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 接单操作
|
||||
* @param $params
|
||||
* @return bool
|
||||
* @author cjhao
|
||||
* @date 2024/9/13 17:21
|
||||
*/
|
||||
public function take($params)
|
||||
{
|
||||
try {
|
||||
Db::startTrans();
|
||||
$order = Order::where(['id'=>$params['id'],'coach_id'=>$params['coach_id']])
|
||||
->findOrEmpty();
|
||||
|
||||
if($order->isEmpty()){
|
||||
throw new Exception('订单不存在');
|
||||
}
|
||||
if(OrderEnum::ORDER_STATUS_WAIT_RECEIVING != $order->order_status){
|
||||
throw new Exception('订单状态已改变,请刷新页面');
|
||||
}
|
||||
$coach = Coach::where(['id'=>$params['coach_id']])->findOrEmpty();
|
||||
//验证接单数量
|
||||
\app\common\logic\CoachLogic::ckechCoachTakeOrderNum($coach);
|
||||
$order->order_status = OrderEnum::ORDER_STATUS_WAIT_DEPART;
|
||||
$order->save();
|
||||
|
||||
//订单日志
|
||||
(new OrderLogLogic())->record(OrderLogEnum::TYPE_COACH,OrderLogEnum::COACH_TAKE_ORDER,$order['id'],$params['coach_id']);
|
||||
event('Notice', [
|
||||
'scene_id' => NoticeEnum::ACCEPT_ORDER_NOTICE,
|
||||
'params' => [
|
||||
'user_id' => $order['user_id'],
|
||||
'order_id' => $order['id']
|
||||
]
|
||||
]);
|
||||
//提交事务
|
||||
Db::commit();
|
||||
return true;
|
||||
}catch (Exception $e) {
|
||||
Db::rollback();
|
||||
self::$error = $e->getMessage();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 出发操作
|
||||
* @param $params
|
||||
* @return bool
|
||||
* @author cjhao
|
||||
* @date 2024/9/13 17:21
|
||||
*/
|
||||
public function depart($params)
|
||||
{
|
||||
try {
|
||||
Db::startTrans();
|
||||
|
||||
$order = Order::where(['id'=>$params['id'],'coach_id'=>$params['coach_id']])
|
||||
->findOrEmpty();
|
||||
if($order->isEmpty()){
|
||||
throw new Exception('订单不存在');
|
||||
}
|
||||
if(OrderEnum::ORDER_STATUS_WAIT_DEPART != $order->order_status){
|
||||
throw new Exception('订单状态已改变,请刷新页面');
|
||||
}
|
||||
$order->order_status = OrderEnum::ORDER_STATUS_DEPART;
|
||||
$order->save();
|
||||
//订单日志
|
||||
(new OrderLogLogic())->record(OrderLogEnum::TYPE_COACH,OrderLogEnum::COACH_DEPART,$order['id'],$params['coach_id']);
|
||||
|
||||
//提交事务
|
||||
Db::commit();
|
||||
return true;
|
||||
}catch (Exception $e) {
|
||||
Db::rollback();
|
||||
self::$error = $e->getMessage();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 达到操作
|
||||
* @param $params
|
||||
* @return bool
|
||||
* @author cjhao
|
||||
* @date 2024/9/13 17:21
|
||||
*/
|
||||
public function arrive($params)
|
||||
{
|
||||
try {
|
||||
$imageLists = $params['image_lists'] ?? [];
|
||||
if(empty($imageLists)){
|
||||
throw new Exception('请上传图片');
|
||||
}
|
||||
Db::startTrans();
|
||||
if (!isset($params['latitude']) || $params['longitude'] == '') {
|
||||
throw new Exception('请上传位置');
|
||||
}
|
||||
|
||||
$order = Order::where(['id'=>$params['id'],'coach_id'=>$params['coach_id']])
|
||||
->findOrEmpty();
|
||||
if($order->isEmpty()){
|
||||
throw new Exception('订单不存在');
|
||||
}
|
||||
if(OrderEnum::ORDER_STATUS_DEPART != $order->order_status){
|
||||
throw new Exception('订单状态已改变,请刷新页面');
|
||||
}
|
||||
$order->order_status = OrderEnum::ORDER_STATUS_ARRIVE;
|
||||
$order->save();
|
||||
$key = (new TencentMapKeyService())->getTencentMapKey();
|
||||
if (empty($key)) {
|
||||
throw new Exception('请联系管理员检查腾讯地图配置');
|
||||
}
|
||||
$data['location'] = $params['latitude'].','.$params['longitude'];
|
||||
$data['key'] = $key;
|
||||
$url = 'https://apis.map.qq.com/ws/geocoder/v1/';
|
||||
$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);
|
||||
}
|
||||
}
|
||||
$data = [];
|
||||
$data = $result['result']['address_component'];
|
||||
$data['longitude'] = $params['longitude'];
|
||||
$data['latitude'] = $params['latitude'];
|
||||
foreach($imageLists as $key => $image){
|
||||
$imageLists[$key] = FileService::setFileUrl($image);
|
||||
}
|
||||
//订单日志
|
||||
(new OrderLogLogic())->record(OrderLogEnum::TYPE_COACH,OrderLogEnum::COACH_ARRIVE,$order['id'],$params['coach_id'],'',$data,$imageLists);
|
||||
//提交事务
|
||||
Db::commit();
|
||||
return true;
|
||||
}catch (Exception $e) {
|
||||
Db::rollback();
|
||||
self::$error = $e->getMessage();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @notes 服务开始操作
|
||||
* @param $params
|
||||
* @return bool
|
||||
* @author cjhao
|
||||
* @date 2024/9/13 17:21
|
||||
*/
|
||||
public function startServer($params)
|
||||
{
|
||||
try {
|
||||
Db::startTrans();
|
||||
$order = Order::where(['id'=>$params['id'],'coach_id'=>$params['coach_id']])
|
||||
->findOrEmpty();
|
||||
if($order->isEmpty()){
|
||||
throw new Exception('订单不存在');
|
||||
}
|
||||
if(OrderEnum::ORDER_STATUS_ARRIVE != $order->order_status){
|
||||
throw new Exception('订单状态已改变,请刷新页面');
|
||||
}
|
||||
$order->order_status = OrderEnum::ORDER_STATUS_START_SERVER;
|
||||
$order->save();
|
||||
//订单日志
|
||||
(new OrderLogLogic())->record(OrderLogEnum::TYPE_COACH,OrderLogEnum::COACH_START_SERVER,$order['id'],$params['coach_id']);
|
||||
//开始服务通知用户
|
||||
event('Notice', [
|
||||
'scene_id' => NoticeEnum::START_SERVICE_NOTICE,
|
||||
'params' => [
|
||||
'user_id' => $order['user_id'],
|
||||
'order_id' => $order['id']
|
||||
]
|
||||
]);
|
||||
//开始服务通知师傅
|
||||
event('Notice', [
|
||||
'scene_id' => NoticeEnum::START_SERVICE_NOTICE_STAFF,
|
||||
'params' => [
|
||||
'coach_id' => $order['coach_id'],
|
||||
'order_id' => $order['id']
|
||||
]
|
||||
]);
|
||||
//提交事务
|
||||
Db::commit();
|
||||
return true;
|
||||
}catch (Exception $e) {
|
||||
Db::rollback();
|
||||
self::$error = $e->getMessage();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 服务完成
|
||||
* @param $params
|
||||
* @return bool
|
||||
* @author cjhao
|
||||
* @date 2024/9/14 14:52
|
||||
*/
|
||||
public function finishServer($params)
|
||||
{
|
||||
try {
|
||||
$order = Order::where(['id'=>$params['id'],'coach_id'=>$params['coach_id']])
|
||||
->findOrEmpty();
|
||||
Coach::update(['order_num'=>['inc',1]],['id'=>$order['coach_id']]);
|
||||
Db::startTrans();
|
||||
$imageLists = $params['image_lists'] ?? [];
|
||||
if(empty($imageLists)){
|
||||
throw new Exception('请上传图片');
|
||||
}
|
||||
if($order->isEmpty()){
|
||||
throw new Exception('订单不存在');
|
||||
}
|
||||
if(OrderEnum::ORDER_STATUS_START_SERVER != $order->order_status){
|
||||
throw new Exception('订单状态已改变,请刷新页面');
|
||||
}
|
||||
$order->order_status = OrderEnum::ORDER_STATUS_SERVER_FINISH;
|
||||
$order->true_server_finish_time = time();
|
||||
$order->save();
|
||||
$key = (new TencentMapKeyService())->getTencentMapKey();
|
||||
if (empty($key)) {
|
||||
throw new Exception('请联系管理员检查腾讯地图配置');
|
||||
}
|
||||
$data['location'] = $params['latitude'].','.$params['longitude'];
|
||||
$data['key'] = $key;
|
||||
$url = 'https://apis.map.qq.com/ws/geocoder/v1/';
|
||||
$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);
|
||||
}
|
||||
}
|
||||
$data = [];
|
||||
$data = $result['result']['address_component'];
|
||||
$data['longitude'] = $params['longitude'];
|
||||
$data['latitude'] = $params['latitude'];
|
||||
foreach($imageLists as $key => $image){
|
||||
$imageLists[$key] = FileService::setFileUrl($image);
|
||||
}
|
||||
(new OrderLogLogic())->record(OrderLogEnum::TYPE_COACH,OrderLogEnum::COACH_SERVER_FINISH,$order['id'],$params['coach_id'],'',$data,$imageLists);
|
||||
//完成服务-用户
|
||||
event('Notice', [
|
||||
'scene_id' => NoticeEnum::FINISH_SERVICE_NOTICE,
|
||||
'params' => [
|
||||
'user_id' => $order['user_id'],
|
||||
'order_id' => $order['id']
|
||||
]
|
||||
]);
|
||||
//完成服务-师傅
|
||||
event('Notice', [
|
||||
'scene_id' => NoticeEnum::END_SERVICE_NOTICE_STAFF,
|
||||
'params' => [
|
||||
'coach_id' => $order['coach_id'],
|
||||
'order_id' => $order['id']
|
||||
]
|
||||
]);
|
||||
Coach::update(['order_num'=>['inc',1]],['id'=>$order['coach_id']]);
|
||||
//提交事务
|
||||
Db::commit();
|
||||
return true;
|
||||
}catch (Exception $e) {
|
||||
Db::rollback();
|
||||
self::$error = $e->getMessage();
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
245
server/app/coachapi/logic/PayLogic.php
Executable file
245
server/app/coachapi/logic/PayLogic.php
Executable file
@@ -0,0 +1,245 @@
|
||||
<?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\coachapi\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\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\CoachBalancePayService;
|
||||
use app\common\service\ConfigService;
|
||||
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) {
|
||||
// $user_money = User::where(['id' => $params['user_id']])->value('user_money');
|
||||
// $item['extra'] = '可用余额:'.$user_money;
|
||||
// }
|
||||
// 充值时去除余额支付
|
||||
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 //终端
|
||||
* @param $wechatCode //终端
|
||||
* @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) {
|
||||
CoachPayNotifyLogic::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 CoachBalancePayService());
|
||||
$result = $payService->pay($from, $order);
|
||||
if (false !== $result) {
|
||||
CoachPayNotifyLogic::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;
|
||||
}
|
||||
}
|
||||
207
server/app/coachapi/logic/ShopLogic.php
Executable file
207
server/app/coachapi/logic/ShopLogic.php
Executable file
@@ -0,0 +1,207 @@
|
||||
<?php
|
||||
namespace app\coachapi\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\ShopCategoryIndex;
|
||||
use app\common\model\shop\ShopCoachApply;
|
||||
use app\common\service\sms\SmsDriver;
|
||||
use Exception;
|
||||
use think\facade\Config;
|
||||
use think\facade\Db;
|
||||
|
||||
class ShopLogic extends BaseLogic
|
||||
{
|
||||
|
||||
|
||||
/**
|
||||
* @notes 服务详情
|
||||
* @param int $id
|
||||
* @return array
|
||||
* @author cjhao
|
||||
* @date 2024/10/12 00:27
|
||||
*/
|
||||
public function detail(array $params){
|
||||
|
||||
$detail = Shop::where(['id'=>$params['id'],'audit_status'=>ShopEnum::AUDIT_STATUS_PASS,'server_status'=>ShopEnum::SERVERSTATUSOPEN])
|
||||
->append(['shop_image','category_ids','business_time_desc','province_name','city_name','region_name'])
|
||||
->field('*,round(st_distance_sphere(point('.$params['longitude'].','.$params['latitude'].'),
|
||||
point(longitude, latitude))/1000,2) as distance')
|
||||
->findOrEmpty()
|
||||
->toArray();
|
||||
|
||||
$detail['distance'] = $detail['distance'].'km';
|
||||
|
||||
$categoryLists = ShopCategoryIndex::alias('SC')
|
||||
->where(['shop_id'=>$params['id'],'is_show'=>1])
|
||||
->join('goods_category GC','SC.category_id = GC.id')
|
||||
->column('GC.name');
|
||||
$detail['category_name'] = implode('|',$categoryLists);
|
||||
return $detail;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 门店申请列表
|
||||
* @param array $params
|
||||
* @return bool
|
||||
* @author cjhao
|
||||
* @date 2024/10/14 12:41
|
||||
*/
|
||||
public function applyJoin(array $params)
|
||||
{
|
||||
try{
|
||||
$id = $params['id'] ?? '';
|
||||
if(empty($id)){
|
||||
throw new Exception('请选择门店');
|
||||
}
|
||||
if(empty($params['coach_id'])){
|
||||
throw new Exception('请先申请成为技师');
|
||||
}
|
||||
// Db::startTrans();
|
||||
$coach = Coach::where(['id'=>$params['coach_id']])->findOrEmpty();
|
||||
if($coach->shop_id){
|
||||
throw new Exception('您已加入了门店,请勿再申请');
|
||||
}
|
||||
$shopCoachApply = ShopCoachApply::where(['coach_id'=>$params['coach_id'],'audit_status'=>ShopEnum::AUDIT_STATUS_WAIT])
|
||||
->findOrEmpty();
|
||||
if(!$shopCoachApply->isEmpty()){
|
||||
throw new Exception('您的门店申请正在审核中,请勿再申请');
|
||||
}
|
||||
$shop = Shop::where(['id'=>$params['id']])->findOrEmpty();
|
||||
if($coach['city_id'] != $shop['city_id']){
|
||||
throw new Exception('抱歉,只能添加本地的商家哦');
|
||||
}
|
||||
$shopCoachApply = new ShopCoachApply();
|
||||
$shopCoachApply->coach_id = $params['coach_id'];
|
||||
$shopCoachApply->shop_id = $params['id'];
|
||||
$shopCoachApply->type = 1;
|
||||
$shopCoachApply->audit_status = ShopEnum::AUDIT_STATUS_WAIT;
|
||||
$shopCoachApply->save();
|
||||
//提交事务
|
||||
// Db::commit();
|
||||
return true;
|
||||
}catch (Exception $e) {
|
||||
// Db::rollback();
|
||||
self::$error = $e->getMessage();
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @notes 申请详情
|
||||
* @param $params
|
||||
* @return array
|
||||
* @author cjhao
|
||||
* @date 2024/10/20 03:43
|
||||
*/
|
||||
public function applyDetail($params)
|
||||
{
|
||||
$coachShopId = Coach::where(['id'=>$params['coach_id']])->value('shop_id');
|
||||
$shop = Shop::where(['id'=>$params['id']])
|
||||
->append(['shop_image','category_ids','region_desc','business_time_desc'])
|
||||
->withoutField('update_time,delete_time')
|
||||
->findOrEmpty()->toArray();
|
||||
|
||||
$shop['type'] = '';
|
||||
$shop['audit_remark'] = '';
|
||||
$shop['audit_status'] = '';
|
||||
//分为已经加入商家
|
||||
if($coachShopId){
|
||||
$shopApply = ShopCoachApply::where(['coach_id'=>$params['coach_id'],'shop_id'=>$coachShopId])
|
||||
->order('id desc')
|
||||
->field('shop_id,type,audit_status,audit_remark')
|
||||
->findOrEmpty()
|
||||
->toArray();
|
||||
$shop['audit_status'] = $shopApply['audit_status'];
|
||||
$shop['audit_remark'] = $shopApply['audit_remark'];
|
||||
$shop['type'] = $shopApply['type'];
|
||||
|
||||
}else{
|
||||
//没有加入商家
|
||||
$shopApply = ShopCoachApply::where(['coach_id'=>$params['coach_id'],'shop_id'=>$params['id']])
|
||||
->order('id desc')
|
||||
->field('id,shop_id,type,audit_status,audit_remark')
|
||||
->findOrEmpty()
|
||||
->toArray();
|
||||
$shop['type'] = 1;
|
||||
$shop['audit_status'] = '';
|
||||
$shop['audit_remark'] = '';
|
||||
if($shopApply && 1 == $shopApply['type'] && (ShopEnum::AUDIT_STATUS_REFUSE == $shopApply['audit_status'] || ShopEnum::AUDIT_STATUS_WAIT == $shopApply['audit_status'])){
|
||||
$shop['audit_status'] = $shopApply['audit_status'];
|
||||
$shop['audit_remark'] = $shopApply['audit_remark'];
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
return $shop;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @notes 取消
|
||||
* @param array $params
|
||||
* @return bool|string
|
||||
* @author cjhao
|
||||
* @date 2024/10/20 23:09
|
||||
*/
|
||||
public function cancel($params){
|
||||
$id = $params['id'] ?? '';
|
||||
if(empty($id)){
|
||||
return '请选择商家';
|
||||
}
|
||||
$shopCoachApply = ShopCoachApply::where(['coach_id'=>$params['coach_id'],'shop_id'=>$params['id']])
|
||||
->order('id desc')
|
||||
->findOrEmpty();
|
||||
if($shopCoachApply->isEmpty()){
|
||||
return '你未申请该商家';
|
||||
}
|
||||
if(ShopEnum::AUDIT_STATUS_WAIT != $shopCoachApply->audit_status){
|
||||
return '商家审核状态已改变';
|
||||
}
|
||||
$shopCoachApply->audit_status = ShopEnum::AUDIT_STATUS_CANCEL;
|
||||
$shopCoachApply->save();
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @notes 申请退出
|
||||
* @param int $coachId
|
||||
* @return bool
|
||||
* @author cjhao
|
||||
* @date 2024/11/17 12:57
|
||||
*/
|
||||
public function applyQuit(int $coachId){
|
||||
try{
|
||||
|
||||
// Db::startTrans();
|
||||
$coach = Coach::where(['id'=>$coachId])->findOrEmpty();
|
||||
if(0 == $coach->shop_id){
|
||||
throw new Exception('您未申请门店');
|
||||
}
|
||||
$shopCoachApply = ShopCoachApply::where(['coach_id'=>$coachId,'audit_status'=>ShopEnum::AUDIT_STATUS_WAIT,'type'=>2])
|
||||
->findOrEmpty();
|
||||
if(!$shopCoachApply->isEmpty()){
|
||||
throw new Exception('您的退出请求正在审核中,请勿再申请');
|
||||
}
|
||||
$shopCoachApply = new ShopCoachApply();
|
||||
$shopCoachApply->coach_id = $coachId;
|
||||
$shopCoachApply->shop_id = $coach->shop_id;
|
||||
$shopCoachApply->type = 2;
|
||||
$shopCoachApply->audit_status = ShopEnum::AUDIT_STATUS_WAIT;
|
||||
$shopCoachApply->save();
|
||||
//提交事务
|
||||
// Db::commit();
|
||||
return true;
|
||||
}catch (Exception $e) {
|
||||
// Db::rollback();
|
||||
self::$error = $e->getMessage();
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
60
server/app/coachapi/logic/SmsLogic.php
Executable file
60
server/app/coachapi/logic/SmsLogic.php
Executable 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\coachapi\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::getSceneByCoachTag($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;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
78
server/app/coachapi/logic/WechatLogic.php
Executable file
78
server/app/coachapi/logic/WechatLogic.php
Executable file
@@ -0,0 +1,78 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | LikeShop有特色的全开源社交分销电商系统
|
||||
// +----------------------------------------------------------------------
|
||||
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
|
||||
// | 商业用途务必购买系统授权,以免引起不必要的法律纠纷
|
||||
// | 禁止对系统程序代码以任何目的,任何形式的再发布
|
||||
// | 微信公众号:好象科技
|
||||
// | 访问官网:http://www.likemarket.net
|
||||
// | 访问社区:http://bbs.likemarket.net
|
||||
// | 访问手册:http://doc.likemarket.net
|
||||
// | 好象科技开发团队 版权所有 拥有最终解释权
|
||||
// +----------------------------------------------------------------------
|
||||
// | Author: LikeShopTeam
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
namespace app\coachapi\logic;
|
||||
|
||||
use app\common\logic\BaseLogic;
|
||||
use app\common\service\WeChatConfigService;
|
||||
use EasyWeChat\Factory;
|
||||
use EasyWeChat\Kernel\Exceptions\Exception;
|
||||
|
||||
/**
|
||||
* 微信逻辑层
|
||||
* Class WechatLogic
|
||||
* @package app\api\logic
|
||||
*/
|
||||
class WechatLogic extends BaseLogic
|
||||
{
|
||||
/**
|
||||
* @notes 微信JSSDK授权接口
|
||||
* @param $params
|
||||
* @return array|false|string
|
||||
* @throws \EasyWeChat\Kernel\Exceptions\InvalidArgumentException
|
||||
* @throws \EasyWeChat\Kernel\Exceptions\InvalidConfigException
|
||||
* @throws \EasyWeChat\Kernel\Exceptions\RuntimeException
|
||||
* @throws \GuzzleHttp\Exception\GuzzleException
|
||||
* @throws \Psr\SimpleCache\InvalidArgumentException
|
||||
* @author Tab
|
||||
* @date 2021/8/30 19:20
|
||||
*/
|
||||
public static function jsConfig($params)
|
||||
{
|
||||
try {
|
||||
// $config = [
|
||||
// 'app_id' => ConfigService::get('official_account','app_id'),
|
||||
// 'secret' => ConfigService::get('official_account','app_secret')
|
||||
// ];
|
||||
$config = WeChatConfigService::getOaConfig();
|
||||
$app = Factory::officialAccount($config);
|
||||
$url = urldecode($params['url']);
|
||||
$app->jssdk->setUrl($url);
|
||||
$apis = [
|
||||
'onMenuShareTimeline',
|
||||
'onMenuShareAppMessage',
|
||||
'onMenuShareQQ',
|
||||
'onMenuShareWeibo',
|
||||
'onMenuShareQZone',
|
||||
'openLocation',
|
||||
'getLocation',
|
||||
'chooseWXPay',
|
||||
'updateAppMessageShareData',
|
||||
'updateTimelineShareData',
|
||||
'openAddress',
|
||||
'scanQRCode'
|
||||
];
|
||||
|
||||
$data = $app->jssdk->getConfigArray($apis, $debug = false, $beta = false);
|
||||
|
||||
return $data;
|
||||
} catch (Exception |\think\Exception $e) {
|
||||
|
||||
self::setError('公众号配置出错:' . $e->getMessage());
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
425
server/app/coachapi/logic/WithdrawLogic.php
Executable file
425
server/app/coachapi/logic/WithdrawLogic.php
Executable file
@@ -0,0 +1,425 @@
|
||||
<?php
|
||||
namespace app\coachapi\logic;
|
||||
use app\common\enum\accountLog\CoachAccountLogEnum;
|
||||
use app\common\logic\BaseLogic;
|
||||
use app\common\logic\CoachAccountLogLogic;
|
||||
use app\common\model\coach\Coach;
|
||||
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\coachapi\logic
|
||||
*/
|
||||
class WithdrawLogic extends BaseLogic
|
||||
{
|
||||
|
||||
public function configLists(int $coachId)
|
||||
{
|
||||
$lists = WithdrawConfig::where(['relation_id'=>$coachId,'source'=>1])
|
||||
->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 $coachId
|
||||
* @param $type
|
||||
* @return WithdrawConfig|array|\think\Model
|
||||
* @author cjhao
|
||||
* @date 2024/9/26 00:22
|
||||
*/
|
||||
public function getWithDrawWay($coachId,$type)
|
||||
{
|
||||
$detail = WithdrawConfig::where(['relation_id'=>$coachId,'type'=>$type,'source'=>1])
|
||||
->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 $coachId
|
||||
* @param $post
|
||||
* @return string|true
|
||||
* @author cjhao
|
||||
* @date 2024/9/26 11:36
|
||||
*/
|
||||
public function setWithDrawWay($coachId,$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['coach_id'] = $coachId;
|
||||
$config = WithdrawConfig::where(['type'=>$type,'relation_id'=>$coachId,'source'=>1])->findOrEmpty();
|
||||
if($config->isEmpty()){
|
||||
WithdrawConfig::create([
|
||||
'relation_id' => $coachId,
|
||||
'source' => 1,
|
||||
'type' => $type,
|
||||
'config' => $post['config'],
|
||||
]);
|
||||
}else{
|
||||
$config->config = $post['config'];
|
||||
$config->save();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @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['coach_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 int $coachId
|
||||
* @return array
|
||||
* @author cjhao
|
||||
* @date 2024/10/29 17:54
|
||||
*/
|
||||
public function getWithdrawInfo(int $coachId){
|
||||
|
||||
$lists = WithdrawConfig::where(['relation_id'=>$coachId,'source'=>1])
|
||||
->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]);
|
||||
}
|
||||
}
|
||||
$coach = Coach::where(['id'=>$coachId])->field('money,deposit')->findOrEmpty();
|
||||
$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' => $coach['money'],
|
||||
'deposit' => $coach['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 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['coach_id'],'source'=>1,'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){
|
||||
// $dayOfWeek = $dayOfWeek === 0 ? 7 : $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('请在每月'.$config['withdraw_cycle_date'].'号来申请提现');
|
||||
}
|
||||
}
|
||||
$coach = Coach::where(['id'=> $params['coach_id']])->findOrEmpty();
|
||||
$coachMoney = $coach->money;
|
||||
if(2 == $applyType){
|
||||
$coachMoney = $coach->deposit;
|
||||
}
|
||||
if($coachMoney < $money){
|
||||
throw new Exception('当前可提现余额仅剩'.$coachMoney);
|
||||
}
|
||||
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);
|
||||
}
|
||||
//提现操作
|
||||
$withdrawApply = WithdrawApply::create([
|
||||
'sn' => generate_sn((new WithdrawApply()), 'sn'),
|
||||
'relation_id' => $params['coach_id'],
|
||||
'source' => 1,
|
||||
'type' => $type,
|
||||
'apply_type' => $applyType,
|
||||
'money' => $money,
|
||||
'left_money' => round($money - $serviceFree,2),
|
||||
'handling_fee' => $serviceFree,
|
||||
'service_charge' => $config['service_charge'],
|
||||
'withdraw_config_snap' => $withdrawConfig,
|
||||
]);
|
||||
if(1 == $applyType){
|
||||
$coach->money = round($coach->money - $money,2);
|
||||
$coach->save();
|
||||
CoachAccountLogLogic::add(
|
||||
$coach->id,
|
||||
CoachAccountLogEnum::MONEY,
|
||||
CoachAccountLogEnum::WITHDRAW_DEC_MONEY,
|
||||
2,
|
||||
$money,
|
||||
$withdrawApply['sn'],
|
||||
);
|
||||
}else{
|
||||
$coach->deposit = round($coach->deposit - $money,2);
|
||||
$coach->save();
|
||||
CoachAccountLogLogic::add(
|
||||
$coach->id,
|
||||
CoachAccountLogEnum::DEPOSIT,
|
||||
CoachAccountLogEnum::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,$coachId)
|
||||
{
|
||||
$detail = WithdrawApply::where(['id'=>$id,'relation_id'=>$coachId,'source'=>1])
|
||||
->append(['status_desc','type_desc'])
|
||||
->withoutField('delete_time')
|
||||
->findOrEmpty()->toArray();
|
||||
return $detail;
|
||||
|
||||
}
|
||||
}
|
||||
124
server/app/coachapi/service/CoachUserTokenService.php
Executable file
124
server/app/coachapi/service/CoachUserTokenService.php
Executable file
@@ -0,0 +1,124 @@
|
||||
<?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\coachapi\service;
|
||||
|
||||
|
||||
use app\common\cache\CoachUserTokenCache;
|
||||
use app\common\cache\UserTokenCache;
|
||||
use app\common\model\coach\CoachUserSession;
|
||||
use app\common\model\coach\ShopUserSession;
|
||||
use app\common\model\user\UserSession;
|
||||
use think\facade\Config;
|
||||
|
||||
class CoachUserTokenService
|
||||
{
|
||||
/**
|
||||
* @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();
|
||||
$coachUserSession = CoachUserSession::where([['coach_user_id', '=', $userId], ['terminal', '=', $terminal]])->find();
|
||||
|
||||
//获取token延长过期的时间
|
||||
$expireTime = $time + Config::get('project.coach_user_token.expire_duration');
|
||||
$coachUserTokenCache = new CoachUserTokenCache();
|
||||
//token处理
|
||||
if ($coachUserSession) {
|
||||
|
||||
//清空缓存
|
||||
$coachUserTokenCache->deleteCoachUserInfo($coachUserSession->token);
|
||||
//重新获取token
|
||||
$coachUserSession->token = create_token($userId);
|
||||
$coachUserSession->expire_time = $expireTime;
|
||||
$coachUserSession->update_time = $time;
|
||||
$coachUserSession->save();
|
||||
} else {
|
||||
//找不到在该终端的token记录,创建token记录
|
||||
$coachUserSession = CoachUserSession::create([
|
||||
'coach_user_id' => $userId,
|
||||
'terminal' => $terminal,
|
||||
'token' => create_token($userId),
|
||||
'expire_time' => $expireTime
|
||||
]);
|
||||
|
||||
}
|
||||
return $coachUserTokenCache->setCoachUserInfo($coachUserSession->token);
|
||||
}
|
||||
|
||||
/**
|
||||
* @notes 延长token过期时间
|
||||
* @param $token
|
||||
* @return array|false|mixed
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
* @author 令狐冲
|
||||
* @date 2021/7/5 14:25
|
||||
*/
|
||||
public static function overtimeToken($token)
|
||||
{
|
||||
$time = time();
|
||||
$adminSession = UserSession::where('token', '=', $token)->find();
|
||||
//延长token过期时间
|
||||
$adminSession->expire_time = $time + Config::get('project.admin_token.expire_duration');
|
||||
$adminSession->update_time = $time;
|
||||
$adminSession->save();
|
||||
return (new UserTokenCache())->setUserInfo($adminSession->token);
|
||||
}
|
||||
|
||||
/**
|
||||
* @notes 设置token为过期
|
||||
* @param $token
|
||||
* @return bool
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
* @author 令狐冲
|
||||
* @date 2021/7/5 14:31
|
||||
*/
|
||||
public static function expireToken($token)
|
||||
{
|
||||
$userSession = UserSession::where('token', '=', $token)
|
||||
->find();
|
||||
if (empty($userSession)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
$time = time();
|
||||
$userSession->expire_time = $time;
|
||||
$userSession->update_time = $time;
|
||||
$userSession->save();
|
||||
|
||||
return (new UserTokenCache())->deleteUserInfo($token);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
190
server/app/coachapi/validate/CoachValidate.php
Executable file
190
server/app/coachapi/validate/CoachValidate.php
Executable file
@@ -0,0 +1,190 @@
|
||||
<?php
|
||||
namespace app\coachapi\validate;
|
||||
use app\adminapi\logic\coach\CoachLogic;
|
||||
use app\common\model\coach\Coach;
|
||||
use app\common\model\coach\CoachUser;
|
||||
use app\common\model\skill\Skill;
|
||||
use app\common\validate\BaseValidate;
|
||||
|
||||
/**
|
||||
* 技师验证类
|
||||
* Class CoachValidate
|
||||
* @package app\adminapi\validate\coach
|
||||
*/
|
||||
class CoachValidate extends BaseValidate
|
||||
{
|
||||
|
||||
protected $rule = [
|
||||
'name' => 'require|max:64',
|
||||
'gender' => 'require|in:1,2',
|
||||
'age' => 'require',
|
||||
'id_card' => 'require|idCard',
|
||||
'education' => 'require',
|
||||
'nation' => 'require',
|
||||
'province_id' => 'require',
|
||||
'city_id' => 'require',
|
||||
// 'region_id' => 'require',
|
||||
'address_detail' => 'require',
|
||||
'skill_id' => 'require|checkSkill',
|
||||
'goods_ids' => 'require|array|checkGoods',
|
||||
'id_card_back' => 'require',
|
||||
'id_card_front' => 'require',
|
||||
'portrait_shooting' => 'require',
|
||||
// 'work_photo' => 'require',
|
||||
// 'certification' => 'require',
|
||||
// 'health_certificate'=> 'require',
|
||||
// 'life_photo' => 'require|array',
|
||||
'work_status' => 'require|in:0,1',
|
||||
'server_status' => 'require|in:0,1',
|
||||
'longitude' => 'require',
|
||||
'latitude' => 'require',
|
||||
|
||||
// 'field' => 'require|checkField',
|
||||
// 'value' => 'require',
|
||||
//
|
||||
// 'mobile' => 'require|mobile',
|
||||
// 'code' => 'require',
|
||||
];
|
||||
|
||||
protected $message = [
|
||||
'id.require' => '请选择技师',
|
||||
'name.require' => '请输入名称',
|
||||
'name.max' => '名称不能超过64个字符',
|
||||
'gender.require' => '请输入性别',
|
||||
'gender.in' => '性别错误',
|
||||
'mobile.require' => '请输入联系电话',
|
||||
'mobile.mobile' => '联系电话格式错误',
|
||||
'id_card.require' => '请输入身份证',
|
||||
'id_card.idCard' => '身份证格式错误',
|
||||
'education.require' => '请输入学历',
|
||||
'nation.require' => '请输入民族',
|
||||
'province_id.require' => '请选择省份',
|
||||
'city_id.require' => '请选择城市',
|
||||
'region_id.require' => '请选择地区',
|
||||
'address_detail.require' => '请输入详情地址',
|
||||
'skill_id.require' => '请选择技能',
|
||||
'goods_ids.require' => '请选择服务',
|
||||
'goods_ids.array' => '服务数据错误',
|
||||
'id_card_back.require' => '请上传身份证人像照',
|
||||
'id_card_front,require' => '请上传身份证国徽照',
|
||||
'portrait_shooting,require' => '请上传人像实拍照',
|
||||
'work_photo.require' => '请上传工作照',
|
||||
'work_status.require' => '请选择工作状态',
|
||||
'work_status.in' => '工作状态错误',
|
||||
'server_status.require' => '请选择服务状态',
|
||||
'server_status.in' => '服务状态错误',
|
||||
'longitude.require' => '请在地图上标记位置',
|
||||
'latitude.require' => '请在地图上标记位置',
|
||||
|
||||
'field.require' => '参数缺失',
|
||||
'value.require' => '值不存在',
|
||||
|
||||
'code.require' => '参数缺失',
|
||||
];
|
||||
public function sceneId()
|
||||
{
|
||||
return $this->only(['id'=>true]);
|
||||
}
|
||||
public function sceneApply(){
|
||||
return $this->remove(['field'=>true,'value'=>true,'code'=>true]);
|
||||
}
|
||||
public function sceneUpdate(){
|
||||
return $this->remove(['work_status'=>true,'server_status'=>true,'field'=>true,'value'=>true,'mobile'=>true,'code'=>true]);
|
||||
}
|
||||
|
||||
public function sceneSetPersonalData()
|
||||
{
|
||||
return $this->only(['field','value']);
|
||||
}
|
||||
|
||||
public function sceneBindMobile()
|
||||
{
|
||||
return $this->only(['mobile', 'code']);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 验证技能
|
||||
* @param $value
|
||||
* @param $rule
|
||||
* @param $data
|
||||
* @return string|true
|
||||
* @author cjhao
|
||||
* @date 2024/8/20 17:44
|
||||
*/
|
||||
public function checkSkill($value,$rule,$data)
|
||||
{
|
||||
$skill = Skill::where(['id'=>$value])->findOrEmpty();
|
||||
if($skill->isEmpty()){
|
||||
return '服务技能不存在,请重新刷新';
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @notes
|
||||
* @param $value
|
||||
* @param $rule
|
||||
* @param $data
|
||||
* @return string|true
|
||||
* @throws \think\db\exception\DataNotFoundException
|
||||
* @throws \think\db\exception\DbException
|
||||
* @throws \think\db\exception\ModelNotFoundException
|
||||
* @author cjhao
|
||||
* @date 2024/8/20 18:15
|
||||
*/
|
||||
public function checkGoods($value,$rule,$data)
|
||||
{
|
||||
$shopId = 0;
|
||||
$coachId = $data['coach_id'] ?? $data['id'];
|
||||
if($coachId){
|
||||
$shopId = Coach::where(['id'=>$coachId])->value('shop_id') ?: 0;
|
||||
}
|
||||
$skillLists = (new CoachLogic())->skillLists($shopId);
|
||||
$skillLists = array_column($skillLists,null,'id');
|
||||
$goodsLists = $skillLists[$data['skill_id']]['goods_list'] ?? [];
|
||||
if(empty($goodsLists)){
|
||||
return '请选择服务';
|
||||
}
|
||||
$goodsIds = array_column($goodsLists,'id');
|
||||
foreach ($value as $id) {
|
||||
if(!in_array($id,$goodsIds)){
|
||||
return '服务数据错误,请刷新技能重新选择';
|
||||
}
|
||||
}
|
||||
return true;
|
||||
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @notes 校验设置个人资料
|
||||
* @param $value
|
||||
* @param $rule
|
||||
* @param $data
|
||||
* @return string|true
|
||||
* @author ljj
|
||||
* @date 2024/12/3 下午3:59
|
||||
*/
|
||||
protected function checkField($value,$rule,$data)
|
||||
{
|
||||
$allowField = ['gender','introduction'];
|
||||
if(!in_array($value,$allowField)){
|
||||
return '参数错误';
|
||||
}
|
||||
switch ($value) {
|
||||
case 'mobile':
|
||||
$staff = Coach::where([
|
||||
['mobile', '=', $data['value']],
|
||||
['id', '<>', $data['coach_id']]
|
||||
])->findOrEmpty();
|
||||
if(!$staff->isEmpty()) {
|
||||
return '手机号已被绑定';
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
}
|
||||
}
|
||||
157
server/app/coachapi/validate/LoginAccountValidate.php
Executable file
157
server/app/coachapi/validate/LoginAccountValidate.php
Executable file
@@ -0,0 +1,157 @@
|
||||
<?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\coachapi\validate;
|
||||
|
||||
use app\common\cache\CoachUserAccountSafeCache;
|
||||
use app\common\enum\coach\CoachUserTerminalEnum;
|
||||
use app\common\enum\LoginEnum;
|
||||
use app\common\enum\notice\NoticeEnum;
|
||||
use app\common\enum\YesNoEnum;
|
||||
use app\common\model\coach\CoachUser;
|
||||
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:' . CoachUserTerminalEnum::WECHAT_MMP . ',' . CoachUserTerminalEnum::WECHAT_OA . ','
|
||||
. CoachUserTerminalEnum::H5 . ',' . CoachUserTerminalEnum::PC . ',' . CoachUserTerminalEnum::IOS .
|
||||
',' . CoachUserTerminalEnum::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)
|
||||
{
|
||||
//账号安全机制,连续输错后锁定,防止账号密码暴力破解
|
||||
$coachUserAccountSafeCache = new CoachUserAccountSafeCache();
|
||||
if (!$coachUserAccountSafeCache->isSafe()) {
|
||||
return '密码连续' . $coachUserAccountSafeCache->count . '次输入错误,请' . $coachUserAccountSafeCache->minute . '分钟后重试';
|
||||
}
|
||||
|
||||
$where = [];
|
||||
if ($data['scene'] == LoginEnum::ACCOUNT_PASSWORD) {
|
||||
// 手机号密码登录
|
||||
$where = ['account' => $data['account']];
|
||||
}
|
||||
|
||||
$coachUserInfo = CoachUser::where($where)
|
||||
->field(['password'])
|
||||
->findOrEmpty();
|
||||
if ($coachUserInfo->isEmpty()) {
|
||||
return '用户不存在';
|
||||
}
|
||||
|
||||
// if ($coachUserInfo['is_disable'] === YesNoEnum::YES) {
|
||||
// return '用户已禁用';
|
||||
// }
|
||||
|
||||
if (empty($coachUserInfo['password'])) {
|
||||
$coachUserAccountSafeCache->record();
|
||||
return '用户不存在';
|
||||
}
|
||||
|
||||
$passwordSalt = Config::get('project.unique_identification');
|
||||
if ($coachUserInfo['password'] !== create_password($password, $passwordSalt)) {
|
||||
$coachUserAccountSafeCache->record();
|
||||
return '密码错误';
|
||||
}
|
||||
|
||||
$coachUserAccountSafeCache->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_STAFF);
|
||||
if ($result) {
|
||||
return true;
|
||||
}
|
||||
return '验证码错误';
|
||||
}
|
||||
}
|
||||
36
server/app/coachapi/validate/OrderValidate.php
Executable file
36
server/app/coachapi/validate/OrderValidate.php
Executable file
@@ -0,0 +1,36 @@
|
||||
<?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\coachapi\validate;
|
||||
|
||||
use app\common\validate\BaseValidate;
|
||||
|
||||
/**
|
||||
* 订单逻辑验证类
|
||||
* Class OrderValidate
|
||||
* @package app\coachapi\validate
|
||||
*/
|
||||
class OrderValidate extends BaseValidate
|
||||
{
|
||||
protected $rule = [
|
||||
'id' => 'require',
|
||||
];
|
||||
|
||||
protected $message = [
|
||||
'id.require' => '订单id缺少'
|
||||
];
|
||||
|
||||
|
||||
|
||||
}
|
||||
83
server/app/coachapi/validate/PasswordValidate.php
Executable file
83
server/app/coachapi/validate/PasswordValidate.php
Executable file
@@ -0,0 +1,83 @@
|
||||
<?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\coachapi\validate;
|
||||
|
||||
use app\common\model\coach\CoachUser;
|
||||
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');
|
||||
$coachUserInfo = CoachUser::where(['id'=>$data['coach_info']['coach_user_id']])->findOrEmpty();
|
||||
if ($coachUserInfo['password'] !== create_password($value, $passwordSalt)) {
|
||||
return '原密码错误';
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
119
server/app/coachapi/validate/PayValidate.php
Executable file
119
server/app/coachapi/validate/PayValidate.php
Executable file
@@ -0,0 +1,119 @@
|
||||
<?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\coachapi\validate;
|
||||
|
||||
|
||||
use app\common\enum\OrderEnum;
|
||||
use app\common\enum\PayEnum;
|
||||
use app\common\model\deposit\DepositOrder;
|
||||
use app\common\model\order\Order;
|
||||
use app\common\model\order\OrderAppend;
|
||||
use app\common\model\order\OrderGap;
|
||||
use app\common\model\RechargeOrder;
|
||||
use app\common\validate\BaseValidate;
|
||||
|
||||
class PayValidate extends BaseValidate
|
||||
{
|
||||
protected $rule = [
|
||||
'from' => 'require',
|
||||
'pay_way' => 'require|in:' . PayEnum::BALANCE_PAY . ',' . PayEnum::WECHAT_PAY . ',' . PayEnum::ALI_PAY,
|
||||
'order_id' => 'require|checkOrderId',
|
||||
'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()->toArray();
|
||||
break;
|
||||
default :
|
||||
$result = [];
|
||||
}
|
||||
if (empty($result)) {
|
||||
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;
|
||||
}
|
||||
}
|
||||
47
server/app/coachapi/validate/RegisterValidate.php
Executable file
47
server/app/coachapi/validate/RegisterValidate.php
Executable file
@@ -0,0 +1,47 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | likeadmin快速开发前后端分离管理后台(PHP版)
|
||||
// +----------------------------------------------------------------------
|
||||
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
|
||||
// | 开源版本可自由商用,可去除界面版权logo
|
||||
// | gitee下载:https://gitee.com/likeshop_gitee/likeadmin
|
||||
// | github下载:https://github.com/likeshop-github/likeadmin
|
||||
// | 访问官网:https://www.likeadmin.cn
|
||||
// | likeadmin团队 版权所有 拥有最终解释权
|
||||
// +----------------------------------------------------------------------
|
||||
// | author: likeadminTeam
|
||||
// +----------------------------------------------------------------------
|
||||
namespace app\coachapi\validate;
|
||||
|
||||
|
||||
use app\common\model\coach\CoachUser;
|
||||
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:' . CoachUser::class,
|
||||
'password' => 'require|length:6,20|alphaNum',
|
||||
// 'password_confirm' => 'require|confirm'
|
||||
];
|
||||
|
||||
protected $message = [
|
||||
'channel.require' => '注册来源参数缺失',
|
||||
'account.require' => '请输入账号',
|
||||
'account.alphaNum' => '账号须为字母数字组合',
|
||||
'account.length' => '账号须为3-12位之间',
|
||||
'account.unique' => '账号已存在',
|
||||
'password.require' => '请输入密码',
|
||||
'password.length' => '密码须在6-20位之间',
|
||||
'password.alphaNum' => '密码须为字母数字组合',
|
||||
// 'password_confirm.require' => '请确认密码',
|
||||
// 'password_confirm.confirm' => '两次输入的密码不一致'
|
||||
];
|
||||
|
||||
}
|
||||
51
server/app/coachapi/validate/SendSmsValidate.php
Executable file
51
server/app/coachapi/validate/SendSmsValidate.php
Executable file
@@ -0,0 +1,51 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | likeadmin快速开发前后端分离管理后台(PHP版)
|
||||
// +----------------------------------------------------------------------
|
||||
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
|
||||
// | 开源版本可自由商用,可去除界面版权logo
|
||||
// | gitee下载:https://gitee.com/likeshop_gitee/likeadmin
|
||||
// | github下载:https://github.com/likeshop-github/likeadmin
|
||||
// | 访问官网:https://www.likeadmin.cn
|
||||
// | likeadmin团队 版权所有 拥有最终解释权
|
||||
// +----------------------------------------------------------------------
|
||||
// | author: likeadminTeam
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
namespace app\coachapi\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::getSceneByCoachTag($value);
|
||||
if(empty($scene)){
|
||||
return '场景值错误';
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
40
server/app/coachapi/validate/WechatValidate.php
Executable file
40
server/app/coachapi/validate/WechatValidate.php
Executable file
@@ -0,0 +1,40 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | LikeShop有特色的全开源社交分销电商系统
|
||||
// +----------------------------------------------------------------------
|
||||
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
|
||||
// | 商业用途务必购买系统授权,以免引起不必要的法律纠纷
|
||||
// | 禁止对系统程序代码以任何目的,任何形式的再发布
|
||||
// | 微信公众号:好象科技
|
||||
// | 访问官网:http://www.likemarket.net
|
||||
// | 访问社区:http://bbs.likemarket.net
|
||||
// | 访问手册:http://doc.likemarket.net
|
||||
// | 好象科技开发团队 版权所有 拥有最终解释权
|
||||
// +----------------------------------------------------------------------
|
||||
// | Author: LikeShopTeam
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
namespace app\coachapi\validate;
|
||||
|
||||
use app\common\validate\BaseValidate;
|
||||
|
||||
/**
|
||||
* 微信验证器
|
||||
* Class WechatValidate
|
||||
* @package app\api\validate
|
||||
*/
|
||||
class WechatValidate extends BaseValidate
|
||||
{
|
||||
public $rule = [
|
||||
'url' => 'require'
|
||||
];
|
||||
|
||||
public $message = [
|
||||
'url.require' => '请提供url'
|
||||
];
|
||||
|
||||
public function sceneJsConfig()
|
||||
{
|
||||
return $this->only(['url']);
|
||||
}
|
||||
}
|
||||
25
server/app/coachapi/validate/WithdrawalApplyValidate.php
Executable file
25
server/app/coachapi/validate/WithdrawalApplyValidate.php
Executable file
@@ -0,0 +1,25 @@
|
||||
<?php
|
||||
namespace app\coachapi\validate;
|
||||
use app\common\validate\BaseValidate;
|
||||
|
||||
/**
|
||||
* 提现审核列验证器
|
||||
* Class WithdrawalApplyValidate
|
||||
* @package app\coachapi\validate
|
||||
*/
|
||||
class WithdrawalApplyValidate extends BaseValidate
|
||||
{
|
||||
protected $rule = [
|
||||
'money' => 'require',
|
||||
'apply_type' => 'require|in:1,2,3'
|
||||
];
|
||||
|
||||
protected $message = [
|
||||
'money.require' => '请输入金额',
|
||||
'apply_type.require' => '请选择提现方式',
|
||||
'apply_type.in' => '提现方式错误'
|
||||
];
|
||||
|
||||
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user