Config.php 3.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. <?php
  2. /**
  3. * @copyright Copyright (c) 2017 https://www.sapixx.com All rights reserved.
  4. * @license Licensed (http://www.apache.org/licenses/LICENSE-2.0).
  5. * @author pillar<ltmn@qq.com>
  6. * 获取配置
  7. */
  8. namespace app\allwin\controller\api\v4;
  9. use app\allwin\controller\api\Base;
  10. use app\allwin\model\AllwinConfig;
  11. use app\allwin\model\Vip;
  12. use app\allwin\model\AllwinInfoMp;
  13. use app\allwin\model\StoreWorker;
  14. use app\allwin\model\Levels;
  15. class Config extends Base{
  16. /**
  17. * 获取应用配置
  18. **/
  19. public function index(){
  20. $info = AllwinConfig::getConfig($this->miniapp->id);
  21. if(!isset($info)) {
  22. return enjson(403,'应用未配置');
  23. }
  24. $article = json_decode($info->article);
  25. $config['service_telephone'] = $info->service_telephone ??'';
  26. $config['shore_img'] = $article->shore_img ??'';
  27. $config['shore_text'] = $article->shore_text ??'';
  28. $config['search_tip'] = $article->search_tip ??'';
  29. $config['index_more'] = $article->index_more ??'';
  30. $config['index_shop_title'] = $article->index_shop_title ??'';
  31. //会员页面文字
  32. $config['vip_front_text'] = $article->vip_front_text ??'';
  33. $config['vip_behind_text'] = $article->vip_behind_text ??'';
  34. //优选分享文案
  35. $config['shop_share_text'] = $article->shop_share_text ??'';
  36. $config['shop_share_img'] = $article->shop_share_img ??'';
  37. //好店分享文案
  38. $config['store_share_text'] = $article->store_share_text ??'';
  39. $config['store_share_img'] = $article->store_share_img ??'';
  40. //判断是否会员
  41. $config['user_card'] = ['title' =>$article->user_card->title,'page' =>$article->user_card->page,'type' => $article->user_card->type];
  42. $config['is_vip'] = 0;
  43. $config['is_store_manage'] = 0;
  44. //判断是否城市号
  45. $config['is_info_vip'] = 0;
  46. if($this->user){
  47. $is_vip = Vip::where(['user_id' => $this->user->id,'state' => 1,'is_lock' => 0])->field('vipcard_id,id')->find();
  48. if($is_vip){
  49. $config['is_vip'] = 1;
  50. $config['vip_name'] = $is_vip->vipcard->name;
  51. $config['user_card'] = ['page' =>'/pages/money/index','type' => 'navigate'];
  52. }
  53. $is_info_vip = AllwinInfoMp::where(['uid' => $this->user->id,'is_vip' => 1,'is_lock' => 0])->count();
  54. if($is_info_vip){
  55. $config['is_info_vip'] = 1;
  56. $config['info_vip'] = '蓝V认证';
  57. }
  58. $is_store_manage = StoreWorker::where(['member_miniapp_id' => $this->miniapp_id,'uid' => $this->user->id,'is_cashier' => 1])->find();
  59. if($is_store_manage){
  60. if($is_store_manage->store->is_lock == 0){
  61. $config['is_store_manage'] = 1;
  62. }
  63. }
  64. }
  65. return enjson(200,'应用配置',$config);
  66. }
  67. /**
  68. * 读取我的推荐用户
  69. * @return void
  70. */
  71. public function levelUser(){
  72. $param['page'] = $this->request->param('page/d');
  73. $param['signkey'] = $this->request->param('signkey');
  74. $param['sign'] = $this->request->param('sign');
  75. $rel = $this->apiSign($param);
  76. if($rel['code'] != 200){
  77. return enjson($rel['code'],'签名验证失败');
  78. }
  79. if(!$this->user) {
  80. return enjson(204);
  81. }
  82. $info = Levels::levelUser($this->user->id,[1,2]);
  83. if($info){
  84. $num = Levels::where(['parent_id' => $this->user->id,'level' => [1,2]])->count();
  85. return enjson(200,'成功',['list'=>$info,'num' => $num]);
  86. }
  87. return enjson(204);
  88. }
  89. }