request->get(); $id = $get['id'] ?? 0; $refund = CgRefundClass::getById($id, true); CgRefundClass::valid($refund, $this->mainId); $refundSn = $refund->refundSn ?? ''; $itemList = CgRefundItemClass::getAllByCondition(['refundSn' => $refundSn], null, '*'); if (!empty($itemList)) { foreach ($itemList as $key => $item) { $shortCover = $item['cover'] ?? ''; $itemList[$key]['cover'] = imgUtil::groupImg($shortCover) . "?x-oss-process=image/resize,m_fill,h_130,w_130"; } } util::success(['info' => $refund, 'itemList' => $itemList]); } //记录 ssh 20220910 public function actionGetRefundList() { $get = Yii::$app->request->get(); $where = []; $where['mainId'] = $this->mainId; $relateOrderSn = $get['relateOrderSn'] ?? ''; if (!empty($relateOrderSn)) { $where['relateOrderSn'] = $relateOrderSn; } $list = CgRefundClass::getRefundList($where); util::success($list); } //退款 ssh 20220909 public function actionCreateOrder() { $shopAdmin = $this->shopAdmin; if (isset($shopAdmin['super']) == false || $shopAdmin['super'] != 1) { util::fail('超管才能操作退款'); } $connection = Yii::$app->db; $transaction = $connection->beginTransaction(); try { $post = Yii::$app->request->post(); $id = isset($post['id']) ? $post['id'] : 0; $order = PurchaseOrderClass::getLockById($id); if ($order->mainId != $this->mainId) { util::fail('没有权限'); } if ($order->status != PurchaseOrderClass::PURCHASE_ORDER_STATUS_COMPLETE) { util::fail('已完成订单才能申请退货退款'); } if ($order->debt != 1) { util::fail('欠款单才能申请退货退款'); } //退款类型 1退货并退款 2 仅退款 $refundType = $post['refundType'] ?? 1; if ($refundType == CgRefundClass::REFUND_TYPE_MONEY_GOOD) { //花材列表结构 // [{productId:0,num:1,unitType:0,unitPrice:12,unitName:'扎'}] productId 花材id num 退货数 unitType 大小单位0大1小 unitPrice 售价 unitName单位名称 $productJson = $post['product'] ?? ''; if (empty($productJson)) { util::fail('请选择花材'); } $productList = json_decode($productJson, true); if (!is_array($productList)) { util::fail('请选择花材哦'); } $post['product'] = $productList; } else { //仅退款花材直接设置为空 $post['product'] = []; } $post['price'] = $post['price'] ?? 0; if ($post['price'] <= 0) { util::fail("退款金额不能小于0"); } if (bccomp($post['price'], $order->realPrice, 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; CgRefundService::addRefund($order, $post); $transaction->commit(); } catch (\Exception $exception) { $transaction->rollBack(); Yii::info("退款申请出错了,报错信息:" . $exception->getMessage()); util::fail('操作失败'); } util::complete(); } }