xhxu 5 лет назад
Родитель
Сommit
0d0c668b03
8 измененных файлов: 42 добавлений и 25 удалений
  1. +2
    -0
      mallinkService/src/main/java/com/iformall/mapper/TtOrderMapper.java
  2. +1
    -1
      mallinkService/src/main/java/com/iformall/service/tt/TtOrderService.java
  3. +2
    -2
      mallinkService/src/main/java/com/iformall/service/tt/impl/TtOrderServiceImpl.java
  4. +7
    -1
      mallinkService/src/main/resources/mapper/TtOrderMapper.xml
  5. +5
    -1
      mallinkTTCApi/src/main/java/com/iformall/controller/BaseController.java
  6. +3
    -1
      mallinkTTCApi/src/main/java/com/iformall/controller/TtUserGrantController.java
  7. +6
    -1
      mallinkTTCApi/src/main/java/com/iformall/interceptor/AuthorizationInterceptor.java
  8. +16
    -18
      mallinkTTCApi/src/main/java/com/iformall/schedule/TtOrderExpiringSchedule.java

+ 2
- 0
mallinkService/src/main/java/com/iformall/mapper/TtOrderMapper.java Просмотреть файл

@@ -22,6 +22,8 @@ public interface TtOrderMapper extends CommonMapper<TtOrder, Long> {
Integer findListCount(TtOrder orderQ);

// 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);



+ 1
- 1
mallinkService/src/main/java/com/iformall/service/tt/TtOrderService.java Просмотреть файл

@@ -39,7 +39,7 @@ public interface TtOrderService {

boolean isByMember(Long memberId, Long id);

List<Long> findExpireIdList(Date expireDate);
List<TtOrder> findExpireIdList(Date expireDate);

List<Long> findRecordedIdList(Date recordedDate);



+ 2
- 2
mallinkService/src/main/java/com/iformall/service/tt/impl/TtOrderServiceImpl.java Просмотреть файл

@@ -389,8 +389,8 @@ public class TtOrderServiceImpl implements TtOrderService {
}

@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


+ 7
- 1
mallinkService/src/main/resources/mapper/TtOrderMapper.xml Просмотреть файл

@@ -251,7 +251,13 @@
</if>
</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 &lt;= #{beforeDate}
</select>

<select id="findBeforeIdList" parameterType="java.util.HashMap" resultType="Long">
select id
from tt_order
where order_status=#{orderStatus} and create_date &lt;= #{beforeDate}


+ 5
- 1
mallinkTTCApi/src/main/java/com/iformall/controller/BaseController.java Просмотреть файл

@@ -75,8 +75,12 @@ public class BaseController {
}

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.setTenantId("1");
tenantEntity.setTenantId(tenantId);
tenantEntity.setParentTenantId(parentTenantId);
return tenantEntity;
}



+ 3
- 1
mallinkTTCApi/src/main/java/com/iformall/controller/TtUserGrantController.java Просмотреть файл

@@ -113,10 +113,12 @@ public class TtUserGrantController extends BaseController {
}

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);

TtCUser newUser = new TtCUser();
newUser.updateTenantInfo(getTenantInfo());
newUser.updateTenantInfo(wxAppinfo.getTenantInfo());
newUser.setAppId(appId);
newUser.setOpenId(openId);



+ 6
- 1
mallinkTTCApi/src/main/java/com/iformall/interceptor/AuthorizationInterceptor.java Просмотреть файл

@@ -66,10 +66,15 @@ public class AuthorizationInterceptor extends HandlerInterceptorAdapter {

//设置userId到request里,后续根据userId,获取用户信息
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()){
request.setAttribute(Constant.LOGIN_MEMBER_KEY, cUser.getUserId());
}
request.setAttribute(Constant.REQUEST_C_USER_KEY, cUser);


return true;
}


+ 16
- 18
mallinkTTCApi/src/main/java/com/iformall/schedule/TtOrderExpiringSchedule.java Просмотреть файл

@@ -3,6 +3,7 @@ package com.iformall.schedule;
import com.iformall.domain.po.WxAppinfo;
import com.iformall.domain.po.WxPayAccount;
import com.iformall.domain.po.base.TenantEntity;
import com.iformall.domain.po.tt.TtOrder;
import com.iformall.enums.*;
import com.iformall.service.WxAppinfoService;
import com.iformall.service.WxPayAccountService;
@@ -16,7 +17,9 @@ import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Component
public class TtOrderExpiringSchedule {
@@ -33,31 +36,26 @@ public class TtOrderExpiringSchedule {
private TtOrderService ttOrderService;


private TenantEntity getTenantInfo() {
TenantEntity tenantEntity = new TenantEntity() ;
tenantEntity.setTenantId("1");
return tenantEntity;
}

@Scheduled(cron = "0 */10 * * * *?") // 每10分钟检查一次
public void orderExpireSchedule() {
Date now = new Date();
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 {
ttOrderService.updateOrderStatus(orderId,cAppInfo,payAccout);
ttOrderService.updateOrderStatus(order.getId(),wxAppinfoMap.get(order.getFinalTenantId()),wxPayAccountMap.get(order.getFinalTenantId()));
} catch (Exception e) {
e.printStackTrace();
}


Загрузка…
Отмена
Сохранить