Memberinform.php 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554
  1. <?php
  2. namespace app\api\controller;
  3. use think\facade\Lang;
  4. /**
  5. *
  6. *
  7. * ----------------------------------------------------------------------------
  8. *
  9. * 举报控制器
  10. */
  11. class Memberinform extends MobileMember
  12. {
  13. public function initialize()
  14. {
  15. parent::initialize(); // TODO: Change the autogenerated stub
  16. Lang::load(base_path() . 'home/lang/' . config('lang.default_lang') . '/memberinfom.lang.php');
  17. }
  18. /**
  19. * @api {POST} api/Memberinform/index 获取当前用户的举报列表
  20. * @apiVersion 1.0.0
  21. * @apiGroup Memberinform
  22. *
  23. * @apiHeader {String} X-DS-KEY 用户授权token
  24. *
  25. * @apiParam {Int} page 页码
  26. * @apiParam {Int} per_page 每页数量
  27. *
  28. * @apiSuccess {String} code 返回码,10000为成功
  29. * @apiSuccess {String} message 返回消息
  30. * @apiSuccess {Object} result 返回数据
  31. * @apiSuccess {Object[]} result.inform_list 举报列表
  32. * @apiSuccess {String} result.inform_list.inform_content 举报内容
  33. * @apiSuccess {Int} result.inform_list.inform_datetime 举报时间
  34. * @apiSuccess {Int} result.inform_list.inform_goods_id 商品ID
  35. * @apiSuccess {String} result.inform_list.inform_goods_image 商品图片名称
  36. * @apiSuccess {String} result.inform_list.inform_goods_image_url 商品图片完整路径
  37. * @apiSuccess {String} result.inform_list.inform_goods_name 商品名称
  38. * @apiSuccess {Int} result.inform_list.inform_handle_datetime 处理时间
  39. * @apiSuccess {Int} result.inform_list.inform_handle_member_id 处理用户ID
  40. * @apiSuccess {String} result.inform_list.inform_handle_message 处理描述
  41. * @apiSuccess {Int} result.inform_list.inform_handle_type 举报处理结果(1无效举报/2恶意举报/3有效举报)
  42. * @apiSuccess {Int} result.inform_list.inform_id 举报ID
  43. * @apiSuccess {Int} result.inform_list.inform_member_id 举报用户ID
  44. * @apiSuccess {String} result.inform_list.inform_member_name 举报用户名称
  45. * @apiSuccess {String} result.inform_list.inform_pic1 举报凭证1
  46. * @apiSuccess {String} result.inform_list.inform_pic2 举报凭证2
  47. * @apiSuccess {String} result.inform_list.inform_pic3 举报凭证3
  48. * @apiSuccess {Int} result.inform_list.inform_state 举报状态(1未处理/2已处理)
  49. * @apiSuccess {Int} result.inform_list.inform_store_id 店铺ID
  50. * @apiSuccess {String} result.inform_list.inform_store_name 店铺名称
  51. * @apiSuccess {String} result.inform_list.informsubject_content 举报主题内容
  52. * @apiSuccess {Int} result.inform_list.informsubject_id 举报主题ID
  53. * @apiSuccess {Int} result.inform_list.informsubject_state 举报主题状态 1:可用 2:失效
  54. * @apiSuccess {Int} result.inform_list.informsubject_type_id 举报类型ID
  55. * @apiSuccess {String} result.inform_list.informsubject_type_name 举报类型名称
  56. * @apiSuccess {Int} result.page_total 总页数
  57. * @apiSuccess {Boolean} result.hasmore 是否有更多 true是false否
  58. */
  59. public function index()
  60. {
  61. /*
  62. * 得到当前用户的举报列表
  63. */
  64. $inform_model = model('inform');
  65. $goods_model = model('goods');
  66. $condition = array();
  67. $inform_state = intval(input('param.select_inform_state'));
  68. if ($inform_state > 0) {
  69. $condition[] = array('inform.inform_state', '=', $inform_state);
  70. }
  71. $condition[] = array('inform.inform_member_id', '=', $this->member_info['member_id']);
  72. $inform_list = $inform_model->getInformList($condition, 10);
  73. foreach ($inform_list as $key => $val) {
  74. $condition = array();
  75. $condition[] = array('goods_id', '=', $val['inform_goods_id']);
  76. $goodsinfo = $goods_model->getGoodsInfo($condition, 'goods_price');
  77. $inform_list[$key]['inform_goods_image_url'] = goods_cthumb($val['inform_goods_image']);
  78. $inform_list[$key]['inform_goods_price'] = $goodsinfo['goods_price'];
  79. }
  80. $result = array_merge(array('inform_list' => $inform_list), mobile_page($inform_model->page_info));
  81. ds_json_encode(10000, '', $result);
  82. }
  83. /**
  84. * @api {POST} api/Memberinform/inform_submit 获取新增/编辑举报公共信息
  85. * @apiVersion 1.0.0
  86. * @apiGroup Memberinform
  87. *
  88. * @apiHeader {String} X-DS-KEY 用户授权token
  89. *
  90. * @apiParam {Int} goods_id 商品ID
  91. *
  92. * @apiSuccess {String} code 返回码,10000为成功
  93. * @apiSuccess {String} message 返回消息
  94. * @apiSuccess {Object} result 返回数据
  95. * @apiSuccess {Object} result.goods_info 举报商品信息
  96. * @apiSuccess {Object[]} result.type_list 举报类型列表
  97. * @apiSuccess {String} result.type_list.informtype_desc 举报类型描述
  98. * @apiSuccess {Int} result.type_list.informtype_id 举报类型ID
  99. * @apiSuccess {String} result.type_list.informtype_name 举报类型名称
  100. * @apiSuccess {Int} result.type_list.informtype_state 举报类型状态 1:有效 2:失效
  101. */
  102. public function inform_submit()
  103. {
  104. //检查当前用户是否允许举报
  105. $this->check_member_allow_inform();
  106. $goods_id = intval(input('param.goods_id'));
  107. //获取商品详细信息
  108. $goods_info = $this->get_goods_info_byid($goods_id);
  109. $seller_model = model('seller');
  110. $seller_info = $seller_model->getSellerInfo(array('member_id' => $this->member_info['member_id']));
  111. //检查是否是本店商品
  112. if (!$seller_info) {
  113. if ($goods_info['store_id'] == $seller_info['store_id']) {
  114. ds_json_encode(10001, lang('param_error'));
  115. }
  116. }
  117. $inform_model = model('inform');
  118. //检查是否当前正在举报
  119. if ($inform_model->isProcessOfInform($goods_id)) {
  120. ds_json_encode(10001, lang('inform_handling'));
  121. }
  122. //获取举报类型
  123. $informsubjecttype_model = model('informsubjecttype');
  124. $inform_subject_type_list = $informsubjecttype_model->getActiveInformsubjecttypeList();
  125. if (empty($inform_subject_type_list)) {
  126. ds_json_encode(10001, lang('inform_type_null'));
  127. }
  128. ds_json_encode(10000, '', array('goods_info' => $goods_info, 'type_list' => $inform_subject_type_list));
  129. }
  130. /**
  131. * @api {POST} api/Memberinform/inform_save 保存用户提交的商品举报
  132. * @apiVersion 1.0.0
  133. * @apiGroup Memberinform
  134. *
  135. * @apiHeader {String} X-DS-KEY 用户授权token
  136. *
  137. * @apiParam {Int} inform_goods_id 商品ID
  138. * @apiParam {String} inform_subject 举报主题
  139. * @apiParam {String} inform_content 举报内容
  140. * @apiParam {Array} pic_name 举报凭证 用,分隔多个举报凭证
  141. *
  142. * @apiSuccess {String} code 返回码,10000为成功
  143. * @apiSuccess {String} message 返回消息
  144. */
  145. public function inform_save()
  146. {
  147. //检查当前用户是否允许举报
  148. $this->check_member_allow_inform();
  149. $goods_id = intval(input('post.inform_goods_id'));
  150. //获取商品详细信息
  151. $goods_info = $this->get_goods_info_byid($goods_id);
  152. $seller_model = model('seller');
  153. $seller_info = $seller_model->getSellerInfo(array('member_id' => $this->member_info['member_id']));
  154. //检查是否是本店商品
  155. if (!$seller_info) {
  156. if ($goods_info['store_id'] == $seller_info['store_id']) {
  157. ds_json_encode(10001, lang('param_error'));
  158. }
  159. }
  160. //实例化举报模型
  161. $inform_model = model('inform');
  162. //检查是否当前正在举报
  163. if ($inform_model->isProcessOfInform($goods_id)) {
  164. ds_json_encode(10001, lang('inform_handling'));
  165. }
  166. //处理用户输入的数据
  167. $input = array();
  168. $input['inform_member_id'] = $this->member_info['member_id'];
  169. $input['inform_member_name'] = $this->member_info['member_name'];
  170. $input['inform_goods_id'] = $goods_id;
  171. $input['inform_goods_name'] = $goods_info['goods_name'];
  172. $input['inform_goods_image'] = $goods_info['goods_image'];
  173. list($input['informsubject_id'], $input['informsubject_content']) = explode(",", trim(input('post.inform_subject')));
  174. $input['inform_content'] = trim(input('post.inform_content'));
  175. $pic_name = input('post.pic_name/a');
  176. $input['inform_pic1'] = isset($pic_name[0]) ? $pic_name[0] : '';
  177. $input['inform_pic2'] = isset($pic_name[1]) ? $pic_name[1] : '';
  178. $input['inform_pic3'] = isset($pic_name[2]) ? $pic_name[2] : '';
  179. $input['inform_datetime'] = TIMESTAMP;
  180. $input['inform_store_id'] = $goods_info['store_id'];
  181. $input['inform_store_name'] = $goods_info['store_name'];
  182. $input['inform_state'] = 1;
  183. $input['inform_handle_message'] = '';
  184. $input['inform_handle_member_id'] = 0;
  185. $input['inform_handle_datetime'] = 1;
  186. //验证输入的数据
  187. $data = [
  188. 'inform_content' => $input["inform_content"],
  189. 'informsubject_content' => $input["informsubject_content"]
  190. ];
  191. $res = word_filter($input['inform_content']);
  192. if (!$res['code']) {
  193. ds_json_encode(10001, $res['msg']);
  194. }
  195. $input['inform_content'] = $res['data']['text'];
  196. $inform_validate = ds_validate('inform');
  197. if (!$inform_validate->scene('inform_save')->check($data)) {
  198. ds_json_encode(10001, $inform_validate->getError());
  199. }
  200. //保存
  201. if ($inform_model->addInform($input)) {
  202. ds_json_encode(10000, lang('inform_success'));
  203. } else {
  204. ds_json_encode(10001, lang('inform_fail'));
  205. }
  206. }
  207. /**
  208. * @api {POST} api/Memberinform/inform_cancel 取消用户提交的商品举报
  209. * @apiVersion 1.0.0
  210. * @apiGroup Memberinform
  211. *
  212. * @apiHeader {String} X-DS-KEY 用户授权token
  213. *
  214. * @apiParam {Int} inform_id 举报ID
  215. *
  216. * @apiSuccess {String} code 返回码,10000为成功
  217. * @apiSuccess {String} message 返回消息
  218. */
  219. public function inform_cancel()
  220. {
  221. $inform_id = intval(input('param.inform_id'));
  222. $inform_info = $this->get_inform_info($inform_id);
  223. if (intval($inform_info['inform_state']) === 1) {
  224. $pics = array();
  225. if (!empty($inform_info['inform_pic1'])) {
  226. $pics[] = $inform_info['inform_pic1'];
  227. }
  228. if (!empty($inform_info['inform_pic2'])) {
  229. $pics[] = $inform_info['inform_pic2'];
  230. }
  231. if (!empty($inform_info['inform_pic3'])) {
  232. $pics[] = $inform_info['inform_pic3'];
  233. }
  234. $this->drop_inform($inform_id, $pics);
  235. ds_json_encode(10000, lang('inform_cancel_success'));
  236. } else {
  237. ds_json_encode(10001, lang('inform_cancel_fail'));
  238. }
  239. }
  240. /**
  241. * @api {POST} api/Memberinform/inform_info 商品举报详细
  242. * @apiVersion 1.0.0
  243. * @apiGroup Memberinform
  244. *
  245. * @apiHeader {String} X-DS-KEY 用户授权token
  246. *
  247. * @apiParam {Int} inform_id 举报ID
  248. *
  249. * @apiSuccess {String} code 返回码,10000为成功
  250. * @apiSuccess {String} message 返回消息
  251. * @apiSuccess {Object} result 返回数据
  252. * @apiSuccess {Object} result.goods_info 商品信息
  253. * @apiSuccess {Int} result.goods_info.areaid_1 一级地区id
  254. * @apiSuccess {Int} result.goods_info.areaid_2 二级地区id
  255. * @apiSuccess {Int} result.goods_info.brand_id 品牌ID
  256. * @apiSuccess {Int} result.goods_info.color_id 颜色规格值ID
  257. * @apiSuccess {Int} result.goods_info.evaluation_count 评论数
  258. * @apiSuccess {Int} result.goods_info.evaluation_good_star 好评评分
  259. * @apiSuccess {Int} result.goods_info.gc_id 分类ID
  260. * @apiSuccess {Int} result.goods_info.gc_id_1 一级分类ID
  261. * @apiSuccess {Int} result.goods_info.gc_id_2 二级分类ID
  262. * @apiSuccess {Int} result.goods_info.gc_id_3 三级分类ID
  263. * @apiSuccess {String} result.goods_info.goods_addtime 添加时间,Unix时间戳
  264. * @apiSuccess {String} result.goods_info.goods_advword 广告词
  265. * @apiSuccess {Int} result.goods_info.goods_click 商品点击次数
  266. * @apiSuccess {Int} result.goods_info.goods_collect 收藏数
  267. * @apiSuccess {Int} result.goods_info.goods_commend 商品推荐 1:是 0:否
  268. * @apiSuccess {Int} result.goods_info.goods_commonid 商品公共ID
  269. * @apiSuccess {Int} result.goods_info.goods_edittime 编辑时间,Unix时间戳
  270. * @apiSuccess {Float} result.goods_info.goods_freight 运费
  271. * @apiSuccess {Int} result.goods_info.goods_id 商品ID
  272. * @apiSuccess {String} result.goods_info.goods_image 商品图片名称
  273. * @apiSuccess {Float} result.goods_info.goods_marketprice 商品市场价
  274. * @apiSuccess {String} result.goods_info.goods_mgdiscount 会员等级折扣
  275. * @apiSuccess {String} result.goods_info.goods_name 商品名称
  276. * @apiSuccess {Float} result.goods_info.goods_price 商品价格
  277. * @apiSuccess {Float} result.goods_info.goods_promotion_price 商品促销价
  278. * @apiSuccess {String} result.goods_info.goods_promotion_type 商品促销类型
  279. * @apiSuccess {Int} result.goods_info.goods_salenum 销售量
  280. * @apiSuccess {String} result.goods_info.goods_serial 货号
  281. * @apiSuccess {String} result.goods_info.goods_spec 商品规格序列化
  282. * @apiSuccess {String} result.goods_info.goods_state 商品状态 0:下架 1:正常 10:违规(禁售)
  283. * @apiSuccess {String} result.goods_info.goods_stcids 店铺分类id 首尾用,隔开
  284. * @apiSuccess {Int} result.goods_info.goods_storage 库存
  285. * @apiSuccess {Int} result.goods_info.goods_storage_alarm 预警库存
  286. * @apiSuccess {Int} result.goods_info.goods_vat 是否开具增值税发票 1:是 0:否
  287. * @apiSuccess {Object} result.goods_info.goods_verify 已审核 1是0否
  288. * @apiSuccess {Int} result.goods_info.is_appoint 是否是预约商品 1:是 0:否
  289. * @apiSuccess {Int} result.goods_info.is_goodsfcode 是否是F码商品 1:是 0:否
  290. * @apiSuccess {Int} result.goods_info.is_have_gift 是否含赠品 1:是 0:否
  291. * @apiSuccess {Int} result.goods_info.is_platform_store 是否自营商品 1:是 0:否
  292. * @apiSuccess {Int} result.goods_info.is_virtual 是否是虚拟商品 1:是 0:否
  293. * @apiSuccess {Int} result.goods_info.region_id 地区ID
  294. * @apiSuccess {Int} result.goods_info.store_id 店铺ID
  295. * @apiSuccess {String} result.goods_info.store_name 店铺名称
  296. * @apiSuccess {Int} result.goods_info.transport_id 商品售卖区域ID
  297. * @apiSuccess {Int} result.goods_info.virtual_indate 虚拟商品有效期
  298. * @apiSuccess {Int} result.goods_info.virtual_invalid_refund 是否允许过期退款 1:是 0:否
  299. * @apiSuccess {Int} result.goods_info.virtual_limit 虚拟商品购买上限
  300. * @apiSuccess {Object} result.inform_info 举报信息
  301. * @apiSuccess {String} result.inform_info.inform_content 举报内容
  302. * @apiSuccess {Int} result.inform_info.inform_datetime 举报时间
  303. * @apiSuccess {Int} result.inform_info.inform_goods_id 商品ID
  304. * @apiSuccess {String} result.inform_info.inform_goods_image 商品图片名称
  305. * @apiSuccess {String} result.inform_info.inform_goods_image_url 商品图片完整路径
  306. * @apiSuccess {String} result.inform_info.inform_goods_name 商品名称
  307. * @apiSuccess {Int} result.inform_info.inform_handle_datetime 处理时间
  308. * @apiSuccess {Int} result.inform_info.inform_handle_member_id 处理用户ID
  309. * @apiSuccess {String} result.inform_info.inform_handle_message 处理描述
  310. * @apiSuccess {Int} result.inform_info.inform_handle_type 举报处理结果(1无效举报/2恶意举报/3有效举报)
  311. * @apiSuccess {Int} result.inform_info.inform_id 举报ID
  312. * @apiSuccess {Int} result.inform_info.inform_member_id 举报用户ID
  313. * @apiSuccess {String} result.inform_info.inform_member_name 举报用户名称
  314. * @apiSuccess {String} result.inform_info.inform_pic1 举报凭证1
  315. * @apiSuccess {String} result.inform_info.inform_pic2 举报凭证2
  316. * @apiSuccess {String} result.inform_info.inform_pic3 举报凭证3
  317. * @apiSuccess {Int} result.inform_info.inform_state 举报状态(1未处理/2已处理)
  318. * @apiSuccess {Int} result.inform_info.inform_store_id 店铺ID
  319. * @apiSuccess {String} result.inform_info.inform_store_name 店铺名称
  320. * @apiSuccess {String} result.inform_info.informsubject_content 举报主题内容
  321. * @apiSuccess {Int} result.inform_info.informsubject_id 举报主题ID
  322. * @apiSuccess {String[]} result.inform_pic 举报凭证列表
  323. * @apiSuccess {Object} result.subject_info 举报主题信息
  324. * @apiSuccess {String} result.subject_info.informsubject_content 举报主题内容
  325. * @apiSuccess {Int} result.subject_info.informsubject_id 举报主题ID
  326. * @apiSuccess {Int} result.subject_info.informsubject_state 举报主题状态
  327. * @apiSuccess {Int} result.subject_info.informsubject_type_id 举报类型ID
  328. * @apiSuccess {String} result.subject_info.informsubject_type_name 举报类型名称
  329. */
  330. public function inform_info()
  331. {
  332. $inform_id = intval(input('param.inform_id'));
  333. $inform_info = $this->get_inform_info($inform_id);
  334. switch ($inform_info['inform_handle_type']) {
  335. case 1:
  336. $inform_info['inform_handle_type_text'] = lang('inform_handle_type_unuse');
  337. break;
  338. case 2:
  339. $inform_info['inform_handle_type_text'] = lang('inform_handle_type_venom');
  340. break;
  341. case 3:
  342. $inform_info['inform_handle_type_text'] = lang('inform_handle_type_valid');
  343. break;
  344. }
  345. // 商品信息
  346. $goods_info = model('goods')->getGoodsInfoByID($inform_info['inform_goods_id']);
  347. // 投诉类型
  348. $subject_info = model('informsubject')->getOneInformsubject(array('informsubject_id' => $inform_info['informsubject_id']));
  349. $inform_pic = array();
  350. for ($i = 1; $i <= 3; $i++) {
  351. if (!empty($inform_info['inform_pic' . $i])) {
  352. $inform_pic[] = ds_get_pic(ATTACH_PATH . DIRECTORY_SEPARATOR . 'inform', $inform_info['inform_pic' . $i]);
  353. }
  354. }
  355. ds_json_encode(10000, '', array('inform_pic' => $inform_pic, 'goods_info' => $goods_info, 'inform_info' => $inform_info, 'subject_info' => $subject_info));
  356. }
  357. /*
  358. * 根据id获取投诉详细信息
  359. */
  360. private function get_inform_info($inform_id)
  361. {
  362. if (empty($inform_id)) {
  363. ds_json_encode(10001, lang('param_error'));
  364. }
  365. $inform_model = model('inform');
  366. $inform_info = $inform_model->getOneInform(array('inform_id' => $inform_id));
  367. if (empty($inform_info)) {
  368. ds_json_encode(10001, lang('param_error'));
  369. }
  370. if (intval($inform_info['inform_member_id']) !== intval($this->member_info['member_id'])) {
  371. ds_json_encode(10001, lang('param_error'));
  372. }
  373. return $inform_info;
  374. }
  375. /*
  376. * 根据id获取投诉详细信息
  377. */
  378. private function drop_inform($inform_id, $inform_pics)
  379. {
  380. $inform_model = model('inform');
  381. //删除图片
  382. if (!empty($inform_pics)) {
  383. foreach ($inform_pics as $pic) {
  384. $this->inform_delete_pic($pic);
  385. }
  386. }
  387. $inform_model->delInform(array('inform_id' => $inform_id));
  388. }
  389. /*
  390. * 根据id获取商品详细信息
  391. */
  392. private function get_goods_info_byid($goods_id)
  393. {
  394. if (empty($goods_id)) {
  395. ds_json_encode(10001, lang('param_error'));
  396. }
  397. $goods_model = model('goods');
  398. $goods_info = $goods_model->getGoodsOnlineInfoByID($goods_id);
  399. //检查该商品是否存在
  400. if (empty($goods_info)) {
  401. ds_json_encode(10001, lang('goods_null'));
  402. }
  403. return $goods_info;
  404. }
  405. /*
  406. * 检查当前用户是否允许举报
  407. */
  408. private function check_member_allow_inform()
  409. {
  410. //检查是否允许举报
  411. $member_model = model('member');
  412. if (!$member_model->isMemberAllowInform($this->member_info['member_id'])) {
  413. ds_json_encode(10001, lang('deny_inform'));
  414. }
  415. }
  416. /**
  417. * @api {POST} api/Memberinform/upload_pic 上传用户提供的举报图片
  418. * @apiVersion 1.0.0
  419. * @apiGroup Memberinform
  420. *
  421. * @apiHeader {String} X-DS-KEY 用户授权token
  422. *
  423. * @apiParam {File} inform_pic 举报凭证
  424. *
  425. * @apiSuccess {String} code 返回码,10000为成功
  426. * @apiSuccess {String} message 返回消息
  427. * @apiSuccess {Object} result 返回数据
  428. * @apiSuccess {String} result.file_name 文件名称
  429. * @apiSuccess {String} result.pic 文件完整路径
  430. */
  431. public function upload_pic()
  432. {
  433. if (!empty($_FILES['inform_pic']['name'])) {
  434. $file_name = $this->member_info['member_id'] . '_' . date('YmdHis') . rand(10000, 99999) . '.png';
  435. $res = ds_upload_pic('home' . DIRECTORY_SEPARATOR . 'inform', 'inform_pic', $file_name);
  436. if ($res['code']) {
  437. $file_name = $res['data']['file_name'];
  438. } else {
  439. ds_json_encode(10001, $res['msg']);
  440. }
  441. $pic = ds_get_pic(ATTACH_PATH . DIRECTORY_SEPARATOR . 'inform', $file_name);
  442. ds_json_encode(10000, '', array('file_name' => $file_name, 'pic' => $pic));
  443. } else {
  444. ds_json_encode(10001, lang('file_empty'));
  445. }
  446. }
  447. /*
  448. * 上传用户提供的举报图片
  449. */
  450. private function inform_delete_pic($pic_name)
  451. {
  452. //上传路径
  453. $pic = BASE_UPLOAD_PATH . DIRECTORY_SEPARATOR . ATTACH_PATH . DIRECTORY_SEPARATOR . 'inform' . DIRECTORY_SEPARATOR . $pic_name;
  454. if (file_exists($pic)) {
  455. @unlink($pic);
  456. }
  457. }
  458. /**
  459. * @api {POST} api/Memberinform/get_subject_by_typeid 根据举报类型id获取,举报具体列表
  460. * @apiVersion 1.0.0
  461. * @apiGroup Memberinform
  462. *
  463. * @apiHeader {String} X-DS-KEY 用户授权token
  464. *
  465. * @apiParam {Int} type_id 类型ID
  466. *
  467. * @apiSuccess {String} code 返回码,10000为成功
  468. * @apiSuccess {String} message 返回消息
  469. * @apiSuccess {Object} result 返回数据
  470. * @apiSuccess {Object[]} result.inform_subject_list 举报主题列表
  471. * @apiSuccess {String} result.inform_subject_list.informsubject_content 举报主题内容
  472. * @apiSuccess {Int} result.inform_subject_list.informsubject_id 举报主题ID
  473. */
  474. public function get_subject_by_typeid()
  475. {
  476. $informsubject_type_id = intval(input('param.type_id'));
  477. if (empty($informsubject_type_id)) {
  478. ds_json_encode(10001, lang('param_error'));
  479. } else {
  480. /*
  481. * 获得举报主题列表
  482. */
  483. $informsubject_model = model('informsubject');
  484. //搜索条件
  485. $condition = array();
  486. $condition[] = array('informsubject_type_id', '=', $informsubject_type_id);
  487. $condition[] = array('informsubject_state', '=', 1);
  488. $inform_subject_list = $informsubject_model->getInformsubjectList($condition, 10, 'informsubject_id,informsubject_content');
  489. ds_json_encode(10000, '', array('inform_subject_list' => $inform_subject_list));
  490. }
  491. }
  492. }