| @@ -0,0 +1,47 @@ | |||||
| package com.iformall.schedule; | |||||
| import com.iformall.domain.po.ProductOrder; | |||||
| import com.iformall.domain.po.ProductOrderSharing; | |||||
| import com.iformall.enums.EnumProductOrderSettleStatus; | |||||
| import com.iformall.enums.EnumProductOrderStatus; | |||||
| import com.iformall.enums.EnumProfitSharing; | |||||
| import com.iformall.service.ProductOrderService; | |||||
| import com.iformall.service.ProductOrderSharingService; | |||||
| import com.iformall.utils.DateUtils; | |||||
| import org.slf4j.Logger; | |||||
| import org.slf4j.LoggerFactory; | |||||
| import org.springframework.beans.factory.annotation.Autowired; | |||||
| import org.springframework.scheduling.annotation.Scheduled; | |||||
| import org.springframework.stereotype.Component; | |||||
| import java.util.Date; | |||||
| import java.util.List; | |||||
| @Component | |||||
| public class ProductOrderSchedule { | |||||
| private final Logger logger = LoggerFactory.getLogger(this.getClass()); | |||||
| @Autowired | |||||
| private ProductOrderService productOrderService; | |||||
| @Autowired | |||||
| private ProductOrderSharingService productOrderSharingService; | |||||
| @Scheduled(cron = "0 1/10 * * * *?") | |||||
| public void productOrderSharingSchedule() { | |||||
| ProductOrder productOrderQ = new ProductOrder(); | |||||
| productOrderQ.setOrderStatus(EnumProductOrderStatus.ORDER_STATUS_PENDING_PAYMENT.getCode()); | |||||
| productOrderQ.setStartDate(DateUtils.getHourDateBefore(1,new Date())); | |||||
| List<ProductOrder> orderList = productOrderService.findList(productOrderQ); | |||||
| for (ProductOrder order: orderList) { | |||||
| try{ | |||||
| productOrderService.handldTimeOut(order.getId()); | |||||
| }catch(Exception e){ | |||||
| logger.error("分账失败:" + e.getMessage()); | |||||
| } | |||||
| } | |||||
| } | |||||
| } | |||||
| @@ -95,4 +95,7 @@ public class ProductOrder extends TenantEntity { | |||||
| @TableField(exist = false) | @TableField(exist = false) | ||||
| private Date payEndDate; | private Date payEndDate; | ||||
| @TableField(exist = false) | |||||
| private Integer isOrderStatus; | |||||
| } | } | ||||
| @@ -34,4 +34,5 @@ public interface ProductOrderService { | |||||
| void handldSharing(ProductOrder order); | void handldSharing(ProductOrder order); | ||||
| void handldTimeOut(Long id); | |||||
| } | } | ||||
| @@ -20,6 +20,7 @@ import com.iformall.service.pay.service.pay.PayAdapterService; | |||||
| import com.iformall.service.pay.service.pay.entity.PayAdapterResult; | import com.iformall.service.pay.service.pay.entity.PayAdapterResult; | ||||
| import com.iformall.service.pay.service.pay.entity.PayQueryAdapterResult; | import com.iformall.service.pay.service.pay.entity.PayQueryAdapterResult; | ||||
| import com.iformall.service.pay.service.share.PayShareAdapterService; | import com.iformall.service.pay.service.share.PayShareAdapterService; | ||||
| import com.iformall.utils.DateUtils; | |||||
| import lombok.extern.slf4j.Slf4j; | import lombok.extern.slf4j.Slf4j; | ||||
| import org.slf4j.Logger; | import org.slf4j.Logger; | ||||
| import org.slf4j.LoggerFactory; | import org.slf4j.LoggerFactory; | ||||
| @@ -153,6 +154,7 @@ public class ProductOrderServiceImpl implements ProductOrderService { | |||||
| productOrder.setPaymentTime(result.getPayTime()); | productOrder.setPaymentTime(result.getPayTime()); | ||||
| productOrder.setPayWay(result.getWay()); | productOrder.setPayWay(result.getWay()); | ||||
| productOrder.setOrderStatus(productOrderStatus); | productOrder.setOrderStatus(productOrderStatus); | ||||
| productOrder.setIsOrderStatus(EnumProductOrderStatus.ORDER_STATUS_PENDING_PAYMENT.getCode()); | |||||
| productOrder.setUpdateDate(new Date()); | productOrder.setUpdateDate(new Date()); | ||||
| int num = productOrderMapper.orderPayUpdStatus(productOrder); | int num = productOrderMapper.orderPayUpdStatus(productOrder); | ||||
| @@ -234,4 +236,37 @@ public class ProductOrderServiceImpl implements ProductOrderService { | |||||
| } | } | ||||
| @Override | |||||
| public void handldTimeOut(Long id) { | |||||
| ProductOrder productOrder = productOrderMapper.selectById(id); | |||||
| if(productOrder == null){ | |||||
| return; | |||||
| } | |||||
| if(!EnumProductOrderStatus.ORDER_STATUS_PENDING_PAYMENT.getCode().equals(productOrder.getOrderStatus())){ | |||||
| return; | |||||
| } | |||||
| Date hourDateBefore = DateUtils.getHourDateBefore(1, new Date()); | |||||
| if(productOrder.getCreateDate().after(hourDateBefore)){ | |||||
| } | |||||
| PayAdapterService payAdapterService = payServiceFactory.getPayAdapterService(productOrder.getPayVendor()); | |||||
| EnumProductOrderPayVendor payVendoEnum = EnumProductOrderPayVendor.getEnum(productOrder.getPayVendor()); | |||||
| WxAppinfo appinfo = wxAppinfoService.getProjectCAppInfoFromRedis(productOrder.getProjectType(), payVendoEnum.getPlat()); | |||||
| WxPayAccount payAccount = wxPayAccountService.getByIdFromRedis(appinfo.getPayId()); | |||||
| ResultData resultData = handleProductOrderByQuery(appinfo,payAccount,productOrder,payAdapterService); | |||||
| if(ResultData.SUCCESS != resultData.code){ | |||||
| return; | |||||
| } | |||||
| if(!EnumProductOrderStatus.ORDER_STATUS_PENDING_PAYMENT.getCode().equals(productOrder.getProfitSharing())){ | |||||
| return; | |||||
| } | |||||
| productOrder.setOrderStatus(EnumProductOrderStatus.ORDER_STATUS_OVERTIME_CANCEL.getCode()); | |||||
| productOrder.setIsOrderStatus(EnumProductOrderStatus.ORDER_STATUS_PENDING_PAYMENT.getCode()); | |||||
| productOrder.setUpdateDate(new Date()); | |||||
| int num = productOrderMapper.orderPayUpdStatus(productOrder); | |||||
| } | |||||
| } | } | ||||
| @@ -234,7 +234,7 @@ public class TtMiniAppPayAdapterService extends BaseTtPayAdapterService implemen | |||||
| preOrder.setTotalAmount(order.getOrderPrice()); | preOrder.setTotalAmount(order.getOrderPrice()); | ||||
| preOrder.setSubject(appInfo.getName()+"-"+order.getProductTitle()); | preOrder.setSubject(appInfo.getName()+"-"+order.getProductTitle()); | ||||
| preOrder.setBody(appInfo.getName()+"-"+order.getProductTitle()); | preOrder.setBody(appInfo.getName()+"-"+order.getProductTitle()); | ||||
| preOrder.setValidTime(30*60); | |||||
| preOrder.setValidTime(60*60); | |||||
| // preOrder.setNotifyUrl();//回调地址 | // preOrder.setNotifyUrl();//回调地址 | ||||
| // preOrder.setThirdpartyId();//第三方服务商ID | // preOrder.setThirdpartyId();//第三方服务商ID | ||||
| // preOrder.setStoreId(record.getStoreId()); | // preOrder.setStoreId(record.getStoreId()); | ||||
| @@ -135,7 +135,12 @@ | |||||
| <if test=" null != payWay"> | <if test=" null != payWay"> | ||||
| ,`pay_way` = #{payWay} | ,`pay_way` = #{payWay} | ||||
| </if> | </if> | ||||
| where id = #{id} and `order_status` != #{orderStatus} | |||||
| where id = #{id} | |||||
| and `order_status` != #{orderStatus} | |||||
| <if test=" null != isOrderStatus"> | |||||
| and `order_status` = #{isOrderStatus} | |||||
| </if> | |||||
| </update> | </update> | ||||
| </mapper> | </mapper> | ||||