RefundService.php 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. <?php
  2. namespace app\common\service;
  3. use app\common\model\OrderInfo;
  4. class RefundService extends BaseService {
  5. /** @var OrderInfo */
  6. protected $orderInfo;
  7. /** @var $num int */
  8. protected $num;
  9. /** @var $num_install int */
  10. protected $num_install;
  11. public static function setOrderInfo(OrderInfo $orderInfo){
  12. $ins=new static;
  13. $ins->orderInfo=$orderInfo;
  14. return $ins;
  15. }
  16. /**
  17. * @param int $num
  18. */
  19. public function setNum(int $num)
  20. {
  21. $this->num = $num;
  22. return $this;
  23. }
  24. /**
  25. * @param int $num_install
  26. */
  27. public function setNumInstall(int $num_install)
  28. {
  29. $this->num_install = $num_install;
  30. return $this;
  31. }
  32. public function amount(){
  33. $amount=0;
  34. if($this->num>0){
  35. $amount=bcdiv($this->getOrderInfo('amount_goods_real'),$this->num);
  36. }
  37. $amount_install=0;
  38. if($this->num>0){
  39. $amount_install=bcdiv($this->getOrderInfo('amount_install'),$this->num_install);
  40. }
  41. return [$amount,$amount_install];
  42. }
  43. /**
  44. * @return OrderInfo
  45. */
  46. public function getOrderInfo($field=null)
  47. {
  48. return is_null($field)?$this->orderInfo:$this->orderInfo[$field];
  49. }
  50. }