| 123456789101112131415161718192021222324252627282930313233343536373839404142434445 |
- <?php
- namespace app\common\dao\system\merchant;
- use app\common\dao\BaseDao;
- use app\common\model\system\merchant\MerchantContribution;
- use app\entity\CommonEntity;
- use app\entity\data\merchant\MerchantContributionEntity;
- class MerchantContributionDao extends BaseDao
- {
- protected function getModel(): string
- {
- return MerchantContribution::class;
- }
- /**
- * 根据商家的让利比例 获取对应的 配置信息
- * @param float $profitSharing
- * @return CommonEntity
- */
- public function getMerchantContributionEntityByProfitSharing(float $profitSharing): CommonEntity
- {
- $data = [];
- try {
- /** @var MerchantContribution $model */
- $model = $this->getModel();
- $dataRes = $model::getDB()->select()->toArray();
- if (!empty($dataRes)) {
- foreach ($dataRes as $item) {
- if ($item['start'] <= $profitSharing && $item['end'] >= $profitSharing) {
- $data = $item;
- break;
- }
- }
- }
- } catch (\Exception $e) {
- }
- return MerchantContributionEntity::newInstance($data);
- }
- }
|