| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103 |
- <?php
- // +----------------------------------------------------------------------
- // | Laravel框架 [ Laravel ]
- // +----------------------------------------------------------------------
- // | 版权所有 2017~2021 Laravel研发中心
- // +----------------------------------------------------------------------
- // | 官方网站: http://www.laravel.cn
- // +----------------------------------------------------------------------
- // | Author: wesmiler <12345678@qq.com>
- // +----------------------------------------------------------------------
- namespace App\Services;
- use App\Models\GongdengOrderModel;
- use App\Models\SignsModel;
- /**
- * 支付回调管理-服务类
- * @author wesmiler
- * @since 2020/11/11
- * Class NotifyService
- * @package App\Services
- */
- class NotifyService extends BaseService
- {
- protected static $instance = null;
- /**
- * 构造函数
- * @author wesmiler
- * @since 2020/11/11
- * NotifyService constructor.
- */
- public function __construct()
- {
- $this->model = new GongdengOrderModel();
- }
- /**
- * 静态入口
- * @return NotifyService|null
- */
- public static function make(){
- if(!self::$instance){
- self::$instance = new NotifyService();
- }
- return self::$instance;
- }
- /**
- * 供灯订单回调处理
- * @param $notifyData
- * @param $outTradeNo
- * @return false
- */
- public function notifyGongdeng($notifyData, $outTradeNo){
- // 验证订单是否存在
- $orderInfo = $this->model::where(['order_sn'=> $outTradeNo])
- ->select(['id','source_id','user_id','num','total','status'])
- ->first();
- // 验证参数
- $orderStatus = isset($orderInfo['status']) ? intval($orderInfo['status']) : 0;
- if (empty($orderInfo)) {
- NotifyService::rebackOk();
- return false;
- }
- // 验证订单状态是否可处理
- if ($orderStatus != 1) {
- NotifyService::rebackOk();
- return false;
- }
- // 验证订单金额是否正确
- $payDebug = config('weixin.payDebug');
- $payMoney = isset($postData['total_fee']) ? moneyFormat($postData['total_fee']) : 0;
- $orderMoney = isset($orderInfo['money']) ? moneyFormat($orderInfo['money']) : 0.00;
- $credit = isset($orderInfo['credit']) ? moneyFormat($orderInfo['credit']) : 0.00;
- $orderAmount = moneyFormat($orderMoney + $credit);
- if (!$payDebug && intval($orderAmount * 100) != intval($payMoney)) {
- return false;
- }
- // 更新订单数据
- // 处理支付明细
- // 开灯处理
- // 消息处理
- }
- /**
- * 返回成功
- */
- public static function rebackOk(){
- echo '<xml><return_code><![CDATA[SUCCESS]]></return_code><return_msg><![CDATA[OK]]></return_msg></xml>';
- exit;
- }
- }
|