ShopProvider.php 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  1. <?php
  2. /**
  3. * Created by PhpStorm.
  4. * User: shenyang
  5. * Date: 2017/6/20
  6. * Time: 上午10:07
  7. */
  8. namespace app\common\providers;
  9. use app\backend\modules\supervisord\services\Supervisor;
  10. use app\common\facades\Setting;
  11. use app\common\facades\SiteSetting;
  12. use app\common\helpers\SettingCache;
  13. use app\common\modules\express\KDN;
  14. use app\common\managers\ModelExpansionManager;
  15. use app\common\models\BaseModel;
  16. use app\common\modules\sms\SmsService;
  17. use app\common\modules\status\StatusContainer;
  18. use app\common\services\easyWechat\container\PaymentContainer;
  19. use app\common\services\easyWechat\container\WorkContainer;
  20. use app\common\services\easyWechat\container\OfficialAccountContainer;
  21. use app\frontend\modules\coin\CoinManager;
  22. use app\frontend\modules\deduction\DeductionManager;
  23. use app\frontend\modules\goods\services\GoodsDetailManager;
  24. use app\frontend\modules\goods\services\GoodsManager;
  25. use app\common\modules\order\OrderManager;
  26. use app\frontend\modules\payment\managers\PaymentManager;
  27. use Illuminate\Support\ServiceProvider;
  28. use app\common\modules\express\Logistics;
  29. class ShopProvider extends ServiceProvider
  30. {
  31. public function register()
  32. {
  33. $this->app->singleton('SettingCache', function () {
  34. return new SettingCache();
  35. });
  36. $this->app->singleton('supervisor', function () {
  37. $supervisord = SiteSetting::get('supervisor');
  38. if ($supervisord['service_type'] == 1) {
  39. $ip = $supervisord['service'];
  40. $host_num = count($supervisord['service']);
  41. } elseif ($supervisord['service_type'] == 2) {
  42. $ip = ['http://localhost'];
  43. $host_num = count($supervisord['service']);
  44. } else {
  45. $ip = $supervisord['address']['ip'] ?: 'http://127.0.0.1';
  46. $ip = [$ip];
  47. $host_num = 1;
  48. }
  49. return new Supervisor($ip, 9001,$host_num);
  50. });
  51. $this->app->singleton('ModelExpansionManager', function () {
  52. return new ModelExpansionManager();
  53. });
  54. $this->app->singleton('CoinManager', function () {
  55. return new CoinManager();
  56. });
  57. $this->app->singleton('DeductionManager', function () {
  58. return new DeductionManager();
  59. });
  60. $this->app->singleton('GoodsManager', function () {
  61. return new GoodsManager();
  62. });
  63. $this->app->singleton('OrderManager', function () {
  64. return new OrderManager();
  65. });
  66. //商品挂件
  67. $this->app->singleton('GoodsWidgetContainer', function () {
  68. return new \app\backend\modules\goods\widget\manage\GoodsWidgetContainer();
  69. });
  70. //购物车容器
  71. $this->app->singleton('CartContainer', function () {
  72. return new \app\frontend\modules\cart\manager\CartContainer();
  73. });
  74. $this->app->singleton('StatusContainer', function () {
  75. return new StatusContainer();
  76. });
  77. $this->app->singleton('express', function () {
  78. return new KDN(Setting::get('shop.express_info.KDN.eBusinessID'), Setting::get('shop.express_info.KDN.appKey'), config('app.express.KDN.reqURL'));
  79. });
  80. $this->app->singleton('logistics', function () {
  81. return new Logistics();
  82. });
  83. $this->app->singleton('sms', function () {
  84. return new SmsService();
  85. });
  86. $this->app->singleton('GoodsDetail', function () {
  87. return new GoodsDetailManager();
  88. });
  89. $this->app->singleton('BusinessMsgNotice', function () {
  90. return new \business\common\notice\BusinessNoticeManager();
  91. });
  92. // $this->app->bind('external_contact', function ($app) {
  93. // return new \app\common\services\easyWechat\Client($app);
  94. // });
  95. }
  96. public function boot()
  97. {
  98. }
  99. }