|
@@ -0,0 +1,71 @@
|
|
|
|
|
+<?php
|
|
|
|
|
+
|
|
|
|
|
+// +----------------------------------------------------------------------
|
|
|
|
|
+// | CRMEB [ CRMEB赋能开发者,助力企业发展 ]
|
|
|
|
|
+// +----------------------------------------------------------------------
|
|
|
|
|
+// | Copyright (c) 2016~2024 https://www.crmeb.com All rights reserved.
|
|
|
|
|
+// +----------------------------------------------------------------------
|
|
|
|
|
+// | Licensed CRMEB并不是自由软件,未经许可不能去掉CRMEB相关版权
|
|
|
|
|
+// +----------------------------------------------------------------------
|
|
|
|
|
+// | Author: CRMEB Team <admin@crmeb.com>
|
|
|
|
|
+// +----------------------------------------------------------------------
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+namespace app\common\repositories\user;
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+use app\common\dao\user\AwardIntegralPriceDao;
|
|
|
|
|
+use app\common\repositories\BaseRepository;
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+class AwardIntegralPriceRepository extends BaseRepository
|
|
|
|
|
+{
|
|
|
|
|
+ /**
|
|
|
|
|
+ * @var AwardIntegralPriceDao
|
|
|
|
|
+ */
|
|
|
|
|
+ protected $dao;
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * UserSignRepository constructor.
|
|
|
|
|
+ * @param AwardIntegralPriceDao $dao
|
|
|
|
|
+ */
|
|
|
|
|
+ public function __construct(AwardIntegralPriceDao $dao)
|
|
|
|
|
+ {
|
|
|
|
|
+ $this->dao = $dao;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ public function awardIntegralPrice($day = '')
|
|
|
|
|
+ {
|
|
|
|
|
+ if (!$day) {
|
|
|
|
|
+ $day = date('Y-m-d');
|
|
|
|
|
+ }
|
|
|
|
|
+ if ($info = $this->dao->search(['day' => date('Y-m-d')])->find()) {
|
|
|
|
|
+ return $info->toArray();
|
|
|
|
|
+ }
|
|
|
|
|
+ $yesterday_price = $this->dao->search(['day' => date('Y-m-d', strtotime('-1 day', strtotime($day)))])->find();
|
|
|
|
|
+ if ($yesterday_price) {
|
|
|
|
|
+ $basePrice = $yesterday_price->price;
|
|
|
|
|
+ } else {
|
|
|
|
|
+ $basePrice = systemConfig('award_integral_price', 0.1);
|
|
|
|
|
+ }
|
|
|
|
|
+ //todo 业绩
|
|
|
|
|
+ $achievement = 0;
|
|
|
|
|
+ /** @var UserExtractRepository $extractRepositories */
|
|
|
|
|
+ $extractRepositories = app()->make(UserExtractRepository::class);
|
|
|
|
|
+ $commission = $extractRepositories->search(['status' => 1])->whereTime('check_time', $day)->sum('commission');
|
|
|
|
|
+ $userService = app()->make(UserRepository::class);
|
|
|
|
|
+ $num = $userService->search(['status' => 1])->sum('award_integral');
|
|
|
|
|
+ $sum_achievement = $commission + $achievement;
|
|
|
|
|
+
|
|
|
|
|
+ $rise = bcdiv($sum_achievement, $num, 3);
|
|
|
|
|
+ $price = bcadd($rise, $basePrice, 3);
|
|
|
|
|
+ return compact('basePrice', 'price', 'rise', 'achievement', 'commission', 'num');
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ public function setPrice($day, $price, $commission, $achievement, $num)
|
|
|
|
|
+ {
|
|
|
|
|
+ $add_time = time();
|
|
|
|
|
+ return $this->dao->create(compact('day', 'price', 'commission', 'achievement', 'num', 'add_time'));
|
|
|
|
|
+ }
|
|
|
|
|
+}
|