| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207 |
- <?php
- /**
- * 重庆赤晓店信息科技有限公司
- * https://www.chixiaodian.com
- * Copyright (c) 2023 赤店商城 All rights reserved.
- */
- namespace app\modules\admin\controllers\booking;
- use app\modules\admin\controllers\BaseController;
- use app\modules\admin\models\booking\BookingForm;
- use app\models\Admin;
- use app\models\BookingOrderExt;
- use app\models\MdStaff;
- use app\models\Md;
- use app\utils\Notice\NoticeSend;
- class BookingController extends BaseController
- {
-
- public function actionCatListSelect()
- {
- $form = new BookingForm();
- $form->store_id = get_store_id();
- $res = $form->catListSelect();
- return $this->asJson($res);
- }
-
- public function actionCatList()
- {
- $form = new BookingForm();
- $form->name = get_params('name');
- $form->status = get_params('status', -1);
- $form->store_id = get_store_id();
- $res = $form->catList();
- return $this->asJson($res);
- }
-
- public function actionCatInfo()
- {
- $form = new BookingForm();
- $id = get_params('id', 0);
- $res = $form->catInfo($id);
- return $this->asJson($res);
- }
-
- public function actionCatSave()
- {
- $form = new BookingForm();
- $id = input_params('id', 0);
- $name = input_params('name', '');
- $pic_url = input_params('pic_url', '');
- $sort = input_params('sort', 1000);
- $is_show = input_params('is_show', 1);
- $form->store_id = get_store_id();
- $res = $form->catSave($id, $name, $pic_url, $sort, $is_show);
- return $this->asJson($res);
- }
-
- public function actionCatStatus()
- {
- $form = new BookingForm();
- $form->ids = input_params('ids', 0);
- $form->status = input_params('status', 1);
- $form->store_id = get_store_id();
- $res = $form->catStatus();
- return $this->asJson($res);
- }
-
- public function actionGoodsBookingTime()
- {
- $goods_id = input_params('goods_id', 0);
- $form = new \app\modules\client\models\v1\GoodsForm();
- $goodsBookingTime = $form->goodsBookingTime($goods_id);
- return $this->asJson([
- 'code' => 0,
- 'data' => $goodsBookingTime,
- ]);
- }
-
- public function actionBookingOrderList()
- {
- $form = new BookingForm();
- $params = all_params();
- $form->store_id = get_store_id();
- $res = $form->bookingOrderList($params);
- return $this->asJson($res);
- }
-
- public function actionBookingOrderCountByGoods()
- {
- $form = new BookingForm();
- $params = all_params();
- $form->store_id = get_store_id();
- $res = $form->bookingOrderCountByGoods($params);
- return $this->asJson($res);
- }
-
- public function actionBookingOrderCountByWorker()
- {
- $form = new BookingForm();
- $params = all_params();
- $form->store_id = get_store_id();
- $res = $form->bookingOrderCountByWorker($params);
- return $this->asJson($res);
- }
-
- public function actionAddBookingOrder()
- {
- $form = new BookingForm();
- $params = all_params();
- $form->store_id = get_store_id();
- $res = $form->bookingOrderSave($params);
- return $this->asJson($res);
- }
- // 服务人员列表
- public function actionWorkerList() {
- $md_id = get_md_id();
- $query = MdStaff::find()->alias('ms')->leftJoin(['md' => Md::tableName()], 'md.id=ms.md_id')->where(['ms.store_id' => get_store_id(), 'ms.is_delete' => 0, 'md.is_delete' => 0])->orderBy("ms.created_at desc, ms.updated_at desc");
- if ($md_id) {
- $query->andWhere(['ms.md_id' => $md_id]);
- }
- $list = $query->select('ms.id, ms.name')->asArray()->all();
- return $this->asJson([
- 'code' => 0,
- 'data' => $list,
- ]);
- }
- //分配订单
- public function actionOrderSetWorker()
- {
- $form = new BookingForm();
- $form->store_id = get_store_id();
- return $this->asJson($form->orderSetWorker(all_params()));
- }
-
-
- //确认收款
- public function actionOrderIsPay()
- {
- $form = new BookingForm();
- $form->store_id = get_store_id();
- return $this->asJson($form->orderIsPay(all_params()));
- }
- //确认收货
- public function actionOrderConfirm()
- {
- $form = new BookingForm();
- $form->store_id = get_store_id();
- return $this->asJson($form->orderConfirm(all_params()));
- }
- //订单操作
- public function actionOrderStatus()
- {
- $order_id = input_params('order_id');
- $type = input_params('type', 5);
- $cond = [
- 'and',
- ['order_id' => $order_id],
- ['store_id' => get_store_id()],
- ];
- $attr = [];
- if($type == 5){
- $cond = array_merge($cond, [
- ['<', 'status_ext', BookingOrderExt::STATUS_EXT_START],
- ]);
- $attr = [
- 'status_ext' => BookingOrderExt::STATUS_EXT_START,
- 'time_start_service' => time(),
- ];
- }
- if($type == 20){
- $cond = array_merge($cond, [
- ['<', 'status_ext', BookingOrderExt::STATUS_EXT_HAS_SYS_CONFIRM],
- ]);
- $attr = [
- 'status_ext' => BookingOrderExt::STATUS_EXT_HAS_SYS_CONFIRM,
- 'time_sys_confirm' => time(),
- ];
- }
- $orderExt = BookingOrderExt::find()->where($cond)->one();
- if(!$orderExt){
- return $this->asJson([
- 'code' => 1,
- 'msg' => '参数错误,或状态异常',
- ]);
- }
- $orderExt->setAttributes($attr, false);
- $save = $orderExt->save();
- if(!$save){
- return $this->asJson([
- 'code' => 1,
- 'msg' => '操作失败,' . array_shift($orderExt->getFirstErrors()),
- ]);
- }
- if($type == 20){
- NoticeSend::bookExamine($order_id);
- }
- return $this->asJson([
- 'code' => 0,
- 'msg' => 'success',
- ]);
- }
-
- }
|