ScoreLogLogic.php 2.1 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. // 1. 报名消费抢购扣除 2.消费券任务发放 3.爆仓 补足前面两个的百分之七十 4.爆仓那个全部返回 5 商城购买商品返积分 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' => 5, 'name' => '商城购买商品返积分'],
  20. ['id' => 6, 'name' => '兑换商品'],
  21. ['id' => 12, 'name' => '平台充补'],
  22. ['id' => 13, 'name' => '平台扣除'],
  23. ];
  24. private static $stateMap = [
  25. ['id' => 1, 'name' => '增加'],
  26. ['id' => 2, 'name' => '减少']
  27. ];
  28. /**
  29. * @return array[]
  30. */
  31. public static function getStateMap(): array
  32. {
  33. return self::$stateMap;
  34. }
  35. /**
  36. * @return array[]
  37. */
  38. public static function getTypeMap(): array
  39. {
  40. return self::$typeMap;
  41. }
  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. }