| | |
| | | package com.yeshi.fanli.controller.admin.shop;
|
| | |
|
| | | import java.io.PrintWriter;
|
| | | import java.lang.reflect.Type;
|
| | | import java.util.ArrayList;
|
| | | import java.util.Date;
|
| | | import java.util.List;
|
| | |
|
| | | import javax.annotation.Resource;
|
| | | import javax.servlet.http.HttpServletRequest;
|
| | |
|
| | | 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.bus.user.UserInfo;
|
| | | import com.yeshi.fanli.entity.common.AdminUser;
|
| | | import com.yeshi.fanli.entity.shop.BanLiShopOrder;
|
| | | import com.yeshi.fanli.exception.shop.BanLiShopOrderException;
|
| | | import com.yeshi.fanli.service.inter.shop.BanLiShopOrderPayService;
|
| | | import com.yeshi.fanli.service.inter.shop.BanLiShopOrderService;
|
| | | import com.yeshi.fanli.service.inter.user.UserInfoService;
|
| | | 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/blOrder")
|
| | | public class BanLiShopOrderAdminController {
|
| | |
|
| | | @Resource
|
| | | private BanLiShopOrderService banLiShopOrderService;
|
| | |
|
| | | @Resource
|
| | | private BanLiShopOrderPayService banLiShopOrderPayService;
|
| | |
|
| | | @Resource
|
| | | private UserInfoService userInfoService;
|
| | |
|
| | | /**
|
| | | * 获取订单列表
|
| | | * |
| | | * @param callback
|
| | | * @param orderId
|
| | | * -订单号 可为空
|
| | | * @param page
|
| | | * -页码
|
| | | * @param state-状态数组
|
| | | * [1,2]
|
| | | * @param uid
|
| | | * 用户ID
|
| | | * @param out
|
| | | */
|
| | | @RequestMapping(value = "listOrder")
|
| | | public void listOrder(AdminAcceptData acceptData, String callback, String orderId, int page, String state, Long uid, PrintWriter out) {
|
| | | long count = 0;
|
| | | List<BanLiShopOrder> orderList = new ArrayList<>();
|
| | | if (!StringUtil.isNullOrEmpty(orderId)) {
|
| | | BanLiShopOrder order = banLiShopOrderService.selectByOrderNo(orderId);
|
| | | if (order != null) {
|
| | | orderList.add(order);
|
| | | count = 1;
|
| | | }
|
| | | } else {
|
| | | List<Integer> stateList = null;
|
| | | if (!StringUtil.isNullOrEmpty(state)) {
|
| | | net.sf.json.JSONArray array = net.sf.json.JSONArray.fromObject(state);
|
| | |
|
| | | for (int i = 0; i < array.size(); i++) {
|
| | | if (stateList == null)
|
| | | stateList = new ArrayList<>();
|
| | |
|
| | | stateList.add(array.optInt(i));
|
| | | }
|
| | |
|
| | | }
|
| | | orderList = banLiShopOrderService.listByUidAndState(uid, stateList, page, Constant.PAGE_SIZE);
|
| | | count = banLiShopOrderService.countByUidAndState(uid, stateList);
|
| | | }
|
| | |
|
| | | GsonBuilder gb = new GsonBuilder();
|
| | | gb.registerTypeAdapter(java.util.Date.class, new JsonSerializer<Date>() {
|
| | |
|
| | | public JsonElement serialize(Date arg0, Type arg1, JsonSerializationContext arg2) {
|
| | | return new JsonPrimitive(TimeUtil.getGernalTime(arg0.getTime(), "yyyy-MM-dd HH:mm:ss"));
|
| | | }
|
| | | });
|
| | | PageEntity pe = new PageEntity(page, Constant.PAGE_SIZE, count,
|
| | | (int) (count % Constant.PAGE_SIZE == 0 ? count / Constant.PAGE_SIZE : count / Constant.PAGE_SIZE + 1));
|
| | |
|
| | | Gson gson = gb.create();
|
| | | JSONObject data = new JSONObject();
|
| | | data.put("pe", pe);
|
| | | data.put("list", gson.toJson(orderList));
|
| | | out.print(JsonUtil.loadJSONP(callback, JsonUtil.loadTrueResult(data)));
|
| | | }
|
| | |
|
| | | // 订单充值
|
| | | @RequestMapping(value = "charge")
|
| | | public void charge(AdminAcceptData acceptData,String callback, Long id, String code, HttpServletRequest request, PrintWriter out) {
|
| | |
|
| | | /* 检验是否登陆 */
|
| | | AdminUser admin = (AdminUser) request.getSession().getAttribute(Constant.SESSION_ADMIN);
|
| | | if (admin == null) {
|
| | | JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("当前账户失效,请重新登陆。"));
|
| | | return;
|
| | | }
|
| | |
|
| | | /* 检验是否通过验证 */
|
| | | String codeType = (String) request.getSession().getAttribute(Constant.SESSION_EXTRACT_VERIFY_RESULT);
|
| | | if (!"1".equals(codeType)) {
|
| | | JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult(9999, "邮箱验证未通过"));
|
| | | return;
|
| | | }
|
| | |
|
| | | try {
|
| | | banLiShopOrderPayService.charge(id);
|
| | | out.print(JsonUtil.loadJSONP(callback, JsonUtil.loadTrueResult("")));
|
| | | } catch (BanLiShopOrderException e) {
|
| | | e.printStackTrace();
|
| | | BanLiShopOrder order = new BanLiShopOrder(id);
|
| | | String stateDesc = String.format("错误码:%s 错误原因:%s", e.getCode() + "", e.getMsg());
|
| | | order.setStateDesc(stateDesc);
|
| | | order.setUpdateTime(new Date());
|
| | | banLiShopOrderService.udpateSelectiveByPrimaryKey(order);
|
| | | out.print(JsonUtil.loadJSONP(callback, JsonUtil.loadFalseResult(e.getCode(), e.getMsg())));
|
| | | }
|
| | | }
|
| | |
|
| | | @RequestMapping(value = "reject")
|
| | | public void reject(AdminAcceptData acceptData,String callback, Long id, String desc,HttpServletRequest request, PrintWriter out) {
|
| | | /* 检验是否登陆 */
|
| | | AdminUser admin = (AdminUser) request.getSession().getAttribute(Constant.SESSION_ADMIN);
|
| | | if (admin == null) {
|
| | | JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("当前账户失效,请重新登陆。"));
|
| | | return;
|
| | | }
|
| | |
|
| | | /* 检验是否通过验证 */
|
| | | String codeType = (String) request.getSession().getAttribute(Constant.SESSION_EXTRACT_VERIFY_RESULT);
|
| | | if (!"1".equals(codeType)) {
|
| | | JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult(9999, "邮箱验证未通过"));
|
| | | return;
|
| | | }
|
| | | try {
|
| | | banLiShopOrderService.rejectOrder(id, desc);
|
| | | out.print(JsonUtil.loadJSONP(callback, JsonUtil.loadTrueResult("")));
|
| | | } catch (BanLiShopOrderException e) {
|
| | | out.print(JsonUtil.loadJSONP(callback, JsonUtil.loadFalseResult(e.getCode(), e.getMsg())));
|
| | | }
|
| | | }
|
| | |
|
| | | @RequestMapping(value = "getOrderDetail")
|
| | | public void getOrderDetail(AdminAcceptData acceptData,String callback, Long id, PrintWriter out) {
|
| | | BanLiShopOrder order = banLiShopOrderService.selectByPrimaryKey(id);
|
| | | if (order == null) {
|
| | | out.print(JsonUtil.loadJSONP(callback, JsonUtil.loadFalseResult(1, "订单不存在")));
|
| | | return;
|
| | | }
|
| | | // 查询用户信息
|
| | | UserInfo user = userInfoService.selectByPKey(order.getUid());
|
| | | JSONObject data = new JSONObject();
|
| | | data.put("order", order);
|
| | | data.put("user", user);
|
| | | out.print(JsonUtil.loadJSONP(callback, JsonUtil.loadTrueResult(data)));
|
| | | }
|
| | |
|
| | | }
|
| | | package com.yeshi.fanli.controller.admin.shop; |
| | | |
| | | import java.io.PrintWriter; |
| | | import java.lang.reflect.Type; |
| | | import java.util.ArrayList; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | |
| | | import javax.annotation.Resource; |
| | | import javax.servlet.http.HttpServletRequest; |
| | | |
| | | 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.bus.user.UserInfo; |
| | | import com.yeshi.fanli.entity.common.AdminUser; |
| | | import com.yeshi.fanli.entity.shop.BanLiShopOrder; |
| | | import com.yeshi.fanli.exception.shop.BanLiShopOrderException; |
| | | import com.yeshi.fanli.service.inter.shop.BanLiShopOrderPayService; |
| | | import com.yeshi.fanli.service.inter.shop.BanLiShopOrderService; |
| | | import com.yeshi.fanli.service.inter.user.UserInfoService; |
| | | 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/blOrder") |
| | | public class BanLiShopOrderAdminController { |
| | | |
| | | @Resource |
| | | private BanLiShopOrderService banLiShopOrderService; |
| | | |
| | | @Resource |
| | | private BanLiShopOrderPayService banLiShopOrderPayService; |
| | | |
| | | @Resource |
| | | private UserInfoService userInfoService; |
| | | |
| | | /** |
| | | * 获取订单列表 |
| | | * |
| | | * @param callback |
| | | * @param orderId |
| | | * -订单号 可为空 |
| | | * @param page |
| | | * -页码 |
| | | * @param state-状态数组 |
| | | * [1,2] |
| | | * @param uid |
| | | * 用户ID |
| | | * @param out |
| | | */ |
| | | @RequestMapping(value = "listOrder") |
| | | public void listOrder(AdminAcceptData acceptData, String callback, String orderId, int page, String state, Long uid, PrintWriter out) { |
| | | long count = 0; |
| | | List<BanLiShopOrder> orderList = new ArrayList<>(); |
| | | if (!StringUtil.isNullOrEmpty(orderId)) { |
| | | BanLiShopOrder order = banLiShopOrderService.selectByOrderNo(orderId); |
| | | if (order != null) { |
| | | orderList.add(order); |
| | | count = 1; |
| | | } |
| | | } else { |
| | | List<Integer> stateList = null; |
| | | if (!StringUtil.isNullOrEmpty(state)) { |
| | | net.sf.json.JSONArray array = net.sf.json.JSONArray.fromObject(state); |
| | | |
| | | for (int i = 0; i < array.size(); i++) { |
| | | if (stateList == null) |
| | | stateList = new ArrayList<>(); |
| | | |
| | | stateList.add(array.optInt(i)); |
| | | } |
| | | |
| | | } |
| | | orderList = banLiShopOrderService.listByUidAndState(uid, stateList, page, Constant.PAGE_SIZE); |
| | | count = banLiShopOrderService.countByUidAndState(uid, stateList); |
| | | } |
| | | |
| | | GsonBuilder gb = new GsonBuilder(); |
| | | gb.registerTypeAdapter(java.util.Date.class, new JsonSerializer<Date>() { |
| | | |
| | | public JsonElement serialize(Date arg0, Type arg1, JsonSerializationContext arg2) { |
| | | return new JsonPrimitive(TimeUtil.getGernalTime(arg0.getTime(), "yyyy-MM-dd HH:mm:ss")); |
| | | } |
| | | }); |
| | | PageEntity pe = new PageEntity(page, Constant.PAGE_SIZE, count, |
| | | (int) (count % Constant.PAGE_SIZE == 0 ? count / Constant.PAGE_SIZE : count / Constant.PAGE_SIZE + 1)); |
| | | |
| | | Gson gson = gb.create(); |
| | | JSONObject data = new JSONObject(); |
| | | data.put("pe", pe); |
| | | data.put("list", gson.toJson(orderList)); |
| | | out.print(JsonUtil.loadJSONP(callback, JsonUtil.loadTrueResult(data))); |
| | | } |
| | | |
| | | // 订单充值 |
| | | @RequestMapping(value = "charge") |
| | | public void charge(AdminAcceptData acceptData,String callback, Long id, String code, HttpServletRequest request, PrintWriter out) { |
| | | |
| | | /* 检验是否登陆 */ |
| | | AdminUser admin = (AdminUser) request.getSession().getAttribute(Constant.SESSION_ADMIN); |
| | | if (admin == null) { |
| | | JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("当前账户失效,请重新登陆。")); |
| | | return; |
| | | } |
| | | |
| | | /* 检验是否通过验证 */ |
| | | String codeType = (String) request.getSession().getAttribute(Constant.SESSION_EXTRACT_VERIFY_RESULT); |
| | | if (!"1".equals(codeType)) { |
| | | JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult(9999, "邮箱验证未通过")); |
| | | return; |
| | | } |
| | | |
| | | try { |
| | | banLiShopOrderPayService.charge(id); |
| | | out.print(JsonUtil.loadJSONP(callback, JsonUtil.loadTrueResult(""))); |
| | | } catch (BanLiShopOrderException e) { |
| | | e.printStackTrace(); |
| | | BanLiShopOrder order = new BanLiShopOrder(id); |
| | | String stateDesc = String.format("错误码:%s 错误原因:%s", e.getCode() + "", e.getMsg()); |
| | | order.setStateDesc(stateDesc); |
| | | order.setUpdateTime(new Date()); |
| | | banLiShopOrderService.udpateSelectiveByPrimaryKey(order); |
| | | out.print(JsonUtil.loadJSONP(callback, JsonUtil.loadFalseResult(e.getCode(), e.getMsg()))); |
| | | } |
| | | } |
| | | |
| | | @RequestMapping(value = "reject") |
| | | public void reject(AdminAcceptData acceptData,String callback, Long id, String desc,HttpServletRequest request, PrintWriter out) { |
| | | /* 检验是否登陆 */ |
| | | AdminUser admin = (AdminUser) request.getSession().getAttribute(Constant.SESSION_ADMIN); |
| | | if (admin == null) { |
| | | JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult("当前账户失效,请重新登陆。")); |
| | | return; |
| | | } |
| | | |
| | | /* 检验是否通过验证 */ |
| | | String codeType = (String) request.getSession().getAttribute(Constant.SESSION_EXTRACT_VERIFY_RESULT); |
| | | if (!"1".equals(codeType)) { |
| | | JsonUtil.printMode(out, callback, JsonUtil.loadFalseResult(9999, "邮箱验证未通过")); |
| | | return; |
| | | } |
| | | try { |
| | | banLiShopOrderService.rejectOrder(id, desc); |
| | | out.print(JsonUtil.loadJSONP(callback, JsonUtil.loadTrueResult(""))); |
| | | } catch (BanLiShopOrderException e) { |
| | | out.print(JsonUtil.loadJSONP(callback, JsonUtil.loadFalseResult(e.getCode(), e.getMsg()))); |
| | | } |
| | | } |
| | | |
| | | @RequestMapping(value = "getOrderDetail") |
| | | public void getOrderDetail(AdminAcceptData acceptData,String callback, Long id, PrintWriter out) { |
| | | BanLiShopOrder order = banLiShopOrderService.selectByPrimaryKey(id); |
| | | if (order == null) { |
| | | out.print(JsonUtil.loadJSONP(callback, JsonUtil.loadFalseResult(1, "订单不存在"))); |
| | | return; |
| | | } |
| | | // 查询用户信息 |
| | | UserInfo user = userInfoService.selectByPKey(order.getUid()); |
| | | JSONObject data = new JSONObject(); |
| | | data.put("order", order); |
| | | data.put("user", user); |
| | | out.print(JsonUtil.loadJSONP(callback, JsonUtil.loadTrueResult(data))); |
| | | } |
| | | |
| | | } |