request->get(); $id = $get['id'] ?? 0; $settle = SettleClass::getById($id); if ($settle['customUserId'] != $this->userId) { util::fail('不是你的账单'); } $respond = SettleClass::getMyDetail($settle); util::success($respond); } public function actionCancelSettle() { util::fail('开发中'); } public function actionGetList() { $get = Yii::$app->request->get(); $where = []; if (isset($get['status']) && is_numeric($get['status'])) { $where['status'] = $get['status']; } $hdId = $get['hdId'] ?? 0; if (!empty($hdId)) { //BaseController文件有判断是否本人花店,这里不需要再判断 $where['hdId'] = $hdId; } $where['shopId'] = $this->shopId; $list = \bizMall\settle\classes\SettleClass::getSettleList($where); $totalAmount = SettleClass::sum(['shopId' => $this->shopId, 'status' => 2, 'hdId' => $hdId], 'actPrice'); $list['totalAmount'] = floatval($totalAmount); util::success($list); } //创建结账和充值单 ssh 20250709 public function actionCreateOrder() { $post = Yii::$app->request->post(); $shop = $this->shop; if (empty($shop)) { util::fail('没有门店信息'); } $hd = $this->hd; if (empty($hd)) { util::fail('没有花店信息呢'); } $custom = $this->custom; if (empty($custom)) { util::fail('花店信息缺失,编号88611'); } $idList = $post['ids'] ?? ''; $idList = trim($idList); if (empty($idList)) { util::fail('请选择订单'); } $ids = explode(',', $idList); if (empty($ids)) { util::fail('请选择订单哦'); } $mayClearAmount = 0; $orderList = OrderClass::getAllByCondition(['id' => ['in', $ids]], null, '*', null, true); if (empty($orderList)) { util::fail('没有选订单'); } $myClearData = []; foreach ($orderList as $order) { if ($order->mainId != $this->mainId) { util::fail('不是你的订单呢'); } $orderId = $order->id; $orderSn = $order->orderSn ?? ''; $remainDebtPrice = $order->remainDebtPrice ?? 0; $mayClearAmount = bcadd($mayClearAmount, $remainDebtPrice, 2); $myClearData[] = ['orderId' => $orderId, 'clearAmount' => $remainDebtPrice, 'orderSn' => $orderSn]; } if ($mayClearAmount <= 0) { util::fail('不需要销账'); } $orderSn = orderSn::getRechargeSn(); $payWay = 0; $shopId = $this->shopId; $mainId = $this->mainId; $hdId = $hd->id; $hdName = $hd->name; $staffId = 0; $staffName = ''; $customId = $custom->id; $customName = $custom->name; $userId = $this->userId; $staff = []; //避免重复提交 util::checkRepeatCommit($userId, 6); $createData = [ 'customId' => $customId, 'customName' => $customName, 'userId' => $userId, 'orderSn' => $orderSn, 'modPrice' => 1, 'payWay' => $payWay, 'style' => 1, 'shopId' => $shopId, 'mainId' => $mainId, 'hdId' => $hdId, 'hdName' => $hdName, 'onlinePay' => 1, 'amount' => $mayClearAmount, 'staffId' => $staffId, 'staffName' => $staffName, 'payStatus' => 0, 'payTime' => '0000-00-00 00:00:00', 'status' => 0, 'remark' => '', ]; $respond = RechargeClass::addRecharge($createData); //创建待账单 $settle = SettleClass::addSettle($myClearData, $shop, $custom, $hd, $staff); $settleId = $settle->id; $settleAmount = $settle->actPrice; $settleNo = $settle->orderSn ?? ''; $respond->settleId = $settleId; $respond->settleAmount = $settleAmount; $respond->settleNo = $settleNo; $respond->save(); util::success($respond); } }