Membercomplain.php 40 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723
  1. <?php
  2. /*
  3. * 交易投诉
  4. */
  5. namespace app\api\controller;
  6. use think\facade\Lang;
  7. /**
  8. *
  9. *
  10. * ----------------------------------------------------------------------------
  11. *
  12. * 投诉控制器
  13. */
  14. class Membercomplain extends MobileMember
  15. {
  16. //定义投诉状态常量
  17. const STATE_NEW = 10;
  18. const STATE_APPEAL = 20;
  19. const STATE_TALK = 30;
  20. const STATE_HANDLE = 40;
  21. const STATE_FINISH = 99;
  22. const STATE_UNACTIVE = 1;
  23. const STATE_ACTIVE = 2;
  24. public function initialize()
  25. {
  26. parent::initialize();
  27. Lang::load(base_path() . 'home/lang/' . config('lang.default_lang') . '/membercomplain.lang.php');
  28. }
  29. /**
  30. * @api {POST} api/Membercomplain/index 投诉列表
  31. * @apiVersion 1.0.0
  32. * @apiGroup Membercomplain
  33. *
  34. * @apiHeader {String} X-DS-KEY 用户授权token
  35. *
  36. * @apiParam {Int} per_page 每页显示数量
  37. * @apiParam {Int} page 当前页数
  38. *
  39. * @apiSuccess {String} code 返回码,10000为成功
  40. * @apiSuccess {String} message 返回消息
  41. * @apiSuccess {Object} result 返回数据
  42. * @apiSuccess {Object[]} result.complaint_list 投诉列表
  43. * @apiSuccess {Int} result.complaint_list.accused_id 被告ID
  44. * @apiSuccess {String} result.complaint_list.accused_name 被告名称
  45. * @apiSuccess {Int} result.complaint_list.accuser_id 原告ID
  46. * @apiSuccess {String} result.complaint_list.accuser_name 原告用户名
  47. * @apiSuccess {Int} result.complaint_list.appeal_datetime 申诉时间,Unix时间戳
  48. * @apiSuccess {String} result.complaint_list.appeal_message 申诉内容
  49. * @apiSuccess {String} result.complaint_list.appeal_pic1 申诉图片1
  50. * @apiSuccess {String} result.complaint_list.appeal_pic2 申诉图片2
  51. * @apiSuccess {String} result.complaint_list.appeal_pic3 申诉图片3
  52. * @apiSuccess {Int} result.complaint_list.complain_active 投诉是否通过平台审批 1:未通过 2:通过
  53. * @apiSuccess {String} result.complaint_list.complain_content 投诉内容
  54. * @apiSuccess {Int} result.complaint_list.complain_datetime 投诉时间,Unix时间戳
  55. * @apiSuccess {Int} result.complaint_list.complain_handle_datetime 投诉处理时间,Unix时间戳
  56. * @apiSuccess {Int} result.complaint_list.complain_handle_member_id 投诉处理人ID
  57. * @apiSuccess {Int} result.complaint_list.complain_id 投诉ID
  58. * @apiSuccess {String} result.complaint_list.complain_pic1 投诉图片1
  59. * @apiSuccess {String} result.complaint_list.complain_pic2 投诉图片2
  60. * @apiSuccess {String} result.complaint_list.complain_pic3 投诉图片3
  61. * @apiSuccess {Int} result.complaint_list.complain_state 投诉状态 10:新投诉 20:投诉通过转给被投诉人 30:被投诉人已申诉 40:提交仲裁 99:已关闭
  62. * @apiSuccess {String} result.complaint_list.complain_subject_content 投诉主题
  63. * @apiSuccess {Int} result.complaint_list.complain_subject_id 投诉主题id
  64. * @apiSuccess {Int} result.complaint_list.final_handle_datetime 最终处理时间,Unix时间戳
  65. * @apiSuccess {Int} result.complaint_list.final_handle_member_id 最终处理人ID
  66. * @apiSuccess {String} result.complaint_list.final_handle_message 最终处理意见
  67. * @apiSuccess {Int} result.complaint_list.order_goods_id 订单商品ID
  68. * @apiSuccess {Int} result.complaint_list.order_id 订单ID
  69. * @apiSuccess {Object} result.goods_list 投诉商品列表,键为订单商品ID
  70. * @apiSuccess {Int} result.goods_list.buyer_id 买家ID
  71. * @apiSuccess {Float} result.goods_list.commis_rate 商品分类佣金比例
  72. * @apiSuccess {Int} result.goods_list.gc_id 分类ID
  73. * @apiSuccess {Int} result.goods_list.goods_id 商品ID
  74. * @apiSuccess {String} result.goods_list.goods_image 商品图片名称
  75. * @apiSuccess {String} result.goods_list.goods_image_url 商品图片完整地址
  76. * @apiSuccess {String} result.goods_list.goods_name 商品名称
  77. * @apiSuccess {Int} result.goods_list.goods_num 购买数量
  78. * @apiSuccess {Float} result.goods_list.goods_pay_price 商品实际支付金额
  79. * @apiSuccess {Float} result.goods_list.goods_price 商品价格
  80. * @apiSuccess {Int} result.goods_list.goods_type 商品类型 1默认2抢购商品3秒杀商品4组合套装5赠品6拼团7会员等级折扣
  81. * @apiSuccess {Int} result.goods_list.order_id 订单ID
  82. * @apiSuccess {Int} result.goods_list.promotions_id 促销ID
  83. * @apiSuccess {Int} result.goods_list.rec_id 订单商品表自增ID
  84. * @apiSuccess {Int} result.goods_list.store_id 店铺ID
  85. * @apiSuccess {Int} result.page_total 总页数
  86. * @apiSuccess {Boolean} result.hasmore 是否有更多 true是false否
  87. */
  88. public function index()
  89. {
  90. /*
  91. * 得到当前用户的投诉列表
  92. */
  93. $complain_model = model('complain');
  94. $condition = array();
  95. $condition[] = array('accuser_id', '=', $this->member_info['member_id']);
  96. switch (intval(input('param.select_complain_state'))) {
  97. case 1:
  98. $condition[] = array('complain_state', '<', 90);
  99. break;
  100. case 2:
  101. $condition[] = array('complain_state', '=', 99);
  102. break;
  103. }
  104. $complain_list = $complain_model->getComplainList($condition, $this->pagesize);
  105. $goods_list = $complain_model->getComplainGoodsList($complain_list);
  106. foreach ($goods_list as $key => $val) {
  107. $goods_list[$key]['goods_image_url'] = goods_thumb($val, 240);
  108. }
  109. $result = array_merge(array('complaint_list' => $complain_list, 'goods_list' => $goods_list), mobile_page($complain_model->page_info));
  110. ds_json_encode(10000, '', $result);
  111. }
  112. public function common_data($order_id, $goods_id)
  113. {
  114. //获取投诉类型
  115. $complainsubject_model = model('complainsubject');
  116. $param = array();
  117. $complain_subject_list = $complainsubject_model->getActiveComplainsubject($param);
  118. if (empty($complain_subject_list)) {
  119. ds_json_encode(10001, lang('complain_subject_error'));
  120. }
  121. $condition = array();
  122. $condition[] = array('buyer_id', '=', $this->member_info['member_id']);
  123. $condition[] = array('order_id', '=', $order_id);
  124. $refundreturn_model = model('refundreturn');
  125. $order_info = $refundreturn_model->getRightOrderList($condition, $goods_id);
  126. $order_info['extend_order_goods'] = $order_info['goods_list'];
  127. $order_list[$order_id] = $order_info;
  128. $order_list = $refundreturn_model->getGoodsRefundList($order_list);
  129. if (isset($order_list[$order_id]['extend_complain'][$goods_id]) && intval($order_list[$order_id]['extend_complain'][$goods_id]) == 1) { //退款投诉
  130. $complainsubject_model = model('complainsubject');
  131. $complain_subject = $complainsubject_model->getComplainsubject(array('complainsubject_id' => 1)); //投诉主题
  132. $complain_subject_list = array_merge($complain_subject, $complain_subject_list);
  133. }
  134. return array('subject_list' => $complain_subject_list);
  135. }
  136. /**
  137. * @api {POST} api/Membercomplain/get_common_data 新增/编辑投诉公共数据
  138. * @apiVersion 1.0.0
  139. * @apiGroup Membercomplain
  140. *
  141. * @apiHeader {String} X-DS-KEY 用户授权token
  142. *
  143. * @apiSuccess {String} code 返回码,10000为成功
  144. * @apiSuccess {String} message 返回消息
  145. * @apiSuccess {Object} result 返回数据
  146. * @apiSuccess {Object[]} result.subject_list 投诉主题列表
  147. * @apiSuccess {String} result.subject_list.complainsubject_content 投诉主题内容
  148. * @apiSuccess {String} result.subject_list.complainsubject_desc 投诉主题描述
  149. * @apiSuccess {Int} result.subject_list.complainsubject_id 投诉主题ID
  150. * @apiSuccess {Int} result.subject_list.complainsubject_state 投诉主题状态 1:有效 2:失效
  151. */
  152. public function get_common_data()
  153. {
  154. $order_id = intval(input('param.order_id'));
  155. $goods_id = intval(input('param.goods_id'));
  156. $common_data = $this->common_data($order_id, $goods_id);
  157. ds_json_encode(10000, '', $common_data);
  158. }
  159. /**
  160. * @api {POST} api/Membercomplain/complain_show 获取投诉信息
  161. * @apiVersion 1.0.0
  162. * @apiGroup Membercomplain
  163. *
  164. * @apiHeader {String} X-DS-KEY 用户授权token
  165. *
  166. * @apiParam {Int} complain_id 投诉ID
  167. *
  168. * @apiSuccess {String} code 返回码,10000为成功
  169. * @apiSuccess {String} message 返回消息
  170. * @apiSuccess {Object} result 返回数据
  171. * @apiSuccess {String[]} result.appeal_pic 申诉凭证图片列表
  172. * @apiSuccess {String[]} result.complain_pic 投诉凭证图片列表
  173. * @apiSuccess {Object} result.complain_info 投诉信息
  174. * @apiSuccess {Int} result.complain_info.accused_id 被告ID
  175. * @apiSuccess {String} result.complain_info.accused_name 被告名称
  176. * @apiSuccess {Int} result.complain_info.accuser_id 原告ID
  177. * @apiSuccess {String} result.complain_info.accuser_name 原告用户名
  178. * @apiSuccess {Int} result.complain_info.appeal_datetime 申诉时间,Unix时间戳
  179. * @apiSuccess {String} result.complain_info.appeal_message 申诉内容
  180. * @apiSuccess {String} result.complain_info.appeal_pic1 申诉图片1
  181. * @apiSuccess {String} result.complain_info.appeal_pic2 申诉图片2
  182. * @apiSuccess {String} result.complain_info.appeal_pic3 申诉图片3
  183. * @apiSuccess {Int} result.complain_info.complain_active 投诉是否通过平台审批 1:未通过 2:通过
  184. * @apiSuccess {String} result.complain_info.complain_content 投诉内容
  185. * @apiSuccess {Int} result.complain_info.complain_datetime 投诉时间,Unix时间戳
  186. * @apiSuccess {Int} result.complain_info.complain_handle_datetime 投诉处理时间,Unix时间戳
  187. * @apiSuccess {Int} result.complain_info.complain_handle_member_id 投诉处理人ID
  188. * @apiSuccess {Int} result.complain_info.complain_id 投诉ID
  189. * @apiSuccess {String} result.complain_info.complain_pic1 投诉图片1
  190. * @apiSuccess {String} result.complain_info.complain_pic2 投诉图片2
  191. * @apiSuccess {String} result.complain_info.complain_pic3 投诉图片3
  192. * @apiSuccess {Int} result.complain_info.complain_state 投诉状态 10:新投诉 20:投诉通过转给被投诉人 30:被投诉人已申诉 40:提交仲裁 99:已关闭
  193. * @apiSuccess {String} result.complain_info.complain_subject_content 投诉主题
  194. * @apiSuccess {Int} result.complain_info.complain_subject_id 投诉主题id
  195. * @apiSuccess {Int} result.complain_info.final_handle_datetime 最终处理时间,Unix时间戳
  196. * @apiSuccess {Int} result.complain_info.final_handle_member_id 最终处理人ID
  197. * @apiSuccess {String} result.complain_info.final_handle_message 最终处理意见
  198. * @apiSuccess {Int} result.complain_info.order_goods_id 订单商品ID
  199. * @apiSuccess {Int} result.complain_info.order_id 订单ID
  200. * @apiSuccess {Object} result.return_info 退款信息
  201. * @apiSuccess {Int} result.return_info.add_time 退款添加时间
  202. * @apiSuccess {String} result.return_info.buyer_email 买家邮箱
  203. * @apiSuccess {Int} result.return_info.buyer_id 买家ID
  204. * @apiSuccess {String} result.return_info.buyer_name 买家用户名
  205. * @apiSuccess {Int} result.return_info.delay_time 自动收货时间
  206. * @apiSuccess {Int} result.return_info.delete_state 订单删除状态 0:未删除 1:放入回收站 2:彻底删除
  207. * @apiSuccess {Int} result.return_info.evaluation_state 评论状态
  208. * @apiSuccess {Object} result.return_info.extend_order_common 订单公共信息
  209. * @apiSuccess {Int} result.return_info.extend_order_common.daddress_id 发货地址ID
  210. * @apiSuccess {String} result.return_info.extend_order_common.deliver_explain 订单发货备注
  211. * @apiSuccess {Int} result.return_info.extend_order_common.evalseller_state 卖家是否已评价买家
  212. * @apiSuccess {Int} result.return_info.extend_order_common.evalseller_time 卖家评价买家的时间
  213. * @apiSuccess {Int} result.return_info.extend_order_common.evaluation_time 评价时间
  214. * @apiSuccess {String} result.return_info.extend_order_common.invoice_info 订单发票信息
  215. * @apiSuccess {Int} result.return_info.extend_order_common.order_id 订单ID
  216. * @apiSuccess {String} result.return_info.extend_order_common.order_message 订单留言
  217. * @apiSuccess {Int} result.return_info.extend_order_common.order_pointscount 订单赠送积分
  218. * @apiSuccess {String} result.return_info.extend_order_common.promotion_info 订单促销信息备注
  219. * @apiSuccess {Int} result.return_info.extend_order_common.reciver_city_id 收货人市级ID
  220. * @apiSuccess {String} result.return_info.extend_order_common.reciver_info 收货人其它信息
  221. * @apiSuccess {String} result.return_info.extend_order_common.reciver_info.address 收货地址
  222. * @apiSuccess {String} result.return_info.extend_order_common.reciver_info.area 收货地区
  223. * @apiSuccess {String} result.return_info.extend_order_common.reciver_info.mob_phone 收货人手机号
  224. * @apiSuccess {String} result.return_info.extend_order_common.reciver_info.phone 收货人联系号码
  225. * @apiSuccess {String} result.return_info.extend_order_common.reciver_info.street 街道地址
  226. * @apiSuccess {String} result.return_info.extend_order_common.reciver_info.tel_phone 座机号
  227. * @apiSuccess {String} result.return_info.extend_order_common.reciver_name 收货人姓名
  228. * @apiSuccess {Int} result.return_info.extend_order_common.reciver_province_id 收货地区省ID
  229. * @apiSuccess {Int} result.return_info.extend_order_common.shipping_express_id 配送公司ID
  230. * @apiSuccess {Int} result.return_info.extend_order_common.shipping_time 发货时间
  231. * @apiSuccess {Int} result.return_info.extend_order_common.store_id 店铺ID
  232. * @apiSuccess {String} result.return_info.extend_order_common.voucher_code 代金券编码
  233. * @apiSuccess {Int} result.return_info.extend_order_common.voucher_price 代金券面额
  234. * @apiSuccess {Object} result.return_info.extend_store 店铺信息
  235. * @apiSuccess {String} result.return_info.extend_store.area_info 店铺地区
  236. * @apiSuccess {Int} result.return_info.extend_store.bind_all_gc 是否绑定所有分类 0否1是
  237. * @apiSuccess {String} result.return_info.extend_store.deliver_region 店铺默认配送区域
  238. * @apiSuccess {Int} result.return_info.extend_store.goods_count 商品数量
  239. * @apiSuccess {Int} result.return_info.extend_store.grade_id 等级ID
  240. * @apiSuccess {Int} result.return_info.extend_store.is_platform_store 是否自营店 0否1是
  241. * @apiSuccess {String} result.return_info.extend_store.mb_sliders 手机店铺轮播图序列化字符串
  242. * @apiSuccess {String} result.return_info.extend_store.mb_title_img 手机店铺背景图
  243. * @apiSuccess {Int} result.return_info.extend_store.member_id 店铺用户ID
  244. * @apiSuccess {String} result.return_info.extend_store.member_name 店铺用户名
  245. * @apiSuccess {Int} result.return_info.extend_store.region_id 店铺地区ID
  246. * @apiSuccess {String} result.return_info.extend_store.seller_name 卖家用户名
  247. * @apiSuccess {String} result.return_info.extend_store.store_address 店铺地址
  248. * @apiSuccess {Int} result.return_info.extend_store.store_addtime 店铺添加时间
  249. * @apiSuccess {Object[]} result.return_info.extend_store.store_aftersales 售后列表
  250. * @apiSuccess {String} result.return_info.extend_store.store_aftersales.name 售后名称
  251. * @apiSuccess {String} result.return_info.extend_store.store_aftersales.num 售后账号
  252. * @apiSuccess {String} result.return_info.extend_store.store_aftersales.type 售后类型 1QQ2旺旺3站内IM
  253. * @apiSuccess {Float} result.return_info.extend_store.store_avaliable_deposit 可用保证金
  254. * @apiSuccess {Float} result.return_info.extend_store.store_avaliable_money 可用预存款
  255. * @apiSuccess {String} result.return_info.extend_store.store_avatar 店铺头像
  256. * @apiSuccess {String} result.return_info.extend_store.store_banner 店铺背景图
  257. * @apiSuccess {Int} result.return_info.extend_store.store_baozh 是否已缴保证金 0否1是
  258. * @apiSuccess {Int} result.return_info.extend_store.store_bill_time 上次结算时间
  259. * @apiSuccess {String} result.return_info.extend_store.store_close_info 店铺关闭原因
  260. * @apiSuccess {Int} result.return_info.extend_store.store_collect 店铺收藏数量
  261. * @apiSuccess {String} result.return_info.extend_store.store_company_name 店铺公司名称
  262. * @apiSuccess {Object} result.return_info.extend_store.store_credit 店铺信用信息
  263. * @apiSuccess {String} result.return_info.extend_store.store_credit.store_deliverycredit 发货速度信息
  264. * @apiSuccess {Int} result.return_info.extend_store.store_credit.store_deliverycredit.credit 发货速度评分
  265. * @apiSuccess {String} result.return_info.extend_store.store_credit.store_deliverycredit.text 发货速度描述
  266. * @apiSuccess {Object} result.return_info.extend_store.store_credit.store_desccredit 描述相符信息
  267. * @apiSuccess {Int} result.return_info.extend_store.store_credit.store_desccredit.credit 描述相符评分
  268. * @apiSuccess {String} result.return_info.extend_store.store_credit.store_desccredit.text 描述相符描述
  269. * @apiSuccess {Object} result.return_info.extend_store.store_credit.store_servicecredit 服务态度信息
  270. * @apiSuccess {Int} result.return_info.extend_store.store_credit.store_servicecredit.credit 服务态度评分
  271. * @apiSuccess {String} result.return_info.extend_store.store_credit.store_servicecredit.text 服务态度描述
  272. * @apiSuccess {Int} result.return_info.extend_store.store_credit_average 平均评分
  273. * @apiSuccess {Int} result.return_info.extend_store.store_credit_percent 好评率
  274. * @apiSuccess {Int} result.return_info.extend_store.store_deliverycredit 发货速度评分
  275. * @apiSuccess {Int} result.return_info.extend_store.store_desccredit 描述相符评分
  276. * @apiSuccess {String} result.return_info.extend_store.store_description 店铺SEO描述
  277. * @apiSuccess {Int} result.return_info.extend_store.store_endtime 店铺到期时间
  278. * @apiSuccess {Int} result.return_info.extend_store.store_erxiaoshi 是否两小时发货 0否1是
  279. * @apiSuccess {Int} result.return_info.extend_store.store_free_price 超出该金额免运费 0未设置
  280. * @apiSuccess {Int} result.return_info.extend_store.store_free_time 商家配送时间
  281. * @apiSuccess {Float} result.return_info.extend_store.store_freeze_deposit 冻结保证金
  282. * @apiSuccess {Float} result.return_info.extend_store.store_freeze_money 冻结预存款
  283. * @apiSuccess {Int} result.return_info.extend_store.store_huodaofk 是否支持货到付款 0否1是
  284. * @apiSuccess {Int} result.return_info.extend_store.store_id 店铺ID
  285. * @apiSuccess {String} result.return_info.extend_store.store_keywords 店铺SEO关键字
  286. * @apiSuccess {String} result.return_info.extend_store.store_latitude 纬度
  287. * @apiSuccess {String} result.return_info.extend_store.store_logo 店铺logo
  288. * @apiSuccess {String} result.return_info.extend_store.store_longitude 经度
  289. * @apiSuccess {String} result.return_info.extend_store.store_mainbusiness 主营商品
  290. * @apiSuccess {String} result.return_info.extend_store.store_mgdiscount 序列化会员等级折扣
  291. * @apiSuccess {Int} result.return_info.extend_store.store_mgdiscount_state 店铺是否开启序列化会员等级折扣 0否1是
  292. * @apiSuccess {String} result.return_info.extend_store.store_name 店铺名称
  293. * @apiSuccess {Float} result.return_info.extend_store.store_payable_deposit 应缴保证金
  294. * @apiSuccess {String} result.return_info.extend_store.store_phone 店铺电话
  295. * @apiSuccess {Object[]} result.return_info.extend_store.store_presales 售前列表
  296. * @apiSuccess {String} result.return_info.extend_store.store_presales.name 售前名称
  297. * @apiSuccess {String} result.return_info.extend_store.store_presales.num 售前账号
  298. * @apiSuccess {String} result.return_info.extend_store.store_presales.type 售前类型 1QQ2旺旺3站内IM
  299. * @apiSuccess {String} result.return_info.extend_store.store_printexplain 打印订单页面下方说明文字
  300. * @apiSuccess {String} result.return_info.extend_store.store_qq 店铺QQ
  301. * @apiSuccess {Int} result.return_info.extend_store.store_qtian 是否支持7天退换 0否1是
  302. * @apiSuccess {Int} result.return_info.extend_store.store_recommend 推荐店铺 0否1是
  303. * @apiSuccess {Int} result.return_info.extend_store.store_sales 销量
  304. * @apiSuccess {Int} result.return_info.extend_store.store_servicecredit 服务态度评分
  305. * @apiSuccess {Int} result.return_info.extend_store.store_shiti 实体店认证 0否1是
  306. * @apiSuccess {Int} result.return_info.extend_store.store_shiyong 是否支持试用 0否1是
  307. * @apiSuccess {String} result.return_info.extend_store.store_slide 店铺幻灯片
  308. * @apiSuccess {String} result.return_info.extend_store.store_slide_url 店铺幻灯片链接
  309. * @apiSuccess {Int} result.return_info.extend_store.store_sort 店铺排序
  310. * @apiSuccess {Int} result.return_info.extend_store.store_state 店铺状态 0关闭,1开启,2审核中
  311. * @apiSuccess {Int} result.return_info.extend_store.store_tuihuo 是否支持退货承诺 0否1是
  312. * @apiSuccess {String} result.return_info.extend_store.store_vrcode_prefix 商家兑换码前缀
  313. * @apiSuccess {String} result.return_info.extend_store.store_workingtime 工作时间
  314. * @apiSuccess {String} result.return_info.extend_store.store_ww 店铺旺旺
  315. * @apiSuccess {Int} result.return_info.extend_store.store_xiaoxie 是否消协保证 0否1是
  316. * @apiSuccess {Int} result.return_info.extend_store.store_zhping 是否正品保障 0否1是
  317. * @apiSuccess {String} result.return_info.extend_store.store_zip 邮政编码
  318. * @apiSuccess {Int} result.return_info.extend_store.storeclass_id 店铺分类ID
  319. * @apiSuccess {Int} result.return_info.finnshed_time 订单完成时间
  320. * @apiSuccess {Float} result.return_info.goods_amount 商品总额
  321. * @apiSuccess {Object[]} result.return_info.goods_list 商品列表
  322. * @apiSuccess {Int} result.return_info.goods_list.buyer_id 买家ID
  323. * @apiSuccess {Float} result.return_info.goods_list.commis_rate 佣金比例
  324. * @apiSuccess {Int} result.return_info.goods_list.gc_id 分类ID
  325. * @apiSuccess {Int} result.return_info.goods_list.goods_id 商品ID
  326. * @apiSuccess {String} result.return_info.goods_list.goods_image 商品图片
  327. * @apiSuccess {String} result.return_info.goods_list.goods_name 商品名称
  328. * @apiSuccess {Int} result.return_info.goods_list.goods_num 购买数量
  329. * @apiSuccess {Float} result.return_info.goods_list.goods_pay_price 实际支付金额
  330. * @apiSuccess {Float} result.return_info.goods_list.goods_price 商品金额
  331. * @apiSuccess {Int} result.return_info.goods_list.goods_type 商品类型 1默认2抢购商品3秒杀商品4组合套装5赠品6拼团7会员等级折扣
  332. * @apiSuccess {Int} result.return_info.goods_list.order_id 订单ID
  333. * @apiSuccess {Int} result.return_info.goods_list.promotions_id 促销ID
  334. * @apiSuccess {Int} result.return_info.goods_list.rec_id 订单商品ID
  335. * @apiSuccess {Int} result.return_info.goods_list.store_id 店铺ID
  336. * @apiSuccess {Int} result.return_info.lock_state 锁定状态:0:正常,大于0:锁定
  337. * @apiSuccess {Int} result.return_info.ob_no 结算单号
  338. * @apiSuccess {Float} result.return_info.order_amount 订单总金额
  339. * @apiSuccess {Int} result.return_info.order_from 订单来源,1:PC 2:手机
  340. * @apiSuccess {Int} result.return_info.order_id 订单ID
  341. * @apiSuccess {String} result.return_info.order_sn 订单编号
  342. * @apiSuccess {Int} result.return_info.order_state 订单状态
  343. * @apiSuccess {Int} result.return_info.order_type 订单类型
  344. * @apiSuccess {String} result.return_info.pay_sn 支付单号
  345. * @apiSuccess {String} result.return_info.payment_code 支付方式代码
  346. * @apiSuccess {String} result.return_info.payment_name 支付方式名称
  347. * @apiSuccess {Int} result.return_info.payment_time 支付时间
  348. * @apiSuccess {Float} result.return_info.pd_amount 使用预存款金额
  349. * @apiSuccess {Float} result.return_info.rcb_amount 使用充值卡金额
  350. * @apiSuccess {Float} result.return_info.refund_amount 退款金额
  351. * @apiSuccess {Int} result.return_info.refund_state 退款状态 0:无退款 1:部分退款 2:全部退款
  352. * @apiSuccess {String} result.return_info.shipping_code 发货运单号
  353. * @apiSuccess {Float} result.return_info.shipping_fee 运费
  354. * @apiSuccess {String} result.return_info.state_desc 状态描述
  355. * @apiSuccess {Int} result.return_info.store_id 店铺ID
  356. * @apiSuccess {String} result.return_info.store_name 店铺名称
  357. */
  358. public function complain_show()
  359. {
  360. $complain_id = intval(input('complain_id'));
  361. //获取投诉详细信息
  362. $complain_info = $this->get_complain_info($complain_id);
  363. $complain_pic = array();
  364. $appeal_pic = array();
  365. for ($i = 1; $i <= 3; $i++) {
  366. if (!empty($complain_info['complain_pic' . $i])) {
  367. $complain_pic[] = ds_get_pic(ATTACH_PATH . DIRECTORY_SEPARATOR . 'complain', $complain_info['complain_pic' . $i]);
  368. }
  369. if (!empty($complain_info['appeal_pic' . $i])) {
  370. $appeal_pic[] = ds_get_pic(ATTACH_PATH . DIRECTORY_SEPARATOR . 'complain', $complain_info['appeal_pic' . $i]);
  371. }
  372. }
  373. $condition = array();
  374. $condition[] = array('buyer_id', '=', $this->member_info['member_id']);
  375. $condition[] = array('order_id', '=', $complain_info['order_id']);
  376. $refundreturn_model = model('refundreturn');
  377. $return_info = $refundreturn_model->getRightOrderList($condition, $complain_info['order_goods_id']);
  378. ds_json_encode(10000, '', array('appeal_pic' => $appeal_pic, 'complain_pic' => $complain_pic, 'return_info' => $return_info, 'complain_info' => $complain_info));
  379. }
  380. /**
  381. * @api {POST} api/Membercomplain/complain_save 保存用户提交的投诉
  382. * @apiVersion 1.0.0
  383. * @apiGroup Membercomplain
  384. *
  385. * @apiHeader {String} X-DS-KEY 用户授权token
  386. *
  387. * @apiParam {Int} input_order_id 订单ID
  388. * @apiParam {Int} input_goods_id 订单商品ID
  389. * @apiParam {String} pic_name 投诉凭证 用,分隔多个投诉凭证
  390. * @apiParam {String} input_complain_subject 投诉主题
  391. * @apiParam {String} input_complain_content 投诉内容
  392. *
  393. * @apiSuccess {String} code 返回码,10000为成功
  394. * @apiSuccess {String} message 返回消息
  395. */
  396. public function complain_save()
  397. {
  398. //获取输入的投诉信息
  399. $input = array();
  400. $input['order_id'] = intval(input('post.input_order_id'));
  401. $input['order_goods_id'] = intval(input('post.input_goods_id'));
  402. $pic_name = input('post.pic_name/a');
  403. $condition = array();
  404. $condition[] = array('buyer_id', '=', $this->member_info['member_id']);
  405. $condition[] = array('order_id', '=', $input['order_id']);
  406. $order_model = model('order');
  407. $order_info = $order_model->getOrderInfo($condition);
  408. $if_complain = $order_model->getOrderOperateState('complain', $order_info); //检查订单是否可以投诉
  409. if ($if_complain < 1) {
  410. ds_json_encode(10001, lang('param_error'));
  411. }
  412. //检查是不是正在进行投诉
  413. if ($this->check_complain_exist($input['order_goods_id'])) {
  414. ds_json_encode(10001, lang('complain_repeat'));
  415. }
  416. list($input['complain_subject_id'], $input['complain_subject_content']) = explode(',', trim(input('post.input_complain_subject')));
  417. $input_complain_content = trim(input('post.input_complain_content'));
  418. $res = word_filter($input_complain_content);
  419. if (!$res['code']) {
  420. ds_json_encode(10001, $res['msg']);
  421. }
  422. $input_complain_content = $res['data']['text'];
  423. $input['complain_content'] = $input_complain_content;
  424. $input['accuser_id'] = $order_info['buyer_id'];
  425. $input['accuser_name'] = $order_info['buyer_name'];
  426. $input['accused_id'] = $order_info['store_id'];
  427. $input['accused_name'] = $order_info['store_name'];
  428. $input['complain_datetime'] = TIMESTAMP;
  429. $input['complain_state'] = self::STATE_NEW;
  430. $input['complain_active'] = self::STATE_UNACTIVE;
  431. $input['complain_pic1'] = isset($pic_name[0]) ? $pic_name[0] : '';
  432. $input['complain_pic2'] = isset($pic_name[1]) ? $pic_name[1] : '';
  433. $input['complain_pic3'] = isset($pic_name[2]) ? $pic_name[2] : '';
  434. $complain_model = model('complain');
  435. $state = $complain_model->addComplain($input); //保存投诉信息
  436. if ($state) {
  437. ds_json_encode(10000, lang('complain_submit_success'));
  438. } else {
  439. ds_json_encode(10001, lang('ds_common_op_fail'));
  440. }
  441. }
  442. /**
  443. * @api {POST} api/Membercomplain/complain_cancel 取消用户提交的投诉
  444. * @apiVersion 1.0.0
  445. * @apiGroup Membercomplain
  446. *
  447. * @apiHeader {String} X-DS-KEY 用户授权token
  448. *
  449. * @apiParam {Int} complain_id 投诉ID
  450. *
  451. * @apiSuccess {String} code 返回码,10000为成功
  452. * @apiSuccess {String} message 返回消息
  453. */
  454. public function complain_cancel()
  455. {
  456. $complain_id = intval(input('param.complain_id'));
  457. $complain_info = $this->get_complain_info($complain_id);
  458. if (intval($complain_info['complain_state']) === 10) {
  459. $pics = array();
  460. if (!empty($complain_info['complain_pic1']))
  461. $pics[] = $complain_info['complain_pic1'];
  462. if (!empty($complain_info['complain_pic2']))
  463. $pics[] = $complain_info['complain_pic2'];
  464. if (!empty($complain_info['complain_pic3']))
  465. $pics[] = $complain_info['complain_pic3'];
  466. if (!empty($pics)) { //删除图片
  467. foreach ($pics as $pic) {
  468. $pic = BASE_UPLOAD_PATH . DIRECTORY_SEPARATOR . ATTACH_PATH . DIRECTORY_SEPARATOR . 'complain' . DIRECTORY_SEPARATOR . $pic;
  469. if (file_exists($pic)) {
  470. @unlink($pic);
  471. }
  472. }
  473. }
  474. $complain_model = model('complain');
  475. $complain_model->delComplain(array('complain_id' => $complain_id));
  476. ds_json_encode(10000, lang('complain_cancel_success'));
  477. } else {
  478. ds_json_encode(10001, lang('complain_cancel_fail'));
  479. }
  480. }
  481. /**
  482. * @api {POST} api/Membercomplain/apply_handle 处理用户申请仲裁
  483. * @apiVersion 1.0.0
  484. * @apiGroup Membercomplain
  485. *
  486. * @apiHeader {String} X-DS-KEY 用户授权token
  487. *
  488. * @apiParam {Int} input_complain_id 投诉ID
  489. *
  490. * @apiSuccess {String} code 返回码,10000为成功
  491. * @apiSuccess {String} message 返回消息
  492. */
  493. public function apply_handle()
  494. {
  495. $complain_id = intval(input('post.input_complain_id'));
  496. //获取投诉详细信息
  497. $complain_info = $this->get_complain_info($complain_id);
  498. $complain_state = intval($complain_info['complain_state']);
  499. //检查当前是不是投诉状态
  500. if ($complain_state < self::STATE_TALK || $complain_state === 99) {
  501. ds_json_encode(10001, lang('param_error'));
  502. }
  503. $update_array = array();
  504. $update_array['complain_state'] = self::STATE_HANDLE;
  505. $condition = array();
  506. $condition[] = array('complain_id', '=', $complain_id);
  507. //保存投诉信息
  508. $complain_model = model('complain');
  509. $complain_model->editComplain($update_array, $condition);
  510. ds_json_encode(10000, lang('handle_submit_success'));
  511. }
  512. /**
  513. * @api {POST} api/Membercomplain/get_complain_talk 根据投诉id获取投诉对话
  514. * @apiVersion 1.0.0
  515. * @apiGroup Membercomplain
  516. *
  517. * @apiHeader {String} X-DS-KEY 用户授权token
  518. *
  519. * @apiParam {Int} complain_id 投诉ID
  520. *
  521. * @apiSuccess {String} code 返回码,10000为成功
  522. * @apiSuccess {String} message 返回消息
  523. * @apiSuccess {Object} result 返回数据
  524. * @apiSuccess {Object[]} result.talk_list 对话列表
  525. * @apiSuccess {String} result.talk_list.css 对话类型 admin管理员,accused被告人,accuser原告人
  526. * @apiSuccess {String} result.talk_list.talk 对话内容
  527. */
  528. public function get_complain_talk()
  529. {
  530. $complain_id = intval(input('post.complain_id'));
  531. $complain_info = $this->get_complain_info($complain_id);
  532. $complaintalk_model = model('complaintalk');
  533. $param = array();
  534. $param['complain_id'] = $complain_id;
  535. $complain_talk_list = $complaintalk_model->getComplaintalkList($param);
  536. $talk_list = array();
  537. $i = 0;
  538. foreach ($complain_talk_list as $talk) {
  539. $talk_list[$i]['css'] = $talk['talk_member_type'];
  540. $talk_list[$i]['talk'] = date("Y-m-d H:i:s", $talk['talk_datetime']);
  541. switch ($talk['talk_member_type']) {
  542. case 'accuser':
  543. $talk_list[$i]['talk'] .= lang('complain_accuser');
  544. break;
  545. case 'accused':
  546. $talk_list[$i]['talk'] .= lang('complain_accused');
  547. break;
  548. case 'admin':
  549. $talk_list[$i]['talk'] .= lang('complain_admin');
  550. break;
  551. default:
  552. $talk_list[$i]['talk'] .= lang('complain_unknow');
  553. }
  554. if (intval($talk['talk_state']) === 2) {
  555. $talk['talk_content'] = lang('talk_forbit_message');
  556. }
  557. $talk_list[$i]['talk'] .= '(' . $talk['talk_member_name'] . ')' . lang('complain_text_say') . ':' . $talk['talk_content'];
  558. $i++;
  559. }
  560. ds_json_encode(10000, '', array('talk_list' => $talk_list));
  561. }
  562. /**
  563. * @api {POST} api/Membercomplain/publish_complain_talk 根据发布投诉对话
  564. * @apiVersion 1.0.0
  565. * @apiGroup Membercomplain
  566. *
  567. * @apiHeader {String} X-DS-KEY 用户授权token
  568. *
  569. * @apiParam {Int} complain_id 投诉ID
  570. * @apiParam {String} complain_talk 对话内容
  571. *
  572. * @apiSuccess {String} code 返回码,10000为成功
  573. * @apiSuccess {String} message 返回消息
  574. */
  575. public function publish_complain_talk()
  576. {
  577. $complain_id = intval(input('post.complain_id'));
  578. $complain_talk = trim(input('post.complain_talk'));
  579. $talk_len = strlen($complain_talk);
  580. if ($talk_len > 0 && $talk_len < 255) {
  581. $complain_info = $this->get_complain_info($complain_id);
  582. $complain_state = intval($complain_info['complain_state']);
  583. //检查投诉是否是可发布对话状态
  584. if ($complain_state > self::STATE_APPEAL && $complain_state < self::STATE_FINISH) {
  585. $complaintalk_model = model('complaintalk');
  586. $param = array();
  587. $param['complain_id'] = $complain_id;
  588. $param['talk_member_id'] = $complain_info['accuser_id'];
  589. $param['talk_member_name'] = $complain_info['accuser_name'];
  590. $param['talk_member_type'] = $complain_info['member_status'];
  591. $param['talk_content'] = $complain_talk;
  592. $param['talk_state'] = 1;
  593. $param['talk_admin'] = 0;
  594. $param['talk_datetime'] = TIMESTAMP;
  595. if ($complaintalk_model->addComplaintalk($param)) {
  596. ds_json_encode(10000, ('talk_send_success'));
  597. } else {
  598. ds_json_encode(10001, ('talk_send_fail'));
  599. }
  600. } else {
  601. ds_json_encode(10001, lang('talk_state_error'));
  602. }
  603. } else {
  604. ds_json_encode(10001, lang('talk_null'));
  605. }
  606. }
  607. /*
  608. * 获取投诉信息
  609. */
  610. private function get_complain_info($complain_id)
  611. {
  612. $complain_model = model('complain');
  613. $complain_info = $complain_model->getOneComplain($complain_id);
  614. if ($complain_info['accuser_id'] != $this->member_info['member_id']) {
  615. ds_json_encode(10001, lang('param_error'));
  616. }
  617. $complain_info['member_status'] = 'accuser';
  618. $complain_info['complain_state_text'] = $this->get_complain_state_text($complain_info['complain_state']);
  619. return $complain_info;
  620. }
  621. /*
  622. * 检查投诉是否已经存在
  623. */
  624. private function check_complain_exist($goods_id)
  625. {
  626. $complain_model = model('complain');
  627. $param = array();
  628. $param[] = array('order_goods_id', '=', $goods_id);
  629. $param[] = array('accuser_id', '=', $this->member_info['member_id']);
  630. $param[] = array('complain_state', '<', 90);
  631. return $complain_model->isComplainExist($param);
  632. }
  633. /*
  634. * 获得投诉状态文本
  635. */
  636. private function get_complain_state_text($complain_state)
  637. {
  638. switch (intval($complain_state)) {
  639. case self::STATE_NEW:
  640. return lang('complain_state_new');
  641. break;
  642. case self::STATE_APPEAL:
  643. return lang('complain_state_appeal');
  644. break;
  645. case self::STATE_TALK:
  646. return lang('complain_state_talk');
  647. break;
  648. case self::STATE_HANDLE:
  649. return lang('complain_state_handle');
  650. break;
  651. case self::STATE_FINISH:
  652. return lang('complain_state_finish');
  653. break;
  654. default:
  655. ds_json_encode(10001, lang('param_error'));
  656. }
  657. }
  658. /**
  659. * @api {POST} api/Membercomplain/upload_pic 上传凭证
  660. * @apiVersion 1.0.0
  661. * @apiGroup Membercomplain
  662. *
  663. * @apiHeader {String} X-DS-KEY 用户授权token
  664. *
  665. * @apiParam {File} complain_pic 投诉凭证
  666. *
  667. * @apiSuccess {String} code 返回码,10000为成功
  668. * @apiSuccess {String} message 返回消息
  669. * @apiSuccess {Object} result 返回数据
  670. * @apiSuccess {String} result.file_name 文件名称
  671. * @apiSuccess {String} result.pic 文件完整路径
  672. */
  673. public function upload_pic()
  674. {
  675. if (!empty($_FILES['complain_pic']['name'])) {
  676. $file_name = $this->member_info['member_id'] . '_' . date('YmdHis') . rand(10000, 99999) . '.png';
  677. $res = ds_upload_pic(ATTACH_PATH . DIRECTORY_SEPARATOR . 'complain', 'complain_pic', $file_name);
  678. if ($res['code']) {
  679. $file_name = $res['data']['file_name'];
  680. } else {
  681. ds_json_encode(10001, $res['msg']);
  682. }
  683. $pic = ds_get_pic(ATTACH_PATH . DIRECTORY_SEPARATOR . 'complain', $file_name);
  684. ds_json_encode(10000, '', array('file_name' => $file_name, 'pic' => $pic));
  685. } else {
  686. ds_json_encode(10001, lang('file_empty'));
  687. }
  688. }
  689. }