ShopServer.php 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204
  1. <?php
  2. namespace app\admin\server\medical;
  3. use app\admin\controller\medical\Shop;
  4. use app\admin\model\MedicalCareOrder;
  5. use app\admin\model\MedicalCareOrderProduct;
  6. use app\admin\model\MedicalCarePostage;
  7. use app\admin\model\MerchantShop;
  8. use app\admin\model\PackageOrderDetail;
  9. use app\admin\model\SystemAdmin;
  10. use app\admin\model\SystemMenu;
  11. use app\admin\model\SystemRole;
  12. class ShopServer
  13. {
  14. /**
  15. * Notes:获取店铺列表
  16. * @param string $keywords
  17. * @param int $page
  18. * @param int $limit
  19. * @return array
  20. * User: QJF
  21. * Date: 2022/9/30
  22. */
  23. public static function getShopList(int $page, int $limit, string $keywords)
  24. {
  25. [$list, $count] = MerchantShop::getShopList($page, $limit,$keywords);
  26. return compact('list', 'page', 'limit', 'count');
  27. }
  28. /**
  29. * Notes:获取店铺列表
  30. * @param string $keywords
  31. * @param int $page
  32. * @param int $limit
  33. * @return array
  34. * User: QJF
  35. * Date: 2022/11/08
  36. */
  37. public static function getHealthyShopList()
  38. {
  39. [$list] = MerchantShop::getHealthyShopList();
  40. return compact('list');
  41. }
  42. /**
  43. * Notes:根据分类获取店铺列表
  44. * @param int $category_id
  45. * @return array
  46. * User: ZQ
  47. * Date: 2022/11/8
  48. */
  49. public static function getCategoryShop($category_id)
  50. {
  51. $list = MerchantShop::getCategoryShop($category_id);
  52. return $list;
  53. }
  54. /**
  55. * Notes:店铺子集列表
  56. * @return array
  57. * User: ZQ
  58. * Date: 2022/11/8
  59. */
  60. public static function getCategorysShop()
  61. {
  62. $list = MerchantShop::getCategorysShop();
  63. return $list;
  64. }
  65. /**
  66. * Notes: 添加m店铺
  67. * @param array $param
  68. * @return int
  69. * User: QJF
  70. * Date: 2022/9/28
  71. */
  72. public static function insertShop(array $param)
  73. {
  74. MerchantShop::affairBegin();
  75. try {
  76. $param['shop_create_time'] = time();
  77. $result = MerchantShop::insertGetId($param);
  78. if (!empty($result)){
  79. MerchantShop::affairCommit();
  80. return $result;
  81. }
  82. throw new \Exception('操作失败!');
  83. }catch (\Exception $exception){
  84. MerchantShop::affairRollback();
  85. throw new \Exception($exception->getMessage(), 500);
  86. }
  87. }
  88. /**
  89. * Notes:修改产品
  90. * @param array $param
  91. * @return int
  92. * User: QJF
  93. * Date: 2022/9/23
  94. */
  95. public static function updateShop($param)
  96. {
  97. MerchantShop::affairBegin();
  98. try {
  99. $where = [];
  100. $where['shop_id'] = $param['shop_id'];
  101. $param['shop_update_time'] = time();
  102. $result = MerchantShop::where($where)->update($param);
  103. if ($result !== false){
  104. MerchantShop::affairCommit();
  105. return true;
  106. }
  107. throw new \Exception('操作失败!');
  108. }catch (\Exception $exception){
  109. MerchantShop::affairRollback();
  110. throw new \Exception($exception->getMessage(), 500);
  111. }
  112. }
  113. /**
  114. * Notes:删除产品
  115. * @param int $role_id
  116. * @return int
  117. * User: QJF
  118. * Date: 2022/9/23
  119. */
  120. public static function delShop($shop_id)
  121. {
  122. MerchantShop::affairBegin();
  123. try {
  124. $where = [];
  125. $where['shop_id'] = $shop_id;
  126. $data['shop_del'] = 1;
  127. $data['shop_update_time'] = time();
  128. $result = MerchantShop::where($where)->update($data);
  129. if (!empty($result)){
  130. MerchantShop::affairCommit();
  131. return true;
  132. }else{
  133. return false;
  134. }
  135. }catch (\Exception $exception){
  136. MerchantShop::affairRollback();
  137. throw new \Exception($exception->getMessage(), 500);
  138. }
  139. }
  140. /**
  141. * Notes:上/下架
  142. * @param int $role_id
  143. * @return int
  144. * User: QJF
  145. * Date: 2022/9/28
  146. */
  147. public static function showShop($shop_id,$product_status)
  148. {
  149. MerchantShop::affairBegin();
  150. try {
  151. $where = [];
  152. $where['shop_id'] = $shop_id;
  153. $data['shop_status'] = $product_status;
  154. $data['shop_update_time'] = time();
  155. $result = MerchantShop::where($where)->update($data);
  156. if (!empty($result)){
  157. MerchantShop::affairCommit();
  158. return true;
  159. }else{
  160. return false;
  161. }
  162. }catch (\Exception $exception){
  163. MerchantShop::affairRollback();
  164. throw new \Exception($exception->getMessage(), 500);
  165. }
  166. }
  167. /**
  168. * Notes:产品详情
  169. * @param int $package_id
  170. * @return int
  171. * User: QJF
  172. * Date: 2022/9/23
  173. */
  174. public static function infoShop($shop_id)
  175. {
  176. MerchantShop::affairBegin();
  177. try {
  178. $where = [];
  179. $where['shop_id'] = $shop_id;
  180. $result = MerchantShop::where($where)->first();
  181. if (!empty($result)){
  182. MerchantShop::affairCommit();
  183. return $result;
  184. }else{
  185. return false;
  186. }
  187. }catch (\Exception $exception){
  188. MerchantShop::affairRollback();
  189. throw new \Exception($exception->getMessage(), 500);
  190. }
  191. }
  192. }