| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116 |
- <?php
- namespace App\Http\logic\api;
- use App\Facade\TableName;
- use App\Game\GlobalUserInfo;
- use Illuminate\Support\Facades\DB;
- use Illuminate\Support\Facades\Redis;
- class OrderLogic extends BaseApiLogic
- {
- // 创建订单
- public function create_order($data_arr, $UserID, $type = 0, $payment_code = 'SerPayMent')
- {
- $body = [
- 'app_id' => 1,
- 'user_id' => $UserID,
- 'order_sn' => $data_arr['custOrderNo'],
- 'amount' => $data_arr['payAmt'],
- 'order_title' => $data_arr['goodsName'],
- 'payment_code' => $payment_code,
- 'payment_name' => '创建收款单',
- 'remarks' => 'pay_order',
- 'created_at' => date('Y-m-d H:i:s'),
- 'type' => $type,
- 'GameID' => 0,
- 'UserID' => $UserID
- ];
- $order = DB::table('agent.dbo.order')->insert($body);
- if (!$order) {
- $this->error = '订单创建失败';
- return false;
- }
- return true;
- }
- public function create($data, $userID, $type = 0)
- {
- $body = [
- 'app_id' => 1,
- 'user_id' => $userID,
- 'order_sn' => $data['pay_orderid'],
- 'amount' => $data['pay_amount'],
- 'order_title' => $data['pay_productname'],
- 'payment_code' => 'pay_order',
- 'payment_name' => '创建收款单',
- 'remarks' => 'pay_order',
- 'created_at' => date('Y-m-d H:i:s'),
- 'type' => $type,
- 'GameID' => 0,
- 'UserID' => $userID
- ];
- $order = DB::table('agent.dbo.order')->insert($body);
- if (!$order) {
- $this->error = '订单创建失败';
- return false;
- }
- return true;
- }
- // 创建订单
- public function orderCreate($order_sn, $amount, $payment_code, $userID, $order_title = '',$GiftsID = 0,$AdId = '',$eventType = 2)
- {
- if (empty($AdId) || $AdId == 'undefined') {
- $redis = Redis::connection();
- $AdId = $redis->get('user_ad_'.$userID);
- }
- // $Channel = DB::connection('write')->table(TableName::QPAccountsDB() . 'AccountsInfo')
- // ->where('UserID', $userID)->select('Channel')->first()->Channel;
- $userInfo = GlobalUserInfo::getGameUserInfo('UserID',$userID);
- $Channel = $userInfo?$userInfo->Channel:100;
- $RegisterDate = $userInfo?$userInfo->RegisterDate:date('Y-m-d');
- $body = [
- 'app_id' => 1,
- 'user_id' => $userID,
- 'order_sn' => $order_sn,
- 'amount' => $amount,
- 'order_title' => empty($order_title) ? '1' : $order_title,
- 'payment_code' => $payment_code,
- 'payment_name' => '创建收款单',
- 'remarks' => 'pay_order',
- 'created_at' => date('Y-m-d H:i:s'),
- 'type' => 0,
- 'GameID' => 0,
- 'UserID' => $userID,
- 'GiftsID' => $GiftsID,
- 'AdId' => $AdId,
- 'eventType' => $eventType,
- 'Channel'=>$Channel
- ];
- $order = DB::connection('write')->table('agent.dbo.order')->insert($body);
- if (!$order) {
- $this->error = 'Payment error_2';
- return false;
- }
- $RecordPlatformDataModel = new \App\Models\RecordPlatformData();
- $RecordPlatformDataModel->PayRequestToday($Channel,$RegisterDate);
- return true;
- }
- }
|