|
|
@@ -46,46 +46,46 @@ class AwardIntegralPriceRepository extends BaseRepository
|
|
|
public function awardIntegralPrice($day = '')
|
|
|
{
|
|
|
try {
|
|
|
- if (!$day) {
|
|
|
- $day = date('Y-m-d', strtotime('-1 day'));
|
|
|
- }
|
|
|
- if ($info = $this->dao->search(['day' => $day])->find()) {
|
|
|
- return $info->toArray();
|
|
|
- }
|
|
|
+ if (!$day) {
|
|
|
+ $day = date('Y-m-d', strtotime('-1 day'));
|
|
|
+ }
|
|
|
+ if ($info = $this->dao->search(['day' => $day])->find()) {
|
|
|
+ return $info->toArray();
|
|
|
+ }
|
|
|
// @file_put_contents('yesterday.txt', AwardIntegralPrice::getLastSql() . PHP_EOL, FILE_APPEND);
|
|
|
- $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);
|
|
|
- }
|
|
|
- $time_start = strtotime($day);
|
|
|
- $time_end = strtotime($day) + 86400;
|
|
|
- //todo 业绩
|
|
|
- $achievement = StoreOrder::where('paid', 1)
|
|
|
- ->whereBetween('create_time', [$day . ' 00:00:00', $day . ' 23:59:59'])
|
|
|
- ->where('is_del', 0)->where('is_system_del', 0)
|
|
|
- ->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%
|
|
|
- /** @var UserExtractRepository $extractRepositories */
|
|
|
- $extractRepositories = app()->make(UserExtractRepository::class);
|
|
|
- $commission = $extractRepositories->search(['status' => 1])->whereBetween('check_time', [$time_start, $time_end])->sum('commission');
|
|
|
- @file_put_contents('yesterday.txt', UserExtract::getLastSql() . PHP_EOL, FILE_APPEND);
|
|
|
- $userService = app()->make(UserRepository::class);
|
|
|
- $num = $userService->search(['status' => 1])->sum('award_integral');
|
|
|
- $sum_achievement = bcadd((string)$commission, (string)$achievement, 8);
|
|
|
- $rise = $num > 0 ? bcdiv($sum_achievement, $num, 8) : 0;
|
|
|
- $add_price = 0;
|
|
|
- if ($rise > 0) {
|
|
|
- @file_put_contents('quanju4.txt', $rise . "-123\r\n", 8);
|
|
|
+ $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);
|
|
|
+ }
|
|
|
+ $time_start = strtotime($day);
|
|
|
+ $time_end = strtotime($day) + 86400;
|
|
|
+ //todo 业绩
|
|
|
+ $achievement = StoreOrder::where('paid', 1)
|
|
|
+ ->whereBetween('create_time', [$day . ' 00:00:00', $day . ' 23:59:59'])
|
|
|
+ ->where('is_del', 0)->where('is_system_del', 0)
|
|
|
+ ->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%
|
|
|
+ /** @var UserExtractRepository $extractRepositories */
|
|
|
+ $extractRepositories = app()->make(UserExtractRepository::class);
|
|
|
+ $commission = $extractRepositories->search(['status' => 1])->whereBetween('check_time', [$time_start, $time_end])->sum('commission');
|
|
|
+ @file_put_contents('yesterday.txt', UserExtract::getLastSql() . PHP_EOL, FILE_APPEND);
|
|
|
+ $userService = app()->make(UserRepository::class);
|
|
|
+ $num = $userService->search(['status' => 1])->sum('award_integral');
|
|
|
+ $sum_achievement = bcadd((string)$commission, (string)$achievement, 8);
|
|
|
+ $rise = $num > 0 ? bcdiv($sum_achievement, $num, 8) : 0;
|
|
|
+ $add_price = 0;
|
|
|
+ if ($rise > 0) {
|
|
|
+ @file_put_contents('quanju4.txt', $rise . "-123\r\n", 8);
|
|
|
// 增长值分成25份
|
|
|
$day_25_rise = bcdiv($rise, 25, 8);
|
|
|
|
|
|
- }else{
|
|
|
- $day_25_rise = 0;
|
|
|
- }
|
|
|
+ } else {
|
|
|
+ $day_25_rise = 0;
|
|
|
+ }
|
|
|
@file_put_contents('quanju4.txt', $day_25_rise . "-456\r\n", 8);
|
|
|
/** @var AwardIntegralPriceDayDao $AwardIntegralPriceDayDao */
|
|
|
$AwardIntegralPriceDayDao = app()->make(AwardIntegralPriceDayDao::class);
|
|
|
@@ -94,22 +94,22 @@ class AwardIntegralPriceRepository extends BaseRepository
|
|
|
$day_25 = strtotime('-25 day');
|
|
|
@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');
|
|
|
+ $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', $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);
|
|
|
-
|
|
|
- } 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);
|
|
|
- }
|
|
|
+ $price = $add_price + $basePrice;
|
|
|
+ @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);
|
|
|
+ @file_put_contents('quanju4.txt', $e->getFile() . "-文件\r\n", 8);
|
|
|
+ @file_put_contents('quanju4.txt', $e->getLine() . "-位置\r\n", 8);
|
|
|
+ }
|
|
|
return compact('basePrice', 'price', 'rise', 'achievement', 'commission', 'num', 'add_price');
|
|
|
}
|
|
|
|