|
|
@@ -3,6 +3,7 @@
|
|
|
namespace app\controller\api;
|
|
|
|
|
|
use app\extra\basic\Base;
|
|
|
+use app\model\saas\SaasOrder;
|
|
|
use LinFly\Annotation\Attributes\Route\Controller;
|
|
|
use LinFly\Annotation\Attributes\Route\PostMapping;
|
|
|
use support\Request;
|
|
|
@@ -20,9 +21,46 @@ class Notify extends Base
|
|
|
$param = $request->all();
|
|
|
echo getDateFull()."===支付返回\n";
|
|
|
print_r($param);
|
|
|
- return success("ok");
|
|
|
+ $data = !empty($param['msg']) ? json_decode($param['msg'],true) : [];
|
|
|
+ print_r($param['msg']);
|
|
|
+ print_r($data);
|
|
|
+ $orderSn = $data['cp_extra'];
|
|
|
+ if ($data['status'] <> "SUCCESS") return json(['err_no' => 0,'err_tips' => "success"]);
|
|
|
+ if (empty($data)) return json(['err_no' => 0,'err_tips' => "success"]);
|
|
|
+ $order = (new SaasOrder)->where("order_sn",$orderSn)->findOrEmpty();
|
|
|
+ if ($order->isEmpty()) return json(['err_no' => 0,'err_tips' => "success"]);
|
|
|
+ if ($order['status'] <> 0) return json(['err_no' => 0,'err_tips' => "success"]);
|
|
|
+ $order->status = 1;
|
|
|
+ $order->pay_at = getDateFull();
|
|
|
+ $order->pay_type = $data['way'];
|
|
|
+ $order->pay_sn = $data['cp_orderno'];
|
|
|
+ $order->pay_money = $data['total_amount'];
|
|
|
+ $order->save();
|
|
|
+ return json(['err_no' => 0,'err_tips' => "success"]);
|
|
|
} catch (\Throwable $th) {
|
|
|
return error($th->getMessage());
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+ #[PostMapping("refund")]
|
|
|
+ public function getOrderRefund(Request $request): Response
|
|
|
+ {
|
|
|
+ try {
|
|
|
+ $param = $request->all();
|
|
|
+ echo getDateFull()."===退款返回\n";
|
|
|
+ print_r($param);
|
|
|
+ $data = !empty($param['msg']) ? json_decode($param['msg'],true) : [];
|
|
|
+ $orderSn = $data['cp_extra'];
|
|
|
+ if ($data['status'] <> "SUCCESS") return json(['err_no' => 0,'err_tips' => "success"]);
|
|
|
+ if (empty($data)) return json(['err_no' => 0,'err_tips' => "success"]);
|
|
|
+ $order = (new SaasOrder)->where("order_sn",$orderSn)->findOrEmpty();
|
|
|
+ if ($order['status'] <> 4) return json(['err_no' => 0,'err_tips' => "success"]);
|
|
|
+ $order->status = 3;
|
|
|
+ $order->refund_at = getDateFull();
|
|
|
+ $order->save();
|
|
|
+ return json(['err_no' => 0,'err_tips' => "success"]);
|
|
|
+ } catch (\Throwable $throwable) {
|
|
|
+ return error($throwable->getMessage());
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|