From f318c9c7c127b00f353bf45f273096d1dc4b424f Mon Sep 17 00:00:00 2001
From: admin <1101184511@qq.com>
Date: 星期三, 20 八月 2025 01:10:48 +0800
Subject: [PATCH] 功能完善

---
 src/main/java/com/taoke/autopay/controller/client/js2/OrderTaskController.java |   96 ++++++++++++++++++++++++++++++++----------------
 1 files changed, 64 insertions(+), 32 deletions(-)

diff --git a/src/main/java/com/taoke/autopay/controller/client/js2/OrderTaskController.java b/src/main/java/com/taoke/autopay/controller/client/js2/OrderTaskController.java
index d2ec13d..fb232a6 100644
--- a/src/main/java/com/taoke/autopay/controller/client/js2/OrderTaskController.java
+++ b/src/main/java/com/taoke/autopay/controller/client/js2/OrderTaskController.java
@@ -11,6 +11,7 @@
 import com.taoke.autopay.entity.js2.OrderTaskExecutionDetail;
 import com.taoke.autopay.factory.js2.OrderTaskExecutionDetailFactory;
 import com.taoke.autopay.service.ClientAdditionalInfoService;
+import com.taoke.autopay.service.ClientInfoService;
 import com.taoke.autopay.service.js2.OrderTaskExecutionDetailService;
 import com.taoke.autopay.service.js2.OrderTaskService;
 import com.taoke.autopay.utils.TimeUtil;
@@ -36,6 +37,8 @@
 @Controller
 @RequestMapping("api/client/js2/task")
 public class OrderTaskController {
+
+    private Logger loggerDoOrder = LoggerFactory.getLogger("doOrderLogger");
 
     @Resource
     private ClientAdditionalInfoService clientAdditionalInfoService;
@@ -66,11 +69,14 @@
     @Resource
     private OrderTaskService orderTaskService;
 
+    @Resource
+    private ClientInfoService clientInfoService;
+
     /**
      * 鑾峰彇璁惧鍙墽琛岀殑浠诲姟鍒楄〃
      *
-     * @param uid 瀹㈡埛绔疘D
-     * @param page 椤电爜
+     * @param uid      瀹㈡埛绔疘D
+     * @param page     椤电爜
      * @param pageSize 姣忛〉鏁伴噺
      * @return 浠诲姟鍒楄〃
      */
@@ -81,54 +87,77 @@
             if (uid == null) {
                 return JsonUtil.loadFalseResult("瀹㈡埛绔疘D涓嶈兘涓虹┖");
             }
-            List<OrderTaskExecutionDetailVO> voList= new ArrayList<>();
-            List<OrderTaskExecutionDetail> list = orderTaskExecutionDetailService.listCanExcuteTaskDetail(uid, (page-1)*pageSize,pageSize);
-            if(!list.isEmpty()){
-                List<Long> taskIds=new ArrayList<>();
+            clientInfoService.setActiveTime(uid, new Date());
+            List<OrderTaskExecutionDetailVO> voList = new ArrayList<>();
+            List<OrderTaskExecutionDetail> list = orderTaskExecutionDetailService.listCanExcuteTaskDetail(uid, (page - 1) * pageSize, pageSize);
+            if (!list.isEmpty()) {
+                List<Long> taskIds = new ArrayList<>();
                 for (OrderTaskExecutionDetail detail : list) {
-                    if(taskIds.contains(detail.getTaskId())){
+                    if (taskIds.contains(detail.getTaskId())) {
                         continue;
                     }
                     taskIds.add(detail.getTaskId());
                 }
                 // 鑾峰彇鎵嬫満鍙蜂笌鏀粯瀹濊处鍙蜂俊鎭�
                 ClientAdditionalInfo clientAdditionalInfo = clientAdditionalInfoService.getClientAdditionalInfoByClientId(uid);
-                List<OrderTask> orderTaskList =  orderTaskService.getOrderTaskByIds(taskIds);
-                Map<Long, OrderTask> orderTaskMap=new HashMap<>();
-                for(OrderTask task:orderTaskList){
-                    orderTaskMap.put(task.getId(),task);
+                List<OrderTask> orderTaskList = orderTaskService.getOrderTaskByIds(taskIds);
+                Map<Long, OrderTask> orderTaskMap = new HashMap<>();
+                for (OrderTask task : orderTaskList) {
+                    orderTaskMap.put(task.getId(), task);
                 }
-                for(OrderTaskExecutionDetail detail:list){
-                    OrderTaskExecutionDetailVO vo = OrderTaskExecutionDetailFactory.createOrderTaskExecutionDetailVO(orderTaskMap.get(detail.getTaskId()),detail,clientAdditionalInfo);
+                for (OrderTaskExecutionDetail detail : list) {
+                    OrderTaskExecutionDetailVO vo = OrderTaskExecutionDetailFactory.createOrderTaskExecutionDetailVO(orderTaskMap.get(detail.getTaskId()), detail, clientAdditionalInfo);
                     voList.add(vo);
                 }
             }
+            voList.sort((o1, o2) -> (int) (o1.getCreateTime().getTime() - o2.getCreateTime().getTime()));
             long count = orderTaskExecutionDetailService.countCanExcuteTaskDetail(uid);
             JSONObject data = new JSONObject();
             data.put("list", gson.toJson(voList));
             data.put("count", count);
             return JsonUtil.loadTrueResult(data);
         } catch (Exception e) {
+            e.printStackTrace();
             loggerTask.error("鑾峰彇浠诲姟鍒楄〃澶辫触: {}", e.getMessage(), e);
             return JsonUtil.loadFalseResult("绯荤粺寮傚父锛�" + e.getMessage());
         }
     }
 
+
+    @ResponseBody
+    @RequestMapping("canOrder")
+    public String canOrder(Long uid, String id) {
+        if (uid == null) {
+            return JsonUtil.loadFalseResult("瀹㈡埛绔疘D涓嶈兘涓虹┖");
+        }
+
+        if (StringUtil.isNullOrEmpty(id)) {
+            return JsonUtil.loadFalseResult("浠诲姟ID涓嶈兘涓虹┖");
+        }
+
+        OrderTaskExecutionDetail detail = orderTaskExecutionDetailService.getOrderTaskExecutionDetailByIdForUpdate(id);
+        if (detail == null || detail.getExecutionStatus() != OrderTaskExecutionDetail.STATUS_NOT_ORDERED) {
+            return JsonUtil.loadFalseResult("浠诲姟涓嶅瓨鍦ㄦ垨宸叉墽琛�");
+        }
+        return JsonUtil.loadTrueResult("");
+    }
+
     /**
      * 涓嬪崟鎴愬姛
      *
-     * @param uid 瀹㈡埛绔疘D
-     * @param id 浠诲姟鎵ц璇︽儏ID
-     * @param orderNo 璁㈠崟鍙�
+     * @param uid          瀹㈡埛绔疘D
+     * @param id
+     * 浠诲姟鎵ц璇︽儏ID
+     * @param orderNo      璁㈠崟鍙�
      * @param productTitle 鍟嗗搧鏍囬
-     * @param shopName 搴楅摵鍚嶇О
+     * @param shopName     搴楅摵鍚嶇О
      * @param orderTimeStr 涓嬪崟鏃堕棿瀛楃涓�
      * @return 鎿嶄綔缁撴灉
      */
     @ResponseBody
     @RequestMapping("orderSuccess")
     public String orderSuccess(Long uid, String id, String orderNo, String productTitle, String shopName, String orderTimeStr) {
-        loggerTask.info("orderSuccess[{}]: {}-{}-{}-{}-{}", uid, id, orderNo, productTitle, shopName, orderTimeStr);
+        loggerDoOrder.info("涓嬪崟鎴愬姛[{}]: {}-{}-{}-{}-{}", uid, id, orderNo, productTitle, shopName, orderTimeStr);
         try {
             if (uid == null) {
                 return JsonUtil.loadFalseResult("瀹㈡埛绔疘D涓嶈兘涓虹┖");
@@ -141,6 +170,9 @@
             if (StringUtil.isNullOrEmpty(orderNo)) {
                 return JsonUtil.loadFalseResult("璁㈠崟鍙蜂笉鑳戒负绌�");
             }
+
+
+            orderNo = orderNo.split("璁㈠崟缂栧彿")[1];
 
             Date orderTime = null;
             if (!StringUtil.isNullOrEmpty(orderTimeStr)) {
@@ -164,15 +196,15 @@
     /**
      * 涓嬪崟澶辫触锛屼笂浼犲け璐ュ師鍥�
      *
-     * @param uid 瀹㈡埛绔疘D
-     * @param id 浠诲姟鎵ц璇︽儏ID
+     * @param uid           瀹㈡埛绔疘D
+     * @param id            浠诲姟鎵ц璇︽儏ID
      * @param failureReason 澶辫触鍘熷洜
      * @return 鎿嶄綔缁撴灉
      */
     @ResponseBody
     @RequestMapping("orderFailure")
     public String orderFailure(Long uid, String id, String failureReason) {
-        loggerTask.info("orderFailure[{}]: {}-{}", uid, id, failureReason);
+        loggerDoOrder.info("涓嬪崟澶辫触[{}]: {}-{}", uid, id, failureReason);
         try {
             if (uid == null) {
                 return JsonUtil.loadFalseResult("瀹㈡埛绔疘D涓嶈兘涓虹┖");
@@ -197,15 +229,15 @@
     /**
      * 纭鏀惰揣鎴愬姛锛屼笂浼犲埜鐮�
      *
-     * @param uid 瀹㈡埛绔疘D
-     * @param id 浠诲姟鎵ц璇︽儏ID
+     * @param uid        瀹㈡埛绔疘D
+     * @param id         浠诲姟鎵ц璇︽儏ID
      * @param couponCode 鍒哥爜
      * @return 鎿嶄綔缁撴灉
      */
     @ResponseBody
     @RequestMapping("confirmReceiptSuccess")
     public String confirmReceiptSuccess(Long uid, String id, String couponCode) {
-        loggerTask.info("confirmReceiptSuccess[{}]: {}-{}", uid, id, couponCode);
+        loggerDoOrder.info("纭鏀惰揣鎴愬姛[{}]: {}-{}", uid, id, couponCode);
         try {
             if (uid == null) {
                 return JsonUtil.loadFalseResult("瀹㈡埛绔疘D涓嶈兘涓虹┖");
@@ -230,15 +262,15 @@
     /**
      * 纭鏀惰揣澶辫触锛屼笂浼犲け璐ュ師鍥�
      *
-     * @param uid 瀹㈡埛绔疘D
-     * @param id 浠诲姟鎵ц璇︽儏ID
+     * @param uid    瀹㈡埛绔疘D
+     * @param id     浠诲姟鎵ц璇︽儏ID
      * @param reason 澶辫触鍘熷洜
      * @return 鎿嶄綔缁撴灉
      */
     @ResponseBody
     @RequestMapping("confirmReceiptFailure")
     public String confirmReceiptFailure(Long uid, String id, String reason) {
-        loggerTask.info("confirmReceiptFailure[{}]: {}-{}", uid, id, reason);
+        loggerDoOrder.info("纭鏀惰揣澶辫触[{}]: {}-{}", uid, id, reason);
         try {
             if (uid == null) {
                 return JsonUtil.loadFalseResult("瀹㈡埛绔疘D涓嶈兘涓虹┖");
@@ -264,13 +296,13 @@
      * 璇勪环鎴愬姛
      *
      * @param uid 瀹㈡埛绔疘D
-     * @param id 浠诲姟鎵ц璇︽儏ID
+     * @param id  浠诲姟鎵ц璇︽儏ID
      * @return 鎿嶄綔缁撴灉
      */
     @ResponseBody
     @RequestMapping("reviewSuccess")
     public String reviewSuccess(Long uid, String id) {
-        loggerTask.info("reviewSuccess[{}]: {}", uid, id);
+        loggerDoOrder.info("璇勪环鎴愬姛[{}]: {}", uid, id);
         try {
             if (uid == null) {
                 return JsonUtil.loadFalseResult("瀹㈡埛绔疘D涓嶈兘涓虹┖");
@@ -291,15 +323,15 @@
     /**
      * 璇勪环澶辫触锛屼笂浼犲け璐ュ師鍥�
      *
-     * @param uid 瀹㈡埛绔疘D
-     * @param id 浠诲姟鎵ц璇︽儏ID
+     * @param uid    瀹㈡埛绔疘D
+     * @param id     浠诲姟鎵ц璇︽儏ID
      * @param reason 澶辫触鍘熷洜
      * @return 鎿嶄綔缁撴灉
      */
     @ResponseBody
     @RequestMapping("reviewFailure")
     public String reviewFailure(Long uid, String id, String reason) {
-        loggerTask.info("reviewFailure[{}]: {}-{}", uid, id, reason);
+        loggerDoOrder.info("璇勪环澶辫触[{}]: {}-{}", uid, id, reason);
         try {
             if (uid == null) {
                 return JsonUtil.loadFalseResult("瀹㈡埛绔疘D涓嶈兘涓虹┖");

--
Gitblit v1.8.0