| | |
| | | import com.yeshi.fanli.util.RedisManager;
|
| | | import com.yeshi.fanli.util.StringUtil;
|
| | | import com.yeshi.fanli.util.taobao.TaoKeApiUtil;
|
| | | import com.yeshi.fanli.vo.order.TaoBaoOrderVO;
|
| | |
|
| | | import org.yeshi.utils.JsonUtil;
|
| | |
|
| | | @Controller
|
| | |
| | | @Resource
|
| | | private UserInfoService userInfoService;
|
| | |
|
| | | @RequestMapping(value = "queryJoinHongBao")
|
| | | public void queryJoinHongBao(String callback, Integer pageIndex, Integer pageSize, String key, String startTime, String endTime, Integer type, Integer goodstype, Integer days, PrintWriter out) {
|
| | | try {
|
| | |
|
| | | if (pageSize == null)
|
| | | pageSize = Constant.PAGE_SIZE;
|
| | |
|
| | | if (pageIndex == null)
|
| | | pageIndex = 1;
|
| | |
|
| | | if (!StringUtil.isNullOrEmpty(endTime)) {
|
| | | SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
|
| | | Date enddate = sdf.parse(endTime);
|
| | | Calendar c = Calendar.getInstance();
|
| | | c.setTime(enddate);
|
| | | c.add(Calendar.DAY_OF_MONTH, 1);// 今天+1天
|
| | | endTime = sdf.format(c.getTime());
|
| | | }
|
| | |
|
| | | List<ReslutOrder> reslutOrders = taoBaoOrderService.queryJoinHongBao((pageIndex - 1) * pageSize, pageSize, key, startTime, endTime, type, days);
|
| | |
|
| | | /* 暂无数据显示 返回消息 */
|
| | | if (reslutOrders == null || reslutOrders.size() == 0) {
|
| | | JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("暂无数据"));
|
| | | return;
|
| | | }
|
| | |
|
| | | /* 验证网络: */
|
| | | StringBuffer auctionIdBuf = new StringBuffer();
|
| | | for (ReslutOrder reslutOrder : reslutOrders) {
|
| | | Long auctionId = reslutOrder.getAuctionId();
|
| | | if (auctionId != null) {
|
| | | auctionIdBuf.append(auctionId + ",");
|
| | | }
|
| | | }
|
| | |
|
| | | /* 验证网络: 获取商品链接 图片链接 */
|
| | | List<TaoBaoGoodsBrief> goodsBriefList = null;
|
| | | if (auctionIdBuf != null && auctionIdBuf.length() > 0) {
|
| | | String auctionIds = auctionIdBuf.toString();
|
| | |
|
| | | String ids = auctionIds.substring(0, auctionIds.length() - 1);
|
| | | goodsBriefList = TaoKeApiUtil.getBatchGoodsInfos(ids);
|
| | | }
|
| | |
|
| | | for (ReslutOrder reslutOrder : reslutOrders) {
|
| | |
|
| | | String orderId = reslutOrder.getOrderId();
|
| | | BigDecimal payment = reslutOrder.getPayment();
|
| | |
|
| | | String orderState = reslutOrder.getOrderState();
|
| | | if ("订单结算".equals(orderState)) {
|
| | | reslutOrder.setOrderStateAdmin("1");
|
| | | } else if ("订单付款".equals(orderState)) {
|
| | | reslutOrder.setOrderStateAdmin("2");
|
| | | } else if ("订单失效".equals(orderState)) {
|
| | | reslutOrder.setOrderStateAdmin("3");
|
| | | }
|
| | |
|
| | | /* 网上爬取商品 图片、链接 */
|
| | | Long auctionId = reslutOrder.getAuctionId();
|
| | |
|
| | | if (goodsBriefList != null && goodsBriefList.size() > 0) {
|
| | | for (TaoBaoGoodsBrief taoBaoGoodsBrief : goodsBriefList) {
|
| | | Long auctionIdTB = taoBaoGoodsBrief.getAuctionId();
|
| | | if (auctionId.equals(auctionIdTB)) {
|
| | | reslutOrder.setGoodsStae("0");// 在售
|
| | | String auctionUrl = taoBaoGoodsBrief.getAuctionUrl();
|
| | | String pictUrl = taoBaoGoodsBrief.getPictUrl();
|
| | | String shopTitle = taoBaoGoodsBrief.getShopTitle();
|
| | | reslutOrder.setShopTitle(shopTitle);
|
| | | reslutOrder.setAuctionUrl(auctionUrl);
|
| | | reslutOrder.setPictUrl(pictUrl);
|
| | | }
|
| | | }
|
| | | } else {
|
| | | reslutOrder.setGoodsStae("1");// 停售
|
| | | }
|
| | |
|
| | | String goodsStae = reslutOrder.getGoodsStae();
|
| | | if (StringUtil.isNullOrEmpty(goodsStae)) {
|
| | | reslutOrder.setGoodsStae("1");// 停售
|
| | | }
|
| | |
|
| | | UserInfo userInfo = reslutOrder.getUserInfo();
|
| | | if (userInfo == null) {
|
| | | userInfo = new UserInfo();
|
| | | reslutOrder.setUserInfo(userInfo);
|
| | | } else {
|
| | | Long uid = userInfo.getId();
|
| | | if (uid != null) {
|
| | | UserInfo currtUser = userInfoService.selectByPKey(uid);
|
| | | if (currtUser != null) {
|
| | | reslutOrder.setUserInfo(currtUser);
|
| | | }
|
| | | }
|
| | | }
|
| | |
|
| | | /* 订单号为空 则不进行查询红包 */
|
| | | if (StringUtil.isNullOrEmpty(orderId)) {
|
| | | continue;
|
| | | }
|
| | |
|
| | | /* 根据订单号 + 付款金额 进行匹配红包 */
|
| | |
|
| | | List<HongBao> listHB = hongBaoService.queryByOrderIDAndPayMoney(Long.parseLong(orderId), payment);
|
| | |
|
| | | /* 无红包 */
|
| | | if (listHB == null || listHB.size() == 0) {
|
| | | Long uid = userInfo.getId();
|
| | | if (uid != null) {
|
| | | listHB = hongBaoService.queryByOrderIDAndUid(Long.parseLong(orderId), uid);
|
| | | }
|
| | |
|
| | | if (listHB == null || listHB.size() == 0) {
|
| | | continue;
|
| | | }
|
| | | }
|
| | |
|
| | | HongBao hongBao = listHB.get(0);
|
| | |
|
| | | reslutOrder.setHongbaoId(hongBao.getId());
|
| | | reslutOrder.setGetTime(hongBao.getGetTime());
|
| | | reslutOrder.setMoney(hongBao.getMoney());
|
| | | reslutOrder.setType(hongBao.getType());
|
| | | // reslutOrder.setState(hongBao.getState());
|
| | | reslutOrder.setCreatetime(hongBao.getCreatetime());
|
| | | reslutOrder.setPreGettime(hongBao.getPreGettime());
|
| | |
|
| | | /* 查询间接收益 红包id */
|
| | | Long pid = reslutOrder.getHongbaoId();
|
| | |
|
| | | if (pid != null) {
|
| | |
|
| | | List<HongBao> childHongBaoList = hongBaoService.findChildHongBaoList(pid);
|
| | |
|
| | | if (childHongBaoList != null && childHongBaoList.size() > 0) {
|
| | |
|
| | | for (HongBao hb : childHongBaoList) {
|
| | |
|
| | | BigDecimal money = hb.getMoney();
|
| | | Integer childType = hb.getType();
|
| | | Long uid = null;
|
| | | String nickName = null;
|
| | |
|
| | | UserInfo user = hb.getUserInfo();
|
| | | if (user != null) {
|
| | | uid = user.getId();
|
| | | UserInfo cuent = userInfoService.getUserByIdWithMybatis(uid);
|
| | | if (cuent != null)
|
| | | nickName = cuent.getNickName();
|
| | | }
|
| | |
|
| | | if (childType != null) {
|
| | | if (childType == HongBao.TYPE_YIJI || childType == HongBao.TYPE_SHARE_YIJI) {
|
| | | // 一级
|
| | | reslutOrder.setLevelOne(uid);
|
| | | reslutOrder.setLevelOneMoney(money);
|
| | | reslutOrder.setLevelOneName(nickName);
|
| | | } else if (childType == HongBao.TYPE_ERJI || childType == HongBao.TYPE_SHARE_ERJI) {
|
| | | reslutOrder.setLevelTwo(uid);
|
| | | reslutOrder.setLevelTwoMoney(money);
|
| | | reslutOrder.setLevelTwoName(nickName);
|
| | | }
|
| | | }
|
| | |
|
| | | }
|
| | | }
|
| | | }
|
| | |
|
| | | DateFormat f = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");// 设置格式
|
| | | SimpleDateFormat format = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss");
|
| | |
|
| | | String createTime = reslutOrder.getCreateTime();
|
| | | if (!StringUtil.isNullOrEmpty(createTime)) {
|
| | | Date d = f.parse(createTime);
|
| | | reslutOrder.setCreateTime(format.format(d));
|
| | | }
|
| | |
|
| | | String settlementTime = reslutOrder.getSettlementTime();
|
| | | if (!StringUtil.isNullOrEmpty(settlementTime)) {
|
| | | Date d = f.parse(settlementTime);
|
| | | reslutOrder.setSettlementTime(format.format(d));
|
| | | }
|
| | |
|
| | | /* 到账状态 */
|
| | | int state = hongBao.getState();
|
| | |
|
| | | if (HongBao.STATE_YILINGQU == state) {
|
| | | reslutOrder.setMoneyState("3"); // 已到账
|
| | | } else if (HongBao.STATE_BUKELINGQU == state || HongBao.STATE_KELINGQU == state) {
|
| | | reslutOrder.setMoneyState("2"); // 未到账
|
| | | } else {
|
| | | reslutOrder.setMoneyState("4"); // 已失效
|
| | | }
|
| | |
|
| | | String rebateSource = null;
|
| | | Integer typeHongBao = reslutOrder.getType();
|
| | | if (typeHongBao != null) {
|
| | |
|
| | | if (typeHongBao == HongBao.TYPE_HUODONG || typeHongBao == HongBao.TYPE_XINREN) {
|
| | | /* 3-活动红包 4-新人红包 */
|
| | | rebateSource = "1";
|
| | |
|
| | | } else if (typeHongBao == HongBao.TYPE_JINGDONG || typeHongBao == HongBao.TYPE_TAOBAO || typeHongBao == HongBao.TYPE_YAOQING) {
|
| | | /* 自购订单 */
|
| | | rebateSource = "2";
|
| | | } else if (typeHongBao == HongBao.TYPE_YIJI || typeHongBao == HongBao.TYPE_ERJI || typeHongBao == HongBao.TYPE_SHARE_YIJI || typeHongBao == HongBao.TYPE_SHARE_ERJI) {
|
| | | /* 邀请订单 分销红包对应的最上级红包 */
|
| | | rebateSource = "3";
|
| | | } else if (typeHongBao == HongBao.TYPE_SHARE_GOODS) {
|
| | | /* 分享订单 */
|
| | | rebateSource = "4";
|
| | | }
|
| | | reslutOrder.setRebateSource(rebateSource);
|
| | | }
|
| | |
|
| | | }
|
| | |
|
| | | int count = taoBaoOrderService.countQueryJoinHongBao(key, startTime, endTime, type, days);
|
| | | int totalPage = count % pageSize == 0 ? count / pageSize : count / pageSize + 1;
|
| | | PageEntity pe = new PageEntity(pageIndex, pageSize, count, totalPage);
|
| | |
|
| | | GsonBuilder gsonBuilder = new GsonBuilder();
|
| | | gsonBuilder.serializeNulls(); // 重点
|
| | | Gson gson = gsonBuilder.setDateFormat("yyyy/MM/dd HH:mm:ss").create();
|
| | |
|
| | | JSONObject data = new JSONObject();
|
| | | data.put("pe", pe);
|
| | | data.put("list", gson.toJson(reslutOrders));
|
| | |
|
| | | JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult(data));
|
| | |
|
| | | } catch (Exception e) {
|
| | | e.printStackTrace();
|
| | | JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("操作异常"));
|
| | | }
|
| | | }
|
| | |
|
| | | |
| | | |
| | | @RequestMapping(value = "countByType")
|
| | | public void countByType(String callback, HttpServletRequest request, PrintWriter out) {
|
| | |
|
| | |
| | | JsonUtil.printMode(out, callback, JsonUtil.loadTrueResult(data));
|
| | |
|
| | | } catch (Exception e) {
|
| | | // TODO Auto-generated catch block
|
| | | JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("统计失败"));
|
| | | e.printStackTrace();
|
| | | }
|