test
parent
09c53981b5
commit
cccf1d5fff
|
|
@ -9,6 +9,7 @@ use Dcat\Admin\Show;
|
||||||
use Dcat\Admin\Http\Controllers\AdminController;
|
use Dcat\Admin\Http\Controllers\AdminController;
|
||||||
use App\Admin\Extensions\Grid\Tools\ProfitBatchSuccess;
|
use App\Admin\Extensions\Grid\Tools\ProfitBatchSuccess;
|
||||||
use App\Admin\Actions\Show\ProfitSuccess;
|
use App\Admin\Actions\Show\ProfitSuccess;
|
||||||
|
use App\Enums\PayWay;
|
||||||
|
|
||||||
class OrderProfitController extends AdminController
|
class OrderProfitController extends AdminController
|
||||||
{
|
{
|
||||||
|
|
@ -69,7 +70,10 @@ class OrderProfitController extends AdminController
|
||||||
$show->field('money');
|
$show->field('money');
|
||||||
$show->field('status')->using(OrderProfit::$statusMap)->dot(OrderProfit::$statusColor);
|
$show->field('status')->using(OrderProfit::$statusMap)->dot(OrderProfit::$statusColor);
|
||||||
$show->field('paid_at');
|
$show->field('paid_at');
|
||||||
$show->field('pay_way');
|
$show->field('pay_way')->using([
|
||||||
|
PayWay::Offline->value => PayWay::Offline->text(),
|
||||||
|
PayWay::WxpayTransfer->value => PayWay::WxpayTransfer->text()
|
||||||
|
])->label();
|
||||||
$show->field('pay_no');
|
$show->field('pay_no');
|
||||||
$show->field('remarks');
|
$show->field('remarks');
|
||||||
$show->field('created_at');
|
$show->field('created_at');
|
||||||
|
|
@ -104,6 +108,9 @@ class OrderProfitController extends AdminController
|
||||||
$form->text('ratio');
|
$form->text('ratio');
|
||||||
$form->text('money');
|
$form->text('money');
|
||||||
$form->text('status');
|
$form->text('status');
|
||||||
|
$show->field('pay_way');
|
||||||
|
$show->field('pay_no');
|
||||||
|
$show->field('paid_at');
|
||||||
|
|
||||||
$form->display('created_at');
|
$form->display('created_at');
|
||||||
$form->display('updated_at');
|
$form->display('updated_at');
|
||||||
|
|
|
||||||
|
|
@ -10,6 +10,7 @@ use Dcat\Admin\Traits\LazyWidget;
|
||||||
use Dcat\Admin\Widgets\Form;
|
use Dcat\Admin\Widgets\Form;
|
||||||
use Illuminate\Support\Facades\DB;
|
use Illuminate\Support\Facades\DB;
|
||||||
use Throwable;
|
use Throwable;
|
||||||
|
use App\Enums\PayWay;
|
||||||
|
|
||||||
class ProfitSuccessForm extends Form implements LazyRenderable
|
class ProfitSuccessForm extends Form implements LazyRenderable
|
||||||
{
|
{
|
||||||
|
|
@ -38,14 +39,14 @@ class ProfitSuccessForm extends Form implements LazyRenderable
|
||||||
{
|
{
|
||||||
$order = OrderProfit::findOrFail($this->payload['id']);
|
$order = OrderProfit::findOrFail($this->payload['id']);
|
||||||
$service = new DistributeService();
|
$service = new DistributeService();
|
||||||
if ($input['pay_way'] === 'wechat-transfer' && !$order->pay_no) {
|
if ($input['pay_way'] === PayWay::WxpayTransfer->value && !$order->pay_no) {
|
||||||
$order->update([
|
$order->update([
|
||||||
'pay_no' => serial_number()
|
'pay_no' => serial_number()
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
DB::beginTransaction();
|
DB::beginTransaction();
|
||||||
if ($input['pay_way'] === 'wechat-transfer') {
|
if ($input['pay_way'] === PayWay::WxpayTransfer->value) {
|
||||||
$service->wechatTransfer($order);
|
$service->wechatTransfer($order);
|
||||||
} else {
|
} else {
|
||||||
$service->success($order, $input);
|
$service->success($order, $input);
|
||||||
|
|
@ -67,7 +68,10 @@ class ProfitSuccessForm extends Form implements LazyRenderable
|
||||||
$order = OrderProfit::findOrFail($this->payload['id']);
|
$order = OrderProfit::findOrFail($this->payload['id']);
|
||||||
|
|
||||||
$this->datetime('paid_at')->value(now());
|
$this->datetime('paid_at')->value(now());
|
||||||
$this->text('pay_way');
|
$this->radio('pay_way')->options([
|
||||||
|
PayWay::Offline->value => PayWay::Offline->text(),
|
||||||
|
PayWay::WxpayTransfer->value => PayWay::WxpayTransfer->text()
|
||||||
|
])->default(PayWay::Offline->value);
|
||||||
$this->text('pay_no');
|
$this->text('pay_no');
|
||||||
$this->text('remarks')->value($order->remark);
|
$this->text('remarks')->value($order->remark);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -11,6 +11,7 @@ enum PayWay: string {
|
||||||
case WxpayH5 = 'wxpay_h5';
|
case WxpayH5 = 'wxpay_h5';
|
||||||
case WxpayJsApi = 'wxpay_jsapi';
|
case WxpayJsApi = 'wxpay_jsapi';
|
||||||
case WxpayMiniProgram = 'wxpay_mp';
|
case WxpayMiniProgram = 'wxpay_mp';
|
||||||
|
case WxpayTransfer = 'wxpay_transfer';
|
||||||
// 阿里支付
|
// 阿里支付
|
||||||
case AlipayApp = 'alipay_app';
|
case AlipayApp = 'alipay_app';
|
||||||
|
|
||||||
|
|
@ -20,7 +21,7 @@ enum PayWay: string {
|
||||||
static::Offline => '#5b69bc',
|
static::Offline => '#5b69bc',
|
||||||
static::Balance => '#dda451',
|
static::Balance => '#dda451',
|
||||||
static::Wallet => '#ff8acc',
|
static::Wallet => '#ff8acc',
|
||||||
static::WxpayApp, static::WxpayH5, static::WxpayJsApi, static::WxpayMiniProgram => '#21b978',
|
static::WxpayApp, static::WxpayH5, static::WxpayJsApi, static::WxpayMiniProgram, static::WxpayTransfer => '#21b978',
|
||||||
static::AlipayApp => '#3085d6',
|
static::AlipayApp => '#3085d6',
|
||||||
default => '#ea5455',
|
default => '#ea5455',
|
||||||
};
|
};
|
||||||
|
|
@ -62,6 +63,7 @@ enum PayWay: string {
|
||||||
static::Wallet => '钱包',
|
static::Wallet => '钱包',
|
||||||
static::WxpayApp, static::WxpayH5, static::WxpayJsApi, static::WxpayMiniProgram => '微信支付',
|
static::WxpayApp, static::WxpayH5, static::WxpayJsApi, static::WxpayMiniProgram => '微信支付',
|
||||||
static::AlipayApp => '支付宝',
|
static::AlipayApp => '支付宝',
|
||||||
|
static::WxpayTransfer => '微信企业付款',
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -63,20 +63,15 @@ class WxpayService
|
||||||
*/
|
*/
|
||||||
public function transfer(array $params)
|
public function transfer(array $params)
|
||||||
{
|
{
|
||||||
$config = config('wechat.payment.default');
|
$config = config('wechat.payment.transfer');
|
||||||
if (!isset($params['openid']) && config('app.debug')) {
|
$debug = config('app.debug');
|
||||||
|
if (!isset($params['openid']) && $debug) {
|
||||||
$params['openid'] = 'oU7xS5UspzVvpPEBqKZuW6N9WXDg';
|
$params['openid'] = 'oU7xS5UspzVvpPEBqKZuW6N9WXDg';
|
||||||
}
|
}
|
||||||
$app = Factory::payment($config);
|
if ($debug) {
|
||||||
|
$params['amount'] = 100;
|
||||||
// 服务商模式 (子商户)
|
|
||||||
$appId = config('wechat.payment.sub.app_id');
|
|
||||||
$mchId = config('wechat.payment.sub.mch_id');
|
|
||||||
|
|
||||||
if ($appId && $mchId) {
|
|
||||||
$app->setSubMerchant($mchId, $appId);
|
|
||||||
}
|
}
|
||||||
|
$app = Factory::payment($config);
|
||||||
/*
|
/*
|
||||||
'partner_trade_no' => '1233455', // 商户订单号,需保持唯一性(只能是字母或者数字,不能包含有符号)
|
'partner_trade_no' => '1233455', // 商户订单号,需保持唯一性(只能是字母或者数字,不能包含有符号)
|
||||||
'openid' => 'oxTWIuGaIt6gTKsQRLau2M0yL16E',
|
'openid' => 'oxTWIuGaIt6gTKsQRLau2M0yL16E',
|
||||||
|
|
|
||||||
|
|
@ -85,6 +85,17 @@ return [
|
||||||
'key' => env('WECHAT_PAYMENT_SUB_KEY'),
|
'key' => env('WECHAT_PAYMENT_SUB_KEY'),
|
||||||
'cert_path' => env('WECHAT_PAYMENT_SUB_CERT_PATH'),
|
'cert_path' => env('WECHAT_PAYMENT_SUB_CERT_PATH'),
|
||||||
'key_path' => env('WECHAT_PAYMENT_SUB_KEY_PATH'),
|
'key_path' => env('WECHAT_PAYMENT_SUB_KEY_PATH'),
|
||||||
|
// 日志
|
||||||
|
'log' => [
|
||||||
|
'default' => 'daily',
|
||||||
|
'channels' => [
|
||||||
|
'daily' => [
|
||||||
|
'driver' => 'daily',
|
||||||
|
'path' => storage_path('logs/wxpay-transfer.log'),
|
||||||
|
'level' => 'info',
|
||||||
|
],
|
||||||
|
],
|
||||||
|
],
|
||||||
],
|
],
|
||||||
// 商城 - 微信小程序支付
|
// 商城 - 微信小程序支付
|
||||||
'mini_program' => [
|
'mini_program' => [
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue