liweifan преди 3 години
родител
ревизия
9babf09460

+ 0 - 42
cooleshow-user/user-admin/src/main/java/com/yonge/cooleshow/admin/client/AdminFeignClient.java

@@ -1,42 +0,0 @@
-package com.yonge.cooleshow.admin.client;
-
-import com.yonge.cooleshow.biz.dal.service.CourseScheduleService;
-import com.yonge.cooleshow.biz.dal.service.UserAccountRecordService;
-import com.yonge.cooleshow.common.entity.HttpResponseResult;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.web.bind.annotation.PostMapping;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RestController;
-import springfox.documentation.annotations.ApiIgnore;
-
-/**
- * Description
- *
- * @author liujunchi
- * @date 2022-05-06
- */
-@ApiIgnore
-@RestController
-@RequestMapping("/task")
-public class AdminFeignClient {
-
-    @Autowired
-    private CourseScheduleService courseScheduleService;
-
-    @Autowired
-    private UserAccountRecordService userAccountRecordService;
-
-    // 老师作业布置
-    @PostMapping(value = "/teacherSend")
-    public HttpResponseResult<Object> sendTodayNotRepliedAndNotDecorateHomework() {
-        courseScheduleService.sendTodayNotRepliedAndNotDecorateHomework();
-        return HttpResponseResult.succeed();
-    }
-
-    //老师课酬
-    @PostMapping(value = "/teacherEarning")
-    public HttpResponseResult<Object> sendTeacherEarning() {
-        userAccountRecordService.sendTeacherEarning();
-        return HttpResponseResult.succeed();
-    }
-}

+ 1 - 3
cooleshow-user/user-admin/src/main/java/com/yonge/cooleshow/admin/controller/open/UserOrderClient.java

@@ -34,7 +34,7 @@ import java.util.concurrent.TimeUnit;
 
 @RestController
 @RequestMapping("/open/userOrder")
-@Api(value = "开放权限接口-订单", hidden = true)
+@Api(value = "开放权限接口", tags = "开放权限接口")
 public class UserOrderClient extends BaseController {
     private final static Logger log = LoggerFactory.getLogger(UserOrderClient.class);
 
@@ -117,7 +117,6 @@ public class UserOrderClient extends BaseController {
         return res.getData().getResMsg();
     }
 
-
     /***
      * 支付回调
      * @author liweifan
@@ -138,7 +137,6 @@ public class UserOrderClient extends BaseController {
         }
     }
 
-
     @GetMapping("/setSuccessStatus")
     @ApiOperation(value = "完成所有订单(测试用)")
     public HttpResponseResult<Boolean> setSuccessStatus() {

+ 19 - 0
cooleshow-user/user-admin/src/main/java/com/yonge/cooleshow/admin/task/TaskController.java

@@ -5,6 +5,7 @@ import com.yonge.cooleshow.common.controller.BaseController;
 import com.yonge.cooleshow.common.entity.HttpResponseResult;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.PostMapping;
 import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RestController;
 
@@ -19,6 +20,10 @@ public class TaskController extends BaseController {
     private UserOrderService userOrderService;
     @Autowired
     private UserBindingTeacherService userBindingTeacherService;
+    @Autowired
+    private CourseScheduleService courseScheduleService;
+    @Autowired
+    private UserAccountRecordService userAccountRecordService;
 
     /***
      * 轮询用户订单
@@ -44,4 +49,18 @@ public class TaskController extends BaseController {
         userBindingTeacherService.unbindTask();
         return succeed(true);
     }
+
+    // 老师作业布置
+    @PostMapping(value = "/teacherSend")
+    public HttpResponseResult<Object> sendTodayNotRepliedAndNotDecorateHomework() {
+        courseScheduleService.sendTodayNotRepliedAndNotDecorateHomework();
+        return HttpResponseResult.succeed();
+    }
+
+    //老师课酬
+    @PostMapping(value = "/teacherEarning")
+    public HttpResponseResult<Object> sendTeacherEarning() {
+        userAccountRecordService.sendTeacherEarning();
+        return HttpResponseResult.succeed();
+    }
 }

+ 1 - 1
cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/service/impl/UserOrderPaymentServiceImpl.java

@@ -46,7 +46,7 @@ public class UserOrderPaymentServiceImpl extends ServiceImpl<UserOrderPaymentDao
     private IdGeneratorService idGeneratorService;
     @Autowired
     private PaymentProperties paymentProperties;
-    @Autowired(required = true)
+    @Autowired
     private PaymentClient paymentClient;
 
     @Override

+ 30 - 6
cooleshow-user/user-biz/src/main/java/com/yonge/cooleshow/biz/dal/service/impl/UserOrderServiceImpl.java

@@ -19,10 +19,12 @@ import com.yonge.cooleshow.common.entity.HttpResponseResult;
 import com.yonge.toolset.base.exception.BizException;
 import com.yonge.cooleshow.common.service.IdGeneratorService;
 import com.yonge.toolset.base.result.BaseResult;
+import com.yonge.toolset.payment.base.enums.OpenEnum;
 import com.yonge.toolset.payment.base.enums.PaymentClientEnum;
 import com.yonge.toolset.payment.base.enums.TradeStatusEnum;
 import com.yonge.toolset.payment.base.model.Payment;
 import com.yonge.toolset.payment.base.model.callback.PaymentCallBack;
+import com.yonge.toolset.payment.core.props.PaymentProperties;
 import com.yonge.toolset.payment.core.service.PaymentClient;
 import com.yonge.toolset.utils.string.StringUtil;
 import org.apache.commons.beanutils.BeanUtils;
@@ -72,6 +74,8 @@ public class UserOrderServiceImpl extends ServiceImpl<UserOrderDao, UserOrder> i
     private PianoRoomBuyRecordService pianoRoomBuyRecordService;
     @Autowired
     private RedissonClient redissonClient;
+    @Autowired
+    private PaymentProperties paymentProperties;
 
     //验证订单是否可以下单,获取订单金额信息
     private static final Map<GoodTypeEnum, Function<OrderReq.OrderReqInfo, HttpResponseResult<OrderCreateRes>>> orderCreate = new HashMap<>();
@@ -200,7 +204,7 @@ public class UserOrderServiceImpl extends ServiceImpl<UserOrderDao, UserOrder> i
         query.setStatus("WAIT_PAY,PAYING");
         List<UserOrderVo> userOrderVos = selectList(query);
         for (UserOrderVo userOrderVo : userOrderVos) {
-            orderSuccess(userOrderVo);
+            testOrderSuccess(userOrderVo);
         }
     }
 
@@ -227,7 +231,7 @@ public class UserOrderServiceImpl extends ServiceImpl<UserOrderDao, UserOrder> i
                 doOrderCancel(detail, orderStatus, "测试接口-订单交易失败");
             }
             if (OrderStatusEnum.PAID.equals(orderStatus)) {
-                orderSuccess(detail);
+                testOrderSuccess(detail);
             }
         }
     }
@@ -313,7 +317,7 @@ public class UserOrderServiceImpl extends ServiceImpl<UserOrderDao, UserOrder> i
             //入订单付款表,同时修改订单状态
             doOrderCancel(detail, OrderStatusEnum.FAIL, e.getMessage());
             return HttpResponseResult.failed(e.getMessage());
-        } catch (Exception e){
+        } catch (Exception e) {
             //入订单付款表,同时修改订单状态
             doOrderCancel(detail, OrderStatusEnum.FAIL, e.getMessage());
             return HttpResponseResult.failed("付款失败");
@@ -640,8 +644,8 @@ public class UserOrderServiceImpl extends ServiceImpl<UserOrderDao, UserOrder> i
                 }
             }
         } catch (Exception e) {
+            log.error("订单完成-更新付款单失败, UserOrderVo is {},PaymentCallBack is {}", JSONObject.toJSONString(detail), JSONObject.toJSONString(data));
             e.printStackTrace();
-            log.error("完成订单失败,参数{}", JSONObject.toJSONString(data));
         }
         //调用业务
         List<UserOrderDetailVo> orderDetailList = orderDetailService.getOrderDetilListByOrderNo(detail.getOrderNo());
@@ -654,14 +658,34 @@ public class UserOrderServiceImpl extends ServiceImpl<UserOrderDao, UserOrder> i
                 userOrderVoConsumer.accept(orderDetailVo);
             }
             Long merchId = orderDetailVo.getMerchId();
-            if (null != merchId) {
+            if (merchId != null && merchId != 0) {
+
                 redissonClient.getBucket(CacheNameEnum.TEACHER_SUBJECT_ITEM.getRedisKey(merchId)).delete();
             }
         }
-
         //清除老师声部缓存
         redissonClient.getBucket(CacheNameEnum.STUDENT_SUBJECT_ITEM.getRedisKey(detail.getUserId())).delete();
 
     }
 
+    private void testOrderSuccess(UserOrderVo detail) {
+        UserOrderPayment orderPayment = new UserOrderPayment();
+
+        OpenEnum openType = OpenEnum.valueOf(paymentProperties.getOpenType());
+        orderPayment.setOpenType(openType);
+
+        orderPayment.setOrderNo(detail.getOrderNo());
+
+        //支付订单号生成
+        Long paymentNo = idGeneratorService.generatorId("paymentNo");
+        orderPayment.setPaymentNo(paymentNo.toString());
+
+        orderPayment.setPayAmt(detail.getActualPrice());
+        orderPayment.setStatus(TradeStatusEnum.succeeded);
+
+        //保存新的付款单
+        orderPaymentService.save(orderPayment);
+        orderSuccess(detail, null);
+    }
+
 }

+ 8 - 1
toolset/audit-log/src/main/java/com/yonge/toolset/log/interceptor/AuditLogInterceptor.java

@@ -1,5 +1,6 @@
 package com.yonge.toolset.log.interceptor;
 
+import com.alibaba.fastjson.JSONObject;
 import io.swagger.annotations.ApiOperation;
 
 import java.io.IOException;
@@ -18,6 +19,8 @@ import javax.servlet.http.HttpServletResponse;
 
 import org.apache.commons.io.IOUtils;
 import org.apache.commons.lang3.StringUtils;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Value;
 import org.springframework.context.annotation.Bean;
@@ -35,6 +38,7 @@ import com.yonge.toolset.utils.web.WebUtil;
  * 日志审计的拦截器
  */
 public class AuditLogInterceptor extends HandlerInterceptorAdapter {
+    private final static Logger log = LoggerFactory.getLogger(AuditLogInterceptor.class);
 
     @Autowired
     private AuditLogService auditLogService;
@@ -45,7 +49,7 @@ public class AuditLogInterceptor extends HandlerInterceptorAdapter {
     private String username;
 
     private Long userId;
-    
+
     private SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
 
     private static List<String> ignoreLogUrl;
@@ -86,6 +90,7 @@ public class AuditLogInterceptor extends HandlerInterceptorAdapter {
     }
 
     public void syncSaveLog(HttpServletRequest request, Object handler) {
+
         try {
             String servletPath = request.getServletPath();
             HandlerMethod handlerMethod = (HandlerMethod) handler;
@@ -123,6 +128,8 @@ public class AuditLogInterceptor extends HandlerInterceptorAdapter {
             }
             //saveLog(operateName, servletPath, request);
         } catch (Exception e) {
+            String servletPath = request.getServletPath();
+            log.error("日志记录异常: servletPath is {},handler is {}", servletPath, handler);
             e.printStackTrace();
         }
     }

+ 3 - 0
toolset/toolset-payment/src/main/java/com/yonge/toolset/payment/original/ali/OriginalAliAppTemplate.java

@@ -249,6 +249,7 @@ public class OriginalAliAppTemplate implements PaymentTemplate {
             String refundNo = jsonParams.getString("out_biz_no");
 
             paymentCallBack.setStatus(TradeStatusEnum.succeeded);
+            paymentCallBack.setResMsg("success");
             //退款
             if (!StringUtil.isEmpty(refundNo)
                     || null != jsonParams.getBigDecimal("refund_fee")) {
@@ -286,8 +287,10 @@ public class OriginalAliAppTemplate implements PaymentTemplate {
             }
             return BaseResult.succeed(paymentCallBack);
         } catch (AlipayApiException e) {
+            paymentCallBack.setResMsg("filed");
             return BaseResult.failed(HttpStatus.INTERNAL_SERVER_ERROR, paymentCallBack, "微信回调对象转换失败");
         } catch (Exception e) {
+            paymentCallBack.setResMsg("filed");
             return BaseResult.failed(HttpStatus.INTERNAL_SERVER_ERROR, paymentCallBack, "解析异常");
         }
     }