ScoreLogLogic.php 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576
  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($page, $limit, $where, $sort)
  42. public static function scoreLog(mixed $page, mixed $limit, mixed $where, array $sort)
  43. {
  44. $model = new ScoreLogModel();
  45. $count = $model
  46. ->where($where)
  47. ->count();
  48. $type_conf = config('type.score');
  49. $list = $model
  50. ->where($where)
  51. ->withAttr('type', function ($value, $data) use ($type_conf) {
  52. return $type_conf[$value];
  53. })
  54. ->withAttr('score', function ($value, $data) {
  55. if ($data['state'] == 2)
  56. $value = '-' . $value;
  57. return $value;
  58. })
  59. ->page($page, $limit)
  60. ->order($sort)
  61. ->select();
  62. return [$count, $list];
  63. }
  64. }