mavg_price.php 773 B

1234567891011121314151617181920212223242526272829303132
  1. <?php
  2. namespace refill;
  3. class mavg_price
  4. {
  5. private $mMchidPrices;
  6. public function __construct()
  7. {
  8. $this->mMchidPrices = [];
  9. }
  10. public function setPrice($mchid,$quality,$card_type,$spec,$avg_price)
  11. {
  12. $key = "{$mchid}-{$quality}-{$card_type}-{$spec}";
  13. if(array_key_exists($key,$this->mMchidPrices)) {
  14. return $this->mMchidPrices[$key];
  15. } else {
  16. $this->mMchidPrices[$key] = $avg_price;
  17. }
  18. }
  19. public function getPrice($mchid,$quality,$card_type,$spec)
  20. {
  21. $key = "{$mchid}-{$quality}-{$card_type}-{$spec}";
  22. if(array_key_exists($key,$this->mMchidPrices)) {
  23. return $this->mMchidPrices[$key];
  24. } else {
  25. return false;
  26. }
  27. }
  28. }