初始版本
This commit is contained in:
235
server/app/api/controller/OrderController.php
Executable file
235
server/app/api/controller/OrderController.php
Executable file
@@ -0,0 +1,235 @@
|
||||
<?php
|
||||
// +----------------------------------------------------------------------
|
||||
// | likeshop开源商城系统
|
||||
// +----------------------------------------------------------------------
|
||||
// | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
|
||||
// | gitee下载:https://gitee.com/likeshop_gitee
|
||||
// | github下载:https://github.com/likeshop-github
|
||||
// | 访问官网:https://www.likeshop.cn
|
||||
// | 访问社区:https://home.likeshop.cn
|
||||
// | 访问手册:http://doc.likeshop.cn
|
||||
// | 微信公众号:likeshop技术社区
|
||||
// | likeshop系列产品在gitee、github等公开渠道开源版本可免费商用,未经许可不能去除前后端官方版权标识
|
||||
// | likeshop系列产品收费版本务必购买商业授权,购买去版权授权后,方可去除前后端官方版权标识
|
||||
// | 禁止对系统程序代码以任何目的,任何形式的再发布
|
||||
// | likeshop团队版权所有并拥有最终解释权
|
||||
// +----------------------------------------------------------------------
|
||||
// | author: likeshop.cn.team
|
||||
// +----------------------------------------------------------------------
|
||||
|
||||
namespace app\api\controller;
|
||||
|
||||
|
||||
use app\api\lists\OrderLists;
|
||||
use app\api\logic\OrderLogic;
|
||||
use app\api\validate\OrderAppendValidate;
|
||||
use app\api\validate\OrderCommentValidate;
|
||||
use app\api\validate\OrderGapValidate;
|
||||
use app\api\validate\OrderValidate;
|
||||
use app\api\validate\PlaceOrderValidate;
|
||||
use app\common\service\ConfigService;
|
||||
use app\common\service\storage\Driver as StorageDriver;
|
||||
use Exception;
|
||||
|
||||
/**
|
||||
* 订单控制器类
|
||||
* Class OrderController
|
||||
* @package app\api\controller
|
||||
*/
|
||||
class OrderController extends BaseApiController
|
||||
{
|
||||
public array $notNeedLogin = ['test'];
|
||||
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @notes 提交订单
|
||||
* @return \think\response\Json
|
||||
* @author ljj
|
||||
* @date 2022/2/25 10:12 上午
|
||||
*/
|
||||
public function placeOrder()
|
||||
{
|
||||
$data = [
|
||||
'terminal' => $this->userInfo['terminal'],
|
||||
'user_id'=> $this->userId
|
||||
];
|
||||
$params = (new PlaceOrderValidate())->post()->goCheck('', $data);
|
||||
//订单结算信息
|
||||
$settlement = (new OrderLogic())->settlement($params);
|
||||
if (false === $settlement) {
|
||||
return $this->fail(OrderLogic::getError());
|
||||
}
|
||||
//结算信息
|
||||
if ($params['action'] == 'settlement') {
|
||||
unset($settlement['city']);
|
||||
return $this->data($settlement);
|
||||
}
|
||||
//提交订单
|
||||
$result = (new OrderLogic())->submitOrder($settlement);
|
||||
if (false === $result) {
|
||||
return $this->fail(OrderLogic::getError());
|
||||
}
|
||||
return $this->data($result);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 获取技师服务时间
|
||||
* @return \think\response\Json
|
||||
* @author cjhao
|
||||
* @date 2024/9/14 14:03
|
||||
*/
|
||||
public function getCoachServerTime()
|
||||
{
|
||||
$coachId = $this->request->get('coach_id');
|
||||
$goodsId = $this->request->get('goods_id');
|
||||
$result = (new OrderLogic())->getCoachServerTime($coachId,$goodsId);
|
||||
if (false === $result) {
|
||||
return $this->fail(OrderLogic::getError());
|
||||
}
|
||||
return $this->data($result);
|
||||
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* @notes 订单列表
|
||||
* @return \think\response\Json
|
||||
* @author ljj
|
||||
* @date 2022/2/28 10:01 上午
|
||||
*/
|
||||
public function lists()
|
||||
{
|
||||
return $this->dataLists(new OrderLists());
|
||||
}
|
||||
|
||||
/**
|
||||
* @notes 订单详情
|
||||
* @return \think\response\Json
|
||||
* @author ljj
|
||||
* @date 2022/2/28 11:23 上午
|
||||
*/
|
||||
public function detail()
|
||||
{
|
||||
$params = (new OrderValidate())->get()->goCheck('detail');
|
||||
$result = (new OrderLogic())->detail($params['id']);
|
||||
return $this->success('',$result);
|
||||
}
|
||||
|
||||
/**
|
||||
* @notes 取消订单
|
||||
* @return \think\response\Json
|
||||
* @author ljj
|
||||
* @date 2022/2/28 11:36 上午
|
||||
*/
|
||||
public function cancel()
|
||||
{
|
||||
$params = (new OrderValidate())->post()->goCheck('cancel');
|
||||
$params['user_id'] = $this->userId;
|
||||
$result = (new OrderLogic())->cancel($params);
|
||||
if (true !== $result) {
|
||||
return $this->fail($result);
|
||||
}
|
||||
return $this->success('操作成功',[],1,1);
|
||||
}
|
||||
|
||||
/**
|
||||
* @notes 删除订单
|
||||
* @return \think\response\Json
|
||||
* @author ljj
|
||||
* @date 2022/2/28 11:50 上午
|
||||
*/
|
||||
public function del()
|
||||
{
|
||||
$params = (new OrderValidate())->post()->goCheck('del');
|
||||
(new OrderLogic())->del($params['id']);
|
||||
return $this->success('操作成功',[],1,1);
|
||||
}
|
||||
|
||||
/**
|
||||
* @notes 支付方式
|
||||
* @return \think\response\Json
|
||||
* @author ljj
|
||||
* @date 2024/7/24 下午7:08
|
||||
*/
|
||||
public function payWay()
|
||||
{
|
||||
$params = (new OrderValidate())->get()->goCheck('payWay',['user_id'=>$this->userId]);
|
||||
$result = OrderLogic::payWay($params);
|
||||
if(false === $result){
|
||||
return $this->fail(OrderLogic::getError());
|
||||
}
|
||||
return $this->data($result);
|
||||
}
|
||||
|
||||
/**
|
||||
* @notes 订单补差价
|
||||
* @return \think\response\Json
|
||||
* @author cjhao
|
||||
* @date 2024/9/18 12:34
|
||||
*/
|
||||
public function orderGap()
|
||||
{
|
||||
$params = (new OrderGapValidate())->post()->goCheck('',['user_id'=>$this->userId]);
|
||||
$result = (new OrderLogic())->orderGap($params);
|
||||
if (false === $result) {
|
||||
return $this->fail(OrderLogic::getError());
|
||||
}
|
||||
return $this->data($result);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @notes 订单加钟
|
||||
* @return \think\response\Json
|
||||
* @author cjhao
|
||||
* @date 2024/9/18 13:45
|
||||
*/
|
||||
public function orderAppend()
|
||||
{
|
||||
$params = (new OrderAppendValidate())->post()->goCheck('',['user_id'=>$this->userId]);
|
||||
$result = (new OrderLogic())->orderAppend($params);
|
||||
if (false === $result) {
|
||||
return $this->fail(OrderLogic::getError());
|
||||
}
|
||||
return $this->data($result);
|
||||
}
|
||||
|
||||
/**
|
||||
* @notes 订单评论
|
||||
* @return \think\response\Json
|
||||
* @author cjhao
|
||||
* @date 2024/9/24 20:43
|
||||
*/
|
||||
public function comment()
|
||||
{
|
||||
$params = (new OrderCommentValidate())->post()->goCheck('',['user_id'=>$this->userId]);
|
||||
$result = (new OrderLogic())->comment($params);
|
||||
if (false === $result) {
|
||||
return $this->fail(OrderLogic::getError());
|
||||
}
|
||||
return $this->success('评论成功',[],1,1,);
|
||||
|
||||
}
|
||||
|
||||
public function test(){
|
||||
// 存储引擎
|
||||
$config = [
|
||||
'default' => ConfigService::get('storage', 'default', 'local'),
|
||||
'engine' => ConfigService::get('storage')
|
||||
];
|
||||
|
||||
// 第三方存储
|
||||
$avatar = 'uploads/user/avatar/' . md5(22 . time()) . '.jpeg';
|
||||
$headimgurl = 'https://thirdwx.qlogo.cn/mmopen/vi_32/PiajxSqBRaEK0ymicw4pcTUx7ZZaQrsnK46O8atVibKY4WbcBpaic9rUapwlul4fJXx87EgkYQwypzYNnAib3evXM9hU8a54IMtE02OXNeAxxDCXmmGKUmwbCbw/132';
|
||||
$StorageDriver = new StorageDriver($config);
|
||||
dd($StorageDriver->fetch($headimgurl, $avatar));
|
||||
if (!$StorageDriver->fetch($headimgurl, $avatar)) {
|
||||
throw new Exception('头像保存失败:' . $StorageDriver->getError());
|
||||
}
|
||||
dd(123);
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user