admin
2025-08-20 f318c9c7c127b00f353bf45f273096d1dc4b424f
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,6 +69,9 @@
    @Resource
    private OrderTaskService orderTaskService;
    @Resource
    private ClientInfoService clientInfoService;
    /**
     * 获取设备可执行的任务列表
     *
@@ -81,6 +87,7 @@
            if (uid == null) {
                return JsonUtil.loadFalseResult("客户端ID不能为空");
            }
            clientInfoService.setActiveTime(uid, new Date());
            List<OrderTaskExecutionDetailVO> voList= new ArrayList<>();
            List<OrderTaskExecutionDetail> list = orderTaskExecutionDetailService.listCanExcuteTaskDetail(uid, (page-1)*pageSize,pageSize);
            if(!list.isEmpty()){
@@ -103,22 +110,44 @@
                    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("客户端ID不能为空");
        }
        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 客户端ID
     * @param id 任务执行详情ID
     * @param id
     * 任务执行详情ID
     * @param orderNo 订单号
     * @param productTitle 商品标题
     * @param shopName 店铺名称
@@ -128,7 +157,7 @@
    @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("客户端ID不能为空");
@@ -141,6 +170,9 @@
            if (StringUtil.isNullOrEmpty(orderNo)) {
                return JsonUtil.loadFalseResult("订单号不能为空");
            }
            orderNo = orderNo.split("订单编号")[1];
            Date orderTime = null;
            if (!StringUtil.isNullOrEmpty(orderTimeStr)) {
@@ -172,7 +204,7 @@
    @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("客户端ID不能为空");
@@ -205,7 +237,7 @@
    @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("客户端ID不能为空");
@@ -238,7 +270,7 @@
    @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("客户端ID不能为空");
@@ -270,7 +302,7 @@
    @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("客户端ID不能为空");
@@ -299,7 +331,7 @@
    @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("客户端ID不能为空");