request->get(); $id = $get['id'] ?? ''; $order = OrderClass::getById($id, true); if (empty($order)) { util::fail('没有找到订单'); } if ($order->mainId != $this->mainId) { util::fail('不是你的订单'); } $staff = $this->shopAdmin; if ($staff->mobile != '15280215347') { util::fail('请联系管理员操作'); } $shop = $this->shop; $respond = HdRefundClass::onlyRefundAmount($shop, $order); $status = $respond['status']; $msg = $respond['msg']; util::success(['status' => $status], $msg); } //列表 public function actionList() { $get = Yii::$app->request->get(); $where = []; $where['mainId'] = $this->mainId; $orderSn = $get['orderSn'] ?? ''; if (!empty($orderSn)) { $where['orderSn'] = $orderSn; } $list = HdRefundClass::getOrderList($where); util::success($list); } //退款单详情 ssh 20220427 public function actionDetail() { $id = Yii::$app->request->get('id', 0); $refund = HdRefundClass::getById($id, true); HdRefundClass::valid($refund, $this->mainId); $refundSn = $refund->refundSn ?? ''; $itemList = HdRefundItemClass::getItemListBySn($refundSn); $goodsList = HdRefundGoodsClass::getGoodsListBySn($refundSn); util::success(['info' => $refund, 'itemList' => $itemList, 'goodsList' => $goodsList]); } //退款 ssh 20220427 public function actionCreateOrder() { $shopAdmin = $this->shopAdmin; if (!isset($shopAdmin['super']) || $shopAdmin['super'] != 1) { util::fail('超管才能操作退款'); } $post = Yii::$app->request->post(); $id = isset($post['id']) ? $post['id'] : 0; $version = $post['version'] ?? 1; if ($version == 1) { util::fail('请升级小程序'); } //避免重复提交 util::checkRepeatCommit($id, 10); $connection = Yii::$app->db; $transaction = $connection->beginTransaction(); try { $order = OrderClass::getById($id, true); OrderClass::valid($order, $this->mainId); if ($order->status == OrderClass::ORDER_STATUS_UN_PAY) { util::fail("待付款订单无法退款"); } if ($order->status == OrderClass::ORDER_STATUS_CANCEL) { util::fail("取消订单不能发起退款"); } if ($order->fromType == 4) { util::fail('请在美团APP发起退货退款'); } if ($order->debt != 1 && $order->addTime < '2023-10-17 00:00:00') { util::fail('10月17日前订单无法申请退款'); } if ($order->payWay == 2) { util::fail('余额支付订单暂不支持售后'); } $addTime = $order->addTime ?? ''; $current = time(); if ($order->debt != 1 && (strtotime($addTime) + 3 * 30 * 24 * 60 * 60) < $current) { util::fail('历史订单,不能再发起退款'); } if (strtotime($addTime) <= strtotime('2022-03-30 00:00:00')) { util::fail('历史订单,不能发起退款哦'); } //商品花材结构 property 0商品 1花材 //[{productId:0,num:1,unitType:0,unitPrice:12,unitName:'扎',property:1}] $productJson = $post['product'] ?? ''; if (empty($productJson)) { util::fail('请选择商品'); } $productList = json_decode($productJson, true); if (!is_array($productList)) { util::fail('请选择商品哦'); } $post['product'] = $productList; $post['price'] = $post['price'] ?? 0; if ($post['price'] <= 0) { util::fail("退款金额不能小于0"); } if (bccomp($post['price'], $order->orderPrice, 2) == 1) { util::fail("退款金额超过订单金额"); } $post['shopId'] = $this->shopId; $post['sjId'] = $this->sjId; $post['shopAdminId'] = $this->shopAdminId; $post['mainId'] = $this->mainId; $shopAdmin = $this->shopAdmin; $adminName = $shopAdmin['name'] ?? ''; $post['shopAdminName'] = $adminName; HdRefundService::addRefund($post, $order); $transaction->commit(); //制作单取消通知 $shopId = $this->shopId ?? 0; $shopExt = ShopExtClass::getByCondition(['shopId' => $shopId], true); ShopExtClass::orderCancelRemind($shopExt, $order); util::complete(); } catch (\Exception $exception) { $transaction->rollBack(); Yii::info("出错了:" . $exception->getMessage()); util::fail('操作失败'); } util::complete(); } public function actionAllRefund() { util::fail('功能开发中'); } }