SettingLogic.php 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  1. <?php
  2. // +----------------------------------------------------------------------
  3. // | likeshop100%开源免费商用商城系统
  4. // +----------------------------------------------------------------------
  5. // | 欢迎阅读学习系统程序代码,建议反馈是我们前进的动力
  6. // | 开源版本可自由商用,可去除界面版权logo
  7. // | 商业版本务必购买商业授权,以免引起法律纠纷
  8. // | 禁止对系统程序代码以任何目的,任何形式的再发布
  9. // | gitee下载:https://gitee.com/likeshop_gitee
  10. // | github下载:https://github.com/likeshop-github
  11. // | 访问官网:https://www.likeshop.cn
  12. // | 访问社区:https://home.likeshop.cn
  13. // | 访问手册:http://doc.likeshop.cn
  14. // | 微信公众号:likeshop技术社区
  15. // | likeshop团队 版权所有 拥有最终解释权
  16. // +----------------------------------------------------------------------
  17. // | author: likeshopTeam
  18. // +----------------------------------------------------------------------
  19. namespace app\businessapi\logic;
  20. use app\common\model\Admin;
  21. use app\common\service\ConfigService;
  22. use app\common\service\FileService;
  23. use app\common\service\RegionService;
  24. use think\facade\Config;
  25. /**
  26. * 配置逻辑类
  27. * Class SettingController
  28. * @package app\businessapi\controller
  29. */
  30. class SettingLogic
  31. {
  32. /**
  33. * @notes 获取店铺配置
  34. * @return array
  35. * @author cjhao
  36. * @date 2023/2/16 14:35
  37. */
  38. public function getShopConfig()
  39. {
  40. $config = [
  41. 'name' => ConfigService::get('shop', 'name'),
  42. 'logo' => ConfigService::get('shop', 'logo'),
  43. 'status' => ConfigService::get('shop', 'status'),
  44. 'mall_contact' => ConfigService::get('shop', 'mall_contact', ''),
  45. 'mall_contact_mobile' => ConfigService::get('shop', 'mall_contact_mobile', ''),
  46. 'return_contact' => ConfigService::get('shop', 'return_contact', ''),
  47. 'return_contact_mobile' => ConfigService::get('shop', 'return_contact_mobile', ''),
  48. 'return_province' => ConfigService::get('shop', 'return_province', ''),
  49. 'return_city' => ConfigService::get('shop', 'return_city', ''),
  50. 'return_district' => ConfigService::get('shop', 'return_district', ''),
  51. 'return_address' => ConfigService::get('shop', 'return_address', ''),
  52. ];
  53. $config['logo'] = FileService::getFileUrl($config['logo']);
  54. $config['region_address'] = RegionService::getAddress([$config['return_province'], $config['return_city'], $config['return_district']]);
  55. $config['address'] = $config['region_address'].$config['return_address'];
  56. return $config;
  57. }
  58. /**
  59. * @notes 设置店铺配置
  60. * @param $params
  61. * @author cjhao
  62. * @date 2023/2/16 14:39
  63. */
  64. public function setShopConfig($params)
  65. {
  66. $params['logo'] = FileService::setFileUrl($params['logo']);
  67. ConfigService::set('shop','name', $params['name']);
  68. ConfigService::set('shop','logo', $params['logo']);
  69. ConfigService::set('shop','status', $params['status']);
  70. ConfigService::set('shop','mall_contact', $params['mall_contact']);
  71. ConfigService::set('shop','mall_contact_mobile', $params['mall_contact_mobile']);
  72. ConfigService::set('shop','return_contact', $params['return_contact']);
  73. ConfigService::set('shop','return_contact_mobile', $params['return_contact_mobile']);
  74. ConfigService::set('shop','return_province', $params['return_province']);
  75. ConfigService::set('shop','return_city', $params['return_city']);
  76. ConfigService::set('shop','return_district', $params['return_district']);
  77. ConfigService::set('shop','return_address', $params['return_address']);
  78. return true;
  79. }
  80. /**
  81. * @notes 获取管理员信息
  82. * @param $adminId
  83. * @return array
  84. * @throws \think\db\exception\DataNotFoundException
  85. * @throws \think\db\exception\DbException
  86. * @throws \think\db\exception\ModelNotFoundException
  87. * @author cjhao
  88. * @date 2023/2/16 14:48
  89. */
  90. public function getAdminInfo($adminId)
  91. {
  92. return Admin::field('id,name,avatar')->find($adminId)->toArray();
  93. }
  94. /**
  95. * @notes 重置密码
  96. * @param $params
  97. * @param $adminId
  98. * @return bool|string
  99. * @author cjhao
  100. * @date 2023/2/16 14:55
  101. */
  102. public function resetPassword($params,$adminId)
  103. {
  104. try{
  105. $passwordSalt = Config::get('project.unique_identification');
  106. $password = create_password($params['password'], $passwordSalt);
  107. Admin::update(['password'=>$password],['id'=>$adminId]);
  108. return true;
  109. }catch (\Exception $e) {
  110. return $e->getMessage();
  111. }
  112. }
  113. }