480 lines
18 KiB
PHP
480 lines
18 KiB
PHP
<?php
|
||
|
||
namespace app\modules\api\controllers;
|
||
|
||
use app\components\SysConst;
|
||
use app\models\DeviceUniqueConfig;
|
||
use app\models\DeviceUniqueData;
|
||
use function AlibabaCloud\Client\value;
|
||
use app\models\Banner;
|
||
use app\models\Store;
|
||
use app\modules\api\components\ApiHelper;
|
||
use app\modules\api\models\OrderForm;
|
||
use app\modules\api\models\StoreForm;
|
||
use app\modules\api\models\StoreCityForm;
|
||
use app\modules\api\models\UserBasicInfoForm;
|
||
use Yii;
|
||
use yii\web\NotFoundHttpException;
|
||
use yii\filters\VerbFilter;
|
||
use app\modules\api\behaviors\LoginBehavior;
|
||
|
||
/**
|
||
*订单
|
||
*/
|
||
class OrderController extends Controller
|
||
{
|
||
/**
|
||
* {@inheritdoc}
|
||
*/
|
||
public function behaviors()
|
||
{
|
||
return array_merge(parent::behaviors(), [
|
||
'verbs' => [
|
||
'class' => VerbFilter::className(),
|
||
'actions' => [
|
||
'delete' => ['POST'],
|
||
],
|
||
],
|
||
'login' => [
|
||
'class' => LoginBehavior::className(),
|
||
'ignore' => [
|
||
// 'api/order/index',
|
||
]
|
||
]
|
||
]);
|
||
}
|
||
|
||
|
||
/**
|
||
* showdoc
|
||
* @catalog 创建球车订单
|
||
* @title 创建球车订单
|
||
* @description 本接口提供创建球车订单
|
||
* @method post
|
||
* @url /api/order/order-buy
|
||
* @param plugin_sign 必选 string 表示 ball_cart
|
||
* @param price 必选 string 订单金额
|
||
* @param store_id 必选 string 门店ID
|
||
* @param ball_number 必选 string 球车编号
|
||
* @return {"code":0,"msg":"ok","data":{"id":"1"}}
|
||
* @remark
|
||
*/
|
||
public function actionOrderBuy()
|
||
{
|
||
$orderForm = new OrderForm();
|
||
$post = \Yii::$app->request->post();
|
||
$orderForm->setScenario($post['plugin_sign']);
|
||
$orderForm->attributes = $post;
|
||
$orderForm->cx_mch_id = $this->cx_mch_id;
|
||
$orderForm->user_id = \Yii::$app->user->identity->id;
|
||
$orderForm->user_type = \Yii::$app->user->identity->type;
|
||
$data = $orderForm->createOrder();
|
||
return $this->responseHandler($data);
|
||
}
|
||
|
||
|
||
/**
|
||
* showdoc
|
||
* @catalog 球车订单列表
|
||
* @title 球车订单列表
|
||
* @description 本接口提供球车订单列表
|
||
* @method get
|
||
* @url /api/order/index
|
||
* @param page 不必选 int 页码
|
||
* @param limit 不必选 int 条数
|
||
* @param order_status 不必选 string 订单状态
|
||
* @param order_type 不必选 string 1-普通用户2-门店
|
||
* @return {"code":0,"msg":"ok","data":[{"order_id":"1","total_price":"100.00","is_pay":"1","store_id":"12","plugin_sign":"ball_cart","created_at":"2022-11-04 11:13:16","updated_at":"2022-11-04 11:13:16","pay_time":"0","cancel_status":"0","status":"0","store_name":"富赛体育高尔夫厦门思明店","begin_time":"2022-11-04 11:13:16","end_time":"2022-11-04 11:13:16","order_status":0}],"count":"1","page_size":10,"page_count":1,"page_no":1,"end_flag":true}
|
||
* @return_param order_id int 订单ID
|
||
* @return_param total_price string 订单金额
|
||
* @return_param is_pay int 是否支付 0=未支付,1=已支付
|
||
* @return_param store_id int 门店ID
|
||
* @return_param plugin_sign string 标识
|
||
* @return_param order_id int 订单ID
|
||
* @return_param created_at string 下单时间
|
||
* @return_param store_name string 门店名称
|
||
* @return_param begin_time string 订单开始时间(只有在订单完成情况下在会有这个字段)
|
||
* @return_param end_time string 订单结束时间(只有在订单完成情况下在会有这个字段)
|
||
* @return_param order_status string 订单状态 0-已完成 1-租赁中 2-未支付 3-已取消
|
||
* @return_param deposit_title string 押金订单左下角备注(只有plugin_sign=deposit时才是押金订单)
|
||
* @remark
|
||
*/
|
||
public function actionIndex()
|
||
{
|
||
//order_type 1- 普通用户 2-门店 3-BOSS
|
||
|
||
$request = Yii::$app->request;
|
||
$get = $request->get();
|
||
$order_type = $request->get('order_type');
|
||
$orderForm = new OrderForm();
|
||
$orderForm->cx_mch_id = $this->cx_mch_id;
|
||
$user_id = \Yii::$app->user->identity->id;
|
||
$user_type = \Yii::$app->user->identity->type;
|
||
|
||
//BOSS账号 查看全部订单
|
||
|
||
//普通用户
|
||
if ($order_type == 1) {
|
||
$orderForm->user_id = $user_id;
|
||
}
|
||
//门店
|
||
if (empty($order_type)) {
|
||
//门店人员
|
||
if ($user_type == 2) {
|
||
$storeData = ApiHelper::findOneUserStoreId($user_id);
|
||
$orderForm->store_id = $storeData['store_id'];
|
||
}
|
||
}
|
||
|
||
$orderForm->status = $get['order_status'];
|
||
$orderForm->page = $get['page'];
|
||
$orderForm->limit = $get['limit'];
|
||
$data = $orderForm->search();
|
||
return $this->responseHandler($data);
|
||
}
|
||
|
||
|
||
/**
|
||
* showdoc
|
||
* @catalog 球车订单详情
|
||
* @title 球车订单详情
|
||
* @description 本接口提供球车订单详情
|
||
* @method get
|
||
* @url /api/order/order-one
|
||
* @param order_id 必选 int 订单ID
|
||
* @return {"code":0,"msg":"ok","data":{"id":"1","order_no":"202211041113166039059736","total_price":"100.00","pay_type":"5","created_at":"2022-11-04 11:13:16","status":"0","cancel_status":"0","store_name":"富赛体育高尔夫厦门思明店","is_pay":"1","pay_time":0,"plugin_sign":"ball_cart","store_id":"12","location_detail":"思明南路422号","updated_at":"1667531596","ball_name":"10086","ball_cover_pic":"http://cxaibc.com/upload/0/1/upload/image/2022/1031/1667205605259683.jpg","mark_name":"1111","begin_time":"1970-01-01 08:33:42","end_time":"2022-11-04 11:13:16","order_status":0}}
|
||
* @return_param order_no int 订单编号
|
||
* @return_param total_price string 订单金额
|
||
* @return_param pay_type int 支付方式 1-微信 5-银联
|
||
* @return_param store_id int 门店ID
|
||
* @return_param plugin_sign string 标识
|
||
* @return_param is_pay int 是否支付
|
||
* @return_param pay_time string 支付时间
|
||
* @return_param created_at string 下单时间
|
||
* @return_param location_detail string 门店位置
|
||
* @return_param ball_name string 球车名称
|
||
* @return_param ball_cover_pic string 球车图片
|
||
* @return_param mark_name string 型号名称
|
||
* @return_param store_name string 门店名称
|
||
* @return_param begin_time string 订单开始时间(只有在订单完成情况下在会有这个字段)
|
||
* @return_param end_time string 订单结束时间(只有在订单完成情况下在会有这个字段)
|
||
* @return_param order_status string 订单状态 0-已完成 1-租赁中 2-未支付 3-已取消
|
||
* @remark
|
||
*/
|
||
public function actionOrderOne()
|
||
{
|
||
$orderForm = new OrderForm();
|
||
$request = Yii::$app->request;
|
||
$orderForm->order_id = $request->get('order_id');
|
||
$data = $orderForm->searchOne();
|
||
return $this->responseHandler($data);
|
||
}
|
||
|
||
|
||
/**
|
||
* 更新订单状态
|
||
* @return array
|
||
*/
|
||
public function actionOrderStatus()
|
||
{
|
||
$orderForm = new OrderForm();
|
||
$orderForm->cx_mch_id = $this->cx_mch_id;
|
||
$orderForm->user_id = \Yii::$app->user->identity->id;
|
||
$data = $orderForm->orderSave();
|
||
return $this->responseHandler($data);
|
||
}
|
||
|
||
|
||
/**
|
||
* showdoc
|
||
* @catalog 取消订单
|
||
* @title 取消订单
|
||
* @description 本接口提供取消订单
|
||
* @method get
|
||
* @url /api/order/order-cancel
|
||
* @param order_id 必选 int 订单ID
|
||
* @return {"code":0,"msg":"取消成功","data":[]}
|
||
* @remark
|
||
*/
|
||
public function actionOrderCancel()
|
||
{
|
||
$orderForm = new OrderForm();
|
||
$orderForm->cx_mch_id = $this->cx_mch_id;
|
||
$orderForm->user_id = \Yii::$app->user->identity->id;
|
||
$orderForm->order_id = \Yii::$app->request->post('order_id');
|
||
$data = $orderForm->orderCancal();
|
||
return $this->responseHandler($data);
|
||
}
|
||
|
||
|
||
/**
|
||
* showdoc
|
||
* @catalog 用户申请还车
|
||
* @title 用户申请还车
|
||
* @description 本接口提供用户申请还车
|
||
* @method post
|
||
* @url /api/order/return-cart
|
||
* @param order_id 必选 int 订单ID
|
||
* @param plugin_sign 必选 int 标识 return_cart
|
||
* @return {"code":0,"msg":"申请还车成功","data":{}}
|
||
* @remark
|
||
*/
|
||
public function actionReturnCart()
|
||
{
|
||
$orderForm = new OrderForm();
|
||
$post = \Yii::$app->request->post();
|
||
$orderForm->setScenario($post['plugin_sign']);
|
||
$orderForm->cx_mch_id = $this->cx_mch_id;
|
||
$orderForm->user_id = \Yii::$app->user->identity->id;
|
||
$orderForm->attributes = $post;
|
||
$data = $orderForm->orderReturnCart();
|
||
return $this->responseHandler($data);
|
||
}
|
||
|
||
|
||
/**
|
||
* showdoc
|
||
* @catalog 门店人员确认还车
|
||
* @title 门店人员确认还车
|
||
* @description 本接口提供门店人员确认还车
|
||
* @method post
|
||
* @url /api/order/confirm-cart
|
||
* @param order_id 必选 int 订单ID
|
||
* @param plugin_sign 必选 int 标识 return_cart
|
||
* @return {"code":0,"msg":"申请还车成功","data":{}}
|
||
* @remark
|
||
*/
|
||
public function actionConfirmCart()
|
||
{
|
||
$orderForm = new OrderForm();
|
||
$post = \Yii::$app->request->post();
|
||
$orderForm->setScenario($post['plugin_sign']);
|
||
$orderForm->cx_mch_id = $this->cx_mch_id;
|
||
$orderForm->user_id = \Yii::$app->user->identity->id;
|
||
$orderForm->user_type = \Yii::$app->user->identity->type;
|
||
$orderForm->attributes = $post;
|
||
$data = $orderForm->orderConfirmCart();
|
||
return $this->responseHandler($data);
|
||
}
|
||
|
||
|
||
/**
|
||
* showdoc
|
||
* @catalog 用户申请售后
|
||
* @title 用户申请售后
|
||
* @description 本接口提供用户申请售后
|
||
* @method post
|
||
* @url /api/order/order-sales
|
||
* @param order_id 必选 int 订单ID
|
||
* @param plugin_sign 必选 int 标识 order_sale
|
||
* @param refund_price 必选 string 退款金额
|
||
* @param type 必选 int 退款类型
|
||
* @param remark 不必选 string 说明
|
||
* @param pic_urls 不必选 string 图片
|
||
* @return {"code":0,"msg":"申请还车成功","data":{}}
|
||
* @remark
|
||
*/
|
||
public function actionOrderSales()
|
||
{
|
||
$orderForm = new OrderForm();
|
||
$post = \Yii::$app->request->post();
|
||
$orderForm->setScenario($post['plugin_sign']);
|
||
$orderForm->cx_mch_id = $this->cx_mch_id;
|
||
$orderForm->user_id = \Yii::$app->user->identity->id;
|
||
$orderForm->user_type = \Yii::$app->user->identity->type;
|
||
$orderForm->attributes = $post;
|
||
$data = $orderForm->orderSales();
|
||
return $this->responseHandler($data);
|
||
}
|
||
|
||
/**
|
||
* showdoc
|
||
* @catalog 门店管理员审核售后订单
|
||
* @title 用户申请售后
|
||
* @description 本接口提供门店管理员审核售后订单
|
||
* @method post
|
||
* @url /api/order/store-order-sales
|
||
* @param order_sale_id 必选 int 售后订单ID
|
||
* @param plugin_sign 必选 int 标识 order_sale_store
|
||
* @param status 必选 int 标识 审核状态 2-同意 3-拒绝
|
||
* @param store_type 必选 int 门店人员身份
|
||
* @param merchant_remark 不必选 string 商家说明
|
||
* @return {"code":0,"msg":"操作成功","data":{}}
|
||
* @remark
|
||
*/
|
||
public function actionStoreOrderSales()
|
||
{
|
||
$orderForm = new OrderForm();
|
||
$post = \Yii::$app->request->post();
|
||
$orderForm->setScenario($post['plugin_sign']);
|
||
$orderForm->cx_mch_id = $this->cx_mch_id;
|
||
$orderForm->user_id = \Yii::$app->user->identity->id;
|
||
$orderForm->user_type = \Yii::$app->user->identity->type;
|
||
$orderForm->attributes = $post;
|
||
$data = $orderForm->orderSalesStore();
|
||
return $this->responseHandler($data);
|
||
}
|
||
|
||
/**
|
||
* showdoc
|
||
* @catalog 门店管理员售后订单列表
|
||
* @title门店管理员售后订单列表
|
||
* @description 本接口提供门店管理员售后订单列表
|
||
* @method get
|
||
* @url /api/order/order-sales-list
|
||
* @param order_id 不必选 int 订单ID
|
||
* @param plugin_sign 必选 int 标识sale_list
|
||
* @param store_type 不必选 int 门店管理员身份
|
||
* @param store_id 不必选 int 门店ID
|
||
* @return {"code":0,"msg":"ok","data":{"refund_price":"600.00","type":1,"remark":null,"apply_time":1668048577,"agree_time":1668050369,"detailed":"球车租赁","status":3,"merchant_remark":"没钱退"}}
|
||
* @return_param refund_price int 退款金额
|
||
* @return_param type int 退款类型
|
||
* @return_param remark string 退款说明
|
||
* @return_param apply_time int 申请时间
|
||
* @return_param agree_time int 同意时间
|
||
* @return_param detailed string 退款明细
|
||
* @return_param status string 状态:1=待商家处理,2=同意,3=拒绝
|
||
* @return_param merchant_remark string 商家同意|拒绝备注、理由
|
||
*/
|
||
public function actionOrderSalesList()
|
||
{
|
||
$orderForm = new OrderForm();
|
||
$post = \Yii::$app->request->get();
|
||
$orderForm->setScenario($post['plugin_sign']);
|
||
$orderForm->cx_mch_id = $this->cx_mch_id;
|
||
$orderForm->user_id = \Yii::$app->user->identity->id;
|
||
$orderForm->user_type = \Yii::$app->user->identity->type;
|
||
$orderForm->attributes = $post;
|
||
$data = $orderForm->saleList();
|
||
return $this->responseHandler($data);
|
||
}
|
||
|
||
/**
|
||
* showdoc
|
||
* @catalog 订单
|
||
* @title 获取是否需要缴纳押金和押金金额
|
||
* @description 本接口提供校验是否需要缴纳押金和获取押金金额
|
||
* @method post
|
||
* @url /api/order/check-deposit
|
||
* @param plugin_sign 必选 string 订单类型:球车租赁=ball_cart,交纳押金=deposit
|
||
* @param store_id 必选 string 门店ID
|
||
* @param ball_number 必选 string 球车编号
|
||
* @param pay_type 必选 string 支付方式:微信支付=wxpay,微信支付分=wxpay_points
|
||
* @return {"code":0,"msg":"ok","data":{"is_deposit":true,"deposit_money":"2000"}}
|
||
* @return_param is_deposit bool 是否需要交纳押金,true为需要,false为不需要
|
||
* @return_param deposit_money string 押金金额
|
||
* @remark 注:code!=0时,msg为异常信息.不会返回data数据
|
||
*/
|
||
public function actionCheckDeposit()
|
||
{
|
||
if(!\Yii::$app->request->isPost){
|
||
$data = $this->invaildRequest();
|
||
return $this->responseHandler($data);
|
||
}
|
||
$orderForm = new OrderForm();
|
||
$orderForm->scenario = 'check_deposit';
|
||
$orderForm->attributes = \Yii::$app->request->post();
|
||
$orderForm->cx_mch_id = $this->cx_mch_id;
|
||
$orderForm->user_id = \Yii::$app->user->identity->id;
|
||
$orderForm->user_type = \Yii::$app->user->identity->type;
|
||
$data = $orderForm->check_deposit();
|
||
return $this->responseHandler($data);
|
||
}
|
||
|
||
|
||
/**
|
||
* showdoc
|
||
* @catalog 订单
|
||
* @title 创建押金订单
|
||
* @description 本接口提供创建押金订单
|
||
* @method post
|
||
* @url /api/order/order-buy-deposit
|
||
* @param plugin_sign 必选 string 订单类型,固定:deposit
|
||
* @param price 必选 string 订单金额
|
||
* @param store_id 必选 string 球车所在门店ID
|
||
* @param ball_number 必选 string 球车编号
|
||
* @param pay_type 必选 string 支付方式:固定为微信支付=wxpay
|
||
* @return {"code":0,"msg":"ok","data":{"id":"1"}}
|
||
* @remark 注:押金订单只能微信支付,不能支付分支付
|
||
*/
|
||
public function actionOrderBuyDeposit()
|
||
{
|
||
if(!\Yii::$app->request->isPost){
|
||
$data = $this->invaildRequest();
|
||
return $this->responseHandler($data);
|
||
}
|
||
$orderForm = new OrderForm();
|
||
$orderForm->scenario = 'deposit';
|
||
$orderForm->attributes = \Yii::$app->request->post();
|
||
$orderForm->cx_mch_id = $this->cx_mch_id;
|
||
$orderForm->user_id = \Yii::$app->user->identity->id;
|
||
$orderForm->user_type = \Yii::$app->user->identity->type;
|
||
$data = $orderForm->createOrderDeposit();
|
||
return $this->responseHandler($data);
|
||
}
|
||
|
||
/**
|
||
* showdoc
|
||
* @catalog 订单
|
||
* @title 押金订单列表
|
||
* @description 押金订单列表
|
||
* @method post
|
||
* @url /api/order/order-deposit
|
||
* @param page 不必选 int 页码
|
||
* @param limit 不必选 int 条数
|
||
* @return {"code":0,"msg":"ok","data":[{"id":"1"}]}
|
||
* @remark 注:押金订单只能微信支付,不能支付分支付
|
||
*/
|
||
public function actionOrderDeposit()
|
||
{
|
||
$request = Yii::$app->request;
|
||
$get = $request->get();
|
||
$orderForm = new OrderForm();
|
||
$orderForm->cx_mch_id = $this->cx_mch_id;
|
||
$orderForm->page = $get['page'];
|
||
$orderForm->limit = $get['limit'];
|
||
$orderForm->user_id = \Yii::$app->user->identity->id;
|
||
$data = $orderForm->search_order_deposit();
|
||
return $this->responseHandler($data);
|
||
}
|
||
|
||
//创建支付分订单
|
||
public function actionOrderBuyPoints()
|
||
{
|
||
$orderForm = new OrderForm();
|
||
$orderForm->scenario = 'ball_cart';
|
||
$orderForm->attributes = \Yii::$app->request->post();
|
||
$orderForm->cx_mch_id = $this->cx_mch_id;
|
||
$orderForm->user_id = \Yii::$app->user->identity->id;
|
||
$orderForm->user_type = \Yii::$app->user->identity->type;
|
||
$data = $orderForm->createOrderPoints();
|
||
return $this->responseHandler($data);
|
||
|
||
}
|
||
|
||
/**
|
||
* showdoc
|
||
* @catalog 订单
|
||
* @title 关闭订单
|
||
* @description 本接口提供订单正在支付中,关闭或取消支付.将球车更新为正常状态
|
||
* @method post
|
||
* @url /api/order/close-order
|
||
* @param order_id 必选 int 订单id
|
||
* @return {"code":0,"msg":"ok","data":{}}
|
||
* @remark 注:押金订单只能微信支付,不能支付分支付
|
||
*/
|
||
public function actionCloseOrder()
|
||
{
|
||
if(!\Yii::$app->request->isPost){
|
||
$data = $this->invaildRequest();
|
||
return $this->responseHandler($data);
|
||
}
|
||
$order_id = \Yii::$app->request->post('order_id');
|
||
$orderForm = new OrderForm();
|
||
$orderForm->cx_mch_id = $this->cx_mch_id;
|
||
$data = $orderForm->closeOrder($order_id);
|
||
return $this->responseHandler($data);
|
||
}
|
||
|
||
}
|