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/UserGoodsStorageController.java | 502 +++++++++++++++++++++++++++---------------------------- 1 files changed, 249 insertions(+), 253 deletions(-) diff --git a/fanli/src/main/java/com/yeshi/fanli/controller/client/v1/UserGoodsStorageController.java b/fanli/src/main/java/com/yeshi/fanli/controller/client/v1/UserGoodsStorageController.java index 3d91ea0..f8098f9 100644 --- a/fanli/src/main/java/com/yeshi/fanli/controller/client/v1/UserGoodsStorageController.java +++ b/fanli/src/main/java/com/yeshi/fanli/controller/client/v1/UserGoodsStorageController.java @@ -1,253 +1,249 @@ -package com.yeshi.fanli.controller.client.v1; - -import java.io.PrintWriter; -import java.util.ArrayList; -import java.util.HashSet; -import java.util.List; -import java.util.Set; - -import javax.annotation.Resource; - -import net.sf.json.JSONArray; -import net.sf.json.JSONObject; - -import org.springframework.stereotype.Controller; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RequestMethod; -import org.yeshi.utils.JsonUtil; - -import com.google.gson.Gson; -import com.google.gson.reflect.TypeToken; -import com.yeshi.fanli.entity.accept.AcceptData; -import com.yeshi.fanli.entity.bus.user.UserGoodsStorage; -import com.yeshi.fanli.exception.share.UserShareGoodsRecordException; -import com.yeshi.fanli.exception.user.UserGoodsStorageException; -import com.yeshi.fanli.service.inter.config.ConfigService; -import com.yeshi.fanli.service.inter.user.UserGoodsStorageService; -import com.yeshi.fanli.util.Constant; -import com.yeshi.fanli.util.StringUtil; - -@Controller -@RequestMapping("api/v1/userstorage") -public class UserGoodsStorageController { - - @Resource - private ConfigService configService; - - @Resource - private UserGoodsStorageService userGoodsStorageService; - - /** - * 鍗曚釜鍟嗗搧鍔犲叆閫夊搧搴� - * - * @param callback - * @param storageIds - * id鏁扮粍 - * @param out - */ - @RequestMapping(value = "accordtorage", method = RequestMethod.POST) - public void accordtorage(AcceptData acceptData, Long uid, Long auctionId, PrintWriter out) { - - if (auctionId == null) { - out.print(JsonUtil.loadFalseResult("鏈�夋嫨鍟嗗搧")); - return; - } - - if (uid == null) { - out.print(JsonUtil.loadFalseResult("鐢ㄦ埛鏈櫥褰�")); - return; - } - - try { - - UserGoodsStorage userGoodsStorage = userGoodsStorageService.getByUidAndAuctionId(uid, auctionId); - boolean storageState = false; - if (userGoodsStorage != null) { - // 鍙栨秷鍔犲叆閫夊搧搴� - userGoodsStorageService.deleteByPrimaryKey(userGoodsStorage.getId()); - } else { - // 鍔犲叆閫夊搧搴� - Set<Long> set = new HashSet<Long>(); - set.add(auctionId); - userGoodsStorageService.save(uid, set); - storageState = true; - } - - JSONObject data = new JSONObject(); - data.put("storageState", storageState); - out.print(JsonUtil.loadTrueResult(data)); - - } catch (Exception e) { - out.print(JsonUtil.loadFalseResult("鎿嶄綔澶辫触")); - e.printStackTrace(); - } - } - - /** - * 鎵归噺娣诲姞閫夊搧搴� - * - * @param acceptData - * @param uid - * 鐢ㄦ埛id - * @param auctionId - * 娣樺疂鍟嗗搧id - * @param out - */ - @RequestMapping(value = "addstorage", method = RequestMethod.POST) - public void addStorage(AcceptData acceptData, Long uid, String auctionIds, PrintWriter out) { - try { - Gson gson = new Gson(); - Set<Long> set = gson.fromJson(auctionIds, new TypeToken<HashSet<Long>>() {}.getType()); - if (set == null || set.size() == 0) { - out.print(JsonUtil.loadFalseResult("鏈�夋嫨鍟嗗搧")); - return; - } - - userGoodsStorageService.save(uid, set); - out.print(JsonUtil.loadTrueResult("娣诲姞鎴愬姛")); - - } catch (UserGoodsStorageException e) { - out.print(JsonUtil.loadFalseResult(e.getMsg())); - } catch (Exception e) { - out.print(JsonUtil.loadFalseResult("娣诲姞澶辫触")); - e.printStackTrace(); - } - } - - /** - * 鏌ヨ鐢ㄦ埛閫夊搧搴撴暟鎹� - * - * @param acceptData - * @param page - * 椤电爜 鍒濆鍊� 1 - * @param uid - * 鐢ㄦ埛id - * @param out - */ - @RequestMapping(value = "getstoragelist", method = RequestMethod.POST) - public void getStorageList(AcceptData acceptData, Integer page, Long uid, PrintWriter out) { - - if (page == null || page < 1) { - out.print(JsonUtil.loadFalseResult("椤电爜涓嶆纭�")); - return; - } - - if (uid == null) { - out.print(JsonUtil.loadFalseResult("鐢ㄦ埛鏈櫥褰�")); - return; - } - - try { - int pageSize = Constant.PAGE_SIZE; - - JSONObject data = new JSONObject(); - JSONArray array = new JSONArray(); - - long count = userGoodsStorageService.countQueryByUid(uid); - if (count > 0) { - array = userGoodsStorageService.getMyStorage((page - 1) * pageSize, pageSize, uid); - } - - data.put("count", count); - data.put("result_list", array); - out.print(JsonUtil.loadTrueResult(data)); - - } catch (Exception e) { - out.print(JsonUtil.loadFalseResult("鍔犺浇鍒楄〃澶辫触")); - e.printStackTrace(); - } - } - - /** - * 鍒犻櫎 - * - * @param callback - * @param storageIds - * id鏁扮粍 - * @param out - */ - @RequestMapping(value = "deletestorage", method = RequestMethod.POST) - public void deleteStorage(AcceptData acceptData, Long uid, String storageIds, PrintWriter out) { - - if (StringUtil.isNullOrEmpty(storageIds)) { - out.print(JsonUtil.loadFalseResult("鏈�夋嫨鍟嗗搧")); - return; - } - - if (uid == null) { - out.print(JsonUtil.loadFalseResult("鐢ㄦ埛鏈櫥褰�")); - return; - } - - try { - Gson gson = new Gson(); - List<Long> list = gson.fromJson(storageIds, new TypeToken<ArrayList<Long>>() {}.getType()); - if (list == null || list.size() == 0) { - out.print(JsonUtil.loadFalseResult("鏈�夋嫨鍟嗗搧")); - return; - } - - userGoodsStorageService.deleteBatchByUidAndPrimaryKey(uid, list); - out.print(JsonUtil.loadTrueResult("鍒犻櫎鎴愬姛")); - - } catch (Exception e) { - out.print(JsonUtil.loadFalseResult("鍒犻櫎澶辫触")); - e.printStackTrace(); - } - } - - - - - /** - * 鍒嗕韩鍟嗗搧杩斿洖浜岀淮鐮佸浘鐗� - * - * @param callback - * @param storageIds - * id鏁扮粍 - * @param out - */ - @RequestMapping(value = "sharegoods", method = RequestMethod.POST) - public void shareGoods(AcceptData acceptData, Long uid, String storageIds, PrintWriter out) { - - if (StringUtil.isNullOrEmpty(storageIds)) { - out.print(JsonUtil.loadFalseResult("鍒嗕韩鍟嗗搧涓嶈兘涓虹┖")); - return; - } - - if (uid == null) { - out.print(JsonUtil.loadFalseResult("鐢ㄦ埛鏈櫥褰�")); - return; - } - - try { - - Gson gson = new Gson(); - List<Long> listStorageID = gson.fromJson(storageIds, new TypeToken<ArrayList<Long>>() {}.getType()); - if (listStorageID == null || listStorageID.size() < 9) { - out.print(JsonUtil.loadFalseResult("鍒嗕韩鍟嗗搧鏁伴噺涓嶈冻")); - return; - } - - if (listStorageID.size() != 9) { - out.print(JsonUtil.loadFalseResult("鍒嗕韩鍟嗗搧鏁伴噺鍙兘鏄�9涓�")); - return; - } - - - JSONObject data = userGoodsStorageService.shareGoods(uid, listStorageID); - out.print(JsonUtil.loadTrueResult(data)); - - } catch (UserGoodsStorageException e) { - out.print(JsonUtil.loadFalseResult("鍒嗕韩澶辫触")); - e.printStackTrace(); - } catch (UserShareGoodsRecordException 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.PrintWriter; +import java.util.ArrayList; +import java.util.HashSet; +import java.util.List; +import java.util.Set; + +import javax.annotation.Resource; + +import net.sf.json.JSONArray; +import net.sf.json.JSONObject; + +import org.springframework.stereotype.Controller; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestMethod; +import org.yeshi.utils.JsonUtil; + +import com.google.gson.Gson; +import com.google.gson.reflect.TypeToken; +import com.yeshi.fanli.entity.accept.AcceptData; +import com.yeshi.fanli.entity.bus.user.UserGoodsStorage; +import com.yeshi.fanli.exception.share.UserShareGoodsRecordException; +import com.yeshi.fanli.exception.user.UserGoodsStorageException; +import com.yeshi.fanli.service.inter.config.ConfigService; +import com.yeshi.fanli.service.inter.user.UserGoodsStorageService; +import com.yeshi.fanli.util.Constant; +import com.yeshi.fanli.util.StringUtil; + +@Controller +@RequestMapping("api/v1/userstorage") +public class UserGoodsStorageController { + + @Resource + private ConfigService configService; + + @Resource + private UserGoodsStorageService userGoodsStorageService; + + /** + * 鍗曚釜鍟嗗搧鍔犲叆閫夊搧搴� + * + * id鏁扮粍 + * @param out + */ + @RequestMapping(value = "accordtorage", method = RequestMethod.POST) + public void accordtorage(AcceptData acceptData, Long uid, String auctionId, PrintWriter out) { + + if (auctionId == null) { + out.print(JsonUtil.loadFalseResult("鏈�夋嫨鍟嗗搧")); + return; + } + + if (uid == null) { + out.print(JsonUtil.loadFalseResult("鐢ㄦ埛鏈櫥褰�")); + return; + } + + + try { + UserGoodsStorage userGoodsStorage = userGoodsStorageService.getByUidAndAuctionId(uid, auctionId, Constant.SOURCE_TYPE_TAOBAO); + boolean storageState = false; + if (userGoodsStorage != null) { + // 鍙栨秷鍔犲叆閫夊搧搴� + userGoodsStorageService.deleteByPrimaryKey(userGoodsStorage.getId()); + } else { + // 鍔犲叆閫夊搧搴� + Set<String> set = new HashSet<>(); + set.add(auctionId); + userGoodsStorageService.save(uid, set, Constant.SOURCE_TYPE_TAOBAO); + storageState = true; + } + + JSONObject data = new JSONObject(); + data.put("storageState", storageState); + out.print(JsonUtil.loadTrueResult(data)); + + } catch (Exception e) { + out.print(JsonUtil.loadFalseResult("鎿嶄綔澶辫触")); + e.printStackTrace(); + } + } + + /** + * 鎵归噺娣诲姞閫夊搧搴� + * + * @param acceptData + * @param uid + * 鐢ㄦ埛id + * 娣樺疂鍟嗗搧id + * @param out + */ + @RequestMapping(value = "addstorage", method = RequestMethod.POST) + public void addStorage(AcceptData acceptData, Long uid, String auctionIds, Integer goodsType,PrintWriter out) { + try { + Gson gson = new Gson(); + Set<String> set = gson.fromJson(auctionIds, new TypeToken<HashSet<String>>() {}.getType()); + if (set == null || set.size() == 0) { + out.print(JsonUtil.loadFalseResult("鏈�夋嫨鍟嗗搧")); + return; + } + + if (goodsType == null) { + goodsType = Constant.SOURCE_TYPE_TAOBAO; + } + userGoodsStorageService.save(uid, set, goodsType); + out.print(JsonUtil.loadTrueResult("娣诲姞鎴愬姛")); + + } catch (UserGoodsStorageException e) { + out.print(JsonUtil.loadFalseResult(e.getMsg())); + } catch (Exception e) { + out.print(JsonUtil.loadFalseResult("娣诲姞澶辫触")); + e.printStackTrace(); + } + } + + /** + * 鏌ヨ鐢ㄦ埛閫夊搧搴撴暟鎹� + * + * @param acceptData + * @param page + * 椤电爜 鍒濆鍊� 1 + * @param uid + * 鐢ㄦ埛id + * @param out + */ + @RequestMapping(value = "getstoragelist", method = RequestMethod.POST) + public void getStorageList(AcceptData acceptData, Integer page, Long uid, PrintWriter out) { + + if (page == null || page < 1) { + out.print(JsonUtil.loadFalseResult("椤电爜涓嶆纭�")); + return; + } + + if (uid == null) { + out.print(JsonUtil.loadFalseResult("鐢ㄦ埛鏈櫥褰�")); + return; + } + + try { + int pageSize = Constant.PAGE_SIZE; + + JSONObject data = new JSONObject(); + JSONArray array = new JSONArray(); + + long count = userGoodsStorageService.countQueryByUid(uid, null); + if (count > 0) { + array = userGoodsStorageService.getMyStorage((page - 1) * pageSize, pageSize, uid, null); + } + + data.put("count", count); + data.put("result_list", array); + out.print(JsonUtil.loadTrueResult(data)); + + } catch (Exception e) { + out.print(JsonUtil.loadFalseResult("鍔犺浇鍒楄〃澶辫触")); + e.printStackTrace(); + } + } + + /** + * 鍒犻櫎 + * + * @param storageIds + * id鏁扮粍 + * @param out + */ + @RequestMapping(value = "deletestorage", method = RequestMethod.POST) + public void deleteStorage(AcceptData acceptData, Long uid, String storageIds, PrintWriter out) { + + if (StringUtil.isNullOrEmpty(storageIds)) { + out.print(JsonUtil.loadFalseResult("鏈�夋嫨鍟嗗搧")); + return; + } + + if (uid == null) { + out.print(JsonUtil.loadFalseResult("鐢ㄦ埛鏈櫥褰�")); + return; + } + + try { + Gson gson = new Gson(); + List<Long> list = gson.fromJson(storageIds, new TypeToken<ArrayList<Long>>() {}.getType()); + if (list == null || list.size() == 0) { + out.print(JsonUtil.loadFalseResult("鏈�夋嫨鍟嗗搧")); + return; + } + + userGoodsStorageService.deleteBatchByUidAndPrimaryKey(uid, list); + out.print(JsonUtil.loadTrueResult("鍒犻櫎鎴愬姛")); + + } catch (Exception e) { + out.print(JsonUtil.loadFalseResult("鍒犻櫎澶辫触")); + e.printStackTrace(); + } + } + + + + + /** + * 鍒嗕韩鍟嗗搧杩斿洖浜岀淮鐮佸浘鐗� + * + * @param storageIds + * id鏁扮粍 + * @param out + */ + @RequestMapping(value = "sharegoods", method = RequestMethod.POST) + public void shareGoods(AcceptData acceptData, Long uid, String storageIds, PrintWriter out) { + + if (StringUtil.isNullOrEmpty(storageIds)) { + out.print(JsonUtil.loadFalseResult("鍒嗕韩鍟嗗搧涓嶈兘涓虹┖")); + return; + } + + if (uid == null) { + out.print(JsonUtil.loadFalseResult("鐢ㄦ埛鏈櫥褰�")); + return; + } + + try { + Gson gson = new Gson(); + List<Long> listStorageID = gson.fromJson(storageIds, new TypeToken<ArrayList<Long>>() {}.getType()); + if (listStorageID == null || listStorageID.size() < 9) { + out.print(JsonUtil.loadFalseResult("鍒嗕韩鍟嗗搧鏁伴噺涓嶈冻")); + return; + } + + if (listStorageID.size() != 9) { + out.print(JsonUtil.loadFalseResult("鍒嗕韩鍟嗗搧鏁伴噺鍙兘鏄�9涓�")); + return; + } + + JSONObject data = userGoodsStorageService.shareGoods(uid, listStorageID); + out.print(JsonUtil.loadTrueResult(data)); + + } catch (UserGoodsStorageException e) { + out.print(JsonUtil.loadFalseResult("鍒嗕韩澶辫触")); + e.printStackTrace(); + } catch (UserShareGoodsRecordException e) { + out.print(JsonUtil.loadFalseResult("鍒嗕韩澶辫触")); + e.printStackTrace(); + } catch (Exception e) { + out.print(JsonUtil.loadFalseResult("鍒嗕韩澶辫触")); + e.printStackTrace(); + } + } + +} -- Gitblit v1.8.0