RaiseOldGoodsServer.php 8.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206
  1. <?php
  2. namespace app\admin\server\raise;
  3. use app\admin\model\RaiseOldGoods;
  4. class RaiseOldGoodsServer
  5. {
  6. /**
  7. * Notes:获取养老产品列表
  8. * @param string $keywords
  9. * @param int $page
  10. * @param int $limit
  11. * @return array
  12. * User: ZQ
  13. * Date: 2022/10/31
  14. */
  15. public static function getGoodsList(int $page, int $limit, string $keywords)
  16. {
  17. [$list, $count] = RaiseOldGoods::getGoodsList($page, $limit, $keywords);
  18. if (!empty($list)){
  19. foreach ($list as $k => $v){
  20. $list[$k]['goods_add_time'] = date('Y-m-d H:i:s',$v['goods_add_time']);
  21. if (!empty($v['goods_update_time'])){
  22. $list[$k]['goods_update_time'] = date('Y-m-d H:i:s',$v['goods_update_time']);
  23. }
  24. }
  25. }
  26. return compact('list', 'page', 'limit', 'count');
  27. }
  28. /**
  29. * Notes:修改养老产品
  30. * @param string $goods_name
  31. * @param int $goods_id
  32. * @return int
  33. * User: ZQ
  34. * Date: 2022/10/31
  35. */
  36. public static function updateGoods($goods_id, $goods_name, $goods_title, $goods_time, $goods_category_id, $goods_banner, $goods_label, $goods_status, $goods_service_population, $goods_service_consumables, $goods_service_qualifications, $goods_service_explain, $goods_service_standard, $goods_service_process, $goods_technological, $goods_tips, $goods_shop_id, $goods_price, $admin_id)
  37. {
  38. RaiseOldGoods::affairBegin();
  39. try {
  40. $where = [];
  41. $where['goods_id'] = $goods_id;
  42. $data = [];
  43. $data['goods_name'] = $goods_name;
  44. $data['goods_title'] = $goods_title;
  45. $data['goods_time'] = $goods_time;
  46. $data['goods_category_id'] = $goods_category_id;
  47. $data['goods_banner'] = $goods_banner;
  48. $data['goods_label'] = $goods_label;
  49. $data['goods_service_population'] = $goods_service_population;
  50. $data['goods_service_consumables'] = $goods_service_consumables;
  51. $data['goods_service_qualifications'] = $goods_service_qualifications;
  52. $data['goods_service_explain'] = $goods_service_explain;
  53. $data['goods_service_standard'] = $goods_service_standard;
  54. $data['goods_service_process'] = $goods_service_process;
  55. $data['goods_technological'] = $goods_technological;
  56. $data['goods_tips'] = $goods_tips;
  57. $data['goods_status'] = $goods_status;
  58. $data['goods_price'] = $goods_price;
  59. $data['goods_shop_id'] = $goods_shop_id;
  60. $data['goods_update_time'] = time();
  61. $result = RaiseOldGoods::where($where)->update($data);
  62. if ($result !== false){
  63. $msg = '管理员:' . $admin_id . '在:' . date("Y-m-d H:i:s", time()) . '修改万悦养老产品-编号: ' . $goods_id;
  64. plog('life-goods-update', '养老服务-养老产品-修改养老产品', $msg);
  65. RaiseOldGoods::affairCommit();
  66. return true;
  67. }
  68. throw new \Exception('操作失败!');
  69. }catch (\Exception $exception){
  70. RaiseOldGoods::affairRollback();
  71. throw new \Exception($exception->getMessage(), 500);
  72. }
  73. }
  74. /**
  75. * Notes:删除养老产品
  76. * @param int $goods_id
  77. * @return int
  78. * User: ZQ
  79. * Date: 2022/10/31
  80. */
  81. public static function delGoods($goods_id,$admin_id)
  82. {
  83. RaiseOldGoods::affairBegin();
  84. try {
  85. $where = [];
  86. $where['goods_id'] = $goods_id;
  87. $data['goods_del'] = 1;
  88. $result = RaiseOldGoods::where($where)->update($data);
  89. if (!empty($result)){
  90. $msg = '管理员:' . $admin_id . '在:' . date("Y-m-d H:i:s", time()) . '删除万悦养老产品-编号: ' . $goods_id;
  91. plog('life-goods-delete', '养老服务-养老产品-删除养老产品', $msg);
  92. RaiseOldGoods::affairCommit();
  93. return true;
  94. }else{
  95. return false;
  96. }
  97. }catch (\Exception $exception){
  98. RaiseOldGoods::affairRollback();
  99. throw new \Exception($exception->getMessage(), 500);
  100. }
  101. }
  102. /**
  103. * Notes: 添加养老产品
  104. * @param string $goods_name
  105. * @param array $goods_rules
  106. * @return int
  107. * User: ZQ
  108. * Date: 2022/10/31
  109. */
  110. public static function insertGoods($goods_name, $goods_title, $goods_time, $goods_category_id, $goods_banner, $goods_label, $goods_status, $goods_service_population, $goods_service_consumables, $goods_service_qualifications, $goods_service_explain, $goods_service_standard, $goods_service_process, $goods_technological, $goods_tips, $goods_shop_id, $goods_price, $admin_id)
  111. {
  112. RaiseOldGoods::affairBegin();
  113. try {
  114. $data = [];
  115. $data['goods_name'] = $goods_name;
  116. $data['goods_title'] = $goods_title;
  117. $data['goods_time'] = $goods_time;
  118. $data['goods_category_id'] = $goods_category_id;
  119. $data['goods_banner'] = $goods_banner;
  120. $data['goods_label'] = $goods_label;
  121. $data['goods_service_population'] = $goods_service_population;
  122. $data['goods_service_consumables'] = $goods_service_consumables;
  123. $data['goods_service_qualifications'] = $goods_service_qualifications;
  124. $data['goods_service_explain'] = $goods_service_explain;
  125. $data['goods_service_standard'] = $goods_service_standard;
  126. $data['goods_service_process'] = $goods_service_process;
  127. $data['goods_technological'] = $goods_technological;
  128. $data['goods_tips'] = $goods_tips;
  129. $data['goods_status'] = $goods_status;
  130. $data['goods_price'] = $goods_price;
  131. $data['goods_shop_id'] = $goods_shop_id;
  132. $data['goods_add_time'] = time();
  133. $result = RaiseOldGoods::insertGetId($data);
  134. if (!empty($result)){
  135. $msg = '管理员:' . $admin_id . '在:' . date("Y-m-d H:i:s", time()) . '添加万悦养老产品-编号: ' . $result;
  136. plog('life-goods-create', '养老服务-养老产品-添加养老产品', $msg);
  137. RaiseOldGoods::affairCommit();
  138. return $result;
  139. }
  140. throw new \Exception('操作失败!');
  141. }catch (\Exception $exception){
  142. RaiseOldGoods::affairRollback();
  143. throw new \Exception($exception->getMessage(), 500);
  144. }
  145. }
  146. /**
  147. * Notes:查询养老产品
  148. * @param int $goods_id
  149. * @return int
  150. * User: ZQ
  151. * Date: 2022/10/31
  152. */
  153. public static function goodsInfo($goods_id)
  154. {
  155. $where = [];
  156. $where['goods_id'] = $goods_id;
  157. $result = RaiseOldGoods::where($where)
  158. ->leftJoin('category','category_id','=','raise_old_goods.goods_category_id')
  159. ->leftJoin('merchant_shop','shop_id','=','raise_old_goods.goods_shop_id')
  160. ->first(['raise_old_goods.*','category.category_name','merchant_shop.shop_name']);
  161. if (!empty($result)){
  162. $result['goods_add_time'] = date('Y-m-d H:i:s',$result['goods_add_time']);
  163. if (!empty($result['goods_update_time'])){
  164. $result['goods_update_time'] = date('Y-m-d H:i:s',$result['goods_update_time']);
  165. }
  166. }
  167. return $result;
  168. }
  169. /**
  170. * Notes:修改养老产品状态
  171. * @param string $goods_name
  172. * @param int $goods_status
  173. * @return int
  174. * User: ZQ
  175. * Date: 2022/9/15
  176. */
  177. public static function updateStatus($goods_id, $goods_status)
  178. {
  179. RaiseOldGoods::affairBegin();
  180. try {
  181. $where = [];
  182. $where['goods_id'] = $goods_id;
  183. $data = [];
  184. $data['goods_status'] = $goods_status;
  185. $result = RaiseOldGoods::where($where)->update($data);
  186. if ($result !== false){
  187. RaiseOldGoods::affairCommit();
  188. return true;
  189. }
  190. throw new \Exception('操作失败!');
  191. }catch (\Exception $exception){
  192. RaiseOldGoods::affairRollback();
  193. throw new \Exception($exception->getMessage(), 500);
  194. }
  195. }
  196. }