|
@@ -3,6 +3,7 @@
|
|
namespace App\Http\Controllers\V1;
|
|
namespace App\Http\Controllers\V1;
|
|
|
|
|
|
|
|
|
|
|
|
+use App\Helper\ByteDance;
|
|
use App\Helper\UniPlatform\Bytedance\Payment as BytedancePayment;
|
|
use App\Helper\UniPlatform\Bytedance\Payment as BytedancePayment;
|
|
use App\Helper\UniPlatform\Kuaishou\Payment as KuaishouPayment;
|
|
use App\Helper\UniPlatform\Kuaishou\Payment as KuaishouPayment;
|
|
use App\Models\Pay;
|
|
use App\Models\Pay;
|
|
@@ -16,8 +17,9 @@ class PayNoticeController extends Controller
|
|
{
|
|
{
|
|
public function bytedance()
|
|
public function bytedance()
|
|
{
|
|
{
|
|
- $app = new BytedancePayment($this->getUniFactory());
|
|
|
|
- return $app->payNotify(function ($data, $fail) {
|
|
|
|
|
|
+ $factory = $this->getUniFactory();
|
|
|
|
+ $app = new BytedancePayment($factory);
|
|
|
|
+ return $app->payNotify(function ($data, $fail) use ($factory) {
|
|
//处理支付订单
|
|
//处理支付订单
|
|
try {
|
|
try {
|
|
\DB::beginTransaction();
|
|
\DB::beginTransaction();
|
|
@@ -33,11 +35,16 @@ class PayNoticeController extends Controller
|
|
$pay->save();
|
|
$pay->save();
|
|
// 处理
|
|
// 处理
|
|
if ($pay->source == Pay::SOURCE_RECHARGE) {
|
|
if ($pay->source == Pay::SOURCE_RECHARGE) {
|
|
- $this->recharge($payId);
|
|
|
|
|
|
+ $goods = $this->recharge($payId);
|
|
} else if ($pay->source == Pay::SOURCE_BUY_VIP) {
|
|
} else if ($pay->source == Pay::SOURCE_BUY_VIP) {
|
|
- $this->buyVip($payId);
|
|
|
|
|
|
+ $goods = $this->buyVip($payId);
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ if(isset($goods)){
|
|
|
|
+ /* @var Pay $payInfo*/
|
|
|
|
+ $payInfo = Pay::with(['user'])->where('id', $payId)->first($payId);
|
|
|
|
+ $factory->pushOrder($payInfo->user->open_id, $payId, $goods);
|
|
|
|
+ }
|
|
\DB::commit();
|
|
\DB::commit();
|
|
} catch (\Exception $e) {
|
|
} catch (\Exception $e) {
|
|
\DB::rollBack();
|
|
\DB::rollBack();
|
|
@@ -91,7 +98,7 @@ class PayNoticeController extends Controller
|
|
private function recharge($payId)
|
|
private function recharge($payId)
|
|
{
|
|
{
|
|
/* @var UserRechargeRecord $record */
|
|
/* @var UserRechargeRecord $record */
|
|
- $record = UserRechargeRecord::where('pay_id', $payId)->first();
|
|
|
|
|
|
+ $record = UserRechargeRecord::with(['combo'])->where('pay_id', $payId)->first();
|
|
if (!$record) {
|
|
if (!$record) {
|
|
return true;
|
|
return true;
|
|
}
|
|
}
|
|
@@ -116,12 +123,18 @@ class PayNoticeController extends Controller
|
|
$record->status = 1;
|
|
$record->status = 1;
|
|
$record->save();
|
|
$record->save();
|
|
|
|
|
|
|
|
+ return [
|
|
|
|
+ 'id' => $record->combo_id,
|
|
|
|
+ 'title' => $record->combo->name,
|
|
|
|
+ 'price' => $record->combo->price
|
|
|
|
+ ];
|
|
|
|
+
|
|
}
|
|
}
|
|
|
|
|
|
private function buyVip($payId)
|
|
private function buyVip($payId)
|
|
{
|
|
{
|
|
/* @var UserVipRecord $record */
|
|
/* @var UserVipRecord $record */
|
|
- $record = UserVipRecord::where('pay_id', $payId)->first();
|
|
|
|
|
|
+ $record = UserVipRecord::with(['combo'])->where('pay_id', $payId)->first();
|
|
if (!$record) {
|
|
if (!$record) {
|
|
return true;
|
|
return true;
|
|
}
|
|
}
|
|
@@ -139,6 +152,12 @@ class PayNoticeController extends Controller
|
|
$record->status = 1;
|
|
$record->status = 1;
|
|
$record->save();
|
|
$record->save();
|
|
|
|
|
|
|
|
+ return [
|
|
|
|
+ 'id' => $record->combo_id,
|
|
|
|
+ 'title' => $record->combo->name,
|
|
|
|
+ 'price' => $record->combo->price
|
|
|
|
+ ];
|
|
|
|
+
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|