| | |
| | | package com.yeshi.fanli.controller.admin.order;
|
| | |
|
| | | import java.io.PrintWriter;
|
| | | import java.lang.reflect.Type;
|
| | | import java.util.Date;
|
| | | import java.util.HashSet;
|
| | | import java.util.Iterator;
|
| | | import java.util.List;
|
| | | import java.util.Set;
|
| | |
|
| | | 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.google.gson.Gson;
|
| | | import com.google.gson.GsonBuilder;
|
| | | import com.google.gson.JsonElement;
|
| | | import com.google.gson.JsonPrimitive;
|
| | | import com.google.gson.JsonSerializationContext;
|
| | | import com.google.gson.JsonSerializer;
|
| | | import com.yeshi.fanli.entity.taobao.TaoBaoOrder;
|
| | | import com.yeshi.fanli.entity.taobao.TaoBaoWeiQuanOrder;
|
| | | import com.yeshi.fanli.job.order.taobao.UpdateOrderJob;
|
| | | import com.yeshi.fanli.job.order.taobao.UpdateTBRelationAndSpecialOrderJob;
|
| | | import com.yeshi.fanli.service.inter.order.tb.TaoBaoOrderService;
|
| | | import com.yeshi.fanli.service.inter.order.tb.TaoBaoWeiQuanOrderService;
|
| | | import com.yeshi.common.entity.PageEntity;
|
| | | import com.yeshi.fanli.util.Constant;
|
| | | import com.yeshi.fanli.util.StringUtil;
|
| | | import org.yeshi.utils.TimeUtil;
|
| | |
|
| | | import net.sf.json.JSONObject;
|
| | |
|
| | | @Controller
|
| | | @RequestMapping("admin/new/api/v1/taobaoOrder")
|
| | | public class TaoBaoOrderController {
|
| | |
|
| | | @Resource
|
| | | private TaoBaoOrderService taoBaoOrderService;
|
| | |
|
| | | @Resource
|
| | | private TaoBaoWeiQuanOrderService taoBaoWeiQuanOrderService;
|
| | |
|
| | | @Resource
|
| | | private UpdateTBRelationAndSpecialOrderJob updateRelationAndSpecialOrderJob;
|
| | |
|
| | | @Resource
|
| | | private UpdateOrderJob updateOrderJob;
|
| | |
|
| | | /**
|
| | | * 查询列表 - 新后台
|
| | | * |
| | | * @param callback
|
| | | * @param key
|
| | | * 查询词 名称
|
| | | * @param pageIndex
|
| | | * @param out
|
| | | */
|
| | | @RequestMapping(value = "listTaoBaoOrder")
|
| | | public void listTaoBaoOrder(AdminAcceptData acceptData, String callback, String key, Integer pageIndex, PrintWriter out) {
|
| | |
|
| | | try {
|
| | |
|
| | | if (pageIndex == null || pageIndex < 0) {
|
| | | pageIndex = 1;
|
| | | }
|
| | |
|
| | | List<TaoBaoOrder> orderList = null;
|
| | | Long count = null;
|
| | |
|
| | | if (!StringUtil.isNullOrEmpty(key)) {
|
| | | orderList = taoBaoOrderService.getTaoBaoOrderByOrderId(key);
|
| | | count = (long) orderList.size();
|
| | | } else {
|
| | | orderList = taoBaoOrderService.listAllOrder(pageIndex, Constant.PAGE_SIZE);
|
| | | count = taoBaoOrderService.countAllOrder();
|
| | | }
|
| | |
|
| | | int pageSize = Constant.PAGE_SIZE;
|
| | |
|
| | | int totalPage = (int) (count % pageSize == 0 ? count / pageSize : count / pageSize + 1);
|
| | | PageEntity pe = new PageEntity(pageIndex, pageSize, count, totalPage);
|
| | |
|
| | | Gson gson = new GsonBuilder().registerTypeAdapter(Date.class, new JsonSerializer<Date>() {
|
| | | @Override
|
| | | public JsonElement serialize(Date value, Type theType, JsonSerializationContext context) {
|
| | | if (value == null) {
|
| | | return new JsonPrimitive("");
|
| | | } else {
|
| | | return new JsonPrimitive(TimeUtil.getGernalTime(value.getTime(), "yyyy-MM-dd HH:mm:ss"));
|
| | | }
|
| | | }
|
| | | }).create();
|
| | |
|
| | | JSONObject data = new JSONObject();
|
| | | data.put("pe", pe);
|
| | | data.put("result_list", gson.toJson(orderList));
|
| | |
|
| | | JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult(data));
|
| | |
|
| | | } catch (Exception e) {
|
| | | JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("查询失败"));
|
| | | e.printStackTrace();
|
| | | }
|
| | | }
|
| | |
|
| | | @RequestMapping(value = "updateTaoBaoOrder")
|
| | | public void updateTaoBaoOrder(AdminAcceptData acceptData,String callback, String ids, PrintWriter out) {
|
| | | try {
|
| | | if (StringUtil.isNullOrEmpty(ids)) {
|
| | | JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("请上传订单ID"));
|
| | | return;
|
| | | }
|
| | | net.sf.json.JSONArray idsArray = net.sf.json.JSONArray.fromObject(ids);
|
| | |
|
| | | Set<String> orderIds = new HashSet<>();
|
| | |
|
| | | for (int i = 0; i < idsArray.size(); i++) {
|
| | | TaoBaoOrder taoBaoOrder = taoBaoOrderService.selectByPrimaryKey(idsArray.optLong(i));
|
| | | orderIds.add(taoBaoOrder.getOrderId());
|
| | | }
|
| | |
|
| | | Long[] startTimes = new Long[orderIds.size()];
|
| | | Long[] endTimes = new Long[orderIds.size()];
|
| | |
|
| | | int p = 0;
|
| | | for (Iterator<String> its = orderIds.iterator(); its.hasNext();) {
|
| | | String orderId = its.next();
|
| | | List<TaoBaoOrder> list = taoBaoOrderService.getTaoBaoOrderByOrderId(orderId);
|
| | | startTimes[p] = TimeUtil.convertToTimeTemp(list.get(0).getCreateTime(), "yyyy-MM-dd HH:mm:ss") - 1000L;
|
| | | endTimes[p] = TimeUtil.convertToTimeTemp(list.get(0).getCreateTime(), "yyyy-MM-dd HH:mm:ss") + 1000L;
|
| | | p++;
|
| | | }
|
| | |
|
| | | for (int i = 0; i < idsArray.size(); i++) {
|
| | | updateRelationAndSpecialOrderJob.updateRelationAndSpecialOrder(startTimes[i], endTimes[i]);
|
| | | updateOrderJob.updateOrder(startTimes[i], endTimes[i]);
|
| | | }
|
| | | JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult("更新成功"));
|
| | | } catch (Exception e) {
|
| | | JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("更新失败"));
|
| | | e.printStackTrace();
|
| | | }
|
| | | }
|
| | |
|
| | | @RequestMapping(value = "listTaoBaoWQOrder")
|
| | | public void listTaoBaoWeiQuanOrder(AdminAcceptData acceptData,String callback, String key, Integer pageIndex, PrintWriter out) {
|
| | | try {
|
| | | if (pageIndex == null || pageIndex < 0) {
|
| | | pageIndex = 1;
|
| | | }
|
| | | List<TaoBaoWeiQuanOrder> orderList = null;
|
| | | Long count = null;
|
| | | if (!StringUtil.isNullOrEmpty(key)) {
|
| | | orderList = taoBaoWeiQuanOrderService.listByOrderId(key);
|
| | | count = (long) orderList.size();
|
| | | } else {
|
| | | orderList = taoBaoWeiQuanOrderService.listByState(null, pageIndex, Constant.PAGE_SIZE);
|
| | | count = taoBaoWeiQuanOrderService.countByState(null);
|
| | | }
|
| | |
|
| | | int pageSize = Constant.PAGE_SIZE;
|
| | |
|
| | | int totalPage = (int) (count % pageSize == 0 ? count / pageSize : count / pageSize + 1);
|
| | | PageEntity pe = new PageEntity(pageIndex, pageSize, count, totalPage);
|
| | |
|
| | | Gson gson = new GsonBuilder().registerTypeAdapter(Date.class, new JsonSerializer<Date>() {
|
| | | @Override
|
| | | public JsonElement serialize(Date value, Type theType, JsonSerializationContext context) {
|
| | | if (value == null) {
|
| | | return new JsonPrimitive("");
|
| | | } else {
|
| | | return new JsonPrimitive(TimeUtil.getGernalTime(value.getTime(), "yyyy-MM-dd HH:mm:ss"));
|
| | | }
|
| | | }
|
| | | }).create();
|
| | |
|
| | | JSONObject data = new JSONObject();
|
| | | data.put("pe", pe);
|
| | | data.put("result_list", gson.toJson(orderList));
|
| | |
|
| | | JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult(data));
|
| | |
|
| | | } catch (Exception e) {
|
| | | JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("查询失败"));
|
| | | e.printStackTrace();
|
| | | }
|
| | | }
|
| | |
|
| | | }
|
| | | package com.yeshi.fanli.controller.admin.order; |
| | | |
| | | import com.google.gson.*; |
| | | import com.yeshi.common.entity.PageEntity; |
| | | import com.yeshi.fanli.entity.accept.AdminAcceptData; |
| | | import com.yeshi.fanli.entity.taobao.TaoBaoOrder; |
| | | import com.yeshi.fanli.entity.taobao.TaoBaoWeiQuanOrder; |
| | | import com.yeshi.fanli.job.order.taobao.UpdateOrderJob; |
| | | import com.yeshi.fanli.job.order.taobao.UpdateTBRelationAndSpecialOrderJob; |
| | | import com.yeshi.fanli.service.inter.order.OrderProcessService; |
| | | import com.yeshi.fanli.service.inter.order.tb.TaoBaoOrderService; |
| | | import com.yeshi.fanli.service.inter.order.tb.TaoBaoWeiQuanOrderService; |
| | | import com.yeshi.fanli.util.Constant; |
| | | import com.yeshi.fanli.util.StringUtil; |
| | | import com.yeshi.fanli.util.ThreadUtil; |
| | | import com.yeshi.fanli.util.taobao.TaoBaoOrderUtil; |
| | | import net.sf.json.JSONObject; |
| | | import org.springframework.stereotype.Controller; |
| | | import org.springframework.web.bind.annotation.RequestMapping; |
| | | import org.springframework.web.bind.annotation.RequestParam; |
| | | import org.springframework.web.multipart.commons.CommonsMultipartFile; |
| | | import org.yeshi.utils.JsonUtil; |
| | | import org.yeshi.utils.TimeUtil; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.io.File; |
| | | import java.io.FileInputStream; |
| | | import java.io.IOException; |
| | | import java.io.PrintWriter; |
| | | import java.lang.reflect.Type; |
| | | import java.util.*; |
| | | |
| | | @Controller |
| | | @RequestMapping("admin/new/api/v1/taobaoOrder") |
| | | public class TaoBaoOrderController { |
| | | |
| | | @Resource |
| | | private TaoBaoOrderService taoBaoOrderService; |
| | | |
| | | @Resource |
| | | private TaoBaoWeiQuanOrderService taoBaoWeiQuanOrderService; |
| | | |
| | | @Resource |
| | | private UpdateTBRelationAndSpecialOrderJob updateRelationAndSpecialOrderJob; |
| | | |
| | | @Resource |
| | | private UpdateOrderJob updateOrderJob; |
| | | |
| | | @Resource |
| | | private OrderProcessService orderProcessService; |
| | | |
| | | /** |
| | | * 查询列表 - 新后台 |
| | | * |
| | | * @param callback |
| | | * @param key 查询词 名称 |
| | | * @param pageIndex |
| | | * @param out |
| | | */ |
| | | @RequestMapping(value = "listTaoBaoOrder") |
| | | public void listTaoBaoOrder(AdminAcceptData acceptData, String callback, String key, Integer pageIndex, PrintWriter out) { |
| | | |
| | | try { |
| | | |
| | | if (pageIndex == null || pageIndex < 0) { |
| | | pageIndex = 1; |
| | | } |
| | | |
| | | List<TaoBaoOrder> orderList = null; |
| | | Long count = null; |
| | | |
| | | if (!StringUtil.isNullOrEmpty(key)) { |
| | | orderList = taoBaoOrderService.getTaoBaoOrderByOrderId(key); |
| | | count = (long) orderList.size(); |
| | | } else { |
| | | orderList = taoBaoOrderService.listAllOrder(pageIndex, Constant.PAGE_SIZE); |
| | | count = taoBaoOrderService.countAllOrder(); |
| | | } |
| | | |
| | | int pageSize = Constant.PAGE_SIZE; |
| | | |
| | | int totalPage = (int) (count % pageSize == 0 ? count / pageSize : count / pageSize + 1); |
| | | PageEntity pe = new PageEntity(pageIndex, pageSize, count, totalPage); |
| | | |
| | | Gson gson = new GsonBuilder().registerTypeAdapter(Date.class, new JsonSerializer<Date>() { |
| | | @Override |
| | | public JsonElement serialize(Date value, Type theType, JsonSerializationContext context) { |
| | | if (value == null) { |
| | | return new JsonPrimitive(""); |
| | | } else { |
| | | return new JsonPrimitive(TimeUtil.getGernalTime(value.getTime(), "yyyy-MM-dd HH:mm:ss")); |
| | | } |
| | | } |
| | | }).create(); |
| | | |
| | | JSONObject data = new JSONObject(); |
| | | data.put("pe", pe); |
| | | data.put("result_list", gson.toJson(orderList)); |
| | | |
| | | JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult(data)); |
| | | |
| | | } catch (Exception e) { |
| | | JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("查询失败")); |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | @RequestMapping(value = "listTaoBaoOrderNoUpdate") |
| | | public void listTaoBaoOrderUnUpdate(AdminAcceptData acceptData, String callback, String key, Integer pageIndex, PrintWriter out) { |
| | | |
| | | try { |
| | | if (pageIndex == null || pageIndex < 0) { |
| | | pageIndex = 1; |
| | | } |
| | | |
| | | List<TaoBaoOrder> orderList = null; |
| | | Long count = null; |
| | | |
| | | if (!StringUtil.isNullOrEmpty(key)) { |
| | | orderList = taoBaoOrderService.getTaoBaoOrderByOrderId(key); |
| | | count = (long) orderList.size(); |
| | | } else { |
| | | orderList = taoBaoOrderService.listAllOrder(pageIndex, Constant.PAGE_SIZE); |
| | | count = taoBaoOrderService.countAllOrder(); |
| | | } |
| | | |
| | | int pageSize = Constant.PAGE_SIZE; |
| | | |
| | | int totalPage = (int) (count % pageSize == 0 ? count / pageSize : count / pageSize + 1); |
| | | PageEntity pe = new PageEntity(pageIndex, pageSize, count, totalPage); |
| | | |
| | | Gson gson = new GsonBuilder().registerTypeAdapter(Date.class, new JsonSerializer<Date>() { |
| | | @Override |
| | | public JsonElement serialize(Date value, Type theType, JsonSerializationContext context) { |
| | | if (value == null) { |
| | | return new JsonPrimitive(""); |
| | | } else { |
| | | return new JsonPrimitive(TimeUtil.getGernalTime(value.getTime(), "yyyy-MM-dd HH:mm:ss")); |
| | | } |
| | | } |
| | | }).create(); |
| | | |
| | | JSONObject data = new JSONObject(); |
| | | data.put("pe", pe); |
| | | data.put("result_list", gson.toJson(orderList)); |
| | | |
| | | JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult(data)); |
| | | |
| | | } catch (Exception e) { |
| | | JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("查询失败")); |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | |
| | | |
| | | |
| | | @RequestMapping(value = "updateTaoBaoOrder") |
| | | public void updateTaoBaoOrder(AdminAcceptData acceptData, String callback, String ids, PrintWriter out) { |
| | | try { |
| | | if (StringUtil.isNullOrEmpty(ids)) { |
| | | JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("请上传订单ID")); |
| | | return; |
| | | } |
| | | net.sf.json.JSONArray idsArray = net.sf.json.JSONArray.fromObject(ids); |
| | | |
| | | Set<String> orderIds = new HashSet<>(); |
| | | |
| | | for (int i = 0; i < idsArray.size(); i++) { |
| | | orderIds.add(idsArray.optString(i)); |
| | | } |
| | | |
| | | Long[] startTimes = new Long[orderIds.size()]; |
| | | Long[] endTimes = new Long[orderIds.size()]; |
| | | |
| | | int p = 0; |
| | | for (Iterator<String> its = orderIds.iterator(); its.hasNext(); ) { |
| | | String orderId = its.next(); |
| | | List<TaoBaoOrder> list = taoBaoOrderService.getTaoBaoOrderByOrderId(orderId); |
| | | startTimes[p] = TimeUtil.convertToTimeTemp(list.get(0).getCreateTime(), "yyyy-MM-dd HH:mm:ss") - 1000L; |
| | | endTimes[p] = TimeUtil.convertToTimeTemp(list.get(0).getCreateTime(), "yyyy-MM-dd HH:mm:ss") + 1000L; |
| | | p++; |
| | | } |
| | | |
| | | for (int i = 0; i < idsArray.size(); i++) { |
| | | updateRelationAndSpecialOrderJob.updateRelationAndSpecialOrder(startTimes[i], endTimes[i]); |
| | | updateOrderJob.updateOrder(startTimes[i], endTimes[i]); |
| | | } |
| | | JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult("更新成功")); |
| | | } catch (Exception e) { |
| | | JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("更新失败")); |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | |
| | | @RequestMapping(value = "listTaoBaoWQOrder") |
| | | public void listTaoBaoWeiQuanOrder(AdminAcceptData acceptData, String callback, String key, Integer pageIndex, PrintWriter out) { |
| | | try { |
| | | if (pageIndex == null || pageIndex < 0) { |
| | | pageIndex = 1; |
| | | } |
| | | List<TaoBaoWeiQuanOrder> orderList = null; |
| | | Long count = null; |
| | | if (!StringUtil.isNullOrEmpty(key)) { |
| | | orderList = taoBaoWeiQuanOrderService.listByOrderId(key); |
| | | count = (long) orderList.size(); |
| | | } else { |
| | | orderList = taoBaoWeiQuanOrderService.listByState(null, pageIndex, Constant.PAGE_SIZE); |
| | | count = taoBaoWeiQuanOrderService.countByState(null); |
| | | } |
| | | |
| | | int pageSize = Constant.PAGE_SIZE; |
| | | |
| | | int totalPage = (int) (count % pageSize == 0 ? count / pageSize : count / pageSize + 1); |
| | | PageEntity pe = new PageEntity(pageIndex, pageSize, count, totalPage); |
| | | |
| | | Gson gson = new GsonBuilder().registerTypeAdapter(Date.class, new JsonSerializer<Date>() { |
| | | @Override |
| | | public JsonElement serialize(Date value, Type theType, JsonSerializationContext context) { |
| | | if (value == null) { |
| | | return new JsonPrimitive(""); |
| | | } else { |
| | | return new JsonPrimitive(TimeUtil.getGernalTime(value.getTime(), "yyyy-MM-dd HH:mm:ss")); |
| | | } |
| | | } |
| | | }).create(); |
| | | |
| | | JSONObject data = new JSONObject(); |
| | | data.put("pe", pe); |
| | | data.put("result_list", gson.toJson(orderList)); |
| | | |
| | | JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult(data)); |
| | | |
| | | } catch (Exception e) { |
| | | JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("查询失败")); |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 新后台端 上传订单文件 |
| | | * |
| | | * @param acceptData |
| | | * @param file |
| | | * @param out |
| | | */ |
| | | @RequestMapping(value = "uploadWQOrderFile") |
| | | public void uploadWQOrderFile(AdminAcceptData acceptData, @RequestParam("file") CommonsMultipartFile file, PrintWriter out) { |
| | | |
| | | if (file == null) { |
| | | out.print(JsonUtil.loadFalseResult("上传文件不能为空")); |
| | | return; |
| | | } |
| | | |
| | | List<TaoBaoWeiQuanOrder> orderList = null; |
| | | try { |
| | | orderList = TaoBaoOrderUtil.parseWeiQuanOrder( |
| | | file.getInputStream()); |
| | | int pos = 0; |
| | | for (TaoBaoWeiQuanOrder order : orderList) |
| | | try { |
| | | pos++; |
| | | // if (pos == 19||pos == 26) |
| | | taoBaoWeiQuanOrderService.addWeiQuanOrder(order);// 添加维权订单到数据库 |
| | | } catch (Exception e) { |
| | | System.out.println("位置:" + pos); |
| | | e.printStackTrace(); |
| | | } |
| | | // 处理维权订单 |
| | | out.print(JsonUtil.loadTrueResult("上传成功,系统正在处理中...")); |
| | | } catch (IOException e) { |
| | | out.print(JsonUtil.loadFalseResult("上传文件失败")); |
| | | e.printStackTrace(); |
| | | } |
| | | |
| | | final List<TaoBaoWeiQuanOrder> finalOrderList = orderList; |
| | | |
| | | ThreadUtil.run(new Runnable() { |
| | | @Override |
| | | public void run() { |
| | | orderProcessService.weiQuanOrder(finalOrderList); |
| | | } |
| | | }); |
| | | |
| | | } |
| | | } |