PackageGoodsCategoryServer.php 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  1. <?php
  2. namespace app\admin\server\package;
  3. use app\admin\model\PackageGoods;
  4. use app\admin\model\PackageGoodsCategory;
  5. use app\admin\model\SystemRole;
  6. class PackageGoodsCategoryServer
  7. {
  8. /**
  9. * Notes:获取角色列表
  10. * @param string $keywords
  11. * @param int $page
  12. * @param int $limit
  13. * @return array
  14. * User: QJF
  15. * Date: 2022/9/17
  16. */
  17. public static function getPackageGoodsCategoryList(int $page, int $limit, $keywords)
  18. {
  19. [$list, $count] = PackageGoodsCategory::getPackageGoodsCategoryList($page, $limit, $keywords);
  20. return compact('list', 'page', 'limit', 'count');
  21. }
  22. /**
  23. * Notes: 添加产品分类
  24. * @param array $param
  25. * @return int
  26. * User: QJF
  27. * Date: 2022/9/17
  28. */
  29. public static function insertPackageGoodsCategory(array $param)
  30. {
  31. SystemRole::affairBegin();
  32. try {
  33. $param['category_create_time'] = time();
  34. $param['category_update_time'] = time();
  35. $result = PackageGoodsCategory::insertGetId($param);
  36. if (!empty($result)){
  37. SystemRole::affairCommit();
  38. return $result;
  39. }
  40. throw new \Exception('操作失败!');
  41. }catch (\Exception $exception){
  42. SystemRole::affairRollback();
  43. throw new \Exception($exception->getMessage(), 500);
  44. }
  45. }
  46. /**
  47. * Notes:修改产品分类
  48. * @param array $param
  49. * @return int
  50. * User: QJF
  51. * Date: 2022/9/21
  52. */
  53. public static function updatePackageGoodsCategory($param)
  54. {
  55. SystemRole::affairBegin();
  56. try {
  57. $where = [];
  58. $where['category_id'] = $param['category_id'];
  59. $param['category_update_time'] = time();
  60. $result = PackageGoodsCategory::where($where)->update($param);
  61. if ($result !== false){
  62. SystemRole::affairCommit();
  63. return true;
  64. }
  65. throw new \Exception('操作失败!');
  66. }catch (\Exception $exception){
  67. SystemRole::affairRollback();
  68. throw new \Exception($exception->getMessage(), 500);
  69. }
  70. }
  71. /**
  72. * Notes:任务
  73. * @param int $role_id
  74. * @return int
  75. * User: QJF
  76. * Date: 2022/9/19
  77. */
  78. public static function delPackageGoodsCategory($category_id)
  79. {
  80. SystemRole::affairBegin();
  81. try {
  82. $where = [];
  83. $where['category_id'] = $category_id;
  84. $data['category_delete_time'] = time();
  85. $result = PackageGoodsCategory::where($where)->update($data);
  86. if (!empty($result)){
  87. SystemRole::affairCommit();
  88. return true;
  89. }else{
  90. return false;
  91. }
  92. }catch (\Exception $exception){
  93. SystemRole::affairRollback();
  94. throw new \Exception($exception->getMessage(), 500);
  95. }
  96. }
  97. /**
  98. * Notes:获取权益包详情
  99. * @param int $category_id
  100. * @return int
  101. * User: QJF
  102. * Date: 2022/9/19
  103. */
  104. public static function infoPackageCategory($category_id)
  105. {
  106. SystemRole::affairBegin();
  107. try {
  108. $where = [];
  109. $where['category_id'] = $category_id;
  110. $result = PackageGoodsCategory::where($where)->first();
  111. if (!empty($result)){
  112. SystemRole::affairCommit();
  113. return $result;
  114. }else{
  115. return false;
  116. }
  117. }catch (\Exception $exception){
  118. SystemRole::affairRollback();
  119. throw new \Exception($exception->getMessage(), 500);
  120. }
  121. }
  122. }