OracleBasCustomerService.php 1.1 KB

123456789101112131415161718192021222324252627282930313233343536
  1. <?php
  2. namespace App\Services;
  3. use App\OracleBasCustomer;
  4. Class OracleBasCustomerService
  5. {
  6. /** @var CacheService $cacheService */
  7. private $cacheService;
  8. function __construct(){
  9. $this->cacheService=app('CacheService');
  10. }
  11. public function getWareHouse($customerIDs = null)
  12. {
  13. if(!$customerIDs){
  14. return OracleBasCustomer::query()->selectRaw('Customer_Type,CustomerId,Descr_C')->where('Customer_Type','WH')->get();
  15. }
  16. return OracleBasCustomer::query()
  17. ->selectRaw('Customer_Type,CustomerId,Descr_C')
  18. ->where('Customer_Type','WH')
  19. ->whereIn('CustomerId',$customerIDs)
  20. ->get();
  21. }
  22. public function getCustomers($codes)
  23. {
  24. return $this->cacheService->getOrExecute('OracleBasCustomersAll'.md5(json_encode($codes)),function()use($codes){
  25. return OracleBasCustomer::query()->select('customerid','descr_c')
  26. ->where('customer_type','OW')
  27. ->where('active_flag','Y')
  28. ->whereIn('customerid',$codes)
  29. ->get();
  30. },config('cache.expirations.owners'));
  31. }
  32. }