From e1a62ec62e7331d97af9302e90e1ce44af8235eb Mon Sep 17 00:00:00 2001 From: admin <weikou2014> Date: 星期三, 27 一月 2021 15:26:55 +0800 Subject: [PATCH] 拼多多授权绑定 --- fanli/src/main/java/com/yeshi/fanli/controller/admin/PushGoodsController.java | 88 +++++++++++++++++++++++++++++++++----------- 1 files changed, 66 insertions(+), 22 deletions(-) diff --git a/fanli/src/main/java/com/yeshi/fanli/controller/admin/PushGoodsController.java b/fanli/src/main/java/com/yeshi/fanli/controller/admin/PushGoodsController.java index 28dccb4..dcfca1c 100644 --- a/fanli/src/main/java/com/yeshi/fanli/controller/admin/PushGoodsController.java +++ b/fanli/src/main/java/com/yeshi/fanli/controller/admin/PushGoodsController.java @@ -1,12 +1,15 @@ package com.yeshi.fanli.controller.admin; import java.io.PrintWriter; +import java.text.SimpleDateFormat; import java.util.ArrayList; import java.util.Arrays; +import java.util.Date; import java.util.List; import javax.annotation.Resource; +import com.yeshi.fanli.entity.accept.AdminAcceptData; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.RequestMapping; import org.yeshi.utils.JsonUtil; @@ -17,13 +20,13 @@ import com.yeshi.fanli.entity.goods.CommonGoods; import com.yeshi.fanli.entity.push.PushGoods; import com.yeshi.fanli.entity.push.PushGoodsGroup; -import com.yeshi.fanli.entity.taobao.TaoBaoGoodsBrief; -import com.yeshi.fanli.exception.PushException; +import com.yeshi.goods.facade.entity.taobao.TaoBaoGoodsBrief; +import com.yeshi.fanli.exception.push.PushException; import com.yeshi.fanli.exception.push.PushGoodsException; import com.yeshi.fanli.service.AdminUserService; import com.yeshi.fanli.service.inter.push.PushGoodsGroupService; import com.yeshi.fanli.service.inter.push.PushGoodsService; -import com.yeshi.fanli.tag.PageEntity; +import com.yeshi.common.entity.PageEntity; import com.yeshi.fanli.util.Constant; import com.yeshi.fanli.util.StringUtil; import com.yeshi.fanli.util.taobao.TaoBaoUtil; @@ -51,7 +54,7 @@ * @param out */ @RequestMapping(value = "save") - public void save(String callback, PushGoods pushGoods, String idArray, String arrayIOS, + public void save(AdminAcceptData acceptData,String callback, PushGoods pushGoods, String idArray, String arrayIOS, String arrayAndroid, PrintWriter out) { try { @@ -76,13 +79,39 @@ pushGoodsService.save(pushGoods, list); JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult("娣诲姞鎴愬姛")); - + } catch (PushGoodsException e) { + JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult(e.getMsg())); } catch (Exception e) { JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("鎿嶄綔寮傚父")); e.printStackTrace(); } } + + /** + * 鏂板/淇敼 + * + * @param callback + * @param special + * @param out + */ + @RequestMapping(value = "saveInfo") + public void saveInfo(AdminAcceptData acceptData,String callback, PushGoods pushGoods, String arrayIOS, String arrayAndroid, PrintWriter out) { + try { + // 鐗堟湰澶勭悊 + convertVersion(pushGoods, arrayIOS, arrayAndroid); + // 淇濆瓨 + pushGoodsService.saveInfo(pushGoods); + + JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult("娣诲姞鎴愬姛")); + } catch (PushGoodsException e) { + JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult(e.getMsg())); + } catch (Exception e) { + JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("鎿嶄綔寮傚父")); + e.printStackTrace(); + } + } + /** * 鍒犻櫎 * @@ -91,7 +120,7 @@ * @param out */ @RequestMapping(value = "delete") - public void delete(String callback, String idArray, PrintWriter out) { + public void delete(AdminAcceptData acceptData,String callback, String idArray, PrintWriter out) { try { if (StringUtil.isNullOrEmpty(idArray)) { @@ -129,7 +158,7 @@ * @param out */ @RequestMapping(value = "getPushInfo") - public void getPushInfo(String callback, Long id, PrintWriter out) { + public void getPushInfo(AdminAcceptData acceptData,String callback, Long id, PrintWriter out) { if (id == null) { JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("鍙傛暟涓嶈兘涓虹┖")); @@ -143,13 +172,22 @@ JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("鏁版嵁淇℃伅宸蹭笉瀛樺湪")); return; } + + Date controlTime = pushGoods.getControlTime(); + SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm"); + if (controlTime == null) { + pushGoods.setControlTime_str(""); + } else { + pushGoods.setControlTime_str(sdf.format(controlTime)); + } + // 鐗堟湰澶勭悊 convertVersionList(pushGoods); List<TaoBaoGoodsBrief> listgoods = new ArrayList<TaoBaoGoodsBrief>(); - List<PushGoodsGroup> listGroup = pushGoodsGroupService.getAllInfoByPushId(pushGoods.getId()); + List<PushGoodsGroup> listGroup = pushGoodsGroupService.getAllInfoByPushId(id); if (listGroup == null) { listGroup = new ArrayList<PushGoodsGroup>(); } else { @@ -162,8 +200,12 @@ } } + GsonBuilder gsonBuilder = new GsonBuilder(); + gsonBuilder.serializeNulls(); + Gson gson = gsonBuilder.create(); + JSONObject data = new JSONObject(); - data.put("pushGoods", pushGoods); + data.put("pushGoods", gson.toJson(pushGoods)); data.put("listGroup", listgoods); JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult(data)); @@ -185,7 +227,7 @@ * @param out */ @RequestMapping(value = "query") - public void query(String callback, Integer pageIndex, Integer pageSize, String key, Integer state, PrintWriter out) { + public void query(AdminAcceptData acceptData, String callback, Integer pageIndex, Integer pageSize, String key, Integer state, PrintWriter out) { if (pageIndex == null || pageIndex < 1) { pageIndex = 1; @@ -197,14 +239,22 @@ try { - List<PushGoods> list = pushGoodsService.listQuery((pageIndex - 1) * pageSize, pageSize, key, state); - + List<PushGoods> list = pushGoodsService.listQuery((pageIndex - 1) * pageSize, pageSize, key, state,acceptData.getSystem()); if (list == null || list.size() == 0) { JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("鏆傛棤鏁版嵁")); return; } + SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm"); for (PushGoods pushGoods : list) { + + Date controlTime = pushGoods.getControlTime(); + if (controlTime == null) { + pushGoods.setControlTime_str(""); + } else { + pushGoods.setControlTime_str(sdf.format(controlTime)); + } + long countGoods = pushGoodsGroupService.countByPushId(pushGoods.getId()); pushGoods.setCountGoods(countGoods); @@ -212,7 +262,7 @@ convertVersionList(pushGoods); } - long count = pushGoodsService.countQuery(key, state); + long count = pushGoodsService.countQuery(key, state,acceptData.getSystem()); int totalPage = (int) (count % pageSize == 0 ? count / pageSize : count / pageSize + 1); PageEntity pe = new PageEntity(pageIndex, pageSize, count, totalPage); @@ -237,34 +287,28 @@ /** * 鍟嗗搧鎺ㄩ�� * - * @param id 鎺ㄩ�乮d * @param out * @throws Exception */ @RequestMapping(value = "push") - public void push(String callback, String idArray, PrintWriter out) throws Exception { - + public void push(AdminAcceptData acceptData,String callback, String idArray, PrintWriter out) throws Exception { if (idArray == null || idArray.trim().length() == 0) { JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("浼犻�掑弬鏁颁笉鑳戒负绌�")); return; } try { - Gson gson = new Gson(); List<Long> list = gson.fromJson(idArray, new TypeToken<ArrayList<Long>>() {}.getType()); - if (list == null || list.size() == 0) { JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("浼犻�掑弬鏁颁笉鑳戒负绌�")); return; } for (Long id: list) { - pushGoodsService.executePush(id); + pushGoodsService.handPush(id); } - JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult("鎺ㄩ�佹垚鍔�")); - } catch (PushException e) { JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult(e.getMsg())); } catch (PushGoodsException e) { @@ -341,7 +385,7 @@ } else { JSONObject json = JSONObject.fromObject(versions); - String versionsIOS = json.getString("IOS"); + String versionsIOS = json.optString("IOS"); if (versionsIOS != null && versionsIOS.trim().length() > 0) { listIOS = Arrays.asList(versionsIOS.split(",")); } -- Gitblit v1.8.0