| | |
| | |
|
| | | 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;
|
| | |
| | | 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;
|
| | |
| | | * @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 {
|
| | |
| | | }
|
| | | }
|
| | |
|
| | | |
| | | /**
|
| | | * 新增/修改
|
| | | * |
| | | * @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();
|
| | | }
|
| | | }
|
| | | |
| | | /**
|
| | | * 删除
|
| | | *
|
| | |
| | | * @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)) {
|
| | |
| | | * @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("参数不能为空"));
|
| | |
| | | Date controlTime = pushGoods.getControlTime();
|
| | | SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm");
|
| | | if (controlTime == null) {
|
| | | pushGoods.setTimeTask(false);
|
| | | pushGoods.setControlTime_str("");
|
| | | } else {
|
| | | pushGoods.setTimeTask(true);
|
| | | pushGoods.setControlTime_str(sdf.format(controlTime));
|
| | | }
|
| | |
|
| | |
| | | * @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;
|
| | |
| | |
|
| | | 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();
|
| | | SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm");
|
| | | if (controlTime == null) {
|
| | | pushGoods.setTimeTask(false);
|
| | | pushGoods.setControlTime_str("");
|
| | | } else {
|
| | | pushGoods.setTimeTask(true);
|
| | | pushGoods.setControlTime_str(sdf.format(controlTime));
|
| | | }
|
| | |
|
| | |
| | | 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);
|
| | |
| | | /**
|
| | | * 商品推送
|
| | | *
|
| | | * @param id 推送id
|
| | | * @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.handPush(id);
|
| | | }
|
| | | |
| | | JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult("推送成功"));
|
| | | |
| | | } catch (PushException e) {
|
| | | JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult(e.getMsg()));
|
| | | } catch (PushGoodsException e) {
|
| | |
| | | } 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(","));
|
| | | }
|