|
|
@@ -22,6 +22,7 @@ use app\common\model\store\order\StoreOrder;
|
|
|
use app\common\model\user\AwardIntegralPrice;
|
|
|
use app\common\model\user\AwardIntegralPriceDay;
|
|
|
use app\common\model\user\AwardLakeLog;
|
|
|
+use app\common\model\user\User;
|
|
|
use app\common\model\user\UserExtract;
|
|
|
use app\common\repositories\BaseRepository;
|
|
|
|
|
|
@@ -68,7 +69,7 @@ class AwardIntegralPriceRepository extends BaseRepository
|
|
|
->where('status', '>=', 0)
|
|
|
->sum('total_price');
|
|
|
@file_put_contents('yesterday.txt', StoreOrder::getLastSql() . PHP_EOL, FILE_APPEND);
|
|
|
- $achievement = bcmul((string)$achievement, '0.1', 8); //从总业绩的5%上涨到10%
|
|
|
+ $achievement = bcmul((string)$achievement, '0.15', 8); //从总业绩的5%上涨到10%,在上涨到15%
|
|
|
/** @var UserExtractRepository $extractRepositories */
|
|
|
$extractRepositories = app()->make(UserExtractRepository::class);
|
|
|
$commission = $extractRepositories->search(['status' => 1])->whereBetween('check_time', [$time_start, $time_end])->sum('commission');
|
|
|
@@ -86,24 +87,25 @@ class AwardIntegralPriceRepository extends BaseRepository
|
|
|
} else {
|
|
|
$day_25_rise = 0;
|
|
|
}
|
|
|
- @file_put_contents('quanju4.txt', $day_25_rise . "-456\r\n", 8);
|
|
|
+// @file_put_contents('quanju4.txt', $day_25_rise . "-456\r\n", 8);
|
|
|
/** @var AwardIntegralPriceDayDao $AwardIntegralPriceDayDao */
|
|
|
$AwardIntegralPriceDayDao = app()->make(AwardIntegralPriceDayDao::class);
|
|
|
|
|
|
$AwardIntegralPriceDayDao->create(['day' => time(), 'all_add_price' => $rise, 'day_add_price' => $day_25_rise]); //保存今天增长的总价格和每日增长价格
|
|
|
+
|
|
|
$day_25 = strtotime('-25 day');
|
|
|
- @file_put_contents('quanju4.txt', $day_25 . "-25天前的时间\r\n", 8);
|
|
|
+// @file_put_contents('quanju4.txt', $day_25 . "-25天前的时间\r\n", 8);
|
|
|
// $add_price = $AwardIntegralPriceDayDao->search([])->where('day','>' ,$day_25)->sum('day_add_price');
|
|
|
$add_price = AwardIntegralPriceDay::where('day', '>', $day_25)->sum('day_add_price');
|
|
|
- @file_put_contents('quanju4.txt', sprintf("%.8f", $add_price) . "-789\r\n", 8);
|
|
|
- @file_put_contents('quanju4.txt', AwardIntegralPriceDay::getLastSql() . "-91110212\r\n", 8);
|
|
|
+// @file_put_contents('quanju4.txt', sprintf("%.8f", $add_price) . "-789\r\n", 8);
|
|
|
+// @file_put_contents('quanju4.txt', AwardIntegralPriceDay::getLastSql() . "-91110212\r\n", 8);
|
|
|
|
|
|
- @file_put_contents('quanju4.txt', $basePrice . "-之前的总价总价\r\n", 8);
|
|
|
- @file_put_contents('quanju4.txt', $add_price . "-963\r\n", 8);
|
|
|
+// @file_put_contents('quanju4.txt', $basePrice . "-之前的总价总价\r\n", 8);
|
|
|
+// @file_put_contents('quanju4.txt', $add_price . "-963\r\n", 8);
|
|
|
// $price = bcadd(sprintf("%.8f", $add_price), (string)$basePrice, 8);
|
|
|
$price = $add_price + $basePrice;
|
|
|
- @file_put_contents('quanju4.txt', time() . "-正常获取走的到这里吗\r\n", 8);
|
|
|
- @file_put_contents('quanju4.txt', $price . "-总价\r\n", 8);
|
|
|
+// @file_put_contents('quanju4.txt', time() . "-正常获取走的到这里吗\r\n", 8);
|
|
|
+// @file_put_contents('quanju4.txt', $price . "-总价\r\n", 8);
|
|
|
|
|
|
} catch (\Exception $e) {
|
|
|
@file_put_contents('quanju4.txt', $e->getMessage() . "-积分价格报错内容\r\n", 8);
|
|
|
@@ -113,10 +115,49 @@ class AwardIntegralPriceRepository extends BaseRepository
|
|
|
return compact('basePrice', 'price', 'rise', 'achievement', 'commission', 'num', 'add_price');
|
|
|
}
|
|
|
|
|
|
+ public static function userIntegralValue($price){
|
|
|
+ $user_lst = User::where('status',1)->where('award_integral','>',0)->select(); //获取所有有效用户
|
|
|
+ if (!empty($user_lst)){
|
|
|
+ $user_lst = $user_lst->toArray();
|
|
|
+ }
|
|
|
+ $userBillRepository = app()->make(UserBillRepository::class);
|
|
|
+ $userRepository = app()->make(UserRepository::class);
|
|
|
+
|
|
|
+ try {
|
|
|
+ foreach ($user_lst as $user){
|
|
|
+ $user_price = bcmul($price, $user['award_integral'], 8); //用户积分总价值
|
|
|
+ if ($user_price > $user['award_range']){
|
|
|
+ $num = bcsub($user_price, $user['award_range'], 8); //超出额度的金额
|
|
|
+ if ($num > 0.01){
|
|
|
+ $num_integral = bcdiv($num, $price, 8); //金额除以价格得到超出额度的积分
|
|
|
+ $userBillRepository->decBill($user['uid'], 'award_integral', 'extract_award', [
|
|
|
+ 'link_id' => 0,
|
|
|
+ 'status' => 1,
|
|
|
+ 'title' => '提取分红积分',
|
|
|
+ 'number' => $num_integral,
|
|
|
+ 'mark' => '自动提取' . floatval($num_integral) . '分红积分',
|
|
|
+ 'balance' => bcsub($user['award_integral'], $num_integral, 2)
|
|
|
+ ]);
|
|
|
+ $userRepository->decField($user['uid'], 'award_integral', $num);
|
|
|
+
|
|
|
+ $userRepository->incBrokerage($user['uid'], $num);
|
|
|
+ $userRepository->incField($user['uid'], 'brokerage_price', $num);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } catch (\Exception $e) {
|
|
|
+ @file_put_contents('quanju4.txt', $e->getMessage() . "-计算超出额度的积分报错内容\r\n", 8);
|
|
|
+ @file_put_contents('quanju4.txt', $e->getFile() . "-文件\r\n", 8);
|
|
|
+ @file_put_contents('quanju4.txt', $e->getLine() . "-位置\r\n", 8);
|
|
|
+ }
|
|
|
+
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+
|
|
|
public function setPrice($day, $price, $commission, $achievement, $num, $add_price)
|
|
|
{
|
|
|
$add_time = time();
|
|
|
- @file_put_contents('quanju4.txt', $add_price . "-我add_price呢\r\n", 8);
|
|
|
+// @file_put_contents('quanju4.txt', $add_price . "-我add_price呢\r\n", 8);
|
|
|
return $this->dao->create(compact('day', 'price', 'commission', 'achievement', 'num', 'add_time', 'add_price'));
|
|
|
}
|
|
|
|