attributes = post_params(); $form->store_id = get_store_id(); $form->user_id = get_user_id(); $form->user = get_user(); return $this->asJson($form->preOrder()); } /** * 订单提交前的预览页面 * @return \yii\web\Response */ public function actionSubmitPreview() { $form = new OrderSubmitPreviewForm(); $form->attributes = post_params(); $form->store_id = get_store_id(); $form->saas_id = get_saas_user_id(); return $this->asJson($form->search()); } /** * 新-订单提交 * @return \yii\web\Response */ public function actionSubmit() { $form = new OrderSubmitForm(); $form->attributes = post_params(); $form->send_price = post_params('send_price'); $form->take_price = post_params('take_price'); $form->store_id = get_store_id(); //$form->user_id = get_user_id(); //$form->user = get_user(); return $this->asJson($form->save()); } /** * 订单支付数据 * @return \yii\web\Response */ public function actionPayData() { $form = new OrderPayDataForm(); $form->attributes = get_params(); $form->store_id = get_store_id(); //$form->user = get_user(); return $this->asJson($form->search()); } /** * 订单列表 * @return \yii\web\Response */ public function actionList() { $form = new OrderListForm(); $form->attributes = get_params(); //$form->store_id = get_store_id(); //$form->saas_id = get_saas_user_id(); return $this->asJson($form->search()); } /** * 订单取消 * @return \yii\web\Response */ public function actionRevoke() { $form = new OrderRevokeForm(); $form->attributes = get_params(); //$form->store_id = get_store_id(); $form->saas_id = get_saas_user_id(); return $this->asJson($form->save()); } /** * @return \yii\web\Response */ public function actionUserDelete() { $order_id = post_params('order_id'); $order = Order::findOne(['id' => $order_id, 'user_delete' => 1]); if ($order) { return $this->asJson([ 'code' => 1, 'msg' => '订单已删除' ]); } Order::updateAll(['user_delete' => 1], ['id' => $order_id]); return $this->asJson([ 'code' => 0, 'msg' => '删除成功' ]); } /** * 订单详情 * @return \yii\web\Response */ public function actionDetail() { $form = new OrderDetailForm(); $form->attributes = get_params(); $form->saas_id = get_saas_user_id(); // $form->store_id = get_store_id(); // if (!empty(get_params('userId'))) { $form->user_id = get_params('userId'); // } else { // $form->user_id = get_user_id(); // } return $this->asJson($form->search()); } /** * 订单确认收货 */ public function actionConfirm() { $form = new OrderConfirmForm(); $form->attributes = get_params(); $form->saas_id = get_saas_user_id(); //$form->store_id = get_store_id(); //$form->user_id = get_user_id(); return $this->asJson($form->save()); } /** * 评论提交 */ public function actionComment() { $form = new OrderCommentForm(); $form->attributes = post_params(); $form->store_id = get_store_id(); $form->saas_id = get_saas_user_id(); // $form->user_id = get_user_id(); return $this->asJson($form->save()); } /** * 售后订单列表 */ public function actionRefundList() { $form = new OrderListForm(); // $form->store_id = get_store_id(); // $form->user_id = get_user_id(); $form->saas_id = get_saas_user_id(); $form->order_id = get_params('order_id'); $form->status = get_params('status'); return $this->asJson($form->getNewRefundList()); } /** * 我的兑换列表 */ public function actionIntegralList() { $form = new OrderListForm(); $form->store_id = get_store_id(); $form->user_id = get_saas_user_id(); return $this->asJson($form->getIntegralList()); } /** * 售后提交 */ public function actionRefund() { $form = new OrderRefundForm(); $form->attributes = post_params(); //$form->store_id = get_store_id(); //$form->user_id = get_user_id(); $form->saas_id = get_saas_user_id(); return $this->asJson($form->save()); } /** * 售后订单详情 */ public function actionRefundDetail() { $form = new OrderRefundDetailForm(); $form->attributes = get_params(); $form->store_id = get_store_id(); $form->user_id = get_user_id(); return $this->asJson($form->search()); } /** * 预取消订单 * @return \yii\web\Response */ public function actionPreCancelOrder() { $order_id = post_params('order_id'); $reason_id = post_params('reason_id', 5); $reason = post_params('reason', '其他原因'); $order = Order::findOne($order_id); if (!$order) { $this->asJson([ 'code' => 1, 'msg' => '订单不存在' ]); } $delivery = \app\models\DeliveryKeloop::findOne(['order_no' => $order->order_no, 'store_id' => $order->store_id]); if($delivery && KeloopForm::isSaasOpen()){ return $this->asJson([ 'code' => 0, 'msg' => '预取消订单', 'data' => [ 'resultcode' => 0, ], ]); } $delivery = \app\models\DeliveryMaiyatian::findOne(['order_no' => $order->order_no, 'store_id' => $order->store_id]); if($delivery && MaiyatianForm::isopen(get_store_id())){ return $this->asJson([ 'code' => 0, 'msg' => '预取消订单', 'data' => [ 'resultcode' => 0, ], ]); } $delivery = \app\models\DeliveryInfo::findOne(['order_no' => $order->order_no, 'store_id' => $order->store_id]); if($delivery['is_local'] == 1){ if($delivery['local_status'] > 0){ return $this->asJson([ 'code' => 1, 'msg' => '预取消订单失败,原因:已经开始配送', 'data' => [ 'resultcode' => 0, ], ]); } return $this->asJson([ 'code' => 0, 'msg' => '预取消订单', 'data' => [ 'resultcode' => 0, ], ]); } if($order->alipay_trade_no){ $res = ADelivery::cancelOrder(1, get_store_id(), get_mini_id(), get_saas_user()->ali_user_id, $order->order_no, $reason_id, $reason);; return $res; } $result = Delivery::preCancelOrder($order->order_no, $reason_id, $reason); return $this->asJson($result); } /** * 取消订单 * @return \yii\web\Response */ public function actionCancelOrder() { $order_id = post_params('order_id'); $reason_id = post_params('reason_id', 5); $reason = post_params('reason', '其他原因'); $order = Order::findOne($order_id); if (!$order) { $this->asJson([ 'code' => 1, 'msg' => '订单不存在' ]); } $delivery = \app\models\DeliveryKeloop::findOne(['order_no' => $order->order_no, 'store_id' => $order->store_id]); if($delivery && KeloopForm::isSaasOpen()){ //用户申请取消订单不取消配送单 return $this->asJson([ 'code' => 0, 'msg' => '取消订单', 'data' => [ 'resultcode' => 0, ], ]); $reason = Delivery::$validReason[$reason_id]; $res = KeloopForm::order_canceled($order->store_id, $order_id, $reason, 1); $res['data']['resultcode'] = $res['code']; return $this->asJson($res); } $delivery = \app\models\DeliveryMaiyatian::findOne(['order_no' => $order->order_no, 'store_id' => $order->store_id]); if($delivery && MaiyatianForm::isopen($order->store_id)){ $reason = Delivery::$validReason[$reason_id]; $res = MaiyatianForm::order_canceled($order->store_id, $order_id, $reason, 1); $res['data']['resultcode'] = $res['code']; return $this->asJson($res); } $delivery = \app\models\DeliveryInfo::findOne(['order_no' => $order->order_no, 'store_id' => $order->store_id]); if($delivery['is_local'] == 1){ if($delivery['local_status'] > 0){ return $this->asJson([ 'code' => 1, 'msg' => '取消订单失败,原因:已经开始配送', 'data' => [ 'resultcode' => 0, ], ]); } return $this->asJson([ 'code' => 0, 'msg' => '取消订单', 'data' => [ 'resultcode' => 0, ], ]); } // if($order->alipay_trade_no){ // $res = ADelivery::cancelOrder(0, $order->store_id, get_mini_id(), get_saas_user()->ali_user_id, $order->order_no, $reason_id, $reason);; // return $this->asJson($res); // } $result = Delivery::cancelOrder($order->order_no, $reason_id, $reason); return $this->asJson($result); } public function actionGetLocation() { $order_id = input_params('order_id'); $order = Order::findOne($order_id); if (!$order) { $this->asJson([ 'code' => 1, 'msg' => '订单不存在' ]); } $form = new OrderDetailForm(); $form->order_id = $order_id; $form->store_id = $order->store_id; return $this->asJson($form->map()); } /** * 获取核销码 * @return \yii\web\Response */ public function actionGetQrcode() { $order_no = get_params('order_no'); $order_type = get_params('order_type', ''); $page = "user/clerk/clerk"; if ($order_type) { $scene = "order_no:{$order_no},type:{$order_type}"; } else { $scene = "{$order_no}"; } $file_name = ['url_path' => '']; if (is_wechat_platform()) { $file_name = ShareQrcode::wxQrcode($page,$scene); } $res = [ 'code' => 0, 'msg' => 'success', 'data' => [ 'url' => $file_name['url_path'], ] ]; return $this->asJson($res); } }