| @@ -9,7 +9,9 @@ public enum EnumTtOrderStatus { | |||
| ORDER_STATUS_PENDING_PAYMENT(0, "待付款"), | |||
| // ORDER_STATUS_PAYMENT_ING(1,"支付中"), | |||
| ORDER_STATUS_PAYMENT_SUCCESS(2, "已支付"), | |||
| ORDER_STATUS_OVERTIME_CANCEL(3, "已取消"), | |||
| ORDER_STATUS_OVERTIME_CANCEL(3, "已取消"),//已关闭 | |||
| ORDER_STATUS_PENDING_REFUND(4, "待退款"), | |||
| ORDER_STATUS_REFUND_SUCCESS(5,"已退款"), | |||
| ORDER_STATUS_REFUND_FAILD(6, "退款失败"), | |||
| @@ -22,4 +22,6 @@ public interface TtOrderMapper extends CommonMapper<TtOrder, Long> { | |||
| Integer findListCount(TtOrder orderQ); | |||
| int updateExpire(@Param("expireDate")Date expireDate,@Param("orderStatus") Integer orderStatus); | |||
| List<Long> findExpireIdList(@Param("expireDate")Date expireDate,@Param("orderStatus") Integer orderStatus); | |||
| } | |||
| @@ -129,6 +129,7 @@ public class AliBusinessCircleOrderServiceImpl implements AliBusinessCircleOrder | |||
| aliBusinessCircleOrderMapper.insertNoticeOrder(record); | |||
| if(record.getCUserId() == null){ | |||
| redisLock.unlock(lockKey, timeStr); | |||
| return; | |||
| } | |||
| Integer businessId = EnumBusiness.BUSINESS_ID6.getCode(); | |||
| @@ -153,6 +154,7 @@ public class AliBusinessCircleOrderServiceImpl implements AliBusinessCircleOrder | |||
| creditNum = creditHistory.getCreditNum(); | |||
| } | |||
| if(creditNum == 0){ | |||
| redisLock.unlock(lockKey, timeStr); | |||
| return; | |||
| } | |||
| record.setIncreasedPoints(creditNum); | |||
| @@ -257,6 +259,7 @@ public class AliBusinessCircleOrderServiceImpl implements AliBusinessCircleOrder | |||
| creditNum = creditHistory.getCreditNum(); | |||
| } | |||
| if(creditNum == 0){ | |||
| redisLock.unlock(lockKey, timeStr); | |||
| return; | |||
| } | |||
| @@ -143,6 +143,7 @@ public class WxBusinessCircleOrderServiceImpl implements WxBusinessCircleOrderSe | |||
| creditNum = creditHistory.getCreditNum(); | |||
| } | |||
| if(creditNum == 0){ | |||
| redisLock.unlock(lockKey, timeStr); | |||
| return; | |||
| } | |||
| record.setIncreasedPoints(creditNum); | |||
| @@ -248,6 +249,7 @@ public class WxBusinessCircleOrderServiceImpl implements WxBusinessCircleOrderSe | |||
| creditNum = creditHistory.getCreditNum(); | |||
| } | |||
| if(creditNum == 0){ | |||
| redisLock.unlock(lockKey, timeStr); | |||
| return; | |||
| } | |||
| @@ -101,6 +101,7 @@ public class WxThirdPartyOrdersServiceImpl implements WxThirdPartyOrdersService | |||
| WxThirdPartyOrders byTransactionId = this.getOrderByTransactionId(EnumThirdOrderType.RMB_PAY,record.getTransactionId(),record.getTenantId()); | |||
| if(byTransactionId != null){ | |||
| logger.error("--第三方付款--通知消息已存在---byTransactionId="+byTransactionId.getTransactionId()); | |||
| redisLock.unlock(lockKey, timeStr); | |||
| throw new MallinkException(ErrorCode.SYS_PARAMETER_ERROR.getCode(), "订单数据已存在"); | |||
| }else{ | |||
| Date now = new Date(); | |||
| @@ -144,6 +145,7 @@ public class WxThirdPartyOrdersServiceImpl implements WxThirdPartyOrdersService | |||
| wxThirdPartyOrdersMapper.insertNoticeOrder(record); | |||
| if(record.getCUserId() == null){ | |||
| redisLock.unlock(lockKey, timeStr); | |||
| return; | |||
| } | |||
| Integer businessId = EnumBusiness.BUSINESS_ID6.getCode(); | |||
| @@ -168,6 +170,7 @@ public class WxThirdPartyOrdersServiceImpl implements WxThirdPartyOrdersService | |||
| creditNum = creditHistory.getCreditNum(); | |||
| } | |||
| if(creditNum == 0){ | |||
| redisLock.unlock(lockKey, timeStr); | |||
| return; | |||
| } | |||
| record.setIncreasedPoints(creditNum); | |||
| @@ -231,9 +234,11 @@ public class WxThirdPartyOrdersServiceImpl implements WxThirdPartyOrdersService | |||
| } | |||
| if(refundAmount >= amount){ | |||
| logger.error("--第三方退款--已经退款--transactionId="+record.getTransactionId()); | |||
| redisLock.unlock(lockKey, timeStr); | |||
| throw new MallinkException(ErrorCode.SYS_PARAMETER_ERROR.getCode(), "已经退款"); | |||
| }else if((refundAmount + record.getRefundAmount()) > amount ){ | |||
| logger.error("--第三方退款--退款金额超限--transactionId="+record.getTransactionId()); | |||
| redisLock.unlock(lockKey, timeStr); | |||
| throw new MallinkException(ErrorCode.SYS_PARAMETER_ERROR.getCode(), "退款金额超限"); | |||
| }else{ | |||
| @@ -292,6 +297,7 @@ public class WxThirdPartyOrdersServiceImpl implements WxThirdPartyOrdersService | |||
| creditNum = creditHistory.getCreditNum(); | |||
| } | |||
| if(creditNum == 0){ | |||
| redisLock.unlock(lockKey, timeStr); | |||
| return; | |||
| } | |||
| @@ -349,6 +355,7 @@ public class WxThirdPartyOrdersServiceImpl implements WxThirdPartyOrdersService | |||
| WxThirdPartyOrders byTransactionId = this.getOrderByTransactionId(EnumThirdOrderType.CREDIT_PAY,record.getTransactionId(),record.getTenantId()); | |||
| if(byTransactionId != null){ | |||
| logger.error("--第三方积分订单--数据已存在---byTransactionId="+byTransactionId.getTransactionId()); | |||
| redisLock.unlock(lockKey, timeStr); | |||
| throw new MallinkException(ErrorCode.SYS_PARAMETER_ERROR.getCode(), "订单数据已存在"); | |||
| }else{ | |||
| Date now = new Date(); | |||
| @@ -387,6 +394,7 @@ public class WxThirdPartyOrdersServiceImpl implements WxThirdPartyOrdersService | |||
| creditNum = creditHistory.getCreditNum(); | |||
| } | |||
| if(creditNum == 0){ | |||
| redisLock.unlock(lockKey, timeStr); | |||
| throw new MallinkException(ErrorCode.CREDIT_ZERO.getCode(), "本次扣减积分为0"); | |||
| } | |||
| wxThirdPartyOrdersMapper.insertNoticeOrder(record); | |||
| @@ -9,6 +9,10 @@ import com.iformall.domain.po.WxPayAccount; | |||
| import com.iformall.domain.po.base.TenantEntity; | |||
| import com.iformall.domain.po.tt.TtOrder; | |||
| import com.iformall.enums.EnumPayWay; | |||
| import org.springframework.scheduling.annotation.Async; | |||
| import java.util.Date; | |||
| import java.util.List; | |||
| public interface TtOrderService { | |||
| @@ -35,5 +39,5 @@ public interface TtOrderService { | |||
| boolean isByMember(Long memberId, Long id); | |||
| List<Long> findExpireIdList(Date expireDate); | |||
| } | |||
| @@ -19,6 +19,7 @@ import com.iformall.exception.MallinkException; | |||
| import com.iformall.mapper.*; | |||
| import com.iformall.service.*; | |||
| import com.iformall.service.tt.TtOrderService; | |||
| import com.iformall.utils.Constant; | |||
| import com.iformall.utils.RedisLock; | |||
| import org.apache.commons.lang3.StringUtils; | |||
| import org.slf4j.Logger; | |||
| @@ -28,6 +29,7 @@ import org.springframework.stereotype.Service; | |||
| import org.springframework.transaction.annotation.Propagation; | |||
| import org.springframework.transaction.annotation.Transactional; | |||
| import java.text.SimpleDateFormat; | |||
| import java.util.*; | |||
| @@ -237,54 +239,22 @@ public class TtOrderServiceImpl implements TtOrderService { | |||
| if (order.getPaymentType() != EnumPayType.PAY_PAYMENT.getCode()) { | |||
| return new ResultData(ErrorCode.PAY_ORDER_IS_NOT_PAYMENT); | |||
| } | |||
| if (order.getOrderStatus() == EnumTtOrderStatus.ORDER_STATUS_PAYMENT_SUCCESS.getCode()) { | |||
| logger.error("订单已支付: " + order.toString()); | |||
| ResultData resultData = this.updateOrderStatus(orderId, appInfo, payAcount); | |||
| if(resultData.code == ResultData.SUCCESS){ | |||
| return new ResultData(ErrorCode.ORDER_HAD_PAY); | |||
| } else if (order.getOrderStatus() == EnumTtOrderStatus.ORDER_STATUS_OVERTIME_CANCEL.getCode()) { | |||
| logger.error("订单已取消: " + order.toString()); | |||
| return new ResultData(ErrorCode.ORDER_HAD_CANCEL); | |||
| } else if(order.getOrderStatus() == EnumTtOrderStatus.ORDER_STATUS_PENDING_PAYMENT.getCode()){ | |||
| logger.info("订单未支付: " + order.toString()); | |||
| OrderQueryResult orderQueryResult = DouYinPayHelper.orderQuery(appInfo.getAppId(), payAcount.getApiKey(), order.getId().toString(), null); | |||
| if(orderQueryResult != null){ | |||
| String trade_state = orderQueryResult.getOrderStatus(); | |||
| if ("PROCESSING".equals(trade_state)) {//处理中 | |||
| // return new ResultData(ErrorCode.PAY_ORDER_PAYING); | |||
| }else if ("SUCCESS".equals(trade_state)) {//成功 | |||
| TtOrder orderSuc = new TtOrder(); | |||
| orderSuc.setId(order.getId()); | |||
| orderSuc.setOrderStatus(EnumTtOrderStatus.ORDER_STATUS_PAYMENT_SUCCESS.getCode()); | |||
| orderSuc.setWay(orderQueryResult.getWay()); | |||
| orderSuc.setPaymentTime(orderQueryResult.getPayTime()); | |||
| orderSuc.setUpdateDate(new Date()); | |||
| ttOrderMapper.updateById(orderSuc); | |||
| return new ResultData(ErrorCode.PAY_ORDER_EXIST,"该订单已经支付,请勿重复支付!"); | |||
| }else if ("FAIL".equals(trade_state)) {//失败 | |||
| }else if ("TIMEOUT".equals(trade_state)) {//超时 | |||
| } | |||
| } | |||
| } else{ | |||
| if (order.getOrderStatus() != EnumTtOrderStatus.ORDER_STATUS_PENDING_PAYMENT.getCode()) { | |||
| logger.error("订单已支付: " + order.toString()); | |||
| return new ResultData(ErrorCode.ORDER_IS_NOT_PAY); | |||
| } | |||
| } | |||
| DouYinCreatePreOrder preOrder = new DouYinCreatePreOrder(); | |||
| preOrder.setAppId(appInfo.getAppId()); | |||
| preOrder.setSercrect(appInfo.getSecret()); | |||
| preOrder.setSalt(payAcount.getApiKey()); | |||
| preOrder.setOutOrderNo(order.getId().toString()); | |||
| preOrder.setTotalAmount(order.getPayment()); | |||
| preOrder.setSubject(coupon.getTitle()); | |||
| preOrder.setBody(coupon.getTitle()); | |||
| preOrder.setValidTime(time_out); | |||
| }else if(resultData.code == ErrorCode.PAY_ORDER_NOT_PAY.getCode() ){ | |||
| DouYinCreatePreOrder preOrder = new DouYinCreatePreOrder(); | |||
| preOrder.setAppId(appInfo.getAppId()); | |||
| preOrder.setSercrect(appInfo.getSecret()); | |||
| preOrder.setSalt(payAcount.getApiKey()); | |||
| preOrder.setOutOrderNo(order.getId().toString()); | |||
| preOrder.setTotalAmount(order.getPayment()); | |||
| preOrder.setSubject(coupon.getTitle()); | |||
| preOrder.setBody(coupon.getTitle()); | |||
| preOrder.setValidTime(time_out); | |||
| // preOrder.setNotifyUrl();//回调地址 | |||
| CreatePreOrderResult preOrderResult = DouYinPayHelper.createPreOrder(preOrder); | |||
| CreatePreOrderResult preOrderResult = DouYinPayHelper.createPreOrder(preOrder); | |||
| // if(preOrderResult.isSuccess()){ | |||
| // TtOrder orderSuc = new TtOrder(); | |||
| // orderSuc.setId(order.getId()); | |||
| @@ -292,7 +262,11 @@ public class TtOrderServiceImpl implements TtOrderService { | |||
| // orderSuc.setUpdateDate(new Date()); | |||
| // ttOrderMapper.updateById(orderSuc); | |||
| // } | |||
| return new ResultData(preOrderResult); | |||
| return new ResultData(preOrderResult); | |||
| }else{ | |||
| return resultData; | |||
| } | |||
| } | |||
| @Override | |||
| @@ -308,18 +282,25 @@ public class TtOrderServiceImpl implements TtOrderService { | |||
| logger.error("pay order, order not allow, orderId: " + orderId); | |||
| return new ResultData(ErrorCode.ORDER_IS_NOT_FIND); | |||
| } | |||
| Boolean isExpire = false;//是否过期 | |||
| Date now = new Date(); | |||
| Date expireDate = new Date(now.getTime() - Constant.PRESS_TIME_OUT ); | |||
| if(order.getCreateDate().before(expireDate)){ | |||
| isExpire = true; | |||
| } | |||
| if(appInfo == null || payAccount == null) { | |||
| return new ResultData(ErrorCode.APP_ID_NOT_FOUND); | |||
| } | |||
| if(order.getOrderStatus() == EnumTtOrderStatus.ORDER_STATUS_PENDING_PAYMENT.getCode()){ | |||
| logger.info("订单支付中: " + order.toString()); | |||
| String msg = ""; | |||
| //待付款 | |||
| OrderQueryResult orderQueryResult = DouYinPayHelper.orderQuery(appInfo.getAppId(), payAccount.getApiKey(), order.getId().toString(), null); | |||
| if(orderQueryResult == null){ | |||
| return new ResultData(ErrorCode.PAY_ORDER_ERROR,"查询单号不存在"); | |||
| msg = "查询-单号不存在"; | |||
| } | |||
| String trade_state = orderQueryResult.getOrderStatus(); | |||
| if ("PROCESSING".equals(trade_state)) {//处理中 | |||
| return new ResultData(ErrorCode.PAY_ORDER_PAYING); | |||
| msg = "查询-处理中"; | |||
| }else if ("SUCCESS".equals(trade_state)) {//成功 | |||
| TtOrder orderSuc = new TtOrder(); | |||
| orderSuc.setId(order.getId()); | |||
| @@ -328,29 +309,54 @@ public class TtOrderServiceImpl implements TtOrderService { | |||
| orderSuc.setPaymentTime(orderQueryResult.getPayTime()); | |||
| orderSuc.setUpdateDate(new Date()); | |||
| ttOrderMapper.updateById(orderSuc); | |||
| // return new ResultData(ErrorCode.PAY_ORDER_EXIST,"该订单已经支付,请勿重复支付!"); | |||
| ttcouponMapper.addSellCount(order.getProductId()); | |||
| redisLock.unlock(lockKey, timeStr); | |||
| return new ResultData(); | |||
| }else if ("FAIL".equals(trade_state)) {//失败 | |||
| // TtOrder orderSuc = new TtOrder(); | |||
| // orderSuc.setId(order.getId()); | |||
| // orderSuc.setOrderStatus(EnumTtOrderStatus.ORDER_STATUS_PENDING_PAYMENT.getCode()); | |||
| // orderSuc.setUpdateDate(new Date()); | |||
| // ttOrderMapper.updateById(orderSuc); | |||
| return new ResultData(ErrorCode.PAY_ORDER_ERROR,"支付失败"); | |||
| msg = "查询-支付失败"; | |||
| }else if ("TIMEOUT".equals(trade_state)) {//超时 | |||
| // TtOrder orderSuc = new TtOrder(); | |||
| // orderSuc.setId(order.getId()); | |||
| // orderSuc.setOrderStatus(EnumTtOrderStatus.ORDER_STATUS_OVERTIME_CANCEL.getCode()); | |||
| // orderSuc.setUpdateDate(new Date()); | |||
| // ttOrderMapper.updateById(orderSuc); | |||
| // return new ResultData(ErrorCode.PAY_ORDER_CLOSED); | |||
| return new ResultData(ErrorCode.PAY_ORDER_ERROR,"支付超时"); | |||
| msg = "查询-支付超时"; | |||
| }else{ | |||
| msg = "查询-单号异常"; | |||
| } | |||
| if(isExpire){ | |||
| TtOrder orderSuc = new TtOrder(); | |||
| orderSuc.setId(order.getId()); | |||
| orderSuc.setOrderStatus(EnumTtOrderStatus.ORDER_STATUS_OVERTIME_CANCEL.getCode()); | |||
| orderSuc.setUpdateDate(new Date()); | |||
| ttOrderMapper.updateById(orderSuc); | |||
| redisLock.unlock(lockKey, timeStr); | |||
| return new ResultData(ErrorCode.PAY_ORDER_CLOSED); | |||
| } | |||
| redisLock.unlock(lockKey, timeStr); | |||
| return new ResultData(ErrorCode.PAY_ORDER_NOT_PAY,msg); | |||
| } | |||
| // else if(order.getOrderStatus() == EnumTtOrderStatus.ORDER_STATUS_PAYMENT_ING.getCode()){ | |||
| // //支付中 | |||
| // } | |||
| else if(order.getOrderStatus() == EnumTtOrderStatus.ORDER_STATUS_PAYMENT_SUCCESS.getCode()){ | |||
| //已支付 | |||
| redisLock.unlock(lockKey, timeStr); | |||
| return new ResultData(); | |||
| } | |||
| else if(order.getOrderStatus() == EnumTtOrderStatus.ORDER_STATUS_OVERTIME_CANCEL.getCode()){ | |||
| //已取消,已关闭 | |||
| redisLock.unlock(lockKey, timeStr); | |||
| return new ResultData(ErrorCode.PAY_ORDER_CLOSED); | |||
| } | |||
| else{ | |||
| redisLock.unlock(lockKey, timeStr); | |||
| return new ResultData(ErrorCode.PAY_ORDER_ERROR,"订单状态异常"); | |||
| } | |||
| redisLock.unlock(lockKey, timeStr); | |||
| }else { | |||
| logger.debug("CacheAspect 读库等待中, key:{}: " + lockKey); | |||
| logger.debug("CacheAspect 业务等待中, key:{}: " + lockKey); | |||
| try { | |||
| Thread.sleep(5000); | |||
| } catch (InterruptedException e) { | |||
| @@ -359,7 +365,7 @@ public class TtOrderServiceImpl implements TtOrderService { | |||
| redisLock.unlock(lockKey, timeStr); | |||
| } | |||
| } | |||
| return new ResultData(); | |||
| return new ResultData(ErrorCode.PAY_ORDER_ERROR,"请重试!"); | |||
| } | |||
| @@ -378,4 +384,9 @@ public class TtOrderServiceImpl implements TtOrderService { | |||
| return false; | |||
| } | |||
| @Override | |||
| public List<Long> findExpireIdList(Date expireDate) { | |||
| return ttOrderMapper.findExpireIdList(expireDate,EnumTtOrderStatus.ORDER_STATUS_PENDING_PAYMENT.getCode()); | |||
| } | |||
| } | |||
| @@ -10,6 +10,8 @@ public class Constant { | |||
| public static final int WX_LIMIT_DAYS = 30; // 微信分账限制30天 | |||
| public static final long PRESS_TIME_OUT = 30 * 60 * 1000;//必须30分钟内支付; | |||
| //游戏常量 | |||
| public static final int limit = 0;//游戏玩法不限次数 | |||
| public static final int notLimit = -1;//游戏玩法不限能玩 | |||
| @@ -246,4 +246,10 @@ | |||
| where orderStatus=0 and create_date < #{expireDate} | |||
| </update> | |||
| <select id="findExpireIdList" parameterType="java.util.HashMap" resultMap="Long"> | |||
| select id | |||
| from tt_order | |||
| where orderStatus=#{orderStatus} and create_date < #{expireDate} | |||
| </select> | |||
| </mapper> | |||
| @@ -12,10 +12,7 @@ import com.iformall.service.tt.TtOrderService; | |||
| import org.slf4j.Logger; | |||
| import org.slf4j.LoggerFactory; | |||
| 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.ResponseBody; | |||
| import org.springframework.web.bind.annotation.RestController; | |||
| import org.springframework.web.bind.annotation.*; | |||
| import javax.servlet.http.HttpServletRequest; | |||
| import java.util.HashMap; | |||
| @@ -96,5 +93,4 @@ public class TtOrderCallbackController extends BaseController { | |||
| } | |||
| } | |||
| } | |||
| @@ -74,7 +74,7 @@ public class TtCouponController extends BaseController { | |||
| } | |||
| TtCoupon detail = ttCouponService.detail(id); | |||
| if(detail == null){ | |||
| new ResultData(); | |||
| return new ResultData(); | |||
| } | |||
| if(detail.getIsPayment().equals(EnumYesOrNo.YES.getCode())){ | |||
| try { | |||
| @@ -227,7 +227,6 @@ public class TtOrderController extends BaseController { | |||
| }else{ | |||
| return new ResultData(); | |||
| } | |||
| } | |||
| } | |||
| @@ -257,8 +257,8 @@ public class TtUserGrantController extends BaseController { | |||
| String session_key = user.getSessionKey(); | |||
| try { | |||
| // 解密用户信息 | |||
| String decrypt = WxMaCryptUtils.decrypt(session_key, encryptedData, iv); | |||
| logger.info("111111"+decrypt); | |||
| // String decrypt = WxMaCryptUtils.decrypt(session_key, encryptedData, iv); | |||
| // logger.info("解密信息"+decrypt); | |||
| WxMaUserInfo userInfo = ttMaService.getUserService().getUserInfo(session_key, encryptedData, iv); | |||
| if (userInfo != null) { | |||
| logger.debug(userInfo.toString()); | |||
| @@ -1,8 +1,15 @@ | |||
| package com.iformall.schedule; | |||
| import com.iformall.domain.po.WxAppinfo; | |||
| import com.iformall.domain.po.WxMerchant; | |||
| import com.iformall.domain.po.WxPayAccount; | |||
| import com.iformall.domain.po.base.TenantEntity; | |||
| import com.iformall.enums.*; | |||
| import com.iformall.mapper.*; | |||
| import com.iformall.service.WxAppinfoService; | |||
| import com.iformall.service.WxPayAccountService; | |||
| import com.iformall.service.tt.TtOrderService; | |||
| import com.iformall.utils.Constant; | |||
| import org.slf4j.Logger; | |||
| import org.slf4j.LoggerFactory; | |||
| import org.springframework.beans.factory.annotation.Autowired; | |||
| @@ -10,30 +17,59 @@ import org.springframework.scheduling.annotation.Scheduled; | |||
| import org.springframework.stereotype.Component; | |||
| import java.util.Date; | |||
| import java.util.List; | |||
| @Component | |||
| public class TtOrderExpiringSchedule { | |||
| private final Logger logger = LoggerFactory.getLogger(this.getClass()); | |||
| private final int PRESS_TIME_OUT = 30 * 60 * 1000; //必须30分钟内支付 | |||
| @Autowired | |||
| private WxAppinfoService wxAppinfoService; | |||
| @Autowired | |||
| private WxPayAccountService payAccountService; | |||
| @Autowired | |||
| TtOrderMapper ttOrderMapper; | |||
| TtOrderService ttOrderService; | |||
| @Autowired | |||
| WxMerchantMapper wxMerchantMapper; | |||
| private TenantEntity getTenantInfo() { | |||
| TenantEntity tenantEntity = new TenantEntity() ; | |||
| tenantEntity.setTenantId("1"); | |||
| return tenantEntity; | |||
| } | |||
| @Scheduled(cron = "0 */1 * * * *?") // 每1分钟检查一次 | |||
| public void orderExpireSchedule() { | |||
| WxAppinfo cAppInfo = wxAppinfoService.getCAppInfo(getTenantInfo(), EnumPayWay.PAY_WAY_TT); | |||
| if(cAppInfo == null){ | |||
| return; | |||
| } | |||
| WxPayAccount payAccout = payAccountService.getById(cAppInfo.getId()); | |||
| if(payAccout == null){ | |||
| return; | |||
| } | |||
| Date now = new Date(); | |||
| Date expireDate = new Date(now.getTime() - PRESS_TIME_OUT ); | |||
| int count = ttOrderMapper.updateExpire(expireDate,EnumTtOrderStatus.ORDER_STATUS_OVERTIME_CANCEL.getCode()); | |||
| if(count > 0){ | |||
| logger.info("订单过期"+count+"个"); | |||
| Date expireDate = new Date(now.getTime() - Constant.PRESS_TIME_OUT ); | |||
| List<Long> idList = ttOrderService.findExpireIdList(expireDate); | |||
| if(idList != null && idList.size() > 0){ | |||
| for (Long orderId:idList) { | |||
| try { | |||
| ttOrderService.updateOrderStatus(orderId,cAppInfo,payAccout); | |||
| } catch (Exception e) { | |||
| e.printStackTrace(); | |||
| } | |||
| } | |||
| } | |||
| } | |||
| @Scheduled(cron = "0 0 4 * * ?") //每天四点入账 | |||
| public void orderRecordedSchedule() { | |||