|
@@ -5,6 +5,7 @@ namespace SixShop\Points\Entity;
|
|
|
|
|
|
|
|
use SixShop\Core\Entity\BaseEntity;
|
|
use SixShop\Core\Entity\BaseEntity;
|
|
|
use SixShop\Points\Model\UserPointLogModel;
|
|
use SixShop\Points\Model\UserPointLogModel;
|
|
|
|
|
+use think\db\Query;
|
|
|
use think\Paginator;
|
|
use think\Paginator;
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -14,7 +15,9 @@ class UserPointLogEntity extends BaseEntity
|
|
|
{
|
|
{
|
|
|
public function getList(array $params, array $pageAndLimit): Paginator
|
|
public function getList(array $params, array $pageAndLimit): Paginator
|
|
|
{
|
|
{
|
|
|
- return $this->withSearch(['user_id', 'type', 'create_time'], $params)
|
|
|
|
|
|
|
+ return $this->withSearch(['user_id', 'type', 'create_time' => function (Query $query, $value) {
|
|
|
|
|
+ $value && $query->whereBetweenTime('user_point_log_model.create_time', $value[0], $value[1]);
|
|
|
|
|
+ }], $params)
|
|
|
->withJoin(['user' => ['nickname']])
|
|
->withJoin(['user' => ['nickname']])
|
|
|
->order('id', 'desc')
|
|
->order('id', 'desc')
|
|
|
->paginate($pageAndLimit);
|
|
->paginate($pageAndLimit);
|
|
@@ -22,7 +25,7 @@ class UserPointLogEntity extends BaseEntity
|
|
|
|
|
|
|
|
public function getStats(array $params)
|
|
public function getStats(array $params)
|
|
|
{
|
|
{
|
|
|
- return $this->withSearch(['user_id', 'create_time'], $params)->field(
|
|
|
|
|
|
|
+ return $this->withSearch(['user_id', 'type', 'create_time'], $params)->field(
|
|
|
[
|
|
[
|
|
|
'SUM(CASE WHEN point > 0 THEN point ELSE 0 END) AS positive_total',
|
|
'SUM(CASE WHEN point > 0 THEN point ELSE 0 END) AS positive_total',
|
|
|
'SUM(CASE WHEN point < 0 THEN point ELSE 0 END) AS negative_total',
|
|
'SUM(CASE WHEN point < 0 THEN point ELSE 0 END) AS negative_total',
|