diff --git a/app/command/ProfitSharing.php b/app/command/ProfitSharing.php index 30ba0f15..fcee2215 100644 --- a/app/command/ProfitSharing.php +++ b/app/command/ProfitSharing.php @@ -48,7 +48,7 @@ class ProfitSharing extends Command echo "没有多商户商城了".PHP_EOL; return false; } - var_dump($stores); + //var_dump($stores); foreach ($stores as $store) { $where = []; @@ -62,7 +62,7 @@ class ProfitSharing extends Command $where[] = ['merchant_id','>', 0]; $where[] = ['commission_ratio','>', 0]; $orders = Order::where($where) - ->field('order_id,total_price,order_price,pay_price,pay_method,cost_price,merchant_id,store_id,order_status,pay_status,delivery_status,receipt_status,delivery_type,delivery_time,create_time,trade_id') + ->field('order_id,total_price,order_price,pay_price,pay_method,cost_price,merchant_id,store_id,order_status,pay_status,delivery_status,receipt_status,delivery_type,delivery_time,create_time,trade_id,commission_ratio') ->select(); // var_dump($orders->toArray()); // exit(); @@ -151,13 +151,11 @@ class ProfitSharing extends Command continue; } - $model = \app\store\model\Merchant::detail($order->merchant_id, $order->store_id); - - if ($model['commission_ratio'] <= 0) { + if ($order->commission_ratio <= 0) { echo $order->merchant_id."当前商户无需抽佣".PHP_EOL; continue; } - $precent = $model['commission_ratio'] / 1000; + $precent = $order->commission_ratio / 1000; $precentPrice = round($precent * $order->pay_price * 100, 2); var_dump($precentPrice); //$precentPrice = 100; @@ -190,7 +188,7 @@ class ProfitSharing extends Command } catch (\Exception $e) { Log::append('微信支付分账失败', [$order->order_id.":".$e->getMessage()]); echo $order->order_id.":".$e->getMessage(); - $ret = Order::where('order_id',$order->order_id)->update(['profitsharing_status' => 3, 'profitsharing_time' => time(),'out_order_no' => $out_trade_no]); + //$ret = Order::where('order_id',$order->order_id)->update(['profitsharing_status' => 3, 'profitsharing_time' => time(),'out_order_no' => $out_trade_no]); continue; } } diff --git a/app/command/ProfitSharingResult.php b/app/command/ProfitSharingResult.php index cca1ec2b..abe6a98c 100644 --- a/app/command/ProfitSharingResult.php +++ b/app/command/ProfitSharingResult.php @@ -48,7 +48,7 @@ class ProfitSharingResult extends Command } $orders = Order::where($where) - ->field('order_id,total_price,order_price,pay_price,pay_method,cost_price,merchant_id,store_id,order_status,pay_status,delivery_status,receipt_status,delivery_type,delivery_time,create_time,out_order_no') + ->field('order_id,total_price,order_price,pay_price,pay_method,cost_price,merchant_id,store_id,order_status,pay_status,delivery_status,receipt_status,delivery_type,delivery_time,create_time,out_order_no,trade_id,commission_ratio') ->select(); // var_dump($orders->toArray()); // exit(); @@ -66,12 +66,12 @@ class ProfitSharingResult extends Command echo $order['store_id']."微信支付方式没有配置".PHP_EOL; continue; } - $payment_template = PaymentTemplate::where('template_id', $payment->template_id)->where('is_delete', 1)->find(); + $payment_template = PaymentTemplate::where('template_id', $payment->template_id)->where('is_delete', 0)->find(); if (!$payment_template) { echo $order['store_id'].$payment->template_id."微信支付模版没有配置".PHP_EOL; continue; } - $wechat_config = $payment_template['config'] ? json_decode($payment_template['config'], true) : []; + $wechat_config = $payment_template['config'] ?? []; if (!$wechat_config) { echo $order['store_id'].$payment->template_id."微信支付模版没有配置11".PHP_EOL; continue; @@ -83,7 +83,7 @@ class ProfitSharingResult extends Command echo $order['store_id']."小程序配置没有".PHP_EOL; continue; } - $mini_config = $mini['values'] ? json_decode($mini['config'], true) : []; + $mini_config = $mini['values'] ?? []; if (!$mini_config) { echo $order['store_id'].$payment->template_id."微信支付模版没有配置11".PHP_EOL; continue; diff --git a/app/common/library/payment/gateway/driver/wechat/V3.php b/app/common/library/payment/gateway/driver/wechat/V3.php index e5b93aa6..54b1b0f6 100644 --- a/app/common/library/payment/gateway/driver/wechat/V3.php +++ b/app/common/library/payment/gateway/driver/wechat/V3.php @@ -169,11 +169,13 @@ class V3 { // 下单的参数 $params = ['transaction_id' => $transaction_id]; - + var_dump($params); + $url = $this->getProfitUrl()."/".$out_order_no."?transaction_id=".$transaction_id; + echo $url; try { $resp = $this->getApp() - ->chain($this->getProfitUrl()."/".$out_order_no) - ->get(['query' => $params]); + ->chain($url) + ->get(); // 记录api返回的数据 $result = helper::jsonDecode((string)$resp->getBody()); var_dump($result);