|
|
|
@ -14,6 +14,8 @@ namespace app\common\repositories\system; |
|
|
|
|
use app\common\dao\store\order\StoreOrderDao; |
|
|
|
|
use app\common\dao\system\HuitongDao; |
|
|
|
|
use app\common\repositories\BaseRepository; |
|
|
|
|
use app\common\repositories\store\order\StoreOrderBaseRepository; |
|
|
|
|
use app\common\repositories\user\UserAssetsRepository; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
@ -34,4 +36,51 @@ class HuitongRepository extends BaseRepository |
|
|
|
|
$this->dao = $dao; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public function dayStatistics() |
|
|
|
|
{ |
|
|
|
|
/** |
|
|
|
|
* @var UserAssetsRepository $userAssets |
|
|
|
|
*/ |
|
|
|
|
$userAssets = app()->make(UserAssetsRepository::class); |
|
|
|
|
$config = $userAssets->getConfig(); |
|
|
|
|
/** |
|
|
|
|
* @var StoreOrderBaseRepository $orderBase |
|
|
|
|
*/ |
|
|
|
|
$orderBase = app()->make(StoreOrderBaseRepository::class); |
|
|
|
|
$count = $orderBase->getTotalBase(); |
|
|
|
|
if (empty($count)) { |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
$base = round($config['huitong_add'] * $count / 100, 2); |
|
|
|
|
if ($base < 0.01) { |
|
|
|
|
$base = 0.01; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
$last = $this->dao->getLastHuitong(); |
|
|
|
|
if (empty($last)) { |
|
|
|
|
$huitong = 1; |
|
|
|
|
} else { |
|
|
|
|
$huitong = $last['current']; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
$totalHuitong = $userAssets->getTotalHuitong(); |
|
|
|
|
|
|
|
|
|
$add = round($base / $totalHuitong, 2); |
|
|
|
|
if ($add < 0.01) { |
|
|
|
|
$add = 0.01; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
$this->dao->create([ |
|
|
|
|
'date' => date('Y-m-d'), |
|
|
|
|
'current' => $huitong + $add, |
|
|
|
|
'ext' => json_encode(array( |
|
|
|
|
'base' => $base, |
|
|
|
|
'huitong' => $huitong, |
|
|
|
|
'total' => $totalHuitong, |
|
|
|
|
)), |
|
|
|
|
]); |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|