From b58e30b2af072a7f856c989507bce584698b4b71 Mon Sep 17 00:00:00 2001 From: air <30444667+sszdot@users.noreply.github.com> Date: Wed, 15 Jan 2025 12:43:52 +0800 Subject: [PATCH] =?UTF-8?q?=E3=80=90=E7=B1=BB=20=20=E5=9E=8B=E3=80=91?= =?UTF-8?q?=EF=BC=9Afeat=20=E3=80=90=E5=8E=9F=20=20=E5=9B=A0=E3=80=91?= =?UTF-8?q?=EF=BC=9A=E5=B0=8F=E7=A8=8B=E5=BA=8F=E7=AB=AF=20=E8=AF=B7?= =?UTF-8?q?=E6=B1=82=20=E9=80=80=E6=AC=BE=E6=8E=A5=E5=8F=A3=20=E3=80=90?= =?UTF-8?q?=E8=BF=87=20=20=E7=A8=8B=E3=80=91=EF=BC=9ArefundOrder=20?= =?UTF-8?q?=E8=AE=A2=E5=8D=95=E7=94=B3=E8=AF=B7=E9=80=80=E6=AC=BE=E6=8E=A5?= =?UTF-8?q?=E5=8F=A3=20=E6=95=B0=E6=8D=AE=E6=A3=80=E9=AA=8C=20=EF=BC=9B?= =?UTF-8?q?=E6=9B=B4=E6=96=B0=E6=95=B0=E6=8D=AE=E8=AE=A2=E5=8D=95=E7=8A=B6?= =?UTF-8?q?=E6=80=81=EF=BC=9B=E8=BF=94=E5=9B=9E=E4=BF=AE=E6=94=B9=E7=8A=B6?= =?UTF-8?q?=E6=80=81=20=E3=80=90=E5=BD=B1=20=20=E5=93=8D=E3=80=91=EF=BC=9A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Api/Controller/CheckController.class.php | 36 +++++++++++++++---- 1 file changed, 30 insertions(+), 6 deletions(-) diff --git a/FlyCube/Api/Controller/CheckController.class.php b/FlyCube/Api/Controller/CheckController.class.php index 0481016..3105ecf 100644 --- a/FlyCube/Api/Controller/CheckController.class.php +++ b/FlyCube/Api/Controller/CheckController.class.php @@ -180,12 +180,36 @@ class CheckController extends PublicController */ public function refundOrder() { - $orderDb = D('order'); - $where['order_sn'] = $_REQUEST['order_sn']; - $where['shop_id'] = $_REQUEST['shop_id']; - $where['openid'] = $this->openid; - $n = $orderDb->where($where)->select(); - echo json_encode(array('status' => 0, 'msg' => $this->openid)); + if ($_REQUEST['order_sn'] && $_REQUEST['shop_id'] && $_REQUEST['refund_remark']) { + $orderDb = D('order'); + $where['order_sn'] = $_REQUEST['order_sn']; + $where['shop_id'] = $_REQUEST['shop_id']; + $where['openid'] = $this->openid; + $order = $orderDb->where($where)->find(); + + // 获取 apply_price 并强制转换为浮动类型,保留两位小数 + $applyPrice = round(floatval($_REQUEST['apply_price']), 2); + // 获取订单的 total_price 并强制转换为浮动类型,保留两位小数 + $totalPrice = round(floatval($order['total_price']), 2); + // 比较时确保两者都是浮动类型并且格式一致 + if ($applyPrice > $totalPrice) { + echo json_encode(array('status' => 0, 'msg' => '申请退款金额不能超过订单总额')); + exit(); + } + $data['apply_price'] = $applyPrice; + $data['refund_remark'] = $_REQUEST['refund_remark']; + $data['refundapply_time'] = time(); + $data['refund_status'] = '申请中'; + $isRefund = $orderDb->where($where)->data($data)->save(); + if ($isRefund) { + echo json_encode(array('status' => 1, 'msg' => '申请退款成功')); + } else { + echo json_encode(array('status' => 0, 'msg' => '申请退款失败')); + } + } else { + echo json_encode(array('status' => 0, 'msg' => '参数错误')); + exit(); + } } /** * @description: 对应用户的订单列表