|
@@ -11,14 +11,14 @@
|
|
|
|
|
|
|
|
namespace App\Services;
|
|
namespace App\Services;
|
|
|
|
|
|
|
|
-use App\Models\AccountLogModel;
|
|
|
|
|
-use App\Models\MemberModel;
|
|
|
|
|
use App\Models\OrderModel;
|
|
use App\Models\OrderModel;
|
|
|
use App\Models\PaymentModel;
|
|
use App\Models\PaymentModel;
|
|
|
use App\Models\PayOrdersModel;
|
|
use App\Models\PayOrdersModel;
|
|
|
use App\Services\Api\SettleService;
|
|
use App\Services\Api\SettleService;
|
|
|
use Illuminate\Support\Facades\DB;
|
|
use Illuminate\Support\Facades\DB;
|
|
|
use Yansongda\Pay\Pay;
|
|
use Yansongda\Pay\Pay;
|
|
|
|
|
+use Yansongda\Pay\Plugin\Wechat\Fund\Profitsharing\AddReceiverPlugin;
|
|
|
|
|
+use Yansongda\Pay\Plugin\Wechat\Fund\Profitsharing\CreatePlugin;
|
|
|
use Yansongda\Pay\Provider\Wechat;
|
|
use Yansongda\Pay\Provider\Wechat;
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -112,7 +112,7 @@ class PaymentService extends BaseService
|
|
|
$payConfig['wechat']['default']['notify_url'] = url(env('APP_URL') . 'api/notify/' . $scene . '/10');
|
|
$payConfig['wechat']['default']['notify_url'] = url(env('APP_URL') . 'api/notify/' . $scene . '/10');
|
|
|
|
|
|
|
|
$this->config = $payConfig;
|
|
$this->config = $payConfig;
|
|
|
- //var_dump($payConfig);
|
|
|
|
|
|
|
+ var_dump($payConfig);
|
|
|
return Pay::wechat($payConfig);
|
|
return Pay::wechat($payConfig);
|
|
|
} else if ($payType == 20) {
|
|
} else if ($payType == 20) {
|
|
|
$appid = isset($config['alipay_appid']) ? $config['alipay_appid'] : '';
|
|
$appid = isset($config['alipay_appid']) ? $config['alipay_appid'] : '';
|
|
@@ -196,6 +196,7 @@ class PaymentService extends BaseService
|
|
|
// 创建支付
|
|
// 创建支付
|
|
|
try {
|
|
try {
|
|
|
$pay = $this->createPay($scene, 10, 'min');
|
|
$pay = $this->createPay($scene, 10, 'min');
|
|
|
|
|
+ var_dump($pay);
|
|
|
RedisService::set("caches:payments:wechat:{$scene}_{$outTradeNo}", ['order' => $order, 'config' => $this->config], 7200);
|
|
RedisService::set("caches:payments:wechat:{$scene}_{$outTradeNo}", ['order' => $order, 'config' => $this->config], 7200);
|
|
|
if (empty($pay)) {
|
|
if (empty($pay)) {
|
|
|
$this->error = 2616;
|
|
$this->error = 2616;
|
|
@@ -818,4 +819,61 @@ class PaymentService extends BaseService
|
|
|
$this->error = '退款处理成功';
|
|
$this->error = '退款处理成功';
|
|
|
return $refundStatus;
|
|
return $refundStatus;
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 分账
|
|
|
|
|
+ * @param $openid
|
|
|
|
|
+ * @param $order
|
|
|
|
|
+ * @param string $scene
|
|
|
|
|
+ * @return array|\Psr\Http\Message\MessageInterface|\Yansongda\Supports\Collection|null
|
|
|
|
|
+ * @throws \Yansongda\Pay\Exception\ContainerException
|
|
|
|
|
+ * @throws \Yansongda\Pay\Exception\InvalidParamsException
|
|
|
|
|
+ */
|
|
|
|
|
+ public function profitsharing($openid, $order ,$scene='sharing')
|
|
|
|
|
+ {
|
|
|
|
|
+ $data = [
|
|
|
|
|
+ 'type' => 'PERSONAL_OPENID',
|
|
|
|
|
+ 'account' => $openid,
|
|
|
|
|
+ 'relation_type' => 'SERVICE_PROVIDER'
|
|
|
|
|
+ ];
|
|
|
|
|
+
|
|
|
|
|
+ $pay = PaymentService::make()->createPay($scene, 10);
|
|
|
|
|
+ $plugin = $pay->mergeCommonPlugins([
|
|
|
|
|
+ AddReceiverPlugin::class
|
|
|
|
|
+ ], $data);
|
|
|
|
|
+
|
|
|
|
|
+ // 添加分账插件配置
|
|
|
|
|
+ $pay->pay($plugin, $data);
|
|
|
|
|
+
|
|
|
|
|
+ // 分账数据
|
|
|
|
|
+ $transactionId = isset($order['transaction_id'])? $order['transaction_id'] : ''; // 支付交易单号
|
|
|
|
|
+ $profitsharingOrderNo = isset($order['out_order_no'])? $order['out_order_no'] : ''; // 分账单号,非支付单号
|
|
|
|
|
+ $body = isset($order['body'])? $order['body'] : ''; // 分账备注描述
|
|
|
|
|
+ $amount = isset($order['amount'])? $order['amount'] : ''; // 分账金额
|
|
|
|
|
+ $unsplit = isset($order['unsplit'])? $order['unsplit'] : true; // 是否限制只分账一次
|
|
|
|
|
+ $postData = [
|
|
|
|
|
+ 'transaction_id' => $transactionId,
|
|
|
|
|
+ 'out_order_no' => $profitsharingOrderNo,
|
|
|
|
|
+ 'receivers' => [
|
|
|
|
|
+ [
|
|
|
|
|
+ 'type' => 'PERSONAL_OPENID',
|
|
|
|
|
+ 'account' => $openid,
|
|
|
|
|
+ 'amount' => $amount, // 分账金额,单位:分
|
|
|
|
|
+ 'description' => $body, //分账描述
|
|
|
|
|
+ ],
|
|
|
|
|
+ ],
|
|
|
|
|
+ 'unfreeze_unsplit' => $unsplit,
|
|
|
|
|
+ ];
|
|
|
|
|
+
|
|
|
|
|
+ // 创建分账数据
|
|
|
|
|
+ $createPlugin = $pay->mergeCommonPlugins([
|
|
|
|
|
+ CreatePlugin::class
|
|
|
|
|
+ ], $postData);
|
|
|
|
|
+
|
|
|
|
|
+ // 发起分账
|
|
|
|
|
+ $result = $pay->pay($createPlugin, $postData);
|
|
|
|
|
+ var_dump($result);
|
|
|
|
|
+
|
|
|
|
|
+ return $result;
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|