课程管理、学生管理、教师管理
This commit is contained in:
parent
f736287ee0
commit
bb5d3f3fb3
@ -1,97 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace app\api\controller;
|
||||
|
||||
use app\BaseController;
|
||||
use app\common\service\CaseShareService;
|
||||
use support\Request;
|
||||
|
||||
class CaseShareController extends BaseController
|
||||
{
|
||||
protected $noNeedLogin = ['getCaseShareList', 'caseDetail', 'getPhotographerCaseShareServiceType'];
|
||||
|
||||
/**
|
||||
* @desc 保存案例
|
||||
* @param Request $request
|
||||
* @return \support\Response
|
||||
*/
|
||||
public function insert(Request $request)
|
||||
{
|
||||
$service = new CaseShareService();
|
||||
$res = $service->insert($request);
|
||||
return $this->json($res);
|
||||
}
|
||||
|
||||
/**
|
||||
* @desc 删除案例
|
||||
* @param Request $request
|
||||
* @return \support\Response
|
||||
*/
|
||||
public function del(Request $request)
|
||||
{
|
||||
$service = new CaseShareService();
|
||||
$res = $service->del($request->post());
|
||||
return $this->json($res);
|
||||
}
|
||||
|
||||
/**
|
||||
* @desc 更新案例
|
||||
* @param Request $request
|
||||
* @return \support\Response
|
||||
*/
|
||||
public function update(Request $request)
|
||||
{
|
||||
$service = new CaseShareService();
|
||||
$res = $service->update($request);
|
||||
return $this->json($res);
|
||||
}
|
||||
|
||||
/**
|
||||
* @desc 获取案例列表
|
||||
* @param Request $request
|
||||
* @return \support\Response
|
||||
*/
|
||||
public function getCaseShareList(Request $request)
|
||||
{
|
||||
$service = new CaseShareService();
|
||||
$res = $service->getCaseShareList($request->get());
|
||||
return $this->json($res);
|
||||
}
|
||||
|
||||
/**
|
||||
* @desc 获取用户案例列表
|
||||
* @param Request $request
|
||||
* @return \support\Response
|
||||
*/
|
||||
public function getUserCaseShareList(Request $request)
|
||||
{
|
||||
$service = new CaseShareService();
|
||||
$res = $service->getUserCaseShareList($request);
|
||||
return $this->json($res);
|
||||
}
|
||||
|
||||
/**
|
||||
* @desc 案例详情
|
||||
* @param Request $request
|
||||
* @return \support\Response
|
||||
*/
|
||||
public function cashShareDetail(Request $request)
|
||||
{
|
||||
$service = new CaseShareService();
|
||||
$res = $service->caseDetail($request->get());
|
||||
return $this->json($res);
|
||||
}
|
||||
|
||||
/**
|
||||
* @desc 摄影师案例服务类型
|
||||
* @param Request $request
|
||||
* @return \support\Response
|
||||
*/
|
||||
public function getPhotographerCaseShareServiceType(Request $request)
|
||||
{
|
||||
$service = new CaseShareService();
|
||||
$res = $service->getPhotographerCaseShareServiceType($request->get());
|
||||
return $this->json($res);
|
||||
}
|
||||
|
||||
}
|
@ -1,45 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace app\api\controller;
|
||||
|
||||
use app\BaseController;
|
||||
use app\common\service\ChatRecordsService;
|
||||
use support\Request;
|
||||
|
||||
class ChatController extends BaseController
|
||||
{
|
||||
|
||||
/**
|
||||
* @desc 发送消息
|
||||
* @param Request $request
|
||||
* @return \support\Response
|
||||
*/
|
||||
public function sendMsg(Request $request)
|
||||
{
|
||||
$service = new ChatRecordsService();
|
||||
$res = $service->sendMsg($request);
|
||||
return $this->json($res);
|
||||
}
|
||||
|
||||
/**
|
||||
* @desc 获取用户消息
|
||||
* @param Request $request
|
||||
* @return \support\Response
|
||||
*/
|
||||
public function getUserChatMsg(Request $request)
|
||||
{
|
||||
$service = new ChatRecordsService();
|
||||
$res = $service->getUserChatMsg($request);
|
||||
return $this->json($res);
|
||||
}
|
||||
|
||||
|
||||
public function updateMsgRead(Request $request)
|
||||
{
|
||||
$service = new ChatRecordsService();
|
||||
$res = $service->updateMsgRead($request);
|
||||
return $this->json($res);
|
||||
}
|
||||
|
||||
|
||||
}
|
@ -1,24 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace app\api\controller;
|
||||
|
||||
use app\BaseController;
|
||||
use app\common\service\ChatFriendService;
|
||||
use support\Request;
|
||||
|
||||
class ChatFriendController extends BaseController
|
||||
{
|
||||
|
||||
/**
|
||||
* @desc 聊天朋友
|
||||
* @param Request $request
|
||||
* @return \support\Response
|
||||
*/
|
||||
public function getFriends(Request $request)
|
||||
{
|
||||
$service = new ChatFriendService();
|
||||
$res = $service->getFriends($request);
|
||||
return $this->json($res);
|
||||
}
|
||||
|
||||
}
|
@ -1,24 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace app\api\controller;
|
||||
|
||||
use app\BaseController;
|
||||
use app\common\service\DepositOrderService;
|
||||
use support\Request;
|
||||
|
||||
class DepositOrderController extends BaseController
|
||||
{
|
||||
|
||||
/**
|
||||
* @desc 竞价订单支付定金
|
||||
* @param Request $request
|
||||
* @return \support\Response
|
||||
*/
|
||||
public function payBidOrder(Request $request)
|
||||
{
|
||||
$service = new DepositOrderService();
|
||||
$res = $service->payBidOrder($request);
|
||||
return $this->json($res);
|
||||
}
|
||||
|
||||
}
|
@ -1,25 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace app\api\controller;
|
||||
|
||||
use app\BaseController;
|
||||
use app\common\service\DeviceService;
|
||||
use support\Request;
|
||||
|
||||
class DeviceController extends BaseController
|
||||
{
|
||||
|
||||
protected $noNeedLogin = ['*'];
|
||||
/**
|
||||
* @desc 设备列表
|
||||
* @param Request $request
|
||||
* @return \support\Response
|
||||
*/
|
||||
public function getDeviceList(Request $request)
|
||||
{
|
||||
$service = new DeviceService();
|
||||
$res = $service->getDeviceService($request->get());
|
||||
return $this->json($res);
|
||||
}
|
||||
|
||||
}
|
@ -1,49 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace app\api\controller;
|
||||
|
||||
use app\BaseController;
|
||||
use app\common\service\FavoriteService;
|
||||
use support\Request;
|
||||
|
||||
class FavoriteController extends BaseController
|
||||
{
|
||||
|
||||
/**
|
||||
* @desc 收藏
|
||||
* @param Request $request
|
||||
* @return \support\Response
|
||||
*/
|
||||
public function add(Request $request)
|
||||
{
|
||||
$service = new FavoriteService();
|
||||
$res = $service->add($request);
|
||||
return $this->json($res);
|
||||
}
|
||||
|
||||
/**
|
||||
* @desc 取消收藏
|
||||
* @param Request $request
|
||||
* @return \support\Response
|
||||
*/
|
||||
public function cancel(Request $request)
|
||||
{
|
||||
$service = new FavoriteService();
|
||||
$res = $service->cancel($request);
|
||||
return $this->json($res);
|
||||
}
|
||||
|
||||
/**
|
||||
* @desc 收藏列表
|
||||
* @param Request $request
|
||||
* @return \support\Response
|
||||
*/
|
||||
public function getFavoriteList(Request $request)
|
||||
{
|
||||
$service = new FavoriteService();
|
||||
$res = $service->getFavoriteList($request);
|
||||
return $this->json($res);
|
||||
}
|
||||
|
||||
|
||||
}
|
@ -1,23 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace app\api\controller;
|
||||
|
||||
use app\BaseController;
|
||||
use app\common\service\PaidServiceService;
|
||||
use support\Request;
|
||||
|
||||
class PaidServiceController extends BaseController
|
||||
{
|
||||
|
||||
/**
|
||||
* @desc 增值服务列表
|
||||
* @param Request $request
|
||||
* @return \support\Response
|
||||
*/
|
||||
public function getList(Request $request)
|
||||
{
|
||||
$service = new PaidServiceService();
|
||||
$res = $service->getList($request->get());
|
||||
return $this->json($res);
|
||||
}
|
||||
}
|
@ -1,19 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace app\api\controller;
|
||||
|
||||
use app\common\service\PayService;
|
||||
use support\Request;
|
||||
|
||||
class PayController
|
||||
{
|
||||
|
||||
|
||||
public function pay(Request $request)
|
||||
{
|
||||
$service = new PayService();
|
||||
$res = $service->payment($request->post());
|
||||
return $this->json($res);
|
||||
}
|
||||
|
||||
}
|
@ -1,71 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace app\api\controller;
|
||||
|
||||
use app\BaseController;
|
||||
use app\common\service\PhotoServiceService;
|
||||
use support\Request;
|
||||
|
||||
class PhotoServiceController extends BaseController
|
||||
{
|
||||
|
||||
protected $noNeedLogin = ['select'];
|
||||
|
||||
|
||||
/**
|
||||
* @desc 获取摄影师自己的服务
|
||||
* @param Request $request
|
||||
* @return \support\Response
|
||||
*/
|
||||
public function getPhotographerSelfService(Request $request)
|
||||
{
|
||||
$service = new PhotoServiceService();
|
||||
$res = $service->getPhotographerSelfService($request);
|
||||
return $this->json($res);
|
||||
}
|
||||
|
||||
/**
|
||||
* @desc 摄影师拍照服务
|
||||
* @param Request $request
|
||||
* @return \support\Response
|
||||
*/
|
||||
public function select(Request $request)
|
||||
{
|
||||
$service = new PhotoServiceService();
|
||||
$res = $service->select($request->get());
|
||||
return $this->json($res);
|
||||
}
|
||||
|
||||
/**
|
||||
* @desc 添加拍照服务
|
||||
* @param Request $request
|
||||
* @return \support\Response
|
||||
*/
|
||||
public function add(Request $request)
|
||||
{
|
||||
$service = new PhotoServiceService();
|
||||
$res = $service->add($request);
|
||||
return $this->json($res);
|
||||
}
|
||||
|
||||
/**
|
||||
* @desc 添加拍照服务
|
||||
* @param Request $request
|
||||
* @return \support\Response
|
||||
*/
|
||||
public function edit(Request $request)
|
||||
{
|
||||
$service = new PhotoServiceService();
|
||||
$res = $service->edit($request);
|
||||
return $this->json($res);
|
||||
}
|
||||
|
||||
|
||||
public function del(Request $request)
|
||||
{
|
||||
$service = new PhotoServiceService();
|
||||
$res = $service->del($request);
|
||||
return $this->json($res);
|
||||
}
|
||||
|
||||
}
|
@ -1,79 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace app\api\controller;
|
||||
|
||||
use app\BaseController;
|
||||
use app\common\service\PhotoServiceOrderService;
|
||||
use support\Request;
|
||||
|
||||
class PhotoServiceOrderController extends BaseController
|
||||
{
|
||||
|
||||
/**
|
||||
* @desc 拍照服务支付
|
||||
* @param Request $request
|
||||
* @return \support\Response
|
||||
*/
|
||||
public function pay(Request $request)
|
||||
{
|
||||
$service = new PhotoServiceOrderService();
|
||||
$res = $service->pay($request);
|
||||
return $this->json($res);
|
||||
}
|
||||
|
||||
/**
|
||||
* @desc 支付保证金
|
||||
* @param Request $request
|
||||
* @return \support\Response
|
||||
*/
|
||||
public function payOrderDeposit(Request $request)
|
||||
{
|
||||
$service = new PhotoServiceOrderService();
|
||||
$res = $service->payOrderDeposit($request);
|
||||
return $this->json($res);
|
||||
}
|
||||
|
||||
/**
|
||||
* @desc 计算支付价格
|
||||
* @param Request $request
|
||||
* @return \support\Response
|
||||
*/
|
||||
public function calculatePrice(Request $request)
|
||||
{
|
||||
$service = new PhotoServiceOrderService();
|
||||
$res = $service->calculatePrice($request->post());
|
||||
return $this->json($res);
|
||||
}
|
||||
|
||||
/**
|
||||
* @desc 摄影师拍照订单列表
|
||||
* @param Request $request
|
||||
* @return \support\Response
|
||||
*/
|
||||
public function getPhotoServiceOrderForPhotographer(Request $request)
|
||||
{
|
||||
$service = new PhotoServiceOrderService();
|
||||
$res = $service->getPhotoServiceOrderForPhotographer($request);
|
||||
return $this->json($res);
|
||||
}
|
||||
/**
|
||||
* @desc 摄影师拍照订单列表
|
||||
* @param Request $request
|
||||
* @return \support\Response
|
||||
*/
|
||||
public function getPhotoServiceOrderForUser(Request $request)
|
||||
{
|
||||
$service = new PhotoServiceOrderService();
|
||||
$res = $service->getPhotoServiceOrderForUser($request);
|
||||
return $this->json($res);
|
||||
}
|
||||
|
||||
|
||||
public function cancelPhotoOrder(Request $request)
|
||||
{
|
||||
$service = new PhotoServiceOrderService();
|
||||
$res = $service->getPhotoServiceOrderForUser($request);
|
||||
return $this->json($res);
|
||||
}
|
||||
|
||||
}
|
@ -1,76 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace app\api\controller;
|
||||
|
||||
use app\BaseController;
|
||||
use app\common\service\PhotographerService;
|
||||
use support\Request;
|
||||
|
||||
class PhotographerController extends BaseController
|
||||
{
|
||||
protected $noNeedLogin = ['getServiceType'];
|
||||
|
||||
/**
|
||||
* @desc 摄影师申请
|
||||
* @param Request $request
|
||||
* @return \support\Response
|
||||
*/
|
||||
public function apply(Request $request)
|
||||
{
|
||||
$service = new PhotographerService();
|
||||
$res = $service->apply($request);
|
||||
return $this->json($res);
|
||||
}
|
||||
|
||||
/**
|
||||
* @desc 摄影师详情
|
||||
* @param Request $request
|
||||
* @return \support\Response
|
||||
*/
|
||||
public function edit(Request $request)
|
||||
{
|
||||
$service = new PhotographerService();
|
||||
$res = $service->edit($request);
|
||||
return $this->json($res);
|
||||
}
|
||||
|
||||
/**
|
||||
* @desc 摄影师详情
|
||||
* @param Request $request
|
||||
* @return \support\Response
|
||||
*/
|
||||
public function detail(Request $request)
|
||||
{
|
||||
$service = new PhotographerService();
|
||||
$res = $service->detail($request);
|
||||
return $this->json($res);
|
||||
}
|
||||
|
||||
/**
|
||||
* @desc 服务列表
|
||||
* @param Request $request
|
||||
* @return \support\Response
|
||||
*/
|
||||
public function getServiceType(Request $request)
|
||||
{
|
||||
$service = new PhotographerService();
|
||||
$res = $service->getServiceType($request->get());
|
||||
return $this->json($res);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @desc 退出工作室
|
||||
* @param Request $request
|
||||
* @return \support\Response
|
||||
*/
|
||||
public function quitStudio(Request $request)
|
||||
{
|
||||
$service = new PhotographerService();
|
||||
$res = $service->quitStudio($request);
|
||||
return $this->json($res);
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
@ -1,52 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace app\api\controller;
|
||||
|
||||
use app\BaseController;
|
||||
use app\common\service\RequirementBiddingService;
|
||||
use support\Request;
|
||||
|
||||
class RequirementBiddingController extends BaseController
|
||||
{
|
||||
|
||||
|
||||
/**
|
||||
* @desc 报价
|
||||
* @param Request $request
|
||||
* @return \support\Response
|
||||
*/
|
||||
public function bid(Request $request)
|
||||
{
|
||||
$service = new RequirementBiddingService();
|
||||
$res = $service->bid($request);
|
||||
return $this->json($res);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @desc 获取用户需求的出价列表
|
||||
* @param Request $request
|
||||
* @return \support\Response
|
||||
*/
|
||||
public function getUserRequirementBiddingOrderList(Request $request)
|
||||
{
|
||||
$service = new RequirementBiddingService();
|
||||
$res = $service->getUserRequirementBiddingOrderList($request);
|
||||
return $this->json($res);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @desc 确定出价
|
||||
* @param Request $request
|
||||
* @return \support\Response
|
||||
*/
|
||||
public function confirmBid(Request $request)
|
||||
{
|
||||
$service = new RequirementBiddingService();
|
||||
$res = $service->confirmBid($request);
|
||||
return $this->json($res);
|
||||
}
|
||||
|
||||
|
||||
}
|
@ -1,86 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace app\api\controller;
|
||||
|
||||
use app\BaseController;
|
||||
use app\common\service\RequirementService;
|
||||
use support\Request;
|
||||
|
||||
class RequirementController extends BaseController
|
||||
{
|
||||
|
||||
/**
|
||||
* @desc 发布需求
|
||||
* @param Request $request
|
||||
* @return \support\Response
|
||||
*/
|
||||
public function publish(Request $request)
|
||||
{
|
||||
$service = new RequirementService();
|
||||
$result = $service->publish($request);
|
||||
return $this->json($result);
|
||||
}
|
||||
|
||||
/**
|
||||
* @desc 删除需求
|
||||
* @param Request $request
|
||||
* @return \support\Response
|
||||
*/
|
||||
public function del(Request $request)
|
||||
{
|
||||
$service = new RequirementService();
|
||||
$result = $service->del($request);
|
||||
return $this->json($result);
|
||||
}
|
||||
|
||||
/**
|
||||
* @desc 需求详情
|
||||
* @param Request $request
|
||||
* @return \support\Response
|
||||
*/
|
||||
public function detail(Request $request)
|
||||
{
|
||||
$service = new RequirementService();
|
||||
$result = $service->detail($request->get());
|
||||
return $this->json($result);
|
||||
}
|
||||
|
||||
/**
|
||||
* @desc 需求列表
|
||||
* @param Request $request
|
||||
* @return \support\Response
|
||||
*/
|
||||
public function getRequirement(Request $request)
|
||||
{
|
||||
$service = new RequirementService();
|
||||
$result = $service->getRequirement($request->get());
|
||||
return $this->json($result);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @desc 用户自己的需求列表
|
||||
* @param Request $request
|
||||
* @return \support\Response
|
||||
*/
|
||||
public function getUserSelfRequirementList(Request $request)
|
||||
{
|
||||
$service = new RequirementService();
|
||||
$result = $service->getUserSelfRequirementList($request);
|
||||
return $this->json($result);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @desc 竞价中的需求
|
||||
* @param Request $request
|
||||
* @return \support\Response
|
||||
*/
|
||||
public function getBidRequirements(Request $request)
|
||||
{
|
||||
$service = new RequirementService();
|
||||
$res = $service->getBidRequirements($request);
|
||||
return $this->json($res);
|
||||
}
|
||||
|
||||
}
|
@ -1,36 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace app\api\controller;
|
||||
|
||||
use app\BaseController;
|
||||
use app\common\service\RequirementOrderService;
|
||||
use support\Request;
|
||||
|
||||
class RequirementOrderController extends BaseController
|
||||
{
|
||||
|
||||
/**
|
||||
* @desc 支付
|
||||
* @param Request $request
|
||||
* @return \support\Response
|
||||
*/
|
||||
public function payRequirement(Request $request)
|
||||
{
|
||||
$service = new RequirementOrderService();
|
||||
$res = $service->payRequirement($request);
|
||||
return $this->json($res);
|
||||
}
|
||||
|
||||
/**
|
||||
* @desc 需求退款
|
||||
* @param Request $request
|
||||
* @return \support\Response
|
||||
*/
|
||||
public function requirementRefund(Request $request)
|
||||
{
|
||||
$service = new RequirementOrderService();
|
||||
$res = $service->requirementRefund($request->post());
|
||||
return $this->json($res);
|
||||
}
|
||||
|
||||
}
|
@ -1,24 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace app\api\controller;
|
||||
|
||||
use app\BaseController;
|
||||
use app\common\service\ServiceStandardService;
|
||||
use support\Request;
|
||||
|
||||
class ServiceStandardController extends BaseController
|
||||
{
|
||||
|
||||
/**
|
||||
* @desc 服务标准
|
||||
* @param Request $request
|
||||
* @return \support\Response
|
||||
*/
|
||||
public function getStandard(Request $request)
|
||||
{
|
||||
$service = new ServiceStandardService();
|
||||
$res = $service->getStandard($request);
|
||||
return $this->json($res);
|
||||
}
|
||||
|
||||
}
|
@ -1,19 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace app\api\controller;
|
||||
|
||||
use app\BaseController;
|
||||
use app\common\service\ServiceTypeService;
|
||||
use support\Request;
|
||||
|
||||
class ServiceTypeController extends BaseController
|
||||
{
|
||||
protected $noNeedLogin = ['*'];
|
||||
public function getServiceType(Request $request)
|
||||
{
|
||||
$service = new ServiceTypeService();
|
||||
$res = $service->getServiceType($request->get());
|
||||
return $this->json($res);
|
||||
}
|
||||
|
||||
}
|
@ -1,20 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace app\api\controller;
|
||||
|
||||
use app\BaseController;
|
||||
use app\common\service\SlideshowService;
|
||||
use support\Request;
|
||||
|
||||
class SlideshowController extends BaseController
|
||||
{
|
||||
protected $noNeedLogin = ['*'];
|
||||
|
||||
public function getSlideshow(Request $request)
|
||||
{
|
||||
$service = new SlideshowService();
|
||||
$res = $service->getSlideshow();
|
||||
return $this->json($res);
|
||||
}
|
||||
|
||||
}
|
25
app/api/controller/StudentController.php
Normal file
25
app/api/controller/StudentController.php
Normal file
@ -0,0 +1,25 @@
|
||||
<?php
|
||||
|
||||
namespace app\api\controller;
|
||||
|
||||
use app\BaseController;
|
||||
use app\common\service\StudentService;
|
||||
use support\Request;
|
||||
|
||||
class StudentController extends BaseController
|
||||
{
|
||||
protected $noNeedLogin = ['login'];
|
||||
|
||||
/**
|
||||
* @desc 登录
|
||||
* @param Request $request
|
||||
* @return \support\Response
|
||||
*/
|
||||
public function login(Request $request)
|
||||
{
|
||||
$service = new StudentService();
|
||||
$res = $service->login($request->post());
|
||||
return $this->json($res);
|
||||
}
|
||||
|
||||
}
|
@ -1,48 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace app\api\controller;
|
||||
|
||||
use app\BaseController;
|
||||
use app\common\service\StudioApplyService;
|
||||
use support\Request;
|
||||
|
||||
class StudioApplyController extends BaseController
|
||||
{
|
||||
|
||||
/**
|
||||
* @desc 申请加入工作室
|
||||
* @param Request $request
|
||||
* @return \support\Response
|
||||
*/
|
||||
public function apply(Request $request)
|
||||
{
|
||||
$service = new StudioApplyService();
|
||||
$res = $service->apply($request);
|
||||
return $this->json($res);
|
||||
}
|
||||
|
||||
/**
|
||||
* @desc 申请列表
|
||||
* @param Request $request
|
||||
* @return \support\Response
|
||||
*/
|
||||
public function getPhotographerApplyList(Request $request)
|
||||
{
|
||||
$service = new StudioApplyService();
|
||||
$res = $service->getPhotographerApplyList($request->get());
|
||||
return $this->json($res);
|
||||
}
|
||||
|
||||
/**
|
||||
* @desc 更改审核状态
|
||||
* @param Request $request
|
||||
* @return \support\Response
|
||||
*/
|
||||
public function changeApplyStatus(Request $request)
|
||||
{
|
||||
$service = new StudioApplyService();
|
||||
$res = $service->changeApplyStatus($request);
|
||||
return $this->json($res);
|
||||
}
|
||||
|
||||
}
|
@ -1,76 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace app\api\controller;
|
||||
|
||||
use app\BaseController;
|
||||
use app\common\service\StudioService;
|
||||
use support\Request;
|
||||
use think\Exception;
|
||||
|
||||
class StudioController extends BaseController
|
||||
{
|
||||
|
||||
protected $noNeedLogin = ['detail'];
|
||||
/**
|
||||
* @desc 添加工作室
|
||||
* @param Request $request
|
||||
* @return \support\Response
|
||||
*/
|
||||
public function add(Request $request)
|
||||
{
|
||||
$service = new StudioService();
|
||||
$res = $service->add($request);
|
||||
return $this->json($res);
|
||||
}
|
||||
|
||||
/**
|
||||
* @desc 工作室列表
|
||||
* @param Request $request
|
||||
* @return \support\Response
|
||||
*/
|
||||
public function select(Request $request)
|
||||
{
|
||||
$service = new StudioService();
|
||||
$res = $service->select($request);
|
||||
return $this->json($res);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @desc 工作室详情
|
||||
* @param Request $request
|
||||
* @return \support\Response
|
||||
*/
|
||||
public function detail(Request $request)
|
||||
{
|
||||
$service = new StudioService();
|
||||
$res = $service->detail($request);
|
||||
return $this->json($res);
|
||||
}
|
||||
|
||||
/**
|
||||
* @desc 工作室摄影师
|
||||
* @param Request $request
|
||||
* @return \support\Response
|
||||
*/
|
||||
public function getStudioPhotographer(Request $request)
|
||||
{
|
||||
$service = new StudioService();
|
||||
$res = $service->getStudioPhotographer($request->get());
|
||||
return $this->json($res);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @desc 移除摄影师
|
||||
* @param Request $request
|
||||
* @return \support\Response
|
||||
*/
|
||||
public function removePhotographer(Request $request)
|
||||
{
|
||||
$service = new StudioService();
|
||||
$res = $service->removePhotographer($request);
|
||||
return $this->json($res);
|
||||
}
|
||||
|
||||
}
|
@ -7,6 +7,7 @@ use app\common\model\TimeZone;
|
||||
use app\common\service\UploadService;
|
||||
use app\constant\ResponseCode;
|
||||
use app\utils\QiniuUtils;
|
||||
use support\Redis;
|
||||
use support\Request;
|
||||
use Tinywan\Jwt\JwtToken;
|
||||
|
||||
@ -20,6 +21,13 @@ class TestController extends BaseController
|
||||
|
||||
try {
|
||||
|
||||
phpinfo();
|
||||
$res = Redis::setEx('test', 60, 10);
|
||||
|
||||
print '<pre>';
|
||||
print_r($res);
|
||||
die;
|
||||
|
||||
|
||||
$time_zone = json_decode(file_get_contents(base_path('/timezones.json')), true);
|
||||
|
||||
|
28
app/common/model/Student.php
Normal file
28
app/common/model/Student.php
Normal file
@ -0,0 +1,28 @@
|
||||
<?php
|
||||
|
||||
namespace app\common\model;
|
||||
|
||||
use app\BaseModel;
|
||||
use support\Model;
|
||||
|
||||
/**
|
||||
* wa_student 学生
|
||||
* @property integer $id (主键)
|
||||
* @property string $student_name 学生姓名
|
||||
* @property string $account 账号
|
||||
* @property string $password 密码
|
||||
* @property string $salt 密码盐
|
||||
* @property string $nickname 昵称
|
||||
* @property string $avatar 头像
|
||||
* @property string $mobile 手机号
|
||||
* @property string $birthday 生日
|
||||
* @property integer $parent_id 家长
|
||||
* @property mixed $created_at 创建时间
|
||||
* @property string $updated_at 更新时间
|
||||
* @property string $deleted_at
|
||||
*/
|
||||
class Student extends BaseModel
|
||||
{
|
||||
|
||||
|
||||
}
|
27
app/common/model/StudentParent.php
Normal file
27
app/common/model/StudentParent.php
Normal file
@ -0,0 +1,27 @@
|
||||
<?php
|
||||
|
||||
namespace app\common\model;
|
||||
|
||||
use app\BaseModel;
|
||||
use support\Model;
|
||||
|
||||
/**
|
||||
* wa_student_parent 家长
|
||||
* @property integer $id (主键)
|
||||
* @property string $parent_name 家长姓名
|
||||
* @property string $account 账号
|
||||
* @property string $salt 密码盐
|
||||
* @property string $password 密码
|
||||
* @property string $nickname 昵称
|
||||
* @property string $avatar 头像
|
||||
* @property string $mobile 手机号
|
||||
* @property string $birthday 生日
|
||||
* @property mixed $created_at 创建时间
|
||||
* @property string $updated_at 更新时间
|
||||
* @property string $deleted_at
|
||||
*/
|
||||
class StudentParent extends BaseModel
|
||||
{
|
||||
|
||||
|
||||
}
|
@ -1,295 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace app\common\service;
|
||||
|
||||
use app\common\model\CaseShare;
|
||||
use app\common\model\Photographer;
|
||||
use app\common\model\ServiceType;
|
||||
use app\common\model\User;
|
||||
use app\common\validate\CaseShareValidate;
|
||||
use app\constant\ResponseCode;
|
||||
use think\Exception;
|
||||
|
||||
class CaseShareService
|
||||
{
|
||||
|
||||
public function insert($request)
|
||||
{
|
||||
try {
|
||||
|
||||
$user = User::where(['id' => $request->user->id])->findOrEmpty();
|
||||
if (!$user->is_photographer) {
|
||||
throw new Exception('您还不是摄影师,不能发布案例');
|
||||
}
|
||||
|
||||
$validate = new CaseShareValidate();
|
||||
$requestData = $request->post();
|
||||
if (!$validate->check($requestData)) {
|
||||
throw new Exception($validate->getError());
|
||||
}
|
||||
|
||||
//查找摄影师
|
||||
$photographer = Photographer::where(['user_id' => $request->user->id])->findOrEmpty();
|
||||
if ($photographer->isEmpty()) {
|
||||
throw new Exception('为找到摄影师信息');
|
||||
}
|
||||
$service_type = ServiceType::where(['id'=>$requestData['service_type']])->findOrEmpty();
|
||||
CaseShare::create([
|
||||
'user_id' => $request->user->id,
|
||||
'photographer_id' => $photographer->id,
|
||||
'service_type' => $requestData['service_type'],
|
||||
'service_name' => $service_type->service_name,
|
||||
'case_name' => $requestData['case_name'],
|
||||
'case_briefing' => $requestData['case_briefing'],
|
||||
'case_introduce' => $requestData['case_introduce'],
|
||||
'imgs' => !empty($requestData['imgs']) ? $requestData['imgs'] : '',
|
||||
// 'imgs' => !empty($requestData['imgs']) ? json_encode($requestData['imgs'], JSON_UNESCAPED_UNICODE) : '',
|
||||
]);
|
||||
|
||||
return [
|
||||
'code' => ResponseCode::SUCCESS,
|
||||
'data' => [],
|
||||
'msg' => '提交成功,审核成功后自动发布'
|
||||
];
|
||||
} catch (Exception $e) {
|
||||
return [
|
||||
'code' => ResponseCode::FAIL,
|
||||
'msg' => $e->getMessage()
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @desc 更新案例
|
||||
* @param $request
|
||||
* @return array
|
||||
*/
|
||||
public function update($request)
|
||||
{
|
||||
try {
|
||||
$req_data = $request->post();
|
||||
$case = CaseShare::where(['id' => $req_data['id']])->findOrEmpty();
|
||||
if ($case->isEmpty()) {
|
||||
throw new Exception('未找到案例');
|
||||
}
|
||||
if ($case->user_id != $request->user->id) {
|
||||
throw new Exception('非案例所有者不能操作');
|
||||
}
|
||||
//查找摄影师
|
||||
$photographer = Photographer::where(['user_id' => $request->user->id])->findOrEmpty();
|
||||
if ($photographer->isEmpty()) {
|
||||
throw new Exception('为找到摄影师信息');
|
||||
}
|
||||
|
||||
$validate = new CaseShareValidate();
|
||||
if (!$validate->check($req_data)) {
|
||||
throw new Exception($validate->getError());
|
||||
}
|
||||
$res = $case->save([
|
||||
'photographer_id' => $photographer->id,
|
||||
'service_type' => $req_data['service_type'],
|
||||
'case_name' => $req_data['case_name'],
|
||||
'case_briefing' => $req_data['case_briefing'],
|
||||
'case_introduce' => $req_data['case_introduce'],
|
||||
'imgs' => empty($req_data['imgs']) ? '' : json_encode($req_data['img'], JSON_UNESCAPED_UNICODE),
|
||||
]);
|
||||
|
||||
if (!$res) {
|
||||
throw new Exception('更新失败');
|
||||
}
|
||||
return [
|
||||
'code' => ResponseCode::SUCCESS,
|
||||
'msg' => '更新成功'
|
||||
];
|
||||
|
||||
} catch (Exception $e) {
|
||||
return [
|
||||
'code' => ResponseCode::FAIL,
|
||||
'msg' => $e->getMessage()
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @desc 删除成功
|
||||
* @param $request
|
||||
* @return array
|
||||
*/
|
||||
public function del($request)
|
||||
{
|
||||
try {
|
||||
$case = CaseShare::where(['id' => $request['id']])->findOrEmpty();
|
||||
if ($case->isEmpty()) {
|
||||
throw new Exception('未找到案例或已被删除');
|
||||
}
|
||||
$res = $case->delete();
|
||||
if (!$res) {
|
||||
throw new Exception('操作失败');
|
||||
}
|
||||
return [
|
||||
'code' => ResponseCode::SUCCESS,
|
||||
'msg' => '已删除成功'
|
||||
];
|
||||
|
||||
} catch (Exception $e) {
|
||||
return [
|
||||
'code' => ResponseCode::FAIL,
|
||||
'msg' => $e->getMessage()
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @desc 案例列表
|
||||
* @param $request
|
||||
* @return array
|
||||
*/
|
||||
public function getCaseShareList($request)
|
||||
{
|
||||
try {
|
||||
$case = CaseShare::where(['is_apply' => 1]);
|
||||
if (isset($request['is_recommend']) && $request['is_recommend']) {
|
||||
$case->where(['is_recommend' => $request['is_recommend']]);
|
||||
}
|
||||
if (isset($request['service_type']) && $request['service_type']) {
|
||||
$case->where(['service_type' => $request['service_type']]);
|
||||
}
|
||||
$page = isset($request['page']) ? $request['page'] : 1;
|
||||
$limit = isset($request['limit']) ? $request['limit'] : 10;
|
||||
$total = $case->count();
|
||||
$list = $case->with(['photographer'])->page($page, $limit)->select();
|
||||
|
||||
foreach ($list as &$item){
|
||||
if($item['imgs']){
|
||||
$item['imgs'] = explode(',', stripslashes($item['imgs']));
|
||||
}
|
||||
}
|
||||
|
||||
return [
|
||||
'code' => ResponseCode::SUCCESS,
|
||||
'data' => [
|
||||
'list' => $list,
|
||||
'total' => $total,
|
||||
'page' => $page
|
||||
],
|
||||
'msg' => 'success'
|
||||
];
|
||||
|
||||
} catch (Exception $e) {
|
||||
return [
|
||||
'code' => ResponseCode::FAIL,
|
||||
'msg' => $e->getMessage()
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @desc 用户案例列表
|
||||
* @param $request
|
||||
* @return array
|
||||
*/
|
||||
public function getUserCaseShareList($request)
|
||||
{
|
||||
try {
|
||||
$requestData = $request->get();
|
||||
$case = CaseShare::where(['user_id' => $request->user->id]);
|
||||
if (isset($requestData['is_recommend']) && $requestData['is_recommend']) {
|
||||
$case->where(['is_recommend' => $requestData['is_recommend']]);
|
||||
}
|
||||
if (isset($requestData['service_type']) && $requestData['service_type']) {
|
||||
$case->where(['service_type' => $requestData['service_type']]);
|
||||
}
|
||||
$page = isset($requestData['page']) ? $requestData['page'] : 1;
|
||||
$limit = isset($requestData['limit']) ? $requestData['limit'] : 10;
|
||||
$total = $case->count();
|
||||
$list = $case->page($page, $limit)->select();
|
||||
|
||||
foreach ($list as &$item){
|
||||
if($item['imgs']){
|
||||
$item['imgs'] = explode(',', $item['imgs']);
|
||||
}
|
||||
}
|
||||
|
||||
return [
|
||||
'code' => ResponseCode::SUCCESS,
|
||||
'data' => [
|
||||
'list' => $list,
|
||||
'total' => $total,
|
||||
'page' => $page
|
||||
],
|
||||
'msg' => 'success'
|
||||
];
|
||||
|
||||
} catch (Exception $e) {
|
||||
return [
|
||||
'code' => ResponseCode::FAIL,
|
||||
'msg' => $e->getMessage()
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @desc 案例详情
|
||||
* @param $request
|
||||
* @return array
|
||||
*/
|
||||
public function caseDetail($request)
|
||||
{
|
||||
try {
|
||||
$case = CaseShare::where(['id' => $request['id']])->with(['serviceType', 'photographer'])->findOrEmpty();
|
||||
if ($case->isEmpty()) {
|
||||
throw new Exception('未找到案例');
|
||||
}
|
||||
if ($case->imgs) {
|
||||
$case->imgs = explode(',', $case->imgs);
|
||||
}
|
||||
return [
|
||||
'code' => ResponseCode::SUCCESS,
|
||||
'data' => $case,
|
||||
];
|
||||
} catch (Exception $e) {
|
||||
return [
|
||||
'code' => ResponseCode::FAIL,
|
||||
'msg' => $e->getMessage()
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @desc 摄影师案例服务类型
|
||||
* @param $request
|
||||
* @return array
|
||||
*/
|
||||
public function getPhotographerCaseShareServiceType($request)
|
||||
{
|
||||
try {
|
||||
$photographer = Photographer::where(['id' => $request['photographer_id']])->findOrEmpty();
|
||||
if ($photographer->isEmpty()) {
|
||||
throw new Exception('摄影师不存在');
|
||||
}
|
||||
|
||||
$service_type = CaseShare::where(['photographer_id' => $request['photographer_id']])->field('service_type')->select()->toArray();
|
||||
if($service_type){
|
||||
$service_type = array_unique(array_column($service_type, 'service_type'));
|
||||
$service_type = ServiceType::where(['id'=>$service_type])->order('sort desc, id desc')->field('id,service_name')->select();
|
||||
}else{
|
||||
$service_type = [];
|
||||
}
|
||||
|
||||
return [
|
||||
'code' => ResponseCode::SUCCESS,
|
||||
'data' => $service_type,
|
||||
'msg' => 'success'
|
||||
];
|
||||
} catch (Exception $e) {
|
||||
return [
|
||||
'code' => ResponseCode::FAIL,
|
||||
'msg' => $e->getMessage()
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
@ -1,45 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace app\common\service;
|
||||
|
||||
use app\common\model\ChatFriend;
|
||||
use app\constant\ResponseCode;
|
||||
use think\Exception;
|
||||
|
||||
class ChatFriendService
|
||||
{
|
||||
|
||||
/**
|
||||
* @desc 获取聊天朋友
|
||||
* @param $request
|
||||
* @return array
|
||||
*/
|
||||
public function getFriends($request)
|
||||
{
|
||||
try {
|
||||
|
||||
$data = $request->get();
|
||||
$chat_friend = ChatFriend::where(['user_id' => $request->user->id])->with(['friend', 'photographer'])->order('latest_chat_time desc, id desc');
|
||||
$page = isset($data['page']) ? $data['page'] : 1;
|
||||
$limit = isset($data['limit']) ? $data['limit'] : 10;
|
||||
|
||||
$total = $chat_friend->count();
|
||||
$list = $chat_friend->page($page, $limit)->select();
|
||||
|
||||
return [
|
||||
'code' => ResponseCode::SUCCESS,
|
||||
'data' => [
|
||||
'list' => $list,
|
||||
'total' => $total,
|
||||
'page' => $page
|
||||
]
|
||||
];
|
||||
} catch (Exception $e) {
|
||||
return [
|
||||
'code' => ResponseCode::FAIL,
|
||||
'msg' => $e->getMessage()
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -1,145 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace app\common\service;
|
||||
|
||||
use app\common\model\ChatFriend;
|
||||
use app\common\model\ChatRecords;
|
||||
use app\common\model\Photographer;
|
||||
use app\constant\ResponseCode;
|
||||
use think\Exception;
|
||||
|
||||
class ChatRecordsService
|
||||
{
|
||||
|
||||
|
||||
/**
|
||||
* @desc 发送消息
|
||||
* @param $request
|
||||
* @return array
|
||||
*/
|
||||
public function sendMsg($request)
|
||||
{
|
||||
try {
|
||||
|
||||
$data = $request->post();
|
||||
//记录聊天数据
|
||||
$res = ChatRecords::create([
|
||||
'from_user_id' => $request->user->id,
|
||||
'to_user_id' => $data['user_id'],
|
||||
'type' => $data['type'],
|
||||
'content' => $data['content'],
|
||||
]);
|
||||
|
||||
//判断是否是好友
|
||||
$friend = ChatFriend::where(['user_id' => $request->user->id, 'friend_id' => $data['user_id']])->findOrEmpty();
|
||||
if ($friend->isEmpty()) {
|
||||
$friend_photographer = Photographer::where(['user_id' => $data['user_id']])->findOrEmpty();
|
||||
$friend_photographer_id = 0;
|
||||
if (!$friend_photographer->isEmpty()) {
|
||||
$friend_photographer_id = $friend_photographer->id;
|
||||
}
|
||||
ChatFriend::create([
|
||||
'user_id' => $request->user->id,
|
||||
'friend_id' => $data['user_id'],
|
||||
'photographer_id' => $friend_photographer_id
|
||||
]);
|
||||
$photographer = Photographer::where(['user_id' => $data['user_id']])->findOrEmpty();
|
||||
$photographer_id = 0;
|
||||
if (!$photographer->isEmpty()) {
|
||||
$photographer_id = $photographer->id;
|
||||
}
|
||||
ChatFriend::create([
|
||||
'user_id' => $data['user_id'],
|
||||
'friend_id' => $request->user->id,
|
||||
'photographer_id' => $photographer_id
|
||||
]);
|
||||
}
|
||||
|
||||
return [
|
||||
'code' => ResponseCode::SUCCESS,
|
||||
'msg' => '发送成功'
|
||||
];
|
||||
} catch (Exception $e) {
|
||||
return [
|
||||
'code' => ResponseCode::FAIL,
|
||||
'msg' => $e->getMessage()
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @desc 获取用户发送的消息
|
||||
* @param $request
|
||||
* @return array
|
||||
*/
|
||||
public function getUserChatMsg($request)
|
||||
{
|
||||
try {
|
||||
$data = $request->get();
|
||||
$chat_msg = ChatRecords::whereRaw('(from_user_id = ? and to_user_id = ?) or (from_user_id = ? and to_user_id = ?)', [
|
||||
$request->user->id,
|
||||
$data['user_id'],
|
||||
$data['user_id'],
|
||||
$request->user->id
|
||||
])
|
||||
->field('from_user_id,to_user_id,type,content, created_at')
|
||||
->order('created_at desc');
|
||||
|
||||
$page = isset($data['page']) ? $data['page'] : 1;
|
||||
$limit = isset($data['limit']) ? $data['limit'] : 10;
|
||||
|
||||
$total = $chat_msg->count();
|
||||
$list = $chat_msg->page($page, $limit)->select()->toArray();
|
||||
|
||||
foreach ($list as &$item) {
|
||||
if($item['from_user_id'] == $request->user->id){
|
||||
$item['is_i_send'] = 1;
|
||||
}else{
|
||||
$item['is_i_send'] = 0;
|
||||
}
|
||||
}
|
||||
|
||||
return [
|
||||
'code' => ResponseCode::SUCCESS,
|
||||
'data' => [
|
||||
'list' => $list,
|
||||
'total' => $total,
|
||||
'page' => $page
|
||||
]
|
||||
];
|
||||
} catch (Exception $e) {
|
||||
return [
|
||||
'code' => ResponseCode::FAIL,
|
||||
'msg' => $e->getMessage()
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @desc 标记消息已读
|
||||
* @param $request
|
||||
* @return array
|
||||
*/
|
||||
public function updateMsgRead($request)
|
||||
{
|
||||
try {
|
||||
|
||||
$data = $request->post();
|
||||
ChatRecords::where(['from_user_id' => $data['from_user_id'], 'to_user_id' => $request->user->id, 'status' => 0])->update(['status' => 1]);
|
||||
|
||||
return [
|
||||
'code' => ResponseCode::SUCCESS,
|
||||
'msg' => '已读',
|
||||
];
|
||||
} catch (Exception $e) {
|
||||
return [
|
||||
'code' => ResponseCode::FAIL,
|
||||
'msg' => $e->getMessage()
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
@ -1,82 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace app\common\service;
|
||||
|
||||
use app\common\model\BiddingOrder;
|
||||
use app\common\model\DepositOrder;
|
||||
use app\common\model\Requirement;
|
||||
use app\common\model\User;
|
||||
use app\constant\ResponseCode;
|
||||
use think\Exception;
|
||||
|
||||
class DepositOrderService
|
||||
{
|
||||
/**
|
||||
* 需求保证金回调地址
|
||||
*/
|
||||
const NOTIFY_URL = '/notify/WechatPayNotify/requirement_deposit_notify';
|
||||
|
||||
|
||||
/**
|
||||
* @desc 竞价订单支付定金
|
||||
* @param $request
|
||||
* @return array
|
||||
*/
|
||||
public function payBidOrder($request)
|
||||
{
|
||||
try {
|
||||
$requestData = $request->post();
|
||||
$bidding_order = BiddingOrder::where(['id' => $requestData['bidding_order_id']])->findOrEmpty();
|
||||
if ($bidding_order->isEmpty()) {
|
||||
throw new Exception('未找到出价订单');
|
||||
}
|
||||
if ($bidding_order->bind_status != 1) {
|
||||
throw new Exception('该出价订单未中标,支付失败');
|
||||
}
|
||||
if ($bidding_order->pay_final_status != 0) {
|
||||
throw new Exception('订单状态异常,支付失败');
|
||||
}
|
||||
$requirement = Requirement::where(['id' => $bidding_order->requirement_id])->findOrEmpty();
|
||||
//@todo:判断是否需要支付定金
|
||||
if(1){
|
||||
|
||||
}
|
||||
|
||||
$trade_no = generate_order_no('B');
|
||||
//创建订单
|
||||
DepositOrder::create([
|
||||
'user_id' => $bidding_order->user_id,
|
||||
'photographer_id' => $bidding_order->photographer_id,
|
||||
'detail' => json_encode($requirement->toArray()),
|
||||
'order_type' => 'requirement',
|
||||
'deposit_amount' => $requirement->deposit_amount,
|
||||
'trade_no' => $trade_no,
|
||||
'pay_status' => 0,
|
||||
]);
|
||||
|
||||
$pay_data = [
|
||||
'trade_no' => $trade_no,
|
||||
'total_amount' => $bidding_order->bidding_price,
|
||||
'desc' => $requirement->requirement_trade_no . '-定金',
|
||||
'notify_url' => getenv('SERVER_DOMAIN') . self::NOTIFY_URL,//回调地址
|
||||
'openid' => $request->user->openid,
|
||||
];
|
||||
$result = (new PayService())->payment($pay_data);
|
||||
|
||||
if(isset($result['code'])){
|
||||
throw new Exception($result['msg']);
|
||||
}
|
||||
|
||||
return [
|
||||
'code' => ResponseCode::SUCCESS,
|
||||
'data' => $result,
|
||||
];
|
||||
} catch (Exception $e) {
|
||||
return [
|
||||
'code' => ResponseCode::FAIL,
|
||||
'msg' => $e->getMessage()
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -1,36 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace app\common\service;
|
||||
|
||||
use app\common\model\Device;
|
||||
use app\constant\ResponseCode;
|
||||
use think\Exception;
|
||||
|
||||
class DeviceService
|
||||
{
|
||||
|
||||
/**
|
||||
* @desc 设备列表
|
||||
* @return array
|
||||
*/
|
||||
public function getDeviceService()
|
||||
{
|
||||
try {
|
||||
$list = Device::order('sort desc, id desc')->field('id,device_name')->select();
|
||||
|
||||
return [
|
||||
'code' => ResponseCode::SUCCESS,
|
||||
'data' => [
|
||||
'list' => $list
|
||||
],
|
||||
'msg' => 'success'
|
||||
];
|
||||
} catch (Exception $e) {
|
||||
return [
|
||||
'code' => ResponseCode::FAIL,
|
||||
'msg' => $e->getMessage()
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -1,128 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace app\common\service;
|
||||
|
||||
use app\common\model\Favorite;
|
||||
use app\constant\ResponseCode;
|
||||
use support\Redis;
|
||||
use think\Exception;
|
||||
|
||||
class FavoriteService
|
||||
{
|
||||
|
||||
|
||||
/**
|
||||
* @desc 收藏
|
||||
* @param $request
|
||||
* @return array
|
||||
*/
|
||||
public function add($request)
|
||||
{
|
||||
try {
|
||||
$data = $request->post();
|
||||
|
||||
$redis_key = 'favorite_' . $request->user->id . '-' . $data['photographer_id'];
|
||||
|
||||
if (Redis::get($redis_key)) {
|
||||
throw new Exception('不能操作太频繁哟~');
|
||||
}
|
||||
Redis::setEx($redis_key, 5, 1);
|
||||
|
||||
$favorite = Favorite::where(['user_id' => $request->user->id, 'photographer_id' => $data['photographer_id']])->findOrEmpty();
|
||||
if (!$favorite->isEmpty()) {
|
||||
throw new Exception('您已收藏了该摄影师,不能重复收藏哟~');
|
||||
}
|
||||
|
||||
$res = Favorite::create([
|
||||
'user_id' => $request->user->id,
|
||||
'photographer_id' => $data['photographer_id']
|
||||
]);
|
||||
if (!$res) {
|
||||
throw new Exception('收藏失败');
|
||||
}
|
||||
|
||||
return [
|
||||
'code' => ResponseCode::SUCCESS,
|
||||
'msg' => '收藏成功'
|
||||
];
|
||||
} catch (Exception $e) {
|
||||
return [
|
||||
'code' => ResponseCode::FAIL,
|
||||
'msg' => $e->getMessage()
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @desc 取消收藏
|
||||
* @param $request
|
||||
* @return array
|
||||
*/
|
||||
public function cancel($request)
|
||||
{
|
||||
try {
|
||||
$data = $request->post();
|
||||
|
||||
$redis_key = 'favorite_' . $request->user->id . '-' . $data['photographer_id'];
|
||||
|
||||
if (Redis::get($redis_key)) {
|
||||
throw new Exception('不能操作太频繁哟~');
|
||||
}
|
||||
Redis::setEx($redis_key, 5, 1);
|
||||
|
||||
$favorite = Favorite::where(['user_id' => $request->user->id, 'photographer_id' => $data['photographer_id']])->findOrEmpty();
|
||||
if ($favorite->isEmpty()) {
|
||||
throw new Exception('您未收藏该摄影师');
|
||||
}
|
||||
$res = $favorite->delete();
|
||||
if (!$res) {
|
||||
throw new Exception('取消收藏失败');
|
||||
}
|
||||
|
||||
return [
|
||||
'code' => ResponseCode::SUCCESS,
|
||||
'msg' => '取消成功'
|
||||
];
|
||||
} catch (Exception $e) {
|
||||
return [
|
||||
'code' => ResponseCode::FAIL,
|
||||
'msg' => $e->getMessage()
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @desc 收藏列表
|
||||
* @param $request
|
||||
* @return array
|
||||
*/
|
||||
public function getFavoriteList($request)
|
||||
{
|
||||
try {
|
||||
$data = $request->get();
|
||||
$favorite = Favorite::order('id desc')->where(['user_id' => $request->user->id]);
|
||||
|
||||
$page = isset($data['page']) ? $data['page'] : 1;
|
||||
$limit = isset($data['limit']) ? $data['limit'] : 10;
|
||||
$total = $favorite->count();
|
||||
$list = $favorite->with(['photographer'])->page($page, $limit)->select();
|
||||
|
||||
return [
|
||||
'code' => ResponseCode::SUCCESS,
|
||||
'data' => [
|
||||
'list' => $list,
|
||||
'total' => $total,
|
||||
'page' => $page
|
||||
]
|
||||
];
|
||||
} catch (Exception $e) {
|
||||
return [
|
||||
'code' => ResponseCode::FAIL,
|
||||
'msg' => $e->getMessage()
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -1,38 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace app\common\service;
|
||||
|
||||
use app\common\model\PaidService;
|
||||
use app\constant\ResponseCode;
|
||||
use think\Exception;
|
||||
|
||||
class PaidServiceService
|
||||
{
|
||||
|
||||
/**
|
||||
* @desc 增值服务列表
|
||||
* @param $request
|
||||
* @return array
|
||||
*/
|
||||
public function getList($request)
|
||||
{
|
||||
try {
|
||||
$model = PaidService::order('sort desc,id desc');
|
||||
if(isset($request['service_type_id']) && $request['service_type_id']){
|
||||
$model->where(['service_type_id'=>$request['service_type_id']]);
|
||||
}
|
||||
|
||||
$list = $model->field('id,service_name,price')->select();
|
||||
return [
|
||||
'code' => ResponseCode::SUCCESS,
|
||||
'data'=> $list
|
||||
];
|
||||
}catch (Exception $e){
|
||||
return [
|
||||
'code' => ResponseCode::FAIL,
|
||||
'msg' => $e->getMessage()
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -1,180 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace app\common\service;
|
||||
|
||||
use app\common\service\Channel\wechat\WechatConstants;
|
||||
use app\constant\ResponseCode;
|
||||
use GuzzleHttp\Exception\RequestException;
|
||||
use think\Exception;
|
||||
use WeChatPay\Builder;
|
||||
use WeChatPay\Crypto\Rsa;
|
||||
use WeChatPay\Formatter;
|
||||
use WeChatPay\Util\PemUtil;
|
||||
|
||||
class PayService
|
||||
{
|
||||
protected $config;
|
||||
protected $instance;
|
||||
protected $platformPublicKeyInstance;
|
||||
protected $merchantPrivateKeyInstance;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
// 服务商 商户号
|
||||
$merchantId = getenv('MERCHANT_ID');
|
||||
// 从本地文件中加载「商户API私钥」,「商户API私钥」会用来生成请求的签名
|
||||
$merchantPrivateKeyFilePath = 'file://' . base_path() . '/certificate/apiclient_key.pem';
|
||||
|
||||
$this->merchantPrivateKeyInstance = Rsa::from($merchantPrivateKeyFilePath, Rsa::KEY_TYPE_PRIVATE);
|
||||
|
||||
// 「商户API证书」的「证书序列号」
|
||||
$merchantCertificateSerial = '3297EB3A1132A39DAFFD70A6C4A6C3078CD346F7';
|
||||
|
||||
// 从本地文件中加载「微信支付平台证书」,用来验证微信支付应答的签名
|
||||
$platformCertificateFilePath = 'file://' . base_path() . '/certificate/wechatpay_660FAD2D6E804E37BE9D77EF5882718CC1E3399F.pem';
|
||||
$this->platformPublicKeyInstance = Rsa::from($platformCertificateFilePath, Rsa::KEY_TYPE_PUBLIC);
|
||||
|
||||
// 从「微信支付平台证书」中获取「证书序列号」
|
||||
$platformCertificateSerial = PemUtil::parseCertificateSerialNo($platformCertificateFilePath);
|
||||
|
||||
// 构造一个 APIv3 客户端实例
|
||||
$this->instance = Builder::factory([
|
||||
'mchid' => $merchantId,
|
||||
'serial' => $merchantCertificateSerial,
|
||||
'privateKey' => $this->merchantPrivateKeyInstance,
|
||||
'certs' => [
|
||||
$platformCertificateSerial => $this->platformPublicKeyInstance,
|
||||
],
|
||||
]);
|
||||
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @desc jsapi支付
|
||||
* @param array $pay_data
|
||||
* @param $seller_channel
|
||||
* @return array
|
||||
*/
|
||||
public function payment(array $pay_data)
|
||||
{
|
||||
try {
|
||||
|
||||
$request_data = [
|
||||
'appid' => getenv('APP_ID'),// 公众号ID
|
||||
'mchid' => getenv('MERCHANT_ID'),//直连商户号
|
||||
'description' => $pay_data['desc'],//商品描述
|
||||
'out_trade_no' => $pay_data['out_trade_no'],//商户订单号
|
||||
'notify_url' => $pay_data['notify_url'],//通知地址
|
||||
'amount' => [
|
||||
'total' => round($pay_data['total_amount'] * 100),//总金额 单位为分
|
||||
],
|
||||
'payer' => [
|
||||
'openid' => $pay_data['openid'],// 用户在服务商AppID下的唯一标识
|
||||
]
|
||||
];
|
||||
|
||||
$resp = $this->instance
|
||||
->chain('/v3/pay/transactions/jsapi')
|
||||
->post([
|
||||
'json' => $request_data,
|
||||
// 'debug' => true
|
||||
]);
|
||||
|
||||
$result = json_decode($resp->getBody(), true);
|
||||
|
||||
raw_log('wechat_pay/transactions_jsapi', ['request_data' => $request_data, 'result' => $result]);
|
||||
|
||||
$pay_data = [
|
||||
'appId' => getenv('APP_ID'), //微信小程序appid
|
||||
'timeStamp' => strval(Formatter::timestamp()),
|
||||
'nonceStr' => Formatter::nonce(),
|
||||
'package' => 'prepay_id=' . $result['prepay_id'],
|
||||
];
|
||||
$pay_data['paySign'] = Rsa::sign(
|
||||
Formatter::joinedByLineFeed(...array_values($pay_data)),
|
||||
$this->merchantPrivateKeyInstance
|
||||
);
|
||||
$pay_data['signType'] = 'RSA';
|
||||
|
||||
return $pay_data;
|
||||
} catch (RequestException $exception) {
|
||||
$response = $exception->getResponse();
|
||||
$result = json_decode($response->getBody()->getContents(), true);
|
||||
|
||||
raw_log('wechat_pay/transactions_jsapi_failed', ['pay_data' => $pay_data, 'result' => $result]);
|
||||
return [
|
||||
'code' => ResponseCode::FAIL,
|
||||
'msg' => $result['message']
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @desc 退款
|
||||
* @param $refund_data
|
||||
* @return array
|
||||
*/
|
||||
public function refundPayment($refund_data)
|
||||
{
|
||||
try {
|
||||
//退款数据
|
||||
$request_data = [
|
||||
'out_trade_no' => $refund_data['out_trade_no'],//微信支付订单号
|
||||
'out_refund_no' => $refund_data['out_refund_no'],//商户退款单号
|
||||
'reason' => $refund_data['refund_desc'],//退款原因
|
||||
'notify_url' => $refund_data['notify_url'],//通知地址
|
||||
'amount' => [
|
||||
'refund' => round($refund_data['refund_amount'] * 100),//退款金额
|
||||
'total' => round($refund_data['total'] * 100),//原订单金额
|
||||
'currency' => 'CNY',//退款币种
|
||||
]
|
||||
];
|
||||
$resp = $this->instance
|
||||
->chain('/v3/refund/domestic/refunds')
|
||||
->post([
|
||||
'json' => $request_data,
|
||||
// 'debug' => true
|
||||
]);
|
||||
|
||||
$result = json_decode($resp->getBody(), true);
|
||||
raw_log('wechat_pay/refund', ['request_data' => $request_data, 'result' => $result]);
|
||||
|
||||
return [
|
||||
'transaction_id' => $result['transaction_id'],
|
||||
'out_transaction_id' => $result['refund_id'],
|
||||
'out_trade_no' => $result['out_refund_no'],
|
||||
];
|
||||
|
||||
} catch (RequestException $exception) {
|
||||
$response = $exception->getResponse();
|
||||
$result = json_decode($response->getBody()->getContents(), true);
|
||||
raw_log('wechat_pay/refund_failed', ['request_data' => $request_data, 'result' => $result]);
|
||||
|
||||
return [
|
||||
'code' => ResponseCode::FAIL,
|
||||
'msg' => $result['message']
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @desc 余额查询 微信没有余额查询接口,返回假数据
|
||||
* @param $seller_channel
|
||||
* @return array
|
||||
*/
|
||||
public function queryBalanceAmount($seller_channel)
|
||||
{
|
||||
return [
|
||||
'code'=>ResponseCode::SUCCESS,
|
||||
'data'=>[
|
||||
'total_amount'=>0.00,
|
||||
'settled_amount'=>0.00,
|
||||
'not_settled_amount'=>0.00
|
||||
]
|
||||
];
|
||||
}
|
||||
|
||||
}
|
@ -1,378 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace app\common\service;
|
||||
|
||||
use app\common\model\DepositOrder;
|
||||
use app\common\model\PaidService;
|
||||
use app\common\model\Photographer;
|
||||
use app\common\model\PhotoService;
|
||||
use app\common\model\PhotoServiceOrder;
|
||||
use app\constant\ResponseCode;
|
||||
use support\Redis;
|
||||
use think\Exception;
|
||||
|
||||
class PhotoServiceOrderService
|
||||
{
|
||||
|
||||
const NOTIFY_URL = '/notify/WechatPayNotify/photo_notify';
|
||||
const NOTIFY_DEPOSIT_URL = '/notify/WechatPayNotify/photo_deposit_notify';
|
||||
|
||||
public function pay($request)
|
||||
{
|
||||
try {
|
||||
$data = $request->post();
|
||||
|
||||
$redis_key = 'photo_service_order_' . $request->user->id;
|
||||
// if (Redis::get($redis_key)) {
|
||||
// throw new Exception('请勿频繁操作');
|
||||
// }
|
||||
// Redis::setEx($redis_key, 3, 1);
|
||||
|
||||
//计算服务价格
|
||||
$photo_service_price = 0.00;
|
||||
$paid_service_price = 0.00;
|
||||
$photo_service_detail = [];
|
||||
$paid_service_detail = [];
|
||||
if ($data['photo_service']) {
|
||||
$photo_service = json_decode($data['photo_service'], true);
|
||||
foreach ($photo_service as $item) {
|
||||
$service = PhotoService::where(['id' => $item['id']])->findOrEmpty();
|
||||
// if($service->isEmpty()){
|
||||
// throw new Exception('所选拍照服务不存在');
|
||||
// }
|
||||
$photo_service_price += round($service->price + $item['number'], 2);
|
||||
array_push($photo_service_detail, [
|
||||
'service' => $service->toArray(),
|
||||
'number' => $item['number']
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
if ($data['paid_service']) {
|
||||
$paid_service = json_decode($data['paid_service'], true);
|
||||
foreach ($paid_service as $item) {
|
||||
$service = PaidService::where(['id' => $item['id']])->findOrEmpty();
|
||||
$paid_service_price += round($service->price * $item['number'], 2);
|
||||
array_push($paid_service_detail, [
|
||||
'service' => $service->toArray(),
|
||||
'number' => $item['number']
|
||||
]);
|
||||
}
|
||||
}
|
||||
$total = round($photo_service_price + $paid_service_price, 2);
|
||||
//保证金
|
||||
$deposit = 0.00;
|
||||
if ($data['is_need_deposit']) {
|
||||
$ratio = RatioService::ratio();
|
||||
$deposit = round($total * $ratio / 100, 2);
|
||||
}
|
||||
$order_no = generate_order_no('P');
|
||||
//插入订单
|
||||
$res = PhotoServiceOrder::create([
|
||||
'user_id' => $request->user->id,
|
||||
'trade_no' => $order_no,
|
||||
'user_name' => $data['user_name'],
|
||||
'sex' => $data['sex'],
|
||||
'user_mobile' => $data['user_mobile'],
|
||||
'service_address' => $data['service_address'],
|
||||
'service_time' => $data['service_time'],
|
||||
'photo_service_type' => $data['photo_service_type'],
|
||||
'photo_service_data' => $data['photo_service'],
|
||||
'photo_service_detail' => json_encode($photo_service_detail),
|
||||
|
||||
'paid_service_type' => $data['paid_service_type'],
|
||||
'paid_service_data' => $data['paid_service'],
|
||||
'paid_service_detail' => json_encode($paid_service_detail),
|
||||
|
||||
'photographer_id' => $data['photographer_id'],
|
||||
'is_need_deposit' => $data['is_need_deposit'],
|
||||
'deposit_amount' => $deposit,
|
||||
'total' => $total,
|
||||
'remake' => $data['remake'],
|
||||
]);
|
||||
|
||||
if (!$res) {
|
||||
throw new Exception('创建订单失败');
|
||||
}
|
||||
$pay_data = [
|
||||
'trade_no' => $order_no,
|
||||
'total_amount' => $total,
|
||||
'desc' => '拍照服务付款',
|
||||
'notify_url' => getenv('SERVER_DOMAIN') . self::NOTIFY_URL,//回调地址
|
||||
'openid' => $request->user->openid,
|
||||
];
|
||||
|
||||
$result = (new PayService())->payment($pay_data);
|
||||
if (isset($result['code'])) {
|
||||
throw new Exception($result['msg']);
|
||||
}
|
||||
|
||||
return [
|
||||
'code' => ResponseCode::SUCCESS,
|
||||
'data' => $result,
|
||||
];
|
||||
|
||||
} catch (Exception $e) {
|
||||
return [
|
||||
'code' => ResponseCode::FAIL,
|
||||
'msg' => $e->getMessage()
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @desc 计算价格
|
||||
* @param $request
|
||||
* @return array|void
|
||||
*/
|
||||
public function calculatePrice($request)
|
||||
{
|
||||
try {
|
||||
$photo_service_price = 0.00;
|
||||
$paid_service_price = 0.00;
|
||||
if ($request['photo_service']) {
|
||||
$photo_service = json_decode($request['photo_service'], true);
|
||||
foreach ($photo_service as $item) {
|
||||
$service = PhotoService::where(['id' => $item['id']])->findOrEmpty();
|
||||
$photo_service_price += round($service->price + $item['number'], 2);
|
||||
}
|
||||
}
|
||||
if ($request['paid_service']) {
|
||||
$paid_service = json_decode($request['paid_service'], true);
|
||||
foreach ($paid_service as $item) {
|
||||
$service = PaidService::where(['id' => $item['id']])->findOrEmpty();
|
||||
$paid_service_price += round($service->price * $item['number'], 2);
|
||||
}
|
||||
}
|
||||
$total = round($photo_service_price + $paid_service_price, 2);
|
||||
$deposit = 0.00;
|
||||
if ($request['is_need_deposit']) {
|
||||
$ratio = RatioService::ratio();
|
||||
$deposit = round($total * $ratio / 100, 2);
|
||||
}
|
||||
|
||||
return [
|
||||
'code' => ResponseCode::SUCCESS,
|
||||
'data' => [
|
||||
'total' => $total,
|
||||
'deposit' => $deposit,
|
||||
]
|
||||
];
|
||||
|
||||
} catch (Exception $e) {
|
||||
return [
|
||||
'code' => ResponseCode::FAIL,
|
||||
'msg' => $e->getMessage()
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @desc 拍照服务支付保证金
|
||||
* @param $request
|
||||
* @return array
|
||||
*/
|
||||
public function payOrderDeposit($request)
|
||||
{
|
||||
try {
|
||||
$data = $request->post();
|
||||
//查找订单
|
||||
$photo_order = PhotoServiceOrder::where(['id' => $data['order_id']])->findOrEmpty();
|
||||
if ($photo_order->isEmpty()) {
|
||||
throw new Exception('订单不存在');
|
||||
}
|
||||
|
||||
if ($photo_order->is_need_deposit != 1) {
|
||||
throw new Exception('该订单无需支付保证金');
|
||||
}
|
||||
if ($photo_order->pay_status != 1) {
|
||||
throw new Exception('用户未付款,无需支付保证金');
|
||||
}
|
||||
$photographer = Photographer::where(['user_id' => $request->user->id])->findOrEmpty();
|
||||
if ($photographer->id != $photo_order->photographer_id) {
|
||||
throw new Exception('非摄影师本人无法支付');
|
||||
}
|
||||
$order_no = generate_order_no('D');
|
||||
|
||||
$deposit_order = DepositOrder::create([
|
||||
'user_id' => $request->user->id,
|
||||
'photographer_id' => $photographer->id,
|
||||
'order_type' => 'photo',
|
||||
'deposit_amount' => $photo_order->deposit_amount,
|
||||
'trade_no' => $order_no,
|
||||
]);
|
||||
|
||||
if (!$deposit_order) {
|
||||
throw new Exception('创建订单失败');
|
||||
}
|
||||
//订单表中插入保证金订单号
|
||||
$photo_order->save([
|
||||
'deposit_order_id' => $deposit_order->id,
|
||||
'deposit_trade_no' => $order_no
|
||||
]);
|
||||
|
||||
$pay_data = [
|
||||
'trade_no' => $order_no,
|
||||
'total_amount' => $photo_order->deposit_amount,
|
||||
'desc' => '拍照服务付款',
|
||||
'notify_url' => getenv('SERVER_DOMAIN') . self::NOTIFY_DEPOSIT_URL,//回调地址
|
||||
'openid' => $request->user->openid,
|
||||
];
|
||||
$result = (new PayService())->payment($pay_data);
|
||||
if (isset($result['code'])) {
|
||||
throw new Exception($result['msg']);
|
||||
}
|
||||
|
||||
return [
|
||||
'code' => ResponseCode::SUCCESS,
|
||||
'data' => $result
|
||||
];
|
||||
|
||||
} catch (Exception $e) {
|
||||
return [
|
||||
'code' => ResponseCode::FAIL,
|
||||
'msg' => $e->getMessage()
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @desc 摄影师拍照订单列表
|
||||
* @param $request
|
||||
* @return array|void
|
||||
*/
|
||||
public function getPhotoServiceOrderForPhotographer($request)
|
||||
{
|
||||
try {
|
||||
$data = $request->get();
|
||||
//摄影师信息
|
||||
$photographer = Photographer::where(['user_id' => $request->user->id])->findOrEmpty();
|
||||
if ($photographer->isEmpty()) {
|
||||
throw new Exception('未找到摄影师信息');
|
||||
}
|
||||
$order = PhotoServiceOrder::order('id desc')->where(['photographer_id' => $photographer->id]);
|
||||
if (isset($data['status']) && $data['status'] != -1) {
|
||||
$order->where(['status' => $data['status']]);
|
||||
}
|
||||
$page = isset($data['page']) ? $data['page'] : 1;
|
||||
$limit = isset($data['limit']) ? $data['limit'] : 10;
|
||||
$total = $order->count();
|
||||
$list = $order->page($page, $limit)->with(['photographer'])->select();
|
||||
|
||||
foreach ($list as &$item){
|
||||
if($item['photo_service_detail']){
|
||||
$item['photo_service_detail'] = json_decode($item['photo_service_detail'], true);
|
||||
}
|
||||
if($item['paid_service_detail']){
|
||||
$item['paid_service_detail'] = json_decode($item['paid_service_detail'], true);
|
||||
}
|
||||
}
|
||||
|
||||
return [
|
||||
'code' => ResponseCode::SUCCESS,
|
||||
'data' => [
|
||||
'list' => $list,
|
||||
'total' => $total,
|
||||
'page' => $page,
|
||||
]
|
||||
];
|
||||
} catch (Exception $e) {
|
||||
return [
|
||||
'code' => ResponseCode::FAIL,
|
||||
'msg' => $e->getMessage()
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @desc 摄影师拍照订单列表
|
||||
* @param $request
|
||||
* @return array|void
|
||||
*/
|
||||
public function getPhotoServiceOrderForUser($request)
|
||||
{
|
||||
try {
|
||||
$data = $request->get();
|
||||
$order = PhotoServiceOrder::order('id desc')->where(['user_id' => $request->user->id]);
|
||||
if (isset($data['status']) && $data['status'] != -1) {
|
||||
$order->where(['status' => $data['status']]);
|
||||
}
|
||||
$page = isset($data['page']) ? $data['page'] : 1;
|
||||
$limit = isset($data['limit']) ? $data['limit'] : 10;
|
||||
$total = $order->count();
|
||||
$list = $order->page($page, $limit)->with(['photographer'])->select();
|
||||
|
||||
foreach ($list as &$item){
|
||||
if($item['photo_service_detail']){
|
||||
$item['photo_service_detail'] = json_decode($item['photo_service_detail'], true);
|
||||
}
|
||||
if($item['paid_service_detail']){
|
||||
$item['paid_service_detail'] = json_decode($item['paid_service_detail'], true);
|
||||
}
|
||||
}
|
||||
|
||||
return [
|
||||
'code' => ResponseCode::SUCCESS,
|
||||
'data' => [
|
||||
'list' => $list,
|
||||
'total' => $total,
|
||||
'page' => $page,
|
||||
]
|
||||
];
|
||||
} catch (Exception $e) {
|
||||
return [
|
||||
'code' => ResponseCode::FAIL,
|
||||
'msg' => $e->getMessage()
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
public function confirmPhotoOrder($request)
|
||||
{
|
||||
try {
|
||||
$data = $request->post();
|
||||
$photographer = Photographer::where(['user_id'=>$request->user->id])->findOrEmpty();
|
||||
if($photographer->isEmpty()){
|
||||
throw new Exception('未找到您的摄影师信息,操作失败');
|
||||
}
|
||||
$order = PhotoServiceOrder::where(['out_trade_no'=>$data['out_trade_no']])->findOrEmpty();
|
||||
if($order->isEmpty()){
|
||||
throw new Exception('未找到订单信息');
|
||||
}
|
||||
if($order->photographer_id != $photographer->id){
|
||||
throw new Exception('非该订单摄影师不能操作');
|
||||
}
|
||||
$order->save([
|
||||
|
||||
]);
|
||||
|
||||
}catch (Exception $e){
|
||||
return [
|
||||
'code' => ResponseCode::FAIL,
|
||||
'msg' => $e->getMessage()
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @desc 取消订单
|
||||
* @param $request
|
||||
* @return array|void
|
||||
*/
|
||||
public function cancelPhotoOrder($request)
|
||||
{
|
||||
try {
|
||||
|
||||
}catch (Exception $e){
|
||||
return [
|
||||
'code' => ResponseCode::FAIL,
|
||||
'msg' => $e->getMessage()
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -1,199 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace app\common\service;
|
||||
|
||||
use app\common\model\Photographer;
|
||||
use app\common\model\PhotoService;
|
||||
use app\common\validate\PhotoServiceValidate;
|
||||
use app\constant\ResponseCode;
|
||||
use think\Exception;
|
||||
|
||||
class PhotoServiceService
|
||||
{
|
||||
|
||||
|
||||
/**
|
||||
* @desc 获取摄影师自己的的服务列表
|
||||
* @param $request
|
||||
* @return array
|
||||
*/
|
||||
public function getPhotographerSelfService($request)
|
||||
{
|
||||
try {
|
||||
$list = PhotoService::where(['user_id' => $request->user->id])->select();
|
||||
|
||||
return [
|
||||
'code' => ResponseCode::SUCCESS,
|
||||
'data' => $list
|
||||
];
|
||||
} catch (Exception $e) {
|
||||
return [
|
||||
'code' => ResponseCode::FAIL,
|
||||
'msg' => $e->getMessage()
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @desc 获取摄影师的服务列表
|
||||
* @param $request
|
||||
* @return array
|
||||
*/
|
||||
public function select($request)
|
||||
{
|
||||
try {
|
||||
$photographer_service = PhotoService::where(['photographer_id' => $request['photographer_id']]);
|
||||
|
||||
if(isset($request['service_type']) && !empty($request['service_type'])){
|
||||
$photographer_service->where(['service_type' => $request['service_type']]);
|
||||
}
|
||||
$list = $photographer_service->field('id,photographer_id,service_type,service_standard,detail,price')
|
||||
->select();
|
||||
|
||||
return [
|
||||
'code' => ResponseCode::SUCCESS,
|
||||
'data' => $list
|
||||
];
|
||||
} catch (Exception $e) {
|
||||
return [
|
||||
'code' => ResponseCode::FAIL,
|
||||
'msg' => $e->getMessage()
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @desc 添加拍照服务
|
||||
* @param $request
|
||||
* @return array
|
||||
*/
|
||||
public function add($request)
|
||||
{
|
||||
try {
|
||||
$data = $request->post();
|
||||
$photographer = Photographer::where(['user_id' => $request->user->id])->findOrEmpty();
|
||||
if ($photographer->isEmpty()) {
|
||||
throw new Exception('未找到摄影师信息,添加失败');
|
||||
}
|
||||
|
||||
$validate = new PhotoServiceValidate();
|
||||
if (!$validate->check($data)) {
|
||||
throw new Exception($validate->getError());
|
||||
}
|
||||
$servicePhotoExit = PhotoService::where(['photographer_id' => $photographer->id, 'service_type' => $data['service_type']])->findOrEmpty();
|
||||
if (!$servicePhotoExit->isEmpty()) {
|
||||
throw new Exception('该服务类型内容已存在,不能重复添加');
|
||||
}
|
||||
|
||||
$res = PhotoService::create([
|
||||
'user_id' => $request->user->id,
|
||||
'photographer_id' => $photographer->id,
|
||||
'service_type' => $data['service_type'],
|
||||
'service_standard' => $data['service_standard'],
|
||||
'detail' => $data['detail'],
|
||||
'price' => $data['price'],
|
||||
]);
|
||||
if (!$res) {
|
||||
throw new Exception('添加失败');
|
||||
}
|
||||
return [
|
||||
'code' => ResponseCode::SUCCESS,
|
||||
'msg' => '添加成功',
|
||||
];
|
||||
} catch (Exception $e) {
|
||||
return [
|
||||
'code' => ResponseCode::FAIL,
|
||||
'msg' => $e->getMessage()
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @desc 添加拍照服务
|
||||
* @param $request
|
||||
* @return array
|
||||
*/
|
||||
public function edit($request)
|
||||
{
|
||||
try {
|
||||
$data = $request->post();
|
||||
$photographer = Photographer::where(['user_id' => $request->user->id])->findOrEmpty();
|
||||
if ($photographer->isEmpty()) {
|
||||
throw new Exception('未找到摄影师信息,操作失败');
|
||||
}
|
||||
|
||||
$validate = new PhotoServiceValidate();
|
||||
if (!$validate->check($data)) {
|
||||
throw new Exception($validate->getError());
|
||||
}
|
||||
$photoService = PhotoService::where(['id' => $data['id']])->findOrEmpty();
|
||||
if ($photoService->isEmpty()) {
|
||||
throw new Exception('服务内容不存在');
|
||||
}
|
||||
if ($photographer->id != $photoService->photographer_id) {
|
||||
throw new Exception('非摄影师本人不能操作');
|
||||
}
|
||||
|
||||
$res = $photoService->save([
|
||||
'service_type' => $data['service_type'],
|
||||
'service_standard' => $data['service_standard'],
|
||||
'detail' => $data['detail'],
|
||||
'price' => $data['price'],
|
||||
]);
|
||||
if (!$res) {
|
||||
throw new Exception('操作失败');
|
||||
}
|
||||
return [
|
||||
'code' => ResponseCode::SUCCESS,
|
||||
'msg' => '操作成功',
|
||||
];
|
||||
} catch (Exception $e) {
|
||||
return [
|
||||
'code' => ResponseCode::FAIL,
|
||||
'msg' => $e->getMessage()
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @desc 删除拍照服务
|
||||
* @param $request
|
||||
* @return array
|
||||
*/
|
||||
public function del($request)
|
||||
{
|
||||
try {
|
||||
$data = $request->post();
|
||||
$photographer = Photographer::where(['user_id' => $request->user->id])->findOrEmpty();
|
||||
if ($photographer->isEmpty()) {
|
||||
throw new Exception('未找到摄影师信息,操作失败');
|
||||
}
|
||||
|
||||
$validate = new PhotoServiceValidate();
|
||||
if (!$validate->check($data)) {
|
||||
throw new Exception($validate->getError());
|
||||
}
|
||||
$photoService = PhotoService::where(['id' => $data['id']])->findOrEmpty();
|
||||
if ($photoService->isEmpty()) {
|
||||
throw new Exception('服务内容不存在');
|
||||
}
|
||||
if ($photographer->id != $photoService->photographer_id) {
|
||||
throw new Exception('非摄影师本人不能操作');
|
||||
}
|
||||
|
||||
$res = $photoService->delete();
|
||||
if (!$res) {
|
||||
throw new Exception('操作失败');
|
||||
}
|
||||
return [
|
||||
'code' => ResponseCode::SUCCESS,
|
||||
'msg' => '操作成功',
|
||||
];
|
||||
} catch (Exception $e) {
|
||||
return [
|
||||
'code' => ResponseCode::FAIL,
|
||||
'msg' => $e->getMessage()
|
||||
];
|
||||
}
|
||||
}
|
||||
}
|
@ -1,258 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace app\common\service;
|
||||
|
||||
use app\common\model\Favorite;
|
||||
use app\common\model\Photographer;
|
||||
use app\common\model\Requirement;
|
||||
use app\common\model\ServiceType;
|
||||
use app\common\model\Studio;
|
||||
use app\common\model\User;
|
||||
use app\common\validate\PhotographerValidate;
|
||||
use app\constant\ResponseCode;
|
||||
use think\Exception;
|
||||
|
||||
class PhotographerService
|
||||
{
|
||||
|
||||
/**
|
||||
* @desc 摄影师申请
|
||||
* @param $request
|
||||
* @return array
|
||||
*/
|
||||
public function apply($request)
|
||||
{
|
||||
try {
|
||||
$requestData = $request->post();
|
||||
$photographer = Photographer::where(['user_id' => $request->user->id])->findOrEmpty();
|
||||
if (!$photographer->findOrEmpty()) {
|
||||
if ($photographer->apply_status == 0) {
|
||||
throw new Exception('你已有申请待审批,请勿重新申请');
|
||||
}
|
||||
if ($photographer->apply_status == 1) {
|
||||
throw new Exception('你是摄影师,请勿重新申请');
|
||||
}
|
||||
}
|
||||
|
||||
$validate = new PhotographerValidate();
|
||||
if (!$validate->check($requestData)) {
|
||||
throw new Exception($validate->getError());
|
||||
}
|
||||
|
||||
$res = Photographer::create([
|
||||
'user_id' => $request->user->id,
|
||||
'name' => $requestData['name'],
|
||||
'avatar' => $requestData['avatar'],
|
||||
'sex' => $requestData['sex'],
|
||||
'mobile' => $requestData['mobile'],
|
||||
'device_id' => $requestData['device_id'],
|
||||
'service_type' => $requestData['service_type'],
|
||||
'age' => $requestData['age'],
|
||||
'province_code' => $requestData['province_code'],
|
||||
'province_name' => $requestData['province_name'],
|
||||
'city_code' => $requestData['city_code'],
|
||||
'city_name' => $requestData['city_name'],
|
||||
'work_time' => $requestData['work_time'],
|
||||
'work_year' => $requestData['work_year'],
|
||||
'introduce' => $requestData['introduce'],
|
||||
]);
|
||||
|
||||
if (!$res) {
|
||||
throw new Exception('操作失败');
|
||||
}
|
||||
return [
|
||||
'code' => ResponseCode::SUCCESS,
|
||||
'msg' => '申请已提交,请等待平台审核'
|
||||
];
|
||||
} catch (Exception $e) {
|
||||
return [
|
||||
'code' => ResponseCode::FAIL,
|
||||
'msg' => $e->getMessage()
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @desc 更改申请状态
|
||||
* @param $request
|
||||
* @return array|void
|
||||
*/
|
||||
public function changeApply($request)
|
||||
{
|
||||
try {
|
||||
$photographer = Photographer::where(['id' => $request['id']])->findOrEmpty();
|
||||
if ($photographer->isEmpty()) {
|
||||
throw new Exception('申请不存在');
|
||||
}
|
||||
|
||||
$photographer->save(['apply_status' => $request['apply_status']]);
|
||||
if ($request['apply_status'] == 1) {
|
||||
User::where(['id' => $photographer->user_id])->save(['is_photographer' => 1]);
|
||||
} else {
|
||||
User::where(['id' => $photographer->user_id])->save(['is_photographer' => 0]);
|
||||
}
|
||||
|
||||
} catch (Exception $e) {
|
||||
return [
|
||||
'code' => ResponseCode::FAIL,
|
||||
'msg' => $e->getMessage()
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @desc 摄影师编辑
|
||||
* @param $request
|
||||
* @return array|void
|
||||
*/
|
||||
public function edit($request)
|
||||
{
|
||||
try {
|
||||
$requestData = $request->post();
|
||||
$photographer = Photographer::where(['id' => $requestData['id']])->findOrEmpty();
|
||||
if ($photographer->isEmpty()) {
|
||||
throw new Exception('未找到摄影师');
|
||||
}
|
||||
|
||||
$photographer->save([
|
||||
'user_id' => $request->user->id,
|
||||
'name' => $requestData['name'],
|
||||
'avatar' => $requestData['avatar'],
|
||||
'sex' => $requestData['sex'],
|
||||
'mobile' => $requestData['mobile'],
|
||||
'device_id' => $requestData['device_id'],
|
||||
'service_type' => $requestData['service_type'],
|
||||
'age' => $requestData['age'],
|
||||
'city_name' => $requestData['city_name'],
|
||||
'work_time' => $requestData['work_time'],
|
||||
'work_year' => $requestData['work_year'],
|
||||
'introduce' => $requestData['introduce'],
|
||||
]);
|
||||
|
||||
} catch (Exception $e) {
|
||||
return [
|
||||
'code' => ResponseCode::FAIL,
|
||||
'msg' => $e->getMessage()
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @desc 摄影师详情
|
||||
* @param $request
|
||||
* @return array
|
||||
*/
|
||||
public function detail($request)
|
||||
{
|
||||
try {
|
||||
$data = $request->get();
|
||||
if (!isset($data['id'])) {
|
||||
throw new Exception('参数错误');
|
||||
}
|
||||
$photographer = Photographer::where(['id' => $data['id'], 'apply_status' => 1])->with('studio')->findOrEmpty();
|
||||
if ($photographer->isEmpty()) {
|
||||
throw new Exception('摄影师不存在');
|
||||
}
|
||||
if ($photographer->device_id) {
|
||||
$photographer->device_id = array_map('intval', explode(',', $photographer->device_id));
|
||||
}
|
||||
if ($photographer->service_type) {
|
||||
$photographer->service_type = array_map('intval', explode(',', $photographer->service_type));
|
||||
}
|
||||
$photographer->is_favorite = 0;
|
||||
if (!empty($request->user)) {
|
||||
$favorite = Favorite::where(['user_id' => $request->user->id, 'photographer_id' => $photographer->id])->findOrEmpty();
|
||||
|
||||
if (!$favorite->isEmpty()) {
|
||||
$photographer->is_favorite = 1;
|
||||
}
|
||||
}
|
||||
|
||||
return [
|
||||
'code' => ResponseCode::SUCCESS,
|
||||
'data' => $photographer,
|
||||
'msg' => 'success'
|
||||
];
|
||||
} catch (Exception $e) {
|
||||
return [
|
||||
'code' => ResponseCode::FAIL,
|
||||
'msg' => $e->getMessage()
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @desc 获取摄影师的服务类目
|
||||
* @param $request
|
||||
* @return array
|
||||
*/
|
||||
public function getServiceType($request)
|
||||
{
|
||||
try {
|
||||
$photographer = Photographer::where(['id' => $request['photographer_id']])->findOrEmpty();
|
||||
if ($photographer->isEmpty()) {
|
||||
throw new Exception('未找到摄影师');
|
||||
}
|
||||
$service_type = [];
|
||||
if ($photographer->service_type) {
|
||||
$service_type = ServiceType::where(['id' => explode(',', $photographer->service_type)])->order('sort desc, id desc')->field('id,service_name')->select();
|
||||
}
|
||||
|
||||
return [
|
||||
'code' => ResponseCode::SUCCESS,
|
||||
'data' => $service_type,
|
||||
'msg' => 'success'
|
||||
];
|
||||
} catch (Exception $e) {
|
||||
return [
|
||||
'code' => ResponseCode::FAIL,
|
||||
'msg' => $e->getMessage()
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @desc
|
||||
* @param $request
|
||||
* @return array|void
|
||||
*/
|
||||
public function quitStudio($request)
|
||||
{
|
||||
try {
|
||||
$data = $request->post();
|
||||
|
||||
$photographer = Photographer::where(['user_id' => $request->user->id])->findOrEmpty();
|
||||
if ($photographer->isEmpty()) {
|
||||
throw new Exception('未找到您的摄影师数据,退出失败');
|
||||
}
|
||||
if(empty($photographer->studio_id)){
|
||||
throw new Exception('摄影师未加入工作室');
|
||||
}
|
||||
// $studio = Studio::where(['id' => $photographer->studio_id])->findOrEmpty();
|
||||
// if ($studio->isEmpty()) {
|
||||
// throw new Exception('未找到工作室信息,退出失败');
|
||||
// }
|
||||
|
||||
$photographer->save([
|
||||
'studio_id' => 0
|
||||
]);
|
||||
User::where(['id' => $request->user->id])->save([
|
||||
'studio_id' => 0
|
||||
]);
|
||||
|
||||
return [
|
||||
'code' => ResponseCode::SUCCESS,
|
||||
'msg' => '操作成功'
|
||||
];
|
||||
} catch (Exception $e) {
|
||||
return [
|
||||
'code' => ResponseCode::FAIL,
|
||||
'msg' => $e->getMessage()
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -1,19 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace app\common\service;
|
||||
|
||||
use app\common\model\Ratio;
|
||||
|
||||
class RatioService
|
||||
{
|
||||
|
||||
/**
|
||||
* @desc 定金比例
|
||||
* @return mixed
|
||||
*/
|
||||
public static function ratio()
|
||||
{
|
||||
return Ratio::where(['id'=>1])->value('ratio');
|
||||
}
|
||||
|
||||
}
|
@ -1,189 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace app\common\service;
|
||||
|
||||
use app\common\model\BiddingOrder;
|
||||
use app\common\model\Photographer;
|
||||
use app\common\model\Requirement;
|
||||
use app\common\model\ServiceType;
|
||||
use app\constant\ResponseCode;
|
||||
use think\Exception;
|
||||
|
||||
class RequirementBiddingService
|
||||
{
|
||||
|
||||
/**
|
||||
* @desc 报价
|
||||
* @param $request
|
||||
* @return array
|
||||
*/
|
||||
public function bid($request)
|
||||
{
|
||||
try {
|
||||
$data = $request->post();
|
||||
$requirement = Requirement::where(['id' => $data['requirement_id']])->findOrEmpty();
|
||||
if ($requirement->isEmpty()) {
|
||||
throw new Exception('报价需求不存在');
|
||||
}
|
||||
if ($requirement->status != 1) {
|
||||
throw new Exception('当前需求已不在报价阶段,无法报价');
|
||||
}
|
||||
$photographer = Photographer::where(['user_id' => $request->user->id])->findOrEmpty();
|
||||
if ($photographer->isEmpty()) {
|
||||
throw new Exception('未找到您的摄影师信息,不能报价');
|
||||
}
|
||||
$bidding_order = BiddingOrder::where(['user_id' => $photographer->user_id, 'requirement_id' => $requirement->id])->findOrEmpty();
|
||||
if (!$bidding_order->isEmpty()) {
|
||||
throw new Exception('你已存在报价记录,不能再次报价');
|
||||
}
|
||||
if (!isset($data['bidding_price']) || $data['bidding_price'] <= 0) {
|
||||
throw new Exception('请输入正确的报价价格');
|
||||
}
|
||||
|
||||
$res = BiddingOrder::create([
|
||||
'user_id' => $request->user->id,
|
||||
'photographer_id' => $photographer->id,
|
||||
'requirement_id' => $requirement->id,
|
||||
'requirement_user_id' => $requirement->user_id,
|
||||
'requirement_detail' => json_encode($requirement->toArray()),
|
||||
'requirement_price' => $requirement->price,
|
||||
'bidding_price' => $data['bidding_price'],
|
||||
]);
|
||||
if (!$res) {
|
||||
throw new Exception('报价失败');
|
||||
}
|
||||
|
||||
return [
|
||||
'code' => ResponseCode::SUCCESS,
|
||||
'msg' => '报价成功',
|
||||
];
|
||||
|
||||
} catch (Exception $e) {
|
||||
return [
|
||||
'code' => ResponseCode::FAIL,
|
||||
'msg' => $e->getMessage()
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @desc 获取用户需求的出价列表
|
||||
* @param $request
|
||||
* @return array
|
||||
*/
|
||||
public function getUserRequirementBiddingOrderList($request)
|
||||
{
|
||||
try {
|
||||
$data = $request->get();
|
||||
$bidding_order = BiddingOrder::where(['requirement_user_id' => $request->user->id, 'requirement_id' => $data['requirement_id']])->order('requirement_id desc,id desc');
|
||||
|
||||
$page = isset($data['page']) ? $data['page'] : 1;
|
||||
$limit = isset($data['limit']) ? $data['limit'] : 10;
|
||||
$total = $bidding_order->count();
|
||||
$list = $bidding_order->with(['photographer'])
|
||||
->field('id,user_id,photographer_id,requirement_id,requirement_price,bidding_price,bind_status,created_at')
|
||||
->page($page, $limit)
|
||||
->select();
|
||||
|
||||
foreach ($list as &$item) {
|
||||
if ($item['photographer']) {
|
||||
$service_type_name = '';
|
||||
if($item['photographer']['service_type']){
|
||||
$service_type_name = ServiceType::where([
|
||||
'id'=>explode(',',$item['photographer']['service_type'])
|
||||
])
|
||||
->field('service_name')
|
||||
->order('sort desc, id desc')
|
||||
->select();
|
||||
if($service_type_name){
|
||||
$service_type_name = array_column($service_type_name->toArray(),'service_name');
|
||||
}
|
||||
}
|
||||
$item['photographer']['service_type_name'] = $service_type_name;
|
||||
}
|
||||
}
|
||||
|
||||
$requirement = Requirement::where(['id' => $data['requirement_id']])->with('serviceType')->findOrEmpty();
|
||||
return [
|
||||
'code' => ResponseCode::SUCCESS,
|
||||
'data' => [
|
||||
'list' => $list,
|
||||
'requirement' => $requirement,
|
||||
'total' => $total,
|
||||
'page' => $page
|
||||
]
|
||||
];
|
||||
|
||||
} catch (Exception $e) {
|
||||
return [
|
||||
'code' => ResponseCode::FAIL,
|
||||
'msg' => $e->getMessage()
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @desc 确定报价
|
||||
* @param $request
|
||||
* @return array|void
|
||||
*/
|
||||
public function confirmBid($request)
|
||||
{
|
||||
try {
|
||||
$data = $request->post();
|
||||
$bid_order = BiddingOrder::where(['id' => $data['bidding_order_id']])->findOrEmpty();
|
||||
if ($bid_order->isEmpty()) {
|
||||
throw new Exception('竞价订单不存在');
|
||||
}
|
||||
|
||||
$requirement = Requirement::where(['id' => $bid_order->requirement_id])->findOrEmpty();
|
||||
if ($requirement->isEmpty()) {
|
||||
throw new Exception('需求不存在');
|
||||
}
|
||||
if ($requirement->status != 1) {
|
||||
throw new Exception('需求不在出价中,无法确定报价');
|
||||
}
|
||||
if ($request->user->id != $bid_order->requirement_user_id) {
|
||||
throw new Exception('非需求本人无法确定报价');
|
||||
}
|
||||
|
||||
//计算定金
|
||||
$ratio = RatioService::ratio();
|
||||
$deposit_amount = 0;
|
||||
if($requirement->is_need_deposit){
|
||||
$deposit_amount = round($ratio * $bid_order->bidding_price / 100, 2);
|
||||
}
|
||||
|
||||
//需求表
|
||||
$requirement->save([
|
||||
'bidding_order_id' => $bid_order->id,
|
||||
'bid_win_user_id' => $bid_order->user_id,
|
||||
'bid_win_photographer_id' => $bid_order->photographer_id,
|
||||
'final_price' => $bid_order->bidding_price,
|
||||
'deposit_amount' => $deposit_amount,
|
||||
'status' => 2
|
||||
]);
|
||||
//竞价表
|
||||
$bid_order->save([
|
||||
'bind_status' => 1
|
||||
]);
|
||||
//更新其他竞价数据为【未中标】
|
||||
BiddingOrder::where(['requirement_id' => $bid_order->requirement_id])->where('id', '<>', $bid_order->id)->save([
|
||||
'bind_status' => 2
|
||||
]);
|
||||
|
||||
return [
|
||||
'code' => ResponseCode::SUCCESS,
|
||||
'msg' => '确定出价完成,请尽快完成支付',
|
||||
];
|
||||
} catch (Exception $e) {
|
||||
return [
|
||||
'code' => ResponseCode::FAIL,
|
||||
'msg' => $e->getMessage()
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -1,127 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace app\common\service;
|
||||
|
||||
use app\common\model\Requirement;
|
||||
use app\common\model\RequirementOrder;
|
||||
use app\constant\ResponseCode;
|
||||
use think\Exception;
|
||||
|
||||
class RequirementOrderService
|
||||
{
|
||||
/**
|
||||
* 回调地址
|
||||
*/
|
||||
const NOTIFY_URL = '/notify/WechatPayNotify/requirement_notify';
|
||||
const NOTIFY_REQUIREMENT_REFUND_URL = '/notify/WechatPayNotify/requirement_refund_notify';//需求退款
|
||||
|
||||
/**
|
||||
* @desc 用户支付需求金额
|
||||
* @param $require
|
||||
* @return array|void
|
||||
*/
|
||||
public function payRequirement($request)
|
||||
{
|
||||
try {
|
||||
$request_data = $request->post();
|
||||
$requirement = Requirement::where(['id' => $request_data['requirement_id']])->findOrEmpty();
|
||||
if ($requirement->status != 2) {
|
||||
throw new Exception('需求订单状态错误,支付失败');
|
||||
}
|
||||
$requirement_order = RequirementOrder::where(['requirement_trade_no' => $requirement->requirement_trade_no])->findOrEmpty();
|
||||
|
||||
if ($requirement_order->isEmpty()) {
|
||||
throw new Exception('需求订单不存在');
|
||||
}
|
||||
if ($requirement_order->pay_status != 0) {
|
||||
throw new Exception('订单状态校验失败,支付失败');
|
||||
}
|
||||
$out_trade_no = generate_order_no('R');
|
||||
$requirement_order->save([
|
||||
'user_id' => $request->user->id,
|
||||
'out_trade_no' => $out_trade_no,
|
||||
'requirement_detail' => json_encode($requirement->toArray()),
|
||||
'amount' => $requirement->final_price
|
||||
]);
|
||||
|
||||
$pay_data = [
|
||||
'out_trade_no' => $out_trade_no,
|
||||
// 'total_amount' => $requirement_order->amount,
|
||||
'total_amount' => 0.01,
|
||||
'desc' => $requirement->requirement_trade_no . '-支付',
|
||||
'notify_url' => getenv('SERVER_DOMAIN') . self::NOTIFY_URL,//回调地址
|
||||
'openid' => $request->user->openid,
|
||||
];
|
||||
$result = (new PayService())->payment($pay_data);
|
||||
|
||||
if (isset($result['code'])) {
|
||||
throw new Exception($result['msg']);
|
||||
}
|
||||
|
||||
return [
|
||||
'code' => ResponseCode::SUCCESS,
|
||||
'data' => $result,
|
||||
];
|
||||
} catch (Exception $e) {
|
||||
return [
|
||||
'code' => ResponseCode::FAIL,
|
||||
'msg' => $e->getMessage()
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @desc 需求退款
|
||||
* @param $request
|
||||
* @return array|void
|
||||
*/
|
||||
public function requirementRefund($request)
|
||||
{
|
||||
try {
|
||||
//查找订单
|
||||
$order = RequirementOrder::where(['out_trade_no' => $request['out_trade_no']])->findOrEmpty();
|
||||
if ($order->isEmpty()) {
|
||||
throw new Exception('未找到订单信息');
|
||||
}
|
||||
if ($order->pay_status != 1) {
|
||||
throw new Exception('订单状态错误,退款失败');
|
||||
}
|
||||
if ($order->is_refund) {
|
||||
throw new Exception('订单已退款');
|
||||
}
|
||||
|
||||
$refund_trade_no = generate_order_no('T');
|
||||
$order->save([
|
||||
'refund_trade_no' => $refund_trade_no,
|
||||
'refund_amount' => $order->amount,
|
||||
]);
|
||||
|
||||
$refund_data = [
|
||||
'out_trade_no' => $order->out_trade_no,
|
||||
'out_refund_no' => $refund_trade_no,
|
||||
'refund_desc' => '正常退款',
|
||||
'notify_url' => getenv('SERVER_DOMAIN') . self::NOTIFY_REQUIREMENT_REFUND_URL,
|
||||
'total' => $order->amount,
|
||||
'refund_amount' => $order->amount,
|
||||
];
|
||||
|
||||
$result = (new PayService())->refundPayment($refund_data);
|
||||
if(isset($result['code'])){
|
||||
throw new Exception($result['msg']);
|
||||
}
|
||||
|
||||
return [
|
||||
'code' => ResponseCode::SUCCESS,
|
||||
'msg' => '已申请退款',
|
||||
];
|
||||
|
||||
} catch (Exception $e) {
|
||||
return [
|
||||
'code' => ResponseCode::FAIL,
|
||||
'msg' => $e->getMessage()
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -1,268 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace app\common\service;
|
||||
|
||||
use app\common\model\Photographer;
|
||||
use app\common\model\Requirement;
|
||||
use app\common\model\RequirementOrder;
|
||||
use app\common\model\User;
|
||||
use app\common\validate\RequirementValidate;
|
||||
use app\constant\ResponseCode;
|
||||
use think\Exception;
|
||||
|
||||
class RequirementService
|
||||
{
|
||||
|
||||
|
||||
/**
|
||||
* @desc 发布需求
|
||||
* @param $request
|
||||
* @return array
|
||||
*/
|
||||
public function publish($request)
|
||||
{
|
||||
try {
|
||||
$data = $request->post();
|
||||
|
||||
$validate = new RequirementValidate();
|
||||
if (!$validate->check($data)) {
|
||||
throw new Exception($validate->getError());
|
||||
}
|
||||
$user = User::where(['id' => $request->user->id])->findOrEmpty();
|
||||
// if ($user->is_photographer) {
|
||||
// throw new Exception('只有普通用户可以发布需求哟~');
|
||||
// }
|
||||
|
||||
$requirement = Requirement::create([
|
||||
'user_id' => $request->user->id,
|
||||
'user_name' => $data['user_name'],
|
||||
'sex' => $data['sex'],
|
||||
'mobile' => $data['mobile'],
|
||||
'service_address' => $data['service_address'],
|
||||
'service_time' => $data['service_time'],
|
||||
'service_type' => $data['service_type'],
|
||||
'is_need_deposit' => $data['is_need_deposit'],
|
||||
'price' => $data['price'],
|
||||
'mark' => $data['mark'],
|
||||
'status' => 1,//0:初始化 1:竞价中 2:已竞价 3:已完成 4:用户取消'
|
||||
]);
|
||||
if (!$requirement) {
|
||||
throw new Exception('发布失败');
|
||||
}
|
||||
$requirement_trade_no = generate_order_no('D');
|
||||
//生成一条需求订单
|
||||
$requirement_order = RequirementOrder::create([
|
||||
'requirement_id' => $requirement->id,
|
||||
'requirement_trade_no' => $requirement_trade_no,
|
||||
]);
|
||||
|
||||
$requirement->save(['requirement_trade_no' => $requirement_trade_no]);
|
||||
|
||||
return [
|
||||
'code' => ResponseCode::SUCCESS,
|
||||
'msg' => '发布成功',
|
||||
];
|
||||
} catch (Exception $e) {
|
||||
return [
|
||||
'code' => ResponseCode::FAIL,
|
||||
'msg' => $e->getMessage()
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @desc 删除需求
|
||||
* @param $request
|
||||
* @return array
|
||||
*/
|
||||
public function del($request)
|
||||
{
|
||||
try {
|
||||
$data = $request->post();
|
||||
|
||||
$requirement = Requirement::where(['id' => $data['id']])->findOrEmpty();
|
||||
if ($requirement->findOrEmpty()) {
|
||||
throw new Exception('未找到需求');
|
||||
}
|
||||
|
||||
if ($requirement->user_id != $request->user->id) {
|
||||
throw new Exception('非需求发布者,不能操作');
|
||||
}
|
||||
//@todo:约定某些状态无法删除
|
||||
if ($requirement->status == 0) {
|
||||
|
||||
}
|
||||
|
||||
$res = $requirement->delete();
|
||||
if (!$res) {
|
||||
throw new Exception('删除失败');
|
||||
}
|
||||
|
||||
return [
|
||||
'code' => ResponseCode::SUCCESS,
|
||||
'msg' => '操作成功',
|
||||
];
|
||||
} catch (Exception $e) {
|
||||
return [
|
||||
'code' => ResponseCode::FAIL,
|
||||
'msg' => $e->getMessage()
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @desc 需求详情
|
||||
* @param $request
|
||||
* @return array
|
||||
*/
|
||||
public function detail($request)
|
||||
{
|
||||
try {
|
||||
$requirement = Requirement::where(['id' => $request['id']])->with(['serviceType'])->findOrEmpty();
|
||||
if ($requirement->isEmpty()) {
|
||||
throw new Exception('需求未找到');
|
||||
}
|
||||
|
||||
return [
|
||||
'code' => ResponseCode::SUCCESS,
|
||||
'data' => $requirement,
|
||||
];
|
||||
} catch (Exception $e) {
|
||||
return [
|
||||
'code' => ResponseCode::FAIL,
|
||||
'msg' => $e->getMessage()
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @desc 用户自己的需求列表
|
||||
* @param $request
|
||||
* @return array
|
||||
*/
|
||||
public function getUserSelfRequirementList($request)
|
||||
{
|
||||
try {
|
||||
$data = $request->get();
|
||||
$requirement = Requirement::order('id desc')->where(['user_id' => $request->user->id]);
|
||||
|
||||
if (isset($data['service_type']) && $data['service_type'] != '') {
|
||||
$requirement->where(['service_type' => $data['service_type']]);
|
||||
}
|
||||
|
||||
if (isset($data['status']) && $data['status']) {
|
||||
if ($data['status'] == 1) {
|
||||
$requirement->where(['status' => [1, 2]]);
|
||||
} else {
|
||||
$requirement->where(['status' => $data['status']]);
|
||||
}
|
||||
}
|
||||
|
||||
$page = isset($data['page']) ? $data['page'] : 1;
|
||||
$limit = isset($data['limit']) ? $data['limit'] : 10;
|
||||
$total = $requirement->count();
|
||||
$list = $requirement->page($page, $limit)->with(['serviceType', 'bidWinPhotographer'])->select();
|
||||
|
||||
return [
|
||||
'code' => ResponseCode::SUCCESS,
|
||||
'data' => [
|
||||
'list' => $list,
|
||||
'total' => $total,
|
||||
'page' => $page,
|
||||
]
|
||||
];
|
||||
} catch (Exception $e) {
|
||||
return [
|
||||
'code' => ResponseCode::FAIL,
|
||||
'msg' => $e->getMessage()
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @desc 获取需求列表
|
||||
* @param $request
|
||||
* @return array
|
||||
*/
|
||||
public function getRequirement($request)
|
||||
{
|
||||
try {
|
||||
$requirement = Requirement::order('id desc');
|
||||
if (isset($request['service_type']) && !empty($request['service_type'])) {
|
||||
$requirement->where(['service_type' => $request['service_type']]);
|
||||
}
|
||||
|
||||
$page = isset($request['page']) ? $request['page'] : 1;
|
||||
$limit = isset($request['limit']) ? $request['limit'] : 10;
|
||||
$total = $requirement->count();
|
||||
$list = $requirement->page($page, $limit)->with('serviceType')->select();
|
||||
|
||||
return [
|
||||
'code' => ResponseCode::SUCCESS,
|
||||
'data' => [
|
||||
'list' => $list,
|
||||
'total' => $total,
|
||||
'page' => $page,
|
||||
]
|
||||
];
|
||||
|
||||
} catch (Exception $e) {
|
||||
return [
|
||||
'code' => ResponseCode::FAIL,
|
||||
'msg' => $e->getMessage()
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @desc 竞价中的需求
|
||||
* @param $request
|
||||
* @return array
|
||||
*/
|
||||
public function getBidRequirements($request)
|
||||
{
|
||||
try {
|
||||
$requestData = $request->get();
|
||||
$photographer = Photographer::where(['user_id' => $request->user->id])->findOrEmpty();
|
||||
$service_type = [];
|
||||
if ($photographer->service_type) {
|
||||
$service_type = explode(',', $photographer->service_type);
|
||||
}
|
||||
$requirement = Requirement::where(['service_type' => $service_type]);
|
||||
if (isset($requestData['status']) && $requestData['status']) {
|
||||
if ($requestData['status'] == 1) {
|
||||
$requirement->where(['status' => [1, 2]]);
|
||||
} else {
|
||||
$requirement->where(['status' => $requestData['status']]);
|
||||
}
|
||||
}
|
||||
$page = isset($requestData['page']) ? $requestData['page'] : 1;
|
||||
$limit = isset($requestData['limit']) ? $requestData['limit'] : 10;
|
||||
$total = $requirement->count();
|
||||
$list = $requirement->with('serviceType')->page($page, $limit)->order('id desc')->select();
|
||||
|
||||
return [
|
||||
'code' => ResponseCode::SUCCESS,
|
||||
'data' => [
|
||||
'list' => $list,
|
||||
'total' => $total,
|
||||
'page' => $page,
|
||||
]
|
||||
];
|
||||
} catch (Exception $e) {
|
||||
return [
|
||||
'code' => ResponseCode::FAIL,
|
||||
'msg' => $e->getMessage()
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
public function cance()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
}
|
@ -1,34 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace app\common\service;
|
||||
|
||||
use app\common\model\ServiceStandard;
|
||||
use app\constant\ResponseCode;
|
||||
use think\Exception;
|
||||
|
||||
class ServiceStandardService
|
||||
{
|
||||
|
||||
/**
|
||||
* @desc 服务标准
|
||||
* @param $request
|
||||
* @return array
|
||||
*/
|
||||
public function getStandard($request)
|
||||
{
|
||||
try {
|
||||
$standard = ServiceStandard::order('sort desc, id desc')->field('standard_name')->select();
|
||||
|
||||
return [
|
||||
'code' => ResponseCode::SUCCESS,
|
||||
'data'=> $standard
|
||||
];
|
||||
}catch (Exception $e){
|
||||
return [
|
||||
'code' => ResponseCode::FAIL,
|
||||
'msg' => $e->getMessage()
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -1,34 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace app\common\service;
|
||||
|
||||
use app\common\model\ServiceType;
|
||||
use app\constant\ResponseCode;
|
||||
use think\Exception;
|
||||
|
||||
class ServiceTypeService
|
||||
{
|
||||
|
||||
/**
|
||||
* @desc 服务类型
|
||||
* @param $request
|
||||
* @return array
|
||||
*/
|
||||
public function getServiceType($request)
|
||||
{
|
||||
try {
|
||||
$service = ServiceType::order('sort desc,id desc')->field('id,service_name')->select();
|
||||
|
||||
return [
|
||||
'code' => ResponseCode::SUCCESS,
|
||||
'data' => $service,
|
||||
];
|
||||
}catch (Exception $e){
|
||||
return [
|
||||
'code' => ResponseCode::FAIL,
|
||||
'msg' => $e->getMessage()
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -1,22 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace app\common\service;
|
||||
|
||||
use app\common\model\Slideshow;
|
||||
use app\constant\ResponseCode;
|
||||
use support\Request;
|
||||
|
||||
class SlideshowService
|
||||
{
|
||||
|
||||
public function getSlideshow()
|
||||
{
|
||||
$res = Slideshow::field('img')->order('sort desc,id desc')->select();
|
||||
|
||||
return [
|
||||
'code' => ResponseCode::SUCCESS,
|
||||
'data' => $res,
|
||||
];
|
||||
}
|
||||
|
||||
}
|
53
app/common/service/StudentService.php
Normal file
53
app/common/service/StudentService.php
Normal file
@ -0,0 +1,53 @@
|
||||
<?php
|
||||
|
||||
namespace app\common\service;
|
||||
|
||||
use app\common\model\Student;
|
||||
use app\constant\ResponseCode;
|
||||
use think\Exception;
|
||||
use Tinywan\Jwt\JwtToken;
|
||||
|
||||
class StudentService
|
||||
{
|
||||
|
||||
|
||||
/**
|
||||
* @desc 登录
|
||||
* @param $request
|
||||
* @return array
|
||||
*/
|
||||
public function login($request)
|
||||
{
|
||||
try {
|
||||
$student = Student::where(['account' => $request['account']])->findOrEmpty();
|
||||
if ($student->isEmpty()) {
|
||||
throw new Exception('账号不存在');
|
||||
}
|
||||
if (empty($request['password'])) {
|
||||
throw new Exception('请填写密码');
|
||||
}
|
||||
|
||||
if (md5($request['password'] . $student->salt) != $student->password) {
|
||||
throw new Exception('密码错误,请填写正确的密码');
|
||||
}
|
||||
|
||||
$token_data = [
|
||||
'id' => $student->id,
|
||||
'role' => 'student'
|
||||
];
|
||||
$token = JwtToken::generateToken($token_data);
|
||||
return [
|
||||
'code' => ResponseCode::SUCCESS,
|
||||
'data' => $token,
|
||||
'msg' => 'success'
|
||||
];
|
||||
|
||||
} catch (Exception $e) {
|
||||
return [
|
||||
'code' => ResponseCode::FAIL,
|
||||
'msg' => $e->getMessage()
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -1,143 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace app\common\service;
|
||||
|
||||
use app\common\model\Photographer;
|
||||
use app\common\model\Studio;
|
||||
use app\common\model\StudioApply;
|
||||
use app\common\model\User;
|
||||
use app\constant\ResponseCode;
|
||||
use think\Exception;
|
||||
|
||||
class StudioApplyService
|
||||
{
|
||||
|
||||
public function apply($request)
|
||||
{
|
||||
try {
|
||||
$data = $request->post();
|
||||
$user = User::where(['id' => $request->user->id])->findOrEmpty();
|
||||
if (!$user->is_photographer) {
|
||||
throw new Exception('你还不是摄影师,请先成为摄影师再申请加入');
|
||||
}
|
||||
if ($user->studio_id) {
|
||||
throw new Exception('您已加入了工作室,不能重复申请');
|
||||
}
|
||||
$photographer = Photographer::where(['user_id' => $user->id])->findOrEmpty();
|
||||
if ($photographer->isEmpty()) {
|
||||
throw new Exception('未找到您的摄影师信息,申请失败');
|
||||
}
|
||||
$studio = Studio::where(['id' => $data['studio_id']])->findOrEmpty();
|
||||
if ($studio->isEmpty()) {
|
||||
throw new Exception('未找到工作室信息,申请失败');
|
||||
}
|
||||
$studio_apply = StudioApply::where(['user_id' => $user->id, 'photographer_id' => $photographer->id, 'apply_status' => 0])->findOrEmpty();
|
||||
if (!$studio_apply->isEmpty()) {
|
||||
throw new Exception('您有申请正在审批,不能重复申请');
|
||||
}
|
||||
|
||||
$res = StudioApply::create([
|
||||
'user_id' => $user->id,
|
||||
'photographer_id' => $photographer->id,
|
||||
'studio_id' => $studio->id
|
||||
]);
|
||||
if (!$res) {
|
||||
throw new Exception('申请失败');
|
||||
}
|
||||
return [
|
||||
'code' => ResponseCode::SUCCESS,
|
||||
'msg' => '申请成功,请等待工作室审核通过'
|
||||
];
|
||||
} catch (Exception $e) {
|
||||
return [
|
||||
'code' => ResponseCode::FAIL,
|
||||
'msg' => $e->getMessage()
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* @desc 申请列表
|
||||
* @param $request
|
||||
* @return array
|
||||
*/
|
||||
public function getPhotographerApplyList($request)
|
||||
{
|
||||
try {
|
||||
if(!isset($request['studio_id'])){
|
||||
throw new Exception('参数错误');
|
||||
}
|
||||
$apply = StudioApply::order('id desc')->where(['id' => $request['studio_id']]);
|
||||
|
||||
$page = isset($request['page']) ? $request['page'] : 1;
|
||||
$limit = isset($request['limit']) ? $request['limit'] : 10;
|
||||
$total = $apply->count();
|
||||
$list = $apply->with(['photographer'])->page($page, $limit)->select();
|
||||
|
||||
return [
|
||||
'code' => ResponseCode::SUCCESS,
|
||||
'data' => [
|
||||
'list' => $list,
|
||||
'total' => $total,
|
||||
'page' => $page
|
||||
],
|
||||
];
|
||||
|
||||
} catch (Exception $e) {
|
||||
return [
|
||||
'code' => ResponseCode::FAIL,
|
||||
'msg' => $e->getMessage()
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @desc 更改审核状态
|
||||
* @param $request
|
||||
* @return array
|
||||
*/
|
||||
public function changeApplyStatus($request)
|
||||
{
|
||||
try {
|
||||
$data = $request->post();
|
||||
$user = User::where(['id' => $request->user->id])->findOrEmpty();
|
||||
|
||||
$apply = StudioApply::where(['id' => $data['id']])->findOrEmpty();
|
||||
|
||||
$studio = Studio::where(['id' => $apply->studio_id])->findOrEmpty();
|
||||
|
||||
if ($apply->isEmpty()) {
|
||||
throw new Exception('申请不存在,修改失败');
|
||||
}
|
||||
if ($user->id != $studio->user_id) {
|
||||
throw new Exception('非工作室管理人员禁止操作');
|
||||
}
|
||||
|
||||
$apply->save(['apply_status' => $request['apply_status']]);
|
||||
|
||||
if ($request['apply_status'] == 1) {
|
||||
//通过
|
||||
$photographer = Photographer::where(['id' => $apply->photographer_id])->findOrEmpty();
|
||||
$photographer->save(['studio_id' => $apply->studio_id]);
|
||||
User::where(['id' => $photographer->user_id])->save(['studio_id' => $apply->studio_id]);
|
||||
} else {
|
||||
//拒绝
|
||||
$photographer = Photographer::where(['id' => $apply->photographer_id])->findOrEmpty();
|
||||
$photographer->save(['studio_id' => 0]);
|
||||
User::where(['id' => $photographer->user_id])->save(['studio_id' => 0]);
|
||||
}
|
||||
|
||||
return [
|
||||
'code' => ResponseCode::SUCCESS,
|
||||
'msg' => '操作成功'
|
||||
];
|
||||
} catch (Exception $e) {
|
||||
return [
|
||||
'code' => ResponseCode::FAIL,
|
||||
'msg' => $e->getMessage()
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -1,198 +0,0 @@
|
||||
<?php
|
||||
|
||||
namespace app\common\service;
|
||||
|
||||
use app\common\model\Photographer;
|
||||
use app\common\model\ServiceType;
|
||||
use app\common\model\Studio;
|
||||
use app\common\model\User;
|
||||
use app\constant\ResponseCode;
|
||||
use think\Exception;
|
||||
|
||||
class StudioService
|
||||
{
|
||||
|
||||
/**
|
||||
* @desc 添加工作室
|
||||
* @param $request
|
||||
* @return array
|
||||
*/
|
||||
public function add($request)
|
||||
{
|
||||
try {
|
||||
$post_data = $request->post();
|
||||
$user = User::where(['id' => $request->user->id])->findOrEmpty();
|
||||
if (!$user->is_photographer) {
|
||||
throw new Exception('您还不是摄影师,请先成为摄影师');
|
||||
}
|
||||
|
||||
$studio = Studio::where(['studio_name' => $post_data['studio_name']])->findOrEmpty();
|
||||
if (!$studio->isEmpty()) {
|
||||
throw new Exception('工作室名称已存在,请更换名称');
|
||||
}
|
||||
//@todo:判断是否一个人只能添加一个工作室
|
||||
$res = Studio::create([
|
||||
'studio_name' => $post_data['studio_name'],
|
||||
'img' => $post_data['img'],
|
||||
'introductions' => $post_data['introductions'],
|
||||
'user_id' => $request->user->id
|
||||
]);
|
||||
|
||||
if (!$res) {
|
||||
throw new Exception('添加失败');
|
||||
}
|
||||
User::where(['id' => $request->user->id])->save(['studio_id' => $res->id]);
|
||||
|
||||
return [
|
||||
'code' => ResponseCode::SUCCESS,
|
||||
'msg' => '添加成功'
|
||||
];
|
||||
} catch (Exception $e) {
|
||||
return [
|
||||
'code' => ResponseCode::FAIL,
|
||||
'msg' => $e->getMessage()
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @desc 工作室列表
|
||||
* @param $request
|
||||
* @return array
|
||||
*/
|
||||
public function select($request)
|
||||
{
|
||||
try {
|
||||
$list = Studio::order('id desc')->select();
|
||||
|
||||
return [
|
||||
'code' => ResponseCode::SUCCESS,
|
||||
'data' => $list,
|
||||
'msg' => 'success'
|
||||
];
|
||||
|
||||
}catch (Exception $e){
|
||||
return [
|
||||
'code' => ResponseCode::FAIL,
|
||||
'msg' => $e->getMessage()
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @desc 详情
|
||||
* @param $request
|
||||
* @return array
|
||||
*/
|
||||
public function detail($request)
|
||||
{
|
||||
try {
|
||||
$data = $request->get();
|
||||
$studio = Studio::where(['id' => $data['id']])->findOrEmpty();
|
||||
if ($studio->isEmpty()) {
|
||||
throw new Exception('工作室不存在');
|
||||
}
|
||||
$studio = $studio->toArray();
|
||||
$studio['is_me'] = 0;
|
||||
if((array)$request->user){
|
||||
if($studio['user_id'] == $request->user->id){
|
||||
$studio['is_me'] = 1;
|
||||
}
|
||||
}
|
||||
return [
|
||||
'code' => ResponseCode::SUCCESS,
|
||||
'data' => $studio,
|
||||
];
|
||||
} catch (Exception $e) {
|
||||
return [
|
||||
'code' => ResponseCode::FAIL,
|
||||
'msg' => $e->getMessage()
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @desc 工作室摄影师
|
||||
* @param $request
|
||||
* @return array
|
||||
*/
|
||||
public function getStudioPhotographer($request)
|
||||
{
|
||||
try {
|
||||
$studio = Studio::where(['id' => $request['studio_id']])->findOrEmpty();
|
||||
if ($studio->isEmpty()) {
|
||||
throw new Exception('工作室不存在');
|
||||
}
|
||||
$photographer = Photographer::where(['p.studio_id' => $studio->id])->alias('p');
|
||||
$page = isset($request['page']) ? $request['page'] : 1;
|
||||
$limit = isset($request['limit']) ? $request['limit'] : 10;
|
||||
$total = $photographer->count();
|
||||
$list = $photographer->page($page, $limit)->select();
|
||||
foreach ($list as &$item) {
|
||||
$service_type_name = '';
|
||||
if ($item['service_type']) {
|
||||
$service_type_name = ServiceType::where([
|
||||
'id' => explode(',', $item['service_type'])
|
||||
])
|
||||
->field('service_name')
|
||||
->order('sort desc, id desc')
|
||||
->select();
|
||||
if ($service_type_name) {
|
||||
$service_type_name = array_column($service_type_name->toArray(), 'service_name');
|
||||
}
|
||||
}
|
||||
$item['service_type_name'] = $service_type_name;
|
||||
}
|
||||
return [
|
||||
'code' => ResponseCode::SUCCESS,
|
||||
'data' => [
|
||||
'list' => $list,
|
||||
'total' => $total,
|
||||
'page' => $page
|
||||
],
|
||||
];
|
||||
|
||||
} catch (Exception $e) {
|
||||
return [
|
||||
'code' => ResponseCode::FAIL,
|
||||
'msg' => $e->getMessage()
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @desc 移除摄影师
|
||||
* @param $request
|
||||
* @return array
|
||||
*/
|
||||
public function removePhotographer($request)
|
||||
{
|
||||
try {
|
||||
$data = $request->post();
|
||||
$studio = Studio::where(['id' => $data['studio_id']])->findOrEmpty();
|
||||
|
||||
$photographer = Photographer::where(['id' => $data['photographer_id']])->findOrEmpty();
|
||||
|
||||
if ($studio->user_id != $request->user->id) {
|
||||
throw new Exception('非工作室管理者不能操作');
|
||||
}
|
||||
$photographer->save(['studio_id' => 0]);
|
||||
User::where(['id' => $photographer->user_id])->save(['studio_id' => 0]);
|
||||
|
||||
return [
|
||||
'code' => ResponseCode::SUCCESS,
|
||||
'msg' => '操作成功'
|
||||
];
|
||||
} catch (Exception $e) {
|
||||
return [
|
||||
'code' => ResponseCode::FAIL,
|
||||
'msg' => $e->getMessage()
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -60,17 +60,30 @@ class TeacherService
|
||||
public function setTimeZone($request)
|
||||
{
|
||||
try {
|
||||
if(empty($request->teacher)){
|
||||
throw new Exception('请教师登陆后再设置');
|
||||
}
|
||||
$teacher = Teacher::where(['id' => $request->teacher->id])->findOrEmpty();
|
||||
if($teacher->isEmpty()){
|
||||
throw new Exception('未找到教师信息,设置失败');
|
||||
}
|
||||
|
||||
$time_zone = TimeZone::where(['id' => $request->post('time_zone_id')])->findOrEmpty();
|
||||
|
||||
$teacher->save([
|
||||
$res = $teacher->save([
|
||||
'time_zone_id' => $time_zone->id,
|
||||
'time_zone_name' => $time_zone->name,
|
||||
'time_zone_abbr' => $time_zone->abbr,
|
||||
'time_zone_offset' => $time_zone->offset,
|
||||
]);
|
||||
if(!$res){
|
||||
throw new Exception('设置失败');
|
||||
}
|
||||
|
||||
return [
|
||||
'code' => ResponseCode::SUCCESS,
|
||||
'msg' => '设置成功'
|
||||
];
|
||||
} catch (Exception $e) {
|
||||
return [
|
||||
'code' => ResponseCode::FAIL,
|
||||
|
@ -38,7 +38,9 @@
|
||||
"illuminate/database": "^8.83",
|
||||
"qiniu/php-sdk": "^7.12",
|
||||
"tinywan/jwt": "^1.10",
|
||||
"webman/think-orm": "^1.1"
|
||||
"webman/think-orm": "^1.1",
|
||||
"illuminate/redis": "^8.83",
|
||||
"illuminate/events": "^8.83"
|
||||
},
|
||||
"suggest": {
|
||||
"ext-event": "For better performance. "
|
||||
|
178
composer.lock
generated
178
composer.lock
generated
@ -4,30 +4,30 @@
|
||||
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
|
||||
"This file is @generated automatically"
|
||||
],
|
||||
"content-hash": "1b1fb19381413b411224d4a20cdc7ad7",
|
||||
"content-hash": "9dc426c41a2a58306c3239ca918e541f",
|
||||
"packages": [
|
||||
{
|
||||
"name": "carbonphp/carbon-doctrine-types",
|
||||
"version": "2.1.0",
|
||||
"version": "3.2.0",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/CarbonPHP/carbon-doctrine-types.git",
|
||||
"reference": "99f76ffa36cce3b70a4a6abce41dba15ca2e84cb"
|
||||
"reference": "18ba5ddfec8976260ead6e866180bd5d2f71aa1d"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/CarbonPHP/carbon-doctrine-types/zipball/99f76ffa36cce3b70a4a6abce41dba15ca2e84cb",
|
||||
"reference": "99f76ffa36cce3b70a4a6abce41dba15ca2e84cb",
|
||||
"url": "https://api.github.com/repos/CarbonPHP/carbon-doctrine-types/zipball/18ba5ddfec8976260ead6e866180bd5d2f71aa1d",
|
||||
"reference": "18ba5ddfec8976260ead6e866180bd5d2f71aa1d",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"php": "^7.4 || ^8.0"
|
||||
"php": "^8.1"
|
||||
},
|
||||
"conflict": {
|
||||
"doctrine/dbal": "<3.7.0 || >=4.0.0"
|
||||
"doctrine/dbal": "<4.0.0 || >=5.0.0"
|
||||
},
|
||||
"require-dev": {
|
||||
"doctrine/dbal": "^3.7.0",
|
||||
"doctrine/dbal": "^4.0.0",
|
||||
"nesbot/carbon": "^2.71.0 || ^3.0.0",
|
||||
"phpunit/phpunit": "^10.3"
|
||||
},
|
||||
@ -57,7 +57,7 @@
|
||||
],
|
||||
"support": {
|
||||
"issues": "https://github.com/CarbonPHP/carbon-doctrine-types/issues",
|
||||
"source": "https://github.com/CarbonPHP/carbon-doctrine-types/tree/2.1.0"
|
||||
"source": "https://github.com/CarbonPHP/carbon-doctrine-types/tree/3.2.0"
|
||||
},
|
||||
"funding": [
|
||||
{
|
||||
@ -73,7 +73,7 @@
|
||||
"type": "tidelift"
|
||||
}
|
||||
],
|
||||
"time": "2023-12-11T17:09:12+00:00"
|
||||
"time": "2024-02-09T16:56:22+00:00"
|
||||
},
|
||||
{
|
||||
"name": "doctrine/inflector",
|
||||
@ -1175,6 +1175,60 @@
|
||||
},
|
||||
"time": "2021-03-26T18:39:16+00:00"
|
||||
},
|
||||
{
|
||||
"name": "illuminate/redis",
|
||||
"version": "v8.83.27",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/illuminate/redis.git",
|
||||
"reference": "0fee121324054226823a59623fab3d98ad88fbd5"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/illuminate/redis/zipball/0fee121324054226823a59623fab3d98ad88fbd5",
|
||||
"reference": "0fee121324054226823a59623fab3d98ad88fbd5",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"illuminate/collections": "^8.0",
|
||||
"illuminate/contracts": "^8.0",
|
||||
"illuminate/macroable": "^8.0",
|
||||
"illuminate/support": "^8.0",
|
||||
"php": "^7.3|^8.0"
|
||||
},
|
||||
"suggest": {
|
||||
"ext-redis": "Required to use the phpredis connector (^4.0|^5.0).",
|
||||
"predis/predis": "Required to use the predis connector (^1.1.9)."
|
||||
},
|
||||
"type": "library",
|
||||
"extra": {
|
||||
"branch-alias": {
|
||||
"dev-master": "8.x-dev"
|
||||
}
|
||||
},
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"Illuminate\\Redis\\": ""
|
||||
}
|
||||
},
|
||||
"notification-url": "https://packagist.org/downloads/",
|
||||
"license": [
|
||||
"MIT"
|
||||
],
|
||||
"authors": [
|
||||
{
|
||||
"name": "Taylor Otwell",
|
||||
"email": "taylor@laravel.com"
|
||||
}
|
||||
],
|
||||
"description": "The Illuminate Redis package.",
|
||||
"homepage": "https://laravel.com",
|
||||
"support": {
|
||||
"issues": "https://github.com/laravel/framework/issues",
|
||||
"source": "https://github.com/laravel/framework"
|
||||
},
|
||||
"time": "2022-01-24T02:32:30+00:00"
|
||||
},
|
||||
{
|
||||
"name": "illuminate/support",
|
||||
"version": "v8.83.27",
|
||||
@ -2398,25 +2452,25 @@
|
||||
},
|
||||
{
|
||||
"name": "symfony/deprecation-contracts",
|
||||
"version": "v2.5.3",
|
||||
"version": "v3.5.0",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/symfony/deprecation-contracts.git",
|
||||
"reference": "80d075412b557d41002320b96a096ca65aa2c98d"
|
||||
"reference": "0e0d29ce1f20deffb4ab1b016a7257c4f1e789a1"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/symfony/deprecation-contracts/zipball/80d075412b557d41002320b96a096ca65aa2c98d",
|
||||
"reference": "80d075412b557d41002320b96a096ca65aa2c98d",
|
||||
"url": "https://api.github.com/repos/symfony/deprecation-contracts/zipball/0e0d29ce1f20deffb4ab1b016a7257c4f1e789a1",
|
||||
"reference": "0e0d29ce1f20deffb4ab1b016a7257c4f1e789a1",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"php": ">=7.1"
|
||||
"php": ">=8.1"
|
||||
},
|
||||
"type": "library",
|
||||
"extra": {
|
||||
"branch-alias": {
|
||||
"dev-main": "2.5-dev"
|
||||
"dev-main": "3.5-dev"
|
||||
},
|
||||
"thanks": {
|
||||
"name": "symfony/contracts",
|
||||
@ -2445,7 +2499,7 @@
|
||||
"description": "A generic function and convention to trigger deprecation notices",
|
||||
"homepage": "https://symfony.com",
|
||||
"support": {
|
||||
"source": "https://github.com/symfony/deprecation-contracts/tree/v2.5.3"
|
||||
"source": "https://github.com/symfony/deprecation-contracts/tree/v3.5.0"
|
||||
},
|
||||
"funding": [
|
||||
{
|
||||
@ -2461,7 +2515,7 @@
|
||||
"type": "tidelift"
|
||||
}
|
||||
],
|
||||
"time": "2023-01-24T14:02:46+00:00"
|
||||
"time": "2024-04-18T09:32:20+00:00"
|
||||
},
|
||||
{
|
||||
"name": "symfony/polyfill-ctype",
|
||||
@ -2939,33 +2993,30 @@
|
||||
},
|
||||
{
|
||||
"name": "symfony/service-contracts",
|
||||
"version": "v2.5.3",
|
||||
"version": "v3.5.0",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/symfony/service-contracts.git",
|
||||
"reference": "a2329596ddc8fd568900e3fc76cba42489ecc7f3"
|
||||
"reference": "bd1d9e59a81d8fa4acdcea3f617c581f7475a80f"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/symfony/service-contracts/zipball/a2329596ddc8fd568900e3fc76cba42489ecc7f3",
|
||||
"reference": "a2329596ddc8fd568900e3fc76cba42489ecc7f3",
|
||||
"url": "https://api.github.com/repos/symfony/service-contracts/zipball/bd1d9e59a81d8fa4acdcea3f617c581f7475a80f",
|
||||
"reference": "bd1d9e59a81d8fa4acdcea3f617c581f7475a80f",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"php": ">=7.2.5",
|
||||
"psr/container": "^1.1",
|
||||
"symfony/deprecation-contracts": "^2.1|^3"
|
||||
"php": ">=8.1",
|
||||
"psr/container": "^1.1|^2.0",
|
||||
"symfony/deprecation-contracts": "^2.5|^3"
|
||||
},
|
||||
"conflict": {
|
||||
"ext-psr": "<1.1|>=2"
|
||||
},
|
||||
"suggest": {
|
||||
"symfony/service-implementation": ""
|
||||
},
|
||||
"type": "library",
|
||||
"extra": {
|
||||
"branch-alias": {
|
||||
"dev-main": "2.5-dev"
|
||||
"dev-main": "3.5-dev"
|
||||
},
|
||||
"thanks": {
|
||||
"name": "symfony/contracts",
|
||||
@ -2975,7 +3026,10 @@
|
||||
"autoload": {
|
||||
"psr-4": {
|
||||
"Symfony\\Contracts\\Service\\": ""
|
||||
}
|
||||
},
|
||||
"exclude-from-classmap": [
|
||||
"/Test/"
|
||||
]
|
||||
},
|
||||
"notification-url": "https://packagist.org/downloads/",
|
||||
"license": [
|
||||
@ -3002,7 +3056,7 @@
|
||||
"standards"
|
||||
],
|
||||
"support": {
|
||||
"source": "https://github.com/symfony/service-contracts/tree/v2.5.3"
|
||||
"source": "https://github.com/symfony/service-contracts/tree/v3.5.0"
|
||||
},
|
||||
"funding": [
|
||||
{
|
||||
@ -3018,7 +3072,7 @@
|
||||
"type": "tidelift"
|
||||
}
|
||||
],
|
||||
"time": "2023-04-21T15:04:16+00:00"
|
||||
"time": "2024-04-18T09:32:20+00:00"
|
||||
},
|
||||
{
|
||||
"name": "symfony/string",
|
||||
@ -3108,53 +3162,51 @@
|
||||
},
|
||||
{
|
||||
"name": "symfony/translation",
|
||||
"version": "v5.4.40",
|
||||
"version": "v6.4.8",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/symfony/translation.git",
|
||||
"reference": "bb51d7f183756d1ac03f50ea47dc5726518cc7e8"
|
||||
"reference": "a002933b13989fc4bd0b58e04bf7eec5210e438a"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/symfony/translation/zipball/bb51d7f183756d1ac03f50ea47dc5726518cc7e8",
|
||||
"reference": "bb51d7f183756d1ac03f50ea47dc5726518cc7e8",
|
||||
"url": "https://api.github.com/repos/symfony/translation/zipball/a002933b13989fc4bd0b58e04bf7eec5210e438a",
|
||||
"reference": "a002933b13989fc4bd0b58e04bf7eec5210e438a",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"php": ">=7.2.5",
|
||||
"symfony/deprecation-contracts": "^2.1|^3",
|
||||
"php": ">=8.1",
|
||||
"symfony/deprecation-contracts": "^2.5|^3",
|
||||
"symfony/polyfill-mbstring": "~1.0",
|
||||
"symfony/polyfill-php80": "^1.16",
|
||||
"symfony/translation-contracts": "^2.3"
|
||||
"symfony/translation-contracts": "^2.5|^3.0"
|
||||
},
|
||||
"conflict": {
|
||||
"symfony/config": "<4.4",
|
||||
"symfony/console": "<5.3",
|
||||
"symfony/dependency-injection": "<5.0",
|
||||
"symfony/http-kernel": "<5.0",
|
||||
"symfony/twig-bundle": "<5.0",
|
||||
"symfony/yaml": "<4.4"
|
||||
"symfony/config": "<5.4",
|
||||
"symfony/console": "<5.4",
|
||||
"symfony/dependency-injection": "<5.4",
|
||||
"symfony/http-client-contracts": "<2.5",
|
||||
"symfony/http-kernel": "<5.4",
|
||||
"symfony/service-contracts": "<2.5",
|
||||
"symfony/twig-bundle": "<5.4",
|
||||
"symfony/yaml": "<5.4"
|
||||
},
|
||||
"provide": {
|
||||
"symfony/translation-implementation": "2.3"
|
||||
"symfony/translation-implementation": "2.3|3.0"
|
||||
},
|
||||
"require-dev": {
|
||||
"nikic/php-parser": "^4.18|^5.0",
|
||||
"psr/log": "^1|^2|^3",
|
||||
"symfony/config": "^4.4|^5.0|^6.0",
|
||||
"symfony/console": "^5.4|^6.0",
|
||||
"symfony/dependency-injection": "^5.0|^6.0",
|
||||
"symfony/finder": "^4.4|^5.0|^6.0",
|
||||
"symfony/http-client-contracts": "^1.1|^2.0|^3.0",
|
||||
"symfony/http-kernel": "^5.0|^6.0",
|
||||
"symfony/intl": "^4.4|^5.0|^6.0",
|
||||
"symfony/config": "^5.4|^6.0|^7.0",
|
||||
"symfony/console": "^5.4|^6.0|^7.0",
|
||||
"symfony/dependency-injection": "^5.4|^6.0|^7.0",
|
||||
"symfony/finder": "^5.4|^6.0|^7.0",
|
||||
"symfony/http-client-contracts": "^2.5|^3.0",
|
||||
"symfony/http-kernel": "^5.4|^6.0|^7.0",
|
||||
"symfony/intl": "^5.4|^6.0|^7.0",
|
||||
"symfony/polyfill-intl-icu": "^1.21",
|
||||
"symfony/service-contracts": "^1.1.2|^2|^3",
|
||||
"symfony/yaml": "^4.4|^5.0|^6.0"
|
||||
},
|
||||
"suggest": {
|
||||
"psr/log-implementation": "To use logging capability in translator",
|
||||
"symfony/config": "",
|
||||
"symfony/yaml": ""
|
||||
"symfony/routing": "^5.4|^6.0|^7.0",
|
||||
"symfony/service-contracts": "^2.5|^3",
|
||||
"symfony/yaml": "^5.4|^6.0|^7.0"
|
||||
},
|
||||
"type": "library",
|
||||
"autoload": {
|
||||
@ -3185,7 +3237,7 @@
|
||||
"description": "Provides tools to internationalize your application",
|
||||
"homepage": "https://symfony.com",
|
||||
"support": {
|
||||
"source": "https://github.com/symfony/translation/tree/v5.4.40"
|
||||
"source": "https://github.com/symfony/translation/tree/v6.4.8"
|
||||
},
|
||||
"funding": [
|
||||
{
|
||||
@ -3201,7 +3253,7 @@
|
||||
"type": "tidelift"
|
||||
}
|
||||
],
|
||||
"time": "2024-05-31T14:33:22+00:00"
|
||||
"time": "2024-05-31T14:49:08+00:00"
|
||||
},
|
||||
{
|
||||
"name": "symfony/translation-contracts",
|
||||
|
@ -18,5 +18,6 @@ return [
|
||||
'password' => null,
|
||||
'port' => 6379,
|
||||
'database' => 0,
|
||||
'prefix'=> 'course_'
|
||||
],
|
||||
];
|
||||
|
169
plugin/admin/app/controller/StudentController.php
Normal file
169
plugin/admin/app/controller/StudentController.php
Normal file
@ -0,0 +1,169 @@
|
||||
<?php
|
||||
|
||||
namespace plugin\admin\app\controller;
|
||||
|
||||
use app\constant\ResponseCode;
|
||||
use support\Request;
|
||||
use support\Response;
|
||||
use plugin\admin\app\model\Student;
|
||||
use plugin\admin\app\controller\Crud;
|
||||
use support\exception\BusinessException;
|
||||
use think\Exception;
|
||||
|
||||
/**
|
||||
* 学生管理
|
||||
*/
|
||||
class StudentController extends Crud
|
||||
{
|
||||
|
||||
/**
|
||||
* @var Student
|
||||
*/
|
||||
protected $model = null;
|
||||
|
||||
/**
|
||||
* 构造函数
|
||||
* @return void
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
$this->model = new Student;
|
||||
}
|
||||
|
||||
/**
|
||||
* 浏览
|
||||
* @return Response
|
||||
*/
|
||||
public function index(): Response
|
||||
{
|
||||
return view('student/index');
|
||||
}
|
||||
|
||||
/**
|
||||
* 插入
|
||||
* @param Request $request
|
||||
* @return Response
|
||||
* @throws BusinessException
|
||||
*/
|
||||
public function insert(Request $request): Response
|
||||
{
|
||||
if ($request->method() === 'POST') {
|
||||
|
||||
$request_data = $request->post();
|
||||
$salt = random_str(16);
|
||||
if (empty($request_data['password'])) {
|
||||
$password = trim(explode('', $request_data['account'])[0]) . '001';
|
||||
$password = md5($password . $salt);
|
||||
} else {
|
||||
$password = md5($request_data['password'] . $salt);
|
||||
}
|
||||
|
||||
$res = \app\common\model\Student::create([
|
||||
'student_name' => $request_data['student_name'],
|
||||
'account' => $request_data['account'],
|
||||
'password' => $password,
|
||||
'salt' => $salt,
|
||||
'avatar' => $request_data['avatar'],
|
||||
'parent_id' => 0,
|
||||
]);
|
||||
|
||||
return json([
|
||||
'code' => ResponseCode::WEB_API_SUCCESS,
|
||||
'msg' => '添加成功'
|
||||
]);
|
||||
// return parent::insert($request);
|
||||
}
|
||||
return view('student/insert');
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新
|
||||
* @param Request $request
|
||||
* @return Response
|
||||
* @throws BusinessException
|
||||
*/
|
||||
public function update(Request $request): Response
|
||||
{
|
||||
if ($request->method() === 'POST') {
|
||||
try {
|
||||
$request_data = $request->post();
|
||||
|
||||
$student = \app\common\model\Student::where(['id' => $request_data['id']])->findOrEmpty();
|
||||
if ($student->isEmpty()) {
|
||||
throw new Exception('未找到学生信息,操作失败');
|
||||
}
|
||||
|
||||
if (empty($request_data['password'])) {
|
||||
$update = [
|
||||
'student_name' => $request_data['student_name'],
|
||||
'account' => $request_data['account'],
|
||||
'avatar' => $request_data['avatar'],
|
||||
'parent_id' => 0,
|
||||
];
|
||||
} else {
|
||||
$salt = random_str(16);
|
||||
$password = md5($request_data['password'] . $salt);
|
||||
$update = [
|
||||
'student_name' => $request_data['student_name'],
|
||||
'account' => $request_data['account'],
|
||||
'password' => $password,
|
||||
'salt' => $salt,
|
||||
'avatar' => $request_data['avatar'],
|
||||
'parent_id' => 0,
|
||||
];
|
||||
}
|
||||
|
||||
$student->save($update);
|
||||
|
||||
return json([
|
||||
'code' => ResponseCode::WEB_API_SUCCESS,
|
||||
'msg' => 'success'
|
||||
]);
|
||||
} catch (Exception $e) {
|
||||
return json([
|
||||
'code' => ResponseCode::WEB_API_FAIL,
|
||||
'msg' => $e->getMessage()
|
||||
]);
|
||||
}
|
||||
|
||||
// return parent::update($request);
|
||||
}
|
||||
return view('student/update');
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @desc 重置密码
|
||||
* @param Request $request
|
||||
* @return Response
|
||||
*/
|
||||
public function resetPassword(Request $request)
|
||||
{
|
||||
try {
|
||||
$request_data = $request->post();
|
||||
$student = \app\common\model\Student::where(['id' => $request_data['id']])->findOrEmpty();
|
||||
$new_password = trim(explode(' ', $student->account)[0]) . '001';
|
||||
$salt = random_str(16);
|
||||
$password = md5($new_password . $salt);
|
||||
|
||||
$res = $student->save([
|
||||
'salt' => $salt,
|
||||
'password' => $password
|
||||
]);
|
||||
if(!$res){
|
||||
throw new Exception('重置失败');
|
||||
}
|
||||
|
||||
return json([
|
||||
'code' => ResponseCode::WEB_API_SUCCESS,
|
||||
'msg' => '重置成功'
|
||||
]);
|
||||
} catch (Exception $e) {
|
||||
return json([
|
||||
'code' => ResponseCode::WEB_API_FAIL,
|
||||
'msg' => $e->getMessage()
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
167
plugin/admin/app/controller/StudentParentController.php
Normal file
167
plugin/admin/app/controller/StudentParentController.php
Normal file
@ -0,0 +1,167 @@
|
||||
<?php
|
||||
|
||||
namespace plugin\admin\app\controller;
|
||||
|
||||
use app\constant\ResponseCode;
|
||||
use support\Request;
|
||||
use support\Response;
|
||||
use plugin\admin\app\model\StudentParent;
|
||||
use plugin\admin\app\controller\Crud;
|
||||
use support\exception\BusinessException;
|
||||
use think\Exception;
|
||||
|
||||
/**
|
||||
* 家长管理
|
||||
*/
|
||||
class StudentParentController extends Crud
|
||||
{
|
||||
|
||||
/**
|
||||
* @var StudentParent
|
||||
*/
|
||||
protected $model = null;
|
||||
|
||||
/**
|
||||
* 构造函数
|
||||
* @return void
|
||||
*/
|
||||
public function __construct()
|
||||
{
|
||||
$this->model = new StudentParent;
|
||||
}
|
||||
|
||||
/**
|
||||
* 浏览
|
||||
* @return Response
|
||||
*/
|
||||
public function index(): Response
|
||||
{
|
||||
return view('student-parent/index');
|
||||
}
|
||||
|
||||
/**
|
||||
* 插入
|
||||
* @param Request $request
|
||||
* @return Response
|
||||
* @throws BusinessException
|
||||
*/
|
||||
public function insert(Request $request): Response
|
||||
{
|
||||
if ($request->method() === 'POST') {
|
||||
|
||||
$request_data = $request->post();
|
||||
$salt = random_str(16);
|
||||
if (empty($request_data['password'])) {
|
||||
$password = trim(mb_substr($request_data['account'], 0, -2)) . '001';
|
||||
$password = md5($password . $salt);
|
||||
} else {
|
||||
$password = md5($request_data['password'] . $salt);
|
||||
}
|
||||
|
||||
$res = \app\common\model\StudentParent::create([
|
||||
'parent_name' => $request_data['parent_name'],
|
||||
'account' => $request_data['account'],
|
||||
'password' => $password,
|
||||
'salt' => $salt,
|
||||
'avatar' => $request_data['avatar'],
|
||||
]);
|
||||
|
||||
return json([
|
||||
'code' => ResponseCode::WEB_API_SUCCESS,
|
||||
'msg' => '添加成功'
|
||||
]);
|
||||
|
||||
// return parent::insert($request);
|
||||
}
|
||||
return view('student-parent/insert');
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新
|
||||
* @param Request $request
|
||||
* @return Response
|
||||
* @throws BusinessException
|
||||
*/
|
||||
public function update(Request $request): Response
|
||||
{
|
||||
if ($request->method() === 'POST') {
|
||||
try {
|
||||
$request_data = $request->post();
|
||||
|
||||
$student = \app\common\model\StudentParent::where(['id' => $request_data['id']])->findOrEmpty();
|
||||
if ($student->isEmpty()) {
|
||||
throw new Exception('未找到家长信息,操作失败');
|
||||
}
|
||||
|
||||
if (empty($request_data['password'])) {
|
||||
$update = [
|
||||
'parent_name' => $request_data['parent_name'],
|
||||
'account' => $request_data['account'],
|
||||
'avatar' => $request_data['avatar'],
|
||||
];
|
||||
} else {
|
||||
$salt = random_str(16);
|
||||
$password = md5($request_data['password'] . $salt);
|
||||
$update = [
|
||||
'parent_name' => $request_data['parent_name'],
|
||||
'account' => $request_data['account'],
|
||||
'password' => $password,
|
||||
'salt' => $salt,
|
||||
'avatar' => $request_data['avatar'],
|
||||
];
|
||||
}
|
||||
|
||||
$student->save($update);
|
||||
|
||||
return json([
|
||||
'code' => ResponseCode::WEB_API_SUCCESS,
|
||||
'msg' => 'success'
|
||||
]);
|
||||
} catch (Exception $e) {
|
||||
return json([
|
||||
'code' => ResponseCode::WEB_API_FAIL,
|
||||
'msg' => $e->getMessage()
|
||||
]);
|
||||
}
|
||||
|
||||
return parent::update($request);
|
||||
}
|
||||
return view('student-parent/update');
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @desc 重置密码
|
||||
* @param Request $request
|
||||
* @return Response
|
||||
*/
|
||||
public function resetPassword(Request $request)
|
||||
{
|
||||
try {
|
||||
$request_data = $request->post();
|
||||
$parent = \app\common\model\StudentParent::where(['id' => $request_data['id']])->findOrEmpty();
|
||||
$new_password = trim(mb_substr($parent->account, 0, -2)) . '001';
|
||||
$salt = random_str(16);
|
||||
$password = md5($new_password . $salt);
|
||||
|
||||
$res = $parent->save([
|
||||
'salt' => $salt,
|
||||
'password' => $password
|
||||
]);
|
||||
if(!$res){
|
||||
throw new Exception('重置失败');
|
||||
}
|
||||
|
||||
return json([
|
||||
'code' => ResponseCode::WEB_API_SUCCESS,
|
||||
'msg' => '重置成功'
|
||||
]);
|
||||
} catch (Exception $e) {
|
||||
return json([
|
||||
'code' => ResponseCode::WEB_API_FAIL,
|
||||
'msg' => $e->getMessage()
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -9,7 +9,7 @@ use plugin\admin\app\controller\Crud;
|
||||
use support\exception\BusinessException;
|
||||
|
||||
/**
|
||||
* 学科设置
|
||||
* 课程管理
|
||||
*/
|
||||
class SubjectController extends Crud
|
||||
{
|
||||
|
39
plugin/admin/app/model/Parent.php
Normal file
39
plugin/admin/app/model/Parent.php
Normal file
@ -0,0 +1,39 @@
|
||||
<?php
|
||||
|
||||
namespace plugin\admin\app\model;
|
||||
|
||||
use plugin\admin\app\model\Base;
|
||||
|
||||
/**
|
||||
* @property integer $id (主键)
|
||||
* @property string $parent_name 学生姓名
|
||||
* @property string $account 账号
|
||||
* @property string $salt 密码盐
|
||||
* @property string $password 密码
|
||||
* @property string $nickname 昵称
|
||||
* @property string $avatar 头像
|
||||
* @property string $mobile 手机号
|
||||
* @property string $birthday 生日
|
||||
* @property mixed $created_at 创建时间
|
||||
* @property string $updated_at 更新时间
|
||||
* @property string $deleted_at
|
||||
*/
|
||||
class Parent extends Base
|
||||
{
|
||||
/**
|
||||
* The table associated with the model.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $table = 'wa_parent';
|
||||
|
||||
/**
|
||||
* The primary key associated with the table.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $primaryKey = 'id';
|
||||
|
||||
|
||||
|
||||
}
|
40
plugin/admin/app/model/Student.php
Normal file
40
plugin/admin/app/model/Student.php
Normal file
@ -0,0 +1,40 @@
|
||||
<?php
|
||||
|
||||
namespace plugin\admin\app\model;
|
||||
|
||||
use plugin\admin\app\model\Base;
|
||||
|
||||
/**
|
||||
* @property integer $id (主键)
|
||||
* @property string $student_name 学生姓名
|
||||
* @property string $account 账号
|
||||
* @property string $password 密码
|
||||
* @property string $salt 密码盐
|
||||
* @property string $nickname 昵称
|
||||
* @property string $avatar 头像
|
||||
* @property string $mobile 手机号
|
||||
* @property string $birthday 生日
|
||||
* @property integer $parent_id 家长
|
||||
* @property mixed $created_at 创建时间
|
||||
* @property string $updated_at 更新时间
|
||||
* @property string $deleted_at
|
||||
*/
|
||||
class Student extends Base
|
||||
{
|
||||
/**
|
||||
* The table associated with the model.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $table = 'wa_student';
|
||||
|
||||
/**
|
||||
* The primary key associated with the table.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $primaryKey = 'id';
|
||||
|
||||
|
||||
|
||||
}
|
39
plugin/admin/app/model/StudentParent.php
Normal file
39
plugin/admin/app/model/StudentParent.php
Normal file
@ -0,0 +1,39 @@
|
||||
<?php
|
||||
|
||||
namespace plugin\admin\app\model;
|
||||
|
||||
use plugin\admin\app\model\Base;
|
||||
|
||||
/**
|
||||
* @property integer $id (主键)
|
||||
* @property string $parent_name 家长姓名
|
||||
* @property string $account 账号
|
||||
* @property string $salt 密码盐
|
||||
* @property string $password 密码
|
||||
* @property string $nickname 昵称
|
||||
* @property string $avatar 头像
|
||||
* @property string $mobile 手机号
|
||||
* @property string $birthday 生日
|
||||
* @property mixed $created_at 创建时间
|
||||
* @property string $updated_at 更新时间
|
||||
* @property string $deleted_at
|
||||
*/
|
||||
class StudentParent extends Base
|
||||
{
|
||||
/**
|
||||
* The table associated with the model.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $table = 'wa_student_parent';
|
||||
|
||||
/**
|
||||
* The primary key associated with the table.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $primaryKey = 'id';
|
||||
|
||||
|
||||
|
||||
}
|
@ -7,6 +7,7 @@ use plugin\admin\app\model\Base;
|
||||
/**
|
||||
* @property integer $id (主键)
|
||||
* @property string $subject_name 课程名称
|
||||
* @property string $english_name 英文名称
|
||||
* @property integer $sort 排序
|
||||
* @property mixed $created_at 创建时间
|
||||
* @property string $updated_at 更新时间
|
||||
|
360
plugin/admin/app/view/student-parent/index.html
Normal file
360
plugin/admin/app/view/student-parent/index.html
Normal file
@ -0,0 +1,360 @@
|
||||
|
||||
<!DOCTYPE html>
|
||||
<html lang="zh-cn">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>浏览页面</title>
|
||||
<link rel="stylesheet" href="/app/admin/component/pear/css/pear.css" />
|
||||
<link rel="stylesheet" href="/app/admin/admin/css/reset.css" />
|
||||
</head>
|
||||
<body class="pear-container">
|
||||
|
||||
<!-- 顶部查询表单 -->
|
||||
<div class="layui-card">
|
||||
<div class="layui-card-body">
|
||||
<form class="layui-form top-search-from">
|
||||
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">家长姓名</label>
|
||||
<div class="layui-input-block">
|
||||
<div class="layui-input-block">
|
||||
<input type="hidden" autocomplete="off" name="parent_name[]" value="like" class="layui-input inline-block">
|
||||
<input type="text" autocomplete="off" name="parent_name[]" class="layui-input">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">账号</label>
|
||||
<div class="layui-input-block">
|
||||
<div class="layui-input-block">
|
||||
<input type="hidden" autocomplete="off" name="account[]" value="like" class="layui-input inline-block">
|
||||
<input type="text" autocomplete="off" name="account[]" class="layui-input">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="layui-form-item layui-inline">
|
||||
<label class="layui-form-label"></label>
|
||||
<button class="pear-btn pear-btn-md pear-btn-primary" lay-submit lay-filter="table-query">
|
||||
<i class="layui-icon layui-icon-search"></i>查询
|
||||
</button>
|
||||
<button type="reset" class="pear-btn pear-btn-md" lay-submit lay-filter="table-reset">
|
||||
<i class="layui-icon layui-icon-refresh"></i>重置
|
||||
</button>
|
||||
</div>
|
||||
<div class="toggle-btn">
|
||||
<a class="layui-hide">展开<i class="layui-icon layui-icon-down"></i></a>
|
||||
<a class="layui-hide">收起<i class="layui-icon layui-icon-up"></i></a>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 数据表格 -->
|
||||
<div class="layui-card">
|
||||
<div class="layui-card-body">
|
||||
<table id="data-table" lay-filter="data-table"></table>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 表格顶部工具栏 -->
|
||||
<script type="text/html" id="table-toolbar">
|
||||
<button class="pear-btn pear-btn-primary pear-btn-md" lay-event="add" permission="app.admin.studentparent.insert">
|
||||
<i class="layui-icon layui-icon-add-1"></i>新增
|
||||
</button>
|
||||
<button class="pear-btn pear-btn-danger pear-btn-md" lay-event="batchRemove" permission="app.admin.studentparent.delete">
|
||||
<i class="layui-icon layui-icon-delete"></i>删除
|
||||
</button>
|
||||
</script>
|
||||
|
||||
<!-- 表格行工具栏 -->
|
||||
<script type="text/html" id="table-bar">
|
||||
<button class="pear-btn pear-btn-xs tool-btn" lay-event="edit" permission="app.admin.studentparent.update">编辑</button>
|
||||
<button class="pear-btn pear-btn-xs tool-btn" lay-event="rest_password" permission="app.admin.teacher.update">重置密码</button>
|
||||
<button class="pear-btn pear-btn-xs tool-btn" lay-event="remove" permission="app.admin.studentparent.delete">删除</button>
|
||||
</script>
|
||||
|
||||
<script src="/app/admin/component/layui/layui.js?v=2.8.12"></script>
|
||||
<script src="/app/admin/component/pear/pear.js"></script>
|
||||
<script src="/app/admin/admin/js/permission.js"></script>
|
||||
<script src="/app/admin/admin/js/common.js"></script>
|
||||
|
||||
<script>
|
||||
|
||||
// 相关常量
|
||||
const PRIMARY_KEY = "id";
|
||||
const SELECT_API = "/app/admin/student-parent/select";
|
||||
const UPDATE_API = "/app/admin/student-parent/update";
|
||||
const DELETE_API = "/app/admin/student-parent/delete";
|
||||
const INSERT_URL = "/app/admin/student-parent/insert";
|
||||
const UPDATE_URL = "/app/admin/student-parent/update";
|
||||
|
||||
// 表格渲染
|
||||
layui.use(["table", "form", "common", "popup", "util"], function() {
|
||||
let table = layui.table;
|
||||
let form = layui.form;
|
||||
let $ = layui.$;
|
||||
let common = layui.common;
|
||||
let util = layui.util;
|
||||
|
||||
// 表头参数
|
||||
let cols = [
|
||||
{
|
||||
type: "checkbox",
|
||||
align: "center"
|
||||
},{
|
||||
title: "id",align: "center",
|
||||
field: "id",
|
||||
},{
|
||||
title: "家长姓名",align: "center",
|
||||
field: "parent_name",
|
||||
},{
|
||||
title: "账号",align: "center",
|
||||
field: "account",
|
||||
},{
|
||||
title: "密码盐",align: "center",
|
||||
field: "salt",
|
||||
hide: true,
|
||||
},{
|
||||
title: "密码",align: "center",
|
||||
field: "password",
|
||||
hide: true,
|
||||
},{
|
||||
title: "昵称",align: "center",
|
||||
field: "nickname",
|
||||
hide: true,
|
||||
},{
|
||||
title: "头像",align: "center",
|
||||
field: "avatar",
|
||||
templet: function (d) {
|
||||
return '<img src="'+encodeURI(d['avatar'])+'" style="max-width:32px;max-height:32px;" alt="" />'
|
||||
}
|
||||
},{
|
||||
title: "手机号",align: "center",
|
||||
field: "mobile",
|
||||
hide: true,
|
||||
},{
|
||||
title: "生日",align: "center",
|
||||
field: "birthday",
|
||||
hide: true,
|
||||
},{
|
||||
title: "创建时间",align: "center",
|
||||
field: "created_at",
|
||||
},{
|
||||
title: "更新时间",align: "center",
|
||||
field: "updated_at",
|
||||
hide: true,
|
||||
},{
|
||||
title: "deleted_at",align: "center",
|
||||
field: "deleted_at",
|
||||
hide: true,
|
||||
},{
|
||||
title: "操作",
|
||||
toolbar: "#table-bar",
|
||||
align: "center",
|
||||
fixed: "right",
|
||||
width: 220,
|
||||
}
|
||||
];
|
||||
|
||||
// 渲染表格
|
||||
table.render({
|
||||
elem: "#data-table",
|
||||
url: SELECT_API,
|
||||
page: true,
|
||||
cols: [cols],
|
||||
skin: "line",
|
||||
size: "lg",
|
||||
toolbar: "#table-toolbar",
|
||||
autoSort: false,
|
||||
defaultToolbar: [{
|
||||
title: "刷新",
|
||||
layEvent: "refresh",
|
||||
icon: "layui-icon-refresh",
|
||||
}, "filter", "print", "exports"],
|
||||
done: function () {
|
||||
layer.photos({photos: 'div[lay-id="data-table"]', anim: 5});
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
// 编辑或删除行事件
|
||||
table.on("tool(data-table)", function(obj) {
|
||||
if (obj.event === "remove") {
|
||||
remove(obj);
|
||||
} else if (obj.event === "edit") {
|
||||
edit(obj);
|
||||
} else if (obj.event === "rest_password") {
|
||||
rest_password(obj);
|
||||
}
|
||||
});
|
||||
|
||||
// 表格顶部工具栏事件
|
||||
table.on("toolbar(data-table)", function(obj) {
|
||||
if (obj.event === "add") {
|
||||
add();
|
||||
} else if (obj.event === "refresh") {
|
||||
refreshTable();
|
||||
} else if (obj.event === "batchRemove") {
|
||||
batchRemove(obj);
|
||||
}
|
||||
});
|
||||
|
||||
// 表格顶部搜索事件
|
||||
form.on("submit(table-query)", function(data) {
|
||||
table.reload("data-table", {
|
||||
page: {
|
||||
curr: 1
|
||||
},
|
||||
where: data.field
|
||||
})
|
||||
return false;
|
||||
});
|
||||
|
||||
// 表格顶部搜索重置事件
|
||||
form.on("submit(table-reset)", function(data) {
|
||||
table.reload("data-table", {
|
||||
where: []
|
||||
})
|
||||
});
|
||||
|
||||
// 字段允许为空
|
||||
form.verify({
|
||||
phone: [/(^$)|^1\d{10}$/, "请输入正确的手机号"],
|
||||
email: [/(^$)|^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/, "邮箱格式不正确"],
|
||||
url: [/(^$)|(^#)|(^http(s*):\/\/[^\s]+\.[^\s]+)/, "链接格式不正确"],
|
||||
number: [/(^$)|^\d+$/,'只能填写数字'],
|
||||
date: [/(^$)|^(\d{4})[-\/](\d{1}|0\d{1}|1[0-2])([-\/](\d{1}|0\d{1}|[1-2][0-9]|3[0-1]))*$/, "日期格式不正确"],
|
||||
identity: [/(^$)|(^\d{15}$)|(^\d{17}(x|X|\d)$)/, "请输入正确的身份证号"]
|
||||
});
|
||||
|
||||
// 表格排序事件
|
||||
table.on("sort(data-table)", function(obj){
|
||||
table.reload("data-table", {
|
||||
initSort: obj,
|
||||
scrollPos: "fixed",
|
||||
where: {
|
||||
field: obj.field,
|
||||
order: obj.type
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
// 表格新增数据
|
||||
let add = function() {
|
||||
layer.open({
|
||||
type: 2,
|
||||
title: "新增",
|
||||
shade: 0.1,
|
||||
maxmin: true,
|
||||
area: [common.isModile()?"100%":"500px", common.isModile()?"100%":"450px"],
|
||||
content: INSERT_URL
|
||||
});
|
||||
}
|
||||
|
||||
// 表格编辑数据
|
||||
let edit = function(obj) {
|
||||
let value = obj.data[PRIMARY_KEY];
|
||||
layer.open({
|
||||
type: 2,
|
||||
title: "修改",
|
||||
shade: 0.1,
|
||||
maxmin: true,
|
||||
area: [common.isModile()?"100%":"500px", common.isModile()?"100%":"450px"],
|
||||
content: UPDATE_URL + "?" + PRIMARY_KEY + "=" + value
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
let rest_password = function(obj) {
|
||||
console.log()
|
||||
let data = {};
|
||||
data[PRIMARY_KEY] = obj.data[PRIMARY_KEY];
|
||||
let first_name = obj.data['account'].split(' ');
|
||||
console.log(first_name)
|
||||
let new_password = first_name[0].trim() + '001';
|
||||
layer.confirm("确定重置密码?重置后新密码格式为【Ben001】", {
|
||||
icon: 3,
|
||||
title: "提示"
|
||||
}, function(index) {
|
||||
layer.close(index);
|
||||
let loading = layer.load();
|
||||
$.ajax({
|
||||
url: '/app/admin/studentParent/resetPassword',
|
||||
data: data,
|
||||
dataType: "json",
|
||||
type: "post",
|
||||
success: function(res) {
|
||||
layer.close(loading);
|
||||
if (res.code) {
|
||||
return layui.popup.failure(res.msg);
|
||||
}
|
||||
return layui.popup.success("操作成功", refreshTable);
|
||||
}
|
||||
})
|
||||
});
|
||||
}
|
||||
|
||||
// 删除一行
|
||||
let remove = function(obj) {
|
||||
return doRemove(obj.data[PRIMARY_KEY]);
|
||||
}
|
||||
|
||||
// 删除多行
|
||||
let batchRemove = function(obj) {
|
||||
let checkIds = common.checkField(obj, PRIMARY_KEY);
|
||||
if (checkIds === "") {
|
||||
layui.popup.warning("未选中数据");
|
||||
return false;
|
||||
}
|
||||
doRemove(checkIds.split(","));
|
||||
}
|
||||
|
||||
// 执行删除
|
||||
let doRemove = function (ids) {
|
||||
let data = {};
|
||||
data[PRIMARY_KEY] = ids;
|
||||
layer.confirm("确定删除?", {
|
||||
icon: 3,
|
||||
title: "提示"
|
||||
}, function(index) {
|
||||
layer.close(index);
|
||||
let loading = layer.load();
|
||||
$.ajax({
|
||||
url: DELETE_API,
|
||||
data: data,
|
||||
dataType: "json",
|
||||
type: "post",
|
||||
success: function(res) {
|
||||
layer.close(loading);
|
||||
if (res.code) {
|
||||
return layui.popup.failure(res.msg);
|
||||
}
|
||||
return layui.popup.success("操作成功", refreshTable);
|
||||
}
|
||||
})
|
||||
});
|
||||
}
|
||||
|
||||
// 刷新表格数据
|
||||
window.refreshTable = function() {
|
||||
table.reloadData("data-table", {
|
||||
scrollPos: "fixed",
|
||||
done: function (res, curr) {
|
||||
if (curr > 1 && res.data && !res.data.length) {
|
||||
curr = curr - 1;
|
||||
table.reloadData("data-table", {
|
||||
page: {
|
||||
curr: curr
|
||||
},
|
||||
})
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
})
|
||||
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
143
plugin/admin/app/view/student-parent/insert.html
Normal file
143
plugin/admin/app/view/student-parent/insert.html
Normal file
@ -0,0 +1,143 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="zh-cn">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>新增页面</title>
|
||||
<link rel="stylesheet" href="/app/admin/component/pear/css/pear.css" />
|
||||
<link rel="stylesheet" href="/app/admin/component/jsoneditor/css/jsoneditor.css" />
|
||||
<link rel="stylesheet" href="/app/admin/admin/css/reset.css" />
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<form class="layui-form" action="">
|
||||
|
||||
<div class="mainBox">
|
||||
<div class="main-container mr-5">
|
||||
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label required">家长姓名</label>
|
||||
<div class="layui-input-block">
|
||||
<input type="text" name="parent_name" value="" required lay-verify="required" class="layui-input">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label required">账号</label>
|
||||
<div class="layui-input-block">
|
||||
<input type="text" name="account" value="" required lay-verify="required" class="layui-input">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">密码</label>
|
||||
<div class="layui-input-block">
|
||||
<input type="text" name="password" value="" class="layui-input">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">头像</label>
|
||||
<div class="layui-input-block">
|
||||
<img class="img-3" src=""/>
|
||||
<input type="text" style="display:none" name="avatar" value="" />
|
||||
<button type="button" class="pear-btn pear-btn-primary pear-btn-sm" id="avatar" permission="app.admin.upload.image">
|
||||
<i class="layui-icon layui-icon-upload"></i>上传图片
|
||||
</button>
|
||||
<button type="button" class="pear-btn pear-btn-primary pear-btn-sm" id="attachment-choose-avatar" permission="app.admin.upload.attachment">
|
||||
<i class="layui-icon layui-icon-align-left"></i>选择图片
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="bottom">
|
||||
<div class="button-container">
|
||||
<button type="submit" class="pear-btn pear-btn-primary pear-btn-md" lay-submit=""
|
||||
lay-filter="save">
|
||||
提交
|
||||
</button>
|
||||
<button type="reset" class="pear-btn pear-btn-md">
|
||||
重置
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</form>
|
||||
|
||||
<script src="/app/admin/component/layui/layui.js?v=2.8.12"></script>
|
||||
<script src="/app/admin/component/pear/pear.js"></script>
|
||||
<script src="/app/admin/component/jsoneditor/jsoneditor.js"></script>
|
||||
<script src="/app/admin/admin/js/permission.js"></script>
|
||||
|
||||
<script>
|
||||
|
||||
// 相关接口
|
||||
const INSERT_API = "/app/admin/student-parent/insert";
|
||||
|
||||
// 字段 头像 avatar
|
||||
layui.use(["upload", "layer"], function() {
|
||||
let input = layui.$("#avatar").prev();
|
||||
input.prev().attr("src", input.val());
|
||||
layui.$("#attachment-choose-avatar").on("click", function() {
|
||||
parent.layer.open({
|
||||
type: 2,
|
||||
title: "选择附件",
|
||||
content: "/app/admin/upload/attachment?ext=jpg,jpeg,png,gif,bmp",
|
||||
area: ["95%", "90%"],
|
||||
success: function (layero, index) {
|
||||
parent.layui.$("#layui-layer" + index).data("callback", function (data) {
|
||||
input.val(data.url).prev().attr("src", data.url);
|
||||
});
|
||||
}
|
||||
});
|
||||
});
|
||||
layui.upload.render({
|
||||
elem: "#avatar",
|
||||
value: "",
|
||||
acceptMime: "image/gif,image/jpeg,image/jpg,image/png",
|
||||
url: "/app/admin/upload/image",
|
||||
field: "__file__",
|
||||
done: function (res) {
|
||||
if (res.code > 0) return layui.layer.msg(res.msg);
|
||||
this.item.prev().val(res.data.url).prev().attr("src", res.data.url);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
//提交事件
|
||||
layui.use(["form", "popup"], function () {
|
||||
// 字段验证允许为空
|
||||
layui.form.verify({
|
||||
phone: [/(^$)|^1\d{10}$/, "请输入正确的手机号"],
|
||||
email: [/(^$)|^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/, "邮箱格式不正确"],
|
||||
url: [/(^$)|(^#)|(^http(s*):\/\/[^\s]+\.[^\s]+)/, "链接格式不正确"],
|
||||
number: [/(^$)|^\d+$/,'只能填写数字'],
|
||||
date: [/(^$)|^(\d{4})[-\/](\d{1}|0\d{1}|1[0-2])([-\/](\d{1}|0\d{1}|[1-2][0-9]|3[0-1]))*$/, "日期格式不正确"],
|
||||
identity: [/(^$)|(^\d{15}$)|(^\d{17}(x|X|\d)$)/, "请输入正确的身份证号"]
|
||||
});
|
||||
layui.form.on("submit(save)", function (data) {
|
||||
layui.$.ajax({
|
||||
url: INSERT_API,
|
||||
type: "POST",
|
||||
dateType: "json",
|
||||
data: data.field,
|
||||
success: function (res) {
|
||||
if (res.code) {
|
||||
return layui.popup.failure(res.msg);
|
||||
}
|
||||
return layui.popup.success("操作成功", function () {
|
||||
parent.refreshTable();
|
||||
parent.layer.close(parent.layer.getFrameIndex(window.name));
|
||||
});
|
||||
}
|
||||
});
|
||||
return false;
|
||||
});
|
||||
});
|
||||
|
||||
</script>
|
||||
|
||||
</body>
|
||||
</html>
|
180
plugin/admin/app/view/student-parent/update.html
Normal file
180
plugin/admin/app/view/student-parent/update.html
Normal file
@ -0,0 +1,180 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="zh-cn">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>更新页面</title>
|
||||
<link rel="stylesheet" href="/app/admin/component/pear/css/pear.css" />
|
||||
<link rel="stylesheet" href="/app/admin/component/jsoneditor/css/jsoneditor.css" />
|
||||
<link rel="stylesheet" href="/app/admin/admin/css/reset.css" />
|
||||
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<form class="layui-form">
|
||||
|
||||
<div class="mainBox">
|
||||
<div class="main-container mr-5">
|
||||
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label required">家长姓名</label>
|
||||
<div class="layui-input-block">
|
||||
<input type="text" name="parent_name" value="" required lay-verify="required" class="layui-input">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label required">账号</label>
|
||||
<div class="layui-input-block">
|
||||
<input type="text" name="account" value="" required lay-verify="required" class="layui-input">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">密码</label>
|
||||
<div class="layui-input-block">
|
||||
<input type="text" name="password" value="" class="layui-input">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">头像</label>
|
||||
<div class="layui-input-block">
|
||||
<img class="img-3" src=""/>
|
||||
<input type="text" style="display:none" name="avatar" value="" />
|
||||
<button type="button" class="pear-btn pear-btn-primary pear-btn-sm" id="avatar" permission="app.admin.upload.image">
|
||||
<i class="layui-icon layui-icon-upload"></i>上传图片
|
||||
</button>
|
||||
<button type="button" class="pear-btn pear-btn-primary pear-btn-sm" id="attachment-choose-avatar" permission="app.admin.upload.attachment">
|
||||
<i class="layui-icon layui-icon-align-left"></i>选择图片
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="bottom">
|
||||
<div class="button-container">
|
||||
<button type="submit" class="pear-btn pear-btn-primary pear-btn-md" lay-submit="" lay-filter="save">
|
||||
提交
|
||||
</button>
|
||||
<button type="reset" class="pear-btn pear-btn-md">
|
||||
重置
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</form>
|
||||
|
||||
<script src="/app/admin/component/layui/layui.js?v=2.8.12"></script>
|
||||
<script src="/app/admin/component/pear/pear.js"></script>
|
||||
<script src="/app/admin/component/jsoneditor/jsoneditor.js"></script>
|
||||
<script src="/app/admin/admin/js/permission.js"></script>
|
||||
|
||||
<script>
|
||||
|
||||
// 相关接口
|
||||
const PRIMARY_KEY = "id";
|
||||
const SELECT_API = "/app/admin/student-parent/select" + location.search;
|
||||
const UPDATE_API = "/app/admin/student-parent/update";
|
||||
|
||||
// 获取数据库记录
|
||||
layui.use(["form", "util", "popup"], function () {
|
||||
let $ = layui.$;
|
||||
$.ajax({
|
||||
url: SELECT_API,
|
||||
dataType: "json",
|
||||
success: function (res) {
|
||||
|
||||
// 给表单初始化数据
|
||||
layui.each(res.data[0], function (key, value) {
|
||||
let obj = $('*[name="'+key+'"]');
|
||||
if (key === "password") {
|
||||
obj.attr("placeholder", "不更新密码请留空");
|
||||
return;
|
||||
}
|
||||
if (typeof obj[0] === "undefined" || !obj[0].nodeName) return;
|
||||
if (obj[0].nodeName.toLowerCase() === "textarea") {
|
||||
obj.val(value);
|
||||
} else {
|
||||
obj.attr("value", value);
|
||||
obj[0].value = value;
|
||||
}
|
||||
});
|
||||
|
||||
// 字段 头像 avatar
|
||||
layui.use(["upload", "layer"], function() {
|
||||
let input = layui.$("#avatar").prev();
|
||||
input.prev().attr("src", input.val());
|
||||
layui.$("#attachment-choose-avatar").on("click", function() {
|
||||
parent.layer.open({
|
||||
type: 2,
|
||||
title: "选择附件",
|
||||
content: "/app/admin/upload/attachment?ext=jpg,jpeg,png,gif,bmp",
|
||||
area: ["95%", "90%"],
|
||||
success: function (layero, index) {
|
||||
parent.layui.$("#layui-layer" + index).data("callback", function (data) {
|
||||
input.val(data.url).prev().attr("src", data.url);
|
||||
});
|
||||
}
|
||||
});
|
||||
});
|
||||
layui.upload.render({
|
||||
elem: "#avatar",
|
||||
acceptMime: "image/gif,image/jpeg,image/jpg,image/png",
|
||||
url: "/app/admin/upload/image",
|
||||
field: "__file__",
|
||||
done: function (res) {
|
||||
if (res.code > 0) return layui.layer.msg(res.msg);
|
||||
this.item.prev().val(res.data.url).prev().attr("src", res.data.url);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
// ajax返回失败
|
||||
if (res.code) {
|
||||
layui.popup.failure(res.msg);
|
||||
}
|
||||
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
//提交事件
|
||||
layui.use(["form", "popup"], function () {
|
||||
// 字段验证允许为空
|
||||
layui.form.verify({
|
||||
phone: [/(^$)|^1\d{10}$/, "请输入正确的手机号"],
|
||||
email: [/(^$)|^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/, "邮箱格式不正确"],
|
||||
url: [/(^$)|(^#)|(^http(s*):\/\/[^\s]+\.[^\s]+)/, "链接格式不正确"],
|
||||
number: [/(^$)|^\d+$/,'只能填写数字'],
|
||||
date: [/(^$)|^(\d{4})[-\/](\d{1}|0\d{1}|1[0-2])([-\/](\d{1}|0\d{1}|[1-2][0-9]|3[0-1]))*$/, "日期格式不正确"],
|
||||
identity: [/(^$)|(^\d{15}$)|(^\d{17}(x|X|\d)$)/, "请输入正确的身份证号"]
|
||||
});
|
||||
layui.form.on("submit(save)", function (data) {
|
||||
data.field[PRIMARY_KEY] = layui.url().search[PRIMARY_KEY];
|
||||
layui.$.ajax({
|
||||
url: UPDATE_API,
|
||||
type: "POST",
|
||||
dateType: "json",
|
||||
data: data.field,
|
||||
success: function (res) {
|
||||
if (res.code) {
|
||||
return layui.popup.failure(res.msg);
|
||||
}
|
||||
return layui.popup.success("操作成功", function () {
|
||||
parent.refreshTable();
|
||||
parent.layer.close(parent.layer.getFrameIndex(window.name));
|
||||
});
|
||||
}
|
||||
});
|
||||
return false;
|
||||
});
|
||||
});
|
||||
|
||||
</script>
|
||||
|
||||
</body>
|
||||
|
||||
</html>
|
323
plugin/admin/app/view/student/index.html
Normal file
323
plugin/admin/app/view/student/index.html
Normal file
@ -0,0 +1,323 @@
|
||||
|
||||
<!DOCTYPE html>
|
||||
<html lang="zh-cn">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>浏览页面</title>
|
||||
<link rel="stylesheet" href="/app/admin/component/pear/css/pear.css" />
|
||||
<link rel="stylesheet" href="/app/admin/admin/css/reset.css" />
|
||||
</head>
|
||||
<body class="pear-container">
|
||||
|
||||
<!-- 顶部查询表单 -->
|
||||
|
||||
|
||||
<!-- 数据表格 -->
|
||||
<div class="layui-card">
|
||||
<div class="layui-card-body">
|
||||
<table id="data-table" lay-filter="data-table"></table>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 表格顶部工具栏 -->
|
||||
<script type="text/html" id="table-toolbar">
|
||||
<button class="pear-btn pear-btn-primary pear-btn-md" lay-event="add" permission="app.admin.student.insert">
|
||||
<i class="layui-icon layui-icon-add-1"></i>新增
|
||||
</button>
|
||||
<button class="pear-btn pear-btn-danger pear-btn-md" lay-event="batchRemove" permission="app.admin.student.delete">
|
||||
<i class="layui-icon layui-icon-delete"></i>删除
|
||||
</button>
|
||||
</script>
|
||||
|
||||
<!-- 表格行工具栏 -->
|
||||
<script type="text/html" id="table-bar">
|
||||
<button class="pear-btn pear-btn-xs tool-btn" lay-event="edit" permission="app.admin.student.update">编辑</button>
|
||||
<button class="pear-btn pear-btn-xs tool-btn" lay-event="rest_password" permission="app.admin.teacher.update">重置密码</button>
|
||||
<button class="pear-btn pear-btn-xs tool-btn" lay-event="remove" permission="app.admin.student.delete">删除</button>
|
||||
</script>
|
||||
|
||||
<script src="/app/admin/component/layui/layui.js?v=2.8.12"></script>
|
||||
<script src="/app/admin/component/pear/pear.js"></script>
|
||||
<script src="/app/admin/admin/js/permission.js"></script>
|
||||
<script src="/app/admin/admin/js/common.js"></script>
|
||||
|
||||
<script>
|
||||
|
||||
// 相关常量
|
||||
const PRIMARY_KEY = "id";
|
||||
const SELECT_API = "/app/admin/student/select";
|
||||
const UPDATE_API = "/app/admin/student/update";
|
||||
const DELETE_API = "/app/admin/student/delete";
|
||||
const INSERT_URL = "/app/admin/student/insert";
|
||||
const UPDATE_URL = "/app/admin/student/update";
|
||||
|
||||
// 表格渲染
|
||||
layui.use(["table", "form", "common", "popup", "util"], function() {
|
||||
let table = layui.table;
|
||||
let form = layui.form;
|
||||
let $ = layui.$;
|
||||
let common = layui.common;
|
||||
let util = layui.util;
|
||||
|
||||
// 表头参数
|
||||
let cols = [
|
||||
{
|
||||
type: "checkbox",
|
||||
align: "center"
|
||||
},{
|
||||
title: "id",align: "center",
|
||||
field: "id",
|
||||
},{
|
||||
title: "学生姓名",align: "center",
|
||||
field: "student_name",
|
||||
},{
|
||||
title: "账号",align: "center",
|
||||
field: "account",
|
||||
},{
|
||||
title: "密码",align: "center",
|
||||
field: "password",
|
||||
hide: true
|
||||
},{
|
||||
title: "密码盐",align: "center",
|
||||
field: "salt",
|
||||
hide: true
|
||||
},{
|
||||
title: "昵称",align: "center",
|
||||
field: "nickname",
|
||||
hide: true
|
||||
},{
|
||||
title: "头像",align: "center",
|
||||
field: "avatar",
|
||||
templet: function (d) {
|
||||
return '<img src="'+encodeURI(d['avatar'])+'" style="max-width:32px;max-height:32px;" alt="" />'
|
||||
}
|
||||
},{
|
||||
title: "手机号",align: "center",
|
||||
field: "mobile",
|
||||
hide: true
|
||||
},{
|
||||
title: "生日",align: "center",
|
||||
field: "birthday",
|
||||
hide: true
|
||||
},{
|
||||
title: "家长",align: "center",
|
||||
field: "parent_id",
|
||||
},{
|
||||
title: "创建时间",align: "center",
|
||||
field: "created_at",
|
||||
},{
|
||||
title: "更新时间",align: "center",
|
||||
field: "updated_at",
|
||||
hide: true,
|
||||
},{
|
||||
title: "deleted_at",align: "center",
|
||||
field: "deleted_at",
|
||||
hide: true,
|
||||
},{
|
||||
title: "操作",
|
||||
toolbar: "#table-bar",
|
||||
align: "center",
|
||||
fixed: "right",
|
||||
width: 220,
|
||||
}
|
||||
];
|
||||
|
||||
// 渲染表格
|
||||
table.render({
|
||||
elem: "#data-table",
|
||||
url: SELECT_API,
|
||||
page: true,
|
||||
cols: [cols],
|
||||
skin: "line",
|
||||
size: "lg",
|
||||
toolbar: "#table-toolbar",
|
||||
autoSort: false,
|
||||
defaultToolbar: [{
|
||||
title: "刷新",
|
||||
layEvent: "refresh",
|
||||
icon: "layui-icon-refresh",
|
||||
}, "filter", "print", "exports"],
|
||||
done: function () {
|
||||
layer.photos({photos: 'div[lay-id="data-table"]', anim: 5});
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
// 编辑或删除行事件
|
||||
table.on("tool(data-table)", function(obj) {
|
||||
if (obj.event === "remove") {
|
||||
remove(obj);
|
||||
} else if (obj.event === "edit") {
|
||||
edit(obj);
|
||||
} else if (obj.event === "rest_password") {
|
||||
rest_password(obj);
|
||||
}
|
||||
});
|
||||
|
||||
// 表格顶部工具栏事件
|
||||
table.on("toolbar(data-table)", function(obj) {
|
||||
if (obj.event === "add") {
|
||||
add();
|
||||
} else if (obj.event === "refresh") {
|
||||
refreshTable();
|
||||
} else if (obj.event === "batchRemove") {
|
||||
batchRemove(obj);
|
||||
}
|
||||
});
|
||||
|
||||
// 表格顶部搜索事件
|
||||
form.on("submit(table-query)", function(data) {
|
||||
table.reload("data-table", {
|
||||
page: {
|
||||
curr: 1
|
||||
},
|
||||
where: data.field
|
||||
})
|
||||
return false;
|
||||
});
|
||||
|
||||
// 表格顶部搜索重置事件
|
||||
form.on("submit(table-reset)", function(data) {
|
||||
table.reload("data-table", {
|
||||
where: []
|
||||
})
|
||||
});
|
||||
|
||||
// 字段允许为空
|
||||
form.verify({
|
||||
phone: [/(^$)|^1\d{10}$/, "请输入正确的手机号"],
|
||||
email: [/(^$)|^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/, "邮箱格式不正确"],
|
||||
url: [/(^$)|(^#)|(^http(s*):\/\/[^\s]+\.[^\s]+)/, "链接格式不正确"],
|
||||
number: [/(^$)|^\d+$/,'只能填写数字'],
|
||||
date: [/(^$)|^(\d{4})[-\/](\d{1}|0\d{1}|1[0-2])([-\/](\d{1}|0\d{1}|[1-2][0-9]|3[0-1]))*$/, "日期格式不正确"],
|
||||
identity: [/(^$)|(^\d{15}$)|(^\d{17}(x|X|\d)$)/, "请输入正确的身份证号"]
|
||||
});
|
||||
|
||||
// 表格排序事件
|
||||
table.on("sort(data-table)", function(obj){
|
||||
table.reload("data-table", {
|
||||
initSort: obj,
|
||||
scrollPos: "fixed",
|
||||
where: {
|
||||
field: obj.field,
|
||||
order: obj.type
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
// 表格新增数据
|
||||
let add = function() {
|
||||
layer.open({
|
||||
type: 2,
|
||||
title: "新增",
|
||||
shade: 0.1,
|
||||
maxmin: true,
|
||||
area: [common.isModile()?"100%":"500px", common.isModile()?"100%":"450px"],
|
||||
content: INSERT_URL
|
||||
});
|
||||
}
|
||||
|
||||
// 表格编辑数据
|
||||
let edit = function(obj) {
|
||||
let value = obj.data[PRIMARY_KEY];
|
||||
layer.open({
|
||||
type: 2,
|
||||
title: "修改",
|
||||
shade: 0.1,
|
||||
maxmin: true,
|
||||
area: [common.isModile()?"100%":"500px", common.isModile()?"100%":"450px"],
|
||||
content: UPDATE_URL + "?" + PRIMARY_KEY + "=" + value
|
||||
});
|
||||
}
|
||||
|
||||
let rest_password = function(obj) {
|
||||
console.log()
|
||||
let data = {};
|
||||
data[PRIMARY_KEY] = obj.data[PRIMARY_KEY];
|
||||
let first_name = obj.data['account'].split(' ');
|
||||
console.log(first_name)
|
||||
let new_password = first_name[0].trim() + '001';
|
||||
layer.confirm("确定充值密码?重置后新密码为【"+ new_password +"】", {
|
||||
icon: 3,
|
||||
title: "提示"
|
||||
}, function(index) {
|
||||
layer.close(index);
|
||||
let loading = layer.load();
|
||||
$.ajax({
|
||||
url: '/app/admin/student/resetPassword',
|
||||
data: data,
|
||||
dataType: "json",
|
||||
type: "post",
|
||||
success: function(res) {
|
||||
layer.close(loading);
|
||||
if (res.code) {
|
||||
return layui.popup.failure(res.msg);
|
||||
}
|
||||
return layui.popup.success("操作成功", refreshTable);
|
||||
}
|
||||
})
|
||||
});
|
||||
}
|
||||
|
||||
// 删除一行
|
||||
let remove = function(obj) {
|
||||
return doRemove(obj.data[PRIMARY_KEY]);
|
||||
}
|
||||
|
||||
// 删除多行
|
||||
let batchRemove = function(obj) {
|
||||
let checkIds = common.checkField(obj, PRIMARY_KEY);
|
||||
if (checkIds === "") {
|
||||
layui.popup.warning("未选中数据");
|
||||
return false;
|
||||
}
|
||||
doRemove(checkIds.split(","));
|
||||
}
|
||||
|
||||
// 执行删除
|
||||
let doRemove = function (ids) {
|
||||
let data = {};
|
||||
data[PRIMARY_KEY] = ids;
|
||||
layer.confirm("确定删除?", {
|
||||
icon: 3,
|
||||
title: "提示"
|
||||
}, function(index) {
|
||||
layer.close(index);
|
||||
let loading = layer.load();
|
||||
$.ajax({
|
||||
url: DELETE_API,
|
||||
data: data,
|
||||
dataType: "json",
|
||||
type: "post",
|
||||
success: function(res) {
|
||||
layer.close(loading);
|
||||
if (res.code) {
|
||||
return layui.popup.failure(res.msg);
|
||||
}
|
||||
return layui.popup.success("操作成功", refreshTable);
|
||||
}
|
||||
})
|
||||
});
|
||||
}
|
||||
|
||||
// 刷新表格数据
|
||||
window.refreshTable = function() {
|
||||
table.reloadData("data-table", {
|
||||
scrollPos: "fixed",
|
||||
done: function (res, curr) {
|
||||
if (curr > 1 && res.data && !res.data.length) {
|
||||
curr = curr - 1;
|
||||
table.reloadData("data-table", {
|
||||
page: {
|
||||
curr: curr
|
||||
},
|
||||
})
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
})
|
||||
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
164
plugin/admin/app/view/student/insert.html
Normal file
164
plugin/admin/app/view/student/insert.html
Normal file
@ -0,0 +1,164 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="zh-cn">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>新增页面</title>
|
||||
<link rel="stylesheet" href="/app/admin/component/pear/css/pear.css" />
|
||||
<link rel="stylesheet" href="/app/admin/component/jsoneditor/css/jsoneditor.css" />
|
||||
<link rel="stylesheet" href="/app/admin/admin/css/reset.css" />
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<form class="layui-form" action="">
|
||||
|
||||
<div class="mainBox">
|
||||
<div class="main-container mr-5">
|
||||
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label required">学生姓名</label>
|
||||
<div class="layui-input-block">
|
||||
<input type="text" name="student_name" value="" required lay-verify="required" class="layui-input">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label required">账号</label>
|
||||
<div class="layui-input-block">
|
||||
<input type="text" name="account" value="" required lay-verify="required" class="layui-input">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">密码</label>
|
||||
<div class="layui-input-block">
|
||||
<input type="text" name="password" value="" class="layui-input">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- <div class="layui-form-item">-->
|
||||
<!-- <label class="layui-form-label">密码盐</label>-->
|
||||
<!-- <div class="layui-input-block">-->
|
||||
<!-- <input type="text" name="salt" value="" class="layui-input">-->
|
||||
<!-- </div>-->
|
||||
<!-- </div>-->
|
||||
|
||||
<!-- <div class="layui-form-item">-->
|
||||
<!-- <label class="layui-form-label">昵称</label>-->
|
||||
<!-- <div class="layui-input-block">-->
|
||||
<!-- <input type="text" name="nickname" value="" class="layui-input">-->
|
||||
<!-- </div>-->
|
||||
<!-- </div>-->
|
||||
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">头像</label>
|
||||
<div class="layui-input-block">
|
||||
<img class="img-3" src=""/>
|
||||
<input type="text" style="display:none" name="avatar" value="" />
|
||||
<button type="button" class="pear-btn pear-btn-primary pear-btn-sm" id="avatar" permission="app.admin.upload.image">
|
||||
<i class="layui-icon layui-icon-upload"></i>上传图片
|
||||
</button>
|
||||
<button type="button" class="pear-btn pear-btn-primary pear-btn-sm" id="attachment-choose-avatar" permission="app.admin.upload.attachment">
|
||||
<i class="layui-icon layui-icon-align-left"></i>选择图片
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">家长</label>
|
||||
<div class="layui-input-block">
|
||||
<input type="text" name="parent_id" value="0" class="layui-input">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="bottom">
|
||||
<div class="button-container">
|
||||
<button type="submit" class="pear-btn pear-btn-primary pear-btn-md" lay-submit=""
|
||||
lay-filter="save">
|
||||
提交
|
||||
</button>
|
||||
<button type="reset" class="pear-btn pear-btn-md">
|
||||
重置
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</form>
|
||||
|
||||
<script src="/app/admin/component/layui/layui.js?v=2.8.12"></script>
|
||||
<script src="/app/admin/component/pear/pear.js"></script>
|
||||
<script src="/app/admin/component/jsoneditor/jsoneditor.js"></script>
|
||||
<script src="/app/admin/admin/js/permission.js"></script>
|
||||
|
||||
<script>
|
||||
|
||||
// 相关接口
|
||||
const INSERT_API = "/app/admin/student/insert";
|
||||
|
||||
// 字段 头像 avatar
|
||||
layui.use(["upload", "layer"], function() {
|
||||
let input = layui.$("#avatar").prev();
|
||||
input.prev().attr("src", input.val());
|
||||
layui.$("#attachment-choose-avatar").on("click", function() {
|
||||
parent.layer.open({
|
||||
type: 2,
|
||||
title: "选择附件",
|
||||
content: "/app/admin/upload/attachment?ext=jpg,jpeg,png,gif,bmp",
|
||||
area: ["95%", "90%"],
|
||||
success: function (layero, index) {
|
||||
parent.layui.$("#layui-layer" + index).data("callback", function (data) {
|
||||
input.val(data.url).prev().attr("src", data.url);
|
||||
});
|
||||
}
|
||||
});
|
||||
});
|
||||
layui.upload.render({
|
||||
elem: "#avatar",
|
||||
value: "",
|
||||
acceptMime: "image/gif,image/jpeg,image/jpg,image/png",
|
||||
url: "/app/admin/upload/image",
|
||||
field: "__file__",
|
||||
done: function (res) {
|
||||
if (res.code > 0) return layui.layer.msg(res.msg);
|
||||
this.item.prev().val(res.data.url).prev().attr("src", res.data.url);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
//提交事件
|
||||
layui.use(["form", "popup"], function () {
|
||||
// 字段验证允许为空
|
||||
layui.form.verify({
|
||||
phone: [/(^$)|^1\d{10}$/, "请输入正确的手机号"],
|
||||
email: [/(^$)|^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/, "邮箱格式不正确"],
|
||||
url: [/(^$)|(^#)|(^http(s*):\/\/[^\s]+\.[^\s]+)/, "链接格式不正确"],
|
||||
number: [/(^$)|^\d+$/,'只能填写数字'],
|
||||
date: [/(^$)|^(\d{4})[-\/](\d{1}|0\d{1}|1[0-2])([-\/](\d{1}|0\d{1}|[1-2][0-9]|3[0-1]))*$/, "日期格式不正确"],
|
||||
identity: [/(^$)|(^\d{15}$)|(^\d{17}(x|X|\d)$)/, "请输入正确的身份证号"]
|
||||
});
|
||||
layui.form.on("submit(save)", function (data) {
|
||||
layui.$.ajax({
|
||||
url: INSERT_API,
|
||||
type: "POST",
|
||||
dateType: "json",
|
||||
data: data.field,
|
||||
success: function (res) {
|
||||
if (res.code) {
|
||||
return layui.popup.failure(res.msg);
|
||||
}
|
||||
return layui.popup.success("操作成功", function () {
|
||||
parent.refreshTable();
|
||||
parent.layer.close(parent.layer.getFrameIndex(window.name));
|
||||
});
|
||||
}
|
||||
});
|
||||
return false;
|
||||
});
|
||||
});
|
||||
|
||||
</script>
|
||||
|
||||
</body>
|
||||
</html>
|
201
plugin/admin/app/view/student/update.html
Normal file
201
plugin/admin/app/view/student/update.html
Normal file
@ -0,0 +1,201 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="zh-cn">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>更新页面</title>
|
||||
<link rel="stylesheet" href="/app/admin/component/pear/css/pear.css" />
|
||||
<link rel="stylesheet" href="/app/admin/component/jsoneditor/css/jsoneditor.css" />
|
||||
<link rel="stylesheet" href="/app/admin/admin/css/reset.css" />
|
||||
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<form class="layui-form">
|
||||
|
||||
<div class="mainBox">
|
||||
<div class="main-container mr-5">
|
||||
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label required">学生姓名</label>
|
||||
<div class="layui-input-block">
|
||||
<input type="text" name="student_name" value="" required lay-verify="required" class="layui-input">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label required">账号</label>
|
||||
<div class="layui-input-block">
|
||||
<input type="text" name="account" value="" required lay-verify="required" class="layui-input">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">密码</label>
|
||||
<div class="layui-input-block">
|
||||
<input type="text" name="password" value="" class="layui-input">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- <div class="layui-form-item">-->
|
||||
<!-- <label class="layui-form-label">密码盐</label>-->
|
||||
<!-- <div class="layui-input-block">-->
|
||||
<!-- <input type="text" name="salt" value="" class="layui-input">-->
|
||||
<!-- </div>-->
|
||||
<!-- </div>-->
|
||||
|
||||
<!-- <div class="layui-form-item">-->
|
||||
<!-- <label class="layui-form-label">昵称</label>-->
|
||||
<!-- <div class="layui-input-block">-->
|
||||
<!-- <input type="text" name="nickname" value="" class="layui-input">-->
|
||||
<!-- </div>-->
|
||||
<!-- </div>-->
|
||||
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">头像</label>
|
||||
<div class="layui-input-block">
|
||||
<img class="img-3" src=""/>
|
||||
<input type="text" style="display:none" name="avatar" value="" />
|
||||
<button type="button" class="pear-btn pear-btn-primary pear-btn-sm" id="avatar" permission="app.admin.upload.image">
|
||||
<i class="layui-icon layui-icon-upload"></i>上传图片
|
||||
</button>
|
||||
<button type="button" class="pear-btn pear-btn-primary pear-btn-sm" id="attachment-choose-avatar" permission="app.admin.upload.attachment">
|
||||
<i class="layui-icon layui-icon-align-left"></i>选择图片
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">家长</label>
|
||||
<div class="layui-input-block">
|
||||
<input type="text" name="parent_id" value="" class="layui-input">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="bottom">
|
||||
<div class="button-container">
|
||||
<button type="submit" class="pear-btn pear-btn-primary pear-btn-md" lay-submit="" lay-filter="save">
|
||||
提交
|
||||
</button>
|
||||
<button type="reset" class="pear-btn pear-btn-md">
|
||||
重置
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</form>
|
||||
|
||||
<script src="/app/admin/component/layui/layui.js?v=2.8.12"></script>
|
||||
<script src="/app/admin/component/pear/pear.js"></script>
|
||||
<script src="/app/admin/component/jsoneditor/jsoneditor.js"></script>
|
||||
<script src="/app/admin/admin/js/permission.js"></script>
|
||||
|
||||
<script>
|
||||
|
||||
// 相关接口
|
||||
const PRIMARY_KEY = "id";
|
||||
const SELECT_API = "/app/admin/student/select" + location.search;
|
||||
const UPDATE_API = "/app/admin/student/update";
|
||||
|
||||
// 获取数据库记录
|
||||
layui.use(["form", "util", "popup"], function () {
|
||||
let $ = layui.$;
|
||||
$.ajax({
|
||||
url: SELECT_API,
|
||||
dataType: "json",
|
||||
success: function (res) {
|
||||
|
||||
// 给表单初始化数据
|
||||
layui.each(res.data[0], function (key, value) {
|
||||
let obj = $('*[name="'+key+'"]');
|
||||
if (key === "password") {
|
||||
obj.attr("placeholder", "不更新密码请留空");
|
||||
return;
|
||||
}
|
||||
if (typeof obj[0] === "undefined" || !obj[0].nodeName) return;
|
||||
if (obj[0].nodeName.toLowerCase() === "textarea") {
|
||||
obj.val(value);
|
||||
} else {
|
||||
obj.attr("value", value);
|
||||
obj[0].value = value;
|
||||
}
|
||||
});
|
||||
|
||||
// 字段 头像 avatar
|
||||
layui.use(["upload", "layer"], function() {
|
||||
let input = layui.$("#avatar").prev();
|
||||
input.prev().attr("src", input.val());
|
||||
layui.$("#attachment-choose-avatar").on("click", function() {
|
||||
parent.layer.open({
|
||||
type: 2,
|
||||
title: "选择附件",
|
||||
content: "/app/admin/upload/attachment?ext=jpg,jpeg,png,gif,bmp",
|
||||
area: ["95%", "90%"],
|
||||
success: function (layero, index) {
|
||||
parent.layui.$("#layui-layer" + index).data("callback", function (data) {
|
||||
input.val(data.url).prev().attr("src", data.url);
|
||||
});
|
||||
}
|
||||
});
|
||||
});
|
||||
layui.upload.render({
|
||||
elem: "#avatar",
|
||||
acceptMime: "image/gif,image/jpeg,image/jpg,image/png",
|
||||
url: "/app/admin/upload/image",
|
||||
field: "__file__",
|
||||
done: function (res) {
|
||||
if (res.code > 0) return layui.layer.msg(res.msg);
|
||||
this.item.prev().val(res.data.url).prev().attr("src", res.data.url);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
// ajax返回失败
|
||||
if (res.code) {
|
||||
layui.popup.failure(res.msg);
|
||||
}
|
||||
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
//提交事件
|
||||
layui.use(["form", "popup"], function () {
|
||||
// 字段验证允许为空
|
||||
layui.form.verify({
|
||||
phone: [/(^$)|^1\d{10}$/, "请输入正确的手机号"],
|
||||
email: [/(^$)|^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/, "邮箱格式不正确"],
|
||||
url: [/(^$)|(^#)|(^http(s*):\/\/[^\s]+\.[^\s]+)/, "链接格式不正确"],
|
||||
number: [/(^$)|^\d+$/,'只能填写数字'],
|
||||
date: [/(^$)|^(\d{4})[-\/](\d{1}|0\d{1}|1[0-2])([-\/](\d{1}|0\d{1}|[1-2][0-9]|3[0-1]))*$/, "日期格式不正确"],
|
||||
identity: [/(^$)|(^\d{15}$)|(^\d{17}(x|X|\d)$)/, "请输入正确的身份证号"]
|
||||
});
|
||||
layui.form.on("submit(save)", function (data) {
|
||||
data.field[PRIMARY_KEY] = layui.url().search[PRIMARY_KEY];
|
||||
layui.$.ajax({
|
||||
url: UPDATE_API,
|
||||
type: "POST",
|
||||
dateType: "json",
|
||||
data: data.field,
|
||||
success: function (res) {
|
||||
if (res.code) {
|
||||
return layui.popup.failure(res.msg);
|
||||
}
|
||||
return layui.popup.success("操作成功", function () {
|
||||
parent.refreshTable();
|
||||
parent.layer.close(parent.layer.getFrameIndex(window.name));
|
||||
});
|
||||
}
|
||||
});
|
||||
return false;
|
||||
});
|
||||
});
|
||||
|
||||
</script>
|
||||
|
||||
</body>
|
||||
|
||||
</html>
|
305
plugin/admin/app/view/subject/index.html
Normal file
305
plugin/admin/app/view/subject/index.html
Normal file
@ -0,0 +1,305 @@
|
||||
|
||||
<!DOCTYPE html>
|
||||
<html lang="zh-cn">
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>浏览页面</title>
|
||||
<link rel="stylesheet" href="/app/admin/component/pear/css/pear.css" />
|
||||
<link rel="stylesheet" href="/app/admin/admin/css/reset.css" />
|
||||
</head>
|
||||
<body class="pear-container">
|
||||
|
||||
<!-- 顶部查询表单 -->
|
||||
<div class="layui-card">
|
||||
<div class="layui-card-body">
|
||||
<form class="layui-form top-search-from">
|
||||
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">课程名称</label>
|
||||
<div class="layui-input-block">
|
||||
<div class="layui-input-block">
|
||||
<input type="hidden" autocomplete="off" name="subject_name[]" value="like" class="layui-input inline-block">
|
||||
<input type="text" autocomplete="off" name="subject_name[]" class="layui-input">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">英文名称</label>
|
||||
<div class="layui-input-block">
|
||||
<div class="layui-input-block">
|
||||
<input type="hidden" autocomplete="off" name="english_name[]" value="like" class="layui-input inline-block">
|
||||
<input type="text" autocomplete="off" name="english_name[]" class="layui-input">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="layui-form-item layui-inline">
|
||||
<label class="layui-form-label"></label>
|
||||
<button class="pear-btn pear-btn-md pear-btn-primary" lay-submit lay-filter="table-query">
|
||||
<i class="layui-icon layui-icon-search"></i>查询
|
||||
</button>
|
||||
<button type="reset" class="pear-btn pear-btn-md" lay-submit lay-filter="table-reset">
|
||||
<i class="layui-icon layui-icon-refresh"></i>重置
|
||||
</button>
|
||||
</div>
|
||||
<div class="toggle-btn">
|
||||
<a class="layui-hide">展开<i class="layui-icon layui-icon-down"></i></a>
|
||||
<a class="layui-hide">收起<i class="layui-icon layui-icon-up"></i></a>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 数据表格 -->
|
||||
<div class="layui-card">
|
||||
<div class="layui-card-body">
|
||||
<table id="data-table" lay-filter="data-table"></table>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- 表格顶部工具栏 -->
|
||||
<script type="text/html" id="table-toolbar">
|
||||
<button class="pear-btn pear-btn-primary pear-btn-md" lay-event="add" permission="app.admin.subject.insert">
|
||||
<i class="layui-icon layui-icon-add-1"></i>新增
|
||||
</button>
|
||||
<button class="pear-btn pear-btn-danger pear-btn-md" lay-event="batchRemove" permission="app.admin.subject.delete">
|
||||
<i class="layui-icon layui-icon-delete"></i>删除
|
||||
</button>
|
||||
</script>
|
||||
|
||||
<!-- 表格行工具栏 -->
|
||||
<script type="text/html" id="table-bar">
|
||||
<button class="pear-btn pear-btn-xs tool-btn" lay-event="edit" permission="app.admin.subject.update">编辑</button>
|
||||
<button class="pear-btn pear-btn-xs tool-btn" lay-event="remove" permission="app.admin.subject.delete">删除</button>
|
||||
</script>
|
||||
|
||||
<script src="/app/admin/component/layui/layui.js?v=2.8.12"></script>
|
||||
<script src="/app/admin/component/pear/pear.js"></script>
|
||||
<script src="/app/admin/admin/js/permission.js"></script>
|
||||
<script src="/app/admin/admin/js/common.js"></script>
|
||||
|
||||
<script>
|
||||
|
||||
// 相关常量
|
||||
const PRIMARY_KEY = "id";
|
||||
const SELECT_API = "/app/admin/subject/select";
|
||||
const UPDATE_API = "/app/admin/subject/update";
|
||||
const DELETE_API = "/app/admin/subject/delete";
|
||||
const INSERT_URL = "/app/admin/subject/insert";
|
||||
const UPDATE_URL = "/app/admin/subject/update";
|
||||
|
||||
// 表格渲染
|
||||
layui.use(["table", "form", "common", "popup", "util"], function() {
|
||||
let table = layui.table;
|
||||
let form = layui.form;
|
||||
let $ = layui.$;
|
||||
let common = layui.common;
|
||||
let util = layui.util;
|
||||
|
||||
// 表头参数
|
||||
let cols = [
|
||||
{
|
||||
type: "checkbox",
|
||||
align: "center"
|
||||
},{
|
||||
title: "id",align: "center",
|
||||
field: "id",
|
||||
},{
|
||||
title: "课程名称",align: "center",
|
||||
field: "subject_name",
|
||||
},{
|
||||
title: "英文名称",align: "center",
|
||||
field: "english_name",
|
||||
},{
|
||||
title: "排序",align: "center",
|
||||
field: "sort",
|
||||
sort: true,
|
||||
},{
|
||||
title: "创建时间",align: "center",
|
||||
field: "created_at",
|
||||
},{
|
||||
title: "更新时间",align: "center",
|
||||
field: "updated_at",
|
||||
hide: true,
|
||||
},{
|
||||
title: "deleted_at",align: "center",
|
||||
field: "deleted_at",
|
||||
hide: true,
|
||||
},{
|
||||
title: "操作",
|
||||
toolbar: "#table-bar",
|
||||
align: "center",
|
||||
fixed: "right",
|
||||
width: 120,
|
||||
}
|
||||
];
|
||||
|
||||
// 渲染表格
|
||||
table.render({
|
||||
elem: "#data-table",
|
||||
url: SELECT_API,
|
||||
page: true,
|
||||
cols: [cols],
|
||||
skin: "line",
|
||||
size: "lg",
|
||||
toolbar: "#table-toolbar",
|
||||
autoSort: false,
|
||||
defaultToolbar: [{
|
||||
title: "刷新",
|
||||
layEvent: "refresh",
|
||||
icon: "layui-icon-refresh",
|
||||
}, "filter", "print", "exports"],
|
||||
done: function () {
|
||||
layer.photos({photos: 'div[lay-id="data-table"]', anim: 5});
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
// 编辑或删除行事件
|
||||
table.on("tool(data-table)", function(obj) {
|
||||
if (obj.event === "remove") {
|
||||
remove(obj);
|
||||
} else if (obj.event === "edit") {
|
||||
edit(obj);
|
||||
}
|
||||
});
|
||||
|
||||
// 表格顶部工具栏事件
|
||||
table.on("toolbar(data-table)", function(obj) {
|
||||
if (obj.event === "add") {
|
||||
add();
|
||||
} else if (obj.event === "refresh") {
|
||||
refreshTable();
|
||||
} else if (obj.event === "batchRemove") {
|
||||
batchRemove(obj);
|
||||
}
|
||||
});
|
||||
|
||||
// 表格顶部搜索事件
|
||||
form.on("submit(table-query)", function(data) {
|
||||
table.reload("data-table", {
|
||||
page: {
|
||||
curr: 1
|
||||
},
|
||||
where: data.field
|
||||
})
|
||||
return false;
|
||||
});
|
||||
|
||||
// 表格顶部搜索重置事件
|
||||
form.on("submit(table-reset)", function(data) {
|
||||
table.reload("data-table", {
|
||||
where: []
|
||||
})
|
||||
});
|
||||
|
||||
// 字段允许为空
|
||||
form.verify({
|
||||
phone: [/(^$)|^1\d{10}$/, "请输入正确的手机号"],
|
||||
email: [/(^$)|^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/, "邮箱格式不正确"],
|
||||
url: [/(^$)|(^#)|(^http(s*):\/\/[^\s]+\.[^\s]+)/, "链接格式不正确"],
|
||||
number: [/(^$)|^\d+$/,'只能填写数字'],
|
||||
date: [/(^$)|^(\d{4})[-\/](\d{1}|0\d{1}|1[0-2])([-\/](\d{1}|0\d{1}|[1-2][0-9]|3[0-1]))*$/, "日期格式不正确"],
|
||||
identity: [/(^$)|(^\d{15}$)|(^\d{17}(x|X|\d)$)/, "请输入正确的身份证号"]
|
||||
});
|
||||
|
||||
// 表格排序事件
|
||||
table.on("sort(data-table)", function(obj){
|
||||
table.reload("data-table", {
|
||||
initSort: obj,
|
||||
scrollPos: "fixed",
|
||||
where: {
|
||||
field: obj.field,
|
||||
order: obj.type
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
// 表格新增数据
|
||||
let add = function() {
|
||||
layer.open({
|
||||
type: 2,
|
||||
title: "新增",
|
||||
shade: 0.1,
|
||||
maxmin: true,
|
||||
area: [common.isModile()?"100%":"500px", common.isModile()?"100%":"450px"],
|
||||
content: INSERT_URL
|
||||
});
|
||||
}
|
||||
|
||||
// 表格编辑数据
|
||||
let edit = function(obj) {
|
||||
let value = obj.data[PRIMARY_KEY];
|
||||
layer.open({
|
||||
type: 2,
|
||||
title: "修改",
|
||||
shade: 0.1,
|
||||
maxmin: true,
|
||||
area: [common.isModile()?"100%":"500px", common.isModile()?"100%":"450px"],
|
||||
content: UPDATE_URL + "?" + PRIMARY_KEY + "=" + value
|
||||
});
|
||||
}
|
||||
|
||||
// 删除一行
|
||||
let remove = function(obj) {
|
||||
return doRemove(obj.data[PRIMARY_KEY]);
|
||||
}
|
||||
|
||||
// 删除多行
|
||||
let batchRemove = function(obj) {
|
||||
let checkIds = common.checkField(obj, PRIMARY_KEY);
|
||||
if (checkIds === "") {
|
||||
layui.popup.warning("未选中数据");
|
||||
return false;
|
||||
}
|
||||
doRemove(checkIds.split(","));
|
||||
}
|
||||
|
||||
// 执行删除
|
||||
let doRemove = function (ids) {
|
||||
let data = {};
|
||||
data[PRIMARY_KEY] = ids;
|
||||
layer.confirm("确定删除?", {
|
||||
icon: 3,
|
||||
title: "提示"
|
||||
}, function(index) {
|
||||
layer.close(index);
|
||||
let loading = layer.load();
|
||||
$.ajax({
|
||||
url: DELETE_API,
|
||||
data: data,
|
||||
dataType: "json",
|
||||
type: "post",
|
||||
success: function(res) {
|
||||
layer.close(loading);
|
||||
if (res.code) {
|
||||
return layui.popup.failure(res.msg);
|
||||
}
|
||||
return layui.popup.success("操作成功", refreshTable);
|
||||
}
|
||||
})
|
||||
});
|
||||
}
|
||||
|
||||
// 刷新表格数据
|
||||
window.refreshTable = function() {
|
||||
table.reloadData("data-table", {
|
||||
scrollPos: "fixed",
|
||||
done: function (res, curr) {
|
||||
if (curr > 1 && res.data && !res.data.length) {
|
||||
curr = curr - 1;
|
||||
table.reloadData("data-table", {
|
||||
page: {
|
||||
curr: curr
|
||||
},
|
||||
})
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
})
|
||||
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
99
plugin/admin/app/view/subject/insert.html
Normal file
99
plugin/admin/app/view/subject/insert.html
Normal file
@ -0,0 +1,99 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="zh-cn">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>新增页面</title>
|
||||
<link rel="stylesheet" href="/app/admin/component/pear/css/pear.css" />
|
||||
<link rel="stylesheet" href="/app/admin/component/jsoneditor/css/jsoneditor.css" />
|
||||
<link rel="stylesheet" href="/app/admin/admin/css/reset.css" />
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<form class="layui-form" action="">
|
||||
|
||||
<div class="mainBox">
|
||||
<div class="main-container mr-5">
|
||||
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label required">课程名称</label>
|
||||
<div class="layui-input-block">
|
||||
<input type="text" name="subject_name" value="" required lay-verify="required" class="layui-input">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label required">英文名称</label>
|
||||
<div class="layui-input-block">
|
||||
<input type="text" name="english_name" value="" required lay-verify="required" class="layui-input">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label required">排序</label>
|
||||
<div class="layui-input-block">
|
||||
<input type="number" name="sort" value="0" required lay-verify="required|number" class="layui-input">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="bottom">
|
||||
<div class="button-container">
|
||||
<button type="submit" class="pear-btn pear-btn-primary pear-btn-md" lay-submit=""
|
||||
lay-filter="save">
|
||||
提交
|
||||
</button>
|
||||
<button type="reset" class="pear-btn pear-btn-md">
|
||||
重置
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</form>
|
||||
|
||||
<script src="/app/admin/component/layui/layui.js?v=2.8.12"></script>
|
||||
<script src="/app/admin/component/pear/pear.js"></script>
|
||||
<script src="/app/admin/component/jsoneditor/jsoneditor.js"></script>
|
||||
<script src="/app/admin/admin/js/permission.js"></script>
|
||||
|
||||
<script>
|
||||
|
||||
// 相关接口
|
||||
const INSERT_API = "/app/admin/subject/insert";
|
||||
|
||||
//提交事件
|
||||
layui.use(["form", "popup"], function () {
|
||||
// 字段验证允许为空
|
||||
layui.form.verify({
|
||||
phone: [/(^$)|^1\d{10}$/, "请输入正确的手机号"],
|
||||
email: [/(^$)|^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/, "邮箱格式不正确"],
|
||||
url: [/(^$)|(^#)|(^http(s*):\/\/[^\s]+\.[^\s]+)/, "链接格式不正确"],
|
||||
number: [/(^$)|^\d+$/,'只能填写数字'],
|
||||
date: [/(^$)|^(\d{4})[-\/](\d{1}|0\d{1}|1[0-2])([-\/](\d{1}|0\d{1}|[1-2][0-9]|3[0-1]))*$/, "日期格式不正确"],
|
||||
identity: [/(^$)|(^\d{15}$)|(^\d{17}(x|X|\d)$)/, "请输入正确的身份证号"]
|
||||
});
|
||||
layui.form.on("submit(save)", function (data) {
|
||||
layui.$.ajax({
|
||||
url: INSERT_API,
|
||||
type: "POST",
|
||||
dateType: "json",
|
||||
data: data.field,
|
||||
success: function (res) {
|
||||
if (res.code) {
|
||||
return layui.popup.failure(res.msg);
|
||||
}
|
||||
return layui.popup.success("操作成功", function () {
|
||||
parent.refreshTable();
|
||||
parent.layer.close(parent.layer.getFrameIndex(window.name));
|
||||
});
|
||||
}
|
||||
});
|
||||
return false;
|
||||
});
|
||||
});
|
||||
|
||||
</script>
|
||||
|
||||
</body>
|
||||
</html>
|
137
plugin/admin/app/view/subject/update.html
Normal file
137
plugin/admin/app/view/subject/update.html
Normal file
@ -0,0 +1,137 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="zh-cn">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>更新页面</title>
|
||||
<link rel="stylesheet" href="/app/admin/component/pear/css/pear.css" />
|
||||
<link rel="stylesheet" href="/app/admin/component/jsoneditor/css/jsoneditor.css" />
|
||||
<link rel="stylesheet" href="/app/admin/admin/css/reset.css" />
|
||||
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<form class="layui-form">
|
||||
|
||||
<div class="mainBox">
|
||||
<div class="main-container mr-5">
|
||||
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label required">课程名称</label>
|
||||
<div class="layui-input-block">
|
||||
<input type="text" name="subject_name" value="" required lay-verify="required" class="layui-input">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label required">英文名称</label>
|
||||
<div class="layui-input-block">
|
||||
<input type="text" name="english_name" value="" required lay-verify="required" class="layui-input">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label required">排序</label>
|
||||
<div class="layui-input-block">
|
||||
<input type="number" name="sort" value="" required lay-verify="required|number" class="layui-input">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="bottom">
|
||||
<div class="button-container">
|
||||
<button type="submit" class="pear-btn pear-btn-primary pear-btn-md" lay-submit="" lay-filter="save">
|
||||
提交
|
||||
</button>
|
||||
<button type="reset" class="pear-btn pear-btn-md">
|
||||
重置
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</form>
|
||||
|
||||
<script src="/app/admin/component/layui/layui.js?v=2.8.12"></script>
|
||||
<script src="/app/admin/component/pear/pear.js"></script>
|
||||
<script src="/app/admin/component/jsoneditor/jsoneditor.js"></script>
|
||||
<script src="/app/admin/admin/js/permission.js"></script>
|
||||
|
||||
<script>
|
||||
|
||||
// 相关接口
|
||||
const PRIMARY_KEY = "id";
|
||||
const SELECT_API = "/app/admin/subject/select" + location.search;
|
||||
const UPDATE_API = "/app/admin/subject/update";
|
||||
|
||||
// 获取数据库记录
|
||||
layui.use(["form", "util", "popup"], function () {
|
||||
let $ = layui.$;
|
||||
$.ajax({
|
||||
url: SELECT_API,
|
||||
dataType: "json",
|
||||
success: function (res) {
|
||||
|
||||
// 给表单初始化数据
|
||||
layui.each(res.data[0], function (key, value) {
|
||||
let obj = $('*[name="'+key+'"]');
|
||||
if (key === "password") {
|
||||
obj.attr("placeholder", "不更新密码请留空");
|
||||
return;
|
||||
}
|
||||
if (typeof obj[0] === "undefined" || !obj[0].nodeName) return;
|
||||
if (obj[0].nodeName.toLowerCase() === "textarea") {
|
||||
obj.val(value);
|
||||
} else {
|
||||
obj.attr("value", value);
|
||||
obj[0].value = value;
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
// ajax返回失败
|
||||
if (res.code) {
|
||||
layui.popup.failure(res.msg);
|
||||
}
|
||||
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
//提交事件
|
||||
layui.use(["form", "popup"], function () {
|
||||
// 字段验证允许为空
|
||||
layui.form.verify({
|
||||
phone: [/(^$)|^1\d{10}$/, "请输入正确的手机号"],
|
||||
email: [/(^$)|^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/, "邮箱格式不正确"],
|
||||
url: [/(^$)|(^#)|(^http(s*):\/\/[^\s]+\.[^\s]+)/, "链接格式不正确"],
|
||||
number: [/(^$)|^\d+$/,'只能填写数字'],
|
||||
date: [/(^$)|^(\d{4})[-\/](\d{1}|0\d{1}|1[0-2])([-\/](\d{1}|0\d{1}|[1-2][0-9]|3[0-1]))*$/, "日期格式不正确"],
|
||||
identity: [/(^$)|(^\d{15}$)|(^\d{17}(x|X|\d)$)/, "请输入正确的身份证号"]
|
||||
});
|
||||
layui.form.on("submit(save)", function (data) {
|
||||
data.field[PRIMARY_KEY] = layui.url().search[PRIMARY_KEY];
|
||||
layui.$.ajax({
|
||||
url: UPDATE_API,
|
||||
type: "POST",
|
||||
dateType: "json",
|
||||
data: data.field,
|
||||
success: function (res) {
|
||||
if (res.code) {
|
||||
return layui.popup.failure(res.msg);
|
||||
}
|
||||
return layui.popup.success("操作成功", function () {
|
||||
parent.refreshTable();
|
||||
parent.layer.close(parent.layer.getFrameIndex(window.name));
|
||||
});
|
||||
}
|
||||
});
|
||||
return false;
|
||||
});
|
||||
});
|
||||
|
||||
</script>
|
||||
|
||||
</body>
|
||||
|
||||
</html>
|
@ -8,12 +8,12 @@
|
||||
<link rel="stylesheet" href="/app/admin/admin/css/reset.css" />
|
||||
</head>
|
||||
<body class="pear-container">
|
||||
|
||||
|
||||
<!-- 顶部查询表单 -->
|
||||
<div class="layui-card">
|
||||
<div class="layui-card-body">
|
||||
<form class="layui-form top-search-from">
|
||||
|
||||
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">账号</label>
|
||||
<div class="layui-input-block">
|
||||
@ -23,7 +23,7 @@
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">教师姓名</label>
|
||||
<div class="layui-input-block">
|
||||
@ -33,7 +33,7 @@
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<div class="layui-form-item">
|
||||
<label class="layui-form-label">时区名称</label>
|
||||
<div class="layui-input-block">
|
||||
@ -43,7 +43,7 @@
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<div class="layui-form-item layui-inline">
|
||||
<label class="layui-form-label"></label>
|
||||
<button class="pear-btn pear-btn-md pear-btn-primary" lay-submit lay-filter="table-query">
|
||||
@ -60,7 +60,7 @@
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<!-- 数据表格 -->
|
||||
<div class="layui-card">
|
||||
<div class="layui-card-body">
|
||||
@ -89,7 +89,7 @@
|
||||
<script src="/app/admin/component/pear/pear.js"></script>
|
||||
<script src="/app/admin/admin/js/permission.js"></script>
|
||||
<script src="/app/admin/admin/js/common.js"></script>
|
||||
|
||||
|
||||
<script>
|
||||
|
||||
// 相关常量
|
||||
@ -99,7 +99,7 @@
|
||||
const DELETE_API = "/app/admin/teacher/delete";
|
||||
const INSERT_URL = "/app/admin/teacher/insert";
|
||||
const UPDATE_URL = "/app/admin/teacher/update";
|
||||
|
||||
|
||||
// 表格渲染
|
||||
layui.use(["table", "form", "common", "popup", "util"], function() {
|
||||
let table = layui.table;
|
||||
@ -107,7 +107,7 @@
|
||||
let $ = layui.$;
|
||||
let common = layui.common;
|
||||
let util = layui.util;
|
||||
|
||||
|
||||
// 表头参数
|
||||
let cols = [
|
||||
{
|
||||
@ -162,7 +162,7 @@
|
||||
width: 180,
|
||||
}
|
||||
];
|
||||
|
||||
|
||||
// 渲染表格
|
||||
table.render({
|
||||
elem: "#data-table",
|
||||
@ -182,8 +182,8 @@
|
||||
layer.photos({photos: 'div[lay-id="data-table"]', anim: 5});
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
|
||||
|
||||
// 编辑或删除行事件
|
||||
table.on("tool(data-table)", function(obj) {
|
||||
if (obj.event === "remove") {
|
||||
@ -216,14 +216,14 @@
|
||||
})
|
||||
return false;
|
||||
});
|
||||
|
||||
|
||||
// 表格顶部搜索重置事件
|
||||
form.on("submit(table-reset)", function(data) {
|
||||
table.reload("data-table", {
|
||||
where: []
|
||||
})
|
||||
});
|
||||
|
||||
|
||||
// 字段允许为空
|
||||
form.verify({
|
||||
phone: [/(^$)|^1\d{10}$/, "请输入正确的手机号"],
|
||||
|
Loading…
x
Reference in New Issue
Block a user