admin
2019-05-10 1980a44902bc179420448d96100e0c5477a93005
fanli/src/main/java/com/yeshi/fanli/controller/admin/QualityFactoryAdminController.java
@@ -39,6 +39,7 @@
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
@@ -58,7 +59,6 @@
   @Resource
   private TaoBaoGoodsUpdateService taoBaoGoodsUpdateService;
   
   public static final int SALES_ASC = 1;
   public static final int SALES_DESC = 2;
@@ -68,10 +68,48 @@
   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("操作异常")));
      }
   }
   /**
    * 保存修改精品库商品关联信息
@@ -82,7 +120,8 @@
    * @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);
@@ -154,7 +193,8 @@
      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("未检测到移除商品数据")));
@@ -176,6 +216,7 @@
   /**
    * 查询
    *
    * @param out
    */
   @RequestMapping(value = "query")
@@ -264,7 +305,6 @@
            if (taoBaoGoodsBrief == null)
               continue; // 为空结束本次循环
            
            Long id = taoBaoGoodsBrief.getId();
            idBuf.append(id + ",");
            
@@ -333,13 +373,11 @@
            
         }
         
         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")) {
@@ -375,7 +413,6 @@
            
            map.put("goodsSource", reslutSource);
            
            map.put("selectionGoods", selectionGoods);
            /* 商品销售状态: 0 在售 1停售 */
@@ -393,7 +430,6 @@
            }
            
            map.put("saleStae", saleStae);
            /* 1 定向计划 2 营销返利 、高佣 3 普佣 */
            Integer includeDxjh = taoBaoGoodsBrief.getIncludeDxjh();
@@ -419,8 +455,6 @@
               }
            }
            
             /* 券后价--计算 */
            BigDecimal couponPrice = TaoBaoUtil.getAfterUseCouplePrice(taoBaoGoodsBrief);
            map.put("couponPrice", couponPrice);
@@ -434,7 +468,6 @@
            // 预计收益
            map.put("estimateProfit", estimateProfit);
            
            BigDecimal couponAmount = taoBaoGoodsBrief.getCouponAmount();
            if (couponAmount != null && zkPrice != null) {
               BigDecimal propors = couponAmount.divide(zkPrice ,10 ,BigDecimal.ROUND_HALF_DOWN);
@@ -443,7 +476,6 @@
            } else {
               map.put("propor", 0);
            }
            /* 商品标签列表 */
            Long id = taoBaoGoodsBrief.getId();
@@ -475,7 +507,8 @@
    * 获取商品信息 以及对应标签列表;此商品标签候选项
    * 
    * @param callback
    * @param id 精选id
    * @param id
    *            精选id
    * @param request
    * @param out
    */
@@ -517,7 +550,6 @@
   }
   /**
    * 单个商品贴上标签
    * 
@@ -534,7 +566,8 @@
         // 获取当前操作用户
         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;
//         }
@@ -628,7 +661,8 @@
         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;
//         } 
@@ -651,7 +685,6 @@
            }
         }
         
      } catch (QualityFactoryException e) {
         e.printStackTrace();
         out.print(JsonUtil.loadJSONP(callback, JsonUtil.loadFalseResult("操作异常")));
@@ -660,8 +693,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 {
         
@@ -671,7 +704,8 @@
         }
         
         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;
@@ -682,7 +716,6 @@
            out.print(JsonUtil.loadJSONP(callback, JsonUtil.loadFalseResult("请传递正确参数:103")));
            return;
         }
         
         Long id = idList.get(0);
         
@@ -698,8 +731,7 @@
            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("暂无标签"));
@@ -739,8 +771,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 {
@@ -750,7 +782,8 @@
         }
         
         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;
@@ -818,7 +851,8 @@
    * @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)) {
@@ -897,17 +931,20 @@
      
   }
   
   /**
    * 批量添加标签 --- 精品库(随机权重)
    *
    * @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 {  
      
@@ -917,7 +954,8 @@
          } 
          
          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("请选择需操作的商品")));
@@ -935,6 +973,5 @@
      }
   }
   
}