Merge branch 'dev' of http://139.159.177.244:3000/hurui/hai-server into dev
commit
1f65902045
@ -0,0 +1,165 @@ |
||||
package com.bweb.controller; |
||||
|
||||
import com.alibaba.fastjson.JSONObject; |
||||
import com.github.pagehelper.PageHelper; |
||||
import com.github.pagehelper.PageInfo; |
||||
import com.hai.common.exception.ErrorCode; |
||||
import com.hai.common.exception.ErrorHelp; |
||||
import com.hai.common.exception.SysCode; |
||||
import com.hai.common.security.UserCenter; |
||||
import com.hai.common.utils.DateUtil; |
||||
import com.hai.common.utils.IDGenerator; |
||||
import com.hai.common.utils.ResponseMsgUtil; |
||||
import com.hai.entity.OutRechargeOrder; |
||||
import com.hai.model.ResponseData; |
||||
import com.hai.service.OutRechargeOrderService; |
||||
import com.hai.service.TelApiService; |
||||
import io.swagger.annotations.Api; |
||||
import io.swagger.annotations.ApiOperation; |
||||
import org.apache.commons.lang3.StringUtils; |
||||
import org.slf4j.Logger; |
||||
import org.slf4j.LoggerFactory; |
||||
import org.springframework.beans.factory.annotation.Autowired; |
||||
import org.springframework.stereotype.Controller; |
||||
import org.springframework.web.bind.annotation.*; |
||||
|
||||
import javax.annotation.Resource; |
||||
import javax.servlet.http.HttpServletRequest; |
||||
import java.util.Date; |
||||
import java.util.HashMap; |
||||
import java.util.Map; |
||||
|
||||
@Controller |
||||
@RequestMapping(value = "/outRechargeOrder") |
||||
@Api(value = "充值订单接口") |
||||
public class OutRechargeOrderController { |
||||
private static Logger log = LoggerFactory.getLogger(HighMerchantStoreController.class); |
||||
|
||||
@Autowired |
||||
private UserCenter userCenter; |
||||
|
||||
@Resource |
||||
private OutRechargeOrderService outRechargeOrderService; |
||||
|
||||
@Resource |
||||
private TelApiService telApiService; |
||||
|
||||
|
||||
@RequestMapping(value = "/getOrderById", method = RequestMethod.GET) |
||||
@ResponseBody |
||||
@ApiOperation(value = "根据id查询订单详情") |
||||
public ResponseData getOrderById(@RequestParam(name = "orderId", required = true) Long orderId) { |
||||
try { |
||||
|
||||
return ResponseMsgUtil.success(outRechargeOrderService.findByOrderId(orderId)); |
||||
|
||||
} catch (Exception e) { |
||||
log.error("HighOrderController --> getOrderById() error!", e); |
||||
return ResponseMsgUtil.exception(e); |
||||
} |
||||
} |
||||
|
||||
@RequestMapping(value = "/cancelOrder", method = RequestMethod.GET) |
||||
@ResponseBody |
||||
@ApiOperation(value = "取消订单") |
||||
public ResponseData cancelOrder(@RequestParam(name = "orderId", required = true) Long orderId) { |
||||
try { |
||||
|
||||
OutRechargeOrder outRechargeOrder = outRechargeOrderService.findByOrderId(orderId); |
||||
|
||||
if (outRechargeOrder.getStatus() == 1) { |
||||
outRechargeOrderService.cancelOrder(orderId); |
||||
} else { |
||||
log.error("orderToPay error!"); |
||||
throw ErrorHelp.genException(SysCode.System, ErrorCode.STATUS_ERROR, ""); |
||||
} |
||||
|
||||
return ResponseMsgUtil.success("操作成功"); |
||||
|
||||
} catch (Exception e) { |
||||
log.error("HighOrderController --> cancelOrder() error!", e); |
||||
return ResponseMsgUtil.exception(e); |
||||
} |
||||
} |
||||
|
||||
@RequestMapping(value = "/finishOrder", method = RequestMethod.GET) |
||||
@ResponseBody |
||||
@ApiOperation(value = "完成充值") |
||||
public ResponseData finishOrder(@RequestParam(name = "orderId", required = true) Long orderId) { |
||||
try { |
||||
|
||||
OutRechargeOrder outRechargeOrder = outRechargeOrderService.findByOrderId(orderId); |
||||
|
||||
if (outRechargeOrder.getStatus() == 2) { |
||||
outRechargeOrderService.finishOrder(orderId); |
||||
} else { |
||||
log.error("orderToPay error!"); |
||||
throw ErrorHelp.genException(SysCode.System, ErrorCode.STATUS_ERROR, ""); |
||||
} |
||||
|
||||
return ResponseMsgUtil.success("操作成功"); |
||||
|
||||
} catch (Exception e) { |
||||
log.error("HighOrderController --> cancelOrder() error!", e); |
||||
return ResponseMsgUtil.exception(e); |
||||
} |
||||
} |
||||
|
||||
@RequestMapping(value = "/getOrderList", method = RequestMethod.GET) |
||||
@ResponseBody |
||||
@ApiOperation(value = "获取订单") |
||||
public ResponseData getUserOrderList( |
||||
@RequestParam(name = "status", required = false) Integer status, |
||||
@RequestParam(name = "orderNo", required = false) String orderNo, |
||||
@RequestParam(name = "rechargeModel", required = false) String rechargeModel, |
||||
@RequestParam(name = "rechargeContent", required = false) String rechargeContent, |
||||
@RequestParam(name = "userPhone", required = false) String userPhone, |
||||
@RequestParam(name = "pageNum", required = true) Integer pageNum, |
||||
@RequestParam(name = "pageSize", required = true) Integer pageSize, |
||||
HttpServletRequest request) { |
||||
try { |
||||
|
||||
|
||||
Map<String,String> map = new HashMap<>(); |
||||
|
||||
if (status != null) { |
||||
map.put("status", status.toString()); |
||||
} |
||||
if (StringUtils.isNotBlank(orderNo)) { |
||||
map.put("orderNo", orderNo); |
||||
} |
||||
if (StringUtils.isNotBlank(rechargeModel)) { |
||||
map.put("rechargeModel", rechargeModel); |
||||
} |
||||
|
||||
if (StringUtils.isNotBlank(rechargeContent)) { |
||||
map.put("rechargeContent", rechargeContent); |
||||
} |
||||
|
||||
if (StringUtils.isNotBlank(userPhone)) { |
||||
map.put("userPhone", userPhone); |
||||
} |
||||
|
||||
PageHelper.startPage(pageNum,pageSize); |
||||
return ResponseMsgUtil.success(new PageInfo<>(outRechargeOrderService.getListRechargeOrder(map))); |
||||
|
||||
} catch (Exception e) { |
||||
log.error("HighOrderController --> getUserOrderList() error!", e); |
||||
return ResponseMsgUtil.exception(e); |
||||
} |
||||
} |
||||
|
||||
@RequestMapping(value = "/countOrder", method = RequestMethod.GET) |
||||
@ResponseBody |
||||
@ApiOperation(value = "完成充值") |
||||
public ResponseData countOrder() { |
||||
try { |
||||
|
||||
return ResponseMsgUtil.success(outRechargeOrderService.CountOrder()); |
||||
|
||||
} catch (Exception e) { |
||||
log.error("HighOrderController --> cancelOrder() error!", e); |
||||
return ResponseMsgUtil.exception(e); |
||||
} |
||||
} |
||||
} |
Loading…
Reference in new issue