feat(修改): 修改阿里支付,支付完成后进行数量等更新
Signed-off-by: bunny <1319900154@qq.com>
This commit is contained in:
parent
e769913c1a
commit
dbed5dc451
|
@ -30,6 +30,11 @@
|
||||||
<artifactId>service-order-client</artifactId>
|
<artifactId>service-order-client</artifactId>
|
||||||
<version>1.0-SNAPSHOT</version>
|
<version>1.0-SNAPSHOT</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.atguigu</groupId>
|
||||||
|
<artifactId>service-product-client</artifactId>
|
||||||
|
<version>1.0-SNAPSHOT</version>
|
||||||
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
<build>
|
<build>
|
||||||
|
|
|
@ -17,7 +17,7 @@ public interface PaymentInfoService {
|
||||||
* 支付完成后更新状态
|
* 支付完成后更新状态
|
||||||
*
|
*
|
||||||
* @param paramMap paramMap
|
* @param paramMap paramMap
|
||||||
* @param i i
|
* @param payType payType
|
||||||
*/
|
*/
|
||||||
void updatePaymentStatus(Map<String, String> paramMap, int i);
|
void updatePaymentStatus(Map<String, String> paramMap, Integer payType);
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,8 +2,10 @@ package com.atguigu.pay.service.impl;
|
||||||
|
|
||||||
import com.alibaba.fastjson.JSON;
|
import com.alibaba.fastjson.JSON;
|
||||||
import com.atguigu.feign.order.OrderFeignClient;
|
import com.atguigu.feign.order.OrderFeignClient;
|
||||||
|
import com.atguigu.feign.product.ProductFeignClient;
|
||||||
import com.atguigu.pay.mapper.PaymentInfoMapper;
|
import com.atguigu.pay.mapper.PaymentInfoMapper;
|
||||||
import com.atguigu.pay.service.PaymentInfoService;
|
import com.atguigu.pay.service.PaymentInfoService;
|
||||||
|
import com.atguigu.spzx.model.dto.product.SkuSaleDto;
|
||||||
import com.atguigu.spzx.model.entity.order.OrderInfo;
|
import com.atguigu.spzx.model.entity.order.OrderInfo;
|
||||||
import com.atguigu.spzx.model.entity.order.OrderItem;
|
import com.atguigu.spzx.model.entity.order.OrderItem;
|
||||||
import com.atguigu.spzx.model.entity.pay.PaymentInfo;
|
import com.atguigu.spzx.model.entity.pay.PaymentInfo;
|
||||||
|
@ -11,7 +13,9 @@ import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
@Service
|
@Service
|
||||||
public class PaymentInfoServiceImpl implements PaymentInfoService {
|
public class PaymentInfoServiceImpl implements PaymentInfoService {
|
||||||
|
@ -19,6 +23,8 @@ public class PaymentInfoServiceImpl implements PaymentInfoService {
|
||||||
private PaymentInfoMapper paymentInfoMapper;
|
private PaymentInfoMapper paymentInfoMapper;
|
||||||
@Autowired
|
@Autowired
|
||||||
private OrderFeignClient orderFeignClient;
|
private OrderFeignClient orderFeignClient;
|
||||||
|
@Autowired
|
||||||
|
private ProductFeignClient productFeignClient;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 保存支付记录
|
* 保存支付记录
|
||||||
|
@ -54,22 +60,35 @@ public class PaymentInfoServiceImpl implements PaymentInfoService {
|
||||||
/**
|
/**
|
||||||
* 支付完成后更新状态
|
* 支付完成后更新状态
|
||||||
*
|
*
|
||||||
* @param map paramMap
|
* @param map paramMap
|
||||||
* @param i i
|
* @param payType payType
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void updatePaymentStatus(Map<String, String> map, int i) {
|
public void updatePaymentStatus(Map<String, String> map, Integer payType) {
|
||||||
// 查询PaymentInfo
|
// 1、查询PaymentInfo
|
||||||
PaymentInfo paymentInfo = paymentInfoMapper.getByOrderNo(map.get("out_trade_no"));
|
PaymentInfo paymentInfo = paymentInfoMapper.getByOrderNo(map.get("out_trade_no"));
|
||||||
if (paymentInfo.getPaymentStatus() == 1) {
|
if (paymentInfo.getPaymentStatus() == 1) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// 更新支付信息
|
// 2、更新支付信息
|
||||||
paymentInfo.setPaymentStatus(1);
|
paymentInfo.setPaymentStatus(1);
|
||||||
paymentInfo.setOutTradeNo(map.get("trade_no"));
|
paymentInfo.setOutTradeNo(map.get("trade_no"));
|
||||||
paymentInfo.setCallbackTime(new Date());
|
paymentInfo.setCallbackTime(new Date());
|
||||||
paymentInfo.setCallbackContent(JSON.toJSONString(map));
|
paymentInfo.setCallbackContent(JSON.toJSONString(map));
|
||||||
paymentInfoMapper.updateById(paymentInfo);
|
paymentInfoMapper.updateById(paymentInfo);
|
||||||
|
|
||||||
|
// 3、更新订单的支付状态
|
||||||
|
orderFeignClient.updateOrderStatus(paymentInfo.getOrderNo(), payType);
|
||||||
|
|
||||||
|
// 4、更新商品销量
|
||||||
|
OrderInfo orderInfo = orderFeignClient.getOrderInfoByOrderNo(paymentInfo.getOrderNo()).getData();
|
||||||
|
List<SkuSaleDto> skuSaleDtoList = orderInfo.getOrderItemList().stream().map(item -> {
|
||||||
|
SkuSaleDto skuSaleDto = new SkuSaleDto();
|
||||||
|
skuSaleDto.setSkuId(item.getSkuId());
|
||||||
|
skuSaleDto.setNum(item.getSkuNum());
|
||||||
|
return skuSaleDto;
|
||||||
|
}).collect(Collectors.toList());
|
||||||
|
productFeignClient.updateSkuSaleNum(skuSaleDtoList);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -67,6 +67,14 @@
|
||||||
<skipDockerBuild>false</skipDockerBuild>
|
<skipDockerBuild>false</skipDockerBuild>
|
||||||
</configuration>
|
</configuration>
|
||||||
</plugin>
|
</plugin>
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
|
<artifactId>maven-compiler-plugin</artifactId>
|
||||||
|
<configuration>
|
||||||
|
<source>8</source>
|
||||||
|
<target>8</target>
|
||||||
|
</configuration>
|
||||||
|
</plugin>
|
||||||
</plugins>
|
</plugins>
|
||||||
</build>
|
</build>
|
||||||
</project>
|
</project>
|
||||||
|
|
Loading…
Reference in New Issue