|
@@ -13,8 +13,6 @@ import com.llisoft.pay.dao.OrderDao;
|
|
|
import com.llisoft.pay.entity.Item;
|
|
|
import com.llisoft.pay.entity.Order;
|
|
|
import com.llisoft.pay.util.CodeUtil;
|
|
|
-import com.llisoft.pay.util.HttpUtil;
|
|
|
-import com.llisoft.pay.util.JsonUtil;
|
|
|
|
|
|
@Service
|
|
|
public class PayService {
|
|
@@ -50,7 +48,7 @@ public class PayService {
|
|
|
@Autowired
|
|
|
private WxPayService wxPayService;
|
|
|
@Autowired
|
|
|
- private AppService appService;
|
|
|
+ private OrderService orderService;
|
|
|
|
|
|
|
|
|
/**
|
|
@@ -118,26 +116,15 @@ public class PayService {
|
|
|
* @throws Exception
|
|
|
*/
|
|
|
@Transactional
|
|
|
- public boolean finish(String payNum, String tradeNum, int money, byte flag) throws Exception{
|
|
|
+ public String finish(String payNum, String tradeNum, int money, byte flag) throws Exception{
|
|
|
Item item = this.get(payNum);
|
|
|
- Order order = orderDao.select(item.getOrderId());
|
|
|
- if (order.getOrderMoney() != money) { // 核对金额
|
|
|
+ if (item.getPayMoney() != money) { // 核对金额
|
|
|
throw new Exception("支付金额异常: " + money);
|
|
|
}
|
|
|
// 更新支付状态
|
|
|
payDao.updatePay(item.getPayId(), tradeNum, STATUS_PAYED, flag);
|
|
|
logger.info("支付处理成功, 状态更新为已支付: {}", payNum);
|
|
|
- // 更新订单状态
|
|
|
- orderDao.updatePay(order.getOrderId(), STATUS_PAYED);
|
|
|
- // 发送支付成功异步通知
|
|
|
- String notifyUrl = appService.getNotifyUrl(order.getAppId(), order.getOrderNum());
|
|
|
- if(Objects.nonNull(notifyUrl)) {
|
|
|
- logger.info("订单完成: 异步通知业务地址: {}, 参数: {}", notifyUrl, JsonUtil.toJson(order));
|
|
|
- String result = HttpUtil.postJson(notifyUrl, JsonUtil.toJson(order));
|
|
|
- logger.info("订单完成: 业务端返回信息: {}", result);
|
|
|
- return "success".equals(result);
|
|
|
- }
|
|
|
- return true;
|
|
|
+ return orderService.finish(item.getOrderId());
|
|
|
}
|
|
|
|
|
|
/**
|