Memberinform.php 24 KB

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