| | |
| | |
|
| | | import net.sf.json.JSONObject;
|
| | |
|
| | | import org.springframework.core.task.TaskExecutor;
|
| | | import org.springframework.stereotype.Controller;
|
| | | import org.springframework.web.bind.annotation.RequestMapping;
|
| | | import org.springframework.web.bind.annotation.RequestMethod;
|
| | |
| | | import com.yeshi.fanli.service.inter.order.OrderProcessService;
|
| | | import com.yeshi.fanli.service.inter.order.OrderService;
|
| | | import com.yeshi.fanli.util.TimeUtil;
|
| | | import com.yeshi.fanli.util.annotation.RequestNoLogin;
|
| | | import com.yeshi.fanli.util.taobao.TaoBaoOrderUtil;
|
| | |
|
| | | @Controller
|
| | |
| | |
|
| | | @Resource
|
| | | private AdminUserService adminUserService;
|
| | | |
| | | @Resource(name = "taskExecutor")
|
| | | private TaskExecutor executor;
|
| | | |
| | |
|
| | |
|
| | | // private static final String PAYSUCCESS = "支付成功";
|
| | |
| | | * @param response
|
| | | * @param out
|
| | | */
|
| | | @RequestNoLogin()
|
| | | @RequestMapping(value = "uploadOrderFile")
|
| | | public void uploadOrderFile(@RequestParam("file") CommonsMultipartFile file, Long uid,
|
| | | HttpServletRequest request, HttpServletResponse response, PrintWriter out) {
|
| | |
| | | return;
|
| | | }
|
| | |
|
| | | List<TaoBaoOrder> orderList = null ;
|
| | | try {
|
| | | List<TaoBaoOrder> orderList = TaoBaoOrderUtil.parseOrder(file.getInputStream());
|
| | | |
| | | orderProcessService.processOrder(TaoBaoOrderUtil.classifyTaoBaoOrderByOrderId(orderList));
|
| | | |
| | | out.print(JsonUtil.loadTrueResult("上传成功"));
|
| | | |
| | | orderList = TaoBaoOrderUtil.parseOrder(file.getInputStream());
|
| | | out.print(JsonUtil.loadTrueResult("上传文件成功"));
|
| | | } catch (IOException e) {
|
| | | out.print(JsonUtil.loadFalseResult("上传文件失败"));
|
| | | e.printStackTrace();
|
| | | out.print(JsonUtil.loadFalseResult("上传异常"));
|
| | | }
|
| | | |
| | | final List<TaoBaoOrder> list = orderList;
|
| | | |
| | | executor.execute(new Runnable() {
|
| | | @Override
|
| | | public void run() {
|
| | | try {
|
| | | |
| | | orderProcessService.processOrder(TaoBaoOrderUtil.classifyTaoBaoOrderByOrderId(list));
|
| | | |
| | | } catch (Exception e) {
|
| | | e.printStackTrace();
|
| | | }
|
| | |
|
| | | }
|
| | | });
|
| | | |
| | | }
|
| | |
|
| | | |
| | | /**
|
| | | * 上传图片jsonp
|
| | | * @param file |
| | | * @param out |
| | | */
|
| | | @RequestNoLogin()
|
| | | @RequestMapping(value = "uploadPicture")
|
| | | public void uploadPicture(@RequestParam("file") CommonsMultipartFile file, Long uid, |
| | | HttpServletResponse response, PrintWriter out) {
|
| | | |
| | | response.setHeader("Access-Control-Allow-Origin", "*");
|
| | | response.setHeader("Access-Control-Allow-Methods", "*");
|
| | |
|
| | | AdminUser admin = adminUserService.selectByPrimaryKey(uid);
|
| | | if (admin == null) {
|
| | | out.print(JsonUtil.loadFalseResult("当前账户验证失败"));
|
| | | return;
|
| | | }
|
| | | |
| | | if (file == null) {
|
| | | out.print(JsonUtil.loadFalseResult("上传文件为空"));
|
| | | return;
|
| | | }
|
| | | |
| | | try {
|
| | | InputStream inputStream = file.getInputStream();
|
| | | String contentType = file.getContentType();
|
| | | String type = contentType.substring(contentType.indexOf("/") + 1);
|
| | | // 上传文件相对位置
|
| | | String fileUrl=UUID.randomUUID().toString().replace("-", "") + "." + type;
|
| | | |
| | | String uploadPath = COSManager.getInstance().uploadFile(inputStream, fileUrl).getUrl();
|
| | | |
| | | out.print(JsonUtil.loadTrueResult(uploadPath));
|
| | | |
| | | } catch (IOException e) {
|
| | | out.print(JsonUtil.loadFalseResult("上传图片失败"));
|
| | | e.printStackTrace();
|
| | | }
|
| | | }
|
| | | }
|