|
@@ -3,6 +3,7 @@
|
|
|
namespace app\api\controller;
|
|
|
|
|
|
use app\common\controller\Api;
|
|
|
+use app\common\model\HotelCanteenRoomModel;
|
|
|
use app\common\model\OfflineShopModel;
|
|
|
use app\common\model\OfflineTypeModel;
|
|
|
use app\utils\DataUtil;
|
|
@@ -120,4 +121,45 @@ class OfflineShop extends Api
|
|
|
Db::name('offline_shop')->where('id',$params['shop_id'])->update(['star'=>$star]);
|
|
|
return $this->success('评价成功');
|
|
|
}
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 提交订单
|
|
|
+ * @return true
|
|
|
+ */
|
|
|
+ public function orderSubmit()
|
|
|
+ {
|
|
|
+ $params = $this->request->param();
|
|
|
+ if (empty($params['shop_id'])) {
|
|
|
+ return $this->error('参数缺失');
|
|
|
+ }
|
|
|
+ if (empty($params['money'])) {
|
|
|
+ return $this->error('请填写支付金额');
|
|
|
+ }
|
|
|
+ $user_id = $this->auth->id;
|
|
|
+
|
|
|
+ $model = new OfflineShopModel();
|
|
|
+ $info = $model->getDetail(params: ['id'=>$params['shop_id']]);
|
|
|
+ if (!$info){
|
|
|
+ return $this->error('门店信息有误');
|
|
|
+ }
|
|
|
+
|
|
|
+ // 开始报名
|
|
|
+ $data = [
|
|
|
+ 'shop_id' => $info['id'],
|
|
|
+ 'user_id' => $user_id,
|
|
|
+ 'order_no' => createUniqueNo('C', $user_id),
|
|
|
+ 'pay_amount' => bcmul($params['money'], 1, 2),
|
|
|
+ 'status' => 1,
|
|
|
+ 'create_time' => time()
|
|
|
+ ];
|
|
|
+ if (!Db::name('offline_shop_order')->insertGetId($data)) {
|
|
|
+ return $this->error('订单创建失败');
|
|
|
+ }
|
|
|
+
|
|
|
+ return $this->success('提交成功',[
|
|
|
+ 'order_no' => $data['order_no'],
|
|
|
+ 'pay_amount' => $data['pay_amount'],
|
|
|
+ 'order_type' => 'offline_shop_order',
|
|
|
+ ]);
|
|
|
+ }
|
|
|
}
|