海南旅游SAAS
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

99 lines
2.7 KiB

4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
  1. <?php
  2. namespace App\Http\Controllers\Api;
  3. use App\Common\OrderStatus;
  4. use App\Models\Agent;
  5. use App\Models\Order;
  6. use App\Models\OrderProductItem;
  7. use App\Models\Product;
  8. use App\Service\SmsService;
  9. use Illuminate\Support\Facades\Cache;
  10. use Illuminate\Support\Facades\DB;
  11. /**
  12. * 仅用于测试
  13. * Class TController
  14. * @package App\Http\Controllers\Api
  15. */
  16. class TestController
  17. {
  18. public function index()
  19. {
  20. $orders = Order::query()
  21. ->where('status', OrderStatus::PAY_EARNEST)
  22. ->get();
  23. $sms = new SmsService();
  24. foreach ($orders as $order) {
  25. if (!empty($order->mobile)) {
  26. $sms->send(
  27. 'pay',
  28. [
  29. $order->order_no,
  30. '定金/订金',
  31. $order->timeout,
  32. '定金/订金',
  33. '小程序'
  34. ],
  35. [
  36. $order->mobile
  37. ],
  38. );
  39. }
  40. }
  41. return 2;
  42. }
  43. /**
  44. * 模拟登录
  45. * @param $user_id
  46. * @return string
  47. */
  48. private function login($user_id)
  49. {
  50. $token_key = md5($user_id . env('APP_KEY'));
  51. Cache::put($token_key, $user_id);
  52. return $token_key;
  53. }
  54. public function index2()
  55. {
  56. $handle = fopen(base_path('area.txt'), 'r');
  57. if ($handle) {
  58. DB::statement('TRUNCATE `areas`;');
  59. while (($line = fgets($handle, 4096)) !== false) {
  60. $line = trim($line);
  61. $last2 = substr($line, 4, 2); //区划码后2位
  62. $front2 = substr($line, 0, 2); //区划码前2位
  63. $front4 = substr($line, 0, 4); //区划码前4位
  64. //判断是否是直辖市,是直辖市则再插入一次上条记录作为二级联动
  65. if (isset($last4, $arr, $parent_arr[$front2]) && $last4 == '0000' && $last2 != '00') {
  66. $insert_id = DB::table('areas')->insertGetId(['code' => $arr[0], 'pid' => $parent_arr[$front2], 'name' => $arr[1]]);
  67. $parent_arr[$front4] = $insert_id;
  68. //对直辖市不做省直辖县处理,如:重庆市
  69. $parent_arr[$front2] = $insert_id;
  70. }
  71. $last4 = substr($line, 2, 4); //区划码后4位
  72. $arr = preg_split('/\s+/', $line);
  73. if (count($arr) !== 2) continue;
  74. if ($last4 == '0000') {
  75. $insert_id = DB::table('areas')->insertGetId(['code' => $arr[0], 'pid' => 0, 'name' => $arr[1]]);
  76. $parent_arr[$front2] = $insert_id;
  77. } else if ($last2 == '00') {
  78. $insert_id = DB::table('areas')->insertGetId(['code' => $arr[0], 'pid' => $parent_arr[$front2], 'name' => $arr[1]]);
  79. $parent_arr[$front4] = $insert_id;
  80. } else {
  81. //考虑到省直辖县级市情况,如:海南琼海市、湖北仙桃市等,但重庆市的省辖县除外(已在上面判断直辖市逻辑中做处理)
  82. $parent_id = $parent_arr[$front4] ?? $parent_arr[$front2];
  83. DB::table('areas')->insertGetId(['code' => $arr[0], 'pid' => $parent_id, 'name' => $arr[1]]);
  84. }
  85. }
  86. } else {
  87. return 'open file fail!';
  88. }
  89. return 'success';
  90. }}