Memberinform.php 24 KB

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