dev-discount
= 4 years ago
commit 1f65902045
  1. 165
      hai-bweb/src/main/java/com/bweb/controller/OutRechargeOrderController.java
  2. 25
      hai-cweb/src/main/java/com/cweb/controller/OutRechargeOrderController.java
  3. 2
      hai-cweb/src/main/resources/dev/application.yml
  4. 19
      hai-service/src/main/java/com/hai/service/OutRechargeOrderService.java
  5. 28
      hai-service/src/main/java/com/hai/service/impl/OutRechargeOrderServiceImpl.java

@ -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);
}
}
}

@ -73,12 +73,8 @@ public class OutRechargeOrderController {
try {
// 用户
// SessionObject sessionObject = userCenter.getSessionObject(request);
// HighUserModel userInfoModel = (HighUserModel) sessionObject.getObject();
// if(sessionObject == null){
// log.error("SecOrganizationController --> addOrganization() error!", "");
// throw ErrorHelp.genException(SysCode.System, ErrorCode.SEC_USER_EXPIRED, "");
// }
SessionObject sessionObject = userCenter.getSessionObject(request);
HighUserModel userInfoModel = (HighUserModel) sessionObject.getObject();
if (StringUtils.isBlank(outRechargeOrder.getRechargeContent()) ||
outRechargeOrder.getPayPrice() == null ||
outRechargeOrder.getOrderPrice() == null
@ -117,12 +113,10 @@ public class OutRechargeOrderController {
}
outRechargeOrder.setRemarks(remarks);
outRechargeOrder.setOrderNo("CZ" + DateUtil.date2String(new Date(),"yyyyMMddHHmmss") + IDGenerator.nextId(5));
// outRechargeOrder.setUserId(userInfoModel.getHighUser().getId());
// outRechargeOrder.setUserName(userInfoModel.getHighUser().getName());
// outRechargeOrder.setUserPhone(userInfoModel.getHighUser().getPhone());
outRechargeOrder.setUserId(2L);
outRechargeOrder.setUserName("袁野");
outRechargeOrder.setUserPhone("18090580471");
outRechargeOrder.setUserId(userInfoModel.getHighUser().getId());
outRechargeOrder.setUserName(userInfoModel.getHighUser().getName());
outRechargeOrder.setUserPhone(userInfoModel.getHighUser().getPhone());
outRechargeOrder.setCreateTimed(new Date());
outRechargeOrder.setStatus(1);
outRechargeOrderService.insertOrder(outRechargeOrder);
@ -185,12 +179,11 @@ public class OutRechargeOrderController {
try {
// 用户
// SessionObject sessionObject = userCenter.getSessionObject(request);
// HighUserModel userInfoModel = (HighUserModel) sessionObject.getObject();
SessionObject sessionObject = userCenter.getSessionObject(request);
HighUserModel userInfoModel = (HighUserModel) sessionObject.getObject();
Map<String,String> map = new HashMap<>();
// map.put("userId", userInfoModel.getHighUser().getId().toString());
map.put("userId", "2");
map.put("userId", userInfoModel.getHighUser().getId().toString());
if (status != null) {
map.put("status", status.toString());
}

@ -9,7 +9,7 @@ debug: false
#datasource数据源设置
spring:
datasource:
url: jdbc:mysql://139.159.177.244:3306/hfkj?allowMultiQueries=true&useUnicode=true&characterEncoding=UTF-8&useSSL=false
url: jdbc:mysql://139.159.177.244:3306/hsg_pre?allowMultiQueries=true&useUnicode=true&characterEncoding=UTF-8&useSSL=false
username: root
password: HF123456.
type: com.alibaba.druid.pool.DruidDataSource

@ -1,6 +1,7 @@
package com.hai.service;
import com.hai.entity.OutRechargeOrder;
import io.swagger.models.auth.In;
import java.util.List;
import java.util.Map;
@ -61,4 +62,22 @@ public interface OutRechargeOrderService {
**/
void cancelOrder(Long orderId);
/**
* @Author Sum1Dream
* @Description //完成订单 Administrator
* @Date 10:10 2021/6/14
* @Param [orderId]
* @return void
**/
void finishOrder(Long orderId);
/**
* @Author Sum1Dream
* @Description //查询订单未支付数量 Administrator
* @Date 10:53 2021/6/14
* @Param []
* @return java.lang.Integer
**/
Long CountOrder();
}

@ -34,7 +34,15 @@ public class OutRechargeOrderServiceImpl implements OutRechargeOrderService {
}
if (MapUtils.getString(map, "orderNo") != null) {
criteria.andOrderNoEqualTo(MapUtils.getString(map, "orderNo"));
criteria.andOrderNoLike("%" + MapUtils.getString(map, "orderNo") + "%");
}
if (MapUtils.getString(map, "userPhone") != null) {
criteria.andUserPhoneEqualTo(MapUtils.getString(map, "userPhone"));
}
if (MapUtils.getString(map, "rechargeContent") != null) {
criteria.andRechargeContentLike("%" + MapUtils.getString(map, "rechargeContent") + "%");
}
if (MapUtils.getString(map, "phone") != null) {
@ -83,4 +91,22 @@ public class OutRechargeOrderServiceImpl implements OutRechargeOrderService {
updateOrder(order);
}
}
@Override
@Transactional(propagation= Propagation.REQUIRES_NEW)
public void finishOrder(Long orderId) {
OutRechargeOrder order = findByOrderId(orderId);
if (order != null) {
order.setStatus(3); // 订单状态:1 待支付 2 已支付 3.已完成 4. 已取消 5.已退款
order.setFinishTime(new Date());
updateOrder(order);
}
}
@Override
public Long CountOrder() {
OutRechargeOrderExample example = new OutRechargeOrderExample();
example.createCriteria().andStatusEqualTo(2);
return outRechargeOrderMapper.countByExample(example);
}
}

Loading…
Cancel
Save