OrderLogic.php 3.4 KB

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