| | |
| | | import java.util.UUID;
|
| | |
|
| | | import javax.annotation.Resource;
|
| | | import javax.servlet.http.HttpServletRequest;
|
| | | import javax.servlet.http.HttpServletResponse;
|
| | |
|
| | | 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 org.springframework.web.bind.annotation.RequestParam;
|
| | | import org.springframework.web.multipart.commons.CommonsMultipartFile;
|
| | | import org.yeshi.utils.JsonUtil;
|
| | | import org.yeshi.utils.tencentcloud.COSManager;
|
| | |
|
| | | import com.yeshi.fanli.entity.common.AdminUser;
|
| | | import com.yeshi.fanli.entity.taobao.TaoBaoOrder;
|
| | | import com.yeshi.fanli.service.AdminUserService;
|
| | | import com.yeshi.fanli.service.inter.hongbao.HongBaoService;
|
| | | 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;
|
| | | import org.yeshi.utils.JsonUtil;
|
| | | import org.yeshi.utils.tencentcloud.COSManager;
|
| | |
|
| | | import net.sf.json.JSONObject;
|
| | |
|
| | | @Controller
|
| | | @RequestMapping("admin/new/api/v1/upload")
|
| | |
| | |
|
| | | @Resource
|
| | | private OrderProcessService orderProcessService;
|
| | | |
| | | @Resource
|
| | | private AdminUserService adminUserService;
|
| | | |
| | | @Resource(name = "taskExecutor")
|
| | | private TaskExecutor executor;
|
| | | |
| | | |
| | |
|
| | | // private static final String PAYSUCCESS = "支付成功";
|
| | | // private static final String ORDERCLOSE="订单关闭";
|
| | |
| | |
|
| | | }
|
| | |
|
| | | |
| | | /**
|
| | | * 新后台端 上传订单文件
|
| | | * @param file excel文件
|
| | | * @param uid 当前用户id
|
| | | * @param request
|
| | | * @param response
|
| | | * @param out
|
| | | */
|
| | | @RequestNoLogin()
|
| | | @RequestMapping(value = "uploadOrderFile")
|
| | | public void uploadOrderFile(@RequestParam("file") CommonsMultipartFile file, Long uid,
|
| | | HttpServletRequest request, 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;
|
| | | }
|
| | | |
| | | List<TaoBaoOrder> orderList = null ;
|
| | | try {
|
| | | orderList = TaoBaoOrderUtil.parseOrder(file.getInputStream());
|
| | | out.print(JsonUtil.loadTrueResult("上传文件成功"));
|
| | | } catch (IOException e) {
|
| | | out.print(JsonUtil.loadFalseResult("上传文件失败"));
|
| | | e.printStackTrace();
|
| | | }
|
| | | |
| | | 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();
|
| | | }
|
| | | }
|
| | | }
|