request->isAjax) { $param = $this->request->getQueryParams(); $order = new OrderService(['mall_id' => $this->mall_id]); $list = $order->getOrderList($param); return $this->success('ok', $list); } return $this->render('index'); } /** * 补单 * * @return void */ public function actionPatchOrder() { if ($this->request->isAjax) { $ids = $this->request->getQueryParam('order_ids'); $order = new OrderService(['mall_id' => $this->mall_id]); $result = $order->patchOrder($ids); if ($result === false) { return $this->error($order->error); } return $this->success('推单成功', $result); } } /** * 转换订单(订单无法补单 转换成普通订单进行售后) * * @return mixed */ public function actionChangeOrder() { if ($this->request->isAjax) { $id = $this->request->getQueryParam('id'); $order = new OrderService(['mall_id' => $this->mall_id]); $result = $order->changeOrder($id); if ($result === false) { return $this->error($order->error); } return $this->success('转换成功', $result); } } public function actionThirdOrderDetail() { $supply_id = $this->request->get('supply_id') ?? 0; $api = ApiService::getConnect($this->mall_id, $supply_id); $ret = $api->orderDetailByThirdOrderSn($this->request->getQueryParam('order_no')); if (!$ret) return $this->error($api->error); // 过滤退款信息 if (!empty($ret['read'][0]['order_items'])) { // 通过SKU ID 进行 $refund = OrderRefund::findOne(['id' => $this->request->getQueryParam('refund_id')]); if (empty($refund)) return $this->error('退款不存在'); $orderDetail = OrderDetail::findOne(['id' => $refund->order_detail_id]); $sku = GoodsSkuModel::findOne(['attr_id' => $orderDetail->goods_attr_id]); $order_items = $ret['read'][0]['order_items']; $sku_ids = array_column($order_items, 'sku_id'); $index = array_search($sku->sku_id, $sku_ids); if ($index === false) return $this->error('无法获取SKU'); $ret = $order_items[$index]; $ret['price'] = bcmul($ret['price'], 0.01, 2); $ret['amount'] = bcmul($ret['amount'], 0.01, 2); $ret['supply_amount'] = bcmul($ret['supply_amount'], 0.01, 2); } return $this->success('ok', $ret, ApiCode::CODE_SUCCESS, JSON_BIGINT_AS_STRING); } }