MerchantContributionDao.php 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. <?php
  2. namespace app\common\dao\system\merchant;
  3. use app\common\dao\BaseDao;
  4. use app\common\model\system\merchant\MerchantContribution;
  5. use app\entity\CommonEntity;
  6. use app\entity\data\merchant\MerchantContributionEntity;
  7. class MerchantContributionDao extends BaseDao
  8. {
  9. protected function getModel(): string
  10. {
  11. return MerchantContribution::class;
  12. }
  13. /**
  14. * 根据商家的让利比例 获取对应的 配置信息
  15. * @param float $profitSharing
  16. * @return CommonEntity
  17. */
  18. public function getMerchantContributionEntityByProfitSharing(float $profitSharing): CommonEntity
  19. {
  20. $data = [];
  21. try {
  22. /** @var MerchantContribution $model */
  23. $model = $this->getModel();
  24. $dataRes = $model::getDB()->select()->toArray();
  25. if (!empty($dataRes)) {
  26. foreach ($dataRes as $item) {
  27. if ($item['start'] <= $profitSharing && $item['end'] >= $profitSharing) {
  28. $data = $item;
  29. break;
  30. }
  31. }
  32. }
  33. } catch (\Exception $e) {
  34. }
  35. return MerchantContributionEntity::newInstance($data);
  36. }
  37. }