OrderLogic.php 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  1. <?php
  2. namespace App\Http\logic\api;
  3. use App\Facade\TableName;
  4. use App\Game\GlobalUserInfo;
  5. use Illuminate\Support\Facades\DB;
  6. use Illuminate\Support\Facades\Redis;
  7. class OrderLogic extends BaseApiLogic
  8. {
  9. // 创建订单
  10. public function create_order($data_arr, $UserID, $type = 0, $payment_code = 'SerPayMent')
  11. {
  12. $body = [
  13. 'app_id' => 1,
  14. 'user_id' => $UserID,
  15. 'order_sn' => $data_arr['custOrderNo'],
  16. 'amount' => $data_arr['payAmt'],
  17. 'order_title' => $data_arr['goodsName'],
  18. 'payment_code' => $payment_code,
  19. 'payment_name' => '创建收款单',
  20. 'remarks' => 'pay_order',
  21. 'created_at' => date('Y-m-d H:i:s'),
  22. 'type' => $type,
  23. 'GameID' => 0,
  24. 'UserID' => $UserID
  25. ];
  26. $order = DB::table('agent.dbo.order')->insert($body);
  27. if (!$order) {
  28. $this->error = '订单创建失败';
  29. return false;
  30. }
  31. return true;
  32. }
  33. public function create($data, $userID, $type = 0)
  34. {
  35. $body = [
  36. 'app_id' => 1,
  37. 'user_id' => $userID,
  38. 'order_sn' => $data['pay_orderid'],
  39. 'amount' => $data['pay_amount'],
  40. 'order_title' => $data['pay_productname'],
  41. 'payment_code' => 'pay_order',
  42. 'payment_name' => '创建收款单',
  43. 'remarks' => 'pay_order',
  44. 'created_at' => date('Y-m-d H:i:s'),
  45. 'type' => $type,
  46. 'GameID' => 0,
  47. 'UserID' => $userID
  48. ];
  49. $order = DB::table('agent.dbo.order')->insert($body);
  50. if (!$order) {
  51. $this->error = '订单创建失败';
  52. return false;
  53. }
  54. return true;
  55. }
  56. // 创建订单
  57. public function orderCreate($order_sn, $amount, $payment_code, $userID, $order_title = '',$GiftsID = 0,$AdId = '',$eventType = 2)
  58. {
  59. if (empty($AdId) || $AdId == 'undefined') {
  60. $redis = Redis::connection();
  61. $AdId = $redis->get('user_ad_'.$userID);
  62. }
  63. // $Channel = DB::connection('write')->table(TableName::QPAccountsDB() . 'AccountsInfo')
  64. // ->where('UserID', $userID)->select('Channel')->first()->Channel;
  65. $userInfo = GlobalUserInfo::getGameUserInfo('UserID',$userID);
  66. $Channel = $userInfo?$userInfo->Channel:100;
  67. $RegisterDate = $userInfo?$userInfo->RegisterDate:date('Y-m-d');
  68. $body = [
  69. 'app_id' => 1,
  70. 'user_id' => $userID,
  71. 'order_sn' => $order_sn,
  72. 'amount' => $amount,
  73. 'order_title' => empty($order_title) ? '1' : $order_title,
  74. 'payment_code' => $payment_code,
  75. 'payment_name' => '创建收款单',
  76. 'remarks' => 'pay_order',
  77. 'created_at' => date('Y-m-d H:i:s'),
  78. 'type' => 0,
  79. 'GameID' => 0,
  80. 'UserID' => $userID,
  81. 'GiftsID' => $GiftsID,
  82. 'AdId' => $AdId,
  83. 'eventType' => $eventType,
  84. 'Channel'=>$Channel
  85. ];
  86. $order = DB::connection('write')->table('agent.dbo.order')->insert($body);
  87. if (!$order) {
  88. $this->error = 'Payment error_2';
  89. return false;
  90. }
  91. $RecordPlatformDataModel = new \App\Models\RecordPlatformData();
  92. $RecordPlatformDataModel->PayRequestToday($Channel,$RegisterDate);
  93. return true;
  94. }
  95. }