PackageGoodsServer.php 3.6 KB

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