admin
2019-05-14 aa784ab65cc24caf45a4c38af7e5fdeb526eb393
fanli/src/main/java/com/yeshi/fanli/controller/admin/QualityFactoryAdminController.java
@@ -39,7 +39,6 @@
import com.yeshi.fanli.util.taobao.TaoKeApiUtil;
import com.yeshi.fanli.vo.quality.QualityFactoryVO;
import net.sf.json.JSONArray;
import net.sf.json.JSONObject;
@Controller
@@ -59,6 +58,7 @@
   @Resource
   private TaoBaoGoodsUpdateService taoBaoGoodsUpdateService;
   public static final int SALES_ASC = 1;
   public static final int SALES_DESC = 2;
@@ -68,48 +68,10 @@
   public static final int TKRATE_ASC = 5;
   public static final int TKRATE_DESC = 6;
   public static final int PROPOR_ASC = 7;
   public static final int PROPOR_DESC = 8;
   @RequestMapping(value = "addBatch")
   public void addBatch(String callback, String auctionIds, String lableNames, HttpServletRequest request,
         PrintWriter out) {
      try {
         // 获取当前操作用户
         AdminUser admin = (AdminUser) request.getSession().getAttribute(Constant.SESSION_ADMIN);
         if (admin == null) {
            out.print(JsonUtil.loadJSONP(callback, JsonUtil.loadFalseResult("当前账户失效,请重新登陆")));
            return;
         }
         if (StringUtil.isNullOrEmpty(auctionIds)) {
            out.print(JsonUtil.loadJSONP(callback, JsonUtil.loadFalseResult("请选者正确的商品入库")));
            return;
         }
         Gson gson = new Gson();
         List<Long> auctionIdList = gson.fromJson(auctionIds, new TypeToken<ArrayList<Long>>() {
         }.getType());
         if (auctionIdList == null || auctionIdList.size() == 0) {
            out.print(JsonUtil.loadJSONP(callback, JsonUtil.loadFalseResult("请选择正确的商品入库")));
            return;
         }
         List<TaoBaoGoodsBrief> listTaoBaoGoods = new ArrayList<>();
         JSONArray array = JSONArray.fromObject(auctionIds);
         for (int i = 0; i < array.size(); i++) {
            listTaoBaoGoods.add(TaoKeApiUtil.searchGoodsDetail(array.optLong(i)));
         }
         qualityFactoryService.addBatchTaoBaoGoods(listTaoBaoGoods, lableNames, admin);
         out.print(JsonUtil.loadJSONP(callback, JsonUtil.loadTrueResult("添加成功")));
      } catch (Exception e) {
         e.printStackTrace();
         out.print(JsonUtil.loadJSONP(callback, JsonUtil.loadFalseResult("操作异常")));
      }
   }
   /**
    * 保存修改精品库商品关联信息
@@ -120,8 +82,7 @@
    * @param out
    */
   @RequestMapping(value = "saveModify")
   public void saveModify(String callback, QualityFactory selectionGoods, HttpServletRequest request,
         PrintWriter out) {
   public void saveModify(String callback, QualityFactory selectionGoods, HttpServletRequest request, PrintWriter out) {
      try {
         AdminUser admin = (AdminUser) request.getSession().getAttribute(Constant.SESSION_ADMIN);
@@ -193,8 +154,7 @@
      try {
         Gson gson = new Gson();
         List<String> goodsIds = gson.fromJson(ids, new TypeToken<ArrayList<String>>() {
         }.getType());
         List<String> goodsIds = gson.fromJson(ids, new TypeToken<ArrayList<String>>() {}.getType());
         if (goodsIds == null || goodsIds.size() == 0) {
            out.print(JsonUtil.loadJSONP(callback, JsonUtil.loadFalseResult("未检测到移除商品数据")));
@@ -216,7 +176,6 @@
   /**
    * 查询
    *
    * @param out
    */
   @RequestMapping(value = "query")
@@ -305,6 +264,7 @@
            if (taoBaoGoodsBrief == null)
               continue; // 为空结束本次循环
            Long id = taoBaoGoodsBrief.getId();
            idBuf.append(id + ",");
@@ -373,11 +333,13 @@
         }
         for (QualityFactory selectionGoods : selectionList) {
            TaoBaoGoodsBrief taoBaoGoodsBrief = selectionGoods.getTaoBaoGoodsBrief();
            if (taoBaoGoodsBrief == null)
               continue; // 为空结束本次循环
            String auctionUrl = taoBaoGoodsBrief.getAuctionUrl();
            if (auctionUrl != null && auctionUrl.trim().length() > 0 && auctionUrl.contains("id=null")) {
@@ -413,6 +375,7 @@
            map.put("goodsSource", reslutSource);
            map.put("selectionGoods", selectionGoods);
            /* 商品销售状态: 0 在售 1停售 */
@@ -430,6 +393,7 @@
            }
            map.put("saleStae", saleStae);
            /* 1 定向计划 2 营销返利 、高佣 3 普佣 */
            Integer includeDxjh = taoBaoGoodsBrief.getIncludeDxjh();
@@ -455,6 +419,8 @@
               }
            }
            /* 券后价--计算 */
            BigDecimal couponPrice = TaoBaoUtil.getAfterUseCouplePrice(taoBaoGoodsBrief);
            map.put("couponPrice", couponPrice);
@@ -468,6 +434,7 @@
            // 预计收益
            map.put("estimateProfit", estimateProfit);
            BigDecimal couponAmount = taoBaoGoodsBrief.getCouponAmount();
            if (couponAmount != null && zkPrice != null) {
               BigDecimal propors = couponAmount.divide(zkPrice, 10, BigDecimal.ROUND_HALF_DOWN);
@@ -476,6 +443,7 @@
            } else {
               map.put("propor", 0);
            }
            /* 商品标签列表 */
            Long id = taoBaoGoodsBrief.getId();
@@ -507,8 +475,7 @@
    * 获取商品信息 以及对应标签列表;此商品标签候选项
    * 
    * @param callback
    * @param id
    *            精选id
    * @param id 精选id
    * @param request
    * @param out
    */
@@ -550,6 +517,7 @@
   }
   /**
    * 单个商品贴上标签
    * 
@@ -566,8 +534,7 @@
         // 获取当前操作用户
         AdminUser admin = (AdminUser) request.getSession().getAttribute(Constant.SESSION_ADMIN);
         // if (admin == null) {
         // out.print(JsonUtil.loadJSONP(callback,
         // JsonUtil.loadFalseResult("当前账户失效,请重新登陆。")));
//            out.print(JsonUtil.loadJSONP(callback, JsonUtil.loadFalseResult("当前账户失效,请重新登陆。")));
         // return;
         // }
@@ -661,8 +628,7 @@
         AdminUser admin = (AdminUser) request.getSession().getAttribute(Constant.SESSION_ADMIN);
         //
         // if (admin == null) {
         // out.print(JsonUtil.loadJSONP(callback,
         // JsonUtil.loadFalseResult("当前账户已失效,请重新登陆")));
//            out.print(JsonUtil.loadJSONP(callback, JsonUtil.loadFalseResult("当前账户已失效,请重新登陆")));
         // return;
         // }
@@ -685,6 +651,7 @@
            }
         }
      } catch (QualityFactoryException e) {
         e.printStackTrace();
         out.print(JsonUtil.loadJSONP(callback, JsonUtil.loadFalseResult("操作异常")));
@@ -693,8 +660,8 @@
   }
   @RequestMapping(value = "queryMyLabels")
   public void queryMyLabels(String callback, Integer pageIndex, Integer pageSize, String ids,
         HttpServletRequest request, PrintWriter out) {
   public void queryMyLabels(String callback, Integer pageIndex, Integer pageSize,
         String ids, HttpServletRequest request, PrintWriter out) {
      try {
@@ -704,8 +671,7 @@
         }
         Gson gson = new Gson();
         List<Long> idList = gson.fromJson(ids, new TypeToken<ArrayList<Long>>() {
         }.getType());
         List<Long> idList = gson.fromJson(ids, new TypeToken<ArrayList<Long>>() {}.getType());
         if (idList == null || idList.size() == 0) {
            out.print(JsonUtil.loadJSONP(callback, JsonUtil.loadFalseResult("请传递正确参数:102")));
            return;
@@ -716,6 +682,7 @@
            out.print(JsonUtil.loadJSONP(callback, JsonUtil.loadFalseResult("请传递正确参数:103")));
            return;
         }
         Long id = idList.get(0);
@@ -731,7 +698,8 @@
            pageSize = Constant.PAGE_SIZE;
         // 商品标签列表
         List<LabelGoods> labelList = labelGoodsService.queryByGoodsId((pageIndex - 1) * pageSize, pageSize, id);
         List<LabelGoods> labelList = labelGoodsService.queryByGoodsId((pageIndex - 1) * pageSize,
               pageSize, id);
         if (labelList == null || labelList.size() == 0) {
            JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("暂无标签"));
@@ -771,8 +739,8 @@
    * @param out
    */
   @RequestMapping(value = "queryLabel")
   public void queryLabel(String callback, Integer pageIndex, Integer pageSize, String key, String ids,
         HttpServletRequest request, PrintWriter out) {
   public void queryLabel(String callback, Integer pageIndex, Integer pageSize, String key,
         String ids, HttpServletRequest request, PrintWriter out) {
      try {
@@ -782,8 +750,7 @@
         }
         Gson gson = new Gson();
         List<Long> idList = gson.fromJson(ids, new TypeToken<ArrayList<Long>>() {
         }.getType());
         List<Long> idList = gson.fromJson(ids, new TypeToken<ArrayList<Long>>() {}.getType());
         if (idList == null || idList.size() == 0) {
            out.print(JsonUtil.loadJSONP(callback, JsonUtil.loadFalseResult("请传递正确参数:102")));
            return;
@@ -851,8 +818,7 @@
    * @param out
    */
   @RequestMapping(value = "addBatchcGoodsLabel")
   public void addBatchcGoodsLabel(String callback, String labIds, Long id, HttpServletRequest request,
         PrintWriter out) {
   public void addBatchcGoodsLabel(String callback, String labIds, Long id, HttpServletRequest request, PrintWriter out) {
      try {
         if (StringUtil.isNullOrEmpty(labIds)) {
@@ -931,20 +897,17 @@
   }
   /**
    * 批量添加标签 --- 精品库(随机权重)
    *
    * @param callback
    * @param request
    * @param out
    * @param 权重范围
    *            大值
    * @param 佣金范围
    *            小值
    * @param out @param         权重范围 大值
    * @param         佣金范围 小值
    */
   @RequestMapping(value = "setWeightBatch")
   public void setWeightBatch(String callback, String ids, Integer weight, Integer weightSmall, Integer weightLarge,
         HttpServletRequest request, PrintWriter out) {
   public void setWeightBatch(String callback,String ids, Integer weight,Integer weightSmall,
         Integer weightLarge, HttpServletRequest request, PrintWriter out) {
      try {
@@ -954,8 +917,7 @@
         }
         Gson gson = new Gson();
         List<Long> idList = gson.fromJson(ids, new TypeToken<ArrayList<Long>>() {
         }.getType());
          List<Long> idList = gson.fromJson(ids, new TypeToken<ArrayList<Long>>() {}.getType());
         if (idList == null || idList.size() == 0) {
            out.print(JsonUtil.loadJSONP(callback, JsonUtil.loadFalseResult("请选择需操作的商品")));
@@ -974,4 +936,5 @@
   }
}