From b67fce32b28a5ee39a61f15d2d27237e648cce13 Mon Sep 17 00:00:00 2001 From: Sum1Dream <418471657@qq.com> Date: Mon, 14 Jun 2021 10:48:43 +0800 Subject: [PATCH 1/3] =?UTF-8?q?=E6=8F=90=E4=BA=A4=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../OutRechargeOrderController.java | 151 ++++++++++++++++++ .../OutRechargeOrderController.java | 25 ++- .../hai/service/OutRechargeOrderService.java | 9 ++ .../impl/OutRechargeOrderServiceImpl.java | 21 ++- 4 files changed, 189 insertions(+), 17 deletions(-) create mode 100644 hai-bweb/src/main/java/com/bweb/controller/OutRechargeOrderController.java diff --git a/hai-bweb/src/main/java/com/bweb/controller/OutRechargeOrderController.java b/hai-bweb/src/main/java/com/bweb/controller/OutRechargeOrderController.java new file mode 100644 index 00000000..fb71ab62 --- /dev/null +++ b/hai-bweb/src/main/java/com/bweb/controller/OutRechargeOrderController.java @@ -0,0 +1,151 @@ +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 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); + } + } +} diff --git a/hai-cweb/src/main/java/com/cweb/controller/OutRechargeOrderController.java b/hai-cweb/src/main/java/com/cweb/controller/OutRechargeOrderController.java index 7df53c1a..c2d604ac 100644 --- a/hai-cweb/src/main/java/com/cweb/controller/OutRechargeOrderController.java +++ b/hai-cweb/src/main/java/com/cweb/controller/OutRechargeOrderController.java @@ -54,12 +54,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 @@ -98,12 +94,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); @@ -166,12 +160,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 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()); } diff --git a/hai-service/src/main/java/com/hai/service/OutRechargeOrderService.java b/hai-service/src/main/java/com/hai/service/OutRechargeOrderService.java index 727bccd4..b7bd386e 100644 --- a/hai-service/src/main/java/com/hai/service/OutRechargeOrderService.java +++ b/hai-service/src/main/java/com/hai/service/OutRechargeOrderService.java @@ -61,4 +61,13 @@ 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); + } diff --git a/hai-service/src/main/java/com/hai/service/impl/OutRechargeOrderServiceImpl.java b/hai-service/src/main/java/com/hai/service/impl/OutRechargeOrderServiceImpl.java index 5c1fd3f1..7030b280 100644 --- a/hai-service/src/main/java/com/hai/service/impl/OutRechargeOrderServiceImpl.java +++ b/hai-service/src/main/java/com/hai/service/impl/OutRechargeOrderServiceImpl.java @@ -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,15 @@ 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); + } + } } From ec790f1bf94c3ec26161d6e7e7cfbdece5098c73 Mon Sep 17 00:00:00 2001 From: Sum1Dream <418471657@qq.com> Date: Mon, 14 Jun 2021 21:06:01 +0800 Subject: [PATCH 2/3] =?UTF-8?q?=E7=BB=9F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/OutRechargeOrderController.java | 14 ++++++++++++++ .../com/hai/service/OutRechargeOrderService.java | 10 ++++++++++ .../service/impl/OutRechargeOrderServiceImpl.java | 7 +++++++ 3 files changed, 31 insertions(+) diff --git a/hai-bweb/src/main/java/com/bweb/controller/OutRechargeOrderController.java b/hai-bweb/src/main/java/com/bweb/controller/OutRechargeOrderController.java index fb71ab62..86d21576 100644 --- a/hai-bweb/src/main/java/com/bweb/controller/OutRechargeOrderController.java +++ b/hai-bweb/src/main/java/com/bweb/controller/OutRechargeOrderController.java @@ -148,4 +148,18 @@ public class OutRechargeOrderController { 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); + } + } } diff --git a/hai-service/src/main/java/com/hai/service/OutRechargeOrderService.java b/hai-service/src/main/java/com/hai/service/OutRechargeOrderService.java index b7bd386e..a03daa32 100644 --- a/hai-service/src/main/java/com/hai/service/OutRechargeOrderService.java +++ b/hai-service/src/main/java/com/hai/service/OutRechargeOrderService.java @@ -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; @@ -70,4 +71,13 @@ public interface OutRechargeOrderService { **/ void finishOrder(Long orderId); + /** + * @Author Sum1Dream + * @Description //查询订单未支付数量 Administrator + * @Date 10:53 2021/6/14 + * @Param [] + * @return java.lang.Integer + **/ + Long CountOrder(); + } diff --git a/hai-service/src/main/java/com/hai/service/impl/OutRechargeOrderServiceImpl.java b/hai-service/src/main/java/com/hai/service/impl/OutRechargeOrderServiceImpl.java index 7030b280..3df247b5 100644 --- a/hai-service/src/main/java/com/hai/service/impl/OutRechargeOrderServiceImpl.java +++ b/hai-service/src/main/java/com/hai/service/impl/OutRechargeOrderServiceImpl.java @@ -102,4 +102,11 @@ public class OutRechargeOrderServiceImpl implements OutRechargeOrderService { updateOrder(order); } } + + @Override + public Long CountOrder() { + OutRechargeOrderExample example = new OutRechargeOrderExample(); + example.createCriteria().andStatusEqualTo(2); + return outRechargeOrderMapper.countByExample(example); + } } From 3c9d017e7dff9d51179a2e4a7454eba49be78256 Mon Sep 17 00:00:00 2001 From: YUANYE <418471657@qq.com> Date: Tue, 15 Jun 2021 17:30:37 +0800 Subject: [PATCH 3/3] =?UTF-8?q?=E6=8F=90=E4=BA=A4=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- hai-cweb/src/main/resources/dev/application.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hai-cweb/src/main/resources/dev/application.yml b/hai-cweb/src/main/resources/dev/application.yml index eed35273..dcf08e5d 100644 --- a/hai-cweb/src/main/resources/dev/application.yml +++ b/hai-cweb/src/main/resources/dev/application.yml @@ -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