| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889 |
- <?php
- namespace app\admin\logic;
- use app\admin\model\dao\MoneyLog;
- use app\admin\model\dao\ScoreLog;
- use app\admin\model\dao\ShopOrder;
- use app\admin\model\dao\User;
- use app\common\model\ScoreLogModel;
- use think\facade\Cache;
- use think\facade\Db;
- class ScoreLogLogic
- {
- // 预约福袋 2.预约福袋空盒退回 3.买商品送积分 4.提现多次返回 6.兑换商品, 12-平台充补,13-平台扣除
- private static $typeMap = [
- // ['id' => 1, 'name' => '预约福袋'],
- // ['id' => 2, 'name' => '预约福袋空盒退回'],
- // ['id' => 3, 'name' => '买商品送积分'],
- // ['id' => 4, 'name' => '提现多次返回'],
- // ['id' => 6, 'name' => '兑换商品'],
- ['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 ScoreLogModel();
- $count = $model
- ->where($where)
- ->count();
- $type_conf = config('type.scoreAll');
- $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];
- }
- }
|