Manage.php 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152
  1. <?php
  2. namespace Res\Lib;
  3. use Dever;
  4. class Manage
  5. {
  6. /**
  7. * 更新信息
  8. *
  9. * @return mixed
  10. */
  11. public function infoUpdate($id, $name, $data)
  12. {
  13. # 更新分类id
  14. $category = Dever::param('category', $data);
  15. if ($category) {
  16. if (is_array($category)) {
  17. $category_id = end($category);
  18. $top_category_id = $category[0];
  19. if (isset($category[1])) {
  20. $second_category_id = $category[1];
  21. } else {
  22. $second_category_id = $category[0];
  23. }
  24. } else {
  25. $category_id = $category;
  26. $top_category_id = $category;
  27. $second_category_id = $category;
  28. }
  29. $update['top_category_id'] = $top_category_id;
  30. $update['second_category_id'] = $second_category_id;
  31. $update['category_id'] = $category_id;
  32. }
  33. $pic = Dever::param('pic', $data);
  34. $pic_cover = Dever::param('pic_cover', $data);
  35. if ($pic && !$pic_cover) {
  36. if (is_string($pic)) {
  37. $pic = explode(',', $pic);
  38. }
  39. $update['pic_cover'] = $pic[0];
  40. }
  41. if (isset($update)) {
  42. $update['where_id'] = $id;
  43. Dever::db('res/info')->update($update);
  44. }
  45. }
  46. /**
  47. * 更新需求属性信息
  48. *
  49. * @return mixed
  50. */
  51. public function attrUpdate($id, $name, $data)
  52. {
  53. print_r($data);die;
  54. foreach ($data as $k => $v) {
  55. }
  56. }
  57. /**
  58. * 显示需求信息
  59. *
  60. * @return mixed
  61. */
  62. public function info($id)
  63. {
  64. $info = Dever::db('res/info')->one($id);
  65. if ($info) {
  66. $table['编号'] = $info['id'];
  67. $table['标题'] = $info['name'];
  68. $table['分类'] = Dever::load("category/api.string", $info['category']);
  69. if ($info['pic_cover']) {
  70. $table['封面图'] = '<img src="'.$info['pic_cover'].'" width="150" />';
  71. }
  72. if ($info['uid'] > 0) {
  73. $user = Dever::load('passport/user-one', $info['uid']);
  74. $table['创建人'] = $user['username'] . '(UID:'.$info['uid'].')';
  75. if ($poster_pay_type == 1) {
  76. //$table['支付状态'] = '';
  77. }
  78. }
  79. //$table['属性'] = $this->attrInfo($info);
  80. if ($info['cdate']) {
  81. $table['发布时间'] = date("Y-m-d H:i:s", $info['cdate']);
  82. }
  83. }
  84. return Dever::table($table);
  85. }
  86. private function attrInfo($info)
  87. {
  88. $table = array();
  89. $info = Info::init($info['top_category_id']);
  90. if ($info) {
  91. $info = $info->info($info, 'id');
  92. if ($info && isset($info['attr'])) {
  93. foreach ($info['attr'] as $k => $v) {
  94. $table[$v['name']] = $v['value_string'];
  95. }
  96. }
  97. }
  98. return Dever::table($table);
  99. }
  100. public function area($id, $name, $data)
  101. {
  102. # 不再执行syncone等后续操作
  103. Dever::config('base')->after = 1;
  104. $type = Dever::input('type');
  105. $area = Dever::param('area', $data);
  106. if ($area) {
  107. if (isset($area[2])) {
  108. $update['district_id'] = $area[2];
  109. }
  110. if (isset($area[1])) {
  111. $update['city_id'] = $area[1];
  112. }
  113. if (isset($area[0])) {
  114. $update['province_id'] = $area[0];
  115. }
  116. if (isset($update)) {
  117. $update['where_id'] = $id;
  118. Dever::db($type . '/info')->update($update);
  119. }
  120. }
  121. }
  122. }