| | |
| | | package com.yeshi.fanli.controller.client.v1;
|
| | |
|
| | | import java.io.PrintWriter;
|
| | | import java.math.BigDecimal;
|
| | | import java.util.ArrayList;
|
| | | import java.util.List;
|
| | |
|
| | | import javax.annotation.Resource;
|
| | |
|
| | | import org.springframework.stereotype.Controller;
|
| | | import org.springframework.web.bind.annotation.RequestMapping;
|
| | | import org.yeshi.utils.JsonUtil;
|
| | |
|
| | | import com.aliyuncs.unmarshaller.JsonUnmashaller;
|
| | | import com.yeshi.fanli.entity.accept.AcceptData;
|
| | | import com.yeshi.fanli.entity.bus.user.HongBaoV2;
|
| | | import com.yeshi.fanli.entity.elme.ElmeHongBaoOrderMap;
|
| | | import com.yeshi.fanli.entity.elme.ElmeOrder;
|
| | | import com.yeshi.fanli.service.inter.elme.ElmeHongBaoOrderMapService;
|
| | | import com.yeshi.fanli.util.Constant;
|
| | | import com.yeshi.fanli.util.StringUtil;
|
| | | import com.yeshi.fanli.util.TimeUtil;
|
| | | import com.yeshi.fanli.vo.elme.ElmeUserOrderVO;
|
| | |
|
| | | import net.sf.json.JSONObject;
|
| | |
|
| | | /**
|
| | | * 饿了么
|
| | | * |
| | | * @author Administrator
|
| | | *
|
| | | */
|
| | | @Controller
|
| | | @RequestMapping("api/v1/elme")
|
| | | public class ElmeController {
|
| | | @Resource
|
| | | private ElmeHongBaoOrderMapService elmeHongBaoOrderMapService;
|
| | |
|
| | | /**
|
| | | * 获取订单列表
|
| | | * |
| | | * @param acceptData
|
| | | * @param uid
|
| | | * @param page
|
| | | * @param callback
|
| | | * @param out
|
| | | */
|
| | | @RequestMapping("getOrderList")
|
| | | public void getOrderList(AcceptData acceptData, Long uid, int page, String callback, PrintWriter out) {
|
| | | List<ElmeUserOrderVO> voList = new ArrayList<>();
|
| | | List<ElmeHongBaoOrderMap> list = elmeHongBaoOrderMapService.listByHongBaoUid(uid, page, 3);
|
| | | if (list != null)
|
| | | for (ElmeHongBaoOrderMap map : list)
|
| | | voList.add(create(map));
|
| | | long count = elmeHongBaoOrderMapService.countByHongBaoUid(uid);
|
| | | JSONObject data = new JSONObject();
|
| | | data.put("count", count);
|
| | | data.put("list", voList);
|
| | | if (!StringUtil.isNullOrEmpty(callback))
|
| | | out.print(JsonUtil.loadJSONP(callback, JsonUtil.loadTrueResult(data)));
|
| | | else
|
| | | out.print(JsonUtil.loadTrueResult(data));
|
| | | }
|
| | |
|
| | | private ElmeUserOrderVO create(ElmeHongBaoOrderMap map) {
|
| | | HongBaoV2 hognBao = map.getHongBao();
|
| | | ElmeOrder order = map.getElmeOrder();
|
| | |
|
| | | ElmeUserOrderVO vo = new ElmeUserOrderVO();
|
| | | vo.setCreateTime(TimeUtil.getGernalTime(hognBao.getCreateTime().getTime(), "yyyy-MM-dd"));
|
| | | if (hognBao.getState() == HongBaoV2.STATE_BUKELINGQU || hognBao.getState() == HongBaoV2.STATE_KELINGQU)
|
| | | vo.setHongBaoState("未到账");
|
| | | else if (hognBao.getState() == HongBaoV2.STATE_SHIXIAO)
|
| | | vo.setHongBaoState("已失效");
|
| | | else
|
| | | vo.setHongBaoState("已到账");
|
| | | vo.setId(map.getId());
|
| | | vo.setMoney(hognBao.getMoney());
|
| | | vo.setOrderId(order.getOrderId());
|
| | | if (order.getPayMoney() == null || order.getPayMoney().compareTo(new BigDecimal(0)) <= 0)
|
| | | vo.setOrderState("未付款/已退款");
|
| | | else
|
| | | vo.setOrderState("已付款");
|
| | |
|
| | | vo.setOrderTime(TimeUtil.getGernalTime(order.getOrderDate().getTime(), "yyyy-MM-dd"));
|
| | | vo.setPayMoney(order.getPayMoney().toString());
|
| | | if (hognBao.getPreGetTime() != null)
|
| | | vo.setPreGetTime(TimeUtil.getGernalTime(hognBao.getPreGetTime().getTime(), "yyyy-MM-dd"));
|
| | | return vo;
|
| | | }
|
| | | }
|
| | | package com.yeshi.fanli.controller.client.v1; |
| | | |
| | | import java.io.PrintWriter; |
| | | import java.math.BigDecimal; |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | |
| | | import javax.annotation.Resource; |
| | | |
| | | import org.springframework.stereotype.Controller; |
| | | import org.springframework.web.bind.annotation.RequestMapping; |
| | | import org.yeshi.utils.JsonUtil; |
| | | |
| | | import com.yeshi.fanli.entity.accept.AcceptData; |
| | | import com.yeshi.fanli.entity.bus.user.HongBaoV2; |
| | | import com.yeshi.fanli.entity.elme.ElmeHongBaoOrderMap; |
| | | import com.yeshi.fanli.entity.elme.ElmeOrder; |
| | | import com.yeshi.fanli.service.inter.elme.ElmeHongBaoOrderMapService; |
| | | import com.yeshi.fanli.util.StringUtil; |
| | | import org.yeshi.utils.TimeUtil; |
| | | import com.yeshi.fanli.vo.elme.ElmeUserOrderVO; |
| | | |
| | | import net.sf.json.JSONObject; |
| | | |
| | | /** |
| | | * 饿了么 |
| | | * |
| | | * @author Administrator |
| | | * |
| | | */ |
| | | @Controller |
| | | @RequestMapping("api/v1/elme") |
| | | public class ElmeController { |
| | | @Resource |
| | | private ElmeHongBaoOrderMapService elmeHongBaoOrderMapService; |
| | | |
| | | /** |
| | | * 获取订单列表 |
| | | * |
| | | * @param acceptData |
| | | * @param uid |
| | | * @param page |
| | | * @param callback |
| | | * @param out |
| | | */ |
| | | @RequestMapping("getOrderList") |
| | | public void getOrderList(AcceptData acceptData, Long uid, int page, String callback, PrintWriter out) { |
| | | List<ElmeUserOrderVO> voList = new ArrayList<>(); |
| | | List<ElmeHongBaoOrderMap> list = elmeHongBaoOrderMapService.listByHongBaoUid(uid, page, 3); |
| | | if (list != null) |
| | | for (ElmeHongBaoOrderMap map : list) |
| | | voList.add(create(map)); |
| | | long count = elmeHongBaoOrderMapService.countByHongBaoUid(uid); |
| | | JSONObject data = new JSONObject(); |
| | | data.put("count", count); |
| | | data.put("list", voList); |
| | | if (!StringUtil.isNullOrEmpty(callback)) |
| | | out.print(JsonUtil.loadJSONP(callback, JsonUtil.loadTrueResult(data))); |
| | | else |
| | | out.print(JsonUtil.loadTrueResult(data)); |
| | | } |
| | | |
| | | private ElmeUserOrderVO create(ElmeHongBaoOrderMap map) { |
| | | HongBaoV2 hognBao = map.getHongBao(); |
| | | ElmeOrder order = map.getElmeOrder(); |
| | | |
| | | ElmeUserOrderVO vo = new ElmeUserOrderVO(); |
| | | vo.setCreateTime(TimeUtil.getGernalTime(hognBao.getCreateTime().getTime(), "yyyy-MM-dd")); |
| | | if (hognBao.getState() == HongBaoV2.STATE_BUKELINGQU || hognBao.getState() == HongBaoV2.STATE_KELINGQU) |
| | | vo.setHongBaoState("未到账"); |
| | | else if (hognBao.getState() == HongBaoV2.STATE_SHIXIAO) |
| | | vo.setHongBaoState("已失效"); |
| | | else |
| | | vo.setHongBaoState("已到账"); |
| | | vo.setId(map.getId()); |
| | | vo.setMoney(hognBao.getMoney()); |
| | | vo.setOrderId(order.getOrderId()); |
| | | if (order.getPayMoney() == null || order.getPayMoney().compareTo(new BigDecimal(0)) <= 0) |
| | | vo.setOrderState("未付款/已退款"); |
| | | else |
| | | vo.setOrderState("已付款"); |
| | | |
| | | vo.setOrderTime(TimeUtil.getGernalTime(order.getOrderDate().getTime(), "yyyy-MM-dd")); |
| | | vo.setPayMoney(order.getPayMoney().toString()); |
| | | if (hognBao.getPreGetTime() != null) |
| | | vo.setPreGetTime(TimeUtil.getGernalTime(hognBao.getPreGetTime().getTime(), "yyyy-MM-dd")); |
| | | return vo; |
| | | } |
| | | } |