CpService.php 913 B

1234567891011121314151617181920212223242526272829303132
  1. <?php
  2. namespace bizGhs\cp\services;
  3. use bizGhs\base\services\BaseService;
  4. use bizGhs\cp\classes\CpClass;
  5. use bizGhs\shop\classes\ShopClass;
  6. class CpService extends BaseService
  7. {
  8. public static $baseFile = '\bizGhs\cp\classes\CpClass';
  9. //从平台导入产品 ssh 20240227
  10. public static function addPtCp($ptCp, $currentShop)
  11. {
  12. $shopCp = CpClass::importPtCp($ptCp, $currentShop);
  13. if (isset($currentShop->default) && $currentShop->default == 1) {
  14. $sjId = $currentShop->sjId ?? 0;
  15. $shopList = ShopClass::getAllByCondition(['sjId' => $sjId], null, '*', null, true);
  16. foreach ($shopList as $shop) {
  17. $shopId = $shop->id ?? 0;
  18. if ($shopId == $currentShop->id) {
  19. continue;
  20. }
  21. CpClass::importPtCp($ptCp, $shop);
  22. }
  23. }
  24. return $shopCp;
  25. }
  26. }