ScoreLogLogic.php 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. <?php
  2. namespace app\admin\logic;
  3. use app\admin\model\dao\MoneyLog;
  4. use app\admin\model\dao\ScoreLog;
  5. use app\admin\model\dao\ShopOrder;
  6. use app\admin\model\dao\User;
  7. use app\common\model\ScoreLogModel;
  8. use think\facade\Cache;
  9. use think\facade\Db;
  10. class ScoreLogLogic
  11. {
  12. // 预约福袋 2.预约福袋空盒退回 3.买商品送积分 4.提现多次返回 6.兑换商品, 12-平台充补,13-平台扣除
  13. private static $typeMap = [
  14. ['id' => 0, 'name' => '其他'],
  15. ['id' => 1, 'name' => '预约福袋'],
  16. ['id' => 2, 'name' => '预约福袋空盒退回'],
  17. ['id' => 3, 'name' => '买商品送积分'],
  18. ['id' => 4, 'name' => '提现多次返回'],
  19. ['id' => 6, 'name' => '兑换商品'],
  20. ['id' => 12, 'name' => '平台充补'],
  21. ['id' => 13, 'name' => '平台扣除']
  22. ];
  23. private static $stateMap = [
  24. ['id' => 1, 'name' => '增加'],
  25. ['id' => 2, 'name' => '减少']
  26. ];
  27. /**
  28. * @return array[]
  29. */
  30. public static function getStateMap(): array
  31. {
  32. return self::$stateMap;
  33. }
  34. /**
  35. * @return array[]
  36. */
  37. public static function getTypeMap(): array
  38. {
  39. return self::$typeMap;
  40. }
  41. public static function scoreLog(mixed $page, mixed $limit, mixed $where, array $sort)
  42. {
  43. $model = new ScoreLogModel();
  44. $count = $model
  45. ->where($where)
  46. ->count();
  47. $type_conf = config('type.score');
  48. $list = $model
  49. ->where($where)
  50. ->withAttr('type', function ($value, $data) use ($type_conf) {
  51. return $type_conf[$value];
  52. })
  53. ->withAttr('score', function ($value, $data) {
  54. if ($data['state'] == 2)
  55. $value = '-' . $value;
  56. return $value;
  57. })
  58. ->page($page, $limit)
  59. ->order($sort)
  60. ->select();
  61. return [$count, $list];
  62. }
  63. }