NewsCategoryServer.php 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156
  1. <?php
  2. namespace app\admin\server\medical;
  3. use app\admin\model\MerchantShop;
  4. use app\admin\model\NewsCategory;
  5. use app\admin\model\SystemRole;
  6. class NewsCategoryServer
  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/30
  16. */
  17. public static function getCategoryList(int $page, int $limit, string $keywords)
  18. {
  19. [$list, $count] = NewsCategory::getCategory($page, $limit,$keywords);
  20. return compact('list', 'page', 'limit', 'count');
  21. }
  22. /**
  23. * Notes: 添加m店铺
  24. * @param array $param
  25. * @return int
  26. * User: QJF
  27. * Date: 2022/9/28
  28. */
  29. public static function insertShop(array $param)
  30. {
  31. SystemRole::affairBegin();
  32. try {
  33. $param['shop_create_time'] = time();
  34. $result = MerchantShop::insertGetId($param);
  35. if (!empty($result)){
  36. SystemRole::affairCommit();
  37. return $result;
  38. }
  39. throw new \Exception('操作失败!');
  40. }catch (\Exception $exception){
  41. SystemRole::affairRollback();
  42. throw new \Exception($exception->getMessage(), 500);
  43. }
  44. }
  45. /**
  46. * Notes:修改产品
  47. * @param array $param
  48. * @return int
  49. * User: QJF
  50. * Date: 2022/9/23
  51. */
  52. public static function updateShop($param)
  53. {
  54. SystemRole::affairBegin();
  55. try {
  56. $where = [];
  57. $where['shop_id'] = $param['shop_id'];
  58. $param['shop_update_time'] = time();
  59. $result = MerchantShop::where($where)->update($param);
  60. if ($result !== false){
  61. SystemRole::affairCommit();
  62. return true;
  63. }
  64. throw new \Exception('操作失败!');
  65. }catch (\Exception $exception){
  66. SystemRole::affairRollback();
  67. throw new \Exception($exception->getMessage(), 500);
  68. }
  69. }
  70. /**
  71. * Notes:删除产品
  72. * @param int $role_id
  73. * @return int
  74. * User: QJF
  75. * Date: 2022/9/23
  76. */
  77. public static function delShop($shop_id)
  78. {
  79. SystemRole::affairBegin();
  80. try {
  81. $where = [];
  82. $where['shop_id'] = $shop_id;
  83. $data['shop_del'] = 1;
  84. $data['shop_update_time'] = time();
  85. $result = MerchantShop::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 $role_id
  100. * @return int
  101. * User: QJF
  102. * Date: 2022/9/28
  103. */
  104. public static function showShop($shop_id,$product_status)
  105. {
  106. SystemRole::affairBegin();
  107. try {
  108. $where = [];
  109. $where['shop_id'] = $shop_id;
  110. $data['shop_status'] = $product_status;
  111. $data['shop_update_time'] = time();
  112. $result = MerchantShop::where($where)->update($data);
  113. if (!empty($result)){
  114. SystemRole::affairCommit();
  115. return true;
  116. }else{
  117. return false;
  118. }
  119. }catch (\Exception $exception){
  120. SystemRole::affairRollback();
  121. throw new \Exception($exception->getMessage(), 500);
  122. }
  123. }
  124. /**
  125. * Notes:产品详情
  126. * @param int $package_id
  127. * @return int
  128. * User: QJF
  129. * Date: 2022/9/23
  130. */
  131. public static function infoShop($shop_id)
  132. {
  133. SystemRole::affairBegin();
  134. try {
  135. $where = [];
  136. $where['shop_id'] = $shop_id;
  137. $result = MerchantShop::where($where)->first();
  138. if (!empty($result)){
  139. SystemRole::affairCommit();
  140. return $result;
  141. }else{
  142. return false;
  143. }
  144. }catch (\Exception $exception){
  145. SystemRole::affairRollback();
  146. throw new \Exception($exception->getMessage(), 500);
  147. }
  148. }
  149. }