wesmiler 2 ヶ月 前
コミット
4f58cc0efe

+ 0 - 57
app/Http/Controllers/Api/v1/NotifyController.php

@@ -3,7 +3,6 @@
 namespace App\Http\Controllers\Api\v1;
 
 use App\Http\Controllers\Api\webApp;
-use App\Services\DyrPayService;
 use App\Services\PaymentService;
 use App\Services\RedisService;
 
@@ -69,62 +68,6 @@ class NotifyController extends webApp
     }
 
     /**
-     * 支付回调
-     * @param int $productId 产品
-     * @return array|false|\Psr\Http\Message\ResponseInterface
-     */
-    public function payCallback($productId)
-    {
-        $date = date('Y-m-d H:i:s');
-        $result = isset($_POST)? $_POST : request()->post();
-        $key = isset($result['out_trade_num'])?$result['out_trade_num'] : date('YmdHis') . '_' . rand(1000, 9999);
-        $channel = 'dryPay';
-        if (empty($result)) {
-            $result = file_get_contents('php://input');
-            $result = $result ? json_decode($result, true) : [];
-        }
-
-        try {
-            $sign = isset($result['sign'])?$result['sign']:'';
-            unset($result['sign']);//删除掉sign字段
-            $checkSign = DyrPayService::make()->makeSign($result, 2);
-            RedisService::set("caches:payments:payNotify_{$productId}:result_".$key, ['all' => request()->all(), 'sign'=>$sign,'checkSign'=>$checkSign, 'product_id' => $productId, 'result' => $result], 7200);
-            if($sign != $checkSign){
-                if (env('APP_DEBUG')) {
-                    logger()->channel($channel)->error("【{$date} 支付回调】签名错误:" . json_encode([ 'product_id' => $productId,'data' => $result], 256));
-                }
-
-                RedisService::set("caches:payments:payNotify_{$productId}:sign_" . $key, ['all' => request()->all(),  'product_id' => $productId, 'result' => $result], 7200);
-                return response('failed');
-            }
-
-            // 验签和重组参数
-            $data = $result;
-            RedisService::set("caches:payments:payNotify_{$productId}:data_" . $key, ['all' => request()->all(),'product_id' => $productId, 'result' => $result], 7200);
-            if (env('APP_DEBUG')) {
-                logger()->channel($channel)->info("【{$date} 支付回调】验证结果:" . json_encode(['data' => $data,'product_id' => $productId],256));
-            }
-
-            // 回调处理
-            if ($result = PaymentService::make()->catchPayNotify($productId, $data)) {
-                RedisService::set("caches:payments:payNotify_{$productId}:success_" . $key, ['msg'=>PaymentService::make()->getError(),'all' => request()->all(), 'product_id' => $productId, 'data' => $data,'result'=>$result], 7200);
-                logger()->channel($channel)->info("【{$date} 支付回调】回调成功:" . json_encode(['data' => $data,'product_id' => $productId],256));
-                return response('success');
-            } else {
-                $msg = PaymentService::make()->getError();
-                RedisService::set("caches:payments:payNotify_{$productId}:failed_" . $key, ['msg'=>$msg,'all' => request()->all(), 'product_id' => $productId, 'data' => $data], 7200);
-                logger()->channel($channel)->info("【{$date} 支付回调】回调失败:" . json_encode(['data' => $data,'product_id' => $productId, 'error' => lang($msg)], 256));
-                return message($msg ? $msg : 2635, false);
-            }
-        } catch (\Exception $exception) {
-            RedisService::set("caches:payments:payNotify_{$productId}:error_" . $key, ['all' => request()->all(), 'product_id' => $productId, 'error' => $exception->getMessage(), 'data' => $result], 7200);
-            logger()->channel($channel)->error("【{$date} 支付回调】回调错误:" . json_encode(['data' => $result,'product_id' => $productId, 'error' => $exception->getMessage()], 256));
-            return message(2635, false, ['error' => $exception->getMessage()]);
-        }
-    }
-
-
-    /**
      * 退款回调
      * @param string $scene 场景,refund-退款
      * @param int $payType 支付方式:10-微信,20-支付宝

+ 2 - 2
app/Models/AccountLogModel.php

@@ -33,8 +33,8 @@ class AccountLogModel extends BaseModel
     // 类型
     public function getTypeNameAttribute()
     {
-        $types = [1=>'订单付款-商品',2=>'充值-余额',3=>'订单退款-商品',4=>'余额提现',5=>'余额转出-驳回',6=>'平台转入-余额',7=>'收益-企业',8=>'收益-佣金',9=>'收益-其他',10=>'转账-余额'];
-        return $this->remark? $this->remark : (isset($types[$this->type])?$types[$this->type]:'账户交易');
+        $types = [1=>'订单付款',2=>'余额充值',3=>'订单退款',4=>'余额转出',5=>'余额转出驳回',6=>'平台转入',7=>'企业结算',8=>'收益',9=>'其他',10=>'余额转账'];
+        return isset($types[$this->type])?$types[$this->type]:'账户交易';
     }
 
     /**

+ 1 - 2
app/Services/Api/BalanceLogService.php

@@ -254,8 +254,7 @@ class BalanceLogService extends BaseService
             'after_money' => moneyFormat(max(0,$balance-$money), 2),
             'date'=> date('Y-m-d'),
             'create_time' => time(),
-            'remark' => "余额转出-{$accountName}".'('.substr($account,-4,4).') '.format_name($realname),
-            'remark1' => "{$account}".($accountRemark?'/'.$accountRemark:''),
+            'remark' => "{$accountName}".'('.substr($account,-4,4).') '.format_name($realname),
             'status' => 1,
             'mark' => 1,
         ];

+ 1 - 1
app/Services/Api/SettleService.php

@@ -85,7 +85,7 @@ class SettleService extends BaseService
             'after_money'=> moneyFormat($balance+$money,2),
             'date'=>date('Y-m-d'),
             'create_time'=>time(),
-            'remark'=> '收益-企业',
+            'remark'=> '企业收益',
             'status'=>1
         ];
         if(!$id = $this->model->insertGetId($log)){

+ 1 - 99
app/Services/PaymentService.php

@@ -549,8 +549,7 @@ class PaymentService extends BaseService
                         'after_money'=>$balance,
                         'date'=>date('Y-m-d'),
                         'create_time'=>time(),
-                        'remark'=> '订单付款-商品',
-                        'remark1'=> $goodsName,
+                        'remark'=> $goodsName,
                         'status'=>1,
                         'mark'=>1
                     ];
@@ -574,103 +573,6 @@ class PaymentService extends BaseService
     }
 
     /**
-     * 充值回调
-     * @param $productId
-     * @param $data
-     * @return bool
-     * @throws \Yansongda\Pay\Exception\ContainerException
-     * @throws \Yansongda\Pay\Exception\InvalidParamsException
-     * @throws \Yansongda\Pay\Exception\ServiceNotFoundException
-     */
-    public function catchPayNotify($productId, $data)
-    {
-        $out_trade_num = isset($data['out_trade_num'])?$data['out_trade_num']:'';
-        $state = isset($data['state'])? $data['state'] : 0;
-        $charge_kami = isset($data['charge_kami'])?$data['charge_kami'] : '';
-        $amount = isset($data['charge_amount'])?floatval($data['charge_amount']) : 0;
-        if($state==0){
-            $this->error = '充值处理中~';
-            return false;
-        }
-
-        $orderInfo = PayOrdersModel::with(['user'])->where(['order_no'=>$out_trade_num,'mark'=>1])->first();
-        $orderId = isset($orderInfo['id'])? $orderInfo['id'] : 0;
-        $orderUserId = isset($orderInfo['user_id'])? $orderInfo['user_id'] : 0;
-        $status = isset($orderInfo['status'])? $orderInfo['status'] : 0;
-        $total = isset($orderInfo['pay_total'])? $orderInfo['pay_total'] : 0;
-        $userInfo = isset($orderInfo['user'])? $orderInfo['user'] : [];
-        $parentId = isset($userInfo['parent_id'])?$userInfo['parent_id'] : 0;
-        if(empty($orderInfo) || $orderId<=0 || $total<=0){
-            $this->error = '充值订单不存在';
-            $this->saveLog("caches:payments:payNotify_{$productId}:notify_{$out_trade_num}_error", ['error'=>$this->error,'order' => $orderInfo, 'notify' => $data]);
-            return false;
-        }
-
-        if($status!=3){
-            $this->error = '充值订单状态错误,状态非充值中';
-            $this->saveLog("caches:payments:payNotify_{$productId}:notify_{$out_trade_num}_error", ['error'=>$this->error,'order' => $orderInfo, 'notify' => $data]);
-            return false;
-        }
-
-        // 成功
-        $status = 4;
-        $refundAmount = 0;
-        if($state == 1){
-            $this->error = '充值成功~';
-        }
-        //部分成功,退部分
-        else if($state == 3) {
-            $status = 6;
-            $refundAmount = moneyFormat($total - $amount,2);
-            $this->error = '充值成功部分退款';
-        }
-        //失败,退全款
-        else if(in_array($state,[-1,2])){
-            $status = 5;
-            $refundAmount = $total;
-            $this->error = '充值失败退款';
-        }
-
-        // 更新订单状态
-        DB::beginTransaction();
-        $this->saveLog("caches:payments:payNotify_{$productId}:notify_{$out_trade_num}", ['error'=>$this->error,'order' => $orderInfo, 'notify' => $data]);
-        if(!PayOrdersModel::where(['id'=>$orderId])->update(['status'=>$status,'charge_kami'=>$charge_kami,'refund_status'=>$status!=4?2:0,'charge_amount'=>$amount,'update_time'=>time()])){
-            $this->error = '更新订单状态错误~';
-            DB::rollBack();
-            return false;
-        }
-
-        // 是否要退款
-        if($refundAmount>0){
-            $orderInfo['money'] = $refundAmount;
-            $orderInfo['remark'] = $this->error;
-            $orderInfo['out_trade_no'] = '';
-            $refundStatus = PaymentService::make()->refund($orderInfo,'pay');
-            if(!PayOrdersModel::where(['id'=>$orderId])->update(['refund_status'=> $refundStatus?1:3,'refund_remark'=>$this->error,'refund_money'=>$refundStatus?$refundAmount:0,'refund_at'=>date('Y-m-d H:i:s'),'update_time'=>time()])){
-                $this->saveLog("caches:payments:payNotify_{$productId}:notify_{$out_trade_num}_error", ['error'=>$this->error,'order' => $orderInfo, 'notify' => $data]);
-                $this->error = '订单退款状态更新错误~';
-                DB::rollBack();
-                return false;
-            }
-        }
-
-        // 订单完成,代理收益结算
-        if($status == 4 && $amount>0)
-        {
-            // 代理佣金结算
-            if (SettleService::make()->agentBonus($orderUserId, $amount, $orderInfo, $parentId) < 0) {
-                DB::rollBack();
-                $this->error = SettleService::make()->getError();
-                return false;
-            }
-        }
-
-        DB::commit();
-        $this->error = '充值订单处理成功~';
-        return ['id'=>$orderId,'amount'=>$amount,'status'=>$status,'refund'=>$refundAmount];
-    }
-
-    /**
      * 日志
      * @param $key
      * @param $data

+ 0 - 1
routes/api.php

@@ -121,7 +121,6 @@ Route::prefix('v1')->middleware('web.login')->group(function() {
 });
 
 // 回调处理
-Route::match(['get','post'],'/dry/notify/{productId}', [\App\Http\Controllers\Api\v1\NotifyController::class, 'payCallback']);
 Route::match(['get','post'],'/notify/refund/{payType}', [\App\Http\Controllers\Api\v1\NotifyController::class, 'refund']);
 Route::match(['get','post'],'/notify/{scene}/{payType}', [\App\Http\Controllers\Api\v1\NotifyController::class, 'callback']);