Browse Source

Merge remote-tracking branch 'origin/dev' into dev

dev
caoyizhong 3 years ago
parent
commit
0a4c087c46
  1. 4
      xhm-admin/pom.xml
  2. 14
      xhm-wjnft/src/main/java/com/xhm/wjnft/service/impl/WjPayInfoServiceImpl.java
  3. 11
      xhm-wjnft/src/main/java/com/xhm/wjnft/utils/redis/RedisKeyExpirationListener.java
  4. 2
      xhm-wjnft/src/main/resources/mapper/wjnft/WjIncomeStatementMapper.xml

4
xhm-admin/pom.xml

@ -66,9 +66,7 @@
<groupId>com.xhm</groupId>
<artifactId>xhm-wjnft</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-core</artifactId>

14
xhm-wjnft/src/main/java/com/xhm/wjnft/service/impl/WjPayInfoServiceImpl.java

@ -4,12 +4,15 @@ import java.util.Date;
import java.util.List;
import java.util.Map;
import com.xhm.common.core.domain.AjaxResult;
import com.xhm.common.core.redis.RedisCache;
import com.xhm.common.utils.DateUtils;
import com.xhm.common.utils.uuid.IdUtils;
import com.xhm.wjnft.domain.WjCollection;
import com.xhm.wjnft.domain.WjOrder;
import com.xhm.wjnft.domain.WjUsers;
import com.xhm.wjnft.mapper.*;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.xhm.wjnft.domain.WjPayInfo;
@ -23,6 +26,7 @@ import org.springframework.transaction.annotation.Transactional;
* @date 2022-02-19
*/
@Service
@Slf4j
public class WjPayInfoServiceImpl implements IWjPayInfoService {
@Autowired
private WjPayInfoMapper wjPayInfoMapper;
@ -36,6 +40,9 @@ public class WjPayInfoServiceImpl implements IWjPayInfoService {
@Autowired
private WjCollectionMapper wjCollectionMapper;
@Autowired
private RedisCache redisCache;
/**
* 查询支付详细信息
@ -240,6 +247,13 @@ public class WjPayInfoServiceImpl implements IWjPayInfoService {
if (total_fee != null) {
wjOrder.setActualAmountPaid(Double.parseDouble(total_fee) / 100);
}
//删除订单缓存
String id = orderMapper.selectWjOrderByOrderNumber(orderNumber).getId();
try {
redisCache.deleteObject(id);
}catch (RuntimeException e){
log.error("订单已做失效处理");
}
orderMapper.updateWjOrderByorderNumber(wjOrder);
//更新支付详细表
WjOrder orderVo = orderMapper.selectWjOrderByOrderNumber(orderNumber);

11
xhm-wjnft/src/main/java/com/xhm/wjnft/utils/redis/RedisKeyExpirationListener.java

@ -4,9 +4,9 @@ import com.xhm.wjnft.domain.WjCollection;
import com.xhm.wjnft.domain.WjOrder;
import com.xhm.wjnft.domain.WjPayInfo;
import com.xhm.wjnft.mapper.WjCollectionMapper;
import com.xhm.wjnft.mapper.WjMyCollectionMapper;
import com.xhm.wjnft.mapper.WjOrderMapper;
import com.xhm.wjnft.mapper.WjPayInfoMapper;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.connection.Message;
import org.springframework.data.redis.listener.KeyExpirationEventMessageListener;
@ -15,6 +15,7 @@ import org.springframework.stereotype.Component;
import java.util.Date;
@Slf4j
@Component
public class RedisKeyExpirationListener extends KeyExpirationEventMessageListener {
public RedisKeyExpirationListener(RedisMessageListenerContainer container) {
@ -35,12 +36,12 @@ public class RedisKeyExpirationListener extends KeyExpirationEventMessageListene
*/
@Override
public void onMessage(Message message, byte[] pattern) {
try {
String key=message.toString();//失效的key
if (key!=null ){
//截取订单号,查询订单,如果是未支付状态则取消订单
WjOrder wjOrder = wjOrderMapper.selectWjOrderById(key);
if (wjOrder !=null && wjOrder.getOrderState().equals(1)){
//
WjOrder order = new WjOrder();
order.setId(key);
order.setOrderState(7);
@ -59,8 +60,12 @@ public class RedisKeyExpirationListener extends KeyExpirationEventMessageListene
wjCollectionData.setNumberRemaining(wjCollection.getNumberRemaining()+1);
wjCollectionMapper.updateWjCollection(wjCollectionData);
}
System.out.println("订单号为:"+key+"的订单超时未支付,取消订单");
log.info("订单号为:"+key+"的订单超时未支付,取消订单");
}
}
}catch (Exception e){
e.printStackTrace();
log.error("【修改支付订单过期状态异常】:" + e.getMessage());
}
}
}

2
xhm-wjnft/src/main/resources/mapper/wjnft/WjIncomeStatementMapper.xml

@ -67,7 +67,7 @@
<if test="uodatedTime != null ">and i.uodated_time = #{uodatedTime}</if>
<if test="startTime != null and startTime != ''"> <![CDATA[ AND i.created_time >= #{startTime} ]]></if>
<if test="endTime != null and endTime != ''"> <![CDATA[ AND i.created_time <= #{endTime} ]]></if>
ORDER BY i.created_time desc
</where>
</select>
<select id="selectWjIncomeStatementByArtistId" parameterType="String" resultMap="WjIncomeStatementResult">

Loading…
Cancel
Save