123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415 |
- <?php
- namespace app\api\controller;
- use think\facade\View;
- use think\facade\Lang;
- class Sellercomplain extends MobileSeller
- {
-
- const STATE_NEW = 10;
- const STATE_APPEAL = 20;
- const STATE_TALK = 30;
- const STATE_HANDLE = 40;
- const STATE_FINISH = 99;
- const STATE_UNACTIVE = 1;
- const STATE_ACTIVE = 2;
- public function initialize()
- {
- parent::initialize();
- Lang::load(base_path() . 'home/lang/' . config('lang.default_lang') . '/sellercomplain.lang.php');
- }
-
- public function index()
- {
- $complain_model = model('complain');
- $condition = array();
- $condition[] = array('accused_id', '=', $this->store_info['store_id']);
- if ((input('param.add_time_to')) != '' && (input('param.add_time_to')) != '') {
- $add_time_from = strtotime((input('param.add_time_from')));
- $add_time_to = strtotime((input('param.add_time_to')));
- $condition[] = array('complain_datetime', 'between', array($add_time_from, $add_time_to));
- }
- switch (intval(input('param.state'))) {
- case 1:
- $condition[] = array('complain_state', 'between', array(10, 90));
- break;
- case 2:
- $condition[] = array('complain_state', '=', 99);
- break;
- default:
- }
- $condition[] = array('complain_active', '=', 2);
- $complain_list = $complain_model->getComplainList($condition, 10);
- View::assign('show_page', $complain_model->page_info->render());
- $goods_list = $complain_model->getComplainGoodsList($complain_list);
- foreach ($goods_list as $key => $val) {
- $goods_list[$key]['goods_image_url'] = goods_thumb($val, 240);
- }
- $result = array_merge(array('complaint_list' => $complain_list, 'goods_list' => $goods_list), mobile_page($complain_model->page_info));
- ds_json_encode(10000, '', $result);
- }
-
- public function complain_show()
- {
- $complain_id = intval(input('param.complain_id'));
-
- $complain_info = $this->get_complain_info($complain_id);
- $complain_pic = array();
- $appeal_pic = array();
- for ($i = 1; $i <= 3; $i++) {
- if (!empty($complain_info['complain_pic' . $i])) {
- $complain_pic[] = ds_get_pic(ATTACH_PATH . DIRECTORY_SEPARATOR . 'complain', $complain_info['complain_pic' . $i]);
- }
- if (!empty($complain_info['appeal_pic' . $i])) {
- $appeal_pic[] = ds_get_pic(ATTACH_PATH . DIRECTORY_SEPARATOR . 'complain', $complain_info['appeal_pic' . $i]);
- }
- }
- $member_model = model('member');
- $member = $member_model->getMemberInfoByID($complain_info['accuser_id']);
- $refundreturn_model = model('refundreturn');
- $condition = array();
- $condition[] = array('order_id', '=', $complain_info['order_id']);
- $return_info = $refundreturn_model->getRightOrderList($condition, $complain_info['order_goods_id']);
- ds_json_encode(10000, '', array('member' => $member, 'return_info' => $return_info, 'complain_info' => $complain_info, 'appeal_pic' => $appeal_pic, 'complain_pic' => $complain_pic));
- }
-
- public function appeal_save()
- {
- $complain_id = intval(input('post.input_complain_id'));
- $pic_name = input('post.pic_name/a');
-
- $complain_info = $this->get_complain_info($complain_id);
-
- if (intval($complain_info['complain_state']) !== self::STATE_APPEAL) {
- ds_json_encode(10001, lang('param_error'));
- }
- $input = array();
- $input['appeal_message'] = input('post.input_appeal_message');
- $sellercomplain_validate = ds_validate('sellercomplain');
- if (!$sellercomplain_validate->scene('appeal_save')->check($input)) {
- ds_json_encode(10001, $sellercomplain_validate->getError());
- }
- $input['appeal_pic1'] = isset($pic_name[0]) ? $pic_name[0] : '';
- $input['appeal_pic2'] = isset($pic_name[1]) ? $pic_name[1] : '';
- $input['appeal_pic3'] = isset($pic_name[2]) ? $pic_name[2] : '';
- $input['appeal_datetime'] = TIMESTAMP;
- $input['complain_state'] = self::STATE_TALK;
- $condition = array();
- $condition[] = array('complain_id', '=', $complain_id);
-
- $complain_model = model('complain');
- $complain_id = $complain_model->editComplain($input, $condition);
- $this->recordSellerlog('投诉申诉处理,投诉编号:' . $complain_id);
- ds_json_encode(10000, lang('appeal_submit_success'));
- }
-
- public function upload_pic()
- {
- if (!empty($_FILES['complain_pic']['name'])) {
- $file_name = $this->member_info['member_id'] . '_' . date('YmdHis') . rand(10000, 99999) . '.png';
- $res = ds_upload_pic(ATTACH_PATH . DIRECTORY_SEPARATOR . 'complain', 'complain_pic', $file_name);
- if ($res['code']) {
- $file_name = $res['data']['file_name'];
- } else {
- ds_json_encode(10001, $res['msg']);
- }
- $pic = ds_get_pic(ATTACH_PATH . DIRECTORY_SEPARATOR . 'complain', $file_name);
- ds_json_encode(10000, '', array('file_name' => $file_name, 'pic' => $pic));
- } else {
- ds_json_encode(10001, lang('file_empty'));
- }
- }
-
- public function apply_handle()
- {
- $complain_id = intval(input('post.input_complain_id'));
-
- $complain_info = $this->get_complain_info($complain_id);
- $complain_state = intval($complain_info['complain_state']);
-
- if ($complain_state < self::STATE_TALK || $complain_state === 99) {
- ds_json_encode(10001, lang('param_error'));
- }
- $update_array = array();
- $update_array['complain_state'] = self::STATE_HANDLE;
- $condition = array();
- $condition[] = array('complain_id', '=', $complain_id);
-
- $complain_model = model('complain');
- $complain_id = $complain_model->editComplain($update_array, $condition);
- $this->recordSellerlog('投诉申请仲裁,投诉编号:' . $complain_id);
- ds_json_encode(10000, lang('handle_submit_success'));
- }
-
- public function get_complain_talk()
- {
- $complain_id = intval(input('post.complain_id'));
- $complain_info = $this->get_complain_info($complain_id);
- $complaintalk_model = model('complaintalk');
- $param = array();
- $param['complain_id'] = $complain_id;
- $complain_talk_list = $complaintalk_model->getComplaintalkList($param);
- $talk_list = array();
- $i = 0;
- if (!empty($complain_talk_list)) {
- foreach ($complain_talk_list as $talk) {
- $talk_list[$i]['css'] = $talk['talk_member_type'];
- $talk_list[$i]['talk'] = date("Y-m-d H:i:s", $talk['talk_datetime']);
- switch ($talk['talk_member_type']) {
- case 'accuser':
- $talk_list[$i]['talk'] .= lang('complain_accuser');
- break;
- case 'accused':
- $talk_list[$i]['talk'] .= lang('complain_accused');
- break;
- case 'admin':
- $talk_list[$i]['talk'] .= lang('complain_admin');
- break;
- default:
- $talk_list[$i]['talk'] .= lang('complain_unknow');
- }
- if (intval($talk['talk_state']) === 2) {
- $talk['talk_content'] = lang('talk_forbit_message');
- }
- $talk_list[$i]['talk'] .= '(' . $talk['talk_member_name'] . ')' . lang('complain_text_say') . ':' . $talk['talk_content'];
- $i++;
- }
- }
- ds_json_encode(10000, '', array('talk_list' => $talk_list));
- }
-
- public function publish_complain_talk()
- {
- $complain_id = intval(input('post.complain_id'));
- $complain_talk = trim(input('post.complain_talk'));
- $talk_len = strlen($complain_talk);
- if ($talk_len > 0 && $talk_len < 255) {
- $complain_info = $this->get_complain_info($complain_id);
- $complain_state = intval($complain_info['complain_state']);
-
- if ($complain_state > self::STATE_APPEAL && $complain_state < self::STATE_FINISH) {
- $complaintalk_model = model('complaintalk');
- $param = array();
- $param['complain_id'] = $complain_id;
- $param['talk_member_id'] = $complain_info['accused_id'];
- $param['talk_member_name'] = $complain_info['accused_name'];
- $param['talk_member_type'] = $complain_info['member_status'];
- $param['talk_content'] = $complain_talk;
- $param['talk_state'] = 1;
- $param['talk_admin'] = 0;
- $param['talk_datetime'] = TIMESTAMP;
- if ($complaintalk_model->addComplaintalk($param)) {
- ds_json_encode(10000, ('talk_send_success'));
- } else {
- ds_json_encode(10001, ('talk_send_fail'));
- }
- } else {
- ds_json_encode(10001, lang('talk_state_error'));
- }
- } else {
- ds_json_encode(10001, lang('talk_null'));
- }
- }
-
- private function get_complain_info($complain_id)
- {
- if (empty($complain_id)) {
- ds_json_encode(10001, lang('param_error'));
- }
- $complain_model = model('complain');
- $complain_info = $complain_model->getOneComplain($complain_id);
- if ($complain_info['accused_id'] != $this->store_info['store_id']) {
- ds_json_encode(10001, lang('param_error'));
- }
- $complain_info['member_status'] = 'accused';
- $complain_info['complain_state_text'] = $this->get_complain_state_text($complain_info['complain_state']);
- return $complain_info;
- }
-
- private function get_complain_state_text($complain_state)
- {
- switch (intval($complain_state)) {
- case self::STATE_NEW:
- return lang('complain_state_new');
- break;
- case self::STATE_APPEAL:
- return lang('complain_state_appeal');
- break;
- case self::STATE_TALK:
- return lang('complain_state_talk');
- break;
- case self::STATE_HANDLE:
- return lang('complain_state_handle');
- break;
- case self::STATE_FINISH:
- return lang('complain_state_finish');
- break;
- default:
- ds_json_encode(10001, lang('param_error'));
- }
- }
- }
|