| @@ -22,6 +22,8 @@ public interface TtOrderMapper extends CommonMapper<TtOrder, Long> { | |||||
| Integer findListCount(TtOrder orderQ); | Integer findListCount(TtOrder orderQ); | ||||
| // int updateExpire(@Param("expireDate")Date expireDate,@Param("orderStatus") Integer orderStatus); | // int updateExpire(@Param("expireDate")Date expireDate,@Param("orderStatus") Integer orderStatus); | ||||
| List<TtOrder> findExpireIdList(@Param("beforeDate")Date beforeDate,@Param("orderStatus") Integer orderStatus); | |||||
| List<Long> findBeforeIdList(@Param("beforeDate")Date beforeDate,@Param("orderStatus") Integer orderStatus,@Param("isRecorded") Integer isRecorded); | List<Long> findBeforeIdList(@Param("beforeDate")Date beforeDate,@Param("orderStatus") Integer orderStatus,@Param("isRecorded") Integer isRecorded); | ||||
| @@ -39,7 +39,7 @@ public interface TtOrderService { | |||||
| boolean isByMember(Long memberId, Long id); | boolean isByMember(Long memberId, Long id); | ||||
| List<Long> findExpireIdList(Date expireDate); | |||||
| List<TtOrder> findExpireIdList(Date expireDate); | |||||
| List<Long> findRecordedIdList(Date recordedDate); | List<Long> findRecordedIdList(Date recordedDate); | ||||
| @@ -389,8 +389,8 @@ public class TtOrderServiceImpl implements TtOrderService { | |||||
| } | } | ||||
| @Override | @Override | ||||
| public List<Long> findExpireIdList(Date expireDate) { | |||||
| return ttOrderMapper.findBeforeIdList(expireDate,EnumTtOrderStatus.ORDER_STATUS_PENDING_PAYMENT.getCode(),null); | |||||
| public List<TtOrder> findExpireIdList(Date expireDate) { | |||||
| return ttOrderMapper.findExpireIdList(expireDate,EnumTtOrderStatus.ORDER_STATUS_PENDING_PAYMENT.getCode()); | |||||
| } | } | ||||
| @Override | @Override | ||||
| @@ -251,7 +251,13 @@ | |||||
| </if> | </if> | ||||
| </select> | </select> | ||||
| <select id="findExpireIdList" parameterType="java.util.HashMap" resultType="Long"> | |||||
| <select id="findExpireIdList" parameterType="java.util.HashMap" resultType="com.iformall.domain.po.tt.TtOrder"> | |||||
| select `id`,`tenant_id`,`parent_tenant_id`,order_status,create_date | |||||
| from tt_order | |||||
| where order_status=#{orderStatus} and create_date <= #{beforeDate} | |||||
| </select> | |||||
| <select id="findBeforeIdList" parameterType="java.util.HashMap" resultType="Long"> | |||||
| select id | select id | ||||
| from tt_order | from tt_order | ||||
| where order_status=#{orderStatus} and create_date <= #{beforeDate} | where order_status=#{orderStatus} and create_date <= #{beforeDate} | ||||
| @@ -75,8 +75,12 @@ public class BaseController { | |||||
| } | } | ||||
| public TenantEntity getTenantInfo() { | public TenantEntity getTenantInfo() { | ||||
| HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest(); | |||||
| String tenantId = (String) request.getAttribute(Constant.TENANT_ID); | |||||
| String parentTenantId = (String) request.getAttribute(Constant.PARENT_TENANT_ID); | |||||
| TenantEntity tenantEntity = new TenantEntity() ; | TenantEntity tenantEntity = new TenantEntity() ; | ||||
| tenantEntity.setTenantId("1"); | |||||
| tenantEntity.setTenantId(tenantId); | |||||
| tenantEntity.setParentTenantId(parentTenantId); | |||||
| return tenantEntity; | return tenantEntity; | ||||
| } | } | ||||
| @@ -113,10 +113,12 @@ public class TtUserGrantController extends BaseController { | |||||
| } | } | ||||
| HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest(); | HttpServletRequest request = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest(); | ||||
| request.setAttribute(Constant.TENANT_ID, wxAppinfo.getTenantId()); | |||||
| request.setAttribute(Constant.PARENT_TENANT_ID, wxAppinfo.getParentTenantId()); | |||||
| String ipaddress = IPUtil.getIpAddr(request); | String ipaddress = IPUtil.getIpAddr(request); | ||||
| TtCUser newUser = new TtCUser(); | TtCUser newUser = new TtCUser(); | ||||
| newUser.updateTenantInfo(getTenantInfo()); | |||||
| newUser.updateTenantInfo(wxAppinfo.getTenantInfo()); | |||||
| newUser.setAppId(appId); | newUser.setAppId(appId); | ||||
| newUser.setOpenId(openId); | newUser.setOpenId(openId); | ||||
| @@ -66,10 +66,15 @@ public class AuthorizationInterceptor extends HandlerInterceptorAdapter { | |||||
| //设置userId到request里,后续根据userId,获取用户信息 | //设置userId到request里,后续根据userId,获取用户信息 | ||||
| request.setAttribute(Constant.LOGIN_USER_KEY, cUser.getId()); | request.setAttribute(Constant.LOGIN_USER_KEY, cUser.getId()); | ||||
| request.setAttribute(Constant.REQUEST_C_USER_KEY, cUser); | |||||
| request.setAttribute(Constant.TENANT_ID, cUser.getTenantId()); | |||||
| if (StringUtils.isNotBlank(cUser.getParentTenantId())) { | |||||
| request.setAttribute(Constant.PARENT_TENANT_ID, cUser.getParentTenantId()); | |||||
| } | |||||
| if(cUser.basicInfoIs()){ | if(cUser.basicInfoIs()){ | ||||
| request.setAttribute(Constant.LOGIN_MEMBER_KEY, cUser.getUserId()); | request.setAttribute(Constant.LOGIN_MEMBER_KEY, cUser.getUserId()); | ||||
| } | } | ||||
| request.setAttribute(Constant.REQUEST_C_USER_KEY, cUser); | |||||
| return true; | return true; | ||||
| } | } | ||||
| @@ -3,6 +3,7 @@ package com.iformall.schedule; | |||||
| import com.iformall.domain.po.WxAppinfo; | import com.iformall.domain.po.WxAppinfo; | ||||
| import com.iformall.domain.po.WxPayAccount; | import com.iformall.domain.po.WxPayAccount; | ||||
| import com.iformall.domain.po.base.TenantEntity; | import com.iformall.domain.po.base.TenantEntity; | ||||
| import com.iformall.domain.po.tt.TtOrder; | |||||
| import com.iformall.enums.*; | import com.iformall.enums.*; | ||||
| import com.iformall.service.WxAppinfoService; | import com.iformall.service.WxAppinfoService; | ||||
| import com.iformall.service.WxPayAccountService; | import com.iformall.service.WxPayAccountService; | ||||
| @@ -16,7 +17,9 @@ import org.springframework.scheduling.annotation.Scheduled; | |||||
| import org.springframework.stereotype.Component; | import org.springframework.stereotype.Component; | ||||
| import java.util.Date; | import java.util.Date; | ||||
| import java.util.HashMap; | |||||
| import java.util.List; | import java.util.List; | ||||
| import java.util.Map; | |||||
| @Component | @Component | ||||
| public class TtOrderExpiringSchedule { | public class TtOrderExpiringSchedule { | ||||
| @@ -33,31 +36,26 @@ public class TtOrderExpiringSchedule { | |||||
| private TtOrderService ttOrderService; | private TtOrderService ttOrderService; | ||||
| private TenantEntity getTenantInfo() { | |||||
| TenantEntity tenantEntity = new TenantEntity() ; | |||||
| tenantEntity.setTenantId("1"); | |||||
| return tenantEntity; | |||||
| } | |||||
| @Scheduled(cron = "0 */10 * * * *?") // 每10分钟检查一次 | @Scheduled(cron = "0 */10 * * * *?") // 每10分钟检查一次 | ||||
| public void orderExpireSchedule() { | public void orderExpireSchedule() { | ||||
| Date now = new Date(); | Date now = new Date(); | ||||
| Date expireDate = new Date(now.getTime() - Constant.PRESS_TIME_OUT ); | Date expireDate = new Date(now.getTime() - Constant.PRESS_TIME_OUT ); | ||||
| List<Long> idList = ttOrderService.findExpireIdList(expireDate); | |||||
| if(idList != null && idList.size() > 0){ | |||||
| WxAppinfo cAppInfo = wxAppinfoService.getCAppInfo(getTenantInfo(), EnumPayWay.PAY_WAY_TT); | |||||
| if(cAppInfo == null){ | |||||
| return; | |||||
| } | |||||
| WxPayAccount payAccout = payAccountService.getById(cAppInfo.getId()); | |||||
| if(payAccout == null){ | |||||
| return; | |||||
| List<TtOrder> orderList = ttOrderService.findExpireIdList(expireDate); | |||||
| if(orderList != null && orderList.size() > 0){ | |||||
| Map<String, WxAppinfo> wxAppinfoMap = new HashMap<>(); | |||||
| Map<String, WxPayAccount> wxPayAccountMap = new HashMap<>(); | |||||
| WxAppinfo appQ = new WxAppinfo(); | |||||
| appQ.setType(EnumAppType.C.getCode()); | |||||
| appQ.setPlat(EnumPayWay.PAY_WAY_TT.getCode()); | |||||
| List<WxAppinfo> wxAppinfoList = wxAppinfoService.getList(appQ); | |||||
| for (WxAppinfo wxAppinfo:wxAppinfoList) { | |||||
| wxAppinfoMap.put(wxAppinfo.getFinalTenantId(),wxAppinfo);//一个集团一个小程序 | |||||
| wxPayAccountMap.put(wxAppinfo.getFinalTenantId(),payAccountService.getById(wxAppinfo.getId())); | |||||
| } | } | ||||
| for (Long orderId:idList) { | |||||
| for (TtOrder order:orderList) { | |||||
| try { | try { | ||||
| ttOrderService.updateOrderStatus(orderId,cAppInfo,payAccout); | |||||
| ttOrderService.updateOrderStatus(order.getId(),wxAppinfoMap.get(order.getFinalTenantId()),wxPayAccountMap.get(order.getFinalTenantId())); | |||||
| } catch (Exception e) { | } catch (Exception e) { | ||||
| e.printStackTrace(); | e.printStackTrace(); | ||||
| } | } | ||||