IndexController.php 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131
  1. <?php
  2. namespace App\Http\Controllers\V1;
  3. use App\libs\wechat\auth\WeChat;
  4. use App\Models\Config;
  5. use App\Models\Help;
  6. use App\Models\Order;
  7. use App\Models\PaymentConfig;
  8. use App\Models\Region;
  9. use App\Models\TaskList;
  10. use Illuminate\Http\Request;
  11. use Illuminate\Support\Facades\Redis;
  12. class IndexController extends Controller
  13. {
  14. public function uploadOrder(){
  15. $order = Order::query()->where('id',65)->first();
  16. $res = WeChat::Mini()->upload_shipping_info($order->wx_order,$order->order,'oLaR66yItDcje4tcY6E3MgXA65Zs');
  17. var_dump($res);
  18. }
  19. public function getServiceConfig()
  20. {
  21. $service_phone = Config::query()->where('key', 'service_phone')->first();
  22. $service_wx = Config::query()->where('key', 'service_wx')->first();
  23. $service_qrcode = Config::query()->where('key', 'service_qrcode')->first();
  24. $about = Config::query()->where('key', 'about')->first();
  25. $push_promotion = Config::query()->where('key', 'push_promotion')->first();
  26. return $this->success(['service_qrcode' => $service_qrcode, 'service_phone' => $service_phone, 'service_wx' => $service_wx, 'about' => $about, 'push' => $push_promotion]);
  27. }
  28. // 隐私政策
  29. public function privacyPolice()
  30. {
  31. $info = Config::query()->where('key', 'privacy')->first();
  32. return $this->success($info);
  33. }
  34. public function getConfigByKey()
  35. {
  36. $key = \request()->input('key', '');
  37. $result = Config::query()->where('key', $key)->first();
  38. return $this->success($result);
  39. }
  40. // 用户协议
  41. public function userAgreement()
  42. {
  43. $info = Config::query()->where('key', 'agreement')->first();
  44. return $this->success($info);
  45. }
  46. // 用户协议
  47. public function payConfig()
  48. {
  49. $info = PaymentConfig::query()->where('state', 1)->get();
  50. return $this->success($info);
  51. }
  52. /**
  53. * 获取精选.
  54. *
  55. * @return \Illuminate\Http\JsonResponse
  56. */
  57. public function getHandpick()
  58. {
  59. // $size = \request()->input('size',15);
  60. // var_dump($size);
  61. $result = TaskList::query()->where('is_handpick', 1)->orderByDesc('sort')->paginate();
  62. return $this->success($result);
  63. }
  64. // 帮助类型
  65. public function helpList()
  66. {
  67. $list = Help::query()->select('id', 'title')->get();
  68. if ($list->isEmpty()) {
  69. return [];
  70. }
  71. $list = $list->toArray();
  72. return $this->success($list);
  73. }
  74. // 帮助类答案
  75. public function answer(Request $request)
  76. {
  77. $info = Help::query()->where('id', $request->id)->first();
  78. $info->look_num = $info->look_num + 1;
  79. $info->save();
  80. return $this->success($info);
  81. }
  82. // 全国地区
  83. public function allRegion()
  84. {
  85. $regionList = Redis::get('all_region');
  86. if (!empty($regionList)) {
  87. return $this->success(json_decode($regionList, true));
  88. }
  89. $list = Region::query()
  90. ->where('type', 1)
  91. ->select('code', 'full_name')
  92. ->get()
  93. ->toArray();
  94. foreach ($list as $key => $val) {
  95. $cityList = Region::query()->where('parent_code', $val['code'])->select('code', 'full_name')->get()->toArray();
  96. foreach ($cityList as $k => $v) {
  97. $areaList = Region::query()->where('parent_code', $v['code'])->select('code', 'full_name')->get()->toArray();
  98. $v['area_list'] = $areaList;
  99. $cityList[$k] = $v;
  100. }
  101. $val['city_list'] = $cityList;
  102. $list[$key] = $val;
  103. }
  104. Redis::setex('all_region', 24 * 3600, json_encode($list));
  105. return $this->success($list);
  106. }
  107. }