From b6fdf185c7e8fb1f06da0e609e39aecaef6b66f5 Mon Sep 17 00:00:00 2001 From: admin <weikou2014> Date: 星期日, 30 六月 2024 01:42:31 +0800 Subject: [PATCH] 微信强授权/后台管理 --- src/main/java/com/taoke/autopay/controller/client/OrderController.java | 68 ++++++++++++++++++++++++++-------- 1 files changed, 52 insertions(+), 16 deletions(-) diff --git a/src/main/java/com/taoke/autopay/controller/client/OrderController.java b/src/main/java/com/taoke/autopay/controller/client/OrderController.java index 77140b3..2d430a6 100644 --- a/src/main/java/com/taoke/autopay/controller/client/OrderController.java +++ b/src/main/java/com/taoke/autopay/controller/client/OrderController.java @@ -8,13 +8,15 @@ import com.google.gson.stream.JsonWriter; import com.taoke.autopay.dao.KeyOrderMapper; import com.taoke.autopay.dto.DYOrderDto; -import com.taoke.autopay.entity.ClientInfo; -import com.taoke.autopay.entity.KeyOrder; +import com.taoke.autopay.entity.*; import com.taoke.autopay.exception.KeyOrderException; +import com.taoke.autopay.exception.WxOrderCountException; import com.taoke.autopay.factory.OrderFactory; import com.taoke.autopay.service.ClientInfoService; import com.taoke.autopay.service.KeyOrderService; +import com.taoke.autopay.service.WxUserOrderCountService; +import com.taoke.autopay.service.WxUserSettingService; import com.taoke.autopay.utils.JsonUtil; import com.taoke.autopay.utils.StringUtil; import com.taoke.autopay.utils.TimeUtil; @@ -53,8 +55,9 @@ // 鍒ゆ柇鏄惁鏄悓涓�澶� desc = TimeUtil.getGernalTime(value.getTime(), "yyyy-MM-dd HH:mm:ss"); out.value(desc); - } else + } else { out.value(""); + } } @Override @@ -68,6 +71,13 @@ @Resource private ClientInfoService clientInfoService; + + @Resource + private WxUserOrderCountService wxUserOrderCountService; + + @Resource + private WxUserSettingService wxUserSettingService; + @ResponseBody @RequestMapping("listOrder") @@ -147,14 +157,14 @@ } /** - * @author hxh + * @return java.lang.String 杩斿洖鏄惁鍙互鍘绘敮浠� + * @author hxh * @description 璁剧疆璁㈠崟鍙� * @date 23:08 2024/6/24 * @param: acceptData * @param: id 璁㈠崟ID * @param: orderNo 璁㈠崟鍙� * @param: orderStatus 璁㈠崟鐘舵�侊細璁㈠崟宸插彇娑�/宸叉敮浠� - * @return java.lang.String **/ @ResponseBody @RequestMapping("setOrderNo") @@ -181,6 +191,9 @@ } try { + if (!StringUtil.isNullOrEmpty(orderStatus)) { + throw new KeyOrderException(orderStatus); + } DYOrderDto dto = DYOrderApi.getOrderDetail(orderNo); // dto.setOrder_status(1); if (dto.getOrder_status() != DYOrderDto.ORDER_STATUS_NOT_PAY) { @@ -191,7 +204,7 @@ orderUpdate.setOrderType(1); orderUpdate.setOrderNo(orderNo); if (order.getState() == KeyOrder.STATE_NOT_PROCESS) { - if (dto.getOrder_status() == DYOrderDto.ORDER_STATUS_CANCELED) { + if (dto.getOrder_status() == DYOrderDto.ORDER_STATUS_CANCELED) { orderUpdate.setState(KeyOrder.STATE_PAY); orderUpdate.setStateDesc(dto.getOrder_status_desc()); } else { @@ -206,12 +219,24 @@ throw new Exception("璁㈠崟宸叉敮浠�"); } } + + if (order.getUid() != null) { + WxUserOrderCount countInfo = wxUserOrderCountService.get(order.getUid(), OrderCountTypeEnum.DY_ORDER_PAY, TimeUtil.getGernalTime(System.currentTimeMillis(), "yyyyMMdd")); + if (countInfo != null) { + WxUserSettings settings = wxUserSettingService.selectByUid(order.getUid()); + if (settings.getDyOrderCountPerDay() <= countInfo.getOrderCount()) { + throw new Exception("浠婃棩宸茶揪鏀粯娆℃暟涓婇檺锛�" + settings.getDyOrderCountPerDay()); + } + } + } + // 璁剧疆杩涘叆 KeyOrder orderUpdate = new KeyOrder(); orderUpdate.setId(id); orderUpdate.setOrderType(1); orderUpdate.setOrderState(dto.getOrder_status()); orderUpdate.setOrderNo(orderNo); + orderUpdate.setExcutePayTime(new Date()); keyOrderService.update(orderUpdate); order = keyOrderService.selectById(id); return JsonUtil.loadTrueResult(gson.toJson(OrderFactory.create(order))); @@ -222,6 +247,9 @@ orderUpdate.setOrderState(0); orderUpdate.setOrderNo(orderNo); orderUpdate.setState(KeyOrder.STATE_REJECT_PAY); + if (order.getExcutePayTime() == null) { + orderUpdate.setExcutePayTime(new Date()); + } orderUpdate.setStateDesc(e.getMessage()); keyOrderService.update(orderUpdate); return JsonUtil.loadFalseResult(e.getMessage()); @@ -246,7 +274,7 @@ return JsonUtil.loadFalseResult("娌℃湁鍖归厤鍒拌鍗曞彿"); } - if(order.getState()==KeyOrder.STATE_NOT_PROCESS) { + if (order.getState() == KeyOrder.STATE_NOT_PROCESS) { if (!paySuccess) { // 鏀粯澶辫触 KeyOrder orderUpdate = new KeyOrder(); @@ -258,8 +286,16 @@ KeyOrder orderUpdate = new KeyOrder(); orderUpdate.setId(id); orderUpdate.setState(KeyOrder.STATE_PAY); + if (order.getPayTime() == null) { + orderUpdate.setPayTime(new Date()); + } orderUpdate.setStateDesc("鏀粯鎴愬姛"); - keyOrderService.update(orderUpdate); + try { + keyOrderService.paySuccess(id, "鏀粯鎴愬姛", TimeUtil.getGernalTime(System.currentTimeMillis(), "yyyyMMdd")); + } catch (WxOrderCountException e) { + e.printStackTrace(); + return JsonUtil.loadFalseResult(e.getMessage()); + } } } return JsonUtil.loadTrueResult(""); @@ -294,16 +330,16 @@ @ResponseBody @RequestMapping("deleteAll") - public String deleteAll(AcceptData acceptData,Long uid) { + public String deleteAll(AcceptData acceptData, Long uid) { - ClientInfo user= clientInfoService.selectByPrimaryKey(uid); - if(user==null){ - return JsonUtil.loadFalseResult("鐢ㄦ埛涓嶅瓨鍦�"); - } + ClientInfo user = clientInfoService.selectByPrimaryKey(uid); + if (user == null) { + return JsonUtil.loadFalseResult("鐢ㄦ埛涓嶅瓨鍦�"); + } - if(user.getRule() != ClientInfo.RULE_ADMIN){ - return JsonUtil.loadFalseResult("鍙湁绠$悊鍛樻墠鑳藉垹闄�"); - } + if (user.getRule() != ClientInfo.RULE_ADMIN) { + return JsonUtil.loadFalseResult("鍙湁绠$悊鍛樻墠鑳藉垹闄�"); + } // 鍒犻櫎24灏忔椂涔嬪墠鐨勬暟鎹� // keyOrderService.deleteAll(new Date(System.currentTimeMillis() - 24*60*60*1000L)); -- Gitblit v1.8.0