IndexController.php 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125
  1. <?php
  2. /**
  3. * Created by PhpStorm.
  4. * Author: 芸众商城 www.yunzshop.com
  5. * Date: 19/03/2017
  6. * Time: 00:48
  7. */
  8. namespace app\backend\controllers;
  9. use app\backend\modules\charts\models\Supplier;
  10. use app\backend\modules\survey\controllers\SurveyController;
  11. use app\common\components\BaseController;
  12. use app\common\models\user\WeiQingUsers;
  13. use app\common\services\CollectHostService;
  14. use app\common\services\PermissionService;
  15. use Illuminate\Support\Facades\DB;
  16. use Yunshop\Merchant\common\models\Merchant;
  17. use Yunshop\StoreCashier\store\admin\StoreIndexController;
  18. use Yunshop\Supplier\supplier\controllers\SupplierIndexController;
  19. use Yunshop\StoreCashier\common\models\Store;
  20. class IndexController extends BaseController
  21. {
  22. protected $isPublic = true;
  23. public function index()
  24. {
  25. $uid = \YunShop::app()->uid;
  26. $user = WeiQingUsers::getUserByUid($uid)->first();
  27. if(PermissionService::isFounder() or PermissionService::isOwner() or PermissionService::isManager()){
  28. return redirect(yzWebFullUrl('survey.survey.index'));
  29. }
  30. if (app('plugins')->isEnabled('store-cashier')) {
  31. $store = Store::getStoreByUserUid($uid)->first();
  32. if ($store && $user) {
  33. return StoreIndexController::index();
  34. }
  35. }
  36. if (app('plugins')->isEnabled('supplier')) {
  37. $supplier = Supplier::getSupplierByUid($uid)->first();
  38. if ($supplier && $user) {
  39. return SupplierIndexController::index();
  40. }
  41. }
  42. if (app('plugins')->isEnabled('merchant')) {
  43. $merchant = Merchant::select()->where('user_uid', $uid)->first();
  44. if ($merchant) {
  45. if ($merchant->is_center == 1) {
  46. return \Yunshop\Merchant\merchant\admin\IndexController::center();
  47. } else {
  48. return \Yunshop\Merchant\merchant\admin\IndexController::staff();
  49. }
  50. }
  51. }
  52. if (app('plugins')->isEnabled('work-wechat') && app('plugins')->isEnabled('work-wechat-platform')) {
  53. if($user['type']==3){
  54. //是企业微信管理员,跳转到企业微信管理首页
  55. $crop_info = \Yunshop\WorkWechatPlatform\common\models\Crop::getByUid($uid);
  56. $crop_id = $crop_info->id;
  57. if($crop_id){
  58. //当前用户是企业微信总的管理员
  59. \Yunshop\WorkWechatPlatform\common\utils\CropUtils::setCropId($crop_id);
  60. \Yunshop\WorkWechatPlatform\common\utils\CropUtils::setCropName($crop_info->name);
  61. return redirect(\Yunshop\WorkWechat\common\utils\Url::absoluteManageIndexUrl());
  62. }else{
  63. $work_wechat_user = \Yunshop\WorkWechat\common\models\WorkWechatUser::getOneByUid($uid);
  64. if($work_wechat_user->id){
  65. //当前用户是企业微信操作员
  66. $crop_id = $work_wechat_user->crop_id;
  67. \Yunshop\WorkWechatPlatform\common\utils\CropUtils::setCropId($crop_id);
  68. \Yunshop\WorkWechatPlatform\common\utils\CropUtils::setCropName($crop_info->name);
  69. return redirect(\Yunshop\WorkWechat\common\utils\Url::absoluteManageIndexUrl());
  70. }
  71. }
  72. }
  73. }
  74. (new CollectHostService(request()->getHttpHost()))->handle();
  75. $designer = (new \app\backend\controllers\PluginsController)->canAccess('designer');
  76. if (is_null($designer)) {
  77. $designer = (new \app\backend\controllers\PluginsController)->canAccess('decorate');
  78. $decorate = \app\common\services\MenuService::canAccess('decorate');
  79. } else {
  80. $decorate = yzWebFullUrl($designer);
  81. }
  82. return view('index',['designer' => $designer,'decorate'=>$decorate])->render();
  83. }
  84. public function changeField()
  85. {
  86. $sql = 'ALTER TABLE `' . DB::getTablePrefix() . 'mc_members` MODIFY `pay_password` varchar(30) NOT NULL DEFAULT 0';
  87. try {
  88. DB::select($sql);
  89. echo '数据已修复';
  90. } catch (\Exception $e) {
  91. echo $e->getMessage();
  92. }
  93. }
  94. public function changeAgeField()
  95. {
  96. $sql = 'ALTER TABLE `' . DB::getTablePrefix() . 'mc_members` MODIFY `age` tinyint(3) NOT NULL DEFAULT 0';
  97. try {
  98. DB::select($sql);
  99. echo '数据已修复';
  100. } catch (\Exception $e) {
  101. echo $e->getMessage();
  102. }
  103. }
  104. }