| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124 |
- package com.kede.user.controller;
- import java.util.Map;
- import javax.annotation.Resource;
- import org.springframework.web.bind.annotation.RequestMapping;
- import org.springframework.web.bind.annotation.RequestMethod;
- import org.springframework.web.bind.annotation.RestController;
- import com.alibaba.fastjson.JSONObject;
- import com.kede.common.bo.Result;
- import com.kede.common.constant.ErrorConstants;
- import com.kede.common.controller.BaseController;
- import com.kede.common.model.Order;
- import com.kede.common.model.Project;
- import com.kede.common.utils.StringUtils;
- import com.kede.core.shiro.token.TokenManager;
- import com.kede.order.service.impl.OrderService;
- import com.kede.project.service.ProjectService;
- import com.kede.user.service.UserService;
- import com.kede.wxsdk.service.WxService;
- @RestController
- @RequestMapping(value = "/api/user")
- public class UserApiController extends BaseController{
-
- @Resource
- private UserService userService;
- @Resource
- private ProjectService projectService;
- @Resource
- private OrderService orderService;
- @Resource
- private WxService wxService;
-
- /**
- * 微信下单
- * @param id
- * @return
- */
- @RequestMapping(value = "/wxPush", method = RequestMethod.POST)
- public Result wxPush(Integer id) {
- Result res=new Result();
- if (id==null) {
- res.getError().add(buildError(ErrorConstants.PARAM_ERROR,"id","id"));
- return res;
- }
- Project p=projectService.get(id);
- if (p==null) {
- res.getError().add(buildError("","项目不存在"));
- return res;
- }
- if (!projectService.checkBuy(id,0)) {
- res.getError().add(buildError("","订单已存在"));
- return res;
- }
- Map<String, String> map=wxService.pushUnifiedOrder(p);
- return res.data(map);
- }
-
- /**
- * 撤销订单
- *
- * @param orderNo
- * @return
- */
- @RequestMapping(value = "/wxClose", method = RequestMethod.GET)
- public Result pushWxClose(String orderNo) {
- Result res=new Result();
- if (StringUtils.isBlank(orderNo)) {
- res.getError().add(buildError(ErrorConstants.PARAM_ERROR,"订单编号","订单编号"));
- return res;
- }
- Order o=orderService.selectByOrderNo(orderNo);
- if (o==null) {
- res.getError().add(buildError("订单不存在","订单不存在"));
- return res;
- }
- if(o.getPayStatus()!=0) {
- res.getError().add(buildError("订单只在未支付状态可以撤销","订单只在未支付状态可以撤销"));
- return res;
- }
- res.data(wxService.pushWxClose(o));
- return res;
- }
-
-
-
- @RequestMapping(value = "/wxQuery", method = RequestMethod.GET)
- public Result pushOrderQuery(String orderNo) {
- Result res=new Result();
- res.data(wxService.pushOrderQuery(orderNo));
- return res;
- }
-
- @RequestMapping(value = "/order/list" ,method = RequestMethod.GET)
- public Result list(String name,Integer type,Integer payStatus ,String startTime,String endTime,Integer pageNo,Integer pageSize) {
- Result res =new Result();
- res.data(orderService.list( name,1,payStatus , startTime, endTime, pageNo, pageSize));
- return res;
-
- }
-
-
- @RequestMapping(value = "/getliveinfo" ,method = RequestMethod.GET)
- public Result getliveinfo(Integer pageNo,Integer pageSize){
- Result res =new Result();
- res.data(wxService.getliveinfo(pageNo, pageSize));
- return res;
-
- }
-
-
- @RequestMapping(value = "/decryptData", method = RequestMethod.POST)
- public String decryptData(String encryptedData, String iv) {
- String sessionKey=(String) TokenManager.getVal2Session("sessionKey");
- JSONObject js=wxService.pushDecryptData(sessionKey, encryptedData, iv);
- return js.toJSONString();
- }
- }
|