| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778 |
- <?php
- namespace app\admin\logic;
- use app\common\model\GreenScoreLogModel;
- use app\common\model\ScoreLogModel;
- class GreenScoreLogLogic
- {
- // 预约福袋 2.预约福袋空盒退回 3.买商品送积分 4.提现多次返回 6.兑换商品, 12-平台充补,13-平台扣除
- private static $typeMap = [
- ['id' => 12, 'name' => '平台充值'],
- ['id' => 13, 'name' => '平台扣除'],
- ['id' => 0, 'name' => '其他'],
- ];
- private static $stateMap = [
- ['id' => 1, 'name' => '增加'],
- ['id' => 2, 'name' => '减少']
- ];
- /**
- * @return array[]
- */
- public static function getStateMap(): array
- {
- return self::$stateMap;
- }
- /**
- * @return array[]
- */
- public static function getTypeMap(): array
- {
- return self::$typeMap;
- }
- /**
- * 绿色积分记录
- * @param $page
- * @param $limit
- * @param $where
- * @param array $sort
- * @return array
- * @throws \think\db\exception\DataNotFoundException
- * @throws \think\db\exception\DbException
- * @throws \think\db\exception\ModelNotFoundException
- */
- public static function scoreLog($page, $limit, $where, $sort)
- {
- $model = new GreenScoreLogModel();
- $count = $model
- ->where($where)
- ->count();
- $type_conf = config('type.green_score');
- $list = $model
- ->where($where)
- ->withAttr('type', function ($value, $data) use ($type_conf) {
- if (array_key_exists($value, $type_conf)) {
- return $type_conf[$value];
- }
- return '';
- })
- ->withAttr('score', function ($value, $data) {
- if ($data['state'] == 2)
- $value = '-' . $value;
- return $value;
- })
- ->page($page, $limit)
- ->order($sort)
- ->select();
- return [$count, $list];
- }
- }
|