Factory.php 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. <?php
  2. // +----------------------------------------------------------------------
  3. // | 萤火商城系统 [ 致力于通过产品和服务,帮助商家高效化开拓市场 ]
  4. // +----------------------------------------------------------------------
  5. // | Copyright (c) 2017~2021 https://www.yiovo.com All rights reserved.
  6. // +----------------------------------------------------------------------
  7. // | Licensed 这不是一个自由软件,不允许对程序代码以任何形式任何目的的再发行
  8. // +----------------------------------------------------------------------
  9. // | Author: 萤火科技 <admin@yiovo.com>
  10. // +----------------------------------------------------------------------
  11. declare (strict_types = 1);
  12. namespace app\api\service\order\source;
  13. use app\common\service\BaseService;
  14. use app\common\enum\order\OrderSource as OrderSourceEnum;
  15. /**
  16. * 商品库存工厂类
  17. * Class Factory
  18. * @package app\common\service\stock
  19. */
  20. class Factory extends BaseService
  21. {
  22. // 订单来源的结算台服务类
  23. private static $class = [
  24. OrderSourceEnum::MASTER => 'Master',
  25. OrderSourceEnum::BARGAIN => 'Master',
  26. OrderSourceEnum::MIAOSHA => 'Master',
  27. OrderSourceEnum::ZA => 'Master',
  28. ];
  29. /**
  30. * 根据订单来源获取商品库存类
  31. * @param int $orderSource
  32. * @return mixed
  33. */
  34. public static function getFactory($orderSource = OrderSourceEnum::MASTER)
  35. {
  36. static $classObj = [];
  37. if (!isset($classObj[$orderSource])) {
  38. $className = __NAMESPACE__ . '\\' . static::$class[$orderSource];
  39. $classObj[$orderSource] = new $className();
  40. }
  41. return $classObj[$orderSource];
  42. }
  43. }