From 30d8e227e8d823b6c38c3b9c90ac2df03b63befe Mon Sep 17 00:00:00 2001 From: admin <weikou2014> Date: 星期二, 25 二月 2025 16:41:22 +0800 Subject: [PATCH] 淘宝转链接口更新 --- fanli/src/main/java/com/yeshi/fanli/controller/client/v1/CustomerServiceController.java | 314 ++++++++++++++++++++++++++-------------------------- 1 files changed, 157 insertions(+), 157 deletions(-) diff --git a/fanli/src/main/java/com/yeshi/fanli/controller/client/v1/CustomerServiceController.java b/fanli/src/main/java/com/yeshi/fanli/controller/client/v1/CustomerServiceController.java index 2d94ec2..699c05e 100644 --- a/fanli/src/main/java/com/yeshi/fanli/controller/client/v1/CustomerServiceController.java +++ b/fanli/src/main/java/com/yeshi/fanli/controller/client/v1/CustomerServiceController.java @@ -1,157 +1,157 @@ -package com.yeshi.fanli.controller.client.v1; - -import java.io.IOException; -import java.io.PrintWriter; -import java.util.ArrayList; -import java.util.Date; -import java.util.List; - -import javax.annotation.Resource; -import javax.servlet.http.HttpServletRequest; - -import org.springframework.stereotype.Controller; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestMethod; -import org.springframework.web.multipart.MultipartFile; -import org.yeshi.utils.JsonUtil; - -import com.google.gson.Gson; -import com.yeshi.fanli.entity.AppInfo; -import com.yeshi.fanli.entity.DeviceInfo; -import com.yeshi.fanli.entity.accept.AcceptData; -import com.yeshi.fanli.entity.customerservice.CustomerServiceCommonQuestion; -import com.yeshi.fanli.entity.customerservice.CustomerServiceHistory; -import com.yeshi.fanli.exception.user.UserComplaintException; -import com.yeshi.fanli.service.inter.customerservice.CustomerServiceCommonQuestionService; -import com.yeshi.fanli.service.inter.customerservice.CustomerServiceHistoryService; -import com.yeshi.fanli.service.inter.user.UserComplaintService; -import com.yeshi.fanli.util.StringUtil; - -import net.sf.json.JSONObject; - -/** - * 瀹㈡湇api鎺ュ彛 - * - * @author Administrator - * - */ -@Controller -@RequestMapping("api/v1/customerservice") -public class CustomerServiceController { - - @Resource - private CustomerServiceCommonQuestionService customerServiceCommonQuestionService; - - @Resource - private CustomerServiceHistoryService customerServiceHistoryService; - - @Resource - private UserComplaintService userComplaintService; - - /** - * 棰勮鏍囬鐨勫叧閿瓧鍒楄〃 - * - * @param acceptData - * @param out - */ - @RequestMapping(value = "getkeys", method = RequestMethod.POST) - public void getKeys(AcceptData acceptData, PrintWriter out) { - List<String> keys = customerServiceCommonQuestionService.listKeysCache(); - JSONObject data = new JSONObject(); - data.put("keys", keys); - out.print(JsonUtil.loadTrueResult(data)); - } - - /** - * 鏍规嵁鍏抽敭瀛楄幏鍙栫瓟妗� - * - * @param acceptData - * @param key - * -鍏抽敭瀛� - * @param out - */ - @RequestMapping(value = "getanswer", method = RequestMethod.POST) - public void getGoodsInfo(AcceptData acceptData, String key, PrintWriter out) { - if (StringUtil.isNullOrEmpty(key)) { - out.print(JsonUtil.loadFalseResult(1, "璇蜂笂浼犻棶棰�")); - return; - } - - if (key.length() > 512) { - out.print(JsonUtil.loadFalseResult(2, "闂杩囬暱锛岃绮剧畝闂")); - return; - } - - Gson gson = new Gson(); - - CustomerServiceHistory history = new CustomerServiceHistory(); - AppInfo appInfo = new AppInfo(); - appInfo.setChannel(acceptData.getChannel()); - appInfo.setPackages(acceptData.getPackages()); - appInfo.setVersion(acceptData.getVersion()); - - history.setAppInfo(appInfo); - history.setAppInfoStr(gson.toJson(appInfo)); - history.setContent(key); - history.setCreateTime(new Date()); - history.setDevice(acceptData.getDevice()); - DeviceInfo deviceInfo = new DeviceInfo(); - deviceInfo.setDevice(acceptData.getDevice()); - deviceInfo.setDeviceType(acceptData.getDeviceType()); - deviceInfo.setNetwork(acceptData.getNetwork()); - deviceInfo.setOsVersion(acceptData.getOsVersion()); - deviceInfo.setPlatform(acceptData.getPlatform()); - - history.setDeviceInfo(deviceInfo); - history.setDeviceInfoStr(gson.toJson(deviceInfo)); - history.setPlatform(acceptData.getPlatform()); - history.setUpdateTime(new Date()); - - // 淇濆瓨闂鍘嗗彶璁板綍 - customerServiceHistoryService.addHistory(history); - - // 鎼滅储闂绛旀 - CustomerServiceCommonQuestion answer = customerServiceCommonQuestionService.searchByKeyCache(key); - if (answer == null) { - answer = new CustomerServiceCommonQuestion(); - answer.setKey(""); - answer.setContentType(CustomerServiceCommonQuestion.TYPE_TEXT); - answer.setContent("瀹㈡湇鏈哄櫒浜轰笉鏄庣櫧鎮ㄧ殑闂锛岃杈撳叆浣犻棶棰樼殑鍑嗙‘鍏抽敭璇嶆垨杞汉宸ュ鏈嶈В鍐筹紝璋㈣阿锛�#^.^#"); - - // out.print(JsonUtil.loadFalseResult(-1, "鏃犵瓟妗�")); - // return; - } - out.print(JsonUtil.loadTrueResult(JsonUtil.getApiCommonGson().toJson(answer))); - } - - /** - * 鐢ㄦ埛鍚愭Ы璁板綍娣诲姞 - * - * @param fileList - * @param uid - * @param content - * @param out - */ - @RequestMapping(value = "complaint") - public void complaint(AcceptData acceptData, MultipartFile[] fileList, String content, Long uid, - HttpServletRequest request, PrintWriter out) { - try { - List<MultipartFile> files = new ArrayList<>(); - if (fileList != null) - for (MultipartFile mf : fileList) { - files.add(mf); - } - userComplaintService.addUserComplaint(files, uid, content); - out.print(JsonUtil.loadTrueResult("淇濆瓨鎴愬姛")); - } catch (UserComplaintException e) { - out.print(JsonUtil.loadFalseResult(e.getMsg())); - e.printStackTrace(); - } catch (IOException e) { - out.print(JsonUtil.loadFalseResult("鍥剧墖涓婁紶澶辫触澶辫触")); - e.printStackTrace(); - } catch (Exception e) { - out.print(JsonUtil.loadFalseResult("淇濆瓨澶辫触")); - e.printStackTrace(); - } - } -} +package com.yeshi.fanli.controller.client.v1; + +import java.io.IOException; +import java.io.PrintWriter; +import java.util.ArrayList; +import java.util.Date; +import java.util.List; + +import javax.annotation.Resource; +import javax.servlet.http.HttpServletRequest; + +import org.springframework.stereotype.Controller; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestMethod; +import org.springframework.web.multipart.MultipartFile; +import org.yeshi.utils.JsonUtil; + +import com.google.gson.Gson; +import com.yeshi.fanli.entity.AppInfo; +import com.yeshi.fanli.entity.DeviceInfo; +import com.yeshi.fanli.entity.accept.AcceptData; +import com.yeshi.fanli.entity.customerservice.CustomerServiceCommonQuestion; +import com.yeshi.fanli.entity.customerservice.CustomerServiceHistory; +import com.yeshi.fanli.exception.user.UserComplaintException; +import com.yeshi.fanli.service.inter.customerservice.CustomerServiceCommonQuestionService; +import com.yeshi.fanli.service.inter.customerservice.CustomerServiceHistoryService; +import com.yeshi.fanli.service.inter.user.UserComplaintService; +import com.yeshi.fanli.util.StringUtil; + +import net.sf.json.JSONObject; + +/** + * 瀹㈡湇api鎺ュ彛 + * + * @author Administrator + * + */ +@Controller +@RequestMapping("api/v1/customerservice") +public class CustomerServiceController { + + @Resource + private CustomerServiceCommonQuestionService customerServiceCommonQuestionService; + + @Resource + private CustomerServiceHistoryService customerServiceHistoryService; + + @Resource + private UserComplaintService userComplaintService; + + /** + * 棰勮鏍囬鐨勫叧閿瓧鍒楄〃 + * + * @param acceptData + * @param out + */ + @RequestMapping(value = "getkeys", method = RequestMethod.POST) + public void getKeys(AcceptData acceptData, PrintWriter out) { + List<String> keys = customerServiceCommonQuestionService.listKeysCache(); + JSONObject data = new JSONObject(); + data.put("keys", keys); + out.print(JsonUtil.loadTrueResult(data)); + } + + /** + * 鏍规嵁鍏抽敭瀛楄幏鍙栫瓟妗� + * + * @param acceptData + * @param key + * -鍏抽敭瀛� + * @param out + */ + @RequestMapping(value = "getanswer", method = RequestMethod.POST) + public void getGoodsInfo(AcceptData acceptData, String key, PrintWriter out) { + if (StringUtil.isNullOrEmpty(key)) { + out.print(JsonUtil.loadFalseResult(1, "璇蜂笂浼犻棶棰�")); + return; + } + + if (key.length() > 512) { + out.print(JsonUtil.loadFalseResult(2, "闂杩囬暱锛岃绮剧畝闂")); + return; + } + + Gson gson = new Gson(); + + CustomerServiceHistory history = new CustomerServiceHistory(); + AppInfo appInfo = new AppInfo(); + appInfo.setChannel(acceptData.getChannel()); + appInfo.setPackages(acceptData.getPackages()); + appInfo.setVersion(acceptData.getVersion()); + + history.setAppInfo(appInfo); + history.setAppInfoStr(gson.toJson(appInfo)); + history.setContent(key); + history.setCreateTime(new Date()); + history.setDevice(acceptData.getDevice()); + DeviceInfo deviceInfo = new DeviceInfo(); + deviceInfo.setDevice(acceptData.getDevice()); + deviceInfo.setDeviceType(acceptData.getDeviceType()); + deviceInfo.setNetwork(acceptData.getNetwork()); + deviceInfo.setOsVersion(acceptData.getOsVersion()); + deviceInfo.setPlatform(acceptData.getPlatform()); + + history.setDeviceInfo(deviceInfo); + history.setDeviceInfoStr(gson.toJson(deviceInfo)); + history.setPlatform(acceptData.getPlatform()); + history.setUpdateTime(new Date()); + + // 淇濆瓨闂鍘嗗彶璁板綍 + customerServiceHistoryService.addHistory(history); + + // 鎼滅储闂绛旀 + CustomerServiceCommonQuestion answer = customerServiceCommonQuestionService.searchByKeyCache(key); + if (answer == null) { + answer = new CustomerServiceCommonQuestion(); + answer.setKey(""); + answer.setContentType(CustomerServiceCommonQuestion.TYPE_TEXT); + answer.setContent("瀹㈡湇鏈哄櫒浜轰笉鏄庣櫧鎮ㄧ殑闂锛岃杈撳叆浣犻棶棰樼殑鍑嗙‘鍏抽敭璇嶆垨杞汉宸ュ鏈嶈В鍐筹紝璋㈣阿锛�#^.^#"); + + // out.print(JsonUtil.loadFalseResult(-1, "鏃犵瓟妗�")); + // return; + } + out.print(JsonUtil.loadTrueResult(JsonUtil.getApiCommonGson().toJson(answer))); + } + + /** + * 鐢ㄦ埛鍚愭Ы璁板綍娣诲姞 + * + * @param fileList + * @param uid + * @param content + * @param out + */ + @RequestMapping(value = "complaint") + public void complaint(AcceptData acceptData, MultipartFile[] fileList, String content, Long uid, + HttpServletRequest request, PrintWriter out) { + try { + List<MultipartFile> files = new ArrayList<>(); + if (fileList != null) + for (MultipartFile mf : fileList) { + files.add(mf); + } + userComplaintService.addUserComplaint(files, uid, content); + out.print(JsonUtil.loadTrueResult("淇濆瓨鎴愬姛")); + } catch (UserComplaintException e) { + out.print(JsonUtil.loadFalseResult(e.getMsg())); + e.printStackTrace(); + } catch (IOException e) { + out.print(JsonUtil.loadFalseResult("鍥剧墖涓婁紶澶辫触澶辫触")); + e.printStackTrace(); + } catch (Exception e) { + out.print(JsonUtil.loadFalseResult("淇濆瓨澶辫触")); + e.printStackTrace(); + } + } +} -- Gitblit v1.8.0